Skip to content

Commit

Permalink
Updated decision logic/scheduling for Measles.
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeaduncan committed Sep 20, 2023
1 parent f195ea1 commit d6eaf0b
Show file tree
Hide file tree
Showing 8 changed files with 203 additions and 41 deletions.
43 changes: 43 additions & 0 deletions input/cql/IMMZCommon.cql
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,12 @@ or [Condition] C
where (C.code as CodeableConcept) in Wcon."Pregnancy Status Pregnant"
*/
/*
define "Patient Has Active Sickle-cell disease":
exists([Condition: code = IMMZc."Sickle-cell Disease Condition"] C
where C.clinicalStatus in FC."Active Condition"
and C.abatement is null)
*/
define "Pregnant Condition":
[Condition] C
Expand All @@ -76,9 +78,11 @@ define "Pregnant":
or exists ("Pregnant Condition")
//Seronegative. Relevant for Dengue
/*
define "Individual is Seronegative for Dengue":
[Observation] O
where (O.value as CodeableConcept) in IMMZc.Seronegative
*/
//Total number of births including abortions, stillbirths and live births.
define "Patient mother's pregnancy outcome observation":
Expand Down Expand Up @@ -168,6 +172,45 @@ define "Current Patient Age In Months":
define "Patient Biological Sex":
Patient.gender

define "Patient HAART Treatment Start Date":
Last([MedicationAdministration] A
where
ExtractMedicationCode(A.medication) in IMMZc."ARV Drugs"
and A.status in { 'active', 'complete' }
and ExtractMedicationInitiationDate(A.effective) less than 12 'month' before Today()
return ExtractMedicationInitiationDate(A.effective))

define "Patient HAART Treatment Started 6 to 12 Months Ago":
"Patient HAART Treatment Start Date" between Now() - 12 months and Now() - 6 months

/**
* @dataElement The patient has a medication record which indicates that they are receiving ARV
*/
define "Patient is receiving HAART":
//exists([MedicationStatement] S where ExtractMedicationCode(S.medication) in IMMZc."ARV Drugs" and S.status = 'active')
//or
exists([MedicationAdministration] A where ExtractMedicationCode(A.medication) in IMMZc."ARV Drugs" and A.status = 'in-progress')
//union
//

/*
@dataElement HIV Status observations of the patient most recent first
*/
define "HIV Status":
[Observation: IMMZc."HIV status"] O
where O.status in { 'final', 'amended', 'corrected' }
and Coalesce(WCom.ModifierExtension(O, 'who-notDone').value, false) is false
return O.value as FHIR.CodeableConcept

/*
@dataElement Date and time of last live attenuated vaccine
*/
define "Live Attenuated Vaccines":
"Doses Administered to Patient" I where I.vaccineCode in IMMZc."Live Attenuated"

define "Date of Latest Live Attenuated Vaccine":
First("Live Attenuated Vaccines").occurrence as dateTime

/******************************
* CQL Helper Functions
*/
Expand Down
11 changes: 11 additions & 0 deletions input/cql/IMMZConcepts.cql
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,24 @@ valueset "Positive Result": 'http://fhir.org/guides/who/smart-immunization/Value
valueset "Immunocompromised": 'http://fhir.org/guides/who/smart-immunization/ValueSet/Immunocompromised-values'
valueset "Patient birth weight observation value": 'http://fhir.org/guides/who/smart-immunization/ValueSet/Birthweight-values'
valueset "PretermBirth": 'http://fhir.org/guides/who/smart-immunization/ValueSet/Preterm-values'
valueset "Live Attenuated": 'http://fhir.org/guides/who/smart-immunization/ValueSet/LiveAttenduatedVaccines'

//valueset "Target Disease": 'http://hl7.org/fhir/ValueSet/immunization-target-disease'

valueset "HIV status": 'http://fhir.org/guides/who/smart-immunization/ValueSet/HIVstatus-values'
valueset "HIV status - HIV positive Choices": 'http://fhir.org/guides/who/anc-cds/ValueSet/anc-b9-de46'
valueset "HIV status - HIV negative Choices": 'http://fhir.org/guides/who/anc-cds/ValueSet/anc-b9-de47'

