Exemplo n.º 1
0
    protected void Btn_ShowWeeklyWeightReadings_Click(object sender, EventArgs e)
    {
        HealthRecordSearcher searcher = PersonInfo.SelectedRecord.CreateSearcher();
        HealthRecordFilter   filter   = new HealthRecordFilter(
            Emotion.TypeId,
            DietaryDailyIntake.TypeId,
            Weight.TypeId,
            SleepJournalAM.TypeId,
            Exercise.TypeId);

        filter.EffectiveDateMin = DateTime.Now.Subtract(new TimeSpan(7, 0, 0, 0));
        searcher.Filters.Add(filter);

        HealthRecordItemCollection items = searcher.GetMatchingItems()[0];

        TimeSeries weight         = new TimeSeries("Weight Graph");
        TimeSeries emotions       = new TimeSeries("Emotions");
        TimeSeries dietaryintakes = new TimeSeries("Dietary Intake (Carbs)");
        TimeSeries sleep          = new TimeSeries("Sleep");
        TimeSeries exercise       = new TimeSeries("Exercise");

        foreach (HealthRecordItem item in items)
        {
            if (item is Weight)
            {
                Weight w = (Weight)item;
                weight.SeriesValue.Add(new TimeSeries.TimeSeriesValues(
                                           w.EffectiveDate, w.Value.DisplayValue.Value));
            }
            if (item is Emotion)
            {
                Emotion m = (Emotion)item;
                emotions.SeriesValue.Add(new TimeSeries.TimeSeriesValues(
                                             m.EffectiveDate, 1.0));
            }
            if (item is DietaryDailyIntake)
            {
            }
            if (item is SleepJournalAM)
            {
                SleepJournalAM s = (SleepJournalAM)item;
                sleep.SeriesValue.Add(new TimeSeries.TimeSeriesValues(
                                          s.EffectiveDate, s.SleepMinutes));
            }
            if (item is Exercise)
            {
            }
        }

        TimeplotView.Plots.Add(weight);
        TimeplotView.Plots.Add(emotions);
        TimeplotView.Plots.Add(dietaryintakes);
        TimeplotView.Plots.Add(sleep);
        TimeplotView.Plots.Add(exercise);
        TimeplotView.DataBind();
        TimeplotView.Visible = true;
    }
        public void WhenHeathVaultSleepJournalAMTransformedToFhir_ThenCodeAndValuesEqual()
        {
            var when           = SystemClock.Instance.InUtc().GetCurrentLocalDateTime();
            var sleepJournalAm = new SleepJournalAM(
                new HealthServiceDateTime(when),
                new ApproximateTime(22, 30),
                new ApproximateTime(6, 28),
                100,
                110,
                WakeState.Tired
                );

            sleepJournalAm.Awakenings.Add(new Occurrence(new ApproximateTime(23, 30), 40));
            sleepJournalAm.Awakenings.Add(new Occurrence(new ApproximateTime(0, 30), 10));

            sleepJournalAm.Medications = new CodableValue("Benzaclin", new CodedValue("ccabbac8-58f0-4e88-a1eb-538e21e7524d", "Mayo", "RxNorm", "2"));

            var observation = sleepJournalAm.ToFhir();

            Assert.IsNotNull(observation);
            Assert.AreEqual("22:30:00.000", observation.Component[0].Value.ToString());
            Assert.AreEqual("06:28:00.000", observation.Component[1].Value.ToString());
            Assert.AreEqual(100, ((Quantity)observation.Component[2].Value).Value);
            Assert.AreEqual(UnitAbbreviations.Minute, ((Quantity)observation.Component[2].Value).Unit);
            Assert.AreEqual(110, ((Quantity)observation.Component[3].Value).Value);
            Assert.AreEqual(UnitAbbreviations.Minute, ((Quantity)observation.Component[3].Value).Unit);

            Assert.AreEqual(new FhirDateTime(when.Year, when.Month, when.Day, 23, 30), ((Hl7.Fhir.Model.Period)observation.Component[4].Value).StartElement);
            Assert.AreEqual(new FhirDateTime(when.Year, when.Month, when.Day + 1, 0, 10), ((Hl7.Fhir.Model.Period)observation.Component[4].Value).EndElement);

            Assert.AreEqual(new FhirDateTime(when.Year, when.Month, when.Day, 0, 30), ((Hl7.Fhir.Model.Period)observation.Component[5].Value).StartElement);
            Assert.AreEqual(new FhirDateTime(when.Year, when.Month, when.Day, 0, 40), ((Hl7.Fhir.Model.Period)observation.Component[5].Value).EndElement);

            Assert.AreEqual("Tired", ((FhirString)observation.Component[6].Value).Value);

            Assert.AreEqual("ccabbac8-58f0-4e88-a1eb-538e21e7524d", ((CodeableConcept)observation.Component[7].Value).Coding[0].Code);
        }
Exemplo n.º 3
0
        internal static Observation ToFhirInternal(SleepJournalAM sleepJournalAM, Observation observation)
        {
            observation.Code = HealthVaultVocabularies.GenerateCodeableConcept(HealthVaultThingTypeNameCodes.SleepJournalAM);

            observation.Effective = new FhirDateTime(sleepJournalAM.When.ToLocalDateTime().ToDateTimeUnspecified());

            observation.Component = new List <Observation.ComponentComponent>();

            var bedtimeComponent = new Observation.ComponentComponent
            {
                Code = new CodeableConcept {
                    Text = HealthVaultVocabularies.SleepJournalAMBedtime
                },
                Value = sleepJournalAM.Bedtime.ToFhir()
            };

            observation.Component.Add(bedtimeComponent);

            var waketimeComponent = new Observation.ComponentComponent
            {
                Code = new CodeableConcept {
                    Text = HealthVaultVocabularies.SleepJournalAMWaketime
                },
                Value = sleepJournalAM.WakeTime.ToFhir()
            };

            observation.Component.Add(waketimeComponent);

            var sleepMinutesComponent = new Observation.ComponentComponent
            {
                Code = new CodeableConcept {
                    Text = HealthVaultVocabularies.SleepJournalAMSleepMinutes
                },
                Value = new Quantity(sleepJournalAM.SleepMinutes, UnitAbbreviations.Minute)
            };

            observation.Component.Add(sleepMinutesComponent);

            var settlingMinutesComponent = new Observation.ComponentComponent
            {
                Code = new CodeableConcept {
                    Text = HealthVaultVocabularies.SleepJournalAMSettlingMinutes
                },
                Value = new Quantity(sleepJournalAM.SettlingMinutes, UnitAbbreviations.Minute)
            };

            observation.Component.Add(settlingMinutesComponent);

            if (sleepJournalAM.Awakenings != null)
            {
                foreach (var awakening in sleepJournalAM.Awakenings)
                {
                    var dummyDateTimeStart = new DateTime(sleepJournalAM.When.Date.Year, sleepJournalAM.When.Date.Month, sleepJournalAM.When.Date.Day);
                    dummyDateTimeStart = dummyDateTimeStart.AddHours(awakening.When.Hour);
                    dummyDateTimeStart = dummyDateTimeStart.AddMinutes(awakening.When.Minute);
                    if (awakening.When.Second.HasValue)
                    {
                        dummyDateTimeStart = dummyDateTimeStart.AddSeconds(awakening.When.Second.Value);
                    }

                    if (awakening.When.Millisecond.HasValue)
                    {
                        dummyDateTimeStart = dummyDateTimeStart.AddSeconds(awakening.When.Millisecond.Value);
                    }

                    var dummyDateTimeEnd = dummyDateTimeStart;
                    dummyDateTimeEnd = dummyDateTimeEnd.AddMinutes(awakening.Minutes);

                    var awakeningComponent = new Observation.ComponentComponent
                    {
                        Code = new CodeableConcept {
                            Text = HealthVaultVocabularies.SleepJournalAMAwakening
                        },
                        Value = new Period(new FhirDateTime(dummyDateTimeStart), new FhirDateTime(dummyDateTimeEnd)),
                    };
                    observation.Component.Add(awakeningComponent);
                }
            }

            var wakeStateComponent = new Observation.ComponentComponent
            {
                Code = new CodeableConcept {
                    Text = HealthVaultVocabularies.SleepJournalAMWakeState
                },
                Value = new FhirString(sleepJournalAM.WakeState.ToString()),
            };

            observation.Component.Add(wakeStateComponent);

            if (sleepJournalAM.Medications != null)
            {
                var medicationComponenet = new Observation.ComponentComponent
                {
                    Code = new CodeableConcept {
                        Text = HealthVaultVocabularies.SleepJournalAMMedication
                    },
                    Value = sleepJournalAM.Medications.ToFhir(),
                };
                observation.Component.Add(medicationComponenet);
            }

            return(observation);
        }
Exemplo n.º 4
0
 // Register the type on the generic ThingToFhir partial class
 public static Observation ToFhir(this SleepJournalAM sleepJournalAM)
 {
     return(SleepJournalAMToFhir.ToFhirInternal(sleepJournalAM, ThingBaseToFhir.ToFhirInternal <Observation>(sleepJournalAM)));
 }