Exemple #1
0
 public WeightAddViewModel(
     IHealthVaultConnection connection,
     INavigationService navigationService) : base(navigationService)
 {
     _connection = connection;
     AddCommand  = new Command(async() => await AddWeightAsync());
 }
        /// <summary>
        /// Gets the permissions which the authenticated person
        /// has when using the calling application for the specified item types
        /// in this  record.
        /// </summary>
        /// <param name="connection">
        /// The connection to use to access the data.
        /// </param>
        /// <param name="accessor">
        /// The record to use.
        /// </param>
        /// <param name="healthRecordItemTypeIds">
        /// A collection of unique identifiers to identify the health record
        /// item types, for which the permissions are being queried.
        /// </param>
        /// <returns>
        /// Returns a dictionary of <see cref="ThingTypePermission"/>
        /// with thing types as the keys.
        /// </returns>
        ///
        /// <remarks>
        /// If the list of thing types is empty, an empty dictionary is
        /// returned. If for a thing type, the person has
        /// neither online access nor offline access permissions,
        /// <b> null </b> will be returned for that type in the dictionary.
        /// </remarks>
        ///
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="healthRecordItemTypeIds"/> is <b>null</b>.
        /// </exception>
        ///
        /// <exception cref="HealthServiceException">
        /// If there is an exception during executing the request to HealthVault.
        /// </exception>
        ///
        public virtual async Task <IDictionary <Guid, ThingTypePermission> > QueryPermissionsByTypesAsync(
            IHealthVaultConnection connection,
            HealthRecordAccessor accessor,
            IList <Guid> healthRecordItemTypeIds)
        {
            HealthRecordPermissions recordPermissions = await QueryRecordPermissionsAsync(connection, accessor, healthRecordItemTypeIds).ConfigureAwait(false);

            Collection <ThingTypePermission> typePermissions = recordPermissions.ItemTypePermissions;

            Dictionary <Guid, ThingTypePermission> permissions = new Dictionary <Guid, ThingTypePermission>();

            foreach (Guid typeId in healthRecordItemTypeIds)
            {
                if (!permissions.ContainsKey(typeId))
                {
                    permissions.Add(typeId, null);
                }
            }

            foreach (ThingTypePermission typePermission in typePermissions)
            {
                permissions[typePermission.TypeId] = typePermission;
            }

            return(permissions);
        }
Exemple #3
0
        public override async Task Initialize(NavigationParams navParams)
        {
            _connection = navParams.Connection as IHealthVaultConnection;
            Context     = navParams.Context as ActionPlanInstanceV2;

            OnPropertyChanged("Context");
        }
        /// <summary>
        /// Gets the <see cref="HealthRecordInfo"/> for the records identified
        /// by the specified <paramref name="recordIds"/>.
        /// </summary>
        ///
        /// <param name="connection">The connection to use to perform the operation. This connection
        /// must be authenticated. </param>
        ///
        /// <param name="recordIds">
        /// The unique identifiers for the records to retrieve.
        /// </param>
        ///
        /// <returns>
        /// A collection of the records matching the specified record
        /// identifiers and authorized for the authenticated person.
        /// </returns>
        ///
        /// <remarks>
        /// This method is useful in cases where the application is storing
        /// record identifiers and needs access to the functionality provided
        /// by the object model.
        /// </remarks>
        ///
        public virtual async Task <Collection <HealthRecordInfo> > GetAuthorizedRecordsAsync(
            IHealthVaultConnection connection,
            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);
        }
        /// <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;
        }
        /// <summary>
        /// Creates a client for accessing the Microsoft HealthVault REST API.
        /// </summary>
        /// <param name="connection">The HealthVault connection.</param>
        /// <param name="recordId">The record identifier.</param>
        public static IMicrosoftHealthVaultRestApi CreateMicrosoftHealthVaultRestApi(this IHealthVaultConnection connection, Guid recordId)
        {
            Uri restUrl = Ioc.Get <HealthVaultConfiguration>().RestHealthVaultUrl;
            ServiceClientCredentials credentials = new HealthVaultRestCredentials(connection, recordId);

            return(new MicrosoftHealthVaultRestApi(restUrl, credentials, (connection as IMessageHandlerFactory)?.Create()));
        }
