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.24 HTS linkage to prevention (Experimental)

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

Among those testing HIV-negative and identified as being at elevated risk for HIV acquisition, % of people who receive an HIV prevention intervention within defined period

Knowledge Artifact Metadata
Name (machine-readable) HIVIND24
Title (human-readable) HIV.IND.24 HTS linkage to prevention
Status Draft
Experimental true
Description

Among those testing HIV-negative and identified as being at elevated risk for HIV acquisition, % of people who receive an HIV prevention intervention within defined 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.24.IP
Description:

Initial Population

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

Number of people testing negative for HIV in the reporting period and identified as being at elevated risk for HIV acquisition (includes people requesting/receiving any HIV prevention intervention, people from key populations, people with known risk factors or those assessed as being at risk of HIV acquisition)

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

Number of people who receive an HIV prevention intervention within a defined period after receiving a negative HIV test result

Logic Definition: Numerator
Stratifier ID: HIV.IND.24.S
Measure Logic
Primary Library HIV.IND.24 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 HE
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 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: Library WC
Resource: WHOCommon
Canonical URL: http://smart.who.int/hiv/Library/WHOCommon
Dependency Description: Library HIE
Resource: HIVIndicatorElements
Canonical URL: http://smart.who.int/hiv/Library/HIVIndicatorElements
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: Code system HIVConcepts
Resource: WHO SMART HIV Concepts CodeSystem
Canonical URL: http://smart.who.int/hiv/CodeSystem/HIVConcepts
Dependency Description: Code system ConditionClinicalStatusCodes
Resource: Condition Clinical Status Codes
Canonical URL: http://terminology.hl7.org/CodeSystem/condition-clinical
Dependency Description: Code system ObservationCategoryCodes
Resource: Observation Category Codes
Canonical URL: http://terminology.hl7.org/CodeSystem/observation-category
Dependency Description: Value set HIV test type - HIV.B.DE81 Choices
Resource: HIV test type ValueSet
Canonical URL: http://smart.who.int/hiv/ValueSet/HIV.B.DE81
Direct Reference Code Display: PrEP for HIV prevention
Code: HIV.C.DE76
System: http://smart.who.int/hiv/CodeSystem/HIVConcepts
Direct Reference Code Display: HIV-negative
Code: HIV.B.DE113
System: http://smart.who.int/hiv/CodeSystem/HIVConcepts
Direct Reference Code Display: OAMT
Code: HIV.PRV.DE4
System: http://smart.who.int/hiv/CodeSystem/HIVConcepts
Direct Reference Code Display: STI testing and treatment services
Code: HIV.B.DE164
System: http://smart.who.int/hiv/CodeSystem/HIVConcepts
Direct Reference Code Display: VMMC procedure performed
Code: HIV.B.DE197
System: http://smart.who.int/hiv/CodeSystem/HIVConcepts
Direct Reference Code Display: HIV prevention intervention
Code: HIV.PRV.DE2
System: http://smart.who.int/hiv/CodeSystem/HIVConcepts
Direct Reference Code Display: Other
Code: HIV.PRV.DE8
System: http://smart.who.int/hiv/CodeSystem/HIVConcepts
Direct Reference Code Display: At elevated risk for HIV acquisition
Code: HIV.B.DE225
System: http://smart.who.int/hiv/CodeSystem/HIVConcepts
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: Male
Code: HIV.A.DE20
System: http://smart.who.int/hiv/CodeSystem/HIVConcepts
Direct Reference Code Display: Female
Code: HIV.A.DE19
System: http://smart.who.int/hiv/CodeSystem/HIVConcepts
Direct Reference Code Display: Transgender female
Code: HIV.A.DE22
System: http://smart.who.int/hiv/CodeSystem/HIVConcepts
Direct Reference Code Display: Transgender male
Code: HIV.A.DE21
System: http://smart.who.int/hiv/CodeSystem/HIVConcepts
Direct Reference Code Display: Other
Code: HIV.A.DE23
System: http://smart.who.int/hiv/CodeSystem/HIVConcepts
Direct Reference Code Display: Key population member*
Code: HIV.B.DE49
System: http://smart.who.int/hiv/CodeSystem/HIVConcepts
Direct Reference Code Display: Social History
Code: social-history
System: http://terminology.hl7.org/CodeSystem/observation-category
Parameter Name: Measurement Period
Use: In
Min Cardinality: 0
Max Cardinality: 1
Type: Period
Parameter Name: Intervention Interval
Use: In
Min Cardinality: 0
Max Cardinality: 1
Type: Quantity
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
Parameter Name: Stratification
Use: Out
Min Cardinality: 0
Max Cardinality: 1
Type: string
Measure Logic Data Requirements
Data Requirement Type: MedicationStatement
Profile(s): MedicationStatement
Must Support Elements: reasonCode, effective
Data Requirement Type: Observation
Profile(s): Observation
Must Support Elements: code, status, category, effective, issued, code.coding
Code Filter(s):
Path: code
Code:
Data Requirement Type: Observation
Profile(s): Observation
Must Support Elements: status, code, value, effective
Data Requirement Type: Observation
Profile(s): Observation
Must Support Elements: code, status, value, effective
Code Filter(s):
Path: code
ValueSet: HIV test type ValueSet
Data Requirement Type: EpisodeOfCare
Profile(s): EpisodeOfCare
Must Support Elements: type, period, statusHistory
Data Requirement Type: Procedure
Profile(s): Procedure
Must Support Elements: status, code, performed
Data Requirement Type: Condition
Profile(s): Condition
Must Support Elements: code
Data Requirement Type: Patient
Profile(s): Patient
Must Support Elements: use
Measure Logic Definitions
Logic Definition Library Name: HIVElements
/* End of HIV prevention intervention */

