Skip to content

Commit 64d23e7

Browse files
leventegal-sheLevente Gal
andauthored
#13195 Create a Survey request document to a case Person's (#13268)
* #13195 Create a Survey request document to a case Person's * #13193 Send a survey request email to a case person's email * #13193 Send a survey request email to a case person's email - fix code formatting * #13193 Send a survey request email to a case person's email - fixed arch tests * #13193 Send a survey request email to a case person's email - fix merge issues * #13193 Send a survey request email to a case person's email - add token into the generated document * #13193 Send a survey request email to a case person's email - fixes after review --------- Co-authored-by: Levente Gal <levente.gal.ext@vitagroup.ag>
1 parent 3e8297a commit 64d23e7

28 files changed

+763
-94
lines changed

sormas-api/src/main/java/de/symeda/sormas/api/externalemail/ExternalEmailOptionsWithAttachmentsDto.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class ExternalEmailOptionsWithAttachmentsDto implements Serializable {
4040

4141
public static final String I18N_PREFIX = "ExternalEmailOptionsWithAttachments";
4242

43-
public static final String TEMPLATE_NAME = "template";
43+
public static final String TEMPLATE = "template";
4444
public static final String RECIPIENT_EMAIL = "recipientEmail";
4545
public static final String ATTACHED_DOCUMENTS = "attachedDocuments";
4646

sormas-api/src/main/java/de/symeda/sormas/api/i18n/Captions.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2692,6 +2692,7 @@ public interface Captions {
26922692
String SurveillanceReport_uuid = "SurveillanceReport.uuid";
26932693
String surveillanceReportNewReport = "surveillanceReportNewReport";
26942694
String surveillanceReportNoReportsForCase = "surveillanceReportNoReportsForCase";
2695+
String SurveyDocumentOptions_survey = "SurveyDocumentOptions.survey";
26952696
String surveyGenerate = "surveyGenerate";
26962697
String surveyNew = "surveyNew";
26972698
String surveyNewSurvey = "surveyNewSurvey";

sormas-api/src/main/java/de/symeda/sormas/api/i18n/Strings.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,10 @@ public interface Strings {
390390
String errorSormasToSormasShareContactWithUnsharedSourceCase = "errorSormasToSormasShareContactWithUnsharedSourceCase";
391391
String errorSormasToSormasSharequestNotFound = "errorSormasToSormasSharequestNotFound";
392392
String errorSurveillanceReportNotEditable = "errorSurveillanceReportNotEditable";
393+
String errorSurveyTokenNotAvailable = "errorSurveyTokenNotAvailable";
393394
String errorTemplateFileCorrupt = "errorTemplateFileCorrupt";
395+
String errorUploadGeneratedDocument = "errorUploadGeneratedDocument";
396+
String errorUploadGeneratedDocumentExceedsFileSizeLimit = "errorUploadGeneratedDocumentExceedsFileSizeLimit";
394397
String errorViewNotFound = "errorViewNotFound";
395398
String errorWasReported = "errorWasReported";
396399
String errorWritingTemplate = "errorWritingTemplate";
@@ -631,6 +634,7 @@ public interface Strings {
631634
String headingEpiCurve = "headingEpiCurve";
632635
String headingEpiDataSourceCaseContacts = "headingEpiDataSourceCaseContacts";
633636
String headingErrorReportNotAvailable = "headingErrorReportNotAvailable";
637+
String headingErrorSendingExternalEmail = "headingErrorSendingExternalEmail";
634638
String headingEventData = "headingEventData";
635639
String headingEventGroupData = "headingEventGroupData";
636640
String headingEventGroupLinkEventIssue = "headingEventGroupLinkEventIssue";
@@ -856,6 +860,8 @@ public interface Strings {
856860
String headingSpecailCaseAccess = "headingSpecailCaseAccess";
857861
String headingStoppedFollowUp = "headingStoppedFollowUp";
858862
String headingSurveillanceReports = "headingSurveillanceReports";
863+
String headingSurveyGenerateDocument = "headingSurveyGenerateDocument";
864+
String headingSurveySendDocument = "headingSurveySendDocument";
859865
String headingSurveySideComponent = "headingSurveySideComponent";
860866
String headingSymptomJournalAccountCreation = "headingSymptomJournalAccountCreation";
861867
String headingSyncUsers = "headingSyncUsers";
@@ -1548,6 +1554,9 @@ public interface Strings {
15481554
String messageSubcontinentsArchived = "messageSubcontinentsArchived";
15491555
String messageSubcontinentsDearchived = "messageSubcontinentsDearchived";
15501556
String messageSurveyCreated = "messageSurveyCreated";
1557+
String messageSurveyNoDocumentTemplate = "messageSurveyNoDocumentTemplate";
1558+
String messageSurveyNoEmailTemplate = "messageSurveyNoEmailTemplate";
1559+
String messageSurveyNoTokens = "messageSurveyNoTokens";
15511560
String messageSurveySaved = "messageSurveySaved";
15521561
String messageSymptomsHint = "messageSymptomsHint";
15531562
String messageSymptomsVisitHint = "messageSymptomsVisitHint";

sormas-api/src/main/java/de/symeda/sormas/api/i18n/Validations.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ public interface Validations {
261261
String specifyYear = "specifyYear";
262262
String statisticsIncidenceOnlyNumbersAllowed = "statisticsIncidenceOnlyNumbersAllowed";
263263
String surveyDocumentTemplateMissingTokenVariable = "surveyDocumentTemplateMissingTokenVariable";
264+
String surveyOnlyCasesSupported = "surveyOnlyCasesSupported";
264265
String taskMissingCaseLink = "taskMissingCaseLink";
265266
String taskMissingContactLink = "taskMissingContactLink";
266267
String taskMissingEventLink = "taskMissingEventLink";
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*
2+
* SORMAS® - Surveillance Outbreak Response Management & Analysis System
3+
* Copyright © 2016-2025 Helmholtz-Zentrum für Infektionsforschung GmbH (HZI)
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
* This program is distributed in the hope that it will be useful,
9+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
* GNU General Public License for more details.
12+
* You should have received a copy of the GNU General Public License
13+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
14+
*/
15+
16+
package de.symeda.sormas.api.survey;
17+
18+
import java.io.Serializable;
19+
import java.util.Properties;
20+
21+
import de.symeda.sormas.api.ReferenceDto;
22+
import de.symeda.sormas.api.audit.AuditedClass;
23+
import de.symeda.sormas.api.docgeneneration.RootEntityType;
24+
25+
@AuditedClass
26+
public class SurveyDocumentOptionsDto implements Serializable {
27+
28+
private static final long serialVersionUID = 2850464241974703991L;
29+
30+
public static final String I18N_PREFIX = "SurveyDocumentOptions";
31+
32+
public static final String SURVEY = "survey";
33+
public static final String RECIPIENT_EMAIL = "recipientEmail";
34+
35+
private final RootEntityType rootEntityType;
36+
private final ReferenceDto rootEntityReference;
37+
private SurveyReferenceDto survey;
38+
private Properties templateProperties;
39+
private String recipientEmail;
40+
41+
public RootEntityType getRootEntityType() {
42+
return rootEntityType;
43+
}
44+
45+
public ReferenceDto getRootEntityReference() {
46+
return rootEntityReference;
47+
}
48+
49+
public SurveyDocumentOptionsDto(RootEntityType rootEntityType, ReferenceDto rootEntityReference) {
50+
this.rootEntityType = rootEntityType;
51+
this.rootEntityReference = rootEntityReference;
52+
}
53+
54+
public SurveyReferenceDto getSurvey() {
55+
return survey;
56+
}
57+
58+
public void setSurvey(SurveyReferenceDto survey) {
59+
this.survey = survey;
60+
}
61+
62+
public Properties getTemplateProperties() {
63+
return templateProperties;
64+
}
65+
66+
public void setTemplateProperties(Properties templateProperties) {
67+
this.templateProperties = templateProperties;
68+
}
69+
70+
public String getRecipientEmail() {
71+
return recipientEmail;
72+
}
73+
74+
public void setRecipientEmail(String recipientEmail) {
75+
this.recipientEmail = recipientEmail;
76+
}
77+
}

sormas-api/src/main/java/de/symeda/sormas/api/survey/SurveyDto.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ public class SurveyDto extends EntityDto {
3838
public static final String DISEASE = "disease";
3939
public static final String SURVEY_NAME = "name";
4040

41+
public static final String NAME = "name";
42+
4143
@NotBlank(message = Validations.requiredField)
4244
@Size(max = FieldConstraints.CHARACTER_LIMIT_SMALL, message = Validations.textTooLong)
4345
private String name;
@@ -85,7 +87,7 @@ public void setEmailTemplate(DocumentTemplateReferenceDto emailTemplate) {
8587
this.emailTemplate = emailTemplate;
8688
}
8789

88-
public SurveyReferenceDto toReferenceDto() {
89-
return new SurveyReferenceDto(this.getUuid(), this.getName());
90-
};
90+
public SurveyReferenceDto toReference() {
91+
return new SurveyReferenceDto(getUuid(), getName());
92+
}
9193
}

sormas-api/src/main/java/de/symeda/sormas/api/survey/SurveyFacade.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,21 @@
1515

1616
package de.symeda.sormas.api.survey;
1717

18+
import java.io.IOException;
1819
import java.util.List;
1920

2021
import javax.ejb.Remote;
2122
import javax.validation.Valid;
2223
import javax.validation.constraints.NotNull;
2324

25+
import de.symeda.sormas.api.Disease;
2426
import de.symeda.sormas.api.docgeneneration.DocumentTemplateDto;
2527
import de.symeda.sormas.api.docgeneneration.DocumentTemplateException;
28+
import de.symeda.sormas.api.docgeneneration.DocumentVariables;
29+
import de.symeda.sormas.api.externalemail.AttachmentException;
30+
import de.symeda.sormas.api.externalemail.ExternalEmailException;
2631
import de.symeda.sormas.api.utils.SortProperty;
32+
import de.symeda.sormas.api.utils.ValidationException;
2733

2834
@Remote
2935
public interface SurveyFacade {
@@ -49,4 +55,14 @@ void uploadDocumentTemplate(@NotNull SurveyReferenceDto surveyRef, DocumentTempl
4955

5056
void uploadEmailTemplate(@NotNull SurveyReferenceDto surveyReference, DocumentTemplateDto uploadedDocumentTemplateDto, byte[] fileContent)
5157
throws DocumentTemplateException;
58+
59+
List<SurveyDto> getAllByDisease(Disease disease);
60+
61+
void generateDocument(SurveyDocumentOptionsDto surveyOptions) throws DocumentTemplateException, ValidationException;
62+
63+
void sendDocument(SurveyDocumentOptionsDto surveyOptions) throws DocumentTemplateException, ValidationException, AttachmentException, IOException, ExternalEmailException;
64+
65+
boolean hasUnassignedTokens(SurveyReferenceDto survey);
66+
67+
DocumentVariables getDocumentVariables(SurveyReferenceDto surveyRef) throws DocumentTemplateException;
5268
}

sormas-api/src/main/java/de/symeda/sormas/api/survey/SurveyTokenIndexDto.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ public class SurveyTokenIndexDto extends PseudonymizableIndexDto {
3131
private final Date assignmentDate;
3232
private final String recipientEmail;
3333
private final Boolean responseReceived;
34+
private final String generatedDocumentUuid;
35+
private final String generatedDocumentName;
36+
private final String generatedDocumentMimeType;
3437

3538
public SurveyTokenIndexDto(
3639
String uuid,
@@ -39,7 +42,7 @@ public SurveyTokenIndexDto(
3942
String token,
4043
CaseReferenceDto caseAssignedTo,
4144
Date assignmentDate,
42-
String recipientEmail, Boolean responseReceived) {
45+
String recipientEmail, Boolean responseReceived, String generatedDocumentUuid, String generatedDocumentName, String generatedDocumentMimeType) {
4346
super(uuid);
4447
this.surveyUuid = surveyUuid;
4548
this.surveyName = surveyName;
@@ -48,6 +51,9 @@ public SurveyTokenIndexDto(
4851
this.assignmentDate = assignmentDate;
4952
this.recipientEmail = recipientEmail;
5053
this.responseReceived = responseReceived;
54+
this.generatedDocumentUuid = generatedDocumentUuid;
55+
this.generatedDocumentName = generatedDocumentName;
56+
this.generatedDocumentMimeType = generatedDocumentMimeType;
5157
}
5258

5359
public String getSurveyUuid() {
@@ -81,4 +87,16 @@ public Boolean getResponseReceived() {
8187
public SurveyTokenReferenceDto toReference() {
8288
return new SurveyTokenReferenceDto(getUuid(), getSurveyName());
8389
}
90+
91+
public String getGeneratedDocumentUuid() {
92+
return generatedDocumentUuid;
93+
}
94+
95+
public String getGeneratedDocumentName() {
96+
return generatedDocumentName;
97+
}
98+
99+
public String getGeneratedDocumentMimeType() {
100+
return generatedDocumentMimeType;
101+
}
84102
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3419,3 +3419,5 @@ SurveyToken.assignmentDate = Assignment date
34193419
SurveyToken.recipientEmail = Recipient email
34203420
SurveyToken.generatedDocument = Generated document
34213421
SurveyToken.responseReceived = Response received
3422+
3423+
SurveyDocumentOptions.survey = Survey

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,8 @@ errorFileNotFound = File '%s' not found
400400
errorReadingTemplate = Error reading template '%s'
401401
errorReadingDocument = Error reading document '%s'
402402
errorProcessingTemplate = Error processing template.
403+
errorUploadGeneratedDocument=Could not upload the generated document.
404+
errorUploadGeneratedDocumentExceedsFileSizeLimit=Cannot upload the generated document because it exceeds the file size limit configured in the system.
403405
errorTemplateFileCorrupt = The template file is corrupt.
404406
errorWritingTemplate = Could not write template file.
405407
errorCampaignDiagramTotalsCalculationError=At least part of the percentage values for the diagram '%s' could not be calculated. Please check the diagram definitions for errors.
@@ -439,6 +441,7 @@ errorAdverseEventNotEditable = This adverse event is not editable anymore
439441
errorAdverseEventInvestigationNotEditable = This adverse event investigation is not editable anymore
440442
errorExternalEmailMissingPersonEmailAddress=This person does not have an email address
441443
errorDocumentTemplateWorkflowChangeNotAllowed=The workflow of this document template cannot be changed.
444+
errorSurveyTokenNotAvailable=There is no available survey token for this survey.
442445

443446
# headings
444447
headingAccessDenied = Access denied
@@ -909,6 +912,9 @@ headingAefiInvestigationSelectConcernedVaccine=Select concerned vaccine
909912
headingAefiInvestigationFormSubHeading=(Only for Serious Adverse Events Following Immunization ? Death / Disability / Hospitalization / Cluster)
910913
headingSurveySideComponent=Surveys
911914
headingCaseSurveyDetails=Survey details
915+
headingSurveyGenerateDocument=Generate document
916+
headingSurveySendDocument=Send document
917+
headingErrorSendingExternalEmail=Error sending email
912918
headingImportSurveyTokens = Import Survey Tokens
913919

914920
# Info texts
@@ -1449,6 +1455,9 @@ messageSubcontinentsArchived = All selected subcontinents have been archived
14491455
messageSubcontinentsDearchived = All selected subcontinents have been de-archived
14501456
messageSurveySaved = Survey saved
14511457
messageSurveyCreated = Survey created
1458+
messageSurveyNoDocumentTemplate = No document template has been set for this survey
1459+
messageSurveyNoEmailTemplate = No email template has been set for this survey
1460+
messageSurveyNoTokens = No unassigned tokens have been found for this survey
14521461
messageCountriesArchived = All selected countries have been archived
14531462
messageCountriesDearchived = All selected regions have been de-archived
14541463
messageRegionsArchived = All selected regions have been archived

0 commit comments

Comments
 (0)