public Report GenerateReport(Patient pat)
        {
            Report report = new Report();

            report.LStrideNumber = 0;
            report.RStrideNumber = 0;
            report.AverageGaitSpeed = 0;
            report.LeftStrideLength = 0;
            report.RightStrideLength = 0;
            report.RStancePercent = 0;
            report.RSwingPercent = 0;
            report.RSingleLimbStancePercent = 0;
            report.LStancePercent = 0;
            report.LSwingPercent = 0;
            report.LSingleLimbStancePercent = 0;
            report.Candence = 0;

            return report;
        }
        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 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.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);
        }
Beispiel #3
0
        /// <summary>
        /// Clones this patient
        /// Does NOT copy the ID
        /// This method would be used if we need to do any temporary editing.
        /// </summary>
        public object Clone()
        {
            Patient net = new Patient()
            {
                Therapist = Therapist,
            };

            return net;
        }
        public Report GenerateReport(Patient pat, string path)
        {
            Report report = new Report();
            //Use ExcelAnalyzer object to get the values.
            ExcelAnalyzer doc = new ExcelAnalyzer();

            //Open Excel file
            doc.excel_init(path);

            #region ExcelPull
            string LStrideNumber = doc.excel_getValue("B5");
            if (LStrideNumber != "")
            {
                report.LStrideNumber = Math.Round(Convert.ToDouble(LStrideNumber), 2);
            }
            else
            {
                report.LStrideNumber = 0;
            }
            string LStancePercent = doc.excel_getValue("B6");
            if (LStancePercent != "")
            {
                report.LStancePercent = Math.Round(Convert.ToDouble(LStancePercent), 3) * 100;
            }
            else
            {
                report.LStancePercent = 0;
            }
            string LSwingPercent = doc.excel_getValue("B7");
            if (LSwingPercent != "")
            {
                report.LSwingPercent = Math.Round(Convert.ToDouble(LSwingPercent), 3) * 100;
            }
            else
            {
                report.LSwingPercent = 0;
            }
            string LSingleLimbStancePercent = doc.excel_getValue("B8");
            if (LSingleLimbStancePercent != "")
            {
                report.LSingleLimbStancePercent = Math.Round(Convert.ToDouble(LSingleLimbStancePercent), 3) * 100;
            }
            else
            {
                report.LSingleLimbStancePercent = 0;
            }
            string RStrideNumber = doc.excel_getValue("B11");
            if (RStrideNumber != "")
            {
                report.RStrideNumber = Math.Round(Convert.ToDouble(RStrideNumber), 2);
            }
            else
            {
                report.RStrideNumber = 0;
            }
            string RStancePercent = doc.excel_getValue("B12");
            if (RStancePercent != "")
            {
                report.RStancePercent = Math.Round(Convert.ToDouble(RStancePercent), 3) * 100;
            }
            else
            {
                report.RStancePercent = 0;
            }
            string RSwingPercent = doc.excel_getValue("B13");
            if (RSwingPercent != "")
            {
                report.RSwingPercent = Math.Round(Convert.ToDouble(RSwingPercent), 3) * 100;
            }
            else
            {
                report.RSwingPercent = 0;
            }
            string RSingleLimbStancePercent = doc.excel_getValue("B14");
            if (RSingleLimbStancePercent != "")
            {
                report.RSingleLimbStancePercent = Math.Round(Convert.ToDouble(RSingleLimbStancePercent), 3) * 100;
            }
            else
            {
                report.RSingleLimbStancePercent = 0;
            }
            string AverageGaitSpeed = doc.excel_getValue("B15");
            if (AverageGaitSpeed != "")
            {
                report.AverageGaitSpeed = Math.Round(Convert.ToDouble(AverageGaitSpeed), 3) * 100;
            }
            else
            {
                report.AverageGaitSpeed = 0;
            }
            string LeftStrideLength = doc.excel_getValue("B15");
            if (LeftStrideLength != "")
            {
                report.LeftStrideLength = Math.Round(Convert.ToDouble(LeftStrideLength), 2);
            }
            else
            {
                report.LeftStrideLength = 0;
            }
            string RightStrideLength = doc.excel_getValue("B15");
            if (RightStrideLength != "")
            {
                report.RightStrideLength = Math.Round(Convert.ToDouble(RightStrideLength), 2);
            }
            else
            {
                report.RightStrideLength = 0;
            }
            string Candence = doc.excel_getValue("B15");
            if (Candence != "")
            {
                report.Candence = Math.Round(Convert.ToDouble(Candence), 2);
            }
            else
            {
                report.Candence = 0;
            }
            #endregion

            //Close Excel
            doc.excel_close();

            return report;
        }