예제 #1
0
        public void Create(Doctor DoctorData)
        {
            Doctor NewDoctor;

            using (var db = new DoctorContext())
            {
                NewDoctor                = db.Doctors.Create();
                NewDoctor.Name           = DoctorData.Name;
                NewDoctor.Last_name      = DoctorData.Last_name;
                NewDoctor.Middle_initial = DoctorData.Middle_initial;
                NewDoctor.NAGP           = DoctorData.NAGP;
                NewDoctor.NPI            = DoctorData.NPI;
                NewDoctor.DEA            = DoctorData.DEA;
                NewDoctor.Clinic_name    = DoctorData.Clinic_name;
                NewDoctor.Office_phone   = DoctorData.Office_phone;
                NewDoctor.Fax            = DoctorData.Fax;
                NewDoctor.Active         = true;
                NewDoctor.Email          = DoctorData.Email;
                NewDoctor.Address        = DoctorData.Address;
                NewDoctor.City           = DoctorData.City;
                NewDoctor.State          = DoctorData.State;
                NewDoctor.Notes          = DoctorData.Notes;

                using (var db2 = new UsersContext())
                {
                    UserProfile CurrentUser = db2.UserProfiles.Include("Doctors").First(x => x.UserId.Equals(WebSecurity.CurrentUserId));
                    NewDoctor.UserProfileId = CurrentUser.UserId;
                    CurrentUser.Doctors.Add(NewDoctor);

                    db2.SaveChanges();
                }
            }
        }
예제 #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));
         }
     }
 }
예제 #3
0
        public void UpdateDoctor_AppliedValuesAreStoredInDataStore()
        {
            using (var dc = new DoctorContext())
            {
                var doctor = new Doctor
                {
                    Firstname = "Paul",
                    Lastname  = "Johnson",
                    Phone     = "+33 6 67 81 09 58",
                    Specialty = null,
                    User      = (from u in dc.DataContext.Users where u.Role.Name == "visiteur" select u).First(),
                    Office    = (from o in dc.DataContext.Offices select o).First()
                };

                dc.CreateDoctor(doctor);

                const string newFirstName = "Dave",
                             newLastName  = "Scott",
                             newPhone     = "+33 7 58 42 15 20";

                doctor.Firstname = newFirstName;
                doctor.Lastname  = newLastName;
                doctor.Phone     = newPhone;

                // Act
                dc.UpdateDoctor(doctor);

                // Assert
                dc.DataContext.Entry(doctor).Reload();

                Assert.AreEqual(newPhone, doctor.Phone);
                Assert.AreEqual(newFirstName, doctor.Firstname);
                Assert.AreEqual(newLastName, doctor.Lastname);
            }
        }
예제 #4
0
 public IActionResult AdvancedSearch()
 {
     using (var def = new DoctorContext())
     {
         return(View());
     }
 }
예제 #5
0
        public UnitOfWork()
        {                         //double lock pattern :
            ////thread safe olarak db'nin tek bir kez üretilmesini sağlamak. Microsoft sınavında çıkar ama çok sık karşılaşılan bir durum değil
            object whatever = ""; //kilitlemek için kullanılan nesnemiz. tipi adı vs önemli değil

            if (db == null)
            {
                lock (whatever) //bu kitliyken başka hiçbir thread buraya ulaşamaz. bu işlem bitene kadar projede başka hiçbir isteğe cevap verilmez (asenkron işlemleri dahil bekletir)
                {
                    if (db == null)
                    {
                        db = new DoctorContext();
                    }
                }
            }

            Categories         = new BaseRepository <Category>(db);
            Contacts           = new BaseRepository <Contact>(db);
            Appointments       = new BaseRepository <Appointment>(db);
            Notifications      = new BaseRepository <Notification>(db);
            Writes             = new BaseRepository <Write>(db);
            WriteComments      = new BaseRepository <WriteComment>(db);
            AppointmentStatuss = new BaseRepository <AppointmentStatus>(db);
            //Sliders = new BaseRepository<Slider>(db);
        }
