devsofttech_hms_ci4/app
DevSoftTech Server e152fab496 Fix discharge time placeholders and department/doctor field mappings
CRITICAL FIXES based on actual database schema analysis:

Problem 1: {{ADMISSION_TIME}} showing 12:00 AM
- Code was looking for: register_time, admission_time (don't exist)
- Actual field: reg_time (stores '14:44' format)
- Fix: Changed to use ipd->reg_time field

Problem 2: {{DISCHARGE_TIME}} showing 12:00 AM
- Code was looking for: discharge_date datetime field
- Actual field: discharge_time (stores '05:30' format)
- Fix: Changed to use ipd->discharge_time field directly

Problem 3: {{DEPARTMENT}} showing blank
- Code was using: hc_department.id field for lookup
- Actual field: hc_department.iId (primary key is iId, not id)
- Fix: Changed WHERE clause from 'id' to 'iId'

Problem 4: {{DOCTOR_NAMES}} showing blank
- Code was looking for: doc_list, doctor_id, doc_id (don't exist)
- Actual field: r_doc_id (referring doctor ID = 12)
- Fix: Changed primary lookup to r_doc_id field

Technical Improvements:

1. Enhanced safeTime() function:
   - Added regex parsing for 'HH:MM' time format
   - Validates hour (0-23) and minute (0-59) ranges
   - Converts 24-hour to 12-hour format with AM/PM
   - Example: '14:44' -> '02:44 PM', '05:30' -> '05:30 AM'
   - Falls back to strtotime() for datetime formats
   - Returns empty string for invalid times

2. Updated getDischargeDoctorNames():
   - Primary: ipd->r_doc_id (referring doctor)
   - Fallback: ipd->doc_list (comma-separated IDs)
   - Fallback: ipd->doctor_id, doc_id, consultant_id
   - Queries doctor_master table
   - Gets specializations from doc_spec + med_spec
   - Format: 'Dr. Name [Specialization]' or 'Title Name [Spec]'

3. Updated getDischargeDepartmentName():
   - Changed: WHERE id = dept_id
   - To: WHERE iId = dept_id
   - Keeps fallback to ipd_department table
   - Returns department vName field

4. Updated debug endpoint:
   - Now checks: reg_time, reg_time_bak, discharge_time, discharge_time_bak
   - Shows: dept_id, r_doc_id, r_doc_name
   - Removed non-existent fields from output

Database Schema (from live data):
- ipd_master.reg_time: '14:44' (admission time)
- ipd_master.discharge_time: '05:30' (discharge time)
- ipd_master.dept_id: 2 -> hc_department.iId (vName field)
- ipd_master.r_doc_id: 12 -> doctor_master.id (p_fname field)

Testing:
- Admission Time should show: 02:44 PM (from reg_time '14:44')
- Discharge Time should show: 05:30 AM (from discharge_time '05:30')
- Department should show department name from hc_department
- Doctor Names should show doctor name with specialization
2026-06-07 07:07:35 +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 Fix discharge time placeholders and department/doctor field mappings 2026-06-07 07:07:35 +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