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

// Auto-generated from StructureDefinition for ResearchStudy.
// Investigation to increase healthcare-related patient-independent knowledge.
// See http://hl7.org/fhir/StructureDefinition/ResearchStudy
message ResearchStudy {
  option (.google.fhir.proto.structure_definition_kind) = KIND_RESOURCE;
  option (.google.fhir.proto.fhir_structure_definition_url) =
      "http://hl7.org/fhir/StructureDefinition/ResearchStudy";

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

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

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

  // Business Identifier for study
  repeated Identifier identifier = 10;

  // Name for this study
  String title = 11;

  // Steps followed in executing study
  repeated Reference protocol = 12
      [(.google.fhir.proto.valid_reference_type) = "PlanDefinition"];

  // Part of larger study
  repeated Reference part_of = 13
      [(.google.fhir.proto.valid_reference_type) = "ResearchStudy"];

  // active | administratively-completed | approved | closed-to-accrual |
  // closed-to-accrual-and-intervention | completed | disapproved | in-review |
  // temporarily-closed-to-accrual |
  // temporarily-closed-to-accrual-and-intervention | withdrawn
  message StatusCode {
    option (.google.fhir.proto.structure_definition_kind) = KIND_PRIMITIVE_TYPE;
    option (.google.fhir.proto.fhir_valueset_url) =
        "http://hl7.org/fhir/ValueSet/research-study-status";
    option (.google.fhir.proto.fhir_profile_base) =
        "http://hl7.org/fhir/StructureDefinition/code";

    ResearchStudyStatusCode.Value value = 1;

    String id = 2;

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

  // treatment | prevention | diagnostic | supportive-care | screening |
  // health-services-research | basic-science | device-feasibility
  CodeableConcept primary_purpose_type = 15;

  // n-a | early-phase-1 | phase-1 | phase-1-phase-2 | phase-2 | phase-2-phase-3
  // | phase-3 | phase-4
  CodeableConcept phase = 16;

  // Classifications for the study
  repeated CodeableConcept category = 17;

  // Drugs, devices, etc. under study
  repeated CodeableConcept focus = 18;

  // Condition being studied
  repeated CodeableConcept condition = 19;

  // Contact details for the study
  repeated ContactDetail contact = 20;

  // References and dependencies
  repeated RelatedArtifact related_artifact = 21;

  // Used to search for the study
  repeated CodeableConcept keyword = 22;

  // Geographic region(s) for study
  repeated CodeableConcept location = 23;

  // What this is study doing
  Markdown description = 24;

  // Inclusion & exclusion criteria
  repeated Reference enrollment = 25
      [(.google.fhir.proto.valid_reference_type) = "Group"];

  // When the study began and ended
  Period period = 26;

  // Organization that initiates and is legally responsible for the study
  Reference sponsor = 27
      [(.google.fhir.proto.valid_reference_type) = "Organization"];

  // Researcher who oversees multiple aspects of the study
  Reference principal_investigator = 28 [
    (.google.fhir.proto.valid_reference_type) = "Practitioner",
    (.google.fhir.proto.valid_reference_type) = "PractitionerRole"
  ];

  // Facility where study activities are conducted
  repeated Reference site = 29
      [(.google.fhir.proto.valid_reference_type) = "Location"];

  // accrual-goal-met | closed-due-to-toxicity |
  // closed-due-to-lack-of-study-progress | temporarily-closed-per-study-design
  CodeableConcept reason_stopped = 30;

  // Comments made about the study
  repeated Annotation note = 31;

  // Defined path through the study for a subject
  message Arm {
    // 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 study arm
    String name = 4
        [(.google.fhir.proto.validation_requirement) = REQUIRED_BY_FHIR];

    // Categorization of study arm
    CodeableConcept type = 5;

    // Short explanation of study path
    String description = 6;
  }
  repeated Arm arm = 32;

  // A goal for the study
  message Objective {
    // 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 objective
    String name = 4;

    // primary | secondary | exploratory
    CodeableConcept type = 5;
  }
  repeated Objective objective = 33;
}
