1. Authentication
Start or cancel an appointment
Before scheduling an appointment with a provider, users must first authenticate themselves by logging in to their patient accounts. The authentication process involves the following steps:
1. Authentication
val res = VseeApi.auth.loginAsPatient(username = username, password = password) when (res) { is Resource.Success -> {} is Resource.Error -> {} }
Initiating Login:
The system calls the
VseeApi.auth.loginAsPatient
function, passing the provided username and password as arguments.
Handling Response:
The function returns a
Resource
object, indicating either success or failure:Success: If authentication is successful, the subsequent code within the
Resource.Success
block executes.Error: If authentication fails, the code within the
Resource.Error
block handles the error appropriately.
This ensures that only authorized patients can access and schedule appointments with providers.
For detailed information about the authentication process, please refer to this document.
2. Create intake
The Intake form, accessed through the 'Schedule an appointment' button, allows patients to update their visit-related information such as reason for visit and consultation type…
Update Reason for visit:
3. Select a consultation
After specifying the reason for their appointment, users need to choose a type of consultation.
val res = VseeApi.visitApi.updateConsultation(intakeId, consultationId) res.doIfSuccess { _updatedIntake.postValue(it) } res.doIfFailure { Timber.e("Unable to update consultation: $it") }
Use this API to retrieve the details of available consultations, including types, slots, and price.
val res = VseeApi.roomApi.getRoom(roomCode = it, timeZone = TimeZone.getDefault().id) res.doIfSuccess { room -> if (room.payment?.consultations?.isEmpty() == true) { error.postValue("No consultation types are available in this room currently.") } else { _consultations.postValue(room.payment!!) } } res.doIfFailure { Timber.e("Unable to get room: $it") }
4. Select appointment time
Once you've chosen a consultation type, select a convenient time slot from those available.
Note: Available appointment slots are managed by providers. If you cannot find a convenient time, reach out to the provider for additional options.
To finalize your selected appointment time, do the following process:
Initiates API Call:
The application invokes the
createVisit
API, passing essential details for visit creation:Intake ID: Unique identifier for the health intake form.
Member ID: ID of the patient scheduling the appointment.
Slot Start: The selected appointment's start time.
Slot End: The selected appointment's end time.
Room Code: Code for the virtual consultation room
Handles API Response:
The API returns a response indicating success or failure:
Success:
It updates the user interface to reflect the successful appointment creation.
Failure:
It informs the user about the failure and prompts them to retry or seek assistance.
val res = VseeApi.visitApi.createVisit( CreateVisitRequest( intakeId = intakeId, memberId = VseeApi.session.getUserId()!!, slotStart = slot.start, slotEnd = slot.end, roomCode = VseeApi.session.getRoomCode() ) ) res.doIfSuccess { Timber.d("Create visit success: $it") _visitCreatedSuccessfully.postValue(slot) } res.doIfFailure { Timber.e("Create visit error: ${res.message}") }
5. Start or cancel an appointment
To retrieve a list of upcoming appointments, call the getVisits
API and set the filter
parameter to 'upcoming'
val request = GetVisitsRequest( roomCode = VseeApi.session.getRoomCode(), accountCode = VseeApi.session.getAccountCode(), filter = "upcoming", extended = true, order = "desc" ) viewModelScope.launch { isLoading.postValue(true) val res = VseeApi.visitApi.getVisits(request) isLoading.postValue(false) when (res) { is Resource.Success -> res.data?.let { data -> _visits.value = data } is Resource.Error -> { Timber.d("Get visits error: ${res.message}") } } }
When the scheduled time arrives, you can choose to start the meeting with your provider or cancel the appointment.
Starting an Appointment:
startActivity(Actions.openPreWaitingRoom(this, visit))
Canceling an Appointment:
viewModelScope.launch { val res = VseeApi.visitApi.closeVisit(visitId, "Close visit on the sample app.") res.doIfSuccess { _closeVisitResult.postValue(true) } res.doIfFailure { _closeVisitResult.postValue(false) } }