diff --git a/app/Controllers/Ipd_discharge.php b/app/Controllers/Ipd_discharge.php index 1d7d905..20cc88d 100644 --- a/app/Controllers/Ipd_discharge.php +++ b/app/Controllers/Ipd_discharge.php @@ -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:']); diff --git a/clear_discharge_cache.php b/clear_discharge_cache.php new file mode 100644 index 0000000..af26cb5 --- /dev/null +++ b/clear_discharge_cache.php @@ -0,0 +1,45 @@ +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"; diff --git a/debug_discharge_content.php b/debug_discharge_content.php new file mode 100644 index 0000000..581b056 --- /dev/null +++ b/debug_discharge_content.php @@ -0,0 +1,77 @@ + +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";