-
Notifications
You must be signed in to change notification settings - Fork 96
BAH-3847: Appointments: Add REST support for 'fulfilling encounters' #168
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,7 @@ public class AppointmentRequest { | |
| private String comments; | ||
| private List<AppointmentProviderDetail> providers = new ArrayList<>(); | ||
| private String priority; | ||
| private String[] fulfillingEncounters = new String[0]; | ||
|
|
||
| public String getAppointmentNumber() { | ||
| return appointmentNumber; | ||
|
|
@@ -144,4 +145,12 @@ public Date getDateAppointmentScheduled() { | |
| public void setDateAppointmentScheduled(Date dateAppointmentScheduled) { | ||
| this.dateAppointmentScheduled = dateAppointmentScheduled; | ||
| } | ||
|
|
||
| public String[] getFulfillingEncounters() { | ||
| return fulfillingEncounters; | ||
| } | ||
|
|
||
| public void setFulfillingEncounters(String[] fulfillingEncounters) { | ||
| this.fulfillingEncounters = fulfillingEncounters; | ||
| } | ||
|
Comment on lines
+149
to
+155
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same applies to this block |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,9 +3,11 @@ | |
| import org.apache.commons.lang.StringUtils; | ||
| import org.apache.commons.logging.Log; | ||
| import org.apache.commons.logging.LogFactory; | ||
| import org.openmrs.Encounter; | ||
| import org.openmrs.Location; | ||
| import org.openmrs.Patient; | ||
| import org.openmrs.Provider; | ||
| import org.openmrs.api.EncounterService; | ||
| import org.openmrs.api.LocationService; | ||
| import org.openmrs.api.PatientService; | ||
| import org.openmrs.api.ProviderService; | ||
|
|
@@ -30,11 +32,13 @@ | |
| import org.springframework.stereotype.Component; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.Arrays; | ||
| import java.util.Date; | ||
| import java.util.HashMap; | ||
| import java.util.HashSet; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.Objects; | ||
| import java.util.Set; | ||
| import java.util.stream.Collectors; | ||
| import java.util.stream.Stream; | ||
|
|
@@ -59,6 +63,9 @@ public class AppointmentMapper { | |
| @Autowired | ||
| AppointmentsService appointmentsService; | ||
|
|
||
| @Autowired | ||
| EncounterService encounterService; | ||
|
|
||
| @Autowired(required = false) | ||
| AppointmentResponseExtension appointmentResponseExtension; | ||
|
|
||
|
|
@@ -118,6 +125,15 @@ public void mapAppointmentRequestToAppointment(AppointmentRequest appointmentReq | |
| if (appointmentRequest.getPriority() != null || StringUtils.isNotBlank(appointmentRequest.getPriority())) { | ||
| appointment.setPriority(AppointmentPriority.valueOf(appointmentRequest.getPriority())); | ||
| } | ||
|
|
||
| if (appointmentRequest.getFulfillingEncounters().length > 0){ | ||
| Set<Encounter> fulfillingEncounters = Arrays.stream(appointmentRequest.getFulfillingEncounters()) | ||
| .map(encounterService::getEncounterByUuid) | ||
| .filter(Objects::nonNull) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there any way we can throw an error (or at least a warning) if an encounter is not found for uuid? This seems like something that shouldn't just fail silently. |
||
| .collect(Collectors.toSet()); | ||
|
|
||
| appointment.setFulfillingEncounters(fulfillingEncounters); | ||
| } | ||
| mapProvidersForAppointment(appointment, appointmentRequest.getProviders()); | ||
| } | ||
|
|
||
|
|
@@ -239,6 +255,9 @@ private AppointmentDefaultResponse mapToDefaultResponse(Appointment a, Appointme | |
| response.getExtensions().put("notificationResults", collect); | ||
| } | ||
| } | ||
| if(a.getFulfillingEncounters() != null && !a.getFulfillingEncounters().isEmpty()) { | ||
| response.setFulfillingEncounters(a.getFulfillingEncounters().stream().map(Encounter::getUuid).toArray(String[]::new)); | ||
| } | ||
| return response; | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This indentation seems to be off
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think our general standard is to use a List instead of an Array (ie List), is there a reason you use an Array here?