How to set external terminology validation

I’m trying to use external terminology validation, right now there is no validation as I’m able to set any value. The default configuration ( 8. Terminology Validation — EHRbase documentation) the validation.external-terminology.enabled=false by default in the application.yml, how can I set that value to true to have external terminology validation?

You can set additional properties via the .env.ehrbase file, including with a Docker instance - you will need to restart the container though.

The .env files require a particular format to be passed through to Spring.

Probably VALIDATION_EXTERNAL_TERMINOLOGY_ENABLED = true

Hi Ian,
is it possible to set that variable having the docker deployed?

Thanks Ian, I have fixed it!
Now when I’m trying to set a coded text of the external terminology I don’t know why all codes are rejected as if they were not in the ValueSet. I follow the documentation and I’m setting the values:

DvCodedText codedText = new DvCodedText();
CodePhrase codePhrase = new CodePhrase();
codePhrase.setTerminologyId(new TerminologyId(“<status value="draft"/> <experimental value="true"/> <publisher value="FHIR Project team"/> <contact> <telecom> <system value="url"/> <value value="http://hl7.org/fhir"/> </telecom> </contact> <description value="Example value set for Condition/Problem/Diagnosis codes."/> <jurisdiction> <coding> <system value="http://unstats.un.org/unsd/methods/m49/m49.htm"/> <code value="001"/> <display value="World"/> </coding> </jurisdiction> <copyright value="This resource includes content from SNOMED Clinical Terms® (SNOMED CT®) which is copyright of the International Health Terminology Standards Development Organisation (IHTSDO). Implementers of these specifications must have the appropriate SNOMED CT Affiliate license - for more information contact http://www.snomed.org/snomed-ct/get-snomed-ct or info@snomed.org"/> <compose> <include> <system value="http://snomed.info/sct"/> <filter> <property value="concept"/> <op value="is-a"/> <value value="404684003"/> </filter> </include> <include> <system value="http://snomed.info/sct"/> <concept> <code value="160245001"/> <display value="No current problems or disability"/> </concept> </include> </compose> </ValueSet>”));
codePhrase.setCodeString(“4637005”);
codedText.setDefiningCode(codePhrase);
codedText.setValue(“Intrahepatic cholestasis”);

And the creation of the composition is in the same format as appears in the documentation.

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