WHO SMART Guidelines - HIV
0.4.4 - ci-build

WHO SMART Guidelines - HIV, published by WHO. This guide is not an authorized publication; it is the continuous build for version 0.4.4 built by the FHIR (HL7® FHIR® Standard) CI Build. This version is based on the current content of https://github.com/WorldHealthOrganization/smart-hiv/tree/main and changes regularly. See the Directory of published versions

Measure: HIV.IND.69 Syphilis treatment coverage, pregnant women, any ANC visit (Experimental)

Official URL: http://smart.who.int/hiv/Measure/HIVIND69 Version: 0.4.4
Draft as of 2024-08-18 Computable Name: HIVIND69

% of pregnant women who tested positive for syphilis who were treated based on national guidelines during the reporting period

Knowledge Artifact Metadata
Name (machine-readable) HIVIND69
Title (human-readable) HIV.IND.69 Syphilis treatment coverage, pregnant women, any ANC visit
Status Draft
Experimental true
Description

% of pregnant women who tested positive for syphilis who were treated based on national guidelines during the reporting period

Measure Steward WHO
Steward Contact Details WHO: http://who.int
Measure Metadata
Version Number 0.4.4
Measure Scoring Proportion
Improvement Notation Increased score indicates improvement
Population Basis boolean
Measure Population Criteria
Initial Population ID: HIV.IND.69.IP
Description:

Initial Population

Logic Definition: Initial Population
Denominator ID: HIV.IND.69.DEN
Description:

Number of pregnant women who tested positive for syphilis during the reporting period

Logic Definition: Denominator
Numerator ID: HIV.IND.69.NUM
Description:

Number of pregnant women who tested positive for syphilis and were treated based on national guidelines during the reporting period

Logic Definition: Numerator
Measure Logic
Primary Library HIV.IND.69 Logic
Dependency Description: FHIR model information
Resource: http://fhir.org/guides/cqf/common/Library/FHIR-ModelInfo|4.0.1
Canonical URL: http://fhir.org/guides/cqf/common/Library/FHIR-ModelInfo|4.0.1
Dependency Description: Library HIE
Resource: HIVIndicatorElements
Canonical URL: http://smart.who.int/hiv/Library/HIVIndicatorElements
Dependency Description: Library Elements
Resource: HIVElements
Canonical URL: http://smart.who.int/hiv/Library/HIVElements
Dependency Description: Library FHIRHelpers
Resource: http://fhir.org/guides/cqf/common/Library/FHIRHelpers|4.0.1
Canonical URL: http://fhir.org/guides/cqf/common/Library/FHIRHelpers|4.0.1
Dependency Description: Library ConceptsCustom
Resource: http://smart.who.int/hiv/Library/HIVConceptsCustom|0.0.1
Canonical URL: http://smart.who.int/hiv/Library/HIVConceptsCustom|0.0.1
Dependency Description: Library WC
Resource: WHOCommon
Canonical URL: http://smart.who.int/hiv/Library/WHOCommon
Dependency Description: Library Concepts
Resource: http://smart.who.int/hiv/Library/HIVConcepts|0.0.2
Canonical URL: http://smart.who.int/hiv/Library/HIVConcepts|0.0.2
Dependency Description: Code system missing concepts
Resource: https://worldhealthorganization.github.io/smart-hiv/CodeSystem/missing-concepts
Canonical URL: https://worldhealthorganization.github.io/smart-hiv/CodeSystem/missing-concepts
Dependency Description: Code system ConditionClinicalStatusCodes
Resource: Condition Clinical Status Codes
Canonical URL: http://terminology.hl7.org/CodeSystem/condition-clinical
Dependency Description: Code system HIVConcepts
Resource: WHO SMART HIV Concepts CodeSystem
Canonical URL: http://smart.who.int/hiv/CodeSystem/HIVConcepts
Direct Reference Code Code: Antenatal care contact
System: https://worldhealthorganization.github.io/smart-hiv/CodeSystem/missing-concepts
Direct Reference Code Code: active
System: http://terminology.hl7.org/CodeSystem/condition-clinical
Direct Reference Code Code: recurrence
System: http://terminology.hl7.org/CodeSystem/condition-clinical
Direct Reference Code Code: relapse
System: http://terminology.hl7.org/CodeSystem/condition-clinical
Direct Reference Code Display: Currently pregnant
Code: HIV.B.DE29
System: http://smart.who.int/hiv/CodeSystem/HIVConcepts
Direct Reference Code Display: Syphilis test result
Code: HIV.B.DE250
System: http://smart.who.int/hiv/CodeSystem/HIVConcepts
Direct Reference Code Display: Positive
Code: HIV.B.DE251
System: http://smart.who.int/hiv/CodeSystem/HIVConcepts
Direct Reference Code Code: syphilis test
System: https://worldhealthorganization.github.io/smart-hiv/CodeSystem/missing-concepts
Direct Reference Code Code: syphilis treatment
System: https://worldhealthorganization.github.io/smart-hiv/CodeSystem/missing-concepts
Parameter Name: Measurement Period
Use: In
Min Cardinality: 0
Max Cardinality: 1
Type: Period
Parameter Name: Numerator
Use: Out
Min Cardinality: 0
Max Cardinality: 1
Type: boolean
Parameter Name: Denominator
Use: Out
Min Cardinality: 0
Max Cardinality: 1
Type: boolean
Parameter Name: Initial Population
Use: Out
Min Cardinality: 0
Max Cardinality: 1
Type: boolean
Measure Logic Data Requirements
Data Requirement Type: Encounter
Profile(s): Encounter
Must Support Elements: type, period
Data Requirement Type: Patient
Profile(s): Patient
Data Requirement Type: Condition
Profile(s): Condition
Must Support Elements: code
Code Filter(s):
Path: code
Code:
Data Requirement Type: Observation
Profile(s): Observation
Must Support Elements: code, status, value, partOf
Code Filter(s):
Path: code
Code:
Data Requirement Type: Procedure
Profile(s): Procedure
Must Support Elements: status, code, performed
Data Requirement Type: MedicationStatement
Profile(s): MedicationStatement
Must Support Elements: status, reasonCode, effective
Measure Logic Definitions
Logic Definition Library Name: HIVElements
/* End of Other E.DE70 */

