HL7 FHIR® Implementation Guide: Electronic Case Reporting (eCR) - US Realm
1.1.0 - STU 2 Ballot

This page is part of the electronic Case Reporting (eCR) (v1.1.0: STU 2 on FHIR R4 Ballot 1) based on FHIR R4. The current version which supercedes this version is 2.1.0. For a full list of available versions, see the Directory of published versions

Example Bundle: eRSD Supplemental Bundle example

Bundle bundle-ersd-supplemental-bundle of type collection


Entry 1 - Full URL = http://aphl.org/fhir/ecr/Library/RuleFilters

Resource Library:

Id: library-RuleFilters-1.0.0
Type: logic-library
Version: 1.0.0
Status: active
Related:

type: depends-on

Resource:
http://aphl.org/fhir/ecr/Library/library-FHIRHelpers|4.0.0

Data Requirements:

type: ValueSet

type: Observation

type: Encounter

type: Location

type: CodeSystem

type: Organization

type: Organization

Content: type: text/cql
                                      library RuleFilters version '1.0.0'

          using FHIR version '4.0.0'

          include FHIRHelpers version '4.0.0'

          codesystem "UsageContext": 'http://terminology.hl7.org/CodeSystem/usage-context-type'
          codesystem "JurisdictionsList": 'http://hl7.org/fhir/us/ecr/CodeSystem/ersd-jurisdictions'
          valueset "Indeterminate or Equivocal Lab Result Value": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1146.1035'
          valueset "Negative or Undetected Lab Result Value": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1146.1034'

          code "focus": 'focus' from UsageContext
          //code "Chlamydia": 'Chlamydia'

          /* parameter "Triggering Encounter" Encounter */

          context Patient

          define "Chlamydia ValueSets":
            [ValueSet] ValueSet
              where exists (
                ValueSet.useContext UseContext
                  where UseContext.code ~ "focus"
                    and not  IsNull(
                      UseContext.value Value
                        where Value.text = 'Chlamydia'
                    )
              )

          define function ExpandValueSetCodes(value List<ValueSet>):
            value Value
              return Value.expansion.contains.code

          define function ExpandValueSetSystems(value List<ValueSet>):
            value Value
              return Value.expansion.contains.system

          define "Flattened ValueSet Expansion Codes":
            flatten( ExpandValueSetCodes("Chlamydia ValueSets") )

          define "Flattened ValueSet Expansion Systems":
            flatten( ExpandValueSetSystems("Chlamydia ValueSets") )

          define function ObservationWithSystemAndCodeInChlamydiaValueSets(observation Observation):
              not IsNull(
                observation.code  OConcept
                  where exists (
                    OConcept.coding OCoding
                      where ( OCoding.code in "Flattened ValueSet Expansion Codes" )
                         and OCoding.system in "Flattened ValueSet Expansion Systems"
                  )
              )

          define function ObservationWithCodeInChlamydiaValueSets(observation Observation):
            not IsNull(
              observation.code  OConcept
                where exists (
                  OConcept.coding OCoding where OCoding.code in flatten( ExpandValueSetCodes("Chlamydia ValueSets") )
                )
            )

          define function ChlamydiaObservations(observation Observation):
            if exists (observation.code.coding.system)
            then ObservationWithSystemAndCodeInChlamydiaValueSets(observation)
            else ObservationWithCodeInChlamydiaValueSets(observation)

          define "Chlamydia Test Results":
            [Observation] O
              where ChlamydiaObservations(O)
                and O.status in { 'preliminary', 'final', 'amended', 'corrected' }

          define "Triggering Encounter":
          [Encounter] E

          define "Encounter Location References":
            flatten("Triggering Encounter" TriggeringEncounter
              return TriggeringEncounter.location.location)

          define "Locations Matching Encounter Location References":
            [Location] Location
              where exists (
                  "Encounter Location References" LocationReference
                    where ('Location/' + Location.id) ~ LocationReference.reference
                )

          /* define "Encounter Location Addresses And Patient Addresses":
            "Locations Matching Encounter Location References".address
              union Patient.address */

          define "Encounter Location Address":
            "Locations Matching Encounter Location References" Address
              return Tuple { state: Address.address.state,  postalCode: Address.address.postalCode }

          define "Patient Address":
            Patient.address PA
            return Tuple { state: PA.state, postalCode: PA.postalCode }

          /* define "Address Elements Relevant to Jurisdiction Qualification":
            "Encounter Location Addresses And Patient Addresses" Address
              return Tuple { state: Address.state,  postalCode: Address.postalCode } */

          define "Jurisdictions":
            flatten([CodeSystem] C
              return C.concept Cpt
                return Tuple { jurisdictionCode: Cpt.code,
                  definition: Cpt.definition,
                  jurisdictionType: Cpt.property P where P.code='type' return P.value as FHIR.string,
                  stateCode: Cpt.property P where P.code = 'state' return P.value as FHIR.code,
                  postalCode: Cpt.property P where P.code = 'postalcode' return P.value as FHIR.code
                  })

          define "Encounter Address Postal Code is in Jurisdiction Codes":
            "Jurisdictions" J
              with "Encounter Location Address" LocationAddress
                such that LocationAddress.postalCode in J.postalCode

          define "Encounter Address State is in Jurisdiction Codes":
              "Jurisdictions" J
                with "Encounter Location Address" LocationAddress
                  such that LocationAddress.state in J.stateCode
                    and 'STATE' in J.jurisdictionType

          define "Patient Address Postal Code is in Jurisdiction Codes":
            "Jurisdictions" J
              with "Patient Address" PA
                such that PA.postalCode in J.postalCode

          define "Patient Address State is in Jurisdiction Codes":
            "Jurisdictions" J
              with "Patient Address" PA
                such that PA.state in J.stateCode
                  and 'STATE' in J.jurisdictionType

          define "Address Exists in Jurisdiction Codes":
            exists (
              "Encounter Address State is in Jurisdiction Codes"
                union "Encounter Address Postal Code is in Jurisdiction Codes"
                  union "Patient Address State is in Jurisdiction Codes"
                    union "Patient Address Postal Code is in Jurisdiction Codes"
              )

          define function EncounterAddressJurisdictions():
            if exists ("Encounter Address Postal Code is in Jurisdiction Codes")
              then "Encounter Address Postal Code is in Jurisdiction Codes"
                else "Encounter Address State is in Jurisdiction Codes"

          define function PatientAddressJurisdictions():
            if exists ("Patient Address Postal Code is in Jurisdiction Codes")
              then "Patient Address Postal Code is in Jurisdiction Codes"
                else "Patient Address State is in Jurisdiction Codes"

          define "Jurisdiction Codes Relevant to Encounter Addresses":
            EncounterAddressJurisdictions()

          define "Jurisdiction Codes Relevant to Patient Addresses":
            PatientAddressJurisdictions()

          define "Indeterminate Chlamydia Test Results":
            "Chlamydia Test Results" O
              let organization: [Organization]
              where (
                (
                  exists (
                      O.interpretation interpretationConcept
                        where interpretationConcept as CodeableConcept in "Indeterminate or Equivocal Lab Result Value"
                  )
                    or O.value as CodeableConcept in "Indeterminate or Equivocal Lab Result Value"
                )
                  or "Address Exists in Jurisdiction Codes"
              )

          define "Negative Chlamydia Test Results":
            "Chlamydia Test Results" O
              let organization: [Organization]
              where (
                (
                  exists (
                      O.interpretation interpretationConcept
                        where interpretationConcept as CodeableConcept in "Negative or Undetected Lab Result Value"
                  )
                    or O.value as CodeableConcept in "Negative or Undetected Lab Result Value"
                )
                  and "Address Exists in Jurisdiction Codes"
              )

          define "Is Reportable":
            exists "Indeterminate Chlamydia Test Results"
              or exists "Negative Chlamydia Test Results"
          
                                  

