Class CommunityHealthWorkerController

    • Constructor Detail

      • CommunityHealthWorkerController

        public CommunityHealthWorkerController()
    • Method Detail

      • getHealthWorkers

        @RequestMapping(value="/chw",
                        method=GET)
        @ResponseStatus(OK)
        @ResponseBody
        public java.util.List<CommunityHealthWorkerDto> getHealthWorkers()
        Get list of community health workers CommunityHealthWorker.
        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)
        Finds CommunityHealthWorkers (CHW) matching all of the provided parameters.
        Parameters:
        chwId - id of CHW
        chwName - name of CHW
        districtName - name of district
        facilityName - name of facility
        groupName - name of group
        pageable - object for paging
        phoneNumber - phone number of CHW
        sectorName - name of sector
        selected - flag that determines if CHW is selected
        villageName - 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 representation ChwInfoDto 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 select
        healthWorkerDto - DTO of community health worker to be updated
        bindingResult - 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 update
        healthWorkerDto - DTO of CHW to update
        bindingResult - 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 upload
        selected - 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