/*
@dataElement: HIV.E.DE85 - ANC contact date
@activity: HIV.E1 Capture or update mother's history
@description: The date and time of the client's ANC contact (in the ANC DAK this is called 'Contact date')
*/

define "Antenatal care contact":
  [Encounter] E
    where E.type.coding.code contains ConceptsCustom."Antenatal care contact".code
Logic Definition Library Name: HIVElements
/* End of Facility-level testing */

/*
@dataElement: HIV.B.DE29 - Currently pregnant
@activity: HIV.B6 Capture or update client history
@description: Client is currently pregnant
*/

define "Currently pregnant B.DE29":
  [Condition: Concepts."Currently pregnant - HIV.B.DE29"] C
  sort by start of prevalenceInterval()
Logic Definition Library Name: HIVIndicatorElements
/* End of Facility-level testing */

/*
@dataElement: HIV.B.DE29 - Currently pregnant
@activity: HIV.B6 Capture or update client history
@description: Client is currently pregnant
*/

define "Currently pregnant B.DE29":
  Elements."Currently pregnant B.DE29" C
    where C.prevalenceInterval() during "Measurement Period"
Logic Definition Library Name: HIVIndicatorElements
define "ANC within pregnancy within measurement period":
  Elements."Antenatal care contact" E
  where E.period.toInterval() during First("Currently pregnant B.DE29").prevalenceInterval()
  and E.period.toInterval() during "Measurement Period"
Logic Definition Library Name: HIVElements
/* End of Syphilis test date B.DE249 */

/*
@dataElement: HIV.B.DE250 - Syphilis test result
@activity: HIV.B23 Offer sexual and reproductive health services
@description: Result from syphilis test
*/

define "Syphilis test result B.DE250":
  [Observation: Concepts."Syphilis test result - HIV.B.DE250"] O
    where O.status in { 'final', 'amended', 'corrected' }
Logic Definition Library Name: HIVElements
/* End of Syphilis test result B.DE250 */

/*
@dataElement: HIV.B.DE251 - Positive
@activity: HIV.B23 Offer sexual and reproductive health services
@description: Test result is positive for syphilis
*/

