Stream: cql
Topic: models of Reference types
Georg Fette (Feb 07 2019 at 08:25):
Hello,
When using the xsd-to-model-converter in vanilla mode on the "fhir-single.xsd" all References with a scope (e.g. "Reference(Patient|Group)") are mapped to the unscoped type Reference. When I parse a CQL-query including such a reference (e.g. "[Patient] A with [Encounter] B such that B.subject = A") I get a parse exception stating that "Reference" is not compatible with "Patient". When I rename the type of "subject" in the model file to "System.Any" the parsing works. What is the advice to handle References in CQL ? Should all usages of References be changed to System.Any in the model ? I could live with the loss of the Reference-scope, although it would be nice to keep that scope.
Greetings
Bryn Rhodes (Feb 08 2019 at 22:58):
Hi @Georg Fette , since references in FHIR are a structure, changing them to System.Any would work for the translator (because it effectively disables type checking for that comparison), but it would mean that the implementation would be given the task of resolving what "reference(patient) = Patient" means.
With a model that represents FHIR directly, you could say something like "[Patient] A with [Encounter] B such that GetId(B.subject.reference) = A.id", where GetId is a function that gets the tail of a URI.
The approach I've been working towards is to instead have the model info specify reference attributes as attributes of the referenced types directly. So "subject : Reference(Patient | Group)" would be represented in the model info as "subject : Patient | Group". This gives the translator the opportunity to perform the type checking, but still pushes the resolution of the reference to the implementation.
Last updated: Apr 12 2022 at 19:14 UTC