Skip to content

Commit

Permalink
62-63
Browse files Browse the repository at this point in the history
  • Loading branch information
Pprado23 committed Aug 18, 2024
1 parent 0475321 commit b95921b
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 77 deletions.
95 changes: 58 additions & 37 deletions input/cql/HIVElements.cql
Original file line number Diff line number Diff line change
Expand Up @@ -2749,10 +2749,8 @@ define "Syphilis test date B.DE249":
@activity: HIV.B23 Offer sexual and reproductive health services
@description: Result from syphilis test
*/
// TODO: Replace placeholder with relevant CQL logic

define "Syphilis test result B.DE250":
exists "Syphilis test result B.DE250 Observation"
define "Syphilis test result B.DE250 Observation":
[Observation: Concepts."Syphilis test result - HIV.B.DE250"] O
where O.status in { 'final', 'amended', 'corrected' }
/* End of Syphilis test result B.DE250 */
Expand All @@ -2762,14 +2760,9 @@ define "Syphilis test result B.DE250 Observation":
@activity: HIV.B23 Offer sexual and reproductive health services
@description: Test result is positive for syphilis
*/
// TODO: Replace placeholder with relevant CQL logic

define "Positive B.DE251":
exists "Positive B.DE251 Condition"
or exists "Positive B.DE251 Observation"
define "Positive B.DE251 Condition":
[Condition: Concepts."Positive - HIV.B.DE251"]
define "Positive B.DE251 Observation":
"Syphilis test result B.DE250 Observation" O
"Syphilis test result B.DE250" O
where O.status in { 'final', 'amended', 'corrected' }
and O.value ~ Concepts."Positive - HIV.B.DE251"
/* End of Positive B.DE251 */
Expand All @@ -2779,14 +2772,9 @@ define "Positive B.DE251 Observation":
@activity: HIV.B23 Offer sexual and reproductive health services
@description: Test result is negative for syphilis
*/
// TODO: Replace placeholder with relevant CQL logic

define "Negative B.DE252":
exists "Negative B.DE252 Condition"
or exists "Negative B.DE252 Observation"
define "Negative B.DE252 Condition":
[Condition: Concepts."Negative - HIV.B.DE252"]
define "Negative B.DE252 Observation":
"Syphilis test result B.DE250 Observation" O
"Syphilis test result B.DE250" O
where O.status in { 'final', 'amended', 'corrected' }
and O.value ~ Concepts."Negative - HIV.B.DE252"
/* End of Negative B.DE252 */
Expand All @@ -2796,14 +2784,9 @@ define "Negative B.DE252 Observation":
@activity: HIV.B23 Offer sexual and reproductive health services
@description: Test result is inconclusive
*/
// TODO: Replace placeholder with relevant CQL logic

define "Inconclusive B.DE253":
exists "Inconclusive B.DE253 Condition"
or exists "Inconclusive B.DE253 Observation"
define "Inconclusive B.DE253 Condition":
[Condition: Concepts."Inconclusive - HIV.B.DE253"]
define "Inconclusive B.DE253 Observation":
"Syphilis test result B.DE250 Observation" O
"Syphilis test result B.DE250" O
where O.status in { 'final', 'amended', 'corrected' }
and O.value ~ Concepts."Inconclusive - HIV.B.DE253"
/* End of Inconclusive B.DE253 */
Expand Down Expand Up @@ -14399,12 +14382,9 @@ define "At elevated risk for HIV acquisition PRV.DE1":
@activity: HIV.B6 Capture or update client history
@description: HIV prevention intervention that client accessed
*/
// TODO: Replace placeholder with relevant CQL logic

define "HIV prevention intervention":
exists "HIV prevention intervention Observation"
define "HIV prevention intervention Observation":
[Observation: Concepts."HIV prevention intervention"] O
where O.status in { 'final', 'amended', 'corrected' }
exists ("PrEP service") or exists("OAMT") or exists("NSP") or exists("STI services") or exists("VMMC") or exists("Other PRV.DE8")
/* End of HIV prevention intervention */

/*
Expand All @@ -14417,6 +14397,11 @@ define "PrEP service":
[MedicationStatement] MS
where exists(MS.reasonCode C where C ~ Concepts."PrEP for HIV prevention")
sort by start of effective.toInterval()

define "PrEP service date":
[MedicationStatement] MS
where exists(MS.reasonCode C where C ~ Concepts."PrEP for HIV prevention")
return start of MS.effective.toInterval()
/* End of PrEP service */

