- Remove Restart Web, Restart PHP-FPM, Shutdown, Reboot buttons
- Remove runServerAction() library method and action() controller
- Remove /system-ops/action route (no longer needed)
- Parse /proc/mdstat into structured array (name, level, health, drives)
- Show each RAID array as a card with colored drive icons per-slot
- Green drive = healthy, red = failed, blue = spare
- Show rebuild progress bar when array is rebuilding
- Internet status shown as colored badge with wifi icon
- Services shown as colored badges (green=running, grey=other)
- Remove 'Update HMS (Git)' button and related functionality
- Remove runUpdate() method from SystemOperations
- Remove update() controller method
- Remove /setting/admin/system-ops/update route
- Remove setup_git_config.sh (no longer needed)
- Keep 'Deploy from GitHub' button as the only update method
- Rationale: Direct GitHub deployment is more reliable and requires no git config
Result: Single, simpler deployment method that always works
- Add POST route for /setting/admin/system-ops/updateDirect
- Add GET route for /setting/admin/system-ops/diagnose
- Both endpoints were implemented but routes were missing
This fixes 'Request failed' error on Deploy from GitHub button
- Added SystemOps controller with index and panel endpoints for dynamic content refresh
- Created system_ops_panel.php fragment for AJAX-based UI updates (no full page reload)
- Implemented 30-second auto-refresh using AJAX instead of location.reload()
- Fixed health badge contrast by adding explicit dark text color (#1f2937)
- Added jQuery availability checks to prevent script errors on page load
- Included server overview, resource usage, services, events, and update history
- Integrated delegated event handlers for action buttons (Update, Restart, Reboot, Shutdown)
- All buttons are protected with confirmation dialogs
- Layout maintains NiceAdmin card styling and responsive design
Routes added:
- GET /admin/system-ops/panel - returns panel fragment for refresh
- Diagnosis.php: resolve doctor mapping via ABDM Report Doctor Mapping,
compile pathology/diagnosis reports into separate Letter Head and
Plain Paper PDFs, add compiled-pdf-links endpoint
- Routes.php: add diagnosis/compiled-pdf-links route
- pathology_detail.php: render/persist dual compiled PDF buttons
- Setting/Template.php: per-modality Letter Head / Plain Paper template
mapping via hospital_setting keys
- Setting/Template/index.php: fix tile links using load_form (which only
replaces #main) instead of load_form_div, which broke every internal
AJAX reload (template type switch, modality switch, reset) on the
diagnosis/discharge/document print template settings pages
- diagnosis_print_settings.php: fix corrupted watermark_alpha number
input (missing step attribute) that silently blocked form submission
for templates with non-integer-step legacy values
- Fix groupWorkflowRowsIntoSessions() to correlate workflow rows by stable
request_id/abdm_consent_request_id instead of chronological proximity to
the newest CONSENT_REQUEST row. Background polling reconciles all
historical sessions in one batch, so older sessions' rows previously got
silently merged into the newest session, causing 'Show Data' to display
an unrelated older session's single facility instead of all consented
facilities.
- Skip synthetic orphan sessions (stray rows with no owning CONSENT_REQUEST)
in getAbdmConsentRequestsList()/getAbdmConsentArtifactDetail() so they
don't show as phantom history rows or get picked as 'most recent'.
- Fix abdm_documents() consent_request_id filter to match all known sibling
artifact IDs for a session (via abdm_hiu_consent_artifacts), not just an
exact single artifact id, so all facilities under one consent request
appear together.
- Fix CreateAbdmHiuConsentArtifacts migration: reduce VARCHAR(180) to
VARCHAR(100) on consent_request_id/artifact_id to satisfy MySQL's
1000-byte composite key length limit (was silently failing to migrate).
- Add fetchAllArtifactsAfterGrant() cascade in M3HiuWorkflowService to fetch
every known artifact under a granted consent, used by both the cron poll
and a new abdm_check_live_status() endpoint/button.
- getLatestAbdmSyncSnapshot() session-scoping fix to avoid an older granted
session masking a newer in-progress one.
- Relabel Dr. Joshi Clinic documents (previously mislabeled 'Test Hospital'
from the HIP's own FHIR bundle Organization name).
- New Patient::abdm_content_request_custom(int \) endpoint builds a custom
consent{} block (purpose, hiTypes, permission.dateRange, dataEraseAt) from
user-submitted hi_types[]/date_from/date_to/purpose form fields, instead of
always using M3HiuWorkflowService::buildDefaultConsent()'s hardcoded
OPConsultation+DiagnosticReport / 365-day defaults. Reuses the existing
requester/hiu-id resolution and hiTypes normalization already built into
preparePayloadForOperation() for the consent_request operation, so no
M3HiuWorkflowService changes were needed.
- New route (POST) patient/abdm_content_request_custom/(:num).
- New 'Custom Request' button + '#abdmCustomConsentModal' form
(Patient_Profile_Opd_V.php) with HI type checkboxes (OPConsultation,
DiagnosticReport, Prescription, DischargeSummary, HealthDocument,
ImmunizationRecord, Wellness, Invoice), Valid From/To date inputs
(defaulted to today-365d..today), and a Purpose text field. On submit,
reuses the existing auto-flow polling loop (runAutoFlowStep) with the
returned request_id to track status through to data fetch.
- Live-verified end-to-end on patient 11 (Devender Singh): submitted a
request for OPConsultation + DiagnosticReport + Prescription; sandbox
granted only OPConsultation/DiagnosticReport, and the Phase 1 consent
detail modal correctly showed Prescription as DENIED alongside the two
GRANTED types, confirming the partial-grant per-HI-type breakdown works
correctly end-to-end.
- New Patient::getAbdmConsentArtifactDetail() helper builds a requested-vs-granted
HI type breakdown for a patient's current ABDM consent artifact, using the
bridge-team-confirmed 'Option A' model: overall status is single-valued
(GRANTED/REVOKED/EXPIRED/DENIED), per-type status is derived by comparing the
requested hiTypes (from the saved consent_request request_json) against the
granted hi_types array (already flattened onto responses by
M3HiuGatewayClient). No bridge changes or DB migrations required.
- New Patient::abdm_consent_detail(int \) JSON endpoint + route
patient/abdm_consent_detail/(:num).
- New 'View Consent' link + Bootstrap modal on the OPD ABDM tab
(Patient_Profile_Opd_V.php) rendering a lifecycle stepper, consent metadata
(Consent ID, Purpose, Valid From/To, Erase Date), and a per-HI-type table
(Document Type / Permission / Status / Timestamp).
- Fixed a bug found during live testing: once a consent reaches COMPLETED
(after a successful data_fetch), the highest-priority workflow row has no
hi_types field (it's a FHIR data bundle), which was causing all granted
types to show as DENIED. Now searches workflow history for the most recent
row that actually carries the granted hi_types payload.
- Live-verified against patient 15 (Meera Bisht): both requested HI types
(OPConsultation, DiagnosticReport) correctly show GRANTED with timestamps.
- M3HiuDocumentRepository::persistFromDataFetch no longer includes the
per-call request_id in the document dedup hash. request_id is unique
every time data_fetch runs, so it was causing a brand-new duplicate
row to be inserted on every re-fetch of the exact same ABDM document.
Now dedup key is transaction_id + consent_ref + care_context_reference
+ bundle_id, which stays stable across repeated fetches -> re-fetches
UPDATE the existing row instead of duplicating it.
- Added Patient::abdm_content_fetch_only() + route
billing/patient/abdm_content_fetch_only/(id): a lightweight action for
when consent is already GRANTED/COMPLETED. It calls data_fetch directly
using the saved consent reference, skipping consent_request + reconcile
polling entirely, avoiding unnecessary bridge calls/noise.
- Patient_Profile_Opd_V.php: added a 'Fetch Records' button that only
appears once consent phase is GRANTED or COMPLETED, wired to the new
endpoint; on success it refreshes the document list in place. The
original 'Fetch ABDM Records' button still owns the full consent
request -> reconcile -> fetch flow and already stops/re-enables
correctly on DENIED/FAILED (verified, no change needed there).
- One-time cleanup: deduped existing abdm_hiu_documents rows in dev DB
(13 -> 3) and recomputed doc_hash with the new stable key.
- 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.