Commit Graph

215 Commits

Author SHA1 Message Date
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
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
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
1439ce0fcc Fix invalid ABDM HIType codes (HealthDocument->HealthDocumentRecord, Wellness->WellnessRecord) causing consent_request 400; fix extractErrorText for array-shaped bridge error responses 2026-07-28 22:16:22 +05:30
5fb87ea4b4 Extract and display ABDM DocumentReference/Binary attachments (images/PDFs/documents) in fetched record detail view 2026-07-28 17:52:43 +05:30
9536cd2990 Replace ABDM HIU M3 sidebar console with global ABHA Patient Request List (Phase 3 across all patients) 2026-07-28 17:06:41 +05:30
becff35929 ABDM OPD tab: fix duplicate fetched-document rows + add dedicated Fetch Records action
- 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.
2026-07-28 04:34:08 +05:30
a5219bca2d ABDM Gateway settings: add admin UI toggle for SSL certificate verification
Adds a 'Verify SSL Certificate' switch on Admin -> ABDM Gateway page,
persisted as hospital_setting.ABDM_BRIDGE_SSL_VERIFY (default ON/secure).
Wired into M3HiuGatewayClient, EAtriaBridgeConnector, and the settings
page's own Test Connection check. Per-machine ABDM_BRIDGE_SSL_VERIFY env
var still overrides this DB setting for deployments needing a quick
local-only workaround. Verification stays on by default everywhere;
disabling it is an explicit, visible opt-in with an on-page warning.
2026-07-28 03:47:06 +05:30
b26920c6f4 ABDM bridge: allow opt-in SSL verify bypass via ABDM_BRIDGE_SSL_VERIFY env for envs with stale local CA bundles
Some local WAMP/XAMPP/Laragon PHP installs ship an outdated cacert.pem,
causing outbound HTTPS calls to the bridge to fail with cURL error 60
(SSL certificate problem). Rather than globally disabling certificate
verification (as bridge support suggested), verification stays ON by
default and can only be disabled per-deployment by explicitly setting
ABDM_BRIDGE_SSL_VERIFY=false in that machine's .env. The real fix on
affected machines is updating curl.cainfo in php.ini.
2026-07-28 03:37:23 +05:30
a1127522ef ABDM M3: flatten nested consent.status from bridge (root cause fix) and redesign OPD Fetch ABDM Records UI 2026-07-28 02:48:02 +05:30
646347534d Harden consent date range across bridge and HIU paths 2026-07-28 00:46:47 +05:30
9a7bd9ed3a Clamp HIU consent dateRange.to to current UTC 2026-07-28 00:32:39 +05:30
90831d4b39 Harden ABDM bridge auth flow and sync handling 2026-07-28 00:14:49 +05:30
92a954a4cd Fix ABDM HIU auto-flow duplicate consent handling 2026-07-27 14:12:56 +05:30
3bda6f5291 ABDM M2 care-context outbound sync and server cron automation 2026-07-23 15:12:46 +05:30
c84ea383e4 ABDM records/push: treat 201/409 as submitted, persist record IDs, and update OPD UI state 2026-07-21 01:32:30 +05:30
5d6acdd480 Implement ABDM bridge health record flows
- 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
2026-07-20 03:02:09 +05:30
7a547eb443 Add E-Atria immunization master sync 2026-07-19 01:00:43 +05:30
82fd31d105 Add patient immunization module 2026-07-19 00:41:12 +05:30
629590d9ab ABDM: separate course section and include doctor in discharge FHIR 2026-07-17 18:40:19 +05:30
d7fe05e6b0 ABDM: enrich discharge FHIR with observations advice and risks 2026-07-17 17:59:54 +05:30
2b53c05a68 Add ABDM documents and patient profile sync UI 2026-07-16 18:23:40 +05:30
acabc6abdd ABDM HIU callback hardening, OPD ABHA optional confirm, and AJAX memory cleanup 2026-07-10 00:09:35 +05:30
6407db9dbc Update HIU workflow, patient view, and related assets 2026-07-07 01:13:28 +05:30
0f8bd43e72 Fix ABDM M3 HIU ID mapping, polling guards, and migration compatibility 2026-07-02 00:55:05 +05:30
3d40642116 Add ABDM M3 HIU workflows, routes, UI, and runbook docs 2026-07-01 17:37:53 +05:30
c310221961 ABDM: use configured HFR for EAtria connector and avoid submit timeout HTML 500 2026-06-30 18:49:37 +05:30
3072639cd5 Revert "ABDM: fix local submit fallback, HFR runtime usage, status sync, and link-token retry"
This reverts commit e08c18f5b2.
2026-06-30 18:11:34 +05:30
e08c18f5b2 ABDM: fix local submit fallback, HFR runtime usage, status sync, and link-token retry 2026-06-30 18:09:55 +05:30
ed48a447e5 ABDM M2: add push-sync outbox, worker, and FHIR generators 2026-06-27 01:53:44 +05:30
239f0ad374 EAtria auth debug: include full token sha256 in bridge logs 2026-06-26 18:06:00 +05:30
5e3d657a01 EAtria auth debug: enforce DB token source and log token fingerprint 2026-06-26 17:57:46 +05:30
51e5ab026c ABDM M2 compliance: strict EAtria auth/HFR and callback replay guards 2026-06-26 17:52:21 +05:30
03638979f0 EAtria settings: use newest hospital_setting row for token/hfr values 2026-06-26 17:21:12 +05:30
0c0dbf78b4 EAtria pushRecord: fallback to /v1/bridge dispatcher on auth-scoped 403 2026-06-26 17:16:36 +05:30
bf3345b2ce EAtria auth: include bridge hospital id in header and records.push body 2026-06-26 16:59:40 +05:30
c632f28482 EAtria connector: retry alternate DB token keys on 401/403 and log token source 2026-06-26 16:55:07 +05:30
fbaa985857 feat(abdm): implement M2 gateway contract endpoints and live test tooling 2026-06-24 04:50:03 +05:30
985d476bc1 ABDM: finalize ABHA verify persistence, M2 routes/workflows, and location masters seeding 2026-06-24 03:15:22 +05:30
96c030b72d chore: checkpoint before discharge history panel refactor 2026-06-22 02:05:24 +05:30
1bac1f6e04 feat: update storestock flow and ABDM bridge handling 2026-06-18 17:38:20 +05:30
1790be3fca ABDM M2: records push, discover/fetch, non-ABHA local storage, consent table compat
- 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
2026-06-17 20:07:39 +05:30
b0e3459c19 Add ABDM careContexts and OPD visit key 2026-06-01 13:54:56 +05:30
9de803ace7 Send ABDM HFR ID only 2026-06-01 13:24:59 +05:30
e8ec06e8f8 Harden ABDM health record push payloads 2026-06-01 13:23:54 +05:30
7422f9c170 Normalize ABDM HI types to gateway accepted *Record values 2026-06-01 07:22:20 +05:30
40cd6d6414 Include HFR ID in HIP link payloads for e-Atria bridge 2026-06-01 07:13:36 +05:30
b12652d6e0 Align ABDM bridge workflow APIs and add report doctor mapping 2026-06-01 07:02:34 +05:30
e1d9e85e64 Fix FHIR DiagnosticReportRecord datetime and practitioner quality 2026-06-01 06:01:24 +05:30
0ebf8d2a8a ABDM: enforce PDF-backed report submit and improve gateway tracking 2026-05-31 04:17:39 +05:30
78c23af7e5 Checkpoint: pathology panel modal workflow, gateway component search, and ABDM-style component/print editors 2026-05-30 06:32:30 +05:30
0558ac5a2e Pharmacy: add ABDM drug terminology autocomplete + canonical mapping 2026-05-25 13:57:56 +05:30
23cca1f9ba feat(abdm): proper FHIR bundles for lab reports and IPD discharge
- 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
2026-05-23 04:41:59 +05:30
6d851f0e9e ABDM compliance: fix OPConsult bundle to match NRCES IG v6.5.0
- Use UUID v4 for all resources + urn:uuid: references (not Patient/123)
- Add fullUrl on every entry (required by FHIR Document bundle spec)
- Fix Composition.type: LOINC 34133-9 -> SNOMED CT 371530004
  (Clinical consultation report)
