{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/getlabs/json-schema/getlabs-patient-dto-schema.json",
  "title": "PatientDto",
  "x-generated": "2026-12-02",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/getlabs-openapi.yml#/components/schemas/PatientDto",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid",
      "description": "The patient's ID."
    },
    "externalId": {
      "type": [
        "string",
        "null"
      ],
      "description": "External identifier for the patient."
    },
    "email": {
      "type": [
        "string",
        "null"
      ],
      "format": "email",
      "description": "Email address."
    },
    "phoneNumber": {
      "type": [
        "string",
        "null"
      ],
      "minLength": 10,
      "maxLength": 10,
      "description": "10 digit phone number."
    },
    "firstName": {
      "type": "string",
      "description": "First name."
    },
    "lastName": {
      "type": "string",
      "description": "Last name."
    },
    "dob": {
      "type": "string",
      "description": "Date of birth (YYYY-MM-DD).",
      "format": "date"
    },
    "birthSex": {
      "description": "Birth sex.",
      "allOf": [
        {
          "$ref": "#/$defs/UserGender"
        }
      ]
    },
    "pronouns": {
      "type": [
        "string",
        "null"
      ],
      "description": "The patient's preferred pronouns."
    },
    "editable": {
      "type": "boolean",
      "description": "Indicates if the patient's details are editable."
    },
    "guardian": {
      "description": "The patient's guardian, this is required if the patient is under 18 years old.",
      "allOf": [
        {
          "$ref": "#/$defs/GuardianDto"
        }
      ]
    },
    "insurance": {
      "description": "Images of the patient's insurance.",
      "allOf": [
        {
          "$ref": "#/$defs/InsuranceDto"
        }
      ]
    },
    "communicationSettings": {
      "description": "The patient's communication settings. New patients are opted in to SMS unless `optInSms` is `false`.",
      "allOf": [
        {
          "$ref": "#/$defs/PatientCommunicationSettingsDto"
        }
      ]
    }
  },
  "required": [
    "firstName",
    "lastName",
    "dob",
    "birthSex"
  ],
  "$defs": {
    "AlternateContactDto": {
      "type": "object",
      "properties": {
        "phoneNumber": {
          "type": "string",
          "minLength": 10,
          "maxLength": 10,
          "description": "10 digit phone number of the alternate contact."
        },
        "name": {
          "type": "string",
          "description": "Name of the alternate contact."
        },
        "relationship": {
          "type": "string",
          "description": "Relationship of the alternate contact to the patient (e.g. 'caregiver', 'relative', 'facility')."
        },
        "isPrimary": {
          "type": "boolean",
          "description": "Whether this alternate contact should be treated as the patient's primary contact."
        }
      },
      "required": [
        "phoneNumber",
        "name",
        "relationship"
      ]
    },
    "FileDto": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "readOnly": true,
          "format": "uuid"
        },
        "name": {
          "type": "string",
          "description": "File name"
        },
        "purpose": {
          "description": "The purpose of this file, must be one of the available options",
          "allOf": [
            {
              "$ref": "#/$defs/FilePurpose"
            }
          ]
        },
        "data": {
          "type": "string",
          "description": "Base64 encoded file contents, maximum size of 25 MB. The file MIME types allowed differ depending on the file \"purpose\":\n* lab-order can be one of: image/png, image/jpeg, image/heic, image/heif, image/tiff, application/pdf\n* collection-instructions can be one of: image/png, image/jpeg, image/heic, image/heif, image/tiff, application/pdf\n* insurance-front, insurance-rear can be one of: image/png, image/jpeg, image/heic, image/heif, image/tiff, application/pdf",
          "writeOnly": true
        },
        "size": {
          "type": "number",
          "description": "The file size in bytes",
          "readOnly": true
        },
        "type": {
          "type": "string",
          "description": "Type of the file.",
          "readOnly": true
        }
      },
      "required": [
        "name",
        "purpose",
        "data",
        "size",
        "type"
      ]
    },
    "FilePurpose": {
      "type": "string",
      "enum": [
        "lab-order",
        "collection-instructions",
        "insurance-front",
        "insurance-rear"
      ],
      "description": "The purpose of this file, must be one of the available options"
    },
    "GuardianDto": {
      "type": "object",
      "properties": {
        "name": {
          "type": [
            "string",
            "null"
          ],
          "description": "Name of the patient's guardian, this is required if the patient is under 18 years old"
        },
        "relationship": {
          "type": [
            "string",
            "null"
          ],
          "description": "Patient's relationship to the guardian, this is required if the patient is under 18 years old"
        }
      }
    },
    "InsuranceDto": {
      "type": "object",
      "properties": {
        "front": {
          "description": "The file object representing the image of the front of the insurance",
          "readOnly": true,
          "type": [
            "object",
            "null"
          ],
          "allOf": [
            {
              "$ref": "#/$defs/FileDto"
            }
          ]
        },
        "rear": {
          "description": "The file object representing the image of the rear of the insurance",
          "readOnly": true,
          "type": [
            "object",
            "null"
          ],
          "allOf": [
            {
              "$ref": "#/$defs/FileDto"
            }
          ]
        },
        "frontId": {
          "type": [
            "string",
            "null"
          ],
          "description": "A file ID with a purpose of 'insurance-front' uploaded using the file endpoint, or null to remove the existing image",
          "format": "uuid",
          "writeOnly": true
        },
        "rearId": {
          "type": [
            "string",
            "null"
          ],
          "description": "A file ID with a purpose of 'insurance-rear' uploaded using the file endpoint, or null to remove the existing image",
          "format": "uuid",
          "writeOnly": true
        }
      }
    },
    "PatientCommunicationSettingsDto": {
      "type": "object",
      "properties": {
        "alternateContact": {
          "description": "Alternate contact for the patient.",
          "type": [
            "object",
            "null"
          ],
          "allOf": [
            {
              "$ref": "#/$defs/AlternateContactDto"
            }
          ]
        },
        "optInSms": {
          "type": "boolean",
          "description": "Whether the patient gets appointment reminders and updates by SMS (never marketing). Defaults to `true` on create; partners must have patient consent."
        }
      }
    },
    "UserGender": {
      "type": "string",
      "enum": [
        "male",
        "female",
        "other"
      ],
      "description": "Birth sex."
    }
  }
}