Esempio n. 1
0
        public virtual async Task <Collection <HealthRecordInfo> > GetAuthorizedRecordsAsync(IList <Guid> recordIds)
        {
            StringBuilder parameters = new StringBuilder(128);

            foreach (Guid id in recordIds)
            {
                parameters.Append(
                    "<id>" + id + "</id>");
            }

            HealthServiceResponseData responseData = await _connection.ExecuteAsync(
                HealthVaultMethods.GetAuthorizedRecords,
                1,
                parameters.ToString())
                                                     .ConfigureAwait(false);

            Collection <HealthRecordInfo> results = new Collection <HealthRecordInfo>();

            XPathNodeIterator records = responseData.InfoNavigator.Select(GetRecordXPathExpression(responseData.InfoNavigator));

            foreach (XPathNavigator recordNav in records)
            {
                results.Add(HealthRecordInfo.CreateFromXml(_connection, recordNav));
            }

            return(results);
        }
Esempio n. 2
0
        // Store custom data in HealthVault
        private async void Set_CustomData_OnClick(object sender, RoutedEventArgs e)
        {
            PersonInfo personInfo = await _connection.GetPersonInfoAsync();

            HealthRecordInfo recordInfo  = personInfo.SelectedRecord;
            IThingClient     thingClient = _connection.CreateThingClient();

            await thingClient.CreateNewThingsAsync(
                recordInfo.Id,
                new List <CustomDataType>
            {
                new CustomDataType
                {
                    StartTime = DateTime.Now.Ticks,
                    EndTime   = DateTime.Now.Ticks + 1200,
                    Values    = new List <double> {
                        1.8, 2.5, 2.6, 3.7
                    },
                    ApplicationId = AppId,
                    SubtypeTag    = CustomDataTypeSubtypeTag,
                    Description   = "CustomDataType"
                }
            });

            OutputBlock.Text = "Created custom data type.";
        }
Esempio n. 3
0
        public async Task SimpleMedications()
        {
            IHealthVaultSodaConnection connection = HealthVaultConnectionFactory.Current.GetOrCreateSodaConnection(Constants.Configuration);
            IThingClient thingClient = connection.CreateThingClient();
            PersonInfo   personInfo  = await connection.GetPersonInfoAsync();

            HealthRecordInfo record = personInfo.SelectedRecord;

            await TestUtilities.RemoveAllThingsAsync <Medication>(thingClient, record.Id);

            var medication = new Medication
            {
                Name      = new CodableValue("My med"),
                Dose      = new GeneralMeasurement("2 tablets"),
                Strength  = new GeneralMeasurement("200mg"),
                Frequency = new GeneralMeasurement("Twice per day"),
                Route     = new CodableValue("By mouth", "po", new VocabularyKey("medication-routes", "wc", "2"))
            };

            await thingClient.CreateNewThingsAsync(record.Id, new IThing[] { medication });

            IReadOnlyCollection <Medication> medications = await thingClient.GetThingsAsync <Medication>(record.Id);

            Assert.AreEqual(1, medications.Count);

            Medication returnedMedication = medications.First();

            Assert.AreEqual(medication.Dose.Display, returnedMedication.Dose.Display);
            Assert.AreEqual(medication.Strength.Display, returnedMedication.Strength.Display);
            Assert.AreEqual(medication.Frequency.Display, returnedMedication.Frequency.Display);
            Assert.AreEqual(medication.Route.Text, returnedMedication.Route.Text);
        }
        public async Task GetThingById()
        {
            IHealthVaultSodaConnection connection = HealthVaultConnectionFactory.Current.GetOrCreateSodaConnection(Constants.Configuration);
            IThingClient thingClient = connection.CreateThingClient();
            PersonInfo   personInfo  = await connection.GetPersonInfoAsync();

            HealthRecordInfo record = personInfo.SelectedRecord;

            await DeletePreviousThings(thingClient, record);

            LocalDateTime nowLocal = SystemClock.Instance.GetCurrentInstant().InZone(DateTimeZoneProviders.Tzdb.GetSystemDefault()).LocalDateTime;

            var weight = new Weight(
                new HealthServiceDateTime(nowLocal),
                new WeightValue(81, new DisplayValue(81, "KG", "kg")));

            await thingClient.CreateNewThingsAsync(
                record.Id,
                new List <IThing>
            {
                weight
            });

            Weight remoteWeight = await thingClient.GetThingAsync <Weight>(record.Id, weight.Key.Id);

            Assert.IsNotNull(remoteWeight);
            Assert.AreEqual(weight.Key.Id, remoteWeight.Key.Id);
            Assert.AreEqual(weight.Value.Value, remoteWeight.Value.Value);
        }