Exemple #7
0
        /// <summary>
        /// Gets the instance where a HealthVault account should be created
        /// for the specified account location.
        /// </summary>
        ///
        /// <param name="connection">
        /// The connection to use to perform the operation.
        /// </param>
        ///
        /// <param name="preferredLocation">
        /// A user's preferred geographical location, used to select the best instance
        /// in which to create a new HealthVault account. If there is a location associated
        /// with the credential that will be used to log into the account, that location
        /// should be used.
        /// </param>
        ///
        /// <remarks>
        /// If no suitable instance can be found, a null value is returned. This can happen,
        /// for example, if the account location is not supported by HealthVault.
        ///
        /// Currently the returned instance IDs all parse to integers, but that is not
        /// guaranteed and should not be relied upon.
        /// </remarks>
        ///
        /// <returns>
        /// A <see cref="HealthServiceInstance"/> object represents the selected instance,
        /// or null if no suitable instance exists.
        /// </returns>
        ///
        /// <exception cref="HealthServiceException">
        /// The HealthVault service returned an error.
        /// </exception>
        ///
        /// <exception cref="ArgumentException">
        /// If <paramref name="preferredLocation"/> is <b>null</b>.
        /// </exception>
        ///
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="connection"/> parameter is <b>null</b>.
        /// </exception>
        public virtual async Task <HealthServiceInstance> SelectInstanceAsync(
            IHealthVaultConnection connection,
            Location preferredLocation)
        {
            Validator.ThrowIfArgumentNull(connection, nameof(connection), Resources.TypeManagerConnectionNull);
            Validator.ThrowIfArgumentNull(preferredLocation, nameof(preferredLocation), Resources.SelectInstanceLocationRequired);

            StringBuilder     requestParameters = new StringBuilder();
            XmlWriterSettings settings          = SDKHelper.XmlUnicodeWriterSettings;

            using (XmlWriter writer = XmlWriter.Create(requestParameters, settings))
            {
                preferredLocation.WriteXml(writer, "preferred-location");
                writer.Flush();
            }

            HealthServiceResponseData responseData = await connection.ExecuteAsync(
                HealthVaultMethods.SelectInstance,
                1,
                requestParameters.ToString()).ConfigureAwait(false);

            XPathExpression infoPath = SDKHelper.GetInfoXPathExpressionForMethod(
                responseData.InfoNavigator,
                "SelectInstance");
            XPathNavigator infoNav = responseData.InfoNavigator.SelectSingleNode(infoPath);

            XPathNavigator instanceNav = infoNav.SelectSingleNode("selected-instance");

            if (instanceNav != null)
            {
                return(HealthServiceInstance.CreateInstance(instanceNav));
            }

            return(null);
        }
Exemple #8
0
        /// <summary>
        /// Gets the definitions for one or more thing type definitions
        /// supported by HealthVault.
        /// </summary>
        ///
        /// <param name="typeIds">
        /// A collection of health item type IDs whose details are being requested. Null
        /// indicates that all health item types should be returned.
        /// </param>
        ///
        /// <param name="sections">
        /// A collection of ThingTypeSections enumeration values that indicate the type
        /// of details to be returned for the specified health item records(s).
        /// </param>
        ///
        /// <param name="imageTypes">
        /// A collection of strings that identify which health item record images should be
        /// retrieved.
        ///
        /// This requests an image of the specified mime type should be returned. For example,
        /// to request a GIF image, "image/gif" should be specified. For icons, "image/vnd.microsoft.icon"
        /// should be specified. Note, not all health item records will have all image types and
        /// some may not have any images at all.
        ///
        /// If '*' is specified, all image types will be returned.
        /// </param>
        ///
        /// <param name="lastClientRefreshDate">
        /// A <see cref="DateTime"/> instance that specifies the time of the last refresh
        /// made by the client.
        /// </param>
        ///
        /// <param name="connection">
        /// A connection to the HealthVault service.
        /// </param>
        ///
        /// <returns>
        /// The type definitions for the specified types, or empty if the
        /// <paramref name="typeIds"/> parameter does not represent a known unique
        /// type identifier.
        /// </returns>
        ///
        /// <remarks>
        /// This method calls the HealthVault service if the types are not
        /// already in the client-side cache.
        /// </remarks>
        ///
        /// <exception cref="ArgumentException">
        /// If <paramref name="typeIds"/> is <b>null</b> and empty, or
        /// <paramref name="typeIds"/> is <b>null</b> and member in <paramref name="typeIds"/> is
        /// <see cref="System.Guid.Empty"/>.
        /// </exception>
        ///
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="connection"/> parameter is <b>null</b>.
        /// </exception>
        ///
        public virtual async Task <IDictionary <Guid, ThingTypeDefinition> > GetHealthRecordItemTypeDefinitionAsync(
            IList <Guid> typeIds,
            ThingTypeSections sections,
            IList <string> imageTypes,
            Instant?lastClientRefreshDate,
            IHealthVaultConnection connection)
        {
            Validator.ThrowIfArgumentNull(connection, nameof(connection), Resources.TypeManagerConnectionNull);

            if ((typeIds != null && typeIds.Contains(Guid.Empty)) ||
                (typeIds != null && typeIds.Count == 0))
            {
                throw new ArgumentException(Resources.TypeIdEmpty, nameof(typeIds));
            }

            if (lastClientRefreshDate != null)
            {
                return(await GetHealthRecordItemTypeDefinitionByDateAsync(
                           typeIds,
                           sections,
                           imageTypes,
                           lastClientRefreshDate.Value,
                           connection).ConfigureAwait(false));
            }

            return(await GetHealthRecordItemTypeDefinitionNoDateAsync(
                       typeIds,
                       sections,
                       imageTypes,
                       connection).ConfigureAwait(false));
        }
 public ThingClient(
     IHealthVaultConnection connection,
     IThingDeserializer thingDeserializer)
 {
     _connection        = connection;
     _thingDeserializer = thingDeserializer;
 }
        /// <summary>
        /// Gets the permissions which the authenticated person
        /// has when using the calling application for the specified item types
        /// in this health record.
        /// </summary>
        /// <param name="connection">
        /// The connection to use to access the data.
        /// </param>
        /// <param name="accessor">
        /// The record to use.
        /// </param>
        /// <param name="healthRecordItemTypeIds">
        /// A collection of uniqueidentifiers to identify the health record
        /// item types, for which the permissions are being queried.
        /// </param>
        /// <returns>
        /// A list of <see cref="ThingTypePermission"/>
        /// objects which represent the permissions that the current
        /// authenticated person has for the HealthRecordItemTypes specified
        /// in the current health record when using the current application.
        /// </returns>
        ///
        /// <remarks>
        /// If the list of thing types is empty, an empty list is
        /// returned. If for a thing type, the person has
        /// neither online access nor offline access permissions,
        /// ThingTypePermission object is not returned for that
        /// thing type.
        /// </remarks>
        ///
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="healthRecordItemTypeIds"/> is <b>null</b>.
        /// </exception>
        ///
        /// <exception cref="HealthServiceException">
        /// If there is an exception during executing the request to HealthVault.
        /// </exception>
        ///
        public virtual async Task <Collection <ThingTypePermission> > QueryPermissionsAsync(
            IHealthVaultConnection connection,
            HealthRecordAccessor accessor,
            IList <Guid> healthRecordItemTypeIds)
        {
            HealthRecordPermissions permissions = await QueryRecordPermissionsAsync(connection, accessor, healthRecordItemTypeIds).ConfigureAwait(false);

            return(permissions.ItemTypePermissions);
        }
        /// <summary>
        /// Sets the application settings for the current application and
        /// person.
        /// </summary>
        ///
        /// <param name="connection">The connection to use to perform the operation. This connection
        /// must be authenticated. </param>
        ///
        /// <param name="applicationSettings">
        /// The application settings XML.
        /// </param>
        ///
        /// <remarks>
        /// This may be <b>null</b> if no application settings have been
        /// stored for the application or user.
        /// </remarks>
        ///
        public virtual async Task SetApplicationSettingsAsync(
            IHealthVaultConnection connection,
            IXPathNavigable applicationSettings)
        {
            string requestParameters =
                GetSetApplicationSettingsParameters(applicationSettings);

            await SetApplicationSettingsAsync(connection, requestParameters).ConfigureAwait(false);
        }
        public WeightViewModel(
            IHealthVaultConnection connection,
            INavigationService navigationService) : base(navigationService)
        {
            _connection = connection;
            AddCommand  = new Command(async() => await GoToAddWeightPageAsync());

            LoadState = LoadState.Loading;
        }
