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

title: "MyOme json report"
description: "MyOme report object"
type: "object"


allOf:
  - $ref: "base.json"
  - type: object
    properties:
      report_type:
        type: string
        const: "PGX"
      results:
        type: object
        properties:
          pgx_findings:
            type: array
            items:
              $ref: "#/definitions/PGxReportResults"
          drug_guidance:
            type: array
            items:
              $ref: "#/definitions/PGxDrugGuidance"

definitions:
  PGxReportResults:
    description: >-
      PGxreportResults is the editable, versioned component of a MyOme
      PGx report.
    type: object
    additionalProperties: false
    $ref: "../../structs.json#/definitions/PGxFinding"
      
      
  PGxDrugGuidance:
    type: object
    properties:
      drug:
        type: string
        examples:
          - amphetamine
          - codeine
      genes:
        description: list of dictionaries with gene and phenotype corresponding to a drug impact
        type: array
        items:
          $ref: "#/definitions/GenePhenotypeMap"
      therapeutic_area:
        type: string
        description: future plans for drug categories to reference an enum (SC-7141)
        examples:
          - BEHAVIORAL_HEALTH
          - PAIN_MANAGEMENT
          - CARDIOLOGY
      toplines:
        description: future plans for finding in toplines to reference an enum (SC-7141)
        type: array
        minItems: 1
        items:
          $ref: "../../structs.json#/definitions/ToplineFinding"
        example:
          - finding: CONTRAINDICATED
            text: Avoid codeine use because of potential for serous toxicity. If opioid use is warranted, consider a non-tramadol opioid.
  
  GenePhenotypeMap:
    type: object
    $ref: "../../structs.json#/definitions/PGxFinding"
    properties:
      gene_phenotype: true
      gene_symbol: true
      raw_call: false
      rsid_based: false
      reference: false
    examples:
      - gene_phenotype: "NORMAL_FUNCTION"
        genotype:
          gene_symbol: "CYP2C19"
      - gene_phenotype: "DECREASED_FUNCTION"
        genotype:
          gene_symbol: "CYP2C9"
