From e131a119dc293b2ad02e24fad4a9001d9d926c15 Mon Sep 17 00:00:00 2001 From: Piotr Mankowski Date: Wed, 24 Jul 2024 15:44:23 -0700 Subject: [PATCH] Updated naming and fixed some errors (#40) --- input/cql/HIVCommon.cql | 62 +++++----- input/cql/HIVConcepts.cql | 24 ++-- input/cql/HIVElements.cql | 181 ++++++++++++++++------------- input/cql/HIVEncounterElements.cql | 24 ++-- input/cql/HIVIND25Logic.cql | 15 ++- input/cql/HIVIndicatorElements.cql | 46 +++++--- 6 files changed, 190 insertions(+), 162 deletions(-) diff --git a/input/cql/HIVCommon.cql b/input/cql/HIVCommon.cql index 48b41143c2..7c8e0a0f5d 100644 --- a/input/cql/HIVCommon.cql +++ b/input/cql/HIVCommon.cql @@ -28,6 +28,10 @@ define "HIV Positive Condition": where C.clinicalStatus ~ HCC."active" and exists(C.category CC where CC ~ HCC."encounter-diagnosis") and C.code ~ HC."HIV-positive - HIV.B.DE116" + sort by start of onset.toInterval() + +define "First HIV Positive Condition": + First("HIV Positive Condition") define "HIV Positive Observation": [Observation] O @@ -53,12 +57,10 @@ define "HIV test resulted": and O.code ~ HC."Rapid diagnostic test for HIV - HIV.B.DE82" define "HIV Treatment Active": -[MedicationStatement] MS -Sort by MS.effective + [MedicationStatement] MS where MS.status = 'completed' and exists(MS.reasonCode C where C ~ HC."On ART - HIV.H.DE47") - - + sort by effective define "HIV PREP Active": [MedicationStatement] MS @@ -121,7 +123,7 @@ define "HIV Test Positive After PEP Prescribed during Measurement Period": define "Needle Syringe Dispensed": [DeviceUseStatement] DUS - with [Observation: HC."Key population member* - HIV.E.DE113"] O + with [Observation: HC."Key population member - HIV.E.DE113"] O such that DUS.reasonReference.references(O) and O.status in { 'final', 'amended', 'corrected' } and exists(O.category OC where OC ~ HCC."social-history") @@ -129,7 +131,7 @@ define "Needle Syringe Dispensed": where DUS.status = 'completed' define PWID_person: - [Observation: HC."Key population member* - HIV.E.DE113"] O + [Observation: HC."Key population member - HIV.E.DE113"] O where O.status in { 'final', 'amended', 'corrected' } and exists(O.category OC where OC ~ HCC."social-history") and O.value ~ HC."People who inject drugs - HIV.B.DE54" @@ -301,7 +303,7 @@ define "HIV Status": define SW: exists ( - [Observation: HC."Key population member* - HIV.E.DE113"] O + [Observation: HC."Key population member - HIV.E.DE113"] O where O.status in { 'final', 'amended', 'corrected' } and exists(O.category OC where OC ~ HCC."social-history") and O.value ~ HC."Sex worker - HIV.B.DE51" @@ -309,7 +311,7 @@ define "HIV Status": define MSM: exists ( - [Observation: HC."Key population member* - HIV.E.DE113"] O + [Observation: HC."Key population member - HIV.E.DE113"] O where O.status in { 'final', 'amended', 'corrected' } and exists(O.category OC where OC ~ HCC."social-history") and O.value ~ HC."Men who have sex with men" @@ -317,7 +319,7 @@ define "HIV Status": define Trans: exists ( - [Observation: HC."Key population member* - HIV.E.DE113"] O + [Observation: HC."Key population member - HIV.E.DE113"] O where O.status in { 'final', 'amended', 'corrected' } and exists(O.category OC where OC ~ HCC."social-history") and O.value ~ HC."Trans and gender-diverse people - HIV.B.DE53" @@ -325,7 +327,7 @@ define "HIV Status": define PWID: exists ( - [Observation: HC."Key population member* - HIV.E.DE113"] O + [Observation: HC."Key population member - HIV.E.DE113"] O where O.status in { 'final', 'amended', 'corrected' } and exists(O.category OC where OC ~ HCC."social-history") and O.value ~ HC."People who inject drugs - HIV.B.DE54" @@ -333,7 +335,7 @@ define "HIV Status": define Prisoner: exists ( - [Observation: HC."Key population member* - HIV.E.DE113"] O + [Observation: HC."Key population member - HIV.E.DE113"] O where O.status in { 'final', 'amended', 'corrected' } and exists(O.category OC where OC ~ HCC."social-history") and O.value ~ HC."People living in prisons and other closed settings" @@ -360,7 +362,7 @@ define "HIV Status": define Exposure_Occupational: exists ( - [Observation: HC."HIV exposure type*"] O + [Observation: HC."HIV exposure type"] O where O.status in { 'final', 'amended', 'corrected' } and exists(O.category OC where OC ~ HCC."social-history") and O.value ~ HC."Occupational" @@ -368,7 +370,7 @@ define Exposure_Occupational: define Exposure_Non_Occupational_violent: exists ( - [Observation: HC."HIV exposure type*"] O + [Observation: HC."HIV exposure type"] O where O.status in { 'final', 'amended', 'corrected' } and exists(O.category OC where OC ~ HCC."social-history") and O.value ~ HC."Non-occupational violent" @@ -376,7 +378,7 @@ define Exposure_Non_Occupational_violent: define Exposure_Non_Occupational_consensual_sex: exists ( - [Observation: HC."HIV exposure type*"] O + [Observation: HC."HIV exposure type"] O where O.status in { 'final', 'amended', 'corrected' } and exists(O.category OC where OC ~ HCC."social-history") and O.value ~ HC."Non-occupational consensual sex" @@ -831,9 +833,9 @@ define "VMMC_adverse_event_Postoperative": define "Time to start ART": case - when difference in days between "First HIV Treatment".effective and "HIV Positive Condition".onset <= 7 then HC."Within 7 days of HIV diagnosis" - when difference in days between "First HIV Treatment".effective and "HIV Positive Condition".onset <= 30 then HC."Within 30 days of HIV diagnosis" - when difference in days between "First HIV Treatment".effective and "HIV Positive Condition".onset <= 90 then HC."Within 90 days of HIV diagnosis" + when difference in days between start of "First HIV Treatment".effective.toInterval() and start of "First HIV Positive Condition".onset.toInterval() <= 7 then HC."Within 7 days of HIV diagnosis" + when difference in days between start of "First HIV Treatment".effective.toInterval() and start of "First HIV Positive Condition".onset.toInterval() <= 30 then HC."Within 30 days of HIV diagnosis" + when difference in days between start of "First HIV Treatment".effective.toInterval() and start of "First HIV Positive Condition".onset.toInterval() <= 90 then HC."Within 90 days of HIV diagnosis" else null end @@ -876,28 +878,28 @@ define "VMMC_adverse_event_Postoperative": //(including PrEP, OAMT, NSP, STI services, VMMC) define "HIV prevention intervention": List{ - if "HIV PREP Active" then 'PrEP' else null, + if exists("HIV PREP Active") then 'PrEP' else null, if OAMT_initiated then 'OAMT' else null, - if "Needle Syringe Dispensed" then 'NSP' else null, - if STI_testing then 'STI services' else null, - if VMMC_done then 'VMMC' else null + if exists("Needle Syringe Dispensed") then 'NSP' else null, + if exists(STI_testing) then 'STI services' else null, + if exists(VMMC_done) then 'VMMC' else null } define "Negative Tests within Measurement Period": -HIC."HIV Negative Observation" O - with HIC."Client is at elevated risk for HIV acquisition" HIV +"HIV Negative Observation" O + with "Client is at elevated risk for HIV acquisition" HIV such that O.hasMember.references(HIV) and O.issued after start of "Measurement Period" and O.issued before end of "Measurement Period" -Sort by O.issued + sort by issued define "First Negative Test within Measurement Period": ( First("Negative Tests within Measurement Period")) define "Negative Tests after First Negative Test": -HIC."HIV Negative Observation" O - with HIC."Client is at elevated risk for HIV acquisition" HIV - such that O.hasMember.references(HIV) - and O.issued after "First Negative Test within Measurement Period" - and O.issued before ("First Negative Test within Measurement Period" + "Testing Interval") -Sort by O.issued \ No newline at end of file + "HIV Negative Observation" O + with "Client is at elevated risk for HIV acquisition" HIV + such that O.hasMember.references(HIV) + where O.issued after "First Negative Test within Measurement Period".issued + and O.issued before ("First Negative Test within Measurement Period".issued + "Testing Interval") + sort by issued \ No newline at end of file diff --git a/input/cql/HIVConcepts.cql b/input/cql/HIVConcepts.cql index e72fc63da4..57f508a445 100644 --- a/input/cql/HIVConcepts.cql +++ b/input/cql/HIVConcepts.cql @@ -10,14 +10,14 @@ library HIVConcepts codesystem "HIVConcepts": 'http://smart.who.int/hiv/CodeSystem/HIVConcepts' -valueset "Gender* Choices": 'http://smart.who.int/hiv/ValueSet/HIV.A.DE18' +valueset "Gender Choices": 'http://smart.who.int/hiv/ValueSet/HIV.A.DE18' valueset "Reason for visit - HIV.B.DE1 Choices": 'http://smart.who.int/hiv/ValueSet/HIV.B.DE1' valueset "Referred through partner services Choices": 'http://smart.who.int/hiv/ValueSet/HIV.B.DE5' valueset "Type of contact or partner for partner services Choices": 'http://smart.who.int/hiv/ValueSet/HIV.B.DE8' valueset "Testing entry point Choices": 'http://smart.who.int/hiv/ValueSet/HIV.B.DE15' valueset "Partner HIV status reported Choices": 'http://smart.who.int/hiv/ValueSet/HIV.B.DE33' -valueset "Key population member type* - HIV.B.DE50 Choices": 'http://smart.who.int/hiv/ValueSet/HIV.B.DE50' -valueset "HIV exposure type* Choices": 'http://smart.who.int/hiv/ValueSet/HIV.B.DE61' +valueset "Key population member type - HIV.B.DE50 Choices": 'http://smart.who.int/hiv/ValueSet/HIV.B.DE50' +valueset "HIV exposure type Choices": 'http://smart.who.int/hiv/ValueSet/HIV.B.DE61' valueset "HIV test type - HIV.B.DE81 Choices": 'http://smart.who.int/hiv/ValueSet/HIV.B.DE81' valueset "Assay number in testing strategy - HIV.B.DE88 Choices": 'http://smart.who.int/hiv/ValueSet/HIV.B.DE88' valueset "Test result of HIV assay 1 - HIV.B.DE94 Choices": 'http://smart.who.int/hiv/ValueSet/HIV.B.DE94' @@ -26,7 +26,7 @@ valueset "Test result of HIV assay 3 - HIV.B.DE102 Choices": 'http://smart.who.i valueset "Test result of HIV assay 1 repeated - HIV.B.DE106 Choices": 'http://smart.who.int/hiv/ValueSet/HIV.B.DE106' valueset "HIV test result - HIV.B.DE111 Choices": 'http://smart.who.int/hiv/ValueSet/HIV.B.DE111' valueset "HIV status Choices": 'http://smart.who.int/hiv/ValueSet/HIV.B.DE115' -valueset "Probable route of transmission* Choices": 'http://smart.who.int/hiv/ValueSet/HIV.B.DE121' +valueset "Probable route of transmission Choices": 'http://smart.who.int/hiv/ValueSet/HIV.B.DE121' valueset "Counselling provided Choices": 'http://smart.who.int/hiv/ValueSet/HIV.B.DE142' valueset "Prevention services offered and referrals - HIV.B.DE149 Choices": 'http://smart.who.int/hiv/ValueSet/HIV.B.DE149' valueset "Sexual and reproductive health integrated services - HIV.B.DE158 Choices": 'http://smart.who.int/hiv/ValueSet/HIV.B.DE158' @@ -117,7 +117,7 @@ valueset "TPT regimen type Choices": 'http://smart.who.int/hiv/ValueSet/HIV.D.DE valueset "TB preventive treatment TPT status Choices": 'http://smart.who.int/hiv/ValueSet/HIV.D.DE1034' valueset "Timing of ART initiation Choices": 'http://smart.who.int/hiv/ValueSet/HIV.E.DE41' valueset "Place of delivery Choices": 'http://smart.who.int/hiv/ValueSet/HIV.E.DE67' -valueset "Key population member type* - HIV.E.DE114 Choices": 'http://smart.who.int/hiv/ValueSet/HIV.E.DE114' +valueset "Key population member type - HIV.E.DE114 Choices": 'http://smart.who.int/hiv/ValueSet/HIV.E.DE114' valueset "Signs of substantial risk of HIV infection - HIV.E.DE155 Choices": 'http://smart.who.int/hiv/ValueSet/HIV.E.DE155' valueset "HIV test type - HIV.E.DE168 Choices": 'http://smart.who.int/hiv/ValueSet/HIV.E.DE168' valueset "Maternal and child health service visit Choices": 'http://smart.who.int/hiv/ValueSet/HIV.E.DE173' @@ -153,7 +153,7 @@ valueset "Other priority populations Choices": 'http://smart.who.int/hiv/ValueSe code "Visit date - HIV.A.DE3": 'HIV.A.DE3' from "HIVConcepts" display 'Visit date' code "Estimated age": 'HIV.A.DE16' from "HIVConcepts" display 'Estimated age' code "Age": 'HIV.A.DE17' from "HIVConcepts" display 'Age' -code "Gender*": 'HIV.A.DE18' from "HIVConcepts" display 'Gender*' +code "Gender": 'HIV.A.DE18' from "HIVConcepts" display 'Gender*' code "Female": 'HIV.A.DE19' from "HIVConcepts" display 'Female' code "Male": 'HIV.A.DE20' from "HIVConcepts" display 'Male' code "Transgender male": 'HIV.A.DE21' from "HIVConcepts" display 'Transgender male' @@ -181,15 +181,15 @@ code "Partner HIV status reported": 'HIV.B.DE33' from "HIVConcepts" display 'Par code "HIV-positive - HIV.B.DE34": 'HIV.B.DE34' from "HIVConcepts" display 'HIV-positive' code "HIV-negative - HIV.B.DE35": 'HIV.B.DE35' from "HIVConcepts" display 'HIV-negative' code "Unknown - HIV.B.DE36": 'HIV.B.DE36' from "HIVConcepts" display 'Unknown' -code "Key population member* - HIV.B.DE49": 'HIV.B.DE49' from "HIVConcepts" display 'Key population member*' -code "Key population member type* - HIV.B.DE50": 'HIV.B.DE50' from "HIVConcepts" display 'Key population member type*' +code "Key population member - HIV.B.DE49": 'HIV.B.DE49' from "HIVConcepts" display 'Key population member*' +code "Key population member type - HIV.B.DE50": 'HIV.B.DE50' from "HIVConcepts" display 'Key population member type*' code "Sex worker - HIV.B.DE51": 'HIV.B.DE51' from "HIVConcepts" display 'Sex worker' code "Men who have sex with men": 'HIV.B.DE52' from "HIVConcepts" display 'Men who have sex with men' code "Trans and gender-diverse people - HIV.B.DE53": 'HIV.B.DE53' from "HIVConcepts" display 'Trans and gender-diverse people' code "People who inject drugs - HIV.B.DE54": 'HIV.B.DE54' from "HIVConcepts" display 'People who inject drugs' code "People living in prisons and other closed settings": 'HIV.B.DE55' from "HIVConcepts" display 'People living in prisons and other closed settings' code "Date HIV test results returned": 'HIV.B.DE60' from "HIVConcepts" display 'Date HIV test results returned' -code "HIV exposure type*": 'HIV.B.DE61' from "HIVConcepts" display 'HIV exposure type*' +code "HIV exposure type": 'HIV.B.DE61' from "HIVConcepts" display 'HIV exposure type*' code "Occupational": 'HIV.B.DE62' from "HIVConcepts" display 'Occupational' code "Non-occupational violent": 'HIV.B.DE63' from "HIVConcepts" display 'Non-occupational violent' code "Non-occupational consensual sex": 'HIV.B.DE64' from "HIVConcepts" display 'Non-occupational consensual sex' @@ -234,7 +234,7 @@ code "HIV status": 'HIV.B.DE115' from "HIVConcepts" display 'HIV status' code "HIV-positive - HIV.B.DE116": 'HIV.B.DE116' from "HIVConcepts" display 'HIV-positive' code "HIV-negative - HIV.B.DE117": 'HIV.B.DE117' from "HIVConcepts" display 'HIV-negative' code "Unknown - HIV.B.DE118": 'HIV.B.DE118' from "HIVConcepts" display 'Unknown' -code "Probable route of transmission*": 'HIV.B.DE121' from "HIVConcepts" display 'Probable route of transmission*' +code "Probable route of transmission": 'HIV.B.DE121' from "HIVConcepts" display 'Probable route of transmission*' code "Heterosexual sex": 'HIV.B.DE122' from "HIVConcepts" display 'Heterosexual sex' code "Sex between men": 'HIV.B.DE123' from "HIVConcepts" display 'Sex between men' code "Unprotected intercourse during sex work": 'HIV.B.DE124' from "HIVConcepts" display 'Unprotected intercourse during sex work' @@ -935,8 +935,8 @@ code "ANC contact date - HIV.E.DE85": 'HIV.E.DE85' from "HIVConcepts" display 'A code "Infant date of birth": 'HIV.E.DE87' from "HIVConcepts" display 'Infant date of birth' code "Age of infant": 'HIV.E.DE90' from "HIVConcepts" display 'Age of infant' code "HIV-exposed infant or child - HIV.E.DE112": 'HIV.E.DE112' from "HIVConcepts" display 'HIV-exposed infant or child' -code "Key population member* - HIV.E.DE113": 'HIV.E.DE113' from "HIVConcepts" display 'Key population member*' -code "Key population member type* - HIV.E.DE114": 'HIV.E.DE114' from "HIVConcepts" display 'Key population member type*' +code "Key population member - HIV.E.DE113": 'HIV.E.DE113' from "HIVConcepts" display 'Key population member*' +code "Key population member type - HIV.E.DE114": 'HIV.E.DE114' from "HIVConcepts" display 'Key population member type*' code "Sex worker - HIV.E.DE115": 'HIV.E.DE115' from "HIVConcepts" display 'Sex worker' code "People who inject drugs - HIV.E.DE116": 'HIV.E.DE116' from "HIVConcepts" display 'People who inject drugs' code "Trans and gender-diverse people - HIV.E.DE117": 'HIV.E.DE117' from "HIVConcepts" display 'Trans and gender-diverse people' diff --git a/input/cql/HIVElements.cql b/input/cql/HIVElements.cql index a9f75bc795..b67ec64463 100644 --- a/input/cql/HIVElements.cql +++ b/input/cql/HIVElements.cql @@ -55,27 +55,37 @@ define "Estimated age Value": @activity: HIV.A6.1 Review sociodemographic data with client | HIV.A5 Create new client record @description: Calculated age (number of years) of the client based on date of birth */ -// TODO: Replace placeholder with relevant CQL logic -define "Age": - [Observation: Concepts."Age"] O - where O.status in { 'final', 'amended', 'corrected' } -define "Age Value": - "Age" O - return O.value +/** + * @dataElement Patient age in years + */ +define "Current Patient Age In Years": + AgeInYearsAt(Today()) + +/** + * @dataElement Patient age in weeks + */ +define "Current Patient Age In Weeks": + AgeInWeeksAt(Today()) + +/** + * @dataElement Patient age in months + */ +define "Current Patient Age In Months": + AgeInMonthsAt(Today()) /* End of Age */ /* -@dataElement: HIV.A.DE18 - Gender* +@dataElement: HIV.A.DE18 - Gender @activity: HIV.A6.1 Review sociodemographic data with client | HIV.A5 Create new client record -@description: Gender of the client* +@description: Gender of the client */ // TODO: Replace placeholder with relevant CQL logic -define "Gender*": - exists "Gender* Observation" -define "Gender* Observation": - [Observation: Concepts."Gender*"] O +define "Gender": + exists "Gender Observation" +define "Gender Observation": + [Observation: Concepts."Gender"] O where O.status in { 'final', 'amended', 'corrected' } -/* End of Gender* */ +/* End of Gender */ /* @dataElement: HIV.A.DE19 - Female @@ -89,7 +99,7 @@ define "Female": define "Female Condition": [Condition: Concepts."Female"] define "Female Observation": - "Gender* Observation" O + "Gender Observation" O where O.status in { 'final', 'amended', 'corrected' } and O.value ~ Concepts."Female" /* End of Female */ @@ -106,7 +116,7 @@ define "Male": define "Male Condition": [Condition: Concepts."Male"] define "Male Observation": - "Gender* Observation" O + "Gender Observation" O where O.status in { 'final', 'amended', 'corrected' } and O.value ~ Concepts."Male" /* End of Male */ @@ -123,7 +133,7 @@ define "Transgender male": define "Transgender male Condition": [Condition: Concepts."Transgender male"] define "Transgender male Observation": - "Gender* Observation" O + "Gender Observation" O where O.status in { 'final', 'amended', 'corrected' } and O.value ~ Concepts."Transgender male" /* End of Transgender male */ @@ -140,7 +150,7 @@ define "Transgender female": define "Transgender female Condition": [Condition: Concepts."Transgender female"] define "Transgender female Observation": - "Gender* Observation" O + "Gender Observation" O where O.status in { 'final', 'amended', 'corrected' } and O.value ~ Concepts."Transgender female" /* End of Transgender female */ @@ -157,7 +167,7 @@ define "Other A.DE23": define "Other A.DE23 Condition": [Condition: Concepts."Other - HIV.A.DE23"] define "Other A.DE23 Observation": - "Gender* Observation" O + "Gender Observation" O where O.status in { 'final', 'amended', 'corrected' } and O.value ~ Concepts."Other - HIV.A.DE23" /* End of Other A.DE23 */ @@ -508,31 +518,31 @@ define "Unknown B.DE36 Observation": /* End of Unknown B.DE36 */ /* -@dataElement: HIV.B.DE49 - Key population member* +@dataElement: HIV.B.DE49 - Key population member @activity: HIV.B6 Capture or update client history @description: Client is a member of a key population that has an increased risk of HIV */ // TODO: Replace placeholder with relevant CQL logic -define "Key population member* B.DE49": - exists "Key population member* B.DE49 Observation" -define "Key population member* B.DE49 Observation": - [Observation: Concepts."Key population member* - HIV.B.DE49"] O +define "Key population member B.DE49": + exists "Key population member B.DE49 Observation" +define "Key population member B.DE49 Observation": + [Observation: Concepts."Key population member - HIV.B.DE49"] O where O.status in { 'final', 'amended', 'corrected' } and O.value is true -/* End of Key population member* B.DE49 */ +/* End of Key population member B.DE49 */ /* -@dataElement: HIV.B.DE50 - Key population member type* +@dataElement: HIV.B.DE50 - Key population member type @activity: HIV.B6 Capture or update client history @description: The type of key population that the client is included in */ // TODO: Replace placeholder with relevant CQL logic -define "Key population member type* B.DE50": - exists "Key population member type* B.DE50 Observation" -define "Key population member type* B.DE50 Observation": - [Observation: Concepts."Key population member type* - HIV.B.DE50"] O +define "Key population member type B.DE50": + exists "Key population member type B.DE50 Observation" +define "Key population member type B.DE50 Observation": + [Observation: Concepts."Key population member type - HIV.B.DE50"] O where O.status in { 'final', 'amended', 'corrected' } -/* End of Key population member type* B.DE50 */ +/* End of Key population member type B.DE50 */ /* @dataElement: HIV.B.DE51 - Sex worker @@ -546,7 +556,7 @@ define "Sex worker B.DE51": define "Sex worker B.DE51 Condition": [Condition: Concepts."Sex worker - HIV.B.DE51"] define "Sex worker B.DE51 Observation": - "Key population member type* B.DE50 Observation" O + "Key population member type B.DE50 Observation" O where O.status in { 'final', 'amended', 'corrected' } and O.value ~ Concepts."Sex worker - HIV.B.DE51" /* End of Sex worker B.DE51 */ @@ -563,7 +573,7 @@ define "Men who have sex with men": define "Men who have sex with men Condition": [Condition: Concepts."Men who have sex with men"] define "Men who have sex with men Observation": - "Key population member type* B.DE50 Observation" O + "Key population member type B.DE50 Observation" O where O.status in { 'final', 'amended', 'corrected' } and O.value ~ Concepts."Men who have sex with men" /* End of Men who have sex with men */ @@ -580,7 +590,7 @@ define "Trans and gender-diverse people B.DE53": define "Trans and gender-diverse people B.DE53 Condition": [Condition: Concepts."Trans and gender-diverse people - HIV.B.DE53"] define "Trans and gender-diverse people B.DE53 Observation": - "Key population member type* B.DE50 Observation" O + "Key population member type B.DE50 Observation" O where O.status in { 'final', 'amended', 'corrected' } and O.value ~ Concepts."Trans and gender-diverse people - HIV.B.DE53" /* End of Trans and gender-diverse people B.DE53 */ @@ -597,7 +607,7 @@ define "People who inject drugs B.DE54": define "People who inject drugs B.DE54 Condition": [Condition: Concepts."People who inject drugs - HIV.B.DE54"] define "People who inject drugs B.DE54 Observation": - "Key population member type* B.DE50 Observation" O + "Key population member type B.DE50 Observation" O where O.status in { 'final', 'amended', 'corrected' } and O.value ~ Concepts."People who inject drugs - HIV.B.DE54" /* End of People who inject drugs B.DE54 */ @@ -614,7 +624,7 @@ define "People living in prisons and other closed settings": define "People living in prisons and other closed settings Condition": [Condition: Concepts."People living in prisons and other closed settings"] define "People living in prisons and other closed settings Observation": - "Key population member type* B.DE50 Observation" O + "Key population member type B.DE50 Observation" O where O.status in { 'final', 'amended', 'corrected' } and O.value ~ Concepts."People living in prisons and other closed settings" /* End of People living in prisons and other closed settings */ @@ -634,17 +644,17 @@ define "Date HIV test results returned Value": /* End of Date HIV test results returned */ /* -@dataElement: HIV.B.DE61 - HIV exposure type* +@dataElement: HIV.B.DE61 - HIV exposure type @activity: HIV.B6 Capture or update client history @description: Ways in which the client was exposed to HIV */ // TODO: Replace placeholder with relevant CQL logic -define "HIV exposure type*": - exists "HIV exposure type* Observation" -define "HIV exposure type* Observation": - [Observation: Concepts."HIV exposure type*"] O +define "HIV exposure type": + exists "HIV exposure type Observation" +define "HIV exposure type Observation": + [Observation: Concepts."HIV exposure type"] O where O.status in { 'final', 'amended', 'corrected' } -/* End of HIV exposure type* */ +/* End of HIV exposure type */ /* @dataElement: HIV.B.DE62 - Occupational @@ -658,7 +668,7 @@ define "Occupational": define "Occupational Condition": [Condition: Concepts."Occupational"] define "Occupational Observation": - "HIV exposure type* Observation" O + "HIV exposure type Observation" O where O.status in { 'final', 'amended', 'corrected' } and O.value ~ Concepts."Occupational" /* End of Occupational */ @@ -675,7 +685,7 @@ define "Non-occupational violent": define "Non-occupational violent Condition": [Condition: Concepts."Non-occupational violent"] define "Non-occupational violent Observation": - "HIV exposure type* Observation" O + "HIV exposure type Observation" O where O.status in { 'final', 'amended', 'corrected' } and O.value ~ Concepts."Non-occupational violent" /* End of Non-occupational violent */ @@ -692,7 +702,7 @@ define "Non-occupational consensual sex": define "Non-occupational consensual sex Condition": [Condition: Concepts."Non-occupational consensual sex"] define "Non-occupational consensual sex Observation": - "HIV exposure type* Observation" O + "HIV exposure type Observation" O where O.status in { 'final', 'amended', 'corrected' } and O.value ~ Concepts."Non-occupational consensual sex" /* End of Non-occupational consensual sex */ @@ -1348,17 +1358,17 @@ define "Unknown B.DE118 Observation": /* End of Unknown B.DE118 */ /* -@dataElement: HIV.B.DE121 - Probable route of transmission* +@dataElement: HIV.B.DE121 - Probable route of transmission @activity: HIV.B8 Provide post-test counselling @description: Probable route(s) of transmission of HIV to client */ // TODO: Replace placeholder with relevant CQL logic -define "Probable route of transmission*": - exists "Probable route of transmission* Observation" -define "Probable route of transmission* Observation": - [Observation: Concepts."Probable route of transmission*"] O +define "Probable route of transmission": + exists "Probable route of transmission Observation" +define "Probable route of transmission Observation": + [Observation: Concepts."Probable route of transmission"] O where O.status in { 'final', 'amended', 'corrected' } -/* End of Probable route of transmission* */ +/* End of Probable route of transmission */ /* @dataElement: HIV.B.DE122 - Heterosexual sex @@ -1372,7 +1382,7 @@ define "Heterosexual sex": define "Heterosexual sex Condition": [Condition: Concepts."Heterosexual sex"] define "Heterosexual sex Observation": - "Probable route of transmission* Observation" O + "Probable route of transmission Observation" O where O.status in { 'final', 'amended', 'corrected' } and O.value ~ Concepts."Heterosexual sex" /* End of Heterosexual sex */ @@ -1389,7 +1399,7 @@ define "Sex between men": define "Sex between men Condition": [Condition: Concepts."Sex between men"] define "Sex between men Observation": - "Probable route of transmission* Observation" O + "Probable route of transmission Observation" O where O.status in { 'final', 'amended', 'corrected' } and O.value ~ Concepts."Sex between men" /* End of Sex between men */ @@ -1406,7 +1416,7 @@ define "Unprotected intercourse during sex work": define "Unprotected intercourse during sex work Condition": [Condition: Concepts."Unprotected intercourse during sex work"] define "Unprotected intercourse during sex work Observation": - "Probable route of transmission* Observation" O + "Probable route of transmission Observation" O where O.status in { 'final', 'amended', 'corrected' } and O.value ~ Concepts."Unprotected intercourse during sex work" /* End of Unprotected intercourse during sex work */ @@ -1423,7 +1433,7 @@ define "Injecting drug use with unsterile equipment": define "Injecting drug use with unsterile equipment Condition": [Condition: Concepts."Injecting drug use with unsterile equipment"] define "Injecting drug use with unsterile equipment Observation": - "Probable route of transmission* Observation" O + "Probable route of transmission Observation" O where O.status in { 'final', 'amended', 'corrected' } and O.value ~ Concepts."Injecting drug use with unsterile equipment" /* End of Injecting drug use with unsterile equipment */ @@ -1440,7 +1450,7 @@ define "Nosocomial": define "Nosocomial Condition": [Condition: Concepts."Nosocomial"] define "Nosocomial Observation": - "Probable route of transmission* Observation" O + "Probable route of transmission Observation" O where O.status in { 'final', 'amended', 'corrected' } and O.value ~ Concepts."Nosocomial" /* End of Nosocomial */ @@ -1457,7 +1467,7 @@ define "Vertical": define "Vertical Condition": [Condition: Concepts."Vertical"] define "Vertical Observation": - "Probable route of transmission* Observation" O + "Probable route of transmission Observation" O where O.status in { 'final', 'amended', 'corrected' } and O.value ~ Concepts."Vertical" /* End of Vertical */ @@ -1474,7 +1484,7 @@ define "Other B.DE128": define "Other B.DE128 Condition": [Condition: Concepts."Other - HIV.B.DE128"] define "Other B.DE128 Observation": - "Probable route of transmission* Observation" O + "Probable route of transmission Observation" O where O.status in { 'final', 'amended', 'corrected' } and O.value ~ Concepts."Other - HIV.B.DE128" /* End of Other B.DE128 */ @@ -12604,13 +12614,22 @@ define "Infant date of birth Value": @activity: HIV.E1 Capture or update mother's history @description: Infant age calculated using date of birth */ -// TODO: Replace placeholder with relevant CQL logic -define "Age of infant": - [Observation: Concepts."Age of infant"] O - where O.status in { 'final', 'amended', 'corrected' } -define "Age of infant Value": - "Age of infant" O - return O.value +define "Age of infant in days": + "Infant date of birth" O + return CalculateAgeInDays(O.value) + +define "Age of infant in hours": + "Infant date of birth" O + return CalculateAgeInHours(O.value) + +define "Age of infant in weeks": + "Infant date of birth" O + return CalculateAgeInWeeks(O.value) + +define "Age of infant in years": + "Infant date of birth" O + return CalculateAgeInYears(O.value) + /* End of Age of infant */ /* @@ -12628,31 +12647,31 @@ define "HIV-exposed infant or child E.DE112 Observation": /* End of HIV-exposed infant or child E.DE112 */ /* -@dataElement: HIV.E.DE113 - Key population member* +@dataElement: HIV.E.DE113 - Key population member @activity: HIV.E1 Capture or update mother's history @description: Mother is a member of a key population which has an increased risk of HIV */ // TODO: Replace placeholder with relevant CQL logic -define "Key population member* E.DE113": - exists "Key population member* E.DE113 Observation" -define "Key population member* E.DE113 Observation": - [Observation: Concepts."Key population member* - HIV.E.DE113"] O +define "Key population member E.DE113": + exists "Key population member E.DE113 Observation" +define "Key population member E.DE113 Observation": + [Observation: Concepts."Key population member - HIV.E.DE113"] O where O.status in { 'final', 'amended', 'corrected' } and O.value is true -/* End of Key population member* E.DE113 */ +/* End of Key population member E.DE113 */ /* -@dataElement: HIV.E.DE114 - Key population member type* +@dataElement: HIV.E.DE114 - Key population member type @activity: HIV.E1 Capture or update mother's history @description: The type of key population that the infant's mother is included in */ // TODO: Replace placeholder with relevant CQL logic -define "Key population member type* E.DE114": - exists "Key population member type* E.DE114 Observation" -define "Key population member type* E.DE114 Observation": - [Observation: Concepts."Key population member type* - HIV.E.DE114"] O +define "Key population member type E.DE114": + exists "Key population member type E.DE114 Observation" +define "Key population member type E.DE114 Observation": + [Observation: Concepts."Key population member type - HIV.E.DE114"] O where O.status in { 'final', 'amended', 'corrected' } -/* End of Key population member type* E.DE114 */ +/* End of Key population member type E.DE114 */ /* @dataElement: HIV.E.DE115 - Sex worker @@ -12666,7 +12685,7 @@ define "Sex worker E.DE115": define "Sex worker E.DE115 Condition": [Condition: Concepts."Sex worker - HIV.E.DE115"] define "Sex worker E.DE115 Observation": - "Key population member type* E.DE114 Observation" O + "Key population member type E.DE114 Observation" O where O.status in { 'final', 'amended', 'corrected' } and O.value ~ Concepts."Sex worker - HIV.E.DE115" /* End of Sex worker E.DE115 */ @@ -12683,7 +12702,7 @@ define "People who inject drugs E.DE116": define "People who inject drugs E.DE116 Condition": [Condition: Concepts."People who inject drugs - HIV.E.DE116"] define "People who inject drugs E.DE116 Observation": - "Key population member type* E.DE114 Observation" O + "Key population member type E.DE114 Observation" O where O.status in { 'final', 'amended', 'corrected' } and O.value ~ Concepts."People who inject drugs - HIV.E.DE116" /* End of People who inject drugs E.DE116 */ @@ -12700,7 +12719,7 @@ define "Trans and gender-diverse people E.DE117": define "Trans and gender-diverse people E.DE117 Condition": [Condition: Concepts."Trans and gender-diverse people - HIV.E.DE117"] define "Trans and gender-diverse people E.DE117 Observation": - "Key population member type* E.DE114 Observation" O + "Key population member type E.DE114 Observation" O where O.status in { 'final', 'amended', 'corrected' } and O.value ~ Concepts."Trans and gender-diverse people - HIV.E.DE117" /* End of Trans and gender-diverse people E.DE117 */ @@ -12717,7 +12736,7 @@ define "People living in prisons and other closed setting": define "People living in prisons and other closed setting Condition": [Condition: Concepts."People living in prisons and other closed setting"] define "People living in prisons and other closed setting Observation": - "Key population member type* E.DE114 Observation" O + "Key population member type E.DE114 Observation" O where O.status in { 'final', 'amended', 'corrected' } and O.value ~ Concepts."People living in prisons and other closed setting" /* End of People living in prisons and other closed setting */ diff --git a/input/cql/HIVEncounterElements.cql b/input/cql/HIVEncounterElements.cql index b1ff386240..dfec38695c 100644 --- a/input/cql/HIVEncounterElements.cql +++ b/input/cql/HIVEncounterElements.cql @@ -125,18 +125,18 @@ define "Date/time of suspected exposure to HIV B.DE14 Value": /* End of Date/time of suspected exposure to HIV B.DE14 */ /* -@dataElement: HIV.B.DE49 - Key population member* +@dataElement: HIV.B.DE49 - Key population member @activity: HIV.B6 Capture or update client history @description: Client is a member of a key population that has an increased risk of HIV */ // TODO: Replace placeholder with relevant CQL logic -define "Key population member* B.DE49": - exists "Key population member* B.DE49 Observation" -define "Key population member* B.DE49 Observation": - Elements."Key population member* B.DE49 Observation" O +define "Key population member B.DE49": + exists "Key population member B.DE49 Observation" +define "Key population member B.DE49 Observation": + Elements."Key population member B.DE49 Observation" O where O.encounter.references(EncounterId) or O.effective.toInterval() starts on or before Today -/* End of Key population member* B.DE49 */ +/* End of Key population member B.DE49 */ /* @dataElement: HIV.B.DE80 - HIV test conducted @@ -7564,18 +7564,18 @@ define "C reactive protein test result Value": /* End of C reactive protein test result */ /* -@dataElement: HIV.E.DE113 - Key population member* +@dataElement: HIV.E.DE113 - Key population member @activity: HIV.E1 Capture or update mother's history @description: Mother is a member of a key population which has an increased risk of HIV */ // TODO: Replace placeholder with relevant CQL logic -define "Key population member* E.DE113": - exists "Key population member* E.DE113 Observation" -define "Key population member* E.DE113 Observation": - Elements."Key population member* E.DE113 Observation" O +define "Key population member E.DE113": + exists "Key population member E.DE113 Observation" +define "Key population member E.DE113 Observation": + Elements."Key population member E.DE113 Observation" O where O.encounter.references(EncounterId) or O.effective.toInterval() starts on or before Today -/* End of Key population member* E.DE113 */ +/* End of Key population member E.DE113 */ /* @dataElement: HIV.E.DE155 - Signs of substantial risk of HIV infection diff --git a/input/cql/HIVIND25Logic.cql b/input/cql/HIVIND25Logic.cql index f81a2112a4..ca631d3309 100644 --- a/input/cql/HIVIND25Logic.cql +++ b/input/cql/HIVIND25Logic.cql @@ -101,20 +101,19 @@ define "Negative Tests within Measurement Period": HIC."HIV Negative Observation" O with HIC."Client is at elevated risk for HIV acquisition" HIV such that O.hasMember.references(HIV) - and O.issued after start of "Measurement Period" - and O.issued before end of "Measurement Period" -Sort by O.issued + where O.issued.value in "Measurement Period" + sort by issued define "First Negative Test within Measurement Period": -( First("Negative Tests within Measurement Period")) + (First("Negative Tests within Measurement Period")) define "Negative Tests after First Negative Test": HIC."HIV Negative Observation" O with HIC."Client is at elevated risk for HIV acquisition" HIV - such that O.hasMember.references(HIV) - and O.issued after "First Negative Test within Measurement Period" - and O.issued before ("First Negative Test within Measurement Period" + "Testing Interval") -Sort by O.issued + such that O.hasMember.references(HIV) + where O.issued after "First Negative Test within Measurement Period".issued + and O.issued before ("First Negative Test within Measurement Period".issued + "Testing Interval") + sort by issued define "Numerator": diff --git a/input/cql/HIVIndicatorElements.cql b/input/cql/HIVIndicatorElements.cql index 4358464455..cf52194753 100644 --- a/input/cql/HIVIndicatorElements.cql +++ b/input/cql/HIVIndicatorElements.cql @@ -236,17 +236,17 @@ define "Date HIV test results returned Value": /* End of Date HIV test results returned */ /* -@dataElement: HIV.B.DE61 - HIV exposure type* +@dataElement: HIV.B.DE61 - HIV exposure type @activity: HIV.B6 Capture or update client history @description: Ways in which the client was exposed to HIV */ // TODO: Replace placeholder with relevant CQL logic -define "HIV exposure type*": - exists "HIV exposure type* Observation" -define "HIV exposure type* Observation": - Elements."HIV exposure type* Observation" O +define "HIV exposure type": + exists "HIV exposure type Observation" +define "HIV exposure type Observation": + Elements."HIV exposure type Observation" O where O.effective.toInterval() during "Measurement Period" -/* End of HIV exposure type* */ +/* End of HIV exposure type */ /* @dataElement: HIV.B.DE62 - Occupational @@ -317,17 +317,17 @@ define "HIV test date B.DE110 Value": /* End of HIV test date B.DE110 */ /* -@dataElement: HIV.B.DE121 - Probable route of transmission* +@dataElement: HIV.B.DE121 - Probable route of transmission @activity: HIV.B8 Provide post-test counselling @description: Probable route(s) of transmission of HIV to client */ // TODO: Replace placeholder with relevant CQL logic -define "Probable route of transmission*": - exists "Probable route of transmission* Observation" -define "Probable route of transmission* Observation": - Elements."Probable route of transmission* Observation" O +define "Probable route of transmission": + exists "Probable route of transmission Observation" +define "Probable route of transmission Observation": + Elements."Probable route of transmission Observation" O where O.effective.toInterval() during "Measurement Period" -/* End of Probable route of transmission* */ +/* End of Probable route of transmission */ /* @dataElement: HIV.B.DE122 - Heterosexual sex @@ -4393,15 +4393,23 @@ define "Infant date of birth Value": @activity: HIV.E1 Capture or update mother's history @description: Infant age calculated using date of birth */ -// TODO: Replace placeholder with relevant CQL logic -define "Age of infant": - Elements."Age of infant" O - where O.effective.toInterval() during "Measurement Period" -define "Age of infant Value": - "Age of infant" O - return O.value + /* End of Age of infant */ +define "Age of infant in days": + "Infant date of birth Value" bd + return CalculateAgeInDaysAt(bd, start of "Measurement Period") + +define "Age of infant in hours": + "Infant date of birth Value" bd + return CalculateAgeInHoursAt(bd, start of "Measurement Period") + +define "Age of infant in weeks": + "Infant date of birth Value" bd + return CalculateAgeInWeeksAt(bd, start of "Measurement Period") +define "Age of infant in years": + "Infant date of birth Value" bd + return CalculateAgeInYearsAt(bd, start of "Measurement Period") /* @dataElement: HIV.E.DE112 - HIV-exposed infant or child @activity: HIV.F6 Check whether infant/child had HIV exposure