|
@ -77,8 +77,6 @@ public class SignPatientLabelInfoService extends BaseService {
|
|
|
throw new Exception("patient info can not find");
|
|
|
}
|
|
|
|
|
|
List<SignFamily> signs = signFamilyDao.findAllSignByPatient(patient);
|
|
|
|
|
|
// 设置患者标识
|
|
|
json.put("code", p.getCode());
|
|
|
// 设置患者姓名
|
|
@ -100,62 +98,65 @@ public class SignPatientLabelInfoService extends BaseService {
|
|
|
// 社保号
|
|
|
json.put("ssc", p.getSsc());
|
|
|
|
|
|
if (signs != null && signs.size() > 0) {
|
|
|
SignFamily ssSign = null;
|
|
|
SignFamily familySign = null;
|
|
|
for (SignFamily sign : signs) {
|
|
|
if (sign.getType() == 1) {
|
|
|
ssSign = sign;
|
|
|
} else if (sign.getType() == 2) {
|
|
|
familySign = sign;
|
|
|
}
|
|
|
SignFamily ssSign = signFamilyDao.findSignByPatient(patient,1);
|
|
|
SignFamily familySign = signFamilyDao.findSignByPatient(patient,2);
|
|
|
|
|
|
if (ssSign != null) {
|
|
|
// 设置患者紧急联系人
|
|
|
json.put("emerMobile", StringUtils.isEmpty(ssSign.getEmerMobile()) ? "" : String.valueOf(ssSign.getEmerMobile()));
|
|
|
// 设置签约日期
|
|
|
json.put("qyrq", ssSign.getApplyDate() != null ? DateUtil.dateToStr((Date) ssSign.getApplyDate(), DateUtil.YYYY_MM_DD) : "");
|
|
|
// 设置签约类型
|
|
|
json.put("signType", 1);
|
|
|
// 设置签约状态
|
|
|
json.put("ssStatus", ssSign.getStatus());
|
|
|
|
|
|
json.put("ssDoctor", ssSign.getDoctor());
|
|
|
json.put("ssDoctorName", ssSign.getDoctorName());
|
|
|
json.put("ssDoctorHealth", ssSign.getDoctorHealth());
|
|
|
json.put("ssDoctorHealthName", ssSign.getDoctorHealthName());
|
|
|
json.put("ssAdminTeam", ssSign.getAdminTeamId());
|
|
|
}
|
|
|
if (familySign != null) {
|
|
|
// 设置患者紧急联系人
|
|
|
json.put("emerMobile", StringUtils.isEmpty(familySign.getEmerMobile()) ? "" : String.valueOf(familySign.getEmerMobile()));
|
|
|
// 设置签约日期
|
|
|
json.put("qyrq", familySign.getApplyDate() != null ? DateUtil.dateToStr((Date) familySign.getApplyDate(), DateUtil.YYYY_MM_DD) : "");
|
|
|
// 设置签约日期
|
|
|
json.put("patientApplyDate", familySign.getPatientApplyDate() != null ? DateUtil.dateToStr((Date) familySign.getPatientApplyDate(), DateUtil.YYYY_MM_DD) : "");
|
|
|
// 设置签约类型
|
|
|
json.put("signType", json.has("signType") ? 3 : 2);
|
|
|
// 缴费情况
|
|
|
json.put("expensesStatus", StringUtils.isNotEmpty(familySign.getExpensesStatus()) ? String.valueOf(familySign.getExpensesStatus()) : "0");
|
|
|
// 缴费时间
|
|
|
json.put("expensesTime", familySign.getExpensesTime() != null ? DateUtil.dateToStr((Date) familySign.getExpensesTime(), DateUtil.YYYY_MM_DD_HH_MM) : "");
|
|
|
// 缴费类型
|
|
|
json.put("expensesType", StringUtils.isNotEmpty(familySign.getExpensesType()) ? String.valueOf(familySign.getExpensesType()) : "");
|
|
|
// 设置签约状态
|
|
|
json.put("familyStatus", familySign.getStatus());
|
|
|
|
|
|
json.put("jtDoctor", familySign.getDoctor());
|
|
|
json.put("jtDoctorName", familySign.getDoctorName());
|
|
|
json.put("jtDoctorHealth", familySign.getDoctorHealth());
|
|
|
json.put("jtDoctorHealthName", familySign.getDoctorHealthName());
|
|
|
json.put("jtAdminTeam", familySign.getAdminTeamId());
|
|
|
|
|
|
if ("1".equals(familySign.getExpensesStatus())) {
|
|
|
json.put("qyrq", familySign.getExpensesTime() != null ? DateUtil.dateToStr((Date) familySign.getExpensesTime(), DateUtil.YYYY_MM_DD) : "");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (ssSign != null) {
|
|
|
// 设置患者紧急联系人
|
|
|
json.put("emerMobile", StringUtils.isEmpty(ssSign.getEmerMobile()) ? "" : String.valueOf(ssSign.getEmerMobile()));
|
|
|
// 设置签约日期
|
|
|
json.put("qyrq", ssSign.getApplyDate() != null ? DateUtil.dateToStr((Date) ssSign.getApplyDate(), DateUtil.YYYY_MM_DD) : "");
|
|
|
// 设置签约类型
|
|
|
json.put("signType", 1);
|
|
|
// 设置签约状态
|
|
|
json.put("ssStatus", ssSign.getStatus());
|
|
|
}
|
|
|
if (familySign != null) {
|
|
|
// 设置患者紧急联系人
|
|
|
json.put("emerMobile", StringUtils.isEmpty(familySign.getEmerMobile()) ? "" : String.valueOf(familySign.getEmerMobile()));
|
|
|
// 设置签约日期
|
|
|
json.put("qyrq", familySign.getApplyDate() != null ? DateUtil.dateToStr((Date) familySign.getApplyDate(), DateUtil.YYYY_MM_DD) : "");
|
|
|
// 设置签约日期
|
|
|
json.put("patientApplyDate", familySign.getPatientApplyDate() != null ? DateUtil.dateToStr((Date) familySign.getPatientApplyDate(), DateUtil.YYYY_MM_DD) : "");
|
|
|
// 设置签约类型
|
|
|
json.put("signType", json.has("signType") ? 3 : 2);
|
|
|
// 缴费情况
|
|
|
json.put("expensesStatus", StringUtils.isNotEmpty(familySign.getExpensesStatus()) ? String.valueOf(familySign.getExpensesStatus()) : "0");
|
|
|
// 缴费时间
|
|
|
json.put("expensesTime", familySign.getExpensesTime() != null ? DateUtil.dateToStr((Date) familySign.getExpensesTime(), DateUtil.YYYY_MM_DD_HH_MM) : "");
|
|
|
// 缴费类型
|
|
|
json.put("expensesType", StringUtils.isNotEmpty(familySign.getExpensesType()) ? String.valueOf(familySign.getExpensesType()) : "");
|
|
|
// 设置签约状态
|
|
|
json.put("familyStatus", familySign.getStatus());
|
|
|
|
|
|
if ("1".equals(familySign.getExpensesStatus())) {
|
|
|
json.put("qyrq", familySign.getExpensesTime() != null ? DateUtil.dateToStr((Date) familySign.getExpensesTime(), DateUtil.YYYY_MM_DD) : "");
|
|
|
}
|
|
|
if (json.has("expensesStatus") && (StringUtils.isEmpty(String.valueOf(json.get("expensesStatus"))) || String.valueOf(json.get("expensesStatus")).equals("0"))) {
|
|
|
String epTime = "";
|
|
|
try {
|
|
|
epTime = redisTemplate.opsForValue().get("expenses:remind:" + p.getCode());
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
|
|
|
if (json.has("expensesStatus") && (StringUtils.isEmpty(String.valueOf(json.get("expensesStatus"))) || String.valueOf(json.get("expensesStatus")).equals("0"))) {
|
|
|
String epTime = "";
|
|
|
try {
|
|
|
epTime = redisTemplate.opsForValue().get("expenses:remind:" + p.getCode());
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
if (StringUtils.isEmpty(epTime)) {
|
|
|
json.put("expensesRemindStatus", 0);
|
|
|
} else {
|
|
|
json.put("expensesRemindStatus", new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
|
|
|
}
|
|
|
if (StringUtils.isEmpty(epTime)) {
|
|
|
json.put("expensesRemindStatus", 0);
|
|
|
} else {
|
|
|
json.put("expensesRemindStatus", new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
|
|
|
}
|
|
|
}
|
|
|
|
|
@ -330,9 +331,6 @@ public class SignPatientLabelInfoService extends BaseService {
|
|
|
// 缴费类型
|
|
|
json.put("expensesType", sign.get("expenses_type") != null ? String.valueOf(sign.get("expenses_type")) : "");
|
|
|
|
|
|
// if("2".equals(String.valueOf(sign.get("type"))) && "1".equals(String.valueOf(sign.get("expenses_status")))){
|
|
|
// json.put("qyrq", sign.get("expenses_time") != null ? DateUtil.dateToStr((Date) sign.get("expenses_time"), DateUtil.YYYY_MM_DD) : "");
|
|
|
// }
|
|
|
if (StringUtils.isEmpty(String.valueOf(json.get("expensesStatus"))) || String.valueOf(json.get("expensesStatus")).equals("0")) {
|
|
|
String epTime = "";
|
|
|
try {
|
|
@ -478,9 +476,7 @@ public class SignPatientLabelInfoService extends BaseService {
|
|
|
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("2".equals(String.valueOf(sign.get("type"))) && "1".equals(String.valueOf(sign.get("expenses_status")))){
|
|
|
// json.put("qyrq", sign.get("expenses_time") != null ? DateUtil.dateToStr((Date) sign.get("expenses_time"), DateUtil.YYYY_MM_DD) : "");
|
|
|
// }
|
|
|
|
|
|
if (StringUtils.isEmpty(String.valueOf(json.get("expensesStatus"))) || String.valueOf(json.get("expensesStatus")).equals("0")) {
|
|
|
String epTime = "";
|
|
|
try {
|
|
@ -508,7 +504,6 @@ public class SignPatientLabelInfoService extends BaseService {
|
|
|
return result.size() > 0 ? new JSONArray(result.values()) : new JSONArray();
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 查询某个标签类型的所有标签居民数统计
|
|
|
*
|
|
@ -652,7 +647,11 @@ public class SignPatientLabelInfoService extends BaseService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取团队签约人数
|
|
|
*
|
|
|
* @param teamCode
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public int getPatientAmountByTeam(Long teamCode) throws Exception {
|
|
|
List<SignFamily> signFamilies = signFamilyDao.findByAdminTeamIdAndStatus(teamCode, 1);
|
|
@ -713,7 +712,7 @@ public class SignPatientLabelInfoService extends BaseService {
|
|
|
" from " +
|
|
|
" wlyy_sign_family " +
|
|
|
" where status > 0 " +
|
|
|
(teamCode > 0 ? " and admin_team_code = ? " : "");
|
|
|
" and admin_team_code = ? ";
|
|
|
|
|
|
if (label.getLabelCode().equals("1")) {
|
|
|
int week = today.get(Calendar.DAY_OF_WEEK) - 2;
|
|
@ -734,11 +733,8 @@ public class SignPatientLabelInfoService extends BaseService {
|
|
|
} else {
|
|
|
throw new Exception("label is not exist");
|
|
|
}
|
|
|
if (teamCode > 0) {
|
|
|
args = new Object[]{teamCode, teamCode};
|
|
|
} else {
|
|
|
args = new Object[]{};
|
|
|
}
|
|
|
|
|
|
args = new Object[]{teamCode};
|
|
|
} else {
|
|
|
if (label.getLabelCode().equals("0")) {
|
|
|
sql = " SELECT " +
|
|
@ -746,18 +742,14 @@ public class SignPatientLabelInfoService extends BaseService {
|
|
|
" FROM" +
|
|
|
" wlyy_sign_family t1 " +
|
|
|
" left join " +
|
|
|
" (select repl.patient,repl.label,repl.label_type,repl.label_name from wlyy_sign_family repf left join wlyy_sign_patient_label_info repl on repf.patient = repl.patient where repf.status > 0 and repl.label_type = ? and repl.status = 1) t2 " +
|
|
|
" (select repl.patient,repl.label,repl.label_type,repl.label_name from wlyy_sign_family repf left join wlyy_sign_patient_label_info repl on repf.patient = repl.patient where repf.admin_team_code = ? and repf.status > 0 and repl.label_type = ? and repl.status = 1) t2 " +
|
|
|
" on t1.patient = t2.patient " +
|
|
|
" WHERE" +
|
|
|
" t2.patient is null " +
|
|
|
" AND t1.status > 0 " +
|
|
|
(teamCode > 0 ? " AND t1.admin_team_code = ? " : "");
|
|
|
" AND t1.admin_team_code = ? ";
|
|
|
|
|
|
if (teamCode > 0) {
|
|
|
args = new Object[]{labelType, teamCode, labelType, teamCode};
|
|
|
} else {
|
|
|
args = new Object[]{labelType, labelType};
|
|
|
}
|
|
|
args = new Object[]{teamCode, labelType, teamCode};
|
|
|
} else {
|
|
|
sql = " SELECT " +
|
|
|
" t1.* " +
|
|
@ -770,20 +762,13 @@ public class SignPatientLabelInfoService extends BaseService {
|
|
|
" AND t2.label_type = ? " +
|
|
|
" AND t2.status = 1 " +
|
|
|
" AND t1.status > 0 " +
|
|
|
(teamCode > 0 ? " AND t1.admin_team_code = ? " : "");
|
|
|
" AND t1.admin_team_code = ? ";
|
|
|
|
|
|
if (teamCode > 0) {
|
|
|
args = new Object[]{label.getLabelCode(), labelType, teamCode, label.getLabelCode(), labelType, teamCode};
|
|
|
} else {
|
|
|
args = new Object[]{label.getLabelCode(), labelType, label.getLabelCode(), labelType};
|
|
|
}
|
|
|
args = new Object[]{label.getLabelCode(), labelType, teamCode};
|
|
|
}
|
|
|
}
|
|
|
|
|
|
String sqlDoc = sql.replaceAll("repdoctor", "doctor");
|
|
|
String sqlDocHealth = sql.replaceAll("repdoctor", "doctor_health").replaceAll("t1", "t3").replaceAll("t2", "t4").replaceAll("repf", "repf1").replaceAll("repl", "repl1");
|
|
|
|
|
|
sql = "select count(DISTINCT t.patient) count from (" + sqlDoc + " union all " + sqlDocHealth + ") t";
|
|
|
sql = "select count(DISTINCT t.patient) count from (" + sql + ") t";
|
|
|
|
|
|
List<Map<String, Object>> count = jdbcTemplate.queryForList(sql, args);
|
|
|
|
|
@ -843,8 +828,8 @@ public class SignPatientLabelInfoService extends BaseService {
|
|
|
JSONArray teams = adminTeamService.findPatientDoctorTeam(patient, doctor);
|
|
|
List<String> teamCodes = new ArrayList<>();
|
|
|
|
|
|
if(teams.length() > 0){
|
|
|
for(int i = 0; i < teams.length(); i++){
|
|
|
if (teams.length() > 0) {
|
|
|
for (int i = 0; i < teams.length(); i++) {
|
|
|
teamCodes.add(String.valueOf(teams.getJSONObject(i).getLong("id")));
|
|
|
}
|
|
|
} else {
|
|
@ -933,9 +918,9 @@ public class SignPatientLabelInfoService extends BaseService {
|
|
|
|
|
|
for (SignPatientLabelInfo label : labels) {
|
|
|
labelMap.put(label.getLabel(), label);
|
|
|
SignPatientLabel lb = labelService.getLabelByCodeAndType(label.getLabel(),"4");
|
|
|
SignPatientLabel lb = labelService.getLabelByCodeAndType(label.getLabel(), "4");
|
|
|
|
|
|
if(!custList.contains(label.getLabel())) {
|
|
|
if (!custList.contains(label.getLabel())) {
|
|
|
if (lb.getLabelCode().equals("1") || lb.getLabelCode().equals("2") || teamCodes.contains(String.valueOf(lb.getTeamCode()))) {
|
|
|
label.setStatus(0);
|
|
|
labelInfoDao.save(label);
|
|
@ -975,7 +960,7 @@ public class SignPatientLabelInfoService extends BaseService {
|
|
|
|| Arrays.asList(diseaseArr).contains("2"))) {
|
|
|
SignPatientLabelInfo mbEx = labelInfoDao.findByPatientAndLabelAndLabelTypeAndStatus(patient, "2", "1", 1);
|
|
|
|
|
|
if(mbEx == null) {
|
|
|
if (mbEx == null) {
|
|
|
// 卫计委三大分组
|
|
|
int wjwAmount = labelInfoDao.deleteByPatientAndLabelTypeAndStatus(patient, "1", 1);
|
|
|
SignPatientLabelInfo disLabel = new SignPatientLabelInfo();
|
|
@ -992,8 +977,8 @@ public class SignPatientLabelInfoService extends BaseService {
|
|
|
}
|
|
|
} else {
|
|
|
int age = IdCardUtil.getAgeForIdcard(idcard);
|
|
|
String lbCode = "",lbName = "";
|
|
|
if(age >= 65){
|
|
|
String lbCode = "", lbName = "";
|
|
|
if (age >= 65) {
|
|
|
lbCode = "3";
|
|
|
lbName = "65岁以上人群";
|
|
|
} else {
|
|
@ -1003,7 +988,7 @@ public class SignPatientLabelInfoService extends BaseService {
|
|
|
|
|
|
SignPatientLabelInfo wjwEx = labelInfoDao.findByPatientAndLabelAndLabelTypeAndStatus(patient, lbCode, "1", 1);
|
|
|
|
|
|
if(wjwEx == null) {
|
|
|
if (wjwEx == null) {
|
|
|
// 卫计委三大分组
|
|
|
int wjwAmount = labelInfoDao.deleteByPatientAndLabelTypeAndStatus(patient, "1", 1);
|
|
|
SignPatientLabelInfo disLabel = new SignPatientLabelInfo();
|
|
@ -1571,7 +1556,7 @@ public class SignPatientLabelInfoService extends BaseService {
|
|
|
" AND (" + (StringUtils.isNotEmpty(labelCode) || StringUtils.isNotEmpty(labelType) ? "" : " t2.patient is null OR ") + " t2.status = 1) " +
|
|
|
(StringUtils.isNotEmpty(labelCode) ? " AND t2.label = ? " : "") +
|
|
|
(StringUtils.isNotEmpty(labelType) ? " AND t2.label_type = ? " : "") +
|
|
|
(teamCode > 0 ? (" AND admin_team_code = " + teamCode) : "") +
|
|
|
" AND admin_team_code = " + teamCode +
|
|
|
" AND (t1.name like ? or t2.label_name like ?) ";
|
|
|
|
|
|
if (StringUtils.isNotEmpty(labelCode)) {
|
|
@ -1672,9 +1657,7 @@ public class SignPatientLabelInfoService extends BaseService {
|
|
|
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("2".equals(String.valueOf(sign.get("type"))) && "1".equals(String.valueOf(sign.get("expenses_status")))){
|
|
|
// json.put("qyrq", sign.get("expenses_time") != null ? DateUtil.dateToStr((Date) sign.get("expenses_time"), DateUtil.YYYY_MM_DD) : "");
|
|
|
// }
|
|
|
|
|
|
if (StringUtils.isEmpty(String.valueOf(json.get("expensesStatus"))) || String.valueOf(json.get("expensesStatus")).equals("0")) {
|
|
|
String epTime = "";
|
|
|
try {
|
|
@ -1709,82 +1692,122 @@ public class SignPatientLabelInfoService extends BaseService {
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONArray searchTeamsPatients(String filter, long teamCode, int page, int pagesize) throws Exception {
|
|
|
JSONArray reArray = new JSONArray();
|
|
|
Map<String, JSONArray> map = new HashMap<>();
|
|
|
Map<Long, AdminTeam> teamMap = new HashMap<>();
|
|
|
List<AdminTeam> teams = null;
|
|
|
int start = page * pagesize;
|
|
|
int size = pagesize;
|
|
|
teams = new ArrayList<>();
|
|
|
AdminTeam teamTemp = adminTeamService.getTeam(teamCode);
|
|
|
if (teamTemp == null) {
|
|
|
throw new Exception("adminTeam is not exist");
|
|
|
}
|
|
|
teams.add(teamTemp);
|
|
|
Map<String, JSONObject> result = new HashMap<>();
|
|
|
List<Map<String, Object>> signList = new ArrayList<>();
|
|
|
page = page * pagesize;
|
|
|
Object[] args = new Object[]{teamCode, "%" + filter + "%"};
|
|
|
|
|
|
String sql = "select distinct t.* from (" +
|
|
|
" select " +
|
|
|
" f.patient " +
|
|
|
" ,f.name " +
|
|
|
" ,f.openid " +
|
|
|
" ,f.admin_team_code " +
|
|
|
" ,p.sex " +
|
|
|
" ,p.idcard " +
|
|
|
" ,p.photo " +
|
|
|
" from " +
|
|
|
" wlyy_sign_family f,wlyy_patient p " +
|
|
|
" where " +
|
|
|
" f.patient = p.code and f.admin_team_code = ? and f.status > 0 and f.name like ? ) t "
|
|
|
+ (page < 0 ? "" : "limit " + start + "," + size);
|
|
|
String sqlTemp = "select " +
|
|
|
" DISTINCT t1.* " +
|
|
|
" FROM " +
|
|
|
" wlyy_sign_family t1 " +
|
|
|
" WHERE " +
|
|
|
" t1.status > 0 " +
|
|
|
" AND t1.admin_team_code = ? " +
|
|
|
" AND t1.name like ? ";
|
|
|
|
|
|
if (teams != null) {
|
|
|
for (AdminTeam team : teams) {
|
|
|
teamMap.put(team.getId(), team);
|
|
|
List<Map<String, Object>> result = jdbcTemplate.queryForList(sql, new Object[]{team.getId(),
|
|
|
"%" + filter + "%"});
|
|
|
String sql = sqlTemp + " limit " + page + "," + pagesize;
|
|
|
signList = jdbcTemplate.queryForList(sql, args);
|
|
|
|
|
|
if (result != null && result.size() > 0) {
|
|
|
for (Map<String, Object> p : result) {
|
|
|
JSONObject pJson = new JSONObject();
|
|
|
if (signList != null && signList.size() > 0) {
|
|
|
for (Map<String, Object> sign : signList) {
|
|
|
Patient p = patientDao.findByCode(sign.get("patient") == null ? "" : sign.get("patient").toString());
|
|
|
|
|
|
pJson.put("code", p.get("patient"));
|
|
|
pJson.put("name", p.get("name") != null ? p.get("name") : "");
|
|
|
pJson.put("openid", p.get("openid") != null ? p.get("openid") : "");
|
|
|
pJson.put("adminTeamCode", p.get("admin_team_code") != null ? p.get("admin_team_code") : "");
|
|
|
pJson.put("sex", p.get("sex") != null ? p.get("sex") : "");
|
|
|
pJson.put("age", p.get("idcard") != null ? IdCardUtil.getAgeForIdcard(String.valueOf(p.get("idcard"))) : "");
|
|
|
pJson.put("photo", p.get("photo") != null ? p.get("photo") : "");
|
|
|
if (p == null) {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
List<SignPatientLabelInfo> labels = labelInfoDao.findByPatientAndStatus(String.valueOf(p.get("patient")), 1);
|
|
|
pJson.put("labels", labels == null ? "" : labels);
|
|
|
if (result.containsKey(p.getCode())) {
|
|
|
JSONObject jsonP = result.get(p.getCode());
|
|
|
|
|
|
if (map.containsKey(String.valueOf(p.get("admin_team_code")))) {
|
|
|
JSONArray array = map.get(String.valueOf(p.get("admin_team_code")));
|
|
|
array.put(pJson);
|
|
|
} else {
|
|
|
JSONArray array = new JSONArray();
|
|
|
array.put(pJson);
|
|
|
map.put(String.valueOf(p.get("admin_team_code")), array);
|
|
|
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")) {
|
|
|
String epTime = redisTemplate.opsForValue().get("expenses:remind:" + p.getCode());
|
|
|
|
|
|
if (StringUtils.isEmpty(epTime)) {
|
|
|
jsonP.put("expensesRemindStatus", 0);
|
|
|
} else {
|
|
|
jsonP.put("expensesRemindStatus", new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (map != null && map.size() > 0) {
|
|
|
for (String key : map.keySet()) {
|
|
|
AdminTeam team = teamMap.get(Long.valueOf(key));
|
|
|
JSONObject tJson = new JSONObject();
|
|
|
List<SignPatientLabelInfo> labels = labelInfoDao.findByPatientAndStatus(sign.get("patient").toString(), 1);
|
|
|
|
|
|
tJson.put("teamCode", team.getId());
|
|
|
tJson.put("teamName", team.getName());
|
|
|
tJson.put("patients", map.get(key));
|
|
|
JSONObject json = new JSONObject();
|
|
|
|
|
|
reArray.put(tJson);
|
|
|
// 设置患者标识
|
|
|
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", 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("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")) {
|
|
|
String epTime = "";
|
|
|
try {
|
|
|
epTime = redisTemplate.opsForValue().get("expenses:remind:" + p.getCode());
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
if (StringUtils.isEmpty(epTime)) {
|
|
|
json.put("expensesRemindStatus", 0);
|
|
|
} else {
|
|
|
json.put("expensesRemindStatus", new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
// 缴费情况
|
|
|
json.put("expensesStatus", "1");
|
|
|
}
|
|
|
// 患者标签
|
|
|
json.put("labels", labels == null ? "" : labels);
|
|
|
|
|
|
result.put(p.getCode(), json);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return reArray;
|
|
|
return result.size() > 0 ? new JSONArray(result.values()) : new JSONArray();
|
|
|
}
|
|
|
|
|
|
|
|
@ -1805,10 +1828,71 @@ public class SignPatientLabelInfoService extends BaseService {
|
|
|
String sql = "";
|
|
|
Object[] args = null;
|
|
|
|
|
|
String tempsql = " select * from wlyy_sign_family where " +
|
|
|
" status > 0 and admin_team_code = ? ";
|
|
|
args = new Object[]{teamCode};
|
|
|
sql = "select t.* from (" + tempsql + ") t limit " + start + "," + pagesize;
|
|
|
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 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");
|
|
|
}
|
|
|
|
|
|
args = new Object[]{teamCode};
|
|
|
} else {
|
|
|
if (labelCode.equals("0")) {
|
|
|
sql = "SELECT " +
|
|
|
" t1.* " +
|
|
|
" FROM " +
|
|
|
" wlyy_sign_family t1 " +
|
|
|
" left join " +
|
|
|
" (select repl.patient,repl.label,repl.label_type,repl.label_name from wlyy_sign_family repf left join wlyy_sign_patient_label_info repl on repf.patient = repl.patient where repf.admin_team_code = ? and repf.status > 0 and repl.label_type = ? and repl.status = 1) t2 " +
|
|
|
" on t1.patient = t2.patient " +
|
|
|
" WHERE " +
|
|
|
" t2.patient is null " +
|
|
|
" AND t1.status > 0 " +
|
|
|
" AND t1.admin_team_code = ? ";
|
|
|
|
|
|
args = new Object[]{teamCode, labelType, 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.status > 0 " +
|
|
|
" AND t1.admin_team_code = ? ";
|
|
|
|
|
|
args = new Object[]{labelCode, labelType, teamCode};
|
|
|
}
|
|
|
}
|
|
|
|
|
|
sql = sql + " limit " + start + "," + pagesize;
|
|
|
signList = jdbcTemplate.queryForList(sql, args);
|
|
|
|
|
|
if (signList != null && signList.size() > 0) {
|
|
@ -1843,24 +1927,11 @@ public class SignPatientLabelInfoService extends BaseService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
if (StringUtils.isNotEmpty(labelCode)) {
|
|
|
SignPatientLabelInfo labelInfoEx = labelInfoDao.findByPatientAndLabelAndLabelTypeAndStatus(p.getCode(), labelCode, labelType, 1);
|
|
|
|
|
|
if (labelInfoEx == null) {
|
|
|
continue;
|
|
|
}
|
|
|
} else if (StringUtils.isNotEmpty(labelType)) {
|
|
|
List<SignPatientLabelInfo> labelExs = labelInfoDao.findByPatientAndLabelTypeAndStatus(p.getCode(), labelType, 1);
|
|
|
|
|
|
if (labelExs == null && labelExs.size() <= 0) {
|
|
|
continue;
|
|
|
}
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
List<SignPatientLabelInfo> labels = labelInfoDao.findByPatientAndStatus(sign.get("patient").toString(), 1);
|
|
|
//List<SignPatientLabelInfo> labels = labelInfoDao.findByPatientAndStatus(sign.get("patient").toString(), 1);
|
|
|
JSONObject json = new JSONObject();
|
|
|
|
|
|
// 设置患者标识
|
|
@ -1896,9 +1967,7 @@ public class SignPatientLabelInfoService extends BaseService {
|
|
|
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("2".equals(String.valueOf(sign.get("type"))) && "1".equals(String.valueOf(sign.get("expenses_status")))){
|
|
|
// json.put("qyrq", sign.get("expenses_time") != null ? DateUtil.dateToStr((Date) sign.get("expenses_time"), DateUtil.YYYY_MM_DD) : "");
|
|
|
// }
|
|
|
|
|
|
if (StringUtils.isEmpty(String.valueOf(json.get("expensesStatus"))) || String.valueOf(json.get("expensesStatus")).equals("0")) {
|
|
|
String epTime = "";
|
|
|
try {
|
|
@ -1917,7 +1986,7 @@ public class SignPatientLabelInfoService extends BaseService {
|
|
|
json.put("expensesStatus", "1");
|
|
|
}
|
|
|
// 患者标签
|
|
|
json.put("labels", labels == null ? "" : labels);
|
|
|
//json.put("labels", labels == null ? "" : labels);
|
|
|
|
|
|
result.put(p.getCode(), json);
|
|
|
}
|