$schema: "https://json-schema.org/draft/2020-12/schema"

title: "Core Types"
description: "Enums and constrained strings"
type: object

definitions:
  # ================================================================================================
  # Constrained Strings

  CURIE:
    type: string
    pattern: '^[A-Za-z]\w+:\S+$'

  Date:
    type: string
    format: date

  EmailAddress:
    type: string
    format: email

  HGVSExpression:
    type: string
    pattern: '^.+?:[cgmnpr]\..+$'
    examples:
      - NC_000017.10:g.41197702T>C
      - NC_000017.11:g.43045685T>C
      - NM_007294.4(BRCA1):c.5585A>G
      - NP_009225.1:p.His1862Arg

  NPI:
    type: string
    pattern: '^\d{9,10}$'
    examples:
      - "012345678"
      - "0123456789"

  UTCTimestamp:
    description: UTC timestamp in ISO-8601 format. e.g., `2018-11-13T20:20:39+00:00`
    type: string
    format: date-time
    pattern: '^[12]\d{3}-[01]\d-[0123]\dT\d{2}:\d{2}:\d{2}\.?\d*[+-Z](\d{2}:\d{2})?$'
    examples:
      - "2018-11-13T20:20:39+00:00"
      - "2018-11-13T20:20:39.0123Z"

  Version:
    type: string
    pattern: '^\d+\.\d+(\.\d+)?(\.[\w\+]+)?$'
    examples:
      - 0.1.2
      - 2.3.4

  # ================================================================================================
  # Enums
  # See stage and status enums in separate section

  ACMGClassification:
    type: string
    enum:
      - BENIGN
      - LIKELY_BENIGN
      - VUS
      - LIKELY_PATHOGENIC
      - PATHOGENIC

  Ancestry:
    # taken from http://ceur-ws.org/Vol-1948/paper4.pdf
    type: string
    enum:
      - EAST_ASIA
      - CDX
      - CHB
      - CHS
      - JPT
      - KHV
      - EUROPE
      - CEU
      - FIN
      - GBR
      - IBS
      - TSI
      - AFRICA
      - ACB
      - ASW
      - ESN
      - GWD
      - LWK
      - MSL
      - YRI
      - AMERICAS
      - CLM
      - MXL
      - PEL
      - PUR
      - SOUTH_ASIA
      - BEB
      - GIH
      - ITU
      - PJL
      - STU

  BiologicalSex:
    description: Biological sex.
    type: string
    enum:
      - FEMALE
      - MALE
      - OTHER

  ConsentType:
    description: Types of consent
    type: string
    enum:
      - CONTACT
      - IRB
      - RESEARCH
      - TESTING

  DataSetType:
    description: Types of data sets
    type: string
    enum:
      - SEQUENCING
      - ALIGNMENT
      - FINDINGS
      - REPORT
      - OTHER

  Gender:
    description: >-
      Cultural/social gender; unconstrained string

      Sources:
        * https://www.csusm.edu/ipa/surveys/inclusive-language-guidelines.html
    type: string
    enum:
      - CISGENDER_MAN
      - CISGENDER_WOMAN
      - NO_RESPONSE
      - NON_BINARY
      - TRANSGENDER_MAN
      - TRANSGENDER_WOMAN

  Inheritance:
    type: string
    description: >-
      Inheritance patterns

      Sources:
        * https://www.ncbi.nlm.nih.gov/books/NBK132145/
        * https://www.jax.org/education-and-learning/clinical-and-continuing-education/cancer-resources/inheritance-patterns
    enum:
      - AUTOSOMAL_DOMINANT
      - AUTOSOMAL_RECESSIVE
      - X_LINKED_DOMINANT
      - X_LINKED_RECESSIVE
      - Y_LINKED
      - COMPLEX
      - MITOCHONDRIAL

  LogLevel:
    type: string
    enum:
      - DEBUG
      - INFO
      - WARNING
      - ERROR
      - CRITICAL

  MonogenicToplineFinding:
    type: string
    enum:
      - POSITIVE
      - NEGATIVE
  
  PGxImpactToplineFinding:
    type: string
    enum:
      - MINIMAL_IMPACT
      - ALTERED_DOSE
      - MAJOR_IMPACT
      - CONTRAINDICATED
      
  PGxGenePhenotype:
    type: string
    enum:
      - DECREASED_FUNCTION
      - INCREASED_FUNCTION
      - INDETERMINATE
      - INTERMEDIATE_METABOLIZER
      - LIKELY_INTERMEDIATE_METABOLIZER
      - LIKELY_POOR_METABOLIZER
      - NORMAL_FUNCTION
      - NORMAL_METABOLIZER
      - POOR_FUNCTION
      - POOR_METABOLIZER
      - POSSIBLE_DECREASED_FUNCTION
      - POSSIBLE_INTERMEDIATE_METABOLIZER
      - REVIEW_NECESSARY
      - RAPID_METABOLIZER
      - ULTRARAPID_METABOLIZER
      - VARIANT_ABSENT
      - VARIANT_PRESENT

  PRSTimespan:
    type: string
    enum:
      - LIFETIME
      - 5YEAR
      - 10YEAR

  PRSToplineFinding:
    type: string
    enum:
      - AVERAGE_RISK
      - ELEVATED_RISK

  PRSType:
    type: string
    enum:
      - BREAST_CANCER
      - CORONARY_ARTERY_DISEASE

  Relationship:
    description: Relationship to an individual (e.g., insurance policyholder)
    type: string
    enum:
      - SELF
      - SPOUSE
      - CHILD
      - OTHER

  ReportLabel:
    type: string
    enum:
      - NEGATIVE
      - QC_WARNING
      - SV
      - MANUAL_VARIANT
      - MOSAIC
      - LOW_PENETRANCE
      - NOVEL_VARIANT

  ReportType:
    type: string
    enum:
      - MONOGENIC
      - PGX
      - PRS
      - DATA_ONLY

  SampleType:
    type: string
    enum:
      - SALIVA
      - BLOOD
      - BUCCAL_SWAB
      - DNA
      - DATA
  
  SupersedeType:
    type: string
    enum:
      - AMENDED
      - CORRECTED

  GeneticVariationType:
    # Enum values here are a subset of Sequence Ontology (SO) terms, 
    # for more info see https://useast.ensembl.org/info/genome/variation/prediction/classification.html 
    type: string
    enum: 
      - SUBSTITUTION
      - INDEL
      - COPY_NUMBER_GAIN
      - COPY_NUMBER_LOSS
      - INVERSION
      - TRANSLOCATION

  Zygosity:
    type: string
    enum:
      - HEMIZYGOUS
      - HOMOZYGOUS
      - HETEROZYGOUS

  ## ===============================================================================================
  ## Status and Stage Enums

  Status:
    description: |
      Generic status for objects.  Certain statuses may apply only to specific
      entities or specific  stages.
    type: string
    enum:
      - OPEN
      - FAILED
      - SUCCESS
      - HOLD
      - CANCELED
      - INCOMPLETE

  ConfirmationStage:
    description: |
      Stage of a Confirmation

    type: string
    enum:
      - BFX_REVIEW
      - DISMISSED
      - WAITING_FOR_SENDOUT
      - WAITING_FOR_DATA
      - DATA_AVAILABLE
      - COMPLETED

  KitStage:
    type: string
    enum:
      - ASSEMBLED
      - INVENTORY
      - STAGED_FOR_SENDING
      - SHIPPED_TO_RECIPIENT
      - AT_RECIPIENT
      - INBOUND
      - RECEIVED_BY_MYOME
      - OPENED_FOR_ACCESSIONING

  OrderStage:
    description: |
      Internal stage of an Order
    type: string
    enum:
      - QUEUED
      - WAITING_FOR_DATA
      - ANALYZING
      - REPORTING
      - COMPLETED

  ReleaseWorkflowType:
    description: |
      Used in product YAML's
    enum:
      - CLS_AUTH
      - LD_AUTH

  RequisitionStage:
    description: |
      Internal stage of a Requisition
    type: string
    enum:
      - SUBMITTED
      - PROCESSING
      - DONE

  ReportStage:
    type: string
    enum:
      - CREATED
      - BFX_REVIEW
      - CLINICAL_REVIEW
      - CLINICAL_REVIEW_COMPLETED
      - WAITING_FOR_SIGNOFF
      - WAITING_FOR_RELEASE
      - FINAL
      - DELIVERED

  RunStage:
    type: string
    enum:
      - CREATED
      - SUBMITTED
      - RUNNING
      - WAITING
      - COMPLETED

  SampleStage:
    description: |
      Internal stage of a Sample
    type: string
    enum:
      - ACCESSIONED
      - IN_STORAGE
      - QUEUED
      - STAGED_FOR_SENDOUT
      - SHIPPED_TO_VENDOR
      - AT_VENDOR
      - DATA_AVAILABLE
      - DATA_RECEIVED
      - DATA_CONFLICT
      - DESTROYED

  SendoutStage:
    description: |
      Stage of a Sendout
    type: string
    enum:
      - CREATED
      - VERIFYING
      - READY_TO_SHIP
      - SHIPPED
      - DELIVERED

  VendorOrderStage:
    description: |
      Stage of a vendor order (e.g., StrandOrder, BroadOrder, etc.) managed by Consign
    type: string
    enum:
      - SUBMITTING
      - POLLING
      - HANDING_OFF
      - COMPLETED

  ExternalOrderStatus:
    type: string
    enum:
      - WAITING_FOR_SAMPLE
      - COLLECTING_DATA
      - INTERPRETING
      - REPORTING
      - SUCCEEDED
      - FAILED

  ExternalRequisitionStatus:
    type: string
    enum:
      - QUEUED
      - WAITING_FOR_SAMPLE
      - PROCESSING
      - SUCCEEDED
      - FAILED
