Datasets:
AutoOntologyBench / source_data /pinned /smart-anc /commit-301a6b8b9043 /input /cql /ANCBaseDataElements.cql
Download source_data/pinned/smart-anc/commit-301a6b8b9043/input/cql/ANCBaseDataElements.cql from Vinyeh/AutoOntologyBench: direct link, hf CLI and curl.
- Browser
- Download file 2.66 kB
-
https://huggingface.co/datasets/Vinyeh/AutoOntologyBench/resolve/main/source_data/pinned/smart-anc/commit-301a6b8b9043/input/cql/ANCBaseDataElements.cql
- Command line
-
hf download hf://datasets/Vinyeh/AutoOntologyBench/source_data/pinned/smart-anc/commit-301a6b8b9043/input/cql/ANCBaseDataElements.cql
-
curl -L -o ANCBaseDataElements.cql https://huggingface.co/datasets/Vinyeh/AutoOntologyBench/resolve/main/source_data/pinned/smart-anc/commit-301a6b8b9043/input/cql/ANCBaseDataElements.cql
2.66 kB
| /* | |
| Additional required data elements that do not have a data dictionary entry | |
| */ | |
| library ANCBaseDataElements | |
| using FHIR version '4.0.1' | |
| include FHIRHelpers version '4.0.1' | |
| include ANCCommon called AC | |
| include FHIRCommon called FC | |
| include ANCBaseConcepts called BCx | |
| context Patient | |
| /* | |
| define "Pregnant": | |
| "Pregnancy" is not null | |
| or "Pregnancy status" in BCx."Pregnancy status - pregnant" | |
| define "Pregnancy status": | |
| FHIRHelpers.ToConcept( | |
| Last( | |
| [Observation: BCx."Pregnancy status"] O | |
| where O.status = 'final' | |
| sort by FHIRHelpers.ToDateTime(effective as FHIR.dateTime) | |
| ).value | |
| ) | |
| */ | |
| define "Antenatal care case": | |
| ["EpisodeOfCare": type in BCx."Antenatal care case"] | |
| define "Antenatal care contact": | |
| ["Encounter": type in BCx."Antenatal care contact"] | |
| /* | |
| @description: Most recent antenatal care case | |
| */ | |
| define "Pregnancy": | |
| First( | |
| "Antenatal care case" E | |
| sort by start of period descending | |
| ) | |
| define "First trimester": | |
| Interval[start of "Pregnancy".period, start of "Pregnancy".period + 12 weeks] | |
| define "Second trimester": | |
| Interval[start of "Pregnancy".period + 13 weeks, start of "Pregnancy".period + 24 weeks] | |
| /* | |
| @description: Third trimester (assuming GA 25+ weeks) | |
| */ | |
| define "Third trimester": | |
| Interval[start of "Pregnancy".period + 25 weeks, end of "Pregnancy".period] | |
| /* | |
| @description: The diagnosis of pregnancy listed as the chief-complaint diagnosis on the most recent antenatal care case | |
| */ | |
| define "Pregnancy condition": | |
| ["Condition": code in BCx."Pregnancy condition"] C | |
| with "Pregnancy".diagnosis Dx | |
| such that Dx.role = FC."CC" | |
| and C.id = Last(Split(Dx.condition.reference, '/')) | |
| /* | |
| @description: The patient's occupation | |
| */ | |
| define "Patient Occupation": | |
| [Patient] P | |
| return (AC.Extension(P, 'occupation')).value as CodeableConcept | |
| /* | |
| @description: The expected next contact date based on current visits and the next expected visit date | |
| Next contact date logic: | |
| 1. If GA < 20 weeks, contacts should be every 8 weeks | |
| 2. If GA >= 20 weeks, contacts should be every 6 weeks | |
| 3. If GA >= 26 weeks, contacts should be every 4 weeks | |
| 4. If GA >= 34 weeks, contacts should be every 2 weeks | |
| 5. If GA would be 40 weeks prior to next contact date, schedule next contact for 40 weeks | |
| 6. Women with a first contact between 22 and 23 weeks have visits every 2 weeks after 30 weeks | |
| 7. Women with a first contact between 28 and 29 weeks have visits every 2 weeks after 32 weeks | |
| 8. Women with a first contact after 30 weeks have all visits every 2 weeks | |
| */ | |
| define "Next contact date": | |
| Today() + 2 weeks // TODO: Calculate based on gestational age and next expected visit | |