use of org.openmrs.module.appointmentscheduling.api.AppointmentService in project openmrs-module-pihcore by PIH.
the class MarkAppointmentsAsMissedOrCompletedTask method run.
@Override
public void run() {
log.info("Executing " + getClass());
AppointmentService appointmentService = Context.getService(AppointmentService.class);
AdtService adtService = Context.getService(AdtService.class);
Date endOfYesterday = new DateTime().withTime(23, 59, 59, 999).minusDays(1).toDate();
for (Appointment appointment : appointmentService.getAppointmentsByConstraints(null, endOfYesterday, null, null, null, null, Appointment.AppointmentStatus.getAppointmentsStatusByTypes(Arrays.asList(Appointment.AppointmentStatusType.SCHEDULED)))) {
appointment.setStatus(Appointment.AppointmentStatus.MISSED);
appointmentService.saveAppointment(appointment);
}
for (Appointment appointment : appointmentService.getAppointmentsByConstraints(null, endOfYesterday, null, null, null, null, Appointment.AppointmentStatus.getAppointmentsStatusByTypes(Arrays.asList(Appointment.AppointmentStatusType.ACTIVE)))) {
if (appointment.getVisit() != null && adtService.wrap(appointment.getVisit()).hasVisitNoteAtLocation(appointment.getTimeSlot().getAppointmentBlock().getLocation())) {
appointment.setStatus(Appointment.AppointmentStatus.COMPLETED);
appointmentService.saveAppointment(appointment);
}
}
}
use of org.openmrs.module.appointmentscheduling.api.AppointmentService in project openmrs-module-mirebalais by PIH.
the class MarkAppointmentsAsMissedOrCompletedTask method execute.
@Override
public void execute() {
AppointmentService appointmentService = Context.getService(AppointmentService.class);
AdtService adtService = Context.getService(AdtService.class);
Date endOfYesterday = new DateTime().withTime(23, 59, 59, 999).minusDays(1).toDate();
for (Appointment appointment : appointmentService.getAppointmentsByConstraints(null, endOfYesterday, null, null, null, null, Appointment.AppointmentStatus.getAppointmentsStatusByTypes(Arrays.asList(Appointment.AppointmentStatusType.SCHEDULED)))) {
appointment.setStatus(Appointment.AppointmentStatus.MISSED);
appointmentService.saveAppointment(appointment);
}
for (Appointment appointment : appointmentService.getAppointmentsByConstraints(null, endOfYesterday, null, null, null, null, Appointment.AppointmentStatus.getAppointmentsStatusByTypes(Arrays.asList(Appointment.AppointmentStatusType.ACTIVE)))) {
if (appointment.getVisit() != null && adtService.wrap(appointment.getVisit()).hasVisitNoteAtLocation(appointment.getTimeSlot().getAppointmentBlock().getLocation())) {
appointment.setStatus(Appointment.AppointmentStatus.COMPLETED);
appointmentService.saveAppointment(appointment);
}
}
}
Aggregations