/// <summary> /// Call the HV REST API to delete a goal in a user's HealthVault record. /// This deletes a goal of the user who is actively signed into the application ("online" scenario). /// </summary> private HealthServiceRestResponseData DeleteGoal(Guid id) { return(HealthServiceRestHelper.CallHeathServiceRestOnline( User.PersonInfo(), HttpMethod.Delete.ToString(), _baseRestUrl + id)); }
/// <summary> /// Call the HV REST API to get a list of goals in a user's HealthVault record. /// This gets goals of the user who is actively signed into the application ("online" scenario). /// </summary> private HealthServiceRestResponseData GetGoals() { return(HealthServiceRestHelper.CallHeathServiceRestOnline( User.PersonInfo(), HttpMethod.Get.ToString(), _baseRestUrl)); }
/// <summary> /// Call the HV REST API to update goals in a user's HealthVault record. /// This updates goals for the user who is actively signed into the application ("online" scenario). /// </summary> private HealthServiceRestResponseData UpdateGoals(GoalsWrapper goals) { return(HealthServiceRestHelper.CallHeathServiceRestOnline( User.PersonInfo(), "PATCH", _baseRestUrl, requestBody: JsonConvert.SerializeObject(goals))); }
/// <summary> /// Call the HV REST API to create goals in a user's HealthVault record. /// This creates goals for the user who is actively signed into the application ("online" scenario). /// </summary> private HealthServiceRestResponseData CreateGoals(GoalsWrapper goals) { return(HealthServiceRestHelper.CallHeathServiceRestOnline( User.PersonInfo(), HttpMethod.Post.ToString(), _baseRestUrl, requestBody: JsonConvert.SerializeObject(goals))); }
/// <summary> /// Call the HV REST API to delete a task for the user. /// Deletes an action plan task of a user who is not signed in ("offline" scenario) if both personId and recordId are provided. /// Otherwise, this deletes an action plan task of the user who is actively signed into the application ("online" scenario). /// See Getting Started doc for more information on offline scenarios. /// </summary> private HealthServiceRestResponseData DeleteTask(Guid id, Guid?personId, Guid?recordId) { return(HealthServiceRestHelper.CallHeathServiceRest( personId, recordId, User.PersonInfo(), HttpMethod.Delete.ToString(), _baseTaskRestUrl + id)); }
/// <summary> /// Call the HV REST API to delete an objective for the user. /// Deletes an action plan objective of a user who is not signed in ("offline" scenario) if both personId and recordId are provided. /// Otherwise, this deletes an action plan objective of the user who is actively signed into the application ("online" scenario). /// See Getting Started doc for more information on offline scenarios. /// </summary> private HealthServiceRestResponseData DeleteObjective(Guid planId, Guid id, Guid?personId, Guid?recordId) { return(HealthServiceRestHelper.CallHeathServiceRest( personId, recordId, User.PersonInfo(), HttpMethod.Delete.ToString(), _basePlanRestUrl + planId + "/objectives/" + id)); }
/// <summary> /// Call the HV REST API to get the a plan for the user. /// Gets an action plan of a user who is not signed in ("offline" scenario) if both personId and recordId are provided. /// Otherwise, this gets an action plan of the user who is actively signed into the application ("online" scenario). /// See Getting Started doc for more information on offline scenarios. /// </summary> private HealthServiceRestResponseData GetPlan(Guid id, Guid?personId, Guid?recordId) { return(HealthServiceRestHelper.CallHeathServiceRest( personId, recordId, User.PersonInfo(), HttpMethod.Get.ToString(), _basePlanRestUrl + id)); }
/// <summary> /// Call the HV REST API to check how auto tracking matches a task against a HealthVault XML thing. /// As this API doesn't actually access HealthVault (all data is being passed in), we've only done this in an online manner. /// </summary> private HealthServiceRestResponseData ValidateTaskAutoTracking(TrackingValidation trackingValidation) { return(HealthServiceRestHelper.CallHeathServiceRest( null, null, User.PersonInfo(), HttpMethod.Post.ToString(), _baseTaskRestUrl + "ValidateTracking", null, JsonConvert.SerializeObject(trackingValidation))); }
/// <summary> /// Call the HV REST API to partially edit the action plan task in a user's HealthVault record. /// Edits an action plan task of a user who is not signed in ("offline" scenario) if both personId and recordId are provided. /// Otherwise, this edits the action plan task of the user who is actively signed into the application ("online" scenario). /// See Getting Started doc for more information on offline scenarios. /// </summary> private HealthServiceRestResponseData PatchTask(ActionPlanTaskInstance task, Guid?personId, Guid?recordId) { return(HealthServiceRestHelper.CallHeathServiceRest( personId, recordId, User.PersonInfo(), "PATCH", _baseTaskRestUrl, null, JsonConvert.SerializeObject(task))); }
/// <summary> /// Call the HV REST API to add the action plan task to a user's HealthVault record. /// Assigns an action plan task to a user who is not signed in ("offline" scenario) if both personId and recordId are provided. /// Otherwise, this assigns the action plan task to the user who is actively signed into the application ("online" scenario). /// See Getting Started doc for more information on offline scenarios. /// </summary> private HealthServiceRestResponseData CreateTask(ActionPlanTask task, Guid?personId, Guid?recordId) { return(HealthServiceRestHelper.CallHeathServiceRest( personId, recordId, User.PersonInfo(), HttpMethod.Post.ToString(), _baseTaskRestUrl, null, JsonConvert.SerializeObject(task))); }
/// <summary> /// Call the HV REST API to get the plan adherence for the user. /// Gets the adherence of a user who is not signed in ("offline" scenario) if both personId and recordId are provided. /// Otherwise, this gets action plan adherence of the user who is actively signed into the application ("online" scenario). /// See Getting Started doc for more information on offline scenarios. /// </summary> private HealthServiceRestResponseData GetPlanAdherence(Guid id, DateTimeOffset startTime, DateTimeOffset endTime, Guid?personId, Guid?recordId) { var queryParameters = new NameValueCollection { { nameof(startTime), startTime.ToString("o", CultureInfo.InvariantCulture) }, { nameof(endTime), endTime.ToString("o", CultureInfo.InvariantCulture) } }; return(HealthServiceRestHelper.CallHeathServiceRest( personId, recordId, User.PersonInfo(), HttpMethod.Get.ToString(), _basePlanRestUrl + id + "/Adherence", queryParameters)); }
/// <summary> /// Gets a list of people who have authorized this application to access their data. /// </summary> private List <PersonInfo> GetAuthorizedPeople() { HealthServiceRestHelper.CheckOfflineAuthorization(User.PersonInfo()); var connection = new OfflineWebApplicationConnection( HealthWebApplicationConfiguration.Current.ApplicationId, HealthWebApplicationConfiguration.Current.HealthVaultMethodUrl, Guid.Empty); // Authenticate with HealthVault using the certificate generated above connection.Authenticate(); // Iterate through all authorized users var people = connection.GetAuthorizedPeople().ToList(); return(people); }