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 2d0761d2a..75f31c9e8 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 @@ -32,6 +32,7 @@ import java.util.Map; import java.util.Set; import java.util.stream.Collectors; +import java.util.stream.Stream; @Component public class AppointmentMapper { @@ -90,7 +91,7 @@ public void mapAppointmentRequestToAppointment(AppointmentRequest appointmentReq if (appointmentRequest.getServiceTypeUuid() != null) { appointmentServiceType = getServiceTypeByUuid(appointmentServiceDefinition.getServiceTypes(true), appointmentRequest.getServiceTypeUuid()); } - if (StringUtils.isNotBlank(appointmentRequest.getStatus())){ + if (StringUtils.isNotBlank(appointmentRequest.getStatus())) { appointment.setStatus(AppointmentStatus.valueOf(appointmentRequest.getStatus())); } appointment.setServiceType(appointmentServiceType); @@ -170,14 +171,12 @@ public AppointmentProviderResponse mapProviderResponse(String response) { private AppointmentServiceType getServiceTypeByUuid(Set serviceTypes, String serviceTypeUuid) { - return serviceTypes.stream() - .filter(avb -> avb.getUuid().equals(serviceTypeUuid)).findAny().get(); + return serviceTypes.stream().filter(avb -> avb.getUuid().equals(serviceTypeUuid)).findAny().get(); } public Appointment mapQueryToAppointment(AppointmentQuery searchQuery) { Appointment appointment = new Appointment(); - appointment.setService( - appointmentServiceDefinitionService.getAppointmentServiceByUuid(searchQuery.getServiceUuid())); + appointment.setService(appointmentServiceDefinitionService.getAppointmentServiceByUuid(searchQuery.getServiceUuid())); appointment.setPatient(patientService.getPatientByUuid(searchQuery.getPatientUuid())); appointment.setProvider(identifyAppointmentProvider(searchQuery.getProviderUuid())); appointment.setLocation(identifyAppointmentLocation(searchQuery.getLocationUuid())); @@ -201,8 +200,7 @@ private AppointmentDefaultResponse mapToDefaultResponse(Appointment a, Appointme response.setStatus(a.getStatus().name()); response.setComments(a.getComments()); response.setTeleconsultation(a.getTeleconsultation()); - if (appointmentResponseExtension != null) - response.setAdditionalInfo(appointmentResponseExtension.run(a)); + if (appointmentResponseExtension != null) response.setAdditionalInfo(appointmentResponseExtension.run(a)); response.setProviders(mapAppointmentProviders(a.getProviders())); response.setRecurring(a.isRecurring()); response.setVoided(a.getVoided()); @@ -252,6 +250,9 @@ private Map createPatientMap(Patient p) { map.put("name", p.getPersonName().getFullName()); map.put("uuid", p.getUuid()); map.put("identifier", p.getPatientIdentifier().getIdentifier()); + map.put("age", p.getAge()); + map.put("gender", p.getGender()); + map.putAll(p.getActiveIdentifiers().stream().filter(e -> e.getIdentifierType() != null).collect(Collectors.toMap(e -> e.getIdentifierType().toString().replaceAll("[- ]", ""), e -> e.getIdentifier()))); return map; }