Exemplo n.º 1
0
        /// <summary>
        /// Create a list of Microsoft Band Accelerometer objects from the data read from the csv file selected by the user.
        /// </summary>
        /// <param name="csvReader">csv reader object</param>
        /// <param name="patientData">Patient data record that will be referenced by each microsoft band accel data record.</param>
        /// <param name="date">Date the data in the file was collected.</param>
        /// <returns></returns>
        public static List<MSBandAccelerometer> BuildMSBandAccelerometerDataList(CsvReader csvReader, PatientData patientData, DateTime date)
        {
            List<MSBandAccelerometer> msBandAccelData = null;

            if (csvReader != null && patientData != null && patientData.Id != null) {
                msBandAccelData = new List<MSBandAccelerometer>();

                while (csvReader.ReadNextRecord()) {
                    if (csvReader != null) {
                        //File should read in the following order.
                        //Time | Lateral | Vertical | Sagittal
                        string dateFormat = "HH:mm:ss.fff";
                        string dateInfo = csvReader[0];
                        DateTime dateTime;
                        if (DateTime.TryParseExact(dateInfo, dateFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTime)) {
                            date = new DateTime(date.Year, date.Month, date.Day, dateTime.Hour, dateTime.Minute, dateTime.Second, dateTime.Millisecond);
                            MSBandAccelerometer msBandAccel = new MSBandAccelerometer() {
                                Date = date,
                                Lateral = (float)Convert.ToDouble(csvReader[1]),
                                Vertical = (float)Convert.ToDouble(csvReader[2]),
                                Sagittal = (float)Convert.ToDouble(csvReader[3]),
                                PatientDataId = patientData.Id
                            };
                            msBandAccelData.Add(msBandAccel);
                        }
                    }
                }
            }

            return msBandAccelData;
        }
Exemplo n.º 2
0
 /// <summary>
 /// Get the BasisPeak Summary data for the given a patient data record or all records for all patients.
 /// </summary>
 /// <param name="patientData">PatientData object used to retrieve the BasisPeak Summary Data records</param>
 /// <param name="skip">Skip a number of records in the data collection</param>
 /// <param name="take">Number of records to return.</param>
 /// <returns></returns>
 public IEnumerable<BasisPeakSummaryData> GetBasisPeakSummaryData(PatientData patientData, int skip = 0 , int take = 0)
 {
     if (patientData == null)
         return _repository.GetAll();
     else
         return _repository.GetMany(r => r.PatientDataId == patientData.Id, r => r.Date, skip, take);
 }