Esempio n. 5
0
        private async void Add100BPs_OnClicked(object sender, EventArgs e)
        {
            OutputLabel.Text = "Adding 100 blood pressures...";

            PersonInfo personInfo = await _connection.GetPersonInfoAsync();

            HealthRecordInfo recordInfo  = personInfo.SelectedRecord;
            IThingClient     thingClient = _connection.CreateThingClient();

            var random = new Random();

            var pressures = new List <BloodPressure>();

            for (int i = 0; i < 100; i++)
            {
                pressures.Add(new BloodPressure(
                                  new HealthServiceDateTime(SystemClock.Instance.GetCurrentInstant().InZone(DateTimeZoneProviders.Tzdb.GetSystemDefault()).LocalDateTime),
                                  random.Next(110, 130),
                                  random.Next(70, 90)));
            }

            await thingClient.CreateNewThingsAsync(
                recordInfo.Id,
                pressures);

            OutputLabel.Text = "Done adding blood pressures.";
        }
        public async Task CreateNewThingsReturnsIds()
        {
            IHealthVaultSodaConnection connection = HealthVaultConnectionFactory.Current.GetOrCreateSodaConnection(Constants.Configuration);
            IThingClient thingClient = connection.CreateThingClient();
            PersonInfo   personInfo  = await connection.GetPersonInfoAsync();

            HealthRecordInfo record = personInfo.SelectedRecord;

            await DeletePreviousThings(thingClient, record);

            LocalDateTime nowLocal = SystemClock.Instance.GetCurrentInstant().InZone(DateTimeZoneProviders.Tzdb.GetSystemDefault()).LocalDateTime;

            var bloodGlucose = new BloodGlucose(
                new HealthServiceDateTime(nowLocal),
                new BloodGlucoseMeasurement(
                    4.2,
                    new DisplayValue(4.2, "mmol/L", "mmol-per-l")),
                new CodableValue("Whole blood", "wb", new VocabularyKey("glucose-measurement-type", "wc", "1")));

            var weight = new Weight(
                new HealthServiceDateTime(nowLocal),
                new WeightValue(81, new DisplayValue(81, "KG", "kg")));

            await thingClient.CreateNewThingsAsync(
                record.Id,
                new List <IThing>
            {
                bloodGlucose,
                weight,
            });

            Assert.IsNotNull(bloodGlucose.Key, "Blood glucose was not assigned a key.");
            Assert.IsNotNull(weight.Key, "Weight was not assigned a key.");
        }
