devsofttech_hms_ci4/app
DevSoftTech Server 09570e0793 Make discharge summary header dynamic based on discharge status
Problem:
- {{DISCHARGE_SUMMARY}} always showed 'Discharge Summary' header
- User wants header to change based on patient discharge status
- 'Date of Discharge' line was unwanted
- Need to see HTML source to check spacing between placeholders

Solution:

1. Added getDischargeStatusText() method:
   - Queries ipd_discharge_status table
   - Uses ipd_master.ipd_status as lookup key
   - Returns status_details or status_desc from table
   - Fallback: 'Discharge Summary' if status not found

2. Modified buildDischargeSectionTokenVars():
   - Now accepts panelData parameter (has ipd info)
   - Gets discharge status text via getDischargeStatusText()
   - Replaces 'Discharge Summary' heading with status text
   - Removes 'Date of Discharge: YYYY-MM-DD' line
   - Uses regex to handle multiple HTML tag formats (h1-h6, b, strong, p)

3. Added debug_discharge_html() endpoint:
   - URL: /Ipd_discharge/debug_discharge_html/{ipdId}
   - Shows complete HTML source with syntax highlighting
   - Displays rendered template with all placeholders replaced
   - Useful for checking spacing and HTML structure
   - Auto-generates content if not saved yet

Database Schema:
- ipd_master.ipd_status: 0-7 (discharge status ID)
- ipd_discharge_status table:
  - id: 0-7
  - status_desc: 'Status Pending', 'Improved/Recovered', 'LAMA', 'Referred', etc.
  - status_details: 'Discharge Summary', 'Leave Against Medical Advice', etc.

Status Mapping (from user's data):
- 0: Status Pending
- 1: Improved/Recovered -> 'Discharge Summary'
- 2: LAMA -> 'Leave Against Medical Advice'
- 3: Referred -> 'Refer To Higher Centre'
- 4: Satisfactory -> 'Discharge Summary'
- 5: Expired -> 'Dead Summary'
- 6: Admission Cancelled
- 7: Discharge on Request

Regex Replacements:
1. Header replacement: /<h[1-6][^>]*>\s*Discharge\s+Summary\s*<\/h[1-6]>/i
2. Bold replacement: /<(b|strong)>\s*Discharge\s+Summary\s*<\/\1>/i
3. Date removal (br): /Date\s+of\s+Discharge\s*:\s*[0-9\-\/]+\s*<br\s*\/?>/i
4. Date removal (p): /<p[^>]*>\s*Date\s+of\s+Discharge\s*:\s*[0-9\-\/]+\s*<\/p>/i

Usage:
- When ipd_status = 1: Shows 'Discharge Summary' (from status_details)
- When ipd_status = 2: Shows 'Leave Against Medical Advice'
- When ipd_status = 5: Shows 'Dead Summary'
- 'Date of Discharge: 2026-06-07' line is removed from all sections

Debug Endpoints:
1. /Ipd_discharge/debug_ipd_fields/{ipdId} - Shows database field values
2. /Ipd_discharge/debug_discharge_html/{ipdId} - Shows complete HTML source

Testing:
- Change ipd_master.ipd_status value
- Regenerate discharge summary
- Header should change based on status
- Date line should not appear
- Use debug_discharge_html to see full HTML structure
2026-06-07 07:35:36 +05:30
..
Authentication/Authenticators Handle legacy null password hashes safely in session login 2026-03-05 14:08:30 +05:30
Commands Checkpoint: pathology panel modal workflow, gateway component search, and ABDM-style component/print editors 2026-05-30 06:32:30 +05:30
Config Fix AJAX route for patient search - remove duplicate billing prefix 2026-06-06 14:53:47 +05:30
Controllers Make discharge summary header dynamic based on discharge status 2026-06-07 07:35:36 +05:30
Database Add page settings and header footer support to discharge templates 2026-06-05 06:22:13 +05:30
Filters Implement OPD template builder, doctor template selection, and OPD print integration fixes 2026-02-27 19:44:36 +05:30
Helpers Add OPD appointment time capture and storage with date+time display 2026-04-28 07:59:47 +05:30
Language Implement OPD template builder, doctor template selection, and OPD print integration fixes 2026-02-27 19:44:36 +05:30
Libraries Add ABDM careContexts and OPD visit key 2026-06-01 13:54:56 +05:30
Models Simplify org-case queries to match CI3 pattern 2026-06-05 14:14:22 +05:30
ThirdParty Implement OPD template builder, doctor template selection, and OPD print integration fixes 2026-02-27 19:44:36 +05:30
Validation Implement OPD template builder, doctor template selection, and OPD print integration fixes 2026-02-27 19:44:36 +05:30
Views Change medicine save to auto-save on Add button click (AJAX) 2026-06-06 21:00:30 +05:30
.htaccess Implement OPD template builder, doctor template selection, and OPD print integration fixes 2026-02-27 19:44:36 +05:30
Common.php Implement OPD template builder, doctor template selection, and OPD print integration fixes 2026-02-27 19:44:36 +05:30
index.html Implement OPD template builder, doctor template selection, and OPD print integration fixes 2026-02-27 19:44:36 +05:30