Переглянути джерело

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

chenweida 8 роки тому
батько
коміт
d2c3a3c70c

+ 117 - 101
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java

@ -1722,68 +1722,81 @@ public class FamilyContractService extends BaseService {
        return result;
    }
    public Map<String, Object> findNoHealthSignFamilyHealth(String doctor, Integer page, Integer pagesize, String patientName, String patientAddr) {
        Map<String, Object> returnMap = new HashMap();
        if (pagesize == null || pagesize <= 0) {
            pagesize = 10;
        }
        if (page == null || page <= 0) {
            page = 1;
        }
        int start = (page - 1) * pagesize;
        //先找出该医生下面没有健康管理师的患者 然后在去患者表找出该患者
        StringBuffer sql = new StringBuffer("" +
                " select p.* from wlyy_patient p where p.code in " +
                " (select a.patient code from wlyy_sign_family a where a.type = 2 and a.status >= 1 and a.doctor_health is null and a.doctor='" + doctor + "' order by a.czrq desc ) ");
        StringBuffer countSql = new StringBuffer("" +
                " select count(*) from wlyy_patient p where p.code in " +
                " (select a.patient code from wlyy_sign_family a where a.type = 2 and a.status >= 1 and a.doctor_health is null and a.doctor='" + doctor + "' order by a.czrq desc ) ");
        if (!org.springframework.util.StringUtils.isEmpty(patientName)) {
            sql.append(" and name like '%" + patientName + "%'");
            countSql.append(" and name like '%" + patientName + "%'");
        }
        if (!org.springframework.util.StringUtils.isEmpty(patientAddr)) {
            sql.append(" and address like '%" + patientAddr + "%'");
            countSql.append(" and address like '%" + patientAddr + "%'");
        }
        sql.append(" limit " + start + "," + pagesize + "");
        List<Patient> returnList = jdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper(Patient.class));
        //得到疾病标签
        StringBuffer dieaseSql = new StringBuffer("" +
                " select p.* from wlyy_sign_patient_label_info p where p.label_type='2' and p.status=1 and  p.patient in " +
                " (select a.patient code from wlyy_sign_family a where a.type = 2 and a.status >= 1 and a.doctor_health is null and a.doctor='" + doctor + "' order by a.czrq desc ) ");
        List<SignPatientLabelInfo> dieaseList = jdbcTemplate.query(dieaseSql.toString(), new BeanPropertyRowMapper(SignPatientLabelInfo.class));
        Map<String, List<SignPatientLabelInfo>> diseaseMap = new HashMap<>();
        if (dieaseList != null && dieaseList.size() > 0) {
            for (SignPatientLabelInfo signPatientLabelInfo : dieaseList) {
                List<SignPatientLabelInfo> signPatientLabelInfoTemp = diseaseMap.get(signPatientLabelInfo.getPatient());
                if (signPatientLabelInfoTemp != null) {
                    signPatientLabelInfoTemp.add(signPatientLabelInfo);
                } else {
                    signPatientLabelInfoTemp = new ArrayList<>();
                    signPatientLabelInfoTemp.add(signPatientLabelInfo);
                }
                diseaseMap.put(signPatientLabelInfo.getPatient(), signPatientLabelInfoTemp);
    public JSONArray findNoHealthSignFamilyHealthByParams(String doctorCode, String patientAddr, String patientName) {
        JSONArray returnMap = new JSONArray();
        String sql = "select a.signcode,a.name,a.address,a.code,a.hasopenid,a.idcard from( SELECT " +
                "  sf.CODE signcode, " +
                "  p.name name, " +
                "  p.name address, " +
                "  p.code code, " +
                "  CASE WHEN p.openid is null THEN '0' WHEN p.openid='' THEN '0' else 1 END hasopenid, " +
                "  p.idcard idcard " +
                " FROM " +
                " wlyy_sign_family sf " +
                " JOIN wlyy_patient p ON sf.patient = p.CODE " +
                " WHERE " +
                " sf.type = 2 " +
                " AND sf. STATUS >= 0 " +
                " and sf.doctor = ? "+
                " AND ( sf.doctor_health is null or sf.doctor_health ='' ) ) a where 1=1" ;
        if(!org.springframework.util.StringUtils.isEmpty(patientAddr)){
            sql+= " AND a.address like '%"+patientAddr+"%'";
        }
        if(!org.springframework.util.StringUtils.isEmpty(patientName)){
            sql+= " AND a.name like '%"+patientName+"%'";
        }
        List<Map<String, Object>> datas =  jdbcTemplate.queryForList(sql, doctorCode );
        if(datas!=null&&datas.size()>0){
            for(Map<String, Object> map:datas){
                returnMap.put(new JSONObject(map));
            }
        }
        if (returnList != null && returnList.size() > 0) {
            for (Patient patient : returnList) {
                List<SignPatientLabelInfo> signPatientLabelInfoTemp = diseaseMap.get(patient.getCode());
                patient.setLabelInfos(signPatientLabelInfoTemp);
        return returnMap;
    }
    public JSONObject findNoHealthSignFamilyHealth(String doctorCode, String labelType, String patientName) {
        JSONObject returnMap = new JSONObject();
        //健康管理师
        String sql = "SELECT " +
                "  sf. CODE signcode, " +
                "  p.name name, " +
                "  p.code code, " +
                "  CASE WHEN p.openid is null THEN '0' WHEN p.openid='' THEN '0' else 1 END hasopenid, " +
                "  sp.id labelid, " +
                "  CASE WHEN sp.label_name is null THEN '未标注' WHEN sp.label_name='' THEN '未标注' else sp.label_name END labelname, "+
                "  sp.label_type labeltype, " +
                "  p.idcard idcard " +
         " FROM " +
                " wlyy_sign_family sf " +
                " JOIN wlyy_patient p ON sf.patient = p.CODE " +
                " left JOIN wlyy_sign_patient_label_info sp ON sf.patient = sp.patient AND sp.label_type = ? AND sp.`status` = 1 " +
          " WHERE " +
                " sf.type = 2 " +
                " AND sf. STATUS >= 0 " +
                " and sf.doctor = ? "+
                " AND ( sf.doctor_health is null or sf.doctor_health ='' ) " ;
        List<Map<String, Object>> datas = null;
        //查找居民
        datas = jdbcTemplate.queryForList(sql,labelType , doctorCode );
        //根据类别查找标签
        List<SignPatientLabel> s = labelDao.findByLabelTypeAndStatus(labelType, 1);
        if (s != null && s.size() > 0) {
            for (SignPatientLabel one : s) {
                returnMap.put(one.getLabelName(), new JSONArray());
            }
            if (datas != null && datas.size() > 0) {
                for (Map<String, Object> map : datas) {
                    JSONObject jo = new JSONObject(map);
                    JSONArray jr = returnMap.getJSONArray(jo.get("labelname").toString());
                    //判断是否为空
                    if (jr == null) {
                        jr = new JSONArray();
                    }
                    jr.put(jo);
                    returnMap.put(jo.get("labelname").toString(), jr);
                }
            }
        }
        Integer allCount = jdbcTemplate.queryForObject(countSql.toString(), Integer.class);
        if (allCount % pagesize == 0) {
            returnMap.put("count", allCount / pagesize);
        } else {
            returnMap.put("count", (allCount / pagesize) + 1);
        }
        returnMap.put("returnList", returnList);
        return returnMap;
    }
@ -2038,54 +2051,48 @@ public class FamilyContractService extends BaseService {
        List<Map<String, Object>> datas = null;
        if (doctor.getLevel() == 3) {
            //健康管理师
            String sql = "SELECT sf. CODE signcode, " +
                    " p.`name` name, " +
                    " p. CODE `code`, " +
                    " case p.openid when null then 0 when \"\" then 0 else 1 end hasopenid, "+
                    " sp.id labelid, " +
                    " sp.label_name labelname, " +
                    " sp.label_type labeltype, "+
                    " p.idcard idcard " +
           " FROM " +
                    " wlyy_sign_family sf, " +
                    " wlyy_patient p, " +
                    " wlyy_sign_patient_label_info sp " +
           " WHERE" +
                    " sf.patient = p.CODE " +
                    " AND p. CODE = sp.patient " +
                    " AND sf.type = 2 " +
            String sql = "SELECT " +
                    "  sf. CODE signcode, " +
                    "  p.name name, " +
                    "  p.code code, " +
                    "  CASE WHEN p.openid is null THEN '0' WHEN p.openid='' THEN '0' else 1 END hasopenid, " +
                    "  sp.id labelid, " +
                     " CASE WHEN sp.label_name is null THEN '未标注' WHEN sp.label_name='' THEN '未标注' else sp.label_name END labelname, "+
                    "  sp.label_type labeltype, " +
                    "  p.idcard idcard " +
                    " FROM " +
                    " wlyy_sign_family sf " +
                    " JOIN wlyy_patient p ON sf.patient = p.CODE " +
                    " left JOIN wlyy_sign_patient_label_info sp ON sf.patient = sp.patient AND sp.label_type = ? AND sp.`status` = 1 " +
                    " WHERE " +
                    " sf.type = 2 " +
                    " AND sf. STATUS >= 0 " +
                    " and sp.`status`=1 " +
                    " and sf.doctor_health = ? " +
                    " and sp.label_type= ?";
                    " and sf.doctor_health = ? ";
            //查找居民
            datas = jdbcTemplate.queryForList(sql, doctorCode, labelType);
            datas = jdbcTemplate.queryForList(sql, labelType, doctorCode);
        } else if (doctor.getLevel() == 2) {
            //健康管理师
            String sql = "SELECT sf. CODE signcode, " +
                    " p.`name` name, " +
                    " p. CODE `code`, " +
                    " sp.id labelid, " +
                    " sp.label_name labelname, " +
                    " case p.openid when null then 0 when \"\" then 0 else 1 end hasopenid, "+
                    " sp.label_type labeltype, "+
                    " p.idcard idcard " +
            " FROM " +
                    " wlyy_sign_family sf, " +
                    " wlyy_patient p, " +
                    " wlyy_sign_patient_label_info sp " +
            " WHERE" +
                    " sf.patient = p.CODE " +
                    " AND p. CODE = sp.patient " +
                    " AND sf.type = 2 " +
            String sql = "SELECT " +
                    "  sf. CODE signcode, " +
                    "  p.name name, " +
                    "  p.code code, " +
                    "  CASE WHEN p.openid is null THEN '0' WHEN p.openid='' THEN '0' else 1 END hasopenid, " +
                    "  sp.id labelid, " +
                    " CASE WHEN sp.label_name is null THEN '未标注' WHEN sp.label_name='' THEN '未标注' else sp.label_name END labelname, "+
                    "  sp.label_type labeltype, " +
                    "  p.idcard idcard " +
                    " FROM " +
                    " wlyy_sign_family sf " +
                    " JOIN wlyy_patient p ON sf.patient = p.CODE " +
                    " left JOIN wlyy_sign_patient_label_info sp ON sf.patient = sp.patient AND sp.label_type = ? AND sp.`status` = 1 " +
                    " WHERE " +
                    " sf.type = 2 " +
                    " AND sf. STATUS >= 0 " +
                    " and sp.`status`=1 " +
                    " and ( sf.doctor = ? or sf.doctor_health = ? ) " +
                    " and sp.label_type= ?";
                    " and ( sf.doctor = ? or sf.doctor_health = ? ) ";
            //查找居民
            datas = jdbcTemplate.queryForList(sql, doctorCode,doctorCode, labelType);
            datas = jdbcTemplate.queryForList(sql, labelType, doctorCode, doctorCode);
        } else {
            throw new Exception("参数错误");
@ -2094,15 +2101,24 @@ public class FamilyContractService extends BaseService {
        List<SignPatientLabel> s = labelDao.findByLabelTypeAndStatus(labelType, 1);
        if (s != null && s.size() > 0) {
            for (SignPatientLabel one : s) {
                returnMap.put(one.getLabelCode(), new JSONArray());
                returnMap.put(one.getLabelName(), new JSONArray());
            }
            if (datas != null && datas.size() > 0) {
                for (Map<String, Object> map : datas) {
                    JSONObject jo=new JSONObject(map);
                    returnMap.getJSONArray(jo.get("labeltype").toString()).put(jo);;
                    JSONObject jo = new JSONObject(map);
                    //判断name是否为空 为空就是未标注
                    //把患者添加到对应的组
                    JSONArray jr = returnMap.getJSONArray(jo.get("labelname").toString());
                    if (jr == null) {
                        jr = new JSONArray();
                    }
                    jr.put(jo);
                    returnMap.put(jo.get("labelname").toString(), jr);
                }
            }
        }
        return returnMap;
    }
}

+ 24 - 53
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorFamilyContractController.java

@ -117,7 +117,7 @@ public class DoctorFamilyContractController extends WeixinBaseController {
    @ResponseBody
    public String getPatientByLable(String labelType) {
        try {
            JSONObject list = familyContractService.getPatientByLable("D20161008002", labelType);
            JSONObject list = familyContractService.getPatientByLable(getUID(), labelType);
            return write(200, "查询成功", "data", list);
        } catch (Exception e) {
            return error(-1, "查询失败");
@ -827,71 +827,42 @@ public class DoctorFamilyContractController extends WeixinBaseController {
    /**
     * 获取没有健康管理师的患者列表
     *
     * @param doctor      医生code
     * @param page        当前页
     * @param pageSize    每页显示条数
     * @param patientName 患者名称
     * @param patientAddr 患者居住地址
     * @return
     */
    @RequestMapping(value = "/findNoHealthSignFamilyHealth")
    @ResponseBody
    public String findNoHealthSignFamilyHealth(
            String doctor,
            Integer page,
            Integer pageSize,
            @RequestParam(required = false) String patientName,
            @RequestParam(required = false) String patientAddr) {
            String labelType,
            @RequestParam(required = false) String patientName) {
        try {
            JSONObject returnJo = new JSONObject();
            JSONArray array = new JSONArray();
            Map<String, Object> returnMap = familyContractService.findNoHealthSignFamilyHealth(doctor, page, pageSize, patientName, patientAddr);
            List<Patient> list = (List<Patient>) returnMap.get("returnList");
            Integer count = (Integer) returnMap.get("count");
            if (list != null) {
                for (Patient sf : list) {
                    if (sf == null) {
                        continue;
                    }
                    JSONObject json = new JSONObject();
                    //json.put("signCode", sf.getCode());//签约code
                    json.put("code", sf.getCode());//患者code
                    json.put("name", sf.getName());//患者name
                    json.put("address", sf.getAddress());//患者地址
                    if (sf.getLabelInfos() != null && sf.getLabelInfos().size() > 0) {
                        List<String> lablesStirng = new ArrayList<>();
                        for (SignPatientLabelInfo signPatientLabelInfo : sf.getLabelInfos()) {
                            lablesStirng.add(signPatientLabelInfo.getLabelName());
                        }
                        json.put("disease", lablesStirng);//疾病
                    }
                    String idcard = sf.getIdcard();
                    if (StringUtils.isNotBlank(idcard) && (idcard.length() == 15 || idcard.length() == 18)) {
                        json.put("age", IdCardUtil.getAgeForIdcard(idcard));//患者年龄
                        String sex = IdCardUtil.getSexForIdcard(idcard);
                        if (sex.equals("1")) {
                            json.put("sex", "2");//患者性别
                        } else if (sex.equals("2")) {
                            json.put("sex", "1");//患者性别
                        } else {
                            json.put("sex", sex);//患者性别
                        }
                    } else {
                        json.put("age", "");//患者年龄
                        json.put("sex", "");//患者性别
                    }
                    array.put(json);
                }
            }
            returnJo.put("list", array);
            returnJo.put("count", count);
            return write(200, "签约数据加载成功!", "data", returnJo);
            JSONObject list = familyContractService.findNoHealthSignFamilyHealth(getUID(),labelType,patientName);
            return write(200, "签约数据加载成功!", "data", list);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
    /**
     * 搜索患者
     * @param patientAddr
     * @param patientName
     * @return
     */
    @RequestMapping(value = "/findNoHealthSignFamilyHealthByParams")
    @ResponseBody
    public String findNoHealthSignFamilyHealthByParams(
            @RequestParam(required = false) String patientAddr,
            @RequestParam(required = false) String patientName) {
        try {
            JSONArray list = familyContractService.findNoHealthSignFamilyHealthByParams("D20161008002",patientAddr,patientName);
            return write(200, "签约数据加载成功!", "data", list);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取没有健康管理师的签约数据数目
     *