Exemple #13
0
        public ThingDeserializer(
            IHealthVaultConnection connection,
            IThingTypeRegistrar thingTypeRegistrar)
        {
            _connection         = connection;
            _thingTypeRegistrar = thingTypeRegistrar;

            _typeHandlers = _thingTypeRegistrar.RegisteredTypeHandlers;
        }
Exemple #14
0
        /// <summary>
        /// Gets information about the HealthVault service corresponding to the specified
        /// categories.
        /// </summary>
        ///
        /// <param name="connection">The connection to use to perform the operation.</param>
        ///
        /// <param name="responseSections">
        /// A bitmask of one or more <see cref="ServiceInfoSections"/> which specify the
        /// categories of information to be populated in the <see cref="ServiceInfo"/>.
        /// </param>
        ///
        /// <remarks>
        /// Gets the latest information about the HealthVault service. Depending on the specified
        /// <paramref name="responseSections"/>, this will include some or all of:<br/>
        /// - The version of the service.<br/>
        /// - The SDK assembly URLs.<br/>
        /// - The SDK assembly versions.<br/>
        /// - The SDK documentation URL.<br/>
        /// - The URL to the HealthVault Shell.<br/>
        /// - The schema definition for the HealthVault method's request and
        ///   response.<br/>
        /// - The common schema definitions for types that the HealthVault methods
        ///   use.<br/>
        /// - Information about all available HealthVault instances.<br/>
        ///
        /// Retrieving only the sections you need will give a faster response time than
        /// downloading the full response.
        /// </remarks>
        ///
        /// <returns>
        /// A <see cref="ServiceInfo"/> instance that contains some or all of the service version,
        /// SDK assemblies versions and URLs, method information, and so on, depending on which
        /// information categories were specified.
        /// </returns>
        ///
        /// <exception cref="ArgumentNullException">
        /// <paramref name="connection"/> is <b>null</b>.
        /// </exception>
        ///
        /// <exception cref="HealthServiceException">
        /// The HealthVault service returned an error.
        /// </exception>
        ///
        /// <exception cref="UriFormatException">
        /// One or more URL strings returned by HealthVault is invalid.
        /// </exception>
        ///
        public virtual async Task <ServiceInfo> GetServiceDefinitionAsync(
            IHealthVaultConnection connection,
            ServiceInfoSections responseSections)
        {
            Validator.ThrowIfArgumentNull(connection, nameof(connection), Resources.ConnectionNull);
            string requestParams = CreateServiceDefinitionRequestParameters(responseSections, null);

            return(await GetServiceDefinitionAsync(connection, requestParams).ConfigureAwait(false));
        }
