-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add initial REST controller and add some fixes for performance and to…
… mitigate errors related to infinite recursion when serializing rest data
- Loading branch information
Showing
7 changed files
with
81 additions
and
48 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
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
48 changes: 48 additions & 0 deletions
48
omod/src/main/java/org/openmrs/module/emrapi/web/controller/InpatientRequestController.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,48 @@ | ||
package org.openmrs.module.emrapi.web.controller; | ||
|
||
import org.openmrs.Location; | ||
import org.openmrs.module.emrapi.adt.AdtService; | ||
import org.openmrs.module.emrapi.adt.InpatientRequest; | ||
import org.openmrs.module.emrapi.adt.InpatientRequestSearchCriteria; | ||
import org.openmrs.module.emrapi.disposition.DispositionType; | ||
import org.openmrs.module.emrapi.rest.converter.SimpleBeanConverter; | ||
import org.openmrs.module.webservices.rest.SimpleObject; | ||
import org.openmrs.module.webservices.rest.web.RequestContext; | ||
import org.openmrs.module.webservices.rest.web.RestUtil; | ||
import org.openmrs.module.webservices.rest.web.representation.Representation; | ||
import org.openmrs.module.webservices.rest.web.resource.impl.NeedsPaging; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestMethod; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.ResponseBody; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
import java.util.List; | ||
|
||
@Controller | ||
public class InpatientRequestController { | ||
|
||
@Autowired | ||
private AdtService adtService; | ||
|
||
@RequestMapping(method = RequestMethod.GET, value = "/rest/v1/emrapi/inpatient/request") | ||
@ResponseBody | ||
public SimpleObject getInpatientRequests( | ||
HttpServletRequest request, | ||
HttpServletResponse response, | ||
@RequestParam(required = false, value = "visitLocation") Location visitLocation, | ||
@RequestParam(required = false, value = "dispositionLocation") List<Location> dispositionLocations, | ||
@RequestParam(required = false, value = "dispositionType") List<DispositionType> dispositionTypes | ||
) { | ||
RequestContext context = RestUtil.getRequestContext(request, response, Representation.REF); | ||
InpatientRequestSearchCriteria criteria = new InpatientRequestSearchCriteria(); | ||
criteria.setVisitLocation(visitLocation); | ||
criteria.setDispositionLocations(dispositionLocations); | ||
criteria.setDispositionTypes(dispositionTypes); | ||
List<InpatientRequest> requests = adtService.getInpatientRequests(criteria); | ||
return new NeedsPaging<>(requests, context).toSimpleObject(new SimpleBeanConverter<InpatientRequest>()); | ||
} | ||
} |
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