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

Small Code optimizations #728

Merged
merged 1 commit into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ public final Meta createMetaAndAddSecurityIfConfidentialityCodesPresent(String m
}

private boolean isNopat(CV coding) {
return coding.getCode().equals("NOPAT");
return "NOPAT".equals(coding.getCode());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void When_CreatingMedicationRequest_Expect_ContextAndSubjectMappedAppropr
public void When_CreatingPrescriptionTypeExtension_Expect_AcuteValues() {
var supplyAuth = unmarshallSupplyAuthorise("buildPrescriptionAcute.xml");
var extension = MedicationMapperUtils.buildPrescriptionTypeExtension(supplyAuth);
assertThat(extension.isPresent()).isTrue();
assertThat(extension).isPresent();
extension.ifPresent(extension1 -> {
assertThat(extension1.getValue()).isInstanceOf(CodeableConcept.class);
var codeableConcept = (CodeableConcept) extension1.getValue();
Expand All @@ -52,7 +52,7 @@ public void When_CreatingPrescriptionTypeExtension_Expect_AcuteValues() {
public void When_CreatingPrescriptionTypeExtension_Expect_RepeatValues() {
var supplyAuth = unmarshallSupplyAuthorise("buildPrescriptionRepeat.xml");
var extension = MedicationMapperUtils.buildPrescriptionTypeExtension(supplyAuth);
assertThat(extension.isPresent()).isTrue();
assertThat(extension).isPresent();
extension.ifPresent(extension1 -> {
assertThat(extension1.getValue()).isInstanceOf(CodeableConcept.class);
var codeableConcept = (CodeableConcept) extension1.getValue();
Expand Down Expand Up @@ -89,7 +89,7 @@ public void When_CreatingDosageQuantity_Expect_ValueToBeMapped() {
var supplyAuth = unmarshallSupplyAuthorise("supplyWithQuantity.xml");
var quantity = MedicationMapperUtils.buildDosageQuantity(supplyAuth.getQuantity());

assertThat(quantity.isPresent()).isTrue();
assertThat(quantity).isPresent();
quantity.ifPresent(value -> {
assertThat(value.getValue().intValue()).isEqualTo(EXPECTED_QUANTITY_SIZE);
assertThat(value.getUnit()).isEqualTo("capsule");
Expand All @@ -108,7 +108,7 @@ public void When_ExtractingSupplyAuthoriseId_Expect_IdToBeExtractedCorrectly() {
var supplyAuth = unmarshallSupplyAuthorise("supplyWithInvalidQuantity.xml");
var authoriseId = MedicationMapperUtils.extractEhrSupplyAuthoriseId(supplyAuth);

assertThat(authoriseId.isPresent()).isTrue();
assertThat(authoriseId).isPresent();
authoriseId.ifPresent(
id -> {
assertThat(id).isEqualTo(AUTHORISE_ID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void When_MappingPrescribeResourceWithAllOptionals_Expect_AllFieldsToBeMa
when(medicationMapper.extractMedicationReference(any()))
.thenReturn(Optional.of(new Reference(new IdType(ResourceType.Medication.name(), MEDICATION_ID))));

assertThat(prescribe.isPresent()).isTrue();
assertThat(prescribe).isPresent();
var medicationRequest = medicationRequestOrderMapper.mapToOrderMedicationRequest(new RCMRMT030101UKEhrExtract(),
medicationStatement, prescribe.get(), PRACTISE_CODE);
assertCommonValues(medicationRequest);
Expand All @@ -88,7 +88,7 @@ public void When_MappingPrescribeResourceWithNoOptionals_Expect_AllFieldsToBeMap
when(medicationMapper.extractMedicationReference(any()))
.thenReturn(Optional.of(new Reference(new IdType(ResourceType.Medication.name(), MEDICATION_ID))));

assertThat(prescribe.isPresent()).isTrue();
assertThat(prescribe).isPresent();
var medicationRequest = medicationRequestOrderMapper.mapToOrderMedicationRequest(new RCMRMT030101UKEhrExtract(),
medicationStatement, prescribe.get(), PRACTISE_CODE);
assertCommonValues(medicationRequest);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public void When_MappingAuthoriseResourceEffectiveTimeWithNullHighValue_Expect_N
final var repeatInformation = medicationRequest.getExtensionsByUrl(REPEAT_INFO_URL);
assertThat(repeatInformation).hasSize(1);

assertThat(repeatInformation.get(0).getExtensionsByUrl(REPEATS_EXPIRY_DATE_URL)).hasSize(0);
assertThat(repeatInformation.get(0).getExtensionsByUrl(REPEATS_EXPIRY_DATE_URL)).isEmpty();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void When_MappingPrescribeResourceWithNoOptionals_Expect_AllFieldsToBeMap
when(medicationMapper.extractMedicationReference(any()))
.thenReturn(Optional.of(new Reference(new IdType(ResourceType.Medication.name(), MEDICATION_ID))));

assertThat(authorise.isPresent()).isTrue();
assertThat(authorise).isPresent();
var medicationStatement1 = medicationStatementMapper.mapToMedicationStatement(
ehrExtract, medicationStatement, authorise.get(), PRACTISE_CODE, new DateTimeType());

Expand Down Expand Up @@ -96,7 +96,7 @@ public void When_MappingPrescribeResourceWithNoLastIssueDate_Expect_AllFieldsToB
when(medicationMapper.extractMedicationReference(any()))
.thenReturn(Optional.of(new Reference(new IdType(ResourceType.Medication.name(), MEDICATION_ID))));

assertThat(authorise.isPresent()).isTrue();
assertThat(authorise).isPresent();
var medicationStatement1 = medicationStatementMapper.mapToMedicationStatement(
new RCMRMT030101UKEhrExtract(), medicationStatement, authorise.get(), PRACTISE_CODE, new DateTimeType());

Expand Down Expand Up @@ -222,10 +222,10 @@ private RCMRMT030101UKEhrExtract unmarshallEhrExtract(String fileName) {
private MedicationStatement mapMedicationStatementFromEhrFile(String filename, DateTimeType authoredOn) {
var ehrExtract = unmarshallEhrExtract(filename);
var medicationStatement = extractMedicationStatement(ehrExtract);
assertThat(medicationStatement.isPresent()).isTrue();
assertThat(medicationStatement).isPresent();

var authorise = extractAuthorise(medicationStatement.orElseThrow());
assertThat(authorise.isPresent()).isTrue();
assertThat(authorise).isPresent();

when(medicationMapper.extractMedicationReference(any()))
.thenReturn(Optional.of(new Reference(new IdType(ResourceType.Medication.name(), MEDICATION_ID))));
Expand Down