Skip to content

Chained search by id does not discriminate resource type #174

@Andrzej-Pietrzak

Description

@Andrzej-Pietrzak

There seems to be a difference between how the 'regular' search syntax and the 'chained' syntax handles references that can contain different resource types.
e.g.:
Given Patient.generalpractitioner field that can contain references to Organizations or Practitioners, searching for Patients with certain Practitioner/Organization reference gives different results for different syntax:

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

SELECT fhir_create_resource('{"allowId":true,"resource":{"resourceType":"Organization","id":"f001","identifier":[{"use":"official","system":"systm1","value":"91654"},{"use":"usual","system":"systm1","value":"17-0112278"}],"type":{"coding":[{"system":"systm1","code":"V6","display":"University Medical Hospital"},{"system":"http://hl7.org/fhir/organization-type","code":"prov","display":"Healthcare Provider"}]},"name":"Burgers University Medical Center","telecom":[{"system":"phone","value":"022-655 2300","use":"work"}],"address":[{"use":"work","line":["Galapagosweg 91"],"city":"Den Burg","postalCode":"9105 PZ","country":"NLD"},{"use":"work","line":["PO Box 2311"],"city":"Den Burg","postalCode":"9100 AA","country":"NLD"}],"contact":[{"purpose":{"coding":[{"system":"http://hl7.org/fhir/contactentity-type","code":"PRESS"}]},"telecom":[{"system":"phone","value":"022-655 2334"}]},{"purpose":{"coding":[{"system":"http://hl7.org/fhir/contactentity-type","code":"PATINF"}]},"telecom":[{"system":"phone","value":"022-655 2335"}]}]}}');
SELECT fhir_create_resource('{"allowId":true,"resource":{"resourceType":"Organization","id":"f002","identifier":[{"use":"official","system":"systm2","value":"3125"},{"use":"usual","system":"systm2","value":"17321"}],"type":{"coding":[{"system":"systm1","code":"V6","display":"University Medical Hospital"},{"system":"http://hl7.org/fhir/organization-type","code":"prov","display":"Healthcare Provider"}]},"name":"Burgers University Medical Center","telecom":[{"system":"phone","value":"022-655 2300","use":"work"}],"address":[{"use":"work","line":["Galapagosweg 91"],"city":"Den Burg","postalCode":"9105 PZ","country":"NLD"},{"use":"work","line":["PO Box 2311"],"city":"Den Burg","postalCode":"9100 AA","country":"NLD"}],"contact":[{"purpose":{"coding":[{"system":"http://hl7.org/fhir/contactentity-type","code":"PRESS"}]},"telecom":[{"system":"phone","value":"022-655 2334"}]},{"purpose":{"coding":[{"system":"http://hl7.org/fhir/contactentity-type","code":"PATINF"}]},"telecom":[{"system":"phone","value":"022-655 6666"}]}]}}');
SELECT fhir_create_resource('{"allowId":true,"resource":{"resourceType":"Practitioner","id":"f001","identifier":[{"use":"official","system":"urn:oid:2.16.528.1.1007.3.1","value":"91654"},{"use":"usual","system":"urn:oid:2.16.840.1.113883.2.4.6.3","value":"129IDH4OP733"}],"name":{"use":"official","family":["van den broek"],"given":["Eric"],"suffix":["MD"]},"telecom":[{"system":"phone","value":"0205568263","use":"work"},{"system":"email","value":"E.M.vandenbroek@bmctest.nl","use":"work"},{"system":"fax","value":"0205664440","use":"work"}],"address":[{"use":"work","line":["Galapagosweg 91"],"city":"Den Burg","postalCode":"9105 PZ","country":"NLD"}],"gender":"male","birthDate":"1975-12-07","practitionerRole":[{"managingOrganization":{"reference":"Organization/f001","display":"BMC"},"role":{"coding":[{"system":"urn:oid:2.16.840.1.113883.2.4.15.111","code":"01.000","display":"Arts"}],"text":"Care role"},"specialty":[{"coding":[{"system":"urn:oid:2.16.840.1.113883.2.4.15.111","code":"01.018","display":"Ear-, Nose and Throat"}],"text":"specialization"}]}]}}');

SELECT fhir_create_resource('{"allowId":true,"resource":{"id":"RitaGunn","name":[{"use":"official","given":["Rita"],"family":["Gunn"]}],"active":true,"generalPractitioner":[{"reference":"Practitioner/f001","display":"DocEric-Practitioner1"},{"reference":"Organization/f001","display":"Burgers-Organization1"}],"resourceType":"Patient"}}');
SELECT fhir_create_resource('{"allowId":true,"resource":{"id":"JamesDean","name":[{"use":"official","given":["James"],"family":["Dean"]}],"active":true,"generalPractitioner":[{"reference":"Organization/f001","display":"Burgers-Organization1"}],"resourceType":"Patient"}}');
SELECT fhir_create_resource('{"allowId":true,"resource":{"id":"MarkBlackstone","name":[{"use":"official","given":["Mark"],"family":["Blackstone"]}],"active":true,"generalPractitioner":[{"reference":"Organization/f002","display":"Burgers-Organization2"}],"resourceType":"Patient"}}');
SELECT fhir_create_resource('{"allowId":true,"resource":{"id":"DaveChappele","name":[{"use":"official","given":["David"],"family":["Chappele"]}],"active":true,"resourceType":"Patient"}}');

-- by any property:
SELECT fhir_search('{"resourceType": "Patient", "queryString": "general-practitioner:Organization.identifier=91654"}'); -- ok, got both patients
SELECT fhir_search('{"resourceType": "Patient", "queryString": "general-practitioner:Practitioner.identifier=91654"}'); -- ok, got only Rita

-- by id:
SELECT fhir_search('{"resourceType": "Patient", "queryString": "general-practitioner:Practitioner=f001"}'); -- nok, got both, expecting only Rita
SELECT fhir_search('{"resourceType": "Patient", "queryString": "general-practitioner:Organization=f001"}'); -- ok, got both 
-- comparing to regular syntax:
SELECT fhir_search('{"resourceType": "Patient", "queryString": "general-practitioner=Practitioner/f001"}'); -- ok, 1 patient
SELECT fhir_search('{"resourceType": "Patient", "queryString": "general-practitioner=Organization/f001"}'); -- ok, both patients

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions