Skip to content

Commit

Permalink
#5496 - Added default disease to missing fields
Browse files Browse the repository at this point in the history
  • Loading branch information
MateStrysewske committed Sep 20, 2021
1 parent 7cfd7f5 commit dc27be0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
Expand Up @@ -37,21 +37,23 @@ public class SharedInfoField extends CustomField<SharedInfoFieldDto> {

public SharedInfoField(CaseReferenceDto caseReferenceDto, Disease initialDiseaseValue) {
caseSelector = caseReferenceDto != null
? new CaseSelector(caseReferenceDto)
: new CaseSelector(I18nProperties.getString(Strings.infoNoSourceCaseSelectedLineListing));
? new CaseSelector(caseReferenceDto)
: new CaseSelector(I18nProperties.getString(Strings.infoNoSourceCaseSelectedLineListing));
disease = new ComboBox<>(I18nProperties.getCaption(Captions.lineListingDiseaseOfSourceCase));
region = new ComboBox<>(I18nProperties.getCaption(Captions.region));
district = new ComboBox<>(I18nProperties.getCaption(Captions.district));

this.initialDiseaseValue = initialDiseaseValue;
this.initialDiseaseValue = initialDiseaseValue;
}

public SharedInfoField(CaseDataDto caseDataDto) {
this(caseDataDto == null ? null : caseDataDto.toReference(), caseDataDto == null ? null : caseDataDto.getDisease());
this(
caseDataDto == null ? null : caseDataDto.toReference(),
caseDataDto == null ? FacadeProvider.getDiseaseConfigurationFacade().getDefaultDisease() : caseDataDto.getDisease());
}

public SharedInfoField(EventDto eventDto) {
this(null, eventDto == null ? null : eventDto.getDisease());
this(null, eventDto == null ? FacadeProvider.getDiseaseConfigurationFacade().getDefaultDisease() : eventDto.getDisease());
}

@Override
Expand Down
Expand Up @@ -89,7 +89,7 @@ protected void addFields() {
}
ComboBox testTypeField = addCustomField(PathogenTestDto.TEST_TYPE, PathogenTestType.class, ComboBox.class);
ComboBox pcrTestSpecification = addCustomField(PathogenTestDto.PCR_TEST_SPECIFICATION, PCRTestSpecification.class, ComboBox.class);
ComboBox testDiseaseField = addCustomField(PathogenTestDto.TESTED_DISEASE, Disease.class, ComboBox.class);
ComboBox testedDiseaseField = addCustomField(PathogenTestDto.TESTED_DISEASE, Disease.class, ComboBox.class);
ComboBox diseaseVariantField = addCustomField(PathogenTestDto.TESTED_DISEASE_VARIANT, DiseaseVariant.class, ComboBox.class);
TextField cqValueField = addCustomField(PathogenTestDto.CQ_VALUE, Float.class, TextField.class);
cqValueField.setConversionError(I18nProperties.getValidationError(Validations.onlyNumbersAllowed, cqValueField.getCaption()));
Expand All @@ -115,23 +115,23 @@ protected void addFields() {
Map<Field, List<Object>> pcrTestSpecificationVisibilityDependencies = new HashMap<Field, List<Object>>() {

{
put(testDiseaseField, Arrays.asList(Disease.CORONAVIRUS));
put(testedDiseaseField, Arrays.asList(Disease.CORONAVIRUS));
put(testTypeField, Arrays.asList(PathogenTestType.PCR_RT_PCR));
}
};
FieldHelper.setVisibleWhen(pcrTestSpecification, pcrTestSpecificationVisibilityDependencies, true);

FieldHelper.setVisibleWhen(
includeTestField,
Arrays.asList(pathogenTestResultField, testVerifiedField, testTypeField, testDiseaseField, testDateField, testDetailsField),
Arrays.asList(pathogenTestResultField, testVerifiedField, testTypeField, testedDiseaseField, testDateField, testDetailsField),
Arrays.asList(true),
true);

FieldHelper.setRequiredWhen(includeTestField, Arrays.asList(pathogenTestResultField), Arrays.asList(true), false, null);

FieldHelper.setRequiredWhen(
pathogenTestResultField,
Arrays.asList(testVerifiedField, testTypeField, testDiseaseField),
Arrays.asList(testVerifiedField, testTypeField, testedDiseaseField),
Arrays.asList(
PathogenTestResultType.POSITIVE,
PathogenTestResultType.NEGATIVE,
Expand All @@ -149,7 +149,7 @@ protected void addFields() {
false,
I18nProperties.getValidationError(Validations.afterDate, testDateField.getCaption(), sampleDateField.getCaption())));

testDiseaseField.addValueChangeListener((ValueChangeListener) valueChangeEvent -> {
testedDiseaseField.addValueChangeListener((ValueChangeListener) valueChangeEvent -> {
Disease disease = (Disease) valueChangeEvent.getProperty().getValue();
List<DiseaseVariant> diseaseVariants =
FacadeProvider.getCustomizableEnumFacade().getEnumValues(CustomizableEnumType.DISEASE_VARIANT, disease);
Expand All @@ -170,7 +170,7 @@ protected void addFields() {
PathogenTestType testType = (PathogenTestType) e.getProperty().getValue();
PathogenTestResultType testResult = (PathogenTestResultType) pathogenTestResultField.getValue();
showCqValueField(cqValueField, testType, testResult);
showPcrTestSpecificationField(pcrTestSpecification, testType, (Disease) testDiseaseField.getValue());
showPcrTestSpecificationField(pcrTestSpecification, testType, (Disease) testedDiseaseField.getValue());
if (testType == PathogenTestType.PCR_RT_PCR || testType == PathogenTestType.DNA_MICROARRAY || testType == PathogenTestType.SEQUENCING) {
typingIdField.setVisible(true);
} else {
Expand All @@ -185,6 +185,7 @@ protected void addFields() {
if (includeTest) {
pathogenTestResultField.setNullSelectionAllowed(false);
pathogenTestResultField.setValue(PathogenTestResultType.PENDING);
testedDiseaseField.setValue(FacadeProvider.getDiseaseConfigurationFacade().getDefaultDisease());
} else {
pathogenTestResultField.setNullSelectionAllowed(true);
pathogenTestResultField.setValue(null);
Expand Down

0 comments on commit dc27be0

Please sign in to comment.