public HttpRequestConfiguration GetHttpRequestConfiguration(GpConnectInteraction interaction, HttpRequestConfiguration httpRequestConfiguration = null)
        {
            if (httpRequestConfiguration == null)
            {
                httpRequestConfiguration = new HttpRequestConfiguration();
            }

            var httpRequestConfigurationFactory = new HttpRequestConfigurationFactory(interaction, httpRequestConfiguration);

            return(httpRequestConfigurationFactory.GetHttpRequestConfiguration());
        }
        public Resource GetResourceForRelativeUrl(GpConnectInteraction gpConnectInteraction, string relativeUrl)
        {
            var httpRequestConfiguration = new HttpRequestConfiguration();

            var httpContextFactory = new HttpRequestConfigurationFactory(gpConnectInteraction, httpRequestConfiguration);

            httpContextFactory.GetHttpRequestConfiguration();

            var jwtHelper  = new JwtHelper();
            var jwtFactory = new JwtFactory(gpConnectInteraction);

            jwtFactory.ConfigureJwt(jwtHelper);

            if (relativeUrl.Contains("Patient"))
            {
                var patient = relativeUrl.ToLower().Replace("/", string.Empty);
                try
                {
                    jwtHelper.RequestedPatientNHSNumber = GlobalContext.PatientNhsNumberMap[patient];
                }
                catch (Exception)
                {
                    Patient patientResource = _fhirResourceRepository.Patient;
                    var     nhsNumber       = patientResource.Identifier[0].Value;
                    jwtHelper.RequestedPatientNHSNumber = nhsNumber;
                }
            }

            if (relativeUrl.Contains("Organization"))
            {
                var organizationId = relativeUrl.Split('/')[1];
                jwtHelper.RequestedOrganizationId = organizationId;
            }

            httpRequestConfiguration.RequestUrl = relativeUrl;

            _securitySteps.ConfigureServerCertificatesAndSsl();

            var requestFactory = new RequestFactory(gpConnectInteraction, _fhirResourceRepository);

            requestFactory.ConfigureBody(httpRequestConfiguration);

            httpRequestConfiguration.RequestHeaders.ReplaceHeader(HttpConst.Headers.kAuthorization, jwtHelper.GetBearerToken());

            var httpRequest = new HttpResourceRequest(httpRequestConfiguration, _securityContext);

            return(httpRequest.MakeRequest().Resource);
        }