/// <summary> /// Gets the connections for the application that people have accepted since the specified /// date. /// </summary> /// /// <param name="connection"> /// The application's connection to HealthVault. /// </param> /// /// <param name="validatedSince"> /// Connections that have been validated since this date will be returned. The date passed /// should be in UTC time. /// </param> /// /// <returns> /// A collection of the connections that people have accepted. /// </returns> /// /// <remarks> /// Validated connect requests are removed by HealthVault after 90 days. It is advised /// that applications call <see cref="GetValidatedPatientConnections(Microsoft.Health.Web.OfflineWebApplicationConnection, DateTime)"/> /// daily or weekly to ensure that all validated connect requests are retrieved. /// </remarks> /// /// <exception cref="ArgumentNullException"> /// If <paramref name="connection"/> is <b>null</b>. /// </exception> /// public virtual Collection<ValidatedPatientConnection> GetValidatedPatientConnections( OfflineWebApplicationConnection connection, DateTime validatedSince) { Validator.ThrowIfArgumentNull(connection, "connection", "ConnectPackageConnectionNull"); HealthServiceRequest request = new HealthServiceRequest(connection, "GetAuthorizedConnectRequests", 1); if (validatedSince != DateTime.MinValue) { request.Parameters = "<authorized-connect-requests-since>" + SDKHelper.XmlFromDateTime(validatedSince) + "</authorized-connect-requests-since>"; } request.Execute(); XPathExpression infoPath = SDKHelper.GetInfoXPathExpressionForMethod( request.Response.InfoNavigator, "GetAuthorizedConnectRequests"); XPathNavigator infoNav = request.Response.InfoNavigator.SelectSingleNode(infoPath); Collection<ValidatedPatientConnection> result = new Collection<ValidatedPatientConnection>(); XPathNodeIterator validatedConnectionsIterator = infoNav.Select("connect-request"); foreach (XPathNavigator nav in validatedConnectionsIterator) { ValidatedPatientConnection validatedConnection = new ValidatedPatientConnection(); validatedConnection.ParseXml(nav); result.Add(validatedConnection); } return result; }
/// <summary> /// Converts a HV Validated Patient Connection to a Participant /// </summary> /// <param name="validatedPatient">The ValidatedPatientConnection from healthvault</param> /// <returns>The corresponding Participant from the database, or null it can't find one</returns> private Participant ValidatedPatientConnectionToParticipant(ValidatedPatientConnection validatedPatient) { Guid participantId = Guid.Empty; try { participantId = Guid.Parse(validatedPatient.ApplicationPatientId); } catch (FormatException) { // old integer-style key; ignore return null; } return ParticipantDAO.FindParticipantById(participantId); }