|
@ -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 + "pt.del='1' 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;
|
|
|
}
|
|
|
|
|
|
|
|
@ -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"));
|
|
@ -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 " +
|
|
@ -1076,7 +1085,7 @@ public class DoctorSchemeService extends BaseService{
|
|
|
" WHERE " +
|
|
|
" t.del='1' " +
|
|
|
" AND t.doctor_code = '"+doctor+"' " +
|
|
|
" AND t.team_code = '"+teamCode+"' " +
|
|
|
" AND t.team_code = "+teamCode +
|
|
|
" AND t.create_time >= '"+startDate+"' " +
|
|
|
" AND t.create_time <= '"+endDate+"'";
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
|
|
@ -1090,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";
|
|
|
|
|
@ -1146,7 +1155,7 @@ public class DoctorSchemeService extends BaseService{
|
|
|
" )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) {
|
|
@ -1403,23 +1412,122 @@ 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;
|
|
|
}
|
|
|
}
|