Question
· Feb 26, 2023

How can I know the patient id for a newly submitted Patient resource?

Hi folks!

Playing with InterSystems FHIR server. 

You can easily install it in IRIS for Health using FHIR template:

zpm "install fhir-server"

NB! For now the IPM command mentioned above works for a namespace called FHIRSERVER only.

I have a FHIR server in a local docker container with endpoint:

localhost:52773/fhir/r4

I send the following Patient resource as a POST request to localhost:52773/fhir/r4/Patient:

 
Spoiler

And I'm getting 201 and no result.

How could I know what is the id of the patient I've just created?

Product version: IRIS 2022.3
Discussion (14)4
Log in or sign up to continue

Indeed it is in the Location Header.

From the related FHIR docs:

The server returns a 201 Created HTTP status code, and SHALL also return a Location header which contains the new Logical Id and Version Id of the created resource version:

  Location: [base]/[type]/[id]/_history/[vid]

where [id] and [vid] are the newly created id and version id for the resource version. The Location header should be as specific as possible - if the server understands versioning, the version is included. If a server does not track versions, the Location header will just contain [base]/[type]/[id]. The Location MAY be an absolute or relative URL.

Hi @Lorenzo Scalese ! Yes! It is in Location header, as @Tani Frankel mentioned. 

This is what I received in headers:

http://localhost:52773/fhir/r4/Patient//1983/_history/1
So, the id is 1983.

It is a bit different from what the public FHIR server on hl7.org/fhir returns - it returns the id also in a response.

Not sure though what is the "standard" behavior but if find it convenient enough to have the id in the response.  

Another good way is to set the header :

Prefer: return=representation

The payload will be sent you back with the id.

Example :

POST http://localhost:33783/fhir/r4/Patient HTTP/1.1
Content-Type: application/json+fhir
Accept: application/json+fhir
Prefer: return=representation

{
  "resourceType": "Patient",
  "active": true,
  "name": [
    {
      "use": "official",
      "family": "Donald",
      "given": [
        "Duck"
      ]
    }
  ]
}

Response :

HTTP/1.1 201 Created
Date: Wed, 29 Mar 2023 12:13:40 GMT
Server: Apache
CACHE-CONTROL: no-cache
ETAG: W/"1"
EXPIRES: Thu, 29 Oct 1998 17:04:19 GMT
LAST-MODIFIED: Wed, 29 Mar 2023 12:13:40 GMT
LOCATION: http://localhost:33783/fhir/r4/Patient/2011/_history/1
PRAGMA: no-cache
CONTENT-LENGTH: 177
Connection: close
Content-Type: application/fhir+json; charset=UTF-8

{
  "resourceType": "Patient",
  "active": true,
  "name": [
    {
      "use": "official",
      "family": "Donald",
      "given": [
        "Duck"
      ]
    }
  ],
  "id": "2011",
  "meta": {
    "lastUpdated": "2023-03-29T12:13:40Z",
    "versionId": "1"
  }
}