/// <summary>
 /// Allows derived classes to construct an instance of themselves given
 /// an instance of the base class.
 /// </summary>
 /// 
 /// <param name="personInfo">
 /// Information about the person for constructing the instance.
 /// </param>
 /// 
 internal PersonInfo(PersonInfo personInfo)
 {
     _connection = personInfo._connection;
     _personId = personInfo._personId;
     _name = personInfo._name;
     _selectedRecordId = personInfo._selectedRecordId;
 }
        /// <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(
            ApplicationConnection connection,
            Guid id)
        {
            Validator.ThrowIfArgumentNull(connection, "connection", "CtorServiceArgumentNull");

            Validator.ThrowArgumentExceptionIf(
                id == Guid.Empty,
                "id",
                "CtorIDArgumentEmpty");

            _connection = connection;
            _recordId = id;
        }
 /// <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 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 HealthRecordItems representing the valid group memberships.
 /// </returns>
 /// <exception cref="HealthServiceException">
 /// If an error occurs while contacting the HealthVault service.
 /// </exception>
 public static Collection<HealthRecordItem> GetValidGroupMembership(
     ApplicationConnection connection,
     HealthRecordAccessor accessor,
     IList<Guid> applicationIds)
 {
     return HealthVaultPlatformRecord.Current.GetValidGroupMembership(connection, accessor, applicationIds);
 }
        /// <summary>
        /// Look up the record that were
        /// previously associated with this alternate id.
        /// </summary>
        /// 
        /// <remarks>
        /// To obtain the person and record info, use <see cref="PersonInfo.GetFromAlternateId"/>.
        /// </remarks>
        /// 
        /// <returns>
        /// A new instance of <see cref="HealthRecordInfo"/> that can be used to access the
        /// record.
        /// </returns>
        ///
        /// <param name="connection">The application connection to use.</param>
        /// <param name="alternateId">The alternateId to look up.</param>
        /// <returns>A HealthRecordInfo that can be used to access the record.</returns>
        /// 
        /// <exception cref="ArgumentNullException">
        /// The alternateId parameter is null.
        /// </exception>
        /// 
        /// <exception cref="ArgumentException">
        /// The alternateId parameter is empty, all whitespace, or more than 255 characters in length.
        /// </exception>
        /// 
        /// <exception cref="HealthServiceException">
        /// The HealthVault service returned an error. 
        /// If the alternate Id is not associated with a person and record id, the ErrorCode property
        /// will be set to AlternateIdNotFound.
        /// </exception>
        /// /// 
        public static HealthRecordInfo GetFromAlternateId(
            ApplicationConnection connection,
            string alternateId)
        {
            PersonInfo personInfo = HealthVaultPlatform.GetPersonAndRecordForAlternateId(connection, alternateId);

            if (personInfo.AuthorizedRecords != null && personInfo.AuthorizedRecords.Count == 1)
            {
                List<HealthRecordInfo> infos = new List<HealthRecordInfo>(personInfo.AuthorizedRecords.Values);
                return infos[0];
            }
            else
            {
                return null;
            }
        }
 /// <summary>
 /// Creates a new instance of the <see cref="HealthRecordInfo"/> class 
 /// for deserialization purposes.
 /// </summary>
 /// 
 /// <param name="connection">
 /// An instance of a <see cref="Microsoft.Health.ApplicationConnection"/> 
 /// to which the record operations are directed.
 /// </param>
 /// 
 /// <remarks>
 /// This constructor is only useful if ParseXml is called.
 /// </remarks>
 /// 
 /// <exception cref="ArgumentNullException">
 /// The <paramref name="connection"/> parameter is <b>null</b>.
 /// </exception>
 /// 
 internal HealthRecordInfo(ApplicationConnection connection)
     : base(connection)
 {
 }
        private void ParseXml(XPathNavigator navigator, bool includeUrl)
        {
            _personId = new Guid(navigator.SelectSingleNode("person-id").Value);

            _name = navigator.SelectSingleNode("name").Value;

            XPathNavigator navAppSettings = navigator.SelectSingleNode("app-settings");

            if (navAppSettings != null)
            {
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(navAppSettings.OuterXml);
                _appSettings = doc;
            }

            XPathNavigator  navSelectedRecordId =
                navigator.SelectSingleNode("selected-record-id");

            if (navSelectedRecordId != null)
            {
                _selectedRecordId = new Guid(navSelectedRecordId.Value);
            }

            XPathNavigator navPreferredCulture =
                navigator.SelectSingleNode("preferred-culture[language != '']");
            if (navPreferredCulture != null)
            {
                _preferredCulture = null;
                XPathNavigator navLanguageCode = navPreferredCulture.SelectSingleNode("language");
                {
                    _preferredCulture = navLanguageCode.Value;

                    // Country code only matters if the language code is present.
                    XPathNavigator navCountryCode = navPreferredCulture.SelectSingleNode("country");
                    if (navCountryCode != null)
                    {
                        _preferredCulture += "-" + navCountryCode.Value;
                    }
                }
            }

            XPathNavigator navPreferredUICulture =
                navigator.SelectSingleNode("preferred-uiculture[language != '']");
            if (navPreferredUICulture != null)
            {
                _preferredUICulture = null;
                XPathNavigator navLanguageCode = navPreferredUICulture.SelectSingleNode("language");
                {
                    _preferredUICulture = navLanguageCode.Value;

                    // Country code only matters if the language code is present.
                    XPathNavigator navCountryCode = navPreferredUICulture.SelectSingleNode("country");
                    if (navCountryCode != null)
                    {
                        _preferredUICulture += "-" + navCountryCode.Value;
                    }
                }
            }

            XPathNavigator connectionNav =
                navigator.SelectSingleNode("connection");
            if (connectionNav != null)
            {
                Guid appId = new Guid(connectionNav.SelectSingleNode("app-id").Value);

                Uri healthServiceUri = null;
                if (includeUrl)
                {
                    healthServiceUri =
                        new Uri(connectionNav.SelectSingleNode("wildcat-url").Value);
                }
                else
                {
                    healthServiceUri =
                        HealthApplicationConfiguration.Current.HealthVaultMethodUrl;
                }

                XPathNavigator credNav = connectionNav.SelectSingleNode("credential");

                if (credNav != null)
                {
                    Credential cred = Credential.CreateFromCookieXml(credNav);

                    _connection = new AuthenticatedConnection(appId, healthServiceUri, cred);
                }

                XPathNavigator compressionNode =
                    connectionNav.SelectSingleNode("request-compression-method");

                if (compressionNode != null)
                {
                    _connection.RequestCompressionMethod = compressionNode.Value;
                }
            }
            else
            {
                Validator.ThrowInvalidIfNull(_connection, "PersonInfoConnectionNull");
            }

            XPathNodeIterator recordsNav = navigator.Select("record");
            foreach (XPathNavigator recordNav in recordsNav)
            {
                // Now see if we can fill in the record information
                HealthRecordInfo record = HealthRecordInfo.CreateFromXml(
                                                ApplicationConnection, recordNav);

                if (record != null)
                {
                    _authorizedRecords.Add(record.Id, record);
                }
            }

            XPathNavigator navMoreRecords = navigator.SelectSingleNode("more-records");
            if (navMoreRecords != null)
            {
                _moreRecords = true;
            }

            XPathNavigator navMoreAppSettings = navigator.SelectSingleNode("more-app-settings");
            if (navMoreAppSettings != null)
            {
                _moreAppSettings = true;
            }
        }
        private HealthRecordItemDataTableView ApplyEffectiveView(
            ApplicationConnection connection)
        {
            HealthRecordItemDataTableView effectiveView =
                HealthRecordItemDataTableView.MultipleTypeTable;

            HealthRecordItemTypeDefinition typeDefinition = null;

            if (Filter.TypeIds.Count == 1 &&
                View != HealthRecordItemDataTableView.MultipleTypeTable)
            {
                typeDefinition =
                    ItemTypeManager.GetHealthRecordItemTypeDefinition(
                        this.Filter.TypeIds[0],
                        connection);

                if (typeDefinition != null &&
                    typeDefinition.ColumnDefinitions.Count > 0)
                {
                    effectiveView
                        = HealthRecordItemDataTableView.SingleTypeTable;
                    _singleTypeDefinition = typeDefinition;

                    foreach (
                        ItemTypeDataColumn column in
                        typeDefinition.ColumnDefinitions)
                    {
                        _displayColumns.Add(
                            column.ColumnName, column.Clone());
                    }

                    this.Filter.View.TransformsToApply.Clear();
                    this.Filter.View.TransformsToApply.Add("stt");
                }
            }

            if (_singleTypeDefinition == null)
            {
                typeDefinition =
                    ItemTypeManager.GetBaseHealthRecordItemTypeDefinition(
                        connection);

                effectiveView
                    = HealthRecordItemDataTableView.MultipleTypeTable;

                foreach (
                    ItemTypeDataColumn column in
                    typeDefinition.ColumnDefinitions)
                {
                    _displayColumns.Add(column.ColumnName, column.Clone());
                }

                this.Filter.View.TransformsToApply.Clear();
                this.Filter.View.TransformsToApply.Add("mtt");
            }

            return effectiveView;
        }
 /// <summary>
 /// Updates the application's configuration in HealthVault.
 /// </summary>
 /// 
 /// <param name="connection">
 /// The connection to use to make the update.
 /// </param>
 /// 
 /// <param name="applicationInfo">
 /// The updated <see cref="ApplicationInfo"/> instance.
 /// </param>
 /// 
 /// <remarks>
 /// This method makes a remote call to the HealthVault service.
 /// The calling application in the <paramref name="connection"/> must be the same as
 /// the application specified by this ApplicationInfo instance or its master application.
 /// Note, this update will replace all configuration elements for the application. It is 
 /// advised that <see cref="ApplicationProvisioning.Provisioner.GetApplication"/> is 
 /// called to retrieve the existing application configuration before changing values and 
 /// calling Update.
 /// </remarks>
 /// 
 /// <exception cref="ArgumentNullException">
 /// If <paramref name="connection"/> is <b>null</b>.
 /// </exception>
 /// 
 /// <exception cref="HealthServiceException">
 /// The HealthVault service returns an error.
 /// </exception>
 /// 
 public static void UpdateChildApplication(
     ApplicationConnection connection,
     ApplicationInfo applicationInfo)
 {
     HealthVaultPlatformProvisioning.Current.UpdateChildApplication(connection, applicationInfo);
 }
 /// <summary>
 /// Updates the specified health record items in one batch call to 
 /// the service.
 /// </summary>
 /// 
 /// <param name="connection">
 /// The connection to use to access the data.
 /// </param>
 /// 
 /// <param name="accessor">
 /// The record to use.
 /// </param>
 /// 
 /// <param name="itemsToUpdate">
 /// The health record items to be updated.
 /// </param>
 /// 
 /// <remarks>
 /// Only new items are updated with the appropriate unique identifier. 
 /// All other sections must be updated manually.
 /// <br/><br/>
 /// This method accesses the HealthVault service across the network.
 /// </remarks>
 /// 
 /// <exception cref="ArgumentNullException">
 /// The <paramref name="itemsToUpdate"/> parameter is <b>null</b>.
 /// </exception>
 /// 
 /// <exception cref="ArgumentException">
 /// The <paramref name="itemsToUpdate"/> contains a <b>null</b> member or
 /// a <see cref="HealthRecordItem"/> instance that does not have an ID.
 /// </exception>
 ///
 /// <exception cref="HealthServiceException">
 /// The HealthVault service returned an error.
 /// The exception's Error property will contain the index of the
 /// item on which the failure occurred in the ErrorInfo property. If any failures occur, 
 /// no items will have been updated.
 /// </exception>
 /// 
 public static void UpdateItems(
     ApplicationConnection connection,
     HealthRecordAccessor accessor,
     IList<HealthRecordItem> itemsToUpdate)
 {
     HealthVaultPlatformItem.Current.UpdateItems(connection, accessor, itemsToUpdate);
 }
 /// <summary>
 /// Marks the specified health record item as deleted.
 /// </summary>
 /// 
 /// <param name="connection">
 /// The connection to use to access the data.
 /// </param>
 /// 
 /// <param name="accessor">
 /// The record to use.
 /// </param>
 /// 
 /// <param name="itemsToRemove">
 /// The unique item identifiers of the items to remove.
 /// </param>
 /// 
 /// <remarks>
 /// This method accesses the HealthVault service across the network.
 /// <br/><br/>
 /// Health record items are never completely deleted. They are marked 
 /// as deleted and are ignored for most normal operations. Items can 
 /// be undeleted by contacting customer service.
 /// </remarks>
 /// 
 /// <exception cref="ArgumentException">
 /// The <paramref name="itemsToRemove"/> parameter is empty.
 /// </exception>
 /// 
 /// <exception cref="HealthServiceException">
 /// Errors removed the health record items from the server.
 /// The exception's Error property will contain the index of the
 /// item on which the failure occurred in the ErrorInfo property. If any failures occur, 
 /// no items will have been removed.
 /// </exception>
 /// 
 public static void RemoveItems(
     ApplicationConnection connection,
     HealthRecordAccessor accessor,
     IList<HealthRecordItemKey> itemsToRemove)
 {
     HealthVaultPlatformItem.Current.RemoveItems(connection, accessor, itemsToRemove);
 }
 /// <summary>
 /// Removes the saved open query from the server.
 /// </summary>
 /// 
 /// <param name="connection">
 /// The connection instance to use to remove the <see cref="OpenQuery"/>.
 /// </param>
 /// 
 /// <param name="id">
 /// The id of the open query to remove.
 /// </param>
 /// 
 /// <remarks>
 /// The person authenticated with the <paramref name="connection"/> 
 /// must have permission to remove the open query.
 /// </remarks>
 /// 
 /// <exception cref="ArgumentNullException">
 /// The <paramref name="connection"/> parameter is <b>null</b>.
 /// </exception>
 /// 
 /// <exception cref="HealthServiceException">
 /// An error occurred when HealthVault processed the request.
 /// </exception>
 /// 
 public static void RemoveOpenQuery(
     ApplicationConnection connection,
     Guid id)
 {
     HealthVaultPlatformOpenQuery.Current.RemoveOpenQuery(connection, id);
 }
 /// <summary>
 /// Releases the authorization of the application on the health record.
 /// </summary>
 /// 
 /// <param name="connection">
 /// The connection to use to access the data.
 /// </param>
 /// 
 /// <param name="accessor">
 /// The record to use.
 /// </param>
 /// 
 /// <exception cref="HealthServiceException">
 /// Errors during the authorization release.
 /// </exception>
 /// 
 /// <remarks>
 /// Once the application releases the authorization to the health record, 
 /// calling any methods of this <see cref="HealthRecordAccessor"/> will result 
 /// in a <see cref="HealthServiceAccessDeniedException"/>."
 /// </remarks>
 public static void RemoveApplicationAuthorization(
     ApplicationConnection connection,
     HealthRecordAccessor accessor)
 {
     HealthVaultPlatformRecord.Current.RemoveApplicationAuthorization(connection, accessor);
 }
 /// <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="HealthRecordItemTypePermission"/> 
 /// with health record item types as the keys. 
 /// </returns>
 /// 
 /// <remarks> 
 /// If the list of health record item types is empty, an empty dictionary is 
 /// returned. If for a health record item 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 static IDictionary<Guid, HealthRecordItemTypePermission> QueryPermissionsByTypes(
     ApplicationConnection connection,
     HealthRecordAccessor accessor,
     IList<Guid> healthRecordItemTypeIds)
 {
     return HealthVaultPlatformRecord.Current.QueryPermissionsByTypes(connection, accessor, healthRecordItemTypeIds);
 }
 /// <summary>
 /// Creates a new open query using the specified 
 /// connection, definition, expiration time,
 /// personal identification number (PIN), description, and XSL.
 /// </summary>
 /// 
 /// <param name="connection">
 /// An <see cref="ApplicationConnection"/> instance that creates the 
 /// new open query.
 /// </param>
 /// 
 /// <param name="searcher">
 /// A <see cref="HealthRecordSearcher"/> instance that defines the open query.
 /// </param>
 ///
 /// <param name="expires">
 /// The number of minutes the query will expire from the creation time.
 /// A value of Int32.MaxValue denotes that the query does not expire.
 /// </param>
 ///
 /// <param name="pinCode">
 /// The PIN that protects the query.  
 /// </param>
 ///
 /// <param name="note">
 /// The note describing the query.
 /// </param>
 /// 
 /// <param name="finalXsl">
 /// The XSL that transforms the results of the query when the 
 /// <see cref="OpenQuery"/> is invoked.
 /// </param>
 /// 
 /// <returns>
 /// An <see cref="OpenQuery"/> instance that represents the newly created query.
 /// </returns>
 /// 
 /// <remarks>
 /// The creation of an open query makes public the data returned by that 
 /// query. However, the query URL must be known to retrieve the data.
 /// </remarks>
 /// 
 /// <exception cref="ArgumentNullException">
 /// The <paramref name="connection"/> or <paramref name="searcher"/> 
 /// parameter is <b>null</b>.
 /// </exception>
 /// 
 /// 
 /// <exception cref="ArgumentException">
 /// The <paramref name="searcher"/> parameter contains no valid search
 /// filters or the <paramref name="pinCode"/> parameter is <b>null</b> 
 /// or empty.
 /// </exception>
 /// 
 /// <exception cref="HealthServiceException">
 /// An error occurred when HealthVault processed the request.
 /// </exception>
 /// 
 public static OpenQuery NewOpenQuery(
     ApplicationConnection connection,
     HealthRecordSearcher searcher,
     int expires,
     string pinCode,
     string note,
     string finalXsl)
 {
     return HealthVaultPlatformOpenQuery.Current.NewOpenQuery(
         connection,
         searcher,
         expires,
         pinCode,
         note,
         finalXsl);
 }
 /// <summary>
 /// Updates the application's configuration in HealthVault.
 /// </summary>
 /// 
 /// <param name="connection">
 /// The connection to use to call HealthVault.
 /// </param>
 /// 
 /// <remarks>
 /// This method makes a remote call to the HealthVault service.
 /// The calling application in the <paramref name="connection"/> must be the same as
 /// the application specified by this ApplicationInfo instance or its master application.
 /// Note, this update will replace all configuration elements for the application. It is 
 /// advised that <see cref="ApplicationProvisioning.Provisioner.GetApplication"/> is 
 /// called to retrieve the existing application configuration before changing values and 
 /// calling Update.
 /// </remarks>
 /// 
 /// <exception cref="ArgumentNullException">
 /// If <paramref name="connection"/> is <b>null</b>.
 /// </exception>
 /// 
 /// <exception cref="InvalidOperationException">
 /// If <see cref="Id"/> is <see cref="Guid.Empty"/>.
 /// </exception>
 /// 
 /// <exception cref="HealthServiceException">
 /// The HealthVault service returns an error.
 /// </exception>
 /// 
 public void Update(ApplicationConnection connection)
 {
     HealthVaultPlatform.UpdateChildApplication(connection, this);
 }
 /// <summary>
 /// Disassociates an alternate id with a record.
 /// </summary>
 /// 
 /// <param name="connection">
 /// The connection to use to access the data.
 /// </param>
 /// 
 /// <param name="accessor">
 /// The record to use.
 /// </param>
 /// 
 /// <param name="alternateId">
 /// The alternate id.
 /// </param>
 /// 
 /// <remarks>
 /// This method accesses the HealthVault service across the network.
 /// </remarks>
 /// 
 /// <exception cref="ArgumentNullException">
 /// The connection, accessor, or alternateId parameters are null
 /// </exception>
 /// 
 /// <exception cref="ArgumentException">
 /// The alternateId parameter is empty, all whitespace, or more than 255 characters in length.
 /// </exception>
 /// 
 /// <exception cref="HealthServiceException">
 /// The HealthVault service returned an error. 
 /// If the alternate Id is not associated with a person and record id, the ErrorCode property
 /// will be set to AlternateIdNotFound.
 /// </exception>
 /// 
 public static void DisassociateAlternateId(
     ApplicationConnection connection,
     HealthRecordAccessor accessor,
     string alternateId)
 {
     HealthVaultPlatformAlternateId.Current.DisassociateAlternateId(connection, accessor, alternateId);
 }
 /// <summary> 
 /// Fills in the data table with data from the HealthVault service.
 /// </summary>
 /// 
 /// <param name="recordId"> 
 /// The unique health record identifier to get the data from.
 /// </param>
 /// 
 /// <param name="connection"> 
 /// The connection to the HealthVault service to use.
 /// </param>
 /// 
 /// <remarks>
 /// This method makes a web-method call to the HealthVault service.
 /// </remarks>
 /// 
 /// <exception cref="HealthServiceException">
 /// An error occurred while accessing the HealthVault service.
 /// </exception>
 /// 
 public void GetData(
     Guid recordId,
     ApplicationConnection connection)
 {
     HealthRecordAccessor record =
         new HealthRecordAccessor(connection, recordId);
     GetData(record);
 }
 /// <summary>
 /// Gets the list of alternate IDs that are associated with a record.
 /// </summary>
 /// 
 /// <param name="connection">
 /// The connection to use to access the data.
 /// </param>
 /// 
 /// <param name="accessor">
 /// The record to use.
 /// </param>
 /// 
 /// <remarks>
 /// This method accesses the HealthVault service across the network.
 /// </remarks>
 /// 
 /// <exception cref="HealthServiceException">
 /// The HealthVault service returned an error. 
 /// If the alternate Id is not associated with a person and record id, the ErrorCode property
 /// will be set to AlternateIdNotFound.
 /// </exception>
 /// 
 public static Collection<string> GetAlternateIds(
     ApplicationConnection connection,
     HealthRecordAccessor accessor)
 {
     return HealthVaultPlatformAlternateId.Current.GetAlternateIds(connection, accessor);
 }
 /// <summary>
 /// Constructs a HealthRecordAccessor for deserialization purposes.
 /// </summary>
 /// 
 /// <param name="connection">
 /// An instance of a connection to which the record 
 /// operations will be directed.
 /// </param>
 /// 
 /// <remarks>
 /// This constructor is useful only if ParseXml is called.
 /// </remarks>
 /// 
 /// <exception cref="ArgumentNullException">
 /// If <paramref name="connection"/> is <b>null</b>.
 /// </exception>
 /// 
 internal HealthRecordAccessor(
     ApplicationConnection connection)
 {
     _connection = connection;
 }
 /// <summary>
 /// Gets information about people authorized for an application.
 /// </summary>                
 /// 
 /// <remarks>
 /// The returned IEnumerable iterator will access the HealthVault service 
 /// across the network. See <see cref="GetAuthorizedPeopleSettings"/> for applicable 
 /// settings.
 /// </remarks>
 /// 
 /// <param name="connection">The connection to use to perform the operation. This connection
 /// must be application-level. </param>
 ///
 /// <param name="settings">
 /// The <see cref="GetAuthorizedPeopleSettings" /> object used to configure the 
 /// IEnumerable iterator returned by this method.
 /// </param>
 /// 
 /// <returns>
 /// An IEnumerable iterator of <see cref="PersonInfo"/> objects representing 
 /// people authorized for the application.
 /// </returns>        
 /// 
 /// <exception cref="HealthServiceException">
 /// The HealthVault service returned an error. The retrieval can be retried from the 
 /// current position by calling this method again and using the last successfully 
 /// retrieved person Id for <see cref="GetAuthorizedPeopleSettings.StartingPersonId"/>.        
 /// </exception>
 /// 
 /// <exception cref="ArgumentNullException">
 /// <paramref name="settings"/> is null.
 /// </exception>
 /// 
 public static IEnumerable<PersonInfo> GetAuthorizedPeople(
     ApplicationConnection connection,
     GetAuthorizedPeopleSettings settings)
 {
     return HealthVaultPlatformApplication.Current.GetAuthorizedPeople(connection, settings);
 }
 /// <summary>
 /// Look up the person and record that were
 /// previously associated with this alternate id.
 /// </summary>
 /// 
 /// <remarks>
 /// To obtain the record info only, use <see cref="HealthRecordInfo.GetFromAlternateId"/>.
 /// </remarks>
 /// 
 /// <returns>
 /// A new instance of <see cref="PersonInfo"/> containing information
 /// about the associated person and record.
 /// </returns>
 ///
 /// <param name="connection">The application connection to use.</param>
 /// <param name="alternateId">The alternateId to look up.</param>
 /// <returns>A <see cref="PersonInfo"/> with information 
 /// about the person and record.</returns>
 /// 
 /// <exception cref="ArgumentNullException">
 /// The connection, alternateId parameters are null.
 /// </exception>
 /// 
 /// <exception cref="ArgumentException">
 /// The alternateId parameter is empty, all whitespace, or more than 255 characters in length.
 /// </exception>
 /// 
 /// <exception cref="HealthServiceException">
 /// The HealthVault service returned an error. 
 /// If the alternate Id is not associated with a person and record id, the ErrorCode property
 /// will be set to AlternateIdNotFound.
 /// </exception>
 /// 
 public static PersonInfo GetFromAlternateId(
     ApplicationConnection connection,
     string alternateId)
 {
     return HealthVaultPlatform.GetPersonAndRecordForAlternateId(connection, alternateId);
 }
 /// <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 static Collection<HealthRecordInfo> GetAuthorizedRecords(
     ApplicationConnection connection,
     IList<Guid> recordIds)
 {
     return HealthVaultPlatformPerson.Current.GetAuthorizedRecords(connection, recordIds);
 }
        /// <summary>
        /// Creates a new instance of the PersonInfo class using
        /// the specified XML.
        /// </summary>
        /// 
        /// <param name="connection">
        /// An <see cref="ApplicationConnection"/> for the current user. The 
        /// connection can be optionally supplied, but it is overwritten if 
        /// the connection information is in the XML.
        /// </param>
        /// 
        /// <param name="navigator">
        /// The XML containing the person information.
        /// </param>
        /// 
        /// <returns>
        /// A new instance of <see cref="PersonInfo"/> populated with the
        /// person information.
        /// </returns>
        /// 
        /// <exception cref="ArgumentNullException">
        /// The <paramref name="navigator"/> parameter is <b>null</b> or 
        /// <paramref name="connection"/> is <b>null</b> and the XML does not 
        /// contain the connection information.
        /// </exception>
        /// 
        internal static PersonInfo CreateFromXmlExcludeUrl(
            ApplicationConnection connection,
            XPathNavigator navigator)
        {
            Validator.ThrowIfNavigatorNull(navigator);

            PersonInfo personInfo = new PersonInfo(connection);
            personInfo.ParseXmlExcludeUrl(navigator);
            return personInfo;
        }
 /// <summary>
 /// Gets the health record items that match the filters as specified by 
 /// the properties of this class.
 /// </summary>
 /// 
 /// <param name="connection">
 /// The connection to use to access the data.
 /// </param>
 /// 
 /// <param name="accessor">
 /// The record to use.
 /// </param>
 /// 
 /// <param name="searcher">
 /// The searcher that defines what items to return. .
 /// </param>
 /// 
 /// <returns>
 /// A collection of health record items that match the applied filters.
 /// </returns>
 /// 
 /// <remarks>
 /// This method accesses the HealthVault service across the network.
 /// </remarks>
 /// 
 /// <exception cref="HealthServiceException">
 /// The response from the server was anything but 
 /// <see cref="HealthServiceStatusCode.Ok"/>.
 /// -or-
 /// <see cref="Microsoft.Health.HealthRecordSearcher.Filters"/> is empty
 /// or contains invalid filters.
 /// </exception>
 /// 
 public static ReadOnlyCollection<HealthRecordItemCollection> GetMatchingItems(
     ApplicationConnection connection,
     HealthRecordAccessor accessor,
     HealthRecordSearcher searcher)
 {
     return HealthVaultPlatformItem.Current.GetMatchingItems(connection, accessor, searcher);
 }
 /// <summary>
 /// Constructs an empty <see cref="PersonInfo"/> object which can be used to 
 /// deserialize person info XML.
 /// </summary>
 /// 
 /// <param name="connection">
 /// The connection the <see cref="PersonInfo"/> object should use for operations
 /// once it has been deserialized.
 /// </param>
 /// 
 /// <exception cref="ArgumentNullException">
 /// The <paramref name="connection"/> is <b>null</b>.
 /// </exception>
 /// 
 internal PersonInfo(ApplicationConnection connection)
 {
     _connection = connection;
 }
 /// <summary>
 /// Gets the health record items that match the filters as specified by 
 /// the properties of this class.
 /// </summary>
 /// 
 /// <param name="connection">
 /// The connection to use to access the data.
 /// </param>
 /// 
 /// <param name="accessor">
 /// The record to use.
 /// </param>
 /// 
 /// <param name="searcher">
 /// The searcher that defines what items to return.
 /// </param>
 /// 
 /// <returns>
 /// An XPathNavigator representing the raw results of the search.
 /// </returns>
 /// 
 /// <remarks>
 /// This method accesses the HealthVault service across the network.
 /// <br/><br/>
 /// This method is typically used when the calling application wants to
 /// handle the raw health record item XML directly instead of using the 
 /// object model.
 /// </remarks>
 /// 
 public static XPathNavigator GetMatchingItemsRaw(
     ApplicationConnection connection,
     HealthRecordAccessor accessor,
     HealthRecordSearcher searcher)
 {
     return HealthVaultPlatformItem.Current.GetMatchingItemsRaw(connection, accessor, searcher);
 }
        /// <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 new HealthRecordInfo CreateFromXml(
            ApplicationConnection connection,
            XPathNavigator navigator)
        {
            Validator.ThrowIfArgumentNull(connection, "connection", "PersonInfoConnectionNull");
            Validator.ThrowIfArgumentNull(navigator, "navigator", "ParseXmlNavNull");

            HealthRecordInfo recordInfo = new HealthRecordInfo(connection);
            recordInfo.ParseXml(navigator);
            return recordInfo;
        }
 /// <summary>
 /// Gets the health record items that match the filters as specified by 
 /// the properties of this class.
 /// </summary>
 /// 
 /// <param name="connection">
 /// The connection to use to access the data.
 /// </param>
 /// 
 /// <param name="accessor">
 /// The record to use.
 /// </param>
 /// 
 /// <param name="searcher">
 /// The searcher that defines what items to return.
 /// </param>
 /// 
 /// <returns>
 /// An XmlReader representing the raw results of the search.
 /// </returns>
 /// 
 /// <remarks>
 /// This method accesses the HealthVault service across the network.
 /// <br/><br/>
 /// This method is typically used when the calling application wants to
 /// handle the raw health record item XML directly instead of using the 
 /// object model.
 /// </remarks>
 /// 
 public static XmlReader GetMatchingItemsReader(
     ApplicationConnection connection,
     HealthRecordAccessor accessor,
     HealthRecordSearcher searcher)
 {
     return HealthVaultPlatformItem.Current.GetMatchingItemsReader(connection, accessor, searcher);
 }
 /// <summary>
 /// Creates a new instance of the <see cref="HealthRecordInfo"/> class, 
 /// providing a new view of a personal health record.
 /// </summary>
 /// 
 /// <param name="connection">
 /// An instance of a <see cref="Microsoft.Health.ApplicationConnection"/> 
 /// to which the record operations are directed.
 /// </param>
 /// 
 /// <param name="id">
 /// The unique identifier for the record.
 /// </param>
 /// 
 /// <remarks>
 /// With this constructor, none of the data held in the properties
 /// is valid except the 
 /// <see cref="Microsoft.Health.HealthRecordAccessor.Id"/> 
 /// property. The ID is not validated with the service and the data
 /// is not retrieved until 
 /// <see cref="Microsoft.Health.HealthRecordInfo.Refresh"/>
 /// is called. However, any of the methods can be called without 
 /// Update being called.
 /// </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 HealthRecordInfo(
     ApplicationConnection connection,
     Guid id)
     : base(connection, id)
 {
 }
 /// <summary>
 /// Gets the health record items specified by the 
 /// <see cref="HealthRecordSearcher"/> and runs them through the specified 
 /// transform.
 /// </summary>
 /// 
 /// <param name="connection">
 /// The connection to use to access the data.
 /// </param>
 /// 
 /// <param name="accessor">
 /// The record to use.
 /// </param>
 /// 
 /// <param name="searcher">
 /// The searcher that defines what items to return.
 /// </param>
 /// 
 /// <param name="transform">
 /// A URL to a transform to run on the resulting XML. This can be
 /// a fully-qualified URL or the name of one of the standard XSLs
 /// provided by the HealthVault system.
 /// </param>
 /// 
 /// <returns>
 /// The string resulting from performing the specified transform on
 /// the XML representation of the items.
 /// </returns>
 /// 
 /// <remarks>
 /// This method accesses the HealthVault service across the network.
 /// <br/><br/>
 /// Any call to HealthVault may specify a transform to be run on the
 /// response XML. The transform can be specified as a XSL fragment or
 /// a well-known transform tag provided by the HealthVault service. If a
 /// XSL fragment is specified, it gets compiled and cached on the server.
 /// <br/>
 /// <br/>
 /// A final-xsl is useful when you want to convert the result from XML to
 /// HTML so that you can display the result directly in a web page.
 /// You may also use it to generate other data formats like CCR, CCD, CSV,
 /// RSS, etc.
 /// <br/>
 /// <br/>
 /// Transform fragments cannot contain embedded script. The following set
 /// of parameters are passed to all final-xsl transforms:<br/>
 /// <ul>
 ///     <li>currentDateTimeUtc - the date and time just before the transform 
 ///     started executing</li>
 ///     <li>requestingApplicationName - the name of the application that
 ///     made the request to HealthVault.</li>
 ///     <li>countryCode - the ISO 3166 country code from the request.</li>
 ///     <li>languageCode - the ISO 639-1 language code from the request.</li>
 ///     <li>personName - the name of the person making the request.</li>
 ///     <li>recordName - if the request identified a HealthVault record to 
 ///     be used, this parameter contains the name of that record.</li>
 /// </ul>
 /// </remarks>
 /// 
 /// <exception cref="ArgumentException">
 /// The <paramref name="transform"/> parameter is <b>null</b> or empty.
 /// </exception>
 /// 
 /// <exception cref="ArgumentException">
 /// <see cref="Microsoft.Health.HealthRecordView.Sections"/> does not
 /// contain the XML section in the view.
 /// </exception>
 /// 
 /// <exception cref="HealthServiceException">
 /// There is a failure retrieving the items.
 /// -or-
 /// No filters have been specified.
 /// </exception>
 /// 
 public static string GetTransformedItems(
     ApplicationConnection connection,
     HealthRecordAccessor accessor,
     HealthRecordSearcher searcher,
     string transform)
 {
     return HealthVaultPlatformItem.Current.GetTransformedItems(connection, accessor, searcher, transform);
 }