/*
Expand All @@ -14440,8 +14425,19 @@ define "OAMT statusHistory":
EOC.statusHistory H
where H.period is not null))

define "OAMT status date":
[EpisodeOfCare] EOC
where exists(EOC.type T where T ~ Concepts."OAMT")
return start of EOC.period


define "OAMT statusHistory date":
[EpisodeOfCare] EOC
where exists(EOC.type T where T ~ Concepts."OAMT")
and (exists (
EOC.statusHistory H
where H.period is not null))
//return start of "OAMT statusHistory".statusHistory.period
//need to ask brynn

/* End of OAMT */

Expand All @@ -14457,6 +14453,14 @@ define "NSP":
such that DUS.reasonReference.references(D)
and D.status in { 'active' }
where DUS.status = 'completed'

define "NSP date":
[DeviceUseStatement] DUS
with [Device: ConceptsCustom."needle-syringe"] D
such that DUS.reasonReference.references(D)
and D.status in { 'active' }
where DUS.status = 'completed'
return start of DUS.timing.toInterval()
/* End of NSP */

/*
Expand All @@ -14469,6 +14473,12 @@ define "STI services":
[Procedure] P
where P.status = 'completed'
and P.code ~ Concepts."STI testing and treatment services"

define "STI services date":
[Procedure] P
where P.status = 'completed'
and P.code ~ Concepts."STI testing and treatment services"
return start of P.performed.toInterval()
/* End of STI services */

/*
Expand All @@ -14486,6 +14496,12 @@ define "VMMC":
[Procedure] P
where P.status = 'completed'
and P.code ~ Concepts."Voluntary medical male circumcision VMMC"

define "VMMC date":
[Procedure] P
where P.status = 'completed'
and P.code ~ Concepts."Voluntary medical male circumcision VMMC"
return start of P.performed.toInterval()
/* End of VMMC */

/*
Expand All @@ -14500,6 +14516,13 @@ define "Other PRV.DE8":
and O.code ~ Concepts."HIV prevention intervention"
and O.value ~ Concepts."Other - HIV.PRV.DE8"
sort by start of effective.toInterval()

define "Other PRV.DE8 date":
[Observation] O
where O.status in {'final', 'amended'}
and O.code ~ Concepts."HIV prevention intervention"
and O.value ~ Concepts."Other - HIV.PRV.DE8"
return start of O.effective.toInterval()

/* End of Other PRV.DE8 */

Expand All @@ -14508,13 +14531,11 @@ define "Other PRV.DE8":
@activity: HIV.B6 Capture or update client history
@description: Date the client accessed HIV prevention intervention
*/
// TODO: Replace placeholder with relevant CQL logic
define "Date accessed HIV prevention intervention":
[Observation: Concepts."Date accessed HIV prevention intervention"] O
where O.status in { 'final', 'amended', 'corrected' }
define "Date accessed HIV prevention intervention Value":
"Date accessed HIV prevention intervention" O
return O.value

define "Date accessed HIV prevention intervention":
flatten{"PrEP service date", "NSP date", "STI services date", "VMMC date", "Other PRV.DE8 date","OAMT status date"}

//, "OAMT","NSP".timing,"STI services".performed,"VMMC".performed,"Other PRV.DE8".effective}
/* End of Date accessed HIV prevention intervention */

/*
Expand Down
42 changes: 40 additions & 2 deletions input/cql/HIVIND62Logic.cql
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ include HIVCommon version '0.0.1' called HIC
include FHIRHelpers version '4.0.1'

include WHOCommon called WCom
include HIVElements called HE
include HIVIndicatorElements called HIE
include HIVConfig called Config

// Indicator Definition
parameter "Measurement Period" Interval<Date> default Interval[@2023-01-01, @2023-01-30]
Expand All @@ -105,6 +108,7 @@ context Patient
*Initial Population
*/


define "Initial Population":
true

Expand All @@ -116,7 +120,10 @@ define "Initial Population":
*/

define "Numerator":
true
exists(HE."Positive B.DE251" S
with HE."Syphilis test date B.DE249" P
such that S.partOf.references(P) and P.performed.toInterval() during "Measurement Period")



/**
Expand All @@ -127,8 +134,39 @@ define "Numerator":
*/

define "Denominator":
true
exists(HE."Syphilis test date B.DE249" P
where P.performed.toInterval() during "Measurement Period"
and exists (HE."Date accessed HIV prevention intervention" t where t = start of P.performed.toInterval()))


/* end Populations */

/*
* Disaggregators
*/

define "Administrative Gender Stratifier":
HIE."By Administrative Gender Stratifier"

define "Age Stratifier":
HIE."By Age Stratifier 2"

define "Geographic Region Stratifier":
HIE."By Geographic Region Stratifier"

