Stream: implementers
Topic: Search returning OperationOutcome - how to identify?
Santosh Jami (Sep 02 2020 at 20:01):
I have done a standard DiagnosticReport search operation using FhirClient (using .NET FHIR API STU3)
Bundle diagnosticReportSearchBundle = fhirClient.Search<DiagnosticReport>(searchParams);
And based on the bundle results, I am reading the data and executing my logic.
I identified my search params were wrong, so FHIR server returned all the DiagnosticResources, and not just limited to my search criteria.
This stumped me.
What is the way to identify if the search returned "OperationOutcome" resource? Should I traverse all entries for every search and determine that there is no OperationOutcome, this is good result. Seems a bad approach, any better way to identify this?
Michele Mottini (Sep 02 2020 at 21:01):
Why would you want to look for OperationOutcome? Servers are under no obligation to return those when search parameters are not recognized. You can try a Prefer: handling=strict
header if you want the search to fail if parameters are not recognized but I do not know how many server implement that (See http://hl7.org/fhir/search.html#errors)
Santosh Jami (Sep 02 2020 at 21:35):
I tried the following query on my Vonk server:
https://localhost/DiagnosticReport?patient=abc123&_format=json
Then I got the below response 200 status code - all the daignosticreports returned to me, no search criteria applied with error details in operationoutcome resource as one of the entries.
I am trying to find how to identify that below outcome was an error in search instead of the relevant results.
I am posting the response here:
{
"resourceType": "Bundle",
"type": "searchset",
"entry": [
{
"fullUrl": "https://localhost:10022/DiagnosticReport/A1-B1-C1",
"search": {
"mode": "match"
},
"resource": {
"resourceType": "DiagnosticReport",
"id": "A1-B1-C1",
"extension": [
{
"url": "http://www.acme.org/resultsource",
"valueString": "Interface"
}
],
"identifier": [
{
"type": {
"coding": [
{
"system": "http://hl7.org/fhir/identifier-type",
"code": "PLAC",
"display": "PLAC"
}
]
},
"system": "PLAC",
"value": "C1"
},
{
"type": {
"coding": [
{
"system": "http://hl7.org/fhir/identifier-type",
"code": "FILL",
"display": "FILL"
}
]
},
"system": "FILL",
"value": "D1"
}
],
"status": "final",
"code": {
"coding": [
{
"system": "99QDI",
"code": "36126",
"display": "RPR(DX) REFL CONFIRM"
}
]
},
"subject": {
"reference": "https://localhost:10022/Patient/A1"
},
"context": {
"reference": "https://localhost:10022/Encounter/B1"
},
"effectiveDateTime": "2018-05-11T21:48:00+00:00",
"issued": "2020-09-01T18:39:00.000+00:00",
"specimen": [
{
"reference": "https://localhost:10022/Specimen/LAB-D1"
}
],
"result": [
{
"reference": "https://localhost:10022/Observation/A1-B1-C1-LabOrder-HEPC"
},
{
"reference": "https://localhost:10022/Observation/A1-B1-C1-LabOrder-Syphilis"
}
],
"conclusion": "SELF",
"meta": {
"versionId": "216b1a5a-4ecf-48f6-a1c1-5fe791b1786f",
"lastUpdated": "2020-09-02T19:00:15.495+00:00"
}
}
},
{
"fullUrl": "https://localhost:10022/DiagnosticReport/F1-G1-H1",
"search": {
"mode": "match"
},
"resource": {
"resourceType": "DiagnosticReport",
"id": "F1-G1-H1",
"extension": [
{
"url": "http://www.acme.org/resultsource",
"valueString": "Interface"
}
],
"identifier": [
{
"type": {
"coding": [
{
"system": "http://hl7.org/fhir/identifier-type",
"code": "PLAC",
"display": "PLAC"
}
]
},
"system": "PLAC",
"value": "H1"
},
{
"type": {
"coding": [
{
"system": "http://hl7.org/fhir/identifier-type",
"code": "FILL",
"display": "FILL"
}
]
},
"system": "FILL",
"value": "I1"
}
],
"status": "final",
"code": {
"coding": [
{
"system": "99QDI",
"code": "36126",
"display": "RPR(DX) REFL CONFIRM"
}
]
},
"subject": {
"reference": "https://localhost:10022/Patient/F1"
},
"context": {
"reference": "https://localhost:10022/Encounter/G1"
},
"effectiveDateTime": "2018-05-11T21:48:00+00:00",
"issued": "2020-08-31T16:50:00.000+00:00",
"specimen": [
{
"reference": "https://localhost:10022/Specimen/LAB-I1"
}
],
"result": [
{
"reference": "https://localhost:10022/Observation/F1-G1-H1-LabOrder-Gonorrhea"
},
{
"reference": "https://localhost:10022/Observation/F1-G1-H1-LabOrder-Syphilis"
}
],
"conclusion": "SELF",
"meta": {
"versionId": "8237b989-a49c-4fb5-b290-1259d3f087f0",
"lastUpdated": "2020-09-02T18:00:27.134+00:00"
}
}
},
{
"fullUrl": "https://localhost:10022/OperationOutcome/8aa5996f-cc57-4e21-963b-45720c76483c",
"search": {
"mode": "outcome"
},
"resource": {
"resourceType": "OperationOutcome",
"id": "8aa5996f-cc57-4e21-963b-45720c76483c",
"meta": {
"versionId": "ae6ae6a4-e891-4dfe-9bc5-8a955809aecd",
"lastUpdated": "2020-09-02T19:30:48.312+00:00"
},
"issue": [
{
"severity": "error",
"code": "exception",
"details": {
"coding": [
{
"system": "http://hl7.org/fhir/dotnet-api-operation-outcome",
"code": "5006"
}
],
"text": "Parameter patient could target one of the resourcetypes 'Patient, Group'. Please specify one of those types using the :type modifier."
}
},
{
"severity": "warning",
"code": "not-supported",
"details": {
"coding": [
{
"system": "http://hl7.org/fhir/dotnet-api-operation-outcome",
"code": "5003"
}
],
"text": "Parameter If-Modified-Since is not implemented"
}
},
{
"severity": "warning",
"code": "not-supported",
"details": {
"coding": [
{
"system": "http://hl7.org/fhir/dotnet-api-operation-outcome",
"code": "5003"
}
],
"text": "Parameter If-None-Match is not implemented"
}
}
]
}
}
],
"total": 5836,
"link": [
{
"relation": "self",
"url": "https://localhost:10022/DiagnosticReport?_format=json&_sort=-_lastUpdated&_count=10&_skip=0"
},
{
"relation": "next",
"url": "https://localhost:10022/DiagnosticReport?_format=json&_sort=-_lastUpdated&_count=10&_skip=10"
},
{
"relation": "last",
"url": "https://localhost:10022/DiagnosticReport?_format=json&_sort=-_lastUpdated&_count=10&_skip=5830"
}
],
"id": "574fb9b4-a4bd-4044-9698-e09231777cb7",
"meta": {
"versionId": "c48f0125-ef9d-4a45-8658-2b05d2b808f3",
"lastUpdated": "2020-09-02T19:30:48.291+00:00"
}
}
ryan moehrke (Sep 02 2020 at 22:54):
In such cases, the search process MAY include an OperationOutcome in the search set that contains additional hints and warnings about the search process. This is included in the search results as an entry with search mode = outcome
if looking for Bundle.entry.search.mode = outcome is easier you have that..
the other thing you can do is check the link.url if it doesn't have a search parameter you sent that means that the parameter was ignored. couldn't find the specific text on that one but I'm pretty sure its true..
Santosh Jami (Sep 04 2020 at 14:26):
Thanks @ryan moehrke .
Adding the fix to look for search params returned in "self-link", and also a condition for Bundle.entry.search.mode = outcome
Last updated: Apr 12 2022 at 19:14 UTC