Ejemplo n.º 1
0
        public PatientSummary RenewPatientPlan(int patientid)
        {
            PatientSummary            patientData = new PatientSummary();
            List <PatientTestSummary> testsummary = new List <PatientTestSummary>();

            try
            {
                using (DiabeticSystemEntities context = new DiabeticSystemEntities())
                {
                    PatientMembershipDetail memberDetail = (from member in context.PatientMembershipDetails
                                                            where member.PatientId == patientid
                                                            select member).FirstOrDefault();

                    int remainingtest = memberDetail.TestRemaining;
                    memberDetail.TestRemaining        = (remainingtest + (Constants.MembershipMonths * 2));
                    memberDetail.BookedDate           = System.DateTime.Now.Date;
                    memberDetail.ExpirationDate       = DateTime.Now.AddMonths(3);
                    context.Entry(memberDetail).State = EntityState.Modified;
                    context.SaveChanges();

                    patientData = GetAPatientDataByPatientId(patientid);
                }
            }
            catch (Exception err)
            {
                throw;
            }

            return(patientData);
        }
Ejemplo n.º 2
0
        public PatientSummary GetAPatientDetail(string username, string password)
        {
            PatientSummary            summary        = new PatientSummary();
            PatientPersonal           personalDetail = new PatientPersonal();
            List <PatientTestSummary> testsummary    = new List <PatientTestSummary>();

            try
            {
                using (DiabeticSystemEntities context = new DiabeticSystemEntities())
                {
                    int userid = (from p in context.PatientPersonals
                                  where p.Name.ToLower() == username.ToLower() &&
                                  p.Password == password.ToLower()
                                  select p.PatientId).FirstOrDefault();
                    if (userid > 0)
                    {
                        summary = (from p in context.PatientPersonals
                                   join member in context.PatientMembershipDetails
                                   on p.PatientId equals member.PatientId
                                   where p.PatientId == userid
                                   select new PatientSummary()
                        {
                            Id = p.PatientId,
                            Name = p.Name,
                            Age = p.Age,
                            Email = p.Email,
                            BloodGroup = p.BloodGroup,
                            TestRemaining = member.TestRemaining,
                            ExpiresOn = member.BookedDate            //member.BookedDate.AddMonths(3)
                        }).FirstOrDefault();

                        summary.ExpiresOn = summary.ExpiresOn.AddMonths(3);

                        testsummary = (from p in context.PatientPersonals
                                       join test in context.PatientTestResults
                                       on p.PatientId equals test.PatientId
                                       where p.PatientId == userid
                                       select new PatientTestSummary()
                        {
                            PatientId = p.PatientId,
                            SugarLevelBeforeFasting = test.SugarBeforeFasting,
                            SugarLevelAfterFasting = test.SugarAfterFasting,
                            TestDate = test.TestDate.Value
                        }).ToList();

                        summary.PatientTestResults = testsummary;
                    }
                    else
                    {
                        summary = null;
                    }
                }
            }
            catch (Exception err)
            {
                throw;
            }

            return(summary);
        }
Ejemplo n.º 3
0
        public PatientSummary GetAPatientDetail(string username, string password)
        {
            PatientSummary            summary        = new PatientSummary();
            PatientPersonal           personalDetail = new PatientPersonal();
            List <PatientTestSummary> testsummary    = new List <PatientTestSummary>();

            try
            {
                using (DiabeticSystemEntities context = new DiabeticSystemEntities())
                {
                    int patientid = (from p in context.PatientPersonals
                                     where p.Name.ToLower() == username.ToLower() &&
                                     p.Password == password.ToLower()
                                     select p.PatientId).FirstOrDefault();
                    if (patientid > 0)
                    {
                        summary = GetAPatientDataByPatientId(patientid);
                    }
                    else
                    {
                        summary = null;
                    }
                }
            }
            catch (Exception err)
            {
                throw;
            }

            return(summary);
        }
Ejemplo n.º 4
0
        private async Task ModeUpSelected(PatientSummary patientSummary)
        {
            //Load text correctly
            if (patientSummary != null)
            {
                patientId.Text = $"({patientSummary.Id}) {patientSummary.LastName}, {patientSummary.FirstName}";
                if (patientSummary.Id != _app.Patient?.Id)
                {
                    //Close last patient
                    await Task.Run(() =>
                    {
                        if (_app.Patient != null && _app.Patient.IsLive)
                        {
                            Debug.WriteLine($"Closing patient {_app.Patient.LastName}");
                            _app.ClosePatient();
                        }
                    });

                    //Mode up selected
                    if (_app.SetPatient(patientSummary.Id))
                    {
                        Courses.Clear();
                        var courseNames = _app.Patient.Courses.Select(c => c.Id).ToList();
                        courseNames.ForEach(Courses.Add);

                        SelectedCourse = Courses.FirstOrDefault();
                        OnPropertyChanged("Courses");
                        OnPropertyChanged("SelectedCourse");
                        OnPropertyChanged("Status");
                    }
                }
            }
        }
Ejemplo n.º 5
0
 private PatientMatch CreatePatientMatch(PatientSummary ps) =>
 new PatientMatch
 {
     Id        = ps.Id,
     LastName  = ps.LastName,
     FirstName = ps.FirstName
 };
Ejemplo n.º 6
0
        public async Task <PatientSummary> LoginPatient(LoginModel model)
        {
            PatientSummary summary = null;

            using (HttpClient client = new HttpClient())
            {
                client.BaseAddress = new Uri(azureapiaddress);
                client.DefaultRequestHeaders.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                HttpResponseMessage Res = await client.GetAsync($"api/DiabeticApi/PatientLogin?username={model.UserName}&password={model.Password}");

                //Checking the response is successful or not which is sent using HttpClient
                if (Res.IsSuccessStatusCode)
                {
                    //Storing the response details recieved from web api
                    var response = Res.Content.ReadAsStringAsync().Result;

                    //Deserializing the response recieved from web api and storing into the Employee list
                    summary = JsonConvert.DeserializeObject <PatientSummary>(response);
                }
            }

            return(summary);
        }
Ejemplo n.º 7
0
 private SearchPatient CreateSearchPatient(PatientSummary patientSummary) =>
 new SearchPatient
 {
     Id               = patientSummary.Id,
     FirstName        = patientSummary.FirstName,
     LastName         = patientSummary.LastName,
     CreationDateTime = patientSummary.CreationDateTime
 };
Ejemplo n.º 8
0
        public ActionResult PatientSummary()
        {
            PatientSummary patients = (PatientSummary)TempData["Patients"];

            if (patients != null)
            {
                return(View(patients));
            }
            return(View());
        }
 public ActionResult PatientSummary()
 {
     if (Session["LoggedInUser"] != null)
     {
         PatientSummary patients = (PatientSummary)Session["LoggedInUser"];
         return(View(patients));
     }
     else
     {
         return(RedirectToAction(nameof(Error)));
     }
 }
        public async Task <ActionResult> RenewPatientMembership(int patientId)
        {
            if (Session["LoggedInUser"] != null)
            {
                PatientSummary summary = await apiCall.RenewPatientMembership(patientId);

                Session["LoggedInUser"] = summary;
                return(PartialView("_PatientPersonalDetails", summary));
            }
            else
            {
                return(RedirectToAction(nameof(Error)));
            }
        }
Ejemplo n.º 11
0
        private PatientSummary GetAPatientDataByPatientId(int patientId)
        {
            PatientSummary            summary     = new PatientSummary();
            List <PatientTestSummary> testsummary = new List <PatientTestSummary>();

            try
            {
                using (DiabeticSystemEntities context = new DiabeticSystemEntities())
                {
                    summary = (from p in context.PatientPersonals
                               join member in context.PatientMembershipDetails
                               on p.PatientId equals member.PatientId
                               where p.PatientId == patientId
                               select new PatientSummary()
                    {
                        Id = p.PatientId,
                        Name = p.Name,
                        Age = p.Age,
                        Email = p.Email,
                        BloodGroup = p.BloodGroup,
                        TestRemaining = member.TestRemaining,
                        ExpiresOn = member.BookedDate                //member.BookedDate.AddMonths(3)
                    }).FirstOrDefault();

                    summary.ExpiresOn = summary.ExpiresOn.AddMonths(3);

                    testsummary = (from p in context.PatientPersonals
                                   join test in context.PatientTestResults
                                   on p.PatientId equals test.PatientId
                                   where p.PatientId == patientId
                                   select new PatientTestSummary()
                    {
                        PatientId = p.PatientId,
                        SugarLevelBeforeFasting = test.SugarBeforeFasting,
                        SugarLevelAfterFasting = test.SugarAfterFasting,
                        TestDate = test.TestDate.Value
                    }).ToList();

                    summary.PatientTestResults = testsummary;
                }
            }
            catch (Exception err)
            {
                throw;
            }

            return(summary);
        }
        //[HttpGet]
        //public ActionResult Timeline(string patientId)
        //{
        //    TrackedPatient model = this.DashboardRepository.Patients.Get("1234");

        //    return View(model);

        //}

        private void UpdateChecklistSummary(PatientSummary model, string dfn, PregnancyResult pregResult)
        {
            const int itemCount = 4;

            PregnancyChecklistItemsResult checklistResult = this.DashboardRepository.Checklist.GetPregnancyItems(dfn, pregResult.Pregnancy.Ien, "", DsioChecklistCompletionStatus.NotComplete);

            if (checklistResult.Success)
            {
                if (checklistResult.Items != null)
                {
                    PregnancyChecklistItemList tempList = new PregnancyChecklistItemList();

                    tempList.AddRange(checklistResult.Items);

                    tempList.AddPregnancyDates(pregResult.Pregnancy.EDD, pregResult.Pregnancy.EndDate);

                    tempList.Sort(delegate(PregnancyChecklistItem x, PregnancyChecklistItem y)
                    {
                        return(x.DueDate.CompareTo(y.DueDate));
                    });

                    int tempCount = 0;
                    foreach (PregnancyChecklistItem tempItem in tempList)
                    {
                        if (model.PregnancyChecklistItems == null)
                        {
                            model.PregnancyChecklistItems = new PregnancyChecklistItemList();
                        }

                        model.PregnancyChecklistItems.Add(tempItem);

                        tempCount += 1;

                        if (tempCount == itemCount)
                        {
                            break;
                        }
                    }

                    if (tempList.Count > itemCount)
                    {
                        model.MoreChecklistItems = string.Format("{0} more", tempList.Count - itemCount);
                    }

                    model.ChecklistLink = Url.Action("PregnancyIndex", "Checklist", new { dfn = model.Patient.Dfn, pregIen = pregResult.Pregnancy.Ien, page = "1" });
                }
            }
        }
