smart-on-fhir / client-py

Python SMART on FHIR client
http://docs.smarthealthit.org
Other
574 stars 209 forks source link

How to make use of meta.lastUpdated to get a list of patients that were updated after a certain timestamp ? #136

Closed anmolbhatia05 closed 1 year ago

anmolbhatia05 commented 1 year ago

I am using fhirclient v4.1.0.

I am trying to get a list of partients that are active and whose entry in the fhir server was updated after a given timestamp. The documentation unfortunately doesn't mention how to use the meta data in the search queries, but, I looked at the tests the creator of the library wrote - https://github.com/smart-on-fhir/client-py/blob/master/fhir-parser-resources/fhirsearch_tests.py#L22 And thus the following code -

import fhirclient.models.patient as p
search_patients = p.Patient.where(
                    struct={
                        "active": "True",
                        "meta.lastUpdated": {"$gt": "2020-07-15T02:52:00"},
                    }
                )
patients = search_patients.perform_resources(client.server)

The above mentioned code gives me requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://api.logicahealth.org/{sandbox_indentifier}/open/Patient?active=True&meta.lastUpdated=%3E2020-07-15T02%3A52%3A00.

Any idea what I am missing ?

Thank you in advance.

anmolbhatia05 commented 1 year ago

I asked the question here - https://groups.google.com/g/smart-on-fhir

Someone kindly pointed out that, I should use _lastUpdated (ref - https://groups.google.com/g/smart-on-fhir)