jecihjoy
(Jacinta Gichuhi)
May 21, 2019, 6:15am
1
The desired functionality is the ability to save appointments for walk in patients with appointments status as WALKIN, however as at now that’s not possible because this line resets the appointments status back to SCHEDULED during creation of the appointment
// appointment type == null
ValidateUtil.validate(appointment);
if (!allowOverbook) {
if (getTimeLeftInTimeSlot(appointment.getTimeSlot()) < appointment
.getAppointmentType().getDuration()) {
throw new TimeSlotFullException();
}
}
appointment.setStatus(AppointmentStatus.SCHEDULED);
return Context.getService(AppointmentService.class).saveAppointment(
appointment);
}
private List<AppointmentBlock> getAppointmentBlockList(Location location,
Date date, List<AppointmentType> appointmentTypes) {
return getAppointmentBlocksByTypes(setDateToStartOfDay(date),
setDateToEndOfDay(date), location.getId().toString(), null,
appointmentTypes);
}
However for module UI users, the line above has been overridden by this
AppointmentService appointmentService = Context.getService(AppointmentService.class);
if (request.getParameter("save") != null) {
new AppointmentValidator().validate(appointment, result);
if (result.hasErrors())
return null;
else {
appointment.setDateCreated(new Date());
if (flow != null) {
appointment.setStatus(AppointmentStatus.WALKIN);
//Start a new visit
String visitTypeIdString = Context.getAdministrationService().getGlobalProperty(
AppointmentUtils.GP_DEFAULT_VISIT_TYPE);
Integer visitTypeId = Integer.parseInt(visitTypeIdString);
VisitType defaultVisitType = Context.getVisitService().getVisitType(visitTypeId);
Visit visit = new Visit(appointment.getPatient(), defaultVisitType, new Date());
visit.setLocation(appointment.getTimeSlot().getAppointmentBlock().getLocation());
visit = Context.getVisitService().saveVisit(visit);
appointment.setVisit(visit);
hence I suppose they are able to create an appointment for walkin patients with status WALKIN
Should I fix this by removing the line above or is there another work around that will enable me to save appointments with appointment status as WALKIN?
@mseaton @dkayiwa @mogoodrich
@jecihjoy oh, interesting!
I would change line 1153 so that it sets the status to SCHEDULE only if appointment.getStatus() == null
Will that work for you use case?
Take care,
Mark