Skip to content

Commit

Permalink
Added in CQL/plandef for Yellow Fever decision tables and contraindic…
Browse files Browse the repository at this point in the history
…ations. Added examples/tests for these. Added MedicationRequest to all Measles contraindication examples.
  • Loading branch information
lukeaduncan committed Jan 23, 2024
1 parent 20d4904 commit 14cf98d
Show file tree
Hide file tree
Showing 45 changed files with 1,296 additions and 9 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ temp
template
bundles
*.jar
.DS_Store
.DS_Store
**/tests-*-bundle.json
5 changes: 5 additions & 0 deletions input/cql/IMMZCommon.cql
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ define "Severe Allergic Reactions Condition":
define "Symptomatic HIV Infection Condition":
[Condition: IMMZc."Symptomatic HIV infection"]

define "Severely immunocompromised Condition":
[Condition: IMMZc."Severely immunocompromised"]

define "Breastfeeding Condition":
[Condition: IMMZc."Breastfeeding"]

/******************************
* Test Results
Expand Down
5 changes: 4 additions & 1 deletion input/cql/IMMZConcepts.cql
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ valueset "HIV status - HIV negative Choices": 'http://fhir.org/guides/who/anc-cd

valueset "ARV Drugs": 'http://smart.who.int/ig/smart-immunizations/ValueSet/ARVDrugs-values'

// Vaccine Value Sets
// Vaccine Value Sets

valueset "MCV Vaccine": 'http://smart.who.int/ig/smart-immunizations/ValueSet/IMMZ.Z.DE9'
valueset "Yellow Fever Vaccine": 'http://smart.who.int/ig/smart-immunizations/ValueSet/IMMZ.Z.DE23'

// Plugin is complaining about not finding these so that should be resolved, but here until it can be fixed
valueset "BCG Vaccine": 'http://smart.who.int/ig/smart-immunizations/ValueSet/IMMZ.A1.DE1'
Expand All @@ -53,3 +54,5 @@ code "Severely immunosuppressed": 'DE165' from "IMMZ.D" display 'Severely immuno
code "History of anaphylactic reactions": 'DE166' from "IMMZ.D" display 'History of anaphylactic reactions'
code "Severe allergic reactions": 'DE167' from "IMMZ.D" display 'Severe allergic reactions'
code "Symptomatic HIV infection": 'DE168' from "IMMZ.D" display 'Symptomatic HIV infection'
code "Severely immunocompromised": 'DE200' from "IMMZ.D" display 'Severely immunocompromised'
code "Breastfeeding": 'DE191' from "IMMZ.D" display 'Breastfeeding'
104 changes: 104 additions & 0 deletions input/cql/IMMZD2DTYellowFever.cql
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/*
* Library: IMMZD2DTYellowFever (IMMZ.D2.DT.YellowFever)
* Rule: Determine if the client is due for a yellow fever vaccination according to the national immunization protocol
* Trigger: IMMZ.D2 Determine required vaccination(s) if any
*/
library IMMZD2DTYellowFever
// Start Skeleton CQL
using FHIR version '4.0.1'
include FHIRHelpers version '4.0.1'
include IMMZCommon called IMMZCom
include IMMZConcepts called IMMZc
include IMMZConfig called IMMZCon
include IMMZVaccineLibrary called IMMZvl
include FHIRCommon called FC
include IMMZD2DTYellowFeverInput called input

// End Skeleton CQL
context Patient

/*
@dynamicValue: Due date of the dose
*/
define "Due date of the dose":
Now()

/*
@dynamicValue: Guidance
*/
define "Guidance":
case
when "Yellow fever immunization schedule is complete" then "Yellow fever immunization schedule is complete Guidance"
when "Client is due for yellow fever vaccination" then "Client is due for yellow fever vaccination Guidance"
when "Client is not due for yellow fever vaccination" then "Client is not due for yellow fever vaccination Guidance"
else null
end

/*
@output: Client is not due for yellow fever vaccination
@pseudocode: "Immunization recommendation status" = 'Not due'
*/
define "Client is not due for yellow fever vaccination":
"Client is not due for yellow fever vaccination Case 1" or "Client is not due for yellow fever vaccination Case 2"

