devsofttech_hms_ci4/clear_discharge_cache.php
DevSoftTech Server f55d300924 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
2026-06-07 20:12:58 +05:30

46 lines
1.6 KiB
PHP

<?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";