Ejemplo n.º 13
0
        public async Task <ActionResult> PatientLogin(LoginModel model)
        {
            PatientSummary patients = null;

            patients = await apiCall.LoginPatient(model);

            if (patients != null)
            {
                TempData["Patients"] = patients;
                return(RedirectToAction("PatientSummary"));
            }
            else
            {
                ModelState.AddModelError(string.Empty, Constants.InvalidUserPassword);
                return(View(nameof(PatientLogin)));
            }
        }
        public async Task <ActionResult> PatientLogin(LoginModel model)
        {
            PatientSummary patients = null;

            patients = await apiCall.LoginPatient(model);

            if (patients != null)
            {
                FormsAuthentication.SetAuthCookie(patients.Name, true);
                Session["LoggedInUser"] = patients;
                return(RedirectToAction(nameof(PatientSummary)));
            }
            else
            {
                ModelState.AddModelError(string.Empty, Constants.InvalidUserPassword);
                return(View(nameof(PatientLogin)));
            }
        }
Ejemplo n.º 15
0
        private bool IsMatch(PatientSummary p, string searchText)
        {
            var searchTerms = GetSearchTerms(searchText);

            if (searchTerms.Length == 0)         // Nothing typed
            {
                return(false);
            }
            else if (searchTerms.Length == 1)    // One word
            {
                return(IsMatch(p.Id, searchTerms[0]) ||
                       IsMatch(p.LastName, searchTerms[0]) ||
                       IsMatch(p.FirstName, searchTerms[0]));
            }
            else                                 // Two or more words
            {
                return(IsMatchWithLastThenFirstName(p, searchTerms) ||
                       IsMatchWithFirstThenLastName(p, searchTerms));
            }
        }
Ejemplo n.º 16
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            patientid = Convert.ToInt32(Session["PatientID"].ToString());
            if (Request.QueryString["report"] == "visit")
            {
                System.Data.DataSet ds;
                IReports            PatientSummary;
                PatientSummary = (IReports)ObjectFactory.CreateInstance("BusinessProcess.Reports.BReports,BusinessProcess.Reports");
                //ds = PatientSummary.IQTouchGetPatientVisitSummary(Convert.ToInt32(Request.QueryString["PatientID"]));
                ds = PatientSummary.IQTouchGetPatientVisitSummary(patientid);


                ReportDocument rptDocument;
                rptDocument = new ReportDocument();
                rptDocument.Load(Server.MapPath("..\\..\\Touch\\Report\\PatientVisit.rpt"));
                rptDocument.SetDataSource(ds);
                rptDocument.SetParameterValue("facilityname", Session["AppLocation"].ToString());
                CrystalReportViewer1.ReportSource  = rptDocument;
                CrystalReportViewer1.ToolPanelView = CrystalDecisions.Web.ToolPanelViewType.None;
            }
            if (Request.QueryString["report"] == "summary")
            {
                System.Data.DataSet ds;
                IReports            PatientSummary;
                PatientSummary = (IReports)ObjectFactory.CreateInstance("BusinessProcess.Reports.BReports,BusinessProcess.Reports");
                ds             = PatientSummary.IQTouchGetPatientSummary(patientid);
                //string strxml = ds.GetXmlSchema();

                ReportDocument rptDocument;
                rptDocument = new ReportDocument();
                rptDocument.Load(Server.MapPath("..\\..\\Touch\\Report\\PatientSummaryMain.rpt"));
                rptDocument.SetDataSource(ds);
                CrystalReportViewer1.ReportSource  = rptDocument;
                CrystalReportViewer1.ToolPanelView = CrystalDecisions.Web.ToolPanelViewType.None;
            }
            if (Request.QueryString["report"] == "chart")
            {
                BindGraph();
            }
        }
Ejemplo n.º 17
0
        public async Task <PatientSummary> RenewPatientMembership(int patientId)
        {
            PatientSummary patientsummary = new PatientSummary();

            using (HttpClient client = new HttpClient())
            {
                client.BaseAddress = new Uri(azureapiaddress);
                client.DefaultRequestHeaders.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                HttpResponseMessage Res = await client.PostAsJsonAsync($"api/DiabeticApi/RenewMembership?patientid={patientId}", patientsummary);

                if (Res.IsSuccessStatusCode)
                {
                    //Storing the response details recieved from web api
                    var response = Res.Content.ReadAsStringAsync().Result;

                    //Deserializing the response recieved from web api and storing into the Employee list
                    patientsummary = JsonConvert.DeserializeObject <PatientSummary>(response);
                }
            }
            return(patientsummary);
        }
Ejemplo n.º 18
0
 private bool ContainsById(PatientSummary patientSummary, IEnumerable <SearchPatient> patients) =>
 patients.FirstOrDefault(p => p.Id == patientSummary.Id) != null;
