forked from openmrs/openmrs-module-appointmentscheduling
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AM-159: Add domain object to capure an Appointment Request
Added web services call for domain object; added min/max values to domain object
- Loading branch information
1 parent
5522685
commit 297d0e0
Showing
12 changed files
with
587 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
140 changes: 140 additions & 0 deletions
140
.../module/appointmentscheduling/rest/resource/openmrs1_9/AppointmentRequestResource1_9.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<AppointmentRequest> { | ||
|
||
@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<AppointmentRequest> doGetAll(RequestContext context) { | ||
return new NeedsPaging<AppointmentRequest>(Context.getService(AppointmentService.class).getAllAppointmentRequests( | ||
context.getIncludeAll()), context); | ||
} | ||
|
||
public String getDisplayString(AppointmentRequest appointmentRequest) { | ||
return appointmentRequest.getAppointmentType().getName() + " : " + appointmentRequest.getStatus(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.