dQM QICore Content Implementation Guide
2025.0.0 - CI Build

dQM QICore Content Implementation Guide, published by cqframework. This guide is not an authorized publication; it is the continuous build for version 2025.0.0 built by the FHIR (HL7® FHIR® Standard) CI Build. This version is based on the current content of https://github.com/cqframework/dqm-content-qicore-2025/ and changes regularly. See the Directory of published versions

Measure: NHSN Acute Care Hospital Monthly Initial Population 1 (Experimental)

Official URL: https://madie.cms.gov/Measure/NHSNAcuteCareHospitalMonthlyInitialPopulation1 Version: Draft based on 0.0.000
Draft as of 2026-01-16 Responsible: Centers for Disease Control and Prevention (CDC) Computable Name: NHSNAcuteCareHospitalMonthlyInitialPopulation1
Other Identifiers: Short Name: NHSNACHMonthly1 (use: usual, ), UUID:1a6d58a6-1063-421b-8231-b8700d8009c9 (use: official, ), UUID:6156503c-1e85-4137-891c-1ee73c0c01d0 (use: official, )

Copyright/Legal: UNKNOWN

Patients of all ages with inpatient (Inpt), emergency department (ED), observation (OBS), or short stay (SS) encounter type or with Inpt, ED, OBS, SS encounter class or with an Inpt, ED, OBS, SS location during the measurement period.

Metadata
Title NHSN Acute Care Hospital Monthly Initial Population 1
Version Draft based on 0.0.000
Short Name NHSNACHMonthly1
GUID (Version Independent) urn:uuid:1a6d58a6-1063-421b-8231-b8700d8009c9
GUID (Version Specific) urn:uuid:6156503c-1e85-4137-891c-1ee73c0c01d0
Effective Period 2025-01-01 through 2025-01-31
Status Draft
Experimental true
Steward (Publisher) Centers for Disease Control and Prevention (CDC)
Developer Lantana Consulting Group
Description

Patients of all ages with inpatient (Inpt), emergency department (ED), observation (OBS), or short stay (SS) encounter type or with Inpt, ED, OBS, SS encounter class or with an Inpt, ED, OBS, SS location during the measurement period.

Copyright

UNKNOWN

Disclaimer

UNKNOWN

Measure Group (Rate) (ID: Group_1)
Basis Encounter
Scoring Cohort
Type Outcome
Initial Population ID: InitialPopulation_1
Description:

All inpatient encounters, as well as ED and OBS encounters that end within 1 hour of the start of the inpatient encounter, for patients of all ages where at least one diabetes medication was ordered or administered during the encounter that is during the measurement period.

Criteria: Initial Population
Supplemental Data Guidance Guidance <p>SDE</p>
Supplemental Data Elements
Supplemental Data Element ID: sde-condition-problems-healthconcerns
Usage Code: Supplemental Data
Description: SDE Condition Problems HealthConcerns
Logic Definition: SDE Condition Problems HealthConcerns
Supplemental Data Element ID: sde-condition-diagnosis
Usage Code: Supplemental Data
Description: SDE Condition Diagnosis
Logic Definition: SDE Condition Diagnosis
Supplemental Data Element ID: sde-coverage
Usage Code: Supplemental Data
Description: SDE Coverage
Logic Definition: SDE Coverage
Supplemental Data Element ID: sde-device
Usage Code: Supplemental Data
Description: SDE Device
Logic Definition: SDE Device
Supplemental Data Element ID: sde-diagnosticreport-lab
Usage Code: Supplemental Data
Description: SDE DiagnosticReport Lab
Logic Definition: SDE DiagnosticReport Lab
Supplemental Data Element ID: sde-diagnosticreport-note
Usage Code: Supplemental Data
Description: SDE DiagnosticReport Note
Logic Definition: SDE DiagnosticReport Note
Supplemental Data Element ID: sde-diagnosticreport-others
Usage Code: Supplemental Data
Description: SDE DiagnosticReport Others
Logic Definition: SDE DiagnosticReport Others
Supplemental Data Element ID: sde-encounter
Usage Code: Supplemental Data
Description: SDE Encounter
Logic Definition: SDE Encounter
Supplemental Data Element ID: sde-ip-encounters
Usage Code: Supplemental Data
Description: SDE IP Encounters
Logic Definition: SDE IP Encounters
Supplemental Data Element ID: sde-location
Usage Code: Supplemental Data
Description: SDE Location
Logic Definition: SDE Location
Supplemental Data Element ID: sde-medication-administration
Usage Code: Supplemental Data
Description: SDE Medication Administration
Logic Definition: SDE Medication Administration
Supplemental Data Element ID: sde-medication-administration-base
Usage Code: Supplemental Data
Description: SDE Medication Administration Base
Logic Definition: SDE Medication Administration Base
Supplemental Data Element ID: sde-medication-administration-not-done
Usage Code: Supplemental Data
Description: SDE Medication Administration Not Done
Logic Definition: SDE Medication Administration Not Done
Supplemental Data Element ID: sde-medication-request-base
Usage Code: Supplemental Data
Description: SDE Medication Request Base
Logic Definition: SDE Medication Request Base
Supplemental Data Element ID: sde-medication-not-requested
Usage Code: Supplemental Data
Description: SDE Medication Not Requested
Logic Definition: SDE Medication Not Requested
Supplemental Data Element ID: sde-medication-request
Usage Code: Supplemental Data
Description: SDE Medication Request
Logic Definition: SDE Medication Request
Supplemental Data Element ID: sde-medication
Usage Code: Supplemental Data
Description: SDE Medication
Logic Definition: SDE Medication
Supplemental Data Element ID: sde-observation-lab-category
Usage Code: Supplemental Data
Description: SDE Observation Lab Category
Logic Definition: SDE Observation Lab Category
Supplemental Data Element ID: sde-observation-simple
Usage Code: Supplemental Data
Description: SDE Observation Simple
Logic Definition: SDE Observation Simple
Supplemental Data Element ID: sde-observation-survey
Usage Code: Supplemental Data
Description: SDE Observation Survey
Logic Definition: SDE Observation Survey
Supplemental Data Element ID: sde-observation-vital-signs-category
Usage Code: Supplemental Data
Description: SDE Observation Vital Signs Category
Logic Definition: SDE Observation Vital Signs Category
Supplemental Data Element ID: sde-procedure
Usage Code: Supplemental Data
Description: SDE Procedure
Logic Definition: SDE Procedure
Supplemental Data Element ID: sde-service-request-base
Usage Code: Supplemental Data
Description: SDE Service Request Base
Logic Definition: SDE Service Request Base
Supplemental Data Element ID: sde-service-not-requested
Usage Code: Supplemental Data
Description: SDE Service Not Requested
Logic Definition: SDE Service Not Requested
Supplemental Data Element ID: sde-service-request
Usage Code: Supplemental Data
Description: SDE Service Request
Logic Definition: SDE Service Request
Supplemental Data Element ID: sde-minimal-patient
Usage Code: Supplemental Data
Description: SDE Minimal Patient
Logic Definition: SDE Minimal Patient
Supplemental Data Element ID: sde-specimens
Usage Code: Supplemental Data
Description: SDE Specimens
Logic Definition: SDE Specimens
Measure Logic
Primary Library NHSNAcuteCareHospitalMonthlyInitialPopulation1
Contents Population Criteria
Logic Definitions
Terminology
Dependencies
Data Requirements
Population Criteria
Measure Group (Rate) (ID: Group_1)
Initial Population
define "Initial Population":
  "Qualifying Encounters During Measurement Period"
    union "Encounters with Patient Hospital Locations"
