library CesareanBirth version '6.1.000' using QDM version '5.6' include MATGlobalCommonFunctionsQDM version '8.0.000' called Global include PCMaternalQDM version '4.0.000' called PCMaternal codesystem "LOINC": 'urn:oid:2.16.840.1.113883.6.1' valueset "37 to 42 Plus Weeks Gestation": 'urn:oid:2.16.840.1.113762.1.4.1110.68' valueset "Abnormal Presentation": 'urn:oid:2.16.840.1.113762.1.4.1045.105' valueset "Cesarean Birth": 'urn:oid:2.16.840.1.113883.3.117.1.7.1.282' valueset "Delivery of Singleton": 'urn:oid:2.16.840.1.113762.1.4.1045.99' valueset "Delivery Procedures": 'urn:oid:2.16.840.1.113762.1.4.1045.59' valueset "Encounter Inpatient": 'urn:oid:2.16.840.1.113883.3.666.5.307' valueset "Estimated Gestational Age at Delivery": 'urn:oid:2.16.840.1.113762.1.4.1045.26' valueset "Ethnicity": 'urn:oid:2.16.840.1.114222.4.11.837' valueset "Genital Herpes": 'urn:oid:2.16.840.1.113883.3.464.1003.110.12.1049' valueset "ONC Administrative Sex": 'urn:oid:2.16.840.1.113762.1.4.1' valueset "Payer Type": 'urn:oid:2.16.840.1.114222.4.11.3591' valueset "Placenta Accreta Spectrum Previa or Vasa Previa": 'urn:oid:2.16.840.1.113762.1.4.1110.37' valueset "Race": 'urn:oid:2.16.840.1.114222.4.11.836' code "[#] Births.preterm": '11637-6' from "LOINC" display '[#] Births.preterm' code "[#] Births.term": '11639-2' from "LOINC" display '[#] Births.term' code "[#] Parity": '11977-6' from "LOINC" display '[#] Parity' code "[#] Pregnancies": '11996-6' from "LOINC" display '[#] Pregnancies' code "Date and time of obstetric delivery": '93857-1' from "LOINC" display 'Date and time of obstetric delivery' parameter "Measurement Period" Interval context Patient define "Delivery Encounter with Calculated Gestational Age Greater than or Equal to 37 Weeks": PCMaternal."Delivery Encounter with Age Range" DeliveryEncounter where PCMaternal."CalculatedGestationalAge" ( DeliveryEncounter ) >= 37 define "Delivery Encounter with Estimated Gestational Age Greater than or Equal to 37 Weeks": PCMaternal."Delivery Encounter with Age Range" DeliveryEncounter where PCMaternal."CalculatedGestationalAge" ( DeliveryEncounter ) is null and PCMaternal."LastEstimatedGestationalAge" ( DeliveryEncounter ) >= 37 weeks define "Delivery Encounter with Gestational Age Greater than or Equal to 37 Weeks": "Delivery Encounter with Calculated Gestational Age Greater than or Equal to 37 Weeks" union "Delivery Encounter with Estimated Gestational Age Greater than or Equal to 37 Weeks" union "Delivery Encounter with Gestational Age Greater than or Equal to 37 Weeks Based on Coding" define "Delivery Encounter with Gestational Age Greater than or Equal to 37 Weeks Based on Coding": PCMaternal."Delivery Encounter with Age Range" DeliveryEncounter let CGA: PCMaternal."CalculatedGestationalAge" ( DeliveryEncounter ), EGA: PCMaternal."LastEstimatedGestationalAge" ( DeliveryEncounter ) where CGA is null and EGA is null and exists ( DeliveryEncounter.diagnoses EncounterDiagnoses where EncounterDiagnoses.code in "37 to 42 Plus Weeks Gestation" ) define "Denominator": "Singleton Delivery Encounters at 37 Plus Weeks Gravida 1 Parity 0, No Previous Births" define "Encounter with Singleton Delivery": PCMaternal."Delivery Encounter with Age Range" DeliveryEncounter where exists ( DeliveryEncounter.diagnoses EncounterDiagnoses where EncounterDiagnoses.code in "Delivery of Singleton" ) define "Initial Population": PCMaternal."Delivery Encounter with Age Range" define "Numerator": "Delivery Encounter with Cesarean Birth" define "SDE Ethnicity": ["Patient Characteristic Ethnicity": "Ethnicity"] define "SDE Payer": ["Patient Characteristic Payer": "Payer Type"] define "SDE Race": ["Patient Characteristic Race": "Race"] define "SDE Sex": ["Patient Characteristic Sex": "ONC Administrative Sex"] define "Delivery Encounter with Cesarean Birth": "Singleton Delivery Encounters at 37 Plus Weeks Gravida 1 Parity 0, No Previous Births" ThirtysevenWeeksPlusEncounter with ["Procedure, Performed": "Cesarean Birth"] CSection such that Global."NormalizeInterval" ( CSection.relevantDatetime, CSection.relevantPeriod ) during PCMaternal."HospitalizationWithEDOBTriageObservation" ( ThirtysevenWeeksPlusEncounter ) define "Denominator Exclusions": "Delivery Encounter with Abnormal Presentation, Genital Herpes, Placenta Previa, Vasa Previa or Placenta Accreta Spectrum" define "Delivery Encounter with Abnormal Presentation, Genital Herpes, Placenta Previa, Vasa Previa or Placenta Accreta Spectrum": "Encounter with Abnormal Presentation" union "Encounter with Genital Herpes, Placenta Previa, Vasa Previa or Placenta Accreta Spectrum" define "SDE Variable Calculated Gestational Age": PCMaternal."Variable Calculated Gestational Age" define "Encounter with Genital Herpes, Placenta Previa, Vasa Previa or Placenta Accreta Spectrum": "Singleton Delivery Encounters at 37 Plus Weeks Gravida 1 Parity 0, No Previous Births" ThirtysevenWeeksPlusEncounter where exists ( ThirtysevenWeeksPlusEncounter.diagnoses EncounterDiagnoses where EncounterDiagnoses.code in "Placenta Accreta Spectrum Previa or Vasa Previa" or EncounterDiagnoses.code in "Genital Herpes" ) define "Singleton Delivery Encounters at 37 Plus Weeks Gravida 1 Parity 0, No Previous Births": ( "Delivery Encounter with Gestational Age Greater than or Equal to 37 Weeks" intersect "Encounter with Singleton Delivery" ) SingletonEncounterGE37Weeks where ( ( "LastGravida"(SingletonEncounterGE37Weeks) = 1 ) or ( "LastParity"(SingletonEncounterGE37Weeks) = 0 ) or ( ( "LastHistoryPretermBirth"(SingletonEncounterGE37Weeks) = 0 ) and ( "LastHistoryTermBirth"(SingletonEncounterGE37Weeks) = 0 ) ) ) define "Encounter with Abnormal Presentation": "Singleton Delivery Encounters at 37 Plus Weeks Gravida 1 Parity 0, No Previous Births" ThirtysevenWeeksPlusEncounter let LastAbnormalPresentation: Last(["Assessment, Performed": "Abnormal Presentation"] AbnormalPresentation where Global."EarliestOf"(AbnormalPresentation.relevantDatetime, AbnormalPresentation.relevantPeriod) before or on PCMaternal."LastTimeOfDelivery"(ThirtysevenWeeksPlusEncounter) sort by Global."EarliestOf"(relevantDatetime, relevantPeriod) ) where Global."EarliestOf" ( LastAbnormalPresentation.relevantDatetime, LastAbnormalPresentation.relevantPeriod ) during PCMaternal."HospitalizationWithEDOBTriageObservation" ( ThirtysevenWeeksPlusEncounter ) or exists ( ThirtysevenWeeksPlusEncounter.diagnoses EncounterDiagnoses where EncounterDiagnoses.code in "Abnormal Presentation" ) define function "LastGravida"(Encounter "Encounter, Performed" ): Last(["Assessment, Performed": "[#] Pregnancies"] Gravida where Global."EarliestOf"(Gravida.relevantDatetime, Gravida.relevantPeriod) 42 weeks or less before PCMaternal."LastTimeOfDelivery"(Encounter) and Gravida.result is not null sort by Global."EarliestOf"(relevantDatetime, relevantPeriod) ).result as Integer define function "LastHistoryPretermBirth"(Encounter "Encounter, Performed" ): Last(["Assessment, Performed": "[#] Births.preterm"] PretermBirth where Global."EarliestOf"(PretermBirth.relevantDatetime, PretermBirth.relevantPeriod) 42 weeks or less before PCMaternal."LastTimeOfDelivery"(Encounter) and PretermBirth.result is not null sort by Global."EarliestOf"(relevantDatetime, relevantPeriod) ).result as Integer define function "LastHistoryTermBirth"(Encounter "Encounter, Performed" ): Last(["Assessment, Performed": "[#] Births.term"] TermBirth where Global."EarliestOf"(TermBirth.relevantDatetime, TermBirth.relevantPeriod) 42 weeks or less before PCMaternal."LastTimeOfDelivery"(Encounter) and TermBirth.result is not null sort by Global."EarliestOf"(relevantDatetime, relevantPeriod) ).result as Integer define function "LastParity"(Encounter "Encounter, Performed" ): Last(["Assessment, Performed": "[#] Parity"] Parity where Global."EarliestOf"(Parity.relevantDatetime, Parity.relevantPeriod) 42 weeks or less before PCMaternal."LastTimeOfDelivery"(Encounter) and Parity.result is not null sort by Global."EarliestOf"(relevantDatetime, relevantPeriod) ).result as Integer