beda-software / fhir-py

FHIR Client for python
MIT License
168 stars 31 forks source link

search: Add support for chained search #43

Closed ruscoder closed 4 years ago

ruscoder commented 4 years ago

GET /EpisodeOfCare?patient:Patient.name=Ivan

ruscoder commented 4 years ago

It can be something like .search(patient={'Patient.name': 'Ivan'}) or something else. Any ideas?

@mkizesov @ir4y

ir4y commented 4 years ago

We can keep using Django way for chaining.

.search(patient__Patient__name = Ivan)

What do you think?

ruscoder commented 4 years ago

FHIR specification also supports GET /EpisodeOfCare?patient.name=Ivan without specifying the target resource. But Aidbox requires the target resource type to be specified.

I like Django way more than I suggested. Let's implement it with the mandatory target resource type.

Some examples:

client.resources('EpisodeOfCare').search(patient__Patient__birth_date__gt='2010')
client.resources('EpisodeOfCare').search(patient__Patient__name='Ivan')
client.resources('EpisodeOfCare').search(patient__Patient__general_practitioner__Organization__name='Hospital')
ruscoder commented 4 years ago

There is only one disadvantage - too long kwarg name

ruscoder commented 4 years ago

Done in master branch