lifeomic / phc-sdk-py

The phc-sdk-py is a developer kit for interfacing with the PHC API on Python 3.8 and above.
https://lifeomic.github.io/phc-sdk-py/index.html
MIT License
1 stars 2 forks source link

Add chunking params to stay under ES term limit #157

Closed rcdilorenzo closed 3 years ago

rcdilorenzo commented 3 years ago

It just works.™️

You can pass in "limitless" values to parameters like ids, patient_ids, and values to term/terms and the SDK will auto-issue multiple requests if the counts exceed the max_terms value.

Here's an example that executes two requests (obviously contrived since the default is max_terms=30_000):

phc.Person.get_data_frame(terms=[
    {"identifier.value": ["myuser1", "myuser2"]}
], max_terms=1)

Likewise, the existing parameters like ids and patient_ids operate the same way:

phc.Patient.get_data_frame(ids=[
    "2f1ac917-0dbd-49ea-9045-d712203795ac",
    "527ad8d5-ad3d-4f92-94ee-db2730f033b5",
    "e19db662-5baf-4925-9ae8-a46ba7b11a2f"
], max_terms=2)