Appointment Service

The AppointmentService provides the ability to retrieve upcoming scheduled appointments, as well as cancel them.

Currently, only Retail visits are able to be scheduled, whereas Virtual visits are on-demand. AppointmentService is only capable of fetching and cancelling Retail visits for this reason. Virtual visits are cancellable through a separate method in VirtualService.

Fetching the user’s scheduled visits

The AppointmentService.getRetailVisits() method returns a list of ScheduledVisit objects, each representing an upcoming appointment scheduled by the user.

The ScheduledVisit object contains various information about the upcoming visit:

  • appointmentDetails - An object containing additional details about the appointment, such as start/end times, timezone, and appointmentId.
  • clinic - An object containing information about the clinic where the visit was scheduled. Present only for Retail visit type, null otherwise.
  • type - An enum representing the type of visit: Retail, Virtual (not applicable at this time) or At Home (not applicable at this time).
  • status - An enum representing the current status of a ScheduledVisit, e.g. Requested, InVisit, Done, Cancelled, etc.

Full object documentation can be found in the Android and iOS SDK documentation.

  • let dexcareSDK = DexcareSDK(configuration: ...)
    dexcareSDK.appointmentService.getRetailVisits(
        success: { retailVisits in
            // display the upcoming visits to the user.
            // you can also give the option to cancel a visit, which will be explained below.
         },
         failure: { error in
               // handle the error, show an error dialog, log the error, etc.
         }
     )
    
    
  • DexCareSDK.appointmentService.getRetailVisits()
        .subscribe({ scheduledVisitsList ->
            // display the upcoming visits to the user.
            // you can also give the option to cancel a visit, which will be explained below.
        }, { error ->
            // handle the error, show an error dialog, log the error, etc.
        })
    

Cancelling a visit

AppointmentService also provides the ability to cancel a scheduled visit.

Two SDK calls are necessary to cancel a scheduled visit, as detailed below.

Getting the list of cancel reasons

The first step to cancelling a Scheduled Visit is to retrieve the list of accepted cancellation reasons. These cancellation reasons can be customized for your health system by the DexCare team.

The AppointmentService.getCancelReasons method returns a list of CancelReason objects. The list should be displayed to the user, allowing them to select one. The selected CancelReason should then be passed back in to the SDK during the final cancellation call.

  • let dexcareSDK = DexcareSDK(configuration: ...)
    
    // get cancel reasons. brandName will be given to you by your Dexcare Contact
    dexcareSDK.appointmentService.getCancelReasons(
        brandName: brandName,
        success: { cancelReasons in
            // save cancelReasons array locally so user can pick which reason when cancelling a scheduledVisit
    
        },
        failure: { error in
            // Should never happen. If continues contact your Dexcare Contact
        }
    )
    
  • DexCareSDK.appointmentService.getCancelReasons()
        .subscribe({ cancellationReasons ->
            // display the cancellation reasons to the user and allow them to select one
        }, { error ->
            // handle the error, show an error dialog, log the error, etc.
        })
    

Cancelling the visit

After obtaining the user’s CancelReason, the scheduled visit is able to be cancelled using the AppointmentService.cancelRetailVisit() method.

  • dexcareSDK.appointmentService.cancelRetailAppointment(
       appointmentId: scheduledVisit.appointmentDetails.appointmentId,
       cancelReason: cancelReason,
       success: {
           // the visit was successfully cancelled
       },
       failure: { error in
            // handle the error, show an error dialog, log the error, etc.
       }
    )
    
  • DexCareSDK.appointmentService.cancelRetailVisit(
            scheduledVisit.appointmentDetails.appointmentId,
            cancelReason
        ).subscribe({
            // the visit was successfully cancelled
        }, { error ->
            // handle the error, show an error dialog, log the error, etc.
        })