Stream: implementers
Topic: Checking Observation is referenced by DiagnosticReport
Tushar Nair (Feb 09 2021 at 02:36):
Hello,
I am trying to create a query that checks whether a given Observation resource is referenced by the DiagnosticReport resource. I am using the query as follows:
http://127.0.0.1:12443/fhir-server/R4/Observation?_has:DiagnosticReport:result:_id=440
When I run the query shown above it returns no result although it doesn't throw any error either. The result that I am receiving is shown below:
{
"resourceType": "Bundle",
"id": "1ac447de-c9ee-4433-9d59-169d2d0ca579",
"meta": {
"lastUpdated": "2021-02-08T18:30:13.871-08:00"
},
"type": "searchset",
"total": 0,
"link": [
{
"relation": "self",
"url": "http://127.0.0.1:12443/fhir-server/R4/Observation?_has%3ADiagnosticReport%3Aresult%3A_id=440"
}
]
}
I know that the Observation/440 is referenced by a DiagnosticReport in the 'result' element as I have already tested it. I would be grateful if someone could please suggest How should I structure the query. Thank you in advance.
René Spronk (Feb 09 2021 at 08:03):
Observation?_has:DiagnosticReport:result:_id=440 searches for Observations that (have a DiagnosticReport associated with them) AND (the diagnosticreport should have _id = 440). So you're not referencing Observation/440 this way.
If you just want to test if Observation/440 has some Diagnosticreport resource that references it, you could try Observation?_id=440&_hasDiagnosticReport:result:date=gt1800 - the date=gt1800 is a dummy criterium which always resolves to 'true' (assuming that date element will be always populated in your project)
Tushar Nair (Feb 09 2021 at 17:54):
René Spronk Thank you so much! It worked.
Last updated: Apr 12 2022 at 19:14 UTC