Commit Graph

711 Commits

Author SHA1 Message Date
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
9f2460fed9 Remove obsolete one-off M3/M2 diagnostic scripts (root cause resolved) 2026-07-28 23:35:01 +05:30
fd0d571f9b Add diagnostic spark command abdm:hiu-reconcile-by-request to test consent_reconcile by consent_request_id 2026-07-28 23:14:20 +05:30
982690c195 check_transaction_lookup.php: add optional operation filter + limit args 2026-07-28 23:12:13 +05:30
81c9940860 Add safe delete script for abdm_hiu_documents rows by abha_address (dry-run by default, --confirm to delete) 2026-07-28 23:10:03 +05:30
d2c25b9e38 Add spark command abdm:hiu-fetch-by-consent for manual data_fetch of a specific consent artifact id 2026-07-28 22:57:57 +05:30
759d17d7a3 Add diagnostic: check_transaction_lookup.php for searching abdm_hiu_workflows/documents by transaction/consent id 2026-07-28 22:48:35 +05:30
7092f9845a Make check_hiu_documents.php read DB creds from .env instead of hardcoded local root credentials 2026-07-28 22:27:26 +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
2525916c08 Add diagnostic to inspect raw consent_request response behind generic HTTP 400 error 2026-07-28 22:12:12 +05:30
6383e28abd Fix diagnostic script to collapse /api/api/ duplication and add sanity check + more candidate paths 2026-07-28 20:59:49 +05:30
51da7b068e Add diagnostic to probe candidate care-context-link bridge endpoints 2026-07-28 20:55:01 +05:30
449a683a7c Add one-off diagnostic script to dump full abdm_hiu_workflows response_json 2026-07-28 20:38:56 +05:30
2196de9959 Fix cron installer to use php83 instead of incompatible default php CLI 2026-07-28 20:21:23 +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
dec025d6bf ABDM Custom Request: default Expiry Date uses exact +1 year instead of +365 days 2026-07-28 16:57:34 +05:30
7256858562 ABDM Custom Request modal: Purpose as fixed dropdown + add Expiry Date field 2026-07-28 16:54:00 +05:30
25db2e5ddc ABDM OPD tab: replace flow buttons with per-patient Consent Request History list (Phase 3) 2026-07-28 16:42:20 +05:30
48d19f0ff7 ABDM: add manual Consent Request form with editable HI types + date range (Phase 2)
- 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.
2026-07-28 16:23:47 +05:30
7f47045c55 ABDM: add per-HI-type Consent Detail view (Phase 1)
- 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.
2026-07-28 16:17:10 +05:30
37c3592f69 ABDM: auto-expire stale pending consent requests after 1 hour
Previously, clicking 'Fetch ABDM Records' when a prior consent request was
stuck in REQUESTED/PENDING (no GRANTED/DENIED callback ever received from
the ABDM bridge/PHR - e.g. patient never opened/approved it in their PHR
app) would just resume/re-poll that same dead request indefinitely, since
getLatestAbdmSyncSnapshot() always prioritized the existing REQUESTED
request over starting a new one.

Now:
- getLatestAbdmSyncSnapshot() computes the age of a REQUESTED/PENDING
  snapshot's updated_at and marks restart_required = true once it has
  been pending for more than ABDM_PENDING_STALE_SECONDS (1 hour).
- abdm_content_auto_flow() honors this flag: when the last sync is stale,
  it no longer resumes the old request_id and instead falls through to
  create a brand-new consent_request against the bridge.

Verified locally: a 6h-old stale REQUESTED request for a test ABHA was
correctly abandoned and a fresh consent_request was created and granted
on the next 'Fetch ABDM Records' click, instead of re-polling the dead
request.
2026-07-28 14:36:15 +05:30
2c9e5755d2 Add check_remote_abdm_fetch.php diagnostic script for ABDM data_fetch troubleshooting on remote servers 2026-07-28 04:51:16 +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
d7dae674cc chore: add more ABDM diagnostic scripts (multi-patient consent flow comparison) 2026-07-28 03:11:43 +05:30
768079c970 chore: add ABDM M3 HIU diagnostic scripts for consent workflow debugging 2026-07-28 03:08:52 +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
716ad04d13 Fix duplicate ABDM consent requests: only treat consent_request submission failure as terminal FAILED 2026-07-28 02:36:27 +05:30
acc4e5c287 Prefer recent granted/completed over pending 404 snapshot 2026-07-28 02:28:57 +05:30
5c15424280 Promote granted consent status in snapshot ranking 2026-07-28 02:26:19 +05:30
98b25914d7 Include callback operations in ABDM sync snapshot 2026-07-28 02:15:34 +05:30
71e0c7cf24 Treat transient consent 404 as pending 2026-07-28 02:07:50 +05:30
c2a3e3054f Resolve fallback consent status in OPD flow 2026-07-28 01:53:44 +05:30
05d35f6021 Make OPD ABDM flow wait for first request 2026-07-28 01:46:36 +05:30
49969cb9be Simplify ABDM request flow for users 2026-07-28 01:28:08 +05:30
a15f5a0785 Handle failed ABDM consent reset and add status help 2026-07-28 01:05:25 +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
bf6090cfd5 Route consent status through flexible handler 2026-07-27 15:35:43 +05:30
3b6ed76a3c Reset stale ABDM request flow after bridge 404 2026-07-27 15:21:42 +05:30
0048cb1eff Resume granted consent flow on reconcile 404 and attempt direct fetch 2026-07-27 15:01:36 +05:30
698b9cd520 Prefer granted/completed ABDM state over latest 404 reconcile rows 2026-07-27 14:40:39 +05:30
c77201ec96 Persist and resume ABDM sync state on profile reload 2026-07-27 14:32:47 +05:30
8086bfbeb6 Stop ABDM auto-sync polling on reconcile 404 2026-07-27 14:28:42 +05:30
49698a72d7 Handle ABDM reconcile not-found as pending state 2026-07-27 14:18:07 +05:30