Skip to content

Commit

Permalink
Updated naming and fixed some errors (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
pmanko authored Jul 24, 2024
1 parent b3be247 commit e131a11
Show file tree
Hide file tree
Showing 6 changed files with 190 additions and 162 deletions.
62 changes: 32 additions & 30 deletions input/cql/HIVCommon.cql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -121,15 +123,15 @@ 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")
and O.value ~ HC."People who inject drugs - HIV.B.DE54"
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"
Expand Down Expand Up @@ -301,39 +303,39 @@ 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"
)

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"
)

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"
)

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"
)

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"
Expand All @@ -360,23 +362,23 @@ 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"
)

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"
)

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"
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -876,28 +878,28 @@ define "VMMC_adverse_event_Postoperative":
//(including PrEP, OAMT, NSP, STI services, VMMC)
define "HIV prevention intervention":
List<String>{
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
"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
24 changes: 12 additions & 12 deletions input/cql/HIVConcepts.cql
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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'
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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'
Expand Down
Loading

0 comments on commit e131a11

Please sign in to comment.