diff --git a/input/cql/ProfilePatterns.cql b/input/cql/ProfilePatterns.cql index d79bfc2c..8ec55fd7 100644 --- a/input/cql/ProfilePatterns.cql +++ b/input/cql/ProfilePatterns.cql @@ -56,10 +56,26 @@ define CommunicationNotDone: define CommunicationRequest: [CommunicationRequest] -// QICoreCondition -// @profile: http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition +// QICore 4.1.1 +//// QICoreCondition +//// @profile: http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition +//define Condition: +// [Condition] + +// QICore 5.0.0 +// QICoreConditionProblemsHealthConcerns +// @profile: http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition-problems-health-concerns define Condition: - [Condition] + [Condition] Condition + where Condition.hasCategory("problem-list-item") + or Condition.hasCategory("health-concern") + +// QICore 5.0.0 +// QICoreConditionEncounterDiagnosis +// @profile: http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition-encounter-diagnosis +define EncounterDiagnosis: + [Condition] Condition + where Condition.hasCategory("encounter-diagnosis") // QICoreCoverage // @profile: http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-coverage @@ -274,18 +290,68 @@ define ObservationCancelled: [Observation] O where O.status = 'cancelled' -// FHIR Vital Signs +// QICoreLaboratoryResultObservation +// @profile: http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-observation-lab +define LaboratoryResultObservation: + [Observation] O + where O.status in { 'registered', 'preliminary', 'final', 'amended', 'corrected' } + and O.isLaboratory() + +// QICoreObservationClinicalTestResult +// @profile: http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-observation-clinical-test +define ObservationClinicalTestResult: + [Observation] O + where O.status in { 'registered', 'preliminary', 'final', 'amended', 'corrected' } + and O.isCliicalTest() + +// QICoreObservationImagingResult +// @profile: http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-observation-imaging +define ObservationImagingResult: + [Observation] O + where O.status in { 'registered', 'preliminary', 'final', 'amended', 'corrected' } + and O.isImaging() + +// QICoreObservationSurvey +// @profile: http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-observation-survey +define ObservationSurvey: + [Observation] O + where O.status in { 'registered', 'preliminary', 'final', 'amended', 'corrected' } + and O.isSurvey() + +// USCoreVitalSigns + +// USCoreBloodPressure + +// USCoreBMI + +// USCoreBodyHeight + +// USCoreBodyTemperature + +// USCoreBodyWeight -// USCore Smoking Status +// USCoreHeadCircumference -// USCore Laboratory Result +// USCoreHeartRate -// USCore Pediatric BMI for Age +// USCorePediatricBMIForAgeObservation -// USCore Pediatric Weight for Height +// USCorePediatricHeadOccipitalFrontCircumferencePercentile + +// USCorePediatricWeightForHeightObservation // USCore Pulse Oximetry +// USCoreRespiratoryRate + +// USCoreSmokingStatus + +// USCoreObservationSexualOrientation + +// USCoreObservationSocialHistory + +// USCoreObservationSDOHAssessment + // QICoreOrganization // @profile: http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-organization define Organization: @@ -433,7 +499,6 @@ define Task: // QICoreTaskRejected // @profile: http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-taskrejected -// TODO: What about cancelled and failed? define TaskRejected: [Task] T - where T.status = 'rejected' + where T.status in { 'rejected', 'cancelled', 'failed' } diff --git a/input/cql/QICoreCommon.cql b/input/cql/QICoreCommon.cql index 9465223a..ecca3892 100644 --- a/input/cql/QICoreCommon.cql +++ b/input/cql/QICoreCommon.cql @@ -20,6 +20,10 @@ codesystem "ConditionClinicalStatusCodes": 'http://terminology.hl7.org/CodeSyste codesystem "ConditionVerificationStatusCodes": 'http://terminology.hl7.org/CodeSystem/condition-ver-status' codesystem "AllergyIntoleranceClinicalStatusCodes": 'http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical' codesystem "AllergyIntoleranceVerificationStatusCodes": 'http://terminology.hl7.org/CodeSystem/allergyintolerance-verification' +codesystem "ObservationCategoryCodes": 'http://terminology.hl7.org/CodeSystem/observation-category' +codesystem "USCoreObservationCategory": 'http://hl7.org/fhir/us/core/CodeSystem/us-core-observation-category' +codesystem "ConditionCategory": 'http://terminology.hl7.org/CodeSystem/condition-category' +codesystem "USCoreConditionCategory": 'http://hl7.org/fhir/us/core/CodeSystem/condition-category' code "Birthdate": '21112-8' from "LOINC" display 'Birth date' code "Dead": '419099009' from "SNOMEDCT" display 'Dead' @@ -27,6 +31,11 @@ code "ER": 'ER' from "RoleCode" display 'Emergency room' code "ICU": 'ICU' from "RoleCode" display 'Intensive care unit' code "Billing": 'billing' from "Diagnosis Role" display 'Billing' +// Condition Category Codes +code "problem-list-item": 'problem-list-item' from "ConditionCategory" display 'Problem List Item' +code "encounter-diagnosis": 'encounter-diagnosis' from "ConditionCategory" display 'Encounter Diagnosis' +code "health-concern": 'health-concern' from "USCoreConditionCategory" display 'Health Concern' + // Condition Clinical Status Codes - Consider value sets for these code "active": 'active' from "ConditionClinicalStatusCodes" code "recurrence": 'recurrence' from "ConditionClinicalStatusCodes" @@ -65,10 +74,97 @@ code "pre-op": 'pre-op' from "Diagnosis Role" display 'pre-op diagnosis' code "post-op": 'post-op' from "Diagnosis Role" display 'post-op diagnosis' code "billing": 'billing' from "Diagnosis Role" display 'billing diagnosis' +// Observation Category Codes +code "social-history": 'social-history' from "ObservationCategoryCodes" display 'Social History' +code "vital-signs": 'vital-signs' from "ObservationCategoryCodes" display 'Vital Signs' +code "imaging": 'imaging' from "ObservationCategoryCodes" display 'Imaging' +code "laboratory": 'laboratory' from "ObservationCategoryCodes" display 'Laboratory' +code "procedure": 'procedure' from "ObservationCategoryCodes" display 'Procedure' +code "survey": 'survey' from "ObservationCategoryCodes" display 'Survey' +code "exam": 'exam' from "ObservationCategoryCodes" display 'Exam' +code "therapy": 'therapy' from "ObservationCategoryCodes" display 'Therapy' +code "activity": 'activity' from "ObservationCategoryCodes" display 'Activity' +code "clinical-test": 'clinical-test' from "USCoreObservationCategoryCodes" display 'Clinical Test' + context Patient /* Candidates for FHIRCommon */ +define fluent function hasCategory(condition Condition, category Code): + exists (condition.category C + where C ~ category + ) + +define fluent function isProblemListItem(condition Condition): + exists (condition.category C + where C ~ "problem-list-item" + ) + +define fluent function isEncounterDiagnosis(condition Condition): + exists (condition.category C + where C ~ "encounter-diagnosis" + ) + +define fluent function isHealthConcern(condition Condition): + exists (condition.category C + where C ~ "health-concern" + ) + +define fluent function hasCategory(observation Observation, category Code): + exists (observation.category C + where C ~ category + ) + +define fluent function isSocialHistory(observation Observation): + exists (observation.category C + where C ~ "social-history" + ) + +define fluent function isVitalSign(observation Observation): + exists (observation.category C + where C ~ "vital-signs" + ) + +define fluent function isImaging(observation Observation): + exists (observation.category C + where C ~ "imaging" + ) + +define fluent function isLaboratory(observation Observation): + exists (observation.category C + where C ~ "laboratory" + ) + +define fluent function isProcedure(observation Observation): + exists (observation.category C + where C ~ "procedure" + ) + +define fluent function isSurvey(observation Observation): + exists (observation.category C + where C ~ "survey" + ) + +define fluent function isExam(observation Observation): + exists (observation.category C + where C ~ "exam" + ) + +define fluent function isTherapy(observation Observation): + exists (observation.category C + where C ~ "therapy" + ) + +define fluent function isActivity(observation Observation): + exists (observation.category C + where C ~ "activity" + ) + +define fluent function isClinicalTest(observation Observation): + exists (observation.category C + where C ~ "clinical-test" + ) + /* @description: Returns true if the given MedicationRequest has a category of Community */