Skip to content

Commit

Permalink
Added in preliminary script to create examples to be used to test CQL…
Browse files Browse the repository at this point in the history
… from a yaml file. This still needs medicationrequests and observations.
  • Loading branch information
lukeaduncan committed Feb 3, 2024
1 parent e21d07b commit 2999bbd
Show file tree
Hide file tree
Showing 12 changed files with 579 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ bundles
.DS_Store
**/tests-*-bundle.json
node_modules/
outputs/*
1 change: 1 addition & 0 deletions input/cql/IMMZConcepts.cql
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,6 @@ 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 "Immunodeficiency syndromes": 'DE187' from "IMMZ.D" display 'Immunodeficiency syndromes'
code "Severely immunocompromised": 'DE200' from "IMMZ.D" display 'Severely immunocompromised'
code "Breastfeeding": 'DE191' from "IMMZ.D" display 'Breastfeeding'
86 changes: 86 additions & 0 deletions input/cql/IMMZD2DTPolioBirth.cql
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*
* Library: IMMZD2DTPolioBirth (IMMZ.D2.DT.Polio.Birth dose)
* Rule: Determine if the client is due for a polio vaccination according to the national immunization protocol
* Decision Table: Birth dose administration as part of "bOPV plus IPV" schedule (In countries that are polio-endemic countries or countries at high risk for importation and subsequent spread of poliovirus, that follow the combined bOPV-IPV schedule)
* Trigger: IMMZ.D2 Determine required vaccination(s) if any
*/
library IMMZD2DTPolioBirth
// 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 IMMZD2DTPolioInput called input

// End Skeleton CQL
context Patient

/*
@dynamicValue: Due date of the dose
*/
define "Due date of the dose":
if "Client is due for the bOPV birth dose" then Patient.birthDate
else null

/*
@dynamicValue: Guidance
*/
define "Guidance":
case
when "Client is due for the bOPV birth dose" then "Client is due for the bOPV birth dose Guidance"
when "Client is not due for the bOPV birth dose" then "Client is not due for the bOPV birth dose Guidance"
else ''
end

/*
@output: Client is due for the bOPV birth dose
@pseudocode: "Immunization recommendation status" = 'Due' (where "Type of polio dose" = 'bOPV')
*/
define "Client is due for the bOPV birth dose":
input."bOPV birth dose (a zero dose) was not administered"
and input."Client's age is less than 1 week"

/*
@output: Client is due for the bOPV birth dose Guidance
@guidance: Should vaccinate client for bOPV birth dose (a zero dose) as polio birth dose was not administered and client's age is less than 1 week. Check for contraindications.
*/
define "Client is due for the bOPV birth dose Guidance":
'Should vaccinate client for bOPV birth dose (a zero dose) as polio birth dose was not administered and client\'s age is less than 1 week. Check for contraindications.'

/*
@output: Client is not due for the bOPV birth dose Case 1
@pseudocode: "Immunization recommendation status" = 'Not due'
*/
define "Client is not due for the bOPV birth dose Case 1":
input."bOPV birth dose (a zero dose) was not administered"
and input."Client's age is more or equal to 1 week"

/*
@output: Client is not due for the bOPV birth dose Case 2
@pseudocode: "Immunization recommendation status" = 'Not due'
*/
define "Client is not due for the bOPV birth dose Case 2":
input."bOPV birth dose (a zero dose) was administered"

/*
@output: Client is not due for the bOPV birth dose
@pseudocode: "Immunization recommendation status" = 'Not due'
*/
define "Client is not due for the bOPV birth dose":
"Client is not due for the bOPV birth dose Case 1"
or "Client is not due for the bOPV birth dose Case 2"