/*
@dataElement: HIV.PRV.DE3 - PrEP service
@activity: HIV.B6 Capture or update client history
@description: Client accessed PrEP services
*/

define "PrEP service":
  [MedicationStatement] MS
    where exists(MS.reasonCode C where C ~ Concepts."PrEP for HIV prevention")
    sort by start of effective.toInterval()
Logic Definition Library Name: HIVElements
/* End of Date informed of HIV-positive diagnosis */

/*
@activity: HIV.B7 Test for HIV using testing algorithm
*/
define "HIV test":
  [Observation: Concepts."HIV test type - HIV.B.DE81 Choices"] O
  where O.status in { 'final', 'amended', 'corrected' }
Logic Definition Library Name: HIVElements
/* End of HIV test date B.DE110 */

/*
@dataElement: HIV.B.DE111 - HIV test result
@activity: HIV.B7 Test for HIV using testing algorithm
@description: The result from HIV testing after applying the testing algorithm
*/
// Same as test - see profile
define "HIV test result Observation":
  "HIV test" O
Logic Definition Library Name: HIVElements
/* End of HIV-positive B.DE112 */

/*
@dataElement: HIV.B.DE113 - HIV-negative
@activity: HIV.B7 Test for HIV using testing algorithm
@description: Test result is HIV-negative
*/
define "HIV-negative test result":
  "HIV test result Observation" O
    where O.value ~ Concepts."HIV-negative - HIV.B.DE113"
Logic Definition Library Name: HIVIndicatorElements
define "Negative Tests within Measurement Period":
  Elements."HIV-negative test result" O
    // with Elements."At elevated risk for HIV acquisition B.DE225" HIV
    // such that O.hasMember.references(HIV)
    where O.effective.toInterval() starts during "Measurement Period"
    sort by start of effective.toInterval()
Logic Definition Library Name: HIVIndicatorElements
define "First Negative Test within Measurement Period":
  (First("Negative Tests within Measurement Period"))
Logic Definition Library Name: HIVElements
define "OAMT status":
    [EpisodeOfCare] EOC
    where exists(EOC.type T where T ~ Concepts."OAMT")
    return EOC.period
Logic Definition Library Name: HIVElements
define "OAMT statusHistory":
    [EpisodeOfCare] EOC
    where exists(EOC.type T where T ~ Concepts."OAMT") 
    and (exists (
      EOC.statusHistory H
      where H.period is not null))
Logic Definition Library Name: HIVElements
/* End of PrEP service */

/*
@dataElement: HIV.PRV.DE4 - OAMT
@activity: HIV.B6 Capture or update client history
@description: Client accessed opioid agonist maintenance treatment (OAMT) services
*/