Ejemplo n.º 19
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            patientid = Convert.ToInt32(Session["PatientID"].ToString());
            if (Request.QueryString["report"] == "visit")
            {
                System.Data.DataSet ds;
                IReports            PatientSummary;
                PatientSummary = (IReports)ObjectFactory.CreateInstance("BusinessProcess.Reports.BReports,BusinessProcess.Reports");
                //ds = PatientSummary.IQTouchGetPatientVisitSummary(Convert.ToInt32(Request.QueryString["PatientID"]));
                ds = PatientSummary.IQTouchGetPatientVisitSummary(patientid);


                ReportDocument rptDocument;
                rptDocument = new ReportDocument();
                rptDocument.Load(Server.MapPath("..\\..\\Touch\\Report\\PatientVisit.rpt"));
                rptDocument.SetDataSource(ds);
                rptDocument.SetParameterValue("facilityname", Session["AppLocation"].ToString());
                CrystalReportViewer1.ReportSource  = rptDocument;
                CrystalReportViewer1.ToolPanelView = CrystalDecisions.Web.ToolPanelViewType.None;
            }
            if (Request.QueryString["report"] == "summary")
            {
                System.Data.DataSet ds;
                IReports            PatientSummary;
                PatientSummary = (IReports)ObjectFactory.CreateInstance("BusinessProcess.Reports.BReports,BusinessProcess.Reports");
                ds             = PatientSummary.IQTouchGetPatientSummary(patientid);
                //string strxml = ds.GetXmlSchema();


                #region Format PhysicalFindingsHistory
                DataTable dtPhysicalFindingsHistory = ds.Tables[10].Copy();
                dtPhysicalFindingsHistory.Rows.Clear();
                for (int i = 0; i < ds.Tables[10].Rows.Count; i++)
                {
                    if (i == 0)
                    {
                        dtPhysicalFindingsHistory.Rows.Add(
                            ds.Tables[10].Rows[0]["visitdate"].ToString(),
                            ds.Tables[10].Rows[0]["Illness"].ToString(),
                            ds.Tables[10].Rows[0]["symptomdescription"].ToString());
                    }
                    else
                    {
                        if (ds.Tables[10].Rows[i]["visitdate"].ToString().Equals(dtPhysicalFindingsHistory.Rows[dtPhysicalFindingsHistory.Rows.Count - 1]["visitdate"].ToString()))
                        {
                            dtPhysicalFindingsHistory.Rows[dtPhysicalFindingsHistory.Rows.Count - 1]["Illness"] = dtPhysicalFindingsHistory.Rows[dtPhysicalFindingsHistory.Rows.Count - 1]["Illness"] + "," + ds.Tables[10].Rows[i]["Illness"].ToString();
                        }
                        else
                        {
                            dtPhysicalFindingsHistory.Rows.Add(
                                ds.Tables[10].Rows[i]["visitdate"].ToString(),
                                ds.Tables[10].Rows[i]["Illness"].ToString(),
                                ds.Tables[10].Rows[i]["symptomdescription"].ToString());
                        }
                    }
                }
                ds.Tables[10].Rows.Clear();

                int c = -1;
                foreach (DataRow dr in dtPhysicalFindingsHistory.Rows)
                {
                    c++;
                    ds.Tables[10].Rows.Add();
                    foreach (DataColumn dc in dtPhysicalFindingsHistory.Columns)
                    {
                        ds.Tables[10].Rows[c][dc.ColumnName] = dr[dc.ColumnName];
                    }
                }
                #endregion

                ReportDocument rptDocument;
                rptDocument = new ReportDocument();
                rptDocument.Load(Server.MapPath("..\\..\\Touch\\Report\\PatientSummaryMain.rpt"));
                rptDocument.SetDataSource(ds);
                rptDocument.Subreports["PatientSummaryCaregiver.rpt"].SetDataSource(ds);
                rptDocument.Subreports["PatientSummaryARVTreatmentHistory.rpt"].SetDataSource(ds);
                rptDocument.Subreports["PatientSummaryRegimenHistory.rpt"].SetDataSource(ds);
                rptDocument.Subreports["PatientSummaryMostResent.rpt"].SetDataSource(ds);
                rptDocument.Subreports["PatientSummaryHistoryofPhysicalFindings.rpt"].SetDataSource(ds);
                rptDocument.Subreports["PatientSummaryHistoryofAdverseEvents.rpt"].SetDataSource(ds);
                rptDocument.Subreports["PatientSummaryImmunisations.rpt"].SetDataSource(ds);
                rptDocument.Subreports["PatientSummaryARVMutations.rpt"].SetDataSource(ds);
                rptDocument.Subreports["PatientSummaryLabHistory.rpt"].SetDataSource(ds);
                rptDocument.Subreports["PatientSummaryWHB.rpt"].SetDataSource(ds);

                CrystalReportViewer1.EnableDrillDown = false;
                CrystalReportViewer1.ReportSource    = rptDocument;
                CrystalReportViewer1.ToolPanelView   = CrystalDecisions.Web.ToolPanelViewType.None;
            }
            if (Request.QueryString["report"] == "chart")
            {
                BindGraph();
            }
        }
Ejemplo n.º 20
0
 //Read and assign parameters from input patient, course and plan//
 public bool extractParametersFromPlan(Application app, string ptId_Input, string crsId_Input, string plnId_Input)
 {
     PtId      = ptId_Input;
     CrsId     = crsId_Input;
     PlnId     = plnId_Input;
     BmParamLs = new List <BmParam>();
     try
     {
         //Read plan//
         PatientSummary ptSumm = app.PatientSummaries.FirstOrDefault(ps => ps.Id == PtId);
         if (ptSumm == null)
         {
             Console.WriteLine("--Cannot find patient.\n");
             return(false);
         }
         Patient pt  = app.OpenPatient(ptSumm);
         Course  crs = pt.Courses.FirstOrDefault(c => c.Id == CrsId);
         if (crs == null)
         {
             Console.WriteLine("--Cannot find course.\n");
             return(false);
         }
         ExternalPlanSetup pln = crs.ExternalPlanSetups.FirstOrDefault(p => p.Id == PlnId);
         if (pln == null)
         {
             Console.WriteLine("--Cannot find plan.\n");
             return(false);
         }
         //get last modified date time//
         ModDate = pln.HistoryDateTime;
         //get prescription info//
         N_Fx      = Math.Max(pln.NumberOfFractions.GetValueOrDefault(), 1); //At least 1 fx is needed
         DoseperFx = pln.DosePerFraction;
         TrtPct    = pln.TreatmentPercentage;
         //get plan normalization factor//
         PlnNormFactr = pln.PlanNormalizationValue;
         //get calculation model//
         CalcModel = pln.PhotonCalculationModel;
         //get beam parameters//
         foreach (Beam bm in pln.Beams)
         {
             if (bm.MetersetPerGy > 0)
             {
                 BmParam bp = new BmParam
                 {
                     bmId        = bm.Id,
                     machId      = bm.TreatmentUnit.Id.ToString(),
                     energy      = bm.EnergyModeDisplayName,
                     doseRt      = bm.DoseRate,
                     bmTechnique = bm.Technique.Id.ToString(),
                     mlcTyp      = bm.MLCPlanType,
                     CtrPtParam  = bm.GetEditableParameters(),
                     mu          = bm.Meterset
                 };
                 bp.MachParam =
                     new ExternalBeamMachineParameters(bp.machId, bp.energy, bp.doseRt, bp.bmTechnique, null);
                 bp.MLCBmTechnique = setMLCBmTechnique(bp, bm.CalculationLogs);
                 if (bp.MLCBmTechnique == null)
                 {
                     Console.WriteLine("--At least one of the beams is invalid, skipping...\n");
                     return(false);
                 }
                 BmParamLs.Add(bp);
             }
         }
         app.ClosePatient();
         Console.WriteLine("-Finish reading parameters from reference.");
         return(true);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.ToString());
         app.ClosePatient();
         return(false);
     }
 }
