diff --git a/DISCHARGE_PLACEHOLDERS_REFERENCE.md b/DISCHARGE_PLACEHOLDERS_REFERENCE.md new file mode 100644 index 0000000..3256bd5 --- /dev/null +++ b/DISCHARGE_PLACEHOLDERS_REFERENCE.md @@ -0,0 +1,255 @@ +# Discharge Summary Template Placeholders Reference + +## Overview +This document explains all available placeholders for discharge summary templates. Use these placeholders in your template HTML to insert dynamic content. + +--- + +## š“ MAIN DISCHARGE SUMMARY + +### `{{CLINICAL_SUMMARY}}` ā RECOMMENDED +**Content:** The main discharge summary text from the HTML editor (instruction_remark field) +**Source:** "Discharge Summary" section in the discharge form +**Use this for:** The primary clinical narrative written by doctors + +**Example:** +```html +
]*>\s*Date\s+of\s+Discharge\s*:\s*[0-9\-\/]+\s*<\/p>/i', '', - $summary + $clinicalSummary ); } @@ -571,10 +572,15 @@ class Ipd_discharge extends BaseController // Extract individual instruction fields for template flexibility $otherAdvice = $section(['Other Advice:']); - $dischargeSummaryAdvice = $section(['Discharge Summary:']); + $followUpInstructions = $section(['Discharge Summary:']); $vars = [ - 'DISCHARGE_SUMMARY' => $summary, + // Main discharge summary from HTML editor (instruction_remark field) + 'CLINICAL_SUMMARY' => $clinicalSummary, + // Legacy alias for backward compatibility + 'DISCHARGE_SUMMARY' => $clinicalSummary, + + // Clinical sections 'FINAL_DIAGNOSIS' => $finalDiagnosis, 'SURGERY' => $surgery, 'PROCEDURE' => $procedure, @@ -584,16 +590,19 @@ class Ipd_discharge extends BaseController 'CLINICAL_INVESTIGATION_REPORTS' => $clinicalInvestigations, 'COURSE_IN_HOSPITAL' => $courseInHospital, 'EXAMINATION_ON_DISCHARGE' => $examOnDischarge, + + // Discharge instructions and advice 'DISCHARGE_MEDICATIONS' => $dischargeMedications, 'DIETARY_ADVICE' => $dietaryAdvice, 'DISCHARGE_INSTRUCTIONS' => $dischargeInstructions, + 'OTHER_ADVICE' => $otherAdvice, + 'FOLLOW_UP_INSTRUCTIONS' => $followUpInstructions, + + // Other sections 'PAIN_MEASUREMENT_SCALE' => $painMeasurement, 'DRUG_ALLERGY_ADR' => $drugAllergyAdr, 'CO_MORBIDITIES' => $coMorbidities, 'SIGNATURE_BLOCK' => $signatureBlock, - 'OTHER_ADVICE' => $otherAdvice, - 'INSTRUCTION_REMARK' => $dischargeSummaryAdvice, - 'DISCHARGE_ADVICE' => $dischargeSummaryAdvice, // Legacy style aliases to ease migration from CI3-style template variables. 'FinalDiagnosis' => $finalDiagnosis, 'Surgery' => $surgery, diff --git a/check_bed_history.php b/check_bed_history.php new file mode 100644 index 0000000..50ba114 --- /dev/null +++ b/check_bed_history.php @@ -0,0 +1,39 @@ +query(" + SELECT + bah.id, + bah.ipd_id, + bah.bed_id, + bm.bed_number, + bm.bed_code, + bm.bed_status, + bm.current_ipd_id, + DATE_FORMAT(bah.assigned_date, '%d-%m-%Y %H:%i') as assigned_date, + bah.released_date + FROM bed_assignment_history bah + LEFT JOIN bed_master bm ON bm.id = bah.bed_id + WHERE bah.ipd_id = 1 + ORDER BY bah.assigned_date DESC +"); + +if ($result->num_rows > 0) { + while($row = $result->fetch_assoc()) { + echo "Assignment ID: {$row['id']}\n"; + echo "Bed: {$row['bed_number']} ({$row['bed_code']})\n"; + echo "Assigned Date: {$row['assigned_date']}\n"; + echo "Released Date: " . ($row['released_date'] ?? 'NOT RELEASED') . "\n"; + echo "Bed Status in master: {$row['bed_status']}\n"; + echo "Current IPD ID in bed: " . ($row['current_ipd_id'] ?? 'NULL') . "\n"; + echo "---\n"; + } +} else { + echo "No bed assignment history found for this patient.\n"; + echo "This patient may need a bed assigned manually.\n"; +} + +$db->close(); diff --git a/check_current_admission.php b/check_current_admission.php new file mode 100644 index 0000000..864151a --- /dev/null +++ b/check_current_admission.php @@ -0,0 +1,36 @@ +query(" + SELECT + i.id, + i.ipd_code, + DATE_FORMAT(i.register_date, '%d-%m-%Y') as register_date, + p.p_fname, + p.p_lname, + bm.bed_number, + bm.current_ipd_id + FROM ipd_master i + LEFT JOIN patient_master p ON p.id = i.p_id + LEFT JOIN bed_master bm ON bm.current_ipd_id = i.id + WHERE i.ipd_status = 0 + ORDER BY i.register_date DESC +"); + +if ($result->num_rows > 0) { + while($row = $result->fetch_assoc()) { + echo "IPD ID: {$row['id']}\n"; + echo "IPD Code: {$row['ipd_code']}\n"; + echo "Patient: {$row['p_fname']} {$row['p_lname']}\n"; + echo "Register Date: {$row['register_date']}\n"; + echo "Bed Assigned: " . ($row['bed_number'] ?? 'NOT ASSIGNED') . "\n"; + echo "---\n"; + } +} else { + echo "No current admissions found.\n"; +} + +$db->close(); diff --git a/check_ipd2_bed.php b/check_ipd2_bed.php new file mode 100644 index 0000000..f07a472 --- /dev/null +++ b/check_ipd2_bed.php @@ -0,0 +1,90 @@ +query(" + SELECT + i.id, + i.ipd_code, + i.ipd_status, + DATE_FORMAT(i.register_date, '%d-%m-%Y') as register_date, + p.p_fname, + p.p_lname + FROM ipd_master i + LEFT JOIN patient_master p ON p.id = i.p_id + WHERE i.id = 2 +"); +if ($result && $result->num_rows > 0) { + $row = $result->fetch_assoc(); + echo "IPD Code: {$row['ipd_code']}\n"; + echo "Patient: {$row['p_fname']} {$row['p_lname']}\n"; + echo "Status: " . ($row['ipd_status'] == 0 ? 'Admitted' : 'Discharged') . "\n"; + echo "Register Date: {$row['register_date']}\n\n"; +} else { + echo "IPD ID 2 not found!\n\n"; +} + +// Check bed_assignment_history +echo "Bed Assignment History:\n"; +$result = $db->query(" + SELECT + bah.id, + bah.ipd_id, + bah.bed_id, + bm.bed_number, + bm.bed_code, + w.ward_name, + DATE_FORMAT(bah.assigned_date, '%d-%m-%Y %H:%i') as assigned_date, + DATE_FORMAT(bah.released_date, '%d-%m-%Y %H:%i') as released_date, + bah.assignment_type, + bah.remarks + FROM bed_assignment_history bah + LEFT JOIN bed_master bm ON bm.id = bah.bed_id + LEFT JOIN ward_master w ON w.id = bah.ward_id + WHERE bah.ipd_id = 2 + ORDER BY bah.id DESC +"); +if ($result && $result->num_rows > 0) { + while ($row = $result->fetch_assoc()) { + echo "Assignment ID: {$row['id']}\n"; + echo "Bed: {$row['bed_number']} ({$row['bed_code']})\n"; + echo "Ward: {$row['ward_name']}\n"; + echo "Assigned: {$row['assigned_date']}\n"; + echo "Released: " . ($row['released_date'] ?? 'NOT RELEASED') . "\n"; + echo "Type: {$row['assignment_type']}\n"; + echo "Remarks: {$row['remarks']}\n"; + echo "---\n"; + } +} else { + echo "No bed assignment history found for IPD ID 2\n\n"; +} + +// Check current bed assignment in bed_master +echo "Current Bed in bed_master:\n"; +$result = $db->query(" + SELECT + bm.id, + bm.bed_number, + bm.bed_code, + bm.bed_status, + bm.current_ipd_id, + w.ward_name + FROM bed_master bm + LEFT JOIN ward_master w ON w.id = bm.ward_id + WHERE bm.current_ipd_id = 2 +"); +if ($result && $result->num_rows > 0) { + $row = $result->fetch_assoc(); + echo "Bed ID: {$row['id']}\n"; + echo "Bed: {$row['bed_number']} ({$row['bed_code']})\n"; + echo "Ward: {$row['ward_name']}\n"; + echo "Status: {$row['bed_status']}\n"; +} else { + echo "No bed currently assigned in bed_master.current_ipd_id for IPD ID 2\n"; +} + +$db->close(); diff --git a/debug_bed_query.php b/debug_bed_query.php new file mode 100644 index 0000000..833831a --- /dev/null +++ b/debug_bed_query.php @@ -0,0 +1,45 @@ +query($query); + +echo "Query executed\n"; +echo "Rows found: " . $result->num_rows . "\n\n"; + +if ($result->num_rows > 0) { + while ($row = $result->fetch_object()) { + echo "Record ID: {$row->id}\n"; + echo "bed_code: " . ($row->bed_code ?? 'NULL') . "\n"; + echo "bed_number: " . ($row->bed_number ?? 'NULL') . "\n"; + echo "ward_name: " . ($row->ward_name ?? 'NULL') . "\n"; + echo "assigned_date: " . ($row->assigned_date ?? 'NULL') . "\n"; + echo "released_date: " . ($row->released_date ?? 'NULL') . "\n"; + echo "assignment_type: " . ($row->assignment_type ?? 'NULL') . "\n"; + echo "remarks: " . ($row->remarks ?? 'NULL') . "\n"; + echo "---\n"; + } +} else { + echo "No records found\n"; +} + +$db->close(); diff --git a/test_panel_tab.php b/test_panel_tab.php new file mode 100644 index 0000000..625f5b1 --- /dev/null +++ b/test_panel_tab.php @@ -0,0 +1,69 @@ +query($query); +if ($result && $result->num_rows > 0) { + echo "ā IPD data found\n\n"; +} else { + echo "ā IPD not found\n"; + exit; +} + +// Step 2: Get bed assignments +echo "Step 2: Get bed assignments...\n"; +$query = " + SELECT + bed_assignment_history.*, + bed_master.bed_code, + bed_master.bed_number, + ward_master.ward_name + FROM bed_assignment_history + LEFT JOIN bed_master ON bed_master.id = bed_assignment_history.bed_id + LEFT JOIN ward_master ON ward_master.id = bed_assignment_history.ward_id + WHERE bed_assignment_history.ipd_id = {$ipdId} + ORDER BY bed_assignment_history.id DESC +"; +$result = $db->query($query); +echo "ā Query executed\n"; +echo "ā Rows found: {$result->num_rows}\n\n"; + +if ($result->num_rows > 0) { + echo "Step 3: Render view with data...\n"; + $bed_assignments = []; + while ($row = $result->fetch_object()) { + $bed_assignments[] = $row; + } + + echo "ā Data prepared\n"; + echo "ā Array count: " . count($bed_assignments) . "\n\n"; + + echo "Step 4: Check if view can access data...\n"; + echo "Sample data from first record:\n"; + if (!empty($bed_assignments)) { + $first = $bed_assignments[0]; + echo " bed_code: " . ($first->bed_code ?? 'NULL') . "\n"; + echo " bed_number: " . ($first->bed_number ?? 'NULL') . "\n"; + echo " ward_name: " . ($first->ward_name ?? 'NULL') . "\n"; + echo " assigned_date: " . ($first->assigned_date ?? 'NULL') . "\n"; + echo " assignment_type: " . ($first->assignment_type ?? 'NULL') . "\n"; + } + + echo "\nā View should display this data\n"; +} else { + echo "ā No bed assignments found - view will show empty message\n"; +} + +$db->close();