Exemple #15
0
        /// <summary>
        /// Generates a new signup code that should be passed to HealthVault Shell in order
        /// to create a new user account.
        /// </summary>
        ///
        /// <param name="connection">The connection to use to perform the operation. This connection
        /// must be application level. </param>
        ///
        /// <returns>
        /// A signup code that can be used to create an account.
        /// </returns>
        ///
        public virtual async Task <string> NewSignupCodeAsync(IHealthVaultConnection connection)
        {
            HealthServiceResponseData responseData = await connection.ExecuteAsync(HealthVaultMethods.NewSignupCode, 1).ConfigureAwait(false);

            XPathExpression infoPath = SDKHelper.GetInfoXPathExpressionForMethod(responseData.InfoNavigator, "NewSignupCode");

            XPathNavigator infoNav = responseData.InfoNavigator.SelectSingleNode(infoPath);

            return(infoNav.SelectSingleNode("signup-code").Value);
        }
        /// <summary>
        /// Gets the information about the person specified.
        /// </summary>
        ///
        /// <param name="connection">The connection to use to perform the operation. This connection
        /// must be authenticated. </param>
        ///
        /// <returns>
        /// Information about the person's HealthVault account.
        /// </returns>
        ///
        /// <remarks>
        /// This method always calls the HealthVault service to get the latest
        /// information. It is recommended that the calling application cache
        /// the return value and only call this method again if it needs to
        /// refresh the cache.
        /// </remarks>
        ///
        /// <exception cref="HealthServiceException">
        /// The HealthVault service returned an error.
        /// </exception>
        ///
        public virtual async Task <PersonInfo> GetPersonInfoAsync(IHealthVaultConnection connection)
        {
            HealthServiceResponseData responseData = await connection.ExecuteAsync(HealthVaultMethods.GetPersonInfo, 1).ConfigureAwait(false);

            XPathExpression personPath = GetPersonXPathExpression(responseData.InfoNavigator);

            XPathNavigator infoNav = responseData.InfoNavigator.SelectSingleNode(personPath);

            return(PersonInfo.CreateFromXml(infoNav));
        }
Exemple #17
0
        /// <summary>
        /// Gets a list of <see cref="HealthRecordUpdateInfo"/> objects for the current application,
        /// that optionally have been updated since a specified date.
        /// </summary>
        ///
        /// <param name="connection">The connection to use to perform the operation. This connection
        /// must be application level. </param>
        ///
        /// <param name="updatedDate">
        /// Date that is used to filter health record IDs according to whether or not they have
        /// been updated since the specified date.
        /// </param>
        ///
        /// <returns>
        /// List of <see cref="HealthRecordUpdateInfo"/> objects filtered by any specified input parameters.
        /// </returns>
        ///
        public virtual async Task <IList <HealthRecordUpdateInfo> > GetUpdatedRecordInfoForApplicationAsync(
            IHealthVaultConnection connection,
            Instant?updatedDate)
        {
            string parameters = GetUpdateDateParameters(updatedDate);

            HealthServiceResponseData responseData = await connection.ExecuteAsync(HealthVaultMethods.GetUpdatedRecordsForApplication, 2, parameters).ConfigureAwait(false);

            return(ParseGetUpdatedRecordsForApplicationResponseHealthRecordUpdateInfos(responseData));
        }
        public MedicationsMainViewModel(
            IHealthVaultConnection connection,
            INavigationService navigationService) : base(navigationService)
        {
            _connection = connection;

            ItemSelectedCommand = new Command <MedicationsSummaryViewRow>(async o => await GoToMedicationsSummaryPageAsync(o.Medication));

            LoadState = LoadState.Loading;
        }
        private async void ExecuteLogin()
        {
            connection = HealthVaultConnectionFactory.Current.GetOrCreateSodaConnection(await GetHealthVaultConfiguration());

            await connection.AuthenticateAsync();

            ((Frame)Window.Current.Content).Navigate(typeof(Views.Navigation.HubPage), new NavigationParams()
            {
                Connection = connection
            });
        }
