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.14 OAMT minimum dose (Experimental)

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

% of OAMT recipients receiving a maintenance dose greater than or equal to the recommended minimum dose

Knowledge Artifact Metadata
Name (machine-readable) HIVIND14
Title (human-readable) HIV.IND.14 OAMT minimum dose
Status Draft
Experimental true
Description

% of OAMT recipients receiving a maintenance dose greater than or equal to the recommended minimum dose

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.14.IP
Description:

Initial Population

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

Number of people receiving maintenance dose of methadone or buprenorphine at a specified date, excluding: a) individuals currently being inducted on OAMT and yet to reach the maintenance dose and b) individuals on reducing doses of OAMT.

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

Number of people, at a specified date, maintained on methadone or buprenorphine receiving recommended minimum maintenance dose (WHO guidance recommends doses of >=60 mg of methadone or >=8 mg of buprenorphine)

Logic Definition: Numerator
Measure Logic
Primary Library HIV.IND.14 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 HIC
Resource: http://smart.who.int/hiv/Library/HIVCommon|0.0.1
Canonical URL: http://smart.who.int/hiv/Library/HIVCommon|0.0.1
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 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 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 Common
Resource: HIVCommon
Canonical URL: http://smart.who.int/hiv/Library/HIVCommon
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
Direct Reference Code Code: methadone
System: https://worldhealthorganization.github.io/smart-hiv/CodeSystem/missing-concepts
Direct Reference Code Code: buprenorphine
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: MedicationRequest
Profile(s): MedicationRequest
Must Support Elements: intent, medication, dosageInstruction, dispenseRequest, dispenseRequest.quantity, dispenseRequest.expectedSupplyDuration, dispenseRequest.numberOfRepeatsAllowed, dispenseRequest.validityPeriod, authoredOn, status
Measure Logic Definitions
Logic Definition Library Name: HIVElements
define "Methadone D.DE555":
  [MedicationRequest] MR
        where MR.intent = 'order'
        and MR.medication ~ ConceptsCustom."methadone"
Logic Definition Library Name: HIVIndicatorElements
/*
@dataElement: HIV.D.DE555 - Methadone
@activity: HIV.D8 Capture or update client history
@description: Opioid substitution to treat opioid dependence
*/
define "Methadone D.DE555":
  Elements."Methadone D.DE555" MR
        where MR.status = 'completed'
        and MR.MedicationRequestPeriod() during "Measurement Period"
Logic Definition Library Name: HIVElements
define "Buprenorphine D.DE552":
  [MedicationRequest] MR
        where MR.intent = 'order'
        and MR.medication ~ ConceptsCustom."buprenorphine"
Logic Definition Library Name: HIVIndicatorElements
/* End of Enhanced adherence counselling provided */

/*
@dataElement: HIV.D.DE552 - Buprenorphine
@activity: HIV.D8 Capture or update client history
@description: Opioid substitution to treat opioid dependence
*/

define "Buprenorphine D.DE552":
  Elements."Buprenorphine D.DE552" MR
        where MR.status = 'completed'
        and MR.MedicationRequestPeriod() during "Measurement Period"
Logic Definition Library Name: HIVIND14Logic
/**
 * Numerator
 * 
 * Definition: Number of people, at a specified date, maintained on methadone or buprenorphine receiving recommended minimum maintenance dose (WHO guidance recommends doses of ≥60 mg of methadone or ≥8 mg of buprenorphine*)
 * Calculation: COUNT of clients with ("Medications prescribed"='Methadone' AND "Dose of medications prescribed" GREATER THAN OR EQUAL TO 60mg) OR ("Medications prescribed"='Buprenorphine' AND "Dose of medications prescribed" GREATER THAN OR EQUAL TO 8mg) for a specified "Reporting date"
 */

define "Numerator":
  First(HIE."Methadone D.DE555").dailyDose() >= System.Quantity{ value: 60, unit: 'mg' }
  or First(HIE."Buprenorphine D.DE552").dailyDose() >= System.Quantity{ value: 8, unit: 'mg' }
Logic Definition Library Name: HIVIND14Logic
/**
 * Denominator
 *
 * Definition: Number of people receiving maintenance dose of methadone or buprenorphine at a specified date, excluding: a) individuals currently being inducted on OAMT and yet to reach the maintenance dose and b) individuals on reducing doses of OAMT.
 * Calculation: COUNT of clients with "Medications prescribed" IN 'Methadone', 'Buprenorphine' for a specified "Reporting date"
 */

define "Denominator":
  Exists(HIE."Methadone D.DE555") or Exists(HIE."Buprenorphine D.DE552")
Logic Definition Library Name: HIVIND14Logic
/* Populations */

/*
 *Initial Population
 */

define "Initial Population":
  true
Logic Definition Library Name: HIVCommon
//define function "GetMedicationDailyDose"(dosage Quantity, dosesPerDay Decimal):
  //dosage * Quantity { value: dosesPerDay, unit: '/d' }


