How to set external terminology validation

The terminologyID should just be the FHIT system value for Snomed CT

codePhrase.setTerminologyId(new TerminologyId(“http://snomed.info/sct”)

I have tried, with this Value Set of FHIR
codePhrase.setTerminologyId(new TerminologyId(“http://hl7.org/fhir/ValueSet/condition-code”));
codePhrase.setCodeString(“192008”);
codedText.setDefiningCode(codePhrase);
codedText.setValue(“Congenital syphilitic hepatomegaly”);

and I got this error:
Exception in thread “main” org.ehrbase.client.exception.WrongStatusCodeException: Wrong Status code. Expected: [200, 201, 204]. Got: 422. Error message: {“error”:“Unprocessable Entity”,“message”:“/content[openEHR-EHR-OBSERVATION.externalterm.v0]/data[at0001]/events[at0002]/data[at0003]/items[at0004]/value: Failed to validate DvCodedText{defining_code=http://hl7.org/fhir/ValueSet/condition-code::192008, value=Congenital syphilitic hepatomegaly}, : The value 192008 does not match any option from value set http://hl7.org/fhir/ValueSet/condition-code”}

No - the terminologyID is just as I indicated above - this tells the system that it is a SNOMED CT code.

Can you share the template you are using- preferably as a template fileset?

I can’t upload the template fileSet, I send you the .opt

ExternalTERM.opt (16.1 KB)

1 Like

That looks correct in terms of the template pointing to the correct Valueset

<referenceSetUri>terminology://fhir.hl7.org/ValueSet/$expand?url=http://hl7.org/fhir/ValueSet/condition-code</referenceSetUri>

Try what I suggested…

codePhrase.setTerminologyId(new TerminologyId(“http://snomed.info/sct”));
codePhrase.setCodeString(“192008”);
codedText.setDefiningCode(codePhrase);
codedText.setValue(“Congenital syphilitic hepatomegaly”);

I tried what you suggested:

codePhrase.setTerminologyId(new TerminologyId(“http://snomed.info/sct”));
codePhrase.setCodeString(“192008”);
codedText.setDefiningCode(codePhrase);
codedText.setValue(“Congenital syphilitic hepatomegaly”);

and I got the same error:
Exception in thread “main” org.ehrbase.client.exception.WrongStatusCodeException: Wrong Status code. Expected: [200, 201, 204]. Got: 422. Error message: {“error”:“Unprocessable Entity”,“message”:“/content[openEHR-EHR-OBSERVATION.externalterm.v0]/data[at0001]/events[at0002]/data[at0003]/items[at0004]/value: Failed to validate DvCodedText{defining_code=http://snomed.info/sct::192008, value=Congenital syphilitic hepatomegaly}, : The value 192008 does not match any option from value set http://hl7.org/fhir/ValueSet/condition-code”}

Is your CDR actually hooked up to a physical FHIR terminology service? That would be a local configuration in your Ehrbase.

The templated constraint is a virtual URI which would have to be resolved to an actual physical FHIR TS which can resolve the is_a relationship within the Valueset.

terminology://fhir.hl7.org/ValueSet/$expand?url=http://hl7.org/fhir/ValueSet/condition-code

I have the default configuration in the application.yml:

External Terminology Validation Properties
validation:
external-terminology:
enabled: false
provider:
fhir:
type: FHIR
url: https://r4.ontoserver.csiro.au/fhir/

And I have set in the .env.ehrbase file the variable
VALIDATION_EXTERNAL_TERMINOLOGY_ENABLED=true
to enable the external therminology validation

1 Like

Hi Ian,

We want to check that the code we are using is part of a ValueSet that is a SubSet of SNOMED-CT.

My understanding is that if we specify the terminology id as http://snomed.info/sct, the check is done against the full terminology, not the SubSet. Is that correct?

My understanding is that if we specify the terminology id as http://snomed.info/sct, the check is done against the full terminology, not the SubSet. Is that correct?

AFAK that is not correct. In this case ‘http://snomed.info/sct
is just being used as the namespace/identifier for the term you are recording

i.e defining_code=http://snomed.info/sct::192008 = this is term 192008 from SNOMED CT.

It is the constraint in the template that points to you wanting to check that this code is in the hl7.org/fhir/ValueSet/condition-code Valueset. on the Ontoserver instance

That’s all looking correctly setup to me. Perhaps @luis_marco or @birger.haarbrandt can advise? I have not played with the ehrbase/FHIR TS hookup myself.

It is clearly trying to do the validation so the .env is kicking in correctly.

OK. Understood.

Thanks

Try searching on this term.

{
                "system": "http://snomed.info/sct",
                "code": "708094006",
                "display": "Acute exacerbation of intrinsic asthma"
            },
  • I could not find the term you looked for in the Valueset returned from Ontoserver - ? there is a paging issue
curl --location 'https://r4.ontoserver.csiro.au/fhir//ValueSet/$expand?url=http%3A%2F%2Fhl7.org%2Ffhir%2FValueSet%2Fcondition-code'

I cant’ get it to work either, sending

    "externalterm/externalterm/any_event:0/diagnostico|terminology": "http://snomed.info/sct",
    "externalterm/externalterm/any_event:0/diagnostico|value": "708094006",
    "externalterm/externalterm/any_event:0/diagnostico|code": "Acute exacerbation of intrinsic asthma",

Error:

OBSERVATION.externalterm.v0]/data[at0001]/events[at0002]/data[at0003]/items[at0004]/value: Failed to validate DvCodedText{defining_code=SNOMED-CT::Acute exacerbation of intrinsic asthma, value=708094006}, : The value Acute exacerbation of intrinsic asthma does not match any option from value set http://hl7.org/fhir/ValueSet/condition-code"

Might be worth reporting on ehrBase Github

I think the example given at ehrBase Terminology validation

is misleading.

It says

"value": {
    "_type": "DV_CODED_TEXT",
    "value": "Buccal",
    "defining_code": {
        "_type": "CODE_PHRASE",
        "terminology_id": {
            "_type": "TERMINOLOGY_ID",
            "value": "http://hl7.org/fhir/ValueSet/surface"
        },
        "code_string": "B"
    }
}

but I think it should be

"value": {
    "_type": "DV_CODED_TEXT",
    "value": "Buccal",
    "defining_code": {
        "_type": "CODE_PHRASE",
        "terminology_id": {
            "_type": "TERMINOLOGY_ID",
            "value": "http://snomed.info/sct"
        },
        "code_string": "B"
    }
}

I think it’s not working for you because you’ve swapped code and value values.
Should be value=“Acute exacerbation of intrinsic asthma” and code_string=“708094006”

1 Like

It’s definitely as you suggested, with http://snomed.info/sct in the terminology id. Now it’s working for me!
Many thanks for your time Ian!

Ooops!! Well spotted.

Have you tried querying that data back?

Yes, I have been able to query the data!

1 Like

Can you post the AQL? Just curious!!

I have done it like this:

Query<Record2<UUID, String>> query = Query.buildNativeQuery("select  e/ehr_id/value, o/data[at0001]/events[at0002]/data[at0003]/items[at0004]/value/defining_code/code_string from EHR e contains COMPOSITION a [openEHR-EHR-COMPOSITION.externalterm.v0] contains OBSERVATION o [openEHR-EHR-OBSERVATION.externalterm.v0]", UUID.class, String.class);`
List<Record2<UUID, String>> result = openEhrClient.aqlEndpoint().execute(query);
result.forEach(res->{System.out.println(res.value1() + " "+ res.value2());});
1 Like