|
@ -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;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 添加居民到某个标签
|
|
|
*
|
|
@ -1121,137 +1220,4 @@ public class SignPatientLabelInfoService extends BaseService {
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 疾病转标签
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
public boolean diseaseToLabel() {
|
|
|
List<PatientDisease> diseases = diseaseDao.findByDel("1");
|
|
|
Iterator<Patient> patients = patientDao.findAll().iterator();
|
|
|
Map<String, String> patientNames = new HashMap<>();
|
|
|
|
|
|
while (patients.hasNext()) {
|
|
|
Patient p = patients.next();
|
|
|
patientNames.put(p.getCode(), p.getName());
|
|
|
}
|
|
|
|
|
|
for (PatientDisease disease : diseases) {
|
|
|
SignPatientLabelInfo labelInfo = new SignPatientLabelInfo();
|
|
|
|
|
|
labelInfo.setPatient(disease.getPatient());
|
|
|
labelInfo.setPname(patientNames.get(disease.getPatient()));
|
|
|
labelInfo.setLabel(disease.getDisease());
|
|
|
labelInfo.setLabelName(disease.getDiseaseName());
|
|
|
labelInfo.setLabelType("3");
|
|
|
labelInfo.setStatus(1);
|
|
|
labelInfo.setCzrq(new Date());
|
|
|
|
|
|
labelInfoDao.save(labelInfo);
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 分组转标签
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
public boolean groupToLabel() throws Exception {
|
|
|
Iterator<Patient> patients = patientDao.findAll().iterator();
|
|
|
Map<String, Patient> patientNames = new HashMap<>();
|
|
|
Map<String, SignPatientLabelInfo> normalLabel = new HashMap<>();
|
|
|
Map<String, SignPatientLabelInfo> manbingLabel = new HashMap<>();
|
|
|
Map<String, SignPatientLabelInfo> sixFiveLabel = new HashMap<>();
|
|
|
|
|
|
while (patients.hasNext()) {
|
|
|
Patient p = patients.next();
|
|
|
patientNames.put(p.getCode(), p);
|
|
|
}
|
|
|
|
|
|
List<DoctorPatientGroupInfo> groupInfos = groupInfoDao.findByGroupAndStatus("1", 1);
|
|
|
|
|
|
for (DoctorPatientGroupInfo groupInfo : groupInfos) {
|
|
|
Patient p = patientNames.get(groupInfo.getPatient());
|
|
|
|
|
|
if (p == null) {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
SignPatientLabelInfo labelInfo = new SignPatientLabelInfo();
|
|
|
|
|
|
labelInfo.setPatient(p.getCode());
|
|
|
labelInfo.setPname(p.getName());
|
|
|
labelInfo.setLabel("1");
|
|
|
labelInfo.setLabelName("普通人群");
|
|
|
labelInfo.setLabelType("1");
|
|
|
labelInfo.setStatus(1);
|
|
|
labelInfo.setCzrq(new Date());
|
|
|
|
|
|
normalLabel.put(p.getCode(), labelInfo);
|
|
|
}
|
|
|
|
|
|
List<DoctorPatientGroupInfo> groupInfos1 = groupInfoDao.findByGroupAndStatus("2", 1);
|
|
|
|
|
|
for (DoctorPatientGroupInfo groupInfo : groupInfos1) {
|
|
|
Patient p = patientNames.get(groupInfo.getPatient());
|
|
|
|
|
|
if (p == null) {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
SignPatientLabelInfo labelInfo = new SignPatientLabelInfo();
|
|
|
|
|
|
labelInfo.setPatient(p.getCode());
|
|
|
labelInfo.setPname(p.getName());
|
|
|
labelInfo.setLabel("2");
|
|
|
labelInfo.setLabelName("慢病人群");
|
|
|
labelInfo.setLabelType("1");
|
|
|
labelInfo.setStatus(1);
|
|
|
labelInfo.setCzrq(new Date());
|
|
|
|
|
|
manbingLabel.put(p.getCode(), labelInfo);
|
|
|
}
|
|
|
|
|
|
List<DoctorPatientGroupInfo> groupInfos2 = groupInfoDao.findByGroupAndStatus("3", 1);
|
|
|
|
|
|
for (DoctorPatientGroupInfo groupInfo : groupInfos2) {
|
|
|
Patient p = patientNames.get(groupInfo.getPatient());
|
|
|
|
|
|
if (p == null) {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
SignPatientLabelInfo labelInfo = new SignPatientLabelInfo();
|
|
|
|
|
|
labelInfo.setPatient(p.getCode());
|
|
|
labelInfo.setPname(p.getName());
|
|
|
labelInfo.setLabel("3");
|
|
|
labelInfo.setLabelName("65岁以上人群");
|
|
|
labelInfo.setLabelType("1");
|
|
|
labelInfo.setStatus(1);
|
|
|
labelInfo.setCzrq(new Date());
|
|
|
|
|
|
sixFiveLabel.put(p.getCode(), labelInfo);
|
|
|
}
|
|
|
|
|
|
if (normalLabel.size() > 0) {
|
|
|
for (SignPatientLabelInfo labelInfo : normalLabel.values()) {
|
|
|
labelInfoDao.save(labelInfo);
|
|
|
}
|
|
|
}
|
|
|
if (manbingLabel.size() > 0) {
|
|
|
for (SignPatientLabelInfo labelInfo : manbingLabel.values()) {
|
|
|
labelInfoDao.save(labelInfo);
|
|
|
}
|
|
|
}
|
|
|
if (sixFiveLabel.size() > 0) {
|
|
|
for (SignPatientLabelInfo labelInfo : sixFiveLabel.values()) {
|
|
|
labelInfoDao.save(labelInfo);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
}
|