Stream: cql
Topic: Arbitrary FHIR Contexts like Specimen
Alexander Kiel (Aug 19 2019 at 16:01):
@Bryn Rhodes We like to count Specimens using $evaluate-measure and CQL. If I understand the mechanics of $evaluate-measure correctly, we need to specify a context of Specimen in CQL in order to be able to have a InInitialPopulation
expression which is a predicate of Specimen in this case. In the CQL Authors Guide v1.4.1 under 1.6 Context, the contexts Patient and Practitioner are only examples. According to:
Depending on different needs, models may define any context appropriate to their use case, but should identify a default context that is used when authors do not declare a specific context.
contexts for all FHIR Resource types should be possible.
Currently I get the following error with info.cqframework/cql-to-elm "1.4.6"
:
Could not resolve context name Specimen in model FHIR.
Would it be possible and the right idea to allow every FHIR Resource type as context in the model FHIR?
Bryn Rhodes (Aug 19 2019 at 18:41):
We had planned on using CompartmentDefinition to specify the allowed contexts, because in addition to the resource type, we need to know the relationships to other resources (and that information needs to be part of the underlying model so the data access layer is capable of evaluating the context-specific query).
Bryn Rhodes (Aug 19 2019 at 18:42):
So a server could define a CompartmentDefinition to support Specimen and then bring that in to the CQL with a specific model info.
Bryn Rhodes (Aug 19 2019 at 18:42):
But specifying every FHIR Resource type would require CompartmentDefinitions for every resource.
Alexander Kiel (Aug 20 2019 at 05:55):
Ok I can supply the CompartmentDefinition myself? I‘ll have a look at it.
Bryn Rhodes (Aug 20 2019 at 05:58):
Well, yes, assuming you have a server that knows how to dynamically apply a CompartmentDefinition :)
Alexander Kiel (Aug 20 2019 at 09:17):
I have my own Server and I see that CompartmentDefinition is the thing I need for the context. But I don't see the class CompartmentDefinition used in cql-to-elm. All I need is the cql-to-elm translater translaing my CQL with specimen context into ELM. The rest I do myself.
Bryn Rhodes (Aug 20 2019 at 19:43):
Yeah, the translator would not reference CompartmentDefinition, the ModelInfo would have that information represented using ContextInfo (so you could say context Specimen
Bryn Rhodes (Aug 20 2019 at 19:44):
In other words, this would need to be a change to the FHIR model info file used by the translator.
Alexander Kiel (Aug 21 2019 at 13:43):
Thanks I'm able to have a Specimen context by adding the following into fhir-modelinfo-4.0.0.xml
and load it with CqlTranslator.loadModelInfo
:
<ns4:contextInfo name="Patient" keyElement="id" birthDateElement="birthDate.value"> <ns4:contextType name="FHIR.Patient"/> </ns4:contextInfo> <ns4:contextInfo name="Specimen" keyElement="id"> <ns4:contextType name="FHIR.Specimen"/> </ns4:contextInfo>
First queries like
library Retrieve using FHIR version '4.0.0' include FHIRHelpers version '4.0.0' codesystem SampleMaterialType: 'https://fhir.bbmri.de/CodeSystem/SampleMaterialType' context Specimen define InInitialPopulation: Specimen.type.coding ~ Code 'whole-blood' from SampleMaterialType
translate.
@Bryn Rhodes What would be the way to get such special contexts into the official lib?
Bryn Rhodes (Aug 21 2019 at 16:36):
For the FHIR model info, we derive that from the FHIR specification, so a compartment definition there would be the driver for that.
Bryn Rhodes (Aug 21 2019 at 16:36):
What are the relationships to other resources?
Alexander Kiel (Aug 22 2019 at 08:05):
From Specimen we need relationships to Patient and Organization at the Moment. But in the ModelInfo I don't see any context specific relationships specified. Where can I find the transformation tool from FHIR StructureDefinitions and CompartmentDefinitions to ModelInfo?
Bryn Rhodes (Aug 22 2019 at 09:30):
Tooling to generate ModelInfo from StructureDefinitions is here: https://github.com/cqframework/cqf-tooling/blob/master/src/main/java/org/opencds/cqf/modelinfo/StructureDefinitionToModelInfo.java
Bryn Rhodes (Aug 22 2019 at 09:32):
The CompartmentDefinition processing isn't automated yet; but would be quite easy to add to that, just haven't gotten there yet. There is a RelationshipInfo element in the ModelInfo that specifies how contexts are related to resources in the model. Would just be a matter of adding relationship infos generated from the CompartmentDefinition.
Alexander Kiel (Sep 02 2019 at 13:20):
Should the InInitialPopulation
expression in this library interpreted as:
"Has the subject of the specimen, currently in context, the gender male?"
If so, the retrieve expression [Patient]
returns the one subject of the specimen in context - right?
At the end, I'll need a CompartmentDefinition for Specimen - I know.
library Retrieve using FHIR version '4.0.0' include FHIRHelpers version '4.0.0' context Specimen define InInitialPopulation: from [Patient] P where P.gender = 'male'
Last updated: Apr 12 2022 at 19:14 UTC