Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PRMT-3439 - Multiple EHR requests for the same EHR from the same GP #23

Open
wants to merge 32 commits into
base: main
Choose a base branch
from

Conversation

joefong-nhs
Copy link
Contributor

  • Add an e2e test for multiple EHR request from the same GP
  • Amend the getAllMessageContaining method to account for that SQS may not return all messages in one go, and may return same message more than once on repeated polling
  • Add a private method to put a small ehr of given NHS number into EHR repo

… sec, unify the way to generate trigger message in two tests
… send the same message to consumer more than once
@joefong-nhs joefong-nhs marked this pull request as ready for review June 20, 2023 10:26
@@ -6,6 +6,7 @@ public enum Patient {
SUSPENDED_WITH_EHR_AT_TPP("9693642937"),
PATIENT_WITH_LARGE_EHR_AT_EMIS_WITH_MOF_SET_TO_REPO_DEV_ODS("9693643038"),
PATIENT_WITH_LARGE_EHR_AT_EMIS_WITH_MOF_SET_TO_REPO_TEST_ODS("9694181372"),
PATIENT_WITH_SMALL_EHR_RECORD_IN_REPO_AND_MOF_SET_TO_TPP("9727018440"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the sake of consistency, I suggest removing the word "RECORD" from the enum.

Suggested change
PATIENT_WITH_SMALL_EHR_RECORD_IN_REPO_AND_MOF_SET_TO_TPP("9727018440"),
PATIENT_WITH_SMALL_EHR_IN_REPO_AND_MOF_SET_TO_TPP("9727018440"),

String smallEhrMessageId = createUuidAsString();
String previousGpForTestPatient = "M85019";

// TODO: Consider to implement a better way of filling details into the EHR files
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This 'TODO' needs addressing.

.withEhrSourceAsRepo(config)
.withEhrDestinationGp(Gp2GpSystem.TPP_PTL_INT)
.build();
int numberOfDuplicatedMessage = 3;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider pluralising this variable to 'numberOfDuplicatedMessages'

Suggested change
int numberOfDuplicatedMessage = 3;
int numberOfDuplicatedMessages = 3;

assertThat(outboundMessages.size()).isEqualTo(1);

String outboundEhrCore = outboundMessages.get(0).body();
assertThat(outboundEhrCore).contains(testPatient.nhsNumber());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would reuse the variable 'nhsNumberForTest' that had already been assigned the method 'testPatient.nhsNumber()'.

Suggested change
assertThat(outboundEhrCore).contains(testPatient.nhsNumber());
assertThat(outboundEhrCore).contains(nhsNumberForTest);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! I have addressed the PR comments

@@ -161,4 +162,12 @@ public static LargeEhrTestFiles prepareTestFilesForLargeEhr(

return new LargeEhrTestFiles(largeEhrCore, largeEhrFragment1, largeEhrFragment2, ehrRequest, continueRequest);
}

public static String createUuidAsString() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public static String createUuidAsString() {
public static String createUUIDAsString() {

Could we capitalise UUID, please?

@@ -181,6 +181,10 @@ public String getEhrRepoUrl() {
return String.format("https://ehr-repo.%s.patient-deductions.nhs.uk/", getEnvSuffix());
}

public String getEhrOutUrl() {
return String.format("https://ehr-out-service.%s.patient-deductions.nhs.uk/", getEnvSuffix());
Copy link
Contributor

@martin-nhs martin-nhs Jul 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this not just be a class-level member constant?

Suggested change
return String.format("https://ehr-out-service.%s.patient-deductions.nhs.uk/", getEnvSuffix());
public static String EHR_OUT_URL = String.format("https://ehr-out-service.%s.patient-deductions.nhs.uk/", getEnvSuffix());

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally, reflect throughout the URLs :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!
I have addressed this by changing the urls into static constants and updating the references in the new tests that we written.

There are some references to those getXXXUrl methods in other test suites which is not in the scope of this ticket, so I added a TODO comment to address those after we finish moving all packages to main.

Comment on lines +36 to +42
public String conversationId() {
return getUUIDAsUpperCaseString(conversationId);
}

public String messageId() {
return getUUIDAsUpperCaseString(messageId);
}
Copy link
Contributor

@martin-nhs martin-nhs Jul 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these really required? I would say that if all the function does is return a single UUID in uppercase - could we not just use:

conversationId.toString().toUpperCase();
messageId.toString().toUpperCase();

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, previously we used toString().toUpperCase() here, but we extracted that to a static function as suggested by a PR comment in PRMT-3413, so probably I am keeping it like this for now.

Comment on lines 10 to 15
private UUID conversationId;
private UUID messageId;
private String sourceGpOds;
private String destinationGpOds;
private String sourceGpAsid;
private String destinationGpAsid;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These can be final :D

Suggested change
private UUID conversationId;
private UUID messageId;
private String sourceGpOds;
private String destinationGpOds;
private String sourceGpAsid;
private String destinationGpAsid;
private UUID conversationId;
private final UUID messageId;
private final String sourceGpOds;
private final String destinationGpOds;
private final String sourceGpAsid;
private final String destinationGpAsid;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, comment addressed

Comment on lines 17 to 24
public ContinueRequestMessage(UUID conversationId, UUID messageId, String sourceGpOds, String destinationGpOds, String sourceGpAsid, String destinationGpAsid) {
this.conversationId = conversationId;
this.messageId = messageId;
this.sourceGpOds = sourceGpOds;
this.destinationGpOds = destinationGpOds;
this.sourceGpAsid = sourceGpAsid;
this.destinationGpAsid = destinationGpAsid;
}
Copy link
Contributor

@martin-nhs martin-nhs Jul 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please leverage Lombok here in favour of adding the following annotation to the class level, in favour of this constructor - just removes some boilerplate stuff :)

@AllArgsConstructor

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! It's so good to know this useful annotation! Boilerplate gone now :D

Comment on lines 18 to 26
public EhrRequestMessage(String nhsNumber, String sourceGpOds, String destinationGpOds, String sourceGpAsid, String destinationGpAsid, UUID conversationId, UUID messageId) {
this.nhsNumber = nhsNumber;
this.sourceGpOds = sourceGpOds;
this.destinationGpOds = destinationGpOds;
this.sourceGpAsid = sourceGpAsid;
this.destinationGpAsid = destinationGpAsid;
this.conversationId = conversationId;
this.messageId = messageId;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as previously mentioned, please use Lombok's @AllArgsConstructor in favour of the manually defined constructor!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure! Replaced boilerplate with @ AllArgsConstructor here as well

Comment on lines +39 to +45
public String conversationId() {
return getUUIDAsUpperCaseString(conversationId);
}

public String messageId() {
return getUUIDAsUpperCaseString(messageId);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above, do we need these?

this.messageId = messageId;
}

public String toJsonString() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above again! :D

Suggested change
public String toJsonString() {
public String getJsonString() {

@@ -29,7 +30,7 @@ public void deleteAllMessages() {
log(String.format("Trying to delete all the messages on : %s", this.queueUri));
try {
thinlyWrappedSqsClient.deleteAllMessages(queueUri);
} catch (Exception e){
} catch (Exception e) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we find what exception is being thrown here and be explicit, such as IllegalArgumentException :) Additionally, please rename e in favour of exception.

Suggested change
} catch (Exception e) {
} catch (Exception exception) {

@martin-nhs
Copy link
Contributor

Brilliant! You've picked up Java fast 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants