CSharpFeeds - All your C# feeds in one place.

Sponsors

Saturday, August 15, 2009

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

by ericgu via Eric Gunnerson's Compendium : CSharp on 8/15/2009 12:47:33 AM

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";
    headerRow.Cells.Add(headerCell);

    headerCell = new TableHeaderCell();
    headerCell.Text = "Weight";
    headerRow.Cells.Add(headerCell);

    c_tableSummary.Rows.Add(headerRow);

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

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

        searcher.Filters.Add(filter);

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

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

            TableCell nameCell = new TableCell();
            nameCell.Text = record.Name;
            row.Cells.Add(nameCell);

            Weight weight = weights[0] as Weight;

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

            c_tableSummary.Rows.Add(row);
        }
    }

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.
email it!bookmark it!digg it!

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

Subscribe

New Feed

Product Spotlight

Recently Updated Sources

Legal Note

The content of the postings is owned by the respective author. CSharpFeeds is not responsible for the contents of the postings. This site is automatically generated and cannot be reviewed for abusive content. If you find abusive content on CSharpFeeds, please contact us. Designated trademarks and brands are the property of their respective owners. All rights reserved.

Advertise with us