Esempio n. 7
0
        public override async Task OnNavigateToAsync()
        {
            await LoadAsync(async() =>
            {
                var person              = await _connection.GetPersonInfoAsync();
                _thingClient            = _connection.CreateThingClient();
                HealthRecordInfo record = person.SelectedRecord;
                _recordId            = record.Id;
                _basicInformation    = (await _thingClient.GetThingsAsync <BasicV2>(_recordId)).FirstOrDefault();
                _personalInformation = (await _thingClient.GetThingsAsync <Personal>(_recordId)).FirstOrDefault();

                ImageSource profileImageSource = await GetImageAsync();

                if (_personalInformation.BirthDate != null)
                {
                    BirthDate = _personalInformation.BirthDate.ToDateTime();
                }
                else
                {
                    BirthDate = DateTime.Now;
                }

                FirstName = _personalInformation.Name?.First ?? string.Empty;
                LastName  = _personalInformation.Name?.Last ?? string.Empty;

                GenderIndex = _basicInformation.Gender != null && _basicInformation.Gender.Value == Gender.Female ? 1 : 0;
                ImageSource = profileImageSource;

                await base.OnNavigateToAsync();
            });
        }
        /// <summary>
        /// Obtains Weight objects from HealthVault
        /// </summary>
        /// <returns></returns>
        public override async Task Initialize(NavigationParams navParams)
        {
            //Save the connection so that we can reuse it for updates later
            _connection = navParams.Connection;

            HealthRecordInfo recordInfo  = (await _connection.GetPersonInfoAsync()).SelectedRecord;
            IThingClient     thingClient = _connection.CreateThingClient();

            if (QueryTimeframe.SelectedIndex == (int)QueryTimeframeEnum.Default)
            {
                //Uses a simple query which specifies the Thing type as the only filter
                Items = await thingClient.GetThingsAsync <Weight>(recordInfo.Id);
            }
            else if (QueryTimeframe.SelectedIndex == (int)QueryTimeframeEnum.Last30d)
            {
                //In this mode, the app specifies a ThingQuery which can be used for functions like
                //filtering, or paging through values
                ThingQuery query = new ThingQuery()
                {
                    EffectiveDateMin = DateTime.Now.AddDays(-30)
                };

                Items = await thingClient.GetThingsAsync <Weight>(recordInfo.Id, query);
            }

            OnPropertyChanged("Items");
            OnPropertyChanged("Latest");

            return;
        }
        private async Task RefreshAsync()
        {
            var person = await _connection.GetPersonInfoAsync();

            IThingClient                 thingClient = _connection.CreateThingClient();
            HealthRecordInfo             record      = person.SelectedRecord;
            IReadOnlyCollection <Weight> items       = await thingClient.GetThingsAsync <Weight>(record.Id);

            RefreshPage(items);
        }
Esempio n. 10
0
        /// <summary>
        /// Updates the BasicV2 thing with the content from the BasicInformation property.
        /// </summary>
        private async void UpdateThing()
        {
            HealthRecordInfo recordInfo  = (await _connection.GetPersonInfoAsync()).SelectedRecord;
            IThingClient     thingClient = _connection.CreateThingClient();

            List <ThingBase> things = new List <ThingBase>();

            things.Add(BasicInformation);

            await thingClient.UpdateThingsAsync(recordInfo.Id, things);
        }
Esempio n. 11
0
        public async Task BasicRecordFields()
        {
            IHealthVaultSodaConnection connection = HealthVaultConnectionFactory.Current.GetOrCreateSodaConnection(Constants.Configuration);
            PersonInfo personInfo = await connection.GetPersonInfoAsync();

            HealthRecordInfo record = personInfo.SelectedRecord;

            Assert.AreEqual("HealthVault SDK Integration Test", record.Name);
            Assert.AreEqual(new Guid("2d4e32e6-9511-42b3-8ac2-5f6524b305a2"), record.Id);
            Assert.AreEqual(RelationshipType.Self, record.RelationshipType);
        }
        public override async Task OnNavigateBackAsync()
        {
            var person = await _connection.GetPersonInfoAsync();

            IThingClient     thingClient           = _connection.CreateThingClient();
            HealthRecordInfo record                = person.SelectedRecord;
            IReadOnlyCollection <Medication> items = await thingClient.GetThingsAsync <Medication>(record.Id);

            UpdateDisplay(items);
            await base.OnNavigateBackAsync();
        }
