Longitudinal Maternal & Infant Health Information for Research
1.0.0-ballot - STU 1 Ballot US

This page is part of the Maternal and Infant Health Research (v1.0.0-ballot: STU1 Ballot 1) based on FHIR R4. . For a full list of available versions, see the Directory of published versions

Library: Library for Pregnancy Associated Maternal Deaths

Official URL: http://www.hl7.org/fhir/us/mihr/Library/PAMDeaths Version: 1.0.0-ballot
Draft as of 2022-03-29 Computable Name: PAMDeaths

Related Artifacts

depends-onhttp://www.hl7.org/fhir/us/mihr/ValueSet/PregnancyProcedureDelivery-mmm-SNOMED
depends-onhttp://www.hl7.org/fhir/us/mihr/ValueSet/PregnancyProcedureDelivery-mmm-CPT
depends-onhttp://www.hl7.org/fhir/us/mihr/ValueSet/PregnancyProcedureDelivery-mmm-ICD
depends-onhttp://www.hl7.org/fhir/us/mihr/ValueSet/2.16.840.1.113883.3.464.1003.111.11.1015
depends-onhttp://www.hl7.org/fhir/us/mihr/ValueSet/2.16.840.1.113883.3.464.1003.111.11.1014
depends-onhttp://www.hl7.org/fhir/us/mihr/ValueSet/pregnancycondition-mmm-ICD
depends-onhttp://www.hl7.org/fhir/us/mihr/ValueSet/pregnancycondition-mmm-SNOMED
depends-onhttp://www.hl7.org/fhir/us/mihr/ValueSet/pregnancystate-mmm-icd10
depends-onhttp://www.hl7.org/fhir/us/mihr/ValueSet/pregnancyconditionconfirmed-mmm-SNOMED
depends-onhttp://www.hl7.org/fhir/us/mihr/ValueSet/PregnancyDeliveryDiagnosis-mmm-ICD
depends-onhttp://www.hl7.org/fhir/us/mihr/ValueSet/PregnancyDeliveryDiagnosis-mmm-SNOMED
depends-onhttp://www.hl7.org/fhir/us/mihr/ValueSet/PregnancyNonLive-mmm-SNOMED
depends-onhttp://www.hl7.org/fhir/us/mihr/ValueSet/PregnancyNonLive-mmm-CPT
depends-onhttp://www.hl7.org/fhir/us/mihr/ValueSet/PregnancyNonLive-mmm-ICD

Contents

text/cql

library PAMDeaths version '0.0.01'

using FHIR version '4.0.1'

include FHIRHelpers version '4.0.001' called FHIRHelpers

codesystem "SNOMEDCT": 'http://snomed.info/sct'

//Delivery Procedure Group
valueset "Pregnancy Delivery SNOMED": 'http://www.hl7.org/fhir/us/mihr/ValueSet/PregnancyProcedureDelivery-mmm-SNOMED'
valueset "Pregnancy Delivery CPT": 'http://www.hl7.org/fhir/us/mihr/ValueSet/PregnancyProcedureDelivery-mmm-CPT'
valueset "Pregnancy Delivery ICD": 'http://www.hl7.org/fhir/us/mihr/ValueSet/PregnancyProcedureDelivery-mmm-ICD'
valueset "Pregnancy Procedure SNOMED": 'http://www.hl7.org/fhir/us/mihr/ValueSet/2.16.840.1.113883.3.464.1003.111.11.1015'
valueset "Pregnancy Procedure CPT": 'http://www.hl7.org/fhir/us/mihr/ValueSet/2.16.840.1.113883.3.464.1003.111.11.1014'

//Pregnancy Group
valueset "Pregnancy Condition ICD": 'http://www.hl7.org/fhir/us/mihr/ValueSet/pregnancycondition-mmm-ICD'
valueset "Pregnancy Condition SNOMED": 'http://www.hl7.org/fhir/us/mihr/ValueSet/pregnancycondition-mmm-SNOMED'
valueset "Pregnancy State ICD": 'http://www.hl7.org/fhir/us/mihr/ValueSet/pregnancystate-mmm-icd10'

//Pregnancy Confirmed Diagnosis
valueset "Pregnancy Condition Confirmed": 'http://www.hl7.org/fhir/us/mihr/ValueSet/pregnancyconditionconfirmed-mmm-SNOMED'

//Pregnancy Delivery Diagnosis
valueset "Pregnancy Delivery Diagnosis ICD": 'http://www.hl7.org/fhir/us/mihr/ValueSet/PregnancyDeliveryDiagnosis-mmm-ICD'
valueset "Pregnancy Delivery Diagnosis SNOMED": 'http://www.hl7.org/fhir/us/mihr/ValueSet/PregnancyDeliveryDiagnosis-mmm-SNOMED'

//Non-Live Brith (Fetal Death/Abortion)
valueset "Non-Live Birth SNOMED": 'http://www.hl7.org/fhir/us/mihr/ValueSet/PregnancNonLive-mmm-SNOMED'
valueset "Non-Live Birth CPT": 'http://www.hl7.org/fhir/us/mihr/ValueSet/PregnancyNonLive-mmm-CPT'
valueset "Non-Live Birth ICD": 'http://www.hl7.org/fhir/us/mihr/ValueSet/PregnancyNonLive-mmm-ICD'

parameter "Measurement Period" Interval<DateTime>

context Patient

define "Initial Population":
	"Pregnancy Associated Maternal Deaths"

define "Pregnancy Associated Maternal Deaths":
Patient.deceased is FHIR.dateTime and

exists ([Condition: "Pregnancy Condition Confirmed"] PregConfirmedDx
         where (Patient.deceased) occurs 645 days or less after (PregConfirmedDx.onset))

