public JwtHelper GetJwtHelper(GpConnectInteraction interaction, JwtHelper jwtHelper = null)
        {
            if (jwtHelper == null)
            {
                jwtHelper = new JwtHelper();
            }

            var jwtFactory = new JwtFactory(interaction);

            jwtFactory.ConfigureJwt(jwtHelper);

            return(jwtHelper);
        }
        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);
        }