Reputation: 649
Am using fhirclient libary "3.2.0" and I would need to make use of the FHIR NutritionIntake resource. My understanding is that it is not available as I could not find underl the "fhirclient.models.". Please, correct me if I am wrong.
My attempt to solve the above has been to implement "class NutritionIntake(DomainResource)". What I implemented so far is as per below. The issue that I am having is that when testing on the input containing "consumedItem" as per below, Get the following errors:
Please would you suggest any help on how to solve it?
Many Thanks, carlo
Error:
fhirclient.models.fhirabstractbase.FHIRValidationError: {root}:
consumedItem.0: Superfluous entry "nutritionProduct" in data for <fhirclient.models.backboneelement.BackboneElement object at 0x000002A536742C70> Superfluous entry "type" in data for <fhirclient.models.backboneelement.BackboneElement object at 0x000002A536742C70> Superfluous entry "amount" in data for <fhirclient.models.backboneelement.BackboneElement object at 0x000002A536742C70> Superfluous entry "schedule" in data for <fhirclient.models.backboneelement.BackboneElement object at 0x000002A536742C70>
Input
"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 Code
from fhirclient.models import fhirreference, identifier, codeableconcept, fhirdate
from fhirclient.models.domainresource import DomainResource
from fhirclient.models.nutritionorder import NutritionOrderSupplement, NutritionOrderOralDiet,
NutritionOrderEnteralFormula
from fhirclient.models import backboneelement from fhirclient.models import annotation
class NutritionIntake(DomainResource): """ Diet, formula or nutritional supplement request.
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']
Upvotes: 1
Views: 259
Reputation: 6793
Given that NutritionUptake is not yet an 'official' resource (it hasn't been included in an official release) it's likely that the Python library won't support it. You can reach out to the community that maintains the library to encourage them to support an interim release, but if not, you could use the Basic resource to try to accomplish the same functionality - primarily with a lot of custom extensions.
Upvotes: 1