Definition
Initial Population
define "Initial Population":
  "Qualifying Encounters During Measurement Period"
    union "Encounters with Patient Hospital Locations"
Definition
Logic Definitions
Logic Definition Library Name: CQMCommon
/*
@description: Returns the Location resource specified by the given reference.
*/
define fluent function getLocation(reference Reference):
  singleton from (
    [Location] L where reference.references(L)
  )
Logic Definition Library Name: FHIRHelpers
/*
@description: Converts the given [Period](https://hl7.org/fhir/datatypes.html#Period)
value to a CQL DateTime Interval
@comment: If the start value of the given period is unspecified, the starting
boundary of the resulting interval will be open (meaning the start of the interval
is unknown, as opposed to interpreted as the beginning of time).
*/
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
/*
@description: Converts the given FHIR [CodeableConcept](https://hl7.org/fhir/datatypes.html#CodeableConcept) value to a CQL Concept.
*/
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
/*
@description: Converts the given FHIR [Coding](https://hl7.org/fhir/datatypes.html#Coding) value to a CQL Code.
*/
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 uri): value.value
Logic Definition Library Name: NHSNAcuteCareHospitalMonthlyInitialPopulation1
// ----------------------------------------------------------------------
// Core encounter logic
// ----------------------------------------------------------------------

// Encounters with NHSN class codes (IMP, ACUTE, NONAC, SS)





define "Encounters with NHSN Inpatient Class":
  [Encounter] Enc
    where Enc.class ~ QICoreCommon."inpatient encounter"
      or Enc.class ~ QICoreCommon."inpatient acute"
      or Enc.class ~ QICoreCommon."inpatient non-acute"
      or Enc.class ~ QICoreCommon."short stay"
Logic Definition Library Name: NHSNAcuteCareHospitalMonthlyInitialPopulation1
define "Qualifying Encounters During Measurement Period":
  ( [Encounter: "Encounter Inpatient"]
    union [Encounter: "Emergency Department Visit"]
    union [Encounter: "Observation Services"]
    union "Encounters with NHSN Inpatient Class"
    union [Encounter: class ~ "emergency"]
    union [Encounter: class ~ "observation encounter"] ) QualifyingEncounters
    where QualifyingEncounters.status in { 'in-progress', 'finished', 'triaged', 'onleave', 'entered-in-error' }
      and QualifyingEncounters.period overlaps "Measurement Period"
Logic Definition Library Name: NHSNAcuteCareHospitalMonthlyInitialPopulation1
define "Encounters":
  [Encounter]
Logic Definition Library Name: NHSNAcuteCareHospitalMonthlyInitialPopulation1
define "Encounters with Patient Hospital Locations":
  "Encounters" Ens
    where exists ( Ens.location EncounterLocation
        where EncounterLocation.period overlaps Ens.period
          and EncounterLocation.location.getLocation ( ).type in "Inpatient, Emergency, and Observation Locations"
    )
      and Ens.status in { 'in-progress', 'finished', 'triaged', 'onleave', 'entered-in-error' }
      and Ens.period overlaps "Measurement Period"
Logic Definition Library Name: NHSNAcuteCareHospitalMonthlyInitialPopulation1
define "Initial Population":
  "Qualifying Encounters During Measurement Period"
    union "Encounters with Patient Hospital Locations"
Logic Definition Library Name: NHSNAcuteCareHospitalMonthlyInitialPopulation1
// Coverage SDE – tuples of Coverage data


define "SDE Coverage":
  [Coverage] Coverages
    where exists ( "Initial Population" IP
        where Coverages.period overlaps IP.period
    )
    return {
      id: Coverages.id,
      meta: Coverages.meta,
      status: Coverages.status,
      type: Coverages.type,
      policyHolder: Coverages.policyHolder,
      subscriber: Coverages.subscriber,
      subscriberId: Coverages.subscriberId,
      beneficiary: Coverages.beneficiary,
      dependent: Coverages.dependent,
      relationship: Coverages.relationship,
      period: Coverages.period,
      payor: Coverages.payor,
      class: Coverages.class,
      order: Coverages.order,
      network: Coverages.network,
      subrogation: Coverages.subrogation,
      contract: Coverages.contract
    }
Logic Definition Library Name: NHSNAcuteCareHospitalMonthlyInitialPopulation1
// Encounter SDEs


define "SDE Encounter":
  "Encounters" Ens
    where not "CheckIP"(Ens)
      and exists ( "Initial Population" IP
          where Ens.period overlaps IP.period
      )
    return {
      id: Ens.id,
      meta: Ens.meta,
      identifier: Ens.identifier,
      status: Ens.status,
      statusHistory: Ens.statusHistory,
      class: Ens.class,
      classHistory: Ens.classHistory,
      type: Ens.type,
      serviceType: Ens.serviceType,
      priority: Ens.priority,
      subject: Ens.subject,
      period: Ens.period,
      length: Ens.length,
      reasonCode: Ens.reasonCode,
      reasonReference: Ens.reasonReference,
      diagnosis: Ens.diagnosis,
      account: Ens.account,
      hospitalization: Ens.hospitalization,
      location: Ens.location,
      partOf: Ens.partOf
    }
Logic Definition Library Name: NHSNAcuteCareHospitalMonthlyInitialPopulation1
// Procedure SDE


define "SDE Procedure":
  [Procedure] Procedures
    where exists ( "Initial Population" IP
        where "Normalize Interval"(Procedures.performed) overlaps IP.period
    )
    return {
      id: Procedures.id,
      meta: Procedures.meta,
      extension: Procedures.extension,
      basedOn: Procedures.basedOn,
      partOf: Procedures.partOf,
      status: Procedures.status,
      category: Procedures.category,
      code: Procedures.code,
      subject: Procedures.subject,
      encounter: Procedures.encounter,
      performed: Procedures.performed,
      location: Procedures.location,
      reasonCode: Procedures.reasonCode,
      reasonReference: Procedures.reasonReference,
      bodySite: Procedures.bodySite
    }
Logic Definition Library Name: NHSNAcuteCareHospitalMonthlyInitialPopulation1
// Device SDE – tuples of Device data


define "SDE Device":
  [Device] Devices
    where exists ( "Initial Population" )
    return {
      id: Devices.id,
      meta: Devices.meta,
      extension: Devices.extension,
      status: Devices.status,
      expirationDate: Devices.expirationDate,
      lotNumber: Devices.lotNumber,
      serialNumber: Devices.serialNumber,
      modelNumber: Devices.modelNumber,
      partNumber: Devices.partNumber,
      type: Devices.type,
      patient: Devices.patient,
      parent: Devices.parent
    }
Logic Definition Library Name: NHSNAcuteCareHospitalMonthlyInitialPopulation1
define "SDE Observation Vital Signs Category":
  [USCoreVitalSignsProfile] Obs
    where exists ( "Initial Population" IP
        where "Normalize Interval"(Obs.effective) overlaps IP.period
    )
    return {
      id: Obs.id,
      meta: Obs.meta,
      extension: Obs.extension,
      partOf: Obs.partOf,
      status: Obs.status,
      category: Obs.category,
      code: Obs.code,
      subject: Obs.subject,
      encounter: Obs.encounter,
      effective: Obs.effective,
      issued: Obs.issued,
      value: Obs.value,
      dataAbsentReason: Obs.dataAbsentReason,
      interpretation: Obs.interpretation,
      bodySite: Obs.bodySite,
      method: Obs.method,
      specimen: Obs.specimen,
      referenceRange: Obs.referenceRange,
      hasMember: Obs.hasMember,
      derivedFrom: Obs.derivedFrom,
      component: Obs.component
    }
