- add facility QR support and OPD queue bridge fixes
- support care-context push warnings for lab, radiology, IPD and remaining HI types
- improve ABHA patient matching and diagnosis autocomplete performance
- clean up webcam streams on page navigation
- EAtriaBridgeConnector: fix OPConsultRecord hi_type normalization (was wrongly
mapping to PrescriptionRecord); allow push with either abha_address or abha_id;
add careContextId alias for care_context_reference in pushRecord payload
- AbdmGateway: migrate OPD share to records/push semantics with unique
care_context_reference, ABHA id/address resolution, bridge_record_id capture,
and 409 DUPLICATE_RECORD non-fatal handling
- AbdmGateway: add non-ABHA local-only storage path for OPD/IPD/Lab share
(push_status=local_only, no bridge call, audit logged)
- AbdmGateway: add POST /records/discover endpoint with ABHA-first + fallback
matching by mobile, hospital ID, patient UHID+birthYear (PHR-compatible)
- AbdmGateway: add GET /records/fetch/{careContextId} endpoint returning
decrypted FHIR payload from health_records
- AbdmGateway: dual-write consent artefacts to abdm_consent_records AND
consents table when both present; getActiveConsentRecord falls back to
consents table when abdm_consent_records is absent
- AbdmAuditService: write to audit_logs (generic schema) when present,
fallback to abdm_audit_logs; field-aware insert supports both schemas
- Routes: register /records/discover and /records/fetch/(:any)
- Webhook signature validator: check EKA_WEBHOOK_SECRET then HMS_WEBHOOK_SECRET
for gateway compatibility
- Rename toggleIpdStatus() to updateDischargeToggleStatus() to match naming pattern
- Add route mapping for /billing/ipd/panel/{id}/discharge/toggle-status endpoint
- Fixes 404 error when clicking toggle button in discharge panel
- Follows same pattern as other discharge operations (discount, charge, update)
- Implemented automatic bed release on patient discharge
- Added bed transfer functionality in nursing workspace
- Added date/time tracking for bed assignments with duration calculation
- Fixed bed_master.current_ipd_id as source of truth for occupancy
- Created data fix scripts for existing records
- Added bed assignment history with duration display (hours/minutes)
- Fixed display issues in bed assignment tab
- Added route for bed transfer endpoint
- Supports custom assignment datetime for backdated entries
- Automatically marks previous bed as released on transfer
ISSUE: Templates auto-regenerate when deleted
User deletes template ID 3, page reload creates template ID 4 automatically
ROOT CAUSE: ensureDefaultDischargeTemplateSeeded() called on EVERY page load
- discharge_templates() method called it on every view
- getDischargeTemplateRows() called it on every discharge PDF generation
- When count=0, it auto-inserted default templates
- Made it impossible to delete all templates
SOLUTION: Changed to manual opt-in template creation
1. Removed auto-seeding calls:
- Setting/Template::discharge_templates() - removed ensureDefaultDischargeTemplateSeeded()
- Ipd_discharge::getDischargeTemplateRows() - removed ensureDefaultDischargeTemplateSeeded()
- Both now only call ensureDischargeTemplateTable() (structure check only)
2. Added manual template creation:
- New 'Create Default Templates' button shown when table is empty
- New endpoint: discharge_templates_seed() - creates defaults on demand
- Route: POST /setting/template/discharge_templates_seed
- Button confirms before creating, shows success message, reloads page
3. Preserved seeding functions:
- ensureDefaultDischargeTemplateSeeded() kept but not auto-called
- Can be manually triggered via new button
- Creates 'Default Discharge Template' and 'NABH Compliant Discharge Summary'
BEHAVIOR NOW:
- Users can delete ALL templates - they stay deleted
- Empty table shows helpful message with creation button
- Templates only created when user explicitly requests them
- No more surprise template regeneration
TESTING:
- Delete all templates
- Page reloads showing empty table with button
- Click 'Create Default Templates'
- 2 templates created (ID 1 and 2)
Problem:
- GET: Ipd_discharge/debug_discharge_html/1 returning 404
- GET: Ipd_discharge/debug_ipd_fields/1 returning 404
- Debug endpoints were created but routes were not registered
Solution:
Added two new routes in app/Config/Routes.php:
1. Debug IPD Fields Endpoint:
Route: Ipd_discharge/debug_ipd_fields/(:num)
Controller: Ipd_discharge::debug_ipd_fields/\
Method: GET
Returns JSON showing:
- All available field names in ipd_master table
- Values of time fields (reg_time, discharge_time)
- Values of department fields (dept_id)
- Values of doctor fields (r_doc_id, r_doc_name)
- Result of getDischargeDepartmentName() function
- Result of getDischargeDoctorNames() function
- Result of safeTime() for time fields
2. Debug Discharge HTML Endpoint:
Route: Ipd_discharge/debug_discharge_html/(:num)
Controller: Ipd_discharge::debug_discharge_html/\
Method: GET
Returns HTML page showing:
- Complete discharge summary HTML source
- Syntax highlighted for easy reading
- All placeholders replaced with actual values
- Useful for checking spacing and HTML structure
Route Placement:
- Added after search_patient_ajax route
- Before ipd_select route
- Follows existing Ipd_discharge route pattern
- Uses (:num) parameter for IPD ID
Usage:
- http://localhost:8080/Ipd_discharge/debug_ipd_fields/1
- http://localhost:8080/Ipd_discharge/debug_discharge_html/1
- Replace '1' with actual IPD ID
Note: Routes must be defined BEFORE more general routes
Otherwise, the (:num) pattern in ipd_select would catch them first
Testing:
1. Pull latest code
2. Access /Ipd_discharge/debug_ipd_fields/1
3. Should return JSON with field values
4. Access /Ipd_discharge/debug_discharge_html/1
5. Should return HTML source page
- Updated Patient::search() to only render view with search query
- Created Patient::search_ajax() method for DataTables AJAX endpoint
- Implemented server-side processing with pagination, sorting, and filtering
- Results ordered by Last Visit DESC by default
- Retrieves all patient data from patient_master table
- Added proper SQL escaping to prevent injection
- Updated Patient_Search_V.php to use DataTables with AJAX remote data
- Added DataTables configuration with 25 rows per page default
- Supports dynamic length menu (10, 25, 50, 100, All)
- Added route for billing/patient/search_ajax endpoint
- Improved user experience with loading spinner and customized messages
- Added 'Discharge' button in sidebar under In-Patient & Nursing Care section
- Created search_patient() and search_patient_ajax() controller methods
- Implemented AJAX-based patient search by IPD Code, UHID, Name, or Mobile
- Added ipd_discharge/search_patient.php view with dynamic results table
- Search results show patient details, bed info, doctor assignments, and discharge status
- Added 'Create Discharge' and 'Print Discharge' action buttons for each patient
- Integrated DataTables for sorting and pagination
- Fixed database column names (patient_master.gender, age, age_in_month)
- Added routes for search page and AJAX endpoint
FEATURE: Quick-add functionality for Course/Treatment master terms
NEW COMPONENTS:
1. Course master table: ipd_discharge_course_master
- term_name, term_code, icd_code, is_active
- Auto-creates on first use
2. Controller endpoints in Ipd_discharge.php:
- course_master_lookup() - AJAX autocomplete search
- course_master_list() - Full list with filters
- course_master_save() - Create/update records
- course_master_delete() - Remove records
3. Routes added to Config/Routes.php:
- Ipd_discharge/course_master_lookup (GET)
- Ipd_discharge/course_master_list (GET)
- Ipd_discharge/course_master_save (POST)
- Ipd_discharge/course_master_delete (POST)
VIEW CHANGES (discharge_create.php):
- Course input now uses input-group layout
- Green 'Save in Master' button added
- Custom dropdown for autocomplete with code badges
- Hidden field: new_course_master_id
- JavaScript: initCourseAutocomplete() function
- Integrated with existing quickAddTermModal
QUICK-ADD MODAL ENHANCEMENT:
- Now supports 3 types: surgery, procedure, course
- Dynamic endpoint selection based on type
- Course type uses course_master_save endpoint
- Auto-populates course input and master_id on save
AUTOCOMPLETE FEATURES:
- Type 2+ characters → searches course_master table
- Dropdown shows: Name + SNOMED/ICD code badges
- Arrow key navigation (Up/Down/Enter/Escape)
- Click or Enter to select
- Hover highlighting with visual feedback
- 300ms debounce for performance
WORKFLOW:
1. Type course/treatment name
2. See dropdown with existing terms (if any)
3. Click 'Save in Master' to add new term
4. Modal opens with name pre-filled
5. Enter SNOMED/ICD codes (optional)
6. Save → Auto-populates input + master_id
7. Click '+ADD Row' to add to discharge
BENEFITS:
- Consistent UI across Surgery/Procedure/Course sections
- Fast term entry without leaving form
- Master library builds during workflow
- ABDM compliance with code support
- Reusable terms across discharges
BUGFIX: 404 error when saving editable complaint fields
PROBLEM: When editing complaint name or remark in IPD discharge
form, the AJAX request to update_complaint_field returned HTTP 404.
ROOT CAUSE: In CodeIgniter 4, routes must be explicitly defined.
The new update_complaint_field method was added to Ipd_discharge
controller but no route was registered in Routes.php.
SOLUTION: Added POST route for Ipd_discharge/update_complaint_field
in app/Config/Routes.php following the existing pattern for other
Ipd_discharge AJAX endpoints.
Now editable complaint fields save correctly with green/red feedback.
- FhirR4Builder: rewrite buildLabReportBundle() with DiagnosticReportLab
profile, structured Observation valueQuantity/valueString, reference
ranges, interpretation codes, Binary+DocumentReference for HTML report,
Encounter resource, HFR-based bundle identifier system
- FhirR4Builder: rewrite buildDischargeSummaryBundle() with optional
Practitioner/Organization params, structured ABDM sections (chief
complaints 422843007, medical history 1003642006, investigations
721981007, procedures 1003640003, medications 721912009, follow-up
736271009), HFR-based bundle identifier system
- AbdmGateway: shareIpdDischargeBundle() now builds a real
DischargeSummaryRecord FHIR bundle and posts via pushRecord()
(POST /v3/records/push) instead of the stale shareIpdDischargeBundle()
- AbdmGateway: shareDiagnosisReportBundle() now builds a real
DiagnosticReportRecord FHIR bundle and posts via pushRecord()
instead of the stale shareDiagnosisReportBundle()
- AbdmGateway: add getHospitalProfileForFhir() and mapLabTypeToTitle()
helpers; fix pre-existing undefined \ bug in
getActiveConsentRecord()
- Add ABDM_FHIR reference package, AbdmBridgeLog controller/view,
bridge record migration, debug scripts and misc UI/settings updates
- POST Opd_prescription/fhir_bundle_submit endpoint:
loads stored FHIR bundle, fetches patient/OPD/doctor context,
calls EAtriaBridgeConnector::pushRecord to push to bridge
- Standalone preview page (/Opd_prescription/fhir_bundle_preview/N):
added Submit to ABDM Bridge button with CSRF-safe AJAX + inline
success/error alert
- FHIR modal in task_board.php: added Submit to ABDM button next
to Copy JSON; JS reads _fhirOpdId/_fhirSessionId and posts to
fhir_bundle_submit with CSRF token refresh
- Add separate Save Settings button below User Settings card
- Create myProfileSaveSettings controller method for dedicated settings save
- Settings save endpoint: POST /my-profile/save-settings
- Validates sidebar_auto_hide_seconds (0-60 range)
- Provides immediate feedback: success/error message display
- Separate from profile photo and password updates
- Message auto-hides after 2 seconds on success
- Safe delete for empty IPD charge groups with CSRF-safe AJAX
- Migration: add sort_order to ipd_item_type (backfilled)
- Sort order UI on create/edit/list views; persist in controller/model
- Up/Down swap buttons on group list (AJAX swap endpoint + CSRF refresh)
- Fix 500 on edit screen: restore missing getItemTypeById() in ItemIpdModel
- IpdBillingModel: propagate sort_order ordering to ipd-charges and bill-details tabs
- Billing IPD Charges tab: Bedside Clinical/Nursing Charge and Doctor Visit Charge panels now collapsible, start collapsed
- new rx_group_delete(int rxId) method in Opd_prescription controller
- deletes linked medicines first (opd_prescrption_prescribed_template), then group row
- POST route: Opd_prescription/rx_group_delete/(:num)
- Delete button (red) added to each row in Rx-Group list table
- confirm dialog before delete (shows group name)
- reloads list after delete; clears form if deleted group was loaded
Production runs HTTPS; browser blocks http://139.59.13.39:8000 (mixed content).
Solution: CI4 proxy endpoints forward audio/health check server-side (HTTP→HTTP).
- Home::sttProxy() POST stt-proxy - forwards audio to STT server
- Home::sttProxyHealth() GET stt-proxy/health - pings STT and returns {ok:bool}
- JS: auto-detect window.location.protocol; use proxy URLs on HTTPS,
direct IP URLs on HTTP (local/dev)
- checkComplaintsSttServer: parse {ok:bool} from proxy health response
- Add complaints Speech-to-Text (browser + server STT fallback) with interim preview
- Add Medical Mic (server STT) for examination, diagnosis, provisional diagnosis fields
- Add speech-test route + Home::speechTest() view for STT testing
- OPD prescription: resolve dosage/when/frequency labels from lookup tables
- OPD prescription: show generic/salt name below medicine name in print
- OPD prescription: translate complaints/diagnosis/advice/investigation to Hindi for patient
- Add translateToLocalPatientText() helper with English->Hindi medical term map
- Add 'Remove All' medicines button (btn_clear_medicine)
- Add template search box in Load Template modal
- Fix investigation batch add: dedup + guard against concurrent add
- Fix single investigation add: check duplicate before adding
- Fix rx status text overflow: ellipsis + title tooltip
- Remove unused FHIR History and Back to Invoice buttons from Rx header
- .gitignore: exclude public/uploads/* and writable/ayushman/*