Skip to content

Commit

Permalink
removed no-longer-used ScheduledAppointmentBlocks
Browse files Browse the repository at this point in the history
  • Loading branch information
mogoodrich committed May 30, 2014
1 parent 3af2dfe commit 7544d6d
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 519 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,8 @@
import org.openmrs.module.appointmentscheduling.AppointmentStatusHistory;
import org.openmrs.module.appointmentscheduling.AppointmentType;
import org.openmrs.module.appointmentscheduling.AppointmentUtils;
import org.openmrs.module.appointmentscheduling.ScheduledAppointmentBlock;
import org.openmrs.module.appointmentscheduling.TimeSlot;
import org.openmrs.module.appointmentscheduling.exception.TimeSlotFullException;
import org.springframework.transaction.annotation.Transactional;

/**
* This service exposes module's core functionality. It is a Spring managed bean
Expand Down Expand Up @@ -850,34 +848,6 @@ public Map<AppointmentType, Integer> getAppointmentTypeDistribution(
@Authorized(AppointmentUtils.PRIV_VIEW_APPOINTMENTS)
List<Appointment> getScheduledAppointmentsForPatient(Patient patient);

/**
* Gets all scheduled appointment blocks for a certain day at a certain location. Ignores any
* appointments that are voided or in one of the "cancelled" state
*
* @param location
* @param date
* @param appointmentType
* @return
*/

@Authorized(AppointmentUtils.PRIV_VIEW_APPOINTMENTS)
List<ScheduledAppointmentBlock> getDailyAppointmentBlocks(
Location location, Date date, AppointmentType appointmentType);

/**
* Gets all scheduled appointment blocks for a certain day at a certain location. Ignores any
* appointments that are voided or in one of the "cancelled" state
*
* @param location
* @param date
* @param appointmentTypes
* @return
*/

@Authorized(AppointmentUtils.PRIV_VIEW_APPOINTMENTS)
List<ScheduledAppointmentBlock> getDailyAppointmentBlocks(
Location location, Date date, List<AppointmentType> appointmentTypes);

/**
* Books a new appointment
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,6 @@
*/
package org.openmrs.module.appointmentscheduling.api.impl;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.joda.time.DateTime;
Expand All @@ -44,7 +30,6 @@
import org.openmrs.module.appointmentscheduling.AppointmentBlock;
import org.openmrs.module.appointmentscheduling.AppointmentStatusHistory;
import org.openmrs.module.appointmentscheduling.AppointmentType;
import org.openmrs.module.appointmentscheduling.ScheduledAppointmentBlock;
import org.openmrs.module.appointmentscheduling.StudentT;
import org.openmrs.module.appointmentscheduling.TimeSlot;
import org.openmrs.module.appointmentscheduling.api.AppointmentService;
Expand All @@ -57,6 +42,20 @@
import org.openmrs.validator.ValidateUtil;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
* It is a default implementation of {@link AppointmentService}.
*/
Expand Down Expand Up @@ -1045,47 +1044,6 @@ public Map<AppointmentType, Integer> getAppointmentTypeDistribution(

}

@Override
@Transactional(readOnly = true)
public List<ScheduledAppointmentBlock> getDailyAppointmentBlocks(
Location location, Date date, AppointmentType appointmentType) {

return getDailyAppointmentBlocks(
location,
date,
appointmentType != null ? Collections
.singletonList(appointmentType) : null);
}

@Override
public List<ScheduledAppointmentBlock> getDailyAppointmentBlocks(
Location location, Date date, List<AppointmentType> appointmentTypes) {

List<ScheduledAppointmentBlock> scheduledAppointmentBlockList = new ArrayList<ScheduledAppointmentBlock>();

for (AppointmentBlock appointmentBlock : getAppointmentBlockList(
location, date, appointmentTypes)) {

ScheduledAppointmentBlock scheduledAppointmentBlock = createScheduledAppointmentBlock(
appointmentBlock, appointmentTypes);

if (!scheduledAppointmentBlock.getAppointments().isEmpty()) {
scheduledAppointmentBlockList.add(scheduledAppointmentBlock);
}
}

return scheduledAppointmentBlockList;
}

private ScheduledAppointmentBlock createScheduledAppointmentBlock(
AppointmentBlock appointmentBlock,
List<AppointmentType> appointmentTypes) {
List<Appointment> appointmentList = getAppointmentDAO()
.getAppointmentsByAppointmentBlockAndAppointmentTypes(
appointmentBlock, appointmentTypes);
return new ScheduledAppointmentBlock(appointmentList, appointmentBlock);
}

