Stream: implementers
Topic: FHIR Error Responses - not informative, tips?
William Capozzoli (Mar 26 2018 at 22:06):
Hello,
My issue fully documented here if you can view this:
http://community.fhir.org/t/fhir-error-responses-finding-helpful-info-in-them/744
1. How to find useful information in the error response?
2. Why is the error response slightly different (less useful) if I use fhir.js to make the CRUD request to fhirtest.uhn.ca, versus when I use fhirtest.uhn.ca's UI (more helpful, see example below)
### Example
Send a bad POST body using fhir.js to fhirtest.uhn
Send a reference with 12345/Practitioner
(incorrect) instead of Practitioner/12345
(correct) then I get error:
Unprocessable Entity
Send a bad POST body using the UI on fhirtest.uhn
Send a reference with 12345/Practitioner
(incorrect) instead of Practitioner/12345
(correct) then I get error:
Error: HTTP 422 Unprocessable Entity: Invalid reference found at path 'PractitionerRole.practitioner'. Resource type '787132' is not valid for this path
^^ much more helpful!!
Lloyd McKenzie (Mar 26 2018 at 22:07):
@James Agnew ?
William Capozzoli (Mar 26 2018 at 22:14):
I tried logging every key
in the response and response[key]
(e.g. status, errors, headers) and tried response.body
response.data
but didn't have much success in finding anything useful. I guess I could log it recursively. Its a ton of metadata/http jargon that's not relevant. Been through a bunch of documentation and tried examining the HAPI FHIR source code. Thanks @Lloyd McKenzie
Michael Lawley (Mar 27 2018 at 08:21):
I would be looking at fhir.js not HAPI for what's happening. If you do this in a web browser like Chrome/Safari, then you can use the developer tools to inspect the actual network traffic.
James Agnew (Mar 27 2018 at 10:24):
Agree with Michael. @William Capozzoli can you check the Chrome developer console network tab to see what's actually being passed across the wire?
William Capozzoli (Mar 29 2018 at 00:02):
@James Agnew its a request being made to our own back-end, which then makes a call to fhirtest.uhn.ca. So its a huge body of data from front-end to back-end, and then from there the data gets transformed into fhir Resource objects which fhirtest.uhn.ca can digest to make a bunch of fhir resources.
Ill look for the actual request, do you want to see Request Headers?
Though I think it was my backend-code causing the error in this situation, as opposed to the quality of the data being sent from front to back. To re-produce the error I just have to update some backend code to mess up the EpisodeOfCare's reference to a practitioner (i.e. make it '12345/Practitioner' instead of 'Practitioner/12345'). Either way its the same '12345' value being sent from front to back.
So the call is not directly from my frontEnd to fhirtest.uhn.ca, if that's what you were thinking.
William Capozzoli (Mar 29 2018 at 00:06):
@Michael Lawley I'm seeing your response now. I guess I was sending the error response all the way back to the front-end so I could read it in the Network tab > Preview/Response. Same info I was reading in the log on my back-end regarding failure to create the Resource in HAPI.
You said look to fhir.js to see what's happening, you mean to use this library to somehow inspect the response? Maybe i'm not following you here.
William Capozzoli (Mar 29 2018 at 00:12):
Here are my request headers from Chrome Network tab. Maybe some of this is affecting the call that my back-end makes to HAPI?:
POST /claim HTTP/1.1 Host: localhost:3001 Connection: keep-alive Content-Length: 1539 Pragma: no-cache Cache-Control: no-cache Origin: http://localhost:3000 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36 content-type: application/json Accept: */* Referer: http://localhost:3000/newclaim Accept-Encoding: gzip, deflate, br Accept-Language: en-US,en;q=0.9
and the response:
{ "status": 422, "headers": { }, "config": { "resource": { "identifier": [ { "system": "http:\/\/claimcdr.com\/claimid", "value": "SDF2-KMD3" }, { "system": "http:\/\/claimcdr.com\/claimfolder", "value": "019ab685-ec64-416a-9dc4-2495ae75088b" } ], "status": "active", "patient": { "reference": "1960729\/Patient" }, "careManager": { "reference": "221712\/Practitioner" }, "managingOrganization": { "reference": "601587\/Organization" }, "resourceType": "EpisodeOfCare" }, "baseUrl": "http:\/\/hapi.fhir.org\/baseDstu3", "credentials": "same-origin", "headers": { "Content-Type": "application\/fhir+json", "Accept": "application\/json", "Prefer": "return=representation" }, "data": "{\"identifier\":[{\"system\":\"http:\/\/claimcdr.com\/claimid\",\"value\":\"SDF2-KMD3\"},{\"system\":\"http:\/\/claimcdr.com\/claimfolder\",\"value\":\"019ab685-ec64-416a-9dc4-2495ae75088b\"}],\"status\":\"active\",\"patient\":{\"reference\":\"1960729\/Patient\"},\"careManager\":{\"reference\":\"221712\/Practitioner\"},\"managingOrganization\":{\"reference\":\"601587\/Organization\"},\"resourceType\":\"EpisodeOfCare\"}", "method": "POST", "url": "http:\/\/hapi.fhir.org\/baseDstu3\/EpisodeOfCare", "body": "{\"identifier\":[{\"system\":\"http:\/\/claimcdr.com\/claimid\",\"value\":\"SDF2-KMD3\"},{\"system\":\"http:\/\/claimcdr.com\/claimfolder\",\"value\":\"019ab685-ec64-416a-9dc4-2495ae75088b\"}],\"status\":\"active\",\"patient\":{\"reference\":\"1960729\/Patient\"},\"careManager\":{\"reference\":\"221712\/Practitioner\"},\"managingOrganization\":{\"reference\":\"601587\/Organization\"},\"resourceType\":\"EpisodeOfCare\"}" }, "error": { "size": 0, "timeout": 0 } }
Last updated: Apr 12 2022 at 19:14 UTC