Exemple #20
0
 internal ThingCollection(
     string name,
     HealthRecordAccessor record,
     ThingQuery query,
     IHealthVaultConnection healthVaultConnection)
 {
     Name       = name;
     Record     = record;
     Query      = query;
     Connection = healthVaultConnection;
 }
        public MedicationsSummaryViewModel(
            Medication medication,
            IHealthVaultConnection connection,
            INavigationService navigationService) : base(navigationService)
        {
            _connection = connection;
            _medication = medication;
            EditCommand = new Command(async() => await GoToEditAsync());

            UpdateDisplay();
        }
Exemple #22
0
        /// <summary>
        /// Creates an instance of a HealthRecordInfo object using
        /// the specified XML.
        /// </summary>
        ///
        /// <param name="connection">
        /// A connection for the current user.
        /// </param>
        ///
        /// <param name="navigator">
        /// The XML containing the record information.
        /// </param>
        ///
        /// <returns>
        /// A new instance of a HealthRecordInfo object populated with the
        /// record information.
        /// </returns>
        ///
        /// <exception cref="ArgumentNullException">
        /// The <paramref name="connection"/> or <paramref name="navigator"/>
        /// parameter is <b>null</b>.
        /// </exception>
        ///
        public static HealthRecordInfo CreateFromXml(
            IHealthVaultConnection connection,
            XPathNavigator navigator)
        {
            Validator.ThrowIfArgumentNull(connection, nameof(connection), Resources.PersonInfoConnectionNull);
            Validator.ThrowIfArgumentNull(navigator, nameof(navigator), Resources.ParseXmlNavNull);

            HealthRecordInfo recordInfo = new HealthRecordInfo();

            recordInfo.ParseXml(navigator);
            return(recordInfo);
        }
        /// <summary>
        /// Gets valid group memberships for a record.
        /// </summary>
        ///
        /// <remarks>
        /// Group membership thing types allow an application to signify that the
        /// record belongs to an application defined group.  A record in the group may be
        /// eligible for special programs offered by other applications, for example.
        /// Applications then need a away to query for valid group memberships.
        /// <br/>
        /// Valid group memberships are those memberships which are not expired, and whose
        /// last updating application is authorized by the last updating person to
        /// read and delete the membership.
        /// </remarks>
        /// <param name="connection">
        /// The connection to use to access the data.
        /// </param>
        /// <param name="accessor">
        /// The record to use.
        /// </param>
        /// <param name="applicationIds">
        /// A collection of unique application identifiers for which to
        /// search for group memberships.  For a null or empty application identifier
        /// list, return all valid group memberships for the record.  Otherwise,
        /// return only those group memberships last updated by one of the
        /// supplied application identifiers.
        /// </param>
        /// <returns>
        /// A List of things representing the valid group memberships.
        /// </returns>
        /// <exception cref="HealthServiceException">
        /// If an error occurs while contacting the HealthVault service.
        /// </exception>
        public virtual async Task <Collection <ThingBase> > GetValidGroupMembershipAsync(
            IHealthVaultConnection connection,
            HealthRecordAccessor accessor,
            IList <Guid> applicationIds)
        {
            StringBuilder parameters = new StringBuilder(128);

            if (applicationIds != null)
            {
                XmlWriterSettings settings = SDKHelper.XmlUnicodeWriterSettings;
                using (XmlWriter writer = XmlWriter.Create(parameters, settings))
                {
                    foreach (Guid guid in applicationIds)
                    {
                        writer.WriteElementString(
                            "application-id",
                            guid.ToString());
                    }
                }
            }

            var thingDeserializer = Ioc.Container.Locate <IThingDeserializer>(
                new
            {
                connection         = connection,
                thingTypeRegistrar = Ioc.Get <IThingTypeRegistrar>()
            });

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

            XPathExpression infoPath =
                SDKHelper.GetInfoXPathExpressionForMethod(
                    responseData.InfoNavigator,
                    "GetValidGroupMembership");

            XPathNavigator infoNav = responseData.InfoNavigator.SelectSingleNode(infoPath);

            Collection <ThingBase> memberships = new Collection <ThingBase>();

            XPathNodeIterator membershipIterator = infoNav.Select("thing");

            if (membershipIterator != null)
            {
                foreach (XPathNavigator membershipNav in membershipIterator)
                {
                    memberships.Add(thingDeserializer.Deserialize(membershipNav.OuterXml));
                }
            }

            return(memberships);
        }
