//    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";
import "google/fhir/r4/proto/core/valuesets.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/task_go_proto";

// Auto-generated from StructureDefinition for Task.
// A task to be performed.
// See http://hl7.org/fhir/StructureDefinition/Task
message Task {
  option (.google.fhir.proto.structure_definition_kind) = KIND_RESOURCE;
  option (.google.fhir.proto.fhir_structure_definition_url) =
      "http://hl7.org/fhir/StructureDefinition/Task";
  option (.google.fhir.proto.fhir_path_message_constraint) =
      "lastModified.exists().not() or authoredOn.exists().not() or lastModified >= authoredOn";

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

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

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

  // Task Instance Identifier
  repeated Identifier identifier = 10;

  // Formal definition of task
  Canonical instantiates_canonical = 11;

  // Formal definition of task
  Uri instantiates_uri = 12;

  // Request fulfilled by this task
  repeated Reference based_on = 13
      [(.google.fhir.proto.valid_reference_type) = "Resource"];

  // Requisition or grouper id
  Identifier group_identifier = 14;

  // Composite task
  repeated Reference part_of = 15
      [(.google.fhir.proto.valid_reference_type) = "Task"];

  // draft | requested | received | accepted | +
  message StatusCode {
    option (.google.fhir.proto.structure_definition_kind) = KIND_PRIMITIVE_TYPE;
    option (.google.fhir.proto.fhir_valueset_url) =
        "http://hl7.org/fhir/ValueSet/task-status";
    option (.google.fhir.proto.fhir_profile_base) =
        "http://hl7.org/fhir/StructureDefinition/code";

    TaskStatusCode.Value value = 1;

    String id = 2;

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

  // Reason for current status
  CodeableConcept status_reason = 17;

  // E.g. "Specimen collected", "IV prepped"
  CodeableConcept business_status = 18;

  // unknown | proposal | plan | 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/task-intent";
    option (.google.fhir.proto.fhir_profile_base) =
        "http://hl7.org/fhir/StructureDefinition/code";

    TaskIntentValueSet.Value value = 1;

    String id = 2;

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

  // routine | urgent | asap | stat
  message PriorityCode {
    option (.google.fhir.proto.structure_definition_kind) = KIND_PRIMITIVE_TYPE;
    option (.google.fhir.proto.fhir_valueset_url) =
        "http://hl7.org/fhir/ValueSet/request-priority";
    option (.google.fhir.proto.fhir_profile_base) =
        "http://hl7.org/fhir/StructureDefinition/code";

    RequestPriorityCode.Value value = 1;

    String id = 2;

    repeated Extension extension = 3;
  }
  PriorityCode priority = 20;

  // Task Type
  CodeableConcept code = 21;

  // Human-readable explanation of task
  String description = 22;

  // What task is acting on
  Reference focus = 23 [(.google.fhir.proto.valid_reference_type) = "Resource"];

  // Beneficiary of the Task
  Reference for_value = 24 [
    (.google.fhir.proto.valid_reference_type) = "Resource",
    json_name = "for"
  ];

  // Healthcare event during which this task originated
  Reference encounter = 25
      [(.google.fhir.proto.valid_reference_type) = "Encounter"];

  // Start and end time of execution
  Period execution_period = 26;

  // Task Creation Date
  DateTime authored_on = 27;

  // Task Last Modified Date
  DateTime last_modified = 28;

  // Who is asking for task to be done
  Reference requester = 29 [
    (.google.fhir.proto.valid_reference_type) = "Device",
    (.google.fhir.proto.valid_reference_type) = "Organization",
    (.google.fhir.proto.valid_reference_type) = "Patient",
    (.google.fhir.proto.valid_reference_type) = "Practitioner",
    (.google.fhir.proto.valid_reference_type) = "PractitionerRole",
    (.google.fhir.proto.valid_reference_type) = "RelatedPerson"
  ];

  // Requested performer
  repeated CodeableConcept performer_type = 30;

  // Responsible individual
  Reference owner = 31 [
    (.google.fhir.proto.valid_reference_type) = "Practitioner",
    (.google.fhir.proto.valid_reference_type) = "PractitionerRole",
    (.google.fhir.proto.valid_reference_type) = "Organization",
    (.google.fhir.proto.valid_reference_type) = "CareTeam",
    (.google.fhir.proto.valid_reference_type) = "HealthcareService",
    (.google.fhir.proto.valid_reference_type) = "Patient",
    (.google.fhir.proto.valid_reference_type) = "Device",
    (.google.fhir.proto.valid_reference_type) = "RelatedPerson"
  ];

  // Where task occurs
  Reference location = 32
      [(.google.fhir.proto.valid_reference_type) = "Location"];

  // Why task is needed
  CodeableConcept reason_code = 33;

  // Why task is needed
  Reference reason_reference = 34
      [(.google.fhir.proto.valid_reference_type) = "Resource"];

  // Associated insurance coverage
  repeated Reference insurance = 35 [
    (.google.fhir.proto.valid_reference_type) = "Coverage",
    (.google.fhir.proto.valid_reference_type) = "ClaimResponse"
  ];

  // Comments made about the task
  repeated Annotation note = 36;

  // Key events in history of the Task
  repeated Reference relevant_history = 37
      [(.google.fhir.proto.valid_reference_type) = "Provenance"];

  // Constraints on fulfillment tasks
  message Restriction {
    // 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;

    // How many times to repeat
    PositiveInt repetitions = 4;

    // When fulfillment sought
    Period period = 5;

    // For whom is fulfillment sought?
    repeated Reference recipient = 6 [
      (.google.fhir.proto.valid_reference_type) = "Patient",
      (.google.fhir.proto.valid_reference_type) = "Practitioner",
      (.google.fhir.proto.valid_reference_type) = "PractitionerRole",
      (.google.fhir.proto.valid_reference_type) = "RelatedPerson",
      (.google.fhir.proto.valid_reference_type) = "Group",
      (.google.fhir.proto.valid_reference_type) = "Organization"
    ];
  }
  Restriction restriction = 38;

  // Information used to perform task
  message Parameter {
    // 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;

    // Label for the input
    CodeableConcept type = 4
        [(.google.fhir.proto.validation_requirement) = REQUIRED_BY_FHIR];

    // Content to use in performing the task
    message ValueX {
      option (.google.fhir.proto.is_choice_type) = true;

      oneof choice {
        Base64Binary base64_binary = 1;
        Boolean boolean = 2;
        Canonical canonical = 3;
        Code code = 4;
        Date date = 5;
        DateTime date_time = 6;
        Decimal decimal = 7;
        Id id = 8;
        Instant instant = 9;
        Integer integer = 10;
        Markdown markdown = 11;
        Oid oid = 12;
        PositiveInt positive_int = 13;
        String string_value = 14 [json_name = "string"];
        Time time = 15;
        UnsignedInt unsigned_int = 16;
        Uri uri = 17;
        Url url = 18;
        Uuid uuid = 19;
        Address address = 20;
        Age age = 21;
        Annotation annotation = 22;
        Attachment attachment = 23;
        CodeableConcept codeable_concept = 24;
        Coding coding = 25;
        ContactPoint contact_point = 26;
        Count count = 27;
        Distance distance = 28;
        Duration duration = 29;
        HumanName human_name = 30;
        Identifier identifier = 31;
        Money money = 32;
        Period period = 33;
        Quantity quantity = 34;
        Range range = 35;
        Ratio ratio = 36;
        Reference reference = 37;
        SampledData sampled_data = 38;
        Signature signature = 39;
        Timing timing = 40;
        ContactDetail contact_detail = 41;
        Contributor contributor = 42;
        DataRequirement data_requirement = 43;
        Expression expression = 44;
        ParameterDefinition parameter_definition = 45;
        RelatedArtifact related_artifact = 46;
        TriggerDefinition trigger_definition = 47;
        UsageContext usage_context = 48;
        Dosage dosage = 49;
        Meta meta = 50;
      }
    }
    ValueX value = 5
        [(.google.fhir.proto.validation_requirement) = REQUIRED_BY_FHIR];
  }
  repeated Parameter input = 39;

  // Information produced as part of task
  message Output {
    // 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;

    // Label for output
    CodeableConcept type = 4
        [(.google.fhir.proto.validation_requirement) = REQUIRED_BY_FHIR];

    // Result of output
    message ValueX {
      option (.google.fhir.proto.is_choice_type) = true;

      oneof choice {
        Base64Binary base64_binary = 1;
        Boolean boolean = 2;
        Canonical canonical = 3;
        Code code = 4;
        Date date = 5;
        DateTime date_time = 6;
        Decimal decimal = 7;
        Id id = 8;
        Instant instant = 9;
        Integer integer = 10;
        Markdown markdown = 11;
        Oid oid = 12;
        PositiveInt positive_int = 13;
        String string_value = 14 [json_name = "string"];
        Time time = 15;
        UnsignedInt unsigned_int = 16;
        Uri uri = 17;
        Url url = 18;
        Uuid uuid = 19;
        Address address = 20;
        Age age = 21;
        Annotation annotation = 22;
        Attachment attachment = 23;
        CodeableConcept codeable_concept = 24;
        Coding coding = 25;
        ContactPoint contact_point = 26;
        Count count = 27;
        Distance distance = 28;
        Duration duration = 29;
        HumanName human_name = 30;
        Identifier identifier = 31;
        Money money = 32;
        Period period = 33;
        Quantity quantity = 34;
        Range range = 35;
        Ratio ratio = 36;
        Reference reference = 37;
        SampledData sampled_data = 38;
        Signature signature = 39;
        Timing timing = 40;
        ContactDetail contact_detail = 41;
        Contributor contributor = 42;
        DataRequirement data_requirement = 43;
        Expression expression = 44;
        ParameterDefinition parameter_definition = 45;
        RelatedArtifact related_artifact = 46;
        TriggerDefinition trigger_definition = 47;
        UsageContext usage_context = 48;
        Dosage dosage = 49;
        Meta meta = 50;
      }
    }
    ValueX value = 5
        [(.google.fhir.proto.validation_requirement) = REQUIRED_BY_FHIR];
  }
  repeated Output output = 40;
}
