|
@ -14,6 +14,7 @@ import com.yihu.wlyy.entity.patient.*;
|
|
|
import com.yihu.wlyy.entity.patient.vo.PatientVO;
|
|
|
import com.yihu.wlyy.health.repository.DevicePatientHealthIndexDao;
|
|
|
import com.yihu.wlyy.repository.doctor.*;
|
|
|
import com.yihu.wlyy.repository.patient.PatientAimSportsDao;
|
|
|
import com.yihu.wlyy.repository.patient.PatientDao;
|
|
|
import com.yihu.wlyy.repository.patient.TrackPatientDao;
|
|
|
import com.yihu.wlyy.repository.patient.scheme.PatientSchemeListDao;
|
|
@ -43,6 +44,7 @@ import java.util.*;
|
|
|
* @date 2017/9/13 15:46
|
|
|
*/
|
|
|
@Service
|
|
|
@Transactional
|
|
|
public class DoctorSchemeService extends BaseService{
|
|
|
private static Logger logger = LoggerFactory.getLogger(DoctorSchemeService.class);
|
|
|
|
|
@ -79,6 +81,9 @@ public class DoctorSchemeService extends BaseService{
|
|
|
@Autowired
|
|
|
private TrackPatientDao trackPatientDao;
|
|
|
|
|
|
@Autowired
|
|
|
private PatientAimSportsDao patientAimSportsDao;
|
|
|
|
|
|
@Value("${im.data_base_name}")
|
|
|
private String im_dataBase_name;
|
|
|
|
|
@ -99,7 +104,7 @@ public class DoctorSchemeService extends BaseService{
|
|
|
|
|
|
//1.4.2加入跟踪居民过滤
|
|
|
if(StringUtils.isNotBlank(trackFlag)&&"1".equals(trackFlag)){
|
|
|
sql = sql + " JOIN wlyy_track_patient tp ON tp.patientCode = p.code ";
|
|
|
sql = sql + " JOIN wlyy_track_patient tp ON tp.patient_code = p.code ";
|
|
|
}
|
|
|
|
|
|
if(-1 != deviceType){
|
|
@ -136,7 +141,7 @@ public class DoctorSchemeService extends BaseService{
|
|
|
|
|
|
//1.4.2加入跟踪居民过滤
|
|
|
if(StringUtils.isNotBlank(trackFlag)&&"1".equals(trackFlag)){
|
|
|
sql = sql + " AND pt.doctor_code = '"+doctorcode+"' AND pt.teamCode = "+teamCode;
|
|
|
sql = sql + " AND tp.del='1' AND tp.doctor_code = '"+doctorcode+"' AND tp.team_code = "+teamCode;
|
|
|
}
|
|
|
|
|
|
|
|
@ -392,7 +397,7 @@ public class DoctorSchemeService extends BaseService{
|
|
|
try {
|
|
|
|
|
|
for (String patientcode : patientcodeList) {
|
|
|
patientSchemeListDao.delByPatientCodeAndSchemeCode(patientcode, Integer.parseInt(type), schemecode);
|
|
|
patientSchemeListDao.delByPatientCode(patientcode, Integer.parseInt(type));
|
|
|
PatientSchemeList patientSchemeListObj = new PatientSchemeList();
|
|
|
patientSchemeListObj.setCode(UUID.randomUUID().toString());
|
|
|
patientSchemeListObj.setPatientcode(patientcode);
|
|
@ -564,7 +569,7 @@ public class DoctorSchemeService extends BaseService{
|
|
|
}
|
|
|
|
|
|
//1.4.2 重点关注居民
|
|
|
List<TrackPatient> list = trackPatientDao.findByDoctorCodeAndTeamCode(doctorcode,Integer.parseInt(teamCode));
|
|
|
List<TrackPatient> list = trackPatientDao.findByDoctorCodeAndTeamCodeAndDel(doctorcode,Integer.parseInt(teamCode),"1");
|
|
|
if(list!=null&&list.size()>0){
|
|
|
result.put("trackPatientCount",list.size());
|
|
|
}else{
|
|
@ -737,13 +742,13 @@ public class DoctorSchemeService extends BaseService{
|
|
|
rs.put("highCount",h.get("highCount"));
|
|
|
}
|
|
|
//2.正常
|
|
|
List<Map<String,Object>> std = jdbcTemplate.queryForList(pStdSql);
|
|
|
List<Map<String,Object>> std = jdbcTemplate.queryForList(stdSql);
|
|
|
if(std!=null&&std.size()>0){
|
|
|
Map<String,Object> st = std.get(0);
|
|
|
rs.put("stdCount",st.get("stdCount"));
|
|
|
}
|
|
|
//3.偏低
|
|
|
List<Map<String,Object>> low = jdbcTemplate.queryForList(pLowSql);
|
|
|
List<Map<String,Object>> low = jdbcTemplate.queryForList(lowSql);
|
|
|
if(low!=null&&low.size()>0){
|
|
|
Map<String,Object> lw = low.get(0);
|
|
|
rs.put("lowCount",lw.get("lowCount"));
|
|
@ -757,13 +762,13 @@ public class DoctorSchemeService extends BaseService{
|
|
|
rs.put("highCount",h.get("highCount"));
|
|
|
}
|
|
|
//2.正常
|
|
|
List<Map<String,Object>> std = jdbcTemplate.queryForList(stdSql);
|
|
|
List<Map<String,Object>> std = jdbcTemplate.queryForList(pStdSql);
|
|
|
if(std!=null&&std.size()>0){
|
|
|
Map<String,Object> st = std.get(0);
|
|
|
rs.put("stdCount",st.get("stdCount"));
|
|
|
}
|
|
|
//3.偏低
|
|
|
List<Map<String,Object>> low = jdbcTemplate.queryForList(lowSql);
|
|
|
List<Map<String,Object>> low = jdbcTemplate.queryForList(pLowSql);
|
|
|
if(low!=null&&low.size()>0){
|
|
|
Map<String,Object> lw = low.get(0);
|
|
|
rs.put("lowCount",lw.get("lowCount"));
|
|
@ -792,7 +797,7 @@ public class DoctorSchemeService extends BaseService{
|
|
|
" AND i.value1 > 6.1 " +
|
|
|
" AND i.record_date >='"+startDate+"'" +
|
|
|
" AND i.record_date <='"+endDate+"'" +
|
|
|
" AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")" +
|
|
|
" AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")" +
|
|
|
" ) bf, " +
|
|
|
" ( " +
|
|
|
" SELECT " +
|
|
@ -806,7 +811,7 @@ public class DoctorSchemeService extends BaseService{
|
|
|
" AND i.value1 > 7.8 " +
|
|
|
" AND i.record_date >='"+startDate+"'" +
|
|
|
" AND i.record_date <='"+endDate+"'" +
|
|
|
" AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")" +
|
|
|
" AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")" +
|
|
|
" ) aft";
|
|
|
String stdSql ="SELECT " +
|
|
|
" (bf.befHighCount + aft.aftHighCount) AS stdCount " +
|
|
@ -824,7 +829,7 @@ public class DoctorSchemeService extends BaseService{
|
|
|
" AND i.value1 >= 3.9 " +
|
|
|
" AND i.record_date >='"+startDate+"'" +
|
|
|
" AND i.record_date <='"+endDate+"'" +
|
|
|
" AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")" +
|
|
|
" AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")" +
|
|
|
" ) bf, " +
|
|
|
" ( " +
|
|
|
" SELECT " +
|
|
@ -839,7 +844,7 @@ public class DoctorSchemeService extends BaseService{
|
|
|
" AND i.value1 >= 4.4 " +
|
|
|
" AND i.record_date >='"+startDate+"'" +
|
|
|
" AND i.record_date <='"+endDate+"'" +
|
|
|
" AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")" +
|
|
|
" AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")" +
|
|
|
" ) aft";
|
|
|
String lowSql ="SELECT " +
|
|
|
" (bf.befHighCount + aft.aftHighCount) AS lowCount " +
|
|
@ -856,7 +861,7 @@ public class DoctorSchemeService extends BaseService{
|
|
|
" AND i.value1 <= 3.9 " +
|
|
|
" AND i.record_date >='"+startDate+"'" +
|
|
|
" AND i.record_date <='"+endDate+"'" +
|
|
|
" AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")" +
|
|
|
" AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")" +
|
|
|
" ) bf, " +
|
|
|
" ( " +
|
|
|
" SELECT " +
|
|
@ -870,7 +875,7 @@ public class DoctorSchemeService extends BaseService{
|
|
|
" AND i.value1 <= 4.4 " +
|
|
|
" AND i.record_date >='"+startDate+"'" +
|
|
|
" AND i.record_date <='"+endDate+"'" +
|
|
|
" AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")" +
|
|
|
" AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")" +
|
|
|
" ) aft";
|
|
|
|
|
|
String pHighSql ="SELECT " +
|
|
@ -883,7 +888,7 @@ public class DoctorSchemeService extends BaseService{
|
|
|
" AND i.value1 >= 139 " +
|
|
|
" AND i.record_date >='"+startDate+"'" +
|
|
|
" AND i.record_date <='"+endDate+"'" +
|
|
|
" AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")";
|
|
|
" AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")";
|
|
|
String pStdSql ="SELECT " +
|
|
|
" count(1) AS stdCount " +
|
|
|
" FROM " +
|
|
@ -895,7 +900,7 @@ public class DoctorSchemeService extends BaseService{
|
|
|
" AND i.value1 >= 90 " +
|
|
|
" AND i.record_date >='"+startDate+"'" +
|
|
|
" AND i.record_date <='"+endDate+"'" +
|
|
|
" AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")";
|
|
|
" AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")";
|
|
|
String pLowSql ="SELECT " +
|
|
|
" count(1) AS lowCount " +
|
|
|
" FROM " +
|
|
@ -906,7 +911,7 @@ public class DoctorSchemeService extends BaseService{
|
|
|
" AND i.value1 <= 90 " +
|
|
|
" AND i.record_date >='"+startDate+"'" +
|
|
|
" AND i.record_date <='"+endDate+"'" +
|
|
|
" AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")";
|
|
|
" AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")";
|
|
|
|
|
|
Map<String,Object> rs = new HashedMap();
|
|
|
//0血檀
|
|
@ -918,13 +923,13 @@ public class DoctorSchemeService extends BaseService{
|
|
|
rs.put("highCount",h.get("highCount"));
|
|
|
}
|
|
|
//2.正常
|
|
|
List<Map<String,Object>> std = jdbcTemplate.queryForList(pStdSql);
|
|
|
List<Map<String,Object>> std = jdbcTemplate.queryForList(stdSql);
|
|
|
if(std!=null&&std.size()>0){
|
|
|
Map<String,Object> st = std.get(0);
|
|
|
rs.put("stdCount",st.get("stdCount"));
|
|
|
}
|
|
|
//3.偏低
|
|
|
List<Map<String,Object>> low = jdbcTemplate.queryForList(pLowSql);
|
|
|
List<Map<String,Object>> low = jdbcTemplate.queryForList(lowSql);
|
|
|
if(low!=null&&low.size()>0){
|
|
|
Map<String,Object> lw = low.get(0);
|
|
|
rs.put("lowCount",lw.get("lowCount"));
|
|
@ -938,13 +943,13 @@ public class DoctorSchemeService extends BaseService{
|
|
|
rs.put("highCount",h.get("highCount"));
|
|
|
}
|
|
|
//2.正常
|
|
|
List<Map<String,Object>> std = jdbcTemplate.queryForList(stdSql);
|
|
|
List<Map<String,Object>> std = jdbcTemplate.queryForList(pStdSql);
|
|
|
if(std!=null&&std.size()>0){
|
|
|
Map<String,Object> st = std.get(0);
|
|
|
rs.put("stdCount",st.get("stdCount"));
|
|
|
}
|
|
|
//3.偏低
|
|
|
List<Map<String,Object>> low = jdbcTemplate.queryForList(lowSql);
|
|
|
List<Map<String,Object>> low = jdbcTemplate.queryForList(pLowSql);
|
|
|
if(low!=null&&low.size()>0){
|
|
|
Map<String,Object> lw = low.get(0);
|
|
|
rs.put("lowCount",lw.get("lowCount"));
|
|
@ -972,16 +977,18 @@ public class DoctorSchemeService extends BaseService{
|
|
|
" ORDER BY " +
|
|
|
" i.record_date DESC LIMIT 1,1";
|
|
|
String xtSchSql="SELECT " +
|
|
|
" l.id " +
|
|
|
" l.*," +
|
|
|
" s.name " +
|
|
|
" FROM " +
|
|
|
" wlyy_patient_scheme_list l " +
|
|
|
" wlyy_patient_scheme_list l JOIN wlyy_doctor_scheme_blood_sugger s ON s.code = l.schemecode " +
|
|
|
" WHERE " +
|
|
|
" l.type = 1 " +
|
|
|
" AND l.patientcode = '"+patient+"'";
|
|
|
String xySchSql="SELECT " +
|
|
|
" l.id " +
|
|
|
" l.*," +
|
|
|
" s.name " +
|
|
|
" FROM " +
|
|
|
" wlyy_patient_scheme_list l " +
|
|
|
" wlyy_patient_scheme_list l JOIN wlyy_doctor_scheme_blood_pressure s ON s.code = l.schemecode" +
|
|
|
" WHERE " +
|
|
|
" l.type = 2 " +
|
|
|
" AND l.patientcode = '"+patient+"'";
|
|
@ -996,16 +1003,16 @@ public class DoctorSchemeService extends BaseService{
|
|
|
|
|
|
List<Map<String,Object>> xtList = jdbcTemplate.queryForList(xtSchSql);
|
|
|
if(xtList!=null&&xtList.size()>0){
|
|
|
rs.put("sugger","1");
|
|
|
rs.put("sugger",xtList.get(0));
|
|
|
}else{
|
|
|
rs.put("sugger","0");
|
|
|
rs.put("sugger",null);
|
|
|
}
|
|
|
|
|
|
List<Map<String,Object>> xyList = jdbcTemplate.queryForList(xySchSql);
|
|
|
if(xyList!=null&&xyList.size()>0){
|
|
|
rs.put("pressure","1");
|
|
|
rs.put("pressure",xyList.get(0));
|
|
|
}else{
|
|
|
rs.put("pressure","0");
|
|
|
rs.put("pressure",null);
|
|
|
}
|
|
|
|
|
|
return rs;
|
|
@ -1017,8 +1024,10 @@ public class DoctorSchemeService extends BaseService{
|
|
|
Map<String,Object> rs = new HashedMap();
|
|
|
PatientAimBloodSugger patientAimBloodSugger = patientAimBloodSuggerDao.findByPatientcode(patient);
|
|
|
PatientAimBloodPressure patientAimBloodPressure = patientAimBloodPressureDao.findByPatientcode(patient);
|
|
|
PatientAimSports patientAimSports = patientAimSportsDao.getPatientAimSportsByPatientCode(patient);
|
|
|
rs.put("patientAimBloodSugger",patientAimBloodSugger);
|
|
|
rs.put("patientAimBloodPressure",patientAimBloodPressure);
|
|
|
rs.put("patientAimSports",patientAimSports);
|
|
|
return rs;
|
|
|
}
|
|
|
|
|
@ -1066,7 +1075,7 @@ public class DoctorSchemeService extends BaseService{
|
|
|
}
|
|
|
|
|
|
public Map<String,Object> getTrackPatientCountTitle(Integer teamCode,String doctor,String startDate,String endDate){
|
|
|
List<TrackPatient> trackPatients = trackPatientDao.findByDoctorCodeAndTeamCode(doctor,teamCode);
|
|
|
List<TrackPatient> trackPatients = trackPatientDao.findByDoctorCodeAndTeamCodeAndDel(doctor,teamCode,"1");
|
|
|
Map<String,Object> rs = new HashedMap();
|
|
|
rs.put("trackPatientCount",trackPatients.size());
|
|
|
String sql = "SELECT " +
|
|
@ -1074,8 +1083,9 @@ public class DoctorSchemeService extends BaseService{
|
|
|
" FROM " +
|
|
|
" wlyy_track_patient t " +
|
|
|
" WHERE " +
|
|
|
" t.doctor_code = '"+doctor+"' " +
|
|
|
" AND t.team_code = '"+teamCode+"' " +
|
|
|
" t.del='1' " +
|
|
|
" AND t.doctor_code = '"+doctor+"' " +
|
|
|
" AND t.team_code = "+teamCode +
|
|
|
" AND t.create_time >= '"+startDate+"' " +
|
|
|
" AND t.create_time <= '"+endDate+"'";
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
|
|
@ -1089,7 +1099,7 @@ public class DoctorSchemeService extends BaseService{
|
|
|
|
|
|
}
|
|
|
|
|
|
public Map<String,Object> getTrackPatientServerCount(Long teamCode,String patient,String doctor,String startDate,String endDate){
|
|
|
public Map<String,Object> getTrackPatientServerCount(Long teamCode,String doctor,String startDate,String endDate){
|
|
|
startDate = startDate + " 00:00:00";
|
|
|
endDate = endDate + " 23:59:59";
|
|
|
|
|
@ -1140,12 +1150,12 @@ public class DoctorSchemeService extends BaseService{
|
|
|
" AND t.create_time >= '" + startDate + "' " +
|
|
|
" AND t.create_time <= '" + endDate + "'" +
|
|
|
" AND c.patient IN(" +
|
|
|
" SELECT t.patient_code FROM wlyy_track_patient t WHERE t.doctor_code ='"+doctor+"' AND t.team_code = " +id+
|
|
|
" SELECT t.patient_code FROM wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='"+doctor+"' AND t.team_code = " +id+
|
|
|
" )" +
|
|
|
" )c ON c.id = m.doctor_code " +
|
|
|
" WHERE " +
|
|
|
" m.team_id = " + id+
|
|
|
" m.doctor_code ='"+doctor+"'" ;
|
|
|
" AND m.doctor_code ='"+doctor+"'" ;
|
|
|
//获取咨詢數
|
|
|
Map<String, Object> consultCout = jdbcTemplate.queryForMap(consult_sql);
|
|
|
if (consultCout.get("consultCount") == null) {
|
|
@ -1157,7 +1167,7 @@ public class DoctorSchemeService extends BaseService{
|
|
|
public Long getReservationByteam(Long id,String doctor, String startDate, String endDate) {
|
|
|
//获取待预约
|
|
|
String reservation_sql = "SELECT COUNT(1) AS reservationCount FROM wlyy_patient_reservation w WHERE w.admin_team_code =" + id + " AND w.czrq <='" + endDate + "' AND w.czrq >='" + startDate + "' " +
|
|
|
" AND w.doctor ='"+doctor+"' AND w.patient IN (SELECT t.patient_code FROM wlyy_track_patient t WHERE t.doctor_code ='"+doctor+"' AND t.team_code = " +id+") ";
|
|
|
" AND w.doctor ='"+doctor+"' AND w.patient IN (SELECT t.patient_code FROM wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='"+doctor+"' AND t.team_code = " +id+") ";
|
|
|
//获取待预约
|
|
|
Map<String, Object> reservationCout = jdbcTemplate.queryForMap(reservation_sql);
|
|
|
if (reservationCout.get("reservationCount") == null) {
|
|
@ -1169,7 +1179,7 @@ public class DoctorSchemeService extends BaseService{
|
|
|
public Long getEduArticleByTeam(Long id,String doctor, String startDate, String endDate) {
|
|
|
//获取健康教育
|
|
|
String article_sql = "SELECT COUNT(1) AS articleCount FROM wlyy_health_edu_article_patient w WHERE w.admin_team_code =" + id + " AND w.czrq <='" + endDate + "' AND w.czrq >='" + startDate + "'" +
|
|
|
" AND w.doctor ='"+doctor+"' AND w.patient IN (SELECT t.patient_code FROM wlyy_track_patient t WHERE t.doctor_code ='"+doctor+"' AND t.team_code = " +id+") ";
|
|
|
" AND w.doctor ='"+doctor+"' AND w.patient IN (SELECT t.patient_code FROM wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='"+doctor+"' AND t.team_code = " +id+") ";
|
|
|
//获取健康教育
|
|
|
Map<String, Object> articleCout = jdbcTemplate.queryForMap(article_sql);
|
|
|
if (articleCout.get("articleCount") == null) {
|
|
@ -1181,7 +1191,7 @@ public class DoctorSchemeService extends BaseService{
|
|
|
public Long getGuidanceByTeam(Long id,String doctor, String startDate, String endDate) {
|
|
|
//获取健康指导
|
|
|
String guidance_sql = "SELECT COUNT(1) AS guidanceCount FROM wlyy_patient_health_guidance w WHERE w.admin_team_code =" + id + " AND w.czrq <='" + endDate + "' AND w.czrq >='" + startDate + "' " +
|
|
|
" AND w.doctor ='"+doctor+"' AND w.patient IN (SELECT t.patient_code FROM wlyy_track_patient t WHERE t.doctor_code ='"+doctor+"' AND t.team_code = " +id+") ";
|
|
|
" AND w.doctor ='"+doctor+"' AND w.patient IN (SELECT t.patient_code FROM wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='"+doctor+"' AND t.team_code = " +id+") ";
|
|
|
//获取健康指导
|
|
|
Map<String, Object> guidanceCout = jdbcTemplate.queryForMap(guidance_sql);
|
|
|
if (guidanceCout.get("guidanceCount") == null) {
|
|
@ -1194,7 +1204,7 @@ public class DoctorSchemeService extends BaseService{
|
|
|
public Long getFollowByTeam(Long id,String doctor, String startDate, String endDate) {
|
|
|
//随访数目
|
|
|
String followup_sql = "SELECT COUNT(1) AS followupCount from wlyy_followup w WHERE w.admin_team_code=" + id + " AND w.create_time >='" + startDate + "' AND w.create_time<='" + endDate + "' " +
|
|
|
" AND w.doctor_code ='"+doctor+"' AND w.patient_code IN (SELECT t.patient_code FROM wlyy_track_patient t WHERE t.doctor_code ='"+doctor+"' AND t.team_code = " +id+") ";
|
|
|
" AND w.doctor_code ='"+doctor+"' AND w.patient_code IN (SELECT t.patient_code FROM wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='"+doctor+"' AND t.team_code = " +id+") ";
|
|
|
//随访数目
|
|
|
Map<String, Object> followupCout = jdbcTemplate.queryForMap(followup_sql);
|
|
|
if (followupCout.get("followupCount") == null) {
|
|
@ -1217,7 +1227,7 @@ public class DoctorSchemeService extends BaseService{
|
|
|
" AND p.patient IN ( " +
|
|
|
" SELECT t.patient_code " +
|
|
|
" FROM wlyy_track_patient t " +
|
|
|
" WHERE t.doctor_code ='"+doctor+"' " +
|
|
|
" WHERE t.del='1' AND t.doctor_code ='"+doctor+"' " +
|
|
|
" AND t.team_code = " +id+")";
|
|
|
//审核数目
|
|
|
Map<String, Object> reviewedCount = jdbcTemplate.queryForMap(sql);
|
|
@ -1243,7 +1253,7 @@ public class DoctorSchemeService extends BaseService{
|
|
|
" WHERE " +
|
|
|
" i.`user` in " +
|
|
|
" ( " +
|
|
|
" SELECT p.patient_code AS `user` FROM wlyy_track_patient p WHERE p.doctor_code='"+doctor+"' AND p.team_code =" +teamCode+
|
|
|
" SELECT p.patient_code AS `user` FROM wlyy_track_patient p WHERE p.del='1' AND p.doctor_code='"+doctor+"' AND p.team_code =" +teamCode+
|
|
|
" ) " +
|
|
|
" AND i.del ='1' " +
|
|
|
" AND i.type = 2 " +
|
|
@ -1263,7 +1273,7 @@ public class DoctorSchemeService extends BaseService{
|
|
|
" WHERE " +
|
|
|
" i.`user` in " +
|
|
|
" ( " +
|
|
|
" SELECT p.patient_code AS `user` FROM wlyy_track_patient p WHERE p.doctor_code='"+doctor+"' AND p.team_code =" +teamCode+
|
|
|
" SELECT p.patient_code AS `user` FROM wlyy_track_patient p WHERE p.del='1' AND p.doctor_code='"+doctor+"' AND p.team_code =" +teamCode+
|
|
|
" ) " +
|
|
|
" AND " +
|
|
|
" i.value1 <= p.sbp " +
|
|
@ -1335,7 +1345,7 @@ public class DoctorSchemeService extends BaseService{
|
|
|
" WHERE " +
|
|
|
" i.`user` in " +
|
|
|
" ( " +
|
|
|
" SELECT p.patient_code AS `user` FROM wlyy_track_patient p WHERE p.doctor_code='"+doctor+"' AND p.team_code =" +teamCode+
|
|
|
" SELECT p.patient_code AS `user` FROM wlyy_track_patient p WHERE p.del='1' AND p.doctor_code='"+doctor+"' AND p.team_code =" +teamCode+
|
|
|
" ) " +
|
|
|
" AND i.del ='1' " +
|
|
|
" AND i.type = 1 " +
|
|
@ -1355,7 +1365,7 @@ public class DoctorSchemeService extends BaseService{
|
|
|
" WHERE " +
|
|
|
" i.`user` in " +
|
|
|
" ( " +
|
|
|
" SELECT p.patient_code AS `user` FROM wlyy_track_patient p WHERE p.doctor_code='"+doctor+"' AND p.team_code =" +teamCode+
|
|
|
" SELECT p.patient_code AS `user` FROM wlyy_track_patient p WHERE p.del='1' AND p.doctor_code='"+doctor+"' AND p.team_code =" +teamCode+
|
|
|
" ) " +
|
|
|
" AND " +
|
|
|
" i.value1 <= p.fbg " +
|
|
@ -1380,7 +1390,8 @@ public class DoctorSchemeService extends BaseService{
|
|
|
" wlyy_patient_device d JOIN " +
|
|
|
" wlyy_track_patient t ON t.patient_code = d.`user` " +
|
|
|
" WHERE " +
|
|
|
" d.category_code = ? " +
|
|
|
" t.del='1' " +
|
|
|
" AND d.category_code = ? " +
|
|
|
" AND t.doctor_code = '"+doctor+"' " +
|
|
|
" AND t.team_code = "+teamCode;
|
|
|
Map<String,Object> rs = new HashedMap();
|
|
@ -1401,23 +1412,515 @@ public class DoctorSchemeService extends BaseService{
|
|
|
return rs;
|
|
|
}
|
|
|
|
|
|
public String setPatientAim(String patients ,String suggerJson,String presJson){
|
|
|
|
|
|
public String setSinglePatientAim(String patient ,String suggerJson,String presJson,String sportJson ){
|
|
|
|
|
|
PatientAimBloodSugger sugger = patientAimBloodSuggerDao.findByPatientcode(patient);
|
|
|
if(sugger!=null){
|
|
|
patientAimBloodSuggerDao.delete(sugger);
|
|
|
}
|
|
|
PatientAimBloodPressure pres = patientAimBloodPressureDao.findByPatientcode(patient);
|
|
|
if(pres!=null){
|
|
|
patientAimBloodPressureDao.delete(pres);
|
|
|
}
|
|
|
|
|
|
PatientAimSports sport = patientAimSportsDao.getPatientAimSportsByPatientCode(patient);
|
|
|
if(sport!=null){
|
|
|
patientAimSportsDao.delete(sport);
|
|
|
}
|
|
|
|
|
|
|
|
|
net.sf.json.JSONObject sj = net.sf.json.JSONObject.fromObject(suggerJson);
|
|
|
net.sf.json.JSONObject pj = net.sf.json.JSONObject.fromObject(presJson);
|
|
|
net.sf.json.JSONObject spj = net.sf.json.JSONObject.fromObject(sportJson);
|
|
|
|
|
|
PatientAimBloodSugger patientAimBloodSugger = (PatientAimBloodSugger)net.sf.json.JSONObject.toBean(sj,PatientAimBloodSugger.class);
|
|
|
PatientAimBloodPressure patientAimBloodPressure = (PatientAimBloodPressure)net.sf.json.JSONObject.toBean(pj,PatientAimBloodPressure.class);
|
|
|
PatientAimSports patientAimSports = (PatientAimSports)net.sf.json.JSONObject.toBean(spj,PatientAimSports.class);
|
|
|
|
|
|
patientAimBloodSugger.setPatientcode(patient);
|
|
|
patientAimBloodSugger.setCode(getCode());
|
|
|
patientAimBloodSugger.setCreateTime(new Date());
|
|
|
patientAimBloodSuggerDao.save(patientAimBloodSugger);
|
|
|
|
|
|
patientAimBloodPressure.setPatientcode(patient);
|
|
|
patientAimBloodPressure.setCode(getCode());
|
|
|
patientAimBloodPressure.setCreateTime(new Date());
|
|
|
patientAimBloodPressureDao.save(patientAimBloodPressure);
|
|
|
|
|
|
patientAimSports.setPatientcode(patient);
|
|
|
patientAimSports.setCode(getCode());
|
|
|
patientAimSports.setCreateTime(new Date());
|
|
|
patientAimSportsDao.save(patientAimSports);
|
|
|
|
|
|
return "1";
|
|
|
|
|
|
}
|
|
|
|
|
|
public String setPatientAim(String patients ,String suggerJson,String presJson,String sportJson){
|
|
|
if(StringUtils.isNotBlank(patients)){
|
|
|
String[] patient = patients.split(",");
|
|
|
for(String p : patient){
|
|
|
|
|
|
PatientAimBloodSugger sugger = patientAimBloodSuggerDao.findByPatientcode(p);
|
|
|
if(sugger!=null){
|
|
|
patientAimBloodSuggerDao.delete(sugger);
|
|
|
}
|
|
|
PatientAimBloodPressure pres = patientAimBloodPressureDao.findByPatientcode(p);
|
|
|
if(pres!=null){
|
|
|
patientAimBloodPressureDao.delete(pres);
|
|
|
}
|
|
|
PatientAimSports sport = patientAimSportsDao.getPatientAimSportsByPatientCode(p);
|
|
|
if(sport!=null){
|
|
|
patientAimSportsDao.delete(sport);
|
|
|
}
|
|
|
|
|
|
|
|
|
net.sf.json.JSONObject sj = net.sf.json.JSONObject.fromObject(suggerJson);
|
|
|
net.sf.json.JSONObject pj = net.sf.json.JSONObject.fromObject(presJson);
|
|
|
net.sf.json.JSONObject spj = net.sf.json.JSONObject.fromObject(sportJson);
|
|
|
PatientAimBloodSugger patientAimBloodSugger = (PatientAimBloodSugger)net.sf.json.JSONObject.toBean(sj,PatientAimBloodSugger.class);
|
|
|
PatientAimBloodPressure patientAimBloodPressure = (PatientAimBloodPressure)net.sf.json.JSONObject.toBean(pj,PatientAimBloodPressure.class);
|
|
|
PatientAimSports patientAimSports = (PatientAimSports)net.sf.json.JSONObject.toBean(spj,PatientAimSports.class);
|
|
|
|
|
|
patientAimBloodSugger.setPatientcode(p);
|
|
|
patientAimBloodSugger.setCode(getCode());
|
|
|
patientAimBloodSugger.setCreateTime(new Date());
|
|
|
patientAimBloodSuggerDao.save(patientAimBloodSugger);
|
|
|
|
|
|
patientAimBloodPressure.setPatientcode(p);
|
|
|
patientAimBloodPressure.setCode(getCode());
|
|
|
patientAimBloodPressure.setCreateTime(new Date());
|
|
|
patientAimBloodPressureDao.save(patientAimBloodPressure);
|
|
|
|
|
|
patientAimSports.setPatientcode(p);
|
|
|
patientAimSports.setCode(getCode());
|
|
|
patientAimSports.setCreateTime(new Date());
|
|
|
patientAimSportsDao.save(patientAimSports);
|
|
|
}
|
|
|
}
|
|
|
return "0";
|
|
|
|
|
|
}
|
|
|
|
|
|
public List<Map<String,Object>> getPatientScheme(String patient,String type){
|
|
|
String sql =null;
|
|
|
if("1".equals(type)){
|
|
|
sql = "SELECT " +
|
|
|
" s.* " +
|
|
|
" FROM " +
|
|
|
" wlyy_patient_scheme_list l " +
|
|
|
" JOIN wlyy_doctor_scheme_blood_sugger s ON s. CODE = l.schemecode " +
|
|
|
" WHERE " +
|
|
|
" l.type = 1 " +
|
|
|
" AND l.patientcode='"+patient+"'" +
|
|
|
" ORDER BY s.dayofweek ASC";
|
|
|
}else{
|
|
|
sql = "SELECT " +
|
|
|
" s.* " +
|
|
|
" FROM " +
|
|
|
" wlyy_patient_scheme_list l " +
|
|
|
" JOIN wlyy_doctor_scheme_blood_pressure s ON s. CODE = l.schemecode " +
|
|
|
" WHERE " +
|
|
|
" l.type = 2 " +
|
|
|
" AND l.patientcode='"+patient+"'" +
|
|
|
" ORDER BY s.dayofweek ASC";
|
|
|
}
|
|
|
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
public List<Map<String,Object>> getTrackPatientIndexCountList(String doctor,Integer teamCode,String type,String startDate,String endDate,String keyword,Integer page,Integer size){
|
|
|
startDate = startDate+" 00:00:00";
|
|
|
endDate = endDate + " 23:59:59";
|
|
|
// /血糖查询
|
|
|
if("1".equals(type)){
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(getXTTrackPatientIndexCountListSql(doctor,teamCode,startDate,endDate,keyword, page, size));
|
|
|
return list;
|
|
|
}else{
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(getXYTrackPatientIndexCountListSql(doctor,teamCode,startDate,endDate,keyword, page, size));
|
|
|
return list;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public String getXTTrackPatientIndexCountListSql(String doctor,Integer teamCode,String startDate,String endDate,String keyword,Integer page,Integer size){
|
|
|
|
|
|
String sql = "SELECT " +
|
|
|
" tt1.patient_code, " +
|
|
|
" tt1.highCount, " +
|
|
|
" tt2.lowCount, " +
|
|
|
" tt3.stdCount, " +
|
|
|
" p.`name`, " +
|
|
|
" IFNULL(year( from_days( datediff( now(), p.birthday))),'未知') age, " +
|
|
|
" p.photo, " +
|
|
|
" p.idcard " +
|
|
|
" FROM " +
|
|
|
" " +
|
|
|
"( " +
|
|
|
" " +
|
|
|
" SELECT " +
|
|
|
" t1.patient_code, " +
|
|
|
" t2.total + t1.total AS highCount " +
|
|
|
" FROM " +
|
|
|
" ( " +
|
|
|
" SELECT " +
|
|
|
" t.patient_code, " +
|
|
|
" IFNULL(pid.total, 0) AS total " +
|
|
|
" FROM " +
|
|
|
" ( " +
|
|
|
" SELECT " +
|
|
|
" tp.patient_code " +
|
|
|
" FROM " +
|
|
|
" wlyy_track_patient tp " +
|
|
|
" WHERE " +
|
|
|
" tp.del = '1' " +
|
|
|
" AND tp.doctor_code = '"+doctor+"' " +
|
|
|
" AND tp.team_code = " +teamCode+
|
|
|
" ) t " +
|
|
|
" LEFT JOIN ( " +
|
|
|
" SELECT " +
|
|
|
" i. USER, " +
|
|
|
" COUNT(1) AS total " +
|
|
|
" FROM " +
|
|
|
" device.wlyy_patient_health_index i " +
|
|
|
" WHERE " +
|
|
|
" i.del = '1' " +
|
|
|
" AND i.type = 1 " +
|
|
|
" AND i.value2 IN (2, 4, 6) " +
|
|
|
" AND i.value1 > 7.8 " +
|
|
|
" AND i.i.record_date >='"+startDate+"'" +
|
|
|
" AND i.i.record_date <='"+endDate+"'" +
|
|
|
" GROUP BY " +
|
|
|
" i. USER " +
|
|
|
" ) pid ON pid. USER = t.patient_code " +
|
|
|
" ) t1 " +
|
|
|
" " +
|
|
|
" JOIN " +
|
|
|
" " +
|
|
|
" ( " +
|
|
|
" SELECT " +
|
|
|
" t.patient_code, " +
|
|
|
" IFNULL(pid.total, 0) AS total " +
|
|
|
" FROM " +
|
|
|
" ( " +
|
|
|
" SELECT " +
|
|
|
" tp.patient_code " +
|
|
|
" FROM " +
|
|
|
" wlyy_track_patient tp " +
|
|
|
" WHERE " +
|
|
|
" tp.del = '1' " +
|
|
|
" AND tp.doctor_code = '"+doctor+"' " +
|
|
|
" AND tp.team_code =" +teamCode+
|
|
|
" ) t " +
|
|
|
" LEFT JOIN ( " +
|
|
|
" SELECT " +
|
|
|
" i. USER, " +
|
|
|
" COUNT(1) AS total " +
|
|
|
" FROM " +
|
|
|
" device.wlyy_patient_health_index i " +
|
|
|
" WHERE " +
|
|
|
" i.del = '1' " +
|
|
|
" AND i.type = 1 " +
|
|
|
" AND i.value2 IN (1, 3, 5, 7) " +
|
|
|
" AND i.value1 > 6.1 " +
|
|
|
" AND i.i.record_date >='"+startDate+"'" +
|
|
|
" AND i.i.record_date <='"+endDate+"'" +
|
|
|
" GROUP BY " +
|
|
|
" i. USER " +
|
|
|
" ) pid ON pid. USER = t.patient_code " +
|
|
|
") t2 ON t1.patient_code = t2.patient_code " +
|
|
|
" " +
|
|
|
") tt1 " +
|
|
|
" " +
|
|
|
" JOIN " +
|
|
|
" " +
|
|
|
"( " +
|
|
|
" SELECT " +
|
|
|
" t1.patient_code, " +
|
|
|
" t1.total + t2.total AS lowCount " +
|
|
|
" FROM " +
|
|
|
" ( " +
|
|
|
" SELECT " +
|
|
|
" t.patient_code, " +
|
|
|
" IFNULL(pid.total, 0) AS total " +
|
|
|
" FROM " +
|
|
|
" ( " +
|
|
|
" SELECT " +
|
|
|
" tp.patient_code " +
|
|
|
" FROM " +
|
|
|
" wlyy_track_patient tp " +
|
|
|
" WHERE " +
|
|
|
" tp.del = '1' " +
|
|
|
" AND tp.doctor_code = '"+doctor+"' " +
|
|
|
" AND tp.team_code = " +teamCode+
|
|
|
" ) t " +
|
|
|
" LEFT JOIN ( " +
|
|
|
" SELECT " +
|
|
|
" i. USER, " +
|
|
|
" COUNT(1) AS total " +
|
|
|
" FROM " +
|
|
|
" device.wlyy_patient_health_index i " +
|
|
|
" WHERE " +
|
|
|
" i.del = '1' " +
|
|
|
" AND i.type = 1 " +
|
|
|
" AND i.value2 IN (2, 4, 6) " +
|
|
|
" AND i.value1 < 4.4 " +
|
|
|
" AND i.i.record_date >='"+startDate+"'" +
|
|
|
" AND i.i.record_date <='"+endDate+"'" +
|
|
|
" GROUP BY " +
|
|
|
" i. USER " +
|
|
|
" ) pid ON pid. USER = t.patient_code " +
|
|
|
" ) t1 " +
|
|
|
" " +
|
|
|
" JOIN " +
|
|
|
" " +
|
|
|
"( " +
|
|
|
" SELECT " +
|
|
|
" t.patient_code, " +
|
|
|
" IFNULL(pid.total, 0) AS total " +
|
|
|
" FROM " +
|
|
|
" ( " +
|
|
|
" SELECT " +
|
|
|
" tp.patient_code " +
|
|
|
" FROM " +
|
|
|
" wlyy_track_patient tp " +
|
|
|
" WHERE " +
|
|
|
" tp.del = '1' " +
|
|
|
" AND tp.doctor_code = '"+doctor+"' " +
|
|
|
" AND tp.team_code = " +teamCode+
|
|
|
" ) t " +
|
|
|
" LEFT JOIN ( " +
|
|
|
" SELECT " +
|
|
|
" i. USER, " +
|
|
|
" COUNT(1) AS total " +
|
|
|
" FROM " +
|
|
|
" device.wlyy_patient_health_index i " +
|
|
|
" WHERE " +
|
|
|
" i.del = '1' " +
|
|
|
" AND i.type = 1 " +
|
|
|
" AND i.value2 IN (1, 3, 5, 7) " +
|
|
|
" AND i.value1 < 3.9 " +
|
|
|
" AND i.i.record_date >='"+startDate+"'" +
|
|
|
" AND i.i.record_date <='"+endDate+"'" +
|
|
|
" GROUP BY " +
|
|
|
" i. USER " +
|
|
|
" ) pid ON pid. USER = t.patient_code " +
|
|
|
") t2 ON t1.patient_code = t2.patient_code " +
|
|
|
" " +
|
|
|
") tt2 ON tt1.patient_code = tt2.patient_code " +
|
|
|
" " +
|
|
|
"JOIN " +
|
|
|
" " +
|
|
|
"( " +
|
|
|
" " +
|
|
|
" SELECT " +
|
|
|
" t1.patient_code, " +
|
|
|
" t1.total + t2.total AS stdCount " +
|
|
|
" FROM " +
|
|
|
" ( " +
|
|
|
" SELECT " +
|
|
|
" t.patient_code, " +
|
|
|
" IFNULL(pid.total, 0) AS total " +
|
|
|
" FROM " +
|
|
|
" ( " +
|
|
|
" SELECT " +
|
|
|
" tp.patient_code " +
|
|
|
" FROM " +
|
|
|
" wlyy_track_patient tp " +
|
|
|
" WHERE " +
|
|
|
" tp.del = '1' " +
|
|
|
" AND tp.doctor_code = '"+doctor+"' " +
|
|
|
" AND tp.team_code = " +teamCode +
|
|
|
" ) t " +
|
|
|
" LEFT JOIN ( " +
|
|
|
" SELECT " +
|
|
|
" i. USER, " +
|
|
|
" COUNT(1) AS total " +
|
|
|
" FROM " +
|
|
|
" device.wlyy_patient_health_index i " +
|
|
|
" WHERE " +
|
|
|
" i.del = '1' " +
|
|
|
" AND i.type = 1 " +
|
|
|
" AND i.value2 IN (2, 4, 6) " +
|
|
|
" AND i.value1 >= 4.4 " +
|
|
|
" AND i.value1 <= 7.8 " +
|
|
|
" AND i.i.record_date >='"+startDate+"'" +
|
|
|
" AND i.i.record_date <='"+endDate+"'" +
|
|
|
" GROUP BY " +
|
|
|
" i. USER " +
|
|
|
" ) pid ON pid. USER = t.patient_code " +
|
|
|
" ) t1 " +
|
|
|
" " +
|
|
|
" JOIN " +
|
|
|
" " +
|
|
|
" ( " +
|
|
|
" SELECT " +
|
|
|
" t.patient_code, " +
|
|
|
" IFNULL(pid.total, 0) AS total " +
|
|
|
" FROM " +
|
|
|
" ( " +
|
|
|
" SELECT " +
|
|
|
" tp.patient_code " +
|
|
|
" FROM " +
|
|
|
" wlyy_track_patient tp " +
|
|
|
" WHERE " +
|
|
|
" tp.del = '1' " +
|
|
|
" AND tp.doctor_code = '"+doctor+"' " +
|
|
|
" AND tp.team_code = " +teamCode+
|
|
|
" ) t " +
|
|
|
" LEFT JOIN ( " +
|
|
|
" SELECT " +
|
|
|
" i. USER, " +
|
|
|
" COUNT(1) AS total " +
|
|
|
" FROM " +
|
|
|
" device.wlyy_patient_health_index i " +
|
|
|
" WHERE " +
|
|
|
" i.del = '1' " +
|
|
|
" AND i.type = 1 " +
|
|
|
" AND i.value2 IN (1, 3, 5, 7) " +
|
|
|
" AND i.value1 >= 3.9 " +
|
|
|
" AND i.value1 <= 6.1 " +
|
|
|
" AND i.i.record_date >='"+startDate+"'" +
|
|
|
" AND i.i.record_date <='"+endDate+"'" +
|
|
|
" GROUP BY " +
|
|
|
" i. USER " +
|
|
|
" ) pid ON pid. USER = t.patient_code " +
|
|
|
" ) t2 ON t1.patient_code = t2.patient_code " +
|
|
|
" " +
|
|
|
" )tt3 ON tt1.patient_code = tt3.patient_code " +
|
|
|
" " +
|
|
|
" JOIN wlyy_patient p On tt1.patient_code =p.code";
|
|
|
if(StringUtils.isNotBlank(keyword)){
|
|
|
Patient p = patientDao.findByIdcard(keyword);
|
|
|
if(p!=null){
|
|
|
sql =sql + " WHERE p.idcard ='"+keyword+"'";
|
|
|
}else{
|
|
|
sql =sql + " WHERE p.name like '%"+keyword+"%' ";
|
|
|
}
|
|
|
}
|
|
|
sql += " ORDER BY highCount DESC LIMIT "+(page-1)*size+","+size;
|
|
|
return sql ;
|
|
|
}
|
|
|
|
|
|
public String getXYTrackPatientIndexCountListSql(String doctor,Integer teamCode,String startDate,String endDate,String keyword,Integer page,Integer size){
|
|
|
String sql ="SELECT " +
|
|
|
" t1.patient_code, " +
|
|
|
" t1.total AS lowCount, " +
|
|
|
" t2.total AS stdCount, " +
|
|
|
" t3.total AS highCount, " +
|
|
|
" p.`name`, " +
|
|
|
" IFNULL(year( from_days( datediff( now(), p.birthday))),'未知') age, " +
|
|
|
" p.photo " +
|
|
|
" FROM " +
|
|
|
" " +
|
|
|
" ( " +
|
|
|
" SELECT " +
|
|
|
" t.patient_code, " +
|
|
|
" IFNULL(pid.total, 0) AS total " +
|
|
|
" FROM " +
|
|
|
" ( " +
|
|
|
" SELECT " +
|
|
|
" tp.patient_code " +
|
|
|
" FROM " +
|
|
|
" wlyy_track_patient tp " +
|
|
|
" WHERE " +
|
|
|
" tp.del = '1' " +
|
|
|
" AND tp.doctor_code = '"+doctor+"' " +
|
|
|
" AND tp.team_code = " +teamCode+
|
|
|
" ) t " +
|
|
|
" LEFT JOIN ( " +
|
|
|
" SELECT " +
|
|
|
" i. USER, " +
|
|
|
" COUNT(1) AS total " +
|
|
|
" FROM " +
|
|
|
" device.wlyy_patient_health_index i " +
|
|
|
" WHERE " +
|
|
|
" i.del = '1' " +
|
|
|
" AND i.type = 2 " +
|
|
|
" AND i.value1 < 90 " +
|
|
|
" AND i.i.record_date >='"+startDate+"'" +
|
|
|
" AND i.i.record_date <='"+endDate+"'" +
|
|
|
" GROUP BY " +
|
|
|
" i. USER " +
|
|
|
" ) pid ON pid. USER = t.patient_code " +
|
|
|
" ) t1 " +
|
|
|
" JOIN " +
|
|
|
" ( " +
|
|
|
" SELECT " +
|
|
|
" t.patient_code, " +
|
|
|
" IFNULL(pid.total, 0) AS total " +
|
|
|
" FROM " +
|
|
|
" ( " +
|
|
|
" SELECT " +
|
|
|
" tp.patient_code " +
|
|
|
" FROM " +
|
|
|
" wlyy_track_patient tp " +
|
|
|
" WHERE " +
|
|
|
" tp.del = '1' " +
|
|
|
" AND tp.doctor_code = '"+doctor+"' " +
|
|
|
" AND tp.team_code = " +teamCode+
|
|
|
" ) t " +
|
|
|
" LEFT JOIN ( " +
|
|
|
" SELECT " +
|
|
|
" i. USER, " +
|
|
|
" COUNT(1) AS total " +
|
|
|
" FROM " +
|
|
|
" device.wlyy_patient_health_index i " +
|
|
|
" WHERE " +
|
|
|
" i.del = '1' " +
|
|
|
" AND i.type = 2 " +
|
|
|
" AND i.value1 >= 90 " +
|
|
|
" AND i.value1 <=139 " +
|
|
|
" AND i.i.record_date >='"+startDate+"'" +
|
|
|
" AND i.i.record_date <='"+endDate+"'" +
|
|
|
" GROUP BY " +
|
|
|
" i. USER " +
|
|
|
" ) pid ON pid. USER = t.patient_code " +
|
|
|
" " +
|
|
|
" ) t2 ON t1.patient_code = t2.patient_code " +
|
|
|
" JOIN " +
|
|
|
" ( " +
|
|
|
" SELECT " +
|
|
|
" t.patient_code, " +
|
|
|
" IFNULL(pid.total, 0) AS total " +
|
|
|
" FROM " +
|
|
|
" ( " +
|
|
|
" SELECT " +
|
|
|
" tp.patient_code " +
|
|
|
" FROM " +
|
|
|
" wlyy_track_patient tp " +
|
|
|
" WHERE " +
|
|
|
" tp.del = '1' " +
|
|
|
" AND tp.doctor_code = '"+doctor+"' " +
|
|
|
" AND tp.team_code = " +teamCode+
|
|
|
" ) t " +
|
|
|
" LEFT JOIN ( " +
|
|
|
" SELECT " +
|
|
|
" i. USER, " +
|
|
|
" COUNT(1) AS total " +
|
|
|
" FROM " +
|
|
|
" device.wlyy_patient_health_index i " +
|
|
|
" WHERE " +
|
|
|
" i.del = '1' " +
|
|
|
" AND i.type = 2 " +
|
|
|
" AND i.value1 >139 " +
|
|
|
" AND i.i.record_date >='"+startDate+"'" +
|
|
|
" AND i.i.record_date <='"+endDate+"'" +
|
|
|
" GROUP BY " +
|
|
|
" i. USER " +
|
|
|
" ) pid ON pid. USER = t.patient_code " +
|
|
|
" ) t3 ON t1.patient_code = t3.patient_code " +
|
|
|
" JOIN wlyy_patient p ON t1.patient_code = p.`code`";
|
|
|
if(StringUtils.isNotBlank(keyword)){
|
|
|
Patient p = patientDao.findByIdcard(keyword);
|
|
|
if(p!=null){
|
|
|
sql =sql + " WHERE p.idcard ='"+keyword+"'";
|
|
|
}else{
|
|
|
sql =sql + " WHERE p.name like '%"+keyword+"%' ";
|
|
|
}
|
|
|
}
|
|
|
sql += " ORDER BY highCount DESC LIMIT "+(page-1)*size+","+size;
|
|
|
return sql;
|
|
|
}
|
|
|
}
|