|
@ -17,9 +17,11 @@ import com.yihu.wlyy.repository.doctor.*;
|
|
|
import com.yihu.wlyy.repository.patient.PatientDao;
|
|
|
import com.yihu.wlyy.repository.patient.TrackPatientDao;
|
|
|
import com.yihu.wlyy.repository.patient.scheme.PatientSchemeListDao;
|
|
|
import com.yihu.wlyy.service.BaseService;
|
|
|
import com.yihu.wlyy.util.DateUtil;
|
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.apache.poi.util.StringUtil;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@ -41,7 +43,7 @@ import java.util.*;
|
|
|
* @date 2017/9/13 15:46
|
|
|
*/
|
|
|
@Service
|
|
|
public class DoctorSchemeService {
|
|
|
public class DoctorSchemeService extends BaseService{
|
|
|
private static Logger logger = LoggerFactory.getLogger(DoctorSchemeService.class);
|
|
|
|
|
|
@Autowired
|
|
@ -91,10 +93,15 @@ public class DoctorSchemeService {
|
|
|
* @date 2017/9/13 16:23
|
|
|
* @return
|
|
|
*/
|
|
|
public List<String> getPatientsByDiseaseConditionDiseaseDeviceType(String teamCode, Integer disease, String diseaseCondition, Integer deviceType,String doctorcode) throws Exception{
|
|
|
public List<String> getPatientsByDiseaseConditionDiseaseDeviceType(String teamCode, Integer disease, String diseaseCondition, Integer deviceType,String doctorcode,String trackFlag) throws Exception{
|
|
|
|
|
|
String sql = "select DISTINCT p.code from wlyy_patient p ";
|
|
|
|
|
|
//1.4.2加入跟踪居民过滤
|
|
|
if(StringUtils.isNotBlank(trackFlag)&&"1".equals(trackFlag)){
|
|
|
sql = sql + " JOIN wlyy_track_patient tp ON tp.patientCode = p.code ";
|
|
|
}
|
|
|
|
|
|
if(-1 != deviceType){
|
|
|
sql = sql + " LEFT JOIN wlyy_patient_device dev on dev.user = p.code ";
|
|
|
}
|
|
@ -127,6 +134,12 @@ public class DoctorSchemeService {
|
|
|
|
|
|
sql = sql + " and p.status > 0 and sp.label_type = 3 and sf.status > 0 ";
|
|
|
|
|
|
//1.4.2加入跟踪居民过滤
|
|
|
if(StringUtils.isNotBlank(trackFlag)&&"1".equals(trackFlag)){
|
|
|
sql = sql + " AND pt.doctor_code = '"+doctorcode+"' AND pt.teamCode = "+teamCode;
|
|
|
}
|
|
|
|
|
|
|
|
|
List<String> result = jdbcTemplate.queryForList(sql,new Object[]{},String.class);
|
|
|
|
|
|
|
|
@ -1213,4 +1226,198 @@ public class DoctorSchemeService {
|
|
|
}
|
|
|
return (Long)reviewedCount.get("reviewedCount");
|
|
|
}
|
|
|
|
|
|
public Map<String,Object> getTrackPatientAimByteam(String doctor ,Long teamCode,String startDate,String endDate){
|
|
|
startDate = startDate +" 00:00:00";
|
|
|
endDate = endDate +" 23:59:59";
|
|
|
|
|
|
String presSql="SELECT " +
|
|
|
" COUNT(1) AS dbCount " +
|
|
|
" FROM " +
|
|
|
" ( " +
|
|
|
" SELECT " +
|
|
|
" i.`user`, " +
|
|
|
" COUNT(1) AS total " +
|
|
|
" FROM " +
|
|
|
" device.wlyy_patient_health_index i " +
|
|
|
" 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+
|
|
|
" ) " +
|
|
|
" AND i.del ='1' " +
|
|
|
" AND i.type = 2 " +
|
|
|
" AND i.record_date >= '"+startDate+"' " +
|
|
|
" AND i.record_date <= '"+endDate+"' " +
|
|
|
" GROUP BY " +
|
|
|
" i.`user` " +
|
|
|
" ) tt " +
|
|
|
" LEFT JOIN " +
|
|
|
" ( " +
|
|
|
" SELECT " +
|
|
|
" i.`user`, " +
|
|
|
" COUNT(1) AS dbtotal " +
|
|
|
" FROM " +
|
|
|
" device.wlyy_patient_health_index i " +
|
|
|
" JOIN wlyy_patient_aim_blood_pressure p ON p.patientcode = i.`user` " +
|
|
|
" 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+
|
|
|
" ) " +
|
|
|
" AND " +
|
|
|
" i.value1 <= p.sbp " +
|
|
|
" AND " +
|
|
|
" i.value1 >= p.sbp_min " +
|
|
|
" AND i.del ='1' " +
|
|
|
" AND i.type = 2 " +
|
|
|
" AND i.record_date >= '"+startDate+"' " +
|
|
|
" AND i.record_date <= '"+endDate+"' " +
|
|
|
" GROUP BY " +
|
|
|
" i.`user` " +
|
|
|
" ) dbt ON tt.`user`=dbt.`user` " +
|
|
|
" WHERE dbt.dbtotal/tt.total > 0.7";
|
|
|
|
|
|
Map<String,Object> rs = new HashedMap();
|
|
|
List<Map<String,Object>> presTotal = jdbcTemplate.queryForList(presSql);
|
|
|
if(presTotal!=null&&presTotal.size()>0){
|
|
|
rs.put("dbPresCount",presTotal.get(0).get("dbCount"));
|
|
|
}else {
|
|
|
rs.put("dbPresCount",0);
|
|
|
}
|
|
|
|
|
|
//餐前达标数量
|
|
|
List<Map<String,Object>> cqXT = jdbcTemplate.queryForList(getXTSql( doctor , teamCode, startDate, endDate, "0"));
|
|
|
Long cqtotal;
|
|
|
if(cqXT!=null&&cqXT.size()>0){
|
|
|
cqtotal = (Long)cqXT.get(0).get("dbCount");
|
|
|
}else{
|
|
|
cqtotal = 0L;
|
|
|
}
|
|
|
//餐后达标数量
|
|
|
List<Map<String,Object>> chXT = jdbcTemplate.queryForList(getXTSql( doctor , teamCode, startDate, endDate, "1"));
|
|
|
Long chtotal;
|
|
|
if(chXT!=null&&chXT.size()>0){
|
|
|
chtotal = (Long)chXT.get(0).get("dbCount");
|
|
|
}else{
|
|
|
chtotal = 0L;
|
|
|
}
|
|
|
|
|
|
rs.put("dbSuggerCount",chtotal+cqtotal);
|
|
|
return rs;
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
*
|
|
|
* @param doctor
|
|
|
* @param teamCode
|
|
|
* @param startDate
|
|
|
* @param endDate
|
|
|
* @param state 0 餐前,1餐后
|
|
|
* @return
|
|
|
*/
|
|
|
public String getXTSql(String doctor ,Long teamCode,String startDate,String endDate,String state){
|
|
|
String value2 ="1,3,5,7";
|
|
|
if("1".equals(state)){
|
|
|
value2 = "2,4,6";
|
|
|
}
|
|
|
//餐前血糖达标数
|
|
|
String xtSql = "SELECT " +
|
|
|
" COUNT(1) AS dbCount " +
|
|
|
" FROM " +
|
|
|
" ( " +
|
|
|
" SELECT " +
|
|
|
" i.`user`, " +
|
|
|
" COUNT(1) AS total " +
|
|
|
" FROM " +
|
|
|
" device.wlyy_patient_health_index i " +
|
|
|
" 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+
|
|
|
" ) " +
|
|
|
" AND i.del ='1' " +
|
|
|
" AND i.type = 1 " +
|
|
|
" AND i.record_date >= '"+startDate+"' " +
|
|
|
" AND i.record_date <= '"+endDate+"' " +
|
|
|
" GROUP BY " +
|
|
|
" i.`user` " +
|
|
|
" ) tt " +
|
|
|
" LEFT JOIN " +
|
|
|
" ( " +
|
|
|
" SELECT " +
|
|
|
" i.`user`, " +
|
|
|
" COUNT(1) AS dbtotal " +
|
|
|
" FROM " +
|
|
|
" device.wlyy_patient_health_index i " +
|
|
|
" JOIN wlyy_patient_aim_blood_sugger p ON p.patientcode = i.`user` " +
|
|
|
" 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+
|
|
|
" ) " +
|
|
|
" AND " +
|
|
|
" i.value1 <= p.fbg " +
|
|
|
" AND " +
|
|
|
" i.value1 >= p.fbg_min " +
|
|
|
" AND i.value2 in("+value2+") " +
|
|
|
" AND i.del ='1' " +
|
|
|
" AND i.type = 1 " +
|
|
|
" AND i.record_date >= '"+startDate+"' " +
|
|
|
" AND i.record_date <= '"+endDate+"' " +
|
|
|
" GROUP BY " +
|
|
|
" i.`user` " +
|
|
|
" ) dbt ON tt.`user`=dbt.`user` " +
|
|
|
" WHERE dbt.dbtotal/tt.total > 0.7";
|
|
|
return xtSql;
|
|
|
}
|
|
|
|
|
|
public Map<String,Object> getDeviceStateByTeam(String doctor ,Long teamCode){
|
|
|
String sql ="SELECT " +
|
|
|
" COUNT(1) AS total " +
|
|
|
" FROM " +
|
|
|
" wlyy_patient_device d JOIN " +
|
|
|
" wlyy_track_patient t ON t.patient_code = d.`user` " +
|
|
|
" WHERE " +
|
|
|
" d.category_code = ? " +
|
|
|
" AND t.doctor_code = '"+doctor+"' " +
|
|
|
" AND t.team_code = "+teamCode;
|
|
|
Map<String,Object> rs = new HashedMap();
|
|
|
//血糖仪
|
|
|
List<Map<String,Object>> xt = jdbcTemplate.queryForList(sql,new Object[]{"1"});
|
|
|
if(xt!=null&&xt.size()>0){
|
|
|
rs.put("suggerDevCount",xt.get(0).get("total"));
|
|
|
}else{
|
|
|
rs.put("suggerDevCount",0);
|
|
|
}
|
|
|
//血压计
|
|
|
List<Map<String,Object>> xh = jdbcTemplate.queryForList(sql,new Object[]{"2"});
|
|
|
if(xh!=null&&xh.size()>0){
|
|
|
rs.put("presDevCount",xh.get(0).get("total"));
|
|
|
}else{
|
|
|
rs.put("presDevCount",0);
|
|
|
}
|
|
|
return rs;
|
|
|
}
|
|
|
|
|
|
public String setPatientAim(String patients ,String suggerJson,String presJson){
|
|
|
if(StringUtils.isNotBlank(patients)){
|
|
|
String[] patient = patients.split(",");
|
|
|
for(String p : patient){
|
|
|
net.sf.json.JSONObject sj = net.sf.json.JSONObject.fromObject(suggerJson);
|
|
|
net.sf.json.JSONObject pj = net.sf.json.JSONObject.fromObject(presJson);
|
|
|
PatientAimBloodSugger patientAimBloodSugger = (PatientAimBloodSugger)net.sf.json.JSONObject.toBean(sj,PatientAimBloodSugger.class);
|
|
|
PatientAimBloodPressure patientAimBloodPressure = (PatientAimBloodPressure)net.sf.json.JSONObject.toBean(pj,PatientAimBloodPressure.class);
|
|
|
patientAimBloodSugger.setCode(getCode());
|
|
|
patientAimBloodSugger.setCreateTime(new Date());
|
|
|
patientAimBloodSuggerDao.save(patientAimBloodSugger);
|
|
|
patientAimBloodPressure.setCode(getCode());
|
|
|
patientAimBloodPressure.setCreateTime(new Date());
|
|
|
patientAimBloodPressureDao.save(patientAimBloodPressure);
|
|
|
}
|
|
|
}
|
|
|
return "0";
|
|
|
|
|
|
}
|
|
|
}
|