protected void Btn_ShowWeeklyReadingsTextSummary_Click(object sender, System.EventArgs e) { HealthRecordSearcher searcher = PersonInfo.SelectedRecord.CreateSearcher(); HealthRecordFilter filter = new HealthRecordFilter( Emotion.TypeId, DietaryDailyIntake.TypeId, Weight.TypeId, SleepJournalAM.TypeId, Exercise.TypeId); filter.EffectiveDateMin = DateTime.Now.Subtract(new TimeSpan(7, 0, 0, 0)); searcher.Filters.Add(filter); filter.View.TransformsToApply.Add("mtt"); HealthRecordItemCollection items = searcher.GetMatchingItems()[0]; DataTable dataTable = new DataTable(); dataTable.Columns.Add(new DataColumn("Date", typeof(string))); dataTable.Columns.Add(new DataColumn("Type", typeof(string))); dataTable.Columns.Add(new DataColumn("Summary", typeof(string))); foreach (HealthRecordItem item in items) { XmlNode mttDocument = item.TransformedXmlData["mtt"].SelectSingleNode("data-xml/row"); DataRow row = dataTable.NewRow(); row["Date"] = mttDocument.Attributes["wc-date"].Value; row["Type"] = mttDocument.Attributes["wc-type"].Value; row["Summary"] = mttDocument.Attributes["summary"].Value; dataTable.Rows.Add(row); } Grid_ReadingsTextSummary.DataSource = dataTable; Grid_ReadingsTextSummary.DataBind(); Grid_ReadingsTextSummary.Visible = true; }
private static JArray CreateJsonResponse(HealthRecordItemCollection items) { JObject result = new JObject(); JObject resultObj = new JObject(); JArray itemArr = new JArray(); if (items != null) { foreach (HealthRecordItem item in items) { ItemTypes.Weight weight = (ItemTypes.Weight)item; JObject itemW = new JObject(); itemW["time"] = weight.EffectiveDate.ToUniversalTime(); itemW["weight"] = weight.Value.Kilograms.ToString(); itemW["unit"] = "kilograms"; itemArr.Add(itemW); } } result["count"] = items.Count(); result["result"] = itemArr; if (itemArr.Count > 0) { resultObj["status"] = "ok"; resultObj["getWeightResponse"] = result; return(itemArr); } else { resultObj["status"] = "no content"; resultObj["getWeightResponse"] = result; return(itemArr); } }
private static JArray CreateJsonResponse(HealthRecordItemCollection items) { JObject result = new JObject(); JObject resultObj = new JObject(); JArray itemArr = new JArray(); if (items != null) { foreach (HealthRecordItem item in items) { VitalSigns vitalSign = (VitalSigns)item; JObject itemV = new JObject(); itemV["unit"] = "°C"; itemV["temperature"] = vitalSign.VitalSignsResults[0].Value; itemV["time"] = vitalSign.EffectiveDate.ToUniversalTime(); itemArr.Add(itemV); } } result["count"] = items.Count(); result["result"] = itemArr; if (itemArr.Count > 0) { resultObj["status"] = "ok"; resultObj["getWeightResponse"] = result; return(itemArr); } else { resultObj["status"] = "no content"; resultObj["getWeightResponse"] = result; return(itemArr); } }
public static async Task <HttpResponseMessage> Run( [HttpTrigger(AuthorizationLevel.Function, "get", Route = null)] HttpRequestMessage req, TraceWriter log) { try { log.Info("Weight request...calling Health Vault server"); HVClient clientSample = new HVClient(); HealthRecordItemCollection items = clientSample.GetWeightFromHealthVault(); JArray jsonResponse = CreateJsonResponse(items); if (jsonResponse.Count > 0) { return(req.CreateResponse(HttpStatusCode.OK, jsonResponse)); } else { return(req.CreateResponse(HttpStatusCode.OK, jsonResponse)); } } catch (global::System.Exception) { JObject jsonResponse = CreateUnauthorizedResponse(); return(req.CreateResponse(HttpStatusCode.Unauthorized, jsonResponse)); } }
public static async Task <HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequestMessage req, TraceWriter log) { try { log.Info("Anagraphic request...calling Health Vault server"); HVClient clientSample = new HVClient(); HealthRecordItemCollection items = clientSample.GetWeightFromHealthVault(); // Get list of authorized people ApplicationConnection connection = clientSample.HealthClientApplication.ApplicationConnection; List <PersonInfo> authorizedPeople = new List <PersonInfo>(connection.GetAuthorizedPeople()); if (authorizedPeople.Count == 0) { log.Info("No records were authorized. Application setup process did not complete."); return(req.CreateResponse(HttpStatusCode.BadRequest, "")); } PersonInfo personInfo = authorizedPeople[0]; JObject jsonResponse = CreateJsonResponse(personInfo); return(req.CreateResponse(HttpStatusCode.OK, jsonResponse)); } catch (global::System.Exception) { // JObject jsonResponse = CreateUnauthorizedResponse(); return(req.CreateResponse(HttpStatusCode.Unauthorized, "")); } }
public static List <string> GetThings(OfflineWebApplicationConnection connection, Guid recordId, Guid[] typeIds, DateTime updatedSinceUtc) { HealthRecordAccessor record = new HealthRecordAccessor(connection, recordId); HealthRecordSearcher searcher = record.CreateSearcher(); HealthRecordFilter filter = new HealthRecordFilter(); searcher.Filters.Add(filter); foreach (Guid typeId in typeIds) { filter.TypeIds.Add(typeId); } filter.UpdatedDateMin = DateTime.SpecifyKind(updatedSinceUtc, DateTimeKind.Utc); filter.View.Sections = HealthRecordItemSections.All | Microsoft.Health.HealthRecordItemSections.Xml; //HealthRecordItemSections.Core | //HealthRecordItemSections.Xml | //HealthRecordItemSections.Audits; HealthRecordItemCollection things = searcher.GetMatchingItems()[0]; List <string> items = new List <string>(); foreach (HealthRecordItem thing in things) { items.Add(thing.GetItemXml(filter.View.Sections)); } return(items); }
protected void Page_Load(object sender, EventArgs e) { Lbl_UserName.Text = this.PersonInfo.SelectedRecord.DisplayName; HealthRecordSearcher searcher = PersonInfo.SelectedRecord.CreateSearcher(); HealthRecordFilter filter = new HealthRecordFilter(Weight.TypeId); filter.MaxItemsReturned = 10; filter.UpdatedDateMin = DateTime.Now.Subtract(new TimeSpan(365, 0, 0, 0)); searcher.Filters.Add(filter); HealthRecordItemCollection items = searcher.GetMatchingItems()[0]; Dictionary <string, string> weights = new Dictionary <string, string>(); foreach (Weight item in items) { weights[item.When.ToString()] = item.Value.ToString(); } WeightView.DataSource = weights; WeightView.DataBind(); }
protected void Btn_ShowWeeklyWeightReadings_Click(object sender, EventArgs e) { HealthRecordSearcher searcher = PersonInfo.SelectedRecord.CreateSearcher(); HealthRecordFilter filter = new HealthRecordFilter( Emotion.TypeId, DietaryDailyIntake.TypeId, Weight.TypeId, SleepJournalAM.TypeId, Exercise.TypeId); filter.EffectiveDateMin = DateTime.Now.Subtract(new TimeSpan(7, 0, 0, 0)); searcher.Filters.Add(filter); HealthRecordItemCollection items = searcher.GetMatchingItems()[0]; TimeSeries weight = new TimeSeries("Weight Graph"); TimeSeries emotions = new TimeSeries("Emotions"); TimeSeries dietaryintakes = new TimeSeries("Dietary Intake (Carbs)"); TimeSeries sleep = new TimeSeries("Sleep"); TimeSeries exercise = new TimeSeries("Exercise"); foreach (HealthRecordItem item in items) { if (item is Weight) { Weight w = (Weight)item; weight.SeriesValue.Add(new TimeSeries.TimeSeriesValues( w.EffectiveDate, w.Value.DisplayValue.Value)); } if (item is Emotion) { Emotion m = (Emotion)item; emotions.SeriesValue.Add(new TimeSeries.TimeSeriesValues( m.EffectiveDate, 1.0)); } if (item is DietaryDailyIntake) { } if (item is SleepJournalAM) { SleepJournalAM s = (SleepJournalAM)item; sleep.SeriesValue.Add(new TimeSeries.TimeSeriesValues( s.EffectiveDate, s.SleepMinutes)); } if (item is Exercise) { } } TimeplotView.Plots.Add(weight); TimeplotView.Plots.Add(emotions); TimeplotView.Plots.Add(dietaryintakes); TimeplotView.Plots.Add(sleep); TimeplotView.Plots.Add(exercise); TimeplotView.DataBind(); TimeplotView.Visible = true; }
private void buttonGetWeight_Click(object sender, EventArgs e) { listViewWeight.Items.Clear(); HealthRecordItemCollection items = _hvclient.GetWeightFromHealthVault(); if (items != null) { foreach (HealthRecordItem item in items) { ItemTypes.Weight weight = (ItemTypes.Weight)item; ListViewItem lvi = new ListViewItem(weight.Value.Kilograms.ToString()); lvi.SubItems.Add(weight.When.ToString()); listViewWeight.Items.Add(lvi); } } }
protected void Page_Load(object sender, EventArgs e) { HealthRecordSearcher searcher = PersonInfo.SelectedRecord.CreateSearcher(); HealthRecordFilter filter = new HealthRecordFilter(Weight.TypeId); searcher.Filters.Add(filter); HealthRecordItemCollection items = searcher.GetMatchingItems()[0]; Dictionary <string, string> weights = new Dictionary <string, string>(); foreach (Weight item in items) { weights[item.When.ToString()] = item.Value.ToString(); } WeightView.DataSource = weights; WeightView.DataBind(); }
/// <summary> /// Creates a connection to HealthVault and obtains weight data /// </summary> /// <returns></returns> public HealthRecordItemCollection GetWeightFromHealthVault() { if (!_isProvisioned) { MessageBox.Show("Please provision application first"); return(null); } HealthClientAuthorizedConnection connection = HealthClientApplication.CreateAuthorizedConnection(PersonId); HealthRecordAccessor accessor = new HealthRecordAccessor(connection, RecordId); HealthRecordSearcher searcher = accessor.CreateSearcher(); HealthRecordFilter filter = new HealthRecordFilter(ItemTypes.Weight.TypeId); searcher.Filters.Add(filter); HealthRecordItemCollection items = searcher.GetMatchingItems()[0]; return(items); }
public static List <HeightModel> GetValues <T>(Guid typeID, PersonInfo personInfo) where T : HeightModel { HealthRecordSearcher searcher = personInfo.SelectedRecord.CreateSearcher(); HealthRecordFilter filter = new HealthRecordFilter(typeID); searcher.Filters.Add(filter); HealthRecordItemCollection items = searcher.GetMatchingItems()[0]; List <HeightModel> typedList = new List <HeightModel>(); foreach (HealthRecordItem item in items) { Height itemObj = (Height)item; HeightModel heightObj = new HeightModel(itemObj.Value.Meters, itemObj.When); typedList.Add(heightObj); } return(typedList); }
protected void Btn_ShowWeeklyWeightReadings_Click(object sender, EventArgs e) { HealthRecordSearcher searcher = PersonInfo.SelectedRecord.CreateSearcher(); HealthRecordFilter filter = new HealthRecordFilter(Weight.TypeId); filter.EffectiveDateMin = DateTime.Now.Subtract(new TimeSpan(7, 0, 0, 0)); searcher.Filters.Add(filter); HealthRecordItemCollection items = searcher.GetMatchingItems()[0]; TimeSeries t = new TimeSeries("Weight Graph"); foreach (Weight item in items) { //Assuming all data is in one unit t.SeriesValue.Add(new TimeSeries.TimeSeriesValues( item.EffectiveDate, item.Value.DisplayValue.Value)); } TimeplotView.Plots.Add(t); TimeplotView.DataBind(); TimeplotView.Visible = true; }
protected void Page_Load(object sender, EventArgs e) { Lbl_UserName.Text = this.PersonInfo.SelectedRecord.DisplayName; HealthRecordSearcher searcher = PersonInfo.SelectedRecord.CreateSearcher(); HealthRecordFilter filter = new HealthRecordFilter( ApplicationSpecific.TypeId, Emotion.TypeId, DietaryDailyIntake.TypeId, Weight.TypeId, SleepJournalAM.TypeId, Exercise.TypeId); filter.EffectiveDateMin = DateTime.Now.Subtract(new TimeSpan(7, 0, 0, 0)); searcher.Filters.Add(filter); HealthRecordItemCollection items = searcher.GetMatchingItems()[0]; List <Weight> weights = new List <Weight>(); List <Emotion> emotions = new List <Emotion>(); List <SleepJournalAM> sleep = new List <SleepJournalAM>(); List <DietaryDailyIntake> dietaryintake = new List <DietaryDailyIntake>(); List <Exercise> exercise = new List <Exercise>(); List <ApplicationSpecific> selfexperiements = new List <ApplicationSpecific>(); foreach (HealthRecordItem item in items) { if (item is Weight) { weights.Add((Weight)item); } if (item is Emotion) { emotions.Add((Emotion)item); } if (item is DietaryDailyIntake) { dietaryintake.Add((DietaryDailyIntake)item); } if (item is SleepJournalAM) { sleep.Add((SleepJournalAM)item); } if (item is Exercise) { exercise.Add((Exercise)item); } if (item is ApplicationSpecific) { selfexperiements.Add((ApplicationSpecific)item); } } DisplayWeight(weights); DisplayMood(emotions); DisplayDailyDiet(dietaryintake); DisplaySleep(sleep); DisplayExercise(exercise); DisplaySelfExperiments(selfexperiements); DataBindMoodInputControls(); }