-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDoctorsOfficePresenter.java
71 lines (54 loc) · 2.28 KB
/
DoctorsOfficePresenter.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package com.clinicpatientqueueexample.doctorsoffice;
import com.clinicpatientqueueexample.common.PrincipalService;
import com.clinicpatientqueueexample.common.ViewNavigator;
import com.clinicpatientqueueexample.common.ViewNotification;
import com.clinicpatientqueueexample.messaging.MessageSenderBean;
import com.clinicpatientqueueexample.patients.Patient;
import com.clinicpatientqueueexample.patients.Registration;
import com.clinicpatientqueueexample.patients.RegistrationService;
import com.clinicpatientqueueexample.patients.RegistrationStatus;
import javax.ejb.EJB;
import javax.enterprise.context.Dependent;
import javax.inject.Inject;
import java.util.List;
import static com.clinicpatientqueueexample.infoscreen.InfoscreenPresenter.INFOSCREEN_ID;
@Dependent
public class DoctorsOfficePresenter {
@EJB
private MessageSenderBean messageSenderBean;
@Inject
private PrincipalService principalService;
@Inject
private RegistrationService registrationService;
@Inject
private UserSessionContext sessionContext;
@Inject
private ViewNavigator navigator;
@Inject
private ViewNotification notification;
public void logout() {
principalService.logout();
navigator.navigateTo(LoginView.VIEW_NAME);
// TODO: invalidate VaadinSessionScoped data properly, a la VaadinSession.getCurrent().close()
sessionContext.setDoctor(null);
}
public List<Registration> getDoctorsRegistrations() {
return registrationService.findByDoctor(sessionContext.getDoctor());
}
public void callInPatient(Registration registration) {
registration.setStatus(RegistrationStatus.CALLED_IN);
final Patient patient = registration.getPatient();
// would filter messages by infoscreen/doctor association in a real system
messageSenderBean.sendCallInMessage(INFOSCREEN_ID + ": Doctor #" + getDoctorID() + " calling in patient #" + patient.getId());
notification.showMessage("Calling in patient " + patient.getName());
}
public String getDoctorName() {
return sessionContext.getDoctor().getName();
}
public String getDoctorOffice() {
return sessionContext.getDoctor().getOffice();
}
public String getDoctorID() {
return sessionContext.getDoctor().getId();
}
}