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

Is search set by chained params supported? #10

Closed
saichint opened this issue Jan 22, 2021 · 9 comments
Closed

Is search set by chained params supported? #10

saichint opened this issue Jan 22, 2021 · 9 comments

Comments

@saichint
Copy link

Hi,
I am having some "Condition" resources where the condition.subject has Reference "identifier.value" which is 'abcd'.
I am trying to search by this "identifier" by doing
client.resources('Condition').search(subject__identifier='abcd')

The query sql is showing that it is searching by subject.id only (which seems to be the default) because client.resources('Condition').search(subject='abcd') does the same thing by searching for subject.id

However, I am able to do the search by identifier from the REST console of aidbox by doing
"GET /Condition?subject:identifier=abcd"

Since the fhir-py documentation says that the chained parameter search is supported, I expected this to work on aidbox-py as well but somehow that is not the case.

Is the support for chained parameter search not there in aidbox-py? If not, is there any workaround to do the searching to get results like the REST call above?

@ruscoder
Copy link
Member

Hello @saichint! You need to specify the target resource for Aidbox, e.g

client.search(subject__Patient__identifier='abcd')

@ruscoder
Copy link
Member

@ruscoder
Copy link
Member

It is because the target resource type can be ambiguous.

@ruscoder
Copy link
Member

Since FHIR supports chained search without specifying target resource type, I've created an issue beda-software/fhir-py#65

PR's are welcome

@saichint
Copy link
Author

saichint commented Jan 22, 2021

I tried client.search(subject__Condition__identifier='abcd')

This did not help.
What this is doing is that, it is sending this URL:
"GET /Condition?subject:Condition.identifier=abcd"
whereas what I need is:
"GET /Condition?subject:identifier=abcd"

The query sql in the 1st case is:

['SELECT * FROM (SELECT DISTINCT ON ("condition".id) "condition".* FROM "condition" INNER JOIN condition j_5ac8fbfa ON ("condition".resource @> ($JSON${"subject":{"id":"$JSON$ || j_5ac8fbfa.id || $JSON$","resourceType":"Condition"}}$JSON$)::jsonb) WHERE ("j_5ac8fbfa".resource @> ?) ) "condition" LIMIT ? OFFSET ?', '{"identifier":[{"value":"abcd"}]}', 100, 0]
and I got no results.

and in the 2nd case when it is working from REST console is:
['SELECT "condition".* FROM "condition" WHERE ("condition".resource @> ?) LIMIT ? OFFSET ? ', '{"subject":{"identifier":{"value":"abcd"}}}', 100, 0]

I know you closed this issue but the workaround what you suggested is not ok and I don't know how to solve this.

@mkizesov
Copy link
Contributor

Please try

client.search(subject__Patient__identifier='abcd')

if your subject is a Patient resource.

@saichint
Copy link
Author

saichint commented Jan 22, 2021 via email

@saichint
Copy link
Author

saichint commented Jan 22, 2021 via email

@mkizesov
Copy link
Contributor

Yep, we forgot to add resources('Condition') there.
so it could be client.resources('Condition').search(subject__Patient__identifier='abcd')
Where Patient is a resource type of the subject (according to FHIR a condition's subject could be either Patient or Group)

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

3 participants