none
How do I access the type-specific data in HealthRecordItemCollection?

    Question

  • Hi,

    I'm having problems working with the HealthRecordItemCollection class.

    I've used a HealthRecordSearcher to find all the Message ItemTypes in an account using an offline Windows Forms Application.

    The results are returned in a HealthRecordItemCollection which I gather seems to be the usual way to return search results. As I know that everything in the collection is a Message itemtype (because I specified that in the healthRecordFilter), how do I then access all of the type specific data that is in each message in the collection? For example, I want to read each From, Subject, Summary, Attachment value that is in each item in the collection.

    I'm still new to HealthVault so apologies if I'm asking a simple question!

    Friday, December 14, 2012 2:13 PM

Answers

  • Hi,

    Can you try something like this:

    HealthRecordFilter filter = new HealthRecordFilter(Message.TypeId); searcher.Filters.Add(filter);

    HealthRecordItemCollection items = searcher.GetMatchingItems()[0];

    foreach (Message msg in items) { // retrieve each message here as msg.<whatever you are interested in> }

    Thanks
    Santhosh

    • Edited by Santhosh Pillai Friday, December 14, 2012 5:42 PM
    • Marked as answer by GizzerGis Monday, December 17, 2012 12:50 PM
    Friday, December 14, 2012 5:41 PM

All replies

  • Hi,

    Can you try something like this:

    HealthRecordFilter filter = new HealthRecordFilter(Message.TypeId); searcher.Filters.Add(filter);

    HealthRecordItemCollection items = searcher.GetMatchingItems()[0];

    foreach (Message msg in items) { // retrieve each message here as msg.<whatever you are interested in> }

    Thanks
    Santhosh

    • Edited by Santhosh Pillai Friday, December 14, 2012 5:42 PM
    • Marked as answer by GizzerGis Monday, December 17, 2012 12:50 PM
    Friday, December 14, 2012 5:41 PM
  • Thanks for your help - it worked perfectly!
    Monday, December 17, 2012 12:52 PM