@using System.Text.Json @using HealthcareManagerUiWebAssem.Models @using HealthcareManagerUiWebAssem.Services.Profile @using HealthcareManagerUiWebAssem.Services.Appointment @using HealthcareManagerUiWebAssem.Services.User @inject UserService UserService @inject IProfileService ProfileService @inject IAppointmentService AppointmentService @inject IJSRuntime JS

Doctor Menu

Here you can manage appointments, review your patients' medical history and chat with your patients.

@foreach (var appointment in appointments) { @foreach (var date in appointment.AppointmentsList) { } }
Patient Name Appointment Time Delete
@GetPatientName(new Guid(appointment.PatientId)) @date.ToString("yyyy-MM-dd HH:mm")
@code { private List patients; private string selectedDoctorId; private DateTime? selectedDate; private List appointments; private List medicalHistoryFiles; [Parameter] public string Role { get; set; } protected override async Task OnInitializedAsync() { await InitializePatients(); await LoadAppointments(); } private async Task LoadAppointments() { var response = await AppointmentService.GetAppointmentsByDoctor(UserService.UserId); var jsonOptions = new JsonSerializerOptions { PropertyNameCaseInsensitive = true }; if (response.StatusCode == HttpStatusCodes.OK) { appointments = JsonSerializer.Deserialize>(response.Data, jsonOptions) ?? new List(); } else { appointments = new List(); } } private async Task InitializePatients() { var response = await ProfileService.GetPatients(); var jsonOptions = new JsonSerializerOptions { PropertyNameCaseInsensitive = true }; if (response.StatusCode == HttpStatusCodes.OK) { patients = JsonSerializer.Deserialize>(response.Data, jsonOptions); } else { // Handle error } } private void AddMedicalHistoryFile() { // Logic for adding a new appointment } private async Task DeleteAppointment(Appointment appointmentToDelete) { var appointmentModelToDelete = new AppointmentManagementModel { PatientId = new Guid(appointmentToDelete.PatientId), DoctorId = new Guid(appointmentToDelete.DoctorId), Appointment = appointmentToDelete.AppointmentsList.FirstOrDefault() }; await AppointmentService.DeleteAppointment(appointmentModelToDelete); appointments.Remove(appointmentToDelete); } private string GetPatientName(Guid patientId) { var patient = patients.Select(d => d).FirstOrDefault(d => d.Id == patientId); return patient?.Name ?? string.Empty; } }