@Override
@Transactional
public Appointment bookAppointment(Appointment appointment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
import org.openmrs.api.context.Context;
import org.openmrs.module.appointmentscheduling.Appointment;
import org.openmrs.module.appointmentscheduling.Appointment.AppointmentStatus;
import org.openmrs.module.appointmentscheduling.AppointmentBlock;
import org.openmrs.module.appointmentscheduling.AppointmentType;
import org.openmrs.module.appointmentscheduling.ScheduledAppointmentBlock;
import org.openmrs.module.appointmentscheduling.TimeSlot;
import org.openmrs.module.appointmentscheduling.exception.TimeSlotFullException;
import org.openmrs.test.BaseModuleContextSensitiveTest;
Expand Down Expand Up @@ -480,101 +478,6 @@ public void shouldGetScheduledAppointmentsForPatientOrderedByStartData() {
assertEquals(new Integer(7), appointments.get(3).getId());
}

@Test
public void shouldGetDailyAppointments() throws Exception {
Location location = Context.getLocationService().getLocation(2);
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S");
Date date = format.parse("2014-01-02 10:00:00.0");
Provider provider = Context.getProviderService().getProvider(1);
AppointmentType appointmentType = Context.getService(
AppointmentService.class).getAppointmentType(1);

List<ScheduledAppointmentBlock> scheduledAppointmentBlockList = service
.getDailyAppointmentBlocks(location, date, appointmentType);

assertNotNull(scheduledAppointmentBlockList);
assertEquals(1, scheduledAppointmentBlockList.size());

ScheduledAppointmentBlock scheduledAppointmentBlock = scheduledAppointmentBlockList
.get(0);

assertEquals(scheduledAppointmentBlock.getAppointments().size(), 4);
assertEquals(format.parse("2014-01-02 00:00:00.0"),
scheduledAppointmentBlock.getStartDate());
assertEquals(format.parse("2014-01-02 12:00:00.0"),
scheduledAppointmentBlock.getEndDate());
assertEquals(provider, scheduledAppointmentBlock.getProvider());

List<Appointment> appointmentList = scheduledAppointmentBlock
.getAppointments();
Appointment appointment = appointmentList.get(0);
assertEquals(1, appointment.getPatient().getId().intValue());
assertEquals("Initial HIV Clinic Appointment", appointment
.getAppointmentType().getName());

appointment = appointmentList.get(1);
assertEquals(1, appointment.getPatient().getId().intValue());
assertEquals("Initial HIV Clinic Appointment", appointment
.getAppointmentType().getName());
}

@Test
public void shouldNotReturnDailyAppointmentsWhenThereIsNoScheduledAppointments()
throws Exception {
Location location = Context.getLocationService().getLocation(1);
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S");
Date date = format.parse("2005-01-02 10:00:00.0");
AppointmentType appointmentType = null;

List<ScheduledAppointmentBlock> scheduledAppointmentBlockList = service
.getDailyAppointmentBlocks(location, date, appointmentType);
assertEquals(0, scheduledAppointmentBlockList.size());
}

@Test
public void shouldReturnDailyAppointmentsWithoutProviderAssigned()
throws Exception {
Location location = Context.getLocationService().getLocation(3);
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S");
Date date = format.parse("2014-01-02 10:00:00.0");

AppointmentType appointmentType = null;

List<ScheduledAppointmentBlock> scheduledAppointmentBlockList = service
.getDailyAppointmentBlocks(location, date, appointmentType);

assertEquals(1, scheduledAppointmentBlockList.size());

AppointmentBlock appointmentBlock = scheduledAppointmentBlockList
.get(0).getAppointmentBlock();
assertEquals(null, appointmentBlock.getProvider());

List<Appointment> appointmentList = scheduledAppointmentBlockList
.get(0).getAppointments();
assertEquals(1, appointmentList.size());
}

@Test
public void shouldReturnDailyAppointmentsWhenMultipleAppointmentTypesChosen()
throws Exception {

SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S");
Date date = format.parse("2014-01-02 00:00:00.0");

Location location = Context.getLocationService().getLocation(3);

AppointmentType appointmentType2 = service.getAppointmentType(3);
AppointmentType appointmentType3 = service.getAppointmentType(1);

List<ScheduledAppointmentBlock> scheduledAppointmentBlockList = service
.getDailyAppointmentBlocks(location, date,
Arrays.asList(appointmentType2, appointmentType3));

assertEquals(1, scheduledAppointmentBlockList.size());
assertEquals(new Integer(5), scheduledAppointmentBlockList.get(0)
.getAppointmentBlock().getId());
}

@Test
@Verifies(value = "retrieve all appointments scheduled in a given time slot", method = "getAppointmentsInTimeSlot(TimeSlot)")
public void getAppointmentsInTimeSlot_shouldGetCorrectAppointments() {
Expand Down
Loading

0 comments on commit 7544d6d

Please sign in to comment.