Skip to main content

Appointments

Appointments ViewController

After initializing the SDK and authenticating the user, you can retrieve the MeetingDoctors Appointments UI using the following method:

errors
  • User not authenticated
MeetingDoctorsError.illegalStateException(reason: .userNotLoged))
public static func appointmentsViewController() async throws -> UIViewController

Example implementation

do {
let appointment = try await MeetingDoctors.appointmentsViewController()
// Handle success
} catch {
// Handle error
}

Healthcare Services ViewController

Once the SDK has been initialized and the user authenticated, the Healthcare Services UI can be retrieved with the following method:

errors
  • User not authenticated
MeetingDoctorsError.illegalStateException(reason: .userNotLoged))
public static func appointmentsHCSViewController() async throws -> UIViewController

Example implementation

do {
let healthcareService = try await MeetingDoctors.appointmentsHCSViewController()
// Handle success
} catch {
// Handle error
}

Notifications

The SDK provides several notification events that can be observed by the integrator through NotificationCenter.

Available Notifications

appointment_user_booked

  • Trigger Condition → Emitted when a user successfully books an appointment.
  • Data ModelMDApptModel

appointment_user_cancelled

  • Trigger Condition → Emitted when a user cancels an appointment.
  • Data ModelMDApptModel

Data Model

The MDApptModel structure provides contextual information about an appointment:

  • appointmentId → The unique identifier of the appointment.
  • healthcareServiceId → The identifier of the healthcare service associated with the appointment.
  • timestamp → The exact date and time when the event was generated.
struct MDApptModel {
var appointmentId: String?
var healthcareServiceId: String?
var timestamp: Date
}

Example: Observing Appointment Notifications

// Observe appointment booked event
NotificationCenter.default.addObserver(
self,
selector: #selector(self.appointment(notification:)),
name: Notification.Name.MeetingDoctors.Appointments.appointment_user_booked,
object: nil
)

// Observe appointment cancelled event
NotificationCenter.default.addObserver(
self,
selector: #selector(self.appointment(notification:)),
name: Notification.Name.MeetingDoctors.Appointments.appointment_user_cancelled,
object: nil
)

// Event handler
@objc func appointment(notification: Notification) {
let item = notification.object as? MDApptModel
NSLog("[ViewController] - Appointment event: \(notification.name), model: \(String(describing: item)))")
}