Ejemplo n.º 21
0
        public bool CopyAndCreate(Application app, string ptId_Tgt, string crsId_Tgt, string plnId_Tgt, string structId_Tgt, PlanParameters plnParam_Ref)
        {
            //Open patient//
            PatientSummary ptSumm = app.PatientSummaries.FirstOrDefault(ps => ps.Id == ptId_Tgt);

            if (ptSumm == null)
            {
                Console.WriteLine("--Cannot find patient" + ptId_Tgt + ".");
                return(false);
            }
            Patient pt = app.OpenPatient(ptSumm);

            try
            {
                pt.BeginModifications();
                //Open or create course//
                Course crs = pt.Courses.FirstOrDefault(c => c.Id == crsId_Tgt);
                if (crs == null)
                {
                    Console.WriteLine("-Create course " + crsId_Tgt + ".");
                    crs    = pt.AddCourse();
                    crs.Id = crsId_Tgt;
                }
                //Create plan//
                ExternalPlanSetup pln = crs.ExternalPlanSetups.FirstOrDefault(p => p.Id == plnId_Tgt);
                if (pln == null)
                {
                    StructureSet structSet = pt.StructureSets.FirstOrDefault(ss => ss.Id == structId_Tgt);
                    if (structSet == null)
                    {
                        Console.WriteLine("--Cannot find structure set " + structId_Tgt + ". Plan is not created\n");
                        app.ClosePatient();
                        return(false);
                    }
                    pln    = crs.AddExternalPlanSetup(structSet);
                    pln.Id = plnId_Tgt;
                }
                //Return if there is already a plan with the same name//
                else
                {
                    Console.WriteLine("--A plan with name " + plnId_Tgt + " already exists. Plan is not created\n");
                    app.ClosePatient();
                    return(false);
                }
                Console.WriteLine("-Start creating plan " + plnId_Tgt + ".");
                //Set plan prescription properties//
                pln.SetPrescription(plnParam_Ref.N_Fx, plnParam_Ref.DoseperFx, plnParam_Ref.TrtPct);
                ///////////Create beam by copying from the beams in reference plan parameters////////////
                //Create empty list of MU values for each beam//
                List <KeyValuePair <string, MetersetValue> > muValues = new List <KeyValuePair <string, MetersetValue> >();
                foreach (PlanParameters.BmParam bmParam in plnParam_Ref.BmParamLs)
                {
                    //Add beam, type based on reference MLC beam technique//
                    IEnumerable <double> muSet = bmParam.CtrPtParam.ControlPoints.Select(cp => cp.MetersetWeight).ToList();
                    switch (bmParam.MLCBmTechnique)
                    {
                    case "StaticMLC":
                        Beam bm =
                            pln.AddMLCBeam(bmParam.MachParam, new float[2, 60],
                                           new VRect <double>(-10.0, -10.0, 10.0, 10.0), 0.0, 0.0, 0.0, bmParam.CtrPtParam.Isocenter);
                        bm.Id = bmParam.bmId;
                        bm.ApplyParameters(bmParam.CtrPtParam);
                        break;

                    case "StaticSegWin":
                        bm =
                            pln.AddMultipleStaticSegmentBeam(bmParam.MachParam, muSet, 0.0, 0.0, 0.0, bmParam.CtrPtParam.Isocenter);
                        bm.Id = bmParam.bmId;
                        muValues.Add(new KeyValuePair <string, MetersetValue>(bmParam.bmId, bmParam.mu));
                        bm.ApplyParameters(bmParam.CtrPtParam);
                        break;

                    case "StaticSlidingWin":
                        bm =
                            pln.AddSlidingWindowBeam(bmParam.MachParam, muSet, 0.0, 0.0, 0.0, bmParam.CtrPtParam.Isocenter);
                        bm.Id = bmParam.bmId;
                        muValues.Add(new KeyValuePair <string, MetersetValue>(bmParam.bmId, bmParam.mu));
                        bm.ApplyParameters(bmParam.CtrPtParam);
                        break;

                    case "ConformalArc":
                        bm =
                            pln.AddConformalArcBeam(bmParam.MachParam, 0.0, bmParam.CtrPtParam.ControlPoints.Count(),
                                                    bmParam.CtrPtParam.ControlPoints.First().GantryAngle, bmParam.CtrPtParam.ControlPoints.Last().GantryAngle,
                                                    bmParam.CtrPtParam.GantryDirection, 0.0, bmParam.CtrPtParam.Isocenter);
                        bm.Id = bmParam.bmId;
                        bm.ApplyParameters(bmParam.CtrPtParam);
                        break;

                    case "VMAT":
                        bm =
                            pln.AddVMATBeam(bmParam.MachParam, muSet, 0.0,
                                            bmParam.CtrPtParam.ControlPoints.First().GantryAngle, bmParam.CtrPtParam.ControlPoints.Last().GantryAngle,
                                            bmParam.CtrPtParam.GantryDirection, 0.0, bmParam.CtrPtParam.Isocenter);
                        bm.Id = bmParam.bmId;
                        bm.ApplyParameters(bmParam.CtrPtParam);
                        break;

                    default:
                        Console.WriteLine("--At least one of the beams is unidentified, plan is not created.\n");
                        app.ClosePatient();
                        return(false);
                    }
                }
                //Set the plan normalization value//
                pln.PlanNormalizationValue = plnParam_Ref.PlnNormFactr;
                //Set the plan calculation model//
                pln.SetCalculationModel(CalculationType.PhotonVolumeDose, plnParam_Ref.CalcModel);
                //If one of the beams is static IMRT, compute dose to enforce MUs to beams//
                if (plnParam_Ref.BmParamLs.Any(bm => bm.MLCBmTechnique == "StaticSegWin" || bm.MLCBmTechnique == "StaticSlidingWin"))
                {
                    Console.WriteLine("--Start computing static beam IMRT plan.");
                    pln.CalculateDoseWithPresetValues(muValues);
                }
                Console.WriteLine("-Finish plan creation.\n");
                app.SaveModifications();
                app.ClosePatient();
                return(true);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                app.ClosePatient();
                return(false);
            }
        }
Ejemplo n.º 22
0
 private bool IsMatchWithFirstThenLastName(PatientSummary p, string[] searchTerms)
 {
     return(IsMatch(p.FirstName, searchTerms[0]) && IsMatch(p.LastName, searchTerms[1]));
 }
Ejemplo n.º 23
0
        private void btnStart_Click(object sender, RoutedEventArgs e)
        {
            MyPatient myPatient = _viewModel.SelectedPatient;
            string    patientId = myPatient.PatientId;

            PatientSummary patientSummary = _application.PatientSummaries.FirstOrDefault(s => s.Id == patientId);

            if (patientSummary == null)
            {
                return;
            }

            Patient       patient = _application.OpenPatient(patientSummary);
            List <Course> courses = new List <Course>();

            foreach (var vmCourse in _viewModel.SelectedPatient.Courses.Where(s => s.IsSelected))
            {
                Course course = patient.Courses.FirstOrDefault(s => s.Id == vmCourse.CourseId);
                if (course != null)
                {
                    courses.Add(course);
                }
            }
            if (courses.Count == 0)
            {
                MessageBox.Show("Can't find selected courses in Aria");
                return;
            }

            //Plan items in scope
            List <PlanningItem> PlansInScope = new List <PlanningItem>();
            PlanningItem        pItem        = null;

            foreach (var pitem in _viewModel.CoursePlanItems.Where(s => s.IsInScope))
            {
                //check if planSetup
                foreach (var course in courses)
                {
                    pItem = course.PlanSetups.FirstOrDefault(s => s.Id == pitem.pItemId);
                    if (pItem == null)
                    {
                        pItem = course.PlanSums.FirstOrDefault(s => s.Id == pitem.pItemId);
                    }

                    if (pItem != null)
                    {
                        PlansInScope.Add(pItem);
                        break;
                    }
                }
                if (pItem == null)
                {
                    MessageBox.Show("No Planning Item found with Id = " + pitem.pItemId, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }
            }

            //Opened plan Item
            string openPlanId = string.Empty;

            foreach (var pitem in _viewModel.PlansInScope)
            {
                if (pitem.IsOpened)
                {
                    openPlanId = pitem.pItemId;
                    break;
                }
            }

            //check if planSetup
            foreach (var course in courses)
            {
                pItem = course.PlanSetups.FirstOrDefault(s => s.Id == openPlanId);
                if (pItem == null)
                {
                    pItem = course.PlanSums.FirstOrDefault(s => s.Id == openPlanId);
                }
                if (pItem != null)
                {
                    break;
                }
            }
            if (pItem == null)
            {
                MessageBox.Show("No Planning Item found with Id = " + openPlanId, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }


            Window window = new Window();

            window.Closing += WindowClosingHandler;
            window.Show();

            //Save selections for use in next run
            SaveToRecent();
            try
            {
                StartPlugin(patient, courses, PlansInScope, pItem, _application.CurrentUser, window);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Caught exception from Script\n" + ex.Message + "\n" + ex.StackTrace);
                return;
            }
        }
Ejemplo n.º 24
0
        public JsonResult patientsummary(string sessionid, string rxid)
        {
            PatientSummary lsummary = new PatientSummary();

            try
            {
                if (!string.IsNullOrEmpty(sessionid) && !string.IsNullOrEmpty(rxid))
                {
                    Patient lpatient = IPatient.GetPatientBySessionID(sessionid);
                    if (lpatient != null)
                    {
                        PatientRx lPatientRx = lIPatientRxRepository.getPatientRxbyRxId(rxid, lpatient.PatientId.ToString());
                        if (lPatientRx != null)
                        {
                            lsummary.RxStartDate   = lPatientRx.RxStartDate.Value;
                            lsummary.RxEndDate     = lPatientRx.RxEndDate.Value;
                            lsummary.RxDuration    = Convert.ToInt32((lsummary.RxEndDate - lsummary.RxStartDate).TotalDays);
                            lsummary.RemainingDays = Convert.ToInt32((lsummary.RxEndDate - DateTime.Now).TotalDays);
                            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;

                            lsummary.SessionSuggested = Convert.ToInt32(requiredSession);
                            lsummary.SessionCompleted = totalSession;


                            PatientRx lPatientRxPain = lIPatientRxRepository.getPatientRxPain(lPatientRx.RxId, lPatientRx.PatientId.ToString());

                            if (lPatientRxPain != null)
                            {
                                List <Session> lSessionList = lPatientRx.Session != null?lPatientRxPain.Session.ToList() : null;

                                if (lSessionList != null && lSessionList.Count > 0)
                                {
                                    lsummary.MaxPainLevel            = lSessionList.Select(x => x.Pain.Max(y => y.PainLevel)).Max().HasValue ? lSessionList.Select(x => x.Pain.Max(y => y.PainLevel)).Max().Value : 0;
                                    lsummary.MaxFlexionAchieved      = lSessionList.Max(x => x.MaxFlexion);
                                    lsummary.MaxExtensionAchieved    = lSessionList.Max(x => x.MaxExtension);
                                    lsummary.TrexMinutes             = lSessionList.Select(x => x.RangeDuration1).Sum().HasValue ? lSessionList.Select(x => x.RangeDuration1).Sum().Value : 0;
                                    lsummary.FlexionExtensionMinutes = lSessionList.Select(x => x.RangeDuration2).Sum().HasValue ? lSessionList.Select(x => x.RangeDuration2).Sum().Value : 0;
                                }
                            }
                        }
                        else
                        {
                            return(Json(new { Status = (int)HttpStatusCode.InternalServerError, result = "patientrx is not configured", TimeZone = DateTime.UtcNow.ToString("s") }));
                        }
                    }
                    else
                    {
                        return(Json(new { Status = (int)HttpStatusCode.Forbidden, result = "patient is not configured", TimeZone = DateTime.UtcNow.ToString("s") }));
                    }
                }
                else
                {
                    return(Json(new { Status = (int)HttpStatusCode.Forbidden, result = "session id not valid", TimeZone = DateTime.UtcNow.ToString("s") }));
                }
            }
            catch (Exception ex)
            {
                return(Json(new { Status = (int)HttpStatusCode.InternalServerError, result = "Internal server error", TimeZone = DateTime.UtcNow.ToString("s") }));
            }
            return(Json(new { Status = (int)HttpStatusCode.OK, result = "success", Summary = lsummary, TimeZone = DateTime.UtcNow.ToString("s") }));
        }
Ejemplo n.º 25
0
        private void btnStart_Click(object sender, RoutedEventArgs e)
        {
            MyPatient myPatient = _viewModel.SelectedPatient;
            string    patientId = myPatient.PatientId;

            PatientSummary patientSummary = _application.PatientSummaries.FirstOrDefault(s => s.Id == patientId);

            if (patientSummary == null)
            {
                return;
            }

            Patient patient = _application.OpenPatient(patientSummary);
            Course  course  = patient.Courses.FirstOrDefault(s => s.Id == _viewModel.SelectedCourse.CourseId);

            if (course == null)
            {
                MessageBox.Show("Can't find selected course in Aria");
                return;
            }

            //planId items in scope
            List <PlanSetup> PlansInScope = new List <PlanSetup>();

            foreach (var pitem in _viewModel.PlansInScope)
            {
                //check if planSetup
                PlanSetup plan = (PlanSetup)course.PlanSetups.FirstOrDefault(s => s.Id == pitem.pItemId);
                if (plan != null)
                {
                    PlansInScope.Add(plan);
                }
            }

            //Opened plan Item
            string openPlanId = string.Empty;

            foreach (var pitem in _viewModel.PlansInScope)
            {
                if (pitem.IsOpened)
                {
                    openPlanId = pitem.pItemId;
                    break;
                }
            }

            //check if planSetup
            PlanSetup openedPlan = course.PlanSetups.FirstOrDefault(s => s.Id == openPlanId);

            if (openedPlan == null)
            {
                MessageBox.Show("No PlanSetup found with Id = " + openPlanId, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }



            Window window = new Window();

            window.Closing += WindowClosingHandler;
            window.Show();

            //Save selections for use in next run
            SaveSelections();
            try
            {
                VMS.TPS.Script.Start(patient, course, PlansInScope, openedPlan, _application.CurrentUser, window);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Caught exception from Script\n" + ex.Message + "\n" + ex.StackTrace);
                return;
            }
        }
        public ActionResult Summary(string dfn)
        {
            // *** Create new model ***
            PatientSummary model = new PatientSummary();

            // *** Get patient demographics ***
            model.Patient = this.CurrentPatient;

            // *** Check for success ***
            if (!model.Patient.NotFound)
            {
                PregnancyResult pregResult = this.DashboardRepository.Pregnancy.GetCurrentOrMostRecentPregnancy(dfn);

                if (pregResult.Success)
                {
                    if (pregResult.Pregnancy != null)
                    {
                        if (pregResult.Pregnancy.RecordType == PregnancyRecordType.Current)
                        {
                            model.CurrentPregnancy = pregResult.Pregnancy;

                            PregnancyDetails tempDetails = PregnancyUtilities.GetPregnancyObservationData(this.DashboardRepository, dfn, model.CurrentPregnancy.Ien);

                            model.CurrentPregnancy.Lmp            = tempDetails.Lmp;
                            model.CurrentPregnancy.FetusBabyCount = tempDetails.FetusBabyCount;

                            model.CurrentPregnancy.EddBasis   = tempDetails.EddBasis;
                            model.CurrentPregnancy.EddIsFinal = tempDetails.EddIsFinal;
                        }
                        else
                        {
                            // TODO: Show most recent pregnancy ?
                        }

                        // *** Get pregnancy checklist ***
                        UpdateChecklistSummary(model, dfn, pregResult);
                    }
                }

                // *** Get Pregnancy History ***
                PregnancyHistoryResult histResult = this.DashboardRepository.Pregnancy.GetPregnancyHistory(dfn);

                if (histResult.Success)
                {
                    model.PregnancyHistory = histResult.PregnancyHistory;
                }
                else
                {
                    model.PregnancyHistory = new PregnancyHistory();
                    this.Error(histResult.Message);
                }
            }

            // *** Set return url ***
            if (TempData.ContainsKey(LastPatientListUrl))
            {
                model.ReturnUrl = TempData[LastPatientListUrl].ToString();

                TempData.Keep(LastPatientListUrl);

                // *** Indicate how to get back here ***
                TempData[ReturnUrl] = Url.Action("Summary", "Patient", new { dfn = dfn });
            }

            return(View("Summary2", model));
        }
Ejemplo n.º 27
0
        public IHttpActionResult PatientLogin(string username, string password)
        {
            PatientSummary patientSummary = repository.GetAPatientDetail(username, password);

            return(Ok(patientSummary));
        }
        public IActionResult ViewPatient(string id, string startDate = null, string endDate = null)
        {
            if (!DataValidator.TryValidateString(id, out string idValidated, 4, 50))
            {
                ViewBag.Error        = true;
                ViewBag.ErrorMessage = $"Błąd parsowania id : `{id.Substring(30)}` nie jest poprawnym ciagiem.";
                return(View());
            }
            var searchParameters = new List <Tuple <string, string> >();

            DateTime startDateValidated = DateTime.MinValue,
                     endDateValidated   = DateTime.Now;

            if (!string.IsNullOrEmpty(startDate) && DataValidator.TryValidateDateTime(startDate, out startDateValidated))
            {
                searchParameters.Add(new Tuple <string, string>("date", startDateValidated.ToString(">=yyyy-MM-dd")));
                ViewBag.startDate = startDateValidated.ToString("dd-MMMM-yyyy");
            }

            if (!string.IsNullOrEmpty(endDate) && DataValidator.TryValidateDateTime(endDate, out endDateValidated))
            {
                searchParameters.Add(new Tuple <string, string>("date", endDateValidated.ToString("<=yyyy-MM-dd")));
                ViewBag.endDate = endDateValidated.ToString("dd-MMMM-yyyy");
            }

            var resourceGetter = new ResourceGetter();
            var person         = resourceGetter.GetItem <Patient>(id);

            if (person == null)
            {
                return(View());
            }

            searchParameters.Add(new Tuple <string, string>("subject", id));
            var patientsObservations        = resourceGetter.SearchItemsWithParameters <Observation>(searchParameters);
            var patientsMedicamentsRequests = resourceGetter.SearchItemsWithParameters <MedicationRequest>("subject", id);   //use only id search parameter

            var valuableExaminations = new Dictionary <string, List <PatientValueExamination> >();
            var valueObservations    = patientsObservations.Where(x => x.Value is SimpleQuantity || x.Component.Count > 0);
            var timelineObservations = patientsObservations.Where(x => !(x.Value is SimpleQuantity) && x.Component.Count == 0).
                                       Select(x =>
            {
                DateTimeOffset?issued = x.Issued;
                return(new TimelineObject()
                {
                    Date = issued.HasValue ? x.Issued.Value.DateTime : DateTime.MinValue,
                    Header = x.Code.Coding.FirstOrDefault()?.Display ?? DefaultObservationHeader,
                    Description = x.Value.ToString(),
                    Code = x.Code.Coding.FirstOrDefault()?.Code ?? DefaultCodeNumber,
                    EventType = TimelineEvent.ObservationMisc
                });
            });

            var timelineMedications = patientsMedicamentsRequests.
                                      Where(x =>
            {
                //filter dates here seems date in MedicationRequest search parameters doesn't affect results
                var dateTime = x.AuthoredOnElement.ToDateTime() ?? DateTime.Now;
                return(dateTime >= startDateValidated && dateTime <= endDateValidated);
            }).
                                      Select(x =>
            {
                var medication = x.Medication as CodeableConcept;
                return(new TimelineObject()
                {
                    Date = (x.AuthoredOnElement.ToDateTime() ?? DateTime.MinValue),
                    Header = "Podanie leku",
                    Description = (medication.Text ?? "Nieznana nazwa leku"),
                    Code = medication.Coding.FirstOrDefault().Code ?? DefaultCodeNumber,
                    EventType = TimelineEvent.MedicationRequest
                });
            });

            foreach (var observation in valueObservations)
            {
                List <PatientValueExamination> examinations = TryGetObservationValue(observation);

                foreach (var examination in examinations)
                {
                    var code = examination.Code;
                    if (!valuableExaminations.ContainsKey(code))
                    {
                        valuableExaminations.Add(code, new List <PatientValueExamination>()
                        {
                            examination
                        });
                    }
                    else
                    {
                        valuableExaminations[code].Add(examination);
                    }
                }
            }

            var patientSummary = new PatientSummary()
            {
                Data               = person,
                Observations       = patientsObservations,
                MedicationRequests = patientsMedicamentsRequests
            };

            //add dict for graphs
            patientSummary.SetPatientValueExaminations(valuableExaminations);
            //add timeline objects and sort them
            patientSummary.AddTimelineObjects(timelineObservations.Concat(timelineMedications).ToList());

            return(View(patientSummary));
        }
Ejemplo n.º 29
0
        public IHttpActionResult RenewMembership(int patientid)
        {
            PatientSummary summary = repository.RenewPatientPlan(patientid);

            return(Ok(summary));
        }