//exists (("Delivery Diagnosis"
		//union "Non-Live Birth Group" )Condition
   		//where Patient.deceased occurs 365 days or less after Condition.onset)

//exists ([Observation] PregConfirmedTest
        //where PregConfirmedTest.value.code ~ '77386006')
        //and PregConfirmedTest.code.coding.code ~ '82810-3')
		//and Patient.deceased occurs 645 days or less on or after PregConfirmedTest.effective)

//or exists ([Procedure: "Delivery Procedure"] DeliveryProcedure
	//where (Patient.deceased) occurs after "Normalize Interval"(DeliveryProcedure.performed))

define "Delivery Procedure":
	[Procedure: "Pregnancy Delivery SNOMED"]
	union [Procedure: "Pregnancy Delivery CPT"]
	union [Procedure: "Pregnancy Delivery ICD"]
	union [Procedure: "Pregnancy Procedure SNOMED"]
	union [Procedure: "Pregnancy Procedure CPT"]

define "Pregnancy Group":
	[Condition: "Pregnancy Condition ICD"]
	union [Condition: "Pregnancy Condition SNOMED"]
	union [Condition: "Pregnancy State ICD"]

define "Delivery Diagnosis":
	[Condition: "Pregnancy Delivery Diagnosis SNOMED"]
	union [Condition: "Pregnancy Delivery Diagnosis ICD"]
	union [Condition: "Pregnancy Delivery SNOMED"]
	union [Condition: "Pregnancy Delivery CPT"]
	union [Condition: "Pregnancy Delivery ICD"]

define "Non-Live Birth Group":
	[Condition: "Non-Live Birth SNOMED"]
	union [Condition: "Non-Live Birth CPT"]
	union [Condition: "Non-Live Birth ICD"]



define "SDE Related Person":
	[RelatedPerson]

define "SDE Allergy Intolerance":
	[AllergyIntolerance]

define "SDE BMI":
	[Observation: code ~ '39156-5']

define "SDE Blood Pressure":
	[Observation: code ~ '85354-9']

define "SDE Height":
	[Observation: code ~ '8302-2']

define "SDE Body Temperature":
	[Observation: code ~ '8310-5']

define "SDE Body Weight":
	[Observation: code ~ '29463-7']

define "SDE Care Plan":
	[CarePlan]

define "SDE Care Team":
	[CareTeam]

define "SDE Conditions":
	[Condition]

//USCore suggests that there's two different Diagnostic Report profiles that need to be caught but
//it boils down to just catching all Diagnostic Reports
define "SDE Diagnostic Report":
	[DiagnosticReport]

define "SDE Document Reference":
	[DocumentReference]

define "SDE Encounter":
	[Encounter]

define "SDE Family Member History":
	[FamilyMemberHistory]

define "SDE Goal":
	[Goal]

define "SDE Head Circumference":
	[Observation: code ~ '9843-4']

define "SDE Heart Rate":
	[Observation: code ~ '8867-4']

define "SDE Immunization":
	[Immunization]

define "SDE Device":
	[Device]

define "SDE Lab Observation":
	[Observation: category ~ 'laboratory']

define "SDE Location":
	[Location]

define "SDE Medication":
	[Medication]

define "SDE Medication Request":
	[MedicationRequest]

define "SDE Organization":
	[Organization]

define "SDE Patient":
	[Patient]

define "SDE Pediatric BMI":
	[Observation: code ~ '59576-9']

define "SDE Occipital Frontal Head Circumference":
	[Observation: code ~ '8289-1']

define "SDE Pediatric Weight for Height":
	[Observation: code ~ '77606-2']

define "SDE Practitioner":
	[Practitioner]

define "SDE Practitioner Role":
	[PractitionerRole]

define "SDE Procedure":
	[Procedure]

define "SDE Provenance":
	[Provenance]

define "SDE Oximetry":
	[Observation: code ~ '2708-6']

define "SDE Respiratory Rate":
	[Observation: code ~ '9279-1']

define "SDE Smoking Status":
    [Observation: category ~ 'social-history']

define "SDE Vital Signs":
	[Observation: category ~ 'vital-signs']

/**
*    CQFMeasures Common Logic
**/
define function "Normalize Interval"(choice Choice<FHIR.dateTime, FHIR.Period, FHIR.Timing, FHIR.instant, FHIR.string, FHIR.Age, FHIR.Range> ):
  case
  	  when choice is FHIR.dateTime then
    	Interval[FHIRHelpers.ToDateTime(choice as FHIR.dateTime), FHIRHelpers.ToDateTime(choice as FHIR.dateTime)]
  		when choice is FHIR.Period then
  		FHIRHelpers.ToInterval(choice as FHIR.Period)
  		when choice is FHIR.instant then
  			Interval[FHIRHelpers.ToDateTime(choice as FHIR.instant), FHIRHelpers.ToDateTime(choice as FHIR.instant)]
  		when choice is FHIR.Age then
  		  Interval[FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity(choice as FHIR.Age),
  			  FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity(choice as FHIR.Age) + 1 year)
  		when choice is FHIR.Range then
  		  Interval[FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity((choice as FHIR.Range).low),
  			  FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity((choice as FHIR.Range).high) + 1 year)
  		when choice is FHIR.Timing then
  		  Interval[FHIRHelpers.ToDateTime((choice as FHIR.Timing).event), FHIRHelpers.ToDateTime((choice as FHIR.Timing).event)]
    when choice is FHIR.string then
      Message(null as Interval<DateTime>, true, '1', 'Error', 'Cannot compute an interval from a String value')
  		else
  			null as Interval<DateTime>
  	end