Exemple #24
0
 public MedicationEditViewModel(
     Medication medication,
     IHealthVaultConnection connection,
     INavigationService navigationService)
     : base(navigationService)
 {
     _medication     = medication;
     _connection     = connection;
     DosageType      = medication.Dose?.Display ?? "";
     Strength        = medication.Strength?.Display ?? "";
     ReasonForTaking = medication.Indication?.Text ?? "";
     DateStarted     = DataTypeFormatter.ApproximateDateTimeToDateTime(medication.DateStarted);
     SaveCommand     = new Command(async() => await SaveAsync(medication));
 }
Exemple #25
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;
        }
Exemple #26
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            var navParams = ((NavigationParams)e.Parameter);

            if (navParams != null)
            {
                _connection = navParams.Connection;

                Item = navParams.Context as Medication;
                OnPropertyChanged("Item");
            }
        }
Exemple #27
0
        /// <summary>
        /// Creates a new instance of the <see cref="HealthRecordAccessor"/>
        /// class.
        /// </summary>
        ///
        /// <param name="connection">
        /// An instance of a connection to which the record
        /// operations will be directed.
        /// </param>
        ///
        /// <param name="id">
        /// The unique identifier for the record.
        /// </param>
        ///
        /// <remarks>
        /// This constructor creates a view of a personal health record.
        /// </remarks>
        /// <exception cref="ArgumentNullException">
        /// The <paramref name="connection"/> parameter is <b>null</b>.
        /// </exception>
        ///
        /// <exception cref="ArgumentException">
        /// The <paramref name="id"/> parameter is Guid.Empty.
        /// </exception>
        ///
        public HealthRecordAccessor(
            IHealthVaultConnection connection,
            Guid id)
        {
            Validator.ThrowIfArgumentNull(connection, nameof(connection), Resources.CtorServiceArgumentNull);

            if (id == Guid.Empty)
            {
                throw new ArgumentException(Resources.CtorIDArgumentEmpty, nameof(id));
            }

            Connection = connection;
            Id         = id;
        }
        /// <summary>
        /// Retrieves lists of vocabulary items for the specified
        /// vocabularies and culture.
        /// </summary>
        ///
        /// <param name="connection">
        /// The connection to use for this operation. The connection
        /// must have application capability.
        /// </param>
        ///
        /// <param name="vocabularyKeys">
        /// A list of keys identifying the requested vocabularies.
        /// </param>
        ///
        /// <param name="cultureIsFixed">
        /// HealthVault looks for the vocabulary items for the culture info
        /// specified using <see cref="HealthServiceConnection.Culture"/>.
        /// If <paramref name="cultureIsFixed"/> is set to <b>false</b> and if
        /// items are not found for the specified culture, items for the
        /// default fallback culture are returned. If
        /// <paramref name="cultureIsFixed"/> is set to <b>true</b>,
        /// fallback will not occur, and if items are not found for the
        /// specified culture, empty strings are returned.
        /// </param>
        ///
        /// <returns>
        /// The specified vocabularies and their items, or empty strings.
        /// </returns>
        ///
        /// <exception cref="ArgumentException">
        /// The <paramref name="vocabularyKeys"/> list is empty.
        /// </exception>
        ///
        /// <exception cref="ArgumentNullException">
        /// The <paramref name="vocabularyKeys"/> list is <b>null</b>
        /// or contains a <b>null</b> entry.
        /// </exception>
        ///
        /// <exception cref="HealthServiceException">
        /// There is an error in the server request.
        /// <br></br>
        /// -Or-
        /// <br></br>
        /// One of the requested vocabularies is not found on the server.
        /// <br></br>
        /// -Or-
        /// <br></br>
        /// One of the requested vocabularies does not contain representations
        /// for its items for the specified culture when
        /// <paramref name="cultureIsFixed"/> is <b>true</b>.
        /// <br></br>
        /// -Or-
        /// <br></br>
        /// There is an error loading the vocabulary.
        /// </exception>
        ///
        public virtual async Task <ReadOnlyCollection <Vocabulary> > GetVocabularyAsync(
            IHealthVaultConnection connection,
            IList <VocabularyKey> vocabularyKeys,
            bool cultureIsFixed)
        {
            Validator.ThrowIfArgumentNull(vocabularyKeys, nameof(vocabularyKeys), Resources.VocabularyKeysNullOrEmpty);

            if (vocabularyKeys.Count == 0)
            {
                throw new ArgumentException(Resources.VocabularyKeysNullOrEmpty, nameof(vocabularyKeys));
            }

            var method        = HealthVaultMethods.GetVocabulary;
            int methodVersion = 2;

            StringBuilder     requestParameters = new StringBuilder(256);
            XmlWriterSettings settings          = SDKHelper.XmlUnicodeWriterSettings;

            settings.OmitXmlDeclaration = true;
            settings.ConformanceLevel   = ConformanceLevel.Fragment;

            using (XmlWriter writer = XmlWriter.Create(requestParameters, settings))
            {
                writer.WriteStartElement("vocabulary-parameters");

                for (int i = 0; i < vocabularyKeys.Count; i++)
                {
                    Validator.ThrowIfArgumentNull(vocabularyKeys[i], "vocabularyKeys[i]", Resources.VocabularyKeysNullOrEmpty);

                    vocabularyKeys[i].WriteXml(writer);
                }

                writer.WriteElementString(
                    "fixed-culture",
                    SDKHelper.XmlFromBool(cultureIsFixed));

                writer.WriteEndElement();
                writer.Flush();
            }

            string parameters = requestParameters.ToString();

            HealthServiceResponseData responseData = await connection.ExecuteAsync(method, methodVersion, parameters).ConfigureAwait(false);

            ReadOnlyCollection <Vocabulary> vocabularies
                = CreateVocabulariesFromResponse(method.ToString(), responseData);

            return(vocabularies);
        }
Exemple #29
0
        /// <summary>
        /// Ensures all the authorized people for the application are returned
        /// </summary>
        ///
        /// <param name="connection">Connection</param>
        /// <param name="settings">Settings</param>
        /// <returns>List of persons</returns>
        public virtual async Task <IList <PersonInfo> > EnsureGetAuthorizedPeopleAsync(
            IHealthVaultConnection connection,
            GetAuthorizedPeopleSettings settings)
        {
            var peopleTasks = GetAuthorizedPeopleAsync(connection, settings);
            var people      = new List <PersonInfo>();

            foreach (var personTask in peopleTasks)
            {
                await personTask;
                people.Add(personTask.Result);
            }

            return(people);
        }
Exemple #30
0
        public ProfileViewModel(
            IHealthVaultConnection connection,
            INavigationService navigationService) : base(navigationService)
        {
            _connection = connection;

            SaveCommand = new Command(async() => await SaveProfileAsync());

            Genders = new List <string>
            {
                StringResource.Gender_Male,
                StringResource.Gender_Female,
            };

            LoadState = LoadState.Loading;
        }