{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/getlabs/json-schema/getlabs-patient-update-dto-schema.json",
  "title": "PatientUpdateDto",
  "x-generated": "2026-12-02",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/getlabs-openapi.yml#/components/schemas/PatientUpdateDto",
  "type": "object",
  "properties": {
    "externalId": {
      "type": [
        "string",
        "null"
      ],
      "description": "External identifier for the patient."
    },
    "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"
        }
      ]
    },
    "firstName": {
      "type": "string",
      "description": "First name (editing only allowed if patient.editable=true)."
    },
    "lastName": {
      "type": "string",
      "description": "Last name (editing only allowed if patient.editable=true)."
    },
    "birthSex": {
      "description": "Birth sex (editing only allowed if patient.editable=true).",
      "allOf": [
        {
          "$ref": "#/$defs/UserGender"
        }
      ]
    },
    "email": {
      "type": [
        "string",
        "null"
      ],
      "format": "email",
      "description": "Email address (editing only allowed if patient.editable=true)."
    },
    "phoneNumber": {
      "type": [
        "string",
        "null"
      ],
      "minLength": 10,
      "maxLength": 10,
      "description": "10 digit phone number (editing only allowed if patient.editable=true)."
    },
    "pronouns": {
      "type": [
        "string",
        "null"
      ],
      "description": "The patient's preferred pronouns (editing only allowed if patient.editable=true)."
    },
    "notes": {
      "type": [
        "string",
        "null"
      ],
      "description": "Notes for the patient (editing only allowed if patient.editable=true). If a null value is passed, existing notes will be deleted."
    },
    "communicationSettings": {
      "description": "Communication settings updates. Only the alternate contact and SMS opt-in can be updated; settings left out keep their current values.",
      "allOf": [
        {
          "$ref": "#/$defs/PatientCommunicationSettingsDto"
        }
      ]
    }
  },
  "$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."
    }
  }
}