Stream: implementers
Topic: Reverse Chaining Within Forward Chain
Ben Li-Sauerwine (Jun 25 2021 at 02:06):
I'm trying to ask a question of HAPI FHIR like,
"Give me Specimens for Patients having a given Diagnosis code"
I notice that it's possible to nest reverse-chains. For instance, I could use Patient?_has:Observation:patient:_has:AuditEvent:entity:user=MyUserId to get Patients with Observations where the Observation has be audited by a specific user as per the FHIR spec (https://www.hl7.org/fhir/search.html#has).
It's also possible within HAPI to nest a forward-chain within a reverse-chain, e.g. Patient?_has:Observation:subject:device.identifier=urn:system|DEVICEID if you wanted Patients with Observations by a specific Device (https://github.com/hapifhir/hapi-fhir/issues/1752).
What I would expect the syntax to look like is something like Specimen?subject:_has:Condition:subject:code=system|CODE, but in practice I get the same error as if I request some nonsense thing from the forward chain, which is the less-than-illuminating:
{
"resourceType": "OperationOutcome",
"issue": [ {
"severity": "error",
"code": "processing",
"diagnostics": "Index 0 out of bounds for length 0"
} ]
}
I can't be the first person who's wished to nest a reverse-chain into a forward-chain, and it doesn't seem to me that there should be any architectural or performance reason why this would not be supported while either forward- or reverse-chaining is supported within reverse-chaining. Is there a canonical way to do this that I'm missing?
Ben Li-Sauerwine (Jun 25 2021 at 02:44):
I figured it out. For any who follow, the syntax would be, e.g.:
Specimen?subject:Patient._has:Condition:subject:code=system|CODE
Last updated: Apr 12 2022 at 19:14 UTC