diff --git a/sormas-api/pom.xml b/sormas-api/pom.xml
index 87264eb1037..6bc0bb92ab1 100644
--- a/sormas-api/pom.xml
+++ b/sormas-api/pom.xml
@@ -2,7 +2,7 @@
de.symeda.sormas
sormas-base
- 0.2.0
+ 0.3.0
../sormas-base
4.0.0
diff --git a/sormas-api/src/main/java/de/symeda/sormas/api/caze/CaseDataDto.java b/sormas-api/src/main/java/de/symeda/sormas/api/caze/CaseDataDto.java
index e6333e3daa2..a54dba641ac 100644
--- a/sormas-api/src/main/java/de/symeda/sormas/api/caze/CaseDataDto.java
+++ b/sormas-api/src/main/java/de/symeda/sormas/api/caze/CaseDataDto.java
@@ -37,7 +37,6 @@ public class CaseDataDto extends CaseReferenceDto {
public static final String INVESTIGATED_DATE = "investigatedDate";
public static final String SURVEILLANCE_OFFICER = "surveillanceOfficer";
public static final String CASE_OFFICER = "caseOfficer";
- public static final String CONTACT_OFFICER = "contactOfficer";
public static final String SYMPTOMS = "symptoms";
public static final String HOSPITALIZATION = "hospitalization";
public static final String EPI_DATA = "epiData";
@@ -77,7 +76,6 @@ public class CaseDataDto extends CaseReferenceDto {
private UserReferenceDto surveillanceOfficer;
private UserReferenceDto caseOfficer;
- private UserReferenceDto contactOfficer;
public CaseClassification getCaseClassification() {
return caseClassification;
@@ -159,14 +157,6 @@ public void setCaseOfficer(UserReferenceDto caseOfficer) {
this.caseOfficer = caseOfficer;
}
- public UserReferenceDto getContactOfficer() {
- return contactOfficer;
- }
-
- public void setContactOfficer(UserReferenceDto contactOfficer) {
- this.contactOfficer = contactOfficer;
- }
-
public SymptomsDto getSymptoms() {
return symptoms;
}
diff --git a/sormas-api/src/main/java/de/symeda/sormas/api/contact/ContactFacade.java b/sormas-api/src/main/java/de/symeda/sormas/api/contact/ContactFacade.java
index 1757b355fc7..22a740c5397 100644
--- a/sormas-api/src/main/java/de/symeda/sormas/api/contact/ContactFacade.java
+++ b/sormas-api/src/main/java/de/symeda/sormas/api/contact/ContactFacade.java
@@ -33,4 +33,6 @@ public interface ContactFacade {
ContactReferenceDto getReferenceByUuid(String uuid);
List getAllUuids(String userUuid);
+
+ void generateContactFollowUpTasks();
}
diff --git a/sormas-api/src/main/java/de/symeda/sormas/api/sample/SampleDto.java b/sormas-api/src/main/java/de/symeda/sormas/api/sample/SampleDto.java
index 702efc307be..ab81301d9d6 100644
--- a/sormas-api/src/main/java/de/symeda/sormas/api/sample/SampleDto.java
+++ b/sormas-api/src/main/java/de/symeda/sormas/api/sample/SampleDto.java
@@ -22,7 +22,6 @@ public class SampleDto extends SampleReferenceDto {
public static final String SAMPLE_MATERIAL_TEXT = "sampleMaterialText";
public static final String LAB = "lab";
public static final String OTHER_LAB = "otherLab";
- public static final String SHIPMENT_STATUS = "shipmentStatus";
public static final String SHIPMENT_DATE = "shipmentDate";
public static final String SHIPMENT_DETAILS = "shipmentDetails";
public static final String RECEIVED_DATE = "receivedDate";
@@ -31,6 +30,9 @@ public class SampleDto extends SampleReferenceDto {
public static final String COMMENT = "comment";
public static final String SAMPLE_SOURCE = "sampleSource";
public static final String SUGGESTED_TYPE_OF_TEST = "suggestedTypeOfTest";
+ public static final String REFERRED_TO = "referredTo";
+ public static final String SHIPPED = "shipped";
+ public static final String RECEIVED = "received";
private CaseReferenceDto associatedCase;
private String sampleCode;
@@ -42,7 +44,6 @@ public class SampleDto extends SampleReferenceDto {
private String sampleMaterialText;
private FacilityReferenceDto lab;
private FacilityReferenceDto otherLab;
- private ShipmentStatus shipmentStatus;
private Date shipmentDate;
private String shipmentDetails;
private Date receivedDate;
@@ -51,6 +52,9 @@ public class SampleDto extends SampleReferenceDto {
private String comment;
private SampleSource sampleSource;
private SampleTestType suggestedTypeOfTest;
+ private SampleReferenceDto referredTo;
+ private boolean shipped;
+ private boolean received;
public CaseReferenceDto getAssociatedCase() {
return associatedCase;
@@ -112,12 +116,6 @@ public FacilityReferenceDto getOtherLab() {
public void setOtherLab(FacilityReferenceDto otherLab) {
this.otherLab = otherLab;
}
- public ShipmentStatus getShipmentStatus() {
- return shipmentStatus;
- }
- public void setShipmentStatus(ShipmentStatus shipmentStatus) {
- this.shipmentStatus = shipmentStatus;
- }
public Date getShipmentDate() {
return shipmentDate;
}
@@ -166,5 +164,23 @@ public SampleTestType getSuggestedTypeOfTest() {
public void setSuggestedTypeOfTest(SampleTestType suggestedTypeOfTest) {
this.suggestedTypeOfTest = suggestedTypeOfTest;
}
+ public SampleReferenceDto getReferredTo() {
+ return referredTo;
+ }
+ public void setReferredTo(SampleReferenceDto referredTo) {
+ this.referredTo = referredTo;
+ }
+ public boolean isShipped() {
+ return shipped;
+ }
+ public void setShipped(boolean shipped) {
+ this.shipped = shipped;
+ }
+ public boolean isReceived() {
+ return received;
+ }
+ public void setReceived(boolean received) {
+ this.received = received;
+ }
}
diff --git a/sormas-api/src/main/java/de/symeda/sormas/api/sample/SampleFacade.java b/sormas-api/src/main/java/de/symeda/sormas/api/sample/SampleFacade.java
index 087cfa8cb1e..466ef778d38 100644
--- a/sormas-api/src/main/java/de/symeda/sormas/api/sample/SampleFacade.java
+++ b/sormas-api/src/main/java/de/symeda/sormas/api/sample/SampleFacade.java
@@ -23,6 +23,8 @@ public interface SampleFacade {
SampleDto saveSample(SampleDto dto);
SampleReferenceDto getReferenceByUuid(String uuid);
+
+ SampleReferenceDto getReferredFrom(String sampleUuid);
List getAllUuids(String userUuid);
diff --git a/sormas-api/src/main/java/de/symeda/sormas/api/sample/SampleIndexDto.java b/sormas-api/src/main/java/de/symeda/sormas/api/sample/SampleIndexDto.java
index 7c293314536..9ace5a03121 100644
--- a/sormas-api/src/main/java/de/symeda/sormas/api/sample/SampleIndexDto.java
+++ b/sormas-api/src/main/java/de/symeda/sormas/api/sample/SampleIndexDto.java
@@ -18,7 +18,6 @@ public class SampleIndexDto extends SampleReferenceDto {
public static final String DISEASE = "disease";
public static final String SAMPLE_CODE = "sampleCode";
public static final String LAB_SAMPLE_ID = "labSampleID";
- public static final String SHIPMENT_STATUS = "shipmentStatus";
public static final String LGA = "lga";
public static final String SHIPMENT_DATE = "shipmentDate";
public static final String RECEIVED_DATE = "receivedDate";
@@ -29,12 +28,14 @@ public class SampleIndexDto extends SampleReferenceDto {
public static final String TEST_RESULT = "testResult";
public static final String SPECIMEN_CONDITION = "specimenCondition";
public static final String NO_TEST_POSSIBLE_REASON = "noTestPossibleReason";
+ public static final String REFERRED_TO = "referredTo";
+ public static final String SHIPPED = "shipped";
+ public static final String RECEIVED = "received";
private CaseReferenceDto associatedCase;
private Disease disease;
private String sampleCode;
private String labSampleID;
- private ShipmentStatus shipmentStatus;
private DistrictReferenceDto lga;
private Date shipmentDate;
private Date receivedDate;
@@ -45,6 +46,9 @@ public class SampleIndexDto extends SampleReferenceDto {
private SampleTestResultType testResult;
private SpecimenCondition specimenCondition;
private String noTestPossibleReason;
+ private SampleReferenceDto referredTo;
+ private boolean shipped;
+ private boolean received;
public CaseReferenceDto getAssociatedCase() {
return associatedCase;
@@ -70,12 +74,6 @@ public String getLabSampleID() {
public void setLabSampleID(String labSampleID) {
this.labSampleID = labSampleID;
}
- public ShipmentStatus getShipmentStatus() {
- return shipmentStatus;
- }
- public void setShipmentStatus(ShipmentStatus shipmentStatus) {
- this.shipmentStatus = shipmentStatus;
- }
public DistrictReferenceDto getLga() {
return lga;
}
@@ -135,6 +133,24 @@ public String getNoTestPossibleReason() {
}
public void setNoTestPossibleReason(String noTestPossibleReason) {
this.noTestPossibleReason = noTestPossibleReason;
+ }
+ public SampleReferenceDto getReferredTo() {
+ return referredTo;
+ }
+ public void setReferredTo(SampleReferenceDto referredTo) {
+ this.referredTo = referredTo;
+ }
+ public boolean isShipped() {
+ return shipped;
+ }
+ public void setShipped(boolean shipped) {
+ this.shipped = shipped;
+ }
+ public boolean isReceived() {
+ return received;
+ }
+ public void setReceived(boolean received) {
+ this.received = received;
}
}
diff --git a/sormas-api/src/main/java/de/symeda/sormas/api/sample/ShipmentStatus.java b/sormas-api/src/main/java/de/symeda/sormas/api/sample/ShipmentStatus.java
deleted file mode 100644
index d3159c2cae4..00000000000
--- a/sormas-api/src/main/java/de/symeda/sormas/api/sample/ShipmentStatus.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package de.symeda.sormas.api.sample;
-
-import de.symeda.sormas.api.I18nProperties;
-
-public enum ShipmentStatus {
-
- NOT_SHIPPED,
- SHIPPED,
- RECEIVED,
- REFERRED_OTHER_LAB,
- ;
-
- public String toString() {
- return I18nProperties.getEnumCaption(this);
- }
-
-}
diff --git a/sormas-api/src/main/java/de/symeda/sormas/api/symptoms/SymptomsHelper.java b/sormas-api/src/main/java/de/symeda/sormas/api/symptoms/SymptomsHelper.java
index 5da1c49436a..f77ae6e9240 100644
--- a/sormas-api/src/main/java/de/symeda/sormas/api/symptoms/SymptomsHelper.java
+++ b/sormas-api/src/main/java/de/symeda/sormas/api/symptoms/SymptomsHelper.java
@@ -1,6 +1,7 @@
package de.symeda.sormas.api.symptoms;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
public final class SymptomsHelper {
@@ -17,4 +18,32 @@ public static String getTemperatureString(float value) {
return String.format("%.1f °C", value);
}
+ public static void updateIsSymptomatic(SymptomsDto dto) {
+ if (dto == null) {
+ return;
+ }
+
+ if (dto.getTemperature() != null && dto.getTemperature() >= 38.0f) {
+ dto.setSymptomatic(true);
+ return;
+ }
+
+ List unconditionalSymptoms = Arrays.asList(dto.getFever(), dto.getVomiting(), dto.getDiarrhea(), dto.getBloodInStool(),
+ dto.getNausea(), dto.getAbdominalPain(), dto.getHeadache(), dto.getMusclePain(), dto.getFatigueWeakness(), dto.getSkinRash(),
+ dto.getNeckStiffness(), dto.getSoreThroat(), dto.getCough(), dto.getRunnyNose(), dto.getDifficultyBreathing(),
+ dto.getChestPain(), dto.getConfusedDisoriented(), dto.getSeizures(), dto.getAlteredConsciousness(), dto.getConjunctivitis(),
+ dto.getEyePainLightSensitive(), dto.getKopliksSpots(), dto.getThrobocytopenia(), dto.getOtitisMedia(), dto.getHearingloss(),
+ dto.getDehydration(), dto.getAnorexiaAppetiteLoss(), dto.getRefusalFeedorDrink(), dto.getJointPain(), dto.getShock(),
+ dto.getHiccups(), dto.getUnexplainedBleeding(), dto.getOtherNonHemorrhagicSymptoms());
+
+ for (SymptomState symptom : unconditionalSymptoms) {
+ if (symptom == SymptomState.YES) {
+ dto.setSymptomatic(true);
+ return;
+ }
+ }
+
+ dto.setSymptomatic(false);
+ }
+
}
diff --git a/sormas-api/src/main/java/de/symeda/sormas/api/task/TaskHelper.java b/sormas-api/src/main/java/de/symeda/sormas/api/task/TaskHelper.java
index 7fd009d50e2..edde0fb1aad 100644
--- a/sormas-api/src/main/java/de/symeda/sormas/api/task/TaskHelper.java
+++ b/sormas-api/src/main/java/de/symeda/sormas/api/task/TaskHelper.java
@@ -35,6 +35,8 @@ else if (UserRole.SURVEILLANCE_OFFICER.equals(userRole)
}
else if (UserRole.INFORMANT.equals(userRole)) {
switch (currentStatus) {
+ case PENDING:
+ return Arrays.asList(TaskStatus.DONE, TaskStatus.NOT_EXECUTABLE);
default:
return Collections.emptyList();
}
diff --git a/sormas-api/src/main/java/de/symeda/sormas/api/task/TaskType.java b/sormas-api/src/main/java/de/symeda/sormas/api/task/TaskType.java
index a3aaca5e45e..0d09cbd8fd6 100644
--- a/sormas-api/src/main/java/de/symeda/sormas/api/task/TaskType.java
+++ b/sormas-api/src/main/java/de/symeda/sormas/api/task/TaskType.java
@@ -16,6 +16,7 @@ public enum TaskType {
CASE_MANAGEMENT(TaskContext.CASE),
CASE_BURIAL(TaskContext.CASE),
CONTACT_TRACING(TaskContext.CASE),
+ SAMPLE_COLLECTION(TaskContext.CASE),
CONTACT_INVESTIGATION(TaskContext.CONTACT),
CONTACT_FOLLOW_UP(TaskContext.CONTACT),
ANIMAL_TESTING(TaskContext.EVENT),
diff --git a/sormas-api/src/main/java/de/symeda/sormas/api/user/UserRole.java b/sormas-api/src/main/java/de/symeda/sormas/api/user/UserRole.java
index 6963db7de87..140e010a40e 100644
--- a/sormas-api/src/main/java/de/symeda/sormas/api/user/UserRole.java
+++ b/sormas-api/src/main/java/de/symeda/sormas/api/user/UserRole.java
@@ -24,6 +24,19 @@ public enum UserRole {
LAB_USER(false, false),
;
+ public static final String _SYSTEM = "SYSTEM";
+ public static final String _USER = "USER";
+ public static final String _ADMIN = "ADMIN";
+ public static final String _SURVEILLANCE_SUPERVISOR = "SURVEILLANCE_SUPERVISOR";
+ public static final String _SURVEILLANCE_OFFICER = "SURVEILLANCE_OFFICER";
+ public static final String _INFORMANT = "INFORMANT";
+ public static final String _CASE_SUPERVISOR = "CASE_SUPERVISOR";
+ public static final String _CASE_OFFICER = "CASE_OFFICER";
+ public static final String _CONTACT_SUPERVISOR = "CONTACT_SUPERVISOR";
+ public static final String _CONTACT_OFFICER = "CONTACT_OFFICER";
+ public static final String _RUMOR_MANAGER = "RUMOR_MANAGER";
+ public static final String _LAB_USER = "LAB_USER";
+
private final boolean supervisor;
private final boolean officer;
diff --git a/sormas-api/src/main/resources/enum.properties b/sormas-api/src/main/resources/enum.properties
index 744822692bb..9a146137116 100644
--- a/sormas-api/src/main/resources/enum.properties
+++ b/sormas-api/src/main/resources/enum.properties
@@ -176,6 +176,7 @@ TaskType.ANIMAL_DEPOPULATION = depopulation of animals
TaskType.OTHER = other task as described in comments
TaskType.DAILY_REPORT_GENERATION = generate daily report
TaskType.SURVEILLANCE_REPORT_GENERATION = generate surveillance report
+TaskType.SAMPLE_COLLECTION = sample collection
TemperatureSource.AXILLARY=axillary
TemperatureSource.ORAL=oral
diff --git a/sormas-api/src/main/resources/fieldCaptions.properties b/sormas-api/src/main/resources/fieldCaptions.properties
index b2b97e43edc..904c0e6297c 100644
--- a/sormas-api/src/main/resources/fieldCaptions.properties
+++ b/sormas-api/src/main/resources/fieldCaptions.properties
@@ -16,8 +16,9 @@ CaseData.healthFacilityDetails=Health facility name & description
CaseData.facilityDetails=Health facility name & description
CaseData.reportingUser=Reporting user
CaseData.reportDate=Date of report
+CaseData.reportInfoLoc = Report date & user
CaseData.investigatedDate=Date of investigation
-CaseData.surveillanceOfficer = Surveillance officer
+CaseData.surveillanceOfficer = Responsible surveillance officer
CaseData.caseOfficer = Case officer
CaseData.contactOfficer = Contact officer
CaseData.region = State
@@ -39,7 +40,6 @@ CaseData.measlesDoses = How many doses
CaseData.vaccinationInfoSource = Source of vaccination information
CaseData.measlesVaccinationInfoSource = Source of vaccination information
CaseData.epiData = Epidemiological data
-CaseData.reportInfoLoc = Report date & user
CaseData.epidNumber = EPID number
# captions for caseData-tabs
@@ -369,7 +369,6 @@ Sample.sampleMaterial = Sample material
Sample.sampleMaterialText = Specify other material
Sample.shipmentDate = Date of shipment
Sample.shipmentDetails = Shipment details
-Sample.shipmentStatus = Shipment status
Sample.lab = Laboratory
Sample.otherLab = Referral laboratory
Sample.lga = LGA
@@ -395,6 +394,8 @@ Sample.testResult = Test result
Sample.comment = Comment
Sample.sampleSource = Sample source
Sample.suggestedTypeOfTest = Suggested type of test
+Sample.shipped = Shipped
+Sample.received = Received
SampleTest = Sample test
SampleTest.testType = Type of test
diff --git a/sormas-app/app/src/androidTest/java/de/symeda/sormas/app/TestEntityCreator.java b/sormas-app/app/src/androidTest/java/de/symeda/sormas/app/TestEntityCreator.java
index bdf9c5d90f0..b4fcb279e07 100644
--- a/sormas-app/app/src/androidTest/java/de/symeda/sormas/app/TestEntityCreator.java
+++ b/sormas-app/app/src/androidTest/java/de/symeda/sormas/app/TestEntityCreator.java
@@ -1,7 +1,5 @@
package de.symeda.sormas.app;
-import android.provider.ContactsContract;
-
import java.util.Date;
import de.symeda.sormas.api.Disease;
@@ -13,7 +11,6 @@
import de.symeda.sormas.api.sample.SampleTestResultType;
import de.symeda.sormas.api.sample.SampleTestType;
import de.symeda.sormas.api.utils.DateHelper;
-import de.symeda.sormas.api.utils.YesNoUnknown;
import de.symeda.sormas.app.backend.caze.Case;
import de.symeda.sormas.app.backend.common.DaoException;
import de.symeda.sormas.app.backend.common.DatabaseHelper;
@@ -43,7 +40,7 @@
public class TestEntityCreator {
public static Person createPerson(String firstName, String lastName) {
- Person person = DatabaseHelper.getPersonDao().create();
+ Person person = DatabaseHelper.getPersonDao().build();
person.setFirstName(firstName);
person.setLastName(lastName);
@@ -66,7 +63,7 @@ public static Case createCase() {
CaseClassification caseClassification = CaseClassification.SUSPECT;
InvestigationStatus investigationStatus = InvestigationStatus.PENDING;
- Case caze = DatabaseHelper.getCaseDao().create(createPerson("Salomon", "Kalou"));
+ Case caze = DatabaseHelper.getCaseDao().build(createPerson("Salomon", "Kalou"));
caze.setDisease(disease);
caze.setRegion(region);
caze.setDistrict(district);
@@ -89,7 +86,7 @@ public static Contact createContact() {
Person person = createPerson("Thierry", "Henry");
Case caze = createCase();
- Contact contact = DatabaseHelper.getContactDao().create();
+ Contact contact = DatabaseHelper.getContactDao().build();
contact.setPerson(person);
contact.setCaze(caze);
@@ -112,7 +109,7 @@ public static Event createEvent() {
String srcLastName = "Mpenza";
String srcTelNo = "0150123123123";
- Event event = DatabaseHelper.getEventDao().create();
+ Event event = DatabaseHelper.getEventDao().build();
event.setEventType(eventType);
event.setEventDesc(eventDesc);
event.setEventDate(eventDate);
@@ -137,7 +134,7 @@ public static Sample createSample() {
Facility lab = DatabaseHelper.getFacilityDao().queryForAll().get(0);
SampleMaterial material = SampleMaterial.BLOOD;
- Sample sample = DatabaseHelper.getSampleDao().create(caze);
+ Sample sample = DatabaseHelper.getSampleDao().build(caze);
sample.setSampleDateTime(sampleDateTime);
sample.setLab(lab);
sample.setSampleMaterial(material);
@@ -153,7 +150,7 @@ public static Sample createSample() {
}
public static PreviousHospitalization createPreviousHospitalization(Case caze) {
- PreviousHospitalization prevHosp = DatabaseHelper.getPreviousHospitalizationDao().create();
+ PreviousHospitalization prevHosp = DatabaseHelper.getPreviousHospitalizationDao().build();
prevHosp.setHospitalization(caze.getHospitalization());
try {
@@ -167,7 +164,7 @@ public static PreviousHospitalization createPreviousHospitalization(Case caze) {
}
public static EpiDataBurial createEpiDataBurial(Case caze) {
- EpiDataBurial burial = DatabaseHelper.getEpiDataBurialDao().create();
+ EpiDataBurial burial = DatabaseHelper.getEpiDataBurialDao().build();
burial.setEpiData(caze.getEpiData());
try {
@@ -181,7 +178,7 @@ public static EpiDataBurial createEpiDataBurial(Case caze) {
}
public static EpiDataGathering createEpiDataGathering(Case caze) {
- EpiDataGathering gathering = DatabaseHelper.getEpiDataGatheringDao().create();
+ EpiDataGathering gathering = DatabaseHelper.getEpiDataGatheringDao().build();
gathering.setEpiData(caze.getEpiData());
try {
@@ -195,7 +192,7 @@ public static EpiDataGathering createEpiDataGathering(Case caze) {
}
public static EpiDataTravel createEpiDataTravel(Case caze) {
- EpiDataTravel travel = DatabaseHelper.getEpiDataTravelDao().create();
+ EpiDataTravel travel = DatabaseHelper.getEpiDataTravelDao().build();
travel.setEpiData(caze.getEpiData());
try {
@@ -209,9 +206,9 @@ public static EpiDataTravel createEpiDataTravel(Case caze) {
}
public static Visit createVisit(Contact contact) throws DaoException {
- Visit visit = DatabaseHelper.getVisitDao().create(contact.getUuid());
- Symptoms symptoms = DatabaseHelper.getSymptomsDao().create();
- Location illLocation = DatabaseHelper.getLocationDao().create();
+ Visit visit = DatabaseHelper.getVisitDao().build(contact.getUuid());
+ Symptoms symptoms = DatabaseHelper.getSymptomsDao().build();
+ Location illLocation = DatabaseHelper.getLocationDao().build();
symptoms.setIllLocation(illLocation);
visit.setSymptoms(symptoms);
visit.setVisitUser(ConfigProvider.getUser());
@@ -225,7 +222,7 @@ public static Visit createVisit(Contact contact) throws DaoException {
public static EventParticipant createEventParticipant(Event event) {
Person person = createPerson("Demba", "Ba");
- EventParticipant eventParticipant = DatabaseHelper.getEventParticipantDao().create();
+ EventParticipant eventParticipant = DatabaseHelper.getEventParticipantDao().build();
eventParticipant.setEvent(event);
eventParticipant.setPerson(person);
@@ -244,7 +241,7 @@ public static SampleTest createSampleTest(Sample sample) {
SampleTestResultType sampleTestResultType = SampleTestResultType.NEGATIVE;
Date sampleTestDateTime = new Date();
- SampleTest sampleTest = DatabaseHelper.getSampleTestDao().create();
+ SampleTest sampleTest = DatabaseHelper.getSampleTestDao().build();
sampleTest.setSample(sample);
sampleTest.setTestType(sampleTestType);
sampleTest.setTestResult(sampleTestResultType);
diff --git a/sormas-app/app/src/main/AndroidManifest.xml b/sormas-app/app/src/main/AndroidManifest.xml
index cc476ac18ea..39d4d875b6f 100644
--- a/sormas-app/app/src/main/AndroidManifest.xml
+++ b/sormas-app/app/src/main/AndroidManifest.xml
@@ -18,6 +18,7 @@
android:launchMode="singleTop">
@@ -27,6 +28,7 @@
@@ -36,9 +38,11 @@
@@ -47,6 +51,7 @@
@@ -55,6 +60,7 @@
android:launchMode="singleTop" />
@@ -68,6 +74,7 @@
android:launchMode="singleTop" />
@@ -77,6 +84,7 @@
@@ -86,6 +94,7 @@
@@ -98,6 +107,7 @@
android:launchMode="singleTop" />
@@ -107,6 +117,7 @@
@@ -124,6 +136,7 @@
@@ -137,6 +150,7 @@
android:launchMode="singleTop" />
diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/AbstractTabActivity.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/AbstractTabActivity.java
index 8a028910f7a..27ab10f9a73 100644
--- a/sormas-app/app/src/main/java/de/symeda/sormas/app/AbstractTabActivity.java
+++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/AbstractTabActivity.java
@@ -17,12 +17,15 @@
import java.net.ConnectException;
+import de.symeda.sormas.app.backend.common.AbstractDomainObject;
import de.symeda.sormas.app.backend.common.DatabaseHelper;
import de.symeda.sormas.app.backend.config.ConfigProvider;
import de.symeda.sormas.app.backend.synclog.SyncLogDao;
+import de.symeda.sormas.app.caze.CaseEditTabs;
import de.symeda.sormas.app.component.SyncLogDialog;
import de.symeda.sormas.app.rest.RetroProvider;
import de.symeda.sormas.app.rest.SynchronizeDataAsync;
+import de.symeda.sormas.app.util.FormTab;
import de.symeda.sormas.app.util.SlidingTabLayout;
import de.symeda.sormas.app.util.SyncCallback;
@@ -68,6 +71,23 @@ public void onPageSelected(int position) {
});
}
+
+ public AbstractDomainObject getData(int position) {
+ FormTab tab = getTabByPosition(position);
+ if (tab != null) {
+ return tab.getData();
+ }
+ return null;
+ }
+
+ public FormTab getTabByPosition(int position) {
+ Object item = pager.getAdapter().instantiateItem(pager, position);
+ if (item instanceof FormTab) {
+ return (FormTab)item;
+ }
+ return null;
+ }
+
public void setCurrentTab(int currentTab) {
this.currentTab = currentTab;
}
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 3ec05959e97..e18fd010082 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
@@ -94,8 +94,6 @@ public class Case extends AbstractDomainObject {
private User surveillanceOfficer;
@DatabaseField(foreign = true, foreignAutoRefresh = true, maxForeignAutoRefreshLevel = 1)
private User caseOfficer;
- @DatabaseField(foreign = true, foreignAutoRefresh = true, maxForeignAutoRefreshLevel = 1)
- private User contactOfficer;
@Enumerated(EnumType.STRING)
private YesNoUnknown pregnant;
@@ -118,6 +116,9 @@ public class Case extends AbstractDomainObject {
@DatabaseField(foreign = true, foreignAutoRefresh = true)
private EpiData epiData;
+ @Column
+ private Long contactOfficer_id;
+
public Person getPerson() {
return person;
}
@@ -223,13 +224,6 @@ public void setCaseOfficer(User caseOfficer) {
this.caseOfficer = caseOfficer;
}
- public User getContactOfficer() {
- return contactOfficer;
- }
- public void setContactOfficer(User contactOfficer) {
- this.contactOfficer = contactOfficer;
- }
-
public InvestigationStatus getInvestigationStatus() {
return investigationStatus;
}
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 a0c2f8a2656..2c1306864d3 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
@@ -23,15 +23,10 @@
import de.symeda.sormas.app.backend.common.DaoException;
import de.symeda.sormas.app.backend.common.DatabaseHelper;
import de.symeda.sormas.app.backend.config.ConfigProvider;
-import de.symeda.sormas.app.backend.epidata.EpiData;
-import de.symeda.sormas.app.backend.hospitalization.Hospitalization;
-import de.symeda.sormas.app.backend.location.Location;
import de.symeda.sormas.app.backend.person.Person;
import de.symeda.sormas.app.backend.symptoms.Symptoms;
import de.symeda.sormas.app.backend.user.User;
-import de.symeda.sormas.app.backend.visit.Visit;
import de.symeda.sormas.app.caze.CaseEditActivity;
-import de.symeda.sormas.app.util.DataUtils;
public class CaseDao extends AbstractAdoDao {
@@ -73,7 +68,7 @@ public Date getLatestChangeDate() {
return date;
}
- // TODO #69 create some date filter for finding the right case (this is implemented in CaseService.java too)
+ // TODO #69 build some date filter for finding the right case (this is implemented in CaseService.java too)
public Case getByPersonAndDisease(Person person, Disease disease) {
try {
QueryBuilder builder = queryBuilder();
@@ -91,25 +86,25 @@ public Case getByPersonAndDisease(Person person, Disease disease) {
}
@Override
- public Case create() {
- throw new UnsupportedOperationException("Use create(Person) instead");
+ public Case build() {
+ throw new UnsupportedOperationException("Use build(Person) instead");
}
- public Case create(Person person) {
- Case caze = super.create();
+ public Case build(Person person) {
+ Case caze = super.build();
caze.setPerson(person);
caze.setReportDate(new Date());
caze.setReportingUser(ConfigProvider.getUser());
// Symptoms
- caze.setSymptoms(DatabaseHelper.getSymptomsDao().create());
+ caze.setSymptoms(DatabaseHelper.getSymptomsDao().build());
// Hospitalization
- caze.setHospitalization(DatabaseHelper.getHospitalizationDao().create());
+ caze.setHospitalization(DatabaseHelper.getHospitalizationDao().build());
// Epi Data
- caze.setEpiData(DatabaseHelper.getEpiDataDao().create());
+ caze.setEpiData(DatabaseHelper.getEpiDataDao().build());
// Location
User currentUser = ConfigProvider.getUser();
@@ -162,4 +157,5 @@ public Case mergeOrCreate(Case source) throws DaoException {
}
return mergedCase;
}
+
}
diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/common/AbstractAdoDao.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/common/AbstractAdoDao.java
index 00f2715ceee..d0f98eb7c63 100644
--- a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/common/AbstractAdoDao.java
+++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/common/AbstractAdoDao.java
@@ -186,7 +186,7 @@ public ADO saveAndSnapshot(ADO ado) throws DaoException {
ADO snapshot;
boolean snapshotNeeded = ado.getId() != null && !ado.isModified();
if (snapshotNeeded) {
- // we need to create a snapshot of the unmodified version, so we can use it for comparison when merging
+ // we need to build a snapshot of the unmodified version, so we can use it for comparison when merging
snapshot = queryForId(ado.getId());
snapshot.setId(null);
snapshot.setSnapshot(true);
@@ -233,7 +233,7 @@ public ADO saveAndSnapshot(ADO ado) throws DaoException {
}
if (ado.getId() == null) {
- // create the new entity and take note that it has been create in the app (modified)
+ // build the new entity and take note that it has been build in the app (modified)
ado.setModified(true);
create(ado);
}
@@ -259,7 +259,7 @@ public ADO saveAndSnapshot(ADO ado) throws DaoException {
ado.setModified(true);
update(ado);
- // now really create the cloneCascading
+ // now really build the cloneCascading
create(snapshot);
}
}
@@ -326,7 +326,7 @@ public ADO deleteWithSnapshot(ADO ado) throws DaoException {
ADO snapshot;
boolean snapshotNeeded = !ado.isModified();
if (snapshotNeeded) {
- // we need to create a cloneCascading of the unmodified version, so we can use it for comparison when merging
+ // we need to build a cloneCascading of the unmodified version, so we can use it for comparison when merging
snapshot = queryForId(ado.getId());
snapshot.setId(null);
snapshot.setSnapshot(true);
@@ -772,7 +772,7 @@ public int updateWithCast(AbstractDomainObject ado) {
return update((ADO)ado);
}
- public ADO create() {
+ public ADO build() {
try {
ADO ado = getAdoClass().newInstance();
ado.setUuid(DataHelper.createUuid());
@@ -780,7 +780,7 @@ public ADO create() {
ado.setCreationDate(now);
ado.setChangeDate(now);
- // create all embedded entities
+ // build all embedded entities
// ignore parent property
EmbeddedAdo annotation = ado.getClass().getAnnotation(EmbeddedAdo.class);
@@ -794,8 +794,8 @@ public ADO create() {
if (parentProperty.equals(property.getName()))
continue;
- // create embedded
- AbstractDomainObject embeddedAdo = DatabaseHelper.getAdoDao((Class)property.getPropertyType()).create();
+ // build embedded
+ AbstractDomainObject embeddedAdo = DatabaseHelper.getAdoDao((Class)property.getPropertyType()).build();
if (embeddedAdo == null) {
throw new IllegalArgumentException("No embedded entity was created for " + property.getName());
@@ -891,6 +891,19 @@ public List queryForEq(String fieldName, Object value) {
}
}
+ public List queryForNotNull(String fieldName) {
+ try {
+ QueryBuilder builder = queryBuilder();
+ Where where = builder.where();
+ where.isNotNull(fieldName);
+ where.and().eq(AbstractDomainObject.SNAPSHOT, false).query();
+ return builder.query();
+ } catch (SQLException e) {
+ Log.e(getTableName(), "queryForNotNull threw exception on: " + fieldName, e);
+ throw new RuntimeException(e);
+ }
+ }
+
/**
* @see Dao#queryBuilder()
*/
@@ -905,7 +918,7 @@ public int create(ADO data) {
try {
return dao.create(data);
} catch (SQLException e) {
- Log.e(getTableName(), "create threw exception on: " + data, e);
+ Log.e(getTableName(), "build threw exception on: " + data, e);
throw new RuntimeException(e);
}
}
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 58879ccdcf9..8eb734fe924 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
@@ -72,7 +72,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
// name of the database file for your application -- change to something appropriate for your app
private static final String DATABASE_NAME = "sormas.db";
// any time you make changes to your database objects, you may have to increase the database version
- private static final int DATABASE_VERSION = 93;
+ private static final int DATABASE_VERSION = 97;
private static DatabaseHelper instance = null;
public static void init(Context context) {
@@ -146,7 +146,7 @@ public static void clearTables(boolean clearInfrastructure) {
}
/**
- * This is called when the database is first created. Usually you should call createTable statements here to create
+ * This is called when the database is first created. Usually you should call createTable statements here to build
* the tables that will store your data.
*/
@Override
@@ -178,7 +178,7 @@ public void onCreate(SQLiteDatabase db, ConnectionSource connectionSource) {
TableUtils.createTable(connectionSource, EpiDataTravel.class);
TableUtils.createTable(connectionSource, SyncLog.class);
} catch (SQLException e) {
- Log.e(DatabaseHelper.class.getName(), "Can't create database", e);
+ Log.e(DatabaseHelper.class.getName(), "Can't build database", e);
throw new RuntimeException(e);
}
}
@@ -206,6 +206,24 @@ public void onUpgrade(SQLiteDatabase db, ConnectionSource connectionSource, int
case 92:
currentVersion = 92;
getDao(District.class).executeRaw("ALTER TABLE region ADD COLUMN epidCode varchar(255);");
+ case 93:
+ currentVersion = 93;
+ getDao(Symptoms.class).executeRaw("ALTER TABLE symptoms ADD COLUMN symptomatic boolean;");
+ case 94:
+ currentVersion = 94;
+ // nothing
+ case 95:
+ currentVersion = 95;
+ getDao(Sample.class).executeRaw("ALTER TABLE samples ADD COLUMN referredTo_id bigint REFERENCES samples(id);");
+ case 96:
+ currentVersion = 96;
+ getDao(Sample.class).executeRaw("ALTER TABLE samples ADD COLUMN shipped boolean;");
+ getDao(Sample.class).executeRaw("ALTER TABLE samples ADD COLUMN received boolean;");
+ getDao(Sample.class).executeRaw("UPDATE samples SET shipped='true' WHERE shipmentStatus = 'SHIPPED' OR shipmentStatus = 'RECEIVED' OR shipmentStatus = 'REFERRED_OTHER_LAB';");
+ getDao(Sample.class).executeRaw("UPDATE samples SET received='true' WHERE shipmentStatus = 'RECEIVED' OR shipmentStatus = 'REFERRED_OTHER_LAB';");
+ getDao(Sample.class).executeRaw("UPDATE samples SET shipped='false' WHERE shipmentStatus = 'NOT_SHIPPED';");
+ getDao(Sample.class).executeRaw("UPDATE samples SET received='false' WHERE shipmentStatus = 'NOT_SHIPPED' OR shipmentStatus = 'SHIPPED';");
+
// ATTENTION: break should only be done after last version
break;
@@ -248,7 +266,7 @@ private void upgradeFromUnupgradableVersion(SQLiteDatabase db, ConnectionSource
if (oldVersion < 30) {
TableUtils.dropTable(connectionSource, Config.class, true);
}
- // after we drop the old databases, we create the new ones
+ // after we drop the old databases, we build the new ones
onCreate(db, connectionSource);
} catch (SQLException e) {
Log.e(DatabaseHelper.class.getName(), "Can't drop databases", e);
@@ -260,7 +278,7 @@ public AbstractAdoDao getAdoDaoInner(Cla
if (!adoDaos.containsKey(type)) {
- // create dao
+ // build dao
AbstractAdoDao dao;
Dao innerDao;
@@ -318,7 +336,7 @@ public AbstractAdoDao getAdoDaoInner(Cla
adoDaos.put(type, dao);
} catch (SQLException e) {
- Log.e(DatabaseHelper.class.getName(), "Can't create dao", e);
+ Log.e(DatabaseHelper.class.getName(), "Can't build dao", e);
throw new RuntimeException(e);
}
}
@@ -343,7 +361,7 @@ public static ConfigDao getConfigDao() {
try {
instance.configDao = new ConfigDao((Dao) instance.getDao(Config.class));
} catch (SQLException e) {
- Log.e(DatabaseHelper.class.getName(), "Can't create ConfigDao", e);
+ Log.e(DatabaseHelper.class.getName(), "Can't build ConfigDao", e);
throw new RuntimeException(e);
}
}
@@ -359,7 +377,7 @@ public static SyncLogDao getSyncLogDao() {
try {
instance.syncLogDao = new SyncLogDao((Dao) instance.getDao(SyncLog.class));
} catch (SQLException e) {
- Log.e(DatabaseHelper.class.getName(), "Can't create SyncLogDao", e);
+ Log.e(DatabaseHelper.class.getName(), "Can't build SyncLogDao", e);
throw new RuntimeException(e);
}
}
@@ -456,7 +474,6 @@ public static EpiDataTravelDao getEpiDataTravelDao() {
return (EpiDataTravelDao) getAdoDao(EpiDataTravel.class);
}
-
/**
* Close the database connections and clear any cached DAOs.
*/
diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/contact/ContactDao.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/contact/ContactDao.java
index 100ebfba3b8..64434dde807 100644
--- a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/contact/ContactDao.java
+++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/contact/ContactDao.java
@@ -14,12 +14,6 @@
import de.symeda.sormas.app.backend.common.AbstractDomainObject;
import de.symeda.sormas.app.backend.common.DatabaseHelper;
import de.symeda.sormas.app.backend.config.ConfigProvider;
-import de.symeda.sormas.app.backend.event.Event;
-import de.symeda.sormas.app.backend.person.Person;
-import de.symeda.sormas.app.backend.region.District;
-import de.symeda.sormas.app.backend.region.Region;
-
-import static android.R.attr.value;
/**
* Created by Stefan Szczesny on 29.11.2016.
@@ -59,9 +53,9 @@ public List getByCase(Case caze) {
}
@Override
- public Contact create() {
+ public Contact build() {
- Contact contact = super.create();
+ Contact contact = super.build();
contact.setReportDateTime(new Date());
contact.setReportingUser(ConfigProvider.getUser());
diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/event/EventDao.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/event/EventDao.java
index e394fffe971..799586f0fb9 100644
--- a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/event/EventDao.java
+++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/event/EventDao.java
@@ -7,12 +7,8 @@
import de.symeda.sormas.api.event.EventStatus;
import de.symeda.sormas.app.backend.common.AbstractAdoDao;
-import de.symeda.sormas.app.backend.common.DaoException;
-import de.symeda.sormas.app.backend.common.DatabaseHelper;
import de.symeda.sormas.app.backend.config.ConfigProvider;
import de.symeda.sormas.app.backend.location.Location;
-import de.symeda.sormas.app.backend.person.Person;
-import de.symeda.sormas.app.util.DataUtils;
public class EventDao extends AbstractAdoDao {
@@ -46,9 +42,9 @@ public Date getLatestChangeDate() {
}
@Override
- public Event create() {
+ public Event build() {
- Event event = super.create();
+ Event event = super.build();
event.setReportDateTime(new Date());
event.setReportingUser(ConfigProvider.getUser());
diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/sample/Sample.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/sample/Sample.java
index 4f7bc45d3ff..c5a38c7ba5b 100644
--- a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/sample/Sample.java
+++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/sample/Sample.java
@@ -14,9 +14,7 @@
import de.symeda.sormas.api.sample.SampleMaterial;
import de.symeda.sormas.api.sample.SampleSource;
import de.symeda.sormas.api.sample.SampleTestType;
-import de.symeda.sormas.api.sample.ShipmentStatus;
import de.symeda.sormas.api.sample.SpecimenCondition;
-import de.symeda.sormas.api.utils.DataHelper;
import de.symeda.sormas.api.utils.DateHelper;
import de.symeda.sormas.app.backend.caze.Case;
import de.symeda.sormas.app.backend.common.AbstractDomainObject;
@@ -36,9 +34,11 @@ public class Sample extends AbstractDomainObject {
public static final String TABLE_NAME = "samples";
public static final String I18N_PREFIX = "Sample";
- public static final String SHIPMENT_STATUS = "shipmentStatus";
public static final String SAMPLE_DATE_TIME = "sampleDateTime";
public static final String ASSOCIATED_CASE = "associatedCase";
+ public static final String REFERRED_TO = "referredTo";
+ public static final String SHIPPED = "shipped";
+ public static final String RECEIVED = "received";
@DatabaseField(foreign = true, foreignAutoRefresh = true, canBeNull = false)
private Case associatedCase;
@@ -71,10 +71,6 @@ public class Sample extends AbstractDomainObject {
@DatabaseField(foreign = true, foreignAutoRefresh = true, maxForeignAutoRefreshLevel = 3)
private Facility otherLab;
- @Enumerated(EnumType.STRING)
- @Column(nullable = false)
- private ShipmentStatus shipmentStatus;
-
@DatabaseField(dataType = DataType.DATE_LONG)
private Date shipmentDate;
@@ -99,6 +95,18 @@ public class Sample extends AbstractDomainObject {
@Enumerated(EnumType.STRING)
private SampleTestType suggestedTypeOfTest;
+ @DatabaseField(foreign = true, foreignAutoRefresh = true)
+ private Sample referredTo;
+
+ @DatabaseField
+ private boolean shipped;
+
+ @DatabaseField
+ private boolean received;
+
+ @DatabaseField(defaultValue = "", canBeNull = false)
+ private String shipmentStatus;
+
public Case getAssociatedCase() {
return associatedCase;
}
@@ -179,14 +187,6 @@ public void setOtherLab(Facility otherLab) {
this.otherLab = otherLab;
}
- public ShipmentStatus getShipmentStatus() {
- return shipmentStatus;
- }
-
- public void setShipmentStatus(ShipmentStatus shipmentStatus) {
- this.shipmentStatus = shipmentStatus;
- }
-
public Date getShipmentDate() {
return shipmentDate;
}
@@ -251,6 +251,30 @@ public void setSuggestedTypeOfTest(SampleTestType suggestedTypeOfTest) {
this.suggestedTypeOfTest = suggestedTypeOfTest;
}
+ public Sample getReferredTo() {
+ return referredTo;
+ }
+
+ public void setReferredTo(Sample referredTo) {
+ this.referredTo = referredTo;
+ }
+
+ public boolean isShipped() {
+ return shipped;
+ }
+
+ public void setShipped(boolean shipped) {
+ this.shipped = shipped;
+ }
+
+ public boolean isReceived() {
+ return received;
+ }
+
+ public void setReceived(boolean received) {
+ this.received = received;
+ }
+
@Override
public String getI18nPrefix() {
return I18N_PREFIX;
diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/sample/SampleDao.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/sample/SampleDao.java
index 0aadbffb9f6..84578dcf651 100644
--- a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/sample/SampleDao.java
+++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/sample/SampleDao.java
@@ -1,21 +1,15 @@
package de.symeda.sormas.app.backend.sample;
import com.j256.ormlite.dao.Dao;
-import com.j256.ormlite.dao.RuntimeExceptionDao;
-import com.j256.ormlite.logger.Log;
-import com.j256.ormlite.logger.Logger;
-import com.j256.ormlite.logger.LoggerFactory;
import java.sql.SQLException;
import java.util.Date;
import java.util.List;
-import de.symeda.sormas.api.sample.ShipmentStatus;
import de.symeda.sormas.app.backend.caze.Case;
import de.symeda.sormas.app.backend.common.AbstractAdoDao;
import de.symeda.sormas.app.backend.common.AbstractDomainObject;
import de.symeda.sormas.app.backend.config.ConfigProvider;
-import de.symeda.sormas.app.util.DataUtils;
/**
* Created by Mate Strysewske on 06.02.2017.
@@ -33,16 +27,15 @@ protected Class getAdoClass() {
}
@Override
- public Sample create() {
+ public Sample build() {
throw new UnsupportedOperationException();
}
- public Sample create(Case associatedCase) {
- Sample sample = super.create();
+ public Sample build(Case associatedCase) {
+ Sample sample = super.build();
sample.setAssociatedCase(associatedCase);
sample.setReportDateTime(new Date());
sample.setReportingUser(ConfigProvider.getUser());
- sample.setShipmentStatus(ShipmentStatus.NOT_SHIPPED);
return sample;
}
diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/sample/SampleDtoHelper.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/sample/SampleDtoHelper.java
index 2b389e74e6c..21be1bc694b 100644
--- a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/sample/SampleDtoHelper.java
+++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/sample/SampleDtoHelper.java
@@ -57,7 +57,6 @@ public void fillInnerFromDto(Sample target, SampleDto source) {
target.setSampleDateTime(source.getSampleDateTime());
target.setSampleMaterial(source.getSampleMaterial());
target.setSampleMaterialText(source.getSampleMaterialText());
- target.setShipmentStatus(source.getShipmentStatus());
target.setShipmentDate(source.getShipmentDate());
target.setShipmentDetails(source.getShipmentDetails());
target.setReceivedDate(source.getReceivedDate());
@@ -66,6 +65,9 @@ public void fillInnerFromDto(Sample target, SampleDto source) {
target.setComment(source.getComment());
target.setSampleSource(source.getSampleSource());
target.setSuggestedTypeOfTest(source.getSuggestedTypeOfTest());
+ target.setReferredTo(DatabaseHelper.getSampleDao().getByReferenceDto(source.getReferredTo()));
+ target.setShipped(source.isShipped());
+ target.setReceived(source.isReceived());
}
@Override
@@ -98,13 +100,19 @@ public void fillInnerFromAdo(SampleDto dto, Sample ado) {
dto.setOtherLab(null);
}
+ if (ado.getReferredTo() != null) {
+ Sample referredSample = DatabaseHelper.getSampleDao().queryForId(ado.getReferredTo().getId());
+ dto.setReferredTo(SampleDtoHelper.toReferenceDto(referredSample));
+ } else {
+ dto.setReferredTo(null);
+ }
+
dto.setSampleCode(ado.getSampleCode());
dto.setLabSampleID(ado.getLabSampleID());
dto.setSampleDateTime(ado.getSampleDateTime());
dto.setReportDateTime(ado.getReportDateTime());
dto.setSampleMaterial(ado.getSampleMaterial());
dto.setSampleMaterialText(ado.getSampleMaterialText());
- dto.setShipmentStatus(ado.getShipmentStatus());
dto.setShipmentDate(ado.getShipmentDate());
dto.setShipmentDetails(ado.getShipmentDetails());
dto.setReceivedDate(ado.getReceivedDate());
@@ -113,6 +121,8 @@ public void fillInnerFromAdo(SampleDto dto, Sample ado) {
dto.setComment(ado.getComment());
dto.setSampleSource(ado.getSampleSource());
dto.setSuggestedTypeOfTest(ado.getSuggestedTypeOfTest());
+ dto.setShipped(ado.isShipped());
+ dto.setReceived(ado.isReceived());
}
public static SampleReferenceDto toReferenceDto(Sample ado) {
diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/symptoms/Symptoms.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/symptoms/Symptoms.java
index 2b0ae89473f..28bcd4adcd3 100644
--- a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/symptoms/Symptoms.java
+++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/symptoms/Symptoms.java
@@ -33,6 +33,7 @@ public class Symptoms extends AbstractDomainObject {
private String onsetSymptom;
@Column(length = 255)
private String symptomsComments;
+ @DatabaseField
private Boolean symptomatic;
@DatabaseField(foreign = true, foreignAutoRefresh = true, maxForeignAutoRefreshLevel = 2)
diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/symptoms/SymptomsDao.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/symptoms/SymptomsDao.java
index 05f5c17f459..f50390e81b2 100644
--- a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/symptoms/SymptomsDao.java
+++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/symptoms/SymptomsDao.java
@@ -4,6 +4,8 @@
import java.sql.SQLException;
+import de.symeda.sormas.api.symptoms.SymptomsDto;
+import de.symeda.sormas.api.symptoms.SymptomsHelper;
import de.symeda.sormas.app.backend.common.AbstractAdoDao;
import de.symeda.sormas.app.backend.common.DaoException;
import de.symeda.sormas.app.backend.common.DatabaseHelper;
@@ -26,4 +28,24 @@ protected Class getAdoClass() {
public String getTableName() {
return Symptoms.TABLE_NAME;
}
+
+ public void updateIsSymptomatic(Symptoms symptoms) {
+ SymptomsDtoHelper symptomsDtoHelper = new SymptomsDtoHelper();
+ SymptomsDto symptomsDto = new SymptomsDto();
+ symptomsDtoHelper.fillInnerFromAdo(symptomsDto, symptoms);
+ SymptomsHelper.updateIsSymptomatic(symptomsDto);
+ symptoms.setSymptomatic(symptomsDto.getSymptomatic());
+ }
+
+ @Override
+ public Symptoms saveAndSnapshot(Symptoms symptoms) throws DaoException {
+ // If new symptoms are created, updateIsSymptomatic has to be called after the initial save
+ if (symptoms.getId() == null) {
+ super.saveAndSnapshot(symptoms);
+ updateIsSymptomatic(symptoms);
+ }
+
+ return super.saveAndSnapshot(symptoms);
+ }
+
}
diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/synclog/SyncLogDao.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/synclog/SyncLogDao.java
index 851ee2d959c..748d13cc49b 100644
--- a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/synclog/SyncLogDao.java
+++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/synclog/SyncLogDao.java
@@ -88,7 +88,7 @@ public int create(SyncLog data) {
try {
return dao.create(data);
} catch (SQLException e) {
- Log.e(getClass().getName(), "create threw exception on: " + data, e);
+ Log.e(getClass().getName(), "build threw exception on: " + data, e);
throw new RuntimeException(e);
}
}
diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/visit/Visit.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/visit/Visit.java
index 566665bcd9f..67b2871d1f4 100644
--- a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/visit/Visit.java
+++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/visit/Visit.java
@@ -101,7 +101,7 @@ public void setVisitRemarks(String visitRemarks) {
}
/**
- * return the symptoms, if null create new in service layer
+ * return the symptoms, if null build new in service layer
* @return
*/
public Symptoms getSymptoms() {
diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/visit/VisitDao.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/visit/VisitDao.java
index 5da8a3ca246..2c7446828f4 100644
--- a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/visit/VisitDao.java
+++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/visit/VisitDao.java
@@ -85,7 +85,7 @@ public Date getLatestChangeDate() {
}
@Override
- public Visit create() {
+ public Visit build() {
throw new UnsupportedOperationException();
}
@@ -97,9 +97,9 @@ public Visit create() {
* @throws InstantiationException
*/
@NonNull
- public Visit create(String contactUuid) {
+ public Visit build(String contactUuid) {
Contact contact = DatabaseHelper.getContactDao().queryUuid(contactUuid);
- Visit visit = super.create();
+ Visit visit = super.build();
visit.setPerson(contact.getPerson());
visit.setDisease(contact.getCaze().getDisease());
visit.setVisitDateTime(new Date());
diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/caze/CaseEditActivity.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/caze/CaseEditActivity.java
index 88b8be0af7f..108ea29a67a 100644
--- a/sormas-app/app/src/main/java/de/symeda/sormas/app/caze/CaseEditActivity.java
+++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/caze/CaseEditActivity.java
@@ -116,6 +116,7 @@ protected void onResume() {
Case currentEntity = DatabaseHelper.getCaseDao().queryUuid(caseUuid);
if (currentEntity.isUnreadOrChildUnread()) {
// Resetting the adapter will reload the form and therefore also override any unsaved changes
+ DatabaseHelper.getCaseDao().markAsRead(currentEntity);
setAdapter();
final Snackbar snackbar = Snackbar.make(findViewById(R.id.base_layout), String.format(getResources().getString(R.string.snackbar_entity_overridden), getResources().getString(R.string.entity_case)), Snackbar.LENGTH_INDEFINITE);
@@ -127,8 +128,6 @@ public void onClick(View view) {
});
snackbar.show();
}
-
- DatabaseHelper.getCaseDao().markAsRead(currentEntity);
}
@Override
@@ -199,7 +198,7 @@ public boolean onPrepareOptionsMenu(Menu menu) {
public boolean onOptionsItemSelected(MenuItem item) {
setCurrentTab(pager.getCurrentItem());
CaseEditTabs tab = CaseEditTabs.values()[currentTab];
- Case caze = (Case) adapter.getData(CaseEditTabs.CASE_DATA.ordinal());
+ Case caze = (Case) getData(CaseEditTabs.CASE_DATA.ordinal());
CaseDao caseDao = DatabaseHelper.getCaseDao();
switch (item.getItemId()) {
// Respond to the action bar's Up/Home button
@@ -285,26 +284,27 @@ public boolean onOptionsItemSelected(MenuItem item) {
// PATIENT
LocationDao locLocationDao = DatabaseHelper.getLocationDao();
PersonDao personDao = DatabaseHelper.getPersonDao();
- Person person = (Person) adapter.getData(CaseEditTabs.PATIENT.ordinal());
+ Person person = (Person) getData(CaseEditTabs.PATIENT.ordinal());
// SYMPTOMS
- Symptoms symptoms = (Symptoms) adapter.getData(CaseEditTabs.SYMPTOMS.ordinal());
- SymptomsEditForm symptomsEditForm = (SymptomsEditForm) adapter.getTabByPosition(CaseEditTabs.SYMPTOMS.ordinal());
+ Symptoms symptoms = (Symptoms) getData(CaseEditTabs.SYMPTOMS.ordinal());
// HOSPITALIZATION
- Hospitalization hospitalization = (Hospitalization) adapter.getData(CaseEditTabs.HOSPITALIZATION.ordinal());
+ Hospitalization hospitalization = (Hospitalization) getData(CaseEditTabs.HOSPITALIZATION.ordinal());
// EPI DATA
- EpiData epiData = (EpiData) adapter.getData(CaseEditTabs.EPIDATA.ordinal());
+ EpiData epiData = (EpiData) getData(CaseEditTabs.EPIDATA.ordinal());
// CASE_DATA
- caze = (Case) adapter.getData(CaseEditTabs.CASE_DATA.ordinal());
+ caze = (Case) getData(CaseEditTabs.CASE_DATA.ordinal());
// Validations have to be processed from last tab to first to make sure that the user will be re-directed
// to the first tab with a validation error
- CaseDataFragmentLayoutBinding caseDataBinding = ((CaseEditDataForm)adapter.getTabByPosition(CaseEditTabs.CASE_DATA.ordinal())).getBinding();
- PersonEditFragmentLayoutBinding personBinding = ((PersonEditForm)adapter.getTabByPosition(CaseEditTabs.PATIENT.ordinal())).getBinding();
- CaseSymptomsFragmentLayoutBinding symptomsBinding = ((SymptomsEditForm)adapter.getTabByPosition(CaseEditTabs.SYMPTOMS.ordinal())).getBinding();
+
+
+ CaseDataFragmentLayoutBinding caseDataBinding = ((CaseEditDataForm)getTabByPosition(CaseEditTabs.CASE_DATA.ordinal())).getBinding();
+ PersonEditFragmentLayoutBinding personBinding = ((PersonEditForm)getTabByPosition(CaseEditTabs.PATIENT.ordinal())).getBinding();
+ CaseSymptomsFragmentLayoutBinding symptomsBinding = ((SymptomsEditForm)getTabByPosition(CaseEditTabs.SYMPTOMS.ordinal())).getBinding();
// Necessary because the entry could've been automatically set, in which case the setValue method of the
// custom field has not been called
diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/caze/CaseEditDataForm.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/caze/CaseEditDataForm.java
index 48763bbed47..495c1175356 100644
--- a/sormas-app/app/src/main/java/de/symeda/sormas/app/caze/CaseEditDataForm.java
+++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/caze/CaseEditDataForm.java
@@ -53,7 +53,7 @@ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
final String caseUuid = (String) getArguments().getString(Case.UUID);
final CaseDao caseDao = DatabaseHelper.getCaseDao();
- final Case caze = caseDao.queryUuid(caseUuid);
+ Case caze = caseDao.queryUuid(caseUuid);
binding.setCaze(caze);
final List emptyList = new ArrayList<>();
diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/caze/CaseEditPagerAdapter.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/caze/CaseEditPagerAdapter.java
index 0d44b376720..721ecdabdac 100644
--- a/sormas-app/app/src/main/java/de/symeda/sormas/app/caze/CaseEditPagerAdapter.java
+++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/caze/CaseEditPagerAdapter.java
@@ -27,14 +27,7 @@
public class CaseEditPagerAdapter extends FragmentStatePagerAdapter {
- private CharSequence titles[]; // This will Store the titles of the Tabs which are Going to be passed when ViewPagerAdapter is created
private Bundle caseEditBundle; // this bundle contains the uuids
- private CaseEditDataForm caseEditDataForm;
- private PersonEditForm personEditForm;
- private SymptomsEditForm symptomsEditForm;
- private HospitalizationForm hospitalizationForm;
- private EpiDataForm epiDataForm;
-
// Build a Constructor and assign the passed Values to appropriate values in the class
public CaseEditPagerAdapter(FragmentManager fm, String caseUuid) {
@@ -43,7 +36,7 @@ public CaseEditPagerAdapter(FragmentManager fm, String caseUuid) {
caseEditBundle.putString(Case.UUID, caseUuid);
}
- //This method return the fragment for the every position in the View Pager
+ // This method return the fragment for the every position in the View Pager
@Override
public Fragment getItem(int position) {
Fragment frag = null;
@@ -51,31 +44,26 @@ public Fragment getItem(int position) {
Case caze = null;
switch (tab) {
case CASE_DATA:
- caseEditDataForm = new CaseEditDataForm();
- caseEditDataForm.setArguments(caseEditBundle);
- frag = caseEditDataForm;
+ frag = new CaseEditDataForm();
+ frag.setArguments(caseEditBundle);
break;
case PATIENT:
- personEditForm = new PersonEditForm();
+ frag = new PersonEditForm();
Bundle personEditBundle = new Bundle();
caze = DatabaseHelper.getCaseDao().queryUuid(caseEditBundle.getString(Case.UUID));
personEditBundle.putString(Person.UUID, caze.getPerson().getUuid());
personEditBundle.putSerializable(Case.DISEASE, caze.getDisease());
-
- personEditForm.setArguments(personEditBundle);
- frag = personEditForm;
+ frag.setArguments(personEditBundle);
break;
case SYMPTOMS:
- symptomsEditForm = new SymptomsEditForm();
+ frag = new SymptomsEditForm();
Bundle symptomsEditBundle = new Bundle();
caze = DatabaseHelper.getCaseDao().queryUuid(caseEditBundle.getString(Case.UUID));
symptomsEditBundle.putString(Symptoms.UUID, caze.getSymptoms().getUuid());
symptomsEditBundle.putSerializable(Case.DISEASE, caze.getDisease());
-
- symptomsEditForm.setArguments(symptomsEditBundle);
- frag = symptomsEditForm;
+ frag.setArguments(symptomsEditBundle);
break;
case CONTACTS:
ContactsListFragment contactsListTab = new ContactsListFragment();
@@ -97,26 +85,22 @@ public Fragment getItem(int position) {
frag = samplesListTab;
break;
case HOSPITALIZATION:
- hospitalizationForm = new HospitalizationForm();
+ frag = new HospitalizationForm();
Bundle hospitalizationBundle = new Bundle();
caze = DatabaseHelper.getCaseDao().queryUuid(caseEditBundle.getString(Case.UUID));
hospitalizationBundle.putString(HospitalizationForm.KEY_CASE_UUID, caze.getUuid());
hospitalizationBundle.putString(Hospitalization.UUID, caze.getHospitalization().getUuid());
-
- hospitalizationForm.setArguments(hospitalizationBundle);
- frag = hospitalizationForm;
+ frag.setArguments(hospitalizationBundle);
break;
case EPIDATA:
- epiDataForm = new EpiDataForm();
+ frag = new EpiDataForm();
Bundle epiDataBundle = new Bundle();
caze = DatabaseHelper.getCaseDao().queryUuid(caseEditBundle.getString(Case.UUID));
epiDataBundle.putSerializable(Case.DISEASE, caze.getDisease());
epiDataBundle.putString(EpiData.UUID, caze.getEpiData().getUuid());
-
- epiDataForm.setArguments(epiDataBundle);
- frag = epiDataForm;
+ frag.setArguments(epiDataBundle);
break;
}
return frag;
@@ -133,38 +117,4 @@ public CharSequence getPageTitle(int position) {
public int getCount() {
return CaseEditTabs.values().length;
}
-
- public AbstractDomainObject getData(int position) {
- CaseEditTabs tab = CaseEditTabs.fromInt(position);
- switch (tab) {
- case CASE_DATA:
- return caseEditDataForm.getData();
- case PATIENT:
- return personEditForm.getData();
- case HOSPITALIZATION:
- return hospitalizationForm.getData();
- case SYMPTOMS:
- return symptomsEditForm.getData();
- case EPIDATA:
- return epiDataForm.getData();
- }
- return null;
- }
-
- public FormTab getTabByPosition(int position) {
- CaseEditTabs tab = CaseEditTabs.fromInt(position);
- switch (tab) {
- case CASE_DATA:
- return caseEditDataForm;
- case PATIENT:
- return personEditForm;
- case HOSPITALIZATION:
- return hospitalizationForm;
- case SYMPTOMS:
- return symptomsEditForm;
- case EPIDATA:
- return epiDataForm;
- }
- return null;
- }
}
diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/caze/CaseNewActivity.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/caze/CaseNewActivity.java
index 05e0f863e25..c4429c98b02 100644
--- a/sormas-app/app/src/main/java/de/symeda/sormas/app/caze/CaseNewActivity.java
+++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/caze/CaseNewActivity.java
@@ -147,7 +147,7 @@ public void accept(Object parameter) {
caze.setPerson((Person) parameter);
savePersonAndCase(caze);
} catch (DaoException e) {
- Log.e(getClass().getName(), "Error while trying to create case", e);
+ Log.e(getClass().getName(), "Error while trying to build case", e);
Snackbar.make(findViewById(R.id.fragment_frame), String.format(getResources().getString(R.string.snackbar_create_error), getResources().getString(R.string.entity_case)), Snackbar.LENGTH_LONG).show();
ErrorReportingHelper.sendCaughtException(tracker, e, null, true);
}
@@ -162,7 +162,7 @@ public void accept(Object parameter) {
}
}
} catch (DaoException e) {
- Log.e(getClass().getName(), "Error while trying to create case", e);
+ Log.e(getClass().getName(), "Error while trying to build case", e);
Snackbar.make(findViewById(R.id.fragment_frame), String.format(getResources().getString(R.string.snackbar_create_error), getResources().getString(R.string.entity_case)), Snackbar.LENGTH_LONG).show();
ErrorReportingHelper.sendCaughtException(tracker, e, null, true);
}
diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/caze/CaseNewForm.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/caze/CaseNewForm.java
index fb3fee442aa..a61e6432b73 100644
--- a/sormas-app/app/src/main/java/de/symeda/sormas/app/caze/CaseNewForm.java
+++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/caze/CaseNewForm.java
@@ -44,9 +44,9 @@ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
person = (Person) arguments.get(CaseNewActivity.PERSON);
disease = (Disease) arguments.get(CaseNewActivity.DISEASE);
} else {
- person = DatabaseHelper.getPersonDao().create();
+ person = DatabaseHelper.getPersonDao().build();
}
- caze = DatabaseHelper.getCaseDao().create(person);
+ caze = DatabaseHelper.getCaseDao().build(person);
binding = DataBindingUtil.inflate(inflater, R.layout.case_new_fragment_layout, container, false);
diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/caze/CasesListArrayAdapter.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/caze/CasesListArrayAdapter.java
index 1e8d72262de..40a706dca8e 100644
--- a/sormas-app/app/src/main/java/de/symeda/sormas/app/caze/CasesListArrayAdapter.java
+++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/caze/CasesListArrayAdapter.java
@@ -65,9 +65,8 @@ public View getView(int position, View convertView, ViewGroup parent) {
TextView caseStatus = (TextView) convertView.findViewById(R.id.cli_case_satus);
if (!(ConfigProvider.getUser().getUserRole() == UserRole.INFORMANT && caze.getCaseClassification() == CaseClassification.NOT_CLASSIFIED)) {
caseStatus.setText(caze.getCaseClassification() != null ? caze.getCaseClassification().toString() : null);
- caseStatus.setVisibility(View.VISIBLE);
} else {
- caseStatus.setVisibility(View.GONE);
+ caseStatus.setText("");
}
TextView person = (TextView) convertView.findViewById(R.id.cli_person);
diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/caze/CasesListFragment.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/caze/CasesListFragment.java
index d7df64567d3..bbff17298b1 100644
--- a/sormas-app/app/src/main/java/de/symeda/sormas/app/caze/CasesListFragment.java
+++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/caze/CasesListFragment.java
@@ -3,7 +3,6 @@
import android.content.Intent;
import android.os.Bundle;
-import android.support.design.widget.Snackbar;
import android.support.v4.app.ListFragment;
import android.support.v4.widget.SwipeRefreshLayout;
import android.view.LayoutInflater;
@@ -15,14 +14,11 @@
import java.util.List;
import de.symeda.sormas.api.caze.InvestigationStatus;
-import de.symeda.sormas.app.AbstractRootTabActivity;
import de.symeda.sormas.app.AbstractTabActivity;
import de.symeda.sormas.app.R;
import de.symeda.sormas.app.backend.caze.Case;
import de.symeda.sormas.app.backend.common.DatabaseHelper;
-import de.symeda.sormas.app.rest.RetroProvider;
import de.symeda.sormas.app.rest.SynchronizeDataAsync;
-import de.symeda.sormas.app.util.SyncCallback;
/**
* Created by Martin on 13.08.2016.
@@ -55,8 +51,8 @@ public void onResume() {
listAdapter.addAll(cases);
if (listAdapter.getCount() == 0) {
- this.getView().findViewById(R.id.empty_list_hint).setVisibility(View.VISIBLE);
this.getView().findViewById(android.R.id.list).setVisibility(View.GONE);
+ this.getView().findViewById(R.id.empty_list_hint).setVisibility(View.VISIBLE);
} else {
this.getView().findViewById(R.id.empty_list_hint).setVisibility(View.GONE);
this.getView().findViewById(android.R.id.list).setVisibility(View.VISIBLE);
@@ -79,7 +75,7 @@ public void onActivityCreated(Bundle savedInstanceState) {
CasesListArrayAdapter adapter = new CasesListArrayAdapter(
this.getActivity(), // Context for the activity.
- R.layout.cases_list_item); // Layout to use (create)
+ R.layout.cases_list_item); // Layout to use (build)
setListAdapter(adapter);
getListView().setOnItemClickListener(new AdapterView.OnItemClickListener() {
diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/caze/SymptomsEditForm.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/caze/SymptomsEditForm.java
index 6039d7a5b54..10fa0b8f04d 100644
--- a/sormas-app/app/src/main/java/de/symeda/sormas/app/caze/SymptomsEditForm.java
+++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/caze/SymptomsEditForm.java
@@ -3,14 +3,14 @@
import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.annotation.Nullable;
+import android.text.format.DateUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.view.ViewTreeObserver;
import android.widget.ArrayAdapter;
import android.widget.Button;
-import com.google.android.gms.analytics.Tracker;
-
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -22,11 +22,9 @@
import de.symeda.sormas.api.symptoms.TemperatureSource;
import de.symeda.sormas.api.utils.Diseases;
import de.symeda.sormas.app.R;
-import de.symeda.sormas.app.SormasApplication;
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.config.ConfigProvider;
import de.symeda.sormas.app.backend.location.Location;
import de.symeda.sormas.app.backend.symptoms.Symptoms;
import de.symeda.sormas.app.component.FieldHelper;
@@ -36,10 +34,8 @@
import de.symeda.sormas.app.databinding.CaseSymptomsFragmentLayoutBinding;
import de.symeda.sormas.app.util.Consumer;
import de.symeda.sormas.app.util.DataUtils;
-import de.symeda.sormas.app.util.ErrorReportingHelper;
import de.symeda.sormas.app.util.FormTab;
import de.symeda.sormas.app.util.Item;
-import de.symeda.sormas.app.util.ValidationFailedException;
import de.symeda.sormas.app.validation.SymptomsValidator;
@@ -53,11 +49,13 @@ public class SymptomsEditForm extends FormTab {
public static final String NEW_SYMPTOMS = "newSymptoms";
public static final String FOR_VISIT = "forVisit";
public static final String VISIT_COOPERATIVE = "visitCooperative";
+
private CaseSymptomsFragmentLayoutBinding binding;
private List nonConditionalSymptoms;
private List conditionalBleedingSymptoms;
- private boolean listenersForRequiredCalled;
+ private boolean forVisit;
+ private boolean visitCooperative;
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
@@ -68,9 +66,9 @@ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
final Disease disease = (Disease) getArguments().getSerializable(Case.DISEASE);
- // create a new visit from contact data
+ // build a new visit from contact data
if(getArguments().getBoolean(NEW_SYMPTOMS)) {
- symptoms = DatabaseHelper.getSymptomsDao().create();
+ symptoms = DatabaseHelper.getSymptomsDao().build();
}
// open the given visit
else {
@@ -78,6 +76,13 @@ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
symptoms = DatabaseHelper.getSymptomsDao().queryUuid(symptomsUuid);
}
+ if (getArguments().getBoolean(FOR_VISIT)) {
+ forVisit = true;
+ if (getArguments().getBoolean(VISIT_COOPERATIVE)) {
+ visitCooperative = true;
+ }
+ }
+
binding.setSymptoms(symptoms);
binding.symptomsOnsetDate.initialize(this);
@@ -97,18 +102,33 @@ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
@Override
public void onChange(PropertyField field) {
toggleUnexplainedBleedingFields();
+ if (forVisit) {
+ SymptomsValidator.setRequiredHintsForVisitSymptoms(visitCooperative, binding);
+ } else {
+ SymptomsValidator.setRequiredHintsForCaseSymptoms(binding);
+ }
}
});
binding.symptomsOtherHemorrhagicSymptoms.addValueChangedListener(new PropertyField.ValueChangeListener() {
@Override
public void onChange(PropertyField field) {
visibilityOtherHemorrhagicSymptoms();
+ if (forVisit) {
+ SymptomsValidator.setRequiredHintsForVisitSymptoms(visitCooperative, binding);
+ } else {
+ SymptomsValidator.setRequiredHintsForCaseSymptoms(binding);
+ }
}
});
binding.symptomsOtherNonHemorrhagicSymptoms.addValueChangedListener(new PropertyField.ValueChangeListener() {
@Override
public void onChange(PropertyField field) {
visibilityOtherNonHemorrhagicSymptoms();
+ if (forVisit) {
+ SymptomsValidator.setRequiredHintsForVisitSymptoms(visitCooperative, binding);
+ } else {
+ SymptomsValidator.setRequiredHintsForCaseSymptoms(binding);
+ }
}
});
@@ -134,9 +154,7 @@ public void onChange(PropertyField field) {
binding.symptomsDigestedBloodVomit, binding.symptomsCoughingBlood, binding.symptomsBleedingVagina,
binding.symptomsSkinBruising1, binding.symptomsBloodUrine, binding.symptomsOtherHemorrhagicSymptoms);
- List- onsetSymptoms = new ArrayList<>();
- onsetSymptoms.add(new Item("",null));
- FieldHelper.initOnsetSymptomSpinnerField(binding.symptomsOnsetSymptom1, onsetSymptoms);
+ FieldHelper.initSpinnerField(binding.symptomsOnsetSymptom1, DataUtils.toItems(null, true));
addListenerForOnsetSymptom();
Button clearAllBtn = binding.symptomsClearAll;
@@ -149,6 +167,12 @@ public void onClick(View v) {
for (SymptomStateField symptom : conditionalBleedingSymptoms) {
symptom.setValue(null);
}
+
+ if (forVisit) {
+ SymptomsValidator.setRequiredHintsForVisitSymptoms(visitCooperative, binding);
+ } else {
+ SymptomsValidator.setRequiredHintsForCaseSymptoms(binding);
+ }
}
});
@@ -166,10 +190,16 @@ public void onClick(View v) {
symptom.setValue(SymptomState.NO);
}
}
+
+ if (forVisit) {
+ SymptomsValidator.setRequiredHintsForVisitSymptoms(visitCooperative, binding);
+ } else {
+ SymptomsValidator.setRequiredHintsForCaseSymptoms(binding);
+ }
}
});
- if (!getArguments().getBoolean(FOR_VISIT)) {
+ if (!forVisit) {
binding.symptomsIllLocationLayout.setVisibility(View.VISIBLE);
// ==================== IllLocation ===============
LocationDialog.addLocationField(getActivity(), symptoms.getIllLocation(), binding.symptomsIllLocation, binding.formCpBtnAddress, new Consumer() {
@@ -184,9 +214,34 @@ public void accept(Object parameter) {
binding.symptomsIllLocationFrom.initialize(this);
binding.symptomsIllLocationTo.initialize(this);
+ SymptomsValidator.setRequiredHintsForCaseSymptoms(binding);
} else {
binding.symptomsIllLocationLayout.setVisibility(View.GONE);
+ SymptomsValidator.setRequiredHintsForVisitSymptoms(visitCooperative, binding);
}
+
+ // Add listeners to symptom state fields; OnWindowFocusChangeListener is used to make sure that these
+ // listeners aren't called when the view is being built.
+ binding.caseSymptomsForm.getViewTreeObserver().addOnWindowFocusChangeListener(
+ new ViewTreeObserver.OnWindowFocusChangeListener() {
+ @Override
+ public void onWindowFocusChanged(boolean b) {
+ binding.caseSymptomsForm.getViewTreeObserver().removeOnWindowFocusChangeListener(this);
+ for (SymptomStateField symptom : nonConditionalSymptoms) {
+ symptom.addValueChangedListener(new PropertyField.ValueChangeListener() {
+ @Override
+ public void onChange(PropertyField field) {
+ if (forVisit) {
+ SymptomsValidator.setRequiredHintsForVisitSymptoms(visitCooperative, binding);
+ } else {
+ SymptomsValidator.setRequiredHintsForCaseSymptoms(binding);
+ }
+ }
+ });
+ }
+ }
+ });
+
//view.requestFocus();
return view;
}
@@ -262,21 +317,15 @@ private void addListenerForOnsetSymptom() {
symptom.addValueChangedListener(new PropertyField.ValueChangeListener() {
@Override
public void onChange(PropertyField field) {
+ Item item = new Item(field.getCaption(), field.getCaption());
+ int position = binding.symptomsOnsetSymptom1.getPositionOf(item);
if (field.getValue() == SymptomState.YES) {
- Item item = new Item(field.getCaption(), field.getCaption());
- // Workaround for Android bug (see https://issuetracker.google.com/issues/36910520)
- // Only continue when the item is not in the list yet, otherwise it will be added again
- // when calling clearAll
- if (binding.symptomsOnsetSymptom1.getPositionOf(item) == -1) {
- adapter.remove(adapter.getItem(adapter.getCount()));
+ if (position == -1) {
adapter.add(item);
- adapter.add(new Item("Select entry", null));
}
} else {
- Item item = new Item(field.getCaption(), field.getCaption());
- if (binding.symptomsOnsetSymptom1.getPositionOf(item) != -1) {
- adapter.remove((Item) binding.symptomsOnsetSymptom1.getItemAtPosition(
- binding.symptomsOnsetSymptom1.getPositionOf(new Item(field.getCaption(), field.getCaption()))));
+ if (position != -1) {
+ adapter.remove(adapter.getItem(position));
}
}
}
@@ -287,21 +336,15 @@ public void onChange(PropertyField field) {
symptom.addValueChangedListener(new PropertyField.ValueChangeListener() {
@Override
public void onChange(PropertyField field) {
+ Item item = new Item(field.getCaption(), field.getCaption());
+ int position = binding.symptomsOnsetSymptom1.getPositionOf(item);
if (field.getValue() == SymptomState.YES) {
- Item item = new Item(field.getCaption(), field.getCaption());
- // Workaround for Android bug (see https://issuetracker.google.com/issues/36910520)
- // Only continue when the item is not in the list yet, otherwise it will be added again
- // when calling clearAll
- if (binding.symptomsOnsetSymptom1.getPositionOf(item) == -1) {
- adapter.remove(adapter.getItem(adapter.getCount()));
+ if (position == -1) {
adapter.add(item);
- adapter.add(new Item("Select entry", null));
}
} else {
- Item item = new Item(field.getCaption(), field.getCaption());
- if (binding.symptomsOnsetSymptom1.getPositionOf(item) != -1) {
- adapter.remove((Item) binding.symptomsOnsetSymptom1.getItemAtPosition(
- binding.symptomsOnsetSymptom1.getPositionOf(new Item(field.getCaption(), field.getCaption()))));
+ if (position != -1) {
+ adapter.remove(adapter.getItem(position));
}
}
}
@@ -318,4 +361,9 @@ public CaseSymptomsFragmentLayoutBinding getBinding() {
return binding;
}
+ public void changeVisitCooperative(boolean cooperative) {
+ visitCooperative = cooperative;
+ SymptomsValidator.setRequiredHintsForVisitSymptoms(visitCooperative, binding);
+ }
+
}
\ No newline at end of file
diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/component/CheckBoxField.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/component/CheckBoxField.java
new file mode 100644
index 00000000000..26254efda90
--- /dev/null
+++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/component/CheckBoxField.java
@@ -0,0 +1,104 @@
+package de.symeda.sormas.app.component;
+
+import android.content.Context;
+import android.databinding.BindingAdapter;
+import android.databinding.InverseBindingAdapter;
+import android.databinding.InverseBindingListener;
+import android.util.AttributeSet;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.CheckBox;
+import android.widget.CompoundButton;
+
+import de.symeda.sormas.app.R;
+
+/**
+ * Created by Mate Strysewske on 10.08.2017.
+ */
+public class CheckBoxField extends PropertyField {
+
+ protected CheckBox checkBox;
+ protected InverseBindingListener inverseBindingListener;
+ private CompoundButton.OnCheckedChangeListener additionalListener;
+
+ public CheckBoxField(Context context) {
+ super(context);
+ initializeViews(context);
+ }
+
+ public CheckBoxField(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ initializeViews(context);
+ }
+
+ public CheckBoxField(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ initializeViews(context);
+ }
+
+ @Override
+ public void setValue(Boolean value) {
+ checkBox.setChecked(value);
+ }
+
+ @Override
+ public Boolean getValue() {
+ return checkBox.isChecked();
+ }
+
+ @BindingAdapter("android:value")
+ public static void setValue(CheckBoxField view, boolean value) {
+ view.setValue(value);
+ }
+
+ @InverseBindingAdapter(attribute = "android:value", event = "android:valueAttrChanged")
+ public static boolean getValue(CheckBoxField view) {
+ return view.getValue();
+ }
+
+ @BindingAdapter("android:valueAttrChanged")
+ public static void setListener(CheckBoxField view, InverseBindingListener listener) {
+ view.inverseBindingListener = listener;
+ }
+
+ private void initializeViews(Context context) {
+ LayoutInflater inflater = (LayoutInflater) context
+ .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ inflater.inflate(R.layout.field_checkbox_field, this);
+ }
+
+ @Override
+ protected void onFinishInflate() {
+ super.onFinishInflate();
+ checkBox = (CheckBox) this.findViewById(R.id.check_box);
+ checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
+ if (inverseBindingListener != null) {
+ inverseBindingListener.onChange();
+ }
+ onValueChanged();
+
+ if (additionalListener != null) {
+ additionalListener.onCheckedChanged(compoundButton, b);
+ }
+ }
+ });
+ checkBox.setText(getCaption());
+ }
+
+ @Override
+ public void setEnabled(boolean enabled) {
+ super.setEnabled(enabled);
+ checkBox.setEnabled(enabled);
+ }
+
+ @Override
+ protected void requestFocusForContentView(View nextView) {
+ ((CheckBoxField) nextView).checkBox.requestFocus();
+ }
+
+ public void setAdditionalListener(CompoundButton.OnCheckedChangeListener additionalListener) {
+ this.additionalListener = additionalListener;
+ }
+}
diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/component/FieldHelper.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/component/FieldHelper.java
index 9e62b3da833..727e6dbabb7 100644
--- a/sormas-app/app/src/main/java/de/symeda/sormas/app/component/FieldHelper.java
+++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/component/FieldHelper.java
@@ -40,16 +40,6 @@ public static SpinnerField initSpinnerField(SpinnerField spinnerField, List
- items) {
- spinnerField.initializeForOnsetSymptom(items);
- return spinnerField;
- }
-
- public static SpinnerField initMonthSpinnerField(SpinnerField spinnerField, List
- items, final AdapterView.OnItemSelectedListener ...moreListeners) {
- spinnerField.initializeForMonth(items, moreListeners);
- return spinnerField;
- }
-
public static SpinnerField initRegionSpinnerField(SpinnerField spinnerField, final AdapterView.OnItemSelectedListener ...moreListeners) {
RegionDao regionDao = DatabaseHelper.getRegionDao();
List
- items = DataUtils.toItems(regionDao.queryForAll(Region.NAME, true));
diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/component/PropertyField.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/component/PropertyField.java
index d8fc4e1d1b0..94b6f062709 100644
--- a/sormas-app/app/src/main/java/de/symeda/sormas/app/component/PropertyField.java
+++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/component/PropertyField.java
@@ -46,8 +46,8 @@ public String getDescription() {
}
public void setError(String errorText) {
- caption.requestFocus();
caption.setError(errorText);
+ caption.requestFocus();
}
public void setErrorWithoutFocus(String errorText) {
@@ -84,21 +84,32 @@ public void addValueChangedListener(ValueChangeListener listener) {
}
public void addCaptionOnClickListener() {
+ caption.setOnFocusChangeListener(new OnFocusChangeListener() {
+ @Override
+ public void onFocusChange(View view, boolean b) {
+ if (caption != null && b) {
+ if (caption.getError() == null && getDescription() != null && !getDescription().isEmpty()) {
+ HelpDialog helpDialog = new HelpDialog(getContext());
+ helpDialog.setMessage(getDescription());
+ helpDialog.show();
+ }
+ }
+ }
+ });
+
caption.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (caption != null) {
- if (getDescription() != null && !getDescription().isEmpty()) {
- HelpDialog helpDialog = new HelpDialog(getContext());
- helpDialog.setMessage(getDescription());
- helpDialog.show();
- }
- }
-
if (caption.getError() != null) {
caption.clearFocus();
+ } else if (getDescription() != null && !getDescription().isEmpty()) {
+ HelpDialog helpDialog = new HelpDialog(getContext());
+ helpDialog.setMessage(getDescription());
+ helpDialog.show();
}
}
+ }
});
// if(getDescription() != null && !getDescription().isEmpty()) {
diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/component/RadioGroupField.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/component/RadioGroupField.java
index 952b1ad1f0a..3d694f42904 100644
--- a/sormas-app/app/src/main/java/de/symeda/sormas/app/component/RadioGroupField.java
+++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/component/RadioGroupField.java
@@ -23,7 +23,7 @@
* Created by Mate Strysewske on 07.12.2016.
*/
-public class RadioGroupField extends PropertyField