Skip to content

Commit

Permalink
HIVB9DT (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
ibacher authored Jul 31, 2024
1 parent e131a11 commit 9e2f743
Show file tree
Hide file tree
Showing 8 changed files with 598 additions and 72 deletions.
161 changes: 93 additions & 68 deletions input/cql/HIVB2DTLogic.cql
Original file line number Diff line number Diff line change
Expand Up @@ -2,87 +2,112 @@
Library: HIV.B2.DT Logic
@DecisionID: HIV.B2.DT
@BusinessRule:
@Trigger:
@Description:
Check for signs of serious illness
Consolidated guidelines on HIV prevention, testing, treatment, service delivery and monitoring: recommendations for a public health approach (2021) Chapter 5: Advanced HIV Disease. Figure 5.1: Algorithm for providing a package of care for people with advanced HIV disease.
Should this just be for anyone with HIV?
Wouldn't other disease domains also code for general exam?
@BusinessRule: Check for signs of serious illness
@Trigger: HIV.B2 Check for signs of serious illness
@Trigger: HIV.D3 Check for signs of serious illness
@HitPolicy: Rule Order
@Description: Check for serious illness
Data Concepts:
* HIV.A.DE17: Age | Calculated age (number of years) of the client based on date of birth
* HIV.D.DE17: Signs of serious illness | Signs that may indicate the client has a serious illness and needs triage or an emergency referral
* HIV.D.DE9: Body temperature | Temperature of the client in Celsius
Consolidated guidelines on HIV prevention, testing, treatment, service delivery and monitoring: recommendations for a public health approach (2021) Chapter 5: Advanced HIV Disease. Figure 5.1: Algorithm for providing a package of care for people with advanced HIV disease.
*/

library HIVB2DTLogic

using FHIR version '4.0.1'


include HIVCommon version '0.0.1' called HIC
include FHIRHelpers version '4.0.1'
include WHOCommon called WCom
include FHIRCommon called FC
using FHIR version '4.0.1'

valueset "Tachycardia": ''
valueset "Tachypnea": ''
valueset "Unable to walk unaided": ''
valueset "Body temperature = ≥ 39 °C": ''
valueset "Other sign of serious illness (specify)": ''
valueset "Lethargy": ''
valueset "Unconsciousness": ''
valueset "Convulsions": ''
valueset "Unable to breastfeed": ''
valueset "Unable to drink": ''
valueset "Repeated vomiting": ''
include HIVCommon version '0.0.1' called HIC
include HIVConcepts called HCx
include HIVEncounterElements called Elements
include FHIRHelpers version '4.0.1'
include FHIRCommon called FC
include WHOCommon called WCom

context Patient
context Patient

/*
* Age = ≥ 10 years
@input: "Age 10 or older"
@pseudocode: 'Age' >= 10 years
*/

define "Age_10_or_more":
define "Age 10 or older":
AgeInYearsAt(Today()) >= 10

/*
* Age < 10 years
@input: "Age under 10"
@pseudocode: 'Age' < 10 years
*/

define "Age_less_than_10":
define "Age under 10":
AgeInYearsAt(Today()) < 10

define "Take action or refer client showing signs of a serious illness":
exists(([Observation: "Tachycardia"]
union [Observation: "Tachypnea"]
union [Observation: "Unable to walk unaided"]) O
where Age_10_or_more
and O.status in { 'final', 'amended' })
or exists(([Observation: "Lethargy"]
union [Observation: "Unconsciousness"]
union [Observation: "Convulsions"]
union [Observation: "Unable to breastfeed"]
union [Observation: "Unable to drink"]
union [Observation: "Unconsciousness"]
union [Observation: "Repeated vomiting"]) O
where Age_less_than_10
and O.status in { 'final', 'amended' }
)

//plan definition Immediately take action or refer for care if a client is having this issue.

/*
@output: "Immediately take action or refer for care if a client is having this issue"
*/
define "Immediately take action or refer for care if a client is having this issue":
exists(Elements."Signs of serious illness" O
where "Age 10 or older"
and O.value ~ HCx."Tachycardia")

/*
@output "Immediately take action or refer for care if client is showing this sign of a serious illness."
*/
define "Immediately take action or refer for care if client is showing this sign of a serious illness":
"Signs of serious illness age 10 or older" or "Signs of serious illness age under 10"

/*
@output "Use clinical judgement and consider local epidemiology to determine if symptoms suggest client is seriously ill"
*/
define "Use clinical judgement and consider local epidemiology to determine if symptoms suggest client is seriously ill":
exists (([Observation: "Body temperature = ≥ 39 °C"]
union [Observation: "Other sign of serious illness (specify)"]) O
where Age_10_or_more
and O.status in { 'final', 'amended' })
// Please this condition needs to be fixed
// or exists((([Observation: "Body temperature = ≥ 39 °C"]
// intersect [Observation: "Tachycardia"])
// or ([Observation: "Body temperature = ≥ 39 °C"]
// intersect [Observation: "Tachypnea"])
// or [Observation: "Other sign of serious illness (specify)"]) O
// where Age_less_than_10
// and O.status in { 'final', 'amended' })
// )


//plan definition Use clinical judgement and consider local epidemiology to determine if symptoms suggest client is seriously ill.
"Signs of serious illness requiring clinical judgement age 10 or older" or "Signs of serious illness requiring clinical judgement age under 10"

/*
@dynamicValue: Guidance
*/
define "Guidance":
case
when "Immediately take action or refer for care if a client is having this issue"
then "Immediately take action or refer for care if a client is having this issue."
when "Immediately take action or refer for care if client is showing this sign of a serious illness" and "Age 10 or older"
then "Immediately take action or refer for care if client is showing this sign of a serious illness."
when "Immediately take action or refer for care if client is showing this sign of a serious illness" and "Age under 10"
then """This is a sign and/or symptom of a serious health condition.
Immediately take action or refer for care if client is showing this sign of a serious illness."""
else null
end

/*
Supporting Logic
*/
define "Signs of serious illness age 10 or older":
"Age 10 or older" and Elements."Signs of serious illness" O
where
O.value ~ HCx."Tachypnea" or
O.value ~ HCx."Unable to walk unaided"

define "Signs of serious illness age under 10":
"Age under 10" and Elements."Signs of serious illness" O
where
O.value in {
HCx."Lethargy - HIV.D.DE22",
HCx."Unconsciousness",
HCx."Convulsions",
HCx."Unable to breastfeed",
HCx."Unable to drink",
HCx."Repeated vomiting"
}

define "Signs of serious illness requiring clinical judgement age 10 or older":
"Age 10 or older" and Elements."Signs of serious illness" O
where
O.value ~ HCx."Fever of 39 C or greater" or
O.value ~ HCx."Other sign of serious illness"

define "Signs of serious illness requiring clinical judgement age under 10":
"Age under 10" and Elements."Signs of serious illness" O
where
O.value ~ HCx."Fever of 39 C or greater" or
O.value ~ HCx."Other sign of serious illness"
Loading

0 comments on commit 9e2f743

Please sign in to comment.