Ejemplo n.º 1
0
        private void LoadRecentPatients()
        {
            if (!File.Exists(recentFileName))
            {
                return;
            }

            XmlDocument xDoc = new XmlDocument();

            xDoc.Load(recentFileName);
            XmlElement xRoot = xDoc.DocumentElement;

            if (xRoot == null)
            {
                return;
            }

            foreach (XmlNode node in xRoot.ChildNodes)
            {
                RecentPatient patient = new RecentPatient();
                patient.IsSelected = false;
                foreach (XmlNode node2 in node.ChildNodes)
                {
                    if (node2.Name == "Id")
                    {
                        patient.PatientId = node2.InnerText;
                    }
                    else if (node2.Name == "LastName")
                    {
                        patient.LastName = node2.InnerText;
                    }
                    else if (node2.Name == "FirstName")
                    {
                        patient.FirstName = node2.InnerText;
                    }
                    else if (node2.Name == "Courses")
                    {
                        foreach (XmlNode node3 in node2.ChildNodes)
                        {
                            patient.Courses.Add(node3.InnerText);
                        }
                    }
                    else if (node2.Name == "PlansInScope")
                    {
                        foreach (XmlNode node3 in node2.ChildNodes)
                        {
                            patient.PlansInScope.Add(node3.InnerText);
                        }
                    }
                    else if (node2.Name == "OpenedPlan")
                    {
                        patient.OpenPlanId = node2.InnerText;
                    }
                }
                _viewModel.RecentPatients.Add(patient);
            }
        }
Ejemplo n.º 2
0
        private void btnOpen_Click(object sender, RoutedEventArgs e)
        {
            Cursor = Cursors.Wait;

            RecentPatient recPatient = ((FrameworkElement)sender).DataContext as RecentPatient;
            string        patientId  = recPatient.PatientId;

            Patient patient = _application.OpenPatientById(patientId);

            if (patient == null)
            {
                MessageBox.Show("Can't find the selected patient in Aria");
                Cursor = Cursors.Arrow;
                return;
            }

            List <Course> courses = new List <Course>();

            foreach (string courseId in recPatient.Courses)
            {
                Course course = patient.Courses.FirstOrDefault(s => s.Id == courseId);
                if (course != null)
                {
                    courses.Add(course);
                }
            }
            if (courses.Count == 0)
            {
                MessageBox.Show("Can't find selected courses in Aria");
                Cursor = Cursors.Arrow;
                return;
            }

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

            foreach (string pitemId in recPatient.PlansInScope)
            {
                //check if planSetup
                foreach (var course in courses)
                {
                    pItem = course.PlanSetups.FirstOrDefault(s => s.Id == pitemId);
                    if (pItem == null)
                    {
                        pItem = course.PlanSums.FirstOrDefault(s => s.Id == pitemId);
                    }

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

            //Opened plan Item
            string openPlanId = recPatient.OpenPlanId;

            //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);
                Cursor = Cursors.Arrow;
                return;
            }


            Window window = new Window();

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

            Cursor = Cursors.Arrow;
            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.º 3
0
        private void btnDelFromHistory_Click(object sender, RoutedEventArgs e)
        {
            RecentPatient recPatient = ((FrameworkElement)sender).DataContext as RecentPatient;

            if (!File.Exists(recentFileName))
            {
                return;
            }

            XmlDocument xDoc = new XmlDocument();

            xDoc.Load(recentFileName);
            XmlElement xRoot = xDoc.DocumentElement;

            if (xRoot == null)
            {
                return;
            }

            foreach (XmlNode node in xRoot.ChildNodes)
            {
                string        patientId    = null;
                string        lastName     = null;
                string        firstName    = null;
                List <string> courses      = new List <string>();
                List <string> plansInScope = new List <string>();
                string        openPlanId   = null;
                foreach (XmlNode node2 in node.ChildNodes)
                {
                    if (node2.Name == "Id")
                    {
                        patientId = node2.InnerText;
                    }
                    else if (node2.Name == "LastName")
                    {
                        lastName = node2.InnerText;
                    }
                    else if (node2.Name == "FirstName")
                    {
                        firstName = node2.InnerText;
                    }
                    else if (node2.Name == "Courses")
                    {
                        foreach (XmlNode node3 in node2.ChildNodes)
                        {
                            courses.Add(node3.InnerText);
                        }
                    }
                    else if (node2.Name == "PlansInScope")
                    {
                        foreach (XmlNode node3 in node2.ChildNodes)
                        {
                            plansInScope.Add(node3.InnerText);
                        }
                    }
                    else if (node2.Name == "OpenedPlan")
                    {
                        openPlanId = node2.InnerText;
                    }
                }

                if (patientId != recPatient.PatientId ||
                    lastName != recPatient.LastName ||
                    firstName != recPatient.FirstName ||
                    !courses.SequenceEqual(recPatient.Courses) ||
                    !plansInScope.SequenceEqual(recPatient.PlansInScope) ||
                    openPlanId != recPatient.OpenPlanId)
                {
                    continue;
                }

                xRoot.RemoveChild(node);
                break;
            }
            xDoc.Save(recentFileName);
            _viewModel.RecentPatients.Clear();
            LoadRecentPatients();
        }
Ejemplo n.º 4
0
 public Task AddOrUpdate(RecentPatient item)
 {
     return(this.Collection.AddOrUpdate(item));
 }