nazrulworld / fhir.resources

FHIR Resources https://www.hl7.org/fhir/resourcelist.html
https://pypi.org/project/fhir.resources/
Other
365 stars 104 forks source link

Bundle entry #105

Open dennisbrox opened 2 years ago

dennisbrox commented 2 years ago

Description

Describe what you were trying to get done. Tell us what happened, what went wrong, and what you expected to happen.

What I Did

Paste the command(s) you ran and the output.
If there was a crash, please include the traceback here.
dennisbrox commented 2 years ago

fhir.resources version 6.4, python 3.10.1, Win 10 I've been trying to add a list of resources to bundle.entry with bundle .type = 'collection' and nothing works. That is: BundleEntry.resource won't let me assign a person resource, bundle.entry doesn't allow append. No problem doing this in C# but the python validation is confusing. What is the exact syntax for adding 2 observations, say obs1 and obs2 to the bundle entry field? Thanks.

nazrulworld commented 2 years ago

@dennisbrox can you please give us your code example? (maybe a gist link or directly past here)

dennisbrox commented 2 years ago

Some of a few things I've tried:

from fhir.resources.bundle import Bundle from fhir.resources.bundle import BundleEntry from fhir.resources.person import Person . . . bundle = Bundle.construct() p = Person.construct()

assign p attribute values

. . . bundle.type = "collection" be = BundleEntry.construct()

bundle.entry.append(be) - doesn't work, no append method, equivalent works in C# as it knows entry is a list bundle.entry = [be] - works , no error at runtime bundle.entry = [p] - validation error of course

and be.resource = p - doesn't work, resource attribute doesn't exist even if it is in the BundleEntry class be = p - doesn't give an exception but bundle.entry = [be] does not validate of course

problem is to create a list of resources to assign to bundle.entry

dennisbrox commented 2 years ago

It works in fhirclient the way it's supposed to. Slightly different syntax between fhir.resources and fhirclient of course. p_entry = BundleEntry() p_entry.resource = p c_entry = BundleEntry() c_entry.resource = c b.entry = [p_entry, c_entry]

So both fhirclient and firely in C# work the way they are supposed to. If fhir.resources doesn't work, it would be useful to be warned of that in github.

nazrulworld commented 2 years ago

@dennisbrox thanks for your update. I am extremely busy these days, will look at this soon as possible.

nazrulworld commented 2 years ago

@dennisbrox I got some time to check your statements. Here are my results.

  1. "bundle.entry.append(be) - doesn't work, no append method, equivalent works in C# as it knows entry is a list": that is true and wanted feature. we are open to accept any PR.
  2. "be.resource = p - doesn't work, resource attribute doesn't exist even if it is in the BundleEntry class" I see it's working for me.
  3. "be = p - doesn't give an exception but bundle.entry = [be] does not validate of course" I can validation exception.
  4. """It works in fhirclient the way it's supposed to. Slightly different syntax between fhir.resources and fhirclient of course. p_entry = BundleEntry() p_entry.resource = p c_entry = BundleEntry() c_entry.resource = c b.entry = [p_entry, c_entry]""" I see working for me!

I would suggest, you could create a python file and create your failed (except no. 1) examples and share here.