public async Task <IActionResult> Record()
        {
            if (User.Identity.IsAuthenticated)
            {
                PatientRecordViewModel model = new PatientRecordViewModel();

                var user = await userManager.FindByNameAsync(User.Identity.Name);

                var patient = repository.GetPatientByUser(user);

                if (patient != null)
                {
                    List <AppointmentViewModel> appointments = new List <AppointmentViewModel>();
                    foreach (var a in patient.Record.Appointments)
                    {
                        appointments.Add(mapper.Map <Appointment, AppointmentViewModel>(repository.GetAppointmentById(a.Id)));
                    }
                    model.Appointments = appointments;
                    model.Patient      = mapper.Map <Patient, PatientViewModel>(patient);

                    return(View(model));
                }
                else
                {
                    return(View());
                }
            }
            else
            {
                TempData["NeedLogin"] = "******";
                return(RedirectToAction("Login", "Account"));
            }
        }
        public IActionResult PayBill(int patientId, int appointmentId)
        {
            var patient     = repository.GetPatientById(patientId);
            var appointment = repository.GetAppointmentById(appointmentId);

            if (patient != null && appointment != null)
            {
                List <AppointmentViewModel> appointments = new List <AppointmentViewModel>()
                {
                    mapper.Map <Appointment, AppointmentViewModel>(appointment)
                };

                PatientRecordViewModel model = new PatientRecordViewModel()
                {
                    Patient      = mapper.Map <Patient, PatientViewModel>(patient),
                    Appointments = appointments
                };

                return(View(model));
            }
            else
            {
                TempData["FormError"] = "Error obtaining appointment data";
                return(RedirectToAction("Record"));
            }
        }
        public IActionResult EditPatient(PatientRecordViewModel model)
        {
            if (ModelState.IsValid)
            {
                var patient = mapper.Map <PatientViewModel, Patient>(model.Patient);

                try
                {
                    repository.UpdatePatient(patient);
                }
                catch (Exception ex)
                {
                    logger.Log(LogLevel.Error, $"Failed to update patient: {ex}");
                }
                try
                {
                    repository.SaveAll();
                }
                catch (Exception ex)
                {
                    logger.Log(LogLevel.Error, $"Failed to save updated patient to db: {ex}");
                }

                var updatedPatient = repository.GetPatientById(patient.Id);
            }
            else
            {
                TempData["FormError"] = "Input data not valid";
            }

            return(RedirectToAction("Record"));
        }
示例#4
0
        public IActionResult Record(string id)
        {
            using (var def = new DoctorContext())
            {
                var users = UsersInfo.Users;
                using (var daef = new DentistAssistantContext())
                {
                    var Notes = (from qaa in daef.Qaa
                                 where qaa.PatientId.ToLower().Equals(id.ToLower()) &&
                                 qaa.Qaqid.Equals(30)
                                 select qaa).FirstOrDefault();

                    var patient = (from p in def.Patients
                                   where p.PatNo.ToLower().Equals(id.ToLower()) &&
                                   p.Enable.Equals(true)
                                   select p).FirstOrDefault();

                    var patientSettingFirstTimeRecord = (from ps in daef.PatientSettings
                                                         where ps.Id.ToUpper().Equals(patient.PatNo.ToUpper())
                                                         select new PatientSettingRecordViewModel()
                    {
                        PatientSetting = ps,
                        PatientRecordUnit = (from pr in ps.PatientRecords
                                             where pr.IsFirst.Equals(true)
                                             select new PatientRecordUnit()
                        {
                            Id = pr.Id,
                            Room = pr.Room,
                            UserNo = pr.UserNo,
                            UserName = users.Where(c => c.UserNo.Equals(pr.UserNo)).FirstOrDefault().UserName,
                            OrderTime = pr.OrderTime,
                            ArriveTime = pr.ArriveTime,
                            DrArriveTime = pr.DrArriveTime,
                            DrLeaveTime = pr.DrLeaveTime,
                            PtLeaveTime = pr.PtLeaveTime,
                            IsFirst = pr.IsFirst,
                            CreateTime = pr.CreateTime,
                            PatientSettingId = pr.PatientSettingId,
                            FdiUnitsF = (from f in pr.Fdis
                                         where f.Type.Equals("F")
                                         select new FdiUnit()
                            {
                                Fdi = f,
                                FdiDetails = f.FdiDetails.ToList()
                            }).ToList(),
                            FdiUnitsN = (from f in pr.Fdis
                                         where f.Type.Equals("N")
                                         select new FdiUnit()
                            {
                                Fdi = f,
                                FdiDetails = f.FdiDetails.ToList()
                            }).ToList(),
                            RecordUserUnit = (from ru in pr.RecordUsers
                                              select new RecordUserUnit()
                            {
                                Id = ru.Id,
                                UserNo = ru.UserNo,
                                UserName = users.Where(c => c.UserNo.Equals(ru.UserNo)).FirstOrDefault().UserName,
                                CreateDate = ru.CreateDate,
                                PatientRecordId = ru.PatientRecordId
                            }).ToList()
                        }).FirstOrDefault()
                    }).FirstOrDefault();

                    //QA
                    var patientRecord = new PatientRecordViewModel()
                    {
                        Patient     = patient,
                        Notes       = Notes == null ? null : Notes.ValueDescription,
                        QACategorys = (from qac in daef.Qacategorys
                                       select new QACategorys()
                        {
                            Id = qac.Id,
                            Title = qac.Title,
                            SeqNo = qac.SeqNo,
                            QAGroupUnits = (from qag in qac.Qagroups
                                            select new QAGroupUnit()
                            {
                                Id = qag.Id,
                                Title = qag.Title,
                                SeqNo = qag.SeqNo,
                                QAQParentUnits = (from qaq in qag.Qaq
                                                  where qaq.ParentId.Equals(0)
                                                  select new QAQParentUnit()
                                {
                                    QAQUnit = new QAQUnit()
                                    {
                                        IsChecked = daef.Qaa.Where(c => c.PatientId.Equals(id) && c.Qaqid.Equals(qaq.Id)).Count() > 0 ? true : false,
                                        QAAValueDescription = daef.Qaa.Where(c => c.PatientId.Equals(id) && c.Qaqid.Equals(qaq.Id)).FirstOrDefault().ValueDescription,
                                        Id = qaq.Id,
                                        Type = qaq.Type,
                                        Title = qaq.Title,
                                        IsValue = qaq.IsValue,
                                        ValueDescription = qaq.ValueDescription,
                                        SeqNo = qaq.SeqNo
                                    },
                                    QAQUnits = (from qaqc in daef.Qaq
                                                where qaqc.ParentId.Equals(qaq.Id)
                                                select new QAQUnit()
                                    {
                                        IsChecked = daef.Qaa.Where(c => c.PatientId.Equals(id) && c.Qaqid.Equals(qaqc.Id)).Count() > 0 ? true : false,
                                        QAAValueDescription = daef.Qaa.Where(c => c.PatientId.Equals(id) && c.Qaqid.Equals(qaqc.Id)).FirstOrDefault().ValueDescription,
                                        Id = qaqc.Id,
                                        Type = qaqc.Type,
                                        Title = qaqc.Title,
                                        IsValue = qaqc.IsValue,
                                        ValueDescription = qaqc.ValueDescription,
                                        SeqNo = qaqc.SeqNo,
                                        ParentId = qaqc.ParentId
                                    }).ToList()
                                }).ToList()
                            }).ToList()
                        }).ToList(),
                    };
                    //patientRecord.ShareViewModel = GetShareImage(patient.Id);
                    patientRecord.ShareViewModel = GetShare(patient.PatNo);

                    if (patientSettingFirstTimeRecord != null)
                    {
                        patientRecord.Introduce = patientSettingFirstTimeRecord.PatientSetting.Introduce;
                        if (!string.IsNullOrEmpty(patientSettingFirstTimeRecord.PatientSetting.QadoctorNo))
                        {
                            patientRecord.QADoctor = def.Users.Find(patientSettingFirstTimeRecord.PatientSetting.QadoctorNo).UserName;
                        }
                        DateTime firstTimeTime;
                        if (DateTime.TryParse(patientSettingFirstTimeRecord.PatientSetting.FirstTimeTime.ToString(), out firstTimeTime))
                        {
                            patientRecord.IsFirstTimeExist = true;
                            patientRecord.PatientSettingRecordViewModel = patientSettingFirstTimeRecord;
                        }

                        if (patientSettingFirstTimeRecord.PatientSetting.IsCompleted == null || patientSettingFirstTimeRecord.PatientSetting.IsCompleted.Equals(true))
                        {
                            patientRecord.IsComplete = true;
                        }
                        else
                        {
                            patientRecord.IsComplete = false;
                        }
                    }
                    else
                    {
                        patientRecord.IsComplete = true;
                    }
                    return(View(patientRecord));
                }
            }
        }