/*
@output: Client is not due for the bOPV birth dose Guidance
@guidance: Should not vaccinate client for bOPV birth dose (a zero dose) as client's age is more than or equal to 1 week. Check for any other vaccines due, and inform the caregiver of when to come back for the next dose.
@guidance: Polio birth dose was already administered. Check polio immunization schedule.
*/
define "Client is not due for the bOPV birth dose Guidance":
case
when "Client is not due for the bOPV birth dose Case 1" then 'Should not vaccinate client for bOPV birth dose (a zero dose) as client\'s age is more than or equal to 1 week. Check for any other vaccines due, and inform the caregiver of when to come back for the next dose.'
when "Client is not due for the bOPV birth dose Case 2" then 'Polio birth dose was already administered. Check polio immunization schedule.'
else ''
end
224 changes: 224 additions & 0 deletions input/cql/IMMZD2DTPolioInput.cql
Original file line number Diff line number Diff line change
@@ -0,0 +1,224 @@
/*
* Library: IMMZD2DTPolioInput (IMMZ.D2.DT.PolioInput)
*/
library IMMZD2DTPolioInput
// 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: Polio containing Doses Administered to Patient
*/
define "Polio Doses Administered to Patient":
IMMZCom."Doses Administered to Patient" I
where
I.vaccineCode in IMMZc."Polio Vaccine"
/*
birth - Birth dose administration as part of "bOPV plus IPV" schedule (In countries that are polio-endemic countries
or countries at high risk for importation and subsequent spread of poliovirus, that follow the combined
bOPV-IPV schedule)
bOPVIPV - bOPV plus IPV schedule (applicable for all countries)
sequential - Sequential IPV–bOPV schedule (in countries with high vaccination coverage (e.g. 90–95%) and low importation
risk (where neighbouring countries and/or countries that share substantial population movement have a
similarly high coverage))
IPVonly - IPV-only (in countries, in polio-free regions, with a very low risk of importation and sustained high routine
immunization coverage (DTP3 >90%)
*/
/*
@input: bOPV birth dose (a zero dose) was not administered
@pseudocode: Count of vaccines administered (where "Vaccine type" = 'Polio containing vaccines' and "Type of dose" = 'Dose 0' AND "Birth Dose" = TRUE) = 0
*/
define "bOPV birth dose (a zero dose) was not administered":
not "bOPV birth dose (a zero dose) was administered"

/*
@input: bOPV birth dose (a zero dose) was administered
@pseudocode: Count of vaccines administered (where "Vaccine type" = 'Polio containing vaccines' and "Type of dose" = 'Dose 0' AND "Birth Dose" = TRUE) = 1
*/
define "bOPV birth dose (a zero dose) was administered":
exists("Polio Doses Administered to Patient" I where I.occurrence before Patient.birthDate + 1 week)

/*
@input: No polio primary series doses were administered
@pseudocode: Count of vaccines administered (where "Vaccine type" = 'Polio containing vaccines' and "Type of dose" = "Primary series") = 0
*/
define "No polio primary series doses were administered":
not exists("Polio Doses Administered to Patient" I where I.occurrence after Patient.birthDate + 6 weeks)

/*
@input: One polio primary series dose was administered
@pseudocode: Count of vaccines administered (where "Vaccine type" = 'Polio containing vaccines' and "Type of dose" = "Primary series") = 1
*/
define "One polio primary series dose was administered":
null

/*
@input: Two polio primary series doses were administered
@pseudocode: Count of vaccines administered (where "Vaccine type" = 'Polio containing vaccines' and "Type of dose" = "Primary series") = 2
*/
define "Two polio primary series doses were administered":
null


/*
@input: Three polio primary series doses were administered
@pseudocode: Count of vaccines administered (where "Vaccine type" = 'Polio containing vaccines' and "Type of dose" = "Primary series") = 3
*/
define "Three polio primary series doses were administered":
null


/*
@input: The polio dose administered is bOPV
@pseudocode: Count of vaccines administered (where "Type of polio dose" = 'bOPV' and "Type of dose" = "Primary series") = 1
*/
define "The polio dose administered is bOPV ":
null


/*
@input: The polio dose administered is IPV
@pseudocode: Count of vaccines administered (where "Type of polio dose" = 'bOPV' and "Type of dose" = "Primary series") = 0
*/
define "The polio dose administered is IPV ":
null


/*
@input: The two doses administered are bOPV
@pseudocode: Count of vaccines administered (where "Type of polio dose" = 'bOPV' and "Type of dose" = "Primary series") = 2
*/
define "The two doses administered are bOPV":
null


/*
@input: From the two doses administered one is bOPV and one is IPV
@pseudocode: Count of vaccines administered (where "Type of polio dose" = 'bOPV' and "Type of dose" = "Primary series") = 1
*/
define "From the two doses administered one is bOPV and one is IPV":
null


/*
@input: The two doses administered are IPV
@pseudocode: Count of vaccines administered (where "Type of polio dose" = 'bOPV' and "Type of dose" = "Primary series") = 0
*/
define "The two doses administered are IPV":

null

/*
@input: The three doses administered are bOPV
@pseudocode: Count of vaccines administered (where "Type of polio dose" = 'bOPV' and "Type of dose" = "Primary series") = 3
*/
define "The three doses administered are bOPV":
null


/*
@input: From the three doses administered one is IPV and two are bOPV
@pseudocode: Count of vaccines administered (where "Type of polio dose" = 'bOPV' and "Type of dose" = "Primary series") = 2
*/
define "From the three doses administered one is IPV and two are bOPV":
null

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

/*
@input: Client's age is more or equal to 1 week
@pseudocode: Today's date - "Date of birth" ≥ 1 'week'
*/
define "Client's age is more or equal to 1 week":
not "Client's age is less than 1 week"

/*
@input: Client's age is less than 6 weeks
@pseudocode: Today's date - "Date of birth" < 6 'week'
*/
define "Client's age is less than 6 weeks":
null


/*
@input: Client's age is between 6 weeks and 3 months
@pseudocode: 6 'week' ≤ Today's date - "Date of birth" ≤ 3 'month'
*/
define "Client's age is between 6 weeks and 3 months":
null


/*
@input: Client's age is more than 3 months
@pseudocode: Today's date - "Date of birth" > 3 'month'
*/
define "Client's age is more than 3 months":
null


/*
@input: Client's age is between 6 weeks and 14 weeks
@pseudocode: 6 'week' '≤ 'Today's date - "Date of birth" < 14 'week'
*/
define "Client's age is between 6 weeks and 14 weeks":
null


/*
@input: Client's age is more than or equal to 14 weeks
@pseudocode: Today's date - "Date of birth" ≥ 14 'week'
*/
define "Client's age is more than or equal to 14 weeks":
null

/*
@input: Client's age is less than 14 weeks
@pseudocode: Today's date - "Date of birth" < 14 'week'
*/
define "Client's age is less than 14 weeks":
null

/*
@input: The latest bOPV dose was administered less than 4 weeks ago
@pseudocode: Today's date - Latest "Date and time of vaccination" (where "Vaccine type" = 'Polio containing vaccines' and "Type of Polio dose" = 'bOPV') < 4 'week'
*/
define "The latest bOPV dose was administered less than 4 weeks ago":
null


/*
@input: The latest bOPV dose was administered more than 4 weeks ago
@pseudocode: Today's date - Latest "Date and time of vaccination" (where "Vaccine type" = 'Polio containing vaccines' and "Type of Polio dose" = 'bOPV') ≥ 4 'week'
*/
define "The latest bOPV dose was administered more than 4 weeks ago":
null


/*
@input: The latest IPV dose was administered less than 4 months ago
@pseudocode: Today's date - Latest "Date and time of vaccination" (where "Vaccine type" = 'Polio containing vaccines' and "Type of polio dose" = 'IPV') < 4 'month'
*/
define "The latest IPV dose was administered less than 4 months ago":
null


/*
@input: The latest IPV dose was administered more than 4 months ago
@pseudocode: Today's date - Latest "Date and time of vaccination" (where "Vaccine type" = 'Polio containing vaccines' and "Type of polio dose" = 'IPV') ≥ 4 'month'
*/
define "The latest IPV dose was administered more than 4 months ago":
null

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"resourceType": "Patient",
"id": "B0Agt1w",
"name": [
{
"text": "B0Agt1w",
"use": "official"
}
],
"birthDate": "2024-01-20",
"gender": "female"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"resourceType": "Patient",
"id": "B0Alt1w",
"name": [
{
"text": "B0Alt1w",
"use": "official"
}
],
"birthDate": "2024-02-02",
"gender": "female"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"resourceType": "Immunization",
"id": "polio-B1",
"status": "completed",
"vaccineCode": {
"coding": [
{
"code": "XM0KZ1",
"system": "http://hl7.org/fhir/sid/icd-11",
"display": "Poliomyelitis oral, trivalent, live attenuated"
}
]
},
"expirationDate": "2025-02-03",
"lotNumber": "123",
"patient": {
"reference": "Patient/B1"
},
"location": {
"display": "Vaccination Site"
},
"occurrenceDateTime": "2024-02-04",
"protocolApplied": [
{
"doseNumberString": "birth"
}
]
}
12 changes: 12 additions & 0 deletions input/tests/plandefinition/IMMZD2DTPolioBirth/B1/Patient/B1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"resourceType": "Patient",
"id": "B1",
"name": [
{
"text": "B1",
"use": "official"
}
],
"birthDate": "2024-02-02",
"gender": "female"
}
Loading

0 comments on commit 2999bbd

Please sign in to comment.