public IActionResult Create(AppointmentModel model)
        {
            ResultModel resultModel     = new ResultModel();
            var         AppointmentData = new AppointmentMaster();

            try
            {
                if (ModelState.IsValid)
                {
                    if (model.ID == 0)
                    {
                        AppointmentData.HospitalId  = model.HospitalId;
                        AppointmentData.PatientName = model.PatientName;
                        AppointmentData.MR          = model.MR;
                        _appointmentServices.InsertAppointment(AppointmentData);
                        SaveAppointmentDates(AppointmentData, model._appointmentDates);
                        resultModel.Message  = ValidationMessages.Success;
                        resultModel.Status   = 1;
                        resultModel.Response = "Appointment Created";
                        return(Ok(resultModel));
                    }
                    else
                    {
                        var appointmentData = _appointmentServices.GetAppointmentById(model.ID);
                        appointmentData.Id          = model.ID;
                        appointmentData.HospitalId  = model.HospitalId;
                        appointmentData.PatientName = model.PatientName;
                        appointmentData.MR          = model.MR;
                        _appointmentServices.UpdateAppointment(appointmentData);
                        SaveAppointmentDates(appointmentData, model._appointmentDates);
                        resultModel.Message  = ValidationMessages.Success;
                        resultModel.Status   = 1;
                        resultModel.Response = "Appointment Edited";
                        return(Ok(resultModel));
                    }
                }
                else
                {
                    resultModel.Message  = ValidationMessages.Failure;
                    resultModel.Status   = 0;
                    resultModel.Response = "Appointment not created";
                    return(Ok(resultModel));
                }
            }
            catch (Exception e)
            {
                _appointmentServices.DeleteAppointment(AppointmentData);
                return(Ok(model));
            }
        }
예제 #2
0
        public async Task <ActionResult> CreateAppointmentOld(PatientAppointmentOldViewModel appointmentold)
        {
            bool success = false;



            if (!ModelState.IsValid)
            {
                var patientAppointment =
                    new PatientAppointmentOldViewModel
                {
                    PhysicianListItems = _appointmentServices.GetAllDoctors()
                };

                return(PartialView("_CreateAppointment", patientAppointment));
            }

            //var context = GlobalHost.ConnectionManager.GetHubContext<AppointHub>();

            var appointment = new Appointment()
            {
                AppointDate = appointmentold.AppointDate,
                Pat_Id      = appointmentold.PatientId,
                Phys_id     = appointmentold.PhysId,
                PriorNo     = 1,
                Status      = false,
                IsCancelled = false
            };


            var hasAppointmentExist =
                _appointmentServices.CheckAppointment(appointmentold.PatientId, appointmentold.PhysId, appointmentold.AppointDate);



            if (!hasAppointmentExist)
            {
                success = true;

                _appointmentServices.InsertAppointment(appointment);

                appointHub = new AppointHub();



                _unitofwork.Commit();

                var appointSchedulebydoctor = await _appointmentServices.GetAllAppointmentList();

                if (appointment.Phys_id != null)
                {
                    appointHub.SendAppointment(appointment.Phys_id, appointSchedulebydoctor.Where(t => t.PhyId == appointment.Phys_id && t.AppointDate == appointment.AppointDate && !t.BlStat).ToList());
                }
            }


            var url = Url.Action("GetAppointment_By_Doctor", "Appointment", new { id = appointment.Phys_id, appdate = appointment.AppointDate });


            return(Json(new { success = success, url = url }, JsonRequestBehavior.AllowGet));
        }
예제 #3
0
        public IActionResult Create(AppointmentModel model)
        {
            if (!(bool)SharedData.isAppointmentMenuAccessible)
            {
                return(AccessDeniedView());
            }
            var appointmentId = 0;

            try
            {
                if (ModelState.IsValid)
                {
                    var AppointmentData = new AppointmentMaster();
                    //Insert Appointment
                    if (model.Id == 0)
                    {
                        AppointmentData.HospitalId  = model.HospitalId;
                        AppointmentData.PatientName = model.PatientName;
                        AppointmentData.MR          = model.MR;
                        AppointmentData.CreatedOn   = DateTime.UtcNow;
                        AppointmentData.Deleted     = false;

                        _appointmentServices.InsertAppointment(AppointmentData);

                        appointmentId = AppointmentData.Id;
                        SaveAppointmentDates(AppointmentData);
                        AddNotification(NotificationMessage.TitleSuccess, NotificationMessage.msgAddAppointment, NotificationMessage.TypeSuccess);
                        return(RedirectToAction("Index", "Appointment"));
                    }

                    //EditAppointment
                    else
                    {
                        AppointmentData.Id          = model.Id;
                        AppointmentData.HospitalId  = model.HospitalId;
                        AppointmentData.PatientName = model.PatientName;
                        AppointmentData.MR          = model.MR;
                        _appointmentServices.UpdateAppointment(AppointmentData);
                        AddNotification(NotificationMessage.TitleSuccess, NotificationMessage.msgEditAppointment, NotificationMessage.TypeSuccess);

                        return(RedirectToAction("Index", "Appointment"));
                    }
                }
                else
                {
                    model.AvailableHospitals.Add(new SelectListItem {
                        Text = "Select Hospitals", Value = "0"
                    });
                    foreach (var c in _hospitalServices.GetAllHospital())
                    {
                        model.AvailableHospitals.Add(new SelectListItem
                        {
                            Text     = _encryptionService.DecryptText(c.HospitalName),
                            Value    = c.Id.ToString(),
                            Selected = c.Id == model.HospitalId
                        });
                    }
                    if (model.Id != 0)
                    {
                        var appointment = _appointmentServices.GetAppointmentById(model.Id);
                        foreach (var ApointmentDate in appointment.AppointmentDates)
                        {
                            var appointmentDate = new AppointmentDatesModel
                            {
                                AppointmentDates    = ApointmentDate.AppointmentDate,
                                AppointmentMasterId = ApointmentDate.AppointmentMasterId,
                                Id = ApointmentDate.Id
                            };
                            model._appointmentDates.Add(appointmentDate);
                        }
                    }

                    return(View(model));
                }
            }
            catch (Exception e)
            {
                var AppointmentData = _appointmentServices.GetAppointmentById(appointmentId);
                _appointmentServices.DeleteAppointment(AppointmentData);
                model.AvailableHospitals.Add(new SelectListItem {
                    Text = "Select Hospitals", Value = "0"
                });
                foreach (var c in _hospitalServices.GetAllHospital())
                {
                    model.AvailableHospitals.Add(new SelectListItem
                    {
                        Text     = _encryptionService.DecryptText(c.HospitalName),
                        Value    = c.Id.ToString(),
                        Selected = c.Id == model.HospitalId
                    });
                }
                AddNotification(NotificationMessage.TitleError, NotificationMessage.ErrorMsg, NotificationMessage.TypeError);

                return(View(model));
            }
        }