Skip to content

Commit

Permalink
[PRMT-4860] Ignore destinationGp field and don't persist it on inboun…
Browse files Browse the repository at this point in the history
…d requests - repo ODS code now comes from SSM (#265)

* [PRMT-4860] Ignore destinationGp field and don't persist it on inbound requests - repo ODS code now comes from SSM

* [PRMT-4860] ignore nemsEventLastUpdatedField on RepoIncomingRequest

---------

Co-authored-by: Andy Flint <[email protected]>
  • Loading branch information
AndyFlintNHS and AndyFlintAnswerDigital authored Jun 10, 2024
1 parent 4fc1b32 commit 80cd2f3
Show file tree
Hide file tree
Showing 14 changed files with 20 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ public class TransferServiceTest {
private static final String NHS_NUMBER = "9798547485";
private static final String SOURCE_GP = "B45744";
private static final String NEMS_MESSAGE_ID = "2d74a113-1076-4c63-91bc-e50d232b6a79";
private static final String DESTINATION_GP = "A74854";
private static final String NEMS_EVENT_LAST_UPDATED = "2023-10-09T15:38:03.291499328Z";
private static final String EHR_CORE_MESSAGE_ID = "13CD1199-4B3A-44DC-9A60-6ABCC22B8A44";

@Test
Expand Down Expand Up @@ -278,8 +276,6 @@ private RepoIncomingEvent createRepoIncomingEvent(UUID inboundConversationId) {
.nhsNumber(NHS_NUMBER)
.sourceGp(SOURCE_GP)
.nemsMessageId(NEMS_MESSAGE_ID)
.destinationGp(DESTINATION_GP)
.nemsEventLastUpdated(NEMS_EVENT_LAST_UPDATED)
.conversationId(inboundConversationId.toString().toUpperCase())
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ public class NegativeAcknowledgmentHandlingIntegrationTest {
private static final String NHS_NUMBER = "9798547485";
private static final String SOURCE_GP = "B45744";
private static final String NEMS_MESSAGE_ID = "2d74a113-1076-4c63-91bc-e50d232b6a79";
private static final String DESTINATION_GP = "A74854";
private static final String CONVERSATION_ID = "13962CB7-6D46-4986-BDB4-3201BB25F1F7";
private static final String NEMS_EVENT_LAST_UPDATED = "2023-10-09T15:38:03.291499328Z";

@BeforeEach
public void tearDown() {
Expand Down Expand Up @@ -79,8 +77,6 @@ private UUID createConversationRecord() {
NHS_NUMBER,
SOURCE_GP,
NEMS_MESSAGE_ID,
DESTINATION_GP,
NEMS_EVENT_LAST_UPDATED,
CONVERSATION_ID
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,8 @@ public class ParserBrokerIntegrationTest {
private static final UUID COPC_INBOUND_CONVERSATION_ID = UUID.fromString("ff1457fb-4f58-4870-8d90-24d9c3ef8b91");
private static final UUID EHR_CORE_INBOUND_CONVERSATION_ID = UUID.fromString("ff27abc3-9730-40f7-ba82-382152e6b90a");
private static final String SOURCE_GP = "A74154";
private static final String DESTINATION_GP = "B74158";
private static final UUID NEMS_MESSAGE_ID = UUID.fromString("ad9246ce-b337-4ba9-973f-e1284e1f79c7");
private static final String NHS_NUMBER = "9896589658";
private static final String NEMS_EVENT_LAST_UPDATED = "2023-10-09T15:38:03.291499328Z";

@AfterEach
public void tearDown() {
Expand Down Expand Up @@ -235,9 +233,7 @@ private RepoIncomingEvent createDefaultRepoIncomingEvent(UUID inboundConversatio
.conversationId(inboundConversationId.toString().toUpperCase())
.nhsNumber(NHS_NUMBER)
.sourceGp(SOURCE_GP)
.destinationGp(DESTINATION_GP)
.nemsMessageId(NEMS_MESSAGE_ID.toString())
.nemsEventLastUpdated(NEMS_EVENT_LAST_UPDATED)
.build();
}
}
1 change: 1 addition & 0 deletions src/integration/resources/application-test.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ environment=${NHS_ENVIRONMENT:local}
log_level=DEBUG
aws.region=${AWS_REGION:eu-west-2}
localstack.url=${LOCALSTACK_URL:http://localhost:4587}
repositoryOdsCode=${REPOSITORY_ODS_CODE:some-ods-code}
repositoryAsid=${REPOSITORY_ASID:some-asid}

aws.repoIncomingQueueName=test_repo_incoming_queue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@ void createConversation(RepoIncomingEvent event) {
.s(event.getSourceGp())
.build());

tableItem.put(DESTINATION_GP.name, AttributeValue.builder()
.s(event.getDestinationGp())
.build());

tableItem.put(TRANSFER_STATUS.name, AttributeValue.builder()
.s(INBOUND_STARTED.name())
.build());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package uk.nhs.prm.repo.ehrtransferservice.repo_incoming;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
Expand All @@ -9,11 +10,10 @@
@Builder
@AllArgsConstructor
@NoArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
public class RepoIncomingEvent {
private String nhsNumber;
private String sourceGp;
private String nemsMessageId;
private String destinationGp;
private String nemsEventLastUpdated;
private String conversationId;
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@ public class Gp2gpMessengerService {
private final Gp2gpMessengerClient gp2gpMessengerClient;
private final TransferService transferService;

@Value("${repositoryOdsCode}")
private String repositoryOdsCode;

@Value("${repositoryAsid}")
private String repositoryAsid;

public void sendEhrRequest(RepoIncomingEvent repoIncomingEvent) throws Exception {
final UUID inboundConversationId = UUID.fromString(repoIncomingEvent.getConversationId());
final Gp2gpMessengerEhrRequestBody requestBody = new Gp2gpMessengerEhrRequestBody(
repoIncomingEvent.getDestinationGp(),
repositoryOdsCode,
repositoryAsid,
repoIncomingEvent.getSourceGp(),
repoIncomingEvent.getConversationId().toUpperCase()
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
environment=${NHS_ENVIRONMENT:local}
aws.region=${AWS_REGION:eu-west-2}
repositoryOdsCode=${REPOSITORY_ODS_CODE}
repositoryAsid=${REPOSITORY_ASID}

aws.transferTrackerDbTableName=${TRANSFER_TRACKER_DB_NAME:DBNAME}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ class TransferServiceTest {
private static final String NHS_NUMBER = "9798547485";
private static final String SOURCE_GP = "B45744";
private static final String NEMS_MESSAGE_ID = "2d74a113-1076-4c63-91bc-e50d232b6a79";
private static final String DESTINATION_GP = "A74854";
private static final String NEMS_EVENT_LAST_UPDATED = "2023-10-09T15:38:03.291499328Z";

@Test
void createExceptionOrResetForRetry_ValidNewConversationOrResetForRetryRequest_Ok() {
Expand Down Expand Up @@ -217,8 +215,6 @@ private RepoIncomingEvent createRepoIncomingEvent(UUID inboundConversationId) {
.nhsNumber(NHS_NUMBER)
.sourceGp(SOURCE_GP)
.nemsMessageId(NEMS_MESSAGE_ID)
.destinationGp(DESTINATION_GP)
.nemsEventLastUpdated(NEMS_EVENT_LAST_UPDATED)
.conversationId(inboundConversationId.toString().toUpperCase())
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,6 @@ private static Stream<Arguments> ArgumentsOfExceptionsThatShouldNotAcknowledge()
}

private RepoIncomingEvent getIncomingEvent() {
return new RepoIncomingEvent("111111111", "source-gp", "nem-message-id", "destination-gp", "last-updated", "unique-uuid");
return new RepoIncomingEvent("111111111", "source-gp", "nem-message-id", "unique-uuid");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.*;
import static uk.nhs.prm.repo.ehrtransferservice.utils.TestDataUtility.REPOSITORY_ASID;
import static uk.nhs.prm.repo.ehrtransferservice.utils.TestDataUtility.createRepoIncomingEvent;
import static uk.nhs.prm.repo.ehrtransferservice.utils.TestDataUtility.*;

@ExtendWith(MockitoExtension.class)
class Gp2gpMessengerServiceTest {
Expand Down Expand Up @@ -66,6 +65,7 @@ void sendEhrRequest_ValidRepoIncomingEvent_SendGp2gpMessengerEhrRequest() throws
final RepoIncomingEvent event = createRepoIncomingEvent(INBOUND_CONVERSATION_ID);

// when
ReflectionTestUtils.setField(gp2gpMessengerService, "repositoryOdsCode", REPOSITORY_ODS_CODE);
ReflectionTestUtils.setField(gp2gpMessengerService, "repositoryAsid", REPOSITORY_ASID);
gp2gpMessengerService.sendEhrRequest(event);

Expand All @@ -83,6 +83,7 @@ void sendEhrRequest_SendGp2gpMessengerEhrRequestThrowsHttpException_ThrowNewExce
final Exception exception = new HttpException();

// when
ReflectionTestUtils.setField(gp2gpMessengerService, "repositoryOdsCode", REPOSITORY_ODS_CODE);
ReflectionTestUtils.setField(gp2gpMessengerService, "repositoryAsid", REPOSITORY_ASID);
doThrow(exception)
.when(gp2gpMessengerClient)
Expand Down Expand Up @@ -130,6 +131,7 @@ void sendEhrCompletePositiveAcknowledgement_SendGp2gpMessengerPositiveAcknowledg
final Exception exception = new HttpException();

// when
ReflectionTestUtils.setField(gp2gpMessengerService, "repositoryOdsCode", REPOSITORY_ODS_CODE);
ReflectionTestUtils.setField(gp2gpMessengerService, "repositoryAsid", REPOSITORY_ASID);
when(transferService.getConversationByInboundConversationId(INBOUND_CONVERSATION_ID))
.thenReturn(conversationRecord);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,14 @@ private TestDataUtility() { }
public static final String NHS_NUMBER = "9798547485";
public static final String SOURCE_GP = "B45744";
public static final String NEMS_MESSAGE_ID = "2d74a113-1076-4c63-91bc-e50d232b6a79";
public static final String DESTINATION_GP = "A74854";
public static final String NEMS_EVENT_LAST_UPDATED = "2023-10-09T15:38:03.291499328Z";
public static final String REPOSITORY_ASID = "REPOSITORY";
public static final String REPOSITORY_ODS_CODE = "REPOSITORY_ODS_CODE";
public static final String REPOSITORY_ASID = "REPOSITORY_ASID";

public static RepoIncomingEvent createRepoIncomingEvent(UUID inboundConversationId) {
return RepoIncomingEvent.builder()
.nhsNumber(NHS_NUMBER)
.sourceGp(SOURCE_GP)
.nemsMessageId(NEMS_MESSAGE_ID)
.destinationGp(DESTINATION_GP)
.nemsEventLastUpdated(NEMS_EVENT_LAST_UPDATED)
.conversationId(inboundConversationId.toString().toUpperCase())
.build();
}
Expand Down
4 changes: 4 additions & 0 deletions terraform/data.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ data "aws_ssm_parameter" "ehr_transfer_service_authorization_keys_for_gp2gp_mess
name = "/repo/${var.environment}/user-input/api-keys/gp2gp-messenger/ehr-transfer-service"
}

data "aws_ssm_parameter" "repository_ods_code" {
name = "/repo/${var.environment}/user-input/external/repository-ods-code"
}

data "aws_ssm_parameter" "repository_asid" {
name = "/repo/${var.environment}/user-input/external/repository-asid"
}
Expand Down
1 change: 1 addition & 0 deletions terraform/ecs-task.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ locals {
name = "EHR_TRANSFER_SERVICE_GP2GP_MESSENGER_URL",
value = "https://gp2gp-messenger.${data.aws_ssm_parameter.env_domain_name.value}"
},
{ name = "REPOSITORY_ODS_CODE", value = data.aws_ssm_parameter.repository_ods_code.value },
{ name = "REPOSITORY_ASID", value = data.aws_ssm_parameter.repository_asid.value },
{ name = "SQS_LARGE_MESSAGE_BUCKET_NAME", value = aws_s3_bucket.sqs_large_message_bucket.bucket },
{ name = "SMALL_EHR_TOPIC_ARN", value = aws_sns_topic.small_ehr.arn },
Expand Down

0 comments on commit 80cd2f3

Please sign in to comment.