Esempio n. 1
0
        public IActionResult Patient(int id, string Username, string equipmentType, string actuator = "")
        {
            ViewBag.User     = Username;
            ViewBag.actuator = actuator;

            string _uType = HttpContext.Session.GetString("UserType");

            if (_uType == "3" || _uType == "2" || _uType == "1" || _uType == "0" || _uType == "6")
            {
                {
                    PatientRx patientRx = lIPatientRxRepository.getByRxIDId(id, actuator);
                    ViewBag.PatientRx = patientRx;
                }
                //Usage
                PatientRx      lPatientRx = lIPatientRxRepository.getPatientRx(id, equipmentType, actuator);
                UsageViewModel lusage     = new UsageViewModel();
                lusage.MaxSessionSuggested = 0;
                lusage.PercentageCompleted = 0;
                lusage.PercentagePending   = 100;
                ViewBag.Usage = lusage;
                if (lPatientRx != null)
                {
                    double requiredSession = (((Convert.ToDateTime(lPatientRx.RxEndDate) - Convert.ToDateTime(lPatientRx.RxStartDate)).TotalDays / 7) * (int)lPatientRx.RxDaysPerweek * (int)lPatientRx.RxSessionsPerWeek);
                    int    totalSession    = lPatientRx.Session != null?lPatientRx.Session.ToList().Count : 0;

                    lusage.MaxSessionSuggested = (int)requiredSession;
                    lusage.PercentageCompleted = (int)((totalSession / requiredSession) * 100);
                    lusage.PercentagePending   = 100 - lusage.PercentageCompleted;
                    ViewBag.Usage = lusage;
                }

                //Pain
                PatientRx     lPatientRxPain = lIPatientRxRepository.getPatientRxPain(id, equipmentType, actuator);
                PainViewModel lpain          = new PainViewModel();
                lpain.TotalPain  = 0;
                lpain.LowPain    = 0;
                lpain.MediumPain = 0;
                lpain.HighPain   = 100;
                ViewBag.Pain     = lpain;
                if (lPatientRxPain != null)
                {
                    List <Session> lSessionList = lPatientRx.Session != null?lPatientRxPain.Session.ToList() : null;

                    if (lSessionList != null && lSessionList.Count > 0)
                    {
                        lpain.TotalPain  = lSessionList.Select(x => x.Pain.Count).Sum();
                        lpain.LowPain    = lpain.TotalPain > 0 ? (int)(((double)(lSessionList.Select(x => x.Pain.Where(y => y.PainLevel <= 2).Count()).Sum()) / lpain.TotalPain) * 100) : 0;
                        lpain.MediumPain = lpain.TotalPain > 0 ? (int)(((double)(lSessionList.Select(x => x.Pain.Where(y => y.PainLevel > 2 && y.PainLevel <= 5).Count()).Sum()) / lpain.TotalPain) * 100) : 0;
                        lpain.HighPain   = 100 - lpain.MediumPain - lpain.LowPain;
                        ViewBag.Pain     = lpain;
                    }
                }



                ROMChartViewModel ROM = lIPatientRxRepository.getPatientRxROMChart(id, equipmentType, actuator);
                if (ROM != null)
                {
                    ViewBag.ROM = ROM;
                }

                ViewBag.EquipmentType = equipmentType;
                if (equipmentType == "Shoulder")
                {
                    //Equipment ROM
                    ViewBag.EquipmentType = equipmentType;
                    List <ShoulderViewModel> ROMList = lIPatientRxRepository.getPatientRxEquipmentROMForShoulder(id, equipmentType, actuator);
                    if (ROMList != null && ROMList.Count > 0)
                    {
                        ViewBag.FlexionColor = (ROMList.Where(x => x.Flexion > 0).Count() > 0) ? "Orange" : "White";
                        ViewBag.EquipmentROM = ROMList;
                    }
                    //Compliance
                    List <ShoulderViewModel> ComplianceList = lIPatientRxRepository.getPatientRxComplianceForShoulder(id, equipmentType, actuator);
                    if (ComplianceList != null && ComplianceList.Count > 0)
                    {
                        ViewBag.ComFlexionColor = (ComplianceList.Where(x => x.Flexion > 0).Count() > 0) ? "Orange" : "White";
                        ViewBag.Compliance      = ComplianceList;
                    }
                }
                else
                {
                    //Equipment ROM
                    ViewBag.EquipmentType = equipmentType;
                    List <FlexionViewModel> FlexionList = lIPatientRxRepository.getPatientRxEquipmentROMByFlexion(id, equipmentType, actuator);
                    if (FlexionList != null && FlexionList.Count > 0)
                    {
                        ViewBag.EquipmentFlexion = FlexionList;
                    }
                    List <ExtensionViewModel> ExtensionList = lIPatientRxRepository.getPatientRxEquipmentROMByExtension(id, equipmentType, actuator);
                    if (ExtensionList != null && ExtensionList.Count > 0)
                    {
                        ViewBag.EquipmentExtension = ExtensionList;
                    }

                    //Compliance

                    List <FlexionViewModel> CFlexionList = lIPatientRxRepository.getPatientRxComplianceByFlexion(id, equipmentType, actuator);
                    if (CFlexionList != null && CFlexionList.Count > 0)
                    {
                        ViewBag.FlexionCompliance = CFlexionList;
                    }
                    List <ExtensionViewModel> CExtensionList = lIPatientRxRepository.getPatientRxComplianceByExtension(id, equipmentType, actuator);
                    if (CExtensionList != null && CExtensionList.Count > 0)
                    {
                        ViewBag.ExtensionCompliance = CExtensionList;
                    }
                }


                //Treatment Calendar
                List <TreatmentCalendarViewModel> TreatmentCalendarList = lIPatientRxRepository.getTreatmentCalendar(id, equipmentType, actuator);
                if (TreatmentCalendarList != null && TreatmentCalendarList.Count > 0)
                {
                    ViewBag.TreatmentCalendar = TreatmentCalendarList;
                }

                //Current Sessions
                List <Session> SessionList = lIPatientRxRepository.getCurrentSessions(id, equipmentType, actuator);
                if (SessionList != null && SessionList.Count > 0)
                {
                    ViewBag.SessionList = SessionList;
                }


                if (actuator == "Forward Flexion" || actuator == "External Rotation")
                {
                    ViewBag.Extension = "External Rotation";
                    ViewBag.Flexion   = "Flexion";
                }
                else
                {
                    ViewBag.Flexion   = "Flexion";
                    ViewBag.Extension = "Extension";
                }
            }


            return(View());
        }