Esempio n. 13
0
        /// <summary>
        /// Gets the latest BasicV2 object for this user.
        /// </summary>
        /// <param name="recordInfo"></param>
        /// <param name="thingClient"></param>
        /// <returns></returns>
        private async Task GetProfileAsync(HealthRecordInfo recordInfo, IThingClient thingClient)
        {
            BasicInformation = (await thingClient.GetThingsAsync <BasicV2>(recordInfo.Id)).FirstOrDefault <BasicV2>();

            RecordInfo = recordInfo;

            //Binding against an enum from XAML isn't straightforward, so use this workaround instead.
            Gender.ItemsSource = System.Enum.GetValues(typeof(Gender));

            OnPropertyChanged("RecordInfo");
            OnPropertyChanged("BasicInformation");
        }
Esempio n. 14
0
        // Get custom data from HealthVault
        private async void Get_CustomData_OnClick(object sender, RoutedEventArgs e)
        {
            PersonInfo personInfo = await _connection.GetPersonInfoAsync();

            HealthRecordInfo recordInfo  = personInfo.SelectedRecord;
            IThingClient     thingClient = _connection.CreateThingClient();

            IReadOnlyCollection <ApplicationSpecific> healthData = await thingClient.GetThingsAsync <ApplicationSpecific>(recordInfo.Id);

            if (healthData.Count == 0)
            {
                OutputBlock.Text = "No custom data found.";
            }
            else
            {
                List <CustomDataType> customDataTypes = new List <CustomDataType>();

                foreach (ApplicationSpecific customDataType in healthData)
                {
                    CustomDataType customData = new CustomDataType
                    {
                        Values = new List <double>()
                    };

                    var appSpecificXml = customDataType?.ApplicationSpecificXml;
                    if (appSpecificXml.Count <= 0)
                    {
                        continue;
                    }
                    XDocument doc = XDocument.Parse(appSpecificXml[0].CreateNavigator()?.OuterXml);

                    foreach (XElement element in doc.Descendants(CustomDataTypeSubtypeTag))
                    {
                        customData.StartTime = long.Parse(element.Attribute("StartTime").Value);
                        customData.EndTime   = long.Parse(element.Attribute("EndTime").Value);

                        var array = element.Attribute("Values")?.Value.Split(',');
                        if (array == null)
                        {
                            continue;
                        }

                        foreach (var entry in array)
                        {
                            double pressure = double.Parse(entry);
                            customData.Values.Add(pressure);
                        }
                        customDataTypes.Add(customData);
                    }
                }
                OutputBlock.Text = "Custom data found.";
            }
        }
Esempio n. 15
0
        /// <summary>
        /// Retrieves the data model for this page.
        /// </summary>
        /// <returns></returns>
        public override async Task Initialize(NavigationParams navParams)
        {
            //Save the connection so we can make updates later.
            _connection = navParams.Connection;

            HealthRecordInfo recordInfo  = (await _connection.GetPersonInfoAsync()).SelectedRecord;
            IThingClient     thingClient = _connection.CreateThingClient();

            GetProfileAsync(recordInfo, thingClient);

            GetPersonalImageAsync(recordInfo, thingClient);

            return;
        }
        /// <summary>
        /// Minimize Authorize records from person info
        /// </summary>
        /// <param name="webConnectionInfo">WebConnectionInfo</param>
        public static void MinimizePersonInfoAuthorizedRecords(this WebConnectionInfo webConnectionInfo)
        {
            var personInfo = webConnectionInfo.PersonInfo;

            // Minimize person info authorized records keeping only self record
            if (personInfo.AuthorizedRecords.Count > 1)
            {
                HealthRecordInfo selfRecordInfo = personInfo.GetSelfRecord();

                personInfo.AuthorizedRecords = new Dictionary <Guid, HealthRecordInfo> {
                    { selfRecordInfo.Id, selfRecordInfo }
                };

                webConnectionInfo.MinimizedPersonInfoRecords = true;
            }
        }
        public async Task MultipleQueries()
        {
            IHealthVaultSodaConnection connection = HealthVaultConnectionFactory.Current.GetOrCreateSodaConnection(Constants.Configuration);
            IThingClient thingClient = connection.CreateThingClient();
            PersonInfo   personInfo  = await connection.GetPersonInfoAsync();

            HealthRecordInfo record = personInfo.SelectedRecord;

            await DeletePreviousThings(thingClient, record);

            LocalDateTime nowLocal = SystemClock.Instance.GetCurrentInstant().InZone(DateTimeZoneProviders.Tzdb.GetSystemDefault()).LocalDateTime;

            var bloodGlucose = new BloodGlucose(
                new HealthServiceDateTime(nowLocal),
                new BloodGlucoseMeasurement(
                    4.2,
                    new DisplayValue(4.2, "mmol/L", "mmol-per-l")),
                new CodableValue("Whole blood", "wb", new VocabularyKey("glucose-measurement-type", "wc", "1")));

            var weight = new Weight(
                new HealthServiceDateTime(nowLocal),
                new WeightValue(81, new DisplayValue(81, "KG", "kg")));

            await thingClient.CreateNewThingsAsync(
                record.Id,
                new List <IThing>
            {
                bloodGlucose,
                weight,
            });

            var resultSet = await thingClient.GetThingsAsync(record.Id, new[] { new ThingQuery(BloodGlucose.TypeId), new ThingQuery(Weight.TypeId) });

            Assert.AreEqual(2, resultSet.Count);
            var resultList = resultSet.ToList();

            ThingCollection glucoseCollection    = resultList[0];
            var             returnedBloodGlucose = (BloodGlucose)glucoseCollection.First();

            Assert.AreEqual(bloodGlucose.Value.Value, returnedBloodGlucose.Value.Value);

            ThingCollection weightCollection = resultList[1];
            var             returnedWeight   = (Weight)weightCollection.First();

            Assert.AreEqual(weight.Value.Kilograms, returnedWeight.Value.Kilograms);
        }
