# Intake & Visit API URL: https://developers.vsee.com/guides/clinickit/ios-intake-visit-api ### Intake An intake is the registration information collected from a patient when they visit a healthcare facility. #### Intake configuration `IntakeConfig` holds the information used to create an intake. **Properties** - `type`: the type of intake. Defaults to `.walkin`. - `reasonForVisit`: the reason for the visit. - `room`: the room for the intake. Defaults to the default room from `VCNetworkManager.shared()`. **Initialization** - `init(reasonForVisit:)`: creates an `IntakeConfig` with the given reason for visit. #### Create an intake Creates an intake from the given configuration. ```swift public func createIntake(with config: IntakeConfig, sucesss: @escaping (Intake) -> Void, failure: @escaping (Error) -> Void) ``` | Parameter | Type | Description | | --- | --- | --- | | `config` | `IntakeConfig` | The intake configuration. | | `success` | `Closure` | Called when the intake is created. Receives the `Intake`. | | `failure` | `Closure` | Called when creating the intake fails. Receives an `Error`. | #### Update an intake Updates the current intake with the given parameters. ```swift public func updateIntake(with params: [String: Any], sucesss: @escaping () -> Void, failure: @escaping (Error) -> Void) ``` | Parameter | Type | Description | | --- | --- | --- | | `params` | `[String: Any]` | The parameters to update on the intake. | | `success` | `Closure` | Called when the intake is updated. | | `failure` | `Closure` | Called when updating the intake fails. Receives an `Error`. | ### Visit A visit is an appointment or session of patient care. It stores details such as the appointment time, the provider and the intake. #### Create a visit from an intake Creates a visit for the given intake. ```swift public func createVisitWithIntake(_ intake: Intake, success: @escaping (Visit) -> Void, failure: @escaping (Error) -> Void) ``` | Parameter | Type | Description | | --- | --- | --- | | `intake` | `Intake` | The intake for the visit. | | `success` | `Closure` | Called when the visit is created. Receives the `Visit`. | | `failure` | `Closure` | Called when creating the visit fails. Receives an `Error`. | ### Schedule a visit For the complete booking flow, see [Schedule an appointment](https://developers.vsee.com/guides/clinickit/schedule-appointment). #### Get the consultation list Returns the consultations the patient can see. The function gets the current room from `VCNetworkManager`, loads the room's consultations, and filters out those that aren't visible to the patient. ```swift public func getConsultationList() throws -> [Consultation]? ``` **Returns:** an optional array of the `Consultation` objects visible to the patient, or `nil` if there are no valid consultations. **Throws:** a `ClinicError` if the current room is unavailable or the consultations can't be loaded. ##### Example usage ```swift let visibleConsultations = VisitService.shared.getConsultationList() ``` #### Update an intake with a consultation Updates the given intake on the server with the details of the chosen consultation. ```swift public func updateIntakeWithConsultation(intake: Intake, consultation: Consultation, sucesss: @escaping () -> Void, failure: @escaping (Error) -> Void) ``` | Parameter | Type | Description | | --- | --- | --- | | `intake` | `Intake` | The intake to update. | | `consultation` | `Consultation` | The consultation whose details are added to the intake. | | `success` | `Closure` | Called when the update succeeds. | | `failure` | `Closure` | Called when the update fails. Receives an `Error` with the details. | ##### Example usage ```swift let intake = Intake.createOnServer(with: config) // The intake to update let selectedConsultation = // the consultation the patient chose VisitService.shared.updateIntakeWithConsultation(intake: intake, consultation: selectedConsultation, success: { // Intake updated print("Intake updated successfully") }, failure: { error in // Handle the error print("Failed to update intake: \(error)") }) ``` #### Schedule a visit for an intake Schedules a visit with the given intake, an optional provider, and a room slot. ```swift public func scheduleVisit(intake: Intake, provider: Provider?, slot: RoomSlot, sucesss: @escaping (Visit?) -> Void, failure: @escaping (Error?) -> Void) ``` | Parameter | Type | Description | | --- | --- | --- | | `intake` | `Intake` | The intake for the scheduled visit. | | `provider` | `Provider` | Optional. The provider for the visit. | | `slot` | `RoomSlot` | The time slot to book. A `RoomSlot` holds the visit's start and end times and whether the slot is booked or open. | | `success` | `Closure` | Called when the visit is scheduled. Receives the created `Visit`. | | `failure` | `Closure` | Called when scheduling fails. Receives an `Error` with the cause. | ##### Example usage ```swift let intake = Intake.createOnServer(with: config) let selectedProvider = Provider() // the provider chosen from the list let selectedSlot = RoomSlot() // the slot chosen from the room's open slots VisitService.shared.scheduleVisit(intake: intake, provider: selectedProvider, slot: selectedSlot, success: { visit in // Visit scheduled }, failure: { error in // Handle the error }) ``` ### List visits #### Get the current visit Gets the visit that is in progress. | Parameter | Type | Description | | --- | --- | --- | | `success` | `Closure` | Called when the current visit is loaded. Receives the in-progress `Visit`. | | `failure` | `Closure` | Called when loading fails. Receives an `Error` with the cause. | ##### Example usage ```swift VisitService.shared.getCurrentVisit(success: { visit in // Handle the current visit print("Current Visit: \(visit)") }, failure: { error in // Handle the error print("Failed to retrieve current Visit with error: \(error)") }) ``` #### Get upcoming visits Gets the list of upcoming visits. | Parameter | Type | Description | | --- | --- | --- | | `success` | `Closure` | Called when the upcoming visits are loaded. Receives an array of `Visit` objects. | | `failure` | `Closure` | Called when loading fails. Receives an `Error` with the cause. | ##### Example usage ```swift VisitService.shared.getUpcomingVisit(success: { visits in // Handle the upcoming visits print("Upcoming Visits: \(visits)") }, failure: { error in // Handle the error print("Failed to retrieve upcoming Visits with error: \(error)") }) ``` #### Get past visits Gets the list of past visits. | Parameter | Type | Description | | --- | --- | --- | | `success` | `Closure` | Called when the past visits are loaded. Receives an array of `Visit` objects. | | `failure` | `Closure` | Called when loading fails. Receives an `Error` with the cause. | ##### Example usage ```swift VisitService.shared.getPastVisit(success: { visits in // Handle the past visits print("Past Visits: \(visits)") }, failure: { error in // Handle the error print("Failed to retrieve past Visits with error: \(error)") }) ``` ### Enter the waiting room For the complete flow, see [Enter waiting room](https://developers.vsee.com/guides/clinickit/enter-waiting-room). #### Enter the waiting room with the native view Starts the visit in a native view. ```swift public func enterWaitingRoomByNativeViewWithVisit(_ visit: Visit) ``` | Parameter | Type | Description | | --- | --- | --- | | `visit` | `Visit` | The visit whose waiting room to enter. | ##### Example usage ```swift let visit = // the Visit to start // Start the visit and go to the waiting room VisitService.shared.enterWaitingRoomByNativeViewWithVisit(visit) ``` #### Enter the waiting room with a browser call Starts the visit as a browser call. See [Communication with BrowserCall UI](https://developers.vsee.com/guides/clinickit/browsercall-ui) for how the call reports events back to your app. ```swift public func enterWaitingRoomByBrowserCallWithVisit(_ visit: Visit) ``` | Parameter | Type | Description | | --- | --- | --- | | `visit` | `Visit` | The visit whose waiting room to enter. | ##### Example usage ```swift let visit = // the Visit to start // Start the visit and go to the waiting room VisitService.shared.enterWaitingRoomByBrowserCallWithVisit(visit) ```