Duplicate Resource/Data added in FHIR Repository
If I add the same patient data with a different unique ID then it inserts as new data using a POST request.
So, In the FHIR server How can I prevent this kind of thing by using POST requests?
Note:- I don't want to use a PUT request for the same. The main thing is I want to get a unique patient record.
Que:- Is there any way to check data duplication on each FHIR resource?
Thanks & Regards,
Harshdeep Acharya
Comments
Probably the best way to avoid these duplicate POSTs is to use conditional update.
The conditional update interaction allows a client to update an existing resource based on some identification criteria, rather than by logical id. To accomplish this, the client issues a PUT as shown:
PUT [base]/[type]?[search parameters]
When the server processes this update, it performs a search using its standard search facilities for the resource type, with the goal of resolving a single logical id for this request. The action it takes depends on how many matches are found:
- No matches, no id provided: The server creates the resource.
- No matches, id provided: The server treats the interaction as an Update as Create interaction (or rejects it, if it does not support Update as Create)
- One Match, no resource id provided OR (resource id provided and it matches the found resource): The server performs the update against the matching resource
- One Match, resource id provided but does not match resource found: The server returns a
400Bad Request error indicating the client id specification was a problem preferably with an OperationOutcome - Multiple matches: The server returns a
412Precondition Failed error indicating the client's criteria were not selective enough preferably with an OperationOutcome
You can read about this operation type here: https://www.hl7.org/fhir/http.html#update