Skip to content

Commit 35cb191

Browse files
committed
Refactor symptom comparison logic to improve mismatch detection between symptoms values
1 parent 3d5302c commit 35cb191

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

sormas-api/src/main/java/de/symeda/sormas/api/symptoms/SymptomsComparisonHelper.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,26 @@ private SymptomsComparisonHelper() {
4343
/**
4444
* Checks if there is a mismatch between two SymptomsDto objects.
4545
*
46-
* @param caseSymptoms
46+
* @param symptomsA
4747
* The symptoms from the case
48-
* @param externalMessageSymptoms
48+
* @param symptomsB
4949
* The symptoms from the external message
5050
* @return true if there is a mismatch between the two symptom objects, false otherwise
5151
*/
52-
public static boolean hasCaseSymptomsMismatch(SymptomsDto caseSymptoms, SymptomsDto externalMessageSymptoms) {
53-
Map<String, Object> externalMessageSymptomsMap = getComparableSymptomsValues(externalMessageSymptoms);
52+
public static boolean hasCaseSymptomsMismatch(SymptomsDto symptomsA, SymptomsDto symptomsB) {
53+
Map<String, Object> externalMessageSymptomsMap = getComparableSymptomsValues(symptomsB);
5454
if (externalMessageSymptomsMap.isEmpty()) {
5555
return false;
5656
}
5757

58-
Map<String, Object> caseSymptomsMap = getComparableSymptomsValues(caseSymptoms);
59-
return !caseSymptomsMap.equals(externalMessageSymptomsMap);
58+
Map<String, Object> caseSymptomsMap = getComparableSymptomsValues(symptomsA);
59+
for (Map.Entry<String, Object> entry : externalMessageSymptomsMap.entrySet()) {
60+
Object caseValue = caseSymptomsMap.get(entry.getKey());
61+
if (caseValue == null || !caseValue.equals(entry.getValue())) {
62+
return true;
63+
}
64+
}
65+
return false;
6066
}
6167

6268
/**

0 commit comments

Comments
 (0)