Exemplo n.º 3
0
 /// <summary>
 /// Get the Zephyr ECG WaveForm data for the given a patient data record or all records for all patients.
 /// </summary>
 /// <param name="patientData">PatientData object used to retrieve the Zephyr ECG WaveForm Data records</param>
 /// <param name="skip">Skip a number of records in the data collection</param>
 /// <param name="take">Number of records to return.</param>
 /// <returns></returns>
 public IEnumerable<ZephyrECGWaveform> GetZephyrECGWaveFormData(PatientData patientData, int skip = 0, int take = 0)
 {
     if (patientData == null)
         return _repository.GetAll();
     else
         return _repository.GetMany(r => r.PatientDataId == patientData.Id, r => r.Time, skip, take);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Get the Microsoft Band Temperature data for the given a patient data record or all records for all patients.
 /// </summary>
 /// <param name="patientData">PatientData object used to retrieve the Microsoft Band Temperature Data records</param>
 /// <param name="skip">Skip a number of records in the data collection</param>
 /// <param name="take">Number of records to return.</param>
 /// <returns></returns>
 public IEnumerable<MSBandTemperature> GetMSBandTemperatureData(PatientData patientData, int skip = 0, int take = 0)
 {
     if (patientData == null)
         return _repository.GetAll();
     else
         return _repository.GetMany(r => r.PatientDataId == patientData.Id, r => r.Date, skip, take);
 }
Exemplo n.º 5
0
        /// <summary>
        /// Create a list of BasisPeakSummaryData objects from the data read from the csv file selected by the user.
        /// </summary>
        /// <param name="csvReader">Csv reader object</param>
        /// <param name="patientData">Patient data record that will be referenced by each basispeak summary data record.</param>
        /// <returns></returns>
        public static List<BasisPeakSummaryData> BuildBasisPeakSummaryDataList(CsvReader csvReader, PatientData patientData)
        {
            List<BasisPeakSummaryData> basisPeakSummaryData = null;

            if (csvReader != null && patientData != null && patientData.Id != null) {
                basisPeakSummaryData = new List<BasisPeakSummaryData>();

                while (csvReader.ReadNextRecord()) {
                    if (csvReader != null) {
                        //TODO: Dr. Milenkovic has asked to automatically convert the date from GMT time.
                        //File should read in the following order.
                        //Date | Calories | GSR | heart-rate | skin-temp | steps
                        BasisPeakSummaryData summary = new BasisPeakSummaryData();
                        summary.Date = DateTime.Parse(csvReader[0]);

                        //Convert date from basis peak summary from GMT to CST.
                        TimeZoneInfo nyTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time");
                        if (nyTimeZone.IsDaylightSavingTime(DateTime.Now)) {
                            summary.Date = summary.Date.AddHours(6);
                        }
                        else {
                            summary.Date = summary.Date.AddHours(5);
                        }

                        if (!string.IsNullOrEmpty(csvReader[1])) {
                            summary.Calories = (float)Convert.ToDouble(csvReader[1]);
                        }
                        if (!string.IsNullOrEmpty(csvReader[2])) {
                            summary.GSR = (float)Convert.ToDouble(csvReader[2]);
                        }
                        if (!string.IsNullOrEmpty(csvReader[3])) {
                            summary.HeartRate = Convert.ToInt32(csvReader[3]);
                        }
                        if (!string.IsNullOrEmpty(csvReader[4])) {
                            summary.SkinTemp = (float)Convert.ToDouble(csvReader[4]);
                        }
                        summary.Steps = (!string.IsNullOrEmpty(csvReader[5])) ? Convert.ToInt32(csvReader[5]) : 0;
                        summary.PatientDataId = patientData.Id;

                        basisPeakSummaryData.Add(summary);
                    }
                }
            }

            return basisPeakSummaryData;
        }
Exemplo n.º 6
0
        /// <summary>
        /// Create a list of ZephyrSummaryData objects from the data read from the csv file selected by the user.
        /// </summary>
        /// <param name="csvReader">csv reader object</param>
        /// <param name="patientData">Patient data record that will be referenced by each zephyr summary data record.</param>
        /// <returns></returns>
        public static List<ZephyrSummaryData> BuildZephyrSummaryDataList(CsvReader csvReader, PatientData patientData)
        {
            List<ZephyrSummaryData> zephyrSummaryData = null;

            if (csvReader != null && patientData != null && patientData.Id != null) {
                zephyrSummaryData = new List<ZephyrSummaryData>();
                while (csvReader.ReadNextRecord()) {
                    if (csvReader != null) {
                        //File should read in the following order.
                        //Time | HR | BR | SkinTemp | Posture | Activity | PeakAccel | BatteryVolts | BatteryLevel | BRAmplitude
                        //cont. BRNoise | BRConfidence | ECGAmplitude | ECGNoise | HRConfidence | HRV | SystemConfidence | GSR
                        //cont. ROGState | ROGTime | VerticalMin | VericalPeak | LateralMin | LateralPeak | SagittalMin | SagittalPeak
                        //cont. DeviceTemp | StatusInfo | LinkQuality | RSSI | TxPower | CoreTemp | AuxADC1 | AuxADC2 | AuxADC3
                        string dateFormat = "dd/MM/yyyy HH:mm:ss.fff";
                        string date = csvReader[0];
                        DateTime dateTime;
                        if (DateTime.TryParseExact(date, dateFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTime)) {

                            ZephyrSummaryData zephyrSummary = new ZephyrSummaryData() {
                                Date = dateTime,
                                HeartRate = Convert.ToInt32(csvReader[1]),
                                BreathingRate = (float)Convert.ToDouble(csvReader[2]),
                                SkinTemp = (float)Convert.ToDouble(csvReader[3]),
                                Posture = Convert.ToInt32(csvReader[4]),
                                Activity = (float)Convert.ToDouble(csvReader[5]),
                                PeakAccel = (float)Convert.ToDouble(csvReader[6]),
                                BatteryVolts = (float)Convert.ToDouble(csvReader[7]),
                                BatteryLevel = (float)Convert.ToDouble(csvReader[8]),
                                BRAmplitude = (float)Convert.ToDouble(csvReader[9]),
                                BRNoise = (float)Convert.ToDouble(csvReader[10]),
                                BRConfidence = Convert.ToInt32(csvReader[11]),
                                ECGAmplitude = (float)Convert.ToDouble(csvReader[12]),
                                ECGNoise = (float)Convert.ToDouble(csvReader[13]),
                                HRConfidence = Convert.ToInt32(csvReader[14]),
                                HRV = Convert.ToInt32(csvReader[15]),
                                SystemConfidence = Convert.ToInt32(csvReader[16]),
                                GSR = Convert.ToInt32(csvReader[17]),
                                ROGState = Convert.ToInt32(csvReader[18]),
                                ROGTime = Convert.ToInt32(csvReader[19]),
                                VerticalMin = (float)Convert.ToDouble(csvReader[20]),
                                VerticalPeak = (float)Convert.ToDouble(csvReader[21]),
                                LateralMin = (float)Convert.ToDouble(csvReader[22]),
                                LateralPeak = (float)Convert.ToDouble(csvReader[23]),
                                SagittalMin = (float)Convert.ToDouble(csvReader[24]),
                                SagittalPeak = (float)Convert.ToDouble(csvReader[25]),
                                DeviceTemp = (float)Convert.ToDouble(csvReader[26]),
                                StatusInfo = Convert.ToInt32(csvReader[27]),
                                LinkQuality = Convert.ToInt32(csvReader[28]),
                                RSSI = Convert.ToInt32(csvReader[29]),
                                TxPower = Convert.ToInt32(csvReader[30]),
                                CoreTemp = (float)Convert.ToDouble(csvReader[31]),
                                AuxADC1 = Convert.ToInt32(csvReader[32]),
                                AuxADC2 = Convert.ToInt32(csvReader[33]),
                                AuxADC3 = Convert.ToInt32(csvReader[34]),
                                PatientDataId = patientData.Id
                            };
                            zephyrSummaryData.Add(zephyrSummary);
                        }
                    }
                }
            }

            return zephyrSummaryData;
        }
Exemplo n.º 7
0
        /// <summary>
        /// Create a list of ZephyrSummaryData objects from the data read from the csv file selected by the user.
        /// </summary>
        /// <param name="csvReader">csv reader object</param>
        /// <param name="patientData">Patient data record that will be referenced by each zephyr general data record.</param>
        /// <returns></returns>
        public static List<ZephyrSummaryData> BuildZephyrGeneralDataList(CsvReader csvReader, PatientData patientData)
        {
            List<ZephyrSummaryData> zephyrSummaryData = null;

            if (csvReader != null && patientData != null && patientData.Id != null) {
                zephyrSummaryData = new List<ZephyrSummaryData>();
                while (csvReader.ReadNextRecord()) {
                    if (csvReader != null) {
                        //File should read in the following order.
                        //Timestamp | HR | BR | Temp | Posture | Activity | Acceleration | Battery | BRAmplitude | ECGAmplitude | ECGNoise
                        //cont. XMin | XPeak | YMin | YPeak | ZMin | ZPeak
                        string dateFormat = "dd/MM/yyyy HH:mm:ss.fff";
                        string date = csvReader[0];
                        DateTime dateTime;
                        if (DateTime.TryParseExact(date, dateFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTime)) {

                            ZephyrSummaryData zephyrSummary = new ZephyrSummaryData() {
                                Date = dateTime,
                                HeartRate = Convert.ToInt32(csvReader[1]),
                                BreathingRate = (float)Convert.ToDouble(csvReader[2]),
                                SkinTemp = (float)Convert.ToDouble(csvReader[3]),
                                Posture = Convert.ToInt32(csvReader[4]),
                                Activity = (float)Convert.ToDouble(csvReader[5]),
                                PeakAccel = (float)Convert.ToDouble(csvReader[6]),
                                BatteryVolts = (float)Convert.ToDouble(csvReader[7]),
                                BRAmplitude = (float)Convert.ToDouble(csvReader[8]),
                                ECGAmplitude = (float)Convert.ToDouble(csvReader[9]),
                                ECGNoise = (float)Convert.ToDouble(csvReader[10]),
                                LateralMin = (float)Convert.ToDouble(csvReader[11]),
                                LateralPeak = (float)Convert.ToDouble(csvReader[12]),
                                VerticalMin = (float)Convert.ToDouble(csvReader[13]),
                                VerticalPeak = (float)Convert.ToDouble(csvReader[14]),
                                SagittalMin = (float)Convert.ToDouble(csvReader[15]),
                                SagittalPeak = (float)Convert.ToDouble(csvReader[16]),
                                PatientDataId = patientData.Id
                            };
                            zephyrSummaryData.Add(zephyrSummary);
                        }
                    }
                }
            }

            return zephyrSummaryData;
        }
Exemplo n.º 8
0
 /// <summary>
 /// Insert activities the user wants associated with the data into the database.
 /// </summary>
 /// <param name="activityModels">List of activities created by the user.</param>
 protected void InsertActivities(List<ActivityModel> activityModels, PatientData patientData)
 {
     if (activityModels != null && activityModels.Count > 0 && patientData != null) {
         foreach (ActivityModel model in activityModels) {
             if (model.ActivityType != null) {
                 Activity activity = new Activity() {
                     DataActivity = (int)Enum.Parse(typeof(ActivityType), model.ActivityType),
                     StartTime = model.StartTime,
                     EndTime = model.EndTime
                 };
                 if (PatientLogic.IsActivityValid(activity)) {
                     patientData.Activities.Add(activity);
                 }
             }
         }
     }
 }
Exemplo n.º 9
0
 /// <summary>
 /// Add a new patient data record to the database
 /// </summary>
 /// <param name="patientData">PatientData object to add to the database</param>
 public void CreatePatientData(PatientData patientData)
 {
     if(patientData != null) {
         _repository.Add(patientData);
     }
 }
Exemplo n.º 10
0
        /// <summary>
        /// Create a list of Microsoft Band UV objects from the data read from the csv file selected by the user.
        /// </summary>
        /// <param name="csvReader">csv reader object</param>
        /// <param name="patientData">Patient data record that will be referenced by each microsoft band uv data record.</param>
        /// <param name="date">Date the data in the file was collected.</param>
        /// <returns></returns>
        public static List<MSBandUV> BuildMSBandUVDataList(CsvReader csvReader, PatientData patientData, DateTime date)
        {
            List<MSBandUV> msBandUVData = null;

            if (csvReader != null && patientData != null && patientData.Id != null) {
                msBandUVData = new List<MSBandUV>();

                while (csvReader.ReadNextRecord()) {
                    if (csvReader != null) {
                        //File should read in the following order.
                        //Date | UVIndex
                        string dateFormat = "HH:mm:ss";
                        string dateInfo = csvReader[0];
                        DateTime dateTime;
                        if (DateTime.TryParseExact(dateInfo, dateFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTime)) {
                            date = new DateTime(date.Year, date.Month, date.Day, dateTime.Hour, dateTime.Minute, dateTime.Second);
                            MSBandUV msBandUV = new MSBandUV() {
                                Date = date,
                                UVIndex = Convert.ToInt32(csvReader[1]),
                                PatientDataId = patientData.Id
                            };
                            msBandUVData.Add(msBandUV);
                        }
                    }
                }
            }

            return msBandUVData;
        }
Exemplo n.º 11
0
        /// <summary>
        /// Create a list of Microsoft Band Gyroscope objects from the data read from the csv file selected by the user.
        /// </summary>
        /// <param name="csvReader">csv reader object</param>
        /// <param name="patientData">Patient data record that will be referenced by each microsoft band gyroscope data record.</param>
        /// <param name="date">Date the data in the file was collected.</param>
        /// <returns></returns>
        public static List<MSBandGyroscope> BuildMSBandGyroscopeDataList(CsvReader csvReader, PatientData patientData, DateTime date)
        {
            List<MSBandGyroscope> msBandGyroscopeData = null;

            if (csvReader != null && patientData != null && patientData.Id != null) {
                msBandGyroscopeData = new List<MSBandGyroscope>();

                while (csvReader.ReadNextRecord()) {
                    if (csvReader != null) {
                        //File should read in the following order.
                        //Timestamp | X | Y | Z
                        string dateFormat = "HH:mm:ss";
                        string dateInfo = csvReader[0];
                        DateTime dateTime;
                        if (DateTime.TryParseExact(dateInfo, dateFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTime)) {
                            date = new DateTime(date.Year, date.Month, date.Day, dateTime.Hour, dateTime.Minute, dateTime.Second);
                            MSBandGyroscope msBandGyroscope = new MSBandGyroscope() {
                                Timestamp = date,
                                X = (float)Convert.ToDouble(csvReader[1]),
                                Y = (float)Convert.ToDouble(csvReader[2]),
                                Z = (float)Convert.ToDouble(csvReader[3]),
                                PatientDataId = patientData.Id
                            };
                            msBandGyroscopeData.Add(msBandGyroscope);
                        }
                    }
                }
            }

            return msBandGyroscopeData;
        }
Exemplo n.º 12
0
        /// <summary>
        /// Create a list of Microsoft Band Distance objects from the data read from the csv file selected by the user.
        /// </summary>
        /// <param name="csvReader">csv reader object</param>
        /// <param name="patientData">Patient data record that will be referenced by each microsoft band distance data record.</param>
        /// <param name="date">Date the data in the file was collected.</param>
        /// <returns></returns>
        public static List<MSBandDistance> BuildMSBandDistanceDataList(CsvReader csvReader, PatientData patientData, DateTime date)
        {
            List<MSBandDistance> msBandDistanceData = null;

            if (csvReader != null && patientData != null && patientData.Id != null) {
                msBandDistanceData = new List<MSBandDistance>();

                while (csvReader.ReadNextRecord()) {
                    if (csvReader != null) {
                        //File should read in the following order.
                        //Time | Motion Type | Pace | Speed | Total
                        string dateFormat = "HH:mm:ss";
                        string dateInfo = csvReader[0];
                        DateTime dateTime;
                        if (DateTime.TryParseExact(dateInfo, dateFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTime)) {
                            date = new DateTime(date.Year, date.Month, date.Day, dateTime.Hour, dateTime.Minute, dateTime.Second);
                            MSBandDistance msBandDistance = new MSBandDistance() {
                                Date = date,
                                MotionType = csvReader[1],
                                Pace = (float)Convert.ToDouble(csvReader[2]),
                                Speed = (float)Convert.ToDouble(csvReader[3]),
                                Total = (float)Convert.ToDouble(csvReader[4]),
                                PatientDataId = patientData.Id
                            };
                            msBandDistanceData.Add(msBandDistance);
                        }
                    }
                }
            }

            return msBandDistanceData;
        }
Exemplo n.º 13
0
        /// <summary>
        /// Insert Zephyr Summary Data records from file into database.
        /// </summary>
        /// <param name="file">Zephyr summary file selected for upload from view.</param>
        /// <param name="patientData">Patient data record created for the patient for this accel data.</param>
        protected bool ProcessZephyrSummaryData(HttpPostedFileBase file, PatientData patientData, List<ActivityModel> activities)
        {
            List<ZephyrSummaryData> zephyrSummaryData = null;

            Stream stream = file.InputStream;
            using (CsvReader csvReader = new CsvReader(new StreamReader(stream), true)) {

                zephyrSummaryData = PatientLogic.BuildZephyrSummaryDataList(csvReader, patientData);
            }

            if (zephyrSummaryData != null && zephyrSummaryData.Count > 0) {
                //Write data to database
                InsertActivities(activities, patientData);
                _patientDataService.CreatePatientData(patientData);
                _patientDataService.SaveChanges();

                //Bulk insert zephyr excel records
                _summaryService.BulkInsert(zephyrSummaryData);

                return true;
            }

            return false;
        }
Exemplo n.º 14
0
        /// <summary>
        /// Insert Microsoft Band uv records from file into database
        /// </summary>
        /// <param name="file">Microsoft Band uv file selected for upload from view.</param>
        /// <param name="patientData">Patient data record created for the patient for this uv data.</param>
        protected bool ProcessMSBandUVData(HttpPostedFileBase file, PatientData patientData, List<ActivityModel> activities)
        {
            List<MSBandUV> msBandUVData = null;

            Stream stream = file.InputStream;
            DateTime date = DateTime.MinValue;

            using (CsvReader csvReader = new CsvReader(new StreamReader(stream), true)) {

                date = PatientLogic.FindMSBandDate(csvReader);
                stream.Seek(0, SeekOrigin.Begin);
                if (date != DateTime.MinValue) {
                    //Assume that the first line which contains the date is now a comment.  Set the comment
                    //indicator to the character M.
                    using (CsvReader reader = new CsvReader(new StreamReader(stream), true, ',', '"', '"', 'M', ValueTrimmingOptions.UnquotedOnly)) {

                        msBandUVData = PatientLogic.BuildMSBandUVDataList(reader, patientData, date);
                    }
                }
            }

            if (msBandUVData != null && msBandUVData.Count > 0) {
                //Write data to database
                InsertActivities(activities, patientData);
                _patientDataService.CreatePatientData(patientData);
                _patientDataService.SaveChanges();

                //Bulk insert
                _msBandUVService.BulkInsert(msBandUVData);

                return true;
            }

            return false;
        }
Exemplo n.º 15
0
        /// <summary>
        /// Insert Basis Peakk Summary data records from file to database.
        /// </summary>
        /// <param name="file"></param>
        /// <param name="patientData"></param>
        protected bool ProcessBasisPeakData(HttpPostedFileBase file, PatientData patientData, List<ActivityModel> activities)
        {
            List<BasisPeakSummaryData> basisPeakSummaryData = null;

            Stream stream = file.InputStream;

            //Note: Excel Reader is disposable per wiki on github
            using (CsvReader csvReader = new CsvReader(new StreamReader(stream), true)) {
                basisPeakSummaryData = PatientLogic.BuildBasisPeakSummaryDataList(csvReader, patientData);
            }

            if(basisPeakSummaryData != null && basisPeakSummaryData.Count > 0) {
                //Write data to database
                InsertActivities(activities, patientData);
                _patientDataService.CreatePatientData(patientData);
                _patientDataService.SaveChanges();

                //Bulk insert zephyr excel records
                _basisPeakService.BulkInsert(basisPeakSummaryData);
                return true;
            }

            return false;
        }
Exemplo n.º 16
0
 /// <summary>
 /// Get the Microsoft Band Pedometer data for the given a patient data record or all records for all patients.
 /// Filter what is returned by time.
 /// </summary>
 /// <param name="patientData">PatientData object used to retrieve the Microsoft Band Pedometer Data records</param>
 /// <param name="startTime">Start time of date/time filter</param>
 /// <param name="endTime">End time of date/time filter</param>
 /// <param name="skip">Skip a number of records in the data collection</param>
 /// <param name="take">Number of records to return.</param>
 /// <returns></returns>
 public IEnumerable<MSBandPedometer> GetMSBandPedometerData(PatientData patientData, DateTime startTime, DateTime endTime, int skip = 0, int take = 0)
 {
     if (patientData == null)
         return _repository.GetAll();
     else
         return _repository.GetMany(r => r.PatientDataId == patientData.Id && r.Date >= startTime && r.Date <= endTime, r => r.Date, skip, take);
 }
Exemplo n.º 17
0
 /// <summary>
 /// Get the Zephyr Breathing Waveform data for the given a patient data record or all records for all patients
 /// during the time provided.
 /// </summary>
 /// <param name="patientData">PatientData object used to retrieve the Zephyr Breathing Waveform Data records</param>
 /// <param name="startTime">Start time of date/time filter</param>
 /// <param name="endTime">End time of date/time filter</param>
 /// <param name="skip">Skip a number of records in the data collection</param>
 /// <param name="take">Number of records to return.</param>
 /// <returns></returns>
 public IEnumerable<ZephyrBreathingWaveform> GetZephyrBreathingWaveformData(PatientData patientData, DateTime startTime, DateTime endTime, int skip = 0, int take = 0)
 {
     if (patientData == null)
         return _repository.GetAll();
     else
         return _repository.GetMany(r => r.PatientDataId == patientData.Id && r.Time >= startTime && r.Time <= endTime, r => r.Time, skip, take);
 }
Exemplo n.º 18
0
        /// <summary>
        /// Create a list of ZephyrAccelerometer objects from the data read from the csv file selected by the user.
        /// </summary>
        /// <param name="csvReader">csv reader object</param>
        /// <param name="patientData">Patient data record that will be referenced by each zephyr accel data record.</param>
        /// <returns></returns>
        public static List<ZephyrAccelerometer> BuildZephyrAccelDataList(CsvReader csvReader, PatientData patientData)
        {
            List<ZephyrAccelerometer> zephyrAccelData = null;

            if (csvReader != null && patientData != null && patientData.Id != null) {
                zephyrAccelData = new List<ZephyrAccelerometer>();
                while (csvReader.ReadNextRecord()) {
                    if (csvReader != null) {
                        //File should read in the following order.
                        //Time | Vertical | Lateral | Sagittal
                        string dateFormat = "dd/MM/yyyy HH:mm:ss.fff";
                        string date = csvReader[0];
                        DateTime dateTime;
                        if (DateTime.TryParseExact(date, dateFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTime)) {
                            ZephyrAccelerometer zephyrAccel = new ZephyrAccelerometer() {
                                Time = dateTime,
                                Vertical = Convert.ToInt32(csvReader[1]),
                                Lateral = Convert.ToInt32(csvReader[2]),
                                Sagittal = Convert.ToInt32(csvReader[3]),
                                PatientDataId = patientData.Id
                            };
                            zephyrAccelData.Add(zephyrAccel);
                        }
                    }
                }
            }

            return zephyrAccelData;
        }
Exemplo n.º 19
0
 /// <summary>
 /// Get the Zephyr BR RR data for the given a patient data record or all records for all patients
 /// during the time provided.
 /// </summary>
 /// <param name="patientData">PatientData object used to retrieve the Zephyr BR RR Data records</param>
 /// <param name="startTime">Start time of date/time filter</param>
 /// <param name="endTime">End time of date/time filter</param>
 /// <param name="skip">Skip a number of records in the data collection</param>
 /// <param name="take">Number of records to return.</param>
 /// <returns></returns>
 public IEnumerable<ZephyrBRRR> GetZephyrBRRRData(PatientData patientData, DateTime startTime, DateTime endTime, int skip = 0, int take = 0)
 {
     if (patientData == null)
         return _repository.GetAll();
     else
         return _repository.GetMany(r => r.PatientDataId == patientData.Id && r.TimeStamp >= startTime && r.TimeStamp <= endTime, r => r.TimeStamp, skip, take);
 }
Exemplo n.º 20
0
        /// <summary>
        /// Create a list of ZephyrBRRR objects from the data read from the csv file selected by the user.
        /// </summary>
        /// <param name="csvReader">csv reader object</param>
        /// <param name="patientData">Patient data record that will be referenced by each zephyr BR RR data record.</param>
        /// <returns></returns>
        public static List<ZephyrBRRR> BuildZephyrBrRrDataList(CsvReader csvReader, PatientData patientData)
        {
            List<ZephyrBRRR> zephyrBrRrData = null;

            if (csvReader != null && patientData != null && patientData.Id != null) {
                zephyrBrRrData = new List<ZephyrBRRR>();
                while (csvReader.ReadNextRecord()) {
                    if (csvReader != null) {
                        //File should read in the following order.
                        //Timestamp | BR | RtoR
                        string dateFormat = "dd/MM/yyyy HH:mm:ss.fff";
                        string date = csvReader[0];
                        DateTime dateTime;
                        if (DateTime.TryParseExact(date, dateFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTime)) {
                            ZephyrBRRR zephyrBrRr = new ZephyrBRRR() {
                                TimeStamp = dateTime,
                                BR = (float)Convert.ToDouble(csvReader[1]),
                                RR = (float)Convert.ToDouble(csvReader[2]),
                                PatientDataId = patientData.Id
                            };
                            zephyrBrRrData.Add(zephyrBrRr);
                        }
                    }
                }
            }

            return zephyrBrRrData;
        }
Exemplo n.º 21
0
        /// <summary>
        /// Create a list of ZephyrECGWaveform objects from the data read from the csv file selected by the user.
        /// </summary>
        /// <param name="csvReader">csv reader object</param>
        /// <param name="patientData">Patient data record that will be referenced by each zephyr ecg data record.</param>
        /// <returns></returns>
        public static List<ZephyrECGWaveform> BuildZephyrEcgDataList(CsvReader csvReader, PatientData patientData)
        {
            List<ZephyrECGWaveform> zephyrEcgData = null;

            if (csvReader != null && patientData != null && patientData.Id != null) {
                zephyrEcgData = new List<ZephyrECGWaveform>();
                while (csvReader.ReadNextRecord()) {
                    if (csvReader != null) {
                        //File should read in the following order.
                        //Time | EcgWaveform
                        string dateFormat = "dd/MM/yyyy HH:mm:ss.fff";
                        string date = csvReader[0];
                        DateTime dateTime;
                        if (DateTime.TryParseExact(date, dateFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTime)) {
                            ZephyrECGWaveform zephyrEcg = new ZephyrECGWaveform() {
                                Time = dateTime,
                                Data = Convert.ToInt32(csvReader[1]),
                                PatientDataId = patientData.Id
                            };
                            zephyrEcgData.Add(zephyrEcg);
                        }
                    }
                }
            }

            return zephyrEcgData;
        }
Exemplo n.º 22
0
        /// <summary>
        /// Create a list of ZephyrEventData objects from the data read from the csv file selected by the user.
        /// </summary>
        /// <param name="csvReader">csv reader object</param>
        /// <param name="patientData">Patient data record that will be referenced by each zephyr event data record.</param>
        /// <returns></returns>
        public static List<ZephyrEventData> BuildZephyrEventDataList(CsvReader csvReader, PatientData patientData)
        {
            List<ZephyrEventData> zephyrEventData = null;

            if (csvReader != null && patientData != null && patientData.Id != null) {
                zephyrEventData = new List<ZephyrEventData>();
                while (csvReader.ReadNextRecord()) {
                    if (csvReader != null) {
                        //File should read in the following order.
                        //Seq | Year | Month | Day | ms | Event Code | Type | Source | EventId | Event Specific Data
                        int ms = Convert.ToInt32(csvReader[4]);
                        TimeSpan time = TimeSpan.FromMilliseconds(ms);

                        DateTime dateTime = new DateTime(Convert.ToInt32(csvReader[1]),
                                                         Convert.ToInt32(csvReader[2]),
                                                         Convert.ToInt32(csvReader[3]),
                                                         time.Hours,
                                                         time.Minutes,
                                                         time.Seconds,
                                                         time.Milliseconds);

                        ZephyrEventData zephyrEvent = new ZephyrEventData() {
                            Date = dateTime,
                            EventCode = Convert.ToInt32(csvReader[5]),
                            Type = csvReader[6],
                            Source = csvReader[7],
                            EventId = Convert.ToInt32(csvReader[8]),
                            EventSpecificData = csvReader[9],
                            PatientDataId = patientData.Id
                        };
                        zephyrEventData.Add(zephyrEvent);

                    }
                }
            }

            return zephyrEventData;
        }
Exemplo n.º 23
0
 /// <summary>
 /// Get the BasisPeak Summary data for the given a patient data record or all records for all patients.
 /// </summary>
 /// <param name="patientData">PatientData object used to retrieve the BasisPeak Summary Data records</param>
 /// <param name="startTime">Start time of date/time filter</param>
 /// <param name="endTime">End time of date/time filter</param>
 /// <param name="skip">Skip a number of records in the data collection</param>
 /// <param name="take">Number of records to return.</param>
 /// <returns></returns>
 public IEnumerable<BasisPeakSummaryData> GetBasisPeakSummaryData(PatientData patientData, DateTime startTime, DateTime endTime, int skip = 0, int take = 0)
 {
     if (patientData == null)
         return _repository.GetAll();
     else
         return _repository.GetMany(r => r.PatientDataId == patientData.Id && r.Date >= startTime && r.Date <= endTime, r => r.Date, skip, take);
 }
Exemplo n.º 24
0
        public ActionResult ProcessData(UploadDataViewModel model)
        {
            MedicalDevice medicalDevice = PatientLogic.DetermineDeviceType(MedicalDevices, model.MedicalDeviceType);

            foreach (HttpPostedFileBase file in model.Files) {

                File_Type fileType = PatientLogic.DetermineFileType(file.FileName, medicalDevice);

                Patient patient = _patientService.GetPatient(UserManager.FindById(User.Identity.GetUserId()).PatientId);

                PatientData patientData = new PatientData() {
                    Id = Guid.NewGuid().ToString(),
                    DataType = (int)fileType,
                    Name = file.FileName,
                    UploadDate = DateTime.Now,
                    FromDate = model.FromDate,
                    ToDate = model.ToDate,
                    MedicalDeviceId = medicalDevice.Id,
                    Patient = patient
                };

                bool result = false;

                if(medicalDevice.Name == Device_Type.BasisPeak.ToString()) {
                    result = ProcessBasisPeakData(file, patientData, model.Activities);
                }
                else if(medicalDevice.Name == Device_Type.Zephyr.ToString()) {
                    switch (fileType) {
                        case File_Type.Accelerometer:
                            result = ProcessZephyrAccelData(file, patientData, model.Activities);
                            break;
                        case File_Type.Breathing:
                            result = ProcessZephyrBreathingData(file, patientData, model.Activities);
                            break;
                        case File_Type.ECG:
                            result = ProcessZephyrECGData(file, patientData, model.Activities);
                            break;
                        case File_Type.EventData:
                            result = ProcessZephyrEventData(file, patientData, model.Activities);
                            break;
                        case File_Type.Summary:
                            result = ProcessZephyrSummaryData(file, patientData, model.Activities);
                            break;
                        case File_Type.General:
                            result = ProcessZephyrGeneralData(file, patientData, model.Activities);
                            break;
                        case File_Type.BR_RR:
                            result = ProcessZephyrBrRrData(file, patientData, model.Activities);
                            break;
                        default:
                            break;
                    }
                }
                else if(medicalDevice.Name.Trim() == Device_Type.Microsoft_Band.ToString().Replace("_", " ")) {
                    switch (fileType) {
                        case File_Type.Accelerometer:
                            result = ProcessMSBandAccelData(file, patientData, model.Activities);
                            break;
                        case File_Type.Calorie:
                            result = ProcessMSBandCalorieData(file, patientData, model.Activities);
                            break;
                        case File_Type.Distance:
                            result = ProcessMSBandDistanceData(file, patientData, model.Activities);
                            break;
                        case File_Type.Gyroscope:
                            result = ProcessMSBandGyroscopeData(file, patientData, model.Activities);
                            break;
                        case File_Type.HeartRate:
                            result = ProcessMSBandHeartRateData(file, patientData, model.Activities);
                            break;
                        case File_Type.Pedometer:
                            result = ProcessMSBandPedometerData(file, patientData, model.Activities);
                            break;
                        case File_Type.Temperature:
                            result = ProcessMSBandTemperatureData(file, patientData, model.Activities);
                            break;
                        case File_Type.UV:
                            result = ProcessMSBandUVData(file, patientData, model.Activities);
                            break;
                        default:
                            break;
                    }
                }
            }

            return RedirectToAction("Index", "PatientData");
        }