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 })); } }
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 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)); } } }
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)); } } }
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)); } } }
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 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)); } } }
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 })); } } }
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 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)); } } }
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)); } } }
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 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)); } } }
public IActionResult Suggestion(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(); SuggestionViewModel suggestionViewModel = new SuggestionViewModel(); suggestionViewModel.Patient = (from p in def.Patients where p.PatNo.ToLower().Equals(id.ToLower()) && p.Enable.Equals(true) select p).FirstOrDefault(); PatientRecordSuggestUnit patientRecordSuggestUnit = new PatientRecordSuggestUnit(); var patientSetting = daef.PatientSettings.Find(suggestionViewModel.Patient.PatNo); if (patientSetting != null) { ViewBag.NoPatientSetting = false; var isPatientRecord = (from pr in daef.PatientRecords where pr.IsSuggest.Equals(true) && pr.PatientSettingId.ToLower().Equals(id.ToLower()) select new PatientRecordSuggestUnit() { Id = pr.Id, UserNo = pr.UserNo, UserName = users.Where(c => c.UserNo.Equals(pr.UserNo)).FirstOrDefault().UserName, CreateTime = pr.CreateTime, PatientSettingId = pr.PatientSettingId, FdiUnitsS = (from f in pr.Fdis where f.Type.Equals("S") select new FdiUnit() { Fdi = f, FdiDetails = f.FdiDetails.ToList() }).ToList() }).FirstOrDefault(); if (isPatientRecord == null) { PatientRecords patientRecords = new PatientRecords(); patientRecords.UserNo = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value; patientRecords.IsSuggest = true; patientRecords.CreateTime = DateTime.Now; patientRecords.PatientSettingId = id; daef.PatientRecords.Add(patientRecords); daef.SaveChanges(); patientRecordSuggestUnit.Id = patientRecords.Id; patientRecordSuggestUnit.UserNo = patientRecords.UserNo; patientRecordSuggestUnit.UserName = users.Where(c => c.UserNo.Equals(patientRecords.UserNo)).FirstOrDefault().UserName; patientRecordSuggestUnit.CreateTime = patientRecords.CreateTime; patientRecordSuggestUnit.PatientSettingId = id; patientRecordSuggestUnit.FdiUnitsS = new List <FdiUnit>(); } else { patientRecordSuggestUnit = isPatientRecord; } suggestionViewModel.PatientRecordSuggestUnit = patientRecordSuggestUnit; suggestionViewModel.SuggestionNote = patientSetting.SuggestionNote; suggestionViewModel.Notes = Notes == null ? null : Notes.ValueDescription; } else { ViewBag.NoPatientSetting = true; } return(View(suggestionViewModel)); } } }
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 })); } }
public IActionResult CreateShare(string patId, string valueDescription, string userNo, string createDate, string shareTypeId) { using (var def = new DoctorContext()) { using (var daef = new DentistAssistantContext()) { try { var UserNo = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value; var UserName = HttpContext.User.FindFirst("DisplayName").Value; switch (shareTypeId) { case "Sticker": //Sticker var user = def.Users.Find(userNo); var shareSticker = new Shares() { PatId = patId, ValueDescription = valueDescription, UserNo = userNo, CreateDate = DateTime.Parse(createDate), IsEnable = true, ShareTypeId = shareTypeId, }; daef.Shares.Add(shareSticker); daef.SaveChanges(); var jsonResultSticker = new { status = true, info = new { userName = user.UserName, time = shareSticker.CreateDate.ToString("yyyy/MM/dd") } }; return(Json(jsonResultSticker)); default: //SizeU //SizeD var shareSize = new Shares() { PatId = patId, ValueDescription = valueDescription, UserNo = UserNo, CreateDate = DateTime.Parse(createDate), IsEnable = true, ShareTypeId = shareTypeId, }; daef.Shares.Add(shareSize); daef.SaveChanges(); var jsonResultSize = new { status = true, info = new { userName = UserName, valueDescription = shareSize.ValueDescription, time = shareSize.CreateDate.ToString("yyyy/MM/dd") } }; return(Json(jsonResultSize)); } } catch (Exception ex) { var jsonResult = new { status = false, message = ex.ToString() }; return(Json(jsonResult)); } } } }