Extending HealthVault Data Types
Applications frequently have to represent something that is not encapsulated by the data structure of the HealthVault data types. Out of the box, HealthVault provides a mechanism by which a data type can be extended.
Every application can choose to write XML information in the extension tag within the common data section of a data type. It is recommended that applications distinguish their extension elements by using a unique source attribute on the extension element.
In our example, let’s assume we are extending the daily dietary intake type to add information on alcohol consumption.
Creating a Type Extension
We would like to track the amount of alcohol consumed in a simple element called “alcoholic-drinks”. To simplify things further, we assume this element represents the number of alcoholic drinks including wine, beer, cocktails etc., and is normalized to mean average alcohol per unit.
The first step is to write an alcoholic-drinks XML element within
the extension tag using a unique source (_appDailyAlcoholExtensionName) in the
extension element. Lines
–
in Example 4-9 show how one can do it in the
.NET SDK.
Example 4-9. Creating a type extension
protected void Submit_Daily_Diet_Click(object sender, System.EventArgs e) { //Post Diet DietaryDailyIntake diet ...Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access