예제 #6
0
        public IActionResult Index(string pageInfo = null)
        {
            //HttpContext.Session.Clear();

            //LoginInfo.SetLoginUser(string.Empty, string.Empty);
            HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);

            using (var def = new DoctorContext())
            {
                var loadUsers = (from u in def.Users
                                 where u.LeaveDate >= DateTime.Now ||
                                 u.LeaveDate.Equals(DateTime.Parse("1900-01-01"))
                                 select u).ToList();
                UsersInfo.SetUsers(loadUsers);
                var users = new LoginIndexViewModel()
                {
                    Users = (from u in UsersInfo.Users
                             select new SelectListItem()
                    {
                        Text = u.UserName,
                        Value = u.UserNo,
                        Selected = false
                    }).ToList()
                };
                if (!string.IsNullOrEmpty(pageInfo))
                {
                    ModelState.AddModelError("PageInfo", pageInfo);
                }
                return(View(users));
            }
        }
예제 #7
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));
         }
     }
 }
예제 #8
0
 public List <Doctor> Find(string Keyword)
 {
     using (var db = new DoctorContext())
     {
         IEnumerable <Doctor> Doctors = db.Doctors.Include("Referrals").Where(x => x.UserProfileId.Equals(WebSecurity.CurrentUserId) &&
                                                                              (x.Name.Contains(Keyword) || x.Last_name.Contains(Keyword) || x.Email.Contains(Keyword) || x.City.Contains(Keyword) || x.State.Contains(Keyword) || x.Clinic_name.Contains(Keyword)));
         return(Doctors.ToList());
     }
 }
예제 #9
0
 public List <Doctor> GetAll()
 {
     Doctor[] DocArray;
     using (var db = new DoctorContext())
     {
         IEnumerable <Doctor> Doctors = db.Doctors.Include("Referrals").Where(x => x.UserProfileId.Equals(WebSecurity.CurrentUserId));
         DocArray = Doctors.ToArray();
         return(Doctors.ToList());
     }
 }
예제 #10
0
 public static Doctor CreateDoctor(DoctorContext doctorContext)
 {
     return(new Doctor
     {
         Id = doctorContext.DoctorId,
         NameComplete = doctorContext.NameComplete,
         Specialty = doctorContext.Specialty,
         AccountNumber = doctorContext.AccountNumber,
         Hospital = doctorContext.Hospital
     });
 }
예제 #11
0
 public IActionResult Index(string id)
 {
     using (var def = new DoctorContext())
     {
         var patient = (from p in def.Patients
                        where p.PatNo.ToLower().Equals(id.ToLower()) &&
                        p.Enable.Equals(true)
                        select p).FirstOrDefault();
         return(View(patient));
     }
 }
예제 #12
0
        public void GetDoctorList_ReturnsExpectedListOfDoctorEntities()
        {
            using (var dc = new DoctorContext())
            {
                var doctors = dc.GetDoctorList();

                Assert.IsTrue(doctors.ElementAt(0).Id == doctors.Count);
                Assert.IsTrue(doctors.ElementAt(1).Id == doctors.Count - 1);
                Assert.IsTrue(doctors.ElementAt(2).Id == doctors.Count - 2);
            }
        }
예제 #13
0
        public void QuitReferral(int DoctorId, Referral Referral)
        {
            Doctor TargetDoctor;

            using (var db2 = new DoctorContext())
            {
                TargetDoctor = db2.Doctors.Include("Referrals").First(x => x.Id.Equals(DoctorId));
                TargetDoctor.Referrals.Remove(Referral);
                db2.Entry(TargetDoctor).State = EntityState.Modified;
                db2.SaveChanges();
            }
        }
예제 #14
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));
             }
         }
     }
 }
