|
@ -455,16 +455,18 @@ public class JMJkEduArticleService extends BaseService {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
//保存到ES中
|
|
|
|
elastricSearchSave.save(healthEduArticleESList, esIndex, esType);
|
|
|
|
|
|
|
|
HealthEduArticleES e = new HealthEduArticleES();
|
|
|
|
BeanUtils.copyProperties(healthEduArticleESList.get(0),e);
|
|
|
|
e.setUserType(2);
|
|
|
|
e.setPatientCode(null);
|
|
|
|
e.setPatientName(null);
|
|
|
|
elastricSearchSave.save(e, esIndex, esType);
|
|
|
|
thirdJkEduArticleService.saveBehavior(articleId,doctor.getCode(),7,patientSet.size());
|
|
|
|
|
|
if(healthEduArticleESList.size()>0){
|
|
|
|
//保存到ES中
|
|
|
|
elastricSearchSave.save(healthEduArticleESList, esIndex, esType);
|
|
|
|
|
|
|
|
HealthEduArticleES e = new HealthEduArticleES();
|
|
|
|
BeanUtils.copyProperties(healthEduArticleESList.get(0),e);
|
|
|
|
e.setUserType(2);
|
|
|
|
e.setPatientCode(null);
|
|
|
|
e.setPatientName(null);
|
|
|
|
elastricSearchSave.save(e, esIndex, esType);
|
|
|
|
thirdJkEduArticleService.saveBehavior(articleId,doctor.getCode(),7,patientSet.size());
|
|
|
|
}
|
|
return healthEduArticleESList;
|
|
return healthEduArticleESList;
|
|
}
|
|
}
|
|
public JSONObject pushArticleConfirm(String articleId, String labelUnit, String labelSex, String labelServe, String labelDisease, String labelHealth,String userCode,String currentUserRole, String currentUserRoleLevel) throws Exception {
|
|
public JSONObject pushArticleConfirm(String articleId, String labelUnit, String labelSex, String labelServe, String labelDisease, String labelHealth,String userCode,String currentUserRole, String currentUserRoleLevel) throws Exception {
|
|
@ -689,10 +691,10 @@ public class JMJkEduArticleService extends BaseService {
|
|
}
|
|
}
|
|
|
|
|
|
private void getPatientByGroup(String userCode,String labelCode, String labelType, Long teamCode, Set<String> patientSet, int page, int pagesize) throws Exception {
|
|
private void getPatientByGroup(String userCode,String labelCode, String labelType, Long teamCode, Set<String> patientSet, int page, int pagesize) throws Exception {
|
|
org.json.JSONArray result = signPatientLabelInfoService.getPatientByLabel(userCode, labelCode, labelType, teamCode, page, pagesize, false, "",true,null,null,null);
|
|
|
|
|
|
org.json.JSONArray result = getPatientByLabel(userCode, labelCode, labelType, teamCode, page, pagesize, false, "",true,null,null,null);
|
|
for (Object o : result) {
|
|
for (Object o : result) {
|
|
org.json.JSONObject json = (org.json.JSONObject) o;
|
|
org.json.JSONObject json = (org.json.JSONObject) o;
|
|
String patient = (String) json.get("code");
|
|
|
|
|
|
String patient = (String) json.get("patient");
|
|
patientSet.add(patient);
|
|
patientSet.add(patient);
|
|
}
|
|
}
|
|
if (result.length() == 100) {
|
|
if (result.length() == 100) {
|
|
@ -700,6 +702,173 @@ public class JMJkEduArticleService extends BaseService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public org.json.JSONArray getPatientByLabel(String doctor, String labelCode, String labelType,
|
|
|
|
Long teamCode, int page, int pagesize, boolean isSlowDisease,
|
|
|
|
String diseaseCondition, boolean isFollowWeChat, String trackFlag, String sDate, String eDate) throws Exception {
|
|
|
|
|
|
|
|
Doctor doc = doctorDao.findByCode(doctor);
|
|
|
|
|
|
|
|
if (doc == null) {
|
|
|
|
throw new Exception("doctor info can not find");
|
|
|
|
}
|
|
|
|
|
|
|
|
Map<String, org.json.JSONObject> result = new TreeMap<>();
|
|
|
|
List<Map<String, Object>> signList = new ArrayList<>();
|
|
|
|
|
|
|
|
Map<String,Object> patientDeviceTypeMap = new HashMap<>();//用于存储患者设备绑定情况
|
|
|
|
int start = page * pagesize;
|
|
|
|
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 DISTINCT * " +
|
|
|
|
" from " +
|
|
|
|
" wlyy_sign_family t1" +
|
|
|
|
" LEFT JOIN wlyy_patient p on p.code = t1.patient "+
|
|
|
|
" LEFT JOIN wlyy_sign_patient_label_info t2 on t2.patient = t1.patient and t2.label_type = 3 and t2.status=1 "+
|
|
|
|
" where (t1.doctor = ? or t1.doctor_health = ?) and t1.status > 0 and t1.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 t1.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 t1.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 t1.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(isFollowWeChat){
|
|
|
|
sql += " AND p.openid IS NOT NULL AND p.openid <>'' ";
|
|
|
|
}
|
|
|
|
sql += " order by p.standard_status DESC ,p.disease_condition DESC,t2.label DESC,t1.openid DESC ,convert(t1.name using gbk) ";
|
|
|
|
args = new Object[]{doctor, doctor, teamCode};
|
|
|
|
}else if("1".equals(labelType)){
|
|
|
|
sql =" SELECT " +
|
|
|
|
" DISTINCT t1.* " +
|
|
|
|
" FROM " +
|
|
|
|
" wlyy_sign_family t1 " +
|
|
|
|
" LEFT JOIN wlyy_patient p on p. CODE = t1.patient " +
|
|
|
|
" LEFT JOIN wlyy_sign_patient_label_info t2 on t2.patient = t1.patient and t2.label_type = 3 and t2.status=1 "+
|
|
|
|
" RIGHT JOIN wlyy_sign_family_server s on s.sign_code = t1.code and s.server_type = '"+labelCode+"' "+
|
|
|
|
" WHERE ( " +
|
|
|
|
" t1.doctor = ? " +
|
|
|
|
" OR t1.doctor_health = ? " +
|
|
|
|
" ) " +
|
|
|
|
" AND t1. STATUS > 0 AND t1.admin_team_code = ?";
|
|
|
|
if(org.apache.commons.lang3.StringUtils.isNotBlank(diseaseCondition)){
|
|
|
|
sql = sql + " AND p.disease_condition ="+diseaseCondition;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(isFollowWeChat){
|
|
|
|
sql += " AND p.openid IS NOT NULL AND p.openid <>'' ";
|
|
|
|
}
|
|
|
|
|
|
|
|
sql = sql +" order by p.standard_status DESC ,p.disease_condition DESC,t2.label DESC,t1.openid DESC ,convert(t1.name using gbk) ";
|
|
|
|
args = new Object[]{doctor, doctor, teamCode};
|
|
|
|
}else if("3".equals(labelType) && isSlowDisease){
|
|
|
|
//慢病管理
|
|
|
|
sql = "SELECT " +
|
|
|
|
" DISTINCT t1.* " +
|
|
|
|
" FROM wlyy_sign_family t1 " +
|
|
|
|
" LEFT JOIN wlyy_patient p on p.code = t1.patient "+
|
|
|
|
" RIGHT JOIN wlyy_sign_patient_label_info t2 on t2.patient = t1.patient ";
|
|
|
|
if(org.apache.commons.lang3.StringUtils.isNotBlank(trackFlag)&&"1".equals(trackFlag)){
|
|
|
|
sql = sql +" JOIN wlyy_track_patient tp ON tp.patient_code = p.code";
|
|
|
|
}
|
|
|
|
sql = sql + " WHERE t2.label = ?";
|
|
|
|
|
|
|
|
if(org.apache.commons.lang3.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 = ? ";
|
|
|
|
|
|
|
|
if(isFollowWeChat){
|
|
|
|
sql += " AND p.openid IS NOT NULL AND p.openid <>'' ";
|
|
|
|
}
|
|
|
|
if(org.apache.commons.lang3.StringUtils.isNotBlank(trackFlag)&&"1".equals(trackFlag)){
|
|
|
|
sql = sql + " AND tp.del='1' AND tp.doctor_code ='"+doctor+"' AND tp.team_code ="+teamCode;
|
|
|
|
if(org.apache.commons.lang3.StringUtils.isNotBlank(sDate)&& org.apache.commons.lang3.StringUtils.isNotBlank(eDate)){
|
|
|
|
sql += " AND tp.create_time >='"+sDate+" 00:00:00' AND tp.create_time <='"+eDate+" 23:59:59' ";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sql = sql + " order by p.standard_status DESC ,p.disease_condition DESC,t2.label DESC,t1.openid DESC ,convert(t1.name using gbk) ";
|
|
|
|
if(org.apache.commons.lang3.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 " +
|
|
|
|
" 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 " +
|
|
|
|
" left join wlyy_patient p on p.code = t1.patient "+
|
|
|
|
" WHERE " +
|
|
|
|
" t2.patient is null " +
|
|
|
|
" AND (t1.doctor = ? or t1.doctor_health = ?) " +
|
|
|
|
" AND t1.status > 0 " +
|
|
|
|
" AND t1.admin_team_code = ? ";
|
|
|
|
if(isFollowWeChat){
|
|
|
|
sql += " AND p.openid IS NOT NULL AND p.openid <>'' ";
|
|
|
|
}
|
|
|
|
sql += "order by p.standard_status DESC ,p.disease_condition DESC,t2.label DESC,t1.openid DESC ,convert(t1.name using gbk)";
|
|
|
|
|
|
|
|
args = new Object[]{labelType, doctor, doctor, teamCode};
|
|
|
|
}else {
|
|
|
|
sql = "SELECT " +
|
|
|
|
" t1.* " +
|
|
|
|
" FROM " +
|
|
|
|
" wlyy_sign_family t1 " +
|
|
|
|
" left join wlyy_sign_patient_label_info t2 on t1.patient = t2.patient " +
|
|
|
|
" left join wlyy_patient p on p.`code` = t1.patient "+
|
|
|
|
" 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 = ? "+
|
|
|
|
" AND p.`status` =1 ";
|
|
|
|
if(isFollowWeChat){
|
|
|
|
sql += " AND p.openid IS NOT NULL AND p.openid <>'' ";
|
|
|
|
}
|
|
|
|
sql += " order by p.standard_status DESC ,p.disease_condition DESC,t2.label DESC,p.openid DESC ,convert(t1.name using gbk)";
|
|
|
|
|
|
|
|
args = new Object[]{labelCode, labelType, doctor, doctor, teamCode};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sql += " limit " + start + "," + pagesize;
|
|
|
|
signList = jdbcTemplate.queryForList(sql, args);
|
|
|
|
return new org.json.JSONArray(signList);
|
|
|
|
}
|
|
|
|
|
|
public JSONObject pushArticleConfirm(String userCode,String[] groups,String group,String labelType,long teamCode,String[] patients,String articleId) throws Exception{
|
|
public JSONObject pushArticleConfirm(String userCode,String[] groups,String group,String labelType,long teamCode,String[] patients,String articleId) throws Exception{
|
|
JSONObject article = thirdJkEduArticleService.getArticalById(articleId,"","");
|
|
JSONObject article = thirdJkEduArticleService.getArticalById(articleId,"","");
|
|
Set<String> patientSet = new HashSet<>();
|
|
Set<String> patientSet = new HashSet<>();
|