//    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/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/medicinal_product_go_proto";

// Auto-generated from StructureDefinition for MedicinalProduct.
// Detailed definition of a medicinal product, typically for uses other than
// direct patient care (e.g. regulatory use). See
// http://hl7.org/fhir/StructureDefinition/MedicinalProduct
message MedicinalProduct {
  option (.google.fhir.proto.structure_definition_kind) = KIND_RESOURCE;
  option (.google.fhir.proto.fhir_structure_definition_url) =
      "http://hl7.org/fhir/StructureDefinition/MedicinalProduct";

  // 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:
  // MedicinalProduct.contained
  reserved 7;

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

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

  // Business identifier for this product. Could be an MPID
  repeated Identifier identifier = 10;

  // Regulatory type, e.g. Investigational or Authorized
  CodeableConcept type = 11;

  // If this medicine applies to human or veterinary uses
  Coding domain = 12;

  // The dose form for a single part product, or combined form of a multiple
  // part product
  CodeableConcept combined_pharmaceutical_dose_form = 13;

  // The legal status of supply of the medicinal product as classified by the
  // regulator
  CodeableConcept legal_status_of_supply = 14;

  // Whether the Medicinal Product is subject to additional monitoring for
  // regulatory reasons
  CodeableConcept additional_monitoring_indicator = 15;

  // Whether the Medicinal Product is subject to special measures for regulatory
  // reasons
  repeated String special_measures = 16;

  // If authorised for use in children
  CodeableConcept paediatric_use_indicator = 17;

  // Allows the product to be classified by various systems
  repeated CodeableConcept product_classification = 18;

  // Marketing status of the medicinal product, in contrast to marketing
  // authorizaton
  repeated MarketingStatus marketing_status = 19;

  // Pharmaceutical aspects of product
  repeated Reference pharmaceutical_product = 20
      [(.google.fhir.proto.valid_reference_type) =
           "MedicinalProductPharmaceutical"];

  // Package representation for the product
  repeated Reference packaged_medicinal_product = 21
      [(.google.fhir.proto.valid_reference_type) = "MedicinalProductPackaged"];

  // Supporting documentation, typically for regulatory submission
  repeated Reference attached_document = 22
      [(.google.fhir.proto.valid_reference_type) = "DocumentReference"];

  // A master file for to the medicinal product (e.g. Pharmacovigilance System
  // Master File)
  repeated Reference master_file = 23
      [(.google.fhir.proto.valid_reference_type) = "DocumentReference"];

  // A product specific contact, person (in a role), or an organization
  repeated Reference contact = 24 [
    (.google.fhir.proto.valid_reference_type) = "Organization",
    (.google.fhir.proto.valid_reference_type) = "PractitionerRole"
  ];

  // Clinical trials or studies that this product is involved in
  repeated Reference clinical_trial = 25
      [(.google.fhir.proto.valid_reference_type) = "ResearchStudy"];

  // The product's name, including full name and possibly coded parts
  message Name {
    // 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;

    // The full product name
    String product_name = 4
        [(.google.fhir.proto.validation_requirement) = REQUIRED_BY_FHIR];

    // Coding words or phrases of the name
    message NamePart {
      // 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;

      // A fragment of a product name
      String part = 4
          [(.google.fhir.proto.validation_requirement) = REQUIRED_BY_FHIR];

      // Idenifying type for this part of the name (e.g. strength part)
      Coding type = 5
          [(.google.fhir.proto.validation_requirement) = REQUIRED_BY_FHIR];
    }
    repeated NamePart name_part = 5;

    // Country where the name applies
    message CountryLanguage {
      // 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;

      // Country code for where this name applies
      CodeableConcept country = 4
          [(.google.fhir.proto.validation_requirement) = REQUIRED_BY_FHIR];

      // Jurisdiction code for where this name applies
      CodeableConcept jurisdiction = 5;

      // Language code for this name
      CodeableConcept language = 6
          [(.google.fhir.proto.validation_requirement) = REQUIRED_BY_FHIR];
    }
    repeated CountryLanguage country_language = 6;
  }
  repeated Name name = 26
      [(.google.fhir.proto.validation_requirement) = REQUIRED_BY_FHIR];

  // Reference to another product, e.g. for linking authorised to
  // investigational product
  repeated Identifier cross_reference = 27;

  // An operation applied to the product, for manufacturing or adminsitrative
  // purpose
  message ManufacturingBusinessOperation {
    // 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;

    // The type of manufacturing operation
    CodeableConcept operation_type = 4;

    // Regulatory authorization reference number
    Identifier authorisation_reference_number = 5;

    // Regulatory authorization date
    DateTime effective_date = 6;

    // To indicate if this proces is commercially confidential
    CodeableConcept confidentiality_indicator = 7;

    // The manufacturer or establishment associated with the process
    repeated Reference manufacturer = 8
        [(.google.fhir.proto.valid_reference_type) = "Organization"];

    // A regulator which oversees the operation
    Reference regulator = 9
        [(.google.fhir.proto.valid_reference_type) = "Organization"];
  }
  repeated ManufacturingBusinessOperation manufacturing_business_operation = 28;

  // Indicates if the medicinal product has an orphan designation for the
  // treatment of a rare disease
  message SpecialDesignation {
    // 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;

    // Identifier for the designation, or procedure number
    repeated Identifier identifier = 4;

    // The type of special designation, e.g. orphan drug, minor use
    CodeableConcept type = 5;

    // The intended use of the product, e.g. prevention, treatment
    CodeableConcept intended_use = 6;

    // Condition for which the medicinal use applies
    message IndicationX {
      option (.google.fhir.proto.is_choice_type) = true;

      oneof choice {
        CodeableConcept codeable_concept = 1;
        Reference reference = 2 [(.google.fhir.proto.valid_reference_type) =
                                     "MedicinalProductIndication"];
      }
    }
    IndicationX indication = 7;

    // For example granted, pending, expired or withdrawn
    CodeableConcept status = 8;

    // Date when the designation was granted
    DateTime date = 9;

    // Animal species for which this applies
    CodeableConcept species = 10;
  }
  repeated SpecialDesignation special_designation = 29;
}
