Skip to content

Commit

Permalink
Sukreet | BAH-947 | accepting provider uuid as a part of appointments…
Browse files Browse the repository at this point in the history
… search request. (Bahmni#19)
  • Loading branch information
sukreet authored and mddubey committed Dec 3, 2019
1 parent c1d35e0 commit 19d6d82
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,19 @@ public List<Appointment> search(AppointmentSearchRequest appointmentSearchReques
setDateCriteria(appointmentSearchRequest, criteria);
setPatientCriteria(appointmentSearchRequest, criteria);
setLimitCriteria(appointmentSearchRequest, criteria);
setProviderCriteria(appointmentSearchRequest, criteria);

return criteria.list();
}

private void setProviderCriteria(AppointmentSearchRequest appointmentSearchRequest, Criteria criteria) {
if (StringUtils.isNotEmpty(appointmentSearchRequest.getProviderUuid())) {
criteria.createAlias("providers", "providers");
criteria.createAlias("providers.provider", "provider");
criteria.add(Restrictions.eq("provider.uuid", appointmentSearchRequest.getProviderUuid()));
}
}

private void setPatientCriteria(AppointmentSearchRequest appointmentSearchRequest, Criteria criteria) {
if (StringUtils.isNotEmpty(appointmentSearchRequest.getPatientUuid())) {
criteria.createAlias("patient", "patient");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public class AppointmentSearchRequest {
private Date startDate;
private Date endDate;
private String patientUuid;
private String providerUuid;
private int limit;

public Date getStartDate() {
Expand Down Expand Up @@ -40,4 +41,12 @@ public int getLimit() {
public void setLimit(int limit) {
this.limit = limit;
}

public String getProviderUuid() {
return providerUuid;
}

public void setProviderUuid(String providerUuid) {
this.providerUuid = providerUuid;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,16 @@ public void shouldReturnAppointmentsForPatientBetweenGivenDates() throws ParseEx
assertEquals(1, appointments.size());
}

@Test
public void shouldReturnAppointmentsForProvider() {
AppointmentSearchRequest appointmentSearchRequest = new AppointmentSearchRequest();
appointmentSearchRequest.setProviderUuid("2d15071d-439d-44e8-9825-aa8e1a30d2a2");

List<Appointment> appointments = appointmentDao.search(appointmentSearchRequest);

assertEquals(1, appointments.size());
}

@Test
public void shouldReturnAllAppointmentsInNoGivenDates() throws ParseException {
AppointmentSearchRequest appointmentSearchRequest = new AppointmentSearchRequest();
Expand Down
5 changes: 4 additions & 1 deletion api/src/test/resources/appointmentTestData.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,12 @@
end_date_time="2108-08-11 13:00:00.0" status="Scheduled" creator="1" date_created="2108-07-10 15:57:09.0"
voided="false" void_reason="" uuid="c36006e5-9fbb-4f20-866b-0ece245615a8"/>

<patient_appointment_provider patient_appointment_provider_id="2" provider_id="2221" patient_appointment_id="14" response="ACCEPTED"
comments="visit as scheduled" date_created="2005-09-22 00:00:00.0" creator="1"
voided="false" void_reason="" uuid="f716177b-82ca-49e7-8394-cfe7c8d21f81" />

<patient_appointment patient_appointment_id="15" patient_id ="2" appointment_service_type_id="1" start_date_time="2108-08-08 13:00:00.0"
end_date_time="2108-08-08 14:00:00.0" status="Scheduled" creator="1" date_created="2108-07-11 15:57:09.0"
voided="false" void_reason="" uuid="c36006e5-9fbb-4f20-866b-0ece236715a8"/>


</dataset>
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ public void shouldSearchAppointmentsGivenDateRange() throws Exception {
assertEquals(4, response.size());
}

@Test
public void shouldSearchAcceptProviderUuidToSearchAppointments() throws Exception {
String requestBodyJson = "{\"startDate\":\"2108-08-13T18:30:00.000Z\"," +
"\"providerUuid\":\"provider-uuid\"}";

MockHttpServletResponse httpResponse = handle(newPostRequest("/rest/v1/appointments/search", requestBodyJson));

assertEquals(200, httpResponse.getStatus());
}

@Test
public void should_changeAppointmentStatusWithDate() throws Exception {
String onDate = "2108-08-22T10:30:00.0Z";
Expand Down

0 comments on commit 19d6d82

Please sign in to comment.