Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add decision tables and plan definitions for process B, C, and part of D #26

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 23 additions & 16 deletions input/cql/HIVB2DTLogic.cql
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Consolidated guidelines on HIV prevention, testing, treatment, service delivery
*/

library HIVB2DTLogic

using FHIR version '4.0.1'

include HIVCommon version '0.0.1' called HIC
Expand All @@ -27,21 +27,23 @@ include FHIRHelpers version '4.0.1'

include WHOCommon called WCom

parameter Today default Today()

context Patient

/*
@input: "Age 10 or older"
@input: "Age"
@pseudocode: 'Age' >= 10 years
*/
define "Age 10 or older":
AgeInYearsAt(Today()) >= 10
Elements."Current Patient Age In Years" >= 10

/*
@input: "Age under 10"
@input: "Age"
@pseudocode: 'Age' < 10 years
*/
define "Age under 10":
AgeInYearsAt(Today()) < 10
Elements."Current Patient Age In Years" < 10

/*
@output: "Immediately take action or refer for care if a client is having this issue"
Expand All @@ -68,17 +70,22 @@ define "Use clinical judgement and consider local epidemiology to determine if s
@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
Combine({
if "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.'
else '',
if "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.'
else '',
if "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 '',
if "Use clinical judgement and consider local epidemiology to determine if symptoms suggest client is seriously ill"
then 'Use clinical judgement and consider local epidemiology to determine if symptoms suggest client is seriously ill. '
else ''
})

/*
Supporting Logic
Expand Down
170 changes: 33 additions & 137 deletions input/cql/HIVB7DTLogic.cql
Original file line number Diff line number Diff line change
Expand Up @@ -2,161 +2,57 @@
Library: HIV.B7.DT Logic

@DecisionID: HIV.B7.DT
@BusinessRule:
@Trigger:
@Description:
@BusinessRule: WHO standard testing strategy for HIV-1 diagnosis (among people ≥18 months of age)
@Trigger: HIV.B7 Test for HIV using testing algorithm, HIV.C4 Test for HIV using testing algorithm, HIV.D.11 Retest using HIV strategy
@Description: WHO standard testing strategy for HIV-1 diagnosis (among people ≥18 months of age)

Test Using Algorithm
Data Concepts:

WHO standard testing strategy for HIV-1 diagnosis (among people ≥18 months of age)
HIV.B7 Test for HIV using testing algorithm, HIV.C4 Test for HIV using testing algorithm, HIV.D.11 Retest using HIV strategy
*/

library HIVB7DTLogic

using FHIR version '4.0.1'

//codesystem "Custom_Codes": 'http://fhir.org/guides/who/hiv-dak/CodeSystem/HIV-DAKConcepts'
codesystem "HIV_DAK_Codes": 'http://fhir.org/guides/who/hiv-dak/CodeSystem/HIV-DAKConcepts'
//valueset "TestresultofHIVassay1Codes": 'http://fhir.org/guides/who/hiv-dak/ValueSet/hiv-b-de95'
valueset "Assay 1 reactive": 'http://fhir.org/guides/who/hiv-dak/ValueSet/hiv-b-de95'
valueset "Assay 1": 'http://fhir.org/guides/who/hiv-dak/ValueSet/hiv-b-de90'
valueset "Assay 2": 'http://fhir.org/guides/who/hiv-dak/ValueSet/hiv-b-de91'
valueset "Assay 2 reactive": 'http://fhir.org/guides/who/hiv-dak/ValueSet/hiv-e-de205'
valueset "Assay 2 non-reactive": 'http://fhir.org/guides/who/hiv-dak/ValueSet/hiv-e-de206'
valueset "Assay 3": 'http://fhir.org/guides/who/hiv-dak/ValueSet/hiv-b-de92'
valueset "Assay 1 repeated": 'http://fhir.org/guides/who/hiv-dak/ValueSet/hiv-b-de93'
valueset "HIVtesttypeCodes": 'http://fhir.org/guides/who/hiv-dak/ValueSet/hiv-b-de82'
valueset "Reactive": 'http://fhir.org/guides/who/hiv-dak/ValueSet/hiv-b-de103'
valueset "Non-reactive": 'http://fhir.org/guides/who/hiv-dak/ValueSet/hiv-b-de104'

include HIVCommon version '0.0.1' called HIC
include HIVConcepts called Concepts
include HIVEncounterElements called Elements
include FHIRHelpers version '4.0.1'
include WHOCommon called WCom


//code "Assay 1 Reactive": 'HIV.B.DE95' from "TestresultofHIVassay1Codes" display 'Assay 1 reactive'
//code "Reactive": 'HIV.B.DE103' from "HIV_DAK_Codes" display 'Reactive'
//code "Non-reactive": 'HIV.B.DE104' from "HIV_DAK_Codes" display 'Non-reactive'
code "Rapid diagnostic test for HIV": 'HIV.B.DE82' from "HIV_DAK_Codes" display 'Rapid diagnostic test for HIV'
code "Enzyme immunoassay for HIV": 'HIV.B.DE83' from "HIV_DAK_Codes" display 'Enzyme immunoassay for HIV'
//code "Assay 1": 'HIV.B.DE90' from "HIV_DAK_Codes" display 'Assay 1'
//code "Assay 2": 'HIV.B.DE91' from "HIV_DAK_Codes" display 'Assay 2'
//code "Assay 3": 'HIV.B.DE92' from "HIV_DAK_Codes" display 'Assay 3'
//code "Assay 1 repeated": 'HIV.B.DE93' from "HIV_DAK_Codes" display 'Assay 1 repeated'
//code "Assay 2 reactive": 'HIV.E.DE205' from "HIV_DAK_Codes" display 'Assay 2 reactive'
//code "Assay 2 non-reactive": 'HIV.E.DE206' from "HIV_DAK_Codes" display 'Assay 2 non-reactive'
//code "Assay 1 reactive": 'HIV.B.DE95' from "HIV_DAK_Codes" display 'Assay 2 non-reactive'

