Improve HealthVault query efficiency with final transforms…

A while back I wrote a post about using the built-in HealthVault transforms to get a different view on your data. That post discusses the mtt, stt, and form transforms.

There’s another transform option in HealthVault that gives you the option to transform the response that comes back. It is best explained through a scenario. Most of this discussions is going to be at the raw xml request/response level. Some

Getting the instance ids of all Weight items in a record

If you want to do a full synchronization of weight values in a HealthVault record (and please read the guidance here before you decide to do so), you will need to get the instance ids of all the items. This simplest way to do this is just to ask for all the weight items, which will result in the following response:

That’s a lot of data (almost 2K) just to get the single instance guid. The first thing we can do is change our request so that the response only contains the key information. This is done by telling the platform not to return you any full items, but just return them as partial items. You do that by setting the max-full attribute to “0”. If you are working with the SDK, you can set the MaxFullItemsReturnedPerRequest property and use GetMatchingItemsRaw().

That takes us down to about 500 bytes, which is much smaller. But there’s still a lot of extraneous information there. What we really need is a way to get back only the information that we care about. That something is a HealthVault final xsl.

A final-xsl is an application-supplied transform that is run on the response right before it is sent back to the client. In the .NET sdk, the GetTransformedItems method is used. In the pure xml world, it is done by adding a <final-xsl> element to the request after the <country> element and before the <msg-time> element. The xsl is represented as a string in the request, so it must be appropriately escaped in the request xml.

That takes us down to about 250 bytes, but still preserves the basic form of the response; the mobile libraries will still be able to parse it successfully. If the application is willing to do more parsing, we can simply further to: