-
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.
EA-198: Add support for configuring (and fetching) Mother Child relat… (
#239)
- Loading branch information
1 parent
81bf287
commit ae67609
Showing
5 changed files
with
58 additions
and
4 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
52 changes: 52 additions & 0 deletions
52
.../src/main/java/org/openmrs/module/emrapi/web/controller/MothersAndChildrenController.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,52 @@ | ||
package org.openmrs.module.emrapi.web.controller; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
|
||
import java.util.List; | ||
|
||
import org.openmrs.module.emrapi.maternal.MaternalService; | ||
import org.openmrs.module.emrapi.maternal.MotherAndChild; | ||
import org.openmrs.module.emrapi.maternal.MothersAndChildrenSearchCriteria; | ||
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; | ||
|
||
@Controller | ||
public class MothersAndChildrenController { | ||
|
||
@Autowired | ||
private MaternalService maternalService; | ||
|
||
@RequestMapping(method = RequestMethod.GET, value = "/rest/**/emrapi/maternal/mothersAndChildren") | ||
@ResponseBody | ||
public SimpleObject getMothersAndChildren( | ||
HttpServletRequest request, | ||
HttpServletResponse response, | ||
@RequestParam(required = false, value = "mother") List<String> motherUuids, | ||
@RequestParam(required = false, value = "child") List<String> childUuids, | ||
@RequestParam(required = false, value = "requireMotherHasActiveVisit") boolean requireMotherHasActiveVisit, | ||
@RequestParam(required = false, value = "requireChildHasActiveVisit") boolean requireChildHasActiveVisit, | ||
@RequestParam(required = false, value = "requireChildBornDuringMothersActiveVisit") boolean requireChildBornDuringMothersActiveVisit | ||
) { | ||
RequestContext context = RestUtil.getRequestContext(request, response, Representation.DEFAULT); | ||
MothersAndChildrenSearchCriteria criteria = new MothersAndChildrenSearchCriteria(); | ||
criteria.setMotherUuids(motherUuids); | ||
criteria.setChildUuids(childUuids); | ||
criteria.setMotherRequiredToHaveActiveVisit(requireMotherHasActiveVisit); | ||
criteria.setChildRequiredToHaveActiveVisit(requireChildHasActiveVisit); | ||
criteria.setChildRequiredToBeBornDuringMothersActiveVisit(requireChildBornDuringMothersActiveVisit); | ||
List<MotherAndChild> motherAndChildList = maternalService.getMothersAndChildren(criteria); | ||
return new NeedsPaging<>(motherAndChildList, context).toSimpleObject(new SimpleBeanConverter<MotherAndChild>()); | ||
} | ||
|
||
} |