WinUI Scheduler: A Smart Tool to Handle Appointments in a Hospital
Tags: winui, csharp, dotnet
Published: 2021-09-16 12:08:13

---
title: WinUI Scheduler: A Smart Tool to Handle Appointments in a Hospital
published: true
date: 2021-09-16 10:33:58 UTC
tags: winui, csharp, dotnet
canonical_url: https://www.syncfusion.com/blogs/post/winui-scheduler-a-smart-tool-to-handle-appointments-in-a-hospital.aspx
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dnmgjy41u9oy76ze7yef.png
---

Today, we see tremendous growth in the healthcare system. Multispecialty hospitals are everywhere, equipped with the facilities needed to treat all kinds of ailments. However, it is not an easy task to manage all the resources- doctors and medical devices- in a hospital. In that scenario, you need an all-rounder appointment management system to treat patients as soon as possible.

The [Syncfusion WinUI Scheduler](https://www.syncfusion.com/winui-controls/scheduler "Link to WinUI Scheduler") allows you to easily create a scheduler for each resource and manage appointments based on its availability. By using the resource view, you can group appointments based on their resources or by dates. The Scheduler also allows you to share events or appointments among multiple resources. Also, you can edit the resource appointment details using a built-in appointment editor.

In this blog, we will see how to easily allocate and manage appointments for doctors in a hospital based on their availability using our WinUI Scheduler control.

**Note:** If you are new to our Scheduler control, please read the [Getting Started with WinUI Scheduler](https://help.syncfusion.com/winui/scheduler/getting-started "Link to getting started with WinUI Scheduler") documentation before proceeding with it.

## Adding resources in the Scheduler

First, let’s add the resources in our WinUI Scheduler. Change the [ResourceGroupType](https://help.syncfusion.com/cr/winui/Syncfusion.UI.Xaml.Scheduler.ResourceGroupType.html "Link to the Class ResourceGroupType of WinUI Scheduler") property value to [Resource](https://help.syncfusion.com/cr/winui/Syncfusion.UI.Xaml.Scheduler.ResourceGroupType.html#Syncfusion_UI_Xaml_Scheduler_ResourceGroupType_Resource "Link to the Resource property") and the add resource collections in the [ResourceCollection](https://help.syncfusion.com/cr/winui/Syncfusion.UI.Xaml.Scheduler.SfScheduler.html#Syncfusion_UI_Xaml_Scheduler_SfScheduler_ResourceCollection "Link to the ResourceCollection property of WinUI Scheduler") property.

Then, create a resource view for a doctor by setting the [Id](https://help.syncfusion.com/cr/winui/Syncfusion.UI.Xaml.Scheduler.SchedulerResource.html#Syncfusion_UI_Xaml_Scheduler_SchedulerResource_Id "Link to Id property of WinUI Scheduler"), [Name](https://help.syncfusion.com/cr/winui/Syncfusion.UI.Xaml.Scheduler.SchedulerResource.html#Syncfusion_UI_Xaml_Scheduler_SchedulerResource_Name "Link to Name property of WinUI Scheduler"), [Foreground](https://help.syncfusion.com/cr/winui/Syncfusion.UI.Xaml.Scheduler.SchedulerResource.html#Syncfusion_UI_Xaml_Scheduler_SchedulerResource_Foreground "Link to Foreground property of WinUI Scheduler"), and [Background](https://help.syncfusion.com/cr/winui/Syncfusion.UI.Xaml.Scheduler.SchedulerResource.html#Syncfusion_UI_Xaml_Scheduler_SchedulerResource_Background "Link to Background property") properties in the [SchedulerResource](https://help.syncfusion.com/cr/winui/Syncfusion.UI.Xaml.Scheduler.SchedulerResource.html "Link to the Class SchedulerResource of WinUI Scheduler") class. Refer to the following code example.

```html
<scheduler:SfScheduler ViewType="Week">
    <scheduler:SfScheduler.ResourceCollection>
        <local:SchedulerResourceCollection>
            // Creates instance of scheduler resource.
            <scheduler:SchedulerResource 
                Name="Dr.Sophia" 
                Id="1000" 
                Foreground="White" 
                Background="#9d65c9" />
        </local:SchedulerResourceCollection>
    </scheduler:SfScheduler.ResourceCollection>
</scheduler:SfScheduler>
```

**Note:** Since the  **ResourceCollection**  is of **IEnumerable** type, we have maintained a local class  **SchedulerResourceCollection** , which is derived from the  **ObservableCollection<Object>**  to directly add the resources in the XAML code.

## Creating a scheduler for each resource

The WinUI Scheduler allows you to create an individual scheduler for each resource (doctor) and then group the appointments based on the [Date](https://help.syncfusion.com/cr/winui/Syncfusion.UI.Xaml.Scheduler.ResourceGroupType.html#Syncfusion_UI_Xaml_Scheduler_ResourceGroupType_Date "Link to Date property of WinUI Scheduler") or [Resource](https://help.syncfusion.com/cr/winui/Syncfusion.UI.Xaml.Scheduler.ResourceGroupType.html#Syncfusion_UI_Xaml_Scheduler_ResourceGroupType_Resource "Link to Resource property of WinUI Scheduler") using the [ResourceGroupType](https://help.syncfusion.com/cr/winui/Syncfusion.UI.Xaml.Scheduler.ResourceGroupType.html "Link to the Class ResourceGroupType of WinUI Scheduler") property.

Refer to the following code example.

```html
xmlns:scheduler="using:Syncfusion.UI.Xaml.Scheduler"

<scheduler:SfScheduler x:Name="Schedule"  
                ViewType="Week"
                ResourceGroupType="Resource">
</scheduler:SfScheduler>
```

![Group by Resource in WinUI Scheduler](https://www.syncfusion.com/blogs/wp-content/uploads/2021/09/Group-by-Resource-in-WinUI-Scheduler.png)<figcaption>Group by Resource in WinUI Scheduler</figcaption>

![Group by Date in WinUI Scheduler](https://www.syncfusion.com/blogs/wp-content/uploads/2021/09/Group-by-Date-in-WinUI-Scheduler.png)<figcaption>Group by Date in WinUI Scheduler</figcaption>

## Scheduling appointments to the resources

Set the schedule resource Id in the [ScheduleAppointment](https://help.syncfusion.com/cr/winui/Syncfusion.UI.Xaml.Scheduler.ScheduleAppointment.html "Link to the Class ScheduleAppointment of WinUI Scheduler") class using the [ResourceIdCollection](https://help.syncfusion.com/cr/winui/Syncfusion.UI.Xaml.Scheduler.ScheduleAppointment.html#Syncfusion_UI_Xaml_Scheduler_ScheduleAppointment_ResourceIdCollection "Link to the ResourceIdCollection property of WinUI Scheduler") property to easily schedule the appointments to their respective doctors.

Refer to the following code example.

```csharp
// Creating an instance for the schedule appointment collection.
var scheduleAppointmentCollection = new ScheduleAppointmentCollection();
//Adding schedule appointment in the schedule appointment collection. 
var appointment = new ScheduleAppointment()
{
    StartTime = DateTime.Now,
    EndTime = DateTime.Now.AddHours(2),
    Subject = "General Checkup",
    // Allocate Scheduler ResourceCollection Id to the appointment.
    ResourceIdCollection = new ObservableCollection<object>() { "1000", "1001" }
};
//Adding the schedule appointment to the schedule appointment collection.
scheduleAppointmentCollection.Add(appointment);
//Adding the schedule appointment collection to the ItemsSource of SfScheduler.
this.Scheduler.ItemsSource = scheduleAppointmentCollection;
```

![Scheduling Appointments to the Resources in WinUI Scheduler](https://www.syncfusion.com/blogs/wp-content/uploads/2021/09/Scheduling-Appointments-to-the-Resources-in-WinUI-Scheduler.png)<figcaption>Scheduling Appointments to the Resources in WinUI Scheduler</figcaption>

## Sharing appointments to multiple resources

Also, you can share the same events or appointments with multiple doctors. If the appointment details are edited or updated, then the changes will be reflected in all other shared instances simultaneously.

To achieve this, set the required Scheduler’s [ResourceCollection](https://help.syncfusion.com/cr/winui/Syncfusion.UI.Xaml.Scheduler.SfScheduler.html#Syncfusion_UI_Xaml_Scheduler_SfScheduler_ResourceCollection "Link to ResourceCollection property of WinUI Scheduler") Id to the [ResourceIdCollection](https://help.syncfusion.com/cr/winui/Syncfusion.UI.Xaml.Scheduler.ScheduleAppointment.html#Syncfusion_UI_Xaml_Scheduler_ScheduleAppointment_ResourceIdCollection "Link to ResourceIdCollection property of WinUI Scheduler") property of the [ScheduleAppointment](https://help.syncfusion.com/cr/winui/Syncfusion.UI.Xaml.Scheduler.ScheduleAppointment.html "Link to the Class ScheduleAppointment of WinUI Scheduler") – created object.

Refer to the following code example.

```csharp
// Creating an instance for schedule appointment collection.
var scheduleAppointmentCollection = new ScheduleAppointmentCollection();
//Adding schedule appointment in the schedule appointment collection. 
var appointment = new ScheduleAppointment()
{
    StartTime = DateTime.Now,
    EndTime = DateTime.Now.AddHours(2),
    Subject = "Surgery",
    // Allocate Scheduler ResourceCollection Id to the appointment. 
    ResourceIdCollection = new ObservableCollection<object>() { "1000", "1001", "1002" },
    AppointmentBackground = new SolidColorBrush(Color.FromArgb(255, 133, 81, 242)),
};
//Adding the schedule appointment to the schedule appointment collection.
scheduleAppointmentCollection.Add(appointment);
//Adding the schedule appointment collection to the ItemsSource of SfScheduler.
this.Scheduler.ItemsSource = scheduleAppointmentCollection;
```

![Sharing Appointments to Multiple Resources in WinUI Scheduler](https://www.syncfusion.com/blogs/wp-content/uploads/2021/09/Sharing-Appointments-to-Multiple-Resources-in-WinUI-Scheduler.png)<figcaption>Sharing Appointments to Multiple Resources in WinUI Scheduler</figcaption>

## Data binding

The Scheduler provides complete data binding support to bind any kind of object to the [ResourceCollection](https://help.syncfusion.com/cr/winui/Syncfusion.UI.Xaml.Scheduler.SfScheduler.html#Syncfusion_UI_Xaml_Scheduler_SfScheduler_ResourceCollection "Link to the ResourceCollection property of WinUI Scheduler"). Create a custom resource model with the required field Id, Name, and other optional fields like Background and Foreground. Then, map the equivalent properties to the [ResourceMapping ](https://help.syncfusion.com/cr/winui/Syncfusion.UI.Xaml.Scheduler.ResourceMapping.html "Link to the Class ResourceMapping of WinUI Scheduler")API in the  **Scheduler**  class.

Refer to the following code example.  Here, we have created a custom class **Doctor** with mandatory fields **Name** , **Id** , **ForegroundColor** , and **BackgroundColor**.

```csharp
public class Doctor
{
    /// <summary>
    /// Gets or sets the resource name.
    /// </summary>
    public string Name { get; set; }

    /// <summary>
    /// Gets or sets the resource id.
    /// </summary>
    public object Id { get; set; }

    /// <summary>
    /// Gets or sets the resource background brush.
    /// </summary>
    public Brush BackgroundBrush { get; set; }

    /// <summary>
    /// Gets or sets the foreground brush.
    /// </summary>
    public Brush ForegroundBrush { get; set; }

}
```

Map the properties of the **Doctor** class with the Scheduler control using the **ResourceMapping** property like the following code example.

```html
<scheduler:SfScheduler.ResourceMapping>
    <scheduler:ResourceMapping 
        Id="Id" 
        Name="Name" 
        Background="BackgroundBrush" 
        Foreground="ForegroundBrush"/>
</scheduler:SfScheduler.ResourceMapping>
```

Then, add the custom resources in the Scheduler’s **ResourceCollection** property.

```html
<scheduler:SfScheduler.ResourceCollection>
   <local:SchedulerResourceCollection>
       <local:Doctor Name="Dr.Sophia" Id="1" ForegroundBrush="White" BackgroundBrush="#9d65c9" />
       <local:Doctor Name="Dr.Kinsley Elena" Id="2" ForegroundBrush="White" BackgroundBrush="#f08a5d" />
       <local:Doctor Name="Dr.Adeline Ruby" Id="3" ForegroundBrush="White" BackgroundBrush="#679b9b" />
   </local:SchedulerResourceCollection>
</scheduler:SfScheduler.ResourceCollection>
```

![Creating Custom Resources in WinUI Scheduler](https://www.syncfusion.com/blogs/wp-content/uploads/2021/09/Creating-Custom-Resources-in-WinUI-Scheduler.png)<figcaption>Creating Custom Resources in WinUI Scheduler</figcaption>

**Note:** For more details, refer to [Manage Resources with the Resource View in WinUI Scheduler demo](https://github.com/SyncfusionExamples/manage-the-resources-with-the-resource-view-in-winui-scheduler/tree/main/ResourceView "Link to Manage Resources with the Resource View in WinUI Scheduler demo on GitHub") on GitHub.

## Appointment rescheduling

If you need to cancel or reschedule a doctor’s appointments, use the built-in [editor](https://help.syncfusion.com/winui/scheduler/appointment-editing "Link to Appointment Editing in WinUI Scheduler") to dynamically create, edit, or delete them. With the [drag-and-drop](https://help.syncfusion.com/winui/scheduler/appointment-drag-and-drop "Link to Appointment Drag and Drop in WinUI Scheduler") and appointment [resizing](https://help.syncfusion.com/winui/scheduler/appointment-editing#appointment-resizing "Link to Appointment resizing of WinUI Scheduler") features, you can simply reassign and reschedule the appointments.

![Built-in Editor in WinUI Scheduler](https://www.syncfusion.com/blogs/wp-content/uploads/2021/09/Built-in-Editor-in-WinUI-Scheduler.png)<figcaption>Built-in Editor in WinUI Scheduler</figcaption>

## Resource availability

You can manage and track the absence and unavailability of doctors using the [special time regions](https://help.syncfusion.com/winui/scheduler/resource-grouping#assign-resources-to-special-time-regions "Link to Assign resources to special time regions in WinUI Scheduler"). This feature allows you to indicate the availability of each doctor. Add the resource Id in the [ResourceIdCollection](https://help.syncfusion.com/cr/winui/Syncfusion.UI.Xaml.Scheduler.ScheduleAppointment.html#Syncfusion_UI_Xaml_Scheduler_ScheduleAppointment_ResourceIdCollection "Link to ResourceIdCollection property of WinUI Scheduler") property of the [SpecialTimeRegions](https://help.syncfusion.com/cr/winui/Syncfusion.UI.Xaml.Scheduler.SpecialTimeRegion.html "Link to the Class SpecialTimeRegion of WinUI Scheduler") API in the [DaysViewSettings](https://help.syncfusion.com/cr/winui/Syncfusion.UI.Xaml.Scheduler.DaysViewSettings.html "Link to the Class DaysViewSettings of WinUI Scheduler") for the days view and [TimelineViewSettings](https://help.syncfusion.com/cr/winui/Syncfusion.UI.Xaml.Scheduler.TimelineViewSettings.html "Link to the Class TimelineViewSettings of WinUI Scheduler") for the timeline view.

Refer to the following code example.

```csharp
var currentDate = DateTime.Now;
var casualLeave = new SpecialTimeRegion();
casualLeave.Text = "Casual leave";
casualLeave.StartTime = new DateTime(currentDate.Year, currentDate.Month, currentDate.AddDays(-2).Day, 0, 0, 0);
casualLeave.EndTime = new DateTime(currentDate.Year, currentDate.Month, currentDate.AddDays(-2).Day, 23, 59, 0);
casualLeave.Background = new SolidColorBrush(Colors.DarkGray);
casualLeave.Foreground = new SolidColorBrush(Colors.Black);
casualLeave.RecurrenceRule = "FREQ=DAILY;INTERVAL=1;COUNT=1";
casualLeave.ResourceIdCollection = new ObservableCollection<object>() { "2" };

var lunch = new SpecialTimeRegion();
lunch.Text = "Lunch";
lunch.Foreground = new SolidColorBrush(Colors.Black);
lunch.StartTime = new DateTime(currentDate.Year, currentDate.Month, currentDate.AddDays(-1).Day, 12, 0, 0);
lunch.EndTime = new DateTime(currentDate.Year, currentDate.Month, currentDate.AddDays(-1).Day, 13, 0, 0);
lunch.Background = new SolidColorBrush(Colors.DarkGray);
lunch.Foreground = new SolidColorBrush(Colors.Black);
lunch.ResourceIdCollection = new ObservableCollection<object>() { "3" };
lunch.RecurrenceRule = "FREQ=DAILY;INTERVAL=1;COUNT=1";

Scheduler.DaysViewSettings.SpecialTimeRegions = new ObservableCollection<SpecialTimeRegion>() { casualLeave, lunch };
```

![Tracking Resources Availabilty in WinUI Scheduler](https://www.syncfusion.com/blogs/wp-content/uploads/2021/09/Tracking-Resources-Availabilty-in-WinUI-Scheduler.png)<figcaption>Tracking Resources Availabilty in WinUI Scheduler</figcaption>

## Customization

Using the data template and data template selector features, the Scheduler resource view lets you apply different colors and even alternative views based on the departments in a hospital. To achieve this, use the [ResourceHeaderTemplate](https://help.syncfusion.com/cr/winui/Syncfusion.UI.Xaml.Scheduler.SfScheduler.html#Syncfusion_UI_Xaml_Scheduler_SfScheduler_ResourceHeaderTemplate "Link to the ResourceHeaderTemplate property of WinUI Scheduler") and [ResourceHeaderTemplateSelector](https://help.syncfusion.com/cr/winui/Syncfusion.UI.Xaml.Scheduler.SfScheduler.html#Syncfusion_UI_Xaml_Scheduler_SfScheduler_ResourceHeaderTemplateSelector "Link to the ResourceHeaderTemplateSelector property of WinUI Scheduler") APIs in the Scheduler class.

Refer to the following code example.

```html
<scheduler:SfScheduler.ResourceHeaderTemplate>
    <DataTemplate>
        <Grid Background="Transparent">
            <StackPanel VerticalAlignment="Center" Orientation="Vertical">
                <Border CornerRadius="36" Height="72" Width="72" BorderThickness="4" BorderBrush="{Binding Data.BackgroundBrush}">
                    <Border CornerRadius="36" Height="64" Width="64" BorderThickness="4" BorderBrush="Transparent">
                        <Image HorizontalAlignment="Center" VerticalAlignment="Center"
                        Width="55"
                        Height="55"
                        Source="{Binding Data.ImageSource}" />
                    </Border>
                </Border>
                <TextBlock HorizontalAlignment="Center"
                    VerticalAlignment="Center"
                    FontSize="15"
                    Text="{Binding Name}"/>
                <TextBlock HorizontalAlignment="Center"
                    VerticalAlignment="Center"
                    FontSize="15"
                    Text="{Binding Data.Designation}"/>
            </StackPanel>
        </Grid>
    </DataTemplate>
</scheduler:SfScheduler.ResourceHeaderTemplate>
```

![Resource View Customization in WinUI Scheduler](https://www.syncfusion.com/blogs/wp-content/uploads/2021/09/Resource-View-Customization-in-WinUI-Scheduler.png)<figcaption>Resource View Customization in WinUI Scheduler</figcaption>

**Note:**  For more details, refer to [Custom Resource View in WinUI Scheduler demo on GitHub](https://github.com/SyncfusionExamples/manage-the-resources-with-the-resource-view-in-winui-scheduler/tree/main/CustomResourceView "Link to Custom Resource View in WinUI Scheduler demo on GitHub").

## Conclusion

Thanks for reading! In this blog post, we have seen how to easily manage and allocate appointments to the resources in a hospital with our [WinUI Scheduler](https://www.syncfusion.com/winui-controls/scheduler "Link to WinUI Scheduler"). Its rich feature set includes date restriction, load-on-demand, flexible working days, localization, globalization, and more. Try out these user-friendly features and enjoy hassle-free scheduling!

If you are an existing Syncfusion user, please download the latest version from the [License and Downloads](https://www.syncfusion.com/account/downloads "Link to license and download page of Essential Studio") page. Also, our NuGet packages are available on [NuGet.org](https://www.nuget.org/ "Link to NuGet Gallery").

If you aren’t a customer yet, you can try our 30-day [free trial](https://www.syncfusion.com/downloads "Link to the free evaluation of the Syncfusion Essential Studio") to check out these features. You can also try our other WinUI control demos from this [GitHub](https://github.com/SyncfusionExamples "Link to the Syncfusion WinUI demos on GitHub") location.

If you have any questions or comments, you can contact us through our [support forums](https://www.syncfusion.com/forums "Link to the Syncfusion support forum"), [Direct-Trac](https://www.syncfusion.com/support/directtrac/incidents "Link to the Syncfusion support system Direct Trac"), or [feedback portal](https://www.syncfusion.com/feedback/ "Link to Syncfusion Feedback Portal"). We are always happy to assist you!

## Related blogs

- [Pick Colors Like a Boss Using Syncfusion Color Controls in WinUI](https://dev.to/syncfusion/pick-colors-like-a-boss-using-syncfusion-color-controls-in-winui-e77 "Link to Pick Colors Like a Boss Using Syncfusion Color Controls in WinUI blog")
- [Syncfusion Defers UWP Support in WinUI 3 Suite](https://dev.to/sureshmohan/syncfusion-defers-uwp-support-in-winui-3-suite-1hen-temp-slug-5937647 "Link to Syncfusion Defers UWP Support in WinUI 3 Suite blog")
- [Everything You Need to Know About the WinUI 3 Range Slider](https://dev.to/syncfusion/everything-you-need-to-know-about-the-winui-3-range-slider-409p "Link to Everything You Need to Know About the WinUI 3 Range Slider blog")
- [Introducing the New WinUI NumberBox Control](https://dev.to/sureshmohan/introducing-the-new-winui-numberbox-control-2k8c-temp-slug-2572256 "Link to Introducing the New WinUI NumberBox Control blog")