2017-06-02 37 views
0

我正在使用fhirclient(Smart on FHIR)python庫,併成功創建了一個捆綁包和單個資源。我會假設在「Bundle」類中有幫助方法來允許我將一個資源添加到一個包中,但我似乎無法弄清楚如何做到這一點。比如我有類似的信息(僞):如何使用fhirclient(FHIR上的Smart)將資源添加到捆綁軟件?

b = fhirclient.Bundle() 
p = fhirclient.Patient() 
c = fhirclient.Claim() 
# Now I want to add my patient (p) and claim (c) to the bundle (b) 

我想既然套裝中包含列表元素「項」,所有我需要做的是添加這樣的資源:

b.entry.append(p) 
b.entry.append(c) 

但這是行不通的。我得到的消息:「AttributeError的:‘NoneType’對象有沒有屬性‘追加’

回答

1

你要創建使用流程是怎樣的條目:

p_entry = BundleEntry() 
p_entry.resource = p 
c_entry = BundleEntry() 
c_entry.resource = c 
b.entry = [p_entry, c_entry] 

使用from fhircilent.models.bundle import BundleEntry

+0

謝謝..工作很好。 – GregH

相關問題