locked
is there sample application to update a record in HealthVault RRS feed

  • Question

  • Hi. could someone suggest the steps to be followed, to update an exiting record. i.e to change the values already present
    and also to add new values. Any pointers would be helpful.

    hkcr
    Friday, April 3, 2009 8:55 AM

Answers

  • PersonInfo is a property of HealthServicePage. I was assuming that you are using online authentication and hence a web application.

    If you have an accessor already, here is what you can to do

    HealthRecordAccessor
    accessor = new HealthRecordAccessor(HealthVaultConnectionManager.CreateConnection(appid, personid),
    recordid
    );  //assuming yours is an offilne appilcation
    HealthRecordSearcher searcher = new HealthRecordSearcher(accessor);
    HealthRecordFilter filter = new HealthRecordFilter();
    filter_contact.TypeIds.Add(BloodPressure.TypeId);
    searcher.Filters.Add(filter);
    ReadOnlyCollection<HealthRecordItemCollection> results = searcher.GetMatchingItems();
    //Assume it returns atleast one item
    BloodPressure bpItem = (BloodPressure) results[0][0];
    bpItem.Systolic = 100;
    accessor.UpdateItem(bpItem);

    Hope this helps

    Raj


    Raj HealthVault Developer Tool http://xray.getrealconsulting.com
    Friday, April 3, 2009 11:53 AM

All replies

  • To update an item, you should first fetch it, change its properties and then call update...


    Guid idOfItem = new Guid("someguid");
    BloodPressure bpItem = (BloodPressure)PersonInfo.SelectedRecord.GetItem(idOfItem, HealthRecordItemSections.Xml);

    //modify bpItem here
    bpItem.Systolic = 100;

    PersonInfo.SelectedRecord.UpdateItem(bpItem);


    Raj 


    Raj HealthVault Developer Tool http://xray.getrealconsulting.com
    Friday, April 3, 2009 10:20 AM
  • I am using accessor, searcher and filter with BloodPressure.TypeID to get a HealthRecordItem.

    now where does PersonInfo class come into picture. It is not static class and hence
    PersonInfo.SelectedRecord.GetItem() cannot be used...

    Or am I not using the correct methods ...


    hkcr
    Friday, April 3, 2009 11:28 AM
  • PersonInfo is a property of HealthServicePage. I was assuming that you are using online authentication and hence a web application.

    If you have an accessor already, here is what you can to do

    HealthRecordAccessor
    accessor = new HealthRecordAccessor(HealthVaultConnectionManager.CreateConnection(appid, personid),
    recordid
    );  //assuming yours is an offilne appilcation
    HealthRecordSearcher searcher = new HealthRecordSearcher(accessor);
    HealthRecordFilter filter = new HealthRecordFilter();
    filter_contact.TypeIds.Add(BloodPressure.TypeId);
    searcher.Filters.Add(filter);
    ReadOnlyCollection<HealthRecordItemCollection> results = searcher.GetMatchingItems();
    //Assume it returns atleast one item
    BloodPressure bpItem = (BloodPressure) results[0][0];
    bpItem.Systolic = 100;
    accessor.UpdateItem(bpItem);

    Hope this helps

    Raj


    Raj HealthVault Developer Tool http://xray.getrealconsulting.com
    Friday, April 3, 2009 11:53 AM
  • Thanks rajesh..The applicaton works fine. hkcr
    Monday, April 6, 2009 4:44 AM