Exemple #1
0
        public JsonResult SaveSurvey(FormCollection frm)
        {
            List <ViewModels.FamilyHistoryRelative> objList = new List <ViewModels.FamilyHistoryRelative>();

            ViewModels.FamilyHistoryRelative objModel = new ViewModels.FamilyHistoryRelative();

            string unitnum = frm["hdunitnum"].ToString();
            string Type    = frm["hdType"].ToString();
            int    apptid  = Convert.ToInt32(frm["hdapptid"]);

            //objModel.Relationship = frm["ddlRelation"]; //frm["hdddlRelation"].ToString();  //
            objModel.RelativeAge    = frm["txtRelativeAge"];
            objModel.VitalStatus    = frm["ddlVital"];    //frm["hdddlVital"]; //
            objModel.FirstDx        = frm["ddlFirstDx"];  //frm["hdddlFirstDx"]; //
            objModel.FirstAgeOnset  = frm["txtFirstAgeOnset"];
            objModel.SecondDx       = frm["ddlSecondDx"]; //frm["hdddlSecondDx"]; //
            objModel.SecondAgeOnset = frm["txtSecondAgeOnset"];
            objModel.ThirdDx        = frm["ddlThirdDx"];  //frm["hdddlThirdDx"]; //
            objModel.ThirdAgeOnset  = frm["txtThirdAgeOnset"];
            objModel.RelativeId     = Convert.ToInt32(frm["hdRelativeId"]);
            //objList.Add(objModel);



            _applicationContext.ServiceContext.AppointmentService.SaveSurvey(unitnum, apptid, objModel, 1);

            objList = _applicationContext.ServiceContext.AppointmentService.GetFamilyHistoryRelative(unitnum, apptid);

            var view = RenderPartialView("_FamilyHistoryRelativeRow", objList);

            var obj = new { view = view, Type = Type };

            return(Json(obj));
        }
        public JsonResult DeleteRelative(string unitnum, int apptid, int RelativeId)
        {
            List<ViewModels.FamilyHistoryRelative> objList = new List<ViewModels.FamilyHistoryRelative>();
               ViewModels.FamilyHistoryRelative objModel = new ViewModels.FamilyHistoryRelative();
               objModel.RelativeId = RelativeId;
               _applicationContext.ServiceContext.AppointmentService.SaveSurvey(unitnum, apptid, objModel, 2);

               objList = _applicationContext.ServiceContext.AppointmentService.GetFamilyHistoryRelative(unitnum, apptid);
               var view = RenderPartialView("_FamilyHistoryRelativeRow", objList);

               var obj = new { view = view };
               return Json(obj);
        }
Exemple #3
0
        public JsonResult DeleteRelative(string unitnum, int apptid, int RelativeId)
        {
            List <ViewModels.FamilyHistoryRelative> objList = new List <ViewModels.FamilyHistoryRelative>();

            ViewModels.FamilyHistoryRelative objModel = new ViewModels.FamilyHistoryRelative();
            objModel.RelativeId = RelativeId;
            _applicationContext.ServiceContext.AppointmentService.SaveSurvey(unitnum, apptid, objModel, 2);

            objList = _applicationContext.ServiceContext.AppointmentService.GetFamilyHistoryRelative(unitnum, apptid);
            var view = RenderPartialView("_FamilyHistoryRelativeRow", objList);


            var obj = new { view = view };

            return(Json(obj));
        }
        public JsonResult SaveSurvey(FormCollection frm)
        {
            List<ViewModels.FamilyHistoryRelative> objList = new List<ViewModels.FamilyHistoryRelative>();

               ViewModels.FamilyHistoryRelative objModel = new ViewModels.FamilyHistoryRelative();

               string unitnum = frm["hdunitnum"].ToString();
               string Type = frm["hdType"].ToString();
               int   apptid  = Convert.ToInt32(frm["hdapptid"]);
               //objModel.Relationship = frm["ddlRelation"]; //frm["hdddlRelation"].ToString();  //
               objModel.RelativeAge = frm["txtRelativeAge"];
               objModel.VitalStatus = frm["ddlVital"]; //frm["hdddlVital"]; //
               objModel.FirstDx = frm["ddlFirstDx"]; //frm["hdddlFirstDx"]; //
               objModel.FirstAgeOnset = frm["txtFirstAgeOnset"];
               objModel.SecondDx = frm["ddlSecondDx"]; //frm["hdddlSecondDx"]; //
               objModel.SecondAgeOnset = frm["txtSecondAgeOnset"];
               objModel.ThirdDx = frm["ddlThirdDx"]; //frm["hdddlThirdDx"]; //
               objModel.ThirdAgeOnset = frm["txtThirdAgeOnset"];
               objModel.RelativeId = Convert.ToInt32(frm["hdRelativeId"]);
               //objList.Add(objModel);

               _applicationContext.ServiceContext.AppointmentService.SaveSurvey(unitnum, apptid, objModel,1);

               objList = _applicationContext.ServiceContext.AppointmentService.GetFamilyHistoryRelative(unitnum, apptid);

               var view = RenderPartialView("_FamilyHistoryRelativeRow", objList);

               var obj = new { view = view, Type = Type };
               return Json(obj);
        }
