Skip to content

Commit 050565b

Browse files
Merge pull request #13758 from SORMAS-Foundation/bugfix-13674-duplicated-db-column-for-birth-weight
Bugfix 13674 duplicated db column for birth weight
2 parents ed406cd + d4ec6fd commit 050565b

10 files changed

Lines changed: 45 additions & 46 deletions

File tree

sormas-api/src/main/java/de/symeda/sormas/api/DiseaseHelper.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
*******************************************************************************/
1818
package de.symeda.sormas.api;
1919

20+
import java.util.Arrays;
21+
import java.util.Collections;
22+
import java.util.Set;
23+
2024
import org.apache.commons.lang3.StringUtils;
2125

2226
import de.symeda.sormas.api.caze.PlagueType;
@@ -27,6 +31,12 @@
2731

2832
public final class DiseaseHelper {
2933

34+
/**
35+
* Diseases which are having subtypes.
36+
*/
37+
public static final Set<Disease> SUBTYPE_ALLOWED_DISEASES =
38+
Collections.unmodifiableSet(new java.util.HashSet<Disease>(Arrays.asList(Disease.INFLUENZA, Disease.RESPIRATORY_SYNCYTIAL_VIRUS)));
39+
3040
private DiseaseHelper() {
3141
// Hide Utility Class Constructor
3242
}
@@ -73,10 +83,10 @@ public static String variantInBrackets(DiseaseVariant diseaseVariant) {
7383

7484
/**
7585
* Checks if the case is an invasive bacterial disease (meningococcal or pneumococcal)
86+
*
7687
* @return boolean
7788
*/
78-
public static boolean checkDiseaseIsInvasiveBacterialDiseases(Disease disease){
79-
return disease != null && (disease == Disease.INVASIVE_MENINGOCOCCAL_INFECTION ||
80-
disease == Disease.INVASIVE_PNEUMOCOCCAL_INFECTION);
89+
public static boolean checkDiseaseIsInvasiveBacterialDiseases(Disease disease) {
90+
return disease != null && (disease == Disease.INVASIVE_MENINGOCOCCAL_INFECTION || disease == Disease.INVASIVE_PNEUMOCOCCAL_INFECTION);
8191
}
8292
}

sormas-api/src/main/java/de/symeda/sormas/api/person/PersonDto.java

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ public class PersonDto extends PseudonymizableDto implements IsPerson {
115115
public static final String BIRTH_WEIGHT = "birthWeight";
116116
public static final String GESTATIONAL_AGE_CATEGORY = "gestationalAgeCategory";
117117
public static final String BIRTH_WEIGHT_CATEGORY = "birthWeightCategory";
118-
public static final String BIRTH_WEIGHT_VALUE = "birthWeightValue";
119118
public static final String MULTIPLE_BIRTH = "multipleBirth";
120119
public static final String PASSPORT_NUMBER = "passportNumber";
121120
public static final String NATIONAL_HEALTH_ID = "nationalHealthId";
@@ -252,26 +251,28 @@ public class PersonDto extends PseudonymizableDto implements IsPerson {
252251
@Size(max = FieldConstraints.CHARACTER_LIMIT_DEFAULT, message = Validations.textTooLong)
253252
private String placeOfBirthFacilityDetails;
254253
@Diseases({
255-
Disease.CONGENITAL_RUBELLA })
254+
Disease.CONGENITAL_RUBELLA,
255+
Disease.RESPIRATORY_SYNCYTIAL_VIRUS })
256256
@HideForCountries
257257
private Integer gestationAgeAtBirth;
258258
@Diseases({
259-
Disease.CONGENITAL_RUBELLA })
259+
Disease.CONGENITAL_RUBELLA,
260+
Disease.RESPIRATORY_SYNCYTIAL_VIRUS })
260261
@HideForCountries
261262
private Integer birthWeight;
262263

263264
// RSV-specific perinatal fields
264265
@Diseases({
265-
Disease.RESPIRATORY_SYNCYTIAL_VIRUS })
266+
Disease.RESPIRATORY_SYNCYTIAL_VIRUS,
267+
Disease.CONGENITAL_RUBELLA })
266268
private GestationalAgeCategory gestationalAgeCategory;
267269
@Diseases({
268-
Disease.RESPIRATORY_SYNCYTIAL_VIRUS })
270+
Disease.RESPIRATORY_SYNCYTIAL_VIRUS,
271+
Disease.CONGENITAL_RUBELLA })
269272
private BirthWeightCategory birthWeightCategory;
270273
@Diseases({
271-
Disease.RESPIRATORY_SYNCYTIAL_VIRUS })
272-
private Integer birthWeightValue;
273-
@Diseases({
274-
Disease.RESPIRATORY_SYNCYTIAL_VIRUS })
274+
Disease.RESPIRATORY_SYNCYTIAL_VIRUS,
275+
Disease.CONGENITAL_RUBELLA })
275276
private MultipleBirth multipleBirth;
276277

