Error Codes

Overview

When an error occurs, the API returns a JSON response containing error details. The response includes a general error code and an array of detailed errors. Each detailed error provides specific information about what went wrong.

Error Response Structure

{
    "code": "BAD_REQUEST",
    "detail": "Bad request. Check documentation if you send all the fields in a proper format.",
    "errors": [
        {
            "details": "The timeslot for the given parameters was not found",
            "emr_error": null,
            "error_code": "NO_TIMESLOTS_AVAILABLE",
            "path": null
        }
    ],
    "instance": "d3e84cc1-148a-4edf-9579-5dcef1d6dbfa",
    "status": 400,
    "title": "Request validation failed",
    "type": "https://docs.leyr.io/api/error-handling/bad_request"
}

Note: Multiple detailed errors may be returned in the errors array. For example, if a request contains an invalid parameter and no available timeslot, both errors will be included in the response.

400 Bad Request

Error CodeDefault Description
INVALID_PATIENT_IDProvided patient_id is not valid
INVALID_CARE_UNIT_IDProvided care_unit_id is not valid
INVALID_HEALTHCARE_SERVICE_IDProvided healthcare_service_id is not valid
INVALID_RESOURCE_IDProvided resource_id is not valid
INVALID_APPOINTMENT_IDProvided appointment_id is not valid
NO_TIMESLOTS_AVAILABLENo timeslots available for the given parameters
INVALID_COMMENT_LENGTHProvided comment is too long
INVALID_CREATED_BY_IDProvided created_by_id is not valid
INVALID_NOTE_CONTENTProvided content for medical note is not valid
MISSING_REQUIRED_FIELDMissing required field in the request
MAX_ITEMS_EXCEEDEDMax items exceeded
BAD_INPUTInvalid input, EHR rejected your request
PATIENT_ID_LOOKUP_TYPE_NOT_SUPPORTEDEHR does not support patient lookup by the given lookup type
INVALID_PATIENT_ID_TYPEProvided patient id type is not valid
AMBIGUOUS_TIMESLOTSMore than one timeslot found for the given parameters
NOT_SUPPORTEDNot supported
BAD_TIME_RANGEBad time range. End time must be greater than start time
MEDICAL_NOTE_MAPPING_BAD_MAPPINGMedical note mapping is not configured correctly for provided template id
INVALID_PARAMETEROne or more provided parameters are invalid
INVALID_CONFIRMATION_CODEInvalid confirmation code for the appointment
INVALID_POSTAL_CODEProvided postal code is not valid
INVALID_COUNTRYProvided country is not valid
INVALID_PAGINATION_TOKENProvided pagination token is not valid
INVALID_TEMPLATE_IDProvided template_id is not valid
AMBIGUOUS_PATCH_PARAMSCannot both reschedule/change and confirm/cancel an appointment in the same request
INVALID_PATCH_PARAMSPatch params must include either reschedule/change or confirm/cancel set of parameters
RESCHEDULE_NOT_POSSIBLERescheduling is not possible for the given appointment
CANCEL_NOT_POSSIBLECancelling is not possible for the given appointment
CHANGE_NOT_POSSIBLEChanging is not possible for the given appointment
CONFIRMATION_NOT_REQUIREDThe given EHR does not require confirmation for scheduling or canceling the appointment
AMBIGUOUS_HEALTHCARE_SERVICESMore than one healthcare service found for the given parameters
AMBIGUOUS_PATIENTSMore than one patient found for the given parameters
AMBIGUOUS_RESOURCESMore than one resource found for the given parameters

401 Unauthorized

Error CodeDefault Description
BAD_CREDENTIALSBad EHR credentials provided for the request
FAILED_EMR_AUTHFailed to authenticate with the EHR

403 Forbidden

Error CodeDefault Description
NO_DATA_ACCESSEHR responded with data access error
CORRUPTED_OR_INVALID_TOKENAuth token you provided is corrupted or invalid

404 Not Found

Error CodeDefault Description
APPOINTMENT_NOT_FOUNDGiven appointment couldn't be found in the EHR
PATIENT_NOT_FOUNDGiven patient couldn't be found in the EHR
CARE_UNIT_NOT_FOUNDGiven care unit couldn't be found in the EHR
RESOURCE_NOT_FOUNDGiven resource couldn't be found in the EHR
INSTANCE_CONFIG_NOT_FOUNDInstance config not found
HEALTHCARE_SERVICE_NOT_FOUNDGiven healthcare service couldn't be found in the EHR
MEDICAL_NOTE_MAPPING_NOT_FOUNDMedical note mapping not found for provided template id

409 Conflict

Error CodeDefault Description
PATIENT_ALREADY_EXISTSThe EHR reported that the given patient already exists in their records

500 Internal Server Error

Error CodeDefault Description
UNEXPECTED_EMR_CHANGEThere seem to be an unexpected change in the EHR

501 Not Implemented

Error CodeDefault Description
MEDICAL_NOTE_TEMPLATE_NOT_IMPLEMENTEDThis medical note template is not implemented for the given EHR