Storing Alternate User Identifiers

Storing Alternate User Identifiers


For current versions of HealthVault, offline applications must store the correspondence between the application’s concept of a user identity (typically some sort of id) and the HealthVault identity of a user (person id and record id). In many cases this is straightforward but some applications may not have a convenient place to store this information. Alternate ID support provides a way for applications to store this correlation in HealthVault.

Applications that are using PatientConnect can use the following code to create this association

  void CreateNewAssociations(Guid applicationId, string healthServiceUrl)
    OfflineWebApplicationConnection offlineConnection = 
        new OfflineWebApplicationConnection(applicationId, 
                healthServiceUrl, Guid.Empty);

    Collection<ValidatedPatientConnection> patientConnections = 

    foreach (ValidatedPatientConnection patientConnection in 
        OfflineWebApplicationConnection personConnection = 
            new OfflineWebApplicationConnection(
                applicationId, healthServiceUrl, patientConnection.PersonId);

        HealthRecordAccessor accessor = new HealthRecordAccessor(
                personConnection, patientConnection.RecordId);

        Collection<string> currentAssociatedIds = 

        if (currentAssociatedIds.Count == 0)

Once the association is created, an application can easily go from an alternate ID to an accessor that can be used to perform operations on a record as following code shows.

HealthRecordInfo GetAccessorForAlternateId(
        ApplicationConnection connection, string alternateId)
    HealthRecordInfo info = HealthRecordInfo.GetFromAlternateId(
        connection, alternateId);
    return info;

The alternate id is up to 255 characters in length and is case sensitive. The id string must be unique for a given application, though multiple alternate ids may be registered for a single record.

Applications that wish to remove the association can use HealthRecordAccessor.DisassociateAlternateId().

© 2015 Microsoft