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

// Auto-generated from StructureDefinition for SubstanceNucleicAcid.
// Nucleic acids are defined by three distinct elements: the base, sugar and
// linkage. Individual substance/moiety IDs will be created for each of these
// elements. The nucleotide sequence will be always entered in the 5’-3’
// direction. See http://hl7.org/fhir/StructureDefinition/SubstanceNucleicAcid
message SubstanceNucleicAcid {
  option (.google.fhir.proto.structure_definition_kind) = KIND_RESOURCE;
  option (.google.fhir.proto.fhir_structure_definition_url) =
      "http://hl7.org/fhir/StructureDefinition/SubstanceNucleicAcid";

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

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

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

  // The type of the sequence shall be specified based on a controlled
  // vocabulary
  CodeableConcept sequence_type = 10;

  // The number of linear sequences of nucleotides linked through phosphodiester
  // bonds shall be described. Subunits would be strands of nucleic acids that
  // are tightly associated typically through Watson-Crick base pairing. NOTE:
  // If not specified in the reference source, the assumption is that there is 1
  // subunit
  Integer number_of_subunits = 11;

  // The area of hybridisation shall be described if applicable for double
  // stranded RNA or DNA. The number associated with the subunit followed by the
  // number associated to the residue shall be specified in increasing order.
  // The underscore “” shall be used as separator as follows: “Subunitnumber
  // Residue”
  String area_of_hybridisation = 12;

  // (TBC)
  CodeableConcept oligo_nucleotide_type = 13;

  // Subunits are listed in order of decreasing length; sequences of the same
  // length will be ordered by molecular weight; subunits that have identical
  // sequences will be repeated multiple times
  message Subunit {
    // 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;

    // Index of linear sequences of nucleic acids in order of decreasing length.
    // Sequences of the same length will be ordered by molecular weight.
    // Subunits that have identical sequences will be repeated and have
    // sequential subscripts
    Integer subunit = 4;

    // Actual nucleotide sequence notation from 5' to 3' end using standard
    // single letter codes. In addition to the base sequence, sugar and type of
    // phosphate or non-phosphate linkage should also be captured
    String sequence = 5;

    // The length of the sequence shall be captured
    Integer length = 6;

    // (TBC)
    Attachment sequence_attachment = 7;

    // The nucleotide present at the 5’ terminal shall be specified based on a
    // controlled vocabulary. Since the sequence is represented from the 5' to
    // the 3' end, the 5’ prime nucleotide is the letter at the first position
    // in the sequence. A separate representation would be redundant
    CodeableConcept five_prime = 8;

    // The nucleotide present at the 3’ terminal shall be specified based on a
    // controlled vocabulary. Since the sequence is represented from the 5' to
    // the 3' end, the 5’ prime nucleotide is the letter at the last position in
    // the sequence. A separate representation would be redundant
    CodeableConcept three_prime = 9;

    // The linkages between sugar residues will also be captured
    message Linkage {
      // 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 entity that links the sugar residues together should also be
      // captured for nearly all naturally occurring nucleic acid the linkage is
      // a phosphate group. For many synthetic oligonucleotides phosphorothioate
      // linkages are often seen. Linkage connectivity is assumed to be 3’-5’.
      // If the linkage is either 3’-3’ or 5’-5’ this should be specified
      String connectivity = 4;

      // Each linkage will be registered as a fragment and have an ID
      Identifier identifier = 5;

      // Each linkage will be registered as a fragment and have at least one
      // name. A single name shall be assigned to each linkage
      String name = 6;

      // Residues shall be captured as described in 5.3.6.8.3
      String residue_site = 7;
    }
    repeated Linkage linkage = 10;

    // 5.3.6.8.1 Sugar ID (Mandatory)
    message Sugar {
      // 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 Substance ID of the sugar or sugar-like component that make up the
      // nucleotide
      Identifier identifier = 4;

      // The name of the sugar or sugar-like component that make up the
      // nucleotide
      String name = 5;

      // The residues that contain a given sugar will be captured. The order of
      // given residues will be captured in the 5‘-3‘direction consistent with
      // the base sequences listed above
      String residue_site = 6;
    }
    repeated Sugar sugar = 11;
  }
  repeated Subunit subunit = 14;
}