Exemple #5
0
        public List<ViewModels.FamilyHistoryRelative> GetFamilyHistoryRelative(string unitnum, int apptid)
        {
            string assignedBy = "";

            if (SessionManager.Instance.ActiveUser != null)
            {
                if (string.IsNullOrEmpty(SessionManager.Instance.ActiveUser.ToString()) == false)
                {
                    assignedBy = SessionManager.Instance.ActiveUser.ToString();

                }
            }
            string _userlogin = SessionManager.Instance.ActiveUser.userLogin;
            SessionManager.Instance.SetActivePatient(unitnum, apptid);
            SessionManager.Instance.GetActivePatient().BackgroundLoadWork();
            RiskApps3.Model.PatientRecord.Patient proband = SessionManager.Instance.GetActivePatient();

            RiskApps3.Model.PatientRecord.PastMedicalHistory pmh = new RiskApps3.Model.PatientRecord.PastMedicalHistory(proband);
            RiskApps3.Model.PatientRecord.FHx.FamilyHistory FHX = new RiskApps3.Model.PatientRecord.FHx.FamilyHistory(proband)  ;

            proband.FHx.BackgroundListLoad();

            /*
            RiskApps3.Model.PatientRecord.Person relative1 = new RiskApps3.Model.PatientRecord.Person(proband.FHx);
            relative1.BackgroundLoadWork();
             */

            //RiskApps3.Model.PatientRecord.FHx.FamilyHistory proband = SessionManager.Instance.GetActivePatient().FHx;

            List<ViewModels.FamilyHistoryRelative> lst = new List<VM.FamilyHistoryRelative>();

            //foreach (Person p in proband.FHx.Relatives)
            //foreach (Person p in FHX.Relatives)
            foreach (Person p in proband.FHx.Relatives)
            {

                ViewModels.FamilyHistoryRelative obj = new ViewModels.FamilyHistoryRelative();

                //Person relative = p;
                relative = p;

                obj.Relationship = "";

               // pmh = relative.PMH;

                if (string.IsNullOrEmpty(relative.bloodline) || relative.relationship.ToLower() == "mother" || relative.relationship.ToLower() == "father")
                {
                    if (relative.relationship.ToLower() != "other")
                        obj.Relationship = relative.relationship;
                }
                else
                {
                    if (relative.bloodline.ToLower() != "unknown" && relative.bloodline.ToLower() != "both")
                        obj.Relationship = relative.bloodline + " " + relative.relationship;
                    else
                        obj.Relationship = relative.relationship;
                }

                if (obj.Relationship.Length == 0)
                {
                    if (!string.IsNullOrEmpty(relative.relationshipOther))
                    {
                        obj.Relationship = relative.relationshipOther;
                    }
                }

                obj.RelativeAge = relative.age;

                obj.VitalStatus = relative.vitalStatus;

                obj.RelativeId = relative.relativeID;
                relative.PMH.BackgroundLoadWork();
                pmh = relative.PMH;

                obj.DeleteFlag = SetDeleteButtonFlag(relative);

                for (int i = 0; i < pmh.Observations.Count; i++)
                {
                    ClincalObservation co = (ClincalObservation)pmh.Observations[i];
                    switch (i)
                    {
                        case 0:

                            obj.FirstDx = co.disease;
                            obj.FirstAgeOnset= co.ageDiagnosis;

                            break;
                        case 1:
                           obj.SecondDx = co.disease;
                            obj.SecondAgeOnset= co.ageDiagnosis;
                            break;
                        case 2:
                           obj.ThirdDx = co.disease;
                            obj.ThirdAgeOnset= co.ageDiagnosis;
                            break;
                        default:
                            break;
                    }
                }

                /**/
                lst.Add(obj);

            }

            return lst;
        }

        public List<VM.Tasks> GetTasks(int InstitutionId, string unitnum)
        {
            if (InstitutionId != null)
            {
                _institutionId = InstitutionId;
                //SetUserSession();
                Patient p = new Patient();
                p.unitnum = unitnum;
                var list = new TaskList(p);
                list.BackgroundListLoad();
                return list.FromRATaskList();
            }

            return new List<VM.Tasks>();
        }

        /// <summary>
        /// for loading Test patient page
        /// </summary>
        /// <returns></returns>
        public VM.TestPatient LoadCreateTestPatients()
        {
            VM.TestPatient tp = new VM.TestPatient();
            TestPatientManager Tpm = new TestPatientManager();
            tp.Surveys = Tpm.GetSurveys();
            tp.Clinics = GetClinicList();
            tp.InitateTestPatients = Tpm.InitiateTestPatients();

            return tp;
        }

        /// <summary>
        /// To Show Risk Score on Click of Run Risk Models Button. It calculates Risk Score
        /// </summary>
        /// <param name="apptid">Appointment Id</param>
        /// <param name="MRN">MRN Number</param>
        /// <returns></returns>
        public VM.RiskScore RiskCalculateAndRunAutomation(int apptid, string MRN)
        {
            Patient proband = CalculateRiskAndRunAutomation(apptid, MRN);
            proband.RP.LoadFullObject();
            VM.RiskScore RS = RiskScoreMapper.ToRiskScore(proband.RP);
            RS.ApptId = apptid;
            RS.MRN = MRN;
            return RS;
        }

        /// <summary>
        ///To show Risk Score on Click of Risk Calculation  
        /// </summary>
        /// <param name="apptid">Appointment Id</param>
        /// <param name="MRN">MRN Number</param>
        /// <returns>Risk Score Model</returns>
        public VM.RiskScore RiskScore(int apptid, string MRN)
        {
            SessionManager.Instance.SetActivePatient(MRN, apptid);
            Patient proband = SessionManager.Instance.GetActivePatient();
            proband.RP.LoadFullObject();
            VM.RiskScore RS = RiskScoreMapper.ToRiskScore(proband.RP);
            RS.ApptId = apptid;
            RS.MRN = MRN;
            return RS;
        }

        /// <summary>
        /// To do process of Run Automation Documents
        /// </summary>
        /// <param name="InstitutionId">Institution Id</param>
        /// <param name="apptid">Appointment Id</param>
        /// <param name="MRN">MRN Number</param>
        /// <returns></returns>
        public FileInfo RunAutomationDocuments(int InstitutionId, int apptid, string MRN)
        {
            Patient proband = CalculateRiskAndRunAutomation(apptid, MRN);
            return proband.file;
        }

        /// <summary>
        /// To Save Appointments
        /// </summary>
        /// <param name="Appt">Appointment Object to Save</param>
        /// <param name="InstitutionId">Institution Id</param>
        public void SaveAppointments(VM.Appointment Appt, int InstitutionId)
        {
            SaveAppointments(Appt);
            UpdateMarkAsComplete(Appt, InstitutionId);
        }

        public string SaveImage(string base64, int _institutionId, string _userlogin, int apptid, string PedigreeImageSavePath)
        {
            string _ImagePath = string.Empty;
            using (System.IO.MemoryStream ms = new System.IO.MemoryStream(Convert.FromBase64String(base64)))
            {
                using (Bitmap bm2 = new Bitmap(ms))
                {

                    //  PedigreeImagePath = System.Web.Serv
                    string _ImageName = _institutionId.ToString() + "_" + _userlogin + "_" + apptid.ToString() + ".png";

                    bm2.Save(PedigreeImageSavePath + _ImageName);
                    _ImagePath = _ImageName;
                }
            }

            return _ImagePath;
        }

        public void SaveSurvey(string unitnum, int apptid, ViewModels.FamilyHistoryRelative obj , int type )
        {
            SessionManager.Instance.SetActivePatient(unitnum, apptid);
            SessionManager.Instance.GetActivePatient().BackgroundLoadWork();
            RiskApps3.Model.PatientRecord.Patient proband = SessionManager.Instance.GetActivePatient();
            proband.FHx.BackgroundListLoad();

            if (type == 0)
            {

                AddRelative(proband, obj);
            }
            else if (type == 1)
            {
                EditSurvey(proband, obj);

            }
            else
            {
                DeleteSurvey(proband, obj);
            }
        }

        public bool SetDeleteButtonFlag(Person relative)
        {
            bool retval = true;

            if (relative == null)
                return false ;

            if (relative.relativeID < 8)
            {
                retval = false;
            }
            else
            {
                foreach (Person p in relative.owningFHx)
                {
                    if (p.motherID == relative.relativeID || p.fatherID == relative.relativeID)
                    {
                        retval = false;
                        break;
                    }
                }
            }

            return retval;
        }

        public string ShowPedigreeImage(int _institutionId, string unitnum, int apptid, string PedigreeImageSavePath)
        {
            int Width = 625;
            int Height = 625;
            string _ImagePath = string.Empty;
            string assignedBy = "";

            if (SessionManager.Instance.ActiveUser != null)
            {
                if (string.IsNullOrEmpty(SessionManager.Instance.ActiveUser.ToString()) == false)
                {
                    assignedBy = SessionManager.Instance.ActiveUser.ToString();

                }
            }
            string _userlogin = SessionManager.Instance.ActiveUser.userLogin;
            SessionManager.Instance.SetActivePatient(unitnum, apptid);

            RiskApps3.Model.PatientRecord.Patient proband = SessionManager.Instance.GetActivePatient();    // TODO:  Check this!!

            PedigreeGenerator pg = new PedigreeGenerator(Width, Height, proband);
            Bitmap bmp;
            if (proband != null)
            {
                bmp = pg.GeneratePedigreeImage(proband);
            }
            else
            {
                bmp = pg.GeneratePedigreeImage();
            }
            System.IO.MemoryStream stream = new System.IO.MemoryStream();
            bmp.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
            var base64Data = Convert.ToBase64String(stream.ToArray());
            /*
            _ImagePath = SaveImage(base64Data, _institutionId, _userlogin, apptid, PedigreeImageSavePath);
               return _ImagePath;
            */
            return base64Data;
        }