title: "Rare Disease Report Writing"
type: "object"

properties:
  toplines:
    title: Topline Finding(s)
    type: array
    minItems: 1
    maxItems: 5
    items:
      allOf:
      - $ref: '../../structs.json#/definitions/ToplineFinding'
      - properties:
          finding:
            $ref: '../../core.json#/definitions/RareDiseaseToplineFinding'
  classifications:
    title: Classifications
    minItems: 1
    type: array
    items:
      allOf:
        - type: object
          properties:
            finding_type:
              $ref: '../../core.json#/definitions/FindingType'
            classification:
              $ref: '../../core.json#/definitions/ACMGPlusNegativeClassification'
        - allOf:
            - if:
                properties:
                  classification:
                    const: "NEGATIVE"
              then:
                $ref: '#/definitions/RareDiseaseNegativeClassification'
            - if:
                properties:
                  finding_type:
                    const: "RARE_DISEASE"
              then:
                $ref: '#/definitions/RareDiseaseClassification'
            - if:
                properties:
                  finding_type:
                    const: "RARE_DISEASE_CNV"
              then:
                $ref: '#/definitions/RareDiseaseCNVClassification'
            - if:
                properties:
                  finding_type:
                    const: "RARE_DISEASE_MITO"
              then:
                $ref: '#/definitions/RareDiseaseMitoClassification'
            - if:
                properties:
                  finding_type:
                    const: "RARE_DISEASE_TRE"
              then:
                $ref: '#/definitions/RareDiseaseTREClassification'
  next_steps:
    $ref: '../../structs.json#/definitions/ReportNextSteps'
  sample_limitations:
    title: Sample Limitations
    type: array
    items:
      type: string

definitions:
  RareDiseaseNegativeClassification:
    type: object
    required:
      - classification
    properties:
      classification:
        const: "NEGATIVE"

  RareDiseaseClassification:
    type: object
    additionalProperties: false
    required:
      - classification
    properties:
      variantfinding_id:
        $ref: '../../ids.json#/definitions/VariantFindingId'
      finding_type:
        const: "RARE_DISEASE"
      gene_symbol:
        title: Location (Gene Symbol)
        type: string
      condition:
        title: Condition
        type: string
      event:
        title: Variant Event
        type: [ "string", "null" ]
      inheritance:
        type: object
        properties:
          mode:
            title: Mode of Inheritance
            $ref: '../../core.json#/definitions/Inheritance'
          zygosity:
            title: Zygosity
            $ref: '../../core.json#/definitions/Zygosity'
          pattern:
            title: Inherited From
            $ref: '../../core.json#/definitions/VariantInheritance'
      classification:
        title: ACMG Classification
        $ref: '../../core.json#/definitions/ACMGPlusNegativeClassification'
      phenotype:
        title: Interpretation Summary
        type: object
        properties:
          evidence_summary:
            title: Description
            type: string
      variation:
        title: Variant Summary
        $ref: '../../structs.json#/definitions/RareDiseaseVariation'
      variant_description:
        title: Evidence
        type: [ "string", "null" ]
      gene_info:
        title: Gene Information
        type: string
  
  RareDiseaseCNVClassification:
    type: object
    additionalProperties: false
    required:
      - classification
    properties:
      variantfinding_id:
        $ref: '../../ids.json#/definitions/VariantFindingId'
      finding_type:
        const: "RARE_DISEASE_CNV"
      cytoband:
        title: Location (Cytoband)
        $ref: '../../core.json#/definitions/Cytoband'
      condition:
        title: Condition
        type: string
      event:
        title: Variant Event
        $ref: '../../core.json#/definitions/GeneticEventType'
      copy_number:
        title: Copy Number
        $ref: '../../core.json#/definitions/CopyNumber'
      inheritance:
        type: object
        properties:
          mode:
            title: Mode of Inheritance
            $ref: '../../core.json#/definitions/Inheritance'
          zygosity:
            title: Zygosity
            $ref: '../../core.json#/definitions/Zygosity'
          pattern:
            title: Inherited From
            $ref: '../../core.json#/definitions/VariantInheritance'
      classification:
        title: ACMG Classification
        $ref: '../../core.json#/definitions/ACMGPlusNegativeClassification'
      phenotype:
        title: Interpretation Summary
        type: object
        properties:
          evidence_summary:
            title: Description
            type: string
      variation:
        title: Variant Summary
        $ref: '../../structs.json#/definitions/RareDiseaseVariation'
      iscn_nomenclature:
        title: ISCN Nomenclature
        $ref: '../../core.json#/definitions/ISCNNomenclature'
      variant_description:
        title: Evidence
        type: [ "string", "null" ]
  
  RareDiseaseMitoClassification:
    type: object
    additionalProperties: false
    required:
      - classification
    properties:
      variantfinding_id:
        $ref: '../../ids.json#/definitions/VariantFindingId'
      finding_type:
        const: "RARE_DISEASE_MITO"
      gene_symbol:
        title: Location (Gene Symbol)
        type: string
      condition:
        title: Condition
        type: string
      event:
        title: Variant Event
        type: [ "string", "null" ]
      inheritance:
        type: object
        properties:
          mode:
            title: Mode of Inheritance
            $ref: '../../core.json#/definitions/Inheritance'
          zygosity:
            title: Zygosity
            $ref: '../../core.json#/definitions/Zygosity'
          pattern:
            title: Inherited From
            $ref: '../../core.json#/definitions/VariantInheritance'
          percent_heteroplasmy:
            title: Percent Heteroplasmy
            $ref: '../../core.json#/definitions/PercentHeteroplasmy'
      classification:
        title: ACMG Classification
        $ref: '../../core.json#/definitions/ACMGPlusNegativeClassification'
      phenotype:
        title: Interpretation Summary
        type: object
        properties:
          evidence_summary:
            title: Description
            type: string
      variation:
        title: Variant Summary
        $ref: '../../structs.json#/definitions/RareDiseaseVariation'
      variant_description:
        title: Evidence
        type: [ "string", "null" ]
      gene_info:
        title: Gene Information
        type: string

  RareDiseaseTREClassification:
    type: object
    additionalProperties: false
    required:
      - classification
    properties:
      variantfinding_id:
        $ref: '../../ids.json#/definitions/VariantFindingId'
      finding_type:
        const: "RARE_DISEASE_TRE"
      gene_symbol:
        title: Location (Gene Symbol)
        type: string
      condition:
        title: Condition
        type: string
      alleles:
        title: Alleles
        type: array
        items:
          type: object
          properties:
            event:
              title: Variant Event
              type: string
            classification:
              title: Allele Classification
              $ref: '../../core.json#/definitions/ACMGPlusNegativeClassification'
            number:
              type: integer
      inheritance:
        type: object
        properties:
          mode:
            title: Mode of Inheritance
            $ref: '../../core.json#/definitions/Inheritance'
          zygosity:
            title: Zygosity
            $ref: '../../core.json#/definitions/Zygosity'
          pattern:
            title: Inherited From
            $ref: '../../core.json#/definitions/VariantInheritance'
      classification:
        title: ACMG Classification
        $ref: '../../core.json#/definitions/ACMGPlusNegativeClassification'
      phenotype:
        title: Interpretation Summary
        type: object
        properties:
          evidence_summary:
            title: Description
            type: string
      variation:
        title: Variant Summary
        $ref: '../../structs.json#/definitions/RareDiseaseVariation'
      variant_description:
        title: Evidence
        type: [ "string", "null" ]
      gene_info:
        title: Gene Information
        type: string