예제 #15
0
        public Doctor FindById(int id)
        {
            Doctor doctor;

            using (var db = new DoctorContext())
            {
                doctor = db.Doctors.Include(x => x.Referrals.Select(l1 => l1.Reason)).Include(z => z.Referrals.Select(l2 => l2.Patient)).First(x => x.UserProfileId.Equals(WebSecurity.CurrentUserId) && x.Id.Equals(id));
                //  using(var db2 = new ReferralContext())
                //  {
                //      Refs = db2.Referrals.Include("Reason").Where(x => x.Doctor_Id.Equals(id)).ToList();
                //  }
                //  doctor.Referrals = Refs;
                return(doctor);
            }
        }
 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 }));
         }
     }
 }
예제 #17
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));
         }
     }
 }
예제 #18
0
        public void AddNewDoctor_ThrowsException_WhenFirstNameIsEmpty()
        {
            using (var dc = new DoctorContext())
            {
                var doctor = new Doctor
                {
                    Firstname = "",
                    Lastname  = "David",
                    Phone     = "+33 6 67 81 09 58",
                    Specialty = null,
                    User      = (from u in dc.DataContext.Users where u.Role.Name == "visiteur" select u).First(),
                    Office    = (from o in dc.DataContext.Offices select o).First()
                };

                dc.CreateDoctor(doctor);
            }
        }
예제 #19
0
 public bool DeleteDoctor(int id)
 {
     try
     {
         using (var context = new HospitalContext())
         {
             DoctorContext doctorContext = context.DoctorContexts.Find(id);
             context.Remove(doctorContext);
             context.SaveChanges();
         }
         return(true);
     }
     catch (Exception)
     {
         throw;
     }
 }
예제 #20
0
 public Doctor CreateDoctor(Doctor doctor)
 {
     try
     {
         DoctorContext doctorContext = EntityAssembler.CreateDoctorContext(doctor);
         using (var context = new HospitalContext())
         {
             context.DoctorContexts.Add(doctorContext);
             context.SaveChanges();
         }
         return(doctor);
     }
     catch (Exception)
     {
         throw;
     }
 }
예제 #21
0
        public void AddNewDoctor_ThrowsException_WhenPhoneIsNull()
        {
            using (var dc = new DoctorContext())
            {
                var doctor = new Doctor
                {
                    Firstname = "Paul",
                    Lastname  = "Johnson",
                    Phone     = null,
                    Specialty = null,
                    User      = (from u in dc.DataContext.Users where u.Role.Name == "visiteur" select u).First(),
                    Office    = (from o in dc.DataContext.Offices select o).First()
                };

                dc.CreateDoctor(doctor);
            }
        }
예제 #22
0
 public Doctor GetDoctor(int id)
 {
     try
     {
         Doctor doctorResult = null;
         using (var context = new HospitalContext())
         {
             DoctorContext doctorContext = context.DoctorContexts.Find(id);
             doctorResult = ModelAssembler.CreateDoctor(doctorContext);
         }
         return(doctorResult);
     }
     catch (Exception)
     {
         throw;
     }
 }
예제 #23
0
 public IActionResult AssistantList(int patientRecordId)
 {
     using (var def = new DoctorContext())
     {
         AssistantListViewModel assistantListViewModel = new AssistantListViewModel()
         {
             PatientRecordId = patientRecordId,
             Users           = (from u in UsersInfo.Users
                                select new SelectListItem()
             {
                 Text = u.UserName,
                 Value = u.UserNo,
                 Selected = false
             }).ToList()
         };
         return(View(assistantListViewModel));
     }
 }
 public IActionResult CreatePatientRecord(string id)
 {
     using (var def = new DoctorContext())
     {
         var patient = def.Patients.Where(c => c.PatNo.ToUpper().Equals(id.ToUpper())).FirstOrDefault();
         CreatePatientRecordViewModel createPatientRecordViewModel = new CreatePatientRecordViewModel()
         {
             Users = (from u in UsersInfo.Users
                      select new SelectListItem()
             {
                 Text = u.UserName,
                 Value = u.UserNo,
                 Selected = false
             }).ToList(),
             PatientNo = patient.PatNo
         };
         return(View(createPatientRecordViewModel));
     }
 }
