|
@ -497,6 +497,249 @@ public class SignPatientLabelInfoService extends BaseService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 根据标签查询患者信息
|
|
|
*
|
|
|
* @param labelCode 标签code
|
|
|
* @param labelType 标签类型
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONArray getPatientByLabelCount(String doctor, String labelCode, String labelType, Long teamCode) throws Exception {
|
|
|
Doctor doc = doctorDao.findByCode(doctor);
|
|
|
|
|
|
if (doc == null) {
|
|
|
throw new Exception("doctor info can not find");
|
|
|
}
|
|
|
|
|
|
Map<String, JSONObject> result = new TreeMap<>();
|
|
|
List<Map<String, Object>> signList = new ArrayList<>();
|
|
|
String sql = "";
|
|
|
Object[] args = null;
|
|
|
|
|
|
if (labelType.equals("5")) {
|
|
|
Calendar today = Calendar.getInstance();
|
|
|
Calendar startDate = Calendar.getInstance();
|
|
|
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
sql = "select * " +
|
|
|
" from " +
|
|
|
" wlyy_sign_family " +
|
|
|
" where (doctor = ? or doctor_health = ?) and status > 0 and admin_team_code = ? ";
|
|
|
|
|
|
if (labelCode.equals("1")) {
|
|
|
int week = today.get(Calendar.DAY_OF_WEEK) - 2;
|
|
|
|
|
|
if (week == -1) {
|
|
|
week = 6;
|
|
|
}
|
|
|
startDate.add(Calendar.DATE, -week);
|
|
|
sql += " and apply_date between '" + (df.format(startDate.getTime()) + " 00:00:00")
|
|
|
+ "' and '" + (df.format(today.getTime()) + " 23:59:59'");
|
|
|
} else if (labelCode.equals("2")) {
|
|
|
startDate.set(Calendar.DATE, 1);
|
|
|
sql += " and apply_date between '" + (df.format(startDate.getTime()) + " 00:00:00")
|
|
|
+ "' and '" + (df.format(today.getTime()) + " 23:59:59'");
|
|
|
} else if (labelCode.equals("3")) {
|
|
|
startDate.add(Calendar.DATE, 30);
|
|
|
sql += " and end between '" + (df.format(today.getTime()) + " 00:00:00")
|
|
|
+ "' and '" + (df.format(startDate.getTime()) + " 23:59:59'");
|
|
|
} else {
|
|
|
throw new Exception("label is not exist");
|
|
|
}
|
|
|
sql += " order by openid desc,convert(name using gbk) ";
|
|
|
args = new Object[]{doctor, doctor, teamCode};
|
|
|
}else if("1".equals(labelType)){
|
|
|
sql = "SELECT " +
|
|
|
" f.* " +
|
|
|
"FROM " +
|
|
|
" wlyy_sign_family_server s ,( " +
|
|
|
" SELECT " +
|
|
|
" t1.*, p.openid AS ptOpenid " +
|
|
|
" FROM " +
|
|
|
" wlyy_sign_family t1, " +
|
|
|
" wlyy_patient p " +
|
|
|
" WHERE " +
|
|
|
" p. CODE = t1.patient " +
|
|
|
" AND ( " +
|
|
|
" t1.doctor = ? " +
|
|
|
" OR t1.doctor_health = ? " +
|
|
|
" ) " +
|
|
|
" AND t1. STATUS > 0 " +
|
|
|
" AND t1.admin_team_code = ?" +
|
|
|
" ) f " +
|
|
|
"WHERE " +
|
|
|
" f. CODE = s.sign_code " +
|
|
|
" AND s.server_type ='"+labelCode+"' " +
|
|
|
" ORDER BY " +
|
|
|
" f.ptOpenid DESC";
|
|
|
args = new Object[]{doctor, doctor, teamCode};
|
|
|
} else {
|
|
|
if (labelCode.equals("0")) {
|
|
|
sql = "SELECT " +
|
|
|
" t1.* " +
|
|
|
" FROM " +
|
|
|
" wlyy_sign_family t1 " +
|
|
|
" left join " +
|
|
|
" (select l.patient,l.label,l.label_type,l.label_name from wlyy_sign_family f left join wlyy_sign_patient_label_info l on f.patient = l.patient where (f.doctor = '" + doctor + "' or f.doctor_health = '" + doctor + "') and f.status > 0 and l.label_type = ? and l.status = 1) t2 " +
|
|
|
" on t1.patient = t2.patient " +
|
|
|
" WHERE " +
|
|
|
" t2.patient is null " +
|
|
|
" 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) ";
|
|
|
|
|
|
args = new Object[]{labelType, doctor, doctor, teamCode};
|
|
|
}else {
|
|
|
sql = "SELECT " +
|
|
|
" t1.* " +
|
|
|
" FROM " +
|
|
|
" wlyy_sign_family t1, " +
|
|
|
" wlyy_sign_patient_label_info t2 " +
|
|
|
" WHERE " +
|
|
|
" t2.label = ? " +
|
|
|
" 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) ";
|
|
|
|
|
|
args = new Object[]{labelCode, labelType, doctor, 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);
|
|
|
}
|
|
|
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();
|
|
|
|
|
|
// 设置患者标识
|
|
|
json.put("code", p.getCode());
|
|
|
// 设置患者姓名
|
|
|
json.put("name", p.getName());
|
|
|
// 设置患者手机号
|
|
|
json.put("mobile", p.getMobile());
|
|
|
// 设置患者微信openid
|
|
|
json.put("openid", StringUtils.isNotEmpty(p.getOpenid()) ? p.getOpenid() : "");
|
|
|
// 设置患者联系电话
|
|
|
json.put("phone", p.getPhone());
|
|
|
// 设置患者紧急联系人
|
|
|
json.put("emerMobile", sign.get("emer_mobile") == null ? "" : String.valueOf(sign.get("emer_mobile")));
|
|
|
// 设置患者头像
|
|
|
json.put("photo", p.getPhoto());
|
|
|
// 设置患者年龄
|
|
|
json.put("age", IdCardUtil.getAgeForIdcard(p.getIdcard()));
|
|
|
// 设置患者性别
|
|
|
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("ssc", p.getSsc());
|
|
|
if (String.valueOf(sign.get("type")).equals("2")) {
|
|
|
// 缴费情况
|
|
|
json.put("expensesStatus", sign.get("expenses_status") != null ? String.valueOf(sign.get("expenses_status")) : "0");
|
|
|
// 缴费时间
|
|
|
json.put("expensesTime", sign.get("expenses_time") != null ? DateUtil.dateToStr((Date) sign.get("expenses_time"), DateUtil.YYYY_MM_DD_HH_MM) : "");
|
|
|
// 缴费类型
|
|
|
json.put("expensesType", sign.get("expenses_type") != null ? String.valueOf(sign.get("expenses_type")) : "");
|
|
|
|
|
|
if (StringUtils.isEmpty(String.valueOf(json.get("expensesStatus"))) || String.valueOf(json.get("expensesStatus")).equals("0")) {
|
|
|
boolean epTime = false;
|
|
|
try {
|
|
|
epTime = redisTemplate.opsForSet().isMember("expenses:remind:set", p.getCode());
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
if (!epTime) {
|
|
|
json.put("expensesRemindStatus", 0);
|
|
|
} else {
|
|
|
json.put("expensesRemindStatus", 1);
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
// 缴费情况
|
|
|
json.put("expensesStatus", "1");
|
|
|
}
|
|
|
boolean epTime = false;
|
|
|
try {
|
|
|
epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", p.getCode());
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
if (!epTime) {
|
|
|
json.put("wechatFocusRemind", 0);
|
|
|
} else {
|
|
|
json.put("wechatFocusRemind", 1);
|
|
|
}
|
|
|
// 患者标签
|
|
|
//json.put("labels", labels == null ? "" : labels);
|
|
|
|
|
|
result.put(p.getCode(), json);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (result.size() > 0) {
|
|
|
List<JSONObject> list = Lists.newArrayList(result.values());
|
|
|
|
|
|
return new JSONArray(list);
|
|
|
} else {
|
|
|
return new JSONArray();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取团队下的患者
|
|
|
*
|