Esempio n. 1
0
 public IActionResult EditFirstTime(string patId)
 {
     using (var def = new DoctorContext())
     {
         var users = UsersInfo.Users;
         using (var daef = new DentistAssistantContext())
         {
             var patientSettingFirstTimeRecord = (from ps in daef.PatientSettings
                                                  where ps.Id.ToUpper().Equals(patId.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")
                                  orderby f.CreateDate descending
                                  select new FdiUnit()
                     {
                         Fdi = f,
                         FdiDetails = f.FdiDetails.ToList()
                     }).ToList(),
                     FdiUnitsN = (from f in pr.Fdis
                                  where f.Type.Equals("N")
                                  orderby f.CreateDate descending
                                  select new FdiUnit()
                     {
                         Fdi = f,
                         FdiDetails = f.FdiDetails.ToList()
                     }).ToList(),
                     RecordUserUnit = (from ru in pr.RecordUsers
                                       orderby ru.CreateDate descending
                                       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();
             return(View(patientSettingFirstTimeRecord));
         }
     }
 }
Esempio n. 2
0
 public IActionResult Search(string searchString)
 {
     using (var def = new DoctorContext())
     {
         using (var daef = new DentistAssistantContext())
         {
             List <PatientCompleteViewModel> patients = new List <PatientCompleteViewModel>();
             if (!string.IsNullOrEmpty(searchString))
             {
                 var patientSetting = daef.PatientSettings.ToList();
                 patients = (from p in def.Patients
                             where (p.PatName.ToLower().Contains(searchString.ToLower()) ||
                                    TransBirth((DateTime)p.Birth).Contains(searchString) ||
                                    (string.IsNullOrEmpty(p.Id) ? false : p.Id.ToLower().Contains(searchString.ToLower())) ||
                                    p.PatNo.ToLower().Contains(searchString.ToLower())) &&
                             p.Enable.Equals(true)
                             select new PatientCompleteViewModel()
                 {
                     Patient = p,
                     PatientSettings = (from ps in patientSetting
                                        where ps.Id.Equals(p.PatNo)
                                        select ps).FirstOrDefault()
                 }).ToList();
             }
             return(View(patients));
         }
     }
 }
Esempio n. 3
0
        public JsonResult SaveSuggestionNote(string patientId, string suggestionNote)
        {
            using (var daef = new DentistAssistantContext())
            {
                try
                {
                    var patientSetting = daef.PatientSettings.Find(patientId);
                    patientSetting.SuggestionNote = suggestionNote;
                    daef.SaveChanges();

                    var jsonResult = new
                    {
                        status  = true,
                        message = ""
                    };
                    return(Json(jsonResult));
                }
                catch
                {
                    var jsonResultError = new
                    {
                        status  = false,
                        message = "系統發生問題"
                    };
                    return(Json(jsonResultError));
                }
            }
        }
 public IActionResult PhraseGroup()
 {
     using (var daef = new DentistAssistantContext())
     {
         return(View(daef.PhraseGroups.ToList()));
     }
 }
Esempio n. 5
0
        public IActionResult FdiDescription(int patientRecordId, int fdiId, string type)
        {
            using (var daef = new DentistAssistantContext())
            {
                FdiDescriptionViewModel fdiDescriptionViewModel = new FdiDescriptionViewModel();
                fdiDescriptionViewModel.PatientRecordId = patientRecordId;
                fdiDescriptionViewModel.Type            = type;

                if (!fdiId.Equals(0))
                {
                    fdiDescriptionViewModel.FdiUnit = (from f in daef.Fdis
                                                       where f.Id.Equals(fdiId)
                                                       select new FdiUnit()
                    {
                        Fdi = f,
                        FdiDetails = f.FdiDetails.ToList()
                    }).FirstOrDefault();
                }
                fdiDescriptionViewModel.PhraseGroups = (from pg in daef.PhraseGroups
                                                        select new SelectListItem()
                {
                    Text = pg.Name,
                    Value = pg.Id.ToString(),
                    Selected = false
                }).ToList();
                return(View(fdiDescriptionViewModel));
            }
        }
 public JsonResult DeletePhraseGroup(int phraseGroupId)
 {
     using (var daef = new DentistAssistantContext())
     {
         try
         {
             var phrases = from p in daef.Phrases
                           where p.PhraseGroupId.Equals(phraseGroupId)
                           select p;
             daef.Phrases.RemoveRange(phrases);
             var phraseGroup = daef.PhraseGroups.Find(phraseGroupId);
             daef.PhraseGroups.Remove(phraseGroup);
             daef.SaveChanges();
             var jsonResultAdd = new
             {
                 status = true
             };
             return(Json(jsonResultAdd));
         }
         catch
         {
             var jsonResultError = new
             {
                 status  = false,
                 message = "系統發生問題"
             };
             return(Json(jsonResultError));
         }
     }
 }
Esempio n. 7
0
        public JsonResult RemoveFdiDescription(int id)
        {
            using (var daef = new DentistAssistantContext())
            {
                try
                {
                    var fdi       = daef.Fdis.Find(id);
                    var fdiDetail = from fd in daef.FdiDetails
                                    where fd.FdiId.Equals(id)
                                    select fd;
                    daef.FdiDetails.RemoveRange(fdiDetail);
                    daef.Fdis.Remove(fdi);
                    daef.SaveChanges();

                    var jsonResult = new
                    {
                        status  = true,
                        message = ""
                    };
                    return(Json(jsonResult));
                }
                catch
                {
                    var jsonResultError = new
                    {
                        status  = false,
                        message = "系統發生問題"
                    };
                    return(Json(jsonResultError));
                }
            }
        }
Esempio n. 8
0
        public JsonResult RemoveAssistant(int id)
        {
            using (var daef = new DentistAssistantContext())
            {
                try
                {
                    var recordUser = daef.RecordUsers.Find(id);
                    daef.RecordUsers.Remove(recordUser);
                    daef.SaveChanges();

                    var jsonResult = new
                    {
                        status  = true,
                        message = ""
                    };
                    return(Json(jsonResult));
                }
                catch
                {
                    var jsonResultError = new
                    {
                        status  = false,
                        message = "系統發生問題"
                    };
                    return(Json(jsonResultError));
                }
            }
        }
Esempio n. 9
0
        public IActionResult CreateFirstTime(CreateFirstTimeViewModel createFirstTimeViewModel)
        {
            using (var daef = new DentistAssistantContext())
            {
                var ps = daef.PatientSettings.Find(createFirstTimeViewModel.PatientNo);
                if (ps == null)
                {
                    //var patientSettings = daef.PatientSettings.Find(createFirstTimeViewModel.PatientId);
                    PatientSettings patientSettings = new PatientSettings();
                    patientSettings.Id            = createFirstTimeViewModel.PatientNo;
                    patientSettings.FirstTimeTime = createFirstTimeViewModel.FirstTime;

                    createFirstTimeViewModel.patientRecord.IsFirst    = true;
                    createFirstTimeViewModel.patientRecord.IsSuggest  = false;
                    createFirstTimeViewModel.patientRecord.CreateTime = createFirstTimeViewModel.FirstTime;
                    patientSettings.PatientRecords.Add(createFirstTimeViewModel.patientRecord);
                    daef.PatientSettings.Add(patientSettings);
                }
                else
                {
                    PatientRecords pr = new PatientRecords();
                    pr.IsFirst          = true;
                    pr.IsSuggest        = false;
                    pr.CreateTime       = createFirstTimeViewModel.FirstTime;
                    pr.UserNo           = createFirstTimeViewModel.patientRecord.UserNo;
                    pr.PatientSettingId = createFirstTimeViewModel.PatientNo;
                    pr.Room             = createFirstTimeViewModel.patientRecord.Room;
                    ps.FirstTimeTime    = createFirstTimeViewModel.FirstTime;
                    ps.PatientRecords.Add(pr);
                    //daef.PatientRecords.Add(pr);
                }
                daef.SaveChanges();
                return(RedirectToAction("Record", "Patient", new { id = createFirstTimeViewModel.PatientNo }));
            }
        }
Esempio n. 10
0
        public JsonResult GetPhrases(int phraseGroupId)
        {
            using (var daef = new DentistAssistantContext())
            {
                try
                {
                    var data = (from p in daef.Phrases
                                where p.PhraseGroupId.Equals(phraseGroupId)
                                select new
                    {
                        id = p.Id,
                        description = p.Description
                    }).ToList();

                    var jsonResult = new
                    {
                        status  = true,
                        message = "",
                        data    = data
                    };
                    return(Json(jsonResult));
                }
                catch
                {
                    var jsonResultError = new
                    {
                        status  = false,
                        message = "系統發生問題"
                    };
                    return(Json(jsonResultError));
                }
            }
        }
Esempio n. 11
0
        public JsonResult UpdatePatientRecords(int id, string timeType, DateTime dateTime)
        {
            using (var daef = new DentistAssistantContext())
            {
                var patientRecord = daef.PatientRecords.Find(id);
                try
                {
                    if (patientRecord != null)
                    {
                        switch (timeType)
                        {
                        case "1":
                            patientRecord.OrderTime = dateTime;
                            break;

                        case "2":
                            patientRecord.ArriveTime = dateTime;
                            break;

                        case "3":
                            patientRecord.DrArriveTime = dateTime;
                            break;

                        case "4":
                            patientRecord.DrLeaveTime = dateTime;
                            break;

                        case "5":
                            patientRecord.PtLeaveTime = dateTime;
                            break;
                        }
                        daef.SaveChanges();
                        var jsonResult = new
                        {
                            status = true
                        };
                        return(Json(jsonResult));
                    }
                    var jsonResultNull = new
                    {
                        status  = false,
                        message = "尚未建立初診詢問單"
                    };
                    return(Json(jsonResultNull));
                }
                catch
                {
                    var jsonResultError = new
                    {
                        status  = false,
                        message = "系統發生問題"
                    };
                    return(Json(jsonResultError));
                }
            }
        }
 public IActionResult DeletePhrases(int phraseGroupId, int id)
 {
     using (var daef = new DentistAssistantContext())
     {
         var phrases = daef.Phrases.Find(id);
         daef.Phrases.Remove(phrases);
         daef.SaveChanges();
         return(Redirect(Url.Action("Index", "Phrases", new { phraseGroupId = phraseGroupId })));
     }
 }
 public IActionResult EditPhrases(PhrasesEditPhrasesViewModel phrasesEditPhrasesViewModel)
 {
     using (var daef = new DentistAssistantContext())
     {
         var phrase = daef.Phrases.Find(phrasesEditPhrasesViewModel.Id);
         phrase.Description = phrasesEditPhrasesViewModel.Description;
         daef.SaveChanges();
         return(View("Index", daef.Phrases.ToList()));
     }
 }
 public IActionResult EditPhrases(int id)
 {
     using (var daef = new DentistAssistantContext())
     {
         var phrase = daef.Phrases.Find(id);
         PhrasesEditPhrasesViewModel phrasesEditPhrasesViewModel = new PhrasesEditPhrasesViewModel()
         {
             Id          = phrase.Id,
             Description = phrase.Description
         };
         return(View(phrasesEditPhrasesViewModel));
     }
 }
        public IActionResult Index(int phraseGroupId)
        {
            using (var daef = new DentistAssistantContext())
            {
                var phraseGroup = daef.PhraseGroups.Find(phraseGroupId);
                var phraseList  = from p in daef.Phrases
                                  where p.PhraseGroupId.Equals(phraseGroupId)
                                  select p;

                ViewBag.PhraseGroupName = phraseGroup.Name;
                ViewBag.PhraseGroupId   = phraseGroup.Id;
                return(View(phraseList.ToList()));
            }
        }
Esempio n. 16
0
 public JsonResult UpdateShareUserNo(int id, string userNo)
 {
     using (var def = new DoctorContext())
     {
         using (var daef = new DentistAssistantContext())
         {
             var shares     = daef.Shares.Find(id);
             var lasetShare = from s in daef.Shares
                              where s.PatId.Equals(shares.PatId) &&
                              s.ShareTypeId.Equals(shares.ShareTypeId) &&
                              s.IsEnable.Equals(true)
                              orderby s.CreateDate descending
                              select s.Id;
             try
             {
                 if (shares != null)
                 {
                     shares.UserNo = userNo;
                     daef.SaveChanges();
                     var userName   = def.Users.Find(shares.UserNo).UserName;
                     var jsonResult = new
                     {
                         status           = true,
                         isUpdate         = lasetShare.FirstOrDefault().Equals(shares.Id) ? true : false,
                         updateShareType  = shares.ShareTypeId,
                         updateCreateDate = shares.CreateDate.ToString("yyyy/MM/dd"),
                         updateUserName   = userName
                     };
                     return(Json(jsonResult));
                 }
                 var jsonResultNull = new
                 {
                     status  = false,
                     message = ""
                 };
                 return(Json(jsonResultNull));
             }
             catch
             {
                 var jsonResultError = new
                 {
                     status  = false,
                     message = "系統發生問題"
                 };
                 return(Json(jsonResultError));
             }
         }
     }
 }
 public IActionResult CreatePatientRecord(CreatePatientRecordViewModel createPatientRecordViewModel)
 {
     using (var def = new DoctorContext())
     {
         using (var daef = new DentistAssistantContext())
         {
             DateTime createTime      = DateTime.Now;
             var      patientSettings = daef.PatientSettings.Find(createPatientRecordViewModel.PatientNo);
             createPatientRecordViewModel.patientRecord.CreateTime = createTime;
             patientSettings.PatientRecords.Add(createPatientRecordViewModel.patientRecord);
             daef.SaveChanges();
             return(RedirectToAction("Assistant", "Patient", new { id = createPatientRecordViewModel.PatientNo }));
         }
     }
 }
Esempio n. 18
0
 public IActionResult Share(string id, string shareTypeId)
 {
     using (var def = new DoctorContext())
     {
         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 users = UsersInfo.Users;
             //Share
             var patientSettings = daef.PatientSettings.Find(id);
             var share           = new Share()
             {
                 Users = (from u in users
                          select new SelectListItem()
                 {
                     Text = u.UserName,
                     Value = u.UserNo,
                     Selected = false
                 }).ToList(),
                 Patient         = patient,
                 ShareType       = shareTypeId,
                 IsCheckedImages = patientSettings != null ? patientSettings.IsShareImage : false,
                 IsCheckedVideos = patientSettings != null ? patientSettings.IsShareVideo : false,
                 Shares          = (from s in daef.Shares
                                    where s.ShareTypeId.ToLower().Trim().Equals(shareTypeId.ToLower().Trim()) &&
                                    s.PatId.Equals(patient.PatNo) &&
                                    s.IsEnable.Equals(true)
                                    orderby s.CreateDate descending
                                    select new ShareEditUnit()
                 {
                     Id = s.Id,
                     PatId = s.PatId,
                     ValueDescription = s.ValueDescription,
                     UserNo = s.UserNo,
                     UserName = (from u in users
                                 where u.UserNo.Equals(s.UserNo)
                                 select u.UserName).FirstOrDefault(),
                     CreateDate = s.CreateDate.ToString("yyyy/MM/dd HH:mm"),
                     ShareTypeId = s.ShareTypeId
                 }).ToList()
             };
             return(View(share));
         }
     }
 }
Esempio n. 19
0
        public JsonResult RemoveShare(string id)
        {
            using (var daef = new DentistAssistantContext())
            {
                try
                {
                    if (!string.IsNullOrEmpty(id))
                    {
                        var shares = daef.Shares.Find(int.Parse(id));
                        shares.IsEnable = false;
                        daef.SaveChanges();

                        var sharesCount = (from s in daef.Shares
                                           where s.PatId.Equals(shares.PatId) &&
                                           s.ShareTypeId.Equals(shares.ShareTypeId) &&
                                           s.IsEnable.Equals(true)
                                           select s).Count();


                        var jsonResultAdd = new
                        {
                            status          = true,
                            isUpdate        = sharesCount > 0 ? false : true,
                            updateShareType = shares.ShareTypeId
                        };
                        return(Json(jsonResultAdd));
                    }
                    else
                    {
                        var jsonResultNoId = new
                        {
                            status  = false,
                            message = "尚未有圖片資訊"
                        };
                        return(Json(jsonResultNoId));
                    }
                }
                catch
                {
                    var jsonResultError = new
                    {
                        status  = false,
                        message = "系統發生問題"
                    };
                    return(Json(jsonResultError));
                }
            }
        }
 public JsonResult CrearePhraseGroupName(string phraseGroupName)
 {
     using (var daef = new DentistAssistantContext())
     {
         try
         {
             if (!string.IsNullOrEmpty(phraseGroupName))
             {
                 var phraseGroup = new PhraseGroups()
                 {
                     Name = phraseGroupName
                 };
                 daef.PhraseGroups.Add(phraseGroup);
                 daef.SaveChanges();
                 var jsonResultAdd = new
                 {
                     status = true,
                     info   = new
                     {
                         phraseGroupId   = phraseGroup.Id,
                         phraseGroupName = phraseGroup.Name
                     }
                 };
                 return(Json(jsonResultAdd));
             }
             else
             {
                 var jsonResultNoId = new
                 {
                     status  = false,
                     message = "請輸入名稱"
                 };
                 return(Json(jsonResultNoId));
             }
         }
         catch
         {
             var jsonResultError = new
             {
                 status  = false,
                 message = "系統發生問題"
             };
             return(Json(jsonResultError));
         }
     }
 }
        public JsonResult RemovePatientRecord(int patientRecordId)
        {
            using (var daef = new DentistAssistantContext())
            {
                try
                {
                    //var patientRecord = daef.PatientRecords.Find(patientRecordId);

                    var patientRecord = daef.PatientRecords.Find(patientRecordId);

                    var fdi = (from f in daef.Fdis
                               where f.PatientRecordId.Equals(patientRecord.Id)
                               select f).ToList();

                    var fdiDetail = (from fd in daef.FdiDetails
                                     where fd.Fdi.PatientRecordId.Equals(patientRecord.Id)
                                     select fd).ToList();

                    var recordUsers = (from ru in daef.RecordUsers
                                       where ru.PatientRecordId.Equals(patientRecord.Id)
                                       select ru).ToList();

                    daef.RecordUsers.RemoveRange(recordUsers);
                    daef.FdiDetails.RemoveRange(fdiDetail);
                    daef.Fdis.RemoveRange(fdi);
                    daef.PatientRecords.Remove(patientRecord);
                    daef.SaveChanges();

                    var jsonResult = new
                    {
                        status = true
                    };
                    return(Json(jsonResult));
                }
                catch
                {
                    var jsonResultError = new
                    {
                        status  = false,
                        message = "系統發生問題"
                    };
                    return(Json(jsonResultError));
                }
            }
        }
 public JsonResult GetPhrases(string searchString)
 {
     using (var daef = new DentistAssistantContext())
     {
         try
         {
             if (!string.IsNullOrEmpty(searchString))
             {
                 var phrases = (from p in daef.Phrases
                                where p.Description.Contains(searchString)
                                select p).ToList();
                 var jsonResultAdd = new
                 {
                     status = true,
                     info   = (from p in daef.Phrases
                               where p.Description.Contains(searchString)
                               select new
                     {
                         id = p.Id,
                         description = p.Description
                     }).ToList()
                 };
                 return(Json(jsonResultAdd));
             }
             else
             {
                 var jsonResultNoId = new
                 {
                     status  = false,
                     message = "請輸入片語關鍵字"
                 };
                 return(Json(jsonResultNoId));
             }
         }
         catch
         {
             var jsonResultError = new
             {
                 status  = false,
                 message = "系統發生問題"
             };
             return(Json(jsonResultError));
         }
     }
 }
Esempio n. 23
0
        public JsonResult SetPatientComplete(string patNo)
        {
            using (var daef = new DentistAssistantContext())
            {
                try
                {
                    var patientSetting = daef.PatientSettings.Find(patNo);
                    if (patientSetting != null)
                    {
                        patientSetting.IsCompleted = false;
                        patientSetting.CreateTime  = DateTime.Now;
                    }
                    else
                    {
                        daef.PatientSettings.Add(new PatientSettings()
                        {
                            Id           = patNo,
                            IsShareImage = false,
                            IsShareVideo = false,
                            IsCompleted  = false,
                            CreateTime   = DateTime.Now
                        });
                    }

                    daef.SaveChanges();

                    var jsonResult = new
                    {
                        status = true
                    };
                    return(Json(jsonResult));
                }
                catch
                {
                    var jsonResultError = new
                    {
                        status  = false,
                        message = "系統發生問題"
                    };
                    return(Json(jsonResultError));
                }
            }
        }
Esempio n. 24
0
        public IActionResult Index()
        {
            using (var def = new DoctorContext())
            {
                using (var daef = new DentistAssistantContext())
                {
                    var x = daef.PatientSettings.ToList();

                    var patientSetting = (from ps in daef.PatientSettings
                                          where ps.IsCompleted != null && ps.IsCompleted != true
                                          select ps.Id).ToList();

                    var patients = (from p in def.Patients
                                    where patientSetting.Contains(p.PatNo)
                                    select p).ToList();
                    return(View(patients));
                }
            }
        }
Esempio n. 25
0
 public JsonResult AddShareType(string patId, string shareTypeId)
 {
     using (var daef = new DentistAssistantContext())
     {
         try
         {
             var UserNo   = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;
             var UserName = HttpContext.User.FindFirst("DisplayName").Value;
             var share    = new Shares()
             {
                 PatId       = patId,
                 UserNo      = UserNo,
                 CreateDate  = DateTime.Now,
                 IsEnable    = true,
                 ShareTypeId = shareTypeId,
             };
             daef.Shares.Add(share);
             daef.SaveChanges();
             var jsonResult = new
             {
                 status = true,
                 info   = new
                 {
                     userName = UserName,
                     time     = share.CreateDate.ToString("yyyy/MM/dd")
                 }
             };
             return(Json(jsonResult));
         }
         catch (Exception ex)
         {
             var jsonResult = new
             {
                 status  = false,
                 message = ex.ToString()
             };
             return(Json(jsonResult));
         }
     }
 }
Esempio n. 26
0
 public JsonResult ShareVideoChanged(string patId, bool isChecked)
 {
     using (var daef = new DentistAssistantContext())
     {
         var patientSetting = daef.PatientSettings.Find(patId);
         try
         {
             if (patientSetting != null)
             {
                 patientSetting.IsShareVideo = isChecked;
                 daef.SaveChanges();
             }
             else
             {
                 daef.PatientSettings.Add(new PatientSettings()
                 {
                     Id           = patId,
                     IsShareVideo = isChecked
                 });
                 daef.SaveChanges();
             }
             var jsonResult = new
             {
                 status = true
             };
             return(Json(jsonResult));
         }
         catch
         {
             var jsonResultError = new
             {
                 status  = false,
                 message = "系統發生問題"
             };
             return(Json(jsonResultError));
         }
     }
 }
Esempio n. 27
0
        public JsonResult AddAssistant(int patientRecordId, string userNo)
        {
            using (var daef = new DentistAssistantContext())
            {
                try
                {
                    var         patientRecord = daef.PatientRecords.Find(patientRecordId);
                    RecordUsers recordUsers   = new RecordUsers()
                    {
                        UserNo     = userNo,
                        CreateDate = DateTime.Now
                    };
                    patientRecord.RecordUsers.Add(recordUsers);

                    daef.SaveChanges();

                    var jsonResult = new
                    {
                        status  = true,
                        message = "",
                        data    = new
                        {
                            id = recordUsers.Id
                        }
                    };
                    return(Json(jsonResult));
                }
                catch
                {
                    var jsonResultError = new
                    {
                        status  = false,
                        message = "系統發生問題"
                    };
                    return(Json(jsonResultError));
                }
            }
        }
        public async Task <IActionResult> AddPhrases(PhrasesAddPhrasesViewModel phrasesAddPhrasesViewModel)
        {
            using (var daef = new DentistAssistantContext())
            {
                //var newParases = (from p in phrasesAddPhrasesViewModel.Description
                //                  select new Phrases()
                //                  {
                //                      Description = p
                //                  }).ToList();

                //daef.Phrases.AddRange(newParases);
                var phraseGroup = daef.PhraseGroups.Find(phrasesAddPhrasesViewModel.PhraseGroupId);
                foreach (string description in phrasesAddPhrasesViewModel.Description)
                {
                    phraseGroup.Phrases.Add(new Phrases()
                    {
                        Description = description
                    });
                }
                await daef.SaveChangesAsync();

                return(Redirect(Url.Action("Index", "Phrases", new { phraseGroupId = phrasesAddPhrasesViewModel.PhraseGroupId })));
            }
        }
Esempio n. 29
0
        private ShareViewModel GetShare(string patId)
        {
            using (var def = new DoctorContext())
            {
                using (var daef = new DentistAssistantContext())
                {
                    ShareViewModel shareViewModel = new ShareViewModel();
                    if (!string.IsNullOrEmpty(patId))
                    {
                        var users           = UsersInfo.Users;
                        var patientSettings = daef.PatientSettings.Find(patId);
                        var shareType       = from st in daef.ShareTypes
                                              select new LastOneShareType()
                        {
                            Id    = st.Id,
                            Type  = st.Type,
                            Name  = st.Name,
                            Share = (from s in st.Shares
                                     where s.PatId.Equals(patId) &&
                                     s.IsEnable.Equals(true)
                                     orderby s.CreateDate descending
                                     select new ShareUnit()
                            {
                                Id = s.Id,
                                PatId = s.PatId,
                                ValueDescription = s.ValueDescription,
                                UserNo = s.UserNo,
                                UserName = users.Where(c => c.UserNo.Equals(s.UserNo)).FirstOrDefault().UserName,
                                CreateDate = s.CreateDate,
                                ShareTypeId = s.ShareTypeId
                            }).FirstOrDefault()
                        };

                        shareViewModel.IsCheckedImages = patientSettings != null ? patientSettings.IsShareImage : false;
                        shareViewModel.IsCheckedVideos = patientSettings != null ? patientSettings.IsShareVideo : false;
                        foreach (var st in shareType)
                        {
                            if (st.Share != null)
                            {
                                switch (st.Id)
                                {
                                case "BlackA":
                                    shareViewModel.BlackA = st.Share;
                                    break;

                                case "BlackB":
                                    shareViewModel.BlackB = st.Share;
                                    break;

                                case "HeadTopA":
                                    shareViewModel.HeadTopA = st.Share;
                                    break;

                                case "HeadTopB":
                                    shareViewModel.HeadTopB = st.Share;
                                    break;

                                case "LCTA":
                                    shareViewModel.LCTA = st.Share;
                                    break;

                                case "LCTB":
                                    shareViewModel.LCTB = st.Share;
                                    break;

                                case "MirrorA":
                                    shareViewModel.MirrorA = st.Share;
                                    break;

                                case "MirrorB":
                                    shareViewModel.MirrorB = st.Share;
                                    break;

                                case "MouseInA":
                                    shareViewModel.MouseInA = st.Share;
                                    break;

                                case "MouseInB":
                                    shareViewModel.MouseInB = st.Share;
                                    break;

                                case "NineA":
                                    shareViewModel.NineA = st.Share;
                                    break;

                                case "NineB":
                                    shareViewModel.NineB = st.Share;
                                    break;

                                case "PanoA":
                                    shareViewModel.PANOA = st.Share;
                                    break;

                                case "PanoB":
                                    shareViewModel.PANOB = st.Share;
                                    break;

                                case "PREP":
                                    shareViewModel.PREP = st.Share;
                                    break;

                                case "Print":
                                    shareViewModel.Print = st.Share;
                                    break;

                                case "ReferenceModelA":
                                    shareViewModel.ReferenceModelA = st.Share;
                                    break;

                                case "ReferenceModelB":
                                    shareViewModel.ReferenceModelB = st.Share;
                                    break;

                                case "ScanA":
                                    shareViewModel.ScanA = st.Share;
                                    break;

                                case "ScanB":
                                    shareViewModel.ScanB = st.Share;
                                    break;

                                case "SizeD":
                                    shareViewModel.SizeD = st.Share;
                                    break;

                                case "SizeU":
                                    shareViewModel.SizeU = st.Share;
                                    break;

                                case "Sticker":
                                    shareViewModel.Sticker = st.Share;
                                    break;

                                case "Take":
                                    shareViewModel.Take = st.Share;
                                    break;

                                case "UCTA":
                                    shareViewModel.UCTA = st.Share;
                                    break;

                                case "UCTB":
                                    shareViewModel.UCTB = st.Share;
                                    break;

                                case "Wax":
                                    shareViewModel.Wax = st.Share;
                                    break;

                                case "WhiteA":
                                    shareViewModel.WhiteA = st.Share;
                                    break;

                                case "WhiteB":
                                    shareViewModel.WhiteB = st.Share;
                                    break;
                                }
                            }
                        }
                    }
                    return(shareViewModel);
                }
            }
        }
Esempio n. 30
0
        public JsonResult AddUpdateFdi(int patientRecordId, int fdiId, string type, bool fm, bool ub, bool ua, bool ur, bool ul,
                                       bool lb, bool la, bool lr, bool ll, bool indescribable,
                                       string fdiDescription, List <string> data)
        {
            using (var daef = new DentistAssistantContext())
            {
                try
                {
                    if (fdiId.Equals(0))
                    {
                        //insert
                        var  patinetRecord = daef.PatientRecords.Find(patientRecordId);
                        Fdis fdis          = new Fdis();
                        fdis.Fm            = fm;
                        fdis.Ub            = ub;
                        fdis.Ua            = ua;
                        fdis.Ur            = ur;
                        fdis.Ul            = ul;
                        fdis.Lb            = lb;
                        fdis.La            = la;
                        fdis.Lr            = lr;
                        fdis.Ll            = ll;
                        fdis.Indescribable = indescribable;
                        fdis.Description   = fdiDescription;
                        fdis.CreateDate    = DateTime.Now;
                        fdis.Type          = type;
                        if (data.Count > 0)
                        {
                            fdis.FdiDetails = (from d in data
                                               select new FdiDetails()
                            {
                                FdiArea = d.Substring(0, 1),
                                FdiPosition = d.Substring(1, 1)
                            }).ToList();
                        }
                        patinetRecord.Fdis.Add(fdis);
                    }
                    else
                    {
                        //update
                        var updateFdi = daef.Fdis.Find(fdiId);
                        updateFdi.Fm            = fm;
                        updateFdi.Ub            = ub;
                        updateFdi.Ua            = ua;
                        updateFdi.Ur            = ur;
                        updateFdi.Ul            = ul;
                        updateFdi.Lb            = lb;
                        updateFdi.La            = la;
                        updateFdi.Lr            = lr;
                        updateFdi.Ll            = ll;
                        updateFdi.Indescribable = indescribable;
                        updateFdi.Description   = fdiDescription;
                        updateFdi.CreateDate    = DateTime.Now;
                        updateFdi.Type          = type;

                        var fdiDetail = from fd in daef.FdiDetails
                                        where fd.FdiId.Equals(fdiId)
                                        select fd;
                        daef.FdiDetails.RemoveRange(fdiDetail);

                        if (data.Count > 0)
                        {
                            foreach (string d in data)
                            {
                                updateFdi.FdiDetails.Add(new FdiDetails()
                                {
                                    FdiArea     = d.Substring(0, 1),
                                    FdiPosition = d.Substring(1, 1)
                                });
                            }
                        }
                    }

                    daef.SaveChanges();

                    var jsonResult = new
                    {
                        status  = true,
                        message = "",
                        data    = new
                        {
                            //fdiId = fdis.Id
                        }
                    };
                    return(Json(jsonResult));
                }
                catch
                {
                    var jsonResultError = new
                    {
                        status  = false,
                        message = "系統發生問題"
                    };
                    return(Json(jsonResultError));
                }
            }
        }