Package org.motechproject.mots.service
Class CommunityHealthWorkerService
- java.lang.Object
-
- org.motechproject.mots.service.CommunityHealthWorkerService
-
@Service public class CommunityHealthWorkerService extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description CommunityHealthWorkerService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CommunityHealthWorkerfindByChwId(java.lang.String chwId)CommunityHealthWorkergetHealthWorker(java.util.UUID id)java.lang.Iterable<CommunityHealthWorker>getHealthWorkers()java.util.List<ChwInfoDto>getHealthWorkersInfoDtos()Gets selected CHWs and returns their short representation using mapper.java.util.List<java.lang.String>getNotSelectedChwIds()Get list of not selected CHW Ids.java.util.Map<java.lang.Integer,java.lang.String>processChwCsv(org.springframework.web.multipart.MultipartFile chwCsvFile, java.lang.Boolean selected)Processes CSV file which contains CHW list and returns list of errors.CommunityHealthWorkerDtosaveHealthWorker(java.util.UUID id, CommunityHealthWorkerDto chw)UpdateCommunityHealthWorker(CHW) and IVR Subscriber.org.springframework.data.domain.Page<CommunityHealthWorker>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)FindsCommunityHealthWorkers (CHW) matching all of the provided parameters.CommunityHealthWorkerselectHealthWorker(CommunityHealthWorker healthWorker)Select CHW, create IVR Subscriber and assign it to CHW.
-
-
-
Method Detail
-
getHealthWorkers
@PreAuthorize("hasRole(\'ROLE_CHW_READ\')") public java.lang.Iterable<CommunityHealthWorker> getHealthWorkers()
-
getHealthWorkersInfoDtos
@PreAuthorize("hasRole(\'ROLE_CHW_READ\')") public java.util.List<ChwInfoDto> getHealthWorkersInfoDtos()Gets selected CHWs and returns their short representation using mapper.- Returns:
- List of CHWs short representation
-
getNotSelectedChwIds
public java.util.List<java.lang.String> getNotSelectedChwIds()
Get list of not selected CHW Ids.- Returns:
- list of not selected CHW Ids
-
findByChwId
public CommunityHealthWorker findByChwId(java.lang.String chwId)
-
searchCommunityHealthWorkers
@PreAuthorize("hasRole(\'ROLE_CHW_READ\')") public org.springframework.data.domain.Page<CommunityHealthWorker> 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)FindsCommunityHealthWorkers (CHW) matching all of the provided parameters. If there are no parameters, return all CommunityHealthWorkers.- Parameters:
pageable- pagination parameters (page size, page number, sort order)selected- flag indicating that CHW is selectedvillageName-Villageto which CHW may belongsectorName-Sectorto which CHW may belongphoneNumber- phone nubmer of CHWgroupName-Groupto which CHW may belongfacilityName-Facilityto which CHW may belongdistrictName-Districtto which CHW may belongchwName- name of a CHWchwId- id of a CHW- Returns:
- page with found CHWs
-
selectHealthWorker
@PreAuthorize("hasRole(\'ROLE_CHW_WRITE\')") public CommunityHealthWorker selectHealthWorker(CommunityHealthWorker healthWorker)Select CHW, create IVR Subscriber and assign it to CHW. Initiate empty AssignedModules instance for selected CHW.- Parameters:
healthWorker- CHW to be selected- Returns:
- saved CHW
-
getHealthWorker
@PreAuthorize("hasRole(\'ROLE_CHW_READ\')") public CommunityHealthWorker getHealthWorker(java.util.UUID id)
-
processChwCsv
@PreAuthorize("hasRole(\'ROLE_UPLOAD_CHW_CSV\')") public java.util.Map<java.lang.Integer,java.lang.String> processChwCsv(org.springframework.web.multipart.MultipartFile chwCsvFile, java.lang.Boolean selected) throws java.io.IOExceptionProcesses CSV file which contains CHW list and returns list of errors.- Parameters:
chwCsvFile- CSV file with CHW listselected- flag indicating that CHW is selected- Returns:
- map with row numbers as keys and errors as values.
- Throws:
java.io.IOException- in case of file issues
-
saveHealthWorker
@PreAuthorize("hasRole(\'ROLE_CHW_WRITE\')") public CommunityHealthWorkerDto saveHealthWorker(java.util.UUID id, CommunityHealthWorkerDto chw)UpdateCommunityHealthWorker(CHW) and IVR Subscriber.- Parameters:
id- id of the CHW to updatechw- CHW to update- Returns:
- saved CHW
-
-