Commit Graph

758 Commits

Author SHA1 Message Date
232bf3ef8a fix: add PHP built-in function fallbacks for system operations when shell_exec is disabled
When shell_exec() is disabled on the server (common in production), the system
operations panel now gracefully falls back to PHP built-in functions:

- gethostname() for hostname instead of shell 'hostname' command
- php_uname() for OS info instead of shell 'uname -a' command
- /proc/uptime parsing or unavailable status for uptime
- disk_free_space() and disk_total_space() for disk usage
- memory_get_usage() and PHP memory limit for memory usage
- Improved parsePhpMemoryLimit() to handle memory limit parsing

This ensures the admin panel shows meaningful information even in restricted
production environments where shell_exec is disabled for security reasons.
2026-08-03 16:52:46 +05:30
096ce5e199 feat: add System Operations tile to admin dashboard and include helper library
- Added System Operations link to Admin dashboard (app/Views/Setting/Admin/index.php)
- Uses load_form_div to load the system operations page inline
- Added SystemOperations library for server status collection and actions
- Tile uses server icon (bi-server) and appears in the admin panel grid
- Link: javascript:load_form_div(base_url('setting/admin/system-ops'), 'maindiv', 'System Operations')
2026-08-03 16:50:00 +05:30
89b862db31 feat: add admin system operations panel with AJAX refresh and server monitoring
- 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
2026-08-03 16:47:41 +05:30
37631c27a0 Improve patient search for legacy UHID values 2026-08-03 15:32:16 +05:30
e473be3ae7 Fix diagnosis print template dual-PDF flow and settings save bug
- 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
2026-08-03 02:43:50 +05:30
f57da52725 Refine IPD bill group row colspan and bold styling 2026-08-01 16:44:55 +05:30
6be0df028e Highlight IPD bill group headers and subtotals 2026-08-01 16:36:54 +05:30
b1846696a4 Prevent stale cached IPD bill PDF responses 2026-08-01 16:28:27 +05:30
71a7875fe1 Format IPD bill print group headers and subtotals 2026-08-01 16:21:22 +05:30
49d83dd105 Add PATIENT_TITLE discharge placeholder 2026-08-01 16:13:13 +05:30
53bc924c06 Polish IPD bill labels and wording 2026-08-01 16:05:16 +05:30
151ea7a53f Refine IPD charge display and billing print outputs 2026-08-01 15:55:00 +05:30
2ea2f9f2dc Show last assigned bed in IPD bill print 2026-08-01 15:41:59 +05:30
ee9bb7b560 Fix ABHA card barcode print rendering 2026-08-01 03:57:43 +05:30
f7a0beadb2 Fix ABHA card header layout 2026-08-01 03:38:56 +05:30
3d43375ec0 Balance ABHA card header branding 2026-08-01 03:32:00 +05:30
a28c8612e3 Update ABHA card header branding 2026-08-01 03:27:27 +05:30
fde98e9dee Always show OPD profile picture action 2026-08-01 03:12:52 +05:30
b10661c8d0 Refine OPD profile photo flow 2026-08-01 03:06:45 +05:30
7f9d288825 chore(opd): set appointment list DataTable default page length to 100 2026-08-01 02:56:07 +05:30
302f779ea2 fix(discharge): show in-hospital lab only for explicitly selected dates 2026-08-01 02:29:55 +05:30
d751ff9b4b fix(discharge): honor investigation checkbox selection and print manual/special investigations 2026-08-01 02:15:13 +05:30
bb448a38eb fix(discharge-template): stop DIETARY_ADVICE at review section 2026-07-31 18:07:21 +05:30
fb7ea94157 fix(discharge-template): resolve placeholders with flexible token matching 2026-07-31 17:51:01 +05:30
49a2027778 fix(discharge-template): prevent empty template payload on ajax save 2026-07-31 17:46:27 +05:30
d7e5f16f79 fix(ipd-discharge): honor updated DB template instead of forcing content-only fallback 2026-07-31 17:41:15 +05:30
7d5622d958 Harden ABHA cleanup against non-standard patient and OPD key columns 2026-07-30 14:34:08 +05:30
1429ffc567 Fix ABHA cleanup command for non-id bridge queue schemas 2026-07-30 14:32:46 +05:30
3c6121a4ad Gate legacy bridge events by ABHA verification and add cleanup command 2026-07-30 14:30:34 +05:30
b7f789b1c3 Fix auto-flow false failures and remove dead opd.fhir.generated bridge event
- Patient.php: broaden non-fatal-pending detection in abdm_content_auto_flow() to recognize more bridge error wordings (No HIU sessions found / matching the criteria) and HTTP 400, stopping spurious 'Auto flow failed' toasts.
- Opd_prescription.php: remove dead opd.fhir.generated bridge_sync_queue enqueue in storePrescriptionFhirBundle(). This unprefixed event type routed to the CSNOtk terminology bridge which has no consumer for it, always 404ing. Real ABDM sharing already works via DreamsoftConnector::sharePrescriptionBundle() (abdm.fhir.share.requested).
2026-07-30 06:25:45 +05:30
55bcaa7d09 Fix ABDM M3 HIU multi-facility consent session grouping and document display
- 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).
2026-07-30 05:08:44 +05:30
82b7b27273 fix(abha): persist OTP-verified mobile number when bridge response omits it
Abha::verifyOtp() and Abha::verifyCommOtp() were overwriting the
user-typed, OTP-verified mobile number with whatever the ABDM bridge's
verify-otp response echoed back for 'mobile'. Many bridge responses
(especially plain mobile-OTP verification, as opposed to Aadhaar eKYC)
do not echo the mobile at all, so it silently became empty and was
never saved to patient_master.mphone1 during ABHA Register (By ABHA
Number / QR / Facility QR / Mobile OTP) or ABHA Create/Verify.