define "Positive B.DE251":
  "Syphilis test result B.DE250" O
    where O.status in { 'final', 'amended', 'corrected' }
      and O.value ~ Concepts."Positive - HIV.B.DE251"
Logic Definition Library Name: HIVElements
/* End of Any STI syndrome diagnosed B.DE235 */

/*
@dataElement: HIV.B.DE249 - Syphilis test date
@activity: HIV.B23 Offer sexual and reproductive health services
@description: Date of syphilis test
*/

define "Syphilis test date B.DE249":
  [Procedure] P
  where P.status = 'completed'
  and P.code ~ ConceptsCustom."syphilis test"
Logic Definition Library Name: HIVIndicatorElements
define "ANC within pregnancy dates":
  Elements."Antenatal care contact" E
  where E.period.toInterval() during First("Currently pregnant B.DE29").prevalenceInterval()
  return E.period.toInterval()
Logic Definition Library Name: HIVIndicatorElements
define "all anc dates":
  flatten{"ANC within pregnancy dates"}
Logic Definition Library Name: HIVElements
/* End of Inconclusive B.DE253 */

/*
@dataElement: HIV.B.DE254 - Syphilis treatment start date
@activity: HIV.B23 Offer sexual and reproductive health services
@description: Date of initiation of syphilis treatment
*/

define "Syphilis treatment start date B.DE254":
  [MedicationStatement] MS
    where MS.status = 'completed'
    and exists(MS.reasonCode C where C ~ ConceptsCustom."syphilis treatment")
Logic Definition Library Name: HIVIndicatorElements
/* End of Inconclusive B.DE253 */

/*
@dataElement: HIV.B.DE254 - Syphilis treatment start date
@activity: HIV.B23 Offer sexual and reproductive health services
@description: Date of initiation of syphilis treatment
*/

define "Syphilis treatment start date B.DE254":
  exists (Elements."Syphilis treatment start date B.DE254" MS
    where MS.effective.toInterval() during "Measurement Period")
Logic Definition Library Name: HIVIND69Logic
/**
 * Numerator
 * 
 * Definition: Number of pregnant women who tested positive for syphilis and were treated based on national guidelines during the reporting period
 * Calculation: COUNT of pregnant women with "ANC contact date" in reporting period AND "Syphilis test date" on ANY "ANC contact date" for this pregnancy AND "Syphilis test result"='Positive' AND "Syphilis treatment start date" in the reporting period
 */

define "Numerator":
  exists(HIE."ANC within pregnancy within measurement period")
  and exists(HE."Positive B.DE251" S
  with HE."Syphilis test date B.DE249" P
    such that S.partOf.references(P) and exists(HIE."all anc dates" t where duration in days of (t intersect P.performed.toInterval()) > 0))
  and HIE."Syphilis treatment start date B.DE254"
Logic Definition Library Name: HIVIND69Logic
/**
 * Denominator
 *
 * Definition: Number of pregnant women who tested positive for syphilis during the reporting period
 * Calculation: COUNT of pregnant women with "ANC contact date" in reporting period AND "Syphilis test date" on ANY "ANC contact date" for this pregnancy AND "Syphilis test result"='Syphilis positive'
 */

define "Denominator":
  exists(HIE."ANC within pregnancy within measurement period")
  and exists(HE."Positive B.DE251" S
  with HE."Syphilis test date B.DE249" P
    such that S.partOf.references(P) and exists(HIE."all anc dates" t where duration in days of (t intersect P.performed.toInterval()) > 0))
Logic Definition Library Name: HIVIND69Logic
/* Populations */

/*
 *Initial Population
 */

define "Initial Population":
  true
Logic Definition Library Name: FHIRHelpers
define function ToString(value string): value.value
Logic Definition Library Name: WHOCommon
/*
From FHIRCommon 4.1.0:
*/