/*
@output: Client is not due for yellow fever vaccination Guidance
@guidance: Should not vaccinate client for yellow fever dose as client's age is less than 9 months. Check for any vaccines due, and inform the caregiver of when to come back for the next dose.
@guidance: Should not vaccinate client for yellow fever dose as live vaccine was administered in the last 4 weeks. Check for any vaccines due, and inform the caregiver of when to come back for the first dose.
*/
define "Client is not due for yellow fever vaccination Guidance":
case
when "Client is not due for yellow fever vaccination Case 1" then 'Should not vaccinate client for yellow fever dose as client\'s age is less than 9 months. Check for any vaccines due, and inform the caregiver of when to come back for the next dose.'
when "Client is not due for yellow fever vaccination Case 2" then 'Should not vaccinate client for yellow fever dose as live vaccine was administered in the last 4 weeks. Check for any vaccines due, and inform the caregiver of when to come back for the first dose.'
else ''
end

/*
@output: Client is not due for yellow fever vaccination Case 1
@pseudocode: "Immunization recommendation status" = 'Not due'
*/
define "Client is not due for yellow fever vaccination Case 1":
input."No yellow fever primary series doses were administered"
and input."Client's age is less than 9 months"

/*
@output: Client is not due for yellow fever vaccination Case 2
@pseudocode: "Immunization recommendation status" = 'Not due'
*/
define "Client is not due for yellow fever vaccination Case 2":
input."No yellow fever primary series doses were administered"
and input."Client's age is more than or equal to 9 months"
and input."Live vaccine was administered in the last 4 weeks"

/*
@output: Client is due for yellow fever vaccination
@pseudocode: "Immunization recommendation status" = "Due"
*/
define "Client is due for yellow fever vaccination":
input."No yellow fever primary series doses were administered"
and input."Client's age is more than or equal to 9 months"
and input."No live vaccine was administered in the last 4 weeks"

/*
@output: Client is due for yellow fever vaccination Guidance
@guidance: Should vaccinate client for yellow fever dose as no yellow fever dose was administered, client is within appropriate age range and no live vaccine was administered in the last 4 weeks. Check for contraindications.
*/
define "Client is due for yellow fever vaccination Guidance":
if "Client is due for yellow fever vaccination" then 'Should vaccinate client for yellow fever dose as no yellow fever dose was administered, client is within appropriate age range and no live vaccine was administered in the last 4 weeks. Check for contraindications.'
else ''

/*
@output: Yellow fever immunization schedule is complete
@pseudocode: "Immunization recommendation status"" = 'Complete'
@pseudocode: "Completed the primary vaccination series" = TRUE (where "Vaccine type" = "Yellow fever containing vaccines")
*/
define "Yellow fever immunization schedule is complete":
input."One yellow fever primary series dose was administered"

/*
@output: Yellow fever immunization schedule is complete Guidance
@guidance: Yellow fever immunization schedule is complete. One yellow fever primary series dose was administered. Check for any other vaccines due.
*/
define "Yellow fever immunization schedule is complete Guidance":
if "Yellow fever immunization schedule is complete" then 'Yellow fever immunization schedule is complete. One yellow fever primary series dose was administered. Check for any other vaccines due.'
else ''
123 changes: 123 additions & 0 deletions input/cql/IMMZD2DTYellowFeverInput.cql
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
/*
* Library: IMMZD2DTYellowFeverInput (IMMZ.D2.DT.YellowFeverInput)
* Rule: Determine if the client is due for a yellow fever vaccination according to the national immunization protocol
* Trigger: IMMZ.D2 Determine required vaccination(s) in any
*/
library IMMZD2DTYellowFeverInput
// Start Skeleton CQL
using FHIR version '4.0.1'
include FHIRHelpers version '4.0.1'
include IMMZCommon called IMMZCom
include IMMZConcepts called IMMZc
include IMMZConfig called IMMZCon
include IMMZVaccineLibrary called IMMZvl
include FHIRCommon called FC

// End Skeleton CQL
context Patient

/*
@internal: Yellow Fever containing Doses Administered to Patient
*/
define "Yellow Fever Doses Administered to Patient":
IMMZCom."Doses Administered to Patient" I
where
I.vaccineCode in IMMZc."Yellow Fever Vaccine"

