Avoiding duplicate resources

478 views
Skip to first unread message

Shlomy Reinstein

unread,
Mar 1, 2016, 8:18:13 AM3/1/16
to HAPI FHIR
Hi,

Is there a way to tell the FHIR server to avoid adding duplicate resources? We have a system that extracts clinical data from hospital systems, converts it to FHIR resources and adds them to the FHIR database. The system, in its current form, may read the very same data (e.g. lab tests, diagnostic reports) multiple times, but should not create duplicate resources. What is the suggested approach for that?

Of course, the system could fetch existing resources and compare them to the data it has read from the hospital systems, in order to avoid creating duplicate resources, but doing this for all the types of data is a lot of code. I hope there is generic mechanism for this in FHIR, such as telling the FHIR server to reject any "create" requests if a resource with the exact same data already exists - similar to the option in SQL to prevent adding a new row to a table if such a row already exists.

Thanks,
Shlomy

James Agnew

unread,
Mar 1, 2016, 12:32:57 PM3/1/16
to Shlomy Reinstein, HAPI FHIR
Hi Shlomy,

This is definitely possible. What you're looking for is "conditional create" and/or "conditional update": http://hl7.org/fhir/http.html#2.1.0.10.2

HAPI supports this function in client/server/jpa.

Cheers,
James

--
You received this message because you are subscribed to the Google Groups "HAPI FHIR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hapi-fhir+...@googlegroups.com.
To post to this group, send email to hapi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hapi-fhir/347e19e7-6776-4d38-8f5e-9df3e56a9aec%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Shlomy Reinstein

unread,
Mar 1, 2016, 1:03:13 PM3/1/16
to James Agnew, HAPI FHIR
Hi,

I am aware of the conditional create/update functionality, but to use this to prevent duplicate resources, I would need to include search parameters which cover the *entire data* of the resource. All I want is to prevent two resources having the exact same data (up to the resource id and version id) - corresponding to the way you tell an SQL database that a table should never have two rows with the same data in all columns.
Note: I am not looking for resources to update. I only want to either create a new resource (if a resource with the exact same data does not exist) or otherwise know that there's a resource with the exact same data so I can avoid the creation.

Thanks,
Shlomy

James Agnew

unread,
Mar 12, 2016, 3:26:16 PM3/12/16
to Shlomy Reinstein, HAPI FHIR
Hi Shlomy,

Ah ok, so if I understand correctly, you want to set the server up so that if you create (for example) a Patient on your server, then try to create a second patient with the exact same details it shouldn't create a duplicate?

FHIR doesn't have any mechanism for this really- I mean, in some circumstances I guess you could create a URL to match all the relevant information and then use a conditional create, but if you want to cover the entire resource contents you're right, conditional create wouldn't accomplish this.

I've been toying with the idea of allowing the server to be configurable to not process updates if the update is exactly the same as the previous version. In that case it would just return the same version number that already existed. It sounds to me like you're looking for the same thing but with create instead of update.

What kind of return from the server would you be looking for in the case that a duplicate was being rejected? Error? HTTP 200 with the ID of the existing resource? I guess Error is probably the safer option...

Cheers,
James

Shlomy Reinstein

unread,
Mar 13, 2016, 3:48:42 AM3/13/16
to James Agnew, HAPI FHIR
Hi,

Thanks for the reply! I would actually like to have that for both update and create. For update, there's the status code SC_NOT_MODIFIED (304). I don't know of a similar code that would be suitable for create, some error would be good.

Thanks,
Shlomy

mchrist...@gmail.com

unread,
Jun 22, 2017, 10:30:14 AM6/22/17
to HAPI FHIR, srei...@gmail.com

Did anything ever happen with this in terms of features in the HAPI FHIR code base? I find myself in a situation very similar to Schlomy's.

Cheers,
Michael

James Agnew

unread,
Jun 22, 2017, 11:14:18 AM6/22/17
to mchrist...@gmail.com, HAPI FHIR, Shlomy Reinstein
Hi Michael,

This feature is partially implemented. HAPI FHIR 2.5 is able to ignore updates which do not actually change anything. It will return a success (assuming this feature is enabled) but will return the same version number as the previous update.

There isn't yet any support on the create side though for duplicate checking (other than the existing conditional create functionality of course). I definitely still want to do this, but it's not yet scheduled (unless someone wants to volunteer of course :) )

Cheers,
James

To unsubscribe from this group and stop receiving emails from it, send an email to hapi-fhir+unsubscribe@googlegroups.com.

To post to this group, send email to hapi...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages