Querying HealthVault with “Where” clauses!

HealthVault give me all height measures greater than 1.7m

One can use the XPath attribute of the filter to do the specific queries on the healthvault search items.

Here is an example, which gives you all the height items greater than 1.7 m :

HealthRecordSearcher searcher = PersonInfo.SelectedRecord.CreateSearcher()
HealthRecordFilter filter = new HealthRecordFilter(typeID);
filter.XPath = "/thing/data-xml/height/value/m[.>=1.7]";
HealthRecordItemCollection items = searcher.GetMatchingItems()[0];

Please note that the XPath tag doesnot support recursive XPath queries.

Easiest way to construct the queries is first find the HealthRecordItem you want to filter, identify its XML via the GetItemXml() and then use that structure to construct your XPath query. The following is the Xml for Height –


Active  2007-12-26T19:43:14Z                              2007          12          26                          19          43          14              


Hope this helps, I’ll post more on this in case there is interest.

Update: Eric wrote a tool to help with this, more details are here.