locked
ItemType with atleast one entry RRS feed

  • Question

  •  

    Hi,

     

    Is there a way using API to find what all item types has atleast one entry in the health record?

     

    For ex, the health vault account page shows a link for an item type if and only if there is atleast one item.

     

    I know I can do a search with all item types and look at the response. But that is too heavy.  Is there any other way?

     

    Rajesh

     

     

    Thursday, May 22, 2008 12:36 PM

Answers

  • We are working on a more efficient way to do this, but for the time being the best way is to create a filter for each type, add each filter to a single HealthRecordSearcher, and then process the results.  It would look something like:

    Code Snippet

     

    HealthRecordSearcher searcher = new HealthRecordSearcher(PersonInfo.SelectedRecord);

     

    Vocabulary vocab = connection.GetVocabulary("thing-types");

     

    foreach (String typeId in vocab.Keys)

    {

        HealthRecordFilter filter = new HealthRecordFilter(typeId, 1);

        filter.TypeIds.Add(new Guid(typeId));

        filter.View.Sections = HealthRecordItemSections.Core;

    }

     

    ReadOnlyCollection<HealthRecordItemCollection> results =

        searcher.GetMatchingItems();

     

     

     

    Each HealthRecordItemCollection represents one of the filters in the search.  You just have to iterate through the collections and match the name of the collection to the typeId.  Any collection containing a result means your application has access to at least one instance of the type.

     

    Jeff Jones

     

    Thursday, May 22, 2008 3:15 PM