From 64fc4db7a65159fc428b1b3daa3add1b1e1dac7e Mon Sep 17 00:00:00 2001 From: ojwanganto Date: Tue, 4 Jun 2024 20:26:26 +0300 Subject: [PATCH] fix failing test on appointment search due to default value for dateAppointmentScheduled --- .../org/openmrs/module/appointments/model/Appointment.java | 2 +- .../module/appointments/web/mapper/AppointmentMapper.java | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/api/src/main/java/org/openmrs/module/appointments/model/Appointment.java b/api/src/main/java/org/openmrs/module/appointments/model/Appointment.java index 1684d54e..a92c9066 100644 --- a/api/src/main/java/org/openmrs/module/appointments/model/Appointment.java +++ b/api/src/main/java/org/openmrs/module/appointments/model/Appointment.java @@ -28,7 +28,7 @@ public class Appointment extends BaseOpenmrsData implements Serializable { * This property is useful for documenting the visit when the patient booked the appointment or when the patient called to book the appointment * NOTE: This is *not* the date the appointment is scheduled to take place. We use startDateTime for this */ - private Date dateAppointmentScheduled = new Date(); + private Date dateAppointmentScheduled; private Patient patient; private AppointmentServiceDefinition service; private AppointmentServiceType serviceType; diff --git a/omod/src/main/java/org/openmrs/module/appointments/web/mapper/AppointmentMapper.java b/omod/src/main/java/org/openmrs/module/appointments/web/mapper/AppointmentMapper.java index 6068b2d1..e1450b7e 100644 --- a/omod/src/main/java/org/openmrs/module/appointments/web/mapper/AppointmentMapper.java +++ b/omod/src/main/java/org/openmrs/module/appointments/web/mapper/AppointmentMapper.java @@ -30,6 +30,7 @@ import org.springframework.stereotype.Component; import java.util.ArrayList; +import java.util.Date; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -103,6 +104,8 @@ public void mapAppointmentRequestToAppointment(AppointmentRequest appointmentReq if (appointmentRequest.getDateAppointmentScheduled() != null) { appointment.setDateAppointmentScheduled(appointmentRequest.getDateAppointmentScheduled()); + } else { + appointment.setDateAppointmentScheduled(new Date()); } appointment.setServiceType(appointmentServiceType); appointment.setService(appointmentServiceDefinition);