fhirbase / fhirbase-plv8

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

Instance history _since param bypases resource id #146

Closed Andrzej-Pietrzak closed 7 years ago

Andrzej-Pietrzak commented 8 years ago
SELECT fhir_truncate_storage('{"resourceType": "Patient"}');
SELECT fhir_create_resource('{"resource": {"resourceType": "Patient", "name": [{"family": ["asdf"]}] }}');
SELECT fhir_create_resource('{"resource": {"resourceType": "Patient", "name": [{"family": ["asdf"]}] }}');
SELECT fhir_create_resource('{"resource": {"resourceType": "Patient", "name": [{"family": ["asdf"]}] }}');
SELECT fhir_create_resource('{"resource": {"resourceType": "Patient", "name": [{"family": ["asdf"]}] }}');
SELECT fhir_create_resource('{"resource": {"resourceType": "Patient", "name": [{"family": ["asdf"]}] }}');

SELECT fhir_create_resource('{"allowId": true, "resource": {"resourceType": "Patient", "id": "id1", "name": [{"family": ["First"]}] }}');
SELECT fhir_update_resource('{"resource":  {"resourceType": "Patient", "id": "id1", "name": [{"family": ["Second"]}] }}');
SELECT fhir_update_resource('{"resource":  {"resourceType": "Patient", "id": "id1", "name": [{"family": ["Third"]}] }}');
SELECT fhir_create_resource('{"allowId": true, "resource": {"resourceType": "Patient", "id": "id2", "name": [{"family": ["Alfa"]}] }}');
SELECT fhir_update_resource('{"resource":  {"resourceType": "Patient", "id": "id2", "name": [{"family": ["Beta"]}] }}');
SELECT fhir_update_resource('{"resource":  {"resourceType": "Patient", "id": "id2", "name": [{"family": ["Gamma"]}] }}');
SELECT fhir_resource_history('{"resourceType": "Patient", "id": "id1", "queryString": "_since=2015-07-15"}'); -- nok, got 11 results, expected 3

Instance history works fine:

SELECT fhir_resource_history('{"resourceType": "Patient", "id": "id1"}'); -- ok, 3 results

for extracted last updated dates for id1: '0' => "2016-07-18T08:45:38.890Z" '1' => "2016-07-18T08:45:32.488Z" '2' => "2016-07-18T08:45:26.118Z"

Unfortunately when providing _since param the id is ignored:

SELECT fhir_resource_history('{"resourceType": "Patient", "id": "id1", "queryString": "_since=2016-07-18T08:45:32.488Z"}'); -- nok, 4 results - id1, id2, id2, id2

SELECT fhir_resource_history('{"resourceType": "Patient", "id": "id1", "queryString": "_since=2016-07-17"}'); -- nok, 11 results
manuso commented 7 years ago

patient history queries return other patients history if someone adds a _since parameter