define "patientGroups Stratifier":
HIE."patientGroups"

define "HIV prevention intervention":
HIE."HIV prevention intervention"

define "HIV Status":
HIE."HIV Status Stratifier"

define "Stratification":
HIE."By Administrative Gender Stratifier".code
+ ':' + HIE."By Age Stratifier 2"
+ ':' + HIE."By Geographic Region Stratifier"
+ Combine(HIE.patientGroups, ':')
+ Combine(HIE."HIV prevention intervention", ':')
+ ':' + HIE."HIV Status Stratifier".code
49 changes: 11 additions & 38 deletions input/cql/HIVIndicatorElements.cql
Original file line number Diff line number Diff line change
Expand Up @@ -1730,29 +1730,20 @@ define "Syphilis test date B.DE249":
@activity: HIV.B23 Offer sexual and reproductive health services
@description: Result from syphilis test
*/
// TODO: Replace placeholder with relevant CQL logic

define "Syphilis test result B.DE250":
exists "Syphilis test result B.DE250 Observation"
define "Syphilis test result B.DE250 Observation":
Elements."Syphilis test result B.DE250 Observation" O
where O.effective.toInterval() during "Measurement Period"
exists(Elements."Syphilis test result B.DE250" O
where O.effective.toInterval() during "Measurement Period")
/* End of Syphilis test result B.DE250 */

/*
@dataElement: HIV.B.DE251 - Positive
@activity: HIV.B23 Offer sexual and reproductive health services
@description: Test result is positive for syphilis
*/
// TODO: Replace placeholder with relevant CQL logic

define "Positive B.DE251":
exists "Positive B.DE251 Condition"
or exists "Positive B.DE251 Observation"
define "Positive B.DE251 Condition":
Elements."Positive B.DE251 Condition" C
where C.prevalenceInterval() overlaps before "Measurement Period"
or C.prevalenceInterval() overlaps after "Measurement Period"
define "Positive B.DE251 Observation":
Elements."Positive B.DE251 Observation" O
exists Elements."Positive B.DE251" O
where O.effective.toInterval() during "Measurement Period"
/* End of Positive B.DE251 */

Expand All @@ -1761,16 +1752,9 @@ define "Positive B.DE251 Observation":
@activity: HIV.B23 Offer sexual and reproductive health services
@description: Test result is negative for syphilis
*/
// TODO: Replace placeholder with relevant CQL logic

define "Negative B.DE252":
exists "Negative B.DE252 Condition"
or exists "Negative B.DE252 Observation"
define "Negative B.DE252 Condition":
Elements."Negative B.DE252 Condition" C
where C.prevalenceInterval() overlaps before "Measurement Period"
or C.prevalenceInterval() overlaps after "Measurement Period"
define "Negative B.DE252 Observation":
Elements."Negative B.DE252 Observation" O
exists Elements."Negative B.DE252" O
where O.effective.toInterval() during "Measurement Period"
/* End of Negative B.DE252 */

Expand All @@ -1779,16 +1763,9 @@ define "Negative B.DE252 Observation":
@activity: HIV.B23 Offer sexual and reproductive health services
@description: Test result is inconclusive
*/
// TODO: Replace placeholder with relevant CQL logic

define "Inconclusive B.DE253":
exists "Inconclusive B.DE253 Condition"
or exists "Inconclusive B.DE253 Observation"
define "Inconclusive B.DE253 Condition":
Elements."Inconclusive B.DE253 Condition" C
where C.prevalenceInterval() overlaps before "Measurement Period"
or C.prevalenceInterval() overlaps after "Measurement Period"
define "Inconclusive B.DE253 Observation":
Elements."Inconclusive B.DE253 Observation" O
exists Elements."Inconclusive B.DE253" O
where O.effective.toInterval() during "Measurement Period"
/* End of Inconclusive B.DE253 */

Expand Down Expand Up @@ -6620,13 +6597,9 @@ define "Other PRV.DE8":
@activity: HIV.B6 Capture or update client history
@description: Date the client accessed HIV prevention intervention
*/
// TODO: Replace placeholder with relevant CQL logic

define "Date accessed HIV prevention intervention":
Elements."Date accessed HIV prevention intervention" O
where O.effective.toInterval() during "Measurement Period"
define "Date accessed HIV prevention intervention Value":
"Date accessed HIV prevention intervention" O
return O.value
exists (Elements."Date accessed HIV prevention intervention" t where t included in "Measurement Period")
/* End of Date accessed HIV prevention intervention */

/*
Expand Down

0 comments on commit b95921b

Please sign in to comment.