hapifhir / hapi-fhir

🔥 HAPI FHIR - Java API for HL7 FHIR Clients and Servers
http://hapifhir.io
Apache License 2.0
2.01k stars 1.31k forks source link

NHS UK FHIR Terminology Server - HAPI FHIR Remote Terminology Service Validation #3113

Open rprobinson opened 2 years ago

rprobinson commented 2 years ago

Environment

HAPI FHIR Version: 5.4.0 FHIR version: R4 OS: Ubuntu 18

Problem

I work for NHS Digital and develop a tool which suppliers use for testing their systems. It uses the HAPI FHIR Validation library to validate incoming requests and I am expanding its functionality to use the remote NHS UK FHIR terminology Server. I am experiencing an issue with the HAPI FHIR Validation library whereby the periodUnit value="h" fails validation. The example message used is from the NHS Digital examples for Interoperability Medicines:

<MedicationDispense xmlns="http://hl7.org/fhir">
    <id value="b6412185-a79e-465d-97ce-44b8fbe31428" />
    <contained>
        <Medication>
            <id value="med1" />
            <code>
                <coding>
                    <system value="http://snomed.info/sct" />
                    <code value="275811000001103" />
                    <display value="Atenolol 100mg tablets (Actavis UK Ltd)" />
                </coding>
            </code>
        </Medication>
    </contained>
    <status value="in-progress" />
    <medicationReference>
        <reference value="#med1" />
    </medicationReference>
    <subject>
        <identifier>
            <system value="https://fhir.nhs.uk/Id/nhs-number" />
            <value value="9999999999" />
        </identifier>
    </subject>
    <quantity>
        <value value="28" />
        <unit value="tablet" />
        <system value="http://snomed.info/sct" />
        <code value="428673006" />
    </quantity>
    <dosageInstruction>
        <timing>
            <repeat>
                <frequency value="1" />
                <period value="6" />
                <periodUnit value="h" />
            </repeat>
        </timing>
        <route>
            <coding>
                <system value="http://snomed.info/sct" />
                <code value="26643006" />
                <display value="Oral" />
            </coding>
        </route>
        <doseAndRate>
            <doseQuantity>
                <value value="1" />
                <unit value="tablet" />
                <system value="http://snomed.info/sct" />
                <code value="428673006" />
            </doseQuantity>
        </doseAndRate>
    </dosageInstruction>
</MedicationDispense>

When I use the following Validation Support Modules: DefaultProfileValidationSupport PrePopulatedValidationSupport InMemoryTerminologyServerValidationSupport CommonCodeSystemsTerminologyService SnapshotGeneratingValidationSupport

The validation succeeds with no issues.

However when I add the RemoteTerminologyServiceValidationSupport module (using the NHS UK FHIR Terminology Server) the validation of the periodUnit fails with:

    <issue>
        <severity value="error"/>
        <code value="processing"/>
        <diagnostics value="The value provided ('h') is not in the value set http://hl7.org/fhir/ValueSet/units-of-time|4.0.1 (http://hl7.org/fhir/ValueSet/units-of-time), and a code is required from this value set) (error message = Unknown code 'h')"/>
        <location value="MedicationDispense.dosageInstruction[0].timing.repeat.periodUnit"/>
        <location value="Line 1, Col 798"/>
    </issue>

On the Remote Terminology Server, all the Snomed and medication dispense status codes otherwise pass.

Evidence

I have been in discussion with those who run the UK FHIR Terminology Server who have provided server-side evidence for this issue (also in viewing my HTTP traffic locally):

For each snomed code the RemoteTerminologyServiceValidationSupport module makes 3 outbound requests made to the remote terminology server:

GET /staging/fhir/CodeSystem?url=http%3A%2F%2Fsnomed.info%2Fsct ...
GET /staging/fhir/ValueSet?url=http%3A%2F%2Fsnomed.info%2Fsct ...
POST /staging/fhir/CodeSystem/$validate-code ...

However for the units-of-measure it makes just one:

GET /staging/fhir/CodeSystem?url=http%3A%2F%2Funitsofmeasure.org ...

Is it relevant that the unitsofmeasure CodeSystem doesn’t have an implicit ValueSet specified as part of the resource (it is valid to not specify one)...

Is the order of adding the validation support modules to the ValidationSupportChain significant? (I have followed the recipes on the documentation but it seems that the remote terminology support module is called before the CommonCode systems module irrespective of order)

Best regards Richard Robinson

rprobinson commented 2 years ago

I'm using the staging server https://ontology.nhs.uk/staging/fhir which I'm informed does have the CodeSystem

KevinMayfield commented 2 years ago

Yes, I get a positive result for GET https://ontology.nhs.uk/staging/fhir/CodeSystem/$lookup?code=h&system=http://unitsofmeasure.org

KevinMayfield commented 2 years ago

This isn't the call to validate is it?

https://ontology.nhs.uk/staging/fhir/CodeSystem/$validate-code?code=h&url=http://unitsofmeasure.org

This works and what I would have expected for the validation request (if it is making just the one call). Which returns

{ "resourceType": "Parameters", "parameter": [ { "name": "result", "valueBoolean": true }, { "name": "display", "valueString": "h" } ] }

rprobinson commented 2 years ago

Yes I think it is the the call that the RemoteTerminologyServiceValidationSupport should be making but doesn't