Browse Source

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

lyr 8 years ago
parent
commit
f8898fa251

+ 84 - 3
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/label/SignPatientLabelInfoService.java

@ -176,6 +176,85 @@ public class SignPatientLabelInfoService extends BaseService {
        return result.size() > 0 ? new JSONArray(result.values()) : new JSONArray();
    }
    /**
     * 获取团队下的患者
     *
     * @param doctor
     * @param teamCode
     * @param page
     * @param pagesize
     * @return
     * @throws Exception
     */
    public JSONArray getPatientByTeamCode(String doctor, long teamCode, int page, int pagesize) throws Exception {
        Doctor doc = doctorDao.findByCode(doctor);
        if (doc == null) {
            throw new Exception("doctor info can not find");
        }
        Map<String, JSONObject> result = new HashMap<>();
        List<Map<String, Object>> signList = new ArrayList<>();
        int start = page * pagesize;
        String sql = "";
        Object[] args = null;
        sql = " select * from wlyy_sign_family where " +
                (doc.getLevel() == 2 ? " doctor" : "doctor_health") +
                " = ? and status > 0 and admin_team_code = ? " +
                " limit " + start + "," + pagesize;
        args = new Object[]{doctor, teamCode};
        signList = jdbcTemplate.queryForList(sql, args);
        if (signList != null && signList.size() > 0) {
            for (Map<String, Object> sign : signList) {
                Patient p = patientDao.findByCode(sign.get("patient") == null ? "" : sign.get("patient").toString());
                if (p == null) {
                    continue;
                }
                if (result.containsKey(p.getCode())) {
                    JSONObject jsonP = result.get(p.getCode());
                    if (!String.valueOf(jsonP.get("signType")).equals(String.valueOf(sign.get("type")))) {
                        jsonP.put("signType", 3);
                    }
                    continue;
                }
                List<SignPatientLabelInfo> labels = labelInfoDao.findByPatientAndStatus(sign.get("patient").toString(), 1);
                JSONObject json = new JSONObject();
                // 设置患者标识
                json.put("code", p.getCode());
                // 设置患者姓名
                json.put("name", p.getName());
                // 设置患者头像
                json.put("photo", p.getPhoto());
                // 设置患者年龄
                json.put("age", DateUtil.getAgeByBirthday(p.getBirthday()));
                // 设置患者性别
                json.put("sex", p.getSex());
                // 设置签约日期
                json.put("qyrq", sign.get("apply_date") != null ? DateUtil.dateToStr((Date) sign.get("apply_date"), DateUtil.YYYY_MM_DD) : "");
                // 设置签约类型
                json.put("signType", sign.get("type") == null ? "" : sign.get("type"));
                // 身份证号
                json.put("idcard", p.getIdcard());
                // 患者标签
                json.put("labels", labels == null ? "" : labels);
                result.put(p.getCode(), json);
            }
        }
        return result.size() > 0 ? new JSONArray(result.values()) : new JSONArray();
    }
    /**
     * 查询某个标签类型的所有标签居民数统计
     *
@ -481,7 +560,8 @@ public class SignPatientLabelInfoService extends BaseService {
     * @return
     * @throws Exception
     */
    public JSONArray searchPatientByNameOrLabel(String doctor, String filter, String labelCode, String labelType) throws Exception {
    public JSONArray searchPatientByNameOrLabel(String doctor, String filter,
                                                String labelCode, String labelType, long teamCode) throws Exception {
        Doctor doc = doctorDao.findByCode(doctor);
        if (doc == null) {
@ -493,7 +573,8 @@ public class SignPatientLabelInfoService extends BaseService {
        Object[] args = null;
        String sql = "select a.*" +
                " from" +
                "     (select * from wlyy_sign_family where " + (doc.getLevel() == 2 ? " doctor" : "doctor_health") + " = ? and status > 0) a" +
                "     (select * from wlyy_sign_family where " + (doc.getLevel() == 2 ? " doctor" : "doctor_health") + " = ? and status > 0 " +
                (teamCode > 0 ? (" and admin_team_code = " + teamCode) : "") + " ) a" +
                " left join" +
                "     (select * from wlyy_sign_patient_label_info where status = 1 " +
                (StringUtils.isNotEmpty(labelCode) ? " and label = ? " : "") +
@ -651,7 +732,7 @@ public class SignPatientLabelInfoService extends BaseService {
     * @param labelType
     * @return
     */
    public int deltePatientsLabel(String patients, String labelCode, String labelType){
    public int deltePatientsLabel(String patients, String labelCode, String labelType) {
        if (StringUtils.isNotEmpty(patients)) {
            String[] patientArr = patients.split(",");

+ 33 - 3
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/SignPatientLabelInfoController.java

@ -43,7 +43,7 @@ public class SignPatientLabelInfoController extends BaseController {
            if (StringUtils.isEmpty(labelType)) {
                return error(-1, "标签类型不能为空");
            }
            if (StringUtils.isEmpty(String.valueOf(teamCode))) {
            if (StringUtils.isEmpty(String.valueOf(teamCode)) || teamCode < 1) {
                return error(-1, "团队cdoe不能为空");
            }
@ -56,6 +56,30 @@ public class SignPatientLabelInfoController extends BaseController {
        }
    }
    /**
     * 获取团队下的居民
     *
     * @param teamCode
     * @param page
     * @param pagesize
     * @return
     */
    @RequestMapping(value = "/patients_by_team")
    public String getPatientInfoByTeam(Long teamCode,int page,int pagesize){
        try {
            if (teamCode == null || teamCode < 1) {
                return error(-1, "团队cdoe不能为空");
            }
            page = page - 1;
            JSONArray result = labelInfoService.getPatientByTeamCode(getUID(), teamCode, page, pagesize);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            return error(-1, "查询失败");
        }
    }
    /**
     * 查询某个团队的某个标签类型下各标签患者数
     *
@ -153,7 +177,9 @@ public class SignPatientLabelInfoController extends BaseController {
     * @return
     */
    @RequestMapping(value = "/patient_search")
    public String searchPatientByNameOrLabel(String filter, String labelCode, String labelType) {
    public String searchPatientByNameOrLabel(String filter, @RequestParam(required = false)String labelCode,
                                             @RequestParam(required = false)String labelType,
                                             @RequestParam(required = false) Long teamCode) {
        try {
            if (StringUtils.isEmpty(filter)) {
                return error(-1, "搜索字段不能为空");
@ -163,7 +189,11 @@ public class SignPatientLabelInfoController extends BaseController {
                return error(-1, "标签参数不为空时标签类型不能为空");
            }
            JSONArray result = labelInfoService.searchPatientByNameOrLabel(getUID(), filter, labelCode, labelType);
            if(teamCode == null){
                teamCode = 0L;
            }
            JSONArray result = labelInfoService.searchPatientByNameOrLabel(getUID(), filter, labelCode, labelType,teamCode);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {