FHIR Chat · Fun with traversal of resources · cql

Stream: cql

Topic: Fun with traversal of resources


view this post on Zulip Richard Stanley (Jan 06 2022 at 04:59):

Hi folks. I'm trying to get to the contract under which an Encounter occurred. The path is Encounter -> Account -> Coverage -> Contract. Is this possible in CQL? This is for attributing an Encounter to a funder. Alternately, a simpler path is Encounter -> serviceProvider (org). But, I want to understand if the more complex approach is feasible.

view this post on Zulip Paul Denning (Jan 06 2022 at 16:18):

Something like

define function "EncounterAccount"(Enc Encounter ):
  Enc.account EA
    return singleton from ([Account] A where A.id = "GetId"(EA.reference))

define function "GetId"(uri String ):
  Last(Split(uri, '/'))

define function "AccountCoverage"(Acct Account ):
  Acct.coverage AC
    return singleton from ([Coverage] CV where CV.id = "GetId"(AC.reference))

define function "CoverageContract"(Cov Coverage ):
  Cov.contract CK
    return singleton from ([Contract] K where K.id = "GetId"(CK.reference))

Based on https://github.com/cqframework/ecqm-content-r4-2021/blob/master/input/cql/MATGlobalCommonFunctionsFHIR4.cql#L266-L272


Last updated: Apr 12 2022 at 19:14 UTC