define "OAMT":
  flatten{"OAMT status","OAMT statusHistory".statusHistory.period}
Logic Definition Library Name: HIVElements
// TODO: fix device use statement 
  // [DeviceUseStatement] DUS
  // with [Device: ConceptsCustom."needle-syringe"] D
  //     such that DUS.reasonReference.references(D) 
  //       and D.status in { 'active' }
  // where DUS.status = 'completed'

  // define "NSP date":
  // [DeviceUseStatement] DUS
  // with [Device: ConceptsCustom."needle-syringe"] D
  //     such that DUS.reasonReference.references(D) 
  //       and D.status in { 'active' }
  // where DUS.status = 'completed'
  // return start of DUS.timing.toInterval()
/* End of NSP */

/*
@dataElement: HIV.PRV.DE6 - STI services
@activity: HIV.B6 Capture or update client history
@description: Client accessed sexually transmitted infection (STI) services
*/

define "STI services":
  [Procedure] P
  where P.status = 'completed'
  and P.code ~ Concepts."STI testing and treatment services"
Logic Definition Library Name: HIVElements
/* End of STI services */

/*
@dataElement: HIV.PRV.DE7 - VMMC
@activity: HIV.B6 Capture or update client history
@description: Client accessed voluntary medical male circumcision (VMMC) services
*/
// define "VMMC_done":
// [Procedure] P
//   where P.status = 'completed'
//   and P.code ~ Concepts."Voluntary medical male circumcision VMMC"


define "VMMC":
  [Procedure] P
  where P.status = 'completed'
  and P.code ~ Concepts."VMMC procedure"
Logic Definition Library Name: HIVElements
/* End of VMMC */

/*
@dataElement: HIV.PRV.DE8 - Other
@activity: HIV.B6 Capture or update client history
@description: Client accessed other HIV prevention services
*/

define "Other PRV.DE8":
  [Observation] O
    where O.status in {'final', 'amended'}
    and O.code ~ Concepts."HIV prevention intervention"
    and O.value ~ Concepts."Other - HIV.PRV.DE8"
    sort by start of effective.toInterval()
Logic Definition Library Name: HIVElements
/* End of HIV retest prior to starting ART conducted */

/*
@dataElement: HIV.B.DE225 - At elevated risk for HIV acquisition
@activity: HIV.B6 Capture or update client history
@description: Client is at elevated risk for HIV acquisition
*/

define "At elevated risk for HIV acquisition B.DE225":
  [Condition] C
    where C.code ~ Concepts."At elevated risk for HIV acquisition - HIV.B.DE225"
Logic Definition Library Name: HIVIndicatorElements
/* End of Other B.DE222 */

/*
@dataElement: HIV.B.DE225 - At elevated risk for HIV acquisition
@activity: HIV.B6 Capture or update client history
@description: Client is at elevated risk for HIV acquisition
*/

define "At elevated risk for HIV acquisition B.DE225":
  exists(Elements."At elevated risk for HIV acquisition B.DE225" C
    where C.prevalenceInterval() overlaps "Measurement Period")
Logic Definition Library Name: HIVIND24Logic
/**
 * Numerator
 * 
 * Definition: Number of people who receive an HIV prevention intervention within a defined period after receiving a negative HIV test result
 * Calculation: COUNT of clients with "At elevated risk for HIV acquisition"=True and with "Date accessed HIV prevention intervention" within X days of "HIV test date" in the reporting period with "HIV test result"='HIV-negative' |  | where X is 7, 14, or 28 days
 */

