From 9839ff9ba632000257f23430ce26704b9e75439a Mon Sep 17 00:00:00 2001 From: Flava177 Date: Tue, 3 Dec 2024 14:30:24 +0000 Subject: [PATCH] #182: Implemented a new feature: Investigation Notes entity with it's fields: investigationNotesData, suspectedDiagnosis, confirmedDiagnosis, investigatedBy, investigatorSignature, investigatorDate --- .../symeda/sormas/app/backend/caze/Case.java | 11 ++ .../sormas/app/backend/caze/CaseDao.java | 8 ++ .../app/backend/caze/CaseDtoHelper.java | 10 ++ .../app/backend/common/DatabaseHelper.java | 36 +++++- .../InvestigationNotes.java | 91 +++++++++++++++ .../InvestigationNotesDao.java | 71 ++++++++++++ .../InvestigationNotesDtoHelper.java | 65 +++++++++++ .../symeda/sormas/app/caze/CaseSection.java | 3 +- .../app/caze/edit/CaseEditActivity.java | 5 +- .../edit/CaseEditFoodHistoryFragment.java | 1 - .../CaseEditInvestigationNotesFragment.java | 80 +++++++++++++ ...nt_case_edit_investigationnotes_layout.xml | 106 ++++++++++++++++++ .../app/src/main/res/values/strings.xml | 1 + 13 files changed, 484 insertions(+), 4 deletions(-) create mode 100644 sormas-app/app/src/main/java/de/symeda/sormas/app/backend/investigationnotes/InvestigationNotes.java create mode 100644 sormas-app/app/src/main/java/de/symeda/sormas/app/backend/investigationnotes/InvestigationNotesDao.java create mode 100644 sormas-app/app/src/main/java/de/symeda/sormas/app/backend/investigationnotes/InvestigationNotesDtoHelper.java create mode 100644 sormas-app/app/src/main/java/de/symeda/sormas/app/caze/edit/CaseEditInvestigationNotesFragment.java create mode 100644 sormas-app/app/src/main/res/layout/fragment_case_edit_investigationnotes_layout.xml 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 353125cf76b..2dd6eae97e0 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 @@ -75,6 +75,7 @@ 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.investigationnotes.InvestigationNotes; import de.symeda.sormas.app.backend.person.Person; import de.symeda.sormas.app.backend.region.Community; import de.symeda.sormas.app.backend.region.District; @@ -118,6 +119,7 @@ public class Case extends PseudonymizableAdo { public static final String HEALTH_CONDITIONS = "healthConditions"; public static final String RISK_FACTOR = "riskFactor"; public static final String FOOD_HISTORY = "foodHistory"; + public static final String INVESTIGATION_NOTES = "investigationNotes"; @DatabaseField(foreign = true, foreignAutoRefresh = true, canBeNull = false, maxForeignAutoRefreshLevel = 3) private Person person; @@ -291,6 +293,9 @@ public class Case extends PseudonymizableAdo { @DatabaseField(foreign = true, foreignAutoRefresh = true) private FoodHistory foodHistory; + @DatabaseField(foreign = true, foreignAutoRefresh = true) + private InvestigationNotes investigationNotes; + @Deprecated @Column private Long contactOfficer_id; @@ -968,6 +973,12 @@ public FoodHistory getFoodHistory() { public void setFoodHistory(FoodHistory foodHistory) { this.foodHistory = foodHistory; } + public InvestigationNotes getInvestigationNotes(){ + return investigationNotes; + } + + public void setInvestigationNotes(InvestigationNotes investigationNotes) {this.investigationNotes = investigationNotes; } + 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 1840a1aff3d..ee92527dbd6 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 @@ -82,6 +82,7 @@ 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.investigationnotes.InvestigationNotes; import de.symeda.sormas.app.backend.person.Person; import de.symeda.sormas.app.backend.persontravelhistory.PersonTravelHistory; import de.symeda.sormas.app.backend.region.Community; @@ -220,6 +221,11 @@ public Date getLatestChangeDate() { date = affectedPersonDate; } + Date investigationNotesDate = getLatestChangeDateJoin(InvestigationNotes.TABLE_NAME, Case.INVESTIGATION_NOTES); + if (investigationNotesDate != null && investigationNotesDate.after(date)) { + date = investigationNotesDate; + } + return date; } @@ -302,6 +308,8 @@ public Case build(Person person) { // food history caze.setFoodHistory(DatabaseHelper.getFoodHistoryDao().build()); + caze.setInvestigationNotes(DatabaseHelper.getInvestigationNotesDao().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 fd851f22296..a58870d37fd 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 @@ -39,6 +39,7 @@ import de.symeda.sormas.app.backend.hospitalization.HospitalizationDtoHelper; import de.symeda.sormas.app.backend.infrastructure.PointOfEntry; import de.symeda.sormas.app.backend.infrastructure.PointOfEntryDtoHelper; +import de.symeda.sormas.app.backend.investigationnotes.InvestigationNotesDtoHelper; import de.symeda.sormas.app.backend.person.Person; import de.symeda.sormas.app.backend.person.PersonDependentDtoHelper; import de.symeda.sormas.app.backend.person.PersonDtoHelper; @@ -73,6 +74,7 @@ public class CaseDtoHelper extends PersonDependentDtoHelper { private HealthConditionsDtoHelper healthConditionsDtoHelper = new HealthConditionsDtoHelper(); private RiskFactorDtoHelper riskFactorDtoHelper = new RiskFactorDtoHelper(); private FoodHistoryDtoHelper foodHistoryDtoHelper = new FoodHistoryDtoHelper(); + private InvestigationNotesDtoHelper investigationNotesDtoHelper = new InvestigationNotesDtoHelper(); @Override protected Class getAdoClass() { @@ -152,6 +154,7 @@ public void fillInnerFromDto(Case target, CaseDataDto source) { 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.setInvestigationNotes(investigationNotesDtoHelper.fillOrCreateFromDto(target.getInvestigationNotes(), source.getInvestigationNotes())); target.setSurveillanceOfficer(DatabaseHelper.getUserDao().getByReferenceDto(source.getSurveillanceOfficer())); target.setClinicianName(source.getClinicianName()); @@ -470,6 +473,13 @@ public void fillInnerFromAdo(CaseDataDto target, Case source) { target.setFoodHistory(null); } + if (source.getInvestigationNotes() != null) { + target.setInvestigationNotes( + investigationNotesDtoHelper.adoToDto(DatabaseHelper.getInvestigationNotesDao().queryForId(source.getInvestigationNotes().getId()))); + } else { + target.setInvestigationNotes(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 643a5eacbfd..287b9a73857 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 @@ -142,6 +142,8 @@ import de.symeda.sormas.app.backend.immunization.ImmunizationDao; import de.symeda.sormas.app.backend.infrastructure.PointOfEntry; import de.symeda.sormas.app.backend.infrastructure.PointOfEntryDao; +import de.symeda.sormas.app.backend.investigationnotes.InvestigationNotes; +import de.symeda.sormas.app.backend.investigationnotes.InvestigationNotesDao; import de.symeda.sormas.app.backend.lbds.LbdsSync; import de.symeda.sormas.app.backend.lbds.LbdsSyncDao; import de.symeda.sormas.app.backend.location.Location; @@ -224,7 +226,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 = 409; + public static final int DATABASE_VERSION = 410; private static DatabaseHelper instance = null; @@ -313,6 +315,7 @@ public static void clearTables(boolean clearInfrastructure) { TableUtils.clearTable(connectionSource, RiskFactor.class); TableUtils.clearTable(connectionSource, FoodHistory.class); TableUtils.clearTable(connectionSource, AffectedPerson.class); + TableUtils.clearTable(connectionSource, InvestigationNotes.class); if (clearInfrastructure) { TableUtils.clearTable(connectionSource, UserUserRole.class); @@ -433,8 +436,10 @@ public void onCreate(SQLiteDatabase db, ConnectionSource connectionSource) { TableUtils.createTable(connectionSource, PersonTravelHistory.class); TableUtils.createTable(connectionSource, ContaminationSource.class); TableUtils.createTable(connectionSource, ContainmentMeasure.class); + TableUtils.createTable(connectionSource, AffectedPerson.class); TableUtils.createTable(connectionSource, RiskFactor.class); TableUtils.createTable(connectionSource, FoodHistory.class); + TableUtils.createTable(connectionSource, InvestigationNotes.class); } catch (SQLException e) { Log.e(DatabaseHelper.class.getName(), "Can't build database", e); throw new RuntimeException(e); @@ -4122,6 +4127,30 @@ public void onUpgrade(SQLiteDatabase db, ConnectionSource connectionSource, int + ");" ); + case 409: + currentVersion = 409; + getDao(InvestigationNotes.class).executeRaw( + "CREATE TABLE investigationnotes (" + + " id INTEGER PRIMARY KEY AUTOINCREMENT," + + " investigationNotesData VARCHAR(255)," + + " suspectedDiagnosis VARCHAR(255)," + + " confirmedDiagnosis VARCHAR(255)," + + " investigatedBy VARCHAR(255)," + + " investigatorSignature VARCHAR(255)," + + " investigatorDate DATE," + + " changedate BIGINT," + + " changeUserId BIGINT," + + " creationDate DATE," + + " uuid VARCHAR(512)," + + " pseudonymized SMALLINT," + + " lastOpenedDate BIGINT," + + " localChangeDate BIGINT NOT NULL," + + " modified SMALLINT," + + " snapshot SMALLINT," + + " UNIQUE (snapshot ASC, uuid ASC)" + + ");" + ); + getDao(Case.class).executeRaw("ALTER TABLE cases ADD COLUMN investigationnotes_id BIGINT;"); // ATTENTION: break should only be done after last version break; @@ -5102,6 +5131,8 @@ else if (type.equals(FormField.class)) { dao = (AbstractAdoDao) new FoodHistoryDao((Dao) innerDao); } else if (type.equals(AffectedPerson.class)) { dao = (AbstractAdoDao) new AffectedPersonDao((Dao) innerDao); + } else if (type.equals(InvestigationNotes.class)) { + dao = (AbstractAdoDao) new InvestigationNotesDao((Dao) innerDao); } else { throw new UnsupportedOperationException(type.toString()); } @@ -5226,6 +5257,9 @@ public static FoodHistoryDao getFoodHistoryDao() { return (FoodHistoryDao) getAdoDao(FoodHistory.class); } + public static InvestigationNotesDao getInvestigationNotesDao() { + return (InvestigationNotesDao) getAdoDao(InvestigationNotes.class); + } public static PersonDao getPersonDao() { return (PersonDao) getAdoDao(Person.class); diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/investigationnotes/InvestigationNotes.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/investigationnotes/InvestigationNotes.java new file mode 100644 index 00000000000..0b21b411d7a --- /dev/null +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/investigationnotes/InvestigationNotes.java @@ -0,0 +1,91 @@ +package de.symeda.sormas.app.backend.investigationnotes; + +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 javax.persistence.Entity; +import java.util.Date; +import javax.persistence.Column; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; + +import de.symeda.sormas.app.backend.common.EmbeddedAdo; +import de.symeda.sormas.app.backend.common.PseudonymizableAdo; + +@Entity(name = InvestigationNotes.TABLE_NAME) +@DatabaseTable(tableName = InvestigationNotes.TABLE_NAME) +@EmbeddedAdo +public class InvestigationNotes extends PseudonymizableAdo { + + private static final long serialVersionUID = -8294812479501735785L; + public static final String TABLE_NAME = "investigationnotes"; + public static final String I18N_PREFIX = "InvestigationNotes"; + + @Column(length = CHARACTER_LIMIT_DEFAULT) + private String investigationNotesData; + @Column(length = CHARACTER_LIMIT_DEFAULT) + private String suspectedDiagnosis; + @Column(length = CHARACTER_LIMIT_DEFAULT) + private String confirmedDiagnosis; + @Column(length = CHARACTER_LIMIT_DEFAULT) + private String investigatedBy; + @Column(length = CHARACTER_LIMIT_DEFAULT) + private String investigatorSignature; + @DatabaseField(dataType = DataType.DATE_LONG) + private Date investigatorDate; + + public String getInvestigationNotesData() { + return investigationNotesData; + } + + public void setInvestigationNotesData(String investigationNotesData) { + this.investigationNotesData = investigationNotesData; + } + + public String getSuspectedDiagnosis() { + return suspectedDiagnosis; + } + + public void setSuspectedDiagnosis(String suspectedDiagnosis) { + this.suspectedDiagnosis = suspectedDiagnosis; + } + + public String getConfirmedDiagnosis() { + return confirmedDiagnosis; + } + + public void setConfirmedDiagnosis(String confirmedDiagnosis) { + this.confirmedDiagnosis = confirmedDiagnosis; + } + + public String getInvestigatedBy() { + return investigatedBy; + } + + public void setInvestigatedBy(String investigatedBy) { + this.investigatedBy = investigatedBy; + } + + public String getInvestigatorSignature() { + return investigatorSignature; + } + + public void setInvestigatorSignature(String investigatorSignature) { + this.investigatorSignature = investigatorSignature; + } + public Date getInvestigatorDate() { + return investigatorDate; + } + + public void setInvestigatorDate(Date investigatorDate) { + this.investigatorDate = investigatorDate; + } + + @Override + public String getI18nPrefix() { + return I18N_PREFIX; + } +} diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/investigationnotes/InvestigationNotesDao.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/investigationnotes/InvestigationNotesDao.java new file mode 100644 index 00000000000..52f3bcb01fb --- /dev/null +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/investigationnotes/InvestigationNotesDao.java @@ -0,0 +1,71 @@ +package de.symeda.sormas.app.backend.investigationnotes; + +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 InvestigationNotesDao extends AbstractAdoDao { + + public InvestigationNotesDao(Dao innerDao) { + super(innerDao); + } + + @Override + protected Class getAdoClass() { + return InvestigationNotes.class; + } + + @Override + public String getTableName() { + return InvestigationNotes.TABLE_NAME; + } + + @Override + public InvestigationNotes queryUuid(String uuid) { + InvestigationNotes data = super.queryUuid(uuid); + if (data != null) { + initLazyData(data); + } + return data; + } + + @Override + public InvestigationNotes querySnapshotByUuid(String uuid) { + InvestigationNotes data = super.querySnapshotByUuid(uuid); + if (data != null) { + initLazyData(data); + } + return data; + } + + @Override + public InvestigationNotes queryForId(Long id) { + InvestigationNotes data = super.queryForId(id); + if (data != null) { + initLazyData(data); + } + return data; + } + + private InvestigationNotes initLazyData(InvestigationNotes foodHistory) { + return foodHistory; + } + + @Override + public InvestigationNotes saveAndSnapshot(InvestigationNotes ado) throws DaoException { + InvestigationNotes 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/investigationnotes/InvestigationNotesDtoHelper.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/investigationnotes/InvestigationNotesDtoHelper.java new file mode 100644 index 00000000000..55a8fbca404 --- /dev/null +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/investigationnotes/InvestigationNotesDtoHelper.java @@ -0,0 +1,65 @@ +package de.symeda.sormas.app.backend.investigationnotes; + +import java.util.List; + +import de.symeda.sormas.api.PostResponse; +import de.symeda.sormas.api.investigationnotes.InvestigationNotesDto; +import de.symeda.sormas.app.backend.common.AdoDtoHelper; +import de.symeda.sormas.app.rest.NoConnectionException; +import retrofit2.Call; + +public class InvestigationNotesDtoHelper extends AdoDtoHelper { + + public InvestigationNotesDtoHelper(){ + } + + @Override + protected Class getAdoClass() { + return InvestigationNotes.class; + } + + @Override + protected Class getDtoClass() { + return InvestigationNotesDto.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 investigationNotesDtos) throws NoConnectionException { + throw new UnsupportedOperationException("Entity is embedded"); + } + + @Override + public void fillInnerFromDto(InvestigationNotes target, InvestigationNotesDto source) { + target.setInvestigationNotesData(source.getInvestigationNotesData()); + target.setSuspectedDiagnosis(source.getSuspectedDiagnosis()); + target.setConfirmedDiagnosis(source.getConfirmedDiagnosis()); + target.setInvestigatedBy(source.getInvestigatedBy()); + target.setInvestigatorSignature(source.getInvestigatorSignature()); + target.setInvestigatorDate(source.getInvestigatorDate()); + } + + @Override + public void fillInnerFromAdo(InvestigationNotesDto target, InvestigationNotes source) { + target.setInvestigationNotesData(source.getInvestigationNotesData()); + target.setSuspectedDiagnosis(source.getSuspectedDiagnosis()); + target.setConfirmedDiagnosis(source.getConfirmedDiagnosis()); + target.setInvestigatedBy(source.getInvestigatedBy()); + target.setInvestigatorSignature(source.getInvestigatorSignature()); + target.setInvestigatorDate(source.getInvestigatorDate()); + } + + @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 ad31d58241b..2bccc3c220f 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 @@ -42,7 +42,8 @@ public enum CaseSection 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), - FOOD_HISTORY(R.string.caption_case_food_history, R.drawable.ic_dvr_black_24dp); + FOOD_HISTORY(R.string.caption_case_food_history, R.drawable.ic_dvr_black_24dp), + INVESTIGATION_NOTES(R.string.caption_case_investigation_notes, R.drawable.ic_drawer_case_blue_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 6c80ed05216..6ff63b5dec6 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,9 +224,12 @@ protected BaseEditFragment buildEditFragment(PageMenuItem menuItem, Case activit case RISK_FACTORS: fragment = CaseEditRiskFactorFragment.newInstance(activityRootData); break; - case FOOD_HISTORY: + case FOOD_HISTORY: fragment = CaseEditFoodHistoryFragment.newInstance(activityRootData); break; + case INVESTIGATION_NOTES: + fragment = CaseEditInvestigationNotesFragment.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 index a868ebd7e5f..48bf48a0a01 100644 --- 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 @@ -40,7 +40,6 @@ import de.symeda.sormas.app.backend.caze.Case; import de.symeda.sormas.app.backend.common.AbstractDomainObject; import de.symeda.sormas.app.backend.common.DatabaseHelper; -import de.symeda.sormas.app.backend.epidata.EpiData; import de.symeda.sormas.app.backend.foodhistory.FoodHistory; import de.symeda.sormas.app.component.Item; import de.symeda.sormas.app.core.IEntryItemOnClickListener; diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/caze/edit/CaseEditInvestigationNotesFragment.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/caze/edit/CaseEditInvestigationNotesFragment.java new file mode 100644 index 00000000000..8e727a006b6 --- /dev/null +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/caze/edit/CaseEditInvestigationNotesFragment.java @@ -0,0 +1,80 @@ +/* + * 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 de.symeda.sormas.api.FormType; +import de.symeda.sormas.api.investigationnotes.InvestigationNotesDto; +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.investigationnotes.InvestigationNotes; +import de.symeda.sormas.app.databinding.FragmentCaseEditInvestigationnotesLayoutBinding; + +public class CaseEditInvestigationNotesFragment extends BaseEditFragment { + + private InvestigationNotes record; + private Case caze; + + public static CaseEditInvestigationNotesFragment newInstance(Case activityRootData) { + return newInstanceWithFieldCheckers( + CaseEditInvestigationNotesFragment.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 InvestigationNotes getPrimaryData() { + return record; + } + + @Override + protected void prepareFragmentData() { + caze = getActivityRootData(); + record = caze.getInvestigationNotes(); + } + + @Override + public void onLayoutBinding(final FragmentCaseEditInvestigationnotesLayoutBinding contentBinding) { + contentBinding.setData(record); + contentBinding.setCaze(caze); + contentBinding.investigationNotesInvestigatorDate.initializeDateField(getFragmentManager()); + + if (caze.getDisease() != null) { + super.hideFieldsForDisease(caze.getDisease(), contentBinding.mainContent, FormType.INVESTIGATION_NOTES_EDIT); + } + } + + @Override + protected void onAfterLayoutBinding(FragmentCaseEditInvestigationnotesLayoutBinding contentBinding) { + setFieldVisibilitiesAndAccesses(InvestigationNotesDto.class, contentBinding.mainContent); + } + + @Override + public int getEditLayout() { + return R.layout.fragment_case_edit_investigationnotes_layout; + } +} diff --git a/sormas-app/app/src/main/res/layout/fragment_case_edit_investigationnotes_layout.xml b/sormas-app/app/src/main/res/layout/fragment_case_edit_investigationnotes_layout.xml new file mode 100644 index 00000000000..eb3735ae1a1 --- /dev/null +++ b/sormas-app/app/src/main/res/layout/fragment_case_edit_investigationnotes_layout.xml @@ -0,0 +1,106 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ 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 6bb588d486e..abfd9bf0543 100644 --- a/sormas-app/app/src/main/res/values/strings.xml +++ b/sormas-app/app/src/main/res/values/strings.xml @@ -165,6 +165,7 @@ Case Vaccinations Risk Factors Food History + Investigation Notes Treatments Create a new case Changed data lost during re-sync.