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

Commit 229f7d2

Browse files
SORMAS-Foundation#3488: finished process for new or existing case with new sample
1 parent c3ee30c commit 229f7d2

4 files changed

Lines changed: 77 additions & 28 deletions

File tree

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

Lines changed: 48 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ protected Component initContent() {
8888

8989
private void addCreateEntityRadioGroup() {
9090
rbCreateEntity = new RadioButtonGroup<>();
91-
rbCreateEntity.setItems(CREATE_CASE, CREATE_CONTACT, CREATE_EVENT_PARTICIPANT);
91+
// TODO: Add creation of contacts and event participants
92+
// rbCreateEntity.setItems(CREATE_CASE, CREATE_CONTACT, CREATE_EVENT_PARTICIPANT);
93+
rbCreateEntity.setItems(CREATE_CASE);
9294
rbCreateEntity.setItemCaptionGenerator((item) -> {
9395
if (item == CREATE_CASE) {
9496
return I18nProperties.getCaption(Captions.caseCreateNew);
@@ -137,13 +139,18 @@ private void addEventParticipantGrid() {
137139
eventParticipantGrid.addSelectionListener(e -> {
138140
if (e.getSelected().size() > 0) {
139141
rbCreateEntity.setValue(null);
140-
rbSelectCase.setValue(null);
141-
rbSelectContact.setValue(null);
142+
if (rbSelectCase != null) {
143+
rbSelectCase.setValue(null);
144+
}
145+
if (rbSelectContact != null) {
146+
rbSelectContact.setValue(null);
147+
}
142148
}
143149
if (selectionChangeCallback != null) {
144150
selectionChangeCallback.accept(!e.getSelected().isEmpty());
145151
}
146152
});
153+
eventParticipantGrid.setEnabled(false);
147154
mainLayout.addComponent(eventParticipantGrid);
148155
}
149156

@@ -158,6 +165,12 @@ private void addSelectEventParticipantRadioGroup() {
158165
rbSelectCase.setValue(null);
159166
rbSelectContact.setValue(null);
160167
eventParticipantGrid.setEnabled(true);
168+
if (caseGrid != null) {
169+
caseGrid.setEnabled(false);
170+
}
171+
if (contactGrid != null) {
172+
contactGrid.setEnabled(false);
173+
}
161174
if (selectionChangeCallback != null) {
162175
selectionChangeCallback.accept(eventParticipantGrid.getSelectedRow() != null);
163176
}
@@ -172,13 +185,18 @@ private void addContactGrid() {
172185
contactGrid.addSelectionListener(e -> {
173186
if (e.getSelected().size() > 0) {
174187
rbCreateEntity.setValue(null);
175-
rbSelectCase.setValue(null);
176-
rbSelectEventParticipant.setValue(null);
188+
if (rbSelectCase != null) {
189+
rbSelectCase.setValue(null);
190+
}
191+
if (rbSelectEventParticipant != null) {
192+
rbSelectEventParticipant.setValue(null);
193+
}
177194
}
178195
if (selectionChangeCallback != null) {
179196
selectionChangeCallback.accept(!e.getSelected().isEmpty());
180197
}
181198
});
199+
contactGrid.setEnabled(false);
182200
mainLayout.addComponent(contactGrid);
183201
}
184202

@@ -193,6 +211,12 @@ private void addSelectContactRadioGroup() {
193211
rbSelectCase.setValue(null);
194212
rbSelectEventParticipant.setValue(null);
195213
contactGrid.setEnabled(true);
214+
if (caseGrid != null) {
215+
caseGrid.setEnabled(false);
216+
}
217+
if (eventParticipantGrid != null) {
218+
eventParticipantGrid.setEnabled(false);
219+
}
196220
if (selectionChangeCallback != null) {
197221
selectionChangeCallback.accept(contactGrid.getSelectedRow() != null);
198222
}
@@ -207,13 +231,18 @@ private void addCaseGrid() {
207231
caseGrid.addSelectionListener(e -> {
208232
if (e.getSelected().size() > 0) {
209233
rbCreateEntity.setValue(null);
210-
rbSelectContact.setValue(null);
211-
rbSelectEventParticipant.setValue(null);
234+
if (rbSelectContact != null) {
235+
rbSelectContact.setValue(null);
236+
}
237+
if (rbSelectEventParticipant != null) {
238+
rbSelectEventParticipant.setValue(null);
239+
}
212240
}
213241
if (selectionChangeCallback != null) {
214242
selectionChangeCallback.accept(!e.getSelected().isEmpty());
215243
}
216244
});
245+
caseGrid.setEnabled(false);
217246
mainLayout.addComponent(caseGrid);
218247
}
219248

@@ -225,9 +254,19 @@ private void addSelectCaseRadioGroup() {
225254
rbSelectCase.addValueChangeListener(e -> {
226255
if (e.getValue() != null) {
227256
rbCreateEntity.setValue(null);
228-
rbSelectContact.setValue(null);
229-
rbSelectEventParticipant.setValue(null);
257+
if (rbSelectContact != null) {
258+
rbSelectContact.setValue(null);
259+
}
260+
if (rbSelectEventParticipant != null) {
261+
rbSelectEventParticipant.setValue(null);
262+
}
230263
caseGrid.setEnabled(true);
264+
if (contactGrid != null) {
265+
contactGrid.setEnabled(false);
266+
}
267+
if (eventParticipantGrid != null) {
268+
eventParticipantGrid.setEnabled(false);
269+
}
231270
if (selectionChangeCallback != null) {
232271
selectionChangeCallback.accept(caseGrid.getSelectedRow() != null);
233272
}

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

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,10 @@
1212
import de.symeda.sormas.api.caze.CaseDataDto;
1313
import de.symeda.sormas.api.caze.CaseIndexDto;
1414
import de.symeda.sormas.api.caze.CaseSimilarityCriteria;
15-
import de.symeda.sormas.api.contact.ContactSimilarityCriteria;
1615
import de.symeda.sormas.api.contact.SimilarContactDto;
1716
import de.symeda.sormas.api.event.SimilarEventParticipantDto;
1817
import de.symeda.sormas.api.i18n.I18nProperties;
1918
import de.symeda.sormas.api.i18n.Strings;
20-
import de.symeda.sormas.api.labmessage.EventParticipantSimilarityCriteria;
2119
import de.symeda.sormas.api.labmessage.LabMessageDto;
2220
import de.symeda.sormas.api.labmessage.SimilarEntriesDto;
2321
import de.symeda.sormas.api.person.PersonDto;
@@ -78,18 +76,20 @@ public void process(String uuid) {
7876
caseSimilarityCriteria.personUuid(selectedPerson.getUuid());
7977
List<CaseIndexDto> similarCases = FacadeProvider.getCaseFacade().getSimilarCases(caseSimilarityCriteria);
8078

81-
ContactSimilarityCriteria contactSimilarityCriteria = new ContactSimilarityCriteria();
82-
contactSimilarityCriteria.setPerson(selectedPerson);
83-
contactSimilarityCriteria.setDisease(labMessageDto.getTestedDisease());
84-
List<SimilarContactDto> similarContacts = FacadeProvider.getContactFacade().getMatchingContacts(contactSimilarityCriteria);
85-
86-
EventParticipantSimilarityCriteria eventParticipantSimilarityCriteria = new EventParticipantSimilarityCriteria();
87-
eventParticipantSimilarityCriteria.setPerson(selectedPerson);
88-
eventParticipantSimilarityCriteria.setDisease(labMessageDto.getTestedDisease());
89-
List<SimilarEventParticipantDto> similarEventParticipants =
90-
FacadeProvider.getEventParticipantFacade().getSimilarEventParticipants(eventParticipantSimilarityCriteria);
91-
92-
pickOrCreateEntry(labMessageDto, similarCases, similarContacts, similarEventParticipants);
79+
// TODO: Add picking of contacts and event participants
80+
// ContactSimilarityCriteria contactSimilarityCriteria = new ContactSimilarityCriteria();
81+
// contactSimilarityCriteria.setPerson(selectedPerson);
82+
// contactSimilarityCriteria.setDisease(labMessageDto.getTestedDisease());
83+
// List<SimilarContactDto> similarContacts = FacadeProvider.getContactFacade().getMatchingContacts(contactSimilarityCriteria);
84+
//
85+
// EventParticipantSimilarityCriteria eventParticipantSimilarityCriteria = new EventParticipantSimilarityCriteria();
86+
// eventParticipantSimilarityCriteria.setPerson(selectedPerson);
87+
// eventParticipantSimilarityCriteria.setDisease(labMessageDto.getTestedDisease());
88+
// List<SimilarEventParticipantDto> similarEventParticipants =
89+
// FacadeProvider.getEventParticipantFacade().getSimilarEventParticipants(eventParticipantSimilarityCriteria);
90+
//
91+
// pickOrCreateEntry(labMessageDto, similarCases, similarContacts, similarEventParticipants);
92+
pickOrCreateEntry(labMessageDto, similarCases, null, null);
9393
}
9494
});
9595
}
@@ -106,6 +106,8 @@ private void pickOrCreateEntry(
106106
SimilarEntriesDto similarEntriesDto = selectField.getValue();
107107
if (similarEntriesDto.isNewCase()) {
108108
createCase(labMessageDto);
109+
} else if (similarEntriesDto.getCaze() != null) {
110+
createSample(FacadeProvider.getCaseFacade().getCaseDataByUuid(similarEntriesDto.getCaze().getUuid()), labMessageDto);
109111
}
110112
});
111113

@@ -126,6 +128,7 @@ private void createCase(LabMessageDto labMessageDto) {
126128
createSample(caseCreateComponent.getWrappedComponent().getValue(), labMessageDto);
127129
window.close();
128130
});
131+
caseCreateComponent.addDiscardListener(() -> window.close());
129132

130133
PersonDto personDto = PersonDto.build();
131134
personDto.setFirstName(labMessageDto.getPersonFirstName());
@@ -172,6 +175,7 @@ private void createSample(CaseDataDto caseDataDto, LabMessageDto labMessageDto)
172175
sampleCreateComponent.addCommitListener(() -> {
173176
createPathogenTest(sampleCreateComponent.getWrappedComponent().getValue(), labMessageDto);
174177
});
178+
sampleCreateComponent.addDiscardListener(() -> window.close());
175179

176180
LabMessageEditForm form = new LabMessageEditForm(true);
177181
form.setValue(labMessageDto);
@@ -197,6 +201,7 @@ private void createPathogenTest(SampleDto sampleDto, LabMessageDto labMessageDto
197201
window.close();
198202
}, null);
199203

204+
pathogenTestCreateComponent.addDiscardListener(() -> window.close());
200205
pathogenTestCreateComponent.getWrappedComponent().setValue(pathogenTestDto);
201206

202207
LabMessageEditForm form = new LabMessageEditForm(true);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public LabMessageGrid(LabMessageCriteria criteria) {
5555

5656
addShowColumn(e -> ControllerProvider.getLabMessageController().show(e.getUuid()));
5757

58-
addComponentColumn(indexDto -> ButtonHelper.createButton(Captions.labMessageProcess, e -> {
58+
addComponentColumn(indexDto -> indexDto.isProcessed() ? null : ButtonHelper.createButton(Captions.labMessageProcess, e -> {
5959
ControllerProvider.getLabMessageController().process(indexDto.getUuid());
6060
}, ValoTheme.BUTTON_PRIMARY)).setId(COLUMN_PROCESS);
6161

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public LabMessagesGridComponent(Label viewTitleLabel, LabMessagesView labMessage
4848
gridLayout = new VerticalLayout();
4949
gridLayout.addComponent(createProcessStatusFilterBar());
5050
gridLayout.addComponent(grid);
51-
grid.getDataProvider().addDataProviderListener(e -> updateProcessedButtons());
51+
grid.getDataProvider().addDataProviderListener(e -> updateStatusButtons());
5252

5353
gridLayout.setMargin(true);
5454
styleGridLayout(gridLayout);
@@ -87,7 +87,7 @@ public void reload(ViewChangeListener.ViewChangeEvent event) {
8787
params = params.substring(1);
8888
criteria.fromUrlParams(params);
8989
}
90-
updateProcessedButtons();
90+
updateStatusButtons();
9191
grid.reload();
9292
}
9393

@@ -105,7 +105,7 @@ private Button createAndAddProcessedButton(String captionKey, Boolean processed,
105105
return button;
106106
}
107107

108-
private void updateProcessedButtons() {
108+
private void updateStatusButtons() {
109109
statusButtons.keySet().forEach(b -> {
110110
CssStyles.style(b, CssStyles.BUTTON_FILTER_LIGHT);
111111
b.setCaption(statusButtons.get(b));
@@ -119,13 +119,18 @@ private void updateProcessedButtons() {
119119
activeStatusButton
120120
.setCaption(statusButtons.get(activeStatusButton) + LayoutUtil.spanCss(CssStyles.BADGE, String.valueOf(grid.getItemCount())));
121121
}
122+
if (Boolean.TRUE.equals(activeStatusButton.getData())) {
123+
grid.getColumn(LabMessageGrid.COLUMN_PROCESS).setHidden(true);
124+
} else {
125+
grid.getColumn(LabMessageGrid.COLUMN_PROCESS).setHidden(false);
126+
}
122127
}
123128

124129
public void updateFilterComponents() {
125130
// TODO replace with Vaadin 8 databinding
126131
labMessagesView.setApplyingCriteria(true);
127132

128-
updateProcessedButtons();
133+
updateStatusButtons();
129134

130135
labMessagesView.setApplyingCriteria(false);
131136
}

0 commit comments

Comments
 (0)