public override async Task OnNavigateToAsync()
        {
            await LoadAsync(async() =>
            {
                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.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;
        }
Beispiel #3
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();
            });
        }
        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);
        }
Beispiel #5
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);
        }
        private async Task SaveAsync(Medication medication)
        {
            UpdateMedication(medication);

            IThingClient thingClient = _connection.CreateThingClient();
            PersonInfo   personInfo  = await _connection.GetPersonInfoAsync();

            await thingClient.UpdateThingsAsync(personInfo.SelectedRecord.Id, new Collection <Medication>() { medication });

            await NavigationService.NavigateBackAsync();
        }
        public override async Task OnNavigateBackAsync()
        {
            await LoadAsync(async() =>
            {
                IThingClient thingClient = _connection.CreateThingClient();
                PersonInfo personInfo    = await _connection.GetPersonInfoAsync();

                _medication = await thingClient.GetThingAsync <Medication>(personInfo.SelectedRecord.Id, _medication.Key.Id);

                UpdateDisplay();
                await base.OnNavigateBackAsync();
            });
        }
Beispiel #8
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;
        }
Beispiel #9
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
            });
        }
        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;
        }
Beispiel #11
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();
            }
        }
Beispiel #12
0
        private async Task AddWeightAsync()
        {
            try
            {
                bool   isMetric = UnitsPickerIndex == 1;
                double weightNumber;
                if (!double.TryParse(WeightValue, out weightNumber))
                {
                    return;
                }

                double kilograms;
                if (isMetric)
                {
                    kilograms = weightNumber;
                }
                else
                {
                    kilograms = weightNumber / WeightViewModel.KgToLbsFactor;
                }

                List <Weight> weightList = new List <Weight>();
                weightList.Add(new Weight(
                                   new HealthServiceDateTime(SystemClock.Instance.GetCurrentInstant().InZone(DateTimeZoneProviders.Tzdb.GetSystemDefault()).LocalDateTime),
                                   new WeightValue(kilograms, new DisplayValue(weightNumber, isMetric ? "kg" : "lbs"))));

                IThingClient thingClient = _connection.CreateThingClient();
                var          person      = await _connection.GetPersonInfoAsync();

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

                await NavigationService.NavigateBackAsync();
            }
            catch (Exception exception)
            {
                await DisplayAlertAsync(StringResource.ErrorDialogTitle, exception.ToString());
            }
        }
        public override async Task Initialize(NavigationParams navParams)
        {
            _connection = navParams.Connection;

            Guid recordId   = (await _connection.GetPersonInfoAsync()).SelectedRecord.Id;
            var  restClient = _connection.CreateMicrosoftHealthVaultRestApi(recordId);

            try
            {
                var response = await restClient.GetActionPlansAsync();

                //Filter to only recommended or InProgress plans
                Plans = from p in response.Plans
                        where p.Status == "Recommended" || p.Status == "InProgress"
                        select p;

                OnPropertyChanged("Plans");
            }
            catch (Microsoft.Rest.RestException e)
            {
                MessageDialog md = new MessageDialog(e.Message);
                await md.ShowAsync();
            }
        }