Esempio n. 18
0
        /// <summary>
        /// Gets the user's PersonalImage Things and then calls GetAndSavePersonalImage to extract the blob,
        /// save to disk, then adds that path to the ImageSource property so the UX can find it.
        /// </summary>
        /// <param name="recordInfo"></param>
        /// <param name="thingClient"></param>
        /// <returns></returns>
        private async Task GetPersonalImageAsync(HealthRecordInfo recordInfo, IThingClient thingClient)
        {
            //Build query
            var query = new ThingQuery(new Guid[] { PersonalImage.TypeId });

            query.View.Sections = ThingSections.Xml | ThingSections.BlobPayload | ThingSections.Signature;

            var things = await thingClient.GetThingsAsync(recordInfo.Id, query);

            if (things.Count > 0)
            {
                Windows.Storage.StorageFile file = await GetAndSavePersonalImage(recordInfo, things);

                ImageSource = file.Path;
                OnPropertyChanged("ImageSource");
            }
        }
Esempio n. 19
0
        public async Task BasicInformationFields()
        {
            IHealthVaultSodaConnection connection = HealthVaultConnectionFactory.Current.GetOrCreateSodaConnection(Constants.Configuration);
            PersonInfo personInfo = await connection.GetPersonInfoAsync();

            HealthRecordInfo record = personInfo.SelectedRecord;

            IThingClient thingClient = connection.CreateThingClient();

            BasicV2 basicInfo = (await thingClient.GetThingsAsync <BasicV2>(record.Id)).First();

            Assert.AreEqual("Redmond", basicInfo.City);
            Assert.AreEqual(1985, basicInfo.BirthYear);
            Assert.AreEqual(Gender.Male, basicInfo.Gender);
            Assert.AreEqual("98052", basicInfo.PostalCode);
            Assert.AreEqual("United States", basicInfo.Country.Text);
            Assert.AreEqual("Washington", basicInfo.StateOrProvince.Text);
        }
