/
FHIR resource operations - tricks

FHIR resource operations - tricks

Table Of Contents

 

 

All the cases presented here can be seen as an example in this POSTMAN collection.

 

Forget me

When Patients want to remove their data from our system, we are NOT going to DELETE the registry from our databases. The main goal in these cases is to preserve the analytics information but remove sensitive data or data which can identify the patient. So, to do that, we will update the patient data leaving empty information like name, surname, or telecom, and of course, we will set active=false to indicate this patient is not active.

NoCache

The HAPI FHIR server has a configured cache of 1 minute when the same GET requests are made. That is if the same resource is queried twice in less than a minute and this resource changes between both queries, the second query will show the same information as the first query, which is not ideal.

Use case: Patient Registration and verification:

  1. A query is made to see if there is a patient with a specific phone number.

  2. If there is not, the patient with this telephone number is created.

  3. The same query is made by telephone to confirm that it has been created correctly.

Expected result: the information of the patient created.
Reality: The patient does not exist.

To avoid this in all queries (Patients, CommunicationRequests, QuesttionaireResponse...) the following property must be added in the request headers:

Cache-Control: no-cache

Patch

PUT requests in HAPI FHIR to update a resource require all the information of this resource in the payload.
That is, if we only want to modify the name of a patient, the payload to be sent will be all the patient's information modifying only the name. If only the name is sent, the rest of the patient's data will be deleted.

To send only the name, we must use the resource PATCH. You can see in postman an example in patient and also in QuestionnaireResponse.

 

Last Record for a resource

 

PHONE + SecretKey

Some projects have the concept of a private key associated with a telephone.
This usually happens when a patient does not have a phone and uses someone else's phone.
To confirm that these people are who they say they are, they are also asked for a secret key.

To address this problem in a patient resource it is done in the following way:

  • The phone number of this person is saved as the identifier.

  • In telecom, you store the phone number and the secret key separated by a colon {{phone}}:{{secretKey}}.

Initially this information would only be stored in telecom, but HAPI FHIR does not allow to search by telecom for a substring, so we were forced to use the identifier to store the phone.

This case will be uncommon, but as a doubt or question is, what happens if some patient creates the same secret key?

Related content