fhir-py icon indicating copy to clipboard operation
fhir-py copied to clipboard

Add better support for related resources via include/revinclude

Open ruscoder opened this issue 6 years ago • 1 comments

When we use revinclude or include we have a bundle with multiple types of resources, but fetch/fetch_all returns only main resource.

We can add fetch_raw/fetch_all_raw that should always return a dict with fetched resources.

Example:

client.resources('Schedule').revinclude('Slot', 'schedule').fetch_all_raw()

returns

{'Slot': [SlotResource, SlotResource, ...],
'Schedule': [ScheduleResource, ScheduleResource, ...],}

And

client.resources('Schedule').fetch_all_raw()

returns

{'Schedule': [ScheduleResource, ScheduleResource, ...],}

TBD

ruscoder avatar Mar 15 '19 06:03 ruscoder

We can also change revinclude/include behaviour for this purposes, for example, if we use include after fetch/fetch_all we should have a list of main resources but with already resolved resources into the particular fields. For example:

client.resources('Patient').include('Practitioner', 'generalPractitioner', include=True)

should return

[PatientResource, PatientResource...]

Where PatientResource.generalPractitioner[x] is a related Practitioner resource.

An the same for revinclude:

# Here we pass name inside resource where we want to include them
client.resources('Schedule').revinclude('Slot', 'schedule', include='slots')

should return

[ScheduleResource, ScheduleResource...]

Where ScheduleResource.slots is a list of related Slots

TBD

ruscoder avatar Mar 15 '19 06:03 ruscoder