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

// Auto-generated from StructureDefinition for TestReport.
// Describes the results of a TestScript execution.
// See http://hl7.org/fhir/StructureDefinition/TestReport
message TestReport {
  option (.google.fhir.proto.structure_definition_kind) = KIND_RESOURCE;
  option (.google.fhir.proto.fhir_structure_definition_url) =
      "http://hl7.org/fhir/StructureDefinition/TestReport";

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

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

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

  // External identifier
  Identifier identifier = 10;

  // Informal name of the executed TestScript
  String name = 11;

  // completed | in-progress | waiting | stopped | 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/report-status-codes";
    option (.google.fhir.proto.fhir_profile_base) =
        "http://hl7.org/fhir/StructureDefinition/code";

    TestReportStatusCode.Value value = 1;

    String id = 2;

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

  // Reference to the  version-specific TestScript that was executed to produce
  // this TestReport
  Reference test_script = 13 [
    (.google.fhir.proto.validation_requirement) = REQUIRED_BY_FHIR,
    (.google.fhir.proto.valid_reference_type) = "TestScript"
  ];

  // pass | fail | pending
  message ResultCode {
    option (.google.fhir.proto.structure_definition_kind) = KIND_PRIMITIVE_TYPE;
    option (.google.fhir.proto.fhir_valueset_url) =
        "http://hl7.org/fhir/ValueSet/report-result-codes";
    option (.google.fhir.proto.fhir_profile_base) =
        "http://hl7.org/fhir/StructureDefinition/code";

    TestReportResultCode.Value value = 1;

    String id = 2;

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

  // The final score (percentage of tests passed) resulting from the execution
  // of the TestScript
  Decimal score = 15;

  // Name of the tester producing this report (Organization or individual)
  String tester = 16;

  // When the TestScript was executed and this TestReport was generated
  DateTime issued = 17;

  // A participant in the test execution, either the execution engine, a client,
  // or a server
  message Participant {
    // 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;

    // test-engine | client | server
    message TypeCode {
      option (.google.fhir.proto.structure_definition_kind) =
          KIND_PRIMITIVE_TYPE;
      option (.google.fhir.proto.fhir_valueset_url) =
          "http://hl7.org/fhir/ValueSet/report-participant-type";
      option (.google.fhir.proto.fhir_profile_base) =
          "http://hl7.org/fhir/StructureDefinition/code";

      TestReportParticipantTypeCode.Value value = 1;

      String id = 2;

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

    // The uri of the participant. An absolute URL is preferred
    Uri uri = 5
        [(.google.fhir.proto.validation_requirement) = REQUIRED_BY_FHIR];

    // The display name of the participant
    String display = 6;
  }
  repeated Participant participant = 18;

  // The results of the series of required setup operations before the tests
  // were executed
  message Setup {
    // 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 setup operation or assert that was executed
    message SetupAction {
      option (.google.fhir.proto.fhir_path_message_constraint) =
          "operation.exists() xor assert.exists()";

      // 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 operation to perform
      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;

        // pass | skip | fail | warning | error
        message ResultCode {
          option (.google.fhir.proto.structure_definition_kind) =
              KIND_PRIMITIVE_TYPE;
          option (.google.fhir.proto.fhir_valueset_url) =
              "http://hl7.org/fhir/ValueSet/report-action-result-codes";
          option (.google.fhir.proto.fhir_profile_base) =
              "http://hl7.org/fhir/StructureDefinition/code";

          TestReportActionResultCode.Value value = 1;

          String id = 2;

          repeated Extension extension = 3;
        }
        ResultCode result = 4
            [(.google.fhir.proto.validation_requirement) = REQUIRED_BY_FHIR];

        // A message associated with the result
        Markdown message = 5;

        // A link to further details on the result
        Uri detail = 6;
      }
      Operation operation = 4;

      // The assertion to perform
      message Assert {
        // 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;

        // pass | skip | fail | warning | error
        message ResultCode {
          option (.google.fhir.proto.structure_definition_kind) =
              KIND_PRIMITIVE_TYPE;
          option (.google.fhir.proto.fhir_valueset_url) =
              "http://hl7.org/fhir/ValueSet/report-action-result-codes";
          option (.google.fhir.proto.fhir_profile_base) =
              "http://hl7.org/fhir/StructureDefinition/code";

          TestReportActionResultCode.Value value = 1;

          String id = 2;

          repeated Extension extension = 3;
        }
        ResultCode result = 4
            [(.google.fhir.proto.validation_requirement) = REQUIRED_BY_FHIR];

        // A message associated with the result
        Markdown message = 5;

        // A link to further details on the result
        String detail = 6;
      }
      Assert assert_value = 5 [json_name = "assert"];
    }
    repeated SetupAction action = 4
        [(.google.fhir.proto.validation_requirement) = REQUIRED_BY_FHIR];
  }
  Setup setup = 19;

  // A test executed from the test script
  message Test {
    // 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;

    // Tracking/logging name of this test
    String name = 4;

    // Tracking/reporting short description of the test
    String description = 5;

    // A test operation or assert that was performed
    message TestAction {
      option (.google.fhir.proto.fhir_path_message_constraint) =
          "operation.exists() xor assert.exists()";

      // 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 operation performed
      Setup.SetupAction.Operation operation = 4;

      // The assertion performed
      Setup.SetupAction.Assert assert_value = 5 [json_name = "assert"];
    }
    repeated TestAction action = 6
        [(.google.fhir.proto.validation_requirement) = REQUIRED_BY_FHIR];
  }
  repeated Test test = 20;

  // The results of running the series of required clean up steps
  message Teardown {
    // 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;

    // One or more teardown operations performed
    message TeardownAction {
      // 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 teardown operation performed
      Setup.SetupAction.Operation operation = 4
          [(.google.fhir.proto.validation_requirement) = REQUIRED_BY_FHIR];
    }
    repeated TeardownAction action = 4
        [(.google.fhir.proto.validation_requirement) = REQUIRED_BY_FHIR];
  }
  Teardown teardown = 21;
}
