0

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

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

  2. 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"
                    }
                }
            ]
    
  3. 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']
Carlo Allocca
  • 591
  • 1
  • 7
  • 19
  • NutritionIntake is not a defined resource in any release of FHIR as yet. Are you trying to define a custom resource? (And realize that doing so makes you non-conformant with FHIR?) – Lloyd McKenzie Feb 12 '21 at 22:14
  • @LloydMcKenzie Thank you. From http://hl7.org/fhir/2020Feb/nutritionintake.html I can read about it. What I am trying to do is to model the number of glass of water that a patient drinks – Carlo Allocca Feb 12 '21 at 23:12
  • Interesting. They added the resource, but didn't add it to the resource list yet. You won't find support for it in most 'standard' libraries because the resource only exists in the continuous integration build environment. Most of the libraries take a while to support new content and many only support 'official' releases. (The next official release won't likely be published until Q2 2022.) You'd have to reach out to the authors of the library and ask if they're willing to produce a library release that supports the draft resource. – Lloyd McKenzie Feb 13 '21 at 03:07
  • I see...I will try to reach out to the FHIR community and python library. Happy to contrinute if needed. Is there an alternative way for now? – Carlo Allocca Feb 13 '21 at 10:50

1 Answers1

1

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.

Lloyd McKenzie
  • 6,345
  • 1
  • 13
  • 10
  • Thanks. Could you give an example of how to use the basic resource to accomplish "resourceType":"NutritionIntake" with "consumedItem" for 250 ml of "Water"? – Carlo Allocca Feb 13 '21 at 22:30
  • Sorry for the lack of whitespace - hard to make it fit in a comment. Would typically also specify subject and other Basic elements too. – Lloyd McKenzie Feb 14 '21 at 03:09
  • Thank you @Lloyd McKenzie. How do I use the above to create a "resourceType":"NutritionIntake? – Carlo Allocca Feb 14 '21 at 09:27
  • This would give you a valid Basic instance. It won't give you a NutritionIntake instance. You can use Basic with existing reference libraries, existing open source servers, etc. NutritionIntake is a work in progress. It's not "official" yet - and won't be for over a year. It will quite possibly look different by the time it's approved. If you want to produce a NutritionIntake instance that looks exactly like the January ballot version, you'll probably have to write the code yourself (and won't have many communication partners). – Lloyd McKenzie Feb 14 '21 at 15:36
  • Ok I see. .Thank you – Carlo Allocca Feb 15 '21 at 09:20