/*
@description: Normalizes a value that is a choice of timing-valued types to an equivalent interval
@comment: Normalizes a choice type of FHIR.dateTime, FHIR.Period, FHIR.Timing, FHIR.instance, FHIR.string, FHIR.Age, or FHIR.Range types
to an equivalent interval. This selection of choice types is a superset of the majority of choice types that are used as possible
representations for timing-valued elements in FHIR, allowing this function to be used across any resource.

The input can be provided as a dateTime, Period, Timing, instant, string, Age, or Range.
The intent of this function is to provide a clear and concise mechanism to treat single
elements that have multiple possible representations as intervals so that logic doesn't have to account
for the variability. More complex calculations (such as medication request period or dispense period
calculation) need specific guidance and consideration. That guidance may make use of this function, but
the focus of this function is on single element calculations where the semantics are unambiguous.
If the input is a dateTime, the result a DateTime Interval beginning and ending on that dateTime.
If the input is a Period, the result is a DateTime Interval.
If the input is a Timing, an error is raised indicating a single interval cannot be computed from a Timing.
If the input is an instant, the result is a DateTime Interval beginning and ending on that instant.
If the input is a string, an error is raised indicating a single interval cannot be computed from a string.
If the input is an Age, the result is a DateTime Interval beginning when the patient was the given Age,
and ending immediately prior to when the patient was the given Age plus one year.
If the input is a Range, the result is a DateTime Interval beginning when the patient was the Age given
by the low end of the Range, and ending immediately prior to when the patient was the Age given by the
high end of the Range plus one year.

NOTE: Due to the
complexity of determining a single interval from a Timing or String type, this function will throw a run-time exception if it is used
with a Timing or String.
*/
define fluent function toInterval(choice Choice<FHIR.dateTime, FHIR.Period, FHIR.Timing, FHIR.instant, FHIR.string, FHIR.Age, FHIR.Range>):
  case
    when choice is FHIR.dateTime then
      Interval[FHIRHelpers.ToDateTime(choice as FHIR.dateTime), FHIRHelpers.ToDateTime(choice as FHIR.dateTime)]
    when choice is FHIR.Period then
      FHIRHelpers.ToInterval(choice as FHIR.Period)
    when choice is FHIR.instant then
      Interval[FHIRHelpers.ToDateTime(choice as FHIR.instant), FHIRHelpers.ToDateTime(choice as FHIR.instant)]
    when choice is FHIR.Age then
      Interval[FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity(choice as FHIR.Age),
        FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity(choice as FHIR.Age) + 1 year)
    when choice is FHIR.Range then
      Interval[FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity((choice as FHIR.Range).low),
        FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity((choice as FHIR.Range).high) + 1 year)
    when choice is FHIR.Timing then
      Message(null as Interval<DateTime>, true, 'NOT_IMPLEMENTED', 'Error', 'Calculation of an interval from a Timing value is not supported')
    when choice is FHIR.string then
      Message(null as Interval<DateTime>, true, 'NOT_IMPLEMENTED', 'Error', 'Calculation of an interval from a String value is not supported')
    else
      null as Interval<DateTime>
  end
Logic Definition Library Name: FHIRHelpers
define function ToDateTime(value dateTime): value.value
Logic Definition Library Name: FHIRHelpers
define function ToInterval(period FHIR.Period):
    if period is null then
        null
    else
        if period."start" is null then
            Interval(period."start".value, period."end".value]
        else
            Interval[period."start".value, period."end".value]
Logic Definition Library Name: FHIRHelpers
define function ToDateTime(value instant): value.value
Logic Definition Library Name: FHIRHelpers
define function ToDate(value date): value.value
Logic Definition Library Name: FHIRHelpers
define function ToQuantity(quantity FHIR.Quantity):
    case
        when quantity is null then null
        when quantity.value is null then null
        when quantity.comparator is not null then
            Message(null, true, 'FHIRHelpers.ToQuantity.ComparatorQuantityNotSupported', 'Error', 'FHIR Quantity value has a comparator and cannot be converted to a System.Quantity value.')
        when quantity.system is null or quantity.system.value = 'http://unitsofmeasure.org'
              or quantity.system.value = 'http://hl7.org/fhirpath/CodeSystem/calendar-units' then
            System.Quantity { value: quantity.value.value, unit: ToCalendarUnit(Coalesce(quantity.code.value, quantity.unit.value, '1')) }
        else
            Message(null, true, 'FHIRHelpers.ToQuantity.InvalidFHIRQuantity', 'Error', 'Invalid FHIR Quantity code: ' & quantity.unit.value & ' (' & quantity.system.value & '|' & quantity.code.value & ')')
    end
