-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Change covid caseclassification #6286 * #6286 - Added criteria to mobile app, caption changes Co-authored-by: Maté Strysewske <mate.strysewske@vitagroup.ag>
- Loading branch information
1 parent
a77f81b
commit 0377438
Showing
5 changed files
with
104 additions
and
25 deletions.
There are no files selected for viewing
78 changes: 78 additions & 0 deletions
78
...java/de/symeda/sormas/api/caze/classification/ClassificationAnyOfSymptomsCriteriaDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package de.symeda.sormas.api.caze.classification; | ||
|
||
import java.lang.reflect.Field; | ||
import java.util.List; | ||
|
||
import de.symeda.sormas.api.Disease; | ||
import de.symeda.sormas.api.caze.CaseDataDto; | ||
import de.symeda.sormas.api.event.EventDto; | ||
import de.symeda.sormas.api.i18n.I18nProperties; | ||
import de.symeda.sormas.api.i18n.Strings; | ||
import de.symeda.sormas.api.person.PersonDto; | ||
import de.symeda.sormas.api.sample.PathogenTestDto; | ||
import de.symeda.sormas.api.symptoms.SymptomState; | ||
import de.symeda.sormas.api.symptoms.SymptomsDto; | ||
import de.symeda.sormas.api.utils.fieldvisibility.FieldVisibilityCheckers; | ||
|
||
public class ClassificationAnyOfSymptomsCriteriaDto extends ClassificationCriteriaDto { | ||
|
||
private SymptomState symptomState; | ||
private FieldVisibilityCheckers fieldVisibilityCheckers; | ||
|
||
public ClassificationAnyOfSymptomsCriteriaDto(SymptomState symptomState, Disease disease, String countryLocale) { | ||
this.symptomState = symptomState; | ||
fieldVisibilityCheckers = FieldVisibilityCheckers.withDisease(disease).andWithCountry(countryLocale); | ||
} | ||
|
||
@Override | ||
public boolean eval(CaseDataDto caze, PersonDto person, List<PathogenTestDto> pathogenTests, List<EventDto> events) { | ||
|
||
for (Field field : SymptomsDto.class.getDeclaredFields()) { | ||
|
||
SymptomsDto symptomsDto = caze.getSymptoms(); | ||
if (field.getType() == SymptomState.class && fieldVisibilityCheckers.isVisible(SymptomsDto.class, field.getName())) { | ||
field.setAccessible(true); | ||
try { | ||
boolean matchedFieldState = field.get(symptomsDto) == symptomState; | ||
field.setAccessible(false); | ||
if (matchedFieldState) { | ||
return true; | ||
} | ||
} catch (IllegalAccessException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
@Override | ||
public String buildDescription() { | ||
StringBuilder stringBuilder = new StringBuilder(); | ||
|
||
stringBuilder.append("<b> ") | ||
.append(I18nProperties.getString(Strings.classificationSymptomsAnyOf).toUpperCase()) | ||
.append("</b>") | ||
.append(" ") | ||
.append(I18nProperties.getString(Strings.setTo)) | ||
.append(" "); | ||
|
||
if (symptomState == null) { | ||
stringBuilder.append("<b>").append(I18nProperties.getString(Strings.none).toUpperCase()).append("</b>").append("</br>"); | ||
} else { | ||
stringBuilder.append("<b>").append(symptomState.toString().toUpperCase()).append("</b>").append("</br>"); | ||
} | ||
|
||
for (Field field : SymptomsDto.class.getDeclaredFields()) { | ||
if (field.getType() == SymptomState.class && fieldVisibilityCheckers.isVisible(SymptomsDto.class, field.getName())) { | ||
stringBuilder.append(I18nProperties.getPrefixCaption(SymptomsDto.I18N_PREFIX, field.getName())).append("; "); | ||
} | ||
} | ||
|
||
if (stringBuilder.length() > 0 && stringBuilder.charAt(stringBuilder.length() - 2) == ';') { | ||
stringBuilder.delete(stringBuilder.length() - 2, stringBuilder.length() - 1); | ||
} | ||
|
||
return stringBuilder.toString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters