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

// Auto-generated from StructureDefinition for ExampleScenario.
// Example of workflow instance.
// See http://hl7.org/fhir/StructureDefinition/ExampleScenario
message ExampleScenario {
  option (.google.fhir.proto.structure_definition_kind) = KIND_RESOURCE;
  option (.google.fhir.proto.fhir_structure_definition_url) =
      "http://hl7.org/fhir/StructureDefinition/ExampleScenario";
  option (.google.fhir.proto.fhir_path_message_warning_constraint) =
      "name.matches('[A-Z]([A-Za-z0-9_]){0,254}')";

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

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

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

  // Canonical identifier for this example scenario, represented as a URI
  // (globally unique)
  Uri url = 10;

  // Additional identifier for the example scenario
  repeated Identifier identifier = 11;

  // Business version of the example scenario
  String version = 12;

  // Name for this example scenario (computer friendly)
  String name = 13;

  // draft | active | retired | 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/publication-status";
    option (.google.fhir.proto.fhir_profile_base) =
        "http://hl7.org/fhir/StructureDefinition/code";

    PublicationStatusCode.Value value = 1;

    String id = 2;

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

  // For testing purposes, not real usage
  Boolean experimental = 15;

  // Date last changed
  DateTime date = 16;

  // Name of the publisher (organization or individual)
  String publisher = 17;

  // Contact details for the publisher
  repeated ContactDetail contact = 18;

  // The context that the content is intended to support
  repeated UsageContext use_context = 19;

  // Intended jurisdiction for example scenario (if applicable)
  repeated CodeableConcept jurisdiction = 20;

  // Use and/or publishing restrictions
  Markdown copyright = 21;

  // The purpose of the example, e.g. to illustrate a scenario
  Markdown purpose = 22;

  // Actor participating in the resource
  message Actor {
    // 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;

    // ID or acronym of the actor
    String actor_id = 4
        [(.google.fhir.proto.validation_requirement) = REQUIRED_BY_FHIR];

    // person | entity
    message TypeCode {
      option (.google.fhir.proto.structure_definition_kind) =
          KIND_PRIMITIVE_TYPE;
      option (.google.fhir.proto.fhir_valueset_url) =
          "http://hl7.org/fhir/ValueSet/examplescenario-actor-type";
      option (.google.fhir.proto.fhir_profile_base) =
          "http://hl7.org/fhir/StructureDefinition/code";

      ExampleScenarioActorTypeCode.Value value = 1;

      String id = 2;

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

    // The name of the actor as shown in the page
    String name = 6;

    // The description of the actor
    Markdown description = 7;
  }
  repeated Actor actor = 23;

  // Each resource and each version that is present in the workflow
  message Instance {
    // 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 id of the resource for referencing
    String resource_id = 4
        [(.google.fhir.proto.validation_requirement) = REQUIRED_BY_FHIR];

    // The type of the resource
    message ResourceTypeCode {
      option (.google.fhir.proto.structure_definition_kind) =
          KIND_PRIMITIVE_TYPE;
      option (.google.fhir.proto.fhir_valueset_url) =
          "http://hl7.org/fhir/ValueSet/resource-types";
      option (.google.fhir.proto.fhir_profile_base) =
          "http://hl7.org/fhir/StructureDefinition/code";

      .google.fhir.r4.core.ResourceTypeCode.Value value = 1;

      String id = 2;

      repeated Extension extension = 3;
    }
    ResourceTypeCode resource_type = 5
        [(.google.fhir.proto.validation_requirement) = REQUIRED_BY_FHIR];

    // A short name for the resource instance
    String name = 6;

    // Human-friendly description of the resource instance
    Markdown description = 7;

    // A specific version of the resource
    message Version {
      // 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 of a specific version of a resource
      String version_id = 4
          [(.google.fhir.proto.validation_requirement) = REQUIRED_BY_FHIR];

      // The description of the resource version
      Markdown description = 5
          [(.google.fhir.proto.validation_requirement) = REQUIRED_BY_FHIR];
    }
    repeated Version version = 8;

    // Resources contained in the instance
    message ContainedInstance {
      // 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;

      // Each resource contained in the instance
      String resource_id = 4
          [(.google.fhir.proto.validation_requirement) = REQUIRED_BY_FHIR];

      // A specific version of a resource contained in the instance
      String version_id = 5;
    }
    repeated ContainedInstance contained_instance = 9;
  }
  repeated Instance instance = 24;

  // Each major process - a group of operations
  message Process {
    // 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 diagram title of the group of operations
    String title = 4
        [(.google.fhir.proto.validation_requirement) = REQUIRED_BY_FHIR];

    // A longer description of the group of operations
    Markdown description = 5;

    // Description of initial status before the process starts
    Markdown pre_conditions = 6;

    // Description of final status after the process ends
    Markdown post_conditions = 7;

    // Each step of the process
    message Step {
      // 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;

      // Nested process
      repeated Process process = 4;

      // If there is a pause in the flow
      Boolean pause = 5;

      // Each interaction or action
      message Operation {
        // 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 sequential number of the interaction
        String number = 4
            [(.google.fhir.proto.validation_requirement) = REQUIRED_BY_FHIR];

        // The type of operation - CRUD
        String type = 5;

        // The human-friendly name of the interaction
        String name = 6;

        // Who starts the transaction
        String initiator = 7;

        // Who receives the transaction
        String receiver = 8;

        // A comment to be inserted in the diagram
        Markdown description = 9;

        // Whether the initiator is deactivated right after the transaction
        Boolean initiator_active = 10;

        // Whether the receiver is deactivated right after the transaction
        Boolean receiver_active = 11;

        // Each resource instance used by the initiator
        Instance.ContainedInstance request = 12;

        // Each resource instance used by the responder
        Instance.ContainedInstance response = 13;
      }
      Operation operation = 6;

      // Alternate non-typical step action
      message Alternative {
        // 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 alternative
        String title = 4
            [(.google.fhir.proto.validation_requirement) = REQUIRED_BY_FHIR];

        // A human-readable description of each option
        Markdown description = 5;

        // What happens in each alternative option
        repeated Step step = 6;
      }
      repeated Alternative alternative = 7;
    }
    repeated Step step = 8;
  }
  repeated Process process = 25;

  // Another nested workflow
  repeated Canonical workflow = 26;
}
