|
@ -9,6 +9,8 @@ import com.yihu.wlyy.entity.patient.Patient;
|
|
|
import com.yihu.wlyy.entity.patient.PatientDisease;
|
|
|
import com.yihu.wlyy.entity.patient.PatientRemindRecords;
|
|
|
import com.yihu.wlyy.entity.patient.SignFamily;
|
|
|
import com.yihu.wlyy.entity.patient.vo.PatientVO;
|
|
|
import com.yihu.wlyy.entity.statistics.WlyyQuotaResult;
|
|
|
import com.yihu.wlyy.logs.BusinessLogs;
|
|
|
import com.yihu.wlyy.repository.doctor.DoctorDao;
|
|
|
import com.yihu.wlyy.repository.doctor.DoctorPatientGroupInfoDao;
|
|
@ -27,6 +29,7 @@ import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@ -319,6 +322,33 @@ public class SignPatientLabelInfoService extends BaseService {
|
|
|
" f. CODE = s.sign_code " +
|
|
|
" AND s.server_type ='"+labelCode+"' ORDER BY f.ptOpenid DESC";
|
|
|
args = new Object[]{doctor, doctor, teamCode};
|
|
|
}else if("3".equals(labelType) && isSlowDisease){
|
|
|
//慢病管理
|
|
|
sql = "SELECT " +
|
|
|
" DISTINCT t1.* " +
|
|
|
" FROM " +
|
|
|
" wlyy_sign_family t1, " +
|
|
|
" wlyy_sign_patient_label_info t2 ";
|
|
|
if(StringUtils.isNotBlank(diseaseCondition)) {
|
|
|
sql = sql + ", wlyy_patient p ";
|
|
|
}
|
|
|
sql = sql + " WHERE t2.label = ?";
|
|
|
|
|
|
if(StringUtils.isNotBlank(diseaseCondition)) {
|
|
|
sql = sql + " AND p.disease_condition = ? ";
|
|
|
}
|
|
|
|
|
|
sql = sql + " AND t2.label_type = ? " +
|
|
|
" AND t2.status = 1 " +
|
|
|
" AND t1.patient = t2.patient " +
|
|
|
" AND (t1.doctor = ? or t1.doctor_health = ?)" +
|
|
|
" AND t1.status > 0 " +
|
|
|
" AND t1.admin_team_code = ? order by t1.openid desc,convert(t1.name using gbk) ";
|
|
|
if(StringUtils.isNotBlank(diseaseCondition)) {
|
|
|
args = new Object[]{labelCode, diseaseCondition, labelType, doctor, doctor, teamCode};
|
|
|
}else{
|
|
|
args = new Object[]{labelCode, labelType, doctor, doctor, teamCode};
|
|
|
}
|
|
|
} else {
|
|
|
if (labelCode.equals("0")) {
|
|
|
sql = "SELECT " +
|
|
@ -371,9 +401,22 @@ public class SignPatientLabelInfoService extends BaseService {
|
|
|
|
|
|
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) {
|
|
|
// Patient p = patientDao.findByCode(sign.get("patient") == null ? "" : sign.get("patient").toString());
|
|
|
//
|
|
|
// if (p == null) {
|
|
|
// continue;
|
|
|
// }
|
|
|
|
|
|
PatientVO p = new PatientVO();
|
|
|
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" +
|
|
|
" 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()+"'";
|
|
|
|
|
|
p = (PatientVO)jdbcTemplate.queryForObject(patientsql,new BeanPropertyRowMapper(PatientVO.class));
|
|
|
}else{
|
|
|
continue;
|
|
|
}
|
|
|
|
|
@ -980,7 +1023,7 @@ public class SignPatientLabelInfoService extends BaseService {
|
|
|
* @param teamCode 标签类型为4时,不能为空
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONArray getPatientAmountByLabelType(String doctor, String labelType, Long teamCode) throws Exception {
|
|
|
public JSONArray getPatientAmountByLabelType(String doctor, String labelType, Long teamCode, boolean isSlowDisease, String diseaseCondition) throws Exception {
|
|
|
Doctor doc = doctorDao.findByCode(doctor);
|
|
|
|
|
|
if (doc == null) {
|
|
@ -1014,18 +1057,19 @@ public class SignPatientLabelInfoService extends BaseService {
|
|
|
int amount = 0;
|
|
|
String sql = "";
|
|
|
Object[] args = null;
|
|
|
Calendar today = Calendar.getInstance();
|
|
|
Calendar startDate = Calendar.getInstance();
|
|
|
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
|
if (labelType.equals("5")) {
|
|
|
Calendar today = Calendar.getInstance();
|
|
|
Calendar startDate = Calendar.getInstance();
|
|
|
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
|
sql = "select count(DISTINCT t1.patient) count" +
|
|
|
" from " +
|
|
|
" wlyy_sign_family t1," +
|
|
|
" wlyy_patient t3 " +
|
|
|
" where t1.patient = t3.code AND (t1.doctor = ? or t1.doctor_health = ?) and t1.status > 0 " +
|
|
|
(teamCode > 0 ? " and t1.admin_team_code = ? " : "");
|
|
|
|
|
|
|
|
|
if (label.getLabelCode().equals("1")) {
|
|
|
int week = today.get(Calendar.DAY_OF_WEEK) - 2;
|
|
|
if (week == -1) {
|
|
@ -1050,6 +1094,28 @@ public class SignPatientLabelInfoService extends BaseService {
|
|
|
} else {
|
|
|
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 (teamCode > 0) {
|
|
|
args = new Object[]{label.getLabelCode(), labelType, doctor, doctor, teamCode};
|
|
|
} else {
|
|
|
args = new Object[]{label.getLabelCode(), labelType, doctor, doctor};
|
|
|
}
|
|
|
} else {
|
|
|
if (label.getLabelCode().equals("0")) {
|
|
|
sql = " SELECT " +
|
|
@ -3586,7 +3652,7 @@ public class SignPatientLabelInfoService extends BaseService {
|
|
|
|
|
|
Map<String, JSONObject> result = new TreeMap<>();
|
|
|
List<Map<String, Object>> signList = new ArrayList<>();
|
|
|
Map<String,Object> patientDeviceTypeMap = new HashMap<>();//用于存储患者设备绑定情况
|
|
|
// Map<String,Object> patientDeviceTypeMap = new HashMap<>();//用于存储患者设备绑定情况
|
|
|
int start = page * pagesize;
|
|
|
String sql = "";
|
|
|
Object[] args = null;
|
|
@ -3652,7 +3718,32 @@ public class SignPatientLabelInfoService extends BaseService {
|
|
|
" AND s.server_type ='"+labelCode+"' " +
|
|
|
" ORDER BY " +
|
|
|
" f.ptOpenid DESC";
|
|
|
|
|
|
}else if("3".equals(labelType) && isSlowDisease){
|
|
|
//慢病管理
|
|
|
sql = "SELECT " +
|
|
|
" DISTINCT t1.* " +
|
|
|
" FROM " +
|
|
|
" wlyy_sign_family t1, " +
|
|
|
" wlyy_sign_patient_label_info t2 ";
|
|
|
if(StringUtils.isNotBlank(diseaseCondition)) {
|
|
|
sql = sql + ", wlyy_patient p ";
|
|
|
}
|
|
|
sql = sql + " WHERE t2.label = ?";
|
|
|
|
|
|
if(StringUtils.isNotBlank(diseaseCondition)) {
|
|
|
sql = sql + " AND p.disease_condition = ? ";
|
|
|
}
|
|
|
|
|
|
sql = sql + " AND t2.label_type = ? " +
|
|
|
" AND t2.status = 1 " +
|
|
|
" AND t1.patient = t2.patient " +
|
|
|
" AND t1.status > 0 " +
|
|
|
" AND t1.admin_team_code = ? order by t1.openid desc,convert(t1.name using gbk) ";
|
|
|
if(StringUtils.isNotBlank(diseaseCondition)) {
|
|
|
args = new Object[]{labelCode,diseaseCondition, labelType, teamCode};
|
|
|
}else{
|
|
|
args = new Object[]{labelCode, labelType, teamCode};
|
|
|
}
|
|
|
}else {
|
|
|
if ("0".equals(labelCode)) {
|
|
|
sql = "SELECT " +
|
|
@ -3700,23 +3791,36 @@ public class SignPatientLabelInfoService extends BaseService {
|
|
|
sql = 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);
|
|
|
}
|
|
|
}
|
|
|
// //查询患者设备绑定情况
|
|
|
// 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) {
|
|
|
Patient p = patientDao.findByCode(sign.get("patient") == null ? "" : sign.get("patient").toString());
|
|
|
|
|
|
if (p == null) {
|
|
|
|
|
|
// Patient p = patientDao.findByCode(sign.get("patient") == null ? "" : sign.get("patient").toString());
|
|
|
// if (p == null) {
|
|
|
// continue;
|
|
|
// }
|
|
|
//查找居民 改造成获取绑定的设备和疾病类型--huangwenjie-2017.11.21
|
|
|
PatientVO p = new PatientVO();
|
|
|
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" +
|
|
|
" 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()+"'";
|
|
|
|
|
|
p = (PatientVO)jdbcTemplate.queryForObject(patientsql,new BeanPropertyRowMapper(PatientVO.class));
|
|
|
}else{
|
|
|
continue;
|
|
|
}
|
|
|
|
|
@ -3825,12 +3929,13 @@ public class SignPatientLabelInfoService extends BaseService {
|
|
|
json.put("diseaseCondition",p.getDiseaseCondition());
|
|
|
//预警状态
|
|
|
json.put("standardStatus",p.getStandardStatus());
|
|
|
//
|
|
|
// String deviceType = "";
|
|
|
// if(!patientDeviceTypeMap.isEmpty() && patientDeviceTypeMap.keySet().contains(p.getCode())){
|
|
|
// deviceType = (String) patientDeviceTypeMap.get(p.getCode());
|
|
|
// }
|
|
|
//设备状态: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;
|
|
@ -4067,8 +4172,6 @@ public class SignPatientLabelInfoService extends BaseService {
|
|
|
int page, int pagesize) throws Exception {
|
|
|
Doctor doc = doctorDao.findByCode(doctor);
|
|
|
|
|
|
Map<String,Object> patientDeviceTypeMap = new HashMap<>();//用于存储患者设备绑定情况
|
|
|
|
|
|
if (doc == null) {
|
|
|
throw new Exception("doctor info can not find");
|
|
|
}
|
|
@ -4099,7 +4202,7 @@ public class SignPatientLabelInfoService extends BaseService {
|
|
|
(StringUtils.isNotEmpty(labelCode) ? " AND t2.label = ? " : "") +
|
|
|
(StringUtils.isNotEmpty(labelType) ? " AND t2.label_type = ? " : "") +
|
|
|
(teamCode > 0 ? (" AND admin_team_code = " + teamCode) : "");
|
|
|
sql = sql + " AND t3.disease > 0 AND t3.status > 0 ";
|
|
|
sql = sql + " AND t3.status > 0 and t2.label_type = '3' and ( t2.label =1 or t2.lable = 2) ";
|
|
|
|
|
|
if (matcher.find()) {
|
|
|
sql = sql + " AND (t1.idcard like ?) ";
|
|
@ -4122,16 +4225,22 @@ public class SignPatientLabelInfoService extends BaseService {
|
|
|
}
|
|
|
|
|
|
|
|
|
sql = sql + " order by t3.standard_status,t3.disease_condition,t3.disease,t3.openid desc limit " + page + "," + pagesize;
|
|
|
sql = sql + " order by t3.standard_status,t3.disease_condition,t2.label,t3.openid desc limit " + page + "," + pagesize;
|
|
|
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());
|
|
|
System.out.println("1111");
|
|
|
|
|
|
if (p == null) {
|
|
|
PatientVO p = new PatientVO();
|
|
|
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" +
|
|
|
" 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()+"'";
|
|
|
|
|
|
p = (PatientVO)jdbcTemplate.queryForObject(patientsql,new BeanPropertyRowMapper(PatientVO.class));
|
|
|
}else{
|
|
|
continue;
|
|
|
}
|
|
|
|
|
@ -4264,11 +4373,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 {
|
|
@ -4301,7 +4406,6 @@ public class SignPatientLabelInfoService extends BaseService {
|
|
|
public JSONArray searchSlowDiseaseTeamsPatients(String filter, long teamCode, int page, int pagesize, String diseaseCondition) throws Exception {
|
|
|
Map<String, JSONObject> result = new HashMap<>();
|
|
|
List<Map<String, Object>> signList = new ArrayList<>();
|
|
|
Map<String,Object> patientDeviceTypeMap = new HashMap<>();//用于存储患者设备绑定情况
|
|
|
|
|
|
page = page * pagesize;
|
|
|
//String reg = "(^\\d{15}$)|(^\\d{17}([0-9]|X)$)";
|
|
@ -4316,6 +4420,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 " +
|
|
|
" WHERE " +
|
|
|
(isIdcard ? " t1.patient = t2.code and " : "") +
|
|
|
" t1.status > 0 " +
|
|
@ -4323,28 +4428,23 @@ public class SignPatientLabelInfoService extends BaseService {
|
|
|
" AND" +
|
|
|
(isIdcard ? " t2.idcard like ? " : " t1.name like ? ");
|
|
|
|
|
|
sqlTemp = sqlTemp + " AND t2.disease_condition = "+diseaseCondition+" AND t2.disease >0 AND t2.status >0 ";
|
|
|
sqlTemp = sqlTemp + " AND t2.disease_condition = "+diseaseCondition+" AND t2.status >0 and t3.label_type = 3 and (t3.label = 1 or t3.label = 2)";
|
|
|
|
|
|
String sql = sqlTemp + " order by t2.standard_status,t2.disease_condition,t2.disease,t2.openid desc limit " + page + "," + pagesize;
|
|
|
String sql = sqlTemp + " order by t2.standard_status,t2.disease_condition,t3.label,t2.openid desc limit " + page + "," + 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) {
|
|
|
Patient p = patientDao.findByCode(sign.get("patient") == null ? "" : sign.get("patient").toString());
|
|
|
|
|
|
if (p == null) {
|
|
|
PatientVO p = new PatientVO();
|
|
|
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" +
|
|
|
" 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()+"'";
|
|
|
|
|
|
p = (PatientVO)jdbcTemplate.queryForObject(patientsql,new BeanPropertyRowMapper(PatientVO.class));
|
|
|
}else{
|
|
|
continue;
|
|
|
}
|
|
|
|
|
@ -4460,11 +4560,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 {
|