Search in sources :

Example 1 with AppointmentService

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);
        }
    }
}
Also used : Appointment(org.openmrs.module.appointmentscheduling.Appointment) AdtService(org.openmrs.module.emrapi.adt.AdtService) Date(java.util.Date) DateTime(org.joda.time.DateTime) AppointmentService(org.openmrs.module.appointmentscheduling.api.AppointmentService)

Example 2 with AppointmentService

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);
        }
    }
}
Also used : Appointment(org.openmrs.module.appointmentscheduling.Appointment) AdtService(org.openmrs.module.emrapi.adt.AdtService) Date(java.util.Date) DateTime(org.joda.time.DateTime) AppointmentService(org.openmrs.module.appointmentscheduling.api.AppointmentService)

Aggregations

Date (java.util.Date)2 DateTime (org.joda.time.DateTime)2 Appointment (org.openmrs.module.appointmentscheduling.Appointment)2 AppointmentService (org.openmrs.module.appointmentscheduling.api.AppointmentService)2 AdtService (org.openmrs.module.emrapi.adt.AdtService)2