public IActionResult Detail(int appointmentId)
        {
            AppointmentDetailViewModel model = new AppointmentDetailViewModel();

            model.LoadData(_unitOfWork, appointmentId);
            return(View(model));
        }
Beispiel #2
0
        /// <summary>
        /// Converts viewmodel to model
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static AppointmentDetailModel ToModel(this AppointmentDetailViewModel model)
        {
            if (model == null)
            {
                return(null);
            }
            var entity = new AppointmentDetailModel
            {
                AppointmentID        = model.AppointmentID,
                ProgramID            = model.ProgramID,
                AppointmentTypeID    = model.AppointmentTypeID,
                ServicesID           = model.ServicesID,
                AppointmentDate      = model.AppointmentDate,
                AppointmentStartTime = model.AppointmentStartTime,
                AppointmentLength    = model.AppointmentLength,
                SupervisionVisit     = model.SupervisionVisit,
                ReferredBy           = model.ReferredBy,
                ReasonForVisit       = model.ReasonForVisit,
                IsCancelled          = model.IsCancelled,
                AppointmentType      = model.AppointmentType,
                ProviderId           = model.ProviderId,
                ProviderName         = model.ProviderName,
                RoomId       = model.RoomId,
                RoomName     = model.RoomName,
                LocationID   = model.LocationID,
                LocationName = model.LocationName,
                ModifiedOn   = model.ModifiedOn
            };

            return(entity);
        }
        public AppointmentDetailViewModel CreateAppointmentDetailViewModel(int appointmentId, int entityId, DateTime appointmentDateTime, int departmentId)
        {
            var model = new AppointmentDetailViewModel()
            {
                IsModelEditable = true, AppointmentId = appointmentId, EntityId = entityId, AppointmentDateTime = appointmentDateTime
            };

            var dept = repository.GetById <Department>(departmentId);

            model.DepartmentId = dept.DepartmentId;

            var app = repository.GetContext().PatientAppointments
                      .Include(p => p.Patient)
                      .FirstOrDefault(p => p.PatientAppointmentId == appointmentId);

            var pat = app == null?repository.GetById <Patient>(entityId) : app.Patient;

            model.DisplayProperties.Add("Department", dept.DepartmentName);
            model.DisplayProperties.Add("Patient Name", pat.GetDisplayName());
            model.DisplayProperties.Add("Email", pat.EmailAddress ?? "N/A");
            model.DisplayProperties.Add("Contact No.", pat.MobileNumber ?? "N/A");

            if (app == null)
            {
                return(model);
            }

            model.AppointmentNotes = app.AppointmentNotes;
            model.CancelNotes      = app.CancelNotes;

            model.IsModelEditable = !app.IsArchived;

            return(model);
        }
Beispiel #4
0
        public async Task <IActionResult> Edit(int id, AppointmentDetailViewModel objAppointmentVM)
        {
            if (ModelState.IsValid)
            {
                objAppointmentVM.Appointments.AppointmentDate = objAppointmentVM.Appointments.AppointmentDate
                                                                .AddHours(objAppointmentVM.Appointments.AppointmentTime.Hour)
                                                                .AddMinutes(objAppointmentVM.Appointments.AppointmentTime.Minute);

                var appointmentFromDb = _db.Appointments.Where(a => a.ID == objAppointmentVM.Appointments.ID).FirstOrDefault();

                appointmentFromDb.CustomerName    = objAppointmentVM.Appointments.CustomerName;
                appointmentFromDb.CustomerEmail   = objAppointmentVM.Appointments.CustomerEmail;
                appointmentFromDb.CustomerPhone   = objAppointmentVM.Appointments.CustomerPhone;
                appointmentFromDb.AppointmentDate = objAppointmentVM.Appointments.AppointmentDate;
                appointmentFromDb.isConfirmed     = objAppointmentVM.Appointments.isConfirmed;

                if (User.IsInRole(SD.SuperAdminEndUser))
                {
                    appointmentFromDb.ReceptionId = objAppointmentVM.Appointments.ReceptionId;
                }

                _db.SaveChanges();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(objAppointmentVM));
        }
