Пример #1
0
        public virtual void CheckPatientVisitsForArchived(string login)
        {
            using (SurgeryModel sm = new SurgeryModel())
            {
                var patient = (from pt in sm.Patients
                               where pt.PatientAccount_Login == login
                               select pt).First();

                DateTime dtp = DateTime.Now.AddDays(14);

                var visits = (from vt in sm.VisitTimes
                              where vt.PatientId == patient.Id && vt.Date < dtp
                              select vt).ToList();

                DateTime dt = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
                foreach (VisitTime visit in visits)
                {
                    if (visit.Date <= DateTime.Now)
                    {
                        ArchivedVisit av = new ArchivedVisit()
                        {
                            Patient = visit.Patient,
                            Doctor  = visit.Doctor,
                            Date    = visit.Date
                        };
                        sm.ArchivedVisits.Add(av);
                        sm.VisitTimes.Remove(visit);
                    }
                }

                sm.SaveChanges();
            }
        }
Пример #2
0
 public SurgeryPresenter(ISurgeryView view)
 {
     surgeryView     = view;
     surgeryModel    = new SurgeryModel();
     wardModel       = new WardModel();
     patientRegModel = new PatientRegistrationModel();
 }
Пример #3
0
        public ActionResult Login(NewLoginViewModel model, string returnUrl)
        {
            if (!ModelState.IsValid)
            {
                ModelState.AddModelError("", "Niepoprawne dane.");
                return(View(model));
            }

            bool isPatientInDB = false, isAdminInDB = false;

            List <Patient> patient;
            List <Admin>   admins;

            using (SurgeryModel db = new SurgeryModel())
            {
                patient = (from p in db.Patients
                           where p.PatientAccount_Login == model.Login && p.PatientAccount_Password == model.Password
                           select p).ToList();

                admins = (from p in db.Admins
                          where p.Login == model.Login && p.Password == model.Password
                          select p).ToList();

                if (patient.Count == 1)
                {
                    isPatientInDB = true;
                }
                else
                if (admins.Count == 1)
                {
                    isAdminInDB = true;
                }
            }

            if (!isPatientInDB && !isAdminInDB)
            {
                ModelState.AddModelError("", "Niepoprawny login lub/i hasło.");
                return(View(model));
            }

            if (isAdminInDB)
            {
                System.Web.Security.FormsAuthentication.SetAuthCookie("Admin", false);
                HttpContext.Response.AppendCookie(new HttpCookie("user", "admin"));
                return(RedirectToAction("Index", "Admin", null));
            }

            else
            {
                var P = patient[0];
                //ViewBag["Role"] = "Patient";
                ViewBag.Id = P.Id;
                System.Web.Security.FormsAuthentication.SetAuthCookie($"{P.Name} {P.Surname}", false);
                HttpContext.Response.AppendCookie(new HttpCookie("user", "patient"));
                HttpContext.Response.AppendCookie(new HttpCookie("user_id", $"{P.Id}"));

                return(RedirectToAction("Main", "Patients", new { id = P.Id })); //znak - to jest jeszcze źle
            }
        }
Пример #4
0
        public ActionResult RegisterPatient([Bind(Include = "Id,Name,Surname,PhoneNumber,PESELNumber,PatientAddress_City,PatientAddress_Street,PatientAddress_StreetNumber,PatientAddress_HomeNumber,PatientAddress_PostalCode,PatientAccount_Password")] Patient model)
        {
            ModelState.SetModelValue("PatientAccount_Login", new ValueProviderResult(model.PESELNumber, null, CultureInfo.InvariantCulture));
            model.PatientAccount_Login = model.PESELNumber;

            ModelState.SetModelValue("PatientAddress_Country", new ValueProviderResult("Polska", null, CultureInfo.InvariantCulture));
            model.PatientAddress_Country = "Polska";

            int countErrors = 0;

            foreach (ModelState modelState in ViewData.ModelState.Values)
            {
                foreach (ModelError error in modelState.Errors)
                {
                    countErrors++;
                }
            }

            if (countErrors == 1)
            {
                var patient = new Patient
                {
                    Name                        = model.Name,
                    Surname                     = model.Surname,
                    PESELNumber                 = model.PESELNumber,
                    PhoneNumber                 = model.PhoneNumber,
                    PatientAddress_Country      = model.PatientAddress_Country,
                    PatientAddress_City         = model.PatientAddress_City,
                    PatientAddress_Street       = model.PatientAddress_Street,
                    PatientAddress_PostalCode   = model.PatientAddress_PostalCode,
                    PatientAddress_StreetNumber = model.PatientAddress_StreetNumber,
                    PatientAccount_Login        = model.PESELNumber,
                    PatientAccount_Password     = model.PatientAccount_Password,
                    PatientAddress_HomeNumber   = model.PatientAddress_HomeNumber == null ? String.Empty : model.PatientAddress_HomeNumber
                };

                using (SurgeryModel db = new SurgeryModel())
                {
                    var patients = (from p in db.Patients
                                    where p.PatientAccount_Login == model.PESELNumber
                                    select p).ToList();

                    if (patients.Count == 1)
                    {
                        ModelState.AddModelError("Error", "Pacjent o takim numerze PESEL już istnieje");
                        return(View(model));
                    }
                }

                using (SurgeryModel db = new SurgeryModel())
                {
                    db.Patients.Add(patient);
                    db.SaveChanges();
                }

                return(RedirectToAction("Index", "Home"));
            }
            return(View(model));
        }
