Skip to content

Commit c32b843

Browse files
GP2GP Handles Handle empty Access Structure Record
1 parent 855c2b5 commit c32b843

File tree

12 files changed

+790
-76
lines changed

12 files changed

+790
-76
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515
* The GP2GP Adaptor now adds the EhrComposition / confidentialityCode field when Encounter.meta.security contains NOPAT security entry
1616
* The GP2GP Adaptor now populates the ObservationStatement / confidentialityCode field when the .meta.security field of an Uncategorized Data Observation contains NOPAT
1717
* When List.meta.security field contains NOPAT, the GP2GP Adaptor will now populate the CompoundStatement.confidentialityCode
18+
* The GP2GP Adaptor now throws an exception when the Access Structure Record is empty, thereby rejecting the transfer
1819

1920
### Fixed
2021
* When DiagnosticReport doesn't contain a Specimen reference, instead of "DUMMY" "NOT-PRESENT" value is used

docker/run-e2e-tests.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
set -e
44

5-
if [ -f "vars.sh" ]; then
6-
source vars.sh
5+
if [ -f "vars.local.e2e.sh" ]; then
6+
source vars.local.e2e.sh
77
else
8-
echo "No vars.sh defined. Using docker-compose defaults."
8+
echo "No vars.local.e2e.sh defined. Using docker-compose defaults."
99
fi
1010
if [[ "$(docker network ls | grep "commonforgp2gp")" == "" ]] ; then
1111
docker network create commonforgp2gp

e2e-tests/src/test/java/uk/nhs/adaptors/gp2gp/e2e/EhrExtractTest.java

Lines changed: 94 additions & 69 deletions
Large diffs are not rendered by default.

service/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,13 @@ dependencies {
8484
testImplementation 'org.wiremock:wiremock-standalone:3.13.1'
8585
testImplementation 'com.squareup.okhttp3:okhttp:5.1.0'
8686
testImplementation 'com.squareup.okhttp3:mockwebserver3:5.1.0'
87-
testImplementation 'com.adobe.testing:s3mock-testcontainers:4.9.1'
87+
testImplementation 'com.adobe.testing:s3mock-testcontainers:4.7.0'
8888

8989
spotbugs 'com.github.spotbugs:spotbugs:4.9.6'
9090
spotbugs 'com.github.spotbugs:spotbugs-annotations:4.9.6'
9191

9292
pitest 'com.arcmutate:base:1.3.2'
93-
pitest 'com.arcmutate:pitest-git-plugin:2.2.4'
93+
pitest 'com.arcmutate:pitest-git-plugin:2.1.0'
9494
}
9595