Logic Definition Library Name: FHIRHelpers
define function ToCalendarUnit(unit System.String):
    case unit
        when 'ms' then 'millisecond'
        when 's' then 'second'
        when 'min' then 'minute'
        when 'h' then 'hour'
        when 'd' then 'day'
        when 'wk' then 'week'
        when 'mo' then 'month'
        when 'a' then 'year'
        else unit
    end
Logic Definition Library Name: WHOCommon
/*
@description: Returns an interval representing the normalized prevalence period of a given Condition resource.
@comment: Uses the toInterval and toAbatementInterval functions to determine the widest potential interval from
onset to abatement as specified in the given Condition.
*/
define fluent function prevalenceInterval(condition Condition):
if condition.clinicalStatus ~ "active"
  or condition.clinicalStatus ~ "recurrence"
  or condition.clinicalStatus ~ "relapse" then
  Interval[start of condition.onset.toInterval(), end of condition.abatementInterval()]
else
  (end of condition.abatementInterval()) abatementDate
    return 
	  if abatementDate is null then
        Interval[start of condition.onset.toInterval(), abatementDate)
      else
        Interval[start of condition.onset.toInterval(), abatementDate]
Logic Definition Library Name: FHIRHelpers
define function ToConcept(concept FHIR.CodeableConcept):
    if concept is null then
        null
    else
        System.Concept {
            codes: concept.coding C return ToCode(C),
            display: concept.text.value
        }
Logic Definition Library Name: FHIRHelpers
define function ToCode(coding FHIR.Coding):
    if coding is null then
        null
    else
        System.Code {
          code: coding.code.value,
          system: coding.system.value,
          version: coding.version.value,
          display: coding.display.value
        }
Logic Definition Library Name: WHOCommon
/*
@description: Returns an interval representing the normalized Abatement of a given Condition resource.
@comment: NOTE: Due to the complexity of determining an interval from a String, this function will throw
a run-time exception if used with a Condition instance that has a String as the abatement value.
*/
define fluent function abatementInterval(condition Condition):
  if condition.abatement is FHIR.dateTime then
    Interval[FHIRHelpers.ToDateTime(condition.abatement as FHIR.dateTime), FHIRHelpers.ToDateTime(condition.abatement as FHIR.dateTime)]
  else if condition.abatement is FHIR.Period then
    FHIRHelpers.ToInterval(condition.abatement as FHIR.Period)
  else if condition.abatement is FHIR.string then
    Message(null as Interval<DateTime>, true, 'NOT_IMPLEMENTED', 'Error', 'Calculation of an interval from a String value is not supported')
  else if condition.abatement is FHIR.Age then
    Interval[FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity(condition.abatement as FHIR.Age),
      FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity(condition.abatement as FHIR.Age) + 1 year)
  else if condition.abatement is FHIR.Range then
    Interval[FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity((condition.abatement as FHIR.Range).low),
      FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity((condition.abatement as FHIR.Range).high) + 1 year)
  else if condition.abatement is FHIR.boolean then
    Interval[end of condition.onset.toInterval(), condition.recordedDate)
  else 
    null
Logic Definition Library Name: FHIRHelpers
define function ToString(value ObservationStatus): value.value
Logic Definition Library Name: FHIRHelpers
define function ToString(value ProcedureStatus): value.value
Logic Definition Library Name: WHOCommon
/*
@description: Returns true if any of the given references are to the given resource
@comment: Returns true if the `id` element of the given resource exactly equals the tail of any of the given references.
NOTE: This function assumes resources from the same source server.
*/
define fluent function references(references List<FHIR.Reference>, resource FHIR.Resource):
  exists (references R where R.references(resource))
Logic Definition Library Name: WHOCommon
/*
@description: Returns true if the given reference is to the given resource
@comment: Returns true if the `id` element of the given resource exactly equals the tail of the given reference.
NOTE: This function assumes resources from the same source server.
*/
define fluent function references(reference FHIR.Reference, resource FHIR.Resource):
  resource.id = Last(Split(reference.reference, '/'))
Logic Definition Library Name: FHIRHelpers
define function ToString(value MedicationStatementStatus): value.value
Generated using version 0.4.6 of the sample-content-ig Liquid templates