Skip to content

Commit

Permalink
refactor method to be more performant
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewErispe committed Oct 15, 2024
1 parent 77380ae commit 5de2658
Showing 1 changed file with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,16 @@ private static boolean helperUpdateGoldenRecordField(

private static String patientName(final Interaction interaction) {
var patientRecord = interaction.demographicData();
Map<String, String> fieldMap = patientRecord.fields.stream()
.collect(Collectors.toMap(DemographicData.DemographicField::ccTag,
DemographicData.DemographicField::value));

String patientDisplayName = FIELDS_CONFIG.nameFieldsForNotificationDisplay.stream()
.map(fieldName -> patientRecord.fields.stream()
.filter(field -> fieldName.equals(
field.ccTag()))
.map(DemographicData.DemographicField::value)
.findFirst()
.orElse(""))
.collect(Collectors.joining(" "))
.trim();
.map(fieldName -> fieldMap.getOrDefault(fieldName,
""))
.filter(StringUtils::isNotBlank)
.collect(Collectors.joining(" "))
.trim();
return patientDisplayName;
}

Expand Down

0 comments on commit 5de2658

Please sign in to comment.