Open Andrzej-Pietrzak opened 8 years ago
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
What's the status on this issue ?
@szymonp-kainos
What's the status on this issue ?
open
I meant: is it in progress or not started or left for later ?
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.
This operation can be used in pretty much two, maybe three use-cases:
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