Package org.motechproject.mots.web
Class CommunityHealthWorkerController
- java.lang.Object
-
- org.motechproject.mots.web.BaseController
-
- org.motechproject.mots.web.CommunityHealthWorkerController
-
@Controller public class CommunityHealthWorkerController extends BaseController
This class is responsible manage and manipulateCommunityHealthWorker
entity class.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
DISTRICT_NAME_PARAM
static java.lang.String
FACILITY_NAME_PARAM
static java.lang.String
GROUP_NAME_PARAM
static java.lang.String
SECTOR_NAME_PARAM
static java.lang.String
VILLAGE_NAME_PARAM
-
Constructor Summary
Constructors Constructor Description CommunityHealthWorkerController()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CommunityHealthWorkerDto
findByChwId(java.lang.String chwId)
Find CHW by CHW Id.CommunityHealthWorkerDto
getHealthWorker(java.util.UUID id)
Get community health worker with given id.java.util.List<CommunityHealthWorkerDto>
getHealthWorkers()
Get list of community health workersCommunityHealthWorker
.java.util.List<ChwInfoDto>
getHealthWorkersInfo()
Get list of basic representationChwInfoDto
of selected CHWs.java.util.List<java.lang.String>
getNotSelectedChwIds()
CommunityHealthWorkerDto
saveHealthWorker(java.util.UUID id, @Valid CommunityHealthWorkerDto healthWorkerDto, org.springframework.validation.BindingResult bindingResult)
Update community health worker.org.springframework.data.domain.Page<CommunityHealthWorkerDto>
searchCommunityHealthWorkers(java.lang.String chwId, java.lang.String chwName, java.lang.String phoneNumber, java.lang.String villageName, java.lang.String facilityName, java.lang.String sectorName, java.lang.String districtName, java.lang.String groupName, java.lang.Boolean selected, org.springframework.data.domain.Pageable pageable)
FindsCommunityHealthWorker
s (CHW) matching all of the provided parameters.CommunityHealthWorkerDto
selectHealthWorker(java.util.UUID id, @Valid CommunityHealthWorkerDto healthWorkerDto, org.springframework.validation.BindingResult bindingResult)
Update community health worker from given dto.java.util.Map<java.lang.Integer,java.lang.String>
uploadChwSpreadsheet(java.lang.Boolean selected, org.springframework.web.multipart.MultipartFile file)
Upload list of CHWs in ".csv" format to mots, parse it and save records in DB.-
Methods inherited from class org.motechproject.mots.web.BaseController
checkBindingResult, getErrors
-
-
-
-
Field Detail
-
VILLAGE_NAME_PARAM
public static final java.lang.String VILLAGE_NAME_PARAM
- See Also:
- Constant Field Values
-
FACILITY_NAME_PARAM
public static final java.lang.String FACILITY_NAME_PARAM
- See Also:
- Constant Field Values
-
SECTOR_NAME_PARAM
public static final java.lang.String SECTOR_NAME_PARAM
- See Also:
- Constant Field Values
-
DISTRICT_NAME_PARAM
public static final java.lang.String DISTRICT_NAME_PARAM
- See Also:
- Constant Field Values
-
GROUP_NAME_PARAM
public static final java.lang.String GROUP_NAME_PARAM
- See Also:
- Constant Field Values
-
-
Method Detail
-
getHealthWorkers
@RequestMapping(value="/chw", method=GET) @ResponseStatus(OK) @ResponseBody public java.util.List<CommunityHealthWorkerDto> getHealthWorkers()
Get list of community health workersCommunityHealthWorker
.- Returns:
- list of all community health workers
-
searchCommunityHealthWorkers
@RequestMapping(value="/chw/search", method=GET) @ResponseStatus(OK) @ResponseBody public org.springframework.data.domain.Page<CommunityHealthWorkerDto> searchCommunityHealthWorkers(@RequestParam(value="chwId",required=false) java.lang.String chwId, @RequestParam(value="chwName",required=false) java.lang.String chwName, @RequestParam(value="phoneNumber",required=false) java.lang.String phoneNumber, @RequestParam(value="villageName",required=false) java.lang.String villageName, @RequestParam(value="facilityName",required=false) java.lang.String facilityName, @RequestParam(value="sectorName",required=false) java.lang.String sectorName, @RequestParam(value="districtName",required=false) java.lang.String districtName, @RequestParam(value="groupName",required=false) java.lang.String groupName, @RequestParam(value="selected",required=false) java.lang.Boolean selected, org.springframework.data.domain.Pageable pageable)
FindsCommunityHealthWorker
s (CHW) matching all of the provided parameters.- Parameters:
chwId
- id of CHWchwName
- name of CHWdistrictName
- name of districtfacilityName
- name of facilitygroupName
- name of grouppageable
- object for pagingphoneNumber
- phone number of CHWsectorName
- name of sectorselected
- flag that determines if CHW is selectedvillageName
- name of village- Returns:
- page with
CommunityHealthWorkerDto
If there are no parameters, return all CommunityHealthWorkers.
-
findByChwId
@RequestMapping(value="/chw/findByChwId/{chwId}", method=GET) @ResponseStatus(OK) @ResponseBody public CommunityHealthWorkerDto findByChwId(@PathVariable("chwId") java.lang.String chwId)
Find CHW by CHW Id.- Parameters:
chwId
- chw id to find CHW by.- Returns:
- found CHW
CommunityHealthWorkerDto
-
getHealthWorkersInfo
@RequestMapping(value="/chwInfo", method=GET) @ResponseStatus(OK) @ResponseBody public java.util.List<ChwInfoDto> getHealthWorkersInfo()
Get list of basic representationChwInfoDto
of selected CHWs.- Returns:
- list of
ChwInfoDto
representations of CHWs
-
getNotSelectedChwIds
@RequestMapping(value="/chw/notSelected", method=GET) @ResponseStatus(OK) @ResponseBody public java.util.List<java.lang.String> getNotSelectedChwIds()
-
selectHealthWorker
@RequestMapping(value="/chw/{id}/select", method=PUT) @ResponseStatus(OK) @ResponseBody public CommunityHealthWorkerDto selectHealthWorker(@PathVariable("id") java.util.UUID id, @RequestBody @Valid @Valid CommunityHealthWorkerDto healthWorkerDto, org.springframework.validation.BindingResult bindingResult)
Update community health worker from given dto.- Parameters:
id
- id of CHW to selecthealthWorkerDto
- DTO of community health worker to be updatedbindingResult
- spring object required for validation- Returns:
- updated community health worker
CommunityHealthWorkerDto
-
getHealthWorker
@RequestMapping(value="/chw/{id}", method=GET) @ResponseStatus(OK) @ResponseBody public CommunityHealthWorkerDto getHealthWorker(@PathVariable("id") java.util.UUID id)
Get community health worker with given id.- Parameters:
id
- id of CHW to find- Returns:
- CHW
CommunityHealthWorkerDto
with given id
-
saveHealthWorker
@RequestMapping(value="/chw/{id}", method=PUT) @ResponseStatus(OK) @ResponseBody public CommunityHealthWorkerDto saveHealthWorker(@PathVariable("id") java.util.UUID id, @RequestBody @Valid @Valid CommunityHealthWorkerDto healthWorkerDto, org.springframework.validation.BindingResult bindingResult)
Update community health worker.- Parameters:
id
- id of CHW to updatehealthWorkerDto
- DTO of CHW to updatebindingResult
- spring object for validation- Returns:
- updated CHW
CommunityHealthWorkerDto
-
uploadChwSpreadsheet
@RequestMapping(value="/chw/upload/{selected}", method=POST) @ResponseStatus(OK) @ResponseBody public java.util.Map<java.lang.Integer,java.lang.String> uploadChwSpreadsheet(@PathVariable("selected") java.lang.Boolean selected, @RequestPart("file") org.springframework.web.multipart.MultipartFile file) throws java.io.IOException
Upload list of CHWs in ".csv" format to mots, parse it and save records in DB.- Parameters:
file
- File in ".csv" format to uploadselected
- flag that determines if CHW is selected- Returns:
- map with row numbers as keys and errors as values.
- Throws:
java.io.IOException
- if there is an error while reading file
-
-