Skip to content

Commit 475b840

Browse files
committed
Started boilerplate for ExternalMessage-API.
Breaks unit tests because some permission is missing: de.symeda.sormas.api.utils.ValidationRuntimeException: The following user right(s) are required based on other user right(s): <br> <b>[Edit surveys]</b> required by 'EXTERNAL_MESSAGE_SURVEY_RESPONSE_PROCESS'<br><b>[View surveys]</b> required by 'EXTERNAL_MESSAGE_SURVEY_RESPONSE_PROCESS'<br><b>[Create surveys]</b> required by 'EXTERNAL_MESSAGE_SURVEY_RESPONSE_PROCESS'<br><b>[Delete surveys]</b> required by 'EXTERNAL_MESSAGE_SURVEY_RESPONSE_PROCESS'<br><b>[View survey tokens]</b> required by 'EXTERNAL_MESSAGE_SURVEY_RESPONSE_PROCESS'<br>
1 parent 9452b3c commit 475b840

File tree

15 files changed

+2288
-1802
lines changed

15 files changed

+2288
-1802
lines changed

sormas-api/src/main/java/de/symeda/sormas/api/externalmessage/ExternalMessageDto.java

Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
import java.util.ArrayList;
1919
import java.util.Date;
2020
import java.util.List;
21+
import java.util.Objects;
2122

23+
import javax.annotation.Nullable;
2224
import javax.validation.constraints.Size;
2325

2426
import de.symeda.sormas.api.CountryHelper;
@@ -32,6 +34,7 @@
3234
import de.symeda.sormas.api.clinicalcourse.ComplianceWithTreatment;
3335
import de.symeda.sormas.api.disease.DiseaseVariant;
3436
import de.symeda.sormas.api.externalmessage.labmessage.SampleReportDto;
37+
import de.symeda.sormas.api.externalmessage.survey.ExternalMessageSurveyResponseWrapper;
3538
import de.symeda.sormas.api.feature.FeatureType;
3639
import de.symeda.sormas.api.i18n.Validations;
3740
import de.symeda.sormas.api.infrastructure.country.CountryReferenceDto;
@@ -262,6 +265,9 @@ public class ExternalMessageDto extends SormasToSormasShareableDto {
262265
private Boolean tuberculosisMdrXdrTuberculosis;
263266
private Boolean tuberculosisBeijingLineage;
264267

268+
@Nullable
269+
private ExternalMessageSurveyResponseWrapper surveyResponseWrapper;
270+
265271
public ExternalMessageType getType() {
266272
return type;
267273
}
@@ -939,4 +945,186 @@ public Boolean getTuberculosisBeijingLineage() {
939945
public void setTuberculosisBeijingLineage(Boolean tuberculosisBeijingLineage) {
940946
this.tuberculosisBeijingLineage = tuberculosisBeijingLineage;
941947
}
948+
949+
public ExternalMessageSurveyResponseWrapper getSurveyResponseWrapper() {
950+
return surveyResponseWrapper;
951+
}
952+
953+
public ExternalMessageDto setSurveyResponseWrapper(ExternalMessageSurveyResponseWrapper surveyResponseWrapper) {
954+
this.surveyResponseWrapper = surveyResponseWrapper;
955+
return this;
956+
}
957+
958+
@Override
959+
public boolean equals(Object o) {
960+
if (o == null || getClass() != o.getClass())
961+
return false;
962+
if (!super.equals(o))
963+
return false;
964+
ExternalMessageDto that = (ExternalMessageDto) o;
965+
return automaticProcessingPossible == that.automaticProcessingPossible
966+
&& type == that.type
967+
&& disease == that.disease
968+
&& Objects.equals(diseaseVariant, that.diseaseVariant)
969+
&& Objects.equals(diseaseVariantDetails, that.diseaseVariantDetails)
970+
&& Objects.equals(messageDateTime, that.messageDateTime)
971+
&& caseClassification == that.caseClassification
972+
&& Objects.equals(caseReportDate, that.caseReportDate)
973+
&& Objects.equals(caseSymptoms, that.caseSymptoms)
974+
&& Objects.equals(reporterName, that.reporterName)
975+
&& Objects.equals(reporterExternalIds, that.reporterExternalIds)
976+
&& Objects.equals(reporterPostalCode, that.reporterPostalCode)
977+
&& Objects.equals(reporterCity, that.reporterCity)
978+
&& Objects.equals(personFirstName, that.personFirstName)
979+
&& Objects.equals(personLastName, that.personLastName)
980+
&& Objects.equals(personExternalId, that.personExternalId)
981+
&& Objects.equals(personNationalHealthId, that.personNationalHealthId)
982+
&& personSex == that.personSex
983+
&& personPresentCondition == that.personPresentCondition
984+
&& Objects.equals(personBirthDateDD, that.personBirthDateDD)
985+
&& Objects.equals(personBirthDateMM, that.personBirthDateMM)
986+
&& Objects.equals(personBirthDateYYYY, that.personBirthDateYYYY)
987+
&& Objects.equals(personPostalCode, that.personPostalCode)
988+
&& Objects.equals(personCity, that.personCity)
989+
&& Objects.equals(personStreet, that.personStreet)
990+
&& Objects.equals(personHouseNumber, that.personHouseNumber)
991+
&& Objects.equals(personCountry, that.personCountry)
992+
&& Objects.equals(personFacility, that.personFacility)
993+
&& Objects.equals(personPhone, that.personPhone)
994+
&& personPhoneNumberType == that.personPhoneNumberType
995+
&& Objects.equals(personEmail, that.personEmail)
996+
&& Objects.equals(personGuardianFirstName, that.personGuardianFirstName)
997+
&& Objects.equals(personGuardianLastName, that.personGuardianLastName)
998+
&& Objects.equals(personGuardianRelationship, that.personGuardianRelationship)
999+
&& Objects.equals(personGuardianPhone, that.personGuardianPhone)
1000+
&& Objects.equals(personGuardianEmail, that.personGuardianEmail)
1001+
&& Objects.equals(personOccupation, that.personOccupation)
1002+
&& treatmentStarted == that.treatmentStarted
1003+
&& Objects.equals(treatmentNotApplicable, that.treatmentNotApplicable)
1004+
&& Objects.equals(treatmentStartedDate, that.treatmentStartedDate)
1005+
&& Objects.equals(diagnosticDate, that.diagnosticDate)
1006+
&& Objects.equals(deceasedDate, that.deceasedDate)
1007+
&& Objects.equals(sampleReports, that.sampleReports)
1008+
&& Objects.equals(surveillanceReport, that.surveillanceReport)
1009+
&& Objects.equals(externalMessageDetails, that.externalMessageDetails)
1010+
&& Objects.equals(caseComments, that.caseComments)
1011+
&& Objects.equals(reportId, that.reportId)
1012+
&& Objects.equals(reportMessageId, that.reportMessageId)
1013+
&& status == that.status
1014+
&& Objects.equals(assignee, that.assignee)
1015+
&& Objects.equals(reportingUser, that.reportingUser)
1016+
&& Objects.equals(personAdditionalDetails, that.personAdditionalDetails)
1017+
&& vaccinationStatus == that.vaccinationStatus
1018+
&& admittedToHealthFacility == that.admittedToHealthFacility
1019+
&& Objects.equals(hospitalizationFacilityName, that.hospitalizationFacilityName)
1020+
&& Objects.equals(hospitalizationFacilityExternalId, that.hospitalizationFacilityExternalId)
1021+
&& Objects.equals(hospitalizationFacilityDepartment, that.hospitalizationFacilityDepartment)
1022+
&& Objects.equals(hospitalizationAdmissionDate, that.hospitalizationAdmissionDate)
1023+
&& Objects.equals(hospitalizationDischargeDate, that.hospitalizationDischargeDate)
1024+
&& Objects.equals(notifierFirstName, that.notifierFirstName)
1025+
&& Objects.equals(notifierLastName, that.notifierLastName)
1026+
&& Objects.equals(notifierRegistrationNumber, that.notifierRegistrationNumber)
1027+
&& Objects.equals(notifierAddress, that.notifierAddress)
1028+
&& Objects.equals(notifierEmail, that.notifierEmail)
1029+
&& Objects.equals(notifierPhone, that.notifierPhone)
1030+
&& Objects.equals(activitiesAsCase, that.activitiesAsCase)
1031+
&& Objects.equals(exposures, that.exposures)
1032+
&& radiographyCompatibility == that.radiographyCompatibility
1033+
&& Objects.equals(otherDiagnosticCriteria, that.otherDiagnosticCriteria)
1034+
&& tuberculosis == that.tuberculosis
1035+
&& hiv == that.hiv
1036+
&& hivArt == that.hivArt
1037+
&& Objects.equals(tuberculosisInfectionYear, that.tuberculosisInfectionYear)
1038+
&& previousTuberculosisTreatment == that.previousTuberculosisTreatment
1039+
&& complianceWithTreatment == that.complianceWithTreatment
1040+
&& Objects.equals(tuberculosisDirectlyObservedTreatment, that.tuberculosisDirectlyObservedTreatment)
1041+
&& Objects.equals(tuberculosisMdrXdrTuberculosis, that.tuberculosisMdrXdrTuberculosis)
1042+
&& Objects.equals(tuberculosisBeijingLineage, that.tuberculosisBeijingLineage)
1043+
&& Objects.equals(surveyResponseWrapper, that.surveyResponseWrapper);
1044+
}
1045+
1046+
@Override
1047+
public int hashCode() {
1048+
return Objects.hash(
1049+
super.hashCode(),
1050+
type,
1051+
disease,
1052+
diseaseVariant,
1053+
diseaseVariantDetails,
1054+
messageDateTime,
1055+
caseClassification,
1056+
caseReportDate,
1057+
caseSymptoms,
1058+
reporterName,
1059+
reporterExternalIds,
1060+
reporterPostalCode,
1061+
reporterCity,
1062+
personFirstName,
1063+
personLastName,
1064+
personExternalId,
1065+
personNationalHealthId,
1066+
personSex,
1067+
personPresentCondition,
1068+
personBirthDateDD,
1069+
personBirthDateMM,
1070+
personBirthDateYYYY,
1071+
personPostalCode,
1072+
personCity,
1073+
personStreet,
1074+
personHouseNumber,
1075+
personCountry,
1076+
personFacility,
1077+
personPhone,
1078+
personPhoneNumberType,
1079+
personEmail,
1080+
personGuardianFirstName,
1081+
personGuardianLastName,
1082+
personGuardianRelationship,
1083+
personGuardianPhone,
1084+
personGuardianEmail,
1085+
personOccupation,
1086+
treatmentStarted,
1087+
treatmentNotApplicable,
1088+
treatmentStartedDate,
1089+
diagnosticDate,
1090+
deceasedDate,
1091+
sampleReports,
1092+
surveillanceReport,
1093+
externalMessageDetails,
1094+
caseComments,
1095+
reportId,
1096+
reportMessageId,
1097+
status,
1098+
assignee,
1099+
reportingUser,
1100+
automaticProcessingPossible,
1101+
personAdditionalDetails,
1102+
vaccinationStatus,
1103+
admittedToHealthFacility,
1104+
hospitalizationFacilityName,
1105+
hospitalizationFacilityExternalId,
1106+
hospitalizationFacilityDepartment,
1107+
hospitalizationAdmissionDate,
1108+
hospitalizationDischargeDate,
1109+
notifierFirstName,
1110+
notifierLastName,
1111+
notifierRegistrationNumber,
1112+
notifierAddress,
1113+
notifierEmail,
1114+
notifierPhone,
1115+
activitiesAsCase,
1116+
exposures,
1117+
radiographyCompatibility,
1118+
otherDiagnosticCriteria,
1119+
tuberculosis,
1120+
hiv,
1121+
hivArt,
1122+
tuberculosisInfectionYear,
1123+
previousTuberculosisTreatment,
1124+
complianceWithTreatment,
1125+
tuberculosisDirectlyObservedTreatment,
1126+
tuberculosisMdrXdrTuberculosis,
1127+
tuberculosisBeijingLineage,
1128+
surveyResponseWrapper);
1129+
}
9421130
}

sormas-api/src/main/java/de/symeda/sormas/api/externalmessage/ExternalMessageFacade.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ public interface ExternalMessageFacade extends PermanentlyDeletableFacade {
2222

2323
ExternalMessageDto saveAndProcessLabmessage(@Valid ExternalMessageDto dto);
2424

25+
List<ExternalMessageDto> saveAndProcessSurveyResponses(@Valid List<ExternalMessageDto> dtos);
26+
2527
void validate(ExternalMessageDto dto);
2628

2729
// Also returns deleted lab messages
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
package de.symeda.sormas.api.externalmessage.survey;
2+
3+
import java.util.List;
4+
import java.util.Map;
5+
import java.util.Objects;
6+
7+
import javax.annotation.Nullable;
8+
import javax.validation.constraints.NotNull;
9+
10+
import de.symeda.sormas.api.Language;
11+
import de.symeda.sormas.api.externalmessage.ExternalMessageType;
12+
import de.symeda.sormas.api.info.InfoFacade;
13+
import de.symeda.sormas.api.patch.DataReplacementStrategy;
14+
import de.symeda.sormas.api.patch.EmptyValueBehavior;
15+
16+
/**
17+
* Mandatory fields that require
18+
* Will be present for {@link ExternalMessageType#SURVEY_RESPONSE}.
19+
*/
20+
public class ExternalMessageSurveyResponseRequest {
21+
22+
private String token;
23+
private String externalSurveyId;
24+
25+
private boolean patchedInCaseOfFailures = false;
26+
27+
@NotNull
28+
private DataReplacementStrategy replacementStrategy = DataReplacementStrategy.IF_NOT_ALREADY_PRESENT;
29+
30+
@NotNull
31+
private EmptyValueBehavior emptyValueBehavior = EmptyValueBehavior.IGNORE;
32+
33+
/**
34+
* Key are those from with root being the {@link de.symeda.sormas.api.caze.CaseDataDto}.
35+
* The accepted fields are those from {@link InfoFacade#generateDataDictionary()}.
36+
*/
37+
@NotNull
38+
private Map<String, Object> patchDictionary;
39+
40+
/**
41+
* Origin that wants the patch operation.
42+
* Can be used within {@link de.symeda.sormas.api.patch.mapping.FieldCustomMapper}.
43+
*/
44+
@Nullable
45+
private String origin;
46+
47+
/**
48+
* To be able to support I18n inputs the input languages can be passed, system locale by default.
49+
*/
50+
@Nullable
51+
private List<Language> inputLanguages;
52+
53+
public String getToken() {
54+
return token;
55+
}
56+
57+
public ExternalMessageSurveyResponseRequest setToken(String token) {
58+
this.token = token;
59+
return this;
60+
}
61+
62+
public String getExternalSurveyId() {
63+
return externalSurveyId;
64+
}
65+
66+
public ExternalMessageSurveyResponseRequest setExternalSurveyId(String externalSurveyId) {
67+
this.externalSurveyId = externalSurveyId;
68+
return this;
69+
}
70+
71+
public boolean isPatchedInCaseOfFailures() {
72+
return patchedInCaseOfFailures;
73+
}
74+
75+
public ExternalMessageSurveyResponseRequest setPatchedInCaseOfFailures(boolean patchedInCaseOfFailures) {
76+
this.patchedInCaseOfFailures = patchedInCaseOfFailures;
77+
return this;
78+
}
79+
80+
public DataReplacementStrategy getReplacementStrategy() {
81+
return replacementStrategy;
82+
}
83+
84+
public ExternalMessageSurveyResponseRequest setReplacementStrategy(DataReplacementStrategy replacementStrategy) {
85+
this.replacementStrategy = replacementStrategy;
86+
return this;
87+
}
88+
89+
public EmptyValueBehavior getEmptyValueBehavior() {
90+
return emptyValueBehavior;
91+
}
92+
93+
public ExternalMessageSurveyResponseRequest setEmptyValueBehavior(EmptyValueBehavior emptyValueBehavior) {
94+
this.emptyValueBehavior = emptyValueBehavior;
95+
return this;
96+
}
97+
98+
public Map<String, Object> getPatchDictionary() {
99+
return patchDictionary;
100+
}
101+
102+
public ExternalMessageSurveyResponseRequest setPatchDictionary(Map<String, Object> patchDictionary) {
103+
this.patchDictionary = patchDictionary;
104+
return this;
105+
}
106+
107+
@Nullable
108+
public String getOrigin() {
109+
return origin;
110+
}
111+
112+
public ExternalMessageSurveyResponseRequest setOrigin(@Nullable String origin) {
113+
this.origin = origin;
114+
return this;
115+
}
116+
117+
@Nullable
118+
public List<Language> getInputLanguages() {
119+
return inputLanguages;
120+
}
121+
122+
public ExternalMessageSurveyResponseRequest setInputLanguages(@Nullable List<Language> inputLanguages) {
123+
this.inputLanguages = inputLanguages;
124+
return this;
125+
}
126+
127+
@Override
128+
public boolean equals(Object o) {
129+
if (o == null || getClass() != o.getClass())
130+
return false;
131+
ExternalMessageSurveyResponseRequest that = (ExternalMessageSurveyResponseRequest) o;
132+
return patchedInCaseOfFailures == that.patchedInCaseOfFailures
133+
&& Objects.equals(token, that.token)
134+
&& Objects.equals(externalSurveyId, that.externalSurveyId)
135+
&& replacementStrategy == that.replacementStrategy
136+
&& emptyValueBehavior == that.emptyValueBehavior
137+
&& Objects.equals(patchDictionary, that.patchDictionary)
138+
&& Objects.equals(origin, that.origin)
139+
&& Objects.equals(inputLanguages, that.inputLanguages);
140+
}
141+
142+
@Override
143+
public int hashCode() {
144+
return Objects
145+
.hash(token, externalSurveyId, patchedInCaseOfFailures, replacementStrategy, emptyValueBehavior, patchDictionary, origin, inputLanguages);
146+
}
147+
}

0 commit comments

Comments
 (0)