Преглед на файлове

慢病管理:居民列表代码提交

huangwenjie преди 7 години
родител
ревизия
d295d3d2bf

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

@ -240,9 +240,10 @@ public class SignPatientLabelInfoService extends BaseService {
     * @param labelType 标签类型
     * @param page      第几页
     * @param pagesize  页大小
     * @param sortByStandardStatus
     * @return
     */
    public JSONArray getPatientByLabel(String doctor, String labelCode, String labelType, Long teamCode, int page, int pagesize) throws Exception {
    public JSONArray getPatientByLabel(String doctor, String labelCode, String labelType, Long teamCode, int page, int pagesize, boolean sortByStandardStatus) throws Exception {
        Doctor doc = doctorDao.findByCode(doctor);
        if (doc == null) {
@ -251,6 +252,8 @@ public class SignPatientLabelInfoService extends BaseService {
        Map<String, JSONObject> result = new TreeMap<>();
        List<Map<String, Object>> signList = new ArrayList<>();
        Map<String,Object> patientDeviceTypeMap = new HashMap<>();//用于存储患者设备绑定情况
        int start = page * pagesize;
        String sql = "";
        Object[] args = null;
@ -349,6 +352,12 @@ public class SignPatientLabelInfoService extends BaseService {
        sql += " limit " + start + "," + pagesize;
        signList = jdbcTemplate.queryForList(sql, args);
        //查询患者设备绑定情况
        if(sortByStandardStatus){
            String _pdsql = "SELECT p.code,(SELECT sum(d.category_code)  from wlyy_patient_device d WHERE p.code = d.`user`) device from wlyy_patient p";
            patientDeviceTypeMap = jdbcTemplate.queryForMap(_pdsql);
        }
        if (signList != null && signList.size() > 0) {
            for (Map<String, Object> sign : signList) {
                Patient p = patientDao.findByCode(sign.get("patient") == null ? "" : sign.get("patient").toString());
@ -454,6 +463,20 @@ public class SignPatientLabelInfoService extends BaseService {
                    // 缴费情况
                    json.put("expensesStatus", "1");
                }
                //病情类型:0健康,1高血压,2糖尿病,3高血压+糖尿病
                json.put("disease",p.getDisease());
                // 病情:0绿标,1黄标,2红标,
                json.put("diseaseCondition",p.getDiseaseCondition());
                //预警状态
                json.put("standardStatus",p.getStandardStatus());
                //设备状态:0未绑定,1血糖仪,2血压仪,3血糖仪+血压仪
                Integer deviceType = 0;
                if(!patientDeviceTypeMap.isEmpty() && patientDeviceTypeMap.keySet().contains(p.getCode())){
                    deviceType = (Integer) patientDeviceTypeMap.get(p.getCode());
                }
                json.put("deviceType",deviceType);
                boolean epTime = false;
                try {
                    epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", p.getCode());
@ -480,7 +503,24 @@ public class SignPatientLabelInfoService extends BaseService {
                public int compare(JSONObject o1, JSONObject o2) {
                    String openid1 = o1.has("openid") ? o1.getString("openid") : "";
                    String openid2 = o2.has("openid") ? o2.getString("openid") : "";
                    int re = openid1.compareTo(openid2);
                    int re = 0;
                    //是否根据预警字段优先排序
                    if(sortByStandardStatus){
                        int standardStatus1 = o1.has("standardStatus")?o1.getInt("standardStatus"):0;
                        int standardStatus2 = o2.has("standardStatus")?o2.getInt("standardStatus"):0;
                        if(standardStatus1 == standardStatus2){
                            re = openid1.compareTo(openid2);
                        }else{
                            re = standardStatus1 - standardStatus1;
                        }
                    }else{
                        re = openid1.compareTo(openid2);
                    }
                    if (re > 0) {
                        return -1;
                    } else if (re < 0) {
@ -3511,13 +3551,15 @@ public class SignPatientLabelInfoService extends BaseService {
     * @param teamCode
     * @param page
     * @param pagesize
     * @param sortByStandardStatus 是否根据预警状态排序,如果true, 需要附带查询患者设备绑定情况
     * @return
     * @throws Exception
     */
    public JSONArray getPatientByTeamCodeExitDoctor(long teamCode, String labelCode, String labelType, int page, int pagesize) throws Exception {
    public JSONArray getPatientByTeamCodeExitDoctor(long teamCode, String labelCode, String labelType, int page, int pagesize, boolean sortByStandardStatus) throws Exception {
        Map<String, JSONObject> result = new TreeMap<>();
        List<Map<String, Object>> signList = new ArrayList<>();
        Map<String,Object> patientDeviceTypeMap = new HashMap<>();//用于存储患者设备绑定情况
        int start = page * pagesize;
        String sql = "";
        Object[] args = null;
@ -3621,6 +3663,13 @@ public class SignPatientLabelInfoService extends BaseService {
        sql = sql + " limit " + start + "," + pagesize;
        signList = jdbcTemplate.queryForList(sql, args);
        //查询患者设备绑定情况
        if(sortByStandardStatus){
            String _pdsql = "SELECT p.code,(SELECT sum(d.category_code)  from wlyy_patient_device d WHERE p.code = d.`user`) device from wlyy_patient p";
            patientDeviceTypeMap = jdbcTemplate.queryForMap(_pdsql);
        }
        if (signList != null && signList.size() > 0) {
            for (Map<String, Object> sign : signList) {
                Patient p = patientDao.findByCode(sign.get("patient") == null ? "" : sign.get("patient").toString());
@ -3629,49 +3678,49 @@ public class SignPatientLabelInfoService extends BaseService {
                    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);
                    }
                    if (String.valueOf(sign.get("type")).equals("2")) {
                        jsonP.put("qyrq", sign.get("apply_date") != null ? DateUtil.dateToStr((Date) sign.get("apply_date"), DateUtil.YYYY_MM_DD) : "");
                        // 缴费情况
                        jsonP.put("expensesStatus", sign.get("expenses_status") != null ? String.valueOf(sign.get("expenses_status")) : "0");
                        // 缴费时间
                        jsonP.put("expensesTime", sign.get("expenses_time") != null ? DateUtil.dateToStr((Date) sign.get("expenses_time"), DateUtil.YYYY_MM_DD_HH_MM) : "");
                        // 缴费类型
                        jsonP.put("expensesType", sign.get("expenses_type") != null ? String.valueOf(sign.get("expenses_type")) : "");
                        if (StringUtils.isEmpty(String.valueOf(jsonP.get("expensesStatus"))) || String.valueOf(jsonP.get("expensesStatus")).equals("0")) {
                            boolean epTime = false;
                            try {
                                epTime = redisTemplate.opsForSet().isMember("expenses:remind:set", p.getCode());
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                            if (!epTime) {
                                jsonP.put("expensesRemindStatus", 0);
                            } else {
                                jsonP.put("expensesRemindStatus", 1);
                            }
                        }
                        boolean epTime = false;
                        try {
                            epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", p.getCode());
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        if (!epTime) {
                            jsonP.put("wechatFocusRemind", 0);
                        } else {
                            jsonP.put("wechatFocusRemind", 1);
                        }
                    }
                    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);
//                    }
//                    if (String.valueOf(sign.get("type")).equals("2")) {
//                        jsonP.put("qyrq", sign.get("apply_date") != null ? DateUtil.dateToStr((Date) sign.get("apply_date"), DateUtil.YYYY_MM_DD) : "");
//                        // 缴费情况
//                        jsonP.put("expensesStatus", sign.get("expenses_status") != null ? String.valueOf(sign.get("expenses_status")) : "0");
//                        // 缴费时间
//                        jsonP.put("expensesTime", sign.get("expenses_time") != null ? DateUtil.dateToStr((Date) sign.get("expenses_time"), DateUtil.YYYY_MM_DD_HH_MM) : "");
//                        // 缴费类型
//                        jsonP.put("expensesType", sign.get("expenses_type") != null ? String.valueOf(sign.get("expenses_type")) : "");
//                        if (StringUtils.isEmpty(String.valueOf(jsonP.get("expensesStatus"))) || String.valueOf(jsonP.get("expensesStatus")).equals("0")) {
//                            boolean epTime = false;
//                            try {
//                                epTime = redisTemplate.opsForSet().isMember("expenses:remind:set", p.getCode());
//                            } catch (Exception e) {
//                                e.printStackTrace();
//                            }
//
//                            if (!epTime) {
//                                jsonP.put("expensesRemindStatus", 0);
//                            } else {
//                                jsonP.put("expensesRemindStatus", 1);
//                            }
//                        }
//                        boolean epTime = false;
//                        try {
//                            epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", p.getCode());
//                        } catch (Exception e) {
//                            e.printStackTrace();
//                        }
//                        if (!epTime) {
//                            jsonP.put("wechatFocusRemind", 0);
//                        } else {
//                            jsonP.put("wechatFocusRemind", 1);
//                        }
//                    }
//
//                    continue;
//                }
                //List<SignPatientLabelInfo> labels = labelInfoDao.findByPatientAndStatus(sign.get("patient").toString(), 1);
                JSONObject json = new JSONObject();
@ -3727,6 +3776,21 @@ public class SignPatientLabelInfoService extends BaseService {
                    // 缴费情况
                    json.put("expensesStatus", "1");
                }
                //病情类型:0健康,1高血压,2糖尿病,3高血压+糖尿病
                json.put("disease",p.getDisease());
                // 病情:0绿标,1黄标,2红标,
                json.put("diseaseCondition",p.getDiseaseCondition());
                //预警状态
                json.put("standardStatus",p.getStandardStatus());
                //设备状态:0未绑定,1血糖仪,2血压仪,3血糖仪+血压仪
                Integer deviceType = 0;
                if(!patientDeviceTypeMap.isEmpty() && patientDeviceTypeMap.keySet().contains(p.getCode())){
                    deviceType = (Integer) patientDeviceTypeMap.get(p.getCode());
                }
                json.put("deviceType",deviceType);
                boolean epTime = false;
                try {
                    epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", p.getCode());
@ -3753,7 +3817,25 @@ public class SignPatientLabelInfoService extends BaseService {
                public int compare(JSONObject o1, JSONObject o2) {
                    String openid1 = o1.has("openid") ? o1.getString("openid") : "";
                    String openid2 = o2.has("openid") ? o2.getString("openid") : "";
                    int re = openid1.compareTo(openid2);
                    int re = 0;
                    //是否根据预警字段优先排序
                    if(sortByStandardStatus){
                        int standardStatus1 = o1.has("standardStatus")?o1.getInt("standardStatus"):0;
                        int standardStatus2 = o2.has("standardStatus")?o2.getInt("standardStatus"):0;
                        if(standardStatus1 == standardStatus2){
                            re = openid1.compareTo(openid2);
                        }else{
                            re = standardStatus1 - standardStatus1;
                        }
                    }else{
                        re = openid1.compareTo(openid2);
                    }
                    if (re > 0) {
                        return -1;
                    } else if (re < 0) {

+ 27 - 7
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/SignWebService.java

@ -1875,13 +1875,22 @@ public class SignWebService extends BaseService {
     *
     * @return
     */
    public JSONObject getOverDuePatients(String year, Long teamCode, String doctor, Integer page, Integer pageSize) {
    public JSONObject getOverDuePatients(String year, Long teamCode, String doctor, Integer page, Integer pageSize, boolean sortByStandardStatus) {
        StringBuffer sql = new StringBuffer("SELECT IFNULL(year( from_days( datediff( now(), p.birthday))),'未知') age," +
                "t.patient code,t.idcard,t.name,t.mobile,t.openid," +
                "t.ssc,t.type signType,p.sex ,t.expenses_status expensesStatus " +
                " FROM wlyy_sign_family t " +
                "t.ssc,t.type signType,p.sex ,t.expenses_status expensesStatus " );
        if(sortByStandardStatus){
            sql.append(",(SELECT sum(d.category_code)  from wlyy_patient_device d WHERE p.code = d.`user`) deviceType ");
        }
        sql.append("FROM wlyy_sign_family t " +
                " LEFT JOIN wlyy_patient p ON t.patient = p.code " +
                " WHERE t.doctor ='" + doctor + "' AND t.admin_team_code =" + teamCode + " AND t.sign_year ='" + year + "' AND t.status =-4 LIMIT " + page * pageSize + "," + pageSize);
        if (sortByStandardStatus){
            sql.append("order by p.standardStatus desc ");
        }
        List<Map<String, Object>> rs = jdbcTemplate.queryForList(sql.toString());
        JSONObject json = new JSONObject();
        json.put("result", rs);
@ -1893,13 +1902,24 @@ public class SignWebService extends BaseService {
     *
     * @return
     */
    public JSONObject getOverDuePatientsByTeam(String year, Long teamCode, Integer page, Integer pageSize) {
    public JSONObject getOverDuePatientsByTeam(String year, Long teamCode, Integer page, Integer pageSize, boolean sortByStandardStatus) {
        StringBuffer sql = new StringBuffer("SELECT IFNULL(year( from_days( datediff( now(), p.birthday))),'未知') age," +
                "t.patient code,t.idcard,t.name,t.mobile,t.openid," +
                "t.ssc,t.type signType,p.sex ,t.expenses_status expensesStatus " +
                " FROM wlyy_sign_family t " +
                "t.ssc,t.type signType,p.sex ,t.expenses_status expensesStatus,p.disease, p.diseaseCondition, p.standardStatus ");
        if(sortByStandardStatus){
            sql.append(",(SELECT sum(d.category_code)  from wlyy_patient_device d WHERE p.code = d.`user`) deviceType ");
        }
        sql.append(" FROM wlyy_sign_family t " +
                " LEFT JOIN wlyy_patient p ON t.patient = p.code " +
                " WHERE t.admin_team_code =" + teamCode + " AND t.sign_year ='" + year + "' AND t.status =-4 LIMIT " + page * pageSize + "," + pageSize);
                " WHERE t.admin_team_code =" + teamCode + " AND t.sign_year ='" + year + "' AND t.status =-4 ");
        if (sortByStandardStatus){
            sql.append("order by p.standardStatus desc ");
        }
        sql.append("LIMIT " + page * pageSize + ", "+ pageSize);
        List<Map<String, Object>> rs = jdbcTemplate.queryForList(sql.toString());
        JSONObject json = new JSONObject();
        json.put("result", rs);

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthEduArticleController.java

@ -497,7 +497,7 @@ public class DoctorHealthEduArticleController extends WeixinBaseController {
    }
    private void getPatientByGroup(String labelCode, String labelType, Long teamCode, Set<String> patientSet, int page, int pagesize) throws Exception {
        JSONArray result = signPatientLabelInfoService.getPatientByLabel(getUID(), labelCode, labelType, teamCode, page, pagesize);
        JSONArray result = signPatientLabelInfoService.getPatientByLabel(getUID(), labelCode, labelType, teamCode, page, pagesize, false);
        for (Object o : result) {
            JSONObject json = (JSONObject) o;
            String patient = (String) json.get("code");

+ 12 - 6
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/SignPatientLabelInfoController.java

@ -148,7 +148,8 @@ public class SignPatientLabelInfoController extends BaseController {
                                        @RequestParam(required = false) String labelType,
                                        @RequestParam(required = false) Long teamCode,
                                        @RequestParam(required = false) int page,
                                        @RequestParam(required = false) int pagesize) {
                                        @RequestParam(required = false) int pagesize,
                                        @RequestParam(required = false) boolean sortByStandardStatus) {
        try {
            if (StringUtils.isEmpty(labelCode)) {
                return error(-1, "标签cdoe不能为空");
@ -162,12 +163,14 @@ public class SignPatientLabelInfoController extends BaseController {
            page = page - 1;
            //按照签约年度  labelCode 是年度 例如 2016
            //labelType=9 签约过期的居民列表
            if (labelType.equals("9")) {
                JSONObject jsonObject = signWebService.getOverDuePatients(labelCode, teamCode, getUID(), page, pagesize);
                JSONObject jsonObject = signWebService.getOverDuePatients(labelCode, teamCode, getUID(), page, pagesize,sortByStandardStatus);
                return write(200, "查询成功", "data", jsonObject);
            }
            JSONArray result = labelInfoService.getPatientByLabel(getUID(), labelCode, labelType, teamCode, page, pagesize);
            JSONArray result = labelInfoService.getPatientByLabel(getUID(), labelCode, labelType, teamCode, page, pagesize,sortByStandardStatus);
            //JSONArray result = labelInfoService.getPatientByLabel("xh1D201703150222", labelCode, labelType, teamCode, page, pagesize);
            return write(200, "查询成功", "data", result);
@ -223,7 +226,9 @@ public class SignPatientLabelInfoController extends BaseController {
    public String getTeamPatient(@RequestParam(required = true) Long teamCode,
                                 @RequestParam(required = false) String labelCode,
                                 @RequestParam(required = false) String labelType,
                                 @RequestParam(required = true) int page, @RequestParam(required = true) int pagesize) {
                                 @RequestParam(required = true) int page,
                                 @RequestParam(required = true) int pagesize,
                                 @RequestParam(required = false) boolean sortByStandardStatus) {
        try {
            if (teamCode == null || teamCode < 1) {
                return error(-1, "团队cdoe不能为空");
@ -235,13 +240,14 @@ public class SignPatientLabelInfoController extends BaseController {
            page = page > 0 ? page - 1 : 0;
            //labelType=9 签约过期的居民列表
            if ("9".equals(labelType)) {
                JSONObject jsonObject = signWebService.getOverDuePatientsByTeam(labelCode, teamCode, page, pagesize);
                JSONObject jsonObject = signWebService.getOverDuePatientsByTeam(labelCode, teamCode, page, pagesize,sortByStandardStatus);
                return write(200, "查询成功", "data", jsonObject);
            }
            JSONArray result = labelInfoService.getPatientByTeamCodeExitDoctor(teamCode, labelCode, labelType, page, pagesize);
            JSONArray result = labelInfoService.getPatientByTeamCodeExitDoctor(teamCode, labelCode, labelType, page, pagesize,sortByStandardStatus);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {

+ 3 - 5
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/controller/doctor/GcLableController.java

@ -1,13 +1,11 @@
package com.yihu.wlyy.web.third.gateway.controller.doctor;
import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabel;
import com.yihu.wlyy.service.app.label.SignPatientLabelInfoService;
import com.yihu.wlyy.service.app.label.SignPatientLabelService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.web.BaseController;
import com.yihu.wlyy.web.third.gateway.service.GcLabelService;
import com.yihu.wlyy.web.third.gateway.vo.DictModel;
import com.yihu.wlyy.web.third.gateway.vo.HospitalModel;
import com.yihu.wlyy.web.third.gateway.vo.PatientLabelModel;
import com.yihu.wlyy.web.third.gateway.vo.PatientModel;
import com.yihu.wlyy.web.third.gateway.vo.base.BaseResultModel;
@ -18,7 +16,6 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
@ -98,10 +95,11 @@ public class GcLableController extends BaseController {
            @ApiParam(name = "labelCode", value = "标签code", required = true) @RequestParam(value = "labelCode", required = true) String labelCode,
            @ApiParam(name = "teamCode", value = "所属团队", required = true) @RequestParam(value = "teamCode", required = true) Long teamCode,
            @ApiParam(name = "page", value = "当前页(1开始)", required = true) @RequestParam(value = "page", required = true, defaultValue = "1") Integer page,
            @ApiParam(name = "pageSize", value = "每页大小", required = true) @RequestParam(value = "pageSize", required = true, defaultValue = "10") Integer pageSize
            @ApiParam(name = "pageSize", value = "每页大小", required = true) @RequestParam(value = "pageSize", required = true, defaultValue = "10") Integer pageSize,
            @ApiParam(name = "sortByStandardStatus", value = "是否按照预警状态排序", required = true) @RequestParam(value="sortByStandardStatus",required = false,defaultValue = "false") boolean sortByStandardStatus
    ) {
        try {
            JSONArray result = signPatientLabelInfoService.getPatientByLabel(getUID(), labelCode, labelType, teamCode, page-1, pageSize);
            JSONArray result = signPatientLabelInfoService.getPatientByLabel(getUID(), labelCode, labelType, teamCode, page-1, pageSize, sortByStandardStatus);
            List<PatientModel> patientLabelModels = new ArrayList<>();
            for (int i = 0; i < result.length(); i++) {
                JSONObject jo = result.getJSONObject(i);