define "Numerator":
  (exists(HE."PrEP service" prep
   where prep.effective.toInterval() starts before (start of HIE."First Negative Test within Measurement Period".effective.toInterval() + "Intervention Interval")
  and prep.effective.toInterval() starts after (start of HIE."First Negative Test within Measurement Period".effective.toInterval())
   )
  or 
  exists(HE."OAMT" t where t starts before (start of HIE."First Negative Test within Measurement Period".effective.toInterval() + "Intervention Interval")
      and t starts after (start of HIE."First Negative Test within Measurement Period".effective.toInterval()))
  or 
  // TODO: DeviceUseStatement causing translation issue
  // exists(HE."NSP" DUS where DUS.timing.toInterval() starts before (start of HIE."First Negative Test within Measurement Period".effective.toInterval() + "Intervention Interval")
  // and DUS.timing.toInterval() starts after (start of HIE."First Negative Test within Measurement Period".effective.toInterval()))
  // or 
  exists(HE."STI services" STI where STI.performed.toInterval() starts before (start of HIE."First Negative Test within Measurement Period".effective.toInterval() + "Intervention Interval")
  and STI.performed.toInterval() starts after (start of HIE."First Negative Test within Measurement Period".effective.toInterval()))
  or 
  exists(HE."VMMC" V where V.performed.toInterval() starts before (start of HIE."First Negative Test within Measurement Period".effective.toInterval() + "Intervention Interval")
  and V.performed.toInterval() starts after (start of HIE."First Negative Test within Measurement Period".effective.toInterval()))
  or
  exists(HE."Other PRV.DE8" O
    where O.effective.toInterval() starts before (start of HIE."First Negative Test within Measurement Period".effective.toInterval() + "Intervention Interval")
    and O.effective.toInterval() starts after (start of HIE."First Negative Test within Measurement Period".effective.toInterval())))
  and
  HIE."At elevated risk for HIV acquisition B.DE225"
Logic Definition Library Name: HIVIND24Logic
/**
 * Denominator
 *
 * Definition: Number of people testing negative for HIV in the reporting period and identified as being at elevated risk for HIV acquisition (includes people requesting/receiving any HIV prevention intervention, people from key populations, people with known risk factors or those assessed as being at risk of HIV acquisition)
 * Calculation: COUNT of clients with "At elevated risk for HIV acquisition"=True AND with an "HIV test date" in the reporting period with "HIV test result"='HIV-negative'
 */

define "Denominator":
  exists(HIE."Negative Tests within Measurement Period")
  and HIE."At elevated risk for HIV acquisition B.DE225"
Logic Definition Library Name: HIVIND24Logic
/* Populations */

/*
 *Initial Population
 */

define "Initial Population":
  true
Logic Definition Library Name: HIVIndicatorElements
/*
@dataElement: HIV.A.DE18 - Gender
@activity: HIV.A6.1 Review sociodemographic data with client | HIV.A5 Create new client record
@description: Gender of the client
*/

/*
 * By Administrative Gender of Patient Stratifier
 * Need to expand codes
 */

define "By Administrative Gender Stratifier":
  case 
      when Patient.gender = 'male' then Concepts."Male"
      when Patient.gender = 'female' then Concepts."Female"
      when Patient.gender = 'transgender female' then Concepts."Transgender female"
      when Patient.gender = 'transgender male' then Concepts."Transgender male"
      else Concepts."Other - HIV.A.DE23"
  end
Logic Definition Library Name: HIVIndicatorElements
/* End of Visit date A.DE3 */

/*
@dataElement: HIV.A.DE17 - Age
@activity: HIV.A6.1 Review sociodemographic data with client | HIV.A5 Create new client record
@description: Calculated age (number of years) of the client based on date of birth
*/
define "Age In Years":
  AgeInYearsAt(start of "Measurement Period")
Logic Definition Library Name: HIVIndicatorElements
define "By Age Stratifier 5":
  case 
      when "Age In Years" < 15 then '<15'
      when "Age In Years" >= 15 and "Age In Years"<= 19 then '15-19'
      when "Age In Years" <= 24 then '20-24'
      when "Age In Years" <= 49 then '25–49'
      when "Age In Years" >= 50 then '50+'
      else null
  end
Logic Definition Library Name: HIVIndicatorElements
// Geographic Region
define "By Geographic Region Stratifier":
    First(Patient.address A where A.use in { 'home' }).state
Logic Definition Library Name: HIVElements
/* End of Key population member B.DE49 */

/*
@dataElement: HIV.B.DE50 - Key population member type
@activity: HIV.B6 Capture or update client history
@description: The type of key population that the client is included in
*/
define "Key population member type Observation":
  [Observation: Concepts."Key population member - HIV.B.DE49"] O
    where O.status in { 'final', 'amended', 'corrected' }
    and exists(O.category OC where OC ~ ConceptsCustom."social-history")
Logic Definition Library Name: HIVIndicatorElements
define "Key population member type Observation":
  Elements."Key population member type Observation" O
    where O.effective.toInterval() before end of "Measurement Period"
    or O.issued before end of "Measurement Period"
