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 (
developbranch), docker-compose deployment - Remote FHIR source: public
hapi.fhir.orgtest 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:
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 inFhirApiWorkFlowServiceImpl,TaskInterpreterImpl, orTaskWorker.sample_type_terminology_mapping— populated it via the realAdmin → Sample Type Management → Terminologyfeature; made no difference to the Add Sample screen.- The “accept as is” action (
attemptAutoSave=true) routes to the exact samesetupForm()/AddSample.jsxcode, 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.