FHIR Error Responses - finding helpful info in them

Hello,

I use the fhir.js library to send CRUD requests to a fhir server hosted by fhirtest.uhn.ca and I’m finding that when I get an error response, the response object has a ton of data (keys ,properties, nested information) but this information says nothing about what actually went wrong (e.g. wrong date format supplied for DOB on patient resource).

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!!

Questions

  1. Any idea how fhirtest.uhn is getting these more informative error responses?
  2. Where to look on the response for helpful information?

Attempts to Solve

  • I’ve tried manually sorting through its various properties using
for (var key in response) { console.log('key', response[key]) }
// status headers config errors

and then i’ll take individual keys in drill down on them even further to see if I find anything useful. Pretty sure I checked response.data response.body too. I guess I could recursively log the entire thing but I’ve done so much research and still haven’t found anything useful.

  • HAPI FHIR documentation.
    I’ve dug through documentation on fhir.hl7 and HAPI and even browsed through the java source code (huge codebase and I was unable to find exactly how the errors were thrown).

  • If I use fhirtest.uhn.ca’s UI here and click CareTeam > CRUD > paste in the req.body (i.e. fhir resource for CareTeam) and click Submit, the response actually has much more helpful data (e.g. ‘ID for practitioner being referenced not found’).

  • checked https://www.hl7.org/fhir/

  • searched ‘error’ ‘error handling’ on community.fhir.org forum.

Thanks,
Will