Stream: cql
Topic: accessing library identifier in cql code
Vasyl Herman (Jun 21 2021 at 14:10):
Hello, Folks!
Is there a way to access library.identirier.id
in cql
code.
image.png
I'd like to define "Measure name", meaning whatever I set after library
it would reflect in "Measure name" definition:
library TEST_Logic version '0.0.0'
using FHIR version '4.0.1'
context Patient
define "Measure name":
identifier.id // TEST_Logic
Thanks!
Chris Moesel (Jun 21 2021 at 18:50):
@Vasyl Herman -- that's definitely an interesting idea, but AFAIK CQL does not insert any implicit definitions to reference that information. Contexts sometime insert an implicit definition (e.g. the Patient
context inserts a Patient
definition) -- but I don't think there is any mechanism that exposes library metadata like the identifier or version for use in the CQL logic itself. @Bryn Rhodes -- correct if I'm wrong (i.e., if you snuck something like this in there without me noticing :wink: )
Corey Sanders (Jun 21 2021 at 20:01):
I'm fairly certain this doesn't exist in the Java engine. In the case where you have libraries referencing other libraries, it isn't completely clear to me what you would even want it to return. If you know that you always want a constant value, though, you could simulate the behavior by defining an input parameter that is echoed back out in a define.
library TEST_Logic version '0.0.0'
using FHIR version '4.0.1'
parameter LibName default 'Unknown'
context Patient
define "Measure name":
"LibName"
Bryn Rhodes (Jun 22 2021 at 15:30):
No, there's nothing like this in the spec now. Feel free to submit a tracker if it's a feature that's really needed, but Corey's solution sounds like a better approach to me.
Michael Riley (Jun 22 2021 at 18:08):
Plus one on this feature from me as well, since oftentimes a client user doesn't have the fhir patient id, they have an identifier that.... identifies the patient such as an MRN or an SSN. Would help with interoperability to client systems.
JP (Jun 22 2021 at 18:28):
The CQL library identifiers (as in Vasyl's example) which exist in CQL/ELM are actually a different thing than Patient identifiers which exist in FHIR despite having the same name. You do have access to Patient identifiers. Something like this would do it:
library Test version '1.0.0'
using FHIR version '4.0.1'
include FHIRHelpers version '4.0.1'
context Patient
define "Identifier":
Patient.identifier I
return Tuple { assigner : I.assigner.display, value : I.value}
{
"resourceType": "Patient",
"id": "test",
"identifier": [
{
"use": "usual",
"type": {
"coding": [
{
"system": "http://terminology.hl7.org/CodeSystem/v2-0203",
"code": "MR"
}
]
},
"system": "urn:oid:1.2.36.146.595.217.0.1",
"value": "12345",
"period": {
"start": "2001-05-06"
},
"assigner": {
"display": "Acme Healthcare"
}
}
],
"active": true,
"name": [
{
"use": "official",
"family": "Chalmers",
"given": [
"Peter",
"James"
]
}],
"gender": "male",
"birthDate": "1974-12-25"
}
Patient=Patient(id=test)
Identifier=[Tuple {
"assigner": Acme Healthcare
"value": 12345
}]
Vasyl Herman (Jun 28 2021 at 12:06):
Thank all of you guys!
Could I ask? Is it correct way to retrieve a Patient's Social Security Number:
define "SSN":
(singleton from (
Patient.identifier identifier
where identifier.system.value = 'http://hl7.org/fhir/sid/us-ssn')).value.value
Or is there more elegant way?
Vasyl Herman (Jun 28 2021 at 12:50):
I was able to shape my query with return
but I am not sure I am doing right:
define "SSN":
(singleton from (
Patient.identifier identifier
where identifier.type.coding in Code {code: 'SS', system: 'http://terminology.hl7.org/CodeSystem/v2-0203', display: 'Social Security Number'}
)) I
return I.value.value
Bryn Rhodes (Jun 28 2021 at 17:36):
Hi @Vasyl Herman , best practice would be to define a codesystem and code for referencing the SS
code from the v2-0203 code system. I also wonder whether using the system
of the identifier and specifying that it be http://hl7.org/fhir/sid/us-ssn
would work? That's more a content question though.
Bryn Rhodes (Jun 28 2021 at 17:38):
For accessing the identifier, that's correct syntax, but you could use FHIRHelpers to avoid the .value accessors:
define "SSN":
(singleton from (
Patient.identifier I
where I.system = 'http://hl7.org/fhir/sid/us-ssn'
)).value
Vasyl Herman (Jun 28 2021 at 17:57):
@Bryn Rhodes, the sample above gives me an Object like that:
Screenshot-2021-06-28-at-20.54.51.png
Vasyl Herman (Jun 28 2021 at 18:11):
I tried to defide a codesystem and code for referensing the SS
like so:
codesystem "IdentifierType": 'http://terminology.hl7.org/CodeSystem/v2-0203'
code "Social Security Number": 'SS' from "IdentifierType" display 'Social Security Number'
context Patient
define "SSN":
(singleton from (
Patient.identifier identifier
where identifier.type.coding in "Social Security Number"
)).value.value
But there is a downside, it is working unless you have all three keys matching in a code
Object of Patient.identifier.type.coding[]: system
, code
and display
. If you remove the display
either from the code definition or a Patient's bundle it returns null
Vasyl Herman (Jun 28 2021 at 18:15):
I also wonder why nither
where identifier in "Social Security Number"
nor
where identifier type in "Social Security Number"
doesn't work for an identifier as it does for a regular FHIR resource say Enconter
?
Bryn Rhodes (Jun 28 2021 at 18:31):
When performing terminology comparisons, use the equivalent operator (~
), which only compares the code
and system
elements (whereas =
compares all attributes, including display
).
Bryn Rhodes (Jun 28 2021 at 18:33):
As far as where identifier in "Social Security Number"
, that feels like a different operation and if we overloaded in
to support that it may lead to confusion, what you're saying there is more something like identifier _is_ a Social Security Number, where in that context "is" means "has a system of Social Security Number".
Bryn Rhodes (Jun 28 2021 at 18:34):
For the type in "Social Security Number"
case, if you defined "Social Security Number" as a ValueSet with any known codes for describing Social Security Number, that would work.
Last updated: Apr 12 2022 at 19:14 UTC