Skip to content

Commit 129bf94

Browse files
committed
Fixe some more minor issues
1 parent cfd8ee9 commit 129bf94

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

sormas-ui/src/main/java/de/symeda/sormas/ui/caze/notifier/TreatmentOption.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
package de.symeda.sormas.ui.caze.notifier;
1717

18+
import java.util.Arrays;
1819
import java.util.Collections;
1920
import java.util.Set;
2021
import java.util.TreeSet;
@@ -35,15 +36,17 @@ public class TreatmentOption implements Comparable<TreatmentOption> {
3536
public static final TreatmentOption UNKNOWN =
3637
new TreatmentOption(YesNoUnknown.UNKNOWN.toString(), I18nProperties.getEnumCaption(YesNoUnknown.UNKNOWN));
3738

38-
public static final Set<TreatmentOption> ALL_OPTIONS = Collections.unmodifiableSet(new TreeSet<>(Set.of(YES, NO, NOT_APPLICABLE, UNKNOWN)));
39+
public static final Set<TreatmentOption> ALL_OPTIONS =
40+
Collections.unmodifiableSet(new TreeSet<>(Arrays.asList(YES, NO, NOT_APPLICABLE, UNKNOWN)));
3941

4042
private String value;
4143
private String caption;
4244

4345
/**
4446
* Creates a TreatmentOption from a YesNoUnknown enum value.
4547
*
46-
* @param yesNoUnknown the enum value to convert, null returns NOT_APPLICABLE
48+
* @param yesNoUnknown
49+
* the enum value to convert, null returns NOT_APPLICABLE
4750
* @return corresponding TreatmentOption
4851
*/
4952
public static final TreatmentOption forValue(YesNoUnknown yesNoUnknown) {
@@ -65,8 +68,10 @@ public static final TreatmentOption forValue(YesNoUnknown yesNoUnknown) {
6568
/**
6669
* Creates a new TreatmentOption.
6770
*
68-
* @param value the internal value
69-
* @param caption the display caption
71+
* @param value
72+
* the internal value
73+
* @param caption
74+
* the display caption
7075
*/
7176
public TreatmentOption(String value, String caption) {
7277
this.value = value;
@@ -111,14 +116,14 @@ public int compareTo(TreatmentOption other) {
111116
if (other == null) {
112117
return 1;
113118
}
114-
119+
115120
// Define the desired order: YES, NO, UNKNOWN, NOT_APPLICABLE
116121
int thisOrder = getOrder(this);
117122
int otherOrder = getOrder(other);
118-
123+
119124
return Integer.compare(thisOrder, otherOrder);
120125
}
121-
126+
122127
private int getOrder(TreatmentOption option) {
123128
if (option.equals(YES)) {
124129
return 1;

sormas-ui/src/main/java/de/symeda/sormas/ui/externalmessage/doctordeclaration/DoctorDeclarationMessageProcessingFlow.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@
1616
package de.symeda.sormas.ui.externalmessage.doctordeclaration;
1717

1818
import java.util.ArrayList;
19+
import java.util.Arrays;
1920
import java.util.Date;
2021
import java.util.List;
2122
import java.util.Objects;
2223
import java.util.concurrent.CompletableFuture;
2324
import java.util.concurrent.CompletionStage;
2425
import java.util.function.Consumer;
26+
import java.util.stream.Collectors;
2527

2628
import org.apache.commons.lang3.StringUtils;
2729
import org.slf4j.Logger;
@@ -320,8 +322,10 @@ public void done(CaseDataDto result) {
320322
notifierDto.setEmail(externalMessage.getNotifierEmail());
321323
if (externalMessage.getReporterName() != null && externalMessage.getReporterName().contains("-")) {
322324
// Split the reporter name into first and last names if it contains a hyphen
323-
notifierDto.setAgentFirstName(externalMessage.getReporterName().split("-")[0]);
324-
notifierDto.setAgentLastName(externalMessage.getReporterName().split("-")[1]);
325+
// Some names may already contain hyphens, assume first parts are the first name and last parts are the last name
326+
final String[] nameParts = externalMessage.getReporterName().split("-");
327+
notifierDto.setAgentFirstName(Arrays.stream(nameParts).limit(nameParts.length - 1).map(String::trim).collect(Collectors.joining(" ")));
328+
notifierDto.setAgentLastName(nameParts.length > 0 ? nameParts[nameParts.length - 1].trim() : "");
325329
}
326330
// Update the case with notifier details and complete the callback
327331
callback.done(getExternalMessageProcessingFacade().updateAndSetCaseNotifier(result.getUuid(), notifierDto));

0 commit comments

Comments
 (0)