Esempio n. 20
0
        private async void SetBP_OnClick(object sender, RoutedEventArgs e)
        {
            PersonInfo personInfo = await _connection.GetPersonInfoAsync();

            HealthRecordInfo recordInfo  = personInfo.SelectedRecord;
            IThingClient     thingClient = _connection.CreateThingClient();

            LocalDateTime nowLocal = _clock.GetCurrentInstant().InZone(_dateTimeZoneProvider.GetSystemDefault()).LocalDateTime;

            await thingClient.CreateNewThingsAsync(
                recordInfo.Id,
                new List <BloodPressure>
            {
                new BloodPressure(new HealthServiceDateTime(nowLocal), 117, 70)
            });

            OutputBlock.Text = "Created blood pressure.";
        }
        private static async Task DeletePreviousThings(IThingClient thingClient, HealthRecordInfo record)
        {
            var query = CreateMultiThingQuery();

            var thingCollection = await thingClient.GetThingsAsync(record.Id, query);

            var thingsToDelete = new List <IThing>();

            foreach (IThing thing in thingCollection)
            {
                thingsToDelete.Add(thing);
            }

            if (thingsToDelete.Count > 0)
            {
                await thingClient.RemoveThingsAsync(record.Id, thingsToDelete);
            }
        }
        public override async Task Initialize(NavigationParams navParams)
        {
            HealthRecordInfo recordInfo  = (await navParams.Connection.GetPersonInfoAsync()).SelectedRecord;
            IThingClient     thingClient = navParams.Connection.CreateThingClient();

            var query = new ThingQuery(new Guid[] { BloodGlucose.TypeId, Weight.TypeId, BloodPressure.TypeId, CholesterolProfile.TypeId,
                                                    LabTestResults.TypeId, Immunization.TypeId, Procedure.TypeId, Allergy.TypeId, Condition.TypeId });

            var items = await thingClient.GetThingsAsync(recordInfo.Id, query);

            //Create a grouped view of the Things by type
            Groups = from colItem in items
                     orderby(colItem as ThingBase).TypeName, (colItem as ThingBase).EffectiveDate descending
            group colItem by(colItem as ThingBase).TypeName into newGroup
            select newGroup;

            OnPropertyChanged("Groups");
        }
Esempio n. 23
0
        public override async Task Initialize(NavigationParams navParams)
        {
            _connection = navParams.Connection;
            HealthRecordInfo recordInfo  = (await _connection.GetPersonInfoAsync()).SelectedRecord;
            IThingClient     thingClient = _connection.CreateThingClient();

            //Set person name for UX
            PersonName = recordInfo.Name;
            OnPropertyChanged("PersonName");

            //Configure navigation frame for the app
            ContentFrame.Navigated += ContentFrame_Navigated;
            SystemNavigationManager.GetForCurrentView().BackRequested += HubPage_BackRequested;

            ContentFrame.Navigate(typeof(NavigationPage), new NavigationParams()
            {
                Connection = _connection
            });
        }
Esempio n. 24
0
        private async void Get_Height_OnClick(object sender, RoutedEventArgs e)
        {
            PersonInfo personInfo = await _connection.GetPersonInfoAsync();

            HealthRecordInfo recordInfo  = personInfo.SelectedRecord;
            IThingClient     thingClient = _connection.CreateThingClient();
            var heights = await thingClient.GetThingsAsync <Height>(recordInfo.Id);

            Height firstHeight = heights.FirstOrDefault();

            if (firstHeight == null)
            {
                OutputBlock.Text = "No height.";
            }
            else
            {
                OutputBlock.Text = firstHeight.Value.Meters.ToString() + "m";
            }
        }