/*
@input: No yellow fever primary series doses were administered
@pseudocode: Count of vaccines administered (where "Vaccine type" = "Yellow fever containing vaccines" and "Type of dose" = "Primary series" ) = 0
*/
define "No yellow fever primary series doses were administered":
not exists("Yellow Fever Doses Administered to Patient" I where I.occurrence after Patient.birthDate + 9 months)

/*
@input: One yellow fever primary series dose was administered
@pseudocode: Count of vaccines administered (where "Vaccine type" = "Yellow fever containing vaccines" and "Type of dose" = "Primary series" ) = 1
*/
define "One yellow fever primary series dose was administered":
Count("Yellow Fever Doses Administered to Patient" I where I.occurrence after Patient.birthDate + 9 months) >= 1

/*
@input: Client's age is less than 6 months
@pseudocode: Today's date - "Date of birth" < 6 'month'
*/
define "Client's age is less than 6 months":
IMMZCom."Current Patient Age In Months" < 6

/*
@input: Client's age is between 6 to 9 months
@pseudocode: 6 'month' ≤ Today's date - "Date of birth" < 9 'month'
*/
define "Client's age is between 6 to 9 months":
not("Client's age is less than 6 months") and "Client's age is less than 9 months"

/*
@input: Client's age is less than 9 months
@pseudocode: Today's date - "Date of birth" < 9 'month'"
*/
define "Client's age is less than 9 months":
IMMZCom."Current Patient Age In Months" < 9

/*
@input: Client's age is more than or equal to 9 months
@pseudocode: Today's date - "Date of birth" ≥ 9 'month'
*/
define "Client's age is more than or equal to 9 months":
not ("Client's age is less than 9 months")

/*
@input: Client's age is more than or equal to 60 years
@pseudocode: 'Today's date - ""Date of birth"" ≥ 60 'year'
*/
define "Client's age is more than or equal to 60 years":
IMMZCom."Current Patient Age In Years" >= 60

/*
@input: Live vaccine was administered in the last 4 weeks
@pseudocode: Today's date - latest "Date and time of vaccination" (where "Live vaccine" = TRUE) < 4 'week'
*/
define "Live vaccine was administered in the last 4 weeks":
IMMZCom."Date of Latest Live Attenuated Vaccine" is not null and IMMZCom."Date of Latest Live Attenuated Vaccine" + 4 weeks > Now()

/*
@input: No live vaccine was administered in the last 4 weeks
@pseudocode: Today's date - latest "Date and time of vaccination" (where "Live vaccine" = TRUE) ≥ 4 'week'
*/
define "No live vaccine was administered in the last 4 weeks":
not("Live vaccine was administered in the last 4 weeks")

/*
@input: The client is currently pregnant
@pseudocode: "Potential contraindications" = 'Currently pregnant'
*/
define "The client is currently pregnant":
IMMZCom."Pregnant"

/*
@input: The client has a history of severe allergic reactions
@pseudocode: "Potential contraindications" = 'Severe allergic reactions'
*/
define "The client has a history of severe allergic reactions":
exists(IMMZCom."Severe Allergic Reactions Condition")

/*
@input: The client is severely immunocompromised
@psuedocode: "Potential contraindications" = "Severely immunocompromised"
*/
define "The client is severely immunocompromised":
exists(IMMZCom."Severely immunocompromised Condition")

/*
@input: The client has a symptomatic HIV infection
@pseudocode: "Potential contraindications" = 'Symptomatic HIV infection'
*/
define "The client has a symptomatic HIV infection":
exists(IMMZCom."Symptomatic HIV Infection Condition")

/*
@input: The client is lactating
@psuedocode: "Potential contraindications" = "Breastfeeding"
*/
define "The client is lactating":
exists(IMMZCom."Breastfeeding Condition")
2 changes: 1 addition & 1 deletion input/cql/IMMZD5DTMeaslesCI.cql
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ context Patient
@internal: Draft Medication Request for MCV dose
*/
define "Draft Medication Request for MCV dose":
[MedicationRequest] MR where MR.status = 'draft' and MR.intent = 'proposal'
[MedicationRequest: IMMZc."MCV Vaccine"] MR where MR.status = 'draft' and MR.intent = 'proposal'
sort by date from (authoredOn as FHIR.dateTime) desc

/*
Expand Down
Loading

0 comments on commit 14cf98d

Please sign in to comment.