definitions:
  Insurance:
    title: Insurance information
    type: object
    unevaluatedProperties: false
    required:
      - company
      - member_id
      - relationship_to_policyholder
    properties:
      company:
        title: Name of the insurance company
        type: string
      phone:
        title: Insurance company phone
        type: string
      member_id:
        title: Insurance member ID
        type: string
      prior_auth_number:
        title: Prior-authorization number
        type: string
      relationship_to_policyholder:
        title: "Patient Relationship to Policyholder"
        description: ""
        $ref: "../core.json#/definitions/Relationship"
    dependencies:
      relationship_to_policyholder:
        oneOf:
          - properties:
              relationship_to_policyholder:
                enum:
                  - SELF
          - properties:
              relationship_to_policyholder:
                enum:
                  - SPOUSE
                  - CHILD
                  - DEPENDENT_HANDICAPPED
                  - DEPENDENT_SPONSORED
                  - DEPENDENT_OF_MINOR_DEPENDENT
                  - EMPLOYEE
                  - FOSTER_CHILD
                  - GRANDCHILD
                  - GRANDPARENT
                  - NEPHEW_OR_NIECE
                  - STEPCHILD
                  - UNKNOWN
                  - WARD_OF_COURT
              policyholder:
                $ref: "#/definitions/Policyholder"
            required:
              - policyholder
          - properties:
              relationship_to_policyholder:
                enum:
                  - OTHER
              relationship_to_policyholder_other:
                title: "Patient Relationship to Policyholder Other"
                type: string
              policyholder:
                $ref: "#/definitions/Policyholder"
            required:
              - relationship_to_policyholder_other
          

  Policyholder:
    title: Policyholder
    type: object
    required:
      - name
      - demographics
    properties:
      name:
        title: Policy Holder Name
        $ref: "../structs.json#/definitions/Name"
        required:
          - first
          - last
      demographics:
        title: Demographics
        type: object
        required:
          - dob
          - sex
        properties:
          dob:
            title: Policyholder Date of Birth
            $ref: '../core.json#/definitions/Date'
            description: 'mm/dd/yyyy'
          sex:
            title: Policyholder Sex
            $ref: '../core.json#/definitions/BiologicalSex'
      contact_info:
        title: Contact Info
        type: array
        minItems: 1
        maxItems: 1
        items:
          type: object
          required:
            - address
          properties:
            prefill_button:
              type: string
              title: Prefill Button
            address:
              title: Policyholder Address
              $ref: '../structs.json#/definitions/Address'