Пример #1
0
        public ActionResult Name()
        {
            var nm = new NameModel();

            nm.Name = UserDataEngine.getInstance().GetCurrentUser(HttpContext).RealName;
            return(View(nm));
        }
Пример #2
0
        public ActionResult Report(long id)
        {
            var nvm = new PatientViewModel();

            using (var c = new DataModelContext())
            {
                User currentUser = UserDataEngine.getInstance().GetCurrentUser(c, HttpContext);

                var patient = c.Patients.Find(id);
                if (patient == null)
                {
                    TempData["Alert"] = "The selected patient does not exist.";
                    return(RedirectToAction("Index"));
                }

                nvm.ID                = patient.ID;
                nvm.FirstName         = patient.FirstName;
                nvm.LastName          = patient.LastName;
                nvm.Therapist         = patient.Therapist;
                nvm.Doctor            = patient.Doctor;
                nvm.LastUpdate        = patient.LastUpdate;
                nvm.ArthritisType     = patient.ArthritisType;
                nvm.AffectedExtremity = patient.AffectedExtremity;
                nvm.Deformity         = patient.Deformity;
                nvm.ShankLength       = patient.ShankLength;
                nvm.ThighLength       = patient.ThighLength;
                nvm.Report            = patient.ReportResult;
                nvm.MedProfile        = patient.MedProfile;
            }
            return(View("Report", nvm));
        }
Пример #3
0
        public ActionResult Index()
        {
            var hvm = new HomeViewModel();

            using (var c = new DataModelContext())
            {
                User currentUser = UserDataEngine.getInstance().GetCurrentUser(c, HttpContext);

                if (currentUser == null)
                {
                    FormsAuthentication.SignOut();
                    return(RedirectToAction("Index", "Account"));
                }

                hvm.Patients = c.Patients.Include("Therapist").Where(n =>
                                                                     n.LastName != null &&
                                                                     n.Therapist.Username == currentUser.Username
                                                                     ).ToList();
            }

            return(View(hvm));
        }
Пример #4
0
        public ActionResult CreateBlank(string PatientFirstName, string PatientLastName,
                                        DateTime PatientBirthday, string PatientGender, int PatientFeet, int PatientInches,
                                        double PatientWeight, string PatientDoctor, string PatientArthritisType,
                                        string PatientAffectedExtremity, string PatientDeformity, string PatientCity, string PatientState,
                                        string PatientPhoneNumber, string PatientEmail)
        {
            var nvm = new PatientListViewModel();

            if (PatientFirstName == "")
            {
                ViewBag.UploadAlert = "Enter the patient's first name";

                using (var c = new DataModelContext())
                {
                    nvm.Patients = c.Patients.Include("Therapist").Where(n => n.LastName != null).ToList();
                }
                return(View("Index", nvm));
            }

            if (PatientLastName == "")
            {
                ViewBag.UploadAlert = "Enter the patient's last name";

                using (var c = new DataModelContext())
                {
                    nvm.Patients = c.Patients.Include("Therapist").Where(n => n.LastName != null).ToList();
                }
                return(View("Index", nvm));
            }

            using (var c = new DataModelContext())
            {
                var patient = new Patient();
                patient.ReportResult = ReportEngine.getInstance().GenerateReport(patient);
                patient.MedProfile   = new MedProfile();

                patient.FirstName         = PatientFirstName;
                patient.LastName          = PatientLastName;
                patient.Therapist         = UserDataEngine.getInstance().GetCurrentUser(c, HttpContext);
                patient.LastUpdate        = DateTime.Now;
                patient.Start             = DateTime.Now;
                patient.Birthday          = PatientBirthday;
                patient.Gender            = PatientGender;
                patient.Height            = (PatientFeet * 12) + PatientInches;
                patient.Weight            = PatientWeight;
                patient.Doctor            = PatientDoctor;
                patient.ArthritisType     = PatientArthritisType;
                patient.AffectedExtremity = PatientAffectedExtremity;
                patient.Deformity         = PatientDeformity;
                patient.ShankLength       = 0;
                patient.ThighLength       = 0;
                patient.PhoneNumber       = PatientPhoneNumber;
                patient.Email             = PatientEmail;
                patient.State             = PatientState;
                patient.City               = PatientCity;
                patient.ContactName        = "Not entered";
                patient.ContactRelation    = "Not entered";
                patient.ContactPhoneNumber = "Not entered";
                patient.ContactEmail       = "Not entered";

                DateTime today = DateTime.Today;
                int      age   = today.Year - PatientBirthday.Year;
                if (PatientBirthday > today.AddYears(-age))
                {
                    age--;
                }
                patient.Age = age;

                c.Patients.Add(patient);

                try
                {
                    c.SaveChanges();
                }
                catch (DbEntityValidationException e)
                {
                    foreach (var i in e.EntityValidationErrors)
                    {
                        Console.WriteLine(i.ValidationErrors);
                    }
                    throw e;
                }
                nvm.Patients = c.Patients.Include("Therapist").Where(n => n.LastName != null).ToList();

                ViewBag.NewPatientID = patient.ID;
            }

            ViewBag.Alert      = "Patient upload successful";
            ViewBag.AlertClass = "alert-success";
            return(View("Index", nvm));
        }