Question

According to the specification here, if you create a resource the server should return a 201 created along with a Location header which contains the new Logical Id and Version Id of the created resource.

I am uploading a patient resource to http://fhir.healthintersections.com.au/open/Patient and using the Chrome debug tools I can see that a 'Content-Location' response header is returned that contains the Logical ID but I cannot access this using jqXHR.getResponseHeader('Content-Location') or jqXHR.getAllResponseHeaders().

After much searching, the problem seems to be that unless the Access-Control-Expose-Headers header is added to server, I can't view the header within my application as it is a cross origin request.

Is there another way around this problem so I can find the logical ID after creation of a resource?

Was it helpful?

Solution

FHIR exposes it's metadata (id, version specific id, last updated) only in the headers, so you really need to get to that Location header to get a newly created resource's id. There might be a work-around, which is using the "search" operation to retrieve a feed with only this newly created resource (assuming it has identifying business keys like patient id). The resource's atom entry will have an with the id.

That said, that's truly a hack. This is not a FHIR related issue however (see for example How to get responseheader location by jquery).

To fix this problem, I'll update my FHIR server (at spark.furore.com/fhir) to include these Access-Control-Expose headers. It should be updated in the next few hours, so you can try whether that works for you.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top