Skip to content

fix(export): PUT patient by id instead of conditional-update so EMR writes reach OpenCR - #74

Merged
mherman22 merged 1 commit into
mainfrom
fix/export-put-by-id
Jul 21, 2026
Merged

mherman22 merged 1 commit into
mainfrom
fix/export-put-by-id

Conversation

@mherman22

Copy link
Copy Markdown

Problem

The real-time EMR → Client Registry (OpenCR) write path is broken. When a patient is saved, exportPatient issues a FHIR conditional update:

PUT /CR/fhir/Patient?identifier=http://sedish-haiti.org/fhir/source-key|<mspp-id>&_format=json

OpenCR does not support conditional update and responds 404 with Cannot PUT /fhir/Patient, so the patient never reaches the registry in real time (it only lands later via the consolidated batch feed).

Verified directly against the live OpenCR:

  • PUT /Patient?identifier=... (conditional) → 404 Cannot PUT /fhir/Patient
  • PUT /Patient/{id} (by id) → 200 OK, and OpenCR runs matching and creates the golden record.

Fix

Write by a stable id (the patient uuid) instead of a conditional update:

admitMessage.setId(patientExport.getPatient().getUuid());
MethodOutcome result = client.update().resource(admitMessage).execute();   // PUT /Patient/{uuid}

OpenCR matches/dedupes on the in-resource source-key identifier (still added above), so this is idempotent and converges with the consolidated batch feed — which already PUTs by id via the fhir-router mediator. This mirrors that mediator's documented approach ("OpenCR does NOT support FHIR conditional-update, so we PUT by id").

Testing

  • mvn clean package green.
  • Confirmed the two PUT styles above against the live OpenCR channel (conditional 404s, by-id 200 + golden created).

Builds on #73 (resilient search translation), which remains intact.

…404s on PUT /Patient?identifier=...); fixes the EMR->Client Registry write path
@mherman22
mherman22 merged commit e3aa609 into main Jul 21, 2026
1 check passed
@mherman22
mherman22 deleted the fix/export-put-by-id branch July 21, 2026 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant