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

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

definitions:
  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
  
  CURIE:
    type: string
    pattern: '^[A-Za-z]\w+:\S+$'

  Date:
    type: string
    format: date

  EmailAddress:
    type: string
    format: email

  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

  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

  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

  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

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

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

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

  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
      - DESTROYED

  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

  ReportStatus:
    type: string
    enum:
      - DRAFT
      - FINAL

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

  RunStatus:
    type: string
    enum:
      - CREATED
      - SUBMITTED
      - RUNNING
      - ERROR
      - COMPLETED
      - WAITING

  SampleType:
    type: string
    enum:
      - SALIVA
      - BLOOD

  UTCTimestamp:
    description: UTC timestamp in ISO-8601 format. e.g., `2018-11-13T20:20:39+00:00`
    type: string
    format: date-time
    pattern: '\+00:00$'
    examples:
      - '2018-11-13T20:20:39+00:00'

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

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