9696
test {
@@ -165,7 +165,7 @@ spotbugsMain {
165165
}
166166

167167
pitest {
168-
pitestVersion = '1.16.1'
168+
pitestVersion = '1.16.3'
169169
junit5PluginVersion = '1.2.1'
170170
outputFormats = ['gitci']
171171

service/src/intTest/java/uk/nhs/adaptors/gp2gp/ehr/SendEhrExtractCoreComponentTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
@ExtendWith({SpringExtension.class, MongoDBExtension.class, ActiveMQExtension.class, MockitoExtension.class})
6565
@SpringBootTest
6666
@DirtiesContext
67+
@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
6768
public class SendEhrExtractCoreComponentTest extends BaseTaskTest {
6869
private static final String OUTBOUND_MESSAGE = serializeOutboundMessage("payload");
6970
public static final String OUTBOUND_MESSAGE_WITH_PLACEHOLDER =

service/src/intTest/java/uk/nhs/adaptors/gp2gp/testcontainers/ActiveMqContainer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public static ActiveMqContainer getInstance() {
2222
@Override
2323
public void start() {
2424
super.start();
25-
var containerBrokerUri = "amqp://" + getContainerIpAddress() + ":" + getMappedPort(ACTIVEMQ_PORT);
25+
var containerBrokerUri = "amqp://" + getHost() + ":" + getMappedPort(ACTIVEMQ_PORT);
2626
System.setProperty("GP2GP_AMQP_BROKERS", containerBrokerUri);
2727
}
2828
}

service/src/main/java/uk/nhs/adaptors/gp2gp/common/task/TaskErrorHandler.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import uk.nhs.adaptors.gp2gp.ehr.exception.EhrExtractException;
1717
import uk.nhs.adaptors.gp2gp.ehr.exception.EhrMapperException;
1818
import uk.nhs.adaptors.gp2gp.gpc.exception.EhrRequestException;
19+
import uk.nhs.adaptors.gp2gp.ehr.exception.EhrValidationException;
1920
import uk.nhs.adaptors.gp2gp.gpc.exception.GpConnectException;
2021
import uk.nhs.adaptors.gp2gp.gpc.exception.GpConnectInvalidException;
2122
import uk.nhs.adaptors.gp2gp.gpc.exception.GpConnectNotFoundException;
@@ -31,6 +32,7 @@ public class TaskErrorHandler {
3132
EhrExtractException.class, this::handleTranslationError,
3233
EhrMapperException.class, this::handleTranslationError,
3334
FhirValidationException.class, this::handleTranslationError,
35+
EhrValidationException.class, this::handleTranslationError,
3436
GpConnectException.class, this::handleGpConnectError,
3537
GpConnectInvalidException.class, this::handleInvalidNotAuthError,
3638
GpConnectNotFoundException.class, this::handleNotFoundError,
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package uk.nhs.adaptors.gp2gp.ehr.exception;
2+
3+
public class EhrValidationException extends RuntimeException {
4+
5+
public EhrValidationException(String message) {
6+
super(message);
7+
}
8+
}

service/src/main/java/uk/nhs/adaptors/gp2gp/ehr/mapper/EhrExtractMapper.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import uk.nhs.adaptors.gp2gp.ehr.utils.StatementTimeMappingUtils;
2121
import uk.nhs.adaptors.gp2gp.ehr.utils.TemplateUtils;
2222
import uk.nhs.adaptors.gp2gp.gpc.GetGpcStructuredTaskDefinition;
23+
import uk.nhs.adaptors.gp2gp.ehr.exception.EhrValidationException;
2324

2425
import java.util.List;
2526
import java.util.Optional;
@@ -56,6 +57,12 @@ public EhrExtractTemplateParameters mapBundleToEhrFhirExtractParams(
5657
mappedComponents.addAll(nonConsultationResourceMapper.mapRemainingResourcesToEhrCompositions(bundle));
5758
ehrExtractTemplateParameters.setComponents(mappedComponents);
5859

60+
if (mappedComponents.isEmpty()) {
61+
final String message = "could not extract EHR Extract: empty structured access record.";
62+
LOGGER.error(message);
63+
throw new EhrValidationException(message);
64+
}
65+
5966
ehrExtractTemplateParameters.setAgentDirectory(
6067
agentDirectoryMapper.mapEHRFolderToAgentDirectory(bundle, getPatientNhsNumber(getGpcStructuredTaskDefinition))
6168
);

service/src/test/java/uk/nhs/adaptors/gp2gp/common/task/TaskErrorHandlerTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import uk.nhs.adaptors.gp2gp.ehr.exception.EhrExtractException;
3232
import uk.nhs.adaptors.gp2gp.ehr.exception.EhrMapperException;
3333
import uk.nhs.adaptors.gp2gp.gpc.exception.EhrRequestException;
34+
import uk.nhs.adaptors.gp2gp.ehr.exception.EhrValidationException;
3435
import uk.nhs.adaptors.gp2gp.gpc.exception.GpConnectException;
3536
import uk.nhs.adaptors.gp2gp.gpc.exception.GpConnectInvalidException;
3637
import uk.nhs.adaptors.gp2gp.gpc.exception.GpConnectNotFoundException;
@@ -65,6 +66,17 @@ void When_HandleProcessingError_WithEhrRequestException_Expect_ProcessToBeFailed
6566
any());
6667
}
6768

69+
@Test
70+
void When_HandleProcessingError_WithEhrValidationException_Expect_ProcessToBeFailedWithCorrectCode() {
71+
taskErrorHandler.handleProcessingError(new EhrValidationException(TEST_EXCEPTION_MESSAGE), taskDefinition);
72+
73+
verify(processFailureHandlingService).failProcess(
74+
any(),
75+
eq("10"),
76+
eq("Failed to successfully generate EHR Extract."),
77+
any());
78+
}
79+
6880
@Test
6981
void When_HandleProcessingError_WithEhrRequestException_Expect_ReturnValueOfFailService() {
7082
when(processFailureHandlingService.failProcess(any(), any(), any(), any()))

0 commit comments

Comments
 (0)