Explorar o código

Merge branch 'dev' of trick9191/patient-co-management into dev

trick9191 %!s(int64=7) %!d(string=hai) anos
pai
achega
bedf9656c5

+ 131 - 38
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/specialist/SpecialistService.java

@ -10,6 +10,7 @@ import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.util.http.HttpResponse;
import com.yihu.wlyy.util.http.HttpUtils;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
@ -17,6 +18,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -58,12 +60,33 @@ public class SpecialistService extends BaseService {
                " FROM " +
                " wlyy_doctor d " +
                " WHERE " +
                " d.`level` = '5' " +
                " d.`level` = '4' " +
                " AND `status` = 1";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        return list;
    }
    public List<Map<String,Object>> findHealthAssistantPatientCount()throws Exception{
        List<Map<String,Object>> list = findHealthAssistant();
        if(list!=null&&list.size()>0){
            for(Map<String,Object> map:list){
                map.put("count",getAssistantPatientCount(map.get("code").toString()));
            }
        }
        return list;
    }
    public Long getAssistantPatientCount(String doctor)throws Exception{
        Map<String,Object> param = new HashedMap();
        param.put("doctor",doctor);
        HttpResponse response = HttpUtils.doGet(specialistUrl+"getAssistantPatientCount",param);
        JSONObject  rs = new JSONObject(response.getContent());
        if("succes".equals(rs.getString("message"))){
            return rs.getLong("obj");
        }
        return 0L;
    }
    public List<SignPatientLabel> findLabelbyType(String type,Long teamCode){
        //自定义标签
        if("4".equals(type)){
@ -76,6 +99,49 @@ public class SpecialistService extends BaseService {
        }
    }
    public List<Map<String,Object>> findLabelAndPatientCount(String doctor,String type,Long teamCode)throws Exception{
        //自定义标签
        if("4".equals(type)){
            List<SignPatientLabel> list = signPatientLabelDao.findByLabelTypeAndStatusAndTeamCode(type,1,teamCode);
            return setPatientCount(list,doctor);
        }else{
            //非自定义标签
            List<SignPatientLabel> list = signPatientLabelDao.findByLabelTypeAndStatus(type,1);
            return setPatientCount(list,doctor);
        }
    }
    public List<Map<String,Object>> setPatientCount(List<SignPatientLabel> list,String doctor)throws Exception{
        List<Map<String,Object>> rs = new ArrayList<>();
        if(list!=null&&list.size()>0){
            for(SignPatientLabel label:list){
                Map<String,Object> map = new HashedMap();
                map.put("label",label.getLabelCode());
                map.put("labelName",label.getLabelName());
                map.put("labelType",label.getLabelType());
                map.put("count",getLabelpatientCount(doctor,label.getLabelCode(),label.getLabelType()));
                rs.add(map);
            }
        }
        return rs;
    }
    public Long getLabelpatientCount(String doctor,String labelType,String labelCode)throws Exception{
        Map<String,Object> param = new HashedMap();
        param.put("doctor",doctor);
        param.put("labelType",labelType);
        param.put("labelCode",labelCode);
        HttpResponse response = HttpUtils.doGet(specialistUrl+"getLabelpatientCount",param);
        JSONObject  rs = new JSONObject(response.getContent());
        if("succes".equals(rs.getString("message"))){
            return rs.getLong("obj");
        }
        return 0L;
    }
    public Long findSpecialistPatientRelationCout(String doctor)throws Exception{
        Map<String,Object> param = new HashedMap();
        param.put("doctor",doctor);
@ -123,52 +189,79 @@ public class SpecialistService extends BaseService {
        return "";
    }
    public List<Map<String,Object>> getPatientByLabel(String labelType,String labelCode,Integer page,Integer size){
        String sql="SELECT " +
                " p. NAME, " +
                " p. CODE, " +
                " IFNULL( " +
                "  YEAR ( " +
                "   from_days(datediff(now(), p.birthday)) " +
                "  ), " +
                "  '未知' " +
                " ) age, " +
                " lb.labelName, " +
                " lb.labelType, " +
                " lb.label, " +
                " p.photo, " +
                " h.label_name as health, " +
                " h.label AS healthcode " +
    public JSONArray getPatientByLabel(String doctor,String labelType,String labelCode,Integer page,Integer size)throws Exception{
        Map<String,Object> param = new HashedMap();
        param.put("doctor",doctor);
        param.put("labelType",labelType);
        param.put("labelCode",labelCode);
        param.put("page",page);
        param.put("size",size);
        HttpResponse response = HttpUtils.doGet(specialistUrl+"getPatientByLabel",param);
        JSONObject  rs = new JSONObject(response.getContent());
        if("succes".equals(rs.getString("message"))){
            return rs.getJSONArray("obj");
        }
        return null;
    }
    public List<Map<String,Object>> findDoctorTeamMenmber(String doctor){
        String sql = "SELECT " +
                " d.`code`, " +
                " d. name, " +
                " d.photo, " +
                " d.`level`, " +
                " d.dept, " +
                " d.dept_name, " +
                " d.job, " +
                " d.job_name " +
                " FROM " +
                " ( " +
                " wlyy_admin_team_member m " +
                " JOIN wlyy_doctor d ON d. CODE = m.doctor_code " +
                " WHERE " +
                " m.team_id = ( " +
                "  SELECT " +
                "   i.label_type AS labelType, " +
                "   i.label, " +
                "   i.label_name AS labelName, " +
                "   i.patient " +
                "   id " +
                "  FROM " +
                "   wlyy_sign_patient_label_info i " +
                "   wlyy_admin_team t " +
                "  WHERE " +
                "   i.label = '"+labelCode+"' " +
                "  AND i.label_type = '"+labelType+"' " +
                "  AND i.`status` = '1' " +
                " ) lb " +
                " JOIN wlyy_patient p ON p. CODE = lb.patient " +
                " LEFT JOIN ( " +
                " SELECT " +
                "  t.label, " +
                "  t.label_name, " +
                "  t.patient " +
                "   t.leader_code = '"+doctor+"' " +
                " )";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        return list;
    }
    public List<Map<String,Object>> getDoctorInHospital(String doctor,String name,Integer page,Integer size){
        String sql = "SELECT " +
                " d. name, " +
                " d. code, " +
                " d.job, " +
                " d.job_name, " +
                " d.dept, " +
                " d.dept_name, " +
                " d.photo " +
                " FROM " +
                "  wlyy_sign_patient_label_info t " +
                " wlyy_doctor d " +
                " WHERE " +
                "  t.label_type = '8' " +
                " AND t.`status` = '1' " +
                " ) h ON h.patient = lb.patient " +
                " LIMIT LIMIT "+(page-1)*size+","+size;
                " d.hospital = ( " +
                "  SELECT " +
                "   dd.hospital " +
                "  FROM " +
                "   wlyy_doctor dd " +
                "  WHERE " +
                "   dd. CODE = '"+doctor+"' " +
                " ) " +
                " AND d.`level` = 4 ";
        if(StringUtils.isNotBlank(name)){
            sql = sql +" AND d.`name` LIKE '%"+name+"%'";
        }
        sql = sql +" LIMIT "+(page-1)*size+","+size;
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        return list;
    }
}

+ 103 - 47
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/specialist/SpecialistController.java

@ -12,6 +12,7 @@ import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
 * Created by Trick on 2018/5/31.
@ -24,106 +25,161 @@ public class SpecialistController extends BaseController {
    @Autowired
    private SpecialistService specialistService;
    @RequestMapping(value = "setPatientLabelInfo",method = RequestMethod.POST)
    @RequestMapping(value = "setPatientLabelInfo", method = RequestMethod.POST)
    @ApiOperation("设置居民标签")
    public String setPatientLabelInfo(@ApiParam(name = "json", value = "居民标签实体") @RequestParam(required = true) String json){
    public String setPatientLabelInfo(@ApiParam(name = "json", value = "居民标签实体") @RequestParam(required = true) String json) {
        try {
            List<SignPatientLabelInfo> info = (List<SignPatientLabelInfo>) JSONArray.parseArray(json, SignPatientLabelInfo.class);
            return write(200,"获取成功","data",specialistService.setPatientLabelInfo(info));
        }catch (Exception e){
            return write(200, "获取成功", "data", specialistService.setPatientLabelInfo(info));
        } catch (Exception e) {
            error(e);
            return error(-1,"请求失败");
            return error(-1, "请求失败");
        }
    }
    @RequestMapping(value = "findHealthAssistant",method = RequestMethod.GET)
    @RequestMapping(value = "findHealthAssistant", method = RequestMethod.GET)
    @ApiOperation("获取所有计管师")
    public String findHealthAssistant(){
    public String findHealthAssistant() {
        try {
            return write(200,"获取成功","data",specialistService.findHealthAssistant());
        }catch (Exception e){
            return write(200, "获取成功", "data", specialistService.findHealthAssistant());
        } catch (Exception e) {
            error(e);
            return error(-1,"请求失败");
            return error(-1, "请求失败");
        }
    }
    @RequestMapping(value = "findHealthAssistantPatientCount", method = RequestMethod.GET)
    @ApiOperation("获取所有计管师下居民数目")
    public String findHealthAssistantPatientCount(){
        try {
            return write(200, "获取成功", "data", specialistService.findHealthAssistantPatientCount());
        } catch (Exception e) {
            error(e);
            return error(-1, "请求失败");
        }
    }
    @RequestMapping(value = "findLabelbyType",method = RequestMethod.GET)
    @RequestMapping(value = "findLabelbyType", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("获取标签")
    public String findLabelbyType(@ApiParam(name = "type", value = "标签类型") @RequestParam(required = true)String type,
                                  @ApiParam(name = "teamCode", value = "团队id") @RequestParam(required = false)Long teamCode){
    public String findLabelbyType(@ApiParam(name = "type", value = "标签类型") @RequestParam(required = true) String type,
                                  @ApiParam(name = "teamCode", value = "团队id") @RequestParam(required = false) Long teamCode) {
        try {
            return write(200,"获取成功","data",specialistService.findLabelbyType(type,teamCode));
        }catch (Exception e){
            return write(200, "获取成功", "data", specialistService.findLabelbyType(type, teamCode));
        } catch (Exception e) {
            error(e);
            return error(-1,"请求失败");
            return error(-1, "请求失败");
        }
    }
    @RequestMapping(value = "findSpecialistPatientRelationCout",method = RequestMethod.GET)
    @RequestMapping(value = "findLabelAndPatientCount", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("获取标签与居民数量")
    public String findLabelAndPatientCount(@ApiParam(name = "doctor", value = "医生") @RequestParam(required = true)String doctor,
                                           @ApiParam(name = "type", value = "标签类型") @RequestParam(required = true)String type,
                                           @ApiParam(name = "teamCode", value = "团队id") @RequestParam(required = false)Long teamCode) {
        try {
            return write(200, "获取成功", "data", specialistService.findLabelAndPatientCount(doctor,type,teamCode));
        } catch (Exception e) {
            error(e);
            return error(-1, "请求失败");
        }
    }
        @RequestMapping(value = "findSpecialistPatientRelationCout", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("获取专科医生下未分配标签居民数目")
    public String findSpecialistPatientRelationCout(@ApiParam(name = "doctor", value = "医生code") @RequestParam(required = true)String doctor){
    public String findSpecialistPatientRelationCout(@ApiParam(name = "doctor", value = "医生code") @RequestParam(required = true) String doctor) {
        try {
            return write(200,"获取成功","data",specialistService.findSpecialistPatientRelationCout(doctor));
        }catch (Exception e){
            return write(200, "获取成功", "data", specialistService.findSpecialistPatientRelationCout(doctor));
        } catch (Exception e) {
            error(e);
            return error(-1,"请求失败");
            return error(-1, "请求失败");
        }
    }
    @RequestMapping(value = "findNoLabelPatientRelation",method = RequestMethod.GET)
    @RequestMapping(value = "findNoLabelPatientRelation", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("获取专科医生下未分配标签居民")
    public  String findNoLabelPatientRelation(@ApiParam(name = "doctor", value = "医生code") @RequestParam(required = true)String doctor){
    public String findNoLabelPatientRelation(@ApiParam(name = "doctor", value = "医生code") @RequestParam(required = true) String doctor) {
        try {
            return write(200,"获取成功","data",specialistService.findNoLabelPatientRelation(doctor));
        }catch (Exception e){
            return write(200, "获取成功", "data", specialistService.findNoLabelPatientRelation(doctor));
        } catch (Exception e) {
            error(e);
            return error(-1,"请求失败");
            return error(-1, "请求失败");
        }
    }
    @RequestMapping(value = "findPatientRelatioByAssistant",method = RequestMethod.GET)
    @RequestMapping(value = "findPatientRelatioByAssistant", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("获取计管师下未分配标签居民")
    public String findPatientRelatioByAssistant(@ApiParam(name = "assistant", value = "计管师") @RequestParam(required = true)String assistant,
                                                @ApiParam(name = "page", value = "第几页,1开始") @RequestParam(required = true)Integer page,
                                                @ApiParam(name = "size", value = "每页大小") @RequestParam(required = true)Integer size)throws Exception {
    public String findPatientRelatioByAssistant(@ApiParam(name = "assistant", value = "计管师") @RequestParam(required = true) String assistant,
                                                @ApiParam(name = "page", value = "第几页,1开始") @RequestParam(required = true) Integer page,
                                                @ApiParam(name = "size", value = "每页大小") @RequestParam(required = true) Integer size) throws Exception {
        try {
            return write(200,"获取成功","data",specialistService.findPatientRelatioByAssistant(assistant,page,size));
        }catch (Exception e){
            return write(200, "获取成功", "data", specialistService.findPatientRelatioByAssistant(assistant, page, size));
        } catch (Exception e) {
            error(e);
            return error(-1,"请求失败");
            return error(-1, "请求失败");
        }
    }
    @RequestMapping(value = "saveHealthAssistant",method = RequestMethod.POST)
    @RequestMapping(value = "saveHealthAssistant", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("分配计管师居民")
    public String saveHealthAssistant(String json){
    public String saveHealthAssistant(String json) {
        try {
            return write(200,"获取成功","data",specialistService.saveHealthAssistant(json));
        }catch (Exception e){
            return write(200, "获取成功", "data", specialistService.saveHealthAssistant(json));
        } catch (Exception e) {
            error(e);
            return error(-1,"请求失败");
            return error(-1, "请求失败");
        }
    }
    @RequestMapping(value = "getPatientByLabel",method = RequestMethod.POST)
    @RequestMapping(value = "getPatientByLabel", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("获取标签下居民")
    public String getPatientByLabel(@ApiParam(name = "labelType", value = "标签类型")String labelType,
                                    @ApiParam(name = "labelCode", value = "标签code")String labelCode,
                                    @ApiParam(name = "page", value = "第几页,1开始")Integer page,
                                    @ApiParam(name = "size", value = "每页大小")Integer size) {
    public String getPatientByLabel(@ApiParam(name = "doctor", value = "医生code") @RequestParam(required = true)String doctor,
                                    @ApiParam(name = "labelType", value = "标签类型")@RequestParam(required = true) String labelType,
                                    @ApiParam(name = "labelCode", value = "标签code") @RequestParam(required = true)String labelCode,
                                    @ApiParam(name = "page", value = "第几页,1开始") @RequestParam(required = true)Integer page,
                                    @ApiParam(name = "size", value = "每页大小")@RequestParam(required = true) Integer size) {
        try {
            return write(200,"获取成功","data",specialistService.getPatientByLabel(labelType,labelCode,page,size));
        }catch (Exception e){
            return write(200, "获取成功", "data", specialistService.getPatientByLabel(doctor,labelType, labelCode, page, size));
        } catch (Exception e) {
            error(e);
            return error(-1,"请求失败");
            return error(-1, "请求失败");
        }
    }
}
    @RequestMapping(value = "findDoctorTeamMenmber", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("获取团队成员")
    public String findDoctorTeamMenmber(@ApiParam(name = "doctor", value = "医生code") @RequestParam(required = true)String doctor) {
        try {
            return write(200, "获取成功", "data", specialistService.findDoctorTeamMenmber(doctor));
        } catch (Exception e) {
            error(e);
            return error(-1, "请求失败");
        }
    }
    @RequestMapping(value = "getDoctorInHospital", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("获取院内工作人员")
    public String getDoctorInHospital(@ApiParam(name = "doctor", value = "医生code") @RequestParam(required = true)String doctor,
                                      @ApiParam(name = "name", value = "医生姓名模糊") @RequestParam(required = false)String name,
                                      @ApiParam(name = "page", value = "第几页,1开始") @RequestParam(required = true)Integer page,
                                      @ApiParam(name = "size", value = "每页大小") @RequestParam(required = true)Integer size){
        try {
            return write(200, "获取成功", "data", specialistService.getDoctorInHospital(doctor,name,page,size));
        } catch (Exception e) {
            error(e);
            return error(-1, "请求失败");
        }
    }
}

+ 1 - 1
patient-co/patient-co-wlyy/src/main/resources/application-devtest.yml

@ -35,7 +35,7 @@ im:
#专病配置
specialist:
  url: http://localhost:10051/svr-wlyy-specialist/
  url: http://localhost:10051/svr-specialist/
#物联网配置
iot:
#  url: http://192.168.131.24:8088/svr-iot/

+ 1 - 1
patient-co/patient-co-wlyy/src/main/resources/application-localtest.yml

@ -31,7 +31,7 @@ im:
#专病配置
specialist:
  url: http://localhost:10051/svr-wlyy-specialist/
  url: http://localhost:10051/svr-specialist/
#物联网配置
iot:
  url: http://192.168.131.24:8088/svr-iot/

+ 1 - 1
patient-co/patient-co-wlyy/src/main/resources/application-test.yml

@ -30,7 +30,7 @@ im:
#专病配置基础服务地址
specialist:
  url: http://172.19.103.33:10051/svr-wlyy-specialist/
  url: http://172.19.103.33:10051/svr-specialist/
#物联网配置
iot:
  url: http://172.19.103.33:8088/svr-iot/