Terminology in AQL

Current situation

The AQL MATCHES statement may perform a request to a terminology server for validating or expanding a ValueSet. Please see below the alternatives for defining a syntax to be embedded inside AQL MATCHES statement (see https://specifications.openehr.org/releases/QUERY/latest/AQL.html#_matches ).

Proposal

Based on the comments and conversations we have had I propose the following approach (see parameters below). I think it is very independent from any particular terminology system but, of course, the URI/URL may embed logic expressions for implicit ValueSets that the Terminology Server should process but the AQL should not care about. In this approach the URIs/URLs are not AQL concern and I assume they may have some words such as “fhir”, host names, etc. Please comment and criticise freely so we can get closer to a consensus J

SELECT ….

FROM….

WHERE….

code_x MATCHES {terminology://system=http://systema.org/systema?system_version=0.1?valueset=http://somthing.org/vsA/0_1?vs_version=1.2}


Grammar is accessible here:

 

Definition of parameters

  • code_x: the code to check if it belongs to the set of codes represented by the result of the TS request.
  • system: the CodeSystem (terminology system) of code_x
  • system_version: the version of the system
  • valueset: the uri of the valueset used to query if code_x belongs to.
  • vs_version: the version of the valueset

In Example 1. code_x belongs to system A. System A has uri http://systemA.org/systemA), the version of system A considered is 0.1. The valueset uri is http://somthing.org/vsA. The version of the VS is 1.2.

There are two main scenarios:

  1. Explicit ValueSets (i.e. in a nutshell an explicit VS is cached list of codes with an id and some metadata like system, version, etc.):
terminology://system=http://snomed.info/sct/32506021000036107?system_version=20130531?valueset=http://highmed.org/24?vs_version=2.52

       2.Implicit ValueSets

terminology://system=http://snomed.info/sct/32506021000036107?system_version=20130531?valueset=http://snomed.info/sct?fhir_vs=isa/50697003

In implicit ValueSets there is not a specific identified resource exposed by the terminology server that corresponds to the ValueSet. The ValueSet should be created “on demand” by the terminology server based on the logic expression specified in the URI.

Aspects to consider

QUESTION 1) An outstanding question is... if we just consider that the only operation will be $validate (i.e. validate if code is in the ValueSet and the request to the server only returns a boolean true/false) as per Diego (https://openehrspecs.slack.com/archives/C2CD84RUL/p1547819288129100 ), or we will also accept $expand (the server returns a list of codes, the format of the codes needs to be determined as per the discussion in https://openehrspecs.slack.com/archives/C2CD84RUL/p1549550758046800)??

If we go only for validate, then the current matches syntax should be slightly modified (instead of matches it should be something like “VALIDATE code_x IN {terminology://……..}”)??

If so, any proposals??

QUESTION 2) If the request from AQL to a TS is always seen as an $expansion (i.e. return the full list of codes in the VS), the operation would return a list of codes and we need some metadata for them to be able to determine to which system they belong to etc. An example is


SELECT….

FROM…
WHERE….

Code_x MATCHES {...........expansion…………..}


Expansion returned = {G70, G71, G72, G72.1, G72.2… G73,....G73.7 }


Now, let´s suppose we were developing the AQL processor and we needed to do the check of the MATCHES statement to return some instances..., which data types do these “codes” have? Are they only Strings? If they are only Strings and the ValueSet expanded contains codes from several CodeSystems, evaluate the “code_x MATCHES{....}” clause may be ambiguous. We know that the code_x belongs to CodeSystem A (because of the system parameter in the request), but we do not know if a code returned in the expansion belongs to that CodeSystem or not, the same string may represent different things in different CodeSystems or different versions of the CodeSystem.

In JAVA words, we need to @override the Object.equals comparison or implement the java.lang.Comparable<CodeTypeInOpenehr> interface so comparison of codes is not only based in characters comparison; but it also compares contextual properties such as system etc. For that, we more contextual properties coming back for each code in the expansion of the ValueSet.

Alternatives have been proposed by Tom, Bjorn, and Ian in (https://openehrspecs.slack.com/archives/C2CD84RUL/p1549554234061500 , https://openehrspecs.slack.com/archives/C2CD84RUL/p1549552584056700?thread_ts=1549550758.046800&cid=C2CD84RUL , https://openehrspecs.slack.com/archives/C2CD84RUL/p1549551743054400?thread_ts=1549550758.046800&cid=C2CD84RUL )

EXAMPLES IN FHIR AND THE PROPOSAL FOR OPENEHR

EXAMPLES EXPLICIT VALUE SETS:

Example request 1:

Fhir:

{{url}}/ValueSet/$validate-code?system=http://loinc.org&code=45276-3&url=http:/loinc.org/vsac/BloodCulture&display=Bacteria identified in Blood by Anaerobe culture 25 degree C incubation

(parameters display, operation) are not the business of AQL but are left for completeness)


openEHR:

terminology://system=http://loinc.org?system_version=2.65?valueset=http://highmed.org/24?vs_version=1.0.5


Example request 2:

Fhir:


{{url}}/ValueSet/$validate-code?system=http://snomed.info/sct&code=30346009&url=http://vsac.highmed.org/vsac/episodes&display=Evaluation and management of established outpatient in office or other outpatient facility

 

openEHR:

 

terminology://system=http://snomed.info/sct?system_version=30346009?valueset=http://vsac.highmed.org/vsac/episodes?vs_version=0.1


Example request 3: (validating using the full snomed as a code system)

 

Fhir:

{{url}}/ValueSet/$validate-code?system=http://snomed.info/sct&code=122298005&url=http://snomed.info/sct?fhir_vs&display=Astrovirus RNA assay


openEHR:

terminology://system=http://snomed.info/sct?system_version=30346009?valueset=http://vsac.highmed.org/vsac/episodes?vs_version=0.1


Example request 4:(ICD full ICD as VS)

 

Fhir:


{{url}}/ValueSet/$validate-code?system=http://icd10.who.org&url=http://vsac.nlm.nih.gov/malignantneoplasms&code=C15.8&display=foo


openEHR:


terminology://system=http://snomed.info/sct?system_version=30346009?valueset=http://vsac.highmed.org/vsac/episodes?vs_version=0.1


EXAMPLES IMPLICIT VALUE SETS:


Example request 5:


Fhir

 

{{url}}/ValueSet/$expand?url=http://hl7.org/fhir/sid/icd-10-en/vs?url=http://hl7.org/fhir/sid/icd-10-en/vs?fhir_vs=is-a/G70&fhir_vs=is-a/G70


openEHR

terminology://system=http://hl7.org/fhir/sid/icd-10-en?system_version=2016?valueset=http://hl7.org/fhir/sid/icd-10-en/vs?fhir_vs=isa/G70


(note this request relies on reasoning over ICD-10 that is not ontology-based, some vendors have implemented it but implicit ValueSets over ICD10 have not been identified as necessary by FHIR yet https://www.hl7.org/fhir/icd.html#4.3.11.6 )


Example request 6:

 

Fhir

 

{{url}}/ValueSet/$expand?url=http://snomed.info/sct?fhir_vs=ecl/<<50697003

 

Version is optional and we should think if system should be optional

 

openEHR

 

terminology://system=http://snomed.info/sct/32506021000036107?system_version=20130531?valueset=http://snomed.info/sct?fhir_vs=ecl/<<50697003



Example request 7 (by reference set):


Fhir

 

{{url}}/ValueSet/$expand?url=http://snomed.info/sct/900000000000207008/version/20170731?fhir_vs=refset/142321000036106

 

openEHR

 

terminology://system=http://snomed.info/sct/900000000000207008/version?system_version=20170731?valueset=http://snomed.info/sct/900000000000207008/version/20170731?fhir_vs=refset/142321000036106