Logic Definition Library Name: NHSNAcuteCareHospitalMonthlyInitialPopulation1
define "SDE DiagnosticReport Others":
  [DiagnosticReportNote] dr
    where not ( exists ( dr.category Category
          where Category ~ "Radiology"
      )
        or exists ( dr.category Category
            where Category ~ "Pathology"
        )
        or exists ( dr.category Category
            where Category ~ "Cardiology"
        )
    )
      and exists ( "Initial Population" IP
          where "Normalize Interval"(dr.effective) overlaps IP.period
      )
    return {
      id: dr.id,
      meta: dr.meta,
      extension: dr.extension,
      basedOn: dr.basedOn,
      status: dr.status,
      category: dr.category,
      code: dr.code,
      subject: dr.subject,
      encounter: dr.encounter,
      effective: dr.effective,
      issued: dr.issued,
      specimen: dr.specimen,
      result: dr.result,
      conclusion: dr.conclusion,
      conclusionCode: dr.conclusionCode
    }
Logic Definition Library Name: NHSNAcuteCareHospitalMonthlyInitialPopulation1
define "SDE Specimens":
  [USCoreSpecimenProfile] sp
    where exists ( "Initial Population" IP
        where "Normalize Interval"(sp.collection.collected) overlaps IP.period
    )
    return {
      id: sp.id,
      type: sp.type
    }
Logic Definition Library Name: NHSNAcuteCareHospitalMonthlyInitialPopulation1
define "SDE Medication Administration Not Done":
  [MedicationAdministrationNotDone] MedAdministrations
    where exists ( "Initial Population" IP
        where "Normalize Interval"(MedAdministrations.effective) overlaps IP.period
    )
    return {
      id: MedAdministrations.id,
      meta: MedAdministrations.meta,
      instantiates: MedAdministrations.instantiates,
      partOf: MedAdministrations.partOf,
      status: MedAdministrations.status,
      statusReason: MedAdministrations.statusReason,
      category: MedAdministrations.category,
      medication: MedAdministrations.medication,
      subject: MedAdministrations.subject,
      context: MedAdministrations.context,
      supportingInformation: MedAdministrations.supportingInformation,
      effective: MedAdministrations.effective,
      performer: MedAdministrations.performer,
      reasonCode: MedAdministrations.reasonCode,
      reasonReference: MedAdministrations.reasonReference,
      request: MedAdministrations.request,
      device: MedAdministrations.device,
      note: MedAdministrations.note,
      dosage: MedAdministrations.dosage
    }
Logic Definition Library Name: NHSNAcuteCareHospitalMonthlyInitialPopulation1
// SDE Medication Not Requested - negation requests (doNotPerform is true)


define "SDE Medication Not Requested":
  [MedicationNotRequested] MedNotRequests
    where exists ( "Initial Population" IP
        where MedNotRequests.authoredOn during IP.period
    )
    return {
      id: MedNotRequests.id,
      meta: MedNotRequests.meta,
      status: MedNotRequests.status,
      statusReason: MedNotRequests.statusReason,
      intent: MedNotRequests.intent,
      category: MedNotRequests.category,
      priority: MedNotRequests.priority,
      doNotPerform: MedNotRequests.doNotPerform,
      reported: MedNotRequests.reported,
      medication: MedNotRequests.medication,
      subject: MedNotRequests.subject,
      encounter: MedNotRequests.encounter,
      authoredOn: MedNotRequests.authoredOn,
      requester: MedNotRequests.requester,
      recorder: MedNotRequests.recorder,
      reasonCode: MedNotRequests.reasonCode,
      reasonReference: MedNotRequests.reasonReference,
      instantiatesCanonical: MedNotRequests.instantiatesCanonical,
      instantiatesUri: MedNotRequests.instantiatesUri,
      courseOfTherapyType: MedNotRequests.courseOfTherapyType,
      dosageInstruction: MedNotRequests.dosageInstruction
    }
Logic Definition Library Name: NHSNAcuteCareHospitalMonthlyInitialPopulation1
define "Initial Population":
  "Qualifying Encounters During Measurement Period"
    union "Encounters with Patient Hospital Locations"
Logic Definition Library Name: NHSNAcuteCareHospitalMonthlyInitialPopulation1
// ServiceRequest SDE - regular requests (doNotPerform is false or absent)


define "SDE Service Request Base":
  [ServiceRequest] ServiceRequests
    where exists ( "Initial Population" IP
        where ServiceRequests.authoredOn during IP.period
    )
    return {
      id: ServiceRequests.id,
      meta: ServiceRequests.meta,
      instantiatesCanonical: ServiceRequests.instantiatesCanonical,
      instantiatesUri: ServiceRequests.instantiatesUri,
      basedOn: ServiceRequests.basedOn,
      replaces: ServiceRequests.replaces,
      requisition: ServiceRequests.requisition,
      status: ServiceRequests.status,
      intent: ServiceRequests.intent,
      category: ServiceRequests.category,
      priority: ServiceRequests.priority,
      //doNotPerform: ServiceRequests.doNotPerform,
      
      code: ServiceRequests.code,
      orderDetail: ServiceRequests.orderDetail,
      quantity: ServiceRequests.quantity,
      subject: ServiceRequests.subject,
      encounter: ServiceRequests.encounter,
      occurrence: ServiceRequests.occurrence,
      asNeeded: ServiceRequests.asNeeded,
      authoredOn: ServiceRequests.authoredOn,
      requester: ServiceRequests.requester,
      performerType: ServiceRequests.performerType,
      performer: ServiceRequests.performer,
      locationCode: ServiceRequests.locationCode,
      reasonCode: ServiceRequests.reasonCode,
      reasonReference: ServiceRequests.reasonReference,
      insurance: ServiceRequests.insurance,
      bodySite: ServiceRequests.bodySite,
      note: ServiceRequests.note,
      patientInstruction: ServiceRequests.patientInstruction
    }
Logic Definition Library Name: NHSNAcuteCareHospitalMonthlyInitialPopulation1
// ServiceNotRequested SDE - negation requests (doNotPerform is true)


define "SDE Service Not Requested":
  [ServiceNotRequested] ServiceNotReqs
    where exists ( "Initial Population" IP
        where ServiceNotReqs.authoredOn during IP.period
    )
    return {
      id: ServiceNotReqs.id,
      meta: ServiceNotReqs.meta,
      instantiatesCanonical: ServiceNotReqs.instantiatesCanonical,
      instantiatesUri: ServiceNotReqs.instantiatesUri,
      basedOn: ServiceNotReqs.basedOn,
      replaces: ServiceNotReqs.replaces,
      requisition: ServiceNotReqs.requisition,
      status: ServiceNotReqs.status,
      intent: ServiceNotReqs.intent,
      category: ServiceNotReqs.category,
      priority: ServiceNotReqs.priority,
      doNotPerform: ServiceNotReqs.doNotPerform,
      code: ServiceNotReqs.code,
      orderDetail: ServiceNotReqs.orderDetail,
      quantity: ServiceNotReqs.quantity,
      subject: ServiceNotReqs.subject,
      encounter: ServiceNotReqs.encounter,
      occurrence: ServiceNotReqs.occurrence,
      asNeeded: ServiceNotReqs.asNeeded,
      authoredOn: ServiceNotReqs.authoredOn,
      requester: ServiceNotReqs.requester,
      performerType: ServiceNotReqs.performerType,
      performer: ServiceNotReqs.performer,
      locationCode: ServiceNotReqs.locationCode,
      reasonCode: ServiceNotReqs.reasonCode,
      reasonReference: ServiceNotReqs.reasonReference,
      insurance: ServiceNotReqs.insurance,
      bodySite: ServiceNotReqs.bodySite,
      note: ServiceNotReqs.note,
      patientInstruction: ServiceNotReqs.patientInstruction
    }
Logic Definition Library Name: NHSNAcuteCareHospitalMonthlyInitialPopulation1
// Combined SDE for all Service Requests (both regular and negation)


define "SDE Service Request":
  "SDE Service Request Base"
    union "SDE Service Not Requested"
Logic Definition Library Name: NHSNAcuteCareHospitalMonthlyInitialPopulation1
// Survey is fixed category code in ObservationScreeningAssessment profile in QI-Core    


define "SDE Observation Survey":
  [ObservationScreeningAssessment] Obs
    where exists ( "Initial Population" IP
        where "Normalize Interval"(Obs.effective) overlaps IP.period
    )
    return {
      id: Obs.id,
      meta: Obs.meta,
      extension: Obs.extension,
      partOf: Obs.partOf,
      status: Obs.status,
      category: Obs.category,
      code: Obs.code,
      subject: Obs.subject,
      encounter: Obs.encounter,
      effective: Obs.effective,
      issued: Obs.issued,
      value: Obs.value,
      dataAbsentReason: Obs.dataAbsentReason,
      interpretation: Obs.interpretation,
      bodySite: Obs.bodySite,
      method: Obs.method,
      specimen: Obs.specimen,
      referenceRange: Obs.referenceRange,
      hasMember: Obs.hasMember,
      derivedFrom: Obs.derivedFrom,
      component: Obs.component
    }
Logic Definition Library Name: NHSNAcuteCareHospitalMonthlyInitialPopulation1
// Minimal patient SDE


define "SDE Minimal Patient":
  [Patient] MinPt
    where exists ( "Initial Population" )
    return {
      id: MinPt.id,
      meta: MinPt.meta,
      extension: MinPt.extension,
      identifier: MinPt.identifier,
      active: MinPt.active,
      name: MinPt.name,
      telecom: MinPt.telecom,
      gender: MinPt.gender,
      birthDate: MinPt.birthDate,
      deceased: MinPt.deceased,
      address: MinPt.address,
      maritalStatus: MinPt.maritalStatus,
      multipleBirth: MinPt.multipleBirth,
      photo: MinPt.photo,
      contact: MinPt.contact,
      communication: MinPt.communication,
      generalPractitioner: MinPt.generalPractitioner,
      managingOrganization: MinPt.managingOrganization,
      link: MinPt.link
    }
Logic Definition Library Name: NHSNAcuteCareHospitalMonthlyInitialPopulation1
define "SDE Medication":
  ( [MedicationRequest]
    union [MedicationAdministration] ) MedReqOrAdmin
    let medication: GetMedication(MedReqOrAdmin.medication as Reference)
    where medication is not null
      and exists ( "Initial Population" IP
          where Coalesce("Normalize Interval"(MedReqOrAdmin.effective), MedReqOrAdmin.authoredOn.toInterval()) overlaps IP.period
      )
    return {
      id: medication.id,
      meta: medication.meta,
      code: medication.code,
      status: medication.status,
      manufacturer: medication.manufacturer,
      form: medication.form,
      amount: medication.amount,
      ingredient: medication.ingredient,
      batch: medication.batch
    }
Logic Definition Library Name: NHSNAcuteCareHospitalMonthlyInitialPopulation1
// SDE Medication Request - regular requests (doNotPerform is false or absent)


define "SDE Medication Request Base":
  [MedicationRequest] MedRequests
    where exists ( "Initial Population" IP
        where MedRequests.authoredOn during IP.period
    )
    return {
      id: MedRequests.id,
      meta: MedRequests.meta,
      status: MedRequests.status,
      statusReason: MedRequests.statusReason,
      intent: MedRequests.intent,
      category: MedRequests.category,
      priority: MedRequests.priority,
      //doNotPerform: MedRequests.doNotPerform,
      
      reported: MedRequests.reported,
      medication: MedRequests.medication,
      subject: MedRequests.subject,
      encounter: MedRequests.encounter,
      authoredOn: MedRequests.authoredOn,
      requester: MedRequests.requester,
      recorder: MedRequests.recorder,
      reasonCode: MedRequests.reasonCode,
      reasonReference: MedRequests.reasonReference,
      instantiatesCanonical: MedRequests.instantiatesCanonical,
      instantiatesUri: MedRequests.instantiatesUri,
      courseOfTherapyType: MedRequests.courseOfTherapyType,
      dosageInstruction: MedRequests.dosageInstruction
    }
Logic Definition Library Name: NHSNAcuteCareHospitalMonthlyInitialPopulation1
// SDE Medication Not Requested - negation requests (doNotPerform is true)


define "SDE Medication Not Requested":
  [MedicationNotRequested] MedNotRequests
    where exists ( "Initial Population" IP
        where MedNotRequests.authoredOn during IP.period
    )
    return {
      id: MedNotRequests.id,
      meta: MedNotRequests.meta,
      status: MedNotRequests.status,
      statusReason: MedNotRequests.statusReason,
      intent: MedNotRequests.intent,
      category: MedNotRequests.category,
      priority: MedNotRequests.priority,
      doNotPerform: MedNotRequests.doNotPerform,
      reported: MedNotRequests.reported,
      medication: MedNotRequests.medication,
      subject: MedNotRequests.subject,
      encounter: MedNotRequests.encounter,
      authoredOn: MedNotRequests.authoredOn,
      requester: MedNotRequests.requester,
      recorder: MedNotRequests.recorder,
      reasonCode: MedNotRequests.reasonCode,
      reasonReference: MedNotRequests.reasonReference,
      instantiatesCanonical: MedNotRequests.instantiatesCanonical,
      instantiatesUri: MedNotRequests.instantiatesUri,
      courseOfTherapyType: MedNotRequests.courseOfTherapyType,
      dosageInstruction: MedNotRequests.dosageInstruction
    }
Logic Definition Library Name: NHSNAcuteCareHospitalMonthlyInitialPopulation1
// Combined SDE for all Medication Requests (both regular and negation)


define "SDE Medication Request":
  "SDE Medication Request Base"
    union "SDE Medication Not Requested"
Logic Definition Library Name: NHSNAcuteCareHospitalMonthlyInitialPopulation1
define "SDE IP Encounters":
  "Initial Population" IP
    return {
      id: IP.id,
      meta: IP.meta,
      identifier: IP.identifier,
      status: IP.status,
      statusHistory: IP.statusHistory,
      class: IP.class,
      classHistory: IP.classHistory,
      type: IP.type,
      serviceType: IP.serviceType,
      priority: IP.priority,
      subject: IP.subject,
      period: IP.period,
      length: IP.length,
      reasonCode: IP.reasonCode,
      reasonReference: IP.reasonReference,
      diagnosis: IP.diagnosis,
      account: IP.account,
      hospitalization: IP.hospitalization,
      location: IP.location,
      partOf: IP.partOf
    }
