I am working with the fhirclient (Smart on FHIR) python library and have successfully created a bundle and individual resources. I would assume there are helper methods in the "Bundle" class to allow me to add a resource to a bundle but I can't quite seem to figure out how to do this. For example I have something like (pseudocode):
b = fhirclient.Bundle()
p = fhirclient.Patient()
c = fhirclient.Claim()
# Now I want to add my patient (p) and claim (c) to the bundle (b)
I thought since the bundle contains the list element "entry" that all I needed to do was append the resource like this:
b.entry.append(p)
b.entry.append(c)
But that doesn't work. I get the message: "AttributeError: 'NoneType' object has no attribute 'append'.
You'll want to create entries using a process like:
p_entry = BundleEntry()
p_entry.resource = p
c_entry = BundleEntry()
c_entry.resource = c
b.entry = [p_entry, c_entry]
import BundleEntry
as from fhirclient.models.bundle import BundleEntry