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

Commit 22f7bd1

Browse files
SORMAS-Foundation#3488: intermediate state
1 parent ed585d0 commit 22f7bd1

10 files changed

Lines changed: 128 additions & 23 deletions

File tree

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ public interface Captions {
180180
String caseConfirmCase = "caseConfirmCase";
181181
String caseContacts = "caseContacts";
182182
String caseCreateCase = "caseCreateCase";
183+
String caseCreateNew = "caseCreateNew";
183184
String CaseData = "CaseData";
184185
String CaseData_additionalDetails = "CaseData.additionalDetails";
185186
String CaseData_caseClassification = "CaseData.caseClassification";
@@ -841,6 +842,7 @@ public interface Captions {
841842
String EventParticipant_uuid = "EventParticipant.uuid";
842843
String eventParticipantAddPerson = "eventParticipantAddPerson";
843844
String eventParticipantContactCountOnlyWithSourceCaseInEvent = "eventParticipantContactCountOnlyWithSourceCaseInEvent";
845+
String eventParticipantCreateNew = "eventParticipantCreateNew";
844846
String EventParticipantExport_addressCommunity = "EventParticipantExport.addressCommunity";
845847
String EventParticipantExport_addressDistrict = "EventParticipantExport.addressDistrict";
846848
String EventParticipantExport_addressGpsCoordinates = "EventParticipantExport.addressGpsCoordinates";

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,7 @@ public interface Strings {
464464
String infoContactCreationSourceCase = "infoContactCreationSourceCase";
465465
String infoContactDashboard = "infoContactDashboard";
466466
String infoContactsViewRegionDistrictFilter = "infoContactsViewRegionDistrictFilter";
467+
String infoCreateEntity = "infoCreateEntity";
467468
String infoCreateNewContactDiscardsChanges = "infoCreateNewContactDiscardsChanges";
468469
String infoCreateNewSampleDiscardsChanges = "infoCreateNewSampleDiscardsChanges";
469470
String infoCreateNewSampleDiscardsChangesEventParticipant = "infoCreateNewSampleDiscardsChangesEventParticipant";

sormas-api/src/main/java/de/symeda/sormas/api/labmessage/LabMessageDto.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
public class LabMessageDto extends EntityDto {
1515

16-
public static final String I18N_PREFIX = "Location";
16+
public static final String I18N_PREFIX = "LabMessage";
1717

1818
public static final String MESSAGE_DATE_TIME = "messageDateTime";
1919
public static final String SAMPLE_DATE_TIME = "sampleDateTime";

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ convertContactToCase=Create case from contact with positive test result?
280280
caseSearchSpecificCase=Search specific case
281281
caseSearchCase=Search case
282282
caseSelect= Select case
283+
caseCreateNew=Create new case
283284

284285
CaseData=Case
285286
CaseData.additionalDetails=General comment
@@ -924,6 +925,7 @@ EventAction.actionReplyingUser=Action replying user
924925
eventParticipantAddPerson=Add person
925926
eventParticipantContactCountOnlyWithSourceCaseInEvent=Only counts contacts whose source case is related to this event
926927
eventParticipantSelect=Select event participant
928+
eventParticipantCreateNew=Create new event participant
927929

928930
EventParticipant=Event participant
929931
EventParticipant.contactCount=Contact count

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,7 @@ infoCaseDate = By default, cases are filtered by the most relevant date availabl
502502
infoCaseIncidence = "Case incidence proportion" means the number of cases per 100,000 inhabitants. You can check the map key to see the thresholds that define how the districts are colorized.
503503
infoCaseMap = If cases are shown by home address and there are no GPS coordinates available for it, the coordinates of the location where the case has been reported are used instead.
504504
infoContactDashboard = All Dashboard elements that display general information about contacts use the follow-up period of the respective contact, starting with the contact report date.
505+
infoCreateEntity = The database contains no entity that seems to be similar to the details of the lab message.<br/><br>Select on <i>Create new case</i>, <i>Create new contact</i> or <i>Create new event particiapnt</i> and click on the <i>Save</i> button to create a new entity for the person.<br/><br/>If you are unsure, you can discard this window and cancel the process.
505506
infoDashboardIncidence = Thresholds are calculated using quartiles.
506507
infoDatabaseExportTables = Please select the database tables you want to export.
507508
infoDefineOutbreaks = Click on a button to define which districts of the region currently have an outbreak of a specific disease.

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

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,72 @@ public List<EventParticipantExportDto> getExportList(
489489

490490
@Override
491491
public List<SimilarEventParticipantDto> getSimilarEventParticipants(EventParticipantSimilarityCriteria eventParticipantSimilarityCriteria) {
492-
return null;
492+
// final CriteriaBuilder cb = em.getCriteriaBuilder();
493+
// final CriteriaQuery<SimilarEventParticipantDto> cq = cb.createQuery(SimilarEventParticipantDto.class);
494+
// final Root<EventParticipant> eventParticipantRoot = cq.from(EventParticipant.class);
495+
//
496+
// ContactJoins joins = new ContactJoins(eventParticipantRoot);
497+
//
498+
// cq.multiselect(
499+
// Stream
500+
// .concat(
501+
// Stream.of(
502+
// joins.getPerson().get(Person.FIRST_NAME),
503+
// joins.getPerson().get(Person.LAST_NAME),
504+
// eventParticipantRoot.get(Contact.UUID),
505+
// joins.getCaze().get(Case.UUID),
506+
// joins.getCasePerson().get(Person.FIRST_NAME),
507+
// joins.getCasePerson().get(Person.LAST_NAME),
508+
// eventParticipantRoot.get(Contact.CASE_ID_EXTERNAL_SYSTEM),
509+
// eventParticipantRoot.get(Contact.LAST_CONTACT_DATE),
510+
// eventParticipantRoot.get(Contact.CONTACT_PROXIMITY),
511+
// eventParticipantRoot.get(Contact.CONTACT_CLASSIFICATION),
512+
// eventParticipantRoot.get(Contact.CONTACT_STATUS),
513+
// eventParticipantRoot.get(Contact.FOLLOW_UP_STATUS)),
514+
// listCriteriaBuilder.getJurisdictionSelections(joins))
515+
// .collect(Collectors.toList()));
516+
//
517+
// final Predicate defaultFilter = contactService.createDefaultFilter(cb, eventParticipantRoot);
518+
// final Predicate userFilter = contactService.createUserFilter(cb, cq, eventParticipantRoot);
519+
//
520+
// final PersonReferenceDto person = eventParticipantSimilarityCriteria.getPerson();
521+
// final Predicate samePersonFilter = person != null ? cb.equal(joins.getPerson().get(Person.UUID), person.getUuid()) : null;
522+
//
523+
// final Disease disease = eventParticipantSimilarityCriteria.getDisease();
524+
// final Predicate diseaseFilter = disease != null ? cb.equal(eventParticipantRoot.get(Contact.DISEASE), disease) : null;
525+
//
526+
// final CaseReferenceDto caze = eventParticipantSimilarityCriteria.getCaze();
527+
// final Predicate cazeFilter = caze != null ? cb.equal(joins.getCaze().get(Case.UUID), caze.getUuid()) : null;
528+
//
529+
// final Date reportDate = eventParticipantSimilarityCriteria.getReportDate();
530+
// final Date lastContactDate = eventParticipantSimilarityCriteria.getLastContactDate();
531+
// final Predicate recentContactsFilter = AbstractAdoService.and(
532+
// cb,
533+
// contactService.recentDateFilter(cb, reportDate, eventParticipantRoot.get(Contact.REPORT_DATE_TIME), 30),
534+
// contactService.recentDateFilter(cb, lastContactDate, eventParticipantRoot.get(Contact.LAST_CONTACT_DATE), 30));
535+
//
536+
// cq.where(AbstractAdoService.and(cb, defaultFilter, userFilter, samePersonFilter, diseaseFilter, cazeFilter, recentContactsFilter));
537+
//
538+
// List<SimilarContactDto> contacts = em.createQuery(cq).getResultList();
539+
//
540+
// Pseudonymizer pseudonymizer = Pseudonymizer.getDefault(userService::hasRight);
541+
// pseudonymizer.pseudonymizeDtoCollection(
542+
// SimilarContactDto.class,
543+
// contacts,
544+
// c -> eventParticipantJurisdictionChecker.isInJurisdictionOrOwned(c.getJurisdiction()),
545+
// (c, isInJurisdiction) -> {
546+
// CaseReferenceDto contactCase = c.getCaze();
547+
// if (contactCase != null) {
548+
// pseudonymizer.pseudonymizeDto(
549+
// CaseReferenceDto.class,
550+
// contactCase,
551+
// eventParticipantJurisdictionChecker.isInJurisdictionOrOwned(c.getCaseJurisdiction()),
552+
// null);
553+
// }
554+
// });
555+
//
556+
// return contacts;
557+
return new ArrayList<SimilarEventParticipantDto>();
493558
}
494559

495560
@Override

sormas-backend/src/main/resources/sql/sormas_schema.sql

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6082,11 +6082,7 @@ CREATE TABLE labmessage (
60826082
primary key(id)
60836083
);
60846084

6085-
ALTER TABLE labmessage OWNER TO sormas_user;
60866085
CREATE TABLE labmessage_history (LIKE labmessage);
6087-
CREATE TRIGGER versioning_trigger BEFORE INSERT OR UPDATE OR DELETE ON labmessage
6088-
FOR EACH ROW EXECUTE PROCEDURE versioning('sys_period', 'labmessage_history', true);
6089-
ALTER TABLE labmessage_history OWNER TO sormas_user;
60906086

60916087
INSERT INTO schema_version (version_number, comment) VALUES (291, 'Add LabMessage #3486');
60926088

@@ -6135,4 +6131,11 @@ ALTER TABLE person_history RENAME COLUMN namesofotherguardians TO namesofguardia
61356131

61366132
INSERT INTO schema_version (version_number, comment) VALUES (296, 'Change namesOfOtherGuardians to namesOfGuardians #3413');
61376133

6134+
-- 2020-12-21 Fix labmessage table #3486
6135+
ALTER TABLE labmessage OWNER TO sormas_user;
6136+
CREATE TRIGGER versioning_trigger BEFORE INSERT OR UPDATE OR DELETE ON labmessage
6137+
FOR EACH ROW EXECUTE PROCEDURE versioning('sys_period', 'labmessage_history', true);
6138+
ALTER TABLE labmessage_history OWNER TO sormas_user;
6139+
6140+
INSERT INTO schema_version (version_number, comment) VALUES (297, 'Fix labmessage table #3486');
61386141
-- *** Insert new sql commands BEFORE this line ***

sormas-ui/src/main/java/de/symeda/sormas/ui/events/EventParticipantSelectionGrid.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ public EventParticipantSelectionGrid(List<SimilarEventParticipantDto> eventParti
2222

2323
private void setContainerData(List<SimilarEventParticipantDto> similarEventParticipants) {
2424
getContainer().removeAllItems();
25-
getContainer().addAll(similarEventParticipants);
26-
setHeightByRows(similarEventParticipants.size() > 0 ? (similarEventParticipants.size() <= 10 ? similarEventParticipants.size() : 10) : 1);
25+
if (similarEventParticipants != null) {
26+
getContainer().addAll(similarEventParticipants);
27+
setHeightByRows(similarEventParticipants.size() > 0 ? (similarEventParticipants.size() <= 10 ? similarEventParticipants.size() : 10) : 1);
28+
}
2729
}
2830

2931
private void buildGrid() {

sormas-ui/src/main/java/de/symeda/sormas/ui/labmessage/EntitySelectionField.java

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,18 @@ protected Component initContent() {
6969

7070
addInfoComponent();
7171
addLabMessageComponent();
72-
addSelectCaseRadioGroup();
73-
addCaseGrid();
74-
addSelectContactRadioGroup();
75-
addContactGrid();
76-
addSelectEventParticipantRadioGroup();
77-
addEventParticipantGrid();
72+
if (cases != null && !cases.isEmpty()) {
73+
addSelectCaseRadioGroup();
74+
addCaseGrid();
75+
}
76+
if (contacts != null && !contacts.isEmpty()) {
77+
addSelectContactRadioGroup();
78+
addContactGrid();
79+
}
80+
if (eventParticipants != null && !eventParticipants.isEmpty()) {
81+
addSelectEventParticipantRadioGroup();
82+
addEventParticipantGrid();
83+
}
7884
addCreateEntityRadioGroup();
7985

8086
return mainLayout;
@@ -84,7 +90,14 @@ private void addCreateEntityRadioGroup() {
8490
rbCreateEntity = new RadioButtonGroup<>();
8591
rbCreateEntity.setItems(CREATE_CASE, CREATE_CONTACT, CREATE_EVENT_PARTICIPANT);
8692
rbCreateEntity.setItemCaptionGenerator((item) -> {
87-
return I18nProperties.getCaption(Captions.personCreateNew);
93+
if (item == CREATE_CASE) {
94+
return I18nProperties.getCaption(Captions.caseCreateNew);
95+
} else if (item == CREATE_CONTACT) {
96+
return I18nProperties.getCaption(Captions.contactCreateNew);
97+
} else if (item == CREATE_EVENT_PARTICIPANT) {
98+
return I18nProperties.getCaption(Captions.eventParticipantCreateNew);
99+
}
100+
throw new IllegalArgumentException((String) item);
88101
});
89102
rbCreateEntity.addValueChangeListener(e -> {
90103
if (e.getValue() != null) {
@@ -102,6 +115,7 @@ private void addCreateEntityRadioGroup() {
102115
}
103116
}
104117
});
118+
CssStyles.style(rbCreateEntity, CssStyles.OPTIONGROUP_HORIZONTAL_PRIMARY);
105119

106120
mainLayout.addComponent(rbCreateEntity);
107121
}
@@ -216,21 +230,35 @@ private void addLabMessageComponent() {
216230
labMessageLayout.setSpacing(true);
217231

218232
createAndAddLabel(labMessageDto.getMessageDateTime(), LabMessageDto.MESSAGE_DATE_TIME, labMessageLayout);
219-
220233
createAndAddLabel(labMessageDto.getSampleDateTime(), LabMessageDto.SAMPLE_DATE_TIME, labMessageLayout);
234+
createAndAddLabel(labMessageDto.getPersonFirstName(), LabMessageDto.PERSON_FIRST_NAME, labMessageLayout);
235+
createAndAddLabel(labMessageDto.getPersonLastName(), LabMessageDto.PERSON_LAST_NAME, labMessageLayout);
236+
createAndAddLabel(labMessageDto.getPersonBirthDateDD(), LabMessageDto.PERSON_BIRTH_DATE_DD, labMessageLayout);
237+
createAndAddLabel(labMessageDto.getPersonBirthDateMM(), LabMessageDto.PERSON_BIRTH_DATE_MM, labMessageLayout);
238+
createAndAddLabel(labMessageDto.getPersonBirthDateYYYY(), LabMessageDto.PERSON_BIRTH_DATE_YYYY, labMessageLayout);
239+
createAndAddLabel(labMessageDto.getPersonSex(), LabMessageDto.PERSON_SEX, labMessageLayout);
221240

222241
mainLayout.addComponent(labMessageLayout);
223242
}
224243

225244
private void createAndAddLabel(Object value, String property, HorizontalLayout layout) {
226-
Label label = new Label(value.toString());
245+
Label label = new Label();
246+
if (value != null) {
247+
label.setValue(value.toString());
248+
}
227249
label.setCaption(I18nProperties.getPrefixCaption(LabMessageDto.I18N_PREFIX, property));
228250
label.setWidthUndefined();
229251
layout.addComponent(label);
230252
}
231253

232254
private void addInfoComponent() {
233-
mainLayout.addComponent(VaadinUiUtil.createInfoComponent(I18nProperties.getString(Strings.infoSelectOrCreateEntity)));
255+
if (cases != null && !cases.isEmpty()
256+
|| contacts != null && !contacts.isEmpty()
257+
|| eventParticipants != null && !eventParticipants.isEmpty()) {
258+
mainLayout.addComponent(VaadinUiUtil.createInfoComponent(I18nProperties.getString(Strings.infoSelectOrCreateEntity)));
259+
} else {
260+
mainLayout.addComponent(VaadinUiUtil.createInfoComponent(I18nProperties.getString(Strings.infoCreateEntity)));
261+
}
234262
}
235263

236264
@Override

sormas-ui/src/main/java/de/symeda/sormas/ui/labmessage/LabMessageController.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,12 @@ public void process(String uuid) {
5252
.selectOrCreatePerson(personDto, I18nProperties.getString(Strings.infoSelectOrCreatePersonForLabMessage), selectedPerson -> {
5353
if (selectedPerson != null) {
5454
if (selectedPerson.getUuid().equals(personDto.getUuid())) {
55-
personDto.getAddress().setStreet(labMessageDto.getPersonStreet());
56-
personDto.getAddress().setHouseNumber(labMessageDto.getPersonHouseNumber());
57-
personDto.getAddress().setPostalCode(labMessageDto.getPersonPostalCode());
58-
personDto.getAddress().setCity(labMessageDto.getPersonCity());
59-
FacadeProvider.getPersonFacade().savePerson(personDto);
55+
PersonDto savedPerson = FacadeProvider.getPersonFacade().getPersonByUuid(personDto.getUuid());
56+
savedPerson.getAddress().setStreet(labMessageDto.getPersonStreet());
57+
savedPerson.getAddress().setHouseNumber(labMessageDto.getPersonHouseNumber());
58+
savedPerson.getAddress().setPostalCode(labMessageDto.getPersonPostalCode());
59+
savedPerson.getAddress().setCity(labMessageDto.getPersonCity());
60+
FacadeProvider.getPersonFacade().savePerson(savedPerson);
6061
}
6162

6263
CaseCriteria caseCriteria = new CaseCriteria();

0 commit comments

Comments
 (0)