Beispiel #5
0
        // Get : Details
        public async Task <IActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Appointments apppointment = null;

            if (orm == 1)
            {
                apppointment = qdb.retAppointment((int)id);
            }
            else
            {
                apppointment = await(from i in _db.Appointments where i.Id == id select i).FirstAsync();
            }

            if (apppointment == null)
            {
                return(NotFound());
            }

            List <Products> products = null;
            List <ProductsSelectedForAppointment> psd = null;

            if (orm == 1)
            {
                products = qdb.p_join_psa((int)id);
                qdb.include_pt_st(products);
                psd = qdb.retpsa((int)id);
            }
            else
            {
                products = await(from i in _db.Products
                                 join j in _db.ProductsSelectedForAppointments on i.Id equals j.ProductId
                                 where j.AppointmentId == id
                                 select i).Include(e => e.ProductTypes).ToListAsync();
                psd = _db.ProductsSelectedForAppointments.Where(e => e.AppointmentId == id).ToList();
            }

            foreach (Products i in products)
            {
                i.Count = psd.First(e => e.ProductId == i.Id).Count;
                i.Price = i.Price * i.Count;
            }

            var applicationUsers = (from i in _db.ApplicationUsers select i);

            AppointmentDetailViewModel vm = new AppointmentDetailViewModel()
            {
                ApplicationUsers = applicationUsers,
                Appointments     = apppointment,
                Products         = products
            };

            return(View(vm));
        }
Beispiel #6
0
        public IActionResult LinkAccounts(AppointmentDetailViewModel Advm)
        {
            int patientId = Advm.Patient.AccountID;
            int doctorId  = Advm.Doctor.AccountID;

            accountrepo.LinkAccounts(patientId, doctorId);

            return(RedirectToAction("Beheerder", "Account"));
        }
Beispiel #7
0
        public AppointmentDetailViewModel ViewModelFromAppointment(Appointment appointment)
        {
            AppointmentDetailViewModel ADVM = new AppointmentDetailViewModel()
            {
                AppointmentID = appointment.AppointmentID,
                DateTime      = appointment.DateTime,
                Duration      = appointment.Duration,
                Description   = appointment.Description,
                Patient       = accountConverter.ViewModelFromAccount(appointment.patient),
                Doctor        = accountConverter.ViewModelFromAccount(appointment.doctor)
            };

            return(ADVM);
        }
Beispiel #8
0
        public Appointment ViewModelToAppointment(AppointmentDetailViewModel ADVM)
        {
            Appointment appointment = new Appointment()
            {
                AppointmentID = ADVM.AppointmentID,
                DateTime      = ADVM.DateTime,
                Duration      = ADVM.Duration,
                Description   = ADVM.Description,
                patient       = accountConverter.ViewModelToAccount(ADVM.Patient),
                doctor        = accountConverter.ViewModelToAccount(ADVM.Doctor)
            };

            return(appointment);
        }
        public object CancelAppointment(AppointmentDetailViewModel model, string user)
        {
            try
            {
                var app = repository.GetById <PatientAppointment>(model.AppointmentId);
                app.CancelNotes = model.CancelNotes;
                app.SetArchiveDetails(user);
                repository.SaveExisting(app);
            }
            catch (Exception e)
            {
                return(new { IsSuccess = false, Message = "Appointment cancellation failed. Please contact administrator." });
            }

            return(new { IsSuccess = true, Message = "Appointment cancelled successfully." });
        }
Beispiel #10
0
        public IActionResult MakeAppointment(AppointmentDetailViewModel viewmodel)
        {
            Appointment inkomend = appointmentconverter.ViewModelToAppointment(viewmodel);

            inkomend.doctor.AccountID = (int)HttpContext.Session.GetInt32("AccountID");

            if (appointmentrepo.MakeAppointment(inkomend) == true)
            {
                //afspraak gepland
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                //mislukt
                return(RedirectToAction("Index", "Appointment"));
            }
        }
Beispiel #11
0
        /// <summary>
        /// Appointment Detail GET Method
        /// </summary>
        /// <param name="id">Appoinment Identifier</param>
        /// <returns></returns>
        public IActionResult Detail(string id)
        {
            Appointment appointment = _appointmentService.GetById(id);

            if (appointment == null)
            {
                return(RedirectToAction("NotFound", "Error"));
            }

            AppointmentDetailViewModel viewModel = new AppointmentDetailViewModel
            {
                Id = id,
                AppointmentDate = appointment.AppointmentDate,
                CustomerName    = _customerService.GetFullNameById(appointment.CustomerId),
                Description     = appointment.Note
            };

            return(View(viewModel));
        }
Beispiel #12
0
        public AppointmentDetailViewModel GetAppointmentById(string Id)
        {
            var Appointment = new AppointmentDetailViewModel();

            using (SQLiteCommand command = Connection.CreateCommand())
            {
                command.CommandText = $"SELECT * FROM {Enum.GetName(typeof(DatabaseTables), 0)} INNER JOIN {Enum.GetName(typeof(DatabaseTables), 1)} ON {Enum.GetName(typeof(DatabaseTables), 0)}.custId == {Enum.GetName(typeof(DatabaseTables), 1)}.customerId INNER JOIN {Enum.GetName(typeof(DatabaseTables),2)} ON {Enum.GetName(typeof(DatabaseTables), 1)}.customerId == {Enum.GetName(typeof(DatabaseTables), 2)}.custId WHERE {Enum.GetName(typeof(DatabaseTables), 0)}.apptId == '{Id}'";
                using (var data = command.ExecuteReaderAsync().Result)
                {
                    while (data.Read())
                    {
                        Appointment.CustomerName   = $"{data["customerName"]}";
                        Appointment.IdentityNumber = $"{data["customerIdentityNo"]}";
                        Appointment.PetName        = $"{data["petName"]}";
                    }
                }
            }

            return(Appointment);
        }
