|
4 | 4 | import io.netty.handler.ssl.SslContext; |
5 | 5 | import lombok.RequiredArgsConstructor; |
6 | 6 | import lombok.extern.slf4j.Slf4j; |
7 | | -import org.apache.commons.lang3.StringUtils; |
8 | 7 | import org.hl7.fhir.dstu3.model.BooleanType; |
9 | 8 | import org.hl7.fhir.dstu3.model.Identifier; |
10 | 9 | import org.hl7.fhir.dstu3.model.Parameters; |
|
41 | 40 | @RequiredArgsConstructor(onConstructor = @__(@Autowired)) |
42 | 41 | @Slf4j |
43 | 42 | public class GpcRequestBuilder { |
| 43 | + |
44 | 44 | @Value("${gp2gp.gpc.overrideFromAsid}") |
45 | 45 | private String overrideFromAsid; |
46 | 46 | @Value("${gp2gp.gpc.overrideToAsid}") |
47 | 47 | private String overrideToAsid; |
48 | 48 |
|
49 | 49 | private static final String NHS_NUMBER_SYSTEM = "https://fhir.nhs.uk/Id/nhs-number"; |
50 | 50 | private static final String FHIR_CONTENT_TYPE = "application/fhir+json"; |
51 | | - private static final String SSP_FROM = "Ssp-From"; |
52 | 51 | private static final String SSP_INTERACTION_ID = "Ssp-InteractionID"; |
53 | 52 | private static final String SSP_TRACE_ID = "Ssp-TraceID"; |
54 | 53 | private static final String AUTHORIZATION = "Authorization"; |
@@ -130,36 +129,14 @@ private WebClient buildWebClient(HttpClient httpClient, String baseUrl) { |
130 | 129 | } |
131 | 130 |
|
132 | 131 | private RequestBodySpec buildRequestWithHeaders(RequestBodySpec uri, TaskDefinition taskDefinition, String interactionId) { |
133 | | - /* |
134 | | - * SSP_FROM must be set to GP2GP ASID which is stored in the toAsid property of the task |
135 | | - * SSP_TO is left blank as it will be set in the GPC Consumer Proxy |
136 | | - */ |
| 132 | + |
137 | 133 | return uri.accept(MediaType.valueOf(FHIR_CONTENT_TYPE)) |
138 | | - .header(SSP_FROM, getToAsid(taskDefinition.getToAsid())) |
139 | 134 | .header(SSP_INTERACTION_ID, interactionId) |
140 | 135 | .header(SSP_TRACE_ID, taskDefinition.getConversationId()) |
141 | 136 | .header(AUTHORIZATION, AUTHORIZATION_BEARER + gpcTokenBuilder.buildToken(taskDefinition.getFromOdsCode())) |
142 | 137 | .header(CONTENT_TYPE, FHIR_CONTENT_TYPE); |
143 | 138 | } |
144 | 139 |
|
145 | | - private String getFromAsid(String fromAsid) { |
146 | | - if (StringUtils.isNotBlank(overrideFromAsid)) { |
147 | | - LOGGER.warn("GP2GP_GPC_OVERRIDE_FROM_ASID is being used, no longer using provided from asid"); |
148 | | - return overrideFromAsid; |
149 | | - } else { |
150 | | - return fromAsid; |
151 | | - } |
152 | | - } |
153 | | - |
154 | | - private String getToAsid(String toAsid) { |
155 | | - if (StringUtils.isNotBlank(overrideToAsid)) { |
156 | | - LOGGER.warn("GP2GP_GPC_OVERRIDE_TO_ASID is being used, no longer using provided to asid"); |
157 | | - return overrideToAsid; |
158 | | - } else { |
159 | | - return toAsid; |
160 | | - } |
161 | | - } |
162 | | - |
163 | 140 | private RequestHeadersSpec<?> buildRequestWithHeadersAndBody(RequestBodySpec uri, String requestBody, |
164 | 141 | BodyInserter<Object, ReactiveHttpOutputMessage> bodyInserter, TaskDefinition taskDefinition, String interactionId) { |
165 | 142 | return buildRequestWithHeaders(uri, taskDefinition, interactionId) |
|
0 commit comments