|
@ -508,6 +508,10 @@ public class SignPatientLabelInfoService extends BaseService {
|
|
return result.size() > 0 ? new JSONArray(result.values()) : new JSONArray();
|
|
return result.size() > 0 ? new JSONArray(result.values()) : new JSONArray();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* 查询某个标签类型的所有标签居民数统计
|
|
* 查询某个标签类型的所有标签居民数统计
|
|
*
|
|
*
|
|
@ -649,6 +653,158 @@ public class SignPatientLabelInfoService extends BaseService {
|
|
|
|
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public int getPatientAmountByTeam(Long teamCode) throws Exception{
|
|
|
|
List<SignFamily> signFamilies = signFamilyDao.findByAdminTeamIdAndStatus(teamCode, 1);
|
|
|
|
return signFamilies.size();
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* 查询某个标签类型的所有标签居民数统计,或者所有类型
|
|
|
|
*
|
|
|
|
* @param labelType 标签类型
|
|
|
|
* @param teamCode 标签类型为4时,不能为空
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public JSONArray getPatientAmountByTeamGroupLable(Long teamCode,String labelType) throws Exception {
|
|
|
|
Boolean isAll = false;
|
|
|
|
List<SignPatientLabel> labels = new ArrayList<>();
|
|
|
|
if("0".equals(labelType)){
|
|
|
|
labels = labelService.getTeamAllLabels(teamCode);
|
|
|
|
isAll = true;
|
|
|
|
}else{
|
|
|
|
labels = labelService.getLabelsByTypeAndTeam(labelType,teamCode);
|
|
|
|
}
|
|
|
|
JSONArray result = new JSONArray();
|
|
|
|
|
|
|
|
SignPatientLabel labelNo = new SignPatientLabel();
|
|
|
|
|
|
|
|
if (!labelType.equals("5")) {
|
|
|
|
labelNo.setLabelCode("0");
|
|
|
|
labelNo.setLabelName(labelType.equals("1") ? "未分组" : "未标注");
|
|
|
|
labelNo.setStatus(1);
|
|
|
|
labelNo.setIsSystem(1);
|
|
|
|
labelNo.setLabelType(labelType);
|
|
|
|
labelNo.setSort(999999999);
|
|
|
|
|
|
|
|
labels.add(labelNo);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (labels != null) {
|
|
|
|
for (SignPatientLabel label : labels) {
|
|
|
|
if(isAll){//查询所有
|
|
|
|
labelType = label.getLabelType();
|
|
|
|
}
|
|
|
|
JSONObject json = new JSONObject();
|
|
|
|
|
|
|
|
json.put("labelCode", label.getLabelCode());
|
|
|
|
json.put("labelName", label.getLabelName());
|
|
|
|
json.put("isSystem", label.getIsSystem());
|
|
|
|
|
|
|
|
int amount = 0;
|
|
|
|
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 status > 0 " +
|
|
|
|
(teamCode > 0 ? " and admin_team_code = ? " : "");
|
|
|
|
|
|
|
|
if (label.getLabelCode().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 (label.getLabelCode().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 (label.getLabelCode().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");
|
|
|
|
}
|
|
|
|
if (teamCode > 0) {
|
|
|
|
args = new Object[]{teamCode,teamCode};
|
|
|
|
} else {
|
|
|
|
args = new Object[]{};
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (label.getLabelCode().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.status > 0 and repl.label_type = ?) t2 " +
|
|
|
|
" on t1.patient = t2.patient " +
|
|
|
|
" WHERE" +
|
|
|
|
" t2.patient is null " +
|
|
|
|
" AND t1.status > 0 " +
|
|
|
|
(teamCode > 0 ? " AND t1.admin_team_code = ? " : "");
|
|
|
|
|
|
|
|
if (teamCode > 0) {
|
|
|
|
args = new Object[]{labelType, teamCode, labelType,teamCode};
|
|
|
|
} else {
|
|
|
|
args = new Object[]{labelType,labelType};
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
sql = " SELECT " +
|
|
|
|
" t1.* " +
|
|
|
|
" FROM" +
|
|
|
|
" wlyy_sign_family t1, " +
|
|
|
|
" wlyy_sign_patient_label_info t2 " +
|
|
|
|
" WHERE" +
|
|
|
|
" t1.patient = t2.patient " +
|
|
|
|
" AND t2.label = ? " +
|
|
|
|
" AND t2.label_type = ? " +
|
|
|
|
" AND t2.status = 1 " +
|
|
|
|
" AND t1.status > 0 " +
|
|
|
|
(teamCode > 0 ? " 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};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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";
|
|
|
|
|
|
|
|
List<Map<String, Object>> count = jdbcTemplate.queryForList(sql, args);
|
|
|
|
|
|
|
|
if (count != null && count.size() > 0 && count.get(0).containsKey("count")) {
|
|
|
|
amount = Integer.valueOf(String.valueOf(count.get(0).get("count")));
|
|
|
|
}
|
|
|
|
|
|
|
|
json.put("amount", amount);
|
|
|
|
|
|
|
|
if (label.getLabelCode().equals("0") && labelType.equals("1") && amount < 1) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
result.put(json);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* 设置患者标签
|
|
* 设置患者标签
|
|
@ -834,9 +990,9 @@ public class SignPatientLabelInfoService extends BaseService {
|
|
* @param labelType 标签类型
|
|
* @param labelType 标签类型
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
public JSONArray getPatientLabelByLabelTypeAndTeamCode(String patient, String labelType,Long teamCode) {
|
|
|
|
|
|
public JSONArray getPatientLabelByLabelTypeAndTeamCode(String patient, String labelType, Long teamCode, String doctor) {
|
|
List<SignPatientLabelInfo> labels = new ArrayList<>();
|
|
List<SignPatientLabelInfo> labels = new ArrayList<>();
|
|
JSONArray result = new JSONArray();
|
|
|
|
|
|
JSONArray result = new JSONArray();
|
|
|
|
|
|
if (StringUtils.isEmpty(labelType)) {
|
|
if (StringUtils.isEmpty(labelType)) {
|
|
labels = labelInfoDao.findByPatientAndStatus(patient, 1);
|
|
labels = labelInfoDao.findByPatientAndStatus(patient, 1);
|
|
@ -844,7 +1000,21 @@ public class SignPatientLabelInfoService extends BaseService {
|
|
labels = labelInfoDao.findByPatientAndLabelTypeAndStatus(patient, labelType, 1);
|
|
labels = labelInfoDao.findByPatientAndLabelTypeAndStatus(patient, labelType, 1);
|
|
}
|
|
}
|
|
|
|
|
|
if(labels != null && labels.size() > 0) {
|
|
|
|
|
|
SignFamily ssSign = signFamilyDao.findSignByPatient(patient, 1);
|
|
|
|
SignFamily jtSign = signFamilyDao.findSignByPatient(patient, 2);
|
|
|
|
Long ssTeam = 0L;
|
|
|
|
Long jtTeam = 0L;
|
|
|
|
|
|
|
|
if (ssSign != null && (doctor.equals(ssSign.getDoctor()) ||
|
|
|
|
doctor.equals(ssSign.getDoctorHealth()))) {
|
|
|
|
ssTeam = ssSign.getAdminTeamId();
|
|
|
|
}
|
|
|
|
if (jtSign != null && (doctor.equals(jtSign.getDoctor()) ||
|
|
|
|
doctor.equals(jtSign.getDoctorHealth()))) {
|
|
|
|
jtTeam = jtSign.getAdminTeamId();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (labels != null && labels.size() > 0) {
|
|
for (SignPatientLabelInfo label : labels) {
|
|
for (SignPatientLabelInfo label : labels) {
|
|
JSONObject json = new JSONObject(label);
|
|
JSONObject json = new JSONObject(label);
|
|
|
|
|
|
@ -1146,6 +1316,10 @@ public class SignPatientLabelInfoService extends BaseService {
|
|
return reArray;
|
|
return reArray;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* 添加居民到某个标签
|
|
* 添加居民到某个标签
|
|
*
|
|
*
|
|
@ -1289,4 +1463,391 @@ public class SignPatientLabelInfoService extends BaseService {
|
|
return 1;
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/***BEGIN EXIT DOCTOR***/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 根据患者姓名或标签名称查询
|
|
|
|
*
|
|
|
|
* @param filter
|
|
|
|
* @return
|
|
|
|
* @throws Exception
|
|
|
|
*/
|
|
|
|
public JSONArray searchPatientByNameOrLabel(String filter,
|
|
|
|
String labelCode, String labelType, long teamCode,
|
|
|
|
String exLabelCode,
|
|
|
|
String exLabelType,
|
|
|
|
int page, int pagesize) throws Exception {
|
|
|
|
Map<String, JSONObject> result = new HashMap<>();
|
|
|
|
List<Map<String, Object>> signList = new ArrayList<>();
|
|
|
|
page = page * pagesize;
|
|
|
|
Object[] args = null;
|
|
|
|
|
|
|
|
String sqlTemp = "select " +
|
|
|
|
" t1.* " +
|
|
|
|
" FROM " +
|
|
|
|
" wlyy_sign_family t1 " +
|
|
|
|
(StringUtils.isNotEmpty(labelCode) || StringUtils.isNotEmpty(labelType) ?
|
|
|
|
" join " : " left join ") +
|
|
|
|
" wlyy_sign_patient_label_info t2 " +
|
|
|
|
" ON t1.patient = t2.patient " +
|
|
|
|
" WHERE " +
|
|
|
|
" t1.status > 0 " +
|
|
|
|
" 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 (t1.name like ? or t2.label_name like ?) ";
|
|
|
|
|
|
|
|
if (StringUtils.isNotEmpty(labelCode)) {
|
|
|
|
args = new Object[]{labelCode, labelType, "%" + filter + "%", "%" + filter + "%"};
|
|
|
|
} else if (StringUtils.isEmpty(labelCode) && StringUtils.isNotEmpty(labelType)) {
|
|
|
|
args = new Object[]{labelType, "%" + filter + "%", "%" + filter + "%"};
|
|
|
|
} else {
|
|
|
|
args = new Object[]{ "%" + filter + "%", "%" + filter + "%"};
|
|
|
|
}
|
|
|
|
|
|
|
|
String sql = "select DISTINCT t.* from (" + sqlTemp+ ") t 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());
|
|
|
|
|
|
|
|
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")) {
|
|
|
|
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 (StringUtils.isNotEmpty(exLabelCode)) {
|
|
|
|
SignPatientLabelInfo labelInfoEx = labelInfoDao.findByPatientAndLabelAndLabelTypeAndStatus(p.getCode(), exLabelCode, exLabelType, 1);
|
|
|
|
|
|
|
|
if (labelInfoEx != null) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
} else if (StringUtils.isNotEmpty(exLabelType)) {
|
|
|
|
List<SignPatientLabelInfo> labelExs = labelInfoDao.findByPatientAndLabelTypeAndStatus(p.getCode(), exLabelType, 1);
|
|
|
|
|
|
|
|
if (labelExs != null && labelExs.size() > 0) {
|
|
|
|
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", 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("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 {
|
|
|
|
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 result.size() > 0 ? new JSONArray(result.values()) : new JSONArray();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 查询所有团队下患者
|
|
|
|
*
|
|
|
|
* @param filter 搜索关键字
|
|
|
|
* @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);
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
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 + "%"});
|
|
|
|
|
|
|
|
if (result != null && result.size() > 0) {
|
|
|
|
for (Map<String, Object> p : result) {
|
|
|
|
JSONObject pJson = new JSONObject();
|
|
|
|
|
|
|
|
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") : "");
|
|
|
|
|
|
|
|
List<SignPatientLabelInfo> labels = labelInfoDao.findByPatientAndStatus(String.valueOf(p.get("patient")), 1);
|
|
|
|
pJson.put("labels", labels == null ? "" : labels);
|
|
|
|
|
|
|
|
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 (map != null && map.size() > 0) {
|
|
|
|
for (String key : map.keySet()) {
|
|
|
|
AdminTeam team = teamMap.get(Long.valueOf(key));
|
|
|
|
JSONObject tJson = new JSONObject();
|
|
|
|
|
|
|
|
tJson.put("teamCode", team.getId());
|
|
|
|
tJson.put("teamName", team.getName());
|
|
|
|
tJson.put("patients", map.get(key));
|
|
|
|
|
|
|
|
reArray.put(tJson);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return reArray;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取团队下的患者(非当前医生而是整个团队)
|
|
|
|
*
|
|
|
|
* @param teamCode
|
|
|
|
* @param page
|
|
|
|
* @param pagesize
|
|
|
|
* @return
|
|
|
|
* @throws Exception
|
|
|
|
*/
|
|
|
|
public JSONArray getPatientByTeamCodeExitDoctor(long teamCode, String labelCode, String labelType, int page, int pagesize) throws Exception {
|
|
|
|
|
|
|
|
Map<String, JSONObject> result = new HashMap<>();
|
|
|
|
List<Map<String, Object>> signList = new ArrayList<>();
|
|
|
|
int start = page * pagesize;
|
|
|
|
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;
|
|
|
|
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")) {
|
|
|
|
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 (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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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", 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("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 {
|
|
|
|
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 result.size() > 0 ? new JSONArray(result.values()) : new JSONArray();
|
|
|
|
}
|
|
|
|
|
|
}
|
|
}
|