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

// Auto-generated from StructureDefinition for List.
// A list is a curated collection of resources.
// See http://hl7.org/fhir/StructureDefinition/List
message List {
  option (.google.fhir.proto.structure_definition_kind) = KIND_RESOURCE;
  option (.google.fhir.proto.fhir_structure_definition_url) =
      "http://hl7.org/fhir/StructureDefinition/List";
  option (.google.fhir.proto.fhir_path_message_constraint) =
      "emptyReason.empty() or entry.empty()";
  option (.google.fhir.proto.fhir_path_message_constraint) =
      "mode = 'changes' or entry.deleted.empty()";
  option (.google.fhir.proto.fhir_path_message_constraint) =
      "mode = 'working' or entry.date.empty()";

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

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

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

  // Business identifier
  repeated Identifier identifier = 10;

  // current | retired | entered-in-error
  message StatusCode {
    option (.google.fhir.proto.structure_definition_kind) = KIND_PRIMITIVE_TYPE;
    option (.google.fhir.proto.fhir_valueset_url) =
        "http://hl7.org/fhir/ValueSet/list-status";
    option (.google.fhir.proto.fhir_profile_base) =
        "http://hl7.org/fhir/StructureDefinition/code";

    ListStatusCode.Value value = 1;

    String id = 2;

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

  // working | snapshot | changes
  message ModeCode {
    option (.google.fhir.proto.structure_definition_kind) = KIND_PRIMITIVE_TYPE;
    option (.google.fhir.proto.fhir_valueset_url) =
        "http://hl7.org/fhir/ValueSet/list-mode";
    option (.google.fhir.proto.fhir_profile_base) =
        "http://hl7.org/fhir/StructureDefinition/code";

    ListModeCode.Value value = 1;

    String id = 2;

    repeated Extension extension = 3;
  }
  ModeCode mode = 12
      [(.google.fhir.proto.validation_requirement) = REQUIRED_BY_FHIR];

  // Descriptive name for the list
  String title = 13;

  // What the purpose of this list is
  CodeableConcept code = 14;

  // If all resources have the same subject
  Reference subject = 15 [
    (.google.fhir.proto.valid_reference_type) = "Patient",
    (.google.fhir.proto.valid_reference_type) = "Group",
    (.google.fhir.proto.valid_reference_type) = "Device",
    (.google.fhir.proto.valid_reference_type) = "Location"
  ];

  // Context in which list created
  Reference encounter = 16
      [(.google.fhir.proto.valid_reference_type) = "Encounter"];

  // When the list was prepared
  DateTime date = 17;

  // Who and/or what defined the list contents (aka Author)
  Reference source = 18 [
    (.google.fhir.proto.valid_reference_type) = "Practitioner",
    (.google.fhir.proto.valid_reference_type) = "PractitionerRole",
    (.google.fhir.proto.valid_reference_type) = "Patient",
    (.google.fhir.proto.valid_reference_type) = "Device"
  ];

  // What order the list has
  CodeableConcept ordered_by = 19;

  // Comments about the list
  repeated Annotation note = 20;

  // Entries in the list
  message Entry {
    // 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;

    // Status/Workflow information about this item
    CodeableConcept flag = 4;

    // If this item is actually marked as deleted
    Boolean deleted = 5;

    // When item added to list
    DateTime date = 6;

    // Actual entry
    Reference item = 7 [
      (.google.fhir.proto.validation_requirement) = REQUIRED_BY_FHIR,
      (.google.fhir.proto.valid_reference_type) = "Resource"
    ];
  }
  repeated Entry entry = 21;

  // Why list is empty
  CodeableConcept empty_reason = 22;
}
