Id: MATGlobalCommonFunctionsFHIR4 Version: 0.1.0 Url: MATGlobalCommonFunctionsFHIR4 Type: system: http://terminology.hl7.org/CodeSystem/library-type code: logic-library Date: 2021-01-28 23:14:33+0000 Publisher: Clinical Quality Framework Description: MATGlobalCommonFunctionsFHIR4 Jurisdiction: 001 Related Artifacts: Dependencies http://fhir.org/guides/cqf/aphl/chronic-ds/Library/FHIRHelpers|4.1.000 Condition Clinical Status Codes AllergyIntolerance Clinical Status Codes AllergyIntolerance Verification Status Diagnosis Role LOINC MedicationRequest Category Codes ConditionVerificationStatus SNOMED CT (all versions) RoleCode Emergency Department Visit Encounter Inpatient Observation Services Parameters: Name Type Min Max In/Out Measurement Period Period 0 1 In Patient Patient 0 1 Out Inpatient Encounter Encounter 0 * Out Data Requirements: Type Profile MS Code Filter Patient http://hl7.org/fhir/StructureDefinition/Patient Encounter http://hl7.org/fhir/StructureDefinition/Encounter ;;;;;;; code filter: path: type value set: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.666.5.307 Encounter http://hl7.org/fhir/StructureDefinition/Encounter ;;;;;; code filter: path: type value set: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.143 Encounter http://hl7.org/fhir/StructureDefinition/Encounter ;;;;;;; code filter: path: type value set: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.292 Condition http://hl7.org/fhir/StructureDefinition/Condition ; Location http://hl7.org/fhir/StructureDefinition/Location ; Medication http://hl7.org/fhir/StructureDefinition/Medication ; Content: text/cql /*#xD; @update: BTR 2020-03-31 ->#xD; Incremented version to 5.0.000#xD; Updated FHIR version to 4.0.1#xD; Changed timezone keyword to timezoneoffset for use with CQL 1.4#xD; Removed Normalize Onset in favor of more general Normalize Interval#xD; #xD; @update: BTR 2021-05-13 ->#xD; //Added ActiveCondition Codes and Inactive Condition Codes value sets#xD; Updated ConditionVerificationStatusCodes and RoleCode URIs#xD; Added function documentation throughout#xD; Fixed EDVisit not using Last#xD; Updated prevalence period to use an inclusive boundary if the condition is active#xD; Added HasStart, HasEnd, Earliest, and Latest functions#xD; Removed ToDate and Age calculation functions#xD; */#xD; library MATGlobalCommonFunctionsFHIR4 version '6.0.000'#xD; #xD; using FHIR version '4.0.1'#xD; #xD; include FHIRHelpers version '4.1.000' called FHIRHelpers#xD; #xD; codesystem "ConditionClinicalStatusCodes": 'http://terminology.hl7.org/CodeSystem/condition-clinical'#xD; codesystem "AllergyIntoleranceClinicalStatusCodes": 'http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical'#xD; codesystem "AllergyIntoleranceVerificationStatusCodes": 'http://terminology.hl7.org/CodeSystem/allergyintolerance-verification'#xD; codesystem "Diagnosis Role": 'http://terminology.hl7.org/CodeSystem/diagnosis-role'#xD; codesystem "LOINC": 'http://loinc.org'#xD; codesystem "MedicationRequestCategory": 'http://terminology.hl7.org/CodeSystem/medicationrequest-category'#xD; codesystem "ConditionVerificationStatusCodes": 'http://terminology.hl7.org/CodeSystem/condition-ver-status'#xD; codesystem "SNOMEDCT": 'http://snomed.info/sct'#xD; codesystem "RoleCode": 'http://terminology.hl7.org/CodeSystem/v3-RoleCode'#xD; #xD; valueset "Emergency Department Visit": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.292'#xD; valueset "Encounter Inpatient": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.666.5.307'#xD; valueset "Observation Services": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.143'#xD; //valueset "Active Condition Codes": 'http://example.org/fhir/ValueSet/active-condition-codes'#xD; //valueset "Inactive Condition Codes": 'http://example.org/fhir/ValueSet/inactive-condition-codes'#xD; #xD; code "active": 'active' from "ConditionClinicalStatusCodes" display 'active'#xD; code "allergy-active": 'active' from "AllergyIntoleranceClinicalStatusCodes" display 'allergy-active'#xD; code "allergy-confirmed": 'confirmed' from "AllergyIntoleranceVerificationStatusCodes" display 'allergy-confirmed'#xD; code "allergy-inactive": 'inactive' from "AllergyIntoleranceClinicalStatusCodes" display 'allergy-inactive'#xD; code "allergy-refuted": 'refuted' from "AllergyIntoleranceVerificationStatusCodes" display 'allergy-refuted'#xD; code "allergy-resolved": 'resolved' from "AllergyIntoleranceClinicalStatusCodes" display 'allergy-resolved'#xD; code "allergy-unconfirmed": 'unconfirmed' from "AllergyIntoleranceVerificationStatusCodes" display 'allergy-unconfirmed'#xD; code "Billing": 'billing' from "Diagnosis Role" display 'Billing'#xD; code "Birthdate": '21112-8' from "LOINC" display 'Birth date'#xD; code "Community": 'community' from "MedicationRequestCategory" display 'Community'#xD; code "confirmed": 'confirmed' from "ConditionVerificationStatusCodes" display 'confirmed'#xD; code "Dead": '419099009' from "SNOMEDCT" display 'Dead'#xD; code "differential": 'differential' from "ConditionVerificationStatusCodes" display 'differential'#xD; code "Discharge": 'discharge' from "MedicationRequestCategory" display 'Discharge'#xD; code "entered-in-error": 'entered-in-error' from "ConditionVerificationStatusCodes" display 'entered-in-error'#xD; code "ER": 'ER' from "RoleCode" display 'Emergency room'#xD; code "ICU": 'ICU' from "RoleCode" display 'Intensive care unit'#xD; code "inactive": 'inactive' from "ConditionClinicalStatusCodes" display 'inactive'#xD; code "provisional": 'provisional' from "ConditionVerificationStatusCodes" display 'provisional'#xD; code "recurrence": 'recurrence' from "ConditionClinicalStatusCodes" display 'recurrence'#xD; code "refuted": 'refuted' from "ConditionVerificationStatusCodes" display 'refuted'#xD; code "relapse": 'relapse' from "ConditionClinicalStatusCodes" display 'relapse'#xD; code "remission": 'remission' from "ConditionClinicalStatusCodes" display 'remission'#xD; code "resolved": 'resolved' from "ConditionClinicalStatusCodes" display 'resolved'#xD; code "unconfirmed": 'unconfirmed' from "ConditionVerificationStatusCodes" display 'unconfirmed'#xD; #xD; parameter "Measurement Period" Interval<DateTime>#xD; default Interval[@2019-01-01T00:00:00.0, @2020-01-01T00:00:00.0)#xD; #xD; context Patient#xD; #xD; define "Inpatient Encounter":#xD; [Encounter: "Encounter Inpatient"] EncounterInpatient#xD; where EncounterInpatient.status = 'finished'#xD; and "LengthInDays"(EncounterInpatient.period) <= 120#xD; and EncounterInpatient.period ends during "Measurement Period"#xD; #xD; /*Calculates the difference in calendar days between the start and end of the given interval.*/#xD; define function "LengthInDays"(Value Interval<DateTime> ):#xD; difference in days between start of Value and end of Value#xD; #xD; /*Returns the most recent emergency department visit, if any, that occurs 1 hour or less prior to the given encounter.*/#xD; define function "ED Visit"(TheEncounter FHIR.Encounter ):#xD; Last(#xD; [Encounter: "Emergency Department Visit"] EDVisit#xD; where EDVisit.status = 'finished'#xD; and EDVisit.period ends 1 hour or less on or before start of FHIRHelpers.ToInterval(TheEncounter.period)#xD; sort by end of period#xD; )#xD; #xD; /*Hospitalization returns the total interval for admission to discharge for the given encounter, or for the admission of any immediately prior emergency department visit to the discharge of the given encounter.*/#xD; define function "Hospitalization"(TheEncounter FHIR.Encounter ):#xD; ( "ED Visit"(TheEncounter) ) X#xD; return#xD; if X is null then TheEncounter.period#xD; else Interval[start of FHIRHelpers.ToInterval(X.period), end of FHIRHelpers.ToInterval(TheEncounter.period)]#xD; #xD; /*Returns list of all locations within an encounter, including locations for immediately prior ED visit.*/#xD; define function "Hospitalization Locations"(TheEncounter FHIR.Encounter ):#xD; ( "ED Visit"(TheEncounter) ) EDEncounter#xD; return#xD; if EDEncounter is null then TheEncounter.location#xD; else flatten { EDEncounter.location, TheEncounter.location }#xD; #xD; /*Returns the length of stay in days (i.e. the number of days between admission and discharge) for the given encounter, or from the admission of any immediately prior emergency department visit to the discharge of the encounter*/#xD; define function "Hospitalization Length of Stay"(TheEncounter FHIR.Encounter ):#xD; LengthInDays("Hospitalization"(TheEncounter))#xD; #xD; /*Returns admission time for an encounter or for immediately prior emergency department visit. */#xD; define function "Hospital Admission Time"(TheEncounter FHIR.Encounter ):#xD; start of "Hospitalization"(TheEncounter)#xD; #xD; /*Hospital Discharge Time returns the discharge time for an encounter*/#xD; define function "Hospital Discharge Time"(TheEncounter FHIR.Encounter ):#xD; end of FHIRHelpers.ToInterval(TheEncounter.period)#xD; #xD; /*Returns earliest arrival time for an encounter including any prior ED visit. */#xD; define function "Hospital Arrival Time"(TheEncounter FHIR.Encounter ):#xD; start of FHIRHelpers.ToInterval(First(#xD; ( "Hospitalization Locations"(TheEncounter) ) HospitalLocation#xD; sort by start of FHIRHelpers.ToInterval(period)#xD; ).period)#xD; #xD; // TODO - fix these (must fetch Location resources and compare id to reference)#xD; /*Returns the latest departure time for encounter including any prior ED visit. */#xD; /*#xD; define function "Hospital Departure Time"(TheEncounter FHIR.Encounter):#xD; end of FHIRHelpers.ToInterval(Last(#xD; ( "Hospitalization Locations"(TheEncounter) ) HospitalLocation#xD; sort by start of FHIRHelpers.ToInterval(period)#xD; ).period)#xD; #xD; define function "Emergency Department Arrival Time"(TheEncounter FHIR.Encounter):#xD; start of FHIRHelpers.ToInterval((#xD; singleton from (#xD; ( "Hospitalization Locations"(TheEncounter) ) HospitalLocation#xD; where HospitalLocation.type ~ "ER"#xD; )#xD; ).period)#xD; #xD; define function "First Inpatient Intensive Care Unit"(TheEncounter FHIR.Encounter):#xD; First(#xD; ( TheEncounter.location ) HospitalLocation#xD; where HospitalLocation.type ~ "ICU"#xD; and HospitalLocation.period during TheEncounter.period#xD; sort by start of FHIRHelpers.ToInterval(period)#xD; )#xD; */#xD; #xD; /*Hospitalization with Observation and Outpatient Surgery Service returns the total interval from the start of any immediately prior emergency department visit, outpatient surgery visit or observation visit to the discharge of the given encounter.*/#xD; /* TODO:#xD; define function "HospitalizationWithObservationAndOutpatientSurgeryService"(Encounter "Encounter, Performed" ):#xD; Encounter Visit#xD; let ObsVisit: Last(["Encounter, Performed": "Observation Services"] LastObs#xD; where LastObs.relevantPeriod ends 1 hour or less on or before start of Visit.relevantPeriod#xD; sort by#xD; end of relevantPeriod#xD; ),#xD; VisitStart: Coalesce(start of ObsVisit.relevantPeriod, start of Visit.relevantPeriod),#xD; EDVisit: Last(["Encounter, Performed": "Emergency Department Visit"] LastED#xD; where LastED.relevantPeriod ends 1 hour or less on or before VisitStart#xD; sort by#xD; end of relevantPeriod#xD; ),#xD; VisitStartWithED: Coalesce(start of EDVisit.relevantPeriod, VisitStart),#xD; OutpatientSurgeryVisit: Last(["Encounter, Performed": "Outpatient Surgery Service"] LastSurgeryOP#xD; where LastSurgeryOP.relevantPeriod ends 1 hour or less on or before VisitStartWithED#xD; sort by#xD; end of relevantPeriod#xD; )#xD; return Interval[Coalesce(start of OutpatientSurgeryVisit.relevantPeriod, VisitStartWithED),#xD; end of Visit.relevantPeriod]#xD; */#xD; #xD; /*Hospitalization with Observation returns the total interval from the start of any immediately prior emergency department visit through the observation visit to the discharge of the given encounter*/#xD; define function "HospitalizationWithObservation"(TheEncounter FHIR.Encounter ):#xD; TheEncounter Visit#xD; let ObsVisit: Last([Encounter: "Observation Services"] LastObs#xD; where LastObs.period ends 1 hour or less on or before start of Visit.period#xD; sort by end of period#xD; ),#xD; VisitStart: Coalesce(start of ObsVisit.period, start of Visit.period),#xD; EDVisit: Last([Encounter: "Emergency Department Visit"] LastED#xD; where LastED.period ends 1 hour or less on or before VisitStart#xD; sort by end of period#xD; )#xD; return Interval[Coalesce(start of EDVisit.period, VisitStart), end of Visit.period]#xD; #xD; /**#xD; * Normalizes the input argument to an interval representation.#xD; * The input can be provided as a dateTime, Period, Timing, instant, string, Age, or Range.#xD; * The intent of this function is to provide a clear and concise mechanism to treat single#xD; * elements that have multiple possible representations as intervals so that logic doesn't have to account#xD; * for the variability. More complex calculations (such as medication request period or dispense period#xD; * calculation) need specific guidance and consideration. That guidance may make use of this function, but#xD; * the focus of this function is on single element calculations where the semantics are unambiguous.#xD; * If the input is a dateTime, the result a DateTime Interval beginning and ending on that dateTime.#xD; * If the input is a Period, the result is a DateTime Interval.#xD; * If the input is a Timing, an error is raised indicating a single interval cannot be computed from a Timing.#xD; * If the input is an instant, the result is a DateTime Interval beginning and ending on that instant.#xD; * If the input is a string, an error is raised indicating a single interval cannot be computed from a string.#xD; * If the input is an Age, the result is a DateTime Interval beginning when the patient was the given Age,#xD; and ending immediately prior to when the patient was the given Age plus one year.#xD; * If the input is a Range, the result is a DateTime Interval beginning when the patient was the Age given#xD; by the low end of the Range, and ending immediately prior to when the patient was the Age given by the#xD; high end of the Range plus one year.#xD; */#xD; define function "Normalize Interval"(choice Choice<FHIR.dateTime, FHIR.Period, FHIR.Timing, FHIR.instant, FHIR.string, FHIR.Age, FHIR.Range> ):#xD; case#xD; when choice is FHIR.dateTime then#xD; Interval[FHIRHelpers.ToDateTime(choice as FHIR.dateTime), FHIRHelpers.ToDateTime(choice as FHIR.dateTime)]#xD; when choice is FHIR.Period then#xD; FHIRHelpers.ToInterval(choice as FHIR.Period)#xD; when choice is FHIR.instant then#xD; Interval[FHIRHelpers.ToDateTime(choice as FHIR.instant), FHIRHelpers.ToDateTime(choice as FHIR.instant)]#xD; when choice is FHIR.Age then#xD; Interval[FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity(choice as FHIR.Age),#xD; FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity(choice as FHIR.Age) + 1 year)#xD; when choice is FHIR.Range then#xD; Interval[FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity((choice as FHIR.Range).low),#xD; FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity((choice as FHIR.Range).high) + 1 year)#xD; when choice is FHIR.Timing then#xD; Message(null as Interval<DateTime>, true, '1', 'Error', 'Cannot compute a single interval from a Timing type')#xD; when choice is FHIR.string then#xD; Message(null as Interval<DateTime>, true, '1', 'Error', 'Cannot compute an interval from a String value')#xD; else#xD; null as Interval<DateTime>#xD; end#xD; #xD; /**#xD; * Returns an interval representing the abatement of the given condition, if an#xD; abatement element is present, null otherwise.#xD; This function uses the semantics of Normalize Interval to interpret the abatement#xD; element.#xD; */#xD; define function "Normalize Abatement"(condition Condition ):#xD; if condition.abatement is FHIR.dateTime then#xD; Interval[FHIRHelpers.ToDateTime(condition.abatement as FHIR.dateTime), FHIRHelpers.ToDateTime(condition.abatement as FHIR.dateTime)]#xD; else if condition.abatement is FHIR.Period then#xD; FHIRHelpers.ToInterval(condition.abatement as FHIR.Period)#xD; else if condition.abatement is FHIR.string then#xD; Message(null as Interval<DateTime>, true, '1', 'Error', 'Cannot compute an interval from a String value')#xD; else if condition.abatement is FHIR.Age then#xD; Interval[FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity(condition.abatement as FHIR.Age),#xD; FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity(condition.abatement as FHIR.Age) + 1 year)#xD; else if condition.abatement is FHIR.Range then#xD; Interval[FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity((condition.abatement as FHIR.Range).low),#xD; FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity((condition.abatement as FHIR.Range).high) + 1 year)#xD; else if condition.abatement is FHIR.boolean then#xD; Interval[end of "Normalize Interval"(condition.onset), condition.recordedDate)#xD; else null#xD; #xD; /*#xD; Returns an interval representing the period during which the condition was prevalent (i.e. onset to abatement)#xD; If the condition is "active", then abatement being unknown#xD; would indicate the condition is ongoing, and the ending boundary of the prevalence#xD; period is inclusive, otherwise, the abatement is considered unknown and the ending boundary#xD; of the prevalence period is exclusive.#xD; Note that when using this function it should be noted that many clinical systems#xD; do not actually capture abatement, so care should be taken when using this function#xD; to meet clinical intent.#xD; */#xD; define function "Prevalence Period"(condition Condition ):#xD; if condition.clinicalStatus ~ "active"#xD; or condition.clinicalStatus ~ "recurrence"#xD; or condition.clinicalStatus ~ "relapse" then#xD; Interval[start of "Normalize Interval"(condition.onset), end of "Normalize Abatement"(condition)]#xD; else#xD; Interval[start of "Normalize Interval"(condition.onset), end of "Normalize Abatement"(condition))#xD; #xD; /*Returns the tail of the given uri (i.e. everything after the last slash in the URI).*/#xD; define function "GetId"(uri String ):#xD; Last(Split(uri, '/'))#xD; #xD; /*Returns the Condition resources referenced by the diagnosis element of the Encounter*/#xD; define function "EncounterDiagnosis"(Encounter Encounter ):#xD; Encounter.diagnosis D#xD; return singleton from ([Condition] C where C.id = "GetId"(D.condition.reference))#xD; #xD; define function "GetCondition"(reference Reference):#xD; singleton from ([Condition] C where C.id = "GetId"(reference.reference))#xD; #xD; define function "PresentOnAdmissionIndicator"(element Element):#xD; GetExtension(element, 'http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter-diagnosisPresentOnAdmission').value as FHIR.CodeableConcept#xD; #xD; // Returns the condition that is specified as the principal diagnosis for the encounter#xD; // TODO: BTR 2019-07-30: Shouldn't need the FHIRHelpers reference here, investigate#xD; define function "PrincipalDiagnosis"(Encounter Encounter ):#xD; (singleton from (Encounter.diagnosis D where FHIRHelpers.ToInteger(D.rank) = 1)) PD#xD; return singleton from ([Condition] C where C.id = "GetId"(PD.condition.reference))#xD; // Returns the location for the given location reference#xD; #xD; /*Returns the Location resource specified by the given reference*/#xD; define function "GetLocation"(reference Reference ):#xD; singleton from (#xD; [Location] L where L.id = GetId(reference.reference)#xD; )#xD; #xD; /*NOTE: Extensions are not the preferred approach, but are used as a way to access#xD; content that is defined by extensions but not yet surfaced in the#xD; CQL model info.*/#xD; define function "GetExtensions"(domainResource DomainResource, url String ):#xD; domainResource.extension E#xD; where E.url = ('http://hl7.org/fhir/us/qicore/StructureDefinition/' + url)#xD; return E#xD; #xD; define function "GetExtension"(domainResource DomainResource, url String ):#xD; singleton from "GetExtensions"(domainResource, url)#xD; #xD; /*NOTE: Extensions are not the preferred approach, but are used as a way to access#xD; content that is defined by extensions but not yet surfaced in the#xD; CQL model info.*/#xD; define function "GetExtensions"(element Element, url String ):#xD; element.extension E#xD; where E.url = (url)#xD; return E#xD; #xD; define function "GetExtension"(element Element, url String ):#xD; singleton from "GetExtensions"(element, url)#xD; #xD; /*NOTE: Extensions are not the preferred approach, but are used as a way to access#xD; content that is defined by extensions but not yet surfaced in the#xD; CQL model info.*/#xD; define function "GetBaseExtensions"(domainResource DomainResource, url String ):#xD; domainResource.extension E#xD; where E.url = ('http://hl7.org/fhir/StructureDefinition/' + url)#xD; return E#xD; #xD; define function "GetBaseExtension"(domainResource DomainResource, url String ):#xD; singleton from "GetBaseExtensions"(domainResource, url)#xD; #xD; /*@description: Returns any base-FHIR extensions defined on the given element with the specified id.#xD; @comment: NOTE: Extensions are not the preferred approach, but are used as a way to access#xD; content that is defined by extensions but not yet surfaced in the CQL model info.*/#xD; define function "BaseExtensions"(element Element, id String ):#xD; element.extension E#xD; where E.url = ('http://hl7.org/fhir/StructureDefinition/' + id)#xD; return E#xD; #xD; /*@description: Returns the single base-FHIR extension (if present) on the given element with the specified id.#xD; @comment: This function uses singleton from to ensure that a run-time exception is thrown if there#xD; is more than one extension on the given resource with the specified url.*/#xD; define function "BaseExtension"(element Element, id String ):#xD; singleton from BaseExtensions(element, id)#xD; #xD; /*NOTE: Provenance is not the preferred approach, this is provided only as an illustration#xD; for what using Provenance could look like, and is not a tested pattern*/#xD; //define function "GetProvenance"(resource Resource ):#xD; //singleton from ([Provenance: target in resource.id])#xD; #xD; define function "GetMedicationCode"(request MedicationRequest ):#xD; if request.medication is CodeableConcept then#xD; request.medication as CodeableConcept#xD; else#xD; (singleton from ([Medication] M where M.id = GetId((request.medication as Reference).reference))).code#xD; #xD; /*Given an interval, return true if the interval has a starting boundary specified (i.e. the start of the interval is not null and not the minimum DateTime value)*/#xD; define function "HasStart"(period Interval<DateTime> ):#xD; not ( start of period is null#xD; or start of period = minimum DateTime#xD; )#xD; #xD; /*Given an interval, return true if the interval has an ending boundary specified (i.e. the end of the interval is not null and not the maximum DateTime value)*/#xD; define function "HasEnd"(period Interval<DateTime> ):#xD; not (#xD; end of period is null#xD; or#xD; end of period = maximum DateTime#xD; )#xD; #xD; /*Given an interval, return the ending point if the interval has an ending boundary specified, otherwise, return the starting point*/#xD; define function "Latest"(choice Choice<FHIR.dateTime, FHIR.Period, FHIR.Timing, FHIR.instant, FHIR.string, FHIR.Age, FHIR.Range> ):#xD; ("Normalize Interval"(choice)) period#xD; return#xD; if ( HasEnd(period)) then end of period#xD; else start of period#xD; #xD; /*Given an interval, return the starting point if the interval has a starting boundary specified, otherwise, return the ending point*/#xD; define function "Earliest"(choice Choice<FHIR.dateTime, FHIR.Period, FHIR.Timing, FHIR.instant, FHIR.string, FHIR.Age, FHIR.Range> ):#xD; ("Normalize Interval"(choice)) period#xD; return#xD; if (HasStart(period)) then start of period#xD; else end of period Content: application/elm+xml Encoded data (446476 characters) Content: application/elm+json Encoded data (848580 characters)
Code system ConditionClinicalStatusCodes
Code system AllergyIntoleranceClinicalStatusCodes
Code system AllergyIntoleranceVerificationStatusCodes
Code system ConditionVerificationStatusCodes