Prechádzať zdrojové kódy

慢病管理相关接口BUG修改

huangwenjie 7 rokov pred
rodič
commit
b526439f75

+ 10 - 1
common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/vo/PatientVO.java

@ -52,8 +52,9 @@ public class PatientVO {
	private String streetName;
	// 地址
	private String address;
	// 疾病类型,0健康,1高血压,2糖尿病,3高血压+糖尿病
	// 疾病类型,0健康,1高血压,2糖尿病,(1,2)高血压+糖尿病
	private String disease;
	private Integer diseasesum;
	// 病情:0绿标,1黄标,2红标
	private Integer diseaseCondition;
	// 病历记录总数
@ -392,4 +393,12 @@ public class PatientVO {
	public void setDisease(String disease) {
		this.disease = disease;
	}
	
	public Integer getDiseasesum() {
		return diseasesum;
	}
	
	public void setDiseasesum(Integer diseasesum) {
		this.diseasesum = diseasesum;
	}
}

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientDao.java

@ -66,7 +66,7 @@ public interface PatientDao extends PagingAndSortingRepository<Patient, Long> {
    @Query("select distinct p.openid from Patient p where p.openid is not null and p.openid <> '' ")
    List<String> findOpenids();
    @Query(value=" select p.* from wlyy_patient p  LEFT JOIN wlyy_sign_family s on s.patient = p.code  RIGHT JOIN wlyy_sign_patient_label_info sp on sp.patient = p.code WHERE s.status > 0 and sp.label_type = 3 and (sp.label = 1 or sp.label = 2)  and s.admin_team_code = ?1 and (s.doctor = ?2 or s.doctor_health =?2))",nativeQuery = true)
    @Query(value=" select p.* from wlyy_patient p  LEFT JOIN wlyy_sign_family s on s.patient = p.code  RIGHT JOIN wlyy_sign_patient_label_info sp on sp.patient = p.code WHERE sp.status = 1 and s.status > 0 and sp.label_type = 3 and (sp.label = 1 or sp.label = 2)  and s.admin_team_code = ?1 and (s.doctor = ?2 or s.doctor_health =?2))",nativeQuery = true)
    List<Patient> findAllSignPatientTeamcode(String teamcode, String  doctorcode);
    @Query(value="SELECT DISTINCT t.* FROM wlyy_sign_family t1,wlyy_patient t WHERE t.`code`=t1.patient AND t1.STATUS>0 AND " +

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

@ -326,11 +326,10 @@ public class SignPatientLabelInfoService extends BaseService {
            //慢病管理
            sql = "SELECT " +
                    "    DISTINCT t1.* " +
                    " FROM " +
                    "    wlyy_sign_family t1, " +
                    "    wlyy_sign_patient_label_info t2 ";
                    " FROM  wlyy_sign_family t1 " +
                    "  RIGHT JOIN wlyy_sign_patient_label_info t2 on t2.patient = t1.patient ";
            if(StringUtils.isNotBlank(diseaseCondition)) {
                sql = sql + ", wlyy_patient p ";
                sql = sql + " LEFT JOIN wlyy_patient p on p.code = t1.patient  ";
            }
            sql = sql + " WHERE t2.label = ?";
    
@ -387,17 +386,6 @@ public class SignPatientLabelInfoService extends BaseService {
        sql += " limit " + start + "," + pagesize;
        signList = jdbcTemplate.queryForList(sql, args);
        //查询患者设备绑定情况
        String _pdsql = "select user,sum(category_code) deviceType FROM wlyy_patient_device GROUP BY user";
        List<Map<String,Object>> patientCodeDeviceTypes =  jdbcTemplate.queryForList(_pdsql);
        if(!patientCodeDeviceTypes.isEmpty()){
            for (Map<String,Object> patientCodeDeviceType : patientCodeDeviceTypes) {
                String user = String.valueOf(patientCodeDeviceType.get("user"));
                String sum = String.valueOf(patientCodeDeviceType.get("deviceType"));
                patientDeviceTypeMap.put(user,sum);
            }
        }
        if (signList != null && signList.size() > 0) {
            for (Map<String, Object> sign : signList) {
@ -411,7 +399,7 @@ public class SignPatientLabelInfoService extends BaseService {
                if(sign.get("patient") != null){
                    String patientsql = "select a.*,b.deviceType as deviceType,c.disease as disease from wlyy_patient a" +
                            "  left join (select user,sum(category_code) deviceType FROM wlyy_patient_device GROUP BY user) b on a.code = b.user" +
                            "  left join (select patient,group_concat(label) disease from wlyy_sign_patient_label_info where label_type = 3" +
                            "  left join (select patient,group_concat(label) disease from wlyy_sign_patient_label_info where label_type = 3 and status=1 " +
                            " and (label = 1 or label = 2) and patient = '"+sign.get("patient").toString()+"' GROUP BY patient) c on a.code = c.patient" +
                            " where a.status =1 and a.code = '"+sign.get("patient").toString()+"'";
        
@ -525,11 +513,7 @@ public class SignPatientLabelInfoService extends BaseService {
                //预警状态
                json.put("standardStatus",p.getStandardStatus());
                //设备状态:0未绑定,1血糖仪,2血压仪,3血糖仪+血压仪
                String deviceType = "";
                if(!patientDeviceTypeMap.isEmpty() && patientDeviceTypeMap.keySet().contains(p.getCode())){
                    deviceType = (String) patientDeviceTypeMap.get(p.getCode());
                }
                json.put("deviceType",deviceType);
                json.put("deviceType",p.getDeviceType());
                boolean epTime = false;
                try {
@ -565,8 +549,24 @@ public class SignPatientLabelInfoService extends BaseService {
                    int standardStatus2 = o2.has("standardStatus")?o2.getInt("standardStatus"):0;
                    //疾病种类
                    int disease1 = o1.has("disease")?o1.getInt("disease"):0;
                    int disease2 = o2.has("disease")?o2.getInt("disease"):0;
                    int disease1 = 0;
                    if(o1.has("disease")){
                        String diseasestr = o1.getString("disease");
                        if(diseasestr.contains(",")){
                            disease1 = 3;
                        }else{
                            disease1 = o1.getInt("disease");
                        }
                    }
                    int disease2 = 0;
                    if(o2.has("disease")){
                        String diseasestr = o2.getString("disease");
                        if(diseasestr.contains(",")){
                            disease2 = 3;
                        }else{
                            disease2 = o2.getInt("disease");
                        }
                    }
                    //颜色标签
                    int diseaseCondition1 = o1.has("diseaseCondition")?o1.getInt("diseaseCondition"):0;
@ -1095,27 +1095,34 @@ public class SignPatientLabelInfoService extends BaseService {
                        args = new Object[]{doctor, doctor};
                    }
                }else if(labelType.equals("3") && isSlowDisease) {
                    sql = " SELECT " +
                            "     count(DISTINCT t1.patient) count" +
                            " FROM" +
                            "     wlyy_sign_family t1, " +
                            "     wlyy_sign_patient_label_info t2, " +
                            "     wlyy_patient t3 " +
                            " WHERE" +
                            "     t1.patient = t2.patient " +
                            "     AND t1.patient = t3.code "+
                            "     AND t2.label = ? " +
                            "     AND t2.label_type = ? " +
                            "     AND t2.status = 1 " +
                            "     AND (t1.doctor = ? or t1.doctor_health = ?)" +
                            "     AND t1.status > 0 " +
                            (teamCode > 0 ? "    AND t1.admin_team_code = ? " : "");
                    
                    if("1".equals(label.getLabelCode()) ||  "2".equals(label.getLabelCode())){
                        sql = " SELECT " +
                                "     count(DISTINCT t1.patient) count" +
                                " FROM" +
                                "     wlyy_sign_family t1, " +
                                "     wlyy_sign_patient_label_info t2, " +
                                "     wlyy_patient t3 " +
                                " WHERE" +
                                "     t1.patient = t2.patient " +
                                "     AND t1.patient = t3.code "+
                                "     AND t2.label = ? " +
                                "     AND t2.label_type = ? " +
                                "     AND t2.status = 1 " +
                                "     AND (t1.doctor = ? or t1.doctor_health = ?)" +
                                "     AND t1.status > 0 " +
                                (teamCode > 0 ? "    AND t1.admin_team_code = ? " : "")+
                                "     AND t3.disease_condition = ? ";
    
                    if (teamCode > 0) {
                        args = new Object[]{label.getLabelCode(), labelType, doctor, doctor, teamCode};
                    } else {
                        args = new Object[]{label.getLabelCode(), labelType, doctor, doctor};
                        if (teamCode > 0) {
                            args = new Object[]{label.getLabelCode(), labelType, doctor, doctor, teamCode,diseaseCondition};
                        } else {
                            args = new Object[]{label.getLabelCode(), labelType, doctor, doctor,diseaseCondition};
                        }
                    }else{
                        continue;
                    }
                } else {
                    if (label.getLabelCode().equals("0")) {
                        sql = " SELECT " +
@ -1172,7 +1179,12 @@ public class SignPatientLabelInfoService extends BaseService {
                json.put("amount", amount);
                int focusAmount = 0;
                sql += labelType.equals("5") ? " AND LENGTH(TRIM(IFNULL(t3.openid,''))) > 0 " : " AND LENGTH(TRIM(IFNULL(t3.openid,''))) > 0 ";
                if(isSlowDisease){
                    sql += " AND t3.standard_status = 1 ";
                }else{
                    sql += labelType.equals("5") ? " AND LENGTH(TRIM(IFNULL(t3.openid,''))) > 0 " : " AND LENGTH(TRIM(IFNULL(t3.openid,''))) > 0 ";
                }
                
                List<Map<String, Object>> focusCount = jdbcTemplate.queryForList(sql, args);
                if (focusCount != null && focusCount.size() > 0 && focusCount.get(0).containsKey("count")) {
@ -3815,7 +3827,7 @@ public class SignPatientLabelInfoService extends BaseService {
                if(sign.get("patient") != null){
                    String patientsql = "select a.*,b.deviceType as deviceType,c.disease as disease from wlyy_patient a" +
                            "  left join (select user,sum(category_code) deviceType FROM wlyy_patient_device GROUP BY user) b on a.code = b.user" +
                            "  left join (select patient,group_concat(label) disease from wlyy_sign_patient_label_info where label_type = 3" +
                            "  left join (select patient,group_concat(label) disease from wlyy_sign_patient_label_info where label_type = 3 AND status =1 " +
                            " and (label = 1 or label = 2) and patient = '"+sign.get("patient").toString()+"' GROUP BY patient) c on a.code = c.patient" +
                            " where a.status =1 and a.code = '"+sign.get("patient").toString()+"'";
    
@ -3970,10 +3982,26 @@ public class SignPatientLabelInfoService extends BaseService {
                    //患者預警狀態
                    int standardStatus1 = o1.has("standardStatus")?o1.getInt("standardStatus"):0;
                    int standardStatus2 = o2.has("standardStatus")?o2.getInt("standardStatus"):0;
    
                    //疾病种类
                    int disease1 = o1.has("disease")?o1.getInt("disease"):0;
                    int disease2 = o2.has("disease")?o2.getInt("disease"):0;
                    int disease1 = 0;
                    if(o1.has("disease")){
                        String diseasestr = o1.getString("disease");
                        if(diseasestr.contains(",")){
                            disease1 = 3;
                        }else{
                            disease1 = o1.getInt("disease");
                        }
                    }
                    int disease2 = 0;
                    if(o2.has("disease")){
                        String diseasestr = o2.getString("disease");
                        if(diseasestr.contains(",")){
                            disease2 = 3;
                        }else{
                            disease2 = o2.getInt("disease");
                        }
                    }
                    //颜色标签
                    int diseaseCondition1 = o1.has("diseaseCondition")?o1.getInt("diseaseCondition"):0;
@ -4192,36 +4220,38 @@ public class SignPatientLabelInfoService extends BaseService {
                "    DISTINCT t1.* " +
                " FROM " +
                "    wlyy_sign_family t1 " +
                " JOIN wlyy_sign_patient_label_info t2 ON t1.patient = t2.patient " +
                " JOIN wlyy_sign_patient_label_info t2 ON t1.patient = t2.patient and t2.status=1 " +
                " JOIN wlyy_patient t3 ON t1.patient = t3.code " +
                (teamCode > 0 ? " join (select * from wlyy_sign_patient_label where label_type != '4' or team_code = " + teamCode + " or (label_type = '4' and (label_code in (1,2)))) lb on t2.label = lb.label_code and t2.label_type = lb.label_type " : "") +
                " WHERE " +
                "    (t1.doctor = ? or t1.doctor_health = ?) " +
                "    AND t1.status > 0 " +
                "    AND t2.status = 1 " +
                (StringUtils.isNotEmpty(labelCode) ? " AND t2.label = ? " : "") +
                (StringUtils.isNotEmpty(labelType) ? " AND t2.label_type = ? " : "") +
//                (StringUtils.isNotEmpty(labelCode) ? " AND t2.label = ? " : "") +
//                (StringUtils.isNotEmpty(labelType) ? " AND t2.label_type = ? " : "") +
                (teamCode > 0 ? (" AND admin_team_code = " + teamCode) : "");
        sql = sql + " AND t3.status > 0 and t2.label_type = '3' and ( t2.label =1 or t2.lable = 2) ";
        sql = sql + " AND t3.status > 0 and t2.label_type = '3' and ( t2.label =1 or t2.label = 2) ";
        if (matcher.find()) {
            sql = sql + "  AND (t1.idcard like ?) ";
            if (StringUtils.isNotEmpty(labelCode)) {
                args = new Object[]{doctor, doctor, labelCode, labelType, "%" + filter + "%"};
            } else if (StringUtils.isEmpty(labelCode) && StringUtils.isNotEmpty(labelType)) {
                args = new Object[]{doctor, doctor, labelType, "%" + filter + "%"};
            } else {
                args = new Object[]{doctor, doctor, "%" + filter + "%"};
            }
//            if (StringUtils.isNotEmpty(labelCode)) {
//                args = new Object[]{doctor, doctor, labelCode, labelType, "%" + filter + "%"};
//            } else if (StringUtils.isEmpty(labelCode) && StringUtils.isNotEmpty(labelType)) {
//                args = new Object[]{doctor, doctor, labelType, "%" + filter + "%"};
//            } else {
//                args = new Object[]{doctor, doctor, "%" + filter + "%"};
//            }
            args = new Object[]{doctor, doctor, "%" + filter + "%"};
        } else {
            sql = sql + "  AND (t1.name like ? or t2.label_name like ?) ";
            if (StringUtils.isNotEmpty(labelCode)) {
                args = new Object[]{doctor, doctor, labelCode, labelType, "%" + filter + "%", "%" + filter + "%"};
            } else if (StringUtils.isEmpty(labelCode) && StringUtils.isNotEmpty(labelType)) {
                args = new Object[]{doctor, doctor, labelType, "%" + filter + "%", "%" + filter + "%"};
            } else {
                args = new Object[]{doctor, doctor, "%" + filter + "%", "%" + filter + "%"};
            }
//            if (StringUtils.isNotEmpty(labelCode)) {
//                args = new Object[]{doctor, doctor, labelCode, labelType, "%" + filter + "%", "%" + filter + "%"};
//            } else if (StringUtils.isEmpty(labelCode) && StringUtils.isNotEmpty(labelType)) {
//                args = new Object[]{doctor, doctor, labelType, "%" + filter + "%", "%" + filter + "%"};
//            } else {
//                args = new Object[]{doctor, doctor, "%" + filter + "%", "%" + filter + "%"};
//            }
            args = new Object[]{doctor, doctor, "%" + filter + "%", "%" + filter + "%"};
        }
@ -4235,7 +4265,7 @@ public class SignPatientLabelInfoService extends BaseService {
                if(sign.get("patient") != null){
                    String patientsql = "select a.*,b.deviceType as deviceType,c.disease as disease from wlyy_patient a" +
                            "  left join (select user,sum(category_code) deviceType FROM wlyy_patient_device GROUP BY user) b on a.code = b.user" +
                            "  left join (select patient,group_concat(label) disease from wlyy_sign_patient_label_info where label_type = 3" +
                            "  left join (select patient,group_concat(label) disease from wlyy_sign_patient_label_info where label_type = 3 and status=1 " +
                            " and (label = 1 or label = 2) and patient = '"+sign.get("patient").toString()+"' GROUP BY patient) c on a.code = c.patient" +
                            " where a.status =1 and a.code = '"+sign.get("patient").toString()+"'";
        
@ -4420,7 +4450,7 @@ public class SignPatientLabelInfoService extends BaseService {
                " FROM " +
                "    wlyy_sign_family t1 " +
                " JOIN wlyy_patiend t2 ON t1.patient = t2.code " +
                " JOIN wlyy_sign_patient_label_info t3 on t1.patient = t3.patient " +
                " RIGHT JOIN wlyy_sign_patient_label_info t3 on t1.patient = t3.patient AND t3.status = 1" +
                " WHERE " +
                (isIdcard ? " t1.patient = t2.code  and " : "") +
                "    t1.status > 0 " +
@ -4439,7 +4469,7 @@ public class SignPatientLabelInfoService extends BaseService {
                if(sign.get("patient") != null){
                    String patientsql = "select a.*,b.deviceType as deviceType,c.disease as disease from wlyy_patient a" +
                            "  left join (select user,sum(category_code) deviceType FROM wlyy_patient_device GROUP BY user) b on a.code = b.user" +
                            "  left join (select patient,group_concat(label) disease from wlyy_sign_patient_label_info where label_type = 3" +
                            "  left join (select patient,group_concat(label) disease from wlyy_sign_patient_label_info where label_type = 3 and status=1 " +
                            " and (label = 1 or label = 2) and patient = '"+sign.get("patient").toString()+"' GROUP BY patient) c on a.code = c.patient" +
                            " where a.status =1 and a.code = '"+sign.get("patient").toString()+"'";
        

+ 5 - 6
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/scheme/DoctorSchemeService.java

@ -81,7 +81,7 @@ public class DoctorSchemeService {
            sql = sql + " LEFT JOIN wlyy_patient_device dev on dev.user = p.code ";
        }
    
        sql = sql+ " LEFT JOIN wlyy_sign_patient_label_info sp on sp.patient = p.code ";
        sql = sql+ " RIGHT JOIN wlyy_sign_patient_label_info sp on sp.patient = p.code and sp.status =1 ";
        sql = sql+ " LEFT JOIN wlyy_sign_family sf on sf.patient = p.code where sf.admin_team_code = "+teamCode;
@ -396,9 +396,9 @@ public class DoctorSchemeService {
//        List<Patient> patients = patientDao.findAllSignPatientTeamcode(teamCode,doctorcode);
    
        List<PatientVO> patients = new ArrayList<>();
        String patientsql = "select p.name,b.deviceType as deviceType,group_concat(sp.label) diseaseType from wlyy_patient p " +
        String patientsql = "select p.*,b.deviceType as deviceType,group_concat(sp.label) diseaseType from wlyy_patient p " +
                "  LEFT JOIN wlyy_sign_family s on s.patient = p.code " +
                "  RIGHT JOIN wlyy_sign_patient_label_info sp on sp.patient = p.code and sp.label_type = 3 and (sp.label = 1 or sp.label = 2) " +
                "  RIGHT JOIN wlyy_sign_patient_label_info sp on sp.patient = p.code and sp.label_type = 3 and (sp.label = 1 or sp.label = 2) and sp.status =1" +
                "  LEFT JOIN (select user,sum(category_code) deviceType FROM wlyy_patient_device GROUP BY user) b on p.code = b.user " +
                "WHERE s.status > 0 and s.admin_team_code ='"+teamCode+"' and (s.doctor = '"+doctorcode+"' or s.doctor_health ='"+doctorcode+"') GROUP BY p.code";
@ -437,7 +437,6 @@ public class DoctorSchemeService {
        if(!patients.isEmpty()){
            for (PatientVO patient : patients) {
                //获取居民颜色标签
                if(1 == getcolor && patient.getDiseaseCondition() != null){
                    switch (patient.getDiseaseCondition()){
@ -459,11 +458,11 @@ public class DoctorSchemeService {
                if(1 == getstands && (patient.getStandardStatus() !=null && patient.getStandardStatus() ==1)){
                    if(patient.getDisease() != null){
                        if( "1" == patient.getDisease() || "1,2" == patient.getDisease()){
                        if( "1".equals(patient.getDisease()) || "1,2".equals(patient.getDisease()) || "2,1".equals(patient.getDisease())){
                            bloodpressure_patientcodes.add(patient.getCode());
                        }
                        if( "2" == patient.getDisease() || "1,2" == patient.getDisease()){
                        if( "2" == patient.getDisease() || "1,2".equals(patient.getDisease()) || "2,1".equals(patient.getDisease())){
                            bloodsugar_patientcodes.add(patient.getCode());
                        }
                    }