When sending this request multiple times, I get multiple Patients created.
{
"resourceType": "Patient",
"identifier": [
{
"use": "usual",
"system": "urn:oid:2.16.840.1.113883.19.5",
"value": "12345"
}
],
"active": true,
"name": [
{
"family": "Levin",
"given": [
"Omri"
]
}
],
"gender": "male",
"birthDate": "1980-09-24"
}
My assumption is that when I provide the identifier
, it would reject the 2nd call, as that PAtient already exists. But seems that is not the case? How do I avoid these duplications?
(Tried it both on Azure and on Google cloud - both with the same result)
I had to dig deeper into the docs. And the answer is here - https://www.hl7.org/fhir/http.html#ccreate
In my case adding the header If-None-Exist: identifier=urn:oid:2.16.840.1.113883.19.5|12345
did the trick on Azure. On Google cloud, however, if trying to use V1 of the API we get an error for adding that header:
{
"issue": [
{
"code": "value",
"details": {
"text": "invalid_query"
},
"diagnostics": "conditional operations are not supported in API version v1",
"severity": "error"
}
],
"resourceType": "OperationOutcome"
}
To overcome that we need to use v1beta1
. So URL should change
- https://healthcare.googleapis.com/v1/projects/...
+ https://healthcare.googleapis.com/v1beta1/projects/...
Read more about the "v1" and "new v1beta1" difference here