# External FHIR orders arrive at accessioning with neither patient nor specimen data pre-filled

**URL:** <https://talk.openelis-global.org/t/external-fhir-orders-arrive-at-accessioning-with-neither-patient-nor-specimen-data-pre-filled/2395>\
**Category:** Integration\
**Tags:** dev\
**Created:** [August 24, 2026, 10:16am UTC](https://talk.openelis-global.org/t/external-fhir-orders-arrive-at-accessioning-with-neither-patient-nor-specimen-data-pre-filled/2395 "2026-08-24T10:16:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bhupesh\_Gupta](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.openelis-global.org/bhupesh_gupta/32/1273_2.png) [@Bhupesh\_Gupta](https://talk.openelis-global.org/u/Bhupesh_Gupta)\
**Post date:** [August 24, 2026, 10:16am UTC](https://talk.openelis-global.org/t/external-fhir-orders-arrive-at-accessioning-with-neither-patient-nor-specimen-data-pre-filled/2395/1 "2026-08-24T10:16:32Z")

</div>

**Summary**

When an external EMR places an order via the FHIR `Task`/`ServiceRequest` import path (`org.openelisglobal.remote.source.uri`), the resulting order reaches OpenELIS’s accessioning UI (`SamplePatientEntry`) missing two things that were already correctly resolved during import: the **patient link** , and the **specimen/sample type**. Both look like the same underlying pattern — fields OpenELIS resolves correctly during FHIR import don’t get threaded through into every screen that needs them.

**Environment**

- OpenELIS-Global-2 (`develop` branch), docker-compose deployment
- Remote FHIR source: public `hapi.fhir.org` test server (reproducible against any HAPI FHIR server)
- Both issues confirmed via direct source inspection and live testing, not just observed behavior

**Gap 1 — Patient never re-attached to the order at accessioning**

Opening an imported order for accessioning (pencil icon on a row in “Test Requests Matching Search” → `SamplePatientEntry?ID=<serviceRequestId>&labNumber=...`) always lands on a blank “Patient Info” screen with 0 search results — even though the correct patient (name, DOB, gender, National ID) was already created by the FHIR import.

Root cause, in `SamplePatientEntryRestController.setupForm()` (~line 570): the method correctly resolves `Priority`, `Referring Site` (from `Task.location`), and `Provider` (from `Task.owner`) from the `ElectronicOrder` — but then unconditionally does:

```auto
form.setPatientProperties(new PatientManagementInfo()); // always blank
form.setPatientSearch(new PatientSearch()); // always blank

```

There’s no code path reading `electronic_order.patient_id` (a real, correctly-populated column) to hydrate the form. Workaround: manually search by name and re-select the patient that already exists.

**Gap 2 — Specimen/sample type never reaches “Add Sample”**

Separately: `electronic_order.data` only ever caches the raw `Task` JSON — never the associated `ServiceRequest` or `Specimen`, regardless of what’s sent. And `AddSample.jsx` (line 21) hardcodes `sampleTypeId: ""` with no pre-fill logic from any order source at all. So “Select sample type” is always blank at accessioning, for every electronically-submitted order, no matter how complete the FHIR payload is.

**We also checked and ruled out:**

- `Task.input` — not read anywhere in `FhirApiWorkFlowServiceImpl`, `TaskInterpreterImpl`, or `TaskWorker`.
- `sample_type_terminology_mapping` — populated it via the real `Admin → Sample Type Management → Terminology` feature; made no difference to the Add Sample screen.
- The “accept as is” action (`attemptAutoSave=true`) routes to the exact same `setupForm()`/`AddSample.jsx` code, so it doesn’t sidestep either gap.

**What does work correctly** , for contrast — so this isn’t read as “FHIR import is broken”: the Test Requests Matching Search list _can_ show the correct Test Name, Referring Lab Number, and some patient identifiers, but only when the “All Info” checkbox is checked (`RestElectronicOrdersController.convertToDisplayItem`, `useAllInfo` branch) — that path does a live fetch of the `ServiceRequest` from the FHIR store and resolves the LOINC code via `testService.getActiveTestsByLoinc`. So the resolution logic exists and works elsewhere; it’s specifically `setupForm()` (patient) and `AddSample.jsx` (sample type) that don’t use it.

**Minimal reproduction**

Attached Postman collection (2 requests): upserts a `Practitioner`, then submits a transaction `Bundle` with `Patient` + `Specimen` + `ServiceRequest` (referencing the Specimen) + `Task` (referencing the ServiceRequest) to a public HAPI FHIR test server. Set `remote_fhir_base` to whatever your instance’s `org.openelisglobal.remote.source.uri` points at, and `practitioner_id` to match `org.openelisglobal.requester.identifier`.

After OpenELIS polls and imports the Task: check “All Info” in Test Requests Matching Search (Test Name resolves correctly), then click the pencil icon on that row — Patient Info opens blank, and Add Sample’s “Select sample type” is blank, despite both being fully specified in the submitted bundle.

**Question for the community:** is this expected/by-design, or a genuine gap worth a PR? Happy to help scope one — looks like it’d mean extending `setupForm()` to resolve `patientProperties` from `electronic_order.patient_id`, and doing the equivalent for `AddSample.jsx`/sample type, reusing the same FHIR-fetch pattern that already works in the `useAllInfo` branch.

---

<div class="post-metadata">

**Author:** ![Moses\_Mutesasira](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.openelis-global.org/moses_mutesasira/32/72_2.png) [@Moses\_Mutesasira](https://talk.openelis-global.org/u/Moses_Mutesasira)\
**Post date:** [August 27, 2026, 11:22am UTC](https://talk.openelis-global.org/t/external-fhir-orders-arrive-at-accessioning-with-neither-patient-nor-specimen-data-pre-filled/2395/2 "2026-08-27T11:22:57Z")

</div>

> [@Specimen data from external FHIR orders is never available at accessioning (Add Sample sample-type always blank)](https://talk.openelis-global.org/t/specimen-data-from-external-fhir-orders-is-never-available-at-accessioning-add-sample-sample-type-always-blank/2394/10):
>
> Hello @Bhupesh_Gupta . Here is an actual complete [FHIR bundle](https://pastebin.com/umJBjDLM) generated from OpenMRS to OpenELIS The Loinc System code associated to the ServiceRequest.code must match an existing Loic assoctiated to an actual test. You can try out the OMRS-LIS set up preconfigured out of the box. Full [HIE setup](https://github.com/DIGI-UW/openelis-openmrs-hie) with the Exchange going through OpenHIM to view and log the trasnactions [Minimal setup](https://github.com/DIGI-UW/openelis-openmrs-hie/tree/direct-lis-emr) with the direct exachange between OpenMRS and OpenELIS

---

<div class="post-metadata">

**Author:** ![Bhupesh\_Gupta](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.openelis-global.org/bhupesh_gupta/32/1273_2.png) [@Bhupesh\_Gupta](https://talk.openelis-global.org/u/Bhupesh_Gupta)\
**Post date:** [August 31, 2026, 1:05pm UTC](https://talk.openelis-global.org/t/external-fhir-orders-arrive-at-accessioning-with-neither-patient-nor-specimen-data-pre-filled/2395/3 "2026-08-31T13:05:32Z")

</div>

Figured it out, refer:

> [@Specimen data from external FHIR orders is never available at accessioning (Add Sample sample-type always blank)](https://talk.openelis-global.org/t/specimen-data-from-external-fhir-orders-is-never-available-at-accessioning-add-sample-sample-type-always-blank/2394/11):
>
> Figured it out! It wasn’t a bad FHIR bundle after all—just a silly configuration mistake on my end.
> 
> `ACCEPT_EXTERNAL_ORDERS` was set to `false` in `SystemConfiguration.properties`. Looking at the front-end code, the Add Order page only pulls the order ID from the URL when `ACCEPT_EXTERNAL_ORDERS` is enabled. Since it was disabled, the entire external order workflow was skipped. Front End Debugger snapshot (for reference):
> 
> ![image](https://canada1.discourse-cdn.com/flex030/uploads/openelisci/original/2X/c/c32addec79bf74f7731316bd061f1ab8a87701ac.png)
> 
> AI wasn’t much help here; it kept hallucinating fixes for reading patient data on the page instead of flagging the configuration setting. Manual debugging did the trick! Setting `ACCEPT_EXTERNAL_ORDERS` to `true` completely fixed it.
> 
> @ELAI It will be good if above video can be updated to point out configuration settings that need to be enabled to run that workflow.

---

<div class="post-metadata">

**Author:** ![Moses\_Mutesasira](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.openelis-global.org/moses_mutesasira/32/72_2.png) [@Moses\_Mutesasira](https://talk.openelis-global.org/u/Moses_Mutesasira)\
**Post date:** [August 31, 2026, 4:19pm UTC](https://talk.openelis-global.org/t/external-fhir-orders-arrive-at-accessioning-with-neither-patient-nor-specimen-data-pre-filled/2395/4 "2026-08-31T16:19:26Z")

</div>

Glad it has worked .