/*valueset "Assay 2 reactive": 'HIV.E.DE205'*/
include WHOCommon called WCom

context Patient

define "Age_greater_than_18_months":
AgeInMonthsAt(Today()) >= 18


/*
@output: "Report as HIV-negative"
*/
define "Report as HIV-negative":
[Observation] O
//@triggeredBy order for Assay 1
with [ServiceRequest] SR
such that O.basedOn.references(SR) and SR.code in "Assay 1"
where (O.status in { 'final', 'amended' }
and O.code in "HIVtesttypeCodes"
and O.value in "Non-reactive"
and "Age_greater_than_18_months")

/* Output observation as HIV negative */
/*@triggeredBy Assay 1 */

define "Should Continue with Performing HIV Assay 2":
[Observation] O
//@triggeredBy ~ order for Assay 1
with [ServiceRequest] SR
such that O.basedOn.references(SR) and SR.code in "Assay 1"
where (O.status in { 'final', 'amended' }
and O.code in "HIVtesttypeCodes"
and O.value in "Reactive"
and "Age_greater_than_18_months")
case
when "Assay 1" and "Non-reactive result"
then true
else null
end

/* Output Service Request for Assay 2 */

define "Should Continue with Performing HIV Assay 1 repeated":
[Observation] O
//@triggeredBy ~ "Continue with performing HIV 'Assay 2'"
with [ServiceRequest] SR
such that O.basedOn.references(SR) and SR.reasonCode in "Assay 1 reactive" and SR.code in "Assay 2"
where (O.status in { 'final', 'amended' }
and O.code in "HIVtesttypeCodes"
and O.value in "Non-reactive"
and "Age_greater_than_18_months")

/* Output Service Request for Continue with performing HIV 'Assay 1 repeated' */

define "Should Continue with Performing HIV Assay 3":
[Observation] O
//@triggeredBy ~ "Continue with performing HIV 'Assay 2'"
with [ServiceRequest] SR
such that O.basedOn.references(SR) and SR.reasonCode in "Assay 1 reactive" and SR.code in "Assay 2"
where (O.status in { 'final', 'amended' }
and O.code in "HIVtesttypeCodes"
and O.value in "Reactive"
and "Age_greater_than_18_months")

/* Output Service Request for Continue with performing Assay 3 */

define "Report as HIV-negative after assay 1 repeated":
[Observation] O
//@triggeredBy ~ "Continue with performing HIV 'Assay 1 repeated'"
with [ServiceRequest] SR
such that O.basedOn.references(SR) and SR.reasonCode in "Assay 2 non-reactive" and SR.code in "Assay 1 repeated"
where (O.status in { 'final', 'amended' }
and O.code in "HIVtesttypeCodes"
and O.value in "Non-reactive"
and "Age_greater_than_18_months")

/* Output observation as HIV negative */
/*
Supporting Logic
*/
define "Assay 1":
exists("Assay 1 result") and not(exists("Assay 2 result"))

define "Report as HIV-inconclusive after assay 1 repeated":
[Observation] O
//@triggeredBy ~ "Continue with performing HIV 'Assay 1 repeated'"
with [ServiceRequest] SR
such that O.basedOn.references(SR) and SR.reasonCode in "Assay 2 non-reactive" and SR.code in "Assay 1 repeated"
where (O.status in { 'final', 'amended' }
and O.code in "HIVtesttypeCodes"
and O.value in "Reactive"
and "Age_greater_than_18_months")
define "Assay 2":
exists("Assay 2 result") and not(exists("Assay 3 result"))

/* Output observation as 'HIV-inconclusive' */
/* Output PlanDefinition as Schedule retest date on "Visit date" + 14 days */
define "Assay 3":
exists("Assay 3 result")

define "Report as HIV-inconclusive after assay 3":
[Observation] O
//@triggeredBy ~ "Continue with performing HIV 'Assay 3'"
with [ServiceRequest] SR
such that O.basedOn.references(SR) and SR.reasonCode in "Assay 2 reactive" and SR.code in "Assay 3"
where (O.status in { 'final', 'amended' }
and O.code in "HIVtesttypeCodes"
and O.value in "Non-reactive"
and "Age_greater_than_18_months")
define "Assay 1 result":
Elements."Test result of HIV assay 1 B.DE94"

/* Output observation as 'HIV-inconclusive' */
/* Output PlanDefinition as Schedule retest date on "Visit date" + 14 days */
define "Assay 2 result":
Elements."Test result of HIV assay 2 B.DE98"

define "Report as HIV-positive":
[Observation] O
//@triggeredBy ~ "Continue with performing HIV 'Assay 3'"
with [ServiceRequest] SR
such that O.basedOn.references(SR) and SR.reasonCode in "Assay 2 reactive" and SR.code in "Assay 3"
where (O.status in { 'final', 'amended' }
and O.code in "HIVtesttypeCodes"
and O.value in "Reactive"
and "Age_greater_than_18_months")

define "Assay 3 result":
Elements."Test result of HIV assay 3 B.DE102"

/* Output observation as 'HIV-positive' */

/*
[Observation] needs to have the following codes and elements
where O.status ~ {'final', 'amended'}
and O.value ~ HIC."HIV-positive"
*/
define "Non-reactive result":
false
Loading
Loading