private bool actionTimeHasPassed(TestAction action, TestReplay TR)
 {
     TimeSpan span = action.getStartTime().Subtract(TR.getStartTime());
     double seconds = span.TotalSeconds;
     bool b = seconds < stopwatch.Elapsed.TotalSeconds;
     return b;
 }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            passer = e.Parameter as InfoPasser;    // This is the type of the trails test.


            nodes.Clear();
            
            TEST_TYPE type = TEST_TYPE.TRAILS_A;
            if (passer.trailsTestVersion == 'A')
                type = TEST_TYPE.TRAILS_A;
            else if (passer.trailsTestVersion == 'B')
                type = TEST_TYPE.TRAILS_B;

            testReplay = new TestReplay(passer.currentPatient, type);

            if (passer.currentPatient.getTestFilenames().Count > 0)
            {
                currentlySelectedDate = passer.currentPatient.getTestFilenames()[0];
            }

            var stuff = passer.currentPatient.getTestFilenames();
            foreach (string filename in stuff)
            {
                if (filename.Contains(testReplay.getTestType().ToString()))
                {
                    testDatesBox.Items.Add(testReplay.getDisplayedDatetime(filename));
                }
            }
        }
 // Take a string in format d/m/y hh:mm PM
 // Convert to format d-m-y_hh;mm_PM
 /*
 public string replaceDate(string d)
 {
     string date = "";
     for (int i = 0; i < d.Length; i++)
     {
         if (d[i] == ' ')
         {
             date += '_';
         }
         else if (d[i] == ':')
         {
             date += ';';
         }
         else if (d[i] == '/')
         {
             date += '-';
         }
         else
             date += d[i];
     }
     return date;
 }
 */
 // Load a previous clock test from a test replay object.
 // Need to create a new TestReplay object so that you do not add
 // more lines - test replay load will currently append information.
 async private void loadTest()
 {
     testReplay = new TestReplay();
     List<String> filenames = passer.currentPatient.getTestFilenames();
     foreach (String filename in filenames)
     {
         if(filename.Contains(currentlySelectedDate))
         {
             await testReplay.loadTestReplay(filename);
             break;
         }
     }
 }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            passer = e.Parameter as InfoPasser;
            testReplay = new TestReplay(passer.currentPatient, TEST_TYPE.CLOCK);

            // set default selected test
            if (passer.currentPatient.getTestFilenames().Count > 0)
            {
                currentlySelectedDate = passer.currentPatient.getTestFilenames()[0];
            }
            else
            {
                granularReplayButton.IsEnabled = false;
            }

            // display the filenames in the listview
            var stuff = passer.currentPatient.getTestFilenames();
            foreach(string filename in stuff)
            {
                if (filename.Contains(testReplay.getTestType().ToString()))
                {
                    testDatesBox.Items.Add(testReplay.getDisplayedDatetime(filename));
                }
            }
        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            passer = e.Parameter as InfoPasser;
            testReplay = new TestReplay(passer.currentPatient, TEST_TYPE.CLOCK);
        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            passer = e.Parameter as InfoPasser;    // This is the type of the trails test.

            nodes.Clear();
            populateNodes(passer.trailsTestVersion, nodes);      // Populate the list of trail nodes (no longer occurs in constructor bec need to have passer to know which test to load)

            //TODO must have real patient info here
            TEST_TYPE type = TEST_TYPE.TRAILS_A;
            if (passer.trailsTestVersion == 'A')
            {
                type = TEST_TYPE.TRAILS_A;
                if (!passer.trailsVertical)
                {
                    type = TEST_TYPE.TRAILS_A_H;
                }
            }
            else if (passer.trailsTestVersion == 'B')
            {
                type = TEST_TYPE.TRAILS_B;
                if(!passer.trailsVertical)
                {
                    type = TEST_TYPE.TRAILS_B_H;
                }
            }
            testReplay = new TestReplay(passer.currentPatient, type);
        }
