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

Add fetch_raw_all support #96

Open
ruscoder opened this issue Jan 4, 2023 · 3 comments
Open

Add fetch_raw_all support #96

ruscoder opened this issue Jan 4, 2023 · 3 comments

Comments

@ruscoder
Copy link
Member

ruscoder commented Jan 4, 2023

Currently, it's impossible to have the same behavior for fetch_raw as we have for fetch_all.

@ruscoder
Copy link
Member Author

ruscoder commented Mar 17, 2023

We already have __iter__/__aiter__ implemented and fetch/fetch_all uses it.

I suggest to rename __iter__/__aiter__ to .iterator()/.aiterator(), and re-use it in __iter__/__aiter__. And in addition, I suggest adding.raw_iterator()/.raw_aiterator() methods that will return iterators similar to fetch_raw. And then add fetch_all_raw that just invokes the iterator and concatenates Bundle.entry.

This logic will give an ability to paginate over resources/raw resources easily, e.g.

ss_iter = client.resources("Patient").limit(5).iterator()
first_chunk = next(ss_iter)
second_chunk = next(ss_iter)
ss_raw_iter = client.resources("Patient").limit(5).raw_iterator()
first_raw_chunk = next(ss_raw_iter)
second_raw_chunk = next(ss_raw_iter)

@ruscoder
Copy link
Member Author

ruscoder commented Aug 2, 2024

fetch_raw has issues with typing model #126, because it might contain multiple resources returned.
Unfortunately, it does implicit transformation into resources

    def fetch_raw(self) -> Any:
        ...
        if data_resource_type == "Bundle":
            for item in data["entry"]:
                item.resource = self._dict_to_resource(item.resource)

        return data

so, if we have Patient resources with included Practitioners, the output will be Bundle with resources as Patients and SyncFHIRResource/AsyncFHIRResource for included resources

@ir4y
Copy link
Member

ir4y commented Aug 3, 2024

The whole idea behind fetch_raw is not to provide an iterator and just return a Bundle resource as it is.
The naming could be improve to make It more obvious.

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

2 participants