/// <summary>
        /// Makes a call to the Health REST service to edit another user who has authorized this application.
        /// This is the type of call that a hospital would make on the behalf of a patient.
        /// </summary>
        public static HealthServiceRestResponseData CallHeathServiceRestOffline(Guid personId, Guid recordId, PersonInfo loggedInPersonInfo, string httpVerb, string path, NameValueCollection queryStringParameters = null, string requestBody = null, NameValueCollection optionalHeaders = null)
        {
            CheckOfflineAuthorization(loggedInPersonInfo);

            // Person and record ID identify the patient for whom to retrieve the plans.
            var connection = new OfflineWebApplicationConnection(
                HealthWebApplicationConfiguration.Current.ApplicationId,
                HealthWebApplicationConfiguration.Current.HealthVaultMethodUrl,
                personId);

            // Authenticate with HealthVault using the connection generated above
            connection.Authenticate();

            // Using the HealthVault SDK, make a HTTP call.
            // The root URL comes from the web.config (RestHealthServiceUrl).
            var request = new HealthServiceRestRequest(
                connection,
                httpVerb,
                path,
                queryStringParameters,
                requestBody,
                optionalHeaders: optionalHeaders)
            {
                // Person and record ID identify the patient for whom to retrieve the plans.
                RecordId = recordId
            };

            request.Execute();

            return(request.Response);
        }
        /// <summary>
        /// Call the HV REST API to generate the invitation code.
        /// </summary>
        /// <param name="onboardingRequest"></param>
        private static HealthServiceRestResponseData GenerateInviteCode(OnboardingRequest onboardingRequest)
        {
            // 2. Using the HealthVault SDK, make a HTTP POST call to get an invitation code for participant.
            // The root URL comes from the web.config (RestHealthServiceUrl).
            var request = new HealthServiceRestRequest(
                WebApplicationUtilities.ApplicationConnection,
                "POST",
                "v3/onboarding/generateinvitecode",
                null,
                JsonConvert.SerializeObject(onboardingRequest));

            request.Execute();

            return(request.Response);
        }
        /// <summary>
        /// Makes a call to the Health REST service to edit data for the logged in user.
        /// This is the type of call that an interactive patient application would use.
        /// </summary>
        public static HealthServiceRestResponseData CallHeathServiceRestOnline(PersonInfo loggedInPersonInfo, string httpVerb, string path, NameValueCollection queryStringParameters = null, string requestBody = null, NameValueCollection optionalHeaders = null)
        {
            // Using the HealthVault SDK, make a HTTP call.
            // The root URL comes from the web.config (RestHealthServiceUrl).
            var request = new HealthServiceRestRequest(
                loggedInPersonInfo.Connection,
                httpVerb,
                path,
                queryStringParameters,
                requestBody,
                optionalHeaders: optionalHeaders)
            {
                // Person and record ID identify the patient for whom to retrieve the plan.
                RecordId = loggedInPersonInfo.SelectedRecord.Id
            };

            request.Execute();

            return(request.Response);
        }