示例#5
0
 public IActionResult QA(string id)
 {
     using (var def = new DoctorContext())
     {
         var users = UsersInfo.Users;
         using (var daef = new DentistAssistantContext())
         {
             var patient = (from p in def.Patients
                            where p.PatNo.ToLower().Equals(id.ToLower()) &&
                            p.Enable.Equals(true)
                            select p).FirstOrDefault();
             var patientSetting = daef.PatientSettings.Find(patient.PatNo);
             var patientRecord  = new PatientRecordViewModel()
             {
                 Patient     = patient,
                 QACategorys = (from qac in daef.Qacategorys
                                select new QACategorys()
                 {
                     Id = qac.Id,
                     Title = qac.Title,
                     SeqNo = qac.SeqNo,
                     QAGroupUnits = (from qag in qac.Qagroups
                                     select new QAGroupUnit()
                     {
                         Id = qag.Id,
                         Title = qag.Title,
                         SeqNo = qag.SeqNo,
                         QAQParentUnits = (from qaq in qag.Qaq
                                           where qaq.ParentId.Equals(0)
                                           select new QAQParentUnit()
                         {
                             QAQUnit = new QAQUnit()
                             {
                                 IsChecked = daef.Qaa.Where(c => c.PatientId.Equals(id) && c.Qaqid.Equals(qaq.Id)).Count() > 0 ? true : false,
                                 QAAValueDescription = daef.Qaa.Where(c => c.PatientId.Equals(id) && c.Qaqid.Equals(qaq.Id)).FirstOrDefault().ValueDescription,
                                 Id = qaq.Id,
                                 Type = qaq.Type,
                                 Title = qaq.Title,
                                 IsValue = qaq.IsValue,
                                 ValueDescription = qaq.ValueDescription,
                                 SeqNo = qaq.SeqNo
                             },
                             QAQUnits = (from qaqc in daef.Qaq
                                         where qaqc.ParentId.Equals(qaq.Id)
                                         select new QAQUnit()
                             {
                                 IsChecked = daef.Qaa.Where(c => c.PatientId.Equals(id) && c.Qaqid.Equals(qaqc.Id)).Count() > 0 ? true : false,
                                 QAAValueDescription = daef.Qaa.Where(c => c.PatientId.Equals(id) && c.Qaqid.Equals(qaqc.Id)).FirstOrDefault().ValueDescription,
                                 Id = qaqc.Id,
                                 Type = qaqc.Type,
                                 Title = qaqc.Title,
                                 IsValue = qaqc.IsValue,
                                 ValueDescription = qaqc.ValueDescription,
                                 SeqNo = qaqc.SeqNo,
                                 ParentId = qaqc.ParentId
                             }).ToList()
                         }).ToList()
                     }).ToList()
                 }).ToList()
             };
             if (patientSetting != null)
             {
                 patientRecord.Introduce = patientSetting.Introduce;
                 if (!string.IsNullOrEmpty(patientSetting.QadoctorNo))
                 {
                     patientRecord.QADoctorList = (from d in users
                                                   select new SelectListItem
                     {
                         Text = d.UserName,
                         Value = d.UserNo,
                         Selected = patientSetting.QadoctorNo.Equals(d.UserNo) ? true : false
                     }).ToList();
                 }
                 else
                 {
                     patientRecord.QADoctorList = (from d in users
                                                   select new SelectListItem
                     {
                         Text = d.UserName,
                         Value = d.UserNo,
                         Selected = false
                     }).ToList();
                 }
             }
             else
             {
                 patientRecord.QADoctorList = (from d in users
                                               select new SelectListItem
                 {
                     Text = d.UserName,
                     Value = d.UserNo,
                     Selected = false
                 }).ToList();
             }
             return(View(patientRecord));
         }
     }
 }
