Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search modification prefixes applied on wrong types #172

Open
Andrzej-Pietrzak opened this issue Mar 3, 2017 · 0 comments
Open

Search modification prefixes applied on wrong types #172

Andrzej-Pietrzak opened this issue Mar 3, 2017 · 0 comments

Comments

@Andrzej-Pietrzak
Copy link

Andrzej-Pietrzak commented Mar 3, 2017

When running code and reference searches the search prefixes are actually applied and that will cause search errors depending on data.
Fhir user would expect these to be applied only for numbers, dates and quantities:
http://hl7.org/fhir/2017Jan/search.html#prefix

References:
Currently when searching for observations assigned to patient eb038cc0-920b-4bca-b938-9c49f0fbc163

SELECT fhir_create_resource('{"allowId": true, "resource": {"id":"eb038cc0-920b-4bca-b938-9c49f0fbc163","name":[{"use":"official","given":["Peyton"],"family":["O''Reilly"]}],"active":true,"gender":"female","address":[{"use":"home","city":"Reilly Stadtt","line":["6385 Barney Branch"],"type":"both","country":"United Kingdom","district":"Berkshire","postalCode":"03539"}],"telecom":[{"use":"home","value":"(558) 317-1070","system":"phone"},{"use":"work","value":"1-576-209-7995","system":"phone"},{"use":"mobile","value":"(811) 678-1351 x8769","system":"phone"},{"use":"home","value":"fake-Peyton-O'[email protected]","system":"email"}],"birthDate":"1984-05-21","identifier":[{"use":"official","value":"787418","system":"Hospital Number"},{"use":"official","value":"6340121235","system":"NHS Number"}],"resourceType":"Patient","managingOrganization":{"display":"sapiente ex","reference":"Organization/7ffa9ca8-2221-4733-a4e9-1f0b9ea7eb23"}}}');
SELECT fhir_create_resource('{"allowId": true, "resource": {"id":"2124bdea-d0b0-4673-9f26-d0d5574ed278","code":{"coding":[{"code":"eb1234","system":"CUSTOM1","display":"Testing codings with operators handling"}]},"status":"final","subject":{"reference":"Patient/eb038cc0-920b-4bca-b938-9c49f0fbc163"},"component":[{"code":{"coding":[{"code":"8480-6","system":"MiG2","display":"Systolic blood pressure"}]},"valueQuantity":{"unit":"mm[Hg]","value":154}},{"code":{"coding":[{"code":"8462-4","system":"MiG2","display":"Diastolic blood pressure"}]},"valueQuantity":{"unit":"mm[Hg]","value":76}}],"resourceType":"Observation","effectiveDateTime":"2008-12-05T19:54:07.848Z"}}');

Using 'patient' search parameter might be confusing as it points to a single resource type and accepts queries with id only yet for a search for certain id's (and notice this one is a valid uuid) we'll get no results because of the pre processing:

SELECT fhir_search_sql('{"resourceType": "Observation", "queryString": "patient=eb038cc0-920b-4bca-b938-9c49f0fbc163"}');
---
["SELECT * FROM \"observation\" tbl1 WHERE ( fhir_extract_as_reference( ( \"tbl1\".\"resource\" )::json , ( '[\"Observation\",\"subject\"]' )::json , 'Reference' ) )::text[] && ( ARRAY[ $1 ] )::text[] LIMIT $2","038cc0-920b-4bca-b938-9c49f0fbc163",10]

It would be best to either not apply the modification at all to reference type or force the users to set the whole reference in search as Type/id. There already has been a similar issue: #162

Code:
Same processing is done, this on the other hand will cause certain code searches to fail. What is the reason to actually apply this modification on codes ?

SELECT fhir_search('{"resourceType": "Observation", "queryString": "code=eb-123"}'); --ok
SELECT fhir_search('{"resourceType": "Observation", "queryString": "code=ebtest1"}'); --ok
SELECT fhir_search('{"resourceType": "Observation", "queryString": "code=eb123"}'); --error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant