locked
HealthVault sample code returns typeID instead of HealthRecordItem RRS feed

  • Question

  • When I run the following code:
    static T GetSingleValue<T>(Guid typeID, HealthRecordAccessor access) where T : class
            {
                HealthRecordSearcher searcher = access.CreateSearcher();
                HealthRecordFilter filter = new HealthRecordFilter(typeID);
                searcher.Filters.Add(filter);
    
                HealthRecordItemCollection items = searcher.GetMatchingItems()[0];
                return items[0] as T;
            }
    
    HealthRecordAccessor access = new HealthRecordAccessor(authConnection, authConnection.GetPersonInfo().GetSelfRecord().Id);
    
     
    Basic basic = GetSingleValue<Basic>(Basic.TypeId, access);
    The value of basic comes back as null of type Basic.typeID even though the items.count = 1;

    How can I change this code so that basic is the HealthRecordItem in items[0]?

    The class metadata for Basic says that it its a subclass of HealthRecordItem.
    public class Basic : HealthRecordItem
    Monday, February 15, 2010 10:59 PM

Answers

  • Hello,

    In the Application Configuration center, you can see Basic Demographic Information and Basic Demographic Information (V1), first is the newer version and second is the older version.
    You are right, Application Configuration Center does not show the type Basic V2, instead you can see Basic Demographic Information which is of newer version.

    Now you need not change any data type access in Application Configuration Center, but you need to change the code in your application to get the items.
    Please use this code in your application.
    BasicV2 basic = GetSingleValue<BasicV2>(BasicV2.TypeId,access);

    The following thread answers your questions: http://social.msdn.microsoft.com/Forums/en-US/healthvault/thread/abcf6444-dcd7-44c1-9cae-39fa1d85b960

    Eric has given a detailed answer about the Basic Demographic Information data type.


    -Mahesh
    Friday, February 19, 2010 4:19 AM

All replies

  • Hello,

    Can you please confirm whether your Application has rules to access Basic data types?. Can you please specify your Application ID?

    If the application is not configured to access the Basic data type, you will get a null value. If you do not have rules for Basic data type, you can add them in Application Configuration Center for the Application ID you are using. After adding the rules, you need to wait for 30 minutes in order to get the changes affected.
    -Mahesh
    Monday, February 15, 2010 11:05 PM
  • I have added a Rule for my Application to access the Basic Demographic Information in the Application Configuration Center.

    My masterAppID is https://config.healthvault-ppe.com/App.aspx?appid=47318b5f-f9e5-483e-afe0-e2037c465e51.

    It has been several hours and basic is still set to null.

    The value of basic comes back as null of type Basic.typeID even though the items.count = 1;

    How can I change this code so that basic is the HealthRecordItem in items[0] and not null?
    Tuesday, February 16, 2010 1:20 PM
  • Hello,

    I have checked the details for your Application ID in the configuration center. You have given access permissions to the newer version of Basic Demographic Information, but you are using Basic type in your code.

    - Please change to the BasicV2 type in your code.
    BasicV2 basic = GetSingleValue<BasicV2>(BasicV2.TypeId,access);

    Hope this helps you...


    -Mahesh
    Tuesday, February 16, 2010 5:39 PM
  • I have configured my Application in the Application Configuration Center to access Basic Demographic Information.
    There is no selection in the Application Configuration Center for Basic V2.
    Why is no selection in the Application Configuration Center for Basic V2?

    I wish to access the Basic Demographic Information as I have configured it.

    Why doesn't HealthVault return the Basic Demographic Information HealthRecordItem that I have configured and asked for ?

    Why doesn't HealthVault convert the HealthRecordItem to the type requested as the documentation says that it should?

    Is something messed up in HealthVault that should be fixed?
    Tuesday, February 16, 2010 6:13 PM
  • Hello,

    In the Application Configuration center, you can see Basic Demographic Information and Basic Demographic Information (V1), first is the newer version and second is the older version.
    You are right, Application Configuration Center does not show the type Basic V2, instead you can see Basic Demographic Information which is of newer version.

    Now you need not change any data type access in Application Configuration Center, but you need to change the code in your application to get the items.
    Please use this code in your application.
    BasicV2 basic = GetSingleValue<BasicV2>(BasicV2.TypeId,access);

    The following thread answers your questions: http://social.msdn.microsoft.com/Forums/en-US/healthvault/thread/abcf6444-dcd7-44c1-9cae-39fa1d85b960

    Eric has given a detailed answer about the Basic Demographic Information data type.


    -Mahesh
    Friday, February 19, 2010 4:19 AM