Skip to content

Commit

Permalink
refactoring: use map instead of peek in some cases
Browse files Browse the repository at this point in the history
  • Loading branch information
jorg3lopez committed May 15, 2024
1 parent 2729fed commit 79e8371
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ public static MessageHeader findOrInitializeMessageHeader(Bundle bundle) {
public static void updateOrganizationIdentifierValue(Bundle bundle, String newValue) {
bundle.getEntry().stream()
.map(Bundle.BundleEntryComponent::getResource)
.filter(resource -> resource instanceof Patient)
.map(resource -> (Patient) resource)
.filter(Patient.class::isInstance)
.map(Patient.class::cast)
.flatMap(patient -> patient.getIdentifier().stream())
.map(
identifier ->
Expand All @@ -117,7 +117,7 @@ public static void updateOrganizationIdentifierValue(Bundle bundle, String newVa
LOGGER.logInfo(
"Updating Organization identifier from: "
+ orgIdentifier.getValue()))
.peek(orgIdentifier -> orgIdentifier.setValue(newValue)))
.map(orgIdentifier -> orgIdentifier.setValue(newValue)))
.forEach(
orgIdentifier ->
LOGGER.logInfo(
Expand All @@ -144,8 +144,8 @@ private static Optional<Organization> getOrganizationFromAssigner(

return bundle.getEntry().stream()
.map(Bundle.BundleEntryComponent::getResource)
.filter(resource -> resource instanceof Organization)
.map(resource -> (Organization) resource)
.filter(Organization.class::isInstance)
.map(Organization.class::cast)
.peek(org -> LOGGER.logInfo("Checking organization with ID: " + org.getId()))
.filter(
org -> {
Expand Down

0 comments on commit 79e8371

Please sign in to comment.