- Add meta.profile to Bundle, Composition, Patient, Practitioner,
  Organization, Encounter, Condition, Observation, AllergyIntolerance,
  MedicationRequest, ServiceRequest, Appointment
- Bundle identifier system: urn:ietf:rfc:3986 -> http://hip.in
- Bundle meta.security: add V (very restricted) confidentiality
- All timestamps: ISO 8601 with +05:30 offset (new isoTimestamp())
- Add generateUuid() private helper using random_bytes
- Composition: add language en-IN, identifier (ndhm.in/phr), custodian,
  author fallback, encounter reference
- Section SNOMED codes: Chief complaints 422843007, Allergies 722446000,
  Physical Examination 425044008, Diagnoses 439401001,
  Medications 721912009, Investigation Advice 721963009, Follow Up 736271009
- Separate Chief Complaints from Diagnoses sections
- Encounter.diagnosis.use: SNOMED 39154008 (confirmed) / 148006 (preliminary)
- Practitioner identifier: doctor.ndhm.gov.in system with MD type code
- Organization identifier: facility.ndhm.gov.in system with PRN type code
- Patient identifier: healthid.ndhm.gov.in (was abdm.gov.in) + MR type code
- ServiceRequest/MedicationRequest: add requester from Practitioner
2026-05-20 03:40:40 +05:30
cd18551ce2 feat: FHIR bundle — use complaint_snomed_json for coded complaints (SNOMED + severity + duration) 2026-05-20 02:08:01 +05:30
a56e8a5776 feat: SNOMED background coding pipeline + ABDM Coding Panel
- Add opd_coding_queue + opd_snomed_suggestions migrations
- Add ProcessSnomedCoding spark command (cron: snomed:process-coding)
  Extracts clinical phrases, matches local SNOMED FULLTEXT, saves suggestions
- Add AbdmCodingPanel controller: index/review/confirm/reject/correct/mark_fhir_ready/tip_check
- Add coding_panel + coding_panel_review views (Bootstrap 5, AJAX actions)
- Inject queue trigger in opd_prescription_save (fail-open, ON DUPLICATE KEY)
- Add consult form tip badge: polls tip_check 4s after save, shows review link
- Add AbdmCodingPanel routes behind abdm permission filter
- Various ABDM gateway, FHIR, ABHA, SNOMED library updates
2026-05-19 20:40:27 +05:30
0628f8f813 feat: ABDM OPD Queue + ABHA Register flow + patient ABHA search fix
ABDM OPD Queue (today):
- New EAtriaBridgeConnector: opdQueueFetch/opdTokenCreate/opdTokenUpdateStatus + patch() helper
- New AbdmOpdQueue controller: index/list/fetchQueue/createToken/updateTokenStatus/processScannedToken
  - fetchQueue syncs gateway tokens into abdm_opd_tokens (local DB) and enriches with HMS patient data
  - processScannedToken auto-finds/creates patient_master record from ABHA scan data, marks token CALLED
- New migration: abdm_opd_tokens table (gateway_token_id, source, status, patient_id, opd_id, processed_at)
- New view: abdm/opd_queue.php - reception screen with auto-refresh 30s, HMS Patient column (green row when OPD registered)
- Sidebar: ABDM OPD Queue nav link added
- Routes: AbdmOpdQueue with abdmPermFilter

ABHA Register tab (earlier this session):
- New Abha controller: initiate/verifyOtp/communication/verifyCommOtp/validateAbha/card + autoCreateOrFindPatient
- New views: abha/card.php, partials/abha_create_panel.php, partials/abha_otp_modal.php
- Patient_V.php: ABHA Register tab with 4-method wizard (ABHA number, QR scan, facility QR, mobile OTP)

Patient ABHA search fix:
- Patient::search() now detects ABHA column (abha_id/abha_no/abha/abha_address) and searches by it

ABDM Bridge infrastructure:
- EAtriaBridgeConnector: new connector for e-atria.in ABDM bridge gateway
- AbdmConnectorFactory/Interface updated
- AbdmGatewaySettings controller + view
- SNOMED/CSNOTK terminology service skeleton
- Finance payout OPD consult views
- Migration: AddAbdmPushFieldsToOpdAndPatient, CreateSnomedCoreTables
- Docs: abdm/ API specs, architecture, gateway guides
2026-05-16 04:21:31 +05:30
6d6dad5ca0 abdm: add Dreamsoft URL/token/sourceCode to AbdmConnector config + config-file fallback in BridgeSyncService::readSetting 2026-05-08 23:14:16 +05:30
38a63a628b abdm: add connector adapter pattern (Interface/Factory/Dreamsoft/Direct) + refactor AbdmGateway 2026-05-08 23:10:24 +05:30
6ae9a3516f feat: add HealthPlix OPD sync flow with settings, diagnostics, and sync ID persistence 2026-04-27 08:32:51 +05:30
062fc7ab32 feat: Add ABDM Task Board module with ABHA workflow
- Add ABDM sidebar heading and Task Board nav link
- Create migration 000040: abdm_work_tasks table
- Add AbdmTaskBoard controller with backfill methods
- Add AbdmWorkTaskService for task creation/deduplication
- Add AbdmGateway controller for ABDM API integration
- Separate task types: patient_abha_create vs patient_abha_update
- Add lab_report_publish and radiology_report_publish task types
- Patient.php: auto-create ABDM tasks on registration
- Diagnosis.php: auto-create tasks on report verify/finalize
- Task board UI: 7 filter buttons with default Unupdated ABHA view
- Fix SQL crash in backfillLabRadiologyTasks (dynamic column detection)
- Improve load_form AJAX error display with HTTP status + response text
- Add ABDM routes in Routes.php
- Add FHIR R4 builder library updates
- Add bridge sync service updates
2026-04-05 23:42:24 +05:30
2127063c7f Add nursing scan-to-structured workflow and discharge UI polish 2026-03-09 00:12:04 +05:30
614713f76b Implement OPD template builder, doctor template selection, and OPD print integration fixes 2026-02-27 19:44:36 +05:30