Beispiel #13
0
        //Get: Delete
        public async Task <IActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var roomList = (IEnumerable <Rooms>)(from p in _db.Rooms
                                                 join a in _db.RoomSelectedForAppointments
                                                 on p.ID equals a.RoomId
                                                 where a.AppointmentId == id
                                                 select p).Include("RoomTypes");

            AppointmentDetailViewModel objAppointmentVM = new AppointmentDetailViewModel()
            {
                Appointments = _db.Appointments.Include(a => a.Reception).Where(a => a.ID == id).FirstOrDefault(),
                Reception    = _db.ApplicationUsers.ToList(),
                Rooms        = roomList.ToList()
            };

            return(View(objAppointmentVM));
        }
        public object CreateAppointment(AppointmentDetailViewModel model, string user)
        {
            try
            {
                var app = new PatientAppointment()
                {
                    PatientId           = model.EntityId,
                    AppointmentDateTime = model.AppointmentDateTime,
                    AppointmentNotes    = model.AppointmentNotes,
                    DepartmentId        = model.DepartmentId
                };

                app.SetCreateDetails(user);
                repository.SaveNew(app);
            }
            catch (Exception e)
            {
                return(new { IsSuccess = false, Message = "Appointment creation failed. Please contact administrator." });
            }

            return(new { IsSuccess = true, Message = "Appointment created successfully." });
        }
Beispiel #15
0
        // Get : Edit
        public async Task <IActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            List <Products> products     = null;
            Appointments    appointments = null;

            if (orm == 1)
            {
                products = qdb.p_join_psa((int)id);
                qdb.include_pt_st(products);
                appointments = qdb.retAppointment((int)id);
            }
            else
            {
                products = (from i in _db.Products
                            join j in _db.ProductsSelectedForAppointments on i.Id equals j.ProductId
                            where j.AppointmentId == id
                            select i
                            ).Include(e => e.ProductTypes).ToList();
                appointments = (from i in _db.Appointments where i.Id == (int)id select i).FirstOrDefault();
            }

            //var appointment = (from i in _db.Appointments where i.Id == (int) id select i).FirstOrDefault();
            var applicationUsers           = (from i in _db.ApplicationUsers select i).ToList();
            AppointmentDetailViewModel avm = new AppointmentDetailViewModel()
            {
                Appointments     = appointments,
                ApplicationUsers = applicationUsers,
                Products         = products
            };

            return(View(avm));
        }
Beispiel #16
0
        public async Task <IActionResult> EditPost(int id, AppointmentDetailViewModel vm)
        {
            if (!ModelState.IsValid)
            {
                return(View(vm));
            }

            Appointments obj = null;

            if (orm == 1)
            {
                obj = qdb.retAppointment(id);
            }
            else
            {
                obj = await _db.Appointments.FirstAsync(e => e.Id == id);
            }

            obj.CustomerName    = vm.Appointments.CustomerName;
            obj.CustomerEmail   = vm.Appointments.CustomerEmail;
            obj.IsConfirmed     = vm.Appointments.IsConfirmed;
            obj.CustomerNumber  = vm.Appointments.CustomerNumber;
            obj.AppointmentDate = vm.Appointments.AppointmentDate.AddHours(vm.Appointments.AppointmentTime.Hour)
                                  .AddMinutes(vm.Appointments.AppointmentTime.Minute);

            if (orm == 1)
            {
                qdb.upAppointment(obj);
            }
            else
            {
                await _db.SaveChangesAsync();
            }

            TempData["edit"] = 1;
            return(RedirectToAction(nameof(Index)));
        }
 public IActionResult CancelAppointment(AppointmentDetailViewModel model)
 {
     return(Json(SchServ.CancelAppointment(model, CurrentUserName)));
 }
 public IActionResult CreateAppointment(AppointmentDetailViewModel model, string AppointmentDateTime)
 {
     model.AppointmentDateTime = DateTime.ParseExact(AppointmentDateTime, "dd/MM/yyyy HH:mm", CultureInfo.CurrentCulture);
     return(Json(SchServ.CreateAppointment(model, CurrentUserName)));
 }