diff --git a/api/src/main/java/org/openmrs/module/appointmentscheduling/AppointmentRequest.java b/api/src/main/java/org/openmrs/module/appointmentscheduling/AppointmentRequest.java
index 1460f187..55ab16b4 100644
--- a/api/src/main/java/org/openmrs/module/appointmentscheduling/AppointmentRequest.java
+++ b/api/src/main/java/org/openmrs/module/appointmentscheduling/AppointmentRequest.java
@@ -8,9 +8,9 @@
public class AppointmentRequest extends BaseOpenmrsData {
- public enum TimeFrameUnits { DAYS, MONTHS, YEARS }
+ public enum TimeFrameUnits { DAYS, WEEKS, MONTHS, YEARS };
- public enum AppointmentRequestStatus { PENDING, FULFILLED, CANCELLED }
+ public enum AppointmentRequestStatus { PENDING, FULFILLED, CANCELLED };
private Integer appointmentRequestId;
@@ -28,8 +28,15 @@ public enum AppointmentRequestStatus { PENDING, FULFILLED, CANCELLED }
private Date requestedOn;
- // TODO
- // TODO link to the existing appointment somehow?
+ private Integer minTimeFrameValue;
+
+ private TimeFrameUnits minTimeFrameUnits;
+
+ private Integer maxTimeFrameValue;
+
+ private TimeFrameUnits maxTimeFrameUnits;
+
+ // TODO Do we want tio link to the created appointment somehow?
@Override
public Integer getId() {
@@ -104,4 +111,36 @@ public Date getRequestedOn() {
public void setRequestedOn(Date requestedOn) {
this.requestedOn = requestedOn;
}
+
+ public Integer getMinTimeFrameValue() {
+ return minTimeFrameValue;
+ }
+
+ public void setMinTimeFrameValue(Integer minTimeFrameValue) {
+ this.minTimeFrameValue = minTimeFrameValue;
+ }
+
+ public TimeFrameUnits getMinTimeFrameUnits() {
+ return minTimeFrameUnits;
+ }
+
+ public void setMinTimeFrameUnits(TimeFrameUnits minTimeFrameUnits) {
+ this.minTimeFrameUnits = minTimeFrameUnits;
+ }
+
+ public Integer getMaxTimeFrameValue() {
+ return maxTimeFrameValue;
+ }
+
+ public void setMaxTimeFrameValue(Integer maxTimeFrameValue) {
+ this.maxTimeFrameValue = maxTimeFrameValue;
+ }
+
+ public TimeFrameUnits getMaxTimeFrameUnits() {
+ return maxTimeFrameUnits;
+ }
+
+ public void setMaxTimeFrameUnits(TimeFrameUnits maxTimeFrameUnits) {
+ this.maxTimeFrameUnits = maxTimeFrameUnits;
+ }
}
diff --git a/api/src/main/resources/AppointmentRequest.hbm.xml b/api/src/main/resources/AppointmentRequest.hbm.xml
index fec3f903..7e5f6ae7 100644
--- a/api/src/main/resources/AppointmentRequest.hbm.xml
+++ b/api/src/main/resources/AppointmentRequest.hbm.xml
@@ -25,6 +25,20 @@
+
+
+
+ org.openmrs.module.appointmentscheduling.AppointmentRequest$TimeFrameUnits
+
+
+
+
+
+
+ org.openmrs.module.appointmentscheduling.AppointmentRequest$TimeFrameUnits
+
+
+
diff --git a/api/src/test/java/org/openmrs/module/appointmentscheduling/api/AppointmentRequestServiceTest.java b/api/src/test/java/org/openmrs/module/appointmentscheduling/api/AppointmentRequestServiceTest.java
index 80b5342d..086efafc 100644
--- a/api/src/test/java/org/openmrs/module/appointmentscheduling/api/AppointmentRequestServiceTest.java
+++ b/api/src/test/java/org/openmrs/module/appointmentscheduling/api/AppointmentRequestServiceTest.java
@@ -63,6 +63,10 @@ public void getAppointmentRequest_shouldGetCorrectAppointmentRequest() throws Ex
assertEquals(AppointmentRequest.AppointmentRequestStatus.PENDING, appointmentRequest.getStatus());
assertEquals(providerService.getProvider(1), appointmentRequest.getRequestedBy());
assertEquals("ASAP", appointmentRequest.getNotes());
+ assertEquals(new Integer(0), appointmentRequest.getMinTimeFrameValue());
+ assertEquals(AppointmentRequest.TimeFrameUnits.DAYS, appointmentRequest.getMinTimeFrameUnits());
+ assertEquals(new Integer(7), appointmentRequest.getMaxTimeFrameValue());
+ assertEquals(AppointmentRequest.TimeFrameUnits.DAYS, appointmentRequest.getMaxTimeFrameUnits());
appointmentRequest = service.getAppointmentRequest(2);
assertNotNull(appointmentRequest);
@@ -72,6 +76,10 @@ public void getAppointmentRequest_shouldGetCorrectAppointmentRequest() throws Ex
assertEquals(service.getAppointmentType(2), appointmentRequest.getAppointmentType());
assertEquals(AppointmentRequest.AppointmentRequestStatus.FULFILLED, appointmentRequest.getStatus());
assertEquals(providerService.getProvider(2), appointmentRequest.getRequestedBy());
+ assertEquals(new Integer(6), appointmentRequest.getMinTimeFrameValue());
+ assertEquals(AppointmentRequest.TimeFrameUnits.WEEKS, appointmentRequest.getMinTimeFrameUnits());
+ assertEquals(new Integer(2), appointmentRequest.getMaxTimeFrameValue());
+ assertEquals(AppointmentRequest.TimeFrameUnits.MONTHS, appointmentRequest.getMaxTimeFrameUnits());
assertNull(appointmentRequest.getNotes());
}
@@ -98,6 +106,11 @@ public void saveAppointmentRequest_shouldSaveNewAppointmentRequest() throws Exce
appointmentRequest.setProvider(providerService.getProvider(1));
appointmentRequest.setRequestedBy(providerService.getProvider(1));
appointmentRequest.setRequestedOn(new Date());
+ appointmentRequest.setMinTimeFrameValue(1);
+ appointmentRequest.setMinTimeFrameUnits(AppointmentRequest.TimeFrameUnits.MONTHS);
+ appointmentRequest.setMaxTimeFrameValue(6);
+ appointmentRequest.setMaxTimeFrameUnits(AppointmentRequest.TimeFrameUnits.MONTHS);
+
appointmentRequest.setNotes("test");
appointmentRequest.setStatus(AppointmentRequest.AppointmentRequestStatus.PENDING);
service.saveAppointmentRequest(appointmentRequest);
diff --git a/api/src/test/resources/standardAppointmentTestDataset.xml b/api/src/test/resources/standardAppointmentTestDataset.xml
index b1981327..9b921558 100644
--- a/api/src/test/resources/standardAppointmentTestDataset.xml
+++ b/api/src/test/resources/standardAppointmentTestDataset.xml
@@ -6,7 +6,7 @@
-
+
@@ -60,8 +60,8 @@
-
-
+
+
diff --git a/omod/src/main/java/org/openmrs/module/appointmentscheduling/rest/resource/openmrs1_9/AppointmentRequestResource1_9.java b/omod/src/main/java/org/openmrs/module/appointmentscheduling/rest/resource/openmrs1_9/AppointmentRequestResource1_9.java
new file mode 100644
index 00000000..6bafcc9b
--- /dev/null
+++ b/omod/src/main/java/org/openmrs/module/appointmentscheduling/rest/resource/openmrs1_9/AppointmentRequestResource1_9.java
@@ -0,0 +1,140 @@
+package org.openmrs.module.appointmentscheduling.rest.resource.openmrs1_9;
+
+import org.openmrs.api.context.Context;
+import org.openmrs.module.appointmentscheduling.AppointmentRequest;
+import org.openmrs.module.appointmentscheduling.api.AppointmentService;
+import org.openmrs.module.appointmentscheduling.rest.controller.AppointmentRestController;
+import org.openmrs.module.webservices.rest.web.RequestContext;
+import org.openmrs.module.webservices.rest.web.RestConstants;
+import org.openmrs.module.webservices.rest.web.annotation.Resource;
+import org.openmrs.module.webservices.rest.web.representation.DefaultRepresentation;
+import org.openmrs.module.webservices.rest.web.representation.FullRepresentation;
+import org.openmrs.module.webservices.rest.web.representation.Representation;
+import org.openmrs.module.webservices.rest.web.resource.impl.DataDelegatingCrudResource;
+import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceDescription;
+import org.openmrs.module.webservices.rest.web.resource.impl.NeedsPaging;
+import org.openmrs.module.webservices.rest.web.response.ResponseException;
+
+@Resource(name = RestConstants.VERSION_1 + AppointmentRestController.APPOINTMENT_SCHEDULING_REST_NAMESPACE + "/appointmentrequest", supportedClass = AppointmentRequest.class, supportedOpenmrsVersions = "1.9.*")
+public class AppointmentRequestResource1_9 extends DataDelegatingCrudResource {
+
+ @Override
+ public DelegatingResourceDescription getRepresentationDescription(Representation representation) {
+ if (representation instanceof DefaultRepresentation) {
+ DelegatingResourceDescription description = new DelegatingResourceDescription();
+ description.addProperty("uuid");
+ description.addProperty("display", findMethod("getDisplayString"));
+ description.addProperty("patient", Representation.DEFAULT);
+ description.addProperty("appointmentType", Representation.REF);
+ description.addProperty("provider", Representation.DEFAULT);
+ description.addProperty("requestedBy", Representation.DEFAULT);
+ description.addProperty("requestedOn");
+ description.addProperty("status");
+ description.addProperty("minTimeFrameValue");
+ description.addProperty("minTimeFrameUnits");
+ description.addProperty("maxTimeFrameValue");
+ description.addProperty("maxTimeFrameUnits");
+ description.addProperty("notes");
+ description.addProperty("voided");
+ description.addSelfLink();
+ description.addLink("full", ".?v=" + RestConstants.REPRESENTATION_FULL);
+ return description;
+ } else if (representation instanceof FullRepresentation) {
+ DelegatingResourceDescription description = new DelegatingResourceDescription();
+ description.addProperty("uuid");
+ description.addProperty("display", findMethod("getDisplayString"));
+ description.addProperty("patient", Representation.FULL);
+ description.addProperty("appointmentType", Representation.FULL);
+ description.addProperty("provider", Representation.FULL);
+ description.addProperty("requestedBy", Representation.FULL);
+ description.addProperty("requestedOn");
+ description.addProperty("status");
+ description.addProperty("minTimeFrameValue");
+ description.addProperty("minTimeFrameUnits");
+ description.addProperty("maxTimeFrameValue");
+ description.addProperty("maxTimeFrameUnits");
+ description.addProperty("notes");
+ description.addProperty("voided");
+ description.addProperty("auditInfo", findMethod("getAuditInfo"));
+ description.addSelfLink();
+ return description;
+ }
+
+ return null;
+ }
+
+ @Override
+ public DelegatingResourceDescription getCreatableProperties() {
+ DelegatingResourceDescription description = new DelegatingResourceDescription();
+ description.addRequiredProperty("patient");
+ description.addRequiredProperty("appointmentType");
+ description.addProperty("provider");
+ description.addProperty("requestedBy");
+ description.addRequiredProperty("requestedOn");
+ description.addRequiredProperty("status");
+ description.addProperty("minTimeFrameValue");
+ description.addProperty("minTimeFrameUnits");
+ description.addProperty("maxTimeFrameValue");
+ description.addProperty("maxTimeFrameUnits");
+ description.addProperty("notes");
+ return description;
+ }
+
+ @Override
+ public DelegatingResourceDescription getUpdatableProperties() {
+ DelegatingResourceDescription description = new DelegatingResourceDescription();
+ description.addRequiredProperty("patient");
+ description.addRequiredProperty("appointmentType");
+ description.addProperty("provider");
+ description.addProperty("requestedBy");
+ description.addRequiredProperty("requestedOn");
+ description.addRequiredProperty("status");
+ description.addProperty("minTimeFrameValue");
+ description.addProperty("minTimeFrameUnits");
+ description.addProperty("maxTimeFrameValue");
+ description.addProperty("maxTimeFrameUnits");
+ description.addProperty("notes");
+ return description;
+ }
+
+ @Override
+ public AppointmentRequest getByUniqueId(String uuid) {
+ return Context.getService(AppointmentService.class).getAppointmentRequestByUuid(uuid);
+ }
+
+ @Override
+ protected void delete(AppointmentRequest appointmentRequest, String reason, RequestContext requestContext) throws ResponseException {
+ if (appointmentRequest.isVoided()) {
+ return;
+ }
+ Context.getService(AppointmentService.class).voidAppointmentRequest(appointmentRequest, reason);
+ }
+
+ @Override
+ public AppointmentRequest newDelegate() {
+ return new AppointmentRequest();
+ }
+
+ @Override
+ public AppointmentRequest save(AppointmentRequest appointmentRequest) {
+ return Context.getService(AppointmentService.class).saveAppointmentRequest(appointmentRequest);
+ }
+
+ @Override
+ public void purge(AppointmentRequest appointmentRequest, RequestContext requestContext) throws ResponseException {
+ if (appointmentRequest == null) {
+ return;
+ }
+ Context.getService(AppointmentService.class).purgeAppointmentRequest(appointmentRequest);
+ }
+
+ @Override
+ protected NeedsPaging doGetAll(RequestContext context) {
+ return new NeedsPaging(Context.getService(AppointmentService.class).getAllAppointmentRequests(
+ context.getIncludeAll()), context);
+ }
+
+ public String getDisplayString(AppointmentRequest appointmentRequest) {
+ return appointmentRequest.getAppointmentType().getName() + " : " + appointmentRequest.getStatus();
+ }
+}
diff --git a/omod/src/main/java/org/openmrs/module/appointmentscheduling/rest/resource/openmrs1_9/AppointmentResource1_9.java b/omod/src/main/java/org/openmrs/module/appointmentscheduling/rest/resource/openmrs1_9/AppointmentResource1_9.java
index 741629b6..2f237434 100644
--- a/omod/src/main/java/org/openmrs/module/appointmentscheduling/rest/resource/openmrs1_9/AppointmentResource1_9.java
+++ b/omod/src/main/java/org/openmrs/module/appointmentscheduling/rest/resource/openmrs1_9/AppointmentResource1_9.java
@@ -1,10 +1,5 @@
package org.openmrs.module.appointmentscheduling.rest.resource.openmrs1_9;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Date;
-import java.util.List;
-
import org.openmrs.Location;
import org.openmrs.Patient;
import org.openmrs.Provider;
@@ -30,6 +25,11 @@
import org.springframework.validation.BindException;
import org.springframework.validation.Errors;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+
import static org.openmrs.module.appointmentscheduling.Appointment.AppointmentStatus;
import static org.openmrs.module.appointmentscheduling.Appointment.AppointmentStatus.getAppointmentsStatusByType;
import static org.openmrs.module.appointmentscheduling.Appointment.AppointmentStatusType;
@@ -149,7 +149,7 @@ public void purge(Appointment appointment, RequestContext requestContext) throws
@Override
protected PageableResult doGetAll(RequestContext context) throws ResponseException {
AppointmentService service = Context.getService(AppointmentService.class);
- return new NeedsPaging(service.getAllAppointments(), context);
+ return new NeedsPaging(service.getAllAppointments(context.getIncludeAll()), context);
}
/**
diff --git a/omod/src/test/java/org/openmrs/module/appointmentscheduling/rest/controller/AppointmentAllowingOverbookResource1_9ControllerTest.java b/omod/src/test/java/org/openmrs/module/appointmentscheduling/rest/controller/AppointmentAllowingOverbookResource1_9ControllerTest.java
index a63137c6..898b148e 100644
--- a/omod/src/test/java/org/openmrs/module/appointmentscheduling/rest/controller/AppointmentAllowingOverbookResource1_9ControllerTest.java
+++ b/omod/src/test/java/org/openmrs/module/appointmentscheduling/rest/controller/AppointmentAllowingOverbookResource1_9ControllerTest.java
@@ -39,7 +39,7 @@ public void shouldCreateNewAppointmentEvenIfTimeBlockFull() throws Exception {
Assert.assertEquals("SCHEDULED", PropertyUtils.getProperty(appt, "status.code"));
Assert.assertEquals("c0c579b0-8e59-401d-8a4a-976a0b183519",
PropertyUtils.getProperty(PropertyUtils.getProperty(appt, "appointmentType"), "uuid"));
- Assert.assertEquals(getAllCount() + 1, appointmentService.getAllAppointments().size());
+ Assert.assertEquals(getAllCount() + 1, appointmentService.getAllAppointments(false).size());
}
@@ -55,6 +55,6 @@ public String getUuid() {
@Override
public long getAllCount() {
- return 7;
+ return 6;
}
}
diff --git a/omod/src/test/java/org/openmrs/module/appointmentscheduling/rest/controller/AppointmentRequestResource1_9ControllerTest.java b/omod/src/test/java/org/openmrs/module/appointmentscheduling/rest/controller/AppointmentRequestResource1_9ControllerTest.java
new file mode 100644
index 00000000..9f432f03
--- /dev/null
+++ b/omod/src/test/java/org/openmrs/module/appointmentscheduling/rest/controller/AppointmentRequestResource1_9ControllerTest.java
@@ -0,0 +1,280 @@
+package org.openmrs.module.appointmentscheduling.rest.controller;
+
+import org.apache.commons.beanutils.PropertyUtils;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.openmrs.api.context.Context;
+import org.openmrs.module.appointmentscheduling.AppointmentRequest;
+import org.openmrs.module.appointmentscheduling.api.AppointmentService;
+import org.openmrs.module.webservices.rest.SimpleObject;
+import org.openmrs.module.webservices.rest.test.Util;
+import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest;
+import org.springframework.mock.web.MockHttpServletRequest;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+import static org.junit.Assert.assertThat;
+import static org.openmrs.module.appointmentscheduling.rest.test.SameDatetimeMatcher.sameDatetime;
+
+public class AppointmentRequestResource1_9ControllerTest extends MainResourceControllerTest {
+
+ private AppointmentService appointmentService;
+
+ @Before
+ public void setup() throws Exception {
+ appointmentService = Context.getService(AppointmentService.class);
+ executeDataSet("standardWebAppointmentTestDataset.xml");
+ }
+
+ @Test
+ public void shouldGetAppointmentRequestByUuid() throws Exception {
+
+ AppointmentRequest appointmentRequest = appointmentService.getAppointmentRequestByUuid(getUuid());
+
+ MockHttpServletRequest req = request(RequestMethod.GET, getURI() + "/"
+ + getUuid());
+ SimpleObject result = deserialize(handle(req));
+
+ Assert.assertNotNull(result);
+ Assert.assertEquals(getUuid(), PropertyUtils.getProperty(result, "uuid"));
+ Assert.assertEquals("PENDING", PropertyUtils.getProperty(result, "status"));
+ Assert.assertEquals("Initial HIV Clinic Appointment : PENDING", PropertyUtils.getProperty(result, "display"));
+ Assert.assertEquals(0, PropertyUtils.getProperty(result, "minTimeFrameValue"));
+ Assert.assertEquals("DAYS", PropertyUtils.getProperty(result, "minTimeFrameUnits"));
+ Assert.assertEquals(7, PropertyUtils.getProperty(result, "maxTimeFrameValue"));
+ Assert.assertEquals("DAYS", PropertyUtils.getProperty(result, "maxTimeFrameUnits"));
+ Assert.assertEquals("c0c579b0-8e59-401d-8a4a-976a0b183519", Util.getByPath(result, "appointmentType/uuid"));
+ Assert.assertEquals("31e09960-8f52-11e3-baa8-0800200c9a66", Util.getByPath(result, "patient/uuid"));
+ Assert.assertEquals("c0c549b0-8e59-401d-8a4a-976a0b183599", Util.getByPath(result, "provider/uuid"));
+ Assert.assertEquals("c0c549b0-8e59-401d-8a4a-976a0b183599", Util.getByPath(result, "requestedBy/uuid"));
+ Assert.assertEquals("ASAP", PropertyUtils.getProperty(result, "notes"));
+ assertThat((String) PropertyUtils.getProperty(result, "requestedOn"), sameDatetime(appointmentRequest.getRequestedOn()));
+ Assert.assertEquals(false, PropertyUtils.getProperty(result, "voided"));
+
+ }
+
+ @Test
+ public void shouldCreateNewAppointmentRequestWithAllFields() throws Exception {
+
+ String json = "{ \"provider\":\"c0c549b0-8e59-401d-8a4a-976a0b183599\", "
+ + "\"requestedOn\":\"2014-01-03T10:00:00.000-0500\", \"requestedBy\":\"c0c54sd0-8e59-401d-8a4a-976a0b183599\", "
+ + "\"patient\":\"22b47970-8f52-11e3-baa8-0800200c9a66\", \"status\":\"FULFILLED\", \"notes\":\"Test\", "
+ + "\"minTimeFrameValue\":\"0\", \"minTimeFrameUnits\":\"DAYS\", "
+ + "\"maxTimeFrameValue\":\"7\", \"maxTimeFrameUnits\":\"DAYS\", "
+ + "\"appointmentType\": \"759799ab-c9a5-435e-b671-77773ada74e4\" }";
+
+ MockHttpServletRequest req = request(RequestMethod.POST, getURI());
+ req.setContent(json.getBytes());
+
+ Object result = deserialize(handle(req));
+ Assert.assertNotNull(PropertyUtils.getProperty(result, "uuid"));
+ Assert.assertEquals("FULFILLED", PropertyUtils.getProperty(result, "status"));
+ Assert.assertEquals("Return TB Clinic Appointment : FULFILLED", PropertyUtils.getProperty(result, "display"));
+ Assert.assertEquals(0, PropertyUtils.getProperty(result, "minTimeFrameValue"));
+ Assert.assertEquals("DAYS", PropertyUtils.getProperty(result, "minTimeFrameUnits"));
+ Assert.assertEquals(7, PropertyUtils.getProperty(result, "maxTimeFrameValue"));
+ Assert.assertEquals("DAYS", PropertyUtils.getProperty(result, "maxTimeFrameUnits"));
+ Assert.assertEquals("759799ab-c9a5-435e-b671-77773ada74e4", Util.getByPath(result, "appointmentType/uuid"));
+ Assert.assertEquals("22b47970-8f52-11e3-baa8-0800200c9a66", Util.getByPath(result, "patient/uuid"));
+ Assert.assertEquals("c0c549b0-8e59-401d-8a4a-976a0b183599", Util.getByPath(result, "provider/uuid"));
+ Assert.assertEquals("c0c54sd0-8e59-401d-8a4a-976a0b183599", Util.getByPath(result, "requestedBy/uuid"));
+ Assert.assertEquals("Test", PropertyUtils.getProperty(result, "notes"));
+ Assert.assertEquals(false, PropertyUtils.getProperty(result, "voided"));
+
+ }
+
+ @Test
+ public void shouldCreateNewAppointmentRequestWithRequiredFieldsOnly()
+ throws Exception {
+
+ String json = "{\"requestedOn\":\"2014-01-03T10:00:00.000-0500\", "
+ + "\"patient\":\"22b47970-8f52-11e3-baa8-0800200c9a66\", \"status\":\"PENDING\", "
+ + "\"appointmentType\": \"759799ab-c9a5-435e-b671-77773ada74e4\" }";
+
+ MockHttpServletRequest req = request(RequestMethod.POST, getURI());
+ req.setContent(json.getBytes());
+
+ Object result = deserialize(handle(req));
+ Assert.assertNotNull(PropertyUtils.getProperty(result, "uuid"));
+ Assert.assertEquals("PENDING", PropertyUtils.getProperty(result, "status"));
+ Assert.assertEquals("Return TB Clinic Appointment : PENDING", PropertyUtils.getProperty(result, "display"));
+ Assert.assertEquals("759799ab-c9a5-435e-b671-77773ada74e4", Util.getByPath(result, "appointmentType/uuid"));
+ Assert.assertEquals("22b47970-8f52-11e3-baa8-0800200c9a66", Util.getByPath(result, "patient/uuid"));
+ Assert.assertEquals(false, PropertyUtils.getProperty(result, "voided"));
+
+ }
+
+ @Test
+ public void shouldEditAnAppointmentRequest() throws Exception {
+
+ String json = "{ \"status\":\"FULFILLED\" }";
+ MockHttpServletRequest req = request(RequestMethod.POST, getURI() + "/" + getUuid());
+ req.setContent(json.getBytes());
+ handle(req);
+
+ AppointmentRequest appointmentRequest = appointmentService.getAppointmentRequestByUuid(getUuid());
+ Assert.assertNotNull(appointmentRequest);
+ Assert.assertEquals(AppointmentRequest.AppointmentRequestStatus.FULFILLED, appointmentRequest.getStatus());
+
+ }
+
+ @Test
+ public void shouldVoidAnAppointment() throws Exception {
+
+ MockHttpServletRequest req = request(RequestMethod.DELETE, getURI() + "/" + getUuid());
+ req.addParameter("!purge", "");
+ req.addParameter("reason", "really ridiculous random reason");
+ handle(req);
+
+ AppointmentRequest voided = appointmentService.getAppointmentRequestByUuid(getUuid()) ;
+ Assert.assertTrue(voided.isVoided());
+ Assert.assertEquals("really ridiculous random reason",voided.getVoidReason());
+ }
+
+ @Test
+ public void shouldPurgeAnAppointment() throws Exception {
+
+ MockHttpServletRequest req = request(RequestMethod.DELETE, getURI() + "/" + getUuid());
+ req.addParameter("purge", "");
+ req.addParameter("reason", "really ridiculous random reason");
+ handle(req);
+
+ Assert.assertNull(appointmentService.getAppointmentRequestByUuid(getUuid()));
+ Assert.assertEquals(getAllCount() - 1, appointmentService.getAllAppointmentRequests(false).size());
+
+ }
+
+/* @Test
+ public void shouldFetchAppointmentsByDate() throws Exception {
+
+ MockHttpServletRequest req = request(RequestMethod.GET, getURI());
+ req.addParameter("fromDate", "2005-12-02T00:00:00.000");
+ req.addParameter("toDate", "2006-12-02T00:00:00.000");
+ handle(req);
+
+ List