/// <summary>
 /// Add a new Microsoft Band HeartRate data record to the database
 /// </summary>
 /// <param name="msBandHeartRate">MSBandHeartRate object to add to the database</param>
 public void CreateMSBandHeartRate(MSBandHeartRate msBandHeartRate)
 {
     if(msBandHeartRate != null) {
         _repository.Add(msBandHeartRate);
     }
 }
Exemple #2
0
        /// <summary>
        /// Create a list of Microsoft Band Heart Rate 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 heart rate data record.</param>
        /// <param name="date">Date the data in the file was collected.</param>
        /// <returns></returns>
        public static List<MSBandHeartRate> BuildMSBandHeartRateDataList(CsvReader csvReader, PatientData patientData, DateTime date)
        {
            List<MSBandHeartRate> msBandHeartRateData = null;

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

                while (csvReader.ReadNextRecord()) {
                    if (csvReader != null) {
                        //File should read in the following order.
                        //Date | Read status | HeartRate
                        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);
                            MSBandHeartRate msBandHeartRate = new MSBandHeartRate() {
                                Date = date,
                                ReadStatus = csvReader[1],
                                HeartRate = Convert.ToInt32(csvReader[2]),
                                PatientDataId = patientData.Id
                            };
                            msBandHeartRateData.Add(msBandHeartRate);
                        }
                    }
                }
            }

            return msBandHeartRateData;
        }