//    Copyright 2019 Google Inc.
//
//    Licensed under the Apache License, Version 2.0 (the "License");
//    you may not use this file except in compliance with the License.
//    You may obtain a copy of the License at
//
//        https://www.apache.org/licenses/LICENSE-2.0
//
//    Unless required by applicable law or agreed to in writing, software
//    distributed under the License is distributed on an "AS IS" BASIS,
//    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//    See the License for the specific language governing permissions and
//    limitations under the License.

syntax = "proto3";

package google.fhir.r4.core;

import "google/protobuf/any.proto";
import "google/fhir/core/proto/annotations.proto";
import "google/fhir/r4/proto/core/codes.proto";
import "google/fhir/r4/proto/core/datatypes.proto";

option java_multiple_files = true;
option java_package = "com.google.fhir.r4.core";
option (.google.fhir.proto.fhir_version) = R4;
option go_package = "github.com/google/fhir/go/google/fhir/r4/proto/core/resources/nutrition_order_go_proto";

// Auto-generated from StructureDefinition for NutritionOrder.
// Diet, formula or nutritional supplement request.
// See http://hl7.org/fhir/StructureDefinition/NutritionOrder
message NutritionOrder {
  option (.google.fhir.proto.structure_definition_kind) = KIND_RESOURCE;
  option (.google.fhir.proto.fhir_structure_definition_url) =
      "http://hl7.org/fhir/StructureDefinition/NutritionOrder";
  option (.google.fhir.proto.fhir_path_message_warning_constraint) =
      "oralDiet.exists() or supplement.exists() or enteralFormula.exists()";

  // Logical id of this artifact
  Id id = 1;

  // Metadata about the resource
  Meta meta = 2;

  // A set of rules under which this content was created
  Uri implicit_rules = 3;

  // Language of the resource content
  Code language = 4;

  // Text summary of the resource, for human interpretation
  Narrative text = 5;

  // Contained, inline Resources
  repeated protobuf.Any contained = 6;

  // Field 7 reserved for strongly-typed ContainedResource for id:
  // NutritionOrder.contained
  reserved 7;

  // Additional content defined by implementations
  repeated Extension extension = 8;

  // Extensions that cannot be ignored
  repeated Extension modifier_extension = 9;

  // Identifiers assigned to this order
  repeated Identifier identifier = 10;

  // Instantiates FHIR protocol or definition
  repeated Canonical instantiates_canonical = 11;

  // Instantiates external protocol or definition
  repeated Uri instantiates_uri = 12;

  // Instantiates protocol or definition
  repeated Uri instantiates = 13;

  // draft | active | on-hold | revoked | completed | entered-in-error | unknown
  message StatusCode {
    option (.google.fhir.proto.structure_definition_kind) = KIND_PRIMITIVE_TYPE;
    option (.google.fhir.proto.fhir_valueset_url) =
        "http://hl7.org/fhir/ValueSet/request-status";
    option (.google.fhir.proto.fhir_profile_base) =
        "http://hl7.org/fhir/StructureDefinition/code";

    RequestStatusCode.Value value = 1;

    String id = 2;

    repeated Extension extension = 3;
  }
  StatusCode status = 14
      [(.google.fhir.proto.validation_requirement) = REQUIRED_BY_FHIR];

  // proposal | plan | directive | order | original-order | reflex-order |
  // filler-order | instance-order | option
  message IntentCode {
    option (.google.fhir.proto.structure_definition_kind) = KIND_PRIMITIVE_TYPE;
    option (.google.fhir.proto.fhir_valueset_url) =
        "http://hl7.org/fhir/ValueSet/request-intent";
    option (.google.fhir.proto.fhir_profile_base) =
        "http://hl7.org/fhir/StructureDefinition/code";

    RequestIntentCode.Value value = 1;

    String id = 2;

    repeated Extension extension = 3;
  }
  IntentCode intent = 15
      [(.google.fhir.proto.validation_requirement) = REQUIRED_BY_FHIR];

  // The person who requires the diet, formula or nutritional supplement
  Reference patient = 16 [
    (.google.fhir.proto.validation_requirement) = REQUIRED_BY_FHIR,
    (.google.fhir.proto.valid_reference_type) = "Patient"
  ];

  // The encounter associated with this nutrition order
  Reference encounter = 17
      [(.google.fhir.proto.valid_reference_type) = "Encounter"];

  // Date and time the nutrition order was requested
  DateTime date_time = 18
      [(.google.fhir.proto.validation_requirement) = REQUIRED_BY_FHIR];

  // Who ordered the diet, formula or nutritional supplement
  Reference orderer = 19 [
    (.google.fhir.proto.valid_reference_type) = "Practitioner",
    (.google.fhir.proto.valid_reference_type) = "PractitionerRole"
  ];

  // List of the patient's food and nutrition-related allergies and intolerances
  repeated Reference allergy_intolerance = 20
      [(.google.fhir.proto.valid_reference_type) = "AllergyIntolerance"];

  // Order-specific modifier about the type of food that should be given
  repeated CodeableConcept food_preference_modifier = 21;

  // Order-specific modifier about the type of food that should not be given
  repeated CodeableConcept exclude_food_modifier = 22;

  // Oral diet components
  message OralDiet {
    // Unique id for inter-element referencing
    String id = 1;

    // Additional content defined by implementations
    repeated Extension extension = 2;

    // Extensions that cannot be ignored even if unrecognized
    repeated Extension modifier_extension = 3;

    // Type of oral diet or diet restrictions that describe what can be consumed
    // orally
    repeated CodeableConcept type = 4;

    // Scheduled frequency of diet
    repeated Timing schedule = 5;

    // Required  nutrient modifications
    message Nutrient {
      // Unique id for inter-element referencing
      String id = 1;

      // Additional content defined by implementations
      repeated Extension extension = 2;

      // Extensions that cannot be ignored even if unrecognized
      repeated Extension modifier_extension = 3;

      // Type of nutrient that is being modified
      CodeableConcept modifier = 4;

      // Quantity of the specified nutrient
      SimpleQuantity amount = 5;
    }
    repeated Nutrient nutrient = 6;

    // Required  texture modifications
    message Texture {
      // Unique id for inter-element referencing
      String id = 1;

      // Additional content defined by implementations
      repeated Extension extension = 2;

      // Extensions that cannot be ignored even if unrecognized
      repeated Extension modifier_extension = 3;

      // Code to indicate how to alter the texture of the foods, e.g. pureed
      CodeableConcept modifier = 4;

      // Concepts that are used to identify an entity that is ingested for
      // nutritional purposes
      CodeableConcept food_type = 5;
    }
    repeated Texture texture = 7;

    // The required consistency of fluids and liquids provided to the patient
    repeated CodeableConcept fluid_consistency_type = 8;

    // Instructions or additional information about the oral diet
    String instruction = 9;
  }
  OralDiet oral_diet = 23;

  // Supplement components
  message Supplement {
    // Unique id for inter-element referencing
    String id = 1;

    // Additional content defined by implementations
    repeated Extension extension = 2;

    // Extensions that cannot be ignored even if unrecognized
    repeated Extension modifier_extension = 3;

    // Type of supplement product requested
    CodeableConcept type = 4;

    // Product or brand name of the nutritional supplement
    String product_name = 5;

    // Scheduled frequency of supplement
    repeated Timing schedule = 6;

    // Amount of the nutritional supplement
    SimpleQuantity quantity = 7;

    // Instructions or additional information about the oral supplement
    String instruction = 8;
  }
  repeated Supplement supplement = 24;

  // Enteral formula components
  message EnteralFormula {
    // Unique id for inter-element referencing
    String id = 1;

    // Additional content defined by implementations
    repeated Extension extension = 2;

    // Extensions that cannot be ignored even if unrecognized
    repeated Extension modifier_extension = 3;

    // Type of enteral or infant formula
    CodeableConcept base_formula_type = 4;

    // Product or brand name of the enteral or infant formula
    String base_formula_product_name = 5;

    // Type of modular component to add to the feeding
    CodeableConcept additive_type = 6;

    // Product or brand name of the modular additive
    String additive_product_name = 7;

    // Amount of energy per specified volume that is required
    SimpleQuantity caloric_density = 8;

    // How the formula should enter the patient's gastrointestinal tract
    CodeableConcept routeof_administration = 9;

    // Formula feeding instruction as structured data
    message Administration {
      // Unique id for inter-element referencing
      String id = 1;

      // Additional content defined by implementations
      repeated Extension extension = 2;

      // Extensions that cannot be ignored even if unrecognized
      repeated Extension modifier_extension = 3;

      // Scheduled frequency of enteral feeding
      Timing schedule = 4;

      // The volume of formula to provide
      SimpleQuantity quantity = 5;

      // Speed with which the formula is provided per period of time
      message RateX {
        option (.google.fhir.proto.is_choice_type) = true;

        oneof choice {
          SimpleQuantity quantity = 1;
          Ratio ratio = 2;
        }
      }
      RateX rate = 6;
    }
    repeated Administration administration = 10;

    // Upper limit on formula volume per unit of time
    SimpleQuantity max_volume_to_deliver = 11;

    // Formula feeding instructions expressed as text
    String administration_instruction = 12;
  }
  EnteralFormula enteral_formula = 25;

  // Comments
  repeated Annotation note = 26;
}
