fhirbase / fhirbase-plv8

[DEPRECATED] Fhirbase 2.0 is an FHIR relational storage
https://health-samurai.io/fhirbase
Other
105 stars 39 forks source link

Conditional update in transaction doesn't work correctly #126

Closed draakhan closed 8 years ago

draakhan commented 8 years ago

Hi!

1) No matches: The server performs a create interaction

SELECT fhir_truncate_storage('{"resourceType": "Patient"}');

SELECT fhir_transaction('{"resourceType":"Bundle","type":"transaction","entry":[{"resource":{"resourceType":"Patient","name":[{"given":["Ala"],"family":["Gray"]}]},"request":{"method":"PUT","url":"Patient?given=Ala"}}]}');
-[ RECORD 1 ]----+----------------------------------------------------------------------------------------------------------------------------------------
fhir_transaction | {"resourceType":"OperationOutcome","issue":[{"severity":"error","code":"422","diagnostics":"Invalid operation PUT Patient?given=Ala"}]}

2) One Match: The server performs the update against the matching resource

SELECT fhir_truncate_storage('{"resourceType": "Patient"}');
SELECT fhir_create_resource('{"allowId": true, "resource": {"resourceType": "Patient","name": [{"given": ["Ala"], "family": ["Blue"]}], "id": "9999"}}');

SELECT fhir_transaction('{"resourceType":"Bundle","type":"transaction","entry":[{"resource":{"resourceType":"Patient","name":[{"given":["Ala"],"family":["Gray"]}]},"request":{"method":"PUT","url":"Patient?given=Ala"}}]}');
-[ RECORD 1 ]----+----------------------------------------------------------------------------------------------------------------------------------------
fhir_transaction | {"resourceType":"OperationOutcome","issue":[{"severity":"error","code":"422","diagnostics":"Invalid operation PUT Patient?given=Ala"}]}

3) Multiple matches: The server returns a 412 Precondition Failed error indicating the client's criteria were not selective enough

SELECT fhir_truncate_storage('{"resourceType": "Patient"}');
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": ["Ala"], "family": ["Black"]}], "id": "9998"}}');

SELECT fhir_transaction('{"resourceType":"Bundle","type":"transaction","entry":[{"resource":{"resourceType":"Patient","name":[{"given":["Ala"],"family":["Gray"]}]},"request":{"method":"PUT","url":"Patient?given=Ala"}}]}');
-[ RECORD 1 ]----+----------------------------------------------------------------------------------------------------------------------------------------
fhir_transaction | {"resourceType":"OperationOutcome","issue":[{"severity":"error","code":"422","diagnostics":"Invalid operation PUT Patient?given=Ala"}]}
danil commented 8 years ago

@draakhan fixed in v1.3.0.24 https://github.com/fhirbase/fhirbase-plv8/blob/v1.3.0.24/test/fhir/transaction_spec.coffee#L104 if not, feel free to reopen