Fix: fall back to the originally submitted/verified mobile when the
gateway response omits it. Also updated Patient_V.php JS (Verify ABHA
tab, ABHA Register Method 1 and Method 4) to resend the mobile number
along with the verify_comm_otp call so the server has it available.

Address/email are unaffected by this bug: those fields are already
mapped via applyAbhaMetaColumns() when present, but the ABDM mobile-OTP
verification API generally doesn't return KYC demographic data (that
only comes from the Aadhaar-eKYC flow) - so they may legitimately
stay blank for phone-based registration methods.
2026-07-29 13:52:07 +05:30
a5bbe3cc20 fix(abdm): skip TLS verify on self-loopback FHIR gateway handoff call
HMS instances behind NAT with no live public IP can hit an expired/unreachable
TLS cert on their own base_url() when doing the internal handoff self-call to
AbdmGateway::share_prescription_bundle, causing 'Gateway handoff failed:
curl error 60: Peer's Certificate has expired'. This call never leaves the
local server, so skip peer verification by default via new
fhirGatewayHandoffSslVerify() helper. Set FHIR_HANDOFF_SSL_VERIFY=true in .env
to re-enable strict verification on deployments with a valid public cert.

Does not affect the actual outbound ABDM bridge submission (EAtriaBridgeConnector),
which keeps its own independent SSL verification/toggle.
2026-07-29 12:39:05 +05:30
7b1b81ce66 ABDM Fetch Data modal: show attached images/PDFs per document (lazy-loaded via abdm_document_detail, since the list endpoint strips attachments to keep it light) 2026-07-29 03:53:13 +05:30
0a31c6aa12 ABDM UI: remove redundant document-list panel, add Fetch Data button when no records found for a consent request 2026-07-29 03:41:29 +05:30
2e7e33238b Fix fatal memory-exhaustion crash in Consent Request History: cap response_json to NULL for data_fetch/hi_data_push_callback rows
Those operations can store the entire decrypted FHIR bundle (incl. base64 scanned-document attachments, sometimes MB per row) in response_json. fetchAbdmWorkflowRows()/getLatestAbdmSyncSnapshot() only ever read small consent-status/hi_types fields out of response_json, which never appear in bulk data_fetch payloads anyway, so cap it at the SQL level instead of buffering it into PHP memory just to build a list view.
2026-07-29 03:35:46 +05:30
448db54d4c Show fetched-record sections as plain bold headings (no collapse) and resolve DiagnosticReport result Observations to actual lab values 2026-07-29 03:22:35 +05:30
37dba1948e Redesign Consent Request History table columns and add Fetch/Show Data modal with FHIR section accordion 2026-07-29 03:16:24 +05:30
7129f6e17b Show Consent Request ID in Consent Request History and fetched-document list; persist consent_request_id per document 2026-07-29 03:05:02 +05:30
016c0fdf2f Fix duplicate ABDM document rows: dedup on bundle_id + care_context_reference, not transaction_id/consent_ref
Confirmed empirically: the SAME clinical document (identical FHIR Bundle.id) gets re-delivered by the bridge under a DIFFERENT transaction_id/consent_ref every time it is re-fetched (e.g. via the by-ABHA-address historical fetch, which returns every past consent session for the patient). The old dedup hash included transaction_id+consent_ref, so every re-fetch created a brand-new duplicate row instead of updating the existing one -- observed as literal duplicate rows in the OPD ABDM Fetched Data list (same date/title appearing 2-3x). bundle_id is set once by the HIP and is stable across re-fetches/consents, so pair it with care_context_reference to uniquely identify a document instead.
2026-07-29 02:44:14 +05:30
ad98afbe57 Add Method 1 (fetch by request_id) for self/current-session data + fix latest-consent-anchor drift bug
- M3HiuWorkflowService: data_fetch now supports fetch_by_request_id=1, sending request_id (not consent_id) per bridge Method 1 -- targets the current/self consent request's own session, distinct from Method 2 (consent_id, which can resolve to a stale session sharing the same artifact).
- Patient::abdm_content_fetch_only(): tries Method 2 (consent_id) -> Method 1 (request_id, self data) -> Method 3 (abha_address, historical fallback) in order, stopping as soon as real documents are found.
- Fixed a real pre-existing bug this surfaced: getLatestAbdmSyncSnapshot() used the same flawed 'status=SUCCESS implies COMPLETED' check (without requiring workflow_state=DATA_RECEIVED) already fixed elsewhere in computeConsentSessionDetail(). This let broad/historical data_fetch rows (status=success, but decrypted_data=[]) hijack priority-500 'best' selection and silently drift the resolved 'latest granted consent' to an unrelated historical consent_id after Method 3 fallback ran. Now requires workflow_state=DATA_RECEIVED, matching the earlier fix.
2026-07-29 02:31:29 +05:30
c87928c2bc Support Method 3 (fetch by abha_address) as fallback to surface historical ABDM records
Per bridge gateway team guidance, GET /v1/hiu/data/fetch?abha_address=... returns ALL historical decrypted records across every past consent for a patient, unlike the consent/request-scoped Methods 1/2 previously used exclusively. Added M3HiuWorkflowService support for a fetch_by_abha_address flag on the data_fetch operation, and wired abdm_content_fetch_only() to automatically fall back to this broader lookup when the consent-scoped fetch finds nothing new -- this surfaced 14 previously-invisible historical documents (consultation reports, pathology/cytology) for the test patient that were never being fetched before.
2026-07-29 02:19:56 +05:30
690dbf9572 Fix misleading 'fetched successfully' message on Fetch Records when no documents were actually saved
abdm_content_fetch_only() always returned phase=COMPLETED and 'Records fetched successfully' whenever the data_fetch API call itself succeeded (fetchResult.ok===1), even when documents_persisted+documents_updated was 0 (bridge/HIP hasn't actually delivered any records yet -- decrypted_data still empty, session status 'requested'). Now check documents_persisted+documents_updated: if 0, report phase=GRANTED with a clear 'not sent any records yet' message instead of falsely claiming success.
2026-07-29 02:08:25 +05:30
afd1de04bf Fix ABDM consent status showing COMPLETED before data actually arrived
computeConsentSessionDetail() treated any data_fetch/hi_data_push_callback row with status=success as proof the session reached COMPLETED. But the DB 'status' column only reflects whether the underlying API call/poll succeeded (no HTTP/transport error) -- NOT whether data was actually received; that's tracked separately via workflow_state (DATA_PENDING vs DATA_RECEIVED). A data_fetch poll that succeeds at the HTTP level but returns decrypted_data=[] (bridge still processing) was incorrectly marked COMPLETED instead of staying at GRANTED. Now also require workflow_state === DATA_RECEIVED for the COMPLETED phase.
2026-07-29 01:55:15 +05:30
67daaf8894 Fix ABDM consent modal showing all HI types as DENIED when granted via async data push
When a consent session's overall phase resolves to GRANTED/COMPLETED via a data_fetch or hi_data_push_callback row (proof data was actually fetched), but no consent_reconcile/consent_status row in that session ever recorded which hi_types were granted (e.g. data arrives via async push before any reconcile poll runs), grantedHiTypes stayed empty and every requested HI type was incorrectly marked DENIED. Fall back to treating the full requested set as granted when we have positive proof of GRANTED/COMPLETED but no negative evidence of per-type denial.
2026-07-29 01:44:17 +05:30
0a19ccb425 Fix ABDM Consent Request History UI showing blank/orphaned COMPLETED row: fetchAbdmWorkflowRows() now always includes every consent_request anchor row for the ABHA (merged with recent-200 window), so heavy per-artifact data_fetch polling volume can no longer push a session's CONSENT_REQUEST row out of range and break groupWorkflowRowsIntoSessions() 2026-07-29 01:21:54 +05:30
5cdf367f94 Fix stale dateRange.to in M3 consent_request: always refresh to current time at actual dispatch (was only clamping if in the future, so a retried/reused payload with a stale-past cutoff silently excluded newer records forever) 2026-07-29 00:27:46 +05:30
01d5efa1eb Add wipe_hiu_data_for_abha.php: full M3 HIU data wipe (documents+workflows+artifacts) for fresh consent testing 2026-07-28 23:54:31 +05:30
e803809506 M3 HIU: track every discovered consent artifact id per consent_request in new abdm_hiu_consent_artifacts registry, and re-poll each individually every cycle (merged fetch-by-request-id alone does not keep returning already-established artifact sessions) 2026-07-28 23:47:19 +05:30
e783a57c4d Fix M3 multi-artifact polling: pollNatGateway now passes consent_request_id (not single resolved artifact id) to data_fetch, so the bridge returns merged sessions across ALL linked HIP facilities in one poll 2026-07-28 23:37:31 +05:30