我正在使用 fhirclient 库“3.2.0”,我需要使用 FHIR NutritionIntake 资源。我的理解是它不可用,因为我在“fhirclient.models”下找不到。如果我错了,请纠正我。
我解决上述问题的尝试是实现“class NutritionIntake(DomainResource)”。到目前为止,我实施的内容如下。我遇到的问题是,在测试包含“consumedItem”的输入时,如下所示,得到以下错误:
请问您能就如何解决它提出任何帮助吗?
非常感谢,卡罗
错误:
fhirclient.models.fhirabstractbase.FHIRValidationError: {root}:
0x000002A536742C70> <fhirclient.models.backboneelement.BackboneElement object at 0x000002A536742C70> data for <fhirclient.models.backboneelement.BackboneElement.BackboneElement object at 0x000002A536742C70 > 多余条目“ amount ”中的数据中的多余条目“ NutritionProduct” <fhirclient.models.backboneelement.BackboneElement object at 0x000002A536742C70> 的数据 <fhirclient.models.backboneelement.BackboneElement object at 0x000002A536742C70> 的数据中的多余条目“ schedule ”
输入
"consumedItem": [ { "type": { "coding": [ { "system": "http://loinc.org", "code": "9108-2", "display": "Fluid intake total 24 hour" }, { "system": "http://snomed.info/sct", "code": "11713004", "display": "Water" } ], "text": "Water" }, "schedule": { "event": "2020-04-03T15:30:10+01:00" }, "nutritionProduct": { "text": "Water" }, "amount": { "value": 250, "unit": "ml", "system": "http://unitsofmeasure.org" } } ]
Python代码
从 fhirclient.models 导入 fhirreference、标识符、可编码概念、从 fhirclient.models.domainresource 导入 DomainResource 从 fhirclient.models.nutritionorder 导入 NutritionOrderSupplement、NutritionOrderOralDiet、
NutritionOrderEnteralFormula
从 fhirclient.models 导入骨干元素 从 fhirclient.models 导入注释
class NutritionIntake(DomainResource): """ 饮食、配方或营养补充请求。
A request to supply a diet, formula feeding (enteral) or oral nutritional
supplement to a patient/resident.
"""
resource_type = "NutritionIntake"
def __init__(self, jsondict=None, strict=True):
""" Initialize all valid properties.
:raises: FHIRValidationError on validation errors, unless strict is False
:param dict jsondict: A JSON dictionary to use for initialization
:param bool strict: If True (the default), invalid variables will raise a TypeError
"""
self.identifier = None
self.basedOn = None
self.partOf = None
self.status = None
self.statusReason = None
self.category = None
self.consumedItem = None
self.ingredientLabel = None
self.subject = None
self.encounter = None
self.effective = None
self.dataAsserted = None
self.informationSource = None
self.derivedFrom = None
self.reasonCode = None
self.note = None
super(NutritionIntake, self).__init__(jsondict=jsondict, strict=strict)
def elementProperties(self):
js = super(NutritionIntake, self).elementProperties()
print("jsjsjsjsjjssjsjsjsjsj ", type(js))
print(js)
js.extend([
("identifier", "identifier", identifier.Identifier, True, None, False),
("basedOn", "basedOn", fhirreference.FHIRReference, True, None, False),
("partOf", "partOf", fhirreference.FHIRReference, True, None, False),
("status", "status", str, False, None, False),
("statusReason", "statusReason", codeableconcept.CodeableConcept, False, None, False),
("category", "category", codeableconcept.CodeableConcept, False, None, False),
("consumedItem", "consumedItem", backboneelement.BackboneElement, True, None, False),
("ingredientLabel", "ingredientLabel", backboneelement.BackboneElement, False, None, False),
("subject", "subject", fhirreference.FHIRReference, False, None, False),
("encounter", "encounter", fhirreference.FHIRReference, False, None, False),
("effective", "effective", fhirreference.FHIRReference, False, None, False),
("dataAsserted", "dataAsserted", fhirdate.FHIRDate, False, None, False),
("informationSource", "informationSource", fhirreference.FHIRReference, False, None, False),
("derivedFrom", "informationSource", fhirdate.FHIRDate, False, None, False),
("reasonCode", "reasonCode", codeableconcept.CodeableConcept, False, None, False),
("note", "note", annotation.Annotation, False, None, False),
("type", "type", codeableconcept.CodeableConcept, True, None, False),
("nutritionProduct", "nutritionProduct", codeableconcept.CodeableConcept, True, None, False)
# ("allergyIntolerance", "allergyIntolerance", fhirreference.FHIRReference, True, None, False),
# ("dateTime", "dateTime", fhirdate.FHIRDate, False, None, True),
# ("encounter", "encounter", fhirreference.FHIRReference, False, None, False),
# ("enteralFormula", "enteralFormula", NutritionOrderEnteralFormula, False, None, False),
# ("excludeFoodModifier", "excludeFoodModifier", codeableconcept.CodeableConcept, True, None, False),
# ("foodPreferenceModifier", "foodPreferenceModifier", codeableconcept.CodeableConcept, True, None, False),
#
# ("oralDiet", "oralDiet", NutritionOrderOralDiet, False, None, False),
# ("orderer", "orderer", fhirreference.FHIRReference, False, None, False),
# ("patient", "patient", fhirreference.FHIRReference, False, None, True),
#
# ("supplement", "supplement", NutritionOrderSupplement, True, None, False),
])
return js
import sys
try:
from fhirclient.models import codeableconcept
except ImportError:
codeableconcept = sys.modules[__package__ + '.codeableconcept']
try:
from fhirclient.models import fhirdate
except ImportError:
fhirdate = sys.modules[__package__ + '.fhirdate']
try:
from fhirclient.models import fhirreference
except ImportError:
fhirreference = sys.modules[__package__ + '.fhirreference']
try:
from fhirclient.models import identifier
except ImportError:
identifier = sys.modules[__package__ + '.identifier']
try:
from fhirclient.models import quantity
except ImportError:
quantity = sys.modules[__package__ + '.quantity']
try:
from fhirclient.models import ratio
except ImportError:
ratio = sys.modules[__package__ + '.ratio']
try:
from fhirclient.models import timing
except ImportError:
timing = sys.modules[__package__ + '.timing']