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 55ab16b4..ae97dbd2 100644
--- a/api/src/main/java/org/openmrs/module/appointmentscheduling/AppointmentRequest.java
+++ b/api/src/main/java/org/openmrs/module/appointmentscheduling/AppointmentRequest.java
@@ -8,8 +8,6 @@
public class AppointmentRequest extends BaseOpenmrsData {
- public enum TimeFrameUnits { DAYS, WEEKS, MONTHS, YEARS };
-
public enum AppointmentRequestStatus { PENDING, FULFILLED, CANCELLED };
private Integer appointmentRequestId;
diff --git a/api/src/main/java/org/openmrs/module/appointmentscheduling/TimeFrameUnits.java b/api/src/main/java/org/openmrs/module/appointmentscheduling/TimeFrameUnits.java
new file mode 100644
index 00000000..befa064f
--- /dev/null
+++ b/api/src/main/java/org/openmrs/module/appointmentscheduling/TimeFrameUnits.java
@@ -0,0 +1,5 @@
+package org.openmrs.module.appointmentscheduling;
+
+public enum TimeFrameUnits {
+ DAYS, WEEKS, MONTHS, YEARS
+}
diff --git a/api/src/main/java/org/openmrs/module/appointmentscheduling/api/impl/AppointmentServiceImpl.java b/api/src/main/java/org/openmrs/module/appointmentscheduling/api/impl/AppointmentServiceImpl.java
index 6bf2e7d8..eabcbde5 100644
--- a/api/src/main/java/org/openmrs/module/appointmentscheduling/api/impl/AppointmentServiceImpl.java
+++ b/api/src/main/java/org/openmrs/module/appointmentscheduling/api/impl/AppointmentServiceImpl.java
@@ -578,7 +578,6 @@ public AppointmentRequest getAppointmentRequestByUuid(String uuid) {
@Override
@Transactional
public AppointmentRequest saveAppointmentRequest(AppointmentRequest appointmentRequest) throws APIException {
- ValidateUtil.validate(appointmentRequest);
return appointmentRequestDAO.saveOrUpdate(appointmentRequest);
}
diff --git a/api/src/main/resources/AppointmentRequest.hbm.xml b/api/src/main/resources/AppointmentRequest.hbm.xml
index 7e5f6ae7..ab7d6e90 100644
--- a/api/src/main/resources/AppointmentRequest.hbm.xml
+++ b/api/src/main/resources/AppointmentRequest.hbm.xml
@@ -28,14 +28,14 @@
- org.openmrs.module.appointmentscheduling.AppointmentRequest$TimeFrameUnits
+ org.openmrs.module.appointmentscheduling.TimeFrameUnits
- org.openmrs.module.appointmentscheduling.AppointmentRequest$TimeFrameUnits
+ org.openmrs.module.appointmentscheduling.TimeFrameUnits
diff --git a/api/src/main/resources/liquibase.xml b/api/src/main/resources/liquibase.xml
index 29b569e9..0d309fa0 100644
--- a/api/src/main/resources/liquibase.xml
+++ b/api/src/main/resources/liquibase.xml
@@ -306,4 +306,98 @@
+
+
+
+
+
+ Create the appointment request table
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
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 086efafc..3000afc6 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
@@ -7,6 +7,7 @@
import org.openmrs.api.PatientService;
import org.openmrs.api.ProviderService;
import org.openmrs.module.appointmentscheduling.AppointmentRequest;
+import org.openmrs.module.appointmentscheduling.TimeFrameUnits;
import org.openmrs.test.BaseModuleContextSensitiveTest;
import org.openmrs.test.Verifies;
import org.springframework.beans.factory.annotation.Autowired;
@@ -64,9 +65,9 @@ public void getAppointmentRequest_shouldGetCorrectAppointmentRequest() throws Ex
assertEquals(providerService.getProvider(1), appointmentRequest.getRequestedBy());
assertEquals("ASAP", appointmentRequest.getNotes());
assertEquals(new Integer(0), appointmentRequest.getMinTimeFrameValue());
- assertEquals(AppointmentRequest.TimeFrameUnits.DAYS, appointmentRequest.getMinTimeFrameUnits());
+ assertEquals(TimeFrameUnits.DAYS, appointmentRequest.getMinTimeFrameUnits());
assertEquals(new Integer(7), appointmentRequest.getMaxTimeFrameValue());
- assertEquals(AppointmentRequest.TimeFrameUnits.DAYS, appointmentRequest.getMaxTimeFrameUnits());
+ assertEquals(TimeFrameUnits.DAYS, appointmentRequest.getMaxTimeFrameUnits());
appointmentRequest = service.getAppointmentRequest(2);
assertNotNull(appointmentRequest);
@@ -77,9 +78,9 @@ public void getAppointmentRequest_shouldGetCorrectAppointmentRequest() throws Ex
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(TimeFrameUnits.WEEKS, appointmentRequest.getMinTimeFrameUnits());
assertEquals(new Integer(2), appointmentRequest.getMaxTimeFrameValue());
- assertEquals(AppointmentRequest.TimeFrameUnits.MONTHS, appointmentRequest.getMaxTimeFrameUnits());
+ assertEquals(TimeFrameUnits.MONTHS, appointmentRequest.getMaxTimeFrameUnits());
assertNull(appointmentRequest.getNotes());
}
@@ -107,9 +108,9 @@ public void saveAppointmentRequest_shouldSaveNewAppointmentRequest() throws Exce
appointmentRequest.setRequestedBy(providerService.getProvider(1));
appointmentRequest.setRequestedOn(new Date());
appointmentRequest.setMinTimeFrameValue(1);
- appointmentRequest.setMinTimeFrameUnits(AppointmentRequest.TimeFrameUnits.MONTHS);
+ appointmentRequest.setMinTimeFrameUnits(TimeFrameUnits.MONTHS);
appointmentRequest.setMaxTimeFrameValue(6);
- appointmentRequest.setMaxTimeFrameUnits(AppointmentRequest.TimeFrameUnits.MONTHS);
+ appointmentRequest.setMaxTimeFrameUnits(TimeFrameUnits.MONTHS);
appointmentRequest.setNotes("test");
appointmentRequest.setStatus(AppointmentRequest.AppointmentRequestStatus.PENDING);
@@ -134,6 +135,7 @@ public void saveAppointmentRequest_shouldSaveNewAppointmentRequestWithMinimalPar
service.saveAppointmentRequest(appointmentRequest);
appointmentRequest = service.getAppointmentRequest(4);
+ assertEquals(AppointmentRequest.AppointmentRequestStatus.PENDING, appointmentRequest.getStatus());
assertNotNull(appointmentRequest);
//Should create a new appointment request row
diff --git a/omod/src/main/java/org/openmrs/module/appointmentscheduling/rest/resource/openmrs1_9/AppointmentRequestStatusResource1_9.java b/omod/src/main/java/org/openmrs/module/appointmentscheduling/rest/resource/openmrs1_9/AppointmentRequestStatusResource1_9.java
new file mode 100644
index 00000000..f12e2758
--- /dev/null
+++ b/omod/src/main/java/org/openmrs/module/appointmentscheduling/rest/resource/openmrs1_9/AppointmentRequestStatusResource1_9.java
@@ -0,0 +1,35 @@
+package org.openmrs.module.appointmentscheduling.rest.resource.openmrs1_9;
+
+import org.openmrs.module.appointmentscheduling.AppointmentRequest;
+import org.openmrs.module.appointmentscheduling.rest.controller.AppointmentRestController;
+import org.openmrs.module.webservices.rest.SimpleObject;
+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.resource.api.Listable;
+import org.openmrs.module.webservices.rest.web.resource.api.Searchable;
+import org.openmrs.module.webservices.rest.web.response.ResponseException;
+
+@Resource(name = RestConstants.VERSION_1 + AppointmentRestController.APPOINTMENT_SCHEDULING_REST_NAMESPACE
+ + "/appointmenttrequeststatus", supportedClass = AppointmentRequest.AppointmentRequestStatus.class, supportedOpenmrsVersions = "1.9.*")
+public class AppointmentRequestStatusResource1_9 implements Listable, Searchable {
+
+ @Override
+ public SimpleObject getAll(RequestContext requestContext) throws ResponseException {
+ AppointmentRequest.AppointmentRequestStatus[] appointmentRequestStatuses = AppointmentRequest.AppointmentRequestStatus.values();
+ SimpleObject simpleObject = new SimpleObject().add("results", appointmentRequestStatuses);
+ return simpleObject;
+ }
+
+ @Override
+ public String getUri(Object o) {
+ return RestConstants.URI_PREFIX + "/appointmentscheduling/appointmentrequeststatus/"
+ + ((AppointmentRequest.AppointmentRequestStatus) o);
+ }
+
+ @Override
+ public SimpleObject search(RequestContext requestContext) throws ResponseException {
+ return null;
+ }
+
+}
diff --git a/omod/src/main/java/org/openmrs/module/appointmentscheduling/rest/resource/openmrs1_9/AppointmentStatusTypeResource1_9.java b/omod/src/main/java/org/openmrs/module/appointmentscheduling/rest/resource/openmrs1_9/AppointmentStatusTypeResource1_9.java
index 4360be6d..5255b726 100644
--- a/omod/src/main/java/org/openmrs/module/appointmentscheduling/rest/resource/openmrs1_9/AppointmentStatusTypeResource1_9.java
+++ b/omod/src/main/java/org/openmrs/module/appointmentscheduling/rest/resource/openmrs1_9/AppointmentStatusTypeResource1_9.java
@@ -11,7 +11,7 @@
import org.openmrs.module.webservices.rest.web.response.ResponseException;
@Resource(name = RestConstants.VERSION_1 + AppointmentRestController.APPOINTMENT_SCHEDULING_REST_NAMESPACE
- + "/appointmentstatustype", supportedClass = AppointmentStatusTypeResource1_9.class, supportedOpenmrsVersions = "1.9.*")
+ + "/appointmentstatustype", supportedClass = Appointment.AppointmentStatusType.class, supportedOpenmrsVersions = "1.9.*")
public class AppointmentStatusTypeResource1_9 implements Listable, Searchable {
@Override
diff --git a/omod/src/main/java/org/openmrs/module/appointmentscheduling/rest/resource/openmrs1_9/TimeFrameUnitsResource1_9.java b/omod/src/main/java/org/openmrs/module/appointmentscheduling/rest/resource/openmrs1_9/TimeFrameUnitsResource1_9.java
new file mode 100644
index 00000000..047bfe80
--- /dev/null
+++ b/omod/src/main/java/org/openmrs/module/appointmentscheduling/rest/resource/openmrs1_9/TimeFrameUnitsResource1_9.java
@@ -0,0 +1,36 @@
+package org.openmrs.module.appointmentscheduling.rest.resource.openmrs1_9;
+
+import org.openmrs.module.appointmentscheduling.AppointmentRequest;
+import org.openmrs.module.appointmentscheduling.TimeFrameUnits;
+import org.openmrs.module.appointmentscheduling.rest.controller.AppointmentRestController;
+import org.openmrs.module.webservices.rest.SimpleObject;
+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.resource.api.Listable;
+import org.openmrs.module.webservices.rest.web.resource.api.Searchable;
+import org.openmrs.module.webservices.rest.web.response.ResponseException;
+
+@Resource(name = RestConstants.VERSION_1 + AppointmentRestController.APPOINTMENT_SCHEDULING_REST_NAMESPACE
+ + "/timeframeunits", supportedClass = TimeFrameUnits.class, supportedOpenmrsVersions = "1.9.*")
+public class TimeFrameUnitsResource1_9 implements Listable, Searchable {
+
+ @Override
+ public SimpleObject getAll(RequestContext requestContext) throws ResponseException {
+ TimeFrameUnits[] timeFrameUnits = TimeFrameUnits.values();
+ SimpleObject simpleObject = new SimpleObject().add("results", timeFrameUnits);
+ return simpleObject;
+ }
+
+ @Override
+ public String getUri(Object o) {
+ return RestConstants.URI_PREFIX + "/appointmentscheduling/timeframeunits/"
+ + ((AppointmentRequest.AppointmentRequestStatus) o);
+ }
+
+ @Override
+ public SimpleObject search(RequestContext requestContext) throws ResponseException {
+ return null;
+ }
+
+}