Skip to content
This repository was archived by the owner on May 5, 2021. It is now read-only.

Commit f940d3f

Browse files
authored
Merge pull request SORMAS-Foundation#3491 from GIP-GRADeS-BFC/hzi_3426_import_event_participant
Hzi 3426 import event participant
2 parents 36ba5af + 42b11b9 commit f940d3f

22 files changed

Lines changed: 1055 additions & 3 deletions

sormas-api/src/main/java/de/symeda/sormas/api/event/EventParticipantCriteria.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import java.io.Serializable;
44

55
import de.symeda.sormas.api.BaseCriteria;
6+
import de.symeda.sormas.api.person.PersonReferenceDto;
67
import de.symeda.sormas.api.utils.IgnoreForUrl;
78

89
public class EventParticipantCriteria extends BaseCriteria implements Serializable {
@@ -15,6 +16,7 @@ public class EventParticipantCriteria extends BaseCriteria implements Serializab
1516
public static final String BIRTHDATE_DD = "birthdateDD";
1617

1718
private EventReferenceDto event;
19+
private PersonReferenceDto person;
1820
private String freeText;
1921
private Integer birthdateYYYY;
2022
private Integer birthdateMM;
@@ -30,6 +32,16 @@ public EventParticipantCriteria event(EventReferenceDto event) {
3032
return this;
3133
}
3234

35+
@IgnoreForUrl
36+
public PersonReferenceDto getPerson() {
37+
return person;
38+
}
39+
40+
public EventParticipantCriteria person(PersonReferenceDto person) {
41+
this.person = person;
42+
return this;
43+
}
44+
3345
public EventParticipantCriteria freeText(String freeText) {
3446
this.freeText = freeText;
3547
return this;

sormas-api/src/main/java/de/symeda/sormas/api/event/EventParticipantFacade.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ List<EventParticipantIndexDto> getIndexList(
5050
Integer max,
5151
List<SortProperty> sortProperties);
5252

53+
EventParticipantDto getByUuid(String uuid);
54+
5355
void validate(EventParticipantDto eventParticipant);
5456

5557
long count(EventParticipantCriteria eventParticipantCriteria);
@@ -62,6 +64,8 @@ List<EventParticipantIndexDto> getIndexList(
6264

6365
boolean isEventParticipantEditAllowed(String uuid);
6466

67+
EventParticipantDto getFirst(EventParticipantCriteria eventParticipantCriteria);
68+
6569
List<EventParticipantExportDto> getExportList(EventParticipantCriteria eventParticipantCriteria, int first, int max, Language userLanguage);
6670

6771
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ public interface Strings {
330330
String headingImportedCaseInfo = "headingImportedCaseInfo";
331331
String headingImportedPersonInfo = "headingImportedPersonInfo";
332332
String headingImportError = "headingImportError";
333+
String headingImportEventParticipant = "headingImportEventParticipant";
333334
String headingImportFacilities = "headingImportFacilities";
334335
String headingImportFailed = "headingImportFailed";
335336
String headingImportPointsOfEntry = "headingImportPointsOfEntry";
@@ -496,6 +497,7 @@ public interface Strings {
496497
String infoSelectOrCreatePersonForContact = "infoSelectOrCreatePersonForContact";
497498
String infoSelectOrCreatePersonForContactImport = "infoSelectOrCreatePersonForContactImport";
498499
String infoSelectOrCreatePersonForEventParticipant = "infoSelectOrCreatePersonForEventParticipant";
500+
String infoSelectOrCreatePersonForEventParticipantImport = "infoSelectOrCreatePersonForEventParticipantImport";
499501
String infoSpecificCaseSearch = "infoSpecificCaseSearch";
500502
String infoSpecificEventSearch = "infoSpecificEventSearch";
501503
String infoStatisticsDisclaimer = "infoStatisticsDisclaimer";

sormas-api/src/main/java/de/symeda/sormas/api/importexport/ImportFacade.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ public interface ImportFacade {
3434
*/
3535
void generateCaseImportTemplateFile() throws IOException;
3636

37+
void generateEventParticipantImportTemplateFile() throws IOException;
38+
3739
void generateCampaignFormImportTemplateFile(String campaignFormUuid) throws IOException;
3840

3941
void generateCaseContactImportTemplateFile() throws IOException;
@@ -60,6 +62,8 @@ public interface ImportFacade {
6062

6163
String getCaseImportTemplateFilePath();
6264

65+
String getEventParticipantImportTemplateFilePath();
66+
6367
String getCampaignFormImportTemplateFilePath();
6468

6569
String getPointOfEntryImportTemplateFilePath();

sormas-api/src/main/java/de/symeda/sormas/api/user/UserRight.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,15 @@ public enum UserRight {
686686
ADMIN,
687687
NATIONAL_USER
688688
),
689+
EVENTPARTICIPANT_IMPORT(
690+
ADMIN,
691+
NATIONAL_USER,
692+
SURVEILLANCE_SUPERVISOR,
693+
ADMIN_SUPERVISOR,
694+
SURVEILLANCE_OFFICER,
695+
EVENT_OFFICER,
696+
IMPORT_USER
697+
),
689698
WEEKLYREPORT_CREATE(
690699
HOSPITAL_INFORMANT,
691700
COMMUNITY_INFORMANT,

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,7 @@ headingImportCampaign = Import campaign form data
351351
headingImportCsvFile = Import CSV File
352352
headingImportDistricts = Import Districts
353353
headingImportError = Import error
354+
headingImportEventParticipant = Import event participants
354355
headingImportedCaseInfo = Imported Case Information
355356
headingImportedPersonInfo = Imported Person Information
356357
headingImportFailed = Import failed
@@ -549,6 +550,7 @@ infoSelectOrCreateContactImport = The database already contains at least one con
549550
infoSelectOrCreatePersonForContact = The database already contains at least one person that seems to be very similar to the personal details of the created contact.<br/><br/>Please look through the list of persons. If you feel certain that one of those persons matches your contact person, select it and click on the <i>Save</i> button. Otherwise, click on <i>Create New Person</i> to create a new person for your contact.<br/><br/>If you are unsure, you can discard this window and cancel the contact creation process.
550551
infoSelectOrCreatePersonForContactImport = The database already contains at least one person that seems to be very similar to the personal details of the imported contact.<br/><br/>Please look through the list of persons. If you feel certain that one of those persons matches your contact person, select it and click on the <i>Save</i> button. Otherwise, click on <i>Create New Person</i> to create a new person for your contact.<br/><br/>If you are unsure, you can discard this window to remove the contact from the current import.
551552
infoSelectOrCreatePersonForEventParticipant = The database already contains at least one person that seems to be very similar to the personal details of the created event participant.<br/><br/>Please look through the list of persons. If you feel certain that one of those persons matches your event person, select it and click on the <i>Save</i> button. Otherwise, click on <i>Create New Person</i> to create a new event person for your event.<br/><br/>If you are unsure, you can discard this window and cancel the event participant creation process.
553+
infoSelectOrCreatePersonForEventParticipantImport = The database already contains at least one person that seems to be very similar to the personal details of the created event participant.<br/><br/>Please look through the list of persons. If you feel certain that one of those persons matches your event person, select it and click on the <i>Save</i> button. Otherwise, click on <i>Create New Person</i> to create a new event person for your event.<br/><br/>If you are unsure, you can discard this window to remove the event participant from the current import.
552554
pseudonymizedCasesSelectedWarning = For the bulked-edited cases you have only limited access to the sensitive data. For those cases the value you put into "Place Description" will be ignored.
553555
infoPickOrCreateEventForCase = The list below contains all existing events having the same disease as the current case. Please check whether the event this case belongs to is already on this list or create a new one if it isn't.
554556
infoSelectOrCreatePersonForCase = The database already contains at least one person that seems to be very similar to the personal details of the created case.<br/><br/>Please look through the list of persons. If you feel certain that one of those persons matches your case person, select them and click on the <i>Save</i> button. Otherwise, click on <i>Create New Person</i> to create a new person for your case.<br/><br/>If you are unsure, you can discard this window and cancel the case creation process.

sormas-api/src/main/resources/strings_fr-FR.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ headingImportCampaign = Importer les données du formulaire de campagne
346346
headingImportCsvFile = Importer un fichier CSV
347347
headingImportDistricts = Importer des départements
348348
headingImportError = Erreur d'import
349+
headingImportEventParticipant = Importer les participants de l'événement
349350
headingImportedCaseInfo = Informations de cas importées
350351
headingImportedPersonInfo = Informations de personne importées
351352
headingImportFailed = Importation échouée
@@ -541,6 +542,7 @@ infoSelectOrCreateContactImport = La base de données contient déjà au moins u
541542
infoSelectOrCreatePersonForContact = La base de données contient déjà au moins une personne qui semble être très similaire aux données personnelles du contact créé.<br/><br/>Veuillez consulter la liste des personnes. Si vous avez la certitude qu'une de ces personnes correspond à votre personne de contact, sélectionnez-la et cliquez sur le bouton <i>Enregistrer</i> . Sinon, cliquez sur <i>Créer une nouvelle personne</i> pour créer une nouvelle personne pour votre contact.<br/><br/>Si vous n'êtes pas sûr, vous pouvez supprimer cette fenêtre et annuler le processus de création de contact.
542543
infoSelectOrCreatePersonForContactImport = La base de données contient déjà au moins une personne qui semble être très similaire aux données personnelles du contact créé.<br/><br/>Veuillez consulter la liste des personnes. Si vous avez la certitude qu'une de ces personnes correspond à votre personne de contact, sélectionnez-la et cliquez sur le bouton <i>Enregistrer</i> . Sinon, cliquez sur <i>Créer une nouvelle personne</i> pour créer une nouvelle personne pour votre contact.<br/><br/>Si vous n'êtes pas sûr, vous pouvez supprimer cette fenêtre et annuler le processus de création de contact.
543544
infoSelectOrCreatePersonForEventParticipant = La base de données contient déjà au moins une personne qui semble être très similaire aux données personnelles du contact créé.<br/><br/>Veuillez consulter la liste des personnes. Si vous avez la certitude qu'une de ces personnes correspond à votre personne de contact, sélectionnez-la et cliquez sur le bouton <i>Enregistrer</i> . Sinon, cliquez sur <i>Créer une nouvelle personne</i> pour créer une nouvelle personne pour votre contact.<br/><br/>Si vous n'êtes pas sûr, vous pouvez supprimer cette fenêtre et annuler le processus de création de contact.
545+
infoSelectOrCreatePersonForEventParticipantImport = La base de données contient déjà au moins une personne qui semble être très similaire aux données personnelles du partcipant créé.<br/><br/>Veuillez consulter la liste des personnes. Si vous avez la certitude qu'une de ces personnes correspond à votre personne de participant, sélectionnez-la et cliquez sur le bouton <i>Enregistrer</i> . Sinon, cliquez sur <i>Créer une nouvelle personne</i> pour créer une nouvelle personne pour votre participant.<br/><br/>Si vous n'êtes pas sûr, vous pouvez fermer cette fenêtre pour supprimer le partcipant de l'importation courante.
544546
pseudonymizedCasesSelectedWarning = Pour les cas gérés en bloc, vous n'avez qu'un accès limité aux données sensibles. Dans ces cas, la valeur que vous mettez dans "Place Description" sera ignorée.
545547
infoPickOrCreateEventForCase = La liste ci-dessous contient tous les événements existants ayant la même maladie que le cas actuel. Veuillez vérifier si l'événement auquel appartient ce cas est déjà dans cette liste ou en créer un nouveau s'il ne l'est pas.
546548
infoSelectOrCreatePersonForCase = La base de données contient déjà au moins une personne qui semble être très similaire aux données personnelles du cas créé.<br/><br/>Veuillez consulter la liste des personnes. Si vous êtes certain qu'une de ces personnes correspond à la personne de votre cas, sélectionnez-les et cliquez sur le bouton <i>Sauvegarder</i>. Sinon, cliquez sur <i>Créer une nouvelle personne</i> pour créer une nouvelle personne pour votre cas.<br/><br/>Si vous n'êtes pas sûr, vous pouvez fermer cette fenêtre et annuler le processus de création du cas.

sormas-backend/src/main/java/de/symeda/sormas/backend/common/StartupShutdownService.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,11 @@ private void createImportTemplateFiles() {
720720
} catch (IOException e) {
721721
logger.error("Could not create facility/laboratory import template .csv file.");
722722
}
723+
try {
724+
importFacade.generateEventParticipantImportTemplateFile();
725+
} catch (IOException e) {
726+
logger.error("Could not create eventparticipant import template .csv file.");
727+
}
723728
}
724729

725730
private void createMissingDiseaseConfigurations() {

sormas-backend/src/main/java/de/symeda/sormas/backend/event/EventParticipantFacadeEjb.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,13 @@ public void deleteEventParticipant(EventParticipantReferenceDto eventParticipant
199199
eventParticipantService.delete(eventParticipant);
200200
}
201201

202+
@Override
203+
public EventParticipantDto getByUuid(String uuid) {
204+
return convertToDto(
205+
eventParticipantService.getByUuid(uuid),
206+
Pseudonymizer.getDefault(userService::hasRight, I18nProperties.getCaption(Captions.inaccessibleValue)));
207+
}
208+
202209
@Override
203210
public List<EventParticipantIndexDto> getIndexList(
204211
EventParticipantCriteria eventParticipantCriteria,
@@ -453,6 +460,18 @@ public boolean isEventParticipantEditAllowed(String uuid) {
453460
return eventParticipantJurisdictionChecker.isInJurisdictionOrOwned(eventParticipant);
454461
}
455462

463+
@Override
464+
public EventParticipantDto getFirst(EventParticipantCriteria criteria) {
465+
466+
if (criteria.getEvent() == null) {
467+
return null;
468+
}
469+
470+
return eventParticipantService.getFirst(criteria)
471+
.map(e -> convertToDto(e, Pseudonymizer.getDefault(userService::hasRight, I18nProperties.getCaption(Captions.inaccessibleValue))))
472+
.orElse(null);
473+
}
474+
456475
public EventParticipant fromDto(@NotNull EventParticipantDto source) {
457476

458477
EventParticipant target = eventParticipantService.getByUuid(source.getUuid());

sormas-backend/src/main/java/de/symeda/sormas/backend/event/EventParticipantService.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@
1919

2020
import java.util.Date;
2121
import java.util.List;
22+
import java.util.Optional;
2223

2324
import javax.ejb.EJB;
2425
import javax.ejb.LocalBean;
2526
import javax.ejb.Stateless;
27+
import javax.persistence.NoResultException;
2628
import javax.persistence.criteria.CriteriaBuilder;
2729
import javax.persistence.criteria.CriteriaQuery;
2830
import javax.persistence.criteria.From;
@@ -145,6 +147,9 @@ public Predicate buildCriteriaFilter(EventParticipantCriteria criteria, Criteria
145147
if (criteria.getEvent() != null) {
146148
filter = and(cb, filter, cb.equal(event.get(Event.UUID), criteria.getEvent().getUuid()));
147149
}
150+
if (criteria.getPerson() != null) {
151+
filter = and(cb, filter, cb.equal(person.get(Person.UUID), criteria.getPerson().getUuid()));
152+
}
148153

149154
if (criteria.getFreeText() != null) {
150155
String[] textFilters = criteria.getFreeText().split("\\s+");
@@ -274,4 +279,22 @@ public List<String> getDeletedUuidsSince(Date since, User user) {
274279
public Predicate createDefaultFilter(CriteriaBuilder cb, Root<EventParticipant> root) {
275280
return cb.isFalse(root.get(EventParticipant.DELETED));
276281
}
282+
283+
public Optional<EventParticipant> getFirst(EventParticipantCriteria criteria) {
284+
285+
CriteriaBuilder cb = em.getCriteriaBuilder();
286+
CriteriaQuery<EventParticipant> cq = cb.createQuery(EventParticipant.class);
287+
Root<EventParticipant> eventParticipant = cq.from(EventParticipant.class);
288+
289+
Predicate filter = buildCriteriaFilter(criteria, cb, eventParticipant);
290+
cq.where(filter);
291+
cq.orderBy(cb.asc(eventParticipant.get(EventParticipant.UUID)));
292+
293+
try {
294+
return Optional.of(em.createQuery(cq).setFirstResult(0).setMaxResults(1).getSingleResult());
295+
} catch (NoResultException e) {
296+
return Optional.empty();
297+
}
298+
}
299+
277300
}

0 commit comments

Comments
 (0)