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

Bundle entry #105

Open
dennisbrox opened this issue Jun 20, 2022 · 6 comments
Open

Bundle entry #105

dennisbrox opened this issue Jun 20, 2022 · 6 comments

Comments

@dennisbrox
Copy link

  • fhir.resources version:
  • Python version:
  • Operating System:

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
Copy link
Author

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
Copy link
Owner

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

@dennisbrox
Copy link
Author

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
Copy link
Author

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
Copy link
Owner

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

@nazrulworld
Copy link
Owner

@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.

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