Update Appointment(s)

Updating is done via our PATCH Appointments endpoints.

Update Single Appointment

If you want to update a single appointment, use PATCH Appointment endpoint, passing appointment_id as the path parameter, and including fields you would like to update in JSON body payload:

curl --location --request PATCH 'https://api.leyr.io/api/emrs/{emr}/appointments/{appointment_id}' 
--header 'x-leyr-client-id: {x-leyr-client-id}'
--header 'x-leyr-client-secret: {x-leyr-client-secret}'
--header 'x-leyr-standard: {x-leyr-standard}'
--data-raw '{
    "start": {start},
    "end": {end},
    "resource_id": {resource_id},
    "comment": {comment}
}'

Parameters validation

  • please do not provide status in the payload when you are updating appointments, as it is reserved for cancelling appointments
  • all the fields (start, end, resource_id and comment) are optional by default, so you can only provide those you actually want to update; but start and end have to be provided together

What Leyr does for you?

  • If you provide resource_id, we will check that there are time slots available for selected Resource:
    • if you provide start and end - we will check that range
    • if you don't provide start and end - we assume you want to change the resource at the same time slot, and will use current start and end times of the appointment_id you are updating
  • If you provide start and end, we will check that there are time slots available for selected time range:
    • if you provide resource_id - we will check for that Resource
    • if you don't provide resource_id - we assume you want to reschedule an appointment with the same Resource, and will use current resource_id of the appointment_id you are updating

Update Multiple Appointments

That one may be tricky - we encourage you to familiarize with the logic described below well ๐Ÿ˜‰

If you want to update multiple appointments at once, doing bulk cancel, use our PATCH Appointments. In that case you no longer pass appointment_id in path parameters. Instead, you pass ids in array in JSON body payload, together with the fields you would like to update:

curl --location --request PATCH 'https://api.leyr.io/api/emrs/{emr}/appointments' 
--header 'x-leyr-client-id: {x-leyr-client-id}'
--header 'x-leyr-client-secret: {x-leyr-client-secret}'
--header 'x-leyr-standard: {x-leyr-standard}'
--data-raw '{
    "ids": ["appointment_id_1", "appointment_id_2", "appointment_id_3"],
    "start": {start},
    "end": {end},
    "resource_id": {resource_id},
    "comment": {comment}
}'

Parameters validation

  • please do not provide status in the payload when you are updating appointments, as it is reserved for cancelling appointments
  • all the fields (start, end, resource_id and comment) are optional by default, so you can only provide those you actually want to update; but start and end have to be provided together

What Leyr does for you?

We treat bulk update endpoint in two different "scenarios", based on if you provide start and end parameters or not

  • if you do not provide start and end - we will treat it as pure bulk update:
    • if you provide resource_id - we will validate if there is a time slot available with provided resource_id for each of the provided ids and move all of them to that Resource. If one of the appointments cannot be moved (there is no time slots available) - we will return a BAD_REQUEST response.
  • if you do provide start and end - we will treat it as a continuous reschedule.
    In this case we expect and validate that the ids you provided have the same Patient, Resource, Healthcare Service and Care Unit.
    If all of them do - we will check available time slots at provided start to end time range and will fit provided ids to those time slots.

    That means we will re-use as many appointments as possible, rescheduling them in the new time slots. We will create new appointments with the same Patient, Resource, Healthcare Service and Care Unit, if provided start to end range is longer than that covered by ids. We will cancel extra appointments from provided ids, if provided start to end range is shorter that that covered by ids.\