Skip to content

Commit 3fa64f7

Browse files
committed
using a more appropriate error code
1 parent e851152 commit 3fa64f7

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

service/src/main/java/uk/nhs/adaptors/gp2gp/ehr/EhrResendController.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
public class EhrResendController {
3131

3232
private static final String OPERATION_OUTCOME_URL = "https://fhir.nhs.uk/STU3/StructureDefinition/GPConnect-OperationOutcome-1";
33-
private static final String FORBIDDEN = "FORBIDDEN";
33+
private static final String CONFLICT = "CONFLICT";
3434
private static final String INVALID_IDENTIFIER_VALUE = "INVALID_IDENTIFIER_VALUE";
3535

3636
private EhrExtractStatusRepository ehrExtractStatusRepository;
@@ -58,14 +58,14 @@ public ResponseEntity<String> scheduleEhrExtractResend(@PathVariable String conv
5858

5959
if (hasNoErrorsInEhrReceivedAcknowledgement(ehrExtractStatus) && ehrExtractStatus.getError() == null) {
6060

61-
var details = getCodeableConcept(FORBIDDEN);
61+
var details = getCodeableConcept(CONFLICT);
6262
var diagnostics = "The current resend operation is still in progress. Please wait for it to complete before retrying";
6363
var operationOutcome = createOperationOutcome(OperationOutcome.IssueType.BUSINESSRULE,
6464
OperationOutcome.IssueSeverity.ERROR,
6565
details,
6666
diagnostics);
6767
var errorBody = fhirParseService.encodeToJson(operationOutcome);
68-
return new ResponseEntity<>(errorBody, HttpStatus.FORBIDDEN);
68+
return new ResponseEntity<>(errorBody, HttpStatus.CONFLICT);
6969
}
7070

7171
LOGGER.info("Creating tasks to start the EHR Extract process resend");

service/src/test/java/uk/nhs/adaptors/gp2gp/ehr/EhrResendControllerTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class EhrResendControllerTest {
4646
private static final String FROM_ASID_CODE = "test-from-asid";
4747
private static final String INCUMBENT_NACK_CODE = "99";
4848
private static final String INCUMBENT_NACK_DISPLAY = "Unexpected condition.";
49-
private static final String FORBIDDEN = "FORBIDDEN";
49+
private static final String CONFLICT = "CONFLICT";
5050
private static final String GPCONNECT_ERROR_OR_WARNING_CODE = "http://fhir.nhs.net/ValueSet/gpconnect-error-or-warning-code-1";
5151
private static final String INVALID_IDENTIFIER_VALUE = "INVALID_IDENTIFIER_VALUE";
5252
public static final String ISSUE_CODE_VALUE = "value";
@@ -144,8 +144,8 @@ void When_AnEhrExtractHasNotFailedAndAnotherResendRequestArrives_Expect_FailedOp
144144
JsonNode rootNode = objectMapper.readTree(response.getBody());
145145

146146
assertAll(
147-
() -> assertResponseHasExpectedOperationOutcome(rootNode, FORBIDDEN, DIAGNOSTICS_MSG, ISSUE_CODE_BUSINESS_RULE),
148-
() -> assertEquals(HttpStatus.FORBIDDEN, response.getStatusCode())
147+
() -> assertResponseHasExpectedOperationOutcome(rootNode, CONFLICT, DIAGNOSTICS_MSG, ISSUE_CODE_BUSINESS_RULE),
148+
() -> assertEquals(HttpStatus.CONFLICT, response.getStatusCode())
149149
);
150150
}
151151

@@ -199,8 +199,8 @@ void When_AnEhrExtractHasNotFailed_Expect_RespondsWith403() throws JsonProcessin
199199
JsonNode rootNode = objectMapper.readTree(response.getBody());
200200

201201
assertAll(
202-
() -> assertResponseHasExpectedOperationOutcome(rootNode, FORBIDDEN, DIAGNOSTICS_MSG, ISSUE_CODE_BUSINESS_RULE),
203-
() -> assertEquals(HttpStatus.FORBIDDEN, response.getStatusCode())
202+
() -> assertResponseHasExpectedOperationOutcome(rootNode, CONFLICT, DIAGNOSTICS_MSG, ISSUE_CODE_BUSINESS_RULE),
203+
() -> assertEquals(HttpStatus.CONFLICT, response.getStatusCode())
204204
);
205205
}
206206

0 commit comments

Comments
 (0)