Logic Definition Library Name: HIVIndicatorElements
// Stratifier
define patientGroups:
  "Key population member type Observation" O
  return Combine(O.code.coding.code, ':')
Logic Definition Library Name: HIVIndicatorElements
/* End of HIV prevention intervention */

/*
@dataElement: HIV.PRV.DE3 - PrEP service
@activity: HIV.B6 Capture or update client history
@description: Client accessed PrEP services
*/

define "PrEP service":
  exists(Elements."PrEP service" prep
   where prep.effective.toInterval() during "Measurement Period"
   )
Logic Definition Library Name: HIVIndicatorElements
/* End of PrEP service */

/*
@dataElement: HIV.PRV.DE4 - OAMT
@activity: HIV.B6 Capture or update client history
@description: Client accessed opioid agonist maintenance treatment (OAMT) services
*/

define "OAMT":
  exists(Elements."OAMT" t where t during "Measurement Period")
Logic Definition Library Name: HIVIndicatorElements
/* End of OAMT */

/*
@dataElement: HIV.PRV.DE5 - NSP
@activity: HIV.B6 Capture or update client history
@description: Client accessed needle-syringe programme (NSP) services
*/

define "NSP":
  false
Logic Definition Library Name: HIVIndicatorElements
// TODO: doesn't compile DeviceUseStatement causes translation error
  //exists(Elements."NSP" DUS where DUS.timing.toInterval() during "Measurement Period")
/* End of NSP */

/*
@dataElement: HIV.PRV.DE6 - STI services
@activity: HIV.B6 Capture or update client history
@description: Client accessed sexually transmitted infection (STI) services
*/

define "STI services":
  exists(Elements."STI services" STI where STI.performed.toInterval() during "Measurement Period")
Logic Definition Library Name: HIVIndicatorElements
/* End of STI services */

/*
@dataElement: HIV.PRV.DE7 - VMMC
@activity: HIV.B6 Capture or update client history
@description: Client accessed voluntary medical male circumcision (VMMC) services
*/

define "VMMC":
  exists(Elements."VMMC" V where V.performed.toInterval() during "Measurement Period")
Logic Definition Library Name: HIVIndicatorElements
/* End of VMMC */

/*
@dataElement: HIV.PRV.DE8 - Other
@activity: HIV.B6 Capture or update client history
@description: Client accessed other HIV prevention services
*/

define "Other PRV.DE8":
  exists(Elements."Other PRV.DE8" O
    where O.effective.toInterval() during "Measurement Period")
Logic Definition Library Name: HIVIndicatorElements
/* End of At elevated risk for HIV acquisition PRV.DE1 */

/*
@dataElement: HIV.PRV.DE2 - HIV prevention intervention
@activity: HIV.B6 Capture or update client history
@description: HIV prevention intervention that client accessed
*/

//(including PrEP, OAMT, NSP, STI services, VMMC) 
define "HIV prevention intervention":
  List<String>{
    if "PrEP service" then 'PrEP' else null,
    if "OAMT" then 'OAMT' else null,
    if "NSP" then 'NSP' else null,
    if "STI services" then 'STI services' else null,
    if "VMMC" then 'VMMC' else null,
    if "Other PRV.DE8" then 'other prevention' else null
  }
Logic Definition Library Name: HIVIND24Logic
define "Stratification":
 HIE."By Administrative Gender Stratifier".code 
  + ':' + HIE."By Age Stratifier 5"
+ ':' + HIE."By Geographic Region Stratifier"
+ Combine(HIE.patientGroups, ':')
+ Combine(HIE."HIV prevention intervention", ':')
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 ObservationStatus): 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 ToString(value ProcedureStatus): value.value
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: 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 ToDateTime(value dateTime): 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: FHIRHelpers
define function ToString(value AdministrativeGender): value.value
Logic Definition Library Name: FHIRHelpers
define function ToString(value string): value.value
Logic Definition Library Name: FHIRHelpers
define function ToString(value AddressUse): value.value
Logic Definition Library Name: FHIRHelpers
define function ToDateTime(value instant): value.value
Generated using version 0.4.6 of the sample-content-ig Liquid templates