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

// Auto-generated from StructureDefinition for DeviceDefinition.
// An instance of a medical-related component of a medical device.
// See http://hl7.org/fhir/StructureDefinition/DeviceDefinition
message DeviceDefinition {
  option (.google.fhir.proto.structure_definition_kind) = KIND_RESOURCE;
  option (.google.fhir.proto.fhir_structure_definition_url) =
      "http://hl7.org/fhir/StructureDefinition/DeviceDefinition";

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

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

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

  // Instance identifier
  repeated Identifier identifier = 10;

  // Unique Device Identifier (UDI) Barcode string
  message UdiDeviceIdentifier {
    // 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 identifier that is to be associated with every Device that references
    // this DeviceDefintiion for the issuer and jurisdication porvided in the
    // DeviceDefinition.udiDeviceIdentifier
    String device_identifier = 4
        [(.google.fhir.proto.validation_requirement) = REQUIRED_BY_FHIR];

    // The organization that assigns the identifier algorithm
    Uri issuer = 5
        [(.google.fhir.proto.validation_requirement) = REQUIRED_BY_FHIR];

    // The jurisdiction to which the deviceIdentifier applies
    Uri jurisdiction = 6
        [(.google.fhir.proto.validation_requirement) = REQUIRED_BY_FHIR];
  }
  repeated UdiDeviceIdentifier udi_device_identifier = 11;

  // Name of device manufacturer
  message ManufacturerX {
    option (.google.fhir.proto.is_choice_type) = true;

    oneof choice {
      String string_value = 1 [json_name = "string"];
      Reference reference = 2
          [(.google.fhir.proto.valid_reference_type) = "Organization"];
    }
  }
  ManufacturerX manufacturer = 12;

  // A name given to the device to identify it
  message DeviceName {
    // 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 name of the device
    String name = 4
        [(.google.fhir.proto.validation_requirement) = REQUIRED_BY_FHIR];

    // udi-label-name | user-friendly-name | patient-reported-name |
    // manufacturer-name | model-name | other
    message TypeCode {
      option (.google.fhir.proto.structure_definition_kind) =
          KIND_PRIMITIVE_TYPE;
      option (.google.fhir.proto.fhir_valueset_url) =
          "http://hl7.org/fhir/ValueSet/device-nametype";
      option (.google.fhir.proto.fhir_profile_base) =
          "http://hl7.org/fhir/StructureDefinition/code";

      DeviceNameTypeCode.Value value = 1;

      String id = 2;

      repeated Extension extension = 3;
    }
    TypeCode type = 5
        [(.google.fhir.proto.validation_requirement) = REQUIRED_BY_FHIR];
  }
  repeated DeviceName device_name = 13;

  // The model number for the device
  String model_number = 14;

  // What kind of device or device system this is
  CodeableConcept type = 15;

  // The capabilities supported on a  device, the standards to which the device
  // conforms for a particular purpose, and used for the communication
  message Specialization {
    // 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 standard that is used to operate and communicate
    String system_type = 4
        [(.google.fhir.proto.validation_requirement) = REQUIRED_BY_FHIR];

    // The version of the standard that is used to operate and communicate
    String version = 5;
  }
  repeated Specialization specialization = 16;

  // Available versions
  repeated String version = 17;

  // Safety characteristics of the device
  repeated CodeableConcept safety = 18;

  // Shelf Life and storage information
  repeated ProductShelfLife shelf_life_storage = 19;

  // Dimensions, color etc.
  ProdCharacteristic physical_characteristics = 20;

  // Language code for the human-readable text strings produced by the device
  // (all supported)
  repeated CodeableConcept language_code = 21;

  // Device capabilities
  message Capability {
    // 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 capability
    CodeableConcept type = 4
        [(.google.fhir.proto.validation_requirement) = REQUIRED_BY_FHIR];

    // Description of capability
    repeated CodeableConcept description = 5;
  }
  repeated Capability capability = 22;

  // The actual configuration settings of a device as it actually operates,
  // e.g., regulation status, time properties
  message Property {
    // 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 that specifies the property DeviceDefinitionPropetyCode (Extensible)
    CodeableConcept type = 4
        [(.google.fhir.proto.validation_requirement) = REQUIRED_BY_FHIR];

    // Property value as a quantity
    repeated Quantity value_quantity = 5;

    // Property value as a code, e.g., NTP4 (synced to NTP)
    repeated CodeableConcept value_code = 6;
  }
  repeated Property property = 23;

  // Organization responsible for device
  Reference owner = 24
      [(.google.fhir.proto.valid_reference_type) = "Organization"];

  // Details for human/organization for support
  repeated ContactPoint contact = 25;

  // Network address to contact device
  Uri url = 26;

  // Access to on-line information
  Uri online_information = 27;

  // Device notes and comments
  repeated Annotation note = 28;

  // The quantity of the device present in the packaging (e.g. the number of
  // devices present in a pack, or the number of devices in the same package of
  // the medicinal product)
  Quantity quantity = 29;

  // The parent device it can be part of
  Reference parent_device = 30
      [(.google.fhir.proto.valid_reference_type) = "DeviceDefinition"];

  // A substance used to create the material(s) of which the device is made
  message Material {
    // 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 substance
    CodeableConcept substance = 4
        [(.google.fhir.proto.validation_requirement) = REQUIRED_BY_FHIR];

    // Indicates an alternative material of the device
    Boolean alternate = 5;

    // Whether the substance is a known or suspected allergen
    Boolean allergenic_indicator = 6;
  }
  repeated Material material = 31;
}