Пример #5
0
        public List <VisitTime> ListVisitsByLicenceNumber(string licenceNumber)
        {
            List <VisitTime> visits;

            using (SurgeryModel sc = new SurgeryModel())
            {
                visits = (from visit in sc.VisitTimes
                          where visit.Doctor.LicenseNumber == licenceNumber
                          orderby visit.Date
                          select visit).ToList();

                foreach (VisitTime vt in visits)
                {
                    sc.Entry(vt).Reference(x => x.Doctor).Load();
                    sc.Entry(vt.Doctor).Reference(x => x.Clinic).Load();
                    sc.Entry(vt).Reference(x => x.Patient).Load();
                }
            }

            return(visits);
        }
Пример #6
0
        public ActionResult PatientEdit([Bind(Include = "Id,Name,Surname,PhoneNumber,PESELNumber,PatientAddress_Country,PatientAddress_City,PatientAddress_Street,PatientAddress_StreetNumber,PatientAddress_HomeNumber,PatientAddress_PostalCode,PatientAccount_Login,PatientAccount_Password")] Patient model)
        {
            //using (Verification v = new Verification(Request)) if (!v.IsAdmin() && v.GetCurrentUserID() != id) id = v.GetCurrentUserID();
            ModelState.SetModelValue("PatientAccount_Login", new ValueProviderResult(model.PESELNumber, null, CultureInfo.InvariantCulture));
            model.PatientAccount_Login = model.PESELNumber;

            ModelState.SetModelValue("PatientAddress_Country", new ValueProviderResult("Polska", null, CultureInfo.InvariantCulture));
            model.PatientAddress_Country = "Polska";

            int countErrors = 0;

            foreach (ModelState modelState in ViewData.ModelState.Values)
            {
                foreach (ModelError error in modelState.Errors)
                {
                    countErrors++;
                }
            }

            if (countErrors <= 2)
            {
                var patient = (from p in db.Patients
                               where p.Id == model.Id
                               select p).FirstOrDefault();

                var oldPESEL = patient.PESELNumber;

                patient.Name                        = model.Name;
                patient.Surname                     = model.Surname;
                patient.PESELNumber                 = model.PESELNumber;
                patient.PhoneNumber                 = model.PhoneNumber;
                patient.PatientAddress_Country      = model.PatientAddress_Country;
                patient.PatientAddress_City         = model.PatientAddress_City;
                patient.PatientAddress_Street       = model.PatientAddress_Street;
                patient.PatientAddress_PostalCode   = model.PatientAddress_PostalCode;
                patient.PatientAddress_StreetNumber = model.PatientAddress_StreetNumber;
                patient.PatientAccount_Login        = model.PESELNumber;
                patient.PatientAccount_Password     = model.PatientAccount_Password;
                patient.PatientAddress_HomeNumber   = model.PatientAddress_HomeNumber == null ? String.Empty : model.PatientAddress_HomeNumber;

                if (oldPESEL != model.PESELNumber)
                {
                    using (SurgeryModel db = new SurgeryModel())
                    {
                        var patients = (from p in db.Patients
                                        where p.PatientAccount_Login == model.PESELNumber
                                        select p).ToList();

                        if (patients.Count == 1)
                        {
                            ModelState.AddModelError("Error", "Pacjent o takim numerze PESEL już istnieje");
                            return(View(model));
                        }
                    }
                }

                db.Entry(patient).State = EntityState.Modified;
                db.SaveChanges();
                using (Verification v = new Verification(Request))
                    if (v.IsAdmin())
                    {
                        return(RedirectToAction("AdminIndex", "Patients"));
                    }
                    else
                    {
                        return(RedirectToAction("Main", "Patients", new { id = patient.Id }));
                    }
            }
            return(View(model));
        }
Пример #7
0
 public static bool Save(IServerAuthentication restClientAuthenticator, SurgeryModel model)
 {
     return(ApiClientGenericObject <SurgeryModel> .Save(restClientAuthenticator, ControllerName, model));
 }
Пример #8
0
 public OperationNotePresenter(IOperationNoteView view)
 {
     operationView = view;
     surgeryModel  = new SurgeryModel();
 }
Пример #9
0
 /// <summary>
 /// constructor of the patient presenter
 /// </summary>
 /// <param name="view"></param>
 public SurgeryListPresenter(ISurgeryListView view)
 {
     surgeryView      = view;
     surgeryListModel = new SurgeryListModel();
     surgeryModel     = new SurgeryModel();
 }
Пример #10
0
 /// <summary>
 /// constructor of the patient presenter
 /// </summary>
 /// <param name="view"></param>
 public SurgeryApprovalPresenter(ISurgeryApprovalView view)
 {
     surgeryView   = view;
     surgeruyModel = new SurgeryModel();
 }