fhirbase-plv8 icon indicating copy to clipboard operation
fhirbase-plv8 copied to clipboard

Conditional update requires id in resource body

Open Andrzej-Pietrzak opened this issue 9 years ago • 5 comments

This operation can be used in pretty much two, maybe three use-cases:

  1. The client knows the id, maybe even knows the last version but wants to be even more sure that the last value of a property is equal to something. And this use-case is really far fetched.
  2. The client wants to create a resource with a unique value of a particular field
  3. The client just doesn't store the id

What do you think about enforcing the id to be equal with the record being updated only when there's a single result from the query and the id was actually provided ?

Samples:

SELECT fhir_create_resource('{"allowId": true, "resource": {"resourceType": "Patient","name": [{"given": ["Tim"]}], "id": "2222"}}'); SELECT fhir_create_resource('{"allowId": true, "resource": {"resourceType": "Patient","name": [{"given": ["Tim"], "family": ["Second"]}], "id": "3333"}}'); SELECT fhir_create_resource('{"allowId": true, "resource": {"resourceType": "Patient","name": [{"given": ["Walter"], "family": ["White"]}], "id": "4444"}}'); SELECT fhir_create_resource('{"allowId": true, "resource": {"resourceType": "Patient","name": [{"given": ["Ala"], "family": ["Blue"]}], "id": "9999"}}'); SELECT fhir_create_resource('{"allowId": true, "resource": {"resourceType": "Patient","name": [{"given": ["Dana"], "family": ["Scully"]}], "id": "8888"}}');

SELECT fhir_update_resource('{"ifNoneExist": "given=nonexisting", "resource": {"resourceType": "Patient", "name": [{"given": ["Gary"], "family": ["Muvout"]}]}}'); --nok, not created SELECT fhir_update_resource('{"ifNoneExist": "given=nonexisting", "resource": {"resourceType": "Patient", "id": "RuthGlouc", "name": [{"given": ["Ruth"], "family": ["Gloucester"]}]}}'); --ok, created with given id

SELECT fhir_update_resource('{"ifNoneExist": "given=Ala", "resource": {"resourceType": "Patient", "name": [{"given": ["Ola"], "family": ["Gray"]}]}}'); --nok, got 400 SELECT fhir_update_resource('{"ifNoneExist": "given=Walter", "resource": {"resourceType": "Patient", "id": "4444","name": [{"given": ["Walter"], "family": ["Black"]}]}}'); --ok, updated SELECT fhir_update_resource('{"ifNoneExist": "given=Dana", "resource": {"resourceType": "Patient", "id": "8888changedTo7777WhichShouldNotHappen","name": [{"given": ["Dana"], "family": ["Shultz"]}]}}'); --ok, updated did not happen SELECT fhir_read_resource('{"resourceType": "Patient", "id": "8888"}'); --ok SELECT fhir_read_resource('{"resourceType": "Patient", "id": "8888changedTo7777WhichShouldNotHappen"}'); -- ok, no res SELECT fhir_resource_history('{"resourceType": "Patient", "id": "8888"}'); --ok SELECT fhir_resource_history('{"resourceType": "Patient", "id": "8888changedTo7777WhichShouldNotHappen"}'); --ok, no res

SELECT fhir_update_resource('{"ifNoneExist": "given=Tim", "resource": {"resourceType": "Patient","name": [{"given": ["Andy"], "family": ["Green"]}]}}'); --nok, 412 expected, got 400 SELECT fhir_update_resource('{"ifNoneExist": "given=Tim", "resource": {"resourceType": "Patient", "id":"TimORange" ,"name": [{"given": ["Timothy"], "family": ["Orange"]}]}}'); --ok

Andrzej-Pietrzak avatar Jan 20 '16 10:01 Andrzej-Pietrzak

Still present in 1.3.0.11

SELECT fhir_create_resource('{"allowId": true, "resource": {"resourceType": "Patient","name": [{"given": ["Ala"], "family": ["Blue"]}], "id": "9999"}}'); SELECT fhir_update_resource('{"ifNoneExist": "given=Ala", "resource": {"resourceType": "Patient", "name": [{"given": ["Ola"], "family": ["Blue"]}]}}'); --nok, got 400 SELECT fhir_update_resource('{"ifNoneExist": "given=Ala", "resource": {"resourceType": "Patient", "name": [{"given": ["Ola"], "family": ["Blue"]}], "id": "9999"}}'); -- passes SELECT fhir_update_resource('{"ifNoneExist": "given=Ola", "resource": {"resourceType": "Patient", "name": [{"given": ["Ula"], "family": ["Blue"]}], "id": "someOtherId9999"}}'); --passes, no update, ignores the id provided by the user anyway

Andrzej-Pietrzak avatar May 04 '16 10:05 Andrzej-Pietrzak

What's the status on this issue ?

szymonp-kainos avatar Jun 06 '16 11:06 szymonp-kainos

@szymonp-kainos

What's the status on this issue ?

open

danil avatar Jun 06 '16 11:06 danil

I meant: is it in progress or not started or left for later ?

szymonp-kainos avatar Jun 06 '16 12:06 szymonp-kainos

Here's the relevant part of the FHIR spec: https://hl7-fhir.github.io/http.html#2.42.0.10.2. Basically, a client should be able to update a resource without knowing the server-assigned ID using this feature.

vadi2 avatar Oct 08 '16 03:10 vadi2