Esempio n. 25
0
        public async Task SimpleWeights()
        {
            IHealthVaultSodaConnection connection = HealthVaultConnectionFactory.Current.GetOrCreateSodaConnection(Constants.Configuration);
            IThingClient thingClient = connection.CreateThingClient();
            PersonInfo   personInfo  = await connection.GetPersonInfoAsync();

            HealthRecordInfo record = personInfo.SelectedRecord;

            await TestUtilities.RemoveAllThingsAsync <Weight>(thingClient, record.Id);

            LocalDateTime nowLocal = SystemClock.Instance.GetCurrentInstant().InZone(DateTimeZoneProviders.Tzdb.GetSystemDefault()).LocalDateTime;

            List <Weight> weightList = new List <Weight>();

            weightList.Add(new Weight(
                               new HealthServiceDateTime(nowLocal.PlusHours(-1)),
                               new WeightValue(81, new DisplayValue(81, "KG", "kg"))));

            weightList.Add(new Weight(
                               new HealthServiceDateTime(nowLocal),
                               new WeightValue(85, new DisplayValue(187, "LBS", "lb"))));

            await thingClient.CreateNewThingsAsync <Weight>(record.Id, weightList);

            IReadOnlyCollection <Weight> retrievedWeights = await thingClient.GetThingsAsync <Weight>(record.Id);

            Assert.AreEqual(2, retrievedWeights.Count);

            var    retrievedWeightsList = retrievedWeights.ToList();
            Weight firstWeight          = retrievedWeightsList[1];
            Weight secondWeight         = retrievedWeightsList[0];

            Assert.AreEqual(81, firstWeight.Value.Kilograms);
            Assert.AreEqual(81, firstWeight.Value.DisplayValue.Value);
            Assert.AreEqual("KG", firstWeight.Value.DisplayValue.Units);
            Assert.AreEqual("kg", firstWeight.Value.DisplayValue.UnitsCode);

            Assert.AreEqual(85, secondWeight.Value.Kilograms);
            Assert.AreEqual(187, secondWeight.Value.DisplayValue.Value);
            Assert.AreEqual("LBS", secondWeight.Value.DisplayValue.Units);
            Assert.AreEqual("lb", secondWeight.Value.DisplayValue.UnitsCode);
        }
Esempio n. 26
0
        private async void Get_BP_OnClick(object sender, RoutedEventArgs e)
        {
            PersonInfo personInfo = await _connection.GetPersonInfoAsync();

            HealthRecordInfo recordInfo  = personInfo.SelectedRecord;
            IThingClient     thingClient = _connection.CreateThingClient();

            var bloodPressures = await thingClient.GetThingsAsync <BloodPressure>(recordInfo.Id);

            BloodPressure firstBloodPressure = bloodPressures.FirstOrDefault();

            if (firstBloodPressure == null)
            {
                OutputBlock.Text = "No blood pressures.";
            }
            else
            {
                OutputBlock.Text = firstBloodPressure.Systolic + "/" + firstBloodPressure.Diastolic;
            }
        }
        public override async Task Initialize(NavigationParams navParams)
        {
            _connection = navParams.Connection;

            HealthRecordInfo recordInfo  = (await _connection.GetPersonInfoAsync()).SelectedRecord;
            IThingClient     thingClient = _connection.CreateThingClient();

            var items = await thingClient.GetThingsAsync <Medication>(recordInfo.Id);

            ResourceLoader loader = new ResourceLoader();

            // Use LINQ to group the medications into current and past groups based on the DateDiscontinued
            Groups = from item in items
                     group item by(item.DateDiscontinued == null?loader.GetString("CurrentMedications") : loader.GetString("PastMedications")) into g
                     select g;

            OnPropertyChanged("Groups");

            return;
        }
Esempio n. 28
0
        /// <summary>
        /// Creates a new Weight object and publishes to HealthVault.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void Add_Tapped(object sender, TappedRoutedEventArgs e)
        {
            const double kgToLbsFactor = 2.20462;
            double       value;
            double       kg;

            if (double.TryParse(NewWeight.Text, out value))
            {
                if (Units.SelectedIndex == 0)
                {
                    kg = value / kgToLbsFactor;
                }
                else
                {
                    kg = value;
                }

                LocalDateTime localNow = SystemClock.Instance.GetCurrentInstant().InZone(DateTimeZoneProviders.Tzdb.GetSystemDefault()).LocalDateTime;

                List <Weight> list = new List <Weight>();
                list.Add(new Weight(
                             new HealthServiceDateTime(localNow),
                             new WeightValue(kg, new DisplayValue(value, (Units.SelectedValue as ComboBoxItem).Content.ToString()))));

                HealthRecordInfo recordInfo  = (await _connection.GetPersonInfoAsync()).SelectedRecord;
                IThingClient     thingClient = _connection.CreateThingClient();
                thingClient.CreateNewThingsAsync <Weight>(recordInfo.Id, list);

                Initialize(new NavigationParams()
                {
                    Connection = _connection
                });
                AddWeightPopup.IsOpen = false;
            }
            else // Show an error message.
            {
                ResourceLoader loader = new ResourceLoader();
                Windows.UI.Popups.MessageDialog messageDialog = new Windows.UI.Popups.MessageDialog(loader.GetString("InvalidWeight"));
                await messageDialog.ShowAsync();
            }
        }
