Introduction to HealthVault Development #13: More more than one person

In the last installment, we modified our application so that it could switch between family members for data display and entry. This time, we’re going to add a table at the top that shows the current weight for all family members.

We add the table right after the <h1> title:

Family Summary <br />
<asp:Table ID="c_tableSummary" runat="server" BorderWidth="1px" CellPadding="2" CellSpacing="2" GridLines="Both"/>
<br />

Then we need a method to walk through the records and fetch the current weight from each of them. The following will do that:

void GenerateSummaryTable()
    TableHeaderRow headerRow = new TableHeaderRow();
    TableHeaderCell headerCell = new TableHeaderCell();
    headerCell.Text = "Name";

    headerCell = new TableHeaderCell();
    headerCell.Text = "Weight";


    foreach (HealthRecordInfo record in PersonInfo.AuthorizedRecords.Values)
        HealthRecordSearcher searcher = record.CreateSearcher();

        HealthRecordFilter filter = new HealthRecordFilter(Weight.TypeId);
        filter.MaxItemsReturned = 1;


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

        if (weights.Count == 1)
            TableRow row = new TableRow();

            TableCell nameCell = new TableCell();
            nameCell.Text = record.Name;

            Weight weight = weights[0] as Weight;

            TableCell weightCell = new TableCell();
            weightCell.Text = weight.Value.DisplayValue.ToString();


Currently, there is no way to make a single request that fetches data for more than one record, so we need to create an execute a separate query for each one.

Next Time

With all the operations that we are performing, the application is running a little bit slowly. We’ll do some investigation into what’s going on, and see if we can’t make some improvements.

Comments (1)

  1. lori says:

    These have been fascinating. Look forward to reading further updates.