Exemple #7
0
 public void addTestToPasser(TestReplay tr)
 {
     testReplay = tr;
 }
 private bool lineDataTimeHasPassed(LineData lineData, TestReplay TR)
 {
     TimeSpan span = lineData.getDateTime().Subtract(TR.getStartTime());
     double seconds = span.TotalSeconds;
     bool b = seconds < stopwatch.Elapsed.TotalSeconds;
     return b;
 }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            passer = e.Parameter as InfoPasser;
            testReplay1 = new TestReplay(passer.currentPatient, TEST_TYPE.REY_OSTERRIETH);
            testReplay2 = new TestReplay(passer.currentPatient, TEST_TYPE.REY_OSTERRIETH);

            if (passer.currentPatient.getTestFilenames().Count > 0)
            {
                currentlySelectedDate1 = passer.currentPatient.getTestFilenames()[0];
                currentlySelectedDate2 = passer.currentPatient.getTestFilenames()[0];
            }
            else
            {
                replayButton.IsEnabled = false;
            }

            var stuff = passer.currentPatient.getTestFilenames();
            foreach(string filename in stuff)
            {
                if (filename.Contains(testReplay1.getTestType().ToString()))
                {
                    testDatesBox1.Items.Add(testReplay1.getDisplayedDatetime(filename));
                    testDatesBox2.Items.Add(testReplay1.getDisplayedDatetime(filename));
                }
            }
        }
 private int getColorTimeInterval(TestReplay TR)
 {
     double testDuration = (TR.getEndTime() - TR.getStartTime()).TotalSeconds;
     if (testDuration <= 8) { return 1; }
     else if (testDuration <= 40) { return 5; }
     else if (testDuration <= 120) { return 15; }
     else { return 30; }
 }
        private async void LoadChartContents()
        {
            await loadJson();

            List<Performance> allResults = new List<Performance>();

            List<string> currentPatients = new List<string>();

            try
            {
                currentPatients = passer.currentPatient.getTestFilenames();
            }

            catch
            {
                //no passed data
            }

            // Go through all the patients and display the complete data.
            // Do not separate into different categories.

            if (fileNames.Count > 0)
            {


                foreach (string name in fileNames)
                {
                    testReplay = new TestReplay();

                    // Find the file that corresponds with this patient name and load it
                    for (int i = 0; i < patientList.Count; i++)
                    {
                        if (name.Contains(patientList[i].patientName))
                        {
                            await testReplay.loadTestReplay(name);
                            var actions = testReplay.getTestActions();
                            if (actions.Count < 1) continue;

                            DateTime start = actions[0].getStartTime();
                            DateTime end = actions[actions.Count - 1].getEndTime();
                            TimeSpan TimeDifference = end - start;

                            //Get name of test
                            string testName = name.Trim(new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' });
                            int j = 0;
                            for (; !Char.IsNumber(testName[j]); j++)
                            {
                                //increase j
                            }
                            testName = testName.Substring(0, j);

                            //Get education level

                            //-------Open and read file----------------------------
                            Windows.Storage.StorageFile myFile = await Windows.Storage.ApplicationData.Current.LocalFolder.GetFileAsync(name);
                            //read
                            String data = await Windows.Storage.FileIO.ReadTextAsync(myFile);
                            //-----------------------------------------------------

                            string educationLevel = "";
                            for (int charSpot = 46; charSpot < data.Count(); charSpot++)
                            {
                                if (data[charSpot] != '\n')
                                {
                                    educationLevel = educationLevel + data[charSpot];
                                }
                                else
                                {
                                    break;
                                }
                            }

                            //gender is written at about 43rd character
                            string gender = data.Substring(42, 3);

                            //gender and education strings purged of dashes and spaces
                            string cleanEducation = System.Text.RegularExpressions.Regex.Replace(educationLevel, @"\s|\-|'", "");
                            string cleanGender = System.Text.RegularExpressions.Regex.Replace(gender, @"\s|\-|'", "");

                            //Get performance time
                            double seconds = TimeDifference.Minutes * 60 + TimeDifference.Seconds + TimeDifference.Milliseconds / 100;
                            int tempAge = Convert.ToInt32(patientList[i].patientAge);

                            allResults.Add(new Performance() { Age = tempAge, Time = seconds, Test = testName, Education = cleanEducation, Gender = cleanGender });

                            if (currentPatients.Contains(name))
                            {
                                selected.Add(new Performance() { Age = tempAge, Time = seconds, Test = testName, Education = cleanEducation, Gender = cleanGender });
                            }

                            break;
                        }
                    }
                }

                List<Performance> sortPatientAge = new List<Performance>(allResults);
                if (allResults.Count > 0)
                {
                    sortPatientAge.Sort(delegate(Performance arg1, Performance arg2)
                    {
                        return arg1.Age.CompareTo(arg2.Age);
                    });
                }

                int minAgeIndex = 0;

                //Sets the min and max ages and populates the combobox list
                try
                {
                    minAgeIndex = sortPatientAge[0].Age;
                    while (minAgeIndex < sortPatientAge[sortPatientAge.Count - 1].Age)
                    {
                        minAgeRange.Items.Add(Convert.ToDouble(minAgeIndex));
                        maxAgeRange.Items.Add(Convert.ToDouble(minAgeIndex));
                        minAgeIndex++;
                    }
                    minAgeRange.Items.Add(Convert.ToDouble(minAgeIndex));
                    maxAgeRange.Items.Add(Convert.ToDouble(minAgeIndex));
                }
                catch
                {
                    //do nothing
                }
                //Sets the min and max times and populates the combobox list
                for (int i = Convert.ToInt32(Math.Floor(performanceListMin(sortPatientAge).Time)); i <= Convert.ToInt32(Math.Ceiling(performanceListMax(sortPatientAge).Time)); i++)
                {
                    minTimeRange.Items.Add(i);
                    maxTimeRange.Items.Add(i);
                }

                minAgeRange.SelectedIndex = 0;
                maxAgeRange.SelectedIndex = (maxAgeRange.Items.Count - 1);

                minTimeRange.SelectedIndex = 0;
                maxTimeRange.SelectedIndex = (maxTimeRange.Items.Count - 1);

                //Adds each performance point to the appropiate data structure that is belongs
                //to based on the type of test 
                for (int i = 0; i < sortPatientAge.Count; i++)
                {
                    switch (sortPatientAge[i].Test)
                    {
                        case "TRAILS_A":
                            TrailsA.Add(sortPatientAge[i]);
                            break;
                        case "TRAILS_B":
                            TrailsB.Add(sortPatientAge[i]);
                            break;
                        case "TRAILS_A_H":
                            TrailsA_H.Add(sortPatientAge[i]);
                            break;
                        case "TRAILS_B_H":
                            TrailsB_H.Add(sortPatientAge[i]);
                            break;
                        default:
                            //error
                            break;
                    }
                }

                for (int i = 0; i < selected.Count; i++)
                {
                    switch (selected[i].Test)
                    {
                        case "TRAILS_A":
                            selectedTrailsA.Add(selected[i]);
                            break;
                        case "TRAILS_B":
                            selectedTrailsB.Add(selected[i]);
                            break;
                        case "TRAILS_A_H":
                            selectedTrailsA_H.Add(selected[i]);
                            break;
                        case "TRAILS_B_H":
                            selectedTrailsB_H.Add(selected[i]);
                            break;
                        default:
                            //error
                            break;
                    }
                }

                TrailsAGroup = generatePlotPoints(TrailsA);
                TrailsBGroup = generatePlotPoints(TrailsB);
                TrailsA_HGroup = generatePlotPoints(TrailsA_H);
                TrailsB_HGroup = generatePlotPoints(TrailsB_H);

                //Stores the averages and medians of each test type
                avgTrailsAGrouped = averagize(TrailsA);
                avgTrailsA_HGrouped = averagize(TrailsA_H);
                avgTrailsBGrouped = averagize(TrailsB);
                avgTrailsB_HGrouped = averagize(TrailsB_H);

                medTrailsAGrouped = medianize(TrailsA);
                medTrailsA_HGrouped = medianize(TrailsA_H);
                medTrailsBGrouped = medianize(TrailsB);
                medTrailsB_HGrouped = medianize(TrailsB_H);

                //Reveals the chart after the data is loaded and calculated
                ScatterChart.Opacity = 100;
                ageAxis.Opacity = 100;
                timeAxis.Opacity = 100;
                progressNorm.IsActive = false;

                //enables the display of median and mean at start
                avgGraphCheckBox.IsChecked = true;
                medGraphCheckBox.IsChecked = true;

                //Sets the Trails A vertical as the default test to be graphed
                dataSelection.SelectedIndex = 0;

            }
            else
            {
                //no data
                progressNorm.IsActive = false;
                noData.Opacity = 100;
            }
        }
        /// The methods provided in this section are simply used to allow
        /// NavigationHelper to respond to the page's navigation methods.
        /// 
        /// Page specific logic should be placed in event handlers for the  
        /// <see cref="GridCS.Common.NavigationHelper.LoadState"/>
        /// and <see cref="GridCS.Common.NavigationHelper.SaveState"/>.
        /// The navigation parameter is available in the LoadState method 
        /// in addition to page state preserved during an earlier session.

        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            navigationHelper.OnNavigatedTo(e);
            passer = e.Parameter as InfoPasser;
            testReplay = new TestReplay();
        }