277278
@Outbreaks
@@ -993,14 +994,6 @@ public void setBirthWeightCategory(BirthWeightCategory birthWeightCategory) {
993994
this.birthWeightCategory = birthWeightCategory;
994995
}
995996

996-
public Integer getBirthWeightValue() {
997-
return birthWeightValue;
998-
}
999-
1000-
public void setBirthWeightValue(Integer birthWeightValue) {
1001-
this.birthWeightValue = birthWeightValue;
1002-
}
1003-
1004997
public MultipleBirth getMultipleBirth() {
1005998
return multipleBirth;
1006999
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2525,8 +2525,7 @@ public static SymptomsDto build() {
25252525
UNDEFINED,
25262526
OTHER })
25272527
@HideForCountriesExcept(countries = {
2528-
CountryHelper.COUNTRY_CODE_SWITZERLAND,
2529-
CountryHelper.COUNTRY_CODE_LUXEMBOURG })
2528+
CountryHelper.COUNTRY_CODE_SWITZERLAND })
25302529
@SymptomGrouping(SymptomGroup.GENERAL)
25312530
private SymptomState fatigue;
25322531
@Diseases({

sormas-api/src/main/resources/captions.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2998,7 +2998,7 @@ Symptoms.symptomStatus= Symptom Status
29982998
Symptoms.reoccurrence= Reoccurrence
29992999
Symptoms.overnightStayRequired= Overnight hospitalization required
30003000
Symptoms.bloating= Bloating
3001-
Symptoms.symptomCurrentStatus= Symptom still presents
3001+
Symptoms.symptomCurrentStatus= Symptom persistence
30023002
Symptoms.durationOfSymptoms= Duration of symptoms (days)
30033003
Symptoms.timeOffWorkDays.giardiasis=Duration of absence from work (days)
30043004

sormas-backend/src/main/java/de/symeda/sormas/backend/person/Person.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ public class Person extends AbstractDomainObject implements IsPerson, HasExterna
128128
public static final String BIRTH_WEIGHT = "birthWeight";
129129
public static final String GESTATIONAL_AGE_CATEGORY = "gestationalAgeCategory";
130130
public static final String BIRTH_WEIGHT_CATEGORY = "birthWeightCategory";
131-
public static final String BIRTH_WEIGHT_VALUE = "birthWeightValue";
132131
public static final String MULTIPLE_BIRTH = "multipleBirth";
133132
public static final String PASSPORT_NUMBER = "passportNumber";
134133
public static final String NATIONAL_HEALTH_ID = "nationalHealthId";
@@ -196,7 +195,6 @@ public class Person extends AbstractDomainObject implements IsPerson, HasExterna
196195
private Integer birthWeight;
197196
private GestationalAgeCategory gestationalAgeCategory;
198197
private BirthWeightCategory birthWeightCategory;
199-
private Integer birthWeightValue;
200198
private MultipleBirth multipleBirth;
201199
private Date deathDate;
202200

@@ -625,14 +623,6 @@ public void setBirthWeightCategory(BirthWeightCategory birthWeightCategory) {
625623
this.birthWeightCategory = birthWeightCategory;
626624
}
627625

628-
public Integer getBirthWeightValue() {
629-
return birthWeightValue;
630-
}
631-
632-
public void setBirthWeightValue(Integer birthWeightValue) {
633-
this.birthWeightValue = birthWeightValue;
634-
}
635-
636626
@Enumerated(EnumType.STRING)
637627
public MultipleBirth getMultipleBirth() {
638628
return multipleBirth;

sormas-backend/src/main/java/de/symeda/sormas/backend/person/PersonFacadeEjb.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,7 +1017,6 @@ public static PersonDto toPersonDto(Person source) {
10171017
target.setBirthWeight(source.getBirthWeight());
10181018
target.setGestationalAgeCategory(source.getGestationalAgeCategory());
10191019
target.setBirthWeightCategory(source.getBirthWeightCategory());
1020-
target.setBirthWeightValue(source.getBirthWeightValue());
10211020
target.setMultipleBirth(source.getMultipleBirth());
10221021

10231022
target.setPassportNumber(source.getPassportNumber());
@@ -1792,7 +1791,6 @@ public Person fillOrBuildEntity(@NotNull PersonDto source, Person target, boolea
17921791
target.setBirthWeight(source.getBirthWeight());
17931792
target.setGestationalAgeCategory(source.getGestationalAgeCategory());
17941793
target.setBirthWeightCategory(source.getBirthWeightCategory());
1795-
target.setBirthWeightValue(source.getBirthWeightValue());
17961794
target.setMultipleBirth(source.getMultipleBirth());
17971795

17981796
target.setPassportNumber(source.getPassportNumber());

sormas-backend/src/main/resources/sql/sormas_schema.sql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14897,4 +14897,10 @@ INSERT INTO userroles_userrights (userrole_id, userright) SELECT id, 'EVENT_VIEW
1489714897

1489814898
INSERT INTO schema_version (version_number, comment) VALUES (598, 'Add view archived events to default ADMIN and NATIONAL_USER roles #13470');
1489914899

14900+
-- Deleted the duplicate column from Person table #13674
14901+
UPDATE person SET birthWeight = COALESCE(birthWeight, birthWeightValue) where birthWeightValue is not null;
14902+
UPDATE person_history SET birthWeight = COALESCE(birthWeight, birthWeightValue) where birthWeightValue is not null;
14903+
ALTER TABLE person DROP COLUMN birthWeightValue;
14904+
ALTER TABLE person_history DROP COLUMN birthWeightValue;
14905+
INSERT INTO schema_version (version_number, comment) VALUES (599, 'Deleted the duplicate column #13674');
1490014906
-- *** Insert new sql commands BEFORE this line. Remember to always consider _history tables. ***

sormas-ui/src/main/java/de/symeda/sormas/ui/caze/CaseDataForm.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171

7272
import de.symeda.sormas.api.CountryHelper;
7373
import de.symeda.sormas.api.Disease;
74+
import de.symeda.sormas.api.DiseaseHelper;
7475
import de.symeda.sormas.api.EntityDto;
7576
import de.symeda.sormas.api.FacadeProvider;
7677
import de.symeda.sormas.api.caze.CaseClassification;
@@ -476,7 +477,7 @@ protected void addFields() {
476477
TextField diseaseVariantDetailsField = addField(CaseDataDto.DISEASE_VARIANT_DETAILS, TextField.class);
477478
diseaseVariantDetailsField.setVisible(false);
478479
diseaseVariantField.setNullSelectionAllowed(true);
479-
if (disease == Disease.RESPIRATORY_SYNCYTIAL_VIRUS) {
480+
if (DiseaseHelper.SUBTYPE_ALLOWED_DISEASES.contains(disease)) {
480481
diseaseVariantField.setCaption(I18nProperties.getCaption(Captions.PathogenTest_rsv_testedDiseaseVariant));
481482
diseaseVariantDetailsField.setCaption(I18nProperties.getCaption(Captions.PathogenTest_rsv_testedDiseaseVariantDetails));
482483
}

sormas-ui/src/main/java/de/symeda/sormas/ui/person/PersonEditForm.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@
3333
import java.util.Collections;
3434
import java.util.Date;
3535
import java.util.GregorianCalendar;
36+
import java.util.HashSet;
3637
import java.util.List;
3738
import java.util.Objects;
39+
import java.util.Set;
3840
import java.util.concurrent.atomic.AtomicBoolean;
3941
import java.util.stream.Collectors;
4042

@@ -117,6 +119,9 @@ public class PersonEditForm extends AbstractEditForm<PersonDto> {
117119
private static final String NATIONAL_HEALTH_ID_WARNING_LABEL = "nationalHealthIdWarningLoc";
118120
private static final String GENERAL_COMMENT_LOC = "generalCommentLoc";
119121
public static final String HAS_GUARDIAN = "hasGuardian";
122+
public static final Set<Disease> PERINATAL_DISEASES =
123+
Collections.unmodifiableSet(new HashSet<>(Arrays.asList(Disease.CONGENITAL_RUBELLA, Disease.RESPIRATORY_SYNCYTIAL_VIRUS)));
124+
120125
//@formatter:off
121126
private static final String HTML_LAYOUT =
122127
loc(PERSON_INFORMATION_HEADING_LOC) +
@@ -129,7 +134,6 @@ public class PersonEditForm extends AbstractEditForm<PersonDto> {
129134
) +
130135
fluidRowLocs(PersonDto.PLACE_OF_BIRTH_REGION, PersonDto.PLACE_OF_BIRTH_DISTRICT, PersonDto.PLACE_OF_BIRTH_COMMUNITY) +
131136
fluidRowLocs(PersonDto.PLACE_OF_BIRTH_FACILITY_TYPE, PersonDto.PLACE_OF_BIRTH_FACILITY, PersonDto.PLACE_OF_BIRTH_FACILITY_DETAILS) +
132-
fluidRowLocs(PersonDto.GESTATION_AGE_AT_BIRTH, PersonDto.BIRTH_WEIGHT) +
133137
fluidRowLocs(PersonDto.SEX, PersonDto.PRESENT_CONDITION) +
134138
fluidRow(
135139
oneOfFourCol(PersonDto.DEATH_DATE),
@@ -157,10 +161,9 @@ public class PersonEditForm extends AbstractEditForm<PersonDto> {
157161
fluidRowLocs(PersonDto.HAS_COVID_APP, PersonDto.COVID_CODE_DELIVERED) +
158162

159163
loc(PERINATAL_DETAILS_HEADER) +
160-
divsCss(VSPACE_3,
161-
fluidRowLocs(PersonDto.GESTATIONAL_AGE_CATEGORY, PersonDto.BIRTH_WEIGHT_CATEGORY) +
162-
fluidRowLocs(PersonDto.BIRTH_WEIGHT_VALUE, PersonDto.MULTIPLE_BIRTH)
163-
) +
164+
divsCss(VSPACE_3,fluidRowLocs(PersonDto.GESTATIONAL_AGE_CATEGORY,PersonDto.GESTATION_AGE_AT_BIRTH) +
165+
fluidRowLocs(PersonDto.BIRTH_WEIGHT_CATEGORY, PersonDto.BIRTH_WEIGHT) +
166+
fluidRowLocs(PersonDto.MULTIPLE_BIRTH,""))+
164167

165168
loc(OCCUPATION_HEADER) +
166169
divsCss(VSPACE_3,
@@ -383,8 +386,6 @@ protected void addFields() {
383386
// RSV Perinatal Details
384387
ComboBox gestationalAgeCategory = addField(PersonDto.GESTATIONAL_AGE_CATEGORY, ComboBox.class);
385388
ComboBox birthWeightCategory = addField(PersonDto.BIRTH_WEIGHT_CATEGORY, ComboBox.class);
386-
TextField birthWeightValue = addField(PersonDto.BIRTH_WEIGHT_VALUE, TextField.class);
387-
birthWeightValue.setConversionError(I18nProperties.getValidationError(Validations.onlyIntegerNumbersAllowed, birthWeightValue.getCaption()));
388389
ComboBox multipleBirth = addField(PersonDto.MULTIPLE_BIRTH, ComboBox.class);
389390

390391
AbstractSelect deathPlaceType = addField(PersonDto.DEATH_PLACE_TYPE, ComboBox.class);
@@ -728,7 +729,7 @@ protected void addFields() {
728729
minimumAdultAge = FacadeProvider.getConfigFacade().getMinimumAdultAge();
729730
minimumEmancipatedAge = FacadeProvider.getConfigFacade().getMinimumEmancipatedAge();
730731

731-
if (disease != null && disease != Disease.RESPIRATORY_SYNCYTIAL_VIRUS) {
732+
if (disease != null && !PERINATAL_DISEASES.contains(disease)) {
732733
perinatalDetailsHeader.setVisible(false);
733734
}
734735
}

sormas-ui/src/main/java/de/symeda/sormas/ui/samples/PathogenTestForm.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252

5353
import de.symeda.sormas.api.CountryHelper;
5454
import de.symeda.sormas.api.Disease;
55+
import de.symeda.sormas.api.DiseaseHelper;
5556
import de.symeda.sormas.api.FacadeProvider;
5657
import de.symeda.sormas.api.customizableenum.CustomizableEnumType;
5758
import de.symeda.sormas.api.disease.DiseaseVariant;
@@ -447,7 +448,7 @@ protected void addFields() {
447448
diseaseVariantField.setVisible(false);
448449
TextField diseaseVariantDetailsField = addField(PathogenTestDto.TESTED_DISEASE_VARIANT_DETAILS, TextField.class);
449450
diseaseVariantDetailsField.setVisible(false);
450-
if (disease == Disease.RESPIRATORY_SYNCYTIAL_VIRUS) {
451+
if (DiseaseHelper.SUBTYPE_ALLOWED_DISEASES.contains(disease)) {
451452
diseaseVariantField.setCaption(I18nProperties.getCaption(Captions.PathogenTest_rsv_testedDiseaseVariant));
452453
diseaseVariantDetailsField.setCaption(I18nProperties.getCaption(Captions.PathogenTest_rsv_testedDiseaseVariantDetails));
453454
}
@@ -1164,7 +1165,7 @@ protected void addFields() {
11641165
BiConsumer<Disease, PathogenTestType> resultField = (disease, testType) -> {
11651166
final boolean testResultFieldReadOnly = testResultField.isReadOnly();
11661167
testResultField.setReadOnly(false);
1167-
1168+
11681169
if (RESULT_FIELD_DECISION_MAP.containsKey(disease) && RESULT_FIELD_DECISION_MAP.get(disease).contains(testType)) {
11691170
testResultField.setValue(PathogenTestResultType.POSITIVE);
11701171
testResultField.setEnabled(false);

0 commit comments

Comments
 (0)