diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/caze/Case.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/caze/Case.java index 158c45802a3..353125cf76b 100644 --- a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/caze/Case.java +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/caze/Case.java @@ -72,6 +72,7 @@ import de.symeda.sormas.app.backend.common.PseudonymizableAdo; import de.symeda.sormas.app.backend.epidata.EpiData; import de.symeda.sormas.app.backend.facility.Facility; +import de.symeda.sormas.app.backend.foodhistory.FoodHistory; import de.symeda.sormas.app.backend.hospitalization.Hospitalization; import de.symeda.sormas.app.backend.infrastructure.PointOfEntry; import de.symeda.sormas.app.backend.person.Person; @@ -116,6 +117,7 @@ public class Case extends PseudonymizableAdo { public static final String VACCINATION_STATUS = "vaccinationStatus"; public static final String HEALTH_CONDITIONS = "healthConditions"; public static final String RISK_FACTOR = "riskFactor"; + public static final String FOOD_HISTORY = "foodHistory"; @DatabaseField(foreign = true, foreignAutoRefresh = true, canBeNull = false, maxForeignAutoRefreshLevel = 3) private Person person; @@ -286,6 +288,9 @@ public class Case extends PseudonymizableAdo { @DatabaseField(foreign = true, foreignAutoRefresh = true) private RiskFactor riskFactor; + @DatabaseField(foreign = true, foreignAutoRefresh = true) + private FoodHistory foodHistory; + @Deprecated @Column private Long contactOfficer_id; @@ -956,6 +961,14 @@ public void setRiskFactor(RiskFactor riskFactor) { this.riskFactor = riskFactor; } + public FoodHistory getFoodHistory() { + return foodHistory; + } + + public void setFoodHistory(FoodHistory foodHistory) { + this.foodHistory = foodHistory; + } + public Double getReportLat() { return reportLat; } diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/caze/CaseDao.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/caze/CaseDao.java index 4d0cb897bf3..c87b870bcdb 100644 --- a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/caze/CaseDao.java +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/caze/CaseDao.java @@ -49,6 +49,7 @@ import de.symeda.sormas.api.caze.InvestigationStatus; import de.symeda.sormas.api.feature.FeatureType; import de.symeda.sormas.api.feature.FeatureTypeProperty; +import de.symeda.sormas.api.foodhistory.FoodHistoryDto; import de.symeda.sormas.api.infrastructure.facility.FacilityType; import de.symeda.sormas.api.task.TaskStatus; import de.symeda.sormas.api.user.JurisdictionLevel; @@ -79,6 +80,7 @@ import de.symeda.sormas.app.backend.event.EventEditAuthorization; import de.symeda.sormas.app.backend.event.EventParticipant; import de.symeda.sormas.app.backend.exposure.Exposure; +import de.symeda.sormas.app.backend.foodhistory.FoodHistory; import de.symeda.sormas.app.backend.person.Person; import de.symeda.sormas.app.backend.persontravelhistory.PersonTravelHistory; import de.symeda.sormas.app.backend.region.Community; @@ -207,6 +209,11 @@ public Date getLatestChangeDate() { date = riskFactorDate; } + Date foodHistoryDate = getLatestChangeDateJoin(FoodHistory.TABLE_NAME, Case.FOOD_HISTORY); + if (foodHistoryDate != null && foodHistoryDate.after(date)) { + date = foodHistoryDate; + } + return date; } @@ -286,6 +293,9 @@ public Case build(Person person) { // risk factor caze.setRiskFactor(DatabaseHelper.getRiskFactorDao().build()); + // food history + caze.setFoodHistory(DatabaseHelper.getFoodHistoryDao().build()); + // Location User currentUser = ConfigProvider.getUser(); diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/caze/CaseDtoHelper.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/caze/CaseDtoHelper.java index 76e5a34ee5b..fd851f22296 100644 --- a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/caze/CaseDtoHelper.java +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/caze/CaseDtoHelper.java @@ -20,6 +20,7 @@ import de.symeda.sormas.api.PostResponse; import de.symeda.sormas.api.caze.CaseDataDto; import de.symeda.sormas.api.caze.CaseReferenceDto; +import de.symeda.sormas.api.foodhistory.FoodHistoryDto; import de.symeda.sormas.api.person.PersonReferenceDto; import de.symeda.sormas.api.symptoms.SymptomsDto; import de.symeda.sormas.app.backend.caze.maternalhistory.MaternalHistoryDtoHelper; @@ -33,6 +34,7 @@ import de.symeda.sormas.app.backend.epidata.EpiDataDtoHelper; import de.symeda.sormas.app.backend.facility.Facility; import de.symeda.sormas.app.backend.facility.FacilityDtoHelper; +import de.symeda.sormas.app.backend.foodhistory.FoodHistoryDtoHelper; import de.symeda.sormas.app.backend.hospitalization.Hospitalization; import de.symeda.sormas.app.backend.hospitalization.HospitalizationDtoHelper; import de.symeda.sormas.app.backend.infrastructure.PointOfEntry; @@ -70,6 +72,7 @@ public class CaseDtoHelper extends PersonDependentDtoHelper { private SormasToSormasOriginInfoDtoHelper sormasToSormasOriginInfoDtoHelper = new SormasToSormasOriginInfoDtoHelper(); private HealthConditionsDtoHelper healthConditionsDtoHelper = new HealthConditionsDtoHelper(); private RiskFactorDtoHelper riskFactorDtoHelper = new RiskFactorDtoHelper(); + private FoodHistoryDtoHelper foodHistoryDtoHelper = new FoodHistoryDtoHelper(); @Override protected Class getAdoClass() { @@ -148,6 +151,7 @@ public void fillInnerFromDto(Case target, CaseDataDto source) { target.setMaternalHistory(maternalHistoryDtoHelper.fillOrCreateFromDto(target.getMaternalHistory(), source.getMaternalHistory())); target.setPortHealthInfo(portHealthInfoDtoHelper.fillOrCreateFromDto(target.getPortHealthInfo(), source.getPortHealthInfo())); target.setRiskFactor(riskFactorDtoHelper.fillOrCreateFromDto(target.getRiskFactor(), source.getRiskFactor())); + target.setFoodHistory(foodHistoryDtoHelper.fillOrCreateFromDto(target.getFoodHistory(), source.getFoodHistory())); target.setSurveillanceOfficer(DatabaseHelper.getUserDao().getByReferenceDto(source.getSurveillanceOfficer())); target.setClinicianName(source.getClinicianName()); @@ -459,6 +463,13 @@ public void fillInnerFromAdo(CaseDataDto target, Case source) { target.setRiskFactor(null); } + if (source.getFoodHistory() != null) { + target.setFoodHistory( + foodHistoryDtoHelper.adoToDto(DatabaseHelper.getFoodHistoryDao().queryForId(source.getFoodHistory().getId()))); + } else { + target.setFoodHistory(null); + } + target.setClinicianName(source.getClinicianName()); target.setClinicianPhone(source.getClinicianPhone()); target.setClinicianEmail(source.getClinicianEmail()); diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/common/DatabaseHelper.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/common/DatabaseHelper.java index 76148f8ed2f..070e265ee07 100644 --- a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/common/DatabaseHelper.java +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/common/DatabaseHelper.java @@ -58,6 +58,7 @@ import de.symeda.sormas.api.exposure.ExposureType; import de.symeda.sormas.api.exposure.HabitationType; import de.symeda.sormas.api.exposure.TypeOfAnimal; +import de.symeda.sormas.api.foodhistory.FoodHistoryDto; import de.symeda.sormas.api.immunization.ImmunizationManagementStatus; import de.symeda.sormas.api.immunization.ImmunizationStatus; import de.symeda.sormas.api.immunization.MeansOfImmunization; @@ -123,6 +124,8 @@ import de.symeda.sormas.app.backend.facility.FacilityDao; import de.symeda.sormas.app.backend.feature.FeatureConfiguration; import de.symeda.sormas.app.backend.feature.FeatureConfigurationDao; +import de.symeda.sormas.app.backend.foodhistory.FoodHistory; +import de.symeda.sormas.app.backend.foodhistory.FoodHistoryDao; import de.symeda.sormas.app.backend.formbuilder.FormBuilder; import de.symeda.sormas.app.backend.formbuilder.FormBuilderDao; import de.symeda.sormas.app.backend.formbuilder.FormBuilderFormField; @@ -218,7 +221,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { // public static final int DATABASE_VERSION = 307; //public static final int DATABASE_VERSION = 343; - public static final int DATABASE_VERSION = 407; + public static final int DATABASE_VERSION = 408; private static DatabaseHelper instance = null; @@ -305,6 +308,7 @@ public static void clearTables(boolean clearInfrastructure) { TableUtils.clearTable(connectionSource, ContaminationSource.class); TableUtils.clearTable(connectionSource, ContainmentMeasure.class); TableUtils.clearTable(connectionSource, RiskFactor.class); + TableUtils.clearTable(connectionSource, FoodHistory.class); if (clearInfrastructure) { TableUtils.clearTable(connectionSource, UserUserRole.class); @@ -426,6 +430,7 @@ public void onCreate(SQLiteDatabase db, ConnectionSource connectionSource) { TableUtils.createTable(connectionSource, ContaminationSource.class); TableUtils.createTable(connectionSource, ContainmentMeasure.class); TableUtils.createTable(connectionSource, RiskFactor.class); + TableUtils.createTable(connectionSource, FoodHistory.class); } catch (SQLException e) { Log.e(DatabaseHelper.class.getName(), "Can't build database", e); throw new RuntimeException(e); @@ -4005,6 +4010,92 @@ public void onUpgrade(SQLiteDatabase db, ConnectionSource connectionSource, int getDao(Hospitalization.class).executeRaw("ALTER TABLE hospitalizations ADD COLUMN typeOfSample varchar(255);"); getDao(Hospitalization.class).executeRaw("ALTER TABLE hospitalizations ADD COLUMN agentIdentified varchar(255);"); + case 407: + currentVersion = 407; + getDao(FoodHistory.class).executeRaw( + "CREATE TABLE foodhistory (" + + " id INTEGER PRIMARY KEY AUTOINCREMENT," + + " suspectedFood VARCHAR(255)," + + " dateConsumed DATE," + + " foodSource VARCHAR(255)," + + " eventType VARCHAR(255)," + + " eventOtherSpecify VARCHAR(255)," + + " nameOfAffectedPerson VARCHAR(255)," + + " nameOfAffectedPerson2 VARCHAR(255)," + + " nameOfAffectedPerson3 VARCHAR(512)," + + " nameOfAffectedPerson4 VARCHAR(255)," + + " telNo VARCHAR(255)," + + " telNo2 VARCHAR(255)," + + " telNo3 VARCHAR(255)," + + " telNo4 VARCHAR(255)," + + " dateTime DATE," + + " dateTime2 DATE," + + " dateTime3 DATE," + + " dateTime4 DATE," + + " age VARCHAR(255)," + + " age2 VARCHAR(255)," + + " age3 VARCHAR(255)," + + " age4 VARCHAR(255)," + + " breakfast VARCHAR(3)," + + " totalNoPersons VARCHAR(255)," + + " foodConsumed VARCHAR(255)," + + " sourceOfFood VARCHAR(255)," + + " consumedAtPlace VARCHAR(3)," + + " lunch VARCHAR(55)," + + " totalNoPersonsL1 VARCHAR(255)," + + " foodConsumedL1 VARCHAR(255)," + + " sourceOfFoodL1 VARCHAR(255)," + + " consumedAtPlaceL1 VARCHAR(3)," + + " supper VARCHAR(55)," + + " totalNoPersonsS1 VARCHAR(255)," + + " foodConsumedS1 VARCHAR(255)," + + " sourceOfFoodS1 VARCHAR(255)," + + " consumedAtPlaceS1 VARCHAR(3)," + + " breakfast2 VARCHAR(3)," + + " totalNoPersons2 VARCHAR(255)," + + " foodConsumed2 VARCHAR(255)," + + " sourceOfFood2 VARCHAR(255)," + + " consumedAtPlace2 VARCHAR(3)," + + " lunchL2 VARCHAR(55)," + + " totalNoPersonsL2 VARCHAR(255)," + + " foodConsumedL2 VARCHAR(255)," + + " sourceOfFoodL2 VARCHAR(255)," + + " consumedAtPlaceL2 VARCHAR(3)," + + " supperS2 VARCHAR(55)," + + " totalNoPersonsS2 VARCHAR(255)," + + " foodConsumedS2 VARCHAR(255)," + + " sourceOfFoodS2 VARCHAR(255)," + + " consumedAtPlaceS2 VARCHAR(3)," + + " breakfast3 VARCHAR(55)," + + " totalNoPersons3 VARCHAR(255)," + + " foodConsumed3 VARCHAR(255)," + + " sourceOfFood3 VARCHAR(255)," + + " consumedAtPlace3 VARCHAR(3)," + + " lunchL3 VARCHAR(55)," + + " totalNoPersonsL3 VARCHAR(255)," + + " foodConsumedL3 VARCHAR(255)," + + " sourceOfFoodL3 VARCHAR(255)," + + " consumedAtPlaceL3 VARCHAR(3)," + + " supperS3 VARCHAR(55)," + + " totalNoPersonsS3 VARCHAR(255)," + + " foodConsumedS3 VARCHAR(255)," + + " sourceOfFoodS3 VARCHAR(255)," + + " consumedAtPlaceS3 VARCHAR(55)," + + " numberOfPeopleAteImplicatedFood INTEGER," + + " numberAffected VARCHAR," + + " changeDate BIGINT," + + " changeUserId BIGINT," + + " creationDate DATE," + + " uuid VARCHAR(512)," + + " lastOpenedDate BIGINT," + + " localChangeDate BIGINT NOT NULL," + + " modified SMALLINT," + + " snapshot SMALLINT," + + " UNIQUE (snapshot ASC, uuid ASC)" + + ");" + ); + getDao(Case.class).executeRaw("ALTER TABLE cases ADD COLUMN foodhistory_id BIGINT;"); + // ATTENTION: break should only be done after last version @@ -4981,6 +5072,8 @@ else if (type.equals(FormField.class)) { dao = (AbstractAdoDao) new ContainmentMeasureDao((Dao) innerDao); } else if(type.equals(RiskFactor.class)) { dao = (AbstractAdoDao) new RiskFactorDao((Dao) innerDao); + } else if(type.equals(FoodHistory.class)) { + dao = (AbstractAdoDao) new FoodHistoryDao((Dao) innerDao); }else { throw new UnsupportedOperationException(type.toString()); } @@ -5101,6 +5194,10 @@ public static PortHealthInfoDao getPortHealthInfoDao() { public static RiskFactorDao getRiskFactorDao() { return (RiskFactorDao) getAdoDao(RiskFactor.class); } + public static FoodHistoryDao getFoodHistoryDao() { + return (FoodHistoryDao) getAdoDao(FoodHistory.class); + } + public static PersonDao getPersonDao() { return (PersonDao) getAdoDao(Person.class); diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/foodhistory/FoodHistory.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/foodhistory/FoodHistory.java new file mode 100644 index 00000000000..6342a4dd193 --- /dev/null +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/foodhistory/FoodHistory.java @@ -0,0 +1,799 @@ +/* + * SORMAS® - Surveillance Outbreak Response Management & Analysis System + * Copyright © 2016-2018 Helmholtz-Zentrum für Infektionsforschung GmbH (HZI) + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package de.symeda.sormas.app.backend.foodhistory; + +import static de.symeda.sormas.api.utils.FieldConstraints.CHARACTER_LIMIT_DEFAULT; + +import com.j256.ormlite.field.DataType; +import com.j256.ormlite.field.DatabaseField; +import com.j256.ormlite.table.DatabaseTable; + +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; + +import de.symeda.sormas.api.utils.EventType; +import de.symeda.sormas.api.utils.FoodSource; +import de.symeda.sormas.api.utils.YesNo; +import de.symeda.sormas.app.backend.common.EmbeddedAdo; +import de.symeda.sormas.app.backend.common.PseudonymizableAdo; + +@Entity(name = FoodHistory.TABLE_NAME) +@DatabaseTable(tableName = FoodHistory.TABLE_NAME) +@EmbeddedAdo +public class FoodHistory extends PseudonymizableAdo { + private static final long serialVersionUID = -8294812479501735785L; + + public static final String TABLE_NAME = "foodhistory"; + public static final String I18N_PREFIX = "FoodHistory"; + + + @Column(length = CHARACTER_LIMIT_DEFAULT) + private String nameOfAffectedPerson; + + @Column(length = CHARACTER_LIMIT_DEFAULT) + private String nameOfAffectedPerson2; + + @Column(length = CHARACTER_LIMIT_DEFAULT) + private String nameOfAffectedPerson3; + + @Column(length = CHARACTER_LIMIT_DEFAULT) + private String nameOfAffectedPerson4; + + @Column(length = CHARACTER_LIMIT_DEFAULT) + private String telNo; + + @Column(length = CHARACTER_LIMIT_DEFAULT) + private String telNo2; + + @Column(length = CHARACTER_LIMIT_DEFAULT) + private String telNo3; + + @Column(length = CHARACTER_LIMIT_DEFAULT) + private String telNo4; + + @DatabaseField(dataType = DataType.DATE_LONG) + private Date dateTime; + + @DatabaseField(dataType = DataType.DATE_LONG) + private Date dateTime2; + + @DatabaseField(dataType = DataType.DATE_LONG) + private Date dateTime3; + + @DatabaseField(dataType = DataType.DATE_LONG) + private Date dateTime4; + + @Column(length = CHARACTER_LIMIT_DEFAULT) + private String age; + + @Column(length = CHARACTER_LIMIT_DEFAULT) + private String age2; + + @Column(length = CHARACTER_LIMIT_DEFAULT) + private String age3; + + @Column(length = CHARACTER_LIMIT_DEFAULT) + private String age4; + + @Column(length = CHARACTER_LIMIT_DEFAULT) + private String suspectedFood; + + @DatabaseField(dataType = DataType.DATE_LONG) + private Date dateConsumed; + + @Enumerated(EnumType.STRING) + private FoodSource foodSource; + + @Enumerated(EnumType.STRING) + private EventType eventType; + + @Column(length = CHARACTER_LIMIT_DEFAULT) + private String eventOtherSpecify; + + @Enumerated(EnumType.STRING) + private YesNo breakfast; + + @Column(length = CHARACTER_LIMIT_DEFAULT) + private String totalNoPersons; + + @Column(length = CHARACTER_LIMIT_DEFAULT) + private String foodConsumed; + + @Column(length = CHARACTER_LIMIT_DEFAULT) + private String sourceOfFood; + + @Enumerated(EnumType.STRING) + private YesNo consumedAtPlace; + + @Enumerated(EnumType.STRING) + private YesNo lunch; + + @Column(length = CHARACTER_LIMIT_DEFAULT) + private String totalNoPersonsL1; + + @Column(length = CHARACTER_LIMIT_DEFAULT) + private String foodConsumedL1; + + @Column(length = CHARACTER_LIMIT_DEFAULT) + private String sourceOfFoodL1; + + @Enumerated(EnumType.STRING) + private YesNo consumedAtPlaceL1; + + @Enumerated(EnumType.STRING) + private YesNo supper; + + @Column(length = CHARACTER_LIMIT_DEFAULT) + private String totalNoPersonsS1; + + @Column(length = CHARACTER_LIMIT_DEFAULT) + private String foodConsumedS1; + + @Column(length = CHARACTER_LIMIT_DEFAULT) + private String sourceOfFoodsS1; + + @Enumerated(EnumType.STRING) + private YesNo consumedAtPlaceS1; + + @Enumerated(EnumType.STRING) + private YesNo breakfast2; + + @Column(length = CHARACTER_LIMIT_DEFAULT) + private String totalNoPersons2; + + @Column(length = CHARACTER_LIMIT_DEFAULT) + private String foodConsumed2; + + @Column(length = CHARACTER_LIMIT_DEFAULT) + private String sourceOfFood2; + + @Enumerated(EnumType.STRING) + private YesNo consumedAtPlace2; + + @Enumerated(EnumType.STRING) + private YesNo lunchL2; + + @Column(length = CHARACTER_LIMIT_DEFAULT) + private String totalNoPersonsL2; + + @Column(length = CHARACTER_LIMIT_DEFAULT) + private String foodConsumedL2; + + @Column(length = CHARACTER_LIMIT_DEFAULT) + private String sourceOfFoodL2; + + @Enumerated(EnumType.STRING) + private YesNo consumedAtPlaceL2; + + @Enumerated(EnumType.STRING) + private YesNo supperS2; + + @Column(length = CHARACTER_LIMIT_DEFAULT) + private String totalNoPersonsS2; + + @Column(length = CHARACTER_LIMIT_DEFAULT) + private String foodConsumedS2; + + @Column(length = CHARACTER_LIMIT_DEFAULT) + private String sourceOfFoodS2; + + @Enumerated(EnumType.STRING) + private YesNo consumedAtPlaceS2; + + @Enumerated(EnumType.STRING) + private YesNo breakfast3; + + @Column(length = CHARACTER_LIMIT_DEFAULT) + private String totalNoPersons3; + + @Column(length = CHARACTER_LIMIT_DEFAULT) + private String foodConsumed3; + + @Column(length = CHARACTER_LIMIT_DEFAULT) + private String sourceOfFood3; + + @Enumerated(EnumType.STRING) + private YesNo consumedAtPlace3; + + @Enumerated(EnumType.STRING) + private YesNo lunchL3; + + @Column(length = CHARACTER_LIMIT_DEFAULT) + private String totalNoPersonsL3; + + @Column(length = CHARACTER_LIMIT_DEFAULT) + private String foodConsumedL3; + + @Column(length = CHARACTER_LIMIT_DEFAULT) + private String sourceOfFoodL3; + + @Enumerated(EnumType.STRING) + private YesNo consumedAtPlaceL3; + + @Enumerated(EnumType.STRING) + private YesNo supperS3; + + @Column(length = CHARACTER_LIMIT_DEFAULT) + private String totalNoPersonsS3; + + @Column(length = CHARACTER_LIMIT_DEFAULT) + private String foodConsumedS3; + + @Column(length = CHARACTER_LIMIT_DEFAULT) + private String sourceOfFoodS3; + + @Enumerated(EnumType.STRING) + private YesNo consumedAtPlaceS3; + + private Integer numberOfPeopleAteImplicatedFood; + + @Column(length = CHARACTER_LIMIT_DEFAULT) + private String numberAffected; + public String getNameOfAffectedPerson() { + return nameOfAffectedPerson; + } + + public void setNameOfAffectedPerson(String nameOfAffectedPerson) { + this.nameOfAffectedPerson = nameOfAffectedPerson; + } + + public String getNameOfAffectedPerson2() { + return nameOfAffectedPerson2; + } + + public void setNameOfAffectedPerson2(String nameOfAffectedPerson2) { + this.nameOfAffectedPerson2 = nameOfAffectedPerson2; + } + + public String getNameOfAffectedPerson3() { + return nameOfAffectedPerson3; + } + + public void setNameOfAffectedPerson3(String nameOfAffectedPerson3) { + this.nameOfAffectedPerson3 = nameOfAffectedPerson3; + } + + public String getNameOfAffectedPerson4() { + return nameOfAffectedPerson4; + } + + public void setNameOfAffectedPerson4(String nameOfAffectedPerson4) { + this.nameOfAffectedPerson4 = nameOfAffectedPerson4; + } + + public String getTelNo() { + return telNo; + } + + public void setTelNo(String telNo) { + this.telNo = telNo; + } + + public String getTelNo2() { + return telNo2; + } + + public void setTelNo2(String telNo2) { + this.telNo2 = telNo2; + } + + public String getTelNo3() { + return telNo3; + } + + public void setTelNo3(String telNo3) { + this.telNo3 = telNo3; + } + + public String getTelNo4() { + return telNo4; + } + + public void setTelNo4(String telNo4) { + this.telNo4 = telNo4; + } + + public Date getDateTime() { + return dateTime; + } + + public void setDateTime(Date dateTime) { + this.dateTime = dateTime; + } + + public Date getDateTime2() { + return dateTime2; + } + + public void setDateTime2(Date dateTime2) { + this.dateTime2 = dateTime2; + } + + public Date getDateTime3() { + return dateTime3; + } + + public void setDateTime3(Date dateTime3) { + this.dateTime3 = dateTime3; + } + + public Date getDateTime4() { + return dateTime4; + } + + public void setDateTime4(Date dateTime4) { + this.dateTime4 = dateTime4; + } + + public String getAge() { + return age; + } + + public void setAge(String age) { + this.age = age; + } + + public String getAge2() { + return age2; + } + + public void setAge2(String age2) { + this.age2 = age2; + } + + public String getAge3() { + return age3; + } + + public void setAge3(String age3) { + this.age3 = age3; + } + + public String getAge4() { + return age4; + } + + public void setAge4(String age4) { + this.age4 = age4; + } + + public String getSuspectedFood() { + return suspectedFood; + } + + public void setSuspectedFood(String suspectedFood) { + this.suspectedFood = suspectedFood; + } + + public Date getDateConsumed() { + return dateConsumed; + } + + public void setDateConsumed(Date dateConsumed) { + this.dateConsumed = dateConsumed; + } + + public FoodSource getFoodSource() { + return foodSource; + } + + public void setFoodSource(FoodSource foodSource) { + this.foodSource = foodSource; + } + + public EventType getEventType() { + return eventType; + } + + public void setEventType(EventType eventType) { + this.eventType = eventType; + } + + public String getEventOtherSpecify() { + return eventOtherSpecify; + } + + public void setEventOtherSpecify(String eventOtherSpecify) { + this.eventOtherSpecify = eventOtherSpecify; + } + + public YesNo getBreakfast() { + return breakfast; + } + + public void setBreakfast(YesNo breakfast) { + this.breakfast = breakfast; + } + + public String getTotalNoPersons() { + return totalNoPersons; + } + + public void setTotalNoPersons(String totalNoPersons) { + this.totalNoPersons = totalNoPersons; + } + + public String getFoodConsumed() { + return foodConsumed; + } + + public void setFoodConsumed(String foodConsumed) { + this.foodConsumed = foodConsumed; + } + + public String getSourceOfFood() { + return sourceOfFood; + } + + public void setSourceOfFood(String sourceOfFood) { + this.sourceOfFood = sourceOfFood; + } + + public YesNo getConsumedAtPlace() { + return consumedAtPlace; + } + + public void setConsumedAtPlace(YesNo consumedAtPlace) { + this.consumedAtPlace = consumedAtPlace; + } + + public YesNo getLunch() { + return lunch; + } + + public void setLunch(YesNo lunch) { + this.lunch = lunch; + } + + public String getTotalNoPersonsL1() { + return totalNoPersonsL1; + } + + public void setTotalNoPersonsL1(String totalNoPersonsL1) { + this.totalNoPersonsL1 = totalNoPersonsL1; + } + + public String getFoodConsumedL1() { + return foodConsumedL1; + } + + public void setFoodConsumedL1(String foodConsumedL1) { + this.foodConsumedL1 = foodConsumedL1; + } + + public String getSourceOfFoodL1() { + return sourceOfFoodL1; + } + + public void setSourceOfFoodL1(String sourceOfFoodL1) { + this.sourceOfFoodL1 = sourceOfFoodL1; + } + + public YesNo getConsumedAtPlaceL1() { + return consumedAtPlaceL1; + } + + public void setConsumedAtPlaceL1(YesNo consumedAtPlaceL1) { + this.consumedAtPlaceL1 = consumedAtPlaceL1; + } + + public YesNo getSupper() { + return supper; + } + + public void setSupper(YesNo supper) { + this.supper = supper; + } + + public String getTotalNoPersonsS1() { + return totalNoPersonsS1; + } + + public void setTotalNoPersonsS1(String totalNoPersonsS1) { + this.totalNoPersonsS1 = totalNoPersonsS1; + } + + public String getFoodConsumedS1() { + return foodConsumedS1; + } + + public void setFoodConsumedS1(String foodConsumedS1) { + this.foodConsumedS1 = foodConsumedS1; + } + + public String getSourceOfFoodsS1() { + return sourceOfFoodsS1; + } + + public void setSourceOfFoodsS1(String sourceOfFoodsS1) { + this.sourceOfFoodsS1 = sourceOfFoodsS1; + } + + public YesNo getConsumedAtPlaceS1() { + return consumedAtPlaceS1; + } + + public void setConsumedAtPlaceS1(YesNo consumedAtPlaceS1) { + this.consumedAtPlaceS1 = consumedAtPlaceS1; + } + + public YesNo getBreakfast2() { + return breakfast2; + } + + public void setBreakfast2(YesNo breakfast2) { + this.breakfast2 = breakfast2; + } + + public String getTotalNoPersons2() { + return totalNoPersons2; + } + + public void setTotalNoPersons2(String totalNoPersons2) { + this.totalNoPersons2 = totalNoPersons2; + } + + public String getFoodConsumed2() { + return foodConsumed2; + } + + public void setFoodConsumed2(String foodConsumed2) { + this.foodConsumed2 = foodConsumed2; + } + + public String getSourceOfFood2() { + return sourceOfFood2; + } + + public void setSourceOfFood2(String sourceOfFood2) { + this.sourceOfFood2 = sourceOfFood2; + } + + public YesNo getConsumedAtPlace2() { + return consumedAtPlace2; + } + + public void setConsumedAtPlace2(YesNo consumedAtPlace2) { + this.consumedAtPlace2 = consumedAtPlace2; + } + + public YesNo getLunchL2() { + return lunchL2; + } + + public void setLunchL2(YesNo lunchL2) { + this.lunchL2 = lunchL2; + } + + public String getTotalNoPersonsL2() { + return totalNoPersonsL2; + } + + public void setTotalNoPersonsL2(String totalNoPersonsL2) { + this.totalNoPersonsL2 = totalNoPersonsL2; + } + + public String getFoodConsumedL2() { + return foodConsumedL2; + } + + public void setFoodConsumedL2(String foodConsumedL2) { + this.foodConsumedL2 = foodConsumedL2; + } + + public String getSourceOfFoodL2() { + return sourceOfFoodL2; + } + + public void setSourceOfFoodL2(String sourceOfFoodL2) { + this.sourceOfFoodL2 = sourceOfFoodL2; + } + + public YesNo getConsumedAtPlaceL2() { + return consumedAtPlaceL2; + } + + public void setConsumedAtPlaceL2(YesNo consumedAtPlaceL2) { + this.consumedAtPlaceL2 = consumedAtPlaceL2; + } + + public YesNo getSupperS2() { + return supperS2; + } + + public void setSupperS2(YesNo supperS2) { + this.supperS2 = supperS2; + } + + public String getTotalNoPersonsS2() { + return totalNoPersonsS2; + } + + public void setTotalNoPersonsS2(String totalNoPersonsS2) { + this.totalNoPersonsS2 = totalNoPersonsS2; + } + + public String getFoodConsumedS2() { + return foodConsumedS2; + } + + public void setFoodConsumedS2(String foodConsumedS2) { + this.foodConsumedS2 = foodConsumedS2; + } + + public String getSourceOfFoodS2() { + return sourceOfFoodS2; + } + + public void setSourceOfFoodS2(String sourceOfFoodS2) { + this.sourceOfFoodS2 = sourceOfFoodS2; + } + + public YesNo getConsumedAtPlaceS2() { + return consumedAtPlaceS2; + } + + public void setConsumedAtPlaceS2(YesNo consumedAtPlaceS2) { + this.consumedAtPlaceS2 = consumedAtPlaceS2; + } + + public YesNo getBreakfast3() { + return breakfast3; + } + + public void setBreakfast3(YesNo breakfast3) { + this.breakfast3 = breakfast3; + } + + public String getTotalNoPersons3() { + return totalNoPersons3; + } + + public void setTotalNoPersons3(String totalNoPersons3) { + this.totalNoPersons3 = totalNoPersons3; + } + + public String getFoodConsumed3() { + return foodConsumed3; + } + + public void setFoodConsumed3(String foodConsumed3) { + this.foodConsumed3 = foodConsumed3; + } + + public String getSourceOfFood3() { + return sourceOfFood3; + } + + public void setSourceOfFood3(String sourceOfFood3) { + this.sourceOfFood3 = sourceOfFood3; + } + + public YesNo getConsumedAtPlace3() { + return consumedAtPlace3; + } + + public void setConsumedAtPlace3(YesNo consumedAtPlace3) { + this.consumedAtPlace3 = consumedAtPlace3; + } + + public YesNo getLunchL3() { + return lunchL3; + } + + public void setLunchL3(YesNo lunchL3) { + this.lunchL3 = lunchL3; + } + + public String getTotalNoPersonsL3() { + return totalNoPersonsL3; + } + + public void setTotalNoPersonsL3(String totalNoPersonsL3) { + this.totalNoPersonsL3 = totalNoPersonsL3; + } + + public String getFoodConsumedL3() { + return foodConsumedL3; + } + + public void setFoodConsumedL3(String foodConsumedL3) { + this.foodConsumedL3 = foodConsumedL3; + } + + public String getSourceOfFoodL3() { + return sourceOfFoodL3; + } + + public void setSourceOfFoodL3(String sourceOfFoodL3) { + this.sourceOfFoodL3 = sourceOfFoodL3; + } + + public YesNo getConsumedAtPlaceL3() { + return consumedAtPlaceL3; + } + + public void setConsumedAtPlaceL3(YesNo consumedAtPlaceL3) { + this.consumedAtPlaceL3 = consumedAtPlaceL3; + } + + public YesNo getSupperS3() { + return supperS3; + } + + public void setSupperS3(YesNo supperS3) { + this.supperS3 = supperS3; + } + + public String getTotalNoPersonsS3() { + return totalNoPersonsS3; + } + + public void setTotalNoPersonsS3(String totalNoPersonsS3) { + this.totalNoPersonsS3 = totalNoPersonsS3; + } + + public String getFoodConsumedS3() { + return foodConsumedS3; + } + + public void setFoodConsumedS3(String foodConsumedS3) { + this.foodConsumedS3 = foodConsumedS3; + } + + public String getSourceOfFoodS3() { + return sourceOfFoodS3; + } + + public void setSourceOfFoodS3(String sourceOfFoodS3) { + this.sourceOfFoodS3 = sourceOfFoodS3; + } + + public YesNo getConsumedAtPlaceS3() { + return consumedAtPlaceS3; + } + + public void setConsumedAtPlaceS3(YesNo consumedAtPlaceS3) { + this.consumedAtPlaceS3 = consumedAtPlaceS3; + } + + public Integer getNumberOfPeopleAteImplicatedFood() { + return numberOfPeopleAteImplicatedFood; + } + + public void setNumberOfPeopleAteImplicatedFood(Integer numberOfPeopleAteImplicatedFood) { + this.numberOfPeopleAteImplicatedFood = numberOfPeopleAteImplicatedFood; + } + + public String getNumberAffected() { + return numberAffected; + } + + public void setNumberAffected(String numberAffected) { + this.numberAffected = numberAffected; + } + + @Override + public String getI18nPrefix() { + return I18N_PREFIX; + } + + +} diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/foodhistory/FoodHistoryDao.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/foodhistory/FoodHistoryDao.java new file mode 100644 index 00000000000..c6676a0d90d --- /dev/null +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/foodhistory/FoodHistoryDao.java @@ -0,0 +1,76 @@ +/* + * SORMAS® - Surveillance Outbreak Response Management & Analysis System + * Copyright © 2016-2018 Helmholtz-Zentrum für Infektionsforschung GmbH (HZI) + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package de.symeda.sormas.app.backend.foodhistory; + +import com.j256.ormlite.dao.Dao; +import java.util.Date; +import de.symeda.sormas.app.backend.common.AbstractAdoDao; +import de.symeda.sormas.app.backend.common.DaoException; + +public class FoodHistoryDao extends AbstractAdoDao { + + public FoodHistoryDao(Dao innerDao) { + super(innerDao); + } + @Override + protected Class getAdoClass() { + return FoodHistory.class; + } + @Override + public String getTableName() { + return FoodHistory.TABLE_NAME; + } + @Override + public FoodHistory queryUuid(String uuid) { + FoodHistory data = super.queryUuid(uuid); + if (data != null) { + initLazyData(data); + } + return data; + } + @Override + public FoodHistory querySnapshotByUuid(String uuid) { + FoodHistory data = super.querySnapshotByUuid(uuid); + if (data != null) { + initLazyData(data); + } + return data; + } + @Override + public FoodHistory queryForId(Long id) { + FoodHistory data = super.queryForId(id); + if (data != null) { + initLazyData(data); + } + return data; + } + private FoodHistory initLazyData(FoodHistory foodHistory) { + return foodHistory; + } + @Override + public FoodHistory saveAndSnapshot(FoodHistory ado) throws DaoException { + FoodHistory snapshot = super.saveAndSnapshot(ado); + return snapshot; + } + @Override + public Date getLatestChangeDate() { + Date date = super.getLatestChangeDate(); + if (date == null) { + return null; + } + return date; + } +} diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/foodhistory/FoodHistoryDtoHelper.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/foodhistory/FoodHistoryDtoHelper.java new file mode 100644 index 00000000000..9aa572db0a9 --- /dev/null +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/foodhistory/FoodHistoryDtoHelper.java @@ -0,0 +1,226 @@ +/* + * SORMAS® - Surveillance Outbreak Response Management & Analysis System + * Copyright © 2016-2018 Helmholtz-Zentrum für Infektionsforschung GmbH (HZI) + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package de.symeda.sormas.app.backend.foodhistory; + +import java.util.List; +import de.symeda.sormas.api.PostResponse; +import de.symeda.sormas.api.foodhistory.FoodHistoryDto; +import de.symeda.sormas.app.backend.common.AdoDtoHelper; +import de.symeda.sormas.app.rest.NoConnectionException; +import retrofit2.Call; + +public class FoodHistoryDtoHelper extends AdoDtoHelper { + + public FoodHistoryDtoHelper(){ + } + + @Override + protected Class getAdoClass() { + return FoodHistory.class; + } + @Override + protected Class getDtoClass() { + return FoodHistoryDto.class; + } + @Override + protected Call> pullAllSince(long since, Integer size, String lastSynchronizedUuid) throws NoConnectionException { + throw new UnsupportedOperationException("Entity is embedded"); + } + @Override + protected Call> pullByUuids(List uuids) throws NoConnectionException { + throw new UnsupportedOperationException("Entity is embedded"); + } + @Override + protected Call> pushAll(List epiDataDtos) throws NoConnectionException { + throw new UnsupportedOperationException("Entity is embedded"); + } + + @Override + public void fillInnerFromDto(FoodHistory target, FoodHistoryDto source) { + + target.setNameOfAffectedPerson(source.getNameOfAffectedPerson()); + target.setNameOfAffectedPerson2(source.getNameOfAffectedPerson2()); + target.setNameOfAffectedPerson3(source.getNameOfAffectedPerson3()); + target.setNameOfAffectedPerson4(source.getNameOfAffectedPerson4()); + + target.setTelNo(source.getTelNo()); + target.setTelNo2(source.getTelNo2()); + target.setTelNo3(source.getTelNo3()); + target.setTelNo4(source.getTelNo4()); + + target.setDateTime(source.getDateTime()); + target.setDateTime2(source.getDateTime2()); + target.setDateTime3(source.getDateTime3()); + target.setDateTime4(source.getDateTime4()); + + target.setAge(source.getAge()); + target.setAge2(source.getAge2()); + target.setAge3(source.getAge3()); + target.setAge4(source.getAge4()); + + target.setSuspectedFood(source.getSuspectedFood()); + target.setDateConsumed(source.getDateConsumed()); + target.setFoodSource(source.getFoodSource()); + target.setEventType(source.getEventType()); + target.setEventOtherSpecify(source.getEventOtherSpecify()); + + target.setBreakfast(source.getBreakfast()); + target.setTotalNoPersons(source.getTotalNoPersons()); + target.setFoodConsumed(source.getFoodConsumed()); + target.setSourceOfFood(source.getSourceOfFood()); + target.setConsumedAtPlace(source.getConsumedAtPlace()); + + target.setLunch(source.getLunch()); + target.setTotalNoPersonsL1(source.getTotalNoPersonsL1()); + target.setFoodConsumedL1(source.getFoodConsumedL1()); + target.setSourceOfFoodL1(source.getSourceOfFoodL1()); + target.setConsumedAtPlaceL1(source.getConsumedAtPlaceL1()); + + target.setSupper(source.getSupper()); + target.setTotalNoPersonsS1(source.getTotalNoPersonsS1()); + target.setFoodConsumedS1(source.getFoodConsumedS1()); + target.setSourceOfFoodsS1(source.getSourceOfFoodsS1()); + target.setConsumedAtPlaceS1(source.getConsumedAtPlaceS1()); + + target.setBreakfast2(source.getBreakfast2()); + target.setTotalNoPersons2(source.getTotalNoPersons2()); + target.setFoodConsumed2(source.getFoodConsumed2()); + target.setSourceOfFood2(source.getSourceOfFood2()); + target.setConsumedAtPlace2(source.getConsumedAtPlace2()); + + target.setLunchL2(source.getLunchL2()); + target.setTotalNoPersonsL2(source.getTotalNoPersonsL2()); + target.setFoodConsumedL2(source.getFoodConsumedL2()); + target.setSourceOfFoodL2(source.getSourceOfFoodL2()); + target.setConsumedAtPlaceL2(source.getConsumedAtPlaceL2()); + + target.setSupperS2(source.getSupperS2()); + target.setTotalNoPersonsS2(source.getTotalNoPersonsS2()); + target.setFoodConsumedS2(source.getFoodConsumedS2()); + target.setSourceOfFoodS2(source.getSourceOfFoodS2()); + target.setConsumedAtPlaceS2(source.getConsumedAtPlaceS2()); + + target.setBreakfast3(source.getBreakfast3()); + target.setTotalNoPersons3(source.getTotalNoPersons3()); + target.setFoodConsumed3(source.getFoodConsumed3()); + target.setSourceOfFood3(source.getSourceOfFood3()); + target.setConsumedAtPlace3(source.getConsumedAtPlace3()); + + target.setLunchL3(source.getLunchL3()); + target.setTotalNoPersonsL3(source.getTotalNoPersonsL3()); + target.setFoodConsumedL3(source.getFoodConsumedL3()); + target.setSourceOfFoodL3(source.getSourceOfFoodL3()); + target.setConsumedAtPlaceL3(source.getConsumedAtPlaceL3()); + + target.setSupperS3(source.getSupperS3()); + target.setTotalNoPersonsS3(source.getTotalNoPersonsS3()); + target.setFoodConsumedS3(source.getFoodConsumedS3()); + target.setSourceOfFoodS3(source.getSourceOfFoodS3()); + target.setConsumedAtPlaceS3(source.getConsumedAtPlaceS3()); + target.setNumberOfPeopleAteImplicatedFood(source.getNumberOfPeopleAteImplicatedFood()); + target.setNumberAffected(source.getNumberAffected()); + } + + @Override + public void fillInnerFromAdo(FoodHistoryDto target, FoodHistory source) { + + target.setNameOfAffectedPerson(source.getNameOfAffectedPerson()); + target.setNameOfAffectedPerson2(source.getNameOfAffectedPerson2()); + target.setNameOfAffectedPerson3(source.getNameOfAffectedPerson3()); + target.setNameOfAffectedPerson4(source.getNameOfAffectedPerson4()); + + target.setTelNo(source.getTelNo()); + target.setTelNo2(source.getTelNo2()); + target.setTelNo3(source.getTelNo3()); + target.setTelNo4(source.getTelNo4()); + + target.setDateTime(source.getDateTime()); + target.setDateTime2(source.getDateTime2()); + target.setDateTime3(source.getDateTime3()); + target.setDateTime4(source.getDateTime4()); + + target.setAge(source.getAge()); + target.setAge2(source.getAge2()); + target.setAge3(source.getAge3()); + target.setAge4(source.getAge4()); + + target.setSuspectedFood(source.getSuspectedFood()); + target.setDateConsumed(source.getDateConsumed()); + target.setFoodSource(source.getFoodSource()); + target.setEventType(source.getEventType()); + target.setEventOtherSpecify(source.getEventOtherSpecify()); + + target.setBreakfast(source.getBreakfast()); + target.setTotalNoPersons(source.getTotalNoPersons()); + target.setFoodConsumed(source.getFoodConsumed()); + target.setSourceOfFood(source.getSourceOfFood()); + target.setConsumedAtPlace(source.getConsumedAtPlace()); + + target.setLunch(source.getLunch()); + target.setTotalNoPersonsL1(source.getTotalNoPersonsL1()); + target.setFoodConsumedL1(source.getFoodConsumedL1()); + target.setSourceOfFoodL1(source.getSourceOfFoodL1()); + target.setConsumedAtPlaceL1(source.getConsumedAtPlaceL1()); + + target.setSupper(source.getSupper()); + target.setTotalNoPersonsS1(source.getTotalNoPersonsS1()); + target.setFoodConsumedS1(source.getFoodConsumedS1()); + target.setSourceOfFoodsS1(source.getSourceOfFoodsS1()); + target.setConsumedAtPlaceS1(source.getConsumedAtPlaceS1()); + + target.setBreakfast2(source.getBreakfast2()); + target.setTotalNoPersons2(source.getTotalNoPersons2()); + target.setFoodConsumed2(source.getFoodConsumed2()); + target.setSourceOfFood2(source.getSourceOfFood2()); + target.setConsumedAtPlace2(source.getConsumedAtPlace2()); + + target.setLunchL2(source.getLunchL2()); + target.setTotalNoPersonsL2(source.getTotalNoPersonsL2()); + target.setFoodConsumedL2(source.getFoodConsumedL2()); + target.setSourceOfFoodL2(source.getSourceOfFoodL2()); + target.setConsumedAtPlaceL2(source.getConsumedAtPlaceL2()); + + target.setSupperS2(source.getSupperS2()); + target.setTotalNoPersonsS2(source.getTotalNoPersonsS2()); + target.setFoodConsumedS2(source.getFoodConsumedS2()); + target.setSourceOfFoodS2(source.getSourceOfFoodS2()); + target.setConsumedAtPlaceS2(source.getConsumedAtPlaceS2()); + + target.setBreakfast3(source.getBreakfast3()); + target.setTotalNoPersons3(source.getTotalNoPersons3()); + target.setFoodConsumed3(source.getFoodConsumed3()); + target.setSourceOfFood3(source.getSourceOfFood3()); + target.setConsumedAtPlace3(source.getConsumedAtPlace3()); + + target.setLunchL3(source.getLunchL3()); + target.setTotalNoPersonsL3(source.getTotalNoPersonsL3()); + target.setFoodConsumedL3(source.getFoodConsumedL3()); + target.setSourceOfFoodL3(source.getSourceOfFoodL3()); + target.setConsumedAtPlaceL3(source.getConsumedAtPlaceL3()); + + target.setSupperS3(source.getSupperS3()); + target.setTotalNoPersonsS3(source.getTotalNoPersonsS3()); + target.setFoodConsumedS3(source.getFoodConsumedS3()); + target.setSourceOfFoodS3(source.getSourceOfFoodS3()); + target.setConsumedAtPlaceS3(source.getConsumedAtPlaceS3()); + target.setNumberOfPeopleAteImplicatedFood(source.getNumberOfPeopleAteImplicatedFood()); + target.setNumberAffected(source.getNumberAffected()); + } + + @Override + protected long getApproximateJsonSizeInBytes() { + return 0; + } +} diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/caze/CaseSection.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/caze/CaseSection.java index b41c38827c0..ad31d58241b 100644 --- a/sormas-app/app/src/main/java/de/symeda/sormas/app/caze/CaseSection.java +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/caze/CaseSection.java @@ -41,7 +41,8 @@ public enum CaseSection EVENTS(R.string.caption_case_events, R.drawable.ic_event_available_black_24dp), IMMUNIZATIONS(R.string.caption_case_immunizations, R.drawable.ic_drawer_immunization_24dp), VACCINATIONS(R.string.caption_case_vaccinations, R.drawable.ic_drawer_vaccines_24), - RISK_FACTORS(R.string.caption_case_risk_factors, R.drawable.ic_warning_black_24dp); + RISK_FACTORS(R.string.caption_case_risk_factors, R.drawable.ic_warning_black_24dp), + FOOD_HISTORY(R.string.caption_case_food_history, R.drawable.ic_dvr_black_24dp); private int friendlyNameResourceId; private int iconResourceId; diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/caze/edit/CaseEditActivity.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/caze/edit/CaseEditActivity.java index 986b6c8f2ac..6c80ed05216 100644 --- a/sormas-app/app/src/main/java/de/symeda/sormas/app/caze/edit/CaseEditActivity.java +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/caze/edit/CaseEditActivity.java @@ -224,6 +224,9 @@ protected BaseEditFragment buildEditFragment(PageMenuItem menuItem, Case activit case RISK_FACTORS: fragment = CaseEditRiskFactorFragment.newInstance(activityRootData); break; + case FOOD_HISTORY: + fragment = CaseEditFoodHistoryFragment.newInstance(activityRootData); + break; default: throw new IndexOutOfBoundsException(DataHelper.toStringNullable(section)); } diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/caze/edit/CaseEditFoodHistoryFragment.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/caze/edit/CaseEditFoodHistoryFragment.java new file mode 100644 index 00000000000..913ebe87bbc --- /dev/null +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/caze/edit/CaseEditFoodHistoryFragment.java @@ -0,0 +1,95 @@ +/* + * SORMAS® - Surveillance Outbreak Response Management & Analysis System + * Copyright © 2016-2018 Helmholtz-Zentrum für Infektionsforschung GmbH (HZI) + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package de.symeda.sormas.app.caze.edit; + +import android.content.res.Resources; + +import java.util.List; + +import de.symeda.sormas.api.FormType; +import de.symeda.sormas.api.foodhistory.FoodHistoryDto; +import de.symeda.sormas.api.utils.EventType; +import de.symeda.sormas.api.utils.FoodSource; +import de.symeda.sormas.api.utils.YesNo; +import de.symeda.sormas.api.utils.fieldaccess.UiFieldAccessCheckers; +import de.symeda.sormas.api.utils.fieldvisibility.FieldVisibilityCheckers; +import de.symeda.sormas.app.BaseEditFragment; +import de.symeda.sormas.app.R; +import de.symeda.sormas.app.backend.caze.Case; +import de.symeda.sormas.app.backend.foodhistory.FoodHistory; +import de.symeda.sormas.app.component.Item; +import de.symeda.sormas.app.databinding.FragmentCaseEditFoodhistoryLayoutBinding; +import de.symeda.sormas.app.util.DataUtils; + +public class CaseEditFoodHistoryFragment extends BaseEditFragment { + + private List foodSourceList; + private List eventTypeList; + + private FoodHistory record; + private Case caze; + + public static CaseEditFoodHistoryFragment newInstance(Case activityRootData) { + return newInstanceWithFieldCheckers( + CaseEditFoodHistoryFragment.class, + null, + activityRootData, + new FieldVisibilityCheckers(), + UiFieldAccessCheckers.forSensitiveData(activityRootData.isPseudonymized())); + } + + @Override + protected String getSubHeadingTitle() { + Resources r = getResources(); + return r.getString(R.string.caption_case_food_history); + } + @Override + public FoodHistory getPrimaryData() { + return record; + } + @Override + protected void prepareFragmentData() { + caze = getActivityRootData(); + record = caze.getFoodHistory(); + foodSourceList = DataUtils.getEnumItems(FoodSource.class, true); + eventTypeList = DataUtils.getEnumItems(EventType.class, true); + } + + @Override + public void onLayoutBinding(final FragmentCaseEditFoodhistoryLayoutBinding contentBinding) { + contentBinding.setData(record); + contentBinding.setCaze(caze); + contentBinding.setYesNoClass(YesNo.class); + + contentBinding.foodHistoryFoodSource.initializeSpinner(foodSourceList); + contentBinding.foodHistoryEventType.initializeSpinner(eventTypeList); + contentBinding.foodHistoryDateConsumed.initializeDateTimeField(getFragmentManager()); + + if (caze.getDisease() != null) { + super.hideFieldsForDisease(caze.getDisease(), contentBinding.mainContent, FormType.FOOD_HISTORY_EDIT); + } + } + + @Override + protected void onAfterLayoutBinding(FragmentCaseEditFoodhistoryLayoutBinding contentBinding) { + setFieldVisibilitiesAndAccesses(FoodHistoryDto.class, contentBinding.mainContent); + + } + @Override + public int getEditLayout() { + return R.layout.fragment_case_edit_foodhistory_layout; + } + +} diff --git a/sormas-app/app/src/main/res/layout/fragment_case_edit_foodhistory_layout.xml b/sormas-app/app/src/main/res/layout/fragment_case_edit_foodhistory_layout.xml new file mode 100644 index 00000000000..3bcd6f97df2 --- /dev/null +++ b/sormas-app/app/src/main/res/layout/fragment_case_edit_foodhistory_layout.xml @@ -0,0 +1,623 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sormas-app/app/src/main/res/values/strings.xml b/sormas-app/app/src/main/res/values/strings.xml index 59a227de2a5..6db2ebfab79 100644 --- a/sormas-app/app/src/main/res/values/strings.xml +++ b/sormas-app/app/src/main/res/values/strings.xml @@ -164,6 +164,7 @@ Case Immunizations Case Vaccinations Risk Factors + Food History Treatments Create a new case Changed data lost during re-sync. @@ -299,7 +300,7 @@ %1$s pulled %1$s/%2$s pushed %1$s deleted -` + ` Are you sure you want to do this? Are you sure you want to delete this record? Are you in this place right now? @@ -338,6 +339,7 @@ the pathogen test has no lab user General comment + Other persons in your household / community affected Additional Medical Information Addresses Animal Contacts @@ -488,7 +490,7 @@ Bacteriology lab findings Looking out for exposure to the identified hazards Within 3 days prior to the onset of the disease did the patient drink from ??? -Within 3 days prior to the onset of the disease did the patient drink from ??? + Within 3 days prior to the onset of the disease did the patient drink from ??? Within 3 days prior to the onset of the disease did the patient eat Within 3 days prior to the onset of the disease did the patient attend any @@ -783,14 +785,16 @@ Not a valid username Password must be >5 characters "Login failed" - "Enter Current Password" - "Enter New Password" - "Enter Confirm Password" - "Enter Current Password" - "Enter new Password" - "Confirm Password" + "Enter Current Password" + "Enter New Password" + "Enter Confirm Password" + "Enter Current Password" + "Enter new Password" + "Confirm Password" Signal Is not An Event Triaging Decision Is Discard Or Referred Risk assessment / Alert is disabled, Signal is not an event Event Details + + Hello blank fragment