Logic Definition Library Name: NHSNAcuteCareHospitalMonthlyInitialPopulation1
define "SDE Observation Simple":
  [SimpleObservation] Obs
    where ( exists ( Obs.category Category
          where Category ~ "social-history"
      )
        or exists ( Obs.category Category
            where Category ~ "imaging"
        )
        or exists ( Obs.category Category
            where Category ~ "procedure"
        )
    )
      and exists ( "Initial Population" IP
          where "Normalize Interval"(Obs.effective) overlaps IP.period
      )
    return {
      id: Obs.id,
      meta: Obs.meta,
      extension: Obs.extension,
      partOf: Obs.partOf,
      status: Obs.status,
      category: Obs.category,
      code: Obs.code,
      subject: Obs.subject,
      encounter: Obs.encounter,
      effective: Obs.effective,
      issued: Obs.issued,
      value: Obs.value,
      dataAbsentReason: Obs.dataAbsentReason,
      interpretation: Obs.interpretation,
      bodySite: Obs.bodySite,
      method: Obs.method,
      specimen: Obs.specimen,
      referenceRange: Obs.referenceRange,
      hasMember: Obs.hasMember,
      derivedFrom: Obs.derivedFrom,
      component: Obs.component
    }
Logic Definition Library Name: NHSNAcuteCareHospitalMonthlyInitialPopulation1
// Observation SDEs


define "SDE Observation Lab Category":
  [LaboratoryResultObservation] Obs
    where exists ( "Initial Population" IP
        where "Normalize Interval"(Obs.effective) overlaps IP.period
    )
    return {
      id: Obs.id,
      meta: Obs.meta,
      extension: Obs.extension,
      partOf: Obs.partOf,
      status: Obs.status,
      category: Obs.category,
      code: Obs.code,
      subject: Obs.subject,
      encounter: Obs.encounter,
      effective: Obs.effective,
      issued: Obs.issued,
      value: Obs.value,
      dataAbsentReason: Obs.dataAbsentReason,
      interpretation: Obs.interpretation,
      bodySite: Obs.bodySite,
      method: Obs.method,
      specimen: Obs.specimen,
      referenceRange: Obs.referenceRange,
      hasMember: Obs.hasMember,
      derivedFrom: Obs.derivedFrom,
      component: Obs.component
    }
Logic Definition Library Name: NHSNAcuteCareHospitalMonthlyInitialPopulation1
// ServiceNotRequested SDE - negation requests (doNotPerform is true)


define "SDE Service Not Requested":
  [ServiceNotRequested] ServiceNotReqs
    where exists ( "Initial Population" IP
        where ServiceNotReqs.authoredOn during IP.period
    )
    return {
      id: ServiceNotReqs.id,
      meta: ServiceNotReqs.meta,
      instantiatesCanonical: ServiceNotReqs.instantiatesCanonical,
      instantiatesUri: ServiceNotReqs.instantiatesUri,
      basedOn: ServiceNotReqs.basedOn,
      replaces: ServiceNotReqs.replaces,
      requisition: ServiceNotReqs.requisition,
      status: ServiceNotReqs.status,
      intent: ServiceNotReqs.intent,
      category: ServiceNotReqs.category,
      priority: ServiceNotReqs.priority,
      doNotPerform: ServiceNotReqs.doNotPerform,
      code: ServiceNotReqs.code,
      orderDetail: ServiceNotReqs.orderDetail,
      quantity: ServiceNotReqs.quantity,
      subject: ServiceNotReqs.subject,
      encounter: ServiceNotReqs.encounter,
      occurrence: ServiceNotReqs.occurrence,
      asNeeded: ServiceNotReqs.asNeeded,
      authoredOn: ServiceNotReqs.authoredOn,
      requester: ServiceNotReqs.requester,
      performerType: ServiceNotReqs.performerType,
      performer: ServiceNotReqs.performer,
      locationCode: ServiceNotReqs.locationCode,
      reasonCode: ServiceNotReqs.reasonCode,
      reasonReference: ServiceNotReqs.reasonReference,
      insurance: ServiceNotReqs.insurance,
      bodySite: ServiceNotReqs.bodySite,
      note: ServiceNotReqs.note,
      patientInstruction: ServiceNotReqs.patientInstruction
    }
Logic Definition Library Name: NHSNAcuteCareHospitalMonthlyInitialPopulation1
define "SDE Medication Administration Base":
  [MedicationAdministration] MedAdministrations
    where exists ( "Initial Population" IP
        where "Normalize Interval"(MedAdministrations.effective) overlaps IP.period
    )
    return {
      id: MedAdministrations.id,
      meta: MedAdministrations.meta,
      instantiates: MedAdministrations.instantiates,
      partOf: MedAdministrations.partOf,
      status: MedAdministrations.status,
      statusReason: MedAdministrations.statusReason,
      category: MedAdministrations.category,
      medication: MedAdministrations.medication,
      subject: MedAdministrations.subject,
      context: MedAdministrations.context,
      supportingInformation: MedAdministrations.supportingInformation,
      effective: MedAdministrations.effective,
      performer: MedAdministrations.performer,
      reasonCode: MedAdministrations.reasonCode,
      reasonReference: MedAdministrations.reasonReference,
      request: MedAdministrations.request,
      device: MedAdministrations.device,
      note: MedAdministrations.note,
      dosage: MedAdministrations.dosage
    }
Logic Definition Library Name: NHSNAcuteCareHospitalMonthlyInitialPopulation1
define "SDE Medication Administration Not Done":
  [MedicationAdministrationNotDone] MedAdministrations
    where exists ( "Initial Population" IP
        where "Normalize Interval"(MedAdministrations.effective) overlaps IP.period
    )
    return {
      id: MedAdministrations.id,
      meta: MedAdministrations.meta,
      instantiates: MedAdministrations.instantiates,
      partOf: MedAdministrations.partOf,
      status: MedAdministrations.status,
      statusReason: MedAdministrations.statusReason,
      category: MedAdministrations.category,
      medication: MedAdministrations.medication,
      subject: MedAdministrations.subject,
      context: MedAdministrations.context,
      supportingInformation: MedAdministrations.supportingInformation,
      effective: MedAdministrations.effective,
      performer: MedAdministrations.performer,
      reasonCode: MedAdministrations.reasonCode,
      reasonReference: MedAdministrations.reasonReference,
      request: MedAdministrations.request,
      device: MedAdministrations.device,
      note: MedAdministrations.note,
      dosage: MedAdministrations.dosage
    }
Logic Definition Library Name: NHSNAcuteCareHospitalMonthlyInitialPopulation1
// Medication SDEs


define "SDE Medication Administration":
  "SDE Medication Administration Base"
    union "SDE Medication Administration Not Done"
Logic Definition Library Name: NHSNAcuteCareHospitalMonthlyInitialPopulation1
define "SDE Medication Administration Base":
  [MedicationAdministration] MedAdministrations
    where exists ( "Initial Population" IP
        where "Normalize Interval"(MedAdministrations.effective) overlaps IP.period
    )
    return {
      id: MedAdministrations.id,
      meta: MedAdministrations.meta,
      instantiates: MedAdministrations.instantiates,
      partOf: MedAdministrations.partOf,
      status: MedAdministrations.status,
      statusReason: MedAdministrations.statusReason,
      category: MedAdministrations.category,
      medication: MedAdministrations.medication,
      subject: MedAdministrations.subject,
      context: MedAdministrations.context,
      supportingInformation: MedAdministrations.supportingInformation,
      effective: MedAdministrations.effective,
      performer: MedAdministrations.performer,
      reasonCode: MedAdministrations.reasonCode,
      reasonReference: MedAdministrations.reasonReference,
      request: MedAdministrations.request,
      device: MedAdministrations.device,
      note: MedAdministrations.note,
      dosage: MedAdministrations.dosage
    }
Logic Definition Library Name: NHSNAcuteCareHospitalMonthlyInitialPopulation1
// DiagnosticReport SDEs


