|
@ -1,6 +1,7 @@
|
|
|
package com.yihu.wlyy.service.app.label;
|
|
|
|
|
|
import com.yihu.wlyy.entity.doctor.profile.Doctor;
|
|
|
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
|
|
|
import com.yihu.wlyy.entity.doctor.team.sign.DoctorPatientGroupInfo;
|
|
|
import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabel;
|
|
|
import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabelInfo;
|
|
@ -14,6 +15,7 @@ import com.yihu.wlyy.repository.patient.PatientDao;
|
|
|
import com.yihu.wlyy.repository.patient.PatientDiseaseDao;
|
|
|
import com.yihu.wlyy.repository.patient.SignFamilyDao;
|
|
|
import com.yihu.wlyy.service.BaseService;
|
|
|
import com.yihu.wlyy.service.app.team.AdminTeamService;
|
|
|
import com.yihu.wlyy.util.DateUtil;
|
|
|
import com.yihu.wlyy.util.IdCardUtil;
|
|
|
import org.apache.commons.beanutils.converters.CalendarConverter;
|
|
@ -57,6 +59,8 @@ public class SignPatientLabelInfoService extends BaseService {
|
|
|
SignFamilyDao signFamilyDao;
|
|
|
@Autowired
|
|
|
StringRedisTemplate redisTemplate;
|
|
|
@Autowired
|
|
|
AdminTeamService adminTeamService;
|
|
|
|
|
|
/**
|
|
|
* 查询单个居民信息
|
|
@ -243,7 +247,7 @@ public class SignPatientLabelInfoService extends BaseService {
|
|
|
}
|
|
|
|
|
|
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");
|
|
|
String sqlDocHealth = sql.replaceAll("repdoctor", "doctor_health").replaceAll("t1", "t3").replaceAll("t2", "t4").replaceAll("repf", "repf1").replaceAll("repl", "repl1");
|
|
|
|
|
|
sql = "select t.* from (" + sqlDoc + " union all " + sqlDocHealth + ") t limit " + start + "," + pagesize;
|
|
|
|
|
@ -612,7 +616,7 @@ public class SignPatientLabelInfoService extends BaseService {
|
|
|
}
|
|
|
|
|
|
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");
|
|
|
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";
|
|
|
|
|
@ -978,6 +982,101 @@ public class SignPatientLabelInfoService extends BaseService {
|
|
|
return result.size() > 0 ? new JSONArray(result.values()) : new JSONArray();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询所有团队下患者
|
|
|
*
|
|
|
* @param filter 搜索关键字
|
|
|
* @param doctor 医生
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONArray searchTeamsPatients(String filter, String doctor, 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;
|
|
|
|
|
|
if (teamCode > 0) {
|
|
|
teams = new ArrayList<>();
|
|
|
AdminTeam team = adminTeamService.getTeam(teamCode);
|
|
|
if (team == null) {
|
|
|
throw new Exception("adminTeam is not exist");
|
|
|
}
|
|
|
teams.add(team);
|
|
|
} else {
|
|
|
teams = adminTeamService.getDoctorTeams(doctor);
|
|
|
}
|
|
|
|
|
|
String sql = "select distinct t.* from (" +
|
|
|
" select " +
|
|
|
" patient " +
|
|
|
" ,name " +
|
|
|
" ,openid " +
|
|
|
" ,admin_team_code " +
|
|
|
" from " +
|
|
|
" wlyy_sign_family " +
|
|
|
" where " +
|
|
|
" doctor = ? and admin_team_code = ? and status > 0 and name like ? " +
|
|
|
" union all " +
|
|
|
"select " +
|
|
|
" patient " +
|
|
|
" ,name " +
|
|
|
" ,openid " +
|
|
|
" ,admin_team_code " +
|
|
|
" from " +
|
|
|
" wlyy_sign_family " +
|
|
|
" where " +
|
|
|
" doctor_health = ? and admin_team_code = ? and status > 0 and 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[]{doctor, team.getId(),
|
|
|
"%" + filter + "%", doctor, team.getId(), "%" + filter + "%"});
|
|
|
|
|
|
if (result != null && result.size() > 0) {
|
|
|
for (Map<String, Object> p : result) {
|
|
|
JSONObject pJson = new JSONObject();
|
|
|
|
|
|
pJson.put("code", String.valueOf(p.get("patient")));
|
|
|
pJson.put("name", String.valueOf(p.get("name")));
|
|
|
pJson.put("openid", String.valueOf(p.get("openid")));
|
|
|
pJson.put("adminTeamCode", String.valueOf(p.get("admin_team_code")));
|
|
|
|
|
|
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;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 添加居民到某个标签
|
|
|
*
|