define fluent function dailyDose(Request "MedicationRequest"):
  Request R
    let
      dosage: singleton from R.dosageInstruction,
      doseAndRate: singleton from dosage.doseAndRate,
      timing: dosage.timing,
      frequency: Coalesce(timing.repeat.frequencyMax, timing.repeat.frequency),
      period: System.Quantity { value: timing.repeat.period, unit: timing.repeat.periodUnit.value },
      doseRange: doseAndRate.dose as Range,
      doseQuantity: doseAndRate.dose as SimpleQuantity,
      dose: Coalesce(doseRange.high, doseQuantity),
      dosesPerDay: Coalesce(ToDaily(frequency, period), Count(timing.repeat.timeOfDay), 1.0),
      quantity: R.dispenseRequest.quantity
    return
      quantity / (dose * dosesPerDay)
Logic Definition Library Name: FHIRHelpers
define function ToDecimal(value decimal): value.value
Logic Definition Library Name: HIVCommon
//System.Integer
define function ToDaily(frequency System.Integer, period System.Quantity):
  case period.unit
    when 'h' then frequency * (24.0 / period.value)
    when 'min' then frequency * (24.0 / period.value) * 60
    when 's' then frequency * (24.0 / period.value) * 60 * 60
    when 'd' then frequency * (24.0 / period.value) / 24
    when 'wk' then frequency * (24.0 / period.value) / (24 * 7)
    when 'mo' then frequency * (24.0 / period.value) / (24 * 30) /* assuming 30 days in month */
    when 'a' then frequency * (24.0 / period.value) / (24 * 365) /* assuming 365 days in year */
    when 'hour' then frequency * (24.0 / period.value)
    when 'minute' then frequency * (24.0 / period.value) * 60
    when 'second' then frequency * (24.0 / period.value) * 60 * 60
    when 'day' then frequency * (24.0 / period.value) / 24
    when 'week' then frequency * (24.0 / period.value) / (24 * 7)
    when 'month' then frequency * (24.0 / period.value) / (24 * 30) /* assuming 30 days in month */
    when 'year' then frequency * (24.0 / period.value) / (24 * 365) /* assuming 365 days in year */
    when 'hours' then frequency * (24.0 / period.value)
    when 'minutes' then frequency * (24.0 / period.value) * 60
    when 'seconds' then frequency * (24.0 / period.value) * 60 * 60
    when 'days' then frequency * (24.0 / period.value) / 24
    when 'weeks' then frequency * (24.0 / period.value) / (24 * 7)
    when 'months' then frequency * (24.0 / period.value) / (24 * 30) /* assuming 30 days in month */
    when 'years' then frequency * (24.0 / period.value) / (24 * 365) /* assuming 365 days in year */
    else null
  end
Logic Definition Library Name: FHIRHelpers
define function ToInteger(value integer): 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: FHIRHelpers
define function ToString(value MedicationRequestIntent): value.value
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: FHIRHelpers
define function ToString(value MedicationRequestStatus): value.value
Logic Definition Library Name: HIVCommon
define fluent function MedicationRequestPeriod(Request MedicationRequest):
  Request R
    let
      dosage: singleton from R.dosageInstruction,
      doseAndRate: singleton from dosage.doseAndRate,
      doseRange: doseAndRate.dose as Range,
      doseQuantity: doseAndRate.dose as SimpleQuantity,
      dose: Coalesce(end of doseRange, doseQuantity),
      timing: dosage.timing,
      frequency: Coalesce(timing.repeat.frequencyMax, timing.repeat.frequency),
      period: System.Quantity { value: timing.repeat.period, unit: timing.repeat.periodUnit.value },
      dosesPerDay: Coalesce(ToDaily(FHIRHelpers.ToInteger(frequency), period), Count(timing.repeat.timeOfDay), 1.0),
      boundsPeriod: timing.repeat.bounds as Period,
      daysSupply: R.dispenseRequest.expectedSupplyDuration,
      quantity: R.dispenseRequest.quantity,
      refills: Coalesce(R.dispenseRequest.numberOfRepeatsAllowed, 0),
      startDate:
        Coalesce(
          start of boundsPeriod,
          start of R.dispenseRequest.validityPeriod,
          R.authoredOn
        )
    return
      if HasEnd(boundsPeriod) then
        Interval[startDate, end of boundsPeriod]
      else
        (
          Coalesce(daysSupply, quantity / (dose * dosesPerDay))
            * (1 + refills)
        ) durationInDays
          return Interval[startDate, startDate + durationInDays]
Logic Definition Library Name: FHIRHelpers
define function ToInterval(range FHIR.Range):
    if range is null then
        null
    else
        Interval[ToQuantity(range.low), ToQuantity(range.high)]
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 dateTime): value.value
Logic Definition Library Name: HIVCommon
define function "HasEnd"(period Interval<DateTime> ):
  not (end of period is null
    or end of period = maximum DateTime
)
Generated using version 0.4.6 of the sample-content-ig Liquid templates