Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ap 84 - Add "age", "gender" and "patient identifiers" to Patient map #91

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -170,14 +171,12 @@ public AppointmentProviderResponse mapProviderResponse(String response) {


private AppointmentServiceType getServiceTypeByUuid(Set<AppointmentServiceType> 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()));
Expand All @@ -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());
Expand Down Expand Up @@ -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())));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does it put in the map?
From the code - seems the key is the "identifier type" and value is the identifier.
Also from the replaceall expression, this seems very specific to your requirements.

Also note, you are using "PatientIdentifierType.toString()" - which is just sending back "identifier" value - this will result in something like "HID101" : "HID101". I am not sure I understand the requirement.

This should not be so, if you want all identifiers, then I prefer you sending as a top level attribute to the patient map object .. maybe call "identifiers" (as we are already sending the primary identifier through patient.identifier).
If you do not require that in the map, kindly remove this line.

return map;
}

Expand Down