示例#6
0
        public IActionResult QA(PatientRecordViewModel patientRecordViewModel)
        {
            using (var daef = new DentistAssistantContext())
            {
                var qAQParentUnit = patientRecordViewModel.QACategorys.SelectMany(
                    c => c.QAGroupUnits.SelectMany(
                        c2 => c2.QAQParentUnits));
                List <Qaa> qaas = new List <Qaa>();
                foreach (var qaqp in qAQParentUnit)
                {
                    if (qaqp.QAQUnit.IsChecked || qaqp.QAQUnit.Type.Equals("T"))
                    {
                        qaas.Add(new Qaa()
                        {
                            PatientId        = patientRecordViewModel.Patient.PatNo,
                            Qaqid            = qaqp.QAQUnit.Id,
                            ValueDescription = qaqp.QAQUnit.QAAValueDescription
                        });
                    }
                    if (qaqp.QAQUnits != null)
                    {
                        if (qaqp.QAQUnits.Count > 0)
                        {
                            foreach (var qaq in qaqp.QAQUnits)
                            {
                                if (qaq.IsChecked || qaq.Type.Equals("T"))
                                {
                                    qaas.Add(new Qaa()
                                    {
                                        PatientId        = patientRecordViewModel.Patient.PatNo,
                                        Qaqid            = qaq.Id,
                                        ValueDescription = qaq.QAAValueDescription
                                    });
                                }
                            }
                        }
                    }
                }

                var qaa = from a in daef.Qaa
                          where a.PatientId.Equals(patientRecordViewModel.Patient.PatNo)
                          select a;
                //移除所有原有的選項
                daef.Qaa.RemoveRange(qaa);
                //新增新的勾選的選項
                daef.Qaa.AddRange(qaas);


                var patientSetting = daef.PatientSettings.Find(patientRecordViewModel.Patient.PatNo);
                if (patientSetting != null)
                {
                    patientSetting.Introduce  = patientRecordViewModel.Introduce;
                    patientSetting.QadoctorNo = patientRecordViewModel.QADoctor;
                }
                else
                {
                    daef.PatientSettings.Add(new PatientSettings()
                    {
                        Id         = patientRecordViewModel.Patient.PatNo,
                        Introduce  = patientRecordViewModel.Introduce,
                        QadoctorNo = patientRecordViewModel.QADoctor
                    });
                }

                daef.SaveChanges();

                return(RedirectToAction("Record", "Patient", new { id = patientRecordViewModel.Patient.PatNo }));
            }
        }
示例#7
0
 void PatientRecordView_Loaded(object sender, RoutedEventArgs e)
 {
     // Initialize Selection
     this.patientRecordViewModel             = this.DataContext as PatientRecordViewModel;
     patientRecordViewModel.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(patientRecordViewModel_PropertyChanged);
 }