Entry 2 - Full URL = http://hl7.org/fhir/us/ecr/Library/library-us-ph-supplemental-valueset-library-example

Resource Library:

Related Artifacts

Composed OfUS Public Health Supplemental Valueset Example

Entry 3 - Full URL = http://hl7.org/fhir/us/ecr/ValueSet/valueset-us-ph-supplemental-valueset-example

Resource ValueSet:

This value set includes codes based on the following rules:


Entry 4 - Full URL = http://hl7.org/fhir/us/ecr/CodeSystem/ersd-jurisdictions-example

Resource CodeSystem:

Properties

CodeURLDescriptionType
typehttp://hl7.org/fhir/us/ecr/CodeSystem/ersd-jurisdiction-typesType of public health jurisdiction.code
statehttp://hl7.org/fhir/us/core/ValueSet/us-core-usps-stateUSPS Two Letter Alphabetic Codes.code
postalcodePostal code within the public health jurisdiction.string

This code system http://hl7.org/fhir/us/ecr/CodeSystem/ersd-jurisdictions-example defines the following codes:

CodeDisplayDefinition
AK ALASKAAlaska Department of Health and Social Services
AL ALABAMAAlabama Department of Public Health
AR ARKANSASArkansas Department of Health
AS AMERICAN_SAMOAAmerican Samoa
AZ ARIZONAArizona Department of Health Services
CA CALIFORNIACalifornia Department of Public Health
CHI ILLINOISChicago Department of Public Health
CHR VIRGIN_ISLANDSChristiansted (Test)
CO COLORADOColorado Department of Public Health and Environment
CT CONNECTICUTConnecticut Department of Public Health
DC DISTRICT_OF_COLUMBIADistrict of Columbia Department of Health
DE DELAWAREDelaware Health and Social Services
DED GUAMDededo
FL FLORIDAFlorida Department of Health
GA GEORGIAGeorgia Department of Public Health
GU GUAMGuam Department of Public Health and Social Services
HI HAWAIIHawaii Department of Health
HT TEXASHouston Health Department
IA IOWAIowa Department of Public Health
ID IDAHOIdaho Department of Health and Welfare
IL ILLINOISIllinois Department of Public Health
IN INDIANAIndiana State Department of Health
KS KANSASKansas Department of Health and Environment
KY KENTUCKYKentucky Cabinet for Health and Family Services
LA LOUISIANALouisiana Department of Health and Hospitals
LAC CALIFORNIALos Angeles County Department of Public Health
MA MASSACHUSETTSMassachusetts Department of Health and Human Services
MD MARYLANDMaryland Department of Health and Mental Hygiene
ME MAINEMaine Department of Health and Human Services
MI MICHIGANMichigan Department of Community Health
MN MINNESOTAMinnesota Department of Health
MO MISSOURIMissouri State Department of Health and Senior Services
MS MISSISSIPPIMississippi State Department of Health
MT MONTANAMontana Department of Public Health and Human Services
NC NORTH_CAROLINANorth Carolina Department of Health and Human Services
ND NORTH_DAKOTANorth Dakota Department of Health
NE NEBRASKANebraska Department of Health and Human Services
NH NEW_HAMPSHIRENew Hampshire Department of Health and Human Services
NJ NEW_JERSEYNew Jersey Department of Health and Senior Services
NM NEW_MEXICONew Mexico Department of Health
NV NEVADANevada State Health Division
NY NEW_YORKNew York State Department of Health
NYC NEW_YORKNew York City Department of Health and Mental Hygiene
OH OHIOOhio Department of Health
OK OKLAHOMAOklahoma State Department of Health
OR OREGONOregon Health Authority
PA PENNSYLVANIAPennsylvania Department of Health
PHL PENNSYLVANIACity of Philadelphia Department of Public Health
PR PUERTO_RICOPuerto Rico
RI RHODE_ISLANDRhode Island Department of Health
SC SOUTH_CAROLINASouth Carolina Department of Health and Environmental Control
SD SOUTH_DAKOTASouth Dakota Department of Health
SDC CALIFORNIASan Diego County Public Health Services
SF CALIFORNIASan Francisco
SN NEVADASouthern Nevada Health District (SNHD)
STC VIRGIN_ISLANDSSaint Croix (Test)
STJ VIRGIN_ISLANDSSaint John (Test)
TN TENNESSEETennessee Department of Health
TX TEXASTexas Department of State Health Services
UT UTAHUtah Department of Health
VA VIRGINIAVirginia Department of Health
VI VIRGIN_ISLANDSVirgin Islands Department of Health (Test)
VT VERMONTVermont Department of Health
WA WASHINGTONWashington State Department of Health
WI WISCONSINWisconsin Department of Health Services
WV WEST_VIRGINIAWest Virginia Department of Health and Human Resources, Bureau for Public Health
WY WYOMINGWyoming Department of Health