Esempio n. 29
0
        private async void GetUserImage_OnClick(object sender, RoutedEventArgs e)
        {
            PersonInfo personInfo = await _connection.GetPersonInfoAsync();

            HealthRecordInfo recordInfo = personInfo.SelectedRecord;

            IThingClient thingClient = _connection.CreateThingClient();
            ThingQuery   query       = new ThingQuery();

            query.View.Sections = ThingSections.Default | ThingSections.BlobPayload;
            var theThings = await thingClient.GetThingsAsync <PersonalImage>(recordInfo.Id, query);

            Stream imageStream = theThings.First().ReadImage();

            using (MemoryStream memoryStream = new MemoryStream())
            {
                await imageStream.CopyToAsync(memoryStream);

                OutputBlock.Text = $"Image has {memoryStream.Length} bytes";
            }
        }
Esempio n. 30
0
        public async Task UsingDatesInThingsQueryReturnProperly()
        {
            IHealthVaultSodaConnection connection = HealthVaultConnectionFactory.Current.GetOrCreateSodaConnection(Constants.Configuration);
            IThingClient thingClient = connection.CreateThingClient();
            PersonInfo   personInfo  = await connection.GetPersonInfoAsync();

            HealthRecordInfo record = personInfo.SelectedRecord;

            ThingQuery query = new ThingQuery(BloodGlucose.TypeId);
            var        now   = DateTime.UtcNow;

            query.CreatedDateMin    = Instant.FromDateTimeUtc(now.AddDays(-5));
            query.CreatedDateMax    = Instant.FromDateTimeUtc(now.AddDays(-4));
            query.UpdatedDateMin    = Instant.FromDateTimeUtc(now.AddDays(-3));
            query.UpdatedDateMax    = Instant.FromDateTimeUtc(now.AddDays(-2));
            query.UpdatedEndDateMin = LocalDateTime.FromDateTime(now.AddDays(-1));
            query.UpdatedEndDateMax = LocalDateTime.FromDateTime(now);

            var results = await thingClient.GetThingsAsync(record.Id, query);

            Assert.IsNotNull(results);
            Assert.IsNotNull(results.Query);
            Assert.IsNotNull(results.Query.CreatedDateMin);
            Assert.AreEqual(results.Query.CreatedDateMin.Value.ToDateTimeUtc(), now.AddDays(-5));

            Assert.IsNotNull(results.Query.CreatedDateMax);
            Assert.AreEqual(results.Query.CreatedDateMax.Value.ToDateTimeUtc(), now.AddDays(-4));

            Assert.IsNotNull(results.Query.UpdatedDateMin);
            Assert.AreEqual(results.Query.UpdatedDateMin.Value.ToDateTimeUtc(), now.AddDays(-3));

            Assert.IsNotNull(results.Query.UpdatedDateMax);
            Assert.AreEqual(results.Query.UpdatedDateMax.Value.ToDateTimeUtc(), now.AddDays(-2));

            Assert.IsNotNull(results.Query.UpdatedEndDateMin);
            Assert.AreEqual(results.Query.UpdatedEndDateMin.Value, LocalDateTime.FromDateTime(now.AddDays(-1)));

            Assert.IsNotNull(results.Query.UpdatedEndDateMax);
            Assert.AreEqual(results.Query.UpdatedEndDateMax.Value, LocalDateTime.FromDateTime(now));
        }