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

API include / revinclude functionality

Open boxysean opened this issue 8 years ago • 3 comments

I couldn't find anything in the library mapping to the API capability of _include or _revinclude.

For example, on the UHN test server, I can run the following query to get all Compositions and their corresponding Patients: http://fhirtest.uhn.ca/baseDstu2/Composition?_include=Composition:patient

Should the library support this notion?

boxysean avatar Apr 14 '16 14:04 boxysean

You mean you'd like to have a way to specify _include and _revinclude? That is certainly a good idea and I'm open to suggestions!

On a related note, resolving references within a Bundle is not yet supported. This is definitely something we want to add to FHIRReference (which hails from fhir-parser).

p2 avatar Apr 14 '16 15:04 p2

Ah, so supporting the resolution of references within a Bundle could possibly give the client user the ability to specify which related references they would like to access when they make their initial queries.

For example, maybe a syntax that would be nice to support could be this:

p = Patient.where({'id': '1000'}).include(Observation)
for observation in p.observations:
    print observation

Then the references are pre-fetched with a single API call with an _include queryparam, and can be naturally accessed within the application.

boxysean avatar Apr 14 '16 16:04 boxysean

The Resource.where() method returns a FHIRSearch instance. Yes, would be feasible to add an include() method to that class to support this notion, then one could call perform(server) to execute the search. 👍🏼

p2 avatar Apr 17 '16 19:04 p2