public static JObject GetAllThings(Guid personId, Guid recordId) { Guid appId = new Guid(Connections.ApplicationId); OfflineWebApplicationConnection connection = Connections.CreateConnection(appId, personId); HealthRecordAccessor accessor = new HealthRecordAccessor(connection, recordId); HealthRecordSearcher searcher = new HealthRecordSearcher(accessor); List <Guid> queryOrder = Types.TypeDefinitions.Keys.ToList(); queryOrder.Add(CustomType.Id); foreach (Guid thingType in queryOrder) { HealthRecordFilter filter = new HealthRecordFilter(thingType); if (thingType.Equals(CustomType.Id) || (Types.TypeDefinitions.ContainsKey(thingType) && !Types.TypeDefinitions[thingType].Persistent)) { filter.EffectiveDateMin = GetMinTime(); } searcher.Filters.Add(filter); } ReadOnlyCollection <HealthRecordItemCollection> things = searcher.GetMatchingItems(); return(TransformThings(things, queryOrder)); }
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 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; }
protected override void ProcessRecord() { HealthClientApplication clientApp = HvShellUtilities.GetClient(); List <PersonInfo> authorizedPeople = new List <PersonInfo>(clientApp.ApplicationConnection.GetAuthorizedPeople()); // Create an authorized connection for each person on the // list. HealthClientAuthorizedConnection authConnection = clientApp.CreateAuthorizedConnection( authorizedPeople[0].PersonId); // Use the authorized connection to read the user's default // health record. HealthRecordAccessor access = new HealthRecordAccessor( authConnection, authConnection.GetPersonInfo().GetSelfRecord().Id); // Search the health record for basic demographic // information. // Most user records contain an item of this type. HealthRecordSearcher search = access.CreateSearcher(); HealthRecordFilter filter = new HealthRecordFilter( HvShellUtilities.NameToTypeId(Type)); search.Filters.Add(filter); foreach (Object o in search.GetMatchingItems()[0]) { WriteObject(o); } }
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(); }
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 static ReadOnlyCollection <HealthRecordItemCollection> ReadHeight(PersonInfo personInfo) { HealthRecordSearcher searcher = personInfo.SelectedRecord.CreateSearcher(); HealthRecordFilter filter = new HealthRecordFilter(); filter.TypeIds.Add(Height.TypeId); searcher.Filters.Add(filter); ReadOnlyCollection <HealthRecordItemCollection> items = searcher.GetMatchingItems(); return(items); }
private static List <T> GetValues <T>(Guid typeId, HealthRecordAccessor access) where T : HealthRecordItem { var searcher = access.CreateSearcher(); var filter = new HealthRecordFilter(typeId); searcher.Filters.Add(filter); var items = searcher.GetMatchingItems()[0]; return(items.Cast <T>().ToList()); }
protected void getBasicInfo() { HealthRecordSearcher searcher = PersonInfo.SelectedRecord.CreateSearcher(); HealthRecordFilter filter = new HealthRecordFilter(Basic.TypeId); searcher.Filters.Add(filter); HealthRecordItemCollection items = searcher.GetMatchingItems()[0]; Basic basicInfo = (Basic)items[0]; dob.Text = basicInfo.BirthYear.ToString(); city.Text = basicInfo.City; state.Text = basicInfo.StateOrProvince; user_info = "<b>Name:</b> " + PersonInfo.Name + ", "; user_info += "<b>Birth Year:</b> " + basicInfo.BirthYear.ToString() + "<br/>"; user_info += "<b>City, State:</b> " + basicInfo.City + ", "+basicInfo.StateOrProvince + "<br/>"; }
/// <summary> /// Creates a new instance of the <see cref="HealthRecordItemDataTable"/> /// class with the specified table view and filter. /// </summary> /// /// <param name="view"> /// The view that the data table should take on the data. /// </param> /// /// <param name="filter"> /// The filter used to gather health record items from the HealthVault /// service. /// </param> /// /// <exception cref="ArgumentNullException"> /// The <paramref name="filter"/> parameter is <b>null</b>. /// </exception> /// /// <exception cref="ArgumentException"> /// The <paramref name="view"/> parameter is /// <see cref="HealthRecordItemDataTableView.SingleTypeTable"/> and /// the <paramref name="filter"/> parameter contains more than one type /// identifier. /// </exception> /// public HealthRecordItemDataTable( HealthRecordItemDataTableView view, HealthRecordFilter filter) { Validator.ThrowIfArgumentNull(filter, "filter", "DataTableFilterNull"); Validator.ThrowArgumentExceptionIf( view == HealthRecordItemDataTableView.SingleTypeTable && filter.TypeIds.Count > 1, "view", "DataTableViewInvalid"); _filter = filter; _view = view; }
private static T GetSingleValue <T>(Guid typeId, HealthRecordAccessor access) where T : class { var searcher = access.CreateSearcher(); var filter = new HealthRecordFilter(typeId); searcher.Filters.Add(filter); var items = searcher.GetMatchingItems()[0]; if (items != null && items.Count > 0) { return(items[0] as T); } return(null); }
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); 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(); }
private static ReadOnlyCollection <HealthRecordItemCollection> ReadHeight(PersonInfo personInfo) { HealthRecordSearcher searcher = personInfo.SelectedRecord.CreateSearcher(); HealthRecordFilter filter = new HealthRecordFilter(); filter.TypeIds.Add(Height.TypeId); searcher.Filters.Add(filter); //To get blob //var item = searcher.GetSingleItem(new Guid("ef21ac67-e525-4a6e-ae5a-e54d3b75c80e"), HealthRecordItemSections.All); //var itemBlob = item.GetBlobStore(personInfo.SelectedRecord); //foreach(var blob in itemBlob.Values) //{ // Console.WriteLine(blob.Name); //} ReadOnlyCollection <HealthRecordItemCollection> items = searcher.GetMatchingItems(); return(items); }
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); }
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; }
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 getProviderInfo() { HealthRecordSearcher searcher = PersonInfo.SelectedRecord.CreateSearcher(); HealthRecordFilter filter = new HealthRecordFilter(Person.TypeId); searcher.Filters.Add(filter); HealthRecordItemCollection items = searcher.GetMatchingItems()[0]; ProviderInfoMenu = "<select id=\"ProviderInfo\">"; String optionStr = ""; foreach (Person Provider in items) { if (Provider.PersonType.Text.Equals("Provider")) { optionStr = optionStr + "<option value=\"" + Provider.Name + "\">" + Provider.Name + "</option>"; } } if (optionStr == "") { optionStr = "<option value=\"Floyd\">Floyd</option><option value=\"Floyd\">Harbin</option><option value=\"Floyd\">Redmond</option>"; } ProviderInfoMenu = ProviderInfoMenu + optionStr + "</select>"; }
public IEnumerable<HealthRecordItemCollection> getHalthVaultModuleItemCollection(string wcToken, List<HealthModel> _healthModel) { WebApplicationConnection connection = GetConnection(wcToken); Guid recordId = connection.GetPersonInfo().SelectedRecord.Id; HealthRecordAccessor accessor = new HealthRecordAccessor(connection, recordId); HealthRecordSearcher searcher = accessor.CreateSearcher(); var _types = from _type in _healthModel select new { typeName = _type.healthVaultModule.TypeIDs }; foreach (var _type in _types.ToList()) { HealthRecordFilter filter = new HealthRecordFilter(); switch (_type.typeName) { case "Contact": filter.TypeIds.Add(Microsoft.Health.ItemTypes.Contact.TypeId); break; case "BasicV2": filter.TypeIds.Add(Microsoft.Health.ItemTypes.BasicV2.TypeId); break; case "Payer": filter.TypeIds.Add(Microsoft.Health.ItemTypes.Payer.TypeId); break; case "Person": filter.TypeIds.Add(Microsoft.Health.ItemTypes.Person.TypeId); break; case "Personal": filter.TypeIds.Add(Microsoft.Health.ItemTypes.Personal.TypeId); break; case "AerobicProfile": filter.TypeIds.Add(Microsoft.Health.ItemTypes.AerobicProfile.TypeId); break; case "AerobicWeeklyGoal": filter.TypeIds.Add(Microsoft.Health.ItemTypes.AerobicWeeklyGoal.TypeId); break; case "AllergicEpisode": filter.TypeIds.Add(Microsoft.Health.ItemTypes.AllergicEpisode.TypeId); break; case "Allergy": filter.TypeIds.Add(Microsoft.Health.ItemTypes.Allergy.TypeId); break; case "Annotation": filter.TypeIds.Add(Microsoft.Health.ItemTypes.Annotation.TypeId); break; case "ApplicationDataReference": filter.TypeIds.Add(Microsoft.Health.ItemTypes.ApplicationDataReference.TypeId); break; case "ApplicationSpecific": filter.TypeIds.Add(Microsoft.Health.ItemTypes.ApplicationSpecific.TypeId); break; case "Appointment": filter.TypeIds.Add(Microsoft.Health.ItemTypes.Appointment.TypeId); break; case "AsthmaInhaler": filter.TypeIds.Add(Microsoft.Health.ItemTypes.AsthmaInhaler.TypeId); break; case "AsthmaInhalerUse": filter.TypeIds.Add(Microsoft.Health.ItemTypes.AsthmaInhalerUse.TypeId); break; case "Basic": filter.TypeIds.Add(Microsoft.Health.ItemTypes.Basic.TypeId); break; case "BloodGlucose": filter.TypeIds.Add(Microsoft.Health.ItemTypes.BloodGlucose.TypeId); break; case "BloodOxygenSaturation": filter.TypeIds.Add(Microsoft.Health.ItemTypes.BloodOxygenSaturation.TypeId); break; case "BloodPressure": filter.TypeIds.Add(Microsoft.Health.ItemTypes.BloodPressure.TypeId); break; case "BodyComposition": filter.TypeIds.Add(Microsoft.Health.ItemTypes.BodyComposition.TypeId); break; case "BodyDimension": filter.TypeIds.Add(Microsoft.Health.ItemTypes.BodyDimension.TypeId); break; case "CalorieGuideline": filter.TypeIds.Add(Microsoft.Health.ItemTypes.CalorieGuideline.TypeId); break; case "CardiacProfile": filter.TypeIds.Add(Microsoft.Health.ItemTypes.CardiacProfile.TypeId); break; case "CarePlan": filter.TypeIds.Add(Microsoft.Health.ItemTypes.CarePlan.TypeId); break; case "CCD": filter.TypeIds.Add(Microsoft.Health.ItemTypes.CCD.TypeId); break; case "CCR": filter.TypeIds.Add(Microsoft.Health.ItemTypes.CCR.TypeId); break; case "CDA": filter.TypeIds.Add(Microsoft.Health.ItemTypes.CDA.TypeId); break; case "CholesterolProfile": filter.TypeIds.Add(Microsoft.Health.ItemTypes.CholesterolProfile.TypeId); break; case "Comment": filter.TypeIds.Add(Microsoft.Health.ItemTypes.Comment.TypeId); break; case "Concern": filter.TypeIds.Add(Microsoft.Health.ItemTypes.Concern.TypeId); break; case "Condition": filter.TypeIds.Add(Microsoft.Health.ItemTypes.Condition.TypeId); break; case "Contraindication": filter.TypeIds.Add(Microsoft.Health.ItemTypes.Contraindication.TypeId); break; case "DailyMedicationUsage": filter.TypeIds.Add(Microsoft.Health.ItemTypes.DailyMedicationUsage.TypeId); break; case "Device": filter.TypeIds.Add(Microsoft.Health.ItemTypes.Device.TypeId); break; case "DiabeticProfile": filter.TypeIds.Add(Microsoft.Health.ItemTypes.DiabeticProfile.TypeId); break; case "DietaryDailyIntake": filter.TypeIds.Add(Microsoft.Health.ItemTypes.DietaryDailyIntake.TypeId); break; case "Directive": filter.TypeIds.Add(Microsoft.Health.ItemTypes.Directive.TypeId); break; case "DischargeSummary": filter.TypeIds.Add(Microsoft.Health.ItemTypes.DischargeSummary.TypeId); break; case "Emotion": filter.TypeIds.Add(Microsoft.Health.ItemTypes.Emotion.TypeId); break; case "Encounter": filter.TypeIds.Add(Microsoft.Health.ItemTypes.Encounter.TypeId); break; case "Exercise": filter.TypeIds.Add(Microsoft.Health.ItemTypes.Exercise.TypeId); break; case "ExerciseSamples": filter.TypeIds.Add(Microsoft.Health.ItemTypes.ExerciseSamples.TypeId); break; case "ExplanationOfBenefits": filter.TypeIds.Add(Microsoft.Health.ItemTypes.ExplanationOfBenefits.TypeId); break; case "FamilyHistory": filter.TypeIds.Add(Microsoft.Health.ItemTypes.FamilyHistory.TypeId); break; case "FamilyHistoryCondition": filter.TypeIds.Add(Microsoft.Health.ItemTypes.FamilyHistoryCondition.TypeId); break; case "FamilyHistoryPerson": filter.TypeIds.Add(Microsoft.Health.ItemTypes.FamilyHistoryPerson.TypeId); break; case "FamilyHistoryV3": filter.TypeIds.Add(Microsoft.Health.ItemTypes.FamilyHistoryV3.TypeId); break; case "File": filter.TypeIds.Add(Microsoft.Health.ItemTypes.File.TypeId); break; case "GeneticSnpResults": filter.TypeIds.Add(Microsoft.Health.ItemTypes.GeneticSnpResults.TypeId); break; case "GroupMembership": filter.TypeIds.Add(Microsoft.Health.ItemTypes.GroupMembership.TypeId); break; case "GroupMembershipActivity": filter.TypeIds.Add(Microsoft.Health.ItemTypes.GroupMembershipActivity.TypeId); break; case "HbA1C": filter.TypeIds.Add(Microsoft.Health.ItemTypes.HbA1C.TypeId); break; case "HealthAssessment": filter.TypeIds.Add(Microsoft.Health.ItemTypes.HealthAssessment.TypeId); break; case "HealthcareProxy": filter.TypeIds.Add(Microsoft.Health.ItemTypes.HealthcareProxy.TypeId); break; case "HealthEvent": filter.TypeIds.Add(Microsoft.Health.ItemTypes.HealthEvent.TypeId); break; case "HealthJournalEntry": filter.TypeIds.Add(Microsoft.Health.ItemTypes.HealthJournalEntry.TypeId); break; case "HeartRate": filter.TypeIds.Add(Microsoft.Health.ItemTypes.HeartRate.TypeId); break; case "Height": filter.TypeIds.Add(Microsoft.Health.ItemTypes.Height.TypeId); break; case "Immunization": filter.TypeIds.Add(Microsoft.Health.ItemTypes.Immunization.TypeId); break; case "InsulinInjection": filter.TypeIds.Add(Microsoft.Health.ItemTypes.InsulinInjection.TypeId); break; case "InsulinInjectionUse": filter.TypeIds.Add(Microsoft.Health.ItemTypes.InsulinInjectionUse.TypeId); break; case "LabTestResults": filter.TypeIds.Add(Microsoft.Health.ItemTypes.LabTestResults.TypeId); break; case "LifeGoal": filter.TypeIds.Add(Microsoft.Health.ItemTypes.LifeGoal.TypeId); break; case "Link": filter.TypeIds.Add(Microsoft.Health.ItemTypes.Link.TypeId); break; case "MedicalImageStudy": filter.TypeIds.Add(Microsoft.Health.ItemTypes.MedicalImageStudy.TypeId); break; case "MedicalImageStudyV2": filter.TypeIds.Add(Microsoft.Health.ItemTypes.MedicalImageStudyV2.TypeId); break; case "Medication": filter.TypeIds.Add(Microsoft.Health.ItemTypes.Medication.TypeId); break; case "MedicationFill": filter.TypeIds.Add(Microsoft.Health.ItemTypes.MedicationFill.TypeId); break; case "Message": filter.TypeIds.Add(Microsoft.Health.ItemTypes.Message.TypeId); break; case "MicrobiologyLabResults": filter.TypeIds.Add(Microsoft.Health.ItemTypes.MicrobiologyLabResults.TypeId); break; case "PapSession": filter.TypeIds.Add(Microsoft.Health.ItemTypes.PapSession.TypeId); break; case "PasswordProtectedPackage": filter.TypeIds.Add(Microsoft.Health.ItemTypes.PasswordProtectedPackage.TypeId); break; case "PeakFlow": filter.TypeIds.Add(Microsoft.Health.ItemTypes.PeakFlow.TypeId); break; case "PersonalImage": filter.TypeIds.Add(Microsoft.Health.ItemTypes.PersonalImage.TypeId); break; case "Pregnancy": filter.TypeIds.Add(Microsoft.Health.ItemTypes.Pregnancy.TypeId); break; case "Problem": filter.TypeIds.Add(Microsoft.Health.ItemTypes.Problem.TypeId); break; case "Procedure": filter.TypeIds.Add(Microsoft.Health.ItemTypes.Procedure.TypeId); break; case "QuestionAnswer": filter.TypeIds.Add(Microsoft.Health.ItemTypes.QuestionAnswer.TypeId); break; case "RadiologyLabResults": filter.TypeIds.Add(Microsoft.Health.ItemTypes.RadiologyLabResults.TypeId); break; case "RespiratoryProfile": filter.TypeIds.Add(Microsoft.Health.ItemTypes.RespiratoryProfile.TypeId); break; case "SleepJournalAM": filter.TypeIds.Add(Microsoft.Health.ItemTypes.SleepJournalAM.TypeId); break; case "SleepJournalPM": filter.TypeIds.Add(Microsoft.Health.ItemTypes.SleepJournalPM.TypeId); break; case "Status": filter.TypeIds.Add(Microsoft.Health.ItemTypes.Status.TypeId); break; case "VitalSigns": filter.TypeIds.Add(Microsoft.Health.ItemTypes.VitalSigns.TypeId); break; case "Weight": filter.TypeIds.Add(Microsoft.Health.ItemTypes.Weight.TypeId); break; case "WeightGoal": filter.TypeIds.Add(Microsoft.Health.ItemTypes.WeightGoal.TypeId); break; } searcher.Filters.Add(filter); } IEnumerable<HealthRecordItemCollection> _healthRecordCollection = searcher.GetMatchingItems(); return _healthRecordCollection; }
public ActionResult GetUserData(int userId = -1) { // just do a basic check if (userId == -1) return Json(new { status = "error", msg = "userId not sent" }, JsonRequestBehavior.AllowGet); // try to find the user var context = new HVDbContext(); var user = (from t in context.HealthVaultUsers where t.Id == userId select t).FirstOrDefault(); // if no user is found return error if (user == null) return Json(new { status = "error", msg = "userId not found" }, JsonRequestBehavior.AllowGet); // extract the token and make the request to health vault for all the data var authToken = user.WCToken; // register the type in the HV SDK ItemTypeManager.RegisterTypeHandler(HVJournalEntry.TypeId, typeof(HVJournalEntry), true); // create the appropriate objects for health vault var appId = HealthApplicationConfiguration.Current.ApplicationId; WebApplicationCredential cred = new WebApplicationCredential( appId, authToken, HealthApplicationConfiguration.Current.ApplicationCertificate); // setup the user WebApplicationConnection connection = new WebApplicationConnection(appId, cred); PersonInfo personInfo = null; try { personInfo = HealthVaultPlatform.GetPersonInfo(connection); } catch { return Json(new { status = "error", msg = "Unable to connect to HealthVault service" }, JsonRequestBehavior.AllowGet); } // get the selected record var authRecord = personInfo.SelectedRecord; // make sure there is a record returned if (authRecord == null) return Json(new { status = "error", msg = "cannot get selected record" }, JsonRequestBehavior.AllowGet); // before we add make sure we still have permission to read var result = authRecord.QueryPermissionsByTypes(new List<Guid>() { HVJournalEntry.TypeId }).FirstOrDefault(); if (!result.Value.OnlineAccessPermissions.HasFlag(HealthRecordItemPermissions.Read)) return Json(new { status = "error", msg = "unable to create record as no permission is given from health vault" }, JsonRequestBehavior.AllowGet); // search hv for the records HealthRecordSearcher searcher = authRecord.CreateSearcher(); HealthRecordFilter filter = new HealthRecordFilter(HVJournalEntry.TypeId); searcher.Filters.Add(filter); HealthRecordItemCollection entries = searcher.GetMatchingItems()[0]; var ret = entries.Cast<HVJournalEntry>().ToList().Select(t => t.JournalEntry); return Json(new { status = "ok", data = ret }, JsonRequestBehavior.AllowGet); }
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(); }
protected void getSymptomSummary() { DateTime from; DateTime to = DateTime.Now; String from_date_string = from_date.Text; if (String.IsNullOrEmpty(from_date_string)) from = DateTime.Now.AddDays(-14); else from = DateTime.Parse(from_date_string + " 00:00:01 AM"); HealthRecordSearcher searcher = PersonInfo.SelectedRecord.CreateSearcher(); HealthRecordFilter filter = new HealthRecordFilter(Condition.TypeId); filter.CreatedDateMax = to; filter.CreatedDateMin = from; searcher.Filters.Add(filter); HealthRecordItemCollection items = searcher.GetMatchingItems()[0]; foreach (Condition condition in items) { if (isSymptom(condition)) { Symptom symptom = new Symptom(); symptom.SymptomName = condition.Name.Text; symptom.SymptomValue = Convert.ToInt32(condition.Status.Text); symptom.When = DateTime.Parse(condition.OnsetDate.ToString()); if (symptom.When >= from) symptoms.Add(symptom); } } symptoms.Sort(delegate(Symptom p1, Symptom p2) { return p1.When.CompareTo(p2.When); }); }
private void AddDisplayColumn( DataColumn cdef, string columnHeader, HealthRecordFilter filter) { bool visible = true; ItemTypeDataColumn typeColumn = cdef as ItemTypeDataColumn; if (typeColumn != null) { visible = typeColumn.VisibleByDefault; } DataControlField fld = null; if (cdef.ColumnName == HealthRecordItemDataGrid.WCIsSignedAttributeName) { if (!this._showIsSignedColumn) { visible = false; } else if (_isSignedColumnValueOverride.Length > 0) { TemplateField tfield = new TemplateField(); tfield.ItemTemplate = new GridViewIsSignedTemplate( TemplateType.Item, cdef.ColumnName, columnHeader, _isSignedColumnValueOverride); tfield.HeaderTemplate = new GridViewIsSignedTemplate( TemplateType.Header, cdef.ColumnName, columnHeader, _isSignedColumnValueOverride); fld = tfield; visible = true; } } // For auditing we want to do special columns if (ShowAuditColumns) { switch (cdef.ColumnName) { case "wc-date": visible = false; break; case "wc-source": visible = false; break; case "wc-audit-date": visible = true; break; case "wc-audit-personname": // If the filter is filtered by a person, don't // show the person column. visible = filter.UpdatedPerson == Guid.Empty; break; case "wc-audit-appname": // If the filter is filtered by a application, // don't show the application column. visible = filter.UpdatedApplication == Guid.Empty; break; case "wc-audit-action": // For an action, we need to use a special // templated field. The templated field overrides // data binding and will convert the enum string // to a string we want to show. TemplateField tfield = new TemplateField(); tfield.ItemTemplate = new GridViewAuditActionTemplate( TemplateType.Item, cdef.ColumnName, columnHeader); tfield.HeaderTemplate = new GridViewAuditActionTemplate( TemplateType.Header, cdef.ColumnName, columnHeader); fld = tfield; visible = true; break; } } if (fld == null) { BoundField genericField = new BoundField(); genericField.DataField = cdef.ColumnName; genericField.HeaderText = columnHeader; fld = genericField; } fld.HeaderStyle.Wrap = false; fld.Visible = visible; if (typeColumn != null) { fld.HeaderStyle.Width = Unit.Pixel(typeColumn.ColumnWidth); } gridView.Columns.Add(fld); }
/// <summary> /// Gets a single health record item from the associated record by /// using the item identifier. /// </summary> /// /// <param name="itemId"> /// The unique identifier for the health record item. /// </param> /// /// <param name="sections"> /// The data sections of the health record item that should be retrieved. /// </param> /// /// <returns> /// An instance of a <see cref="Microsoft.Health.HealthRecordItem"/> /// representing the health record item with the specified identifier. /// </returns> /// /// <remarks> /// This method accesses the HealthVault service across the network. /// <br/><br/> /// All filters are cleared and replaced with a single filter /// for the specified item. /// </remarks> /// /// <exception cref="HealthServiceException"> /// The server returned something other than a code of /// HealthServiceStatusCode.OK, or the result count did not equal one (1). /// -or- /// <see cref="Microsoft.Health.HealthRecordSearcher.Filters"/> is empty /// or contains invalid filters. /// </exception> /// public HealthRecordItem GetSingleItem( Guid itemId, HealthRecordItemSections sections) { // Create a new searcher to get the item. HealthRecordSearcher searcher = new HealthRecordSearcher(Record); HealthRecordFilter filter = new HealthRecordFilter(); filter.ItemIds.Add(itemId); filter.View.Sections = sections; filter.CurrentVersionOnly = true; searcher.Filters.Add(filter); ReadOnlyCollection<HealthRecordItemCollection> resultSet = HealthVaultPlatform.GetMatchingItems(Record.Connection, Record, searcher); // Check in case HealthVault returned invalid data. if (resultSet.Count > 1) { HealthServiceResponseError error = new HealthServiceResponseError(); error.Message = ResourceRetriever.GetResourceString( "GetSingleThingTooManyResults"); HealthServiceException e = HealthServiceExceptionHelper.GetHealthServiceException( HealthServiceStatusCode.MoreThanOneThingReturned, error); throw e; } HealthRecordItem result = null; if (resultSet.Count == 1) { HealthRecordItemCollection resultGroup = resultSet[0]; if (resultGroup.Count > 1) { HealthServiceResponseError error = new HealthServiceResponseError(); error.Message = ResourceRetriever.GetResourceString( "GetSingleThingTooManyResults"); HealthServiceException e = HealthServiceExceptionHelper.GetHealthServiceException( HealthServiceStatusCode.MoreThanOneThingReturned, error); throw e; } if (resultGroup.Count == 1) { result = resultGroup[0]; } } return result; }
/// <summary> /// Creates a new HealthRecordSearcher for a list of specific types. /// </summary> /// /// <returns> /// A <see cref="HealthRecordSearcher"/> that searches for items with specific type IDs /// within this record. /// </returns> /// /// <remarks> /// The method adds a filter to the <see cref="HealthRecordSearcher"/> that only returns /// items of the specified type IDs. That filter may be accessed through the /// returned searcher using searcher.Filters[0]. /// /// You can also call the <see cref="HealthRecordSearcher"/> constructor /// directly and pass in a reference to this /// <see cref="HealthRecordAccessor"/>. /// </remarks> /// /// <param name="typeIds"> /// A list of unique type ids to filter on. /// </param> /// public HealthRecordSearcher CreateSearcher(params Guid[] typeIds) { HealthRecordSearcher searcher = new HealthRecordSearcher(this); HealthRecordFilter filter = new HealthRecordFilter(typeIds); searcher.Filters.Add(filter); return searcher; }
private XPathNavigator GetPartialThings( HealthRecordAccessor record, IList<HealthRecordItemKey> thingKeys, int currentThingKeyIndex, int numberOfFullThingsToRetrieve) { HealthRecordSearcher searcher = record.CreateSearcher(); HealthRecordFilter filter = new HealthRecordFilter(); for (int i = currentThingKeyIndex; i < thingKeys.Count && i < currentThingKeyIndex + numberOfFullThingsToRetrieve; i++) { filter.ItemKeys.Add(thingKeys[i]); } filter.View = this.Filter.View; filter.States = this.Filter.States; filter.CurrentVersionOnly = this.Filter.CurrentVersionOnly; searcher.Filters.Add(filter); return searcher.GetMatchingItemsRaw(); }
/// <summary> /// Creates a new instance of the <see cref="HealthRecordItemDataTable"/> /// class with the specified serialization information. /// </summary> /// /// <param name="info"> /// Serialized information about this data table. /// </param> /// /// <param name="context"> /// The stream context of the serialized information. /// </param> /// /// <exception cref="ArgumentNullException"> /// The <paramref name="info"/> parameter is <b>null</b>. /// </exception> /// protected HealthRecordItemDataTable( SerializationInfo info, StreamingContext context) : base(info, context) { Validator.ThrowIfArgumentNull(info, "info", "ExceptionSerializationInfoNull"); string filterXml = info.GetString("filter"); if (!String.IsNullOrEmpty(filterXml)) { XPathDocument filterDoc =new XPathDocument(new StringReader(filterXml)); _filter = HealthRecordFilter.CreateFromXml(filterDoc.CreateNavigator()); } _view = (HealthRecordItemDataTableView) Enum.Parse(typeof(HealthRecordItemDataTableView), info.GetString("view")); }
/// <summary> /// Fetch the <see cref="HealthRecordItem" /> instances that are specified /// in the ChangedItems collection. /// </summary> /// <remarks> /// After the operation has completed, see <see cref="HealthRecordItemChangedItem.Item" /> /// to use the fetched <see cref="HealthRecordItem" /> /// /// Items that have been removed from a record or are otherwise inaccessible will /// have a <see cref="HealthRecordItemChangedItem.Item" /> value of null. /// </remarks> /// /// <param name="applicationId">The application id to use.</param> /// <param name="healthServiceUrl">The health service URL to use.</param> /// /// <exception cref="ArgumentNullException"> /// The <paramref name="healthServiceUrl"/> parameter is <b>null</b>. /// </exception> public void GetItems(Guid applicationId, string healthServiceUrl) { Validator.ThrowIfArgumentNull(healthServiceUrl, "healthServiceUrl", "HealthServiceUrlNull"); if (ChangedItems.Count == 0) { return; } OfflineWebApplicationConnection offlineConn = new OfflineWebApplicationConnection( applicationId, healthServiceUrl, _personId); offlineConn.Authenticate(); HealthRecordAccessor accessor = new HealthRecordAccessor(offlineConn, _recordId); HealthRecordSearcher searcher = accessor.CreateSearcher(); HealthRecordFilter filter = new HealthRecordFilter(); searcher.Filters.Add(filter); Dictionary<Guid, HealthRecordItemChangedItem> changedLookup = new Dictionary<Guid, HealthRecordItemChangedItem>(ChangedItems.Count); foreach (HealthRecordItemChangedItem item in ChangedItems) { filter.ItemIds.Add(item.Id); changedLookup.Add(item.Id, item); } HealthRecordItemCollection things = searcher.GetMatchingItems()[0]; // Take the resultant items and put them back in the ChangedItems collection foreach (HealthRecordItem fetchedItem in things) { HealthRecordItemChangedItem item = changedLookup[fetchedItem.Key.Id]; item.Item = fetchedItem; } }
protected override void ProcessRecord() { HealthClientApplication clientApp = HvShellUtilities.GetClient(); List<PersonInfo> authorizedPeople = new List<PersonInfo>(clientApp.ApplicationConnection.GetAuthorizedPeople()); // Create an authorized connection for each person on the // list. HealthClientAuthorizedConnection authConnection = clientApp.CreateAuthorizedConnection( authorizedPeople[0].PersonId); // Use the authorized connection to read the user's default // health record. HealthRecordAccessor access = new HealthRecordAccessor( authConnection, authConnection.GetPersonInfo().GetSelfRecord().Id); // Search the health record for basic demographic // information. // Most user records contain an item of this type. HealthRecordSearcher search = access.CreateSearcher(); HealthRecordFilter filter = new HealthRecordFilter( HvShellUtilities.NameToTypeId(Type)); search.Filters.Add(filter); foreach (Object o in search.GetMatchingItems()[0]) { WriteObject(o); } }
// // GET: /JournalEntry/ public ActionResult Index() { // register the custom type ItemTypeManager.RegisterTypeHandler(HVJournalEntry.TypeId, typeof(HVJournalEntry), true); // get the user var hvUser = (User as HVPrincipal); if (hvUser != null) { // get the auth token var authToken = hvUser.AuthToken; // create the appropriate objects for health vault var appId = HealthApplicationConfiguration.Current.ApplicationId; WebApplicationCredential cred = new WebApplicationCredential( appId, authToken, HealthApplicationConfiguration.Current.ApplicationCertificate); // setup the user WebApplicationConnection connection = new WebApplicationConnection(appId, cred); PersonInfo personInfo = null; personInfo = HealthVaultPlatform.GetPersonInfo(connection); // before we add make sure we still have permission to add var result = personInfo.SelectedRecord.QueryPermissionsByTypes(new List<Guid>() { HVJournalEntry.TypeId }).FirstOrDefault(); if (!result.Value.OnlineAccessPermissions.HasFlag(HealthRecordItemPermissions.Read)) throw new ArgumentNullException("unable to create record as no permission is given from health vault"); // search hv for the records HealthRecordSearcher searcher = personInfo.SelectedRecord.CreateSearcher(); HealthRecordFilter filter = new HealthRecordFilter(HVJournalEntry.TypeId); searcher.Filters.Add(filter); // get the matching items HealthRecordItemCollection entries = searcher.GetMatchingItems()[0]; // compile a list of journalEntryItems only var items = entries.Cast<HVJournalEntry>().ToList(); var ret = new List<JournalEntry>(items.Count()); foreach (var t in items) { var je = t.JournalEntry; je.HvId = t.Key.ToString(); ret.Add(je); } // return the list to the view return View(ret); } else { // if we make it here there is nothing to display return View(new List<JournalEntry>(0)); } }
public static HealthRecordItemCollection GetHVItemsOnline(PersonInfo info, DateTime? lastSync) { HealthRecordSearcher searcher = info.SelectedRecord.CreateSearcher(); HealthRecordFilter filter = new HealthRecordFilter(Exercise.TypeId, AerobicSession.TypeId); if (lastSync.HasValue) filter.UpdatedDateMin = (DateTime)lastSync; // TODO: Add filter so that we get only items with steps searcher.Filters.Add(filter); HealthRecordItemCollection items = searcher.GetMatchingItems()[0]; return items; }
/// <summary> /// Builds the filter used to populate the data grid. The filter is /// generated by looking at the TypeIds. /// </summary> /// /// <returns> /// A <see cref="Microsoft.Health.HealthRecordFilter"/> that is used /// by the underlying /// <see cref="Microsoft.Health.HealthRecordItemDataTable"/> /// to retrieve data for the data grid. /// </returns> /// private HealthRecordFilter BuildFilterFromParams() { HealthRecordFilter filter = new HealthRecordFilter(); foreach (Guid typeId in TypeIds) { filter.TypeIds.Add(typeId); } return filter; }
public static HealthRecordItemCollection GetHVItemsOffline(Guid personId, Guid recordGuid, DateTime? lastSync) { // Do the offline connection OfflineWebApplicationConnection offlineConn = new OfflineWebApplicationConnection(personId); offlineConn.RequestTimeoutSeconds = 180; //extending time to prevent time outs for accounts with large number of items offlineConn.Authenticate(); HealthRecordAccessor accessor = new HealthRecordAccessor(offlineConn, recordGuid); HealthRecordSearcher searcher = accessor.CreateSearcher(); HealthRecordFilter filter = new HealthRecordFilter(Exercise.TypeId, AerobicSession.TypeId); if (lastSync.HasValue) filter.UpdatedDateMin = (DateTime)lastSync; searcher.Filters.Add(filter); HealthRecordItemCollection items = null; try { items = searcher.GetMatchingItems()[0]; } catch (Exception err) { WlkMiTracer.Instance.Log("HVSync.cs:GetHVItemsOffline", WlkMiEvent.AppSync, WlkMiCat.Error, string.Format("Error for user {0} : {1} ", recordGuid.ToString(), err.ToString())); } return items; }