define "SDE DiagnosticReport Lab":
  [DiagnosticReportLab] dr
    where exists ( "Initial Population" IP
        where "Normalize Interval"(dr.effective) overlaps IP.period
    )
Logic Definition Library Name: NHSNAcuteCareHospitalMonthlyInitialPopulation1
// ----------------------------------------------------------------------
// Core retrieves
// ----------------------------------------------------------------------

// Locations from IP encounters





define "Get Locations from IP Encounters in Measurement Period":
  flatten ( "Initial Population" IP
      let locationElements: IP.location
      return locationElements LE
        let locationReference: LE.location
        return locationReference.getLocation ( )
  )
Logic Definition Library Name: NHSNAcuteCareHospitalMonthlyInitialPopulation1
// Location SDE


define "SDE Location":
  "Get Locations from IP Encounters in Measurement Period" Locations
    where exists ( "Initial Population" )
      and Locations is not null
    return {
      id: Locations.id,
      meta: Locations.meta,
      extension: Locations.extension,
      status: Locations.status,
      operationalStatus: Locations.operationalStatus,
      name: Locations.name,
      alias: Locations.alias,
      description: Locations.description,
      mode: Locations.mode,
      type: Locations.type,
      telecom: Locations.telecom,
      address: Locations.address,
      physicalType: Locations.physicalType,
      position: Locations.position,
      managingOrganization: Locations.managingOrganization,
      partOf: Locations.partOf,
      hoursOfOperation: Locations.hoursOfOperation,
      availabilityExceptions: Locations.availabilityExceptions,
      endpoint: Locations.endpoint
    }
Logic Definition Library Name: NHSNAcuteCareHospitalMonthlyInitialPopulation1
define "SDE DiagnosticReport Note":
  [DiagnosticReportNote] dr
    where ( exists ( dr.category Category
          where Category ~ "Radiology"
      )
        or exists ( dr.category Category
            where Category ~ "Pathology"
        )
        or exists ( dr.category Category
            where Category ~ "Cardiology"
        )
    )
      and exists ( "Initial Population" IP
          where "Normalize Interval"(dr.effective) overlaps IP.period
      )
    return {
      id: dr.id,
      meta: dr.meta,
      extension: dr.extension,
      basedOn: dr.basedOn,
      status: dr.status,
      category: dr.category,
      code: dr.code,
      subject: dr.subject,
      encounter: dr.encounter,
      effective: dr.effective,
      issued: dr.issued,
      specimen: dr.specimen,
      result: dr.result,
      conclusion: dr.conclusion,
      conclusionCode: dr.conclusionCode
    }
Logic Definition Library Name: NHSNAcuteCareHospitalMonthlyInitialPopulation1
// SDE Medication Request - regular requests (doNotPerform is false or absent)


define "SDE Medication Request Base":
  [MedicationRequest] MedRequests
    where exists ( "Initial Population" IP
        where MedRequests.authoredOn during IP.period
    )
    return {
      id: MedRequests.id,
      meta: MedRequests.meta,
      status: MedRequests.status,
      statusReason: MedRequests.statusReason,
      intent: MedRequests.intent,
      category: MedRequests.category,
      priority: MedRequests.priority,
      //doNotPerform: MedRequests.doNotPerform,
      
      reported: MedRequests.reported,
      medication: MedRequests.medication,
      subject: MedRequests.subject,
      encounter: MedRequests.encounter,
      authoredOn: MedRequests.authoredOn,
      requester: MedRequests.requester,
      recorder: MedRequests.recorder,
      reasonCode: MedRequests.reasonCode,
      reasonReference: MedRequests.reasonReference,
      instantiatesCanonical: MedRequests.instantiatesCanonical,
      instantiatesUri: MedRequests.instantiatesUri,
      courseOfTherapyType: MedRequests.courseOfTherapyType,
      dosageInstruction: MedRequests.dosageInstruction
    }
Logic Definition Library Name: NHSNAcuteCareHospitalMonthlyInitialPopulation1
// ----------------------------------------------------------------------
// SDEs
// ----------------------------------------------------------------------




define "SDE Condition Problems HealthConcerns":
  [ConditionProblemsHealthConcerns] Diagnosis
    where exists ( "Initial Population" IP
        where Diagnosis.prevalenceInterval ( ) overlaps day of IP.period
    )
    return {
      id: Diagnosis.id,
      meta: Diagnosis.meta,
      status: Diagnosis.clinicalStatus,
      verificationStatus: Diagnosis.verificationStatus,
      category: Diagnosis.category,
      severity: Diagnosis.severity,
      code: Diagnosis.code,
      bodySite: Diagnosis.bodySite,
      subject: Diagnosis.subject,
      encounterReferenceId: Diagnosis.encounter.reference.getId ( ),
      onset: Diagnosis.onset,
      stage: Diagnosis.stage,
      evidence: Diagnosis.evidence,
      note: Diagnosis.note
    }
Logic Definition Library Name: NHSNAcuteCareHospitalMonthlyInitialPopulation1
define "SDE Condition Diagnosis":
  [ConditionEncounterDiagnosis] Diagnosis
    where exists ( "Initial Population" IP
        where Diagnosis.prevalenceInterval ( ) overlaps day of IP.period
    )
    return {
      id: Diagnosis.id,
      meta: Diagnosis.meta,
      status: Diagnosis.clinicalStatus,
      verificationStatus: Diagnosis.verificationStatus,
      category: Diagnosis.category,
      severity: Diagnosis.severity,
      code: Diagnosis.code,
      bodySite: Diagnosis.bodySite,
      subject: Diagnosis.subject,
      encounterReferenceId: Diagnosis.encounter.reference.getId ( ),
      onset: Diagnosis.onset,
      stage: Diagnosis.stage,
      evidence: Diagnosis.evidence,
      note: Diagnosis.note
    }
Logic Definition Library Name: NHSNAcuteCareHospitalMonthlyInitialPopulation1
// ServiceRequest SDE - regular requests (doNotPerform is false or absent)


define "SDE Service Request Base":
  [ServiceRequest] ServiceRequests
    where exists ( "Initial Population" IP
        where ServiceRequests.authoredOn during IP.period
    )
    return {
      id: ServiceRequests.id,
      meta: ServiceRequests.meta,
      instantiatesCanonical: ServiceRequests.instantiatesCanonical,
      instantiatesUri: ServiceRequests.instantiatesUri,
      basedOn: ServiceRequests.basedOn,
      replaces: ServiceRequests.replaces,
      requisition: ServiceRequests.requisition,
      status: ServiceRequests.status,
      intent: ServiceRequests.intent,
      category: ServiceRequests.category,
      priority: ServiceRequests.priority,
      //doNotPerform: ServiceRequests.doNotPerform,
      
      code: ServiceRequests.code,
      orderDetail: ServiceRequests.orderDetail,
      quantity: ServiceRequests.quantity,
      subject: ServiceRequests.subject,
      encounter: ServiceRequests.encounter,
      occurrence: ServiceRequests.occurrence,
      asNeeded: ServiceRequests.asNeeded,
      authoredOn: ServiceRequests.authoredOn,
      requester: ServiceRequests.requester,
      performerType: ServiceRequests.performerType,
      performer: ServiceRequests.performer,
      locationCode: ServiceRequests.locationCode,
      reasonCode: ServiceRequests.reasonCode,
      reasonReference: ServiceRequests.reasonReference,
      insurance: ServiceRequests.insurance,
      bodySite: ServiceRequests.bodySite,
      note: ServiceRequests.note,
      patientInstruction: ServiceRequests.patientInstruction
    }
Logic Definition Library Name: NHSNAcuteCareHospitalMonthlyInitialPopulation1
// ----------------------------------------------------------------------
// Helper functions
// ----------------------------------------------------------------------




define function "CheckIP"(encounter Encounter):
  exists ( "Initial Population" IP
      where encounter.id = IP.id
  )
Logic Definition Library Name: NHSNAcuteCareHospitalMonthlyInitialPopulation1
// Former NHSNHelpers functions, adapted for QI Core


define function "Normalize Interval"(choice Choice<DateTime, Interval<DateTime>>):
  case
    when choice is DateTime then Interval[choice as DateTime, choice as DateTime]
    when choice is Interval<DateTime>then choice as Interval<DateTime>
    else null as Interval<DateTime>end
Logic Definition Library Name: NHSNAcuteCareHospitalMonthlyInitialPopulation1
define function "GetMedication"(reference Reference):
  singleton from ( [Medication] Medication
      where reference.references ( Medication )
  )
Logic Definition Library Name: QICoreCommon
/*
@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 Reference, resource Resource):
  resource.id = Last(Split(reference.reference, '/'))
Logic Definition Library Name: QICoreCommon
/*
@description: Normalizes a value that is a choice of timing-valued types to an equivalent interval
@comment: Normalizes a choice type of DateTime, Quanitty, Interval<DateTime>, or Interval<Quantity> 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 QICore, allowing this function to be used across any resource.
The input can be provided as a DateTime, Quantity, Interval<DateTime> or Interval<Quantity>.
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 Quantity, the quantity is expected to be a calendar-duration interpreted as an Age,
and the result is a DateTime Interval beginning on the Date the patient turned that age and ending immediately before one year later.
If the input is a DateTime Interval, the result is the input.
If the input is a Quantity Interval, the quantities are expected to be calendar-durations interpreted as an Age, and the result
is a DateTime Interval beginning on the date the patient turned the age given as the start of the quantity interval, and ending
immediately before one year later than the date the patient turned the age given as the end of the quantity interval.
If the input is a Timing, an error will be thrown indicating that Timing calculations are not implemented. Any other input will reslt in a null DateTime Interval
*/
define fluent function toInterval(choice Choice<DateTime, Quantity, Interval<DateTime>, Interval<Quantity>, Timing>):
  case
	  when choice is DateTime then
    	Interval[choice as DateTime, choice as DateTime]
		when choice is Interval<DateTime> then
  		choice as Interval<DateTime>
		when choice is Quantity then
		  Interval[Patient.birthDate + (choice as Quantity),
			  Patient.birthDate + (choice as Quantity) + 1 year)
		when choice is Interval<Quantity> then
		  Interval[Patient.birthDate + (choice.low as Quantity),
			  Patient.birthDate + (choice.high as Quantity) + 1 year)
		when choice is Timing then
      Message(null, true, 'NOT_IMPLEMENTED', 'Error', 'Calculation of an interval from a Timing value is not supported') as Interval<DateTime>
		else
			null as Interval<DateTime>
	end
Logic Definition Library Name: QICoreCommon
/*
@description: Returns an interval representing the normalized prevalence period of a given Condition.
@comment: Uses the ToInterval and ToAbatementInterval functions to determine the widest potential interval from
onset to abatement as specified in the given Condition. If the condition is active, or has an abatement date the resulting 
interval will have a closed ending boundary. Otherwise, the resulting interval will have an open ending boundary.
*/
define fluent function prevalenceInterval(condition Choice<"ConditionEncounterDiagnosis", "ConditionProblemsHealthConcerns">):
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: QICoreCommon
/*
@description: Returns an interval representing the normalized abatement of a given Condition.
@comment: If the abatement element of the Condition is represented as a DateTime, the result
is an interval beginning and ending on that DateTime.
If the abatement is represented as a Quantity, the quantity is expected to be a calendar-duration and is interpreted as the age of the patient. The
result is an interval from the date the patient turned that age to immediately before one year later.
If the abatement is represented as a Quantity Interval, the quantities are expected to be calendar-durations and are interpreted as an age range during
which the abatement occurred. The result is an interval from the date the patient turned the starting age of the quantity interval, and ending immediately
before one year later than the date the patient turned the ending age of the quantity interval.
*/
define fluent function abatementInterval(condition Choice<"ConditionEncounterDiagnosis", "ConditionProblemsHealthConcerns">):
	if condition.abatement is DateTime then
	  Interval[condition.abatement as DateTime, condition.abatement as DateTime]
	else if condition.abatement is Quantity then
		Interval[Patient.birthDate + (condition.abatement as Quantity),
			Patient.birthDate + (condition.abatement as Quantity) + 1 year)
	else if condition.abatement is Interval<Quantity> then
	  Interval[Patient.birthDate + (condition.abatement.low as Quantity),
		  Patient.birthDate + (condition.abatement.high as Quantity) + 1 year)
	else if condition.abatement is Interval<DateTime> then
	  Interval[condition.abatement.low, condition.abatement.high)
	else null as Interval<DateTime>
Logic Definition Library Name: QICoreCommon
/*
@description: Returns the tail of the given uri (i.e. everything after the last slash in the URI).
@comment: This function can be used to determine the logical id of a given resource. It can be used in
a single-server environment to trace references. However, this function does not attempt to resolve
or distinguish the base of the given url, and so cannot be used safely in multi-server environments.
*/
define fluent function getId(uri String):
  Last(Split(uri, '/'))
Terminology
Code System Description: Code system ActCode
Resource: ActCode
Canonical URL: http://terminology.hl7.org/CodeSystem/v3-ActCode
Code System Description: Code system ActCode
Resource: ActCode
Canonical URL: http://terminology.hl7.org/CodeSystem/v3-ActCode
Code System Description: Code system LOINC
Resource: Logical Observation Identifiers, Names and Codes (LOINC)
Canonical URL: http://loinc.org
Code System Description: Code system Observation Category
Resource: Observation Category Codes
Canonical URL: http://terminology.hl7.org/CodeSystem/observation-category
Code System Description: Code system ConditionClinicalStatusCodes
Resource: Condition Clinical Status Codes
Canonical URL: http://terminology.hl7.org/CodeSystem/condition-clinical
Value Set Description: Value set Encounter Inpatient
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.666.5.307
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.666.5.307
Value Set Description: Value set Emergency Department Visit
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.292
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.292
Value Set Description: Value set Observation Services
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.143
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.143
Value Set Description: Value set Inpatient, Emergency, and Observation Locations
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1046.265
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1046.265
Direct Reference Code Display: inpatient encounter
Code: IMP
System: http://terminology.hl7.org/CodeSystem/v3-ActCode
Direct Reference Code Display: inpatient acute
Code: ACUTE
System: http://terminology.hl7.org/CodeSystem/v3-ActCode
Direct Reference Code Display: inpatient non-acute
Code: NONAC
System: http://terminology.hl7.org/CodeSystem/v3-ActCode
Direct Reference Code Display: short stay
Code: SS
System: http://terminology.hl7.org/CodeSystem/v3-ActCode
Direct Reference Code Display: emergency
Code: EMER
System: http://terminology.hl7.org/CodeSystem/v3-ActCode
Direct Reference Code Display: observation encounter
Code: OBSENC
System: http://terminology.hl7.org/CodeSystem/v3-ActCode
Direct Reference Code Display: Radiology
Code: LP29684-5
System: http://loinc.org
Direct Reference Code Display: Pathology
Code: LP7839-6
System: http://loinc.org
Direct Reference Code Display: Cardiology
Code: LP29708-2
System: http://loinc.org
Direct Reference Code Display: Social History
Code: social-history
System: http://terminology.hl7.org/CodeSystem/observation-category
Direct Reference Code Display: Imaging
Code: imaging
System: http://terminology.hl7.org/CodeSystem/observation-category
Direct Reference Code Display: Procedure
Code: procedure
System: http://terminology.hl7.org/CodeSystem/observation-category
Direct Reference Code Display: Active
Code: active
System: http://terminology.hl7.org/CodeSystem/condition-clinical
Direct Reference Code Display: Recurrence
Code: recurrence
System: http://terminology.hl7.org/CodeSystem/condition-clinical
Direct Reference Code Display: Relapse
Code: relapse
System: http://terminology.hl7.org/CodeSystem/condition-clinical
Dependencies
Dependency None
Data Requirements
Data Requirement Type: Encounter
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter
Data Requirement Type: Resource
Profile(s): Resource
Must Support Elements: id
Data Requirement Type: Resource
Profile(s): Resource
Must Support Elements: id.value
Data Requirement Type: Location
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-location
Data Requirement Type: Coverage
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-coverage
Must Support Elements: period, id, id.value, meta, status, status.value, type, policyHolder, subscriber, subscriberId, subscriberId.value, beneficiary, dependent, dependent.value, relationship, payor, class, order, order.value, network, network.value, subrogation, subrogation.value, contract
Data Requirement Type: Encounter
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter
Must Support Elements: location, period, status, status.value
Data Requirement Type: Encounter
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter
Must Support Elements: id
Data Requirement Type: Encounter
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter
Must Support Elements: id.value
Data Requirement Type: Encounter
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter
Must Support Elements: period, id, id.value, meta, identifier, status, status.value, statusHistory, class, classHistory, type, serviceType, priority, subject, length, reasonCode, reasonReference, diagnosis, account, hospitalization, location, partOf
Data Requirement Type: Procedure
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-procedure
Must Support Elements: performed, id, id.value, meta, extension, basedOn, partOf, status, status.value, category, code, subject, encounter, location, reasonCode, reasonReference, bodySite
Data Requirement Type: Device
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-device
Must Support Elements: id, id.value, meta, extension, status, status.value, expirationDate, expirationDate.value, lotNumber, lotNumber.value, serialNumber, serialNumber.value, modelNumber, modelNumber.value, partNumber, partNumber.value, type, patient, parent
Data Requirement Type: Observation
Profile(s): http://hl7.org/fhir/us/core/StructureDefinition/us-core-vital-signs
Must Support Elements: effective, id, id.value, meta, extension, partOf, status, status.value, category, code, subject, encounter, issued, issued.value, value, dataAbsentReason, interpretation, bodySite, method, specimen, referenceRange, hasMember, derivedFrom, component
Data Requirement Type: Specimen
Profile(s): http://hl7.org/fhir/us/core/StructureDefinition/us-core-specimen
Must Support Elements: collection, collection.collected, id, id.value, type
Data Requirement Type: Observation
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-observation-screening-assessment
Must Support Elements: effective, id, id.value, meta, extension, partOf, status, status.value, category, code, subject, encounter, issued, issued.value, value, dataAbsentReason, interpretation, bodySite, method, specimen, referenceRange, hasMember, derivedFrom, component
Data Requirement Type: Medication
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-medication
Data Requirement Type: Patient
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-patient
Data Requirement Type: MedicationRequest
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-medicationrequest
Data Requirement Type: MedicationAdministration
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-medicationadministration
Data Requirement Type: MedicationRequest
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-medicationnotrequested
Must Support Elements: authoredOn, authoredOn.value, id, id.value, meta, status, status.value, statusReason, intent, intent.value, category, priority, priority.value, doNotPerform, doNotPerform.value, reported, medication, medication.extension, subject, encounter, requester, recorder, reasonCode, reasonReference, instantiatesCanonical, instantiatesUri, courseOfTherapyType, dosageInstruction
Data Requirement Type: Observation
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-simple-observation
Must Support Elements: category, effective, id, id.value, meta, extension, partOf, status, status.value, code, subject, encounter, issued, issued.value, value, dataAbsentReason, interpretation, bodySite, method, specimen, referenceRange, hasMember, derivedFrom, component
Data Requirement Type: Observation
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-observation-lab
Must Support Elements: effective, id, id.value, meta, extension, partOf, status, status.value, category, code, subject, encounter, issued, issued.value, value, dataAbsentReason, interpretation, bodySite, method, specimen, referenceRange, hasMember, derivedFrom, component
Data Requirement Type: ServiceRequest
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-servicenotrequested
Must Support Elements: authoredOn, authoredOn.value, id, id.value, meta, instantiatesCanonical, instantiatesUri, basedOn, replaces, requisition, status, status.value, intent, intent.value, category, priority, priority.value, doNotPerform, doNotPerform.value, code, code.extension, orderDetail, quantity, subject, encounter, occurrence, asNeeded, requester, performerType, performer, locationCode, reasonCode, reasonReference, insurance, bodySite, note, patientInstruction, patientInstruction.value
Data Requirement Type: MedicationAdministration
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-medicationadministrationnotdone
Must Support Elements: effective, id, id.value, meta, instantiates, partOf, status, status.value, statusReason, category, medication, medication.extension, subject, context, supportingInformation, performer, reasonCode, reasonReference, request, device, note, dosage
Data Requirement Type: MedicationAdministration
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-medicationadministration
Must Support Elements: effective, id, id.value, meta, instantiates, partOf, status, status.value, statusReason, category, medication, subject, context, supportingInformation, performer, reasonCode, reasonReference, request, device, note, dosage
Data Requirement Type: DiagnosticReport
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-diagnosticreport-lab
Must Support Elements: effective
Data Requirement Type: DiagnosticReport
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-diagnosticreport-note
Must Support Elements: category, effective, id, id.value, meta, extension, basedOn, status, status.value, code, subject, encounter, issued, issued.value, specimen, result, conclusion, conclusion.value, conclusionCode
Data Requirement Type: MedicationRequest
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-medicationrequest
Must Support Elements: authoredOn, authoredOn.value, id, id.value, meta, status, status.value, statusReason, intent, intent.value, category, priority, priority.value, reported, medication, subject, encounter, requester, recorder, reasonCode, reasonReference, instantiatesCanonical, instantiatesUri, courseOfTherapyType, dosageInstruction
Data Requirement Type: Patient
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-patient
Must Support Elements: birthDate
Data Requirement Type: Patient
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-patient
Must Support Elements: birthDate.value
Data Requirement Type: Condition
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition-problems-health-concerns
Must Support Elements: id, id.value, meta, clinicalStatus, verificationStatus, category, severity, code, bodySite, subject, encounter, encounter.reference, encounter.reference.value, onset, stage, evidence, note
Data Requirement Type: Condition
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition-encounter-diagnosis
Must Support Elements: id, id.value, meta, clinicalStatus, verificationStatus, category, severity, code, bodySite, subject, encounter, encounter.reference, encounter.reference.value, onset, stage, evidence, note
Data Requirement Type: ServiceRequest
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-servicerequest
Must Support Elements: authoredOn, authoredOn.value, id, id.value, meta, instantiatesCanonical, instantiatesUri, basedOn, replaces, requisition, status, status.value, intent, intent.value, category, priority, priority.value, code, orderDetail, quantity, subject, encounter, occurrence, asNeeded, requester, performerType, performer, locationCode, reasonCode, reasonReference, insurance, bodySite, note, patientInstruction, patientInstruction.value
Generated using version 0.5.0 of the sample-content-ig Liquid templates