# Specimen data from external FHIR orders is never available at accessioning (Add Sample sample-type always blank)

**URL:** <https://talk.openelis-global.org/t/specimen-data-from-external-fhir-orders-is-never-available-at-accessioning-add-sample-sample-type-always-blank/2394>\
**Category:** Integration\
**Tags:** dev\
**Created:** [August 24, 2026, 8:13am UTC](https://talk.openelis-global.org/t/specimen-data-from-external-fhir-orders-is-never-available-at-accessioning-add-sample-sample-type-always-blank/2394 "2026-08-24T08:13:55Z")\
**Posts on this page:** 11\
**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, 8:13am UTC](https://talk.openelis-global.org/t/specimen-data-from-external-fhir-orders-is-never-available-at-accessioning-add-sample-sample-type-always-blank/2394/1 "2026-08-24T08:13:55Z")

</div>

**Summary**

When an external EMR places an order via the FHIR `Task`/`ServiceRequest` import path (`org.openelisglobal.remote.source.uri`), a well-formed `Specimen` resource — correctly referenced from `ServiceRequest.specimen` — never makes it to the accessioning UI. The “Add Sample” screen’s sample-type dropdown is always empty, regardless of what the EMR sends, requiring a lab tech to manually re-select it every time.

**Environment**

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

**Root cause (traced in source)**

1. `FhirApiWorkFlowServiceImpl`’s Task-import path (`saveRemoteTaskAsLocalTask` / `beginTaskImportOrderPath`) does correctly resolve `Task.basedOn` → `ServiceRequest` → `ServiceRequest.specimen` → `Specimen`, and mirrors all of them into the co-resident FHIR store. This part works.

2. However, `electronic_order.data` (the table backing the Incoming Orders queue) only ever caches the raw `Task` resource JSON — it never stores the associated `ServiceRequest` or `Specimen`. Confirmed by inspecting the column directly:

3. The “Add Sample” screen (`frontend/src/components/addOrder/AddSample.jsx`, line 21) initializes `sampleTypeId: ""` with **no pre-fill logic from any order source at all** — manual entry, electronic order, or FHIR import all land on the same blank dropdown.

So the gap isn’t in FHIR resource resolution (that part is correct) — it’s that the specimen data gets dropped between “resolved during Task import” and “displayed at accessioning.”

**We also checked and ruled out:**

- `Task.input` — not read anywhere in `FhirApiWorkFlowServiceImpl`, `TaskInterpreterImpl`, or `TaskWorker`. A checklist we found suggesting `Task.input` explicitly flags the specimen doesn’t match this codebase.
- `sample_type_terminology_mapping` — populating this (via the real `Admin → Sample Type Management → Terminology` feature) makes no difference to this specific screen; it appears to serve a different purpose (unconfirmed which).

**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`.

```auto
{

  "info": {

    "name": "OpenELIS Specimen-Linking Repro",

    "description": "Minimal reproduction: an external FHIR order (Task + ServiceRequest + Specimen + Patient) with a well-formed ServiceRequest.specimen reference still results in an empty 'Select sample type' dropdown when accessioning the order in OpenELIS. See the forum post this collection accompanies for full analysis.\n\nUsage:\n1. Set `remote_fhir_base` to whatever your OpenELIS instance's `org.openelisglobal.remote.source.uri` points at (this example uses the public 
 test server).\n2. Set `practitioner_id` to match your instance's `org.openelisglobal.requester.identifier` (strip any 'Practitioner/' prefix).\n3. Run '01 - Upsert requesting Practitioner', then '02 - Place order with Specimen'.\n4. Wait for OpenELIS's poll cycle (org.openelisglobal.remote.poll.frequency, default ~2 min), then check the Incoming Orders queue in OpenELIS and try to accession the resulting order.",

    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"

  },

  "variable": [

    { "key": "remote_fhir_base", "value": "
", "type": "string" },

    { "key": "practitioner_id", "value": "f9badd80-ab76-11e2-9e96-0800200c9a66", "type": "string" },

    { "key": "patient_id", "value": "", "type": "string" },

    { "key": "specimen_id", "value": "", "type": "string" },

    { "key": "service_request_id", "value": "", "type": "string" },

    { "key": "task_id", "value": "", "type": "string" }

  ],

  "item": [

    {

      "name": "01 - Upsert requesting Practitioner",

      "request": {

        "auth": { "type": "noauth" },

        "method": "PUT",

        "header": [{ "key": "Content-Type", "value": "application/fhir+json" }],

        "url": {

          "raw": "{{remote_fhir_base}}/Practitioner/{{practitioner_id}}",

          "host": ["{{remote_fhir_base}}"],

          "path": ["Practitioner", "{{practitioner_id}}"]

        },

        "body": {

          "mode": "raw",

          "raw": "{\n \"resourceType\": \"Practitioner\",\n \"id\": \"{{practitioner_id}}\",\n \"name\": [{ \"family\": \"Smith\", \"given\": [\"John\"] }]\n}",

          "options": { "raw": { "language": "json" } }

        }

      },

      "event": [

        {

          "listen": "test",

          "script": {

            "type": "text/javascript",

            "exec": [

              "pm.test('Practitioner upserted', function () {",

              " pm.expect([200, 201]).to.include(pm.response.code);",

              "});"

            ]

          }

        }

      ]

    },

    {

      "name": "02 - Place order with Specimen (repro)",

      "request": {

        "auth": { "type": "noauth" },

        "method": "POST",

        "header": [{ "key": "Content-Type", "value": "application/fhir+json" }],

        "url": { "raw": "{{remote_fhir_base}}", "host": ["{{remote_fhir_base}}"] },

        "body": {

          "mode": "raw",

          "raw": "{\n \"resourceType\": \"Bundle\",\n \"type\": \"transaction\",\n \"entry\": [\n {\n \"fullUrl\": \"urn:uuid:{{patient_id}}\",\n \"resource\": {\n \"resourceType\": \"Patient\",\n \"id\": \"{{patient_id}}\",\n \"name\": [{ \"family\": \"Repro\", \"given\": [\"Specimen\"] }],\n \"gender\": \"unknown\"\n },\n \"request\": { \"method\": \"PUT\", \"url\": \"Patient/{{patient_id}}\" }\n },\n {\n \"fullUrl\": \"urn:uuid:{{specimen_id}}\",\n \"resource\": {\n \"resourceType\": \"Specimen\",\n \"id\": \"{{specimen_id}}\",\n \"status\": \"available\",\n \"subject\": { \"reference\": \"Patient/{{patient_id}}\" },\n \"type\": {\n \"coding\": [\n { \"system\": \"http://snomed.info/sct\", \"code\": \"258529004\", \"display\": \"Throat swab\" }\n]\n },\n \"collection\": { \"collectedDateTime\": \"2026-08-24T09:00:00Z\" }\n },\n \"request\": { \"method\": \"PUT\", \"url\": \"Specimen/{{specimen_id}}\" }\n },\n {\n \"fullUrl\": \"urn:uuid:{{service_request_id}}\",\n \"resource\": {\n \"resourceType\": \"ServiceRequest\",\n \"id\": \"{{service_request_id}}\",\n \"status\": \"active\",\n \"intent\": \"order\",\n \"subject\": { \"reference\": \"Patient/{{patient_id}}\" },\n \"specimen\": [{ \"reference\": \"Specimen/{{specimen_id}}\" }],\n \"code\": {\n \"coding\": [\n { \"system\": \"http://loinc.org\", \"code\": \"94500-6\", \"display\": \"SARS-CoV-2 RNA panel\" }\n]\n }\n },\n \"request\": { \"method\": \"PUT\", \"url\": \"ServiceRequest/{{service_request_id}}\" }\n },\n {\n \"fullUrl\": \"urn:uuid:{{task_id}}\",\n \"resource\": {\n \"resourceType\": \"Task\",\n \"id\": \"{{task_id}}\",\n \"status\": \"requested\",\n \"intent\": \"order\",\n \"basedOn\": [{ \"reference\": \"ServiceRequest/{{service_request_id}}\" }],\n \"for\": { \"reference\": \"Patient/{{patient_id}}\" },\n \"owner\": { \"reference\": \"Practitioner/{{practitioner_id}}\" },\n \"requester\": { \"reference\": \"Practitioner/{{practitioner_id}}\" }\n },\n \"request\": { \"method\": \"PUT\", \"url\": \"Task/{{task_id}}\" }\n }\n ]\n}",

          "options": { "raw": { "language": "json" } }

        }

      },

      "event": [

        {

          "listen": "prerequest",

          "script": {

            "type": "text/javascript",

            "exec": [

              "function newGuid() { return pm.variables.replaceIn('{{$guid}}'); }",

              "pm.collectionVariables.set('patient_id', newGuid());",

              "pm.collectionVariables.set('specimen_id', newGuid());",

              "pm.collectionVariables.set('service_request_id', newGuid());",

              "pm.collectionVariables.set('task_id', newGuid());"

            ]

          }

        },

        {

          "listen": "test",

          "script": {

            "type": "text/javascript",

            "exec": [

              "pm.test('Transaction Bundle accepted', function () {",

              " pm.expect([200, 201]).to.include(pm.response.code);",

              "});",

              "console.log('task_id=' + pm.collectionVariables.get('task_id'));",

              "console.log('Expected: OpenELIS polls this Task, creates the order, but the resulting');",

              "console.log('electronic_order carries no specimen data, and Add Sample shows no sample type.');"

            ]

          }

        }

      ]

    }

  ]

}

```

**Expected:** the order appears in Incoming Orders, and generating a Lab Number pre-fills the sample type from the Specimen we sent.  
**Actual:** order appears correctly, but “Add Sample” → “Select sample type” is blank, same as if no Specimen had been sent at all.

**Question for the community:** is this expected/by-design (i.e., sample type is _always_ meant to be a manual lab-side confirmation regardless of source), or is this a genuine gap where `ServiceRequest`/`Specimen` data should be threaded through to the order cache and pre-filled?

---

<div class="post-metadata">

**Author:** ![Agaba\_Derrick\_Junior](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.openelis-global.org/agaba_derrick_junior/32/503_2.png) [@Agaba\_Derrick\_Junior](https://talk.openelis-global.org/u/Agaba_Derrick_Junior)\
**Post date:** [August 24, 2026, 10:27am UTC](https://talk.openelis-global.org/t/specimen-data-from-external-fhir-orders-is-never-available-at-accessioning-add-sample-sample-type-always-blank/2394/2 "2026-08-24T10:27:49Z")

</div>

thanks @Bhupesh_Gupta for the question, just to confirm what version of OE are you running ?

---

<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, 1:06pm UTC](https://talk.openelis-global.org/t/specimen-data-from-external-fhir-orders-is-never-available-at-accessioning-add-sample-sample-type-always-blank/2394/3 "2026-08-24T13:06:10Z")

</div>

I am using OpenELIS version 3.2.1.11, currently I am evaluating it for integrating it with our own EMR.

---

<div class="post-metadata">

**Author:** ![ELAI](https://avatars.discourse-cdn.com/v4/letter/e/ac8455/32.png) [@ELAI](https://talk.openelis-global.org/u/ELAI)\
**Post date:** [August 24, 2026, 8:15pm UTC](https://talk.openelis-global.org/t/specimen-data-from-external-fhir-orders-is-never-available-at-accessioning-add-sample-sample-type-always-blank/2394/4 "2026-08-24T20:15:43Z")

</div>

[![](https://canada1.discourse-cdn.com/flex030/uploads/openelisci/original/2X/0/05f979fbe65e72d4bf22f8540a297921a163efe7.jpeg "EMR and LIS order and results exchange between OpenMRS and OpenELIS using FHIR") ](https://www.youtube.com/watch?v=LsHhDrrlvKw)

Could u find this resource use full.

---

<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 25, 2026, 4:09am UTC](https://talk.openelis-global.org/t/specimen-data-from-external-fhir-orders-is-never-available-at-accessioning-add-sample-sample-type-always-blank/2394/5 "2026-08-25T04:09:10Z")

</div>

Yes this is useful and this is working as expected however the demo is using OpenELIS version 2.8 whereas mine is version 3.2.1.11. Seems like it is either broken in 3.2.1.11 or may be my FHIR bundle is not properly configured. Can you please advise on how I can fix it?

---

<div class="post-metadata">

**Author:** ![ELAI](https://avatars.discourse-cdn.com/v4/letter/e/ac8455/32.png) [@ELAI](https://talk.openelis-global.org/u/ELAI)\
**Post date:** [August 25, 2026, 7:01am UTC](https://talk.openelis-global.org/t/specimen-data-from-external-fhir-orders-is-never-available-at-accessioning-add-sample-sample-type-always-blank/2394/6 "2026-08-25T07:01:59Z")

</div>

You dont have any logs when you enter this command  
**docker logs openelisglobal-webapp** ,or **docker logs external-fhir-api**

if any please can share them

---

<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 25, 2026, 10:15am UTC](https://talk.openelis-global.org/t/specimen-data-from-external-fhir-orders-is-never-available-at-accessioning-add-sample-sample-type-always-blank/2394/7 "2026-08-25T10:15:52Z")

</div>

Server side there is no error, the error is in front end refer snapshot below:

 ![OpenELISError](https://canada1.discourse-cdn.com/flex030/uploads/openelisci/original/2X/a/a769a3198a23eab7013e17ec77b52e982383d075.png)

However I verified the patient information is populated properly.

 ![OpenELISPatient](https://canada1.discourse-cdn.com/flex030/uploads/openelisci/original/2X/c/cc14ca24adbf32640cf8d92bf51b4b82203857bb.png)

NOTE: I am trying this for the first time by creating sample FHIR bundle with the help of AI, if you can share a working example of a bundle which I can try out at my end so that I can rule out any issues in FHIR bundle, that will help to further close in on the cause and fix.

---

<div class="post-metadata">

**Author:** ![ELAI](https://avatars.discourse-cdn.com/v4/letter/e/ac8455/32.png) [@ELAI](https://talk.openelis-global.org/u/ELAI)\
**Post date:** [August 26, 2026, 7:08am UTC](https://talk.openelis-global.org/t/specimen-data-from-external-fhir-orders-is-never-available-at-accessioning-add-sample-sample-type-always-blank/2394/8 "2026-08-26T07:08:13Z")

</div>

> **[Home - OpenELIS GLOBAL2 Implementation Guide v0.1.0](https://digi-uw.github.io/openelis-global2-fhir-ig/index.html)**

here is our implementation guide for bundle resources

Can checkout the interoperability with openmrs here

> **[OpenMRS Interoperability - OpenELIS Global Documentation](https://docs.openelisci.org/en/latest/deployomrs/)**
>
> Technical documentation for the OpenELIS Global2

---

<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 26, 2026, 5:34pm UTC](https://talk.openelis-global.org/t/specimen-data-from-external-fhir-orders-is-never-available-at-accessioning-add-sample-sample-type-always-blank/2394/9 "2026-08-26T17:34:27Z")

</div>

The documentation has individual resources like patient, specimen, task, practitioner etc. I need a bundle which contains a combination of these as they are linked together. Would appreciate if you can advise on issue in my original json which I posted while creating topic.

---

<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, 9:43am UTC](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 "2026-08-27T09:43:23Z")

</div>

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:01pm UTC](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 "2026-08-31T13:01:06Z")

</div>

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.