valueset "ARV Drugs": 'http://fhir.org/guides/who/smart-immunization/ValueSet/ARVDrugs-values'

// Vaccine Value Sets

valueset "MCV Vaccine": 'http://fhir.org/guides/who/smart-immunization/ValueSet/IMMZ.A1.DE9'

// Plugin is complaining about not finding these so that should be resolved, but here until it can be fixed
valueset "BCG Vaccine": 'http://fhir.org/guides/who/smart-immunization/ValueSet/IMMZ.A1.DE1'
valueset "Cholera Vaccine": 'http://fhir.org/guides/who/smart-immunization/ValueSet/IMMZ.A1.DE2'



code "Adverse Event Severity": '246112005' from "SNOMED-CT" display 'Severity (attribute)'
Expand Down
95 changes: 54 additions & 41 deletions input/cql/IMMZDT08.cql
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,30 @@ context Patient
* @dataElement Should provision MCV Dose
*/
define "Provision of the MCV dose":
"Second MCV Dose Administered to Patient" is null or
(
"Needs Supplimentary MCV Dose" and "Supplimentary MCV Dose Administered to Patient" is null
not("MCV Dose Contraindicated")
and IMMZCom."Date of Latest Live Attenuated Vaccine" + 4 weeks <= Now()
and (
"Second MCV Dose Administered to Patient" is null or
(
"Needs Supplementary MCV Dose" and "Supplementary MCV Dose Administered to Patient" is null
)
)

define "Schedule Due Date for MCV dose":
if "Expected Due Date for MCV dose" > IMMZCom."Date of Latest Live Attenuated Vaccine" + 4 weeks
then "Expected Due Date for MCV dose"
else IMMZCom."Date of Latest Live Attenuated Vaccine" + 4 weeks

define "Expected Due Date for MCV dose":
case
when "Needs Birth MCV Dose"
then Patient.birthDate + 6 months
when "No MCV Doses Administered to Patient"
then if "High Transmission Setting" then Patient.birthDate + 9 months else Patient.birthDate + 12 months
when "Second MCV Dose Administered to Patient" is not null and "Needs Supplimentary MCV Dose"
then IMMZCom."Patient HAART Treatment Start Date" + 6 months
when "Second MCV Dose Administered to Patient" is not null and "Needs Supplementary MCV Dose"
then "Date Second MCV Dose Administered to Patient" + 4 weeks
when "First MCV Dose Administered to Patient" is not null
then if Patient.birthDate + 15 months > "Date First MCV Dose Administered to Patient" + 4 weeks then Patient.birthDate + 15 months else "Date First MCV Dose Administered to Patient" + 4 weeks
then Patient.birthDate + 15 months
else null
end

Expand All @@ -48,14 +57,14 @@ define "MCV Next Dose Number":
if "Needs Birth MCV Dose" or "Birth MCV Dose Administered to Patient" is not null
then
case
when "Second MCV Dose Administered to Patient" is not null and "Needs Supplimentary MCV Dose" then 'booster'
when "Second MCV Dose Administered to Patient" is not null and "Needs Supplementary MCV Dose" then 'booster'
when "First MCV Dose Administered to Patient" is not null then 3
when "Birth MCV Dose Administered to Patient" is not null then 2
else 1
end
else
case
when "Second MCV Dose Administered to Patient" is not null and "Needs Supplimentary MCV Dose" then 'booster'
when "Second MCV Dose Administered to Patient" is not null and "Needs Supplementary MCV Dose" then 'booster'
when "First MCV Dose Administered to Patient" is not null then 2
else 1
end
Expand All @@ -69,8 +78,6 @@ define "Expiration Date for MCV dose":
case
when "Needs Birth MCV Dose"
then Patient.birthDate + 9 months
when "Needs Supplimentary MCV Dose"
then IMMZCom."Patient HAART Treatment Start Date" + 12 months
else null
end

Expand All @@ -79,7 +86,7 @@ define "Overdue Date for MCV dose":

define "Date Last Valid MCV Dose":
case
when "Supplimentary MCV Dose Administered to Patient" is not null then "Date Supplimentary MCV Dose Administered to Patient"
when "Supplementary MCV Dose Administered to Patient" is not null then "Date Supplementary MCV Dose Administered to Patient"
when "Second MCV Dose Administered to Patient" is not null then "Date Second MCV Dose Administered to Patient"
when "First MCV Dose Administered to Patient" is not null then "Date First MCV Dose Administered to Patient"
when "Birth MCV Dose Administered to Patient" is not null then "Date Birth MCV Dose Administered to Patient"
Expand All @@ -89,6 +96,8 @@ define "Date Last Valid MCV Dose":
define "Should vaccinate patient for MCV":
"Provision of the MCV dose" and ("Schedule Due Date for MCV dose" <= (Now()))

define "MCV Dose Contraindicated":
IMMZCom."Pregnant"

/**
* @dataElement MCV containing Doses Administered to Patient
Expand Down Expand Up @@ -128,29 +137,33 @@ define "High Transmission Setting":
)

define "Needs Birth MCV Dose":
"No MCV Doses Administered to Patient" and
(
IMMZCom."Current Patient Age In Months" between 6 and 9 and
(
"No MCV Doses Administered to Patient"
and (
if "High Transmission Setting"
then IMMZCom."Current Patient Age In Months" between 6 and 9
else IMMZCom."Current Patient Age In Months" between 6 and 12
)
and IMMZCom."Date of Latest Live Attenuated Vaccine" +4 weeks <= Now()
and
(
IMMZCom."HIV Status" in IMMZc."HIV status - HIV positive Choices" and
not(IMMZCom."Patient is receiving HAART")
(
IMMZCom."HIV Status" in IMMZc."HIV status - HIV positive Choices"
and (
not(IMMZCom."Patient is receiving HAART")
or "Immune reconstitution was achieved"
)
)
or "Individual is known to be HIV-infected or exposed"
)
or "High Transmission Setting"
)
)

define "Needs Supplimentary MCV Dose":
not(IMMZCom."Pregnant") and
IMMZCom."HIV Status" in IMMZc."HIV status - HIV positive Choices" and
IMMZCom."Patient is receiving HAART" and
(
define "Needs Supplementary MCV Dose":
IMMZCom."HIV Status" in IMMZc."HIV status - HIV positive Choices"
and IMMZCom."Current Patient Age In Years" < 15
and IMMZCom."Patient is receiving HAART"
and "Immune reconstitution was achieved"
and "Supplementary MCV Dose Administered to Patient" is null
and IMMZCom."Date of Latest Live Attenuated Vaccine" +4 weeks <= Now()

"Immune reconstitution was achieved" or
not exists(IMMZCom."Observed CD4% Measurements")
and IMMZCom."Patient HAART Treatment Start Date" <= Now()
and IMMZCom."Patient HAART Treatment Start Date" + 12 months >= Now()
)

/**
* @dataElement Birth MCV dose given to Patient
Expand Down Expand Up @@ -196,19 +209,19 @@ define "Date Second MCV Dose Administered to Patient":
* @dataElement "Second MCV Dose Administered to Patient"
* only valid if 4 weeks after first dose
*/
define "Supplimentary MCV Dose Administered to Patient":
Last("MCV Doses Administered to Patient" I where I.occurrence after IMMZCom."Patient HAART Treatment Start Date" + 6 months)
define "Supplementary MCV Dose Administered to Patient":
Last("MCV Doses Administered to Patient" I where I.occurrence after "Date Second MCV Dose Administered to Patient")

/**
* @dataElement Date second MCV dose administered
*/
define "Date Supplimentary MCV Dose Administered to Patient":
date from ("Supplimentary MCV Dose Administered to Patient".occurrence as FHIR.dateTime)
define "Date Supplementary MCV Dose Administered to Patient":
date from ("Supplementary MCV Dose Administered to Patient".occurrence as FHIR.dateTime)

/*
* Rule: Should vaccinate patient for measles (supplimentary) because no doses
* Rule: Should vaccinate patient for measles (Supplementary) because no doses
* Annotations:
* - Provide measles immunization supplimentary dose - Using the "MCV0 Vaccine immunization - NO Previous" schedule (supplimentary dose zero)
* - Provide measles immunization Supplementary dose - Using the "MCV0 Vaccine immunization - NO Previous" schedule (Supplementary dose zero)
* -
* Outputs:
* - Immunize patient for Measles - No doses
Expand All @@ -220,7 +233,7 @@ define "Date Supplimentary MCV Dose Administered to Patient":
* ((((((((((("Measles vaccine immunization history" = "No-doses" = true) and ("Current Patient Age in Months" > 6)) and ("HIV Status" = "Positive" = true)) and ("Current Patient Age in Months" < 9)) and ("Patient is receiving HAART" = false)) or (((("Measles vaccine immunization history" = "No-doses" = true) and ("Current Patient Age in Months" > 6)) and ("Country currently has a measles outbreak" = true)) and ("Current Patient Age in Months" < 9))) or (((("Measles vaccine immunization history" = "No-doses" = true) and ("Current Patient Age in Months" > 6)) and ("In a setting where the risk of measles among infants < 9 months of age remains high" = true)) and ("Current Patient Age in Months" < 9))) or (((("Measles vaccine immunization history" = "No-doses" = true) and ("Current Patient Age in Months" > 6)) and ("Population is in conflict zones internally displaced populations and refugees" = true)) and ("Current Patient Age in Months" < 9))) or (((("Measles vaccine immunization history" = "No-doses" = true) and ("Current Patient Age in Months" > 6)) and ("Individual is at high risk of contracting measles (e.g. contacts of known measles cases or in settings with increased risk of exposure during outbreaks suck as day-care facilities" = true)) and ("Current Patient Age in Months" < 9))) or (((("Measles vaccine immunization history" = "No-doses" = true) and ("Current Patient Age in Months" > 6)) and ("Individual is travelling to a country experiencing measles outbreaks" = true)) and ("Current Patient Age in Months" < 9))) or (((("Measles vaccine immunization history" = "No-doses" = true) and ("Current Patient Age in Months" > 6)) and ("Individual is known to be HIV-infected or exposed (i.e. born to an HIV-infected woman" = true)) and ("Current Patient Age in Months" < 9)))
*/
/*
define "Should vaccinate patient for measles (supplimentary) because no doses":
define "Should vaccinate patient for measles (Supplementary) because no doses":
IMMZCom."No MCV Doses Administered to Patient" and
(
IMMZCom."Current Patient Age In Months" between 6 and 9 and
Expand Down Expand Up @@ -290,12 +303,12 @@ define "Should vaccinate patient for measles because 1 dose in a 2 dose scheme":
*/

/*
* Rule: Should vaccinate patient for measles supplimentary dose because HIV positive and started HAART
* Rule: Should vaccinate patient for measles Supplementary dose because HIV positive and started HAART
* Annotations:
* - Provide measles immunization supplimentary dose - Using the "MCV Vaccine immunization" schedule (additional supplimentary dose)
* - Provide measles immunization Supplementary dose - Using the "MCV Vaccine immunization" schedule (additional Supplementary dose)
* -
* Outputs:
* - Immunize patient for Measles supplimentary
* - Immunize patient for Measles Supplementary
* -
* References:
* - WHO recommendations for routine immunization - summary tables: https://www.who.int/teams/immunization-vaccines-and-biologicals/policies/who-recommendations-for-routine-immunization---summary-tables
Expand All @@ -304,7 +317,7 @@ define "Should vaccinate patient for measles because 1 dose in a 2 dose scheme":
* ((((("HIV Status" = "Positive" = true) and ("Patient is receiving HAART" = true)) and ("Immune reconstitution was achieved" = true)) and ("Pregnancy Status" = false)) or (((((("HIV Status" = "Positive" = true) and ("Patient is receiving HAART" = true)) and ("CD4+ T Lymphocyte monitoring is available" = false)) and ("Time since HAART was initiated in Months" >= 6)) and ("Time since HAART was initiated in Months" <= 12)) and ("Pregnancy Status" = false)))
*/
/*
define "Should vaccinate patient for measles supplimentary dose because HIV positive and started HAART":
define "Should vaccinate patient for measles Supplementary dose because HIV positive and started HAART":
not(IMMZCom."Pregnant") and
IMMZCom."HIV Status" in IMMZc."HIV status - HIV positive Choices" and
IMMZCom."Patient is receiving HAART" and
Expand Down
9 changes: 9 additions & 0 deletions input/fsh/ValueSet_ARVDrugs.fsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ValueSet: ARVDrugsvalues
Id: ARVDrugs-values
Title: "ARV Drugs values"
Description: "Codes representing ARV Drugs values"
* ^status = #draft
* ^experimental = false
* ^immutable = true
* $SCT#713540004 "Substance with antiretroviral mechanism of action (substance)"
* $SCT#788075003 "Medicinal product acting as antiretroviral agent (product)"
14 changes: 14 additions & 0 deletions input/fsh/ValueSet_HIVstatus.fsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//Example Valuset you can use as a template to create new ones
//change ValueSet name, Id, Title, Description
ValueSet: HIVstatusvalues
Id: HIVstatus-values
Title: "HIV status values"
Description: "Codes representing HIV status values"
//don't touch status, experimental, immutable
* ^status = #draft
* ^experimental = false
* ^immutable = true
//fill in codes, check AL_CodeSystems.fsh for the short names of the codesystem
* $SCT#278977008 "Human immunodeficiency virus status (observable entity)"
* $ICD11#1C62.Z "Human immunodeficiency virus disease without mention of associated disease or condition, clinical stage unspecified"
* $ICD11#MA14.0 "Laboratory evidence of human immunodeficiency virus"
31 changes: 31 additions & 0 deletions input/fsh/ValueSet_LiveAttenuated.fsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//Example Valuset you can use as a template to create new ones
//change ValueSet name, Id, Title, Description
ValueSet: LiveAttenuatedVaccines
Id: LiveAttenuatedVaccines
Title: "Set of live attenuated vaccines"
Description: "Codes representing live attenuated vaccines"
//don't touch status, experimental, immutable
* ^status = #draft
* ^experimental = false
* ^immutable = true
//fill in codes, check AL_CodeSystems.fsh for the short names of the codesystem
* $ICD11#XM8142
* $ICD11#XM72A0
* $ICD11#XM47S0
* $ICD11#XM8L15
* $ICD11#XM8TF3
* $ICD11#XM21H2
* $ICD11#XM4AJ8
* $ICD11#XM9439
* $ICD11#XM2340
* $ICD11#XM79H3
* $ICD11#XM0VX8
* $ICD11#XM0KZ1
* $ICD11#XM4GV0
* $ICD11#XM9PS9
* $ICD11#XM3B09
* $ICD11#XM5V64
* $ICD11#XM33K4
* $ICD11#XM0NS8
* $ICD11#XM3418
* $ICD11#XM5DF6
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"resourceType": "Observation",
"id": "birthweightnormal-NoVaxeninfant-f",
"status": "final",
"code": {
"coding": [
{
"code": "276610007",
"system": "http://snomed.info/sct",
"display": "Birthweight"
}
]
},
"subject": {
"reference": "Patient/IMMZ-Patient-NoVaxeninfant-f"
},
"effectiveDateTime": "2023-03-02",
"valueQuantity": {
"value": 2123,
"code": "g",
"system": "http://unitsofmeasure.org",
"unit": "gram"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"resourceType": "Patient",
"id": "IMMZ-Patient-NoVaxeninfant-f",
"meta": {
"profile": [
"http://worldhealthorganization.github.io/ddcc/StructureDefinition/Patient-uv-ips"
]
},
"name": [
{
"text": "NoVaxeninfant-f",
"use": "official"
}
],
"birthDate": "2023-03-02",
"gender": "female"
}

0 comments on commit d6eaf0b

Please sign in to comment.