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

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

definitions:
  # ================================================================================================
  # Constrained Strings
  ChromosomeRegion:
    type: string
    pattern: '^chr[a-zA-Z0-9]+:\d+-\d+$'
    examples:
      - "chr15:22748502-23372000"
      - "chr6:162475207-163148693" 

  CLIANumber:
    type: string
    pattern: '^\d{2}D[A-Za-z0-9]{7}$'
    examples:
      - "12D3ad2R7q"
      - "34D31532S5"

  ClinicalUsage:
    description: Intended clinical usage for a product
    type: string
    enum:
      - PROACTIVE
      - DIAGNOSTIC
      - NOT_APPLICABLE

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

  Cytoband:
    type: string
    pattern: '^chr[a-zA-Z0-9]+(?:q|p)\d+(\.\d+)?'
    examples:
      - chr15q11.2
      - chr21q22.12

  Date:
    type: string
    format: date

  EmailAddress:
    type: string
    title: Email Address
    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

  HPOTerm:
    type: string
    pattern: '^HP:\d{7}'
    examples:
      - HP:0000006
      - HP:0010574
      - HP:0009834

  ISCNNomenclature:
    type: string
    pattern: '^seq\[GRCh3[78]\].+?x.+?$'
    examples:
      - seq[GRCh37]6q26(162475207_163148693)x3
      - seq[GRCh37]15q11.2(22748502_23372000)x1
      - seq[GRCh37] (X,1-22)x2
      - seq[GRCh37](X,Y)x1,(1-22)x2

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

  PhoneNumber:
    type: string
    pattern: '^\+?\d{1,4}?[-\s]?\(?\d{1,3}?\)?[-\s]?\d{1,4}[-\s]?\d{1,9}?$'
    examples:
      - "+919367788755"
      - "8989829304"
      - "+16308520397"
      - "786-307-3615"
      - "+1-555-555-5555"

  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"

  UUID:
    description: Python UUID
    type: string
    pattern: '^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}'
    examples:
      - "90cd1561-bcc4-46bc-9ba2-19bb2521a28e"
      - "c2a78d62-969f-455e-8b8f-bd5f0efd9273"

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

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

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

  ACMGPlusNegativeClassification:
    type: string
    enum:
      - BENIGN
      - LIKELY_BENIGN
      - VUS
      - LIKELY_PATHOGENIC
      - PATHOGENIC
      - NEGATIVE

  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

  AncestryRace:
    type: string
    capitalize: true
    enum:
      - WHITE
      - HISPANIC
      - BLACK_AFRICAN_AMERICAN
      - EAST_ASIAN
      - SOUTH_ASIAN
      - ASHKENAZI_JEWISH

  BiologicalRelationship:
    description: Relationship to an individual (e.g., family pedigree)
    type: string
    enum:
      - PARENT
      - SIBLING

  BiologicalSex:
    description: Sex assigned at birth
    type: string
    enum:
      - FEMALE
      - MALE
      - OTHER

  BreastCancerGeneticTesting:
    title: Breast Cancer Genetic Testing
    type: string
    anyOf:
      - title: Never
        type: string
        enum:
        - NEVER
      - title: Test result negative
        type: string
        enum:
        - NEGATIVE
      - title: Positive in BRCA1
        type: string
        enum:
        - BRCA1
      - title: Positive in BRCA2
        type: string
        enum:
        - BRCA2
      - title: Unknown
        type: string
        enum:
        - UNKNOWN

  ConsentContext:
    description: Context of a consent grant
    type: string
    enum:
      - PATIENT_PORTAL
      - CLINICIAN_PORTAL
      - PAPER_TRF
      - INSTITUTION

  ConsentTerminationReason:
    description: Reason for termination of a consent grant
    type: string
    enum:
      - REVOCATION
      - EXPIRATION

  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

  DNAVisitServiceType:
    description: Pre- and post-test service types offered by DNAVisit
    type: string
    enum:
      - PRE_TEST_REVIEW_ONLY
      - PRE_TEST_COUNSELING
      - POST_TEST_REVIEW_ONLY
      - POST_TEST_COUNSELING

  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

  GeneticEventType:
    type: string
    description: Type of copy number event
    # Enum values are a subset of GeneticVariationType
    enum:
      - COPY_NUMBER_GAIN
      - COPY_NUMBER_LOSS

  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
    
  InterpretationType:
    type: string
    enum:
      - STRAND
      - NO_INTERPRETATION

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

  MonogenicToplineFinding:
    type: string
    enum:
      - POSITIVE
      - NEGATIVE

  NoteType:
    type: string
    enum:
      - INTERNAL
      - REPORTABLE

  OrganizationProviderRole:
    type: string
    enum:
      - ADMIN
      - DELEGATE
      - CLINICIAN

  PaymentStatus:
    type: string
    enum:
      - PENDING
      - CANCELED
      - SUCCEEDED
      - FREE

  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

  PreferredReportDeliveryMethod:
    title: Preferred Report Delivery Method
    type: string
    enum:
      - FAX
      - EMAIL

  PreTestCounselingType:
    description: Pre-test counseling type requested
    type: string
    enum:
      - NO_COUNSELING
      - PRE_TEST_COUNSELING

  PostTestCounselingType:
    description: ""
    type: string
    enum:
      - NO_COUNSELING
      - ANY_RESULT
      - POSITIVE_RESULT
      - VUS_OR_POSITIVE_RESULT
    enumNames:
      - "No counseling"
      - "For any result"
      - "For a result with a finding"
      - "Unused"

  ProviderLicenseStatus:
    type: string
    enum:
      - UNVERIFIED
      - VERIFIED
      - REVOKED

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

  PRSToplineFinding:
    type: string
    enum:
      - AVERAGE_RISK
      - ELEVATED_RISK
      - HIGH_RISK
      - LOW_RISK
      - INTERMEDIATE_RISK
      - BORDERLINE_RISK

  PRSType:
    type: string
    enum:
      - BREAST_CANCER
      - CORONARY_ARTERY_DISEASE
      - POOLED_COHORT_EQUATION
      - TYPE_2_DIABETES

  RefGenomeBuild:
    type: string
    enum:
      - GRCh37
      - GRCh38

  Relationship:
    description: Relationship to an individual (e.g., insurance policyholder)
    type: string
    enum:
      - SELF
      - SPOUSE
      - CHILD
      - DEPENDENT_HANDICAPPED
      - DEPENDENT_SPONSORED
      - DEPENDENT_OF_MINOR_DEPENDENT
      - EMPLOYEE
      - FOSTER_CHILD
      - GRANDCHILD
      - GRANDPARENT
      - NEPHEW_OR_NIECE
      - STEPCHILD
      - UNKNOWN
      - WARD_OF_COURT
      - OTHER

  ReleasedToPatient:
    type: string
    enum:
      - WORKFLOW_RELEASE
      - MANUAL_RELEASE
      - CURES_RELEASE

  ReleasedToProvider:
    type: string
    enum:
      - WORKFLOW_RELEASE
      - MANUAL_RELEASE

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

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

  RequisitionObservationType:
    type: string
    enum:
      - HPO
      - TC_RISK_SCORE # Tyrer-Cuzick Risk Score
      - NDD_ICD10_CODES
      - CLINICAL_PHENOTYPES__DEVELOPMENTAL_BEHAVIORAL
      - CLINICAL_PHENOTYPES__PERINATAL_HISTORY
      - CLINICAL_PHENOTYPES__CRANIOFACIAL
      - CLINICAL_PHENOTYPES__CARDIAC
      - CLINICAL_PHENOTYPES__NEUROLOGICAL
      - CLINICAL_PHENOTYPES__MUSCULOSKELETAL
      - CLINICAL_PHENOTYPES__CUTANEOUS
      - CLINICAL_PHENOTYPES__GASTROINTESTINAL
      - CLINICAL_PHENOTYPES__GENITOURINARY
      - CLINICAL_PHENOTYPES__GROWTH
      - CLINICAL_PHENOTYPES__OTHER
      - height
      - weight
      - ashkenazi_jewish
      - tyrer_cuzick_inputs
      - smoking
      - diabetes
      - cholesterol
      - blood_pressure
      - body_mass_index
      - diabetes_family_history
      - glucose
      - triglyceride
      - waist_circumference

  SampleType:
    type: string
    title: Sample Type
    enum:
      - SALIVA
      - BLOOD
      - BUCCAL_SWAB
      - DNA
      - DATA
  
  SequencingProtocol:
    type: string
    enum:
      - HC_WGS
      - LC_WGS
      - BGE

  SequencingType:
    type: string
    enum:
      - LONG_READ
      - SHORT_READ

  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

  MenopausalStatus:
    title: Menopausal Status
    type: string
    default: UNKNOWN
    enum:
      - PREMENOPAUSAL
      - PERIMENOPAUSAL
      - POSTMENOPAUSAL
      - UNKNOWN

  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:
      - PENDING_APPROVAL
      - DENIED
      - SUBMITTED
      - PROCESSING
      - COMPLETED

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

  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

  Vendor:
    type: string
    enum:
      - PSOMAGEN
      - BROAD

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

  YesNoUnknown:
    type: string
    default: UNKNOWN
    enum:
      - "YES"
      - "NO"
      - UNKNOWN

  ExternalOrderStatus:
    type: string
    enum:
      - SUBMITTED
      - APPROVED
      - DENIED
      - AWAITING_SAMPLE
      - ANALYZING
      - CLINICIAN_REVIEW
      - COMPLETED
      - CANCELED

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