Fix: SIGNATURE_BLOCK placeholder and cached content issue
ISSUE 1: {{SIGNATURE_BLOCK}} placeholder not working
- Signature extraction was using wrong end markers
- Start: 'Signature of Consultant'
- End: 'Signature of Medical Officer', 'Signature of Receiver / Date'
- Problem: All three texts are in SAME table row
- Extraction cut off too early (found end marker immediately after start)
FIX: Remove end markers for signature block extraction
- Signature table is LAST element in content
- Extract from 'Signature of Consultant' to end of content
- Now captures entire signature table correctly
ISSUE 2: Other Advice not showing in PDF
- Cached content was generated BEFORE 'Other Advice:' label was added
- Database has data but cached HTML doesn't include label
FIX: Created cache clearing utility
- clear_discharge_cache.php script
- Clears cached content for specified IPD
- Forces regeneration with new labels
DEBUG TOOLS ADDED:
- debug_discharge_content.php - Check what's in cached content
- clear_discharge_cache.php - Clear cache to force regeneration
TESTING:
1. php clear_discharge_cache.php 1
2. Visit /Ipd_discharge/preview_discharge_report/1?regen=1
3. Verify PDF shows Other Advice: and Discharge Summary: labels
4. Verify {{SIGNATURE_BLOCK}} placeholder works in templates
This commit is contained in:
parent
295454c1ce
commit
f55d300924
|
|
@ -566,7 +566,8 @@ class Ipd_discharge extends BaseController
|
|||
$dischargeInstructions = $section(['Discharge Advice/Instructions/Summary']);
|
||||
$drugAllergyAdr = $section(['Drug Allergy / ADR']);
|
||||
$coMorbidities = $section(['Co-Morbidities']);
|
||||
$signatureBlock = $section(['Signature of Consultant'], ['Signature of Medical Officer', 'Signature of Receiver / Date']);
|
||||
// Extract entire signature table - no end markers (it's the last section)
|
||||
$signatureBlock = $section(['Signature of Consultant'], []);
|
||||
|
||||
// Extract individual instruction fields for template flexibility
|
||||
$otherAdvice = $section(['Other Advice:']);
|
||||
|
|
|
|||
45
clear_discharge_cache.php
Normal file
45
clear_discharge_cache.php
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
// Clear discharge cache to force regeneration
|
||||
$envFile = __DIR__ . '/.env';
|
||||
$dbHost = 'localhost';
|
||||
$dbUser = 'root';
|
||||
$dbPass = '';
|
||||
$dbName = 'hms_data_ci4';
|
||||
|
||||
$lines = file($envFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
||||
foreach ($lines as $line) {
|
||||
if (strpos($line, 'database.default.hostname') !== false) {
|
||||
$dbHost = trim(explode('=', $line, 2)[1] ?? 'localhost');
|
||||
} elseif (strpos($line, 'database.default.username') !== false) {
|
||||
$dbUser = trim(explode('=', $line, 2)[1] ?? 'root');
|
||||
} elseif (strpos($line, 'database.default.password') !== false) {
|
||||
$dbPass = trim(explode('=', $line, 2)[1] ?? '');
|
||||
} elseif (strpos($line, 'database.default.database') !== false) {
|
||||
$dbName = trim(explode('=', $line, 2)[1] ?? 'hms_data_ci4');
|
||||
}
|
||||
}
|
||||
|
||||
$conn = new mysqli($dbHost, $dbUser, $dbPass, $dbName);
|
||||
if ($conn->connect_error) {
|
||||
die("ERROR: Connection failed: " . $conn->connect_error . "\n");
|
||||
}
|
||||
|
||||
$ipdId = isset($argv[1]) ? intval($argv[1]) : 1;
|
||||
|
||||
echo "=== Clearing discharge cache for IPD ID: {$ipdId} ===\n\n";
|
||||
|
||||
$stmt = $conn->prepare("DELETE FROM ipd_discharge WHERE ipd_id = ?");
|
||||
$stmt->bind_param("i", $ipdId);
|
||||
|
||||
if ($stmt->execute()) {
|
||||
echo "✅ Cleared cached content for IPD ID {$ipdId}\n";
|
||||
echo "Affected rows: " . $stmt->affected_rows . "\n\n";
|
||||
echo "Now visit the discharge preview page to regenerate content with the new 'Other Advice:' label.\n";
|
||||
echo "URL: /Ipd_discharge/preview_discharge_report/{$ipdId}?regen=1\n";
|
||||
} else {
|
||||
echo "❌ Failed to clear: " . $stmt->error . "\n";
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
echo "\n=== Done ===\n";
|
||||
77
debug_discharge_content.php
Normal file
77
debug_discharge_content.php
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
|
||||
<?php
|
||||
// Debug script to check what's in the generated discharge content
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
$envFile = __DIR__ . '/.env';
|
||||
$dbHost = 'localhost';
|
||||
$dbUser = 'root';
|
||||
$dbPass = '';
|
||||
$dbName = 'hms_data_ci4';
|
||||
|
||||
$lines = file($envFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
||||
foreach ($lines as $line) {
|
||||
if (strpos($line, 'database.default.hostname') !== false) {
|
||||
$dbHost = trim(explode('=', $line, 2)[1] ?? 'localhost');
|
||||
} elseif (strpos($line, 'database.default.username') !== false) {
|
||||
$dbUser = trim(explode('=', $line, 2)[1] ?? 'root');
|
||||
} elseif (strpos($line, 'database.default.password') !== false) {
|
||||
$dbPass = trim(explode('=', $line, 2)[1] ?? '');
|
||||
} elseif (strpos($line, 'database.default.database') !== false) {
|
||||
$dbName = trim(explode('=', $line, 2)[1] ?? 'hms_data_ci4');
|
||||
}
|
||||
}
|
||||
|
||||
$conn = new mysqli($dbHost, $dbUser, $dbPass, $dbName);
|
||||
if ($conn->connect_error) {
|
||||
die("ERROR: Connection failed: " . $conn->connect_error . "\n");
|
||||
}
|
||||
|
||||
$ipdId = isset($argv[1]) ? intval($argv[1]) : 1;
|
||||
|
||||
echo "=== Checking discharge content for IPD ID: {$ipdId} ===\n\n";
|
||||
|
||||
// Check if cached content exists
|
||||
$stmt = $conn->prepare("SELECT content FROM ipd_discharge WHERE ipd_id = ? LIMIT 1");
|
||||
$stmt->bind_param("i", $ipdId);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($row = $result->fetch_assoc()) {
|
||||
$content = $row['content'];
|
||||
echo "=== CACHED CONTENT FOUND ===\n\n";
|
||||
|
||||
// Check for signature block
|
||||
if (stripos($content, 'Signature of Consultant') !== false) {
|
||||
echo "✅ 'Signature of Consultant' text FOUND in content\n";
|
||||
} else {
|
||||
echo "❌ 'Signature of Consultant' text NOT FOUND in content\n";
|
||||
}
|
||||
|
||||
// Check for Other Advice
|
||||
if (stripos($content, 'Other Advice') !== false) {
|
||||
echo "✅ 'Other Advice' text FOUND in content\n";
|
||||
} else {
|
||||
echo "❌ 'Other Advice' text NOT FOUND in content\n";
|
||||
}
|
||||
|
||||
// Check for Discharge Summary
|
||||
if (stripos($content, 'Discharge Summary:') !== false) {
|
||||
echo "✅ 'Discharge Summary:' label FOUND in content\n";
|
||||
} else {
|
||||
echo "❌ 'Discharge Summary:' label NOT FOUND in content\n";
|
||||
}
|
||||
|
||||
echo "\n=== CONTENT PREVIEW (first 2000 chars) ===\n";
|
||||
echo substr($content, 0, 2000) . "\n...\n\n";
|
||||
|
||||
echo "=== CONTENT PREVIEW (last 1000 chars) ===\n";
|
||||
echo "..." . substr($content, -1000) . "\n\n";
|
||||
} else {
|
||||
echo "No cached content found for IPD ID {$ipdId}\n";
|
||||
echo "Content is generated on-demand. Try accessing the preview page first.\n";
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
echo "=== Done ===\n";
|
||||
Loading…
Reference in New Issue
Block a user