예제 #25
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));
                }
            }
        }
예제 #26
0
 public Doctor UpdateDoctor(Doctor doctor)
 {
     try
     {
         using (var context = new HospitalContext())
         {
             DoctorContext doctorContext = context.DoctorContexts.Find(doctor.Id);
             doctorContext.NameComplete  = doctor.NameComplete;
             doctorContext.Specialty     = doctor.Specialty;
             doctorContext.AccountNumber = doctor.AccountNumber;
             doctorContext.Hospital      = doctor.Hospital;
             context.SaveChanges();
         }
         return(doctor);
     }
     catch (Exception)
     {
         throw;
     }
 }
예제 #27
0
        public void AddNewDoctor_DoctorIsStoredInDataStore()
        {
            using (var dc = new DoctorContext())
            {
                var doctor = new Doctor
                {
                    Firstname = "Paul",
                    Lastname  = "Johnson",
                    Phone     = "+33 6 67 81 09 58",
                    Specialty = null,
                    User      = (from u in dc.DataContext.Users where u.Role.Name == "visiteur" select u).First(),
                    Office    = (from o in dc.DataContext.Offices select o).First()
                };

                dc.CreateDoctor(doctor);

                var exists = dc.DataContext.Doctors.Any(c => c.Id == doctor.Id);

                Assert.IsTrue(exists);
            }
        }
        public ActionResult Login(User userModel)
        {
            User userDetails = new User()
            {
                Id = -1
            };

            if (userModel.Id == 0 && userModel.password == "admin")
            {
                return(RedirectToAction("AdminIndex"));
            }
            if (userModel.Id > 999)
            {
                using (PatientContext dbp = new PatientContext())
                {
                    userDetails = dbp.Patients.Where(x => x.Id == userModel.Id && x.password == userModel.password).FirstOrDefault();

                    if (userDetails != null)
                    {
                        Session["userID"] = userDetails.Id;
                        return(RedirectToAction("Index", "Patient"));
                    }
                }
            }
            if (userModel.Id > 0)
            {
                using (DoctorContext db = new DoctorContext())
                {
                    userDetails = db.Doctors.Where(x => x.Id == userModel.Id && x.password == userModel.password).FirstOrDefault();
                    if (userDetails != null)
                    {
                        Session["userID"] = userDetails.Id;
                        return(RedirectToAction("Index", "Doctor"));
                    }
                }
            }
            return(View("Login", userModel));
        }
예제 #29
0
        public void Edit(Doctor newData, int id)
        {
            Doctor Modified;

            using (var db = new DoctorContext())
            {
                Modified                = db.Doctors.Find(id);
                Modified.Active         = newData.Active;
                Modified.Name           = newData.Name;
                Modified.Middle_initial = newData.Middle_initial;
                Modified.Last_name      = newData.Last_name;
                Modified.Clinic_name    = newData.Clinic_name;
                Modified.Address        = newData.Address;
                Modified.Email          = newData.Email;
                Modified.Fax            = newData.Fax;
                Modified.Office_phone   = newData.Office_phone;
                Modified.DEA            = newData.DEA;
                Modified.NAGP           = newData.NAGP;
                Modified.NPI            = newData.NPI;
                Modified.Notes          = newData.Notes;
                db.SaveChanges();
            }
        }
예제 #30
0
 public IActionResult CreateShare(string patId, string shareTypeId)
 {
     using (var def = new DoctorContext())
     {
         var         UserNo      = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;
         var         UserName    = HttpContext.User.FindFirst("DisplayName").Value;
         var         users       = UsersInfo.Users;
         CreateShare createShare = new CreateShare()
         {
             PatId = patId,
             Users = (from u in users
                      select new SelectListItem()
             {
                 Text = u.UserName,
                 Value = u.UserNo,
                 Selected = false
             }).ToList(),
             UserName    = UserName,
             CreateDate  = DateTime.Now,
             ShareTypeId = shareTypeId
         };
         return(View(createShare));
     }
 }