Stream: cql
Topic: Patient Operators, applicable in all data models?
Adam Rodriguez (May 30 2019 at 19:32):
Hello @Bryn Rhodes , @Chris Moesel ,
Another inquiry today from me - this time about Patient operators and whether or not they are applicable to all data models.
Reference, section 5.8.4 in: https://cql.hl7.org/02-authorsguide.html#clinical-operators
I'm interested in creating an initial population of patients <= 18 years of age. I see that there are operators such as 'AgeInYearsAt(X)' and 'AgeInYears()' that are available.
For example, given that a MeasurementPeriod was pre-defined:
define InDemographic:
AgeInYearsAt(start of MeasurementPeriod) >= 16
and AgeInYearsAt(start of MeasurementPeriod) < 24
Questions:
1. If I were using the FHIR data model, would either 'AgeInYearsAt(X)' or 'AgeInYears()' inherently know to look for the Patient.birthDate path in FHIR?
2. If not, how would I incorporate the Patient.birthDate path into an Initial Population definition?
As always, your time and guidance are much appreciated!
Patient Operators, applicable in all data models?
Chris Moesel (May 30 2019 at 20:09):
1. If I were using the FHIR data model, would either 'AgeInYearsAt(X)' or 'AgeInYears()' inherently know to look for the Patient.birthDate path in FHIR?
Yes. The FHIR model info actually specifies the patientBirthDatePropertyName
as seen here:
https://github.com/cqframework/clinical_quality_language/blob/master/Src/java/quick/src/main/resources/org/hl7/fhir/fhir-modelinfo-3.0.0.xml#L8
CQL uses this information to support the age-based queries. The CQL spec discusses this feature here:
https://cql.hl7.org/07-physicalrepresentation.html#data-model-references
2. If not, how would I incorporate the Patient.birthDate path into an Initial Population definition?
As noted above, you'll get this for free. But if you're interested in how you'd do it otherwise, you can use the CalculateAgeIn[X]At
functions as specified here:
https://cql.hl7.org/09-b-cqlreference.html#calculateage
define InDemographic: CalculateAgeInYearsAt(Patient.birthDate.value, start of MeasurementPeriod) >= 16 and CalculateAgeInYearsAt(Patient.birthDate.value, start of MeasurementPeriod) < 24
Adam Rodriguez (May 31 2019 at 01:51):
Thank you @Chris Moesel for the great explanation. Knowing the "long form" version of calculating age is great to keep in my back pocket. Though, I think I'll take advantage of the patient operators whenever possible :)
Last updated: Apr 12 2022 at 19:14 UTC