|
@ -0,0 +1,2225 @@
|
|
|
package com.yihu.jw.hospital.module.health.service.scheme;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yihu.jw.device.dao.DevicePatientHealthIndexDao;
|
|
|
import com.yihu.jw.device.dao.PatientAimBloodPressureDao;
|
|
|
import com.yihu.jw.device.dao.PatientAimBloodSuggerDao;
|
|
|
import com.yihu.jw.device.dao.PatientAimSportsDao;
|
|
|
import com.yihu.jw.entity.base.device.PatientAimBloodPressure;
|
|
|
import com.yihu.jw.entity.base.device.PatientAimBloodSugger;
|
|
|
import com.yihu.jw.entity.base.device.PatientAimSports;
|
|
|
import com.yihu.jw.entity.base.patient.BasePatientDO;
|
|
|
import com.yihu.jw.entity.care.device.DevicePatientHealthIndex;
|
|
|
import com.yihu.jw.entity.scheme.*;
|
|
|
import com.yihu.jw.entity.scheme.vo.DoctorSchemeBloodPressureVO;
|
|
|
import com.yihu.jw.entity.scheme.vo.DoctorSchemeBloodSuggerVO;
|
|
|
import com.yihu.jw.hospital.module.health.dao.*;
|
|
|
import com.yihu.jw.patient.dao.BasePatientDao;
|
|
|
import com.yihu.jw.restmodel.patient.PatientVO;
|
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.orm.jpa.JpaTransactionManager;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.TransactionDefinition;
|
|
|
import org.springframework.transaction.TransactionStatus;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.transaction.support.DefaultTransactionDefinition;
|
|
|
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.CompletableFuture;
|
|
|
import java.util.concurrent.ExecutionException;
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
import java.util.concurrent.Executors;
|
|
|
|
|
|
/**
|
|
|
* 医生监测方案相关业务层方法
|
|
|
*
|
|
|
* @author huangwenjie
|
|
|
* @date 2017/9/13 15:46
|
|
|
*/
|
|
|
@Service
|
|
|
@Transactional
|
|
|
public class DoctorSchemeService {
|
|
|
private static Logger logger = LoggerFactory.getLogger(DoctorSchemeService.class);
|
|
|
|
|
|
@Autowired
|
|
|
JdbcTemplate jdbcTemplate;
|
|
|
|
|
|
@Autowired
|
|
|
private DoctrorSchemeBloodSuggerDao doctroSchemeBloodSuggerDao;
|
|
|
|
|
|
@Autowired
|
|
|
private DoctoreSchemeBloodPressureDao doctoreSchemeBloodPressureDao;
|
|
|
|
|
|
@Autowired
|
|
|
private JpaTransactionManager transactionManager;
|
|
|
|
|
|
@Autowired
|
|
|
private PatientSchemeListDao patientSchemeListDao;
|
|
|
|
|
|
@Autowired
|
|
|
private BasePatientDao patientDao;
|
|
|
|
|
|
@Autowired
|
|
|
private DevicePatientHealthIndexDao devicePatientHealthIndexDao;
|
|
|
|
|
|
@Autowired
|
|
|
private PatientAimBloodSuggerDao patientAimBloodSuggerDao;
|
|
|
|
|
|
@Autowired
|
|
|
private PatientAimBloodPressureDao patientAimBloodPressureDao;
|
|
|
|
|
|
@Autowired
|
|
|
private DoctorSwitchDao doctorSwitchDao;
|
|
|
|
|
|
@Autowired
|
|
|
private TrackPatientDao trackPatientDao;
|
|
|
|
|
|
@Autowired
|
|
|
private PatientAimSportsDao patientAimSportsDao;
|
|
|
|
|
|
@Value("${im.data_base_name}")
|
|
|
private String im_dataBase_name;
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 根据团队CODE/居民标签/病情/设备绑定状态查询团队具名CODE列表
|
|
|
*
|
|
|
* @param teamCode 团队CODE
|
|
|
* @param disease 病情
|
|
|
* @param diseaseCondition 居民标签
|
|
|
* @param deviceType 设备绑定状态
|
|
|
* @return
|
|
|
* @author huangwenjie
|
|
|
* @date 2017/9/13 16:23
|
|
|
*/
|
|
|
public List<String> getPatientsByDiseaseConditionDiseaseDeviceType(String teamCode, Integer disease, String diseaseCondition, Integer deviceType, String doctorcode, String trackFlag) throws Exception {
|
|
|
String sql = "SELECT a.id\n" +
|
|
|
"FROM base_patient a \n" +
|
|
|
"INNER JOIN base_patient_doctor_relation b ON a.id=b.patient_id\n";
|
|
|
|
|
|
//1.4.2加入跟踪居民过滤
|
|
|
if (StringUtils.isNotBlank(trackFlag) && "1".equals(trackFlag)) {
|
|
|
sql = sql + " INNER JOIN wlyy_track_patient tp ON tp.patient_code = a.id ";
|
|
|
}
|
|
|
if (-1 != deviceType) {
|
|
|
sql = sql + " LEFT JOIN wlyy_patient_device dev on dev.user = a.id ";
|
|
|
}
|
|
|
sql += "WHERE 1=1\n";
|
|
|
|
|
|
//疾病类型,-1全部,0健康,1高血压,2糖尿病,3高血压+糖尿病
|
|
|
if (-1 == disease) {
|
|
|
sql += " AND a.disease IN ('1','2','1,2','2,1') ";
|
|
|
} else {
|
|
|
if (disease == 3) {
|
|
|
sql += " AND a.disease IN ('1,2','2,1') ";
|
|
|
} else {
|
|
|
sql += " and a.disease ='" + disease + "' ";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (StringUtils.isNotBlank(diseaseCondition) && !"-1".equals(diseaseCondition)) {
|
|
|
sql += " AND a.disease_condition IN (" + diseaseCondition + ") ";
|
|
|
}
|
|
|
|
|
|
if (-1 != deviceType) {
|
|
|
if (0 == deviceType) {
|
|
|
sql = sql + " and dev.user is null ";
|
|
|
} else {
|
|
|
sql = sql + " and dev.user is not null ";
|
|
|
}
|
|
|
}
|
|
|
sql += " AND b.doctor_id ='" + doctorcode + "' ";
|
|
|
//1.4.2加入跟踪居民过滤
|
|
|
if (StringUtils.isNotBlank(trackFlag) && "1".equals(trackFlag)) {
|
|
|
sql += " AND tp.del='1' AND tp.doctor_code = '" + doctorcode + "' ";
|
|
|
}
|
|
|
List<String> result = jdbcTemplate.queryForList(sql, new Object[]{}, String.class);
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取医生的血糖监测方案,根据创建时间降序排序,系统方案放最后
|
|
|
*
|
|
|
* @param doctorcode
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public List<DoctorSchemeBloodSuggerVO> getDoctorScheBloodSuggerList(String doctorcode) throws Exception {
|
|
|
|
|
|
List<DoctorSchemeBloodSuggerVO> result = new ArrayList<>();
|
|
|
|
|
|
HashMap<String, List<DoctorSchemeBloodSugger>> mapresult = new HashMap<>();
|
|
|
|
|
|
LinkedList<String> keys = new LinkedList<>();
|
|
|
|
|
|
List<DoctorSchemeBloodSugger> schemelist = doctroSchemeBloodSuggerDao.getListByDoctorcode(doctorcode);
|
|
|
|
|
|
if (!schemelist.isEmpty()) {
|
|
|
|
|
|
for (DoctorSchemeBloodSugger doctorSchemeBloodSugger : schemelist) {
|
|
|
if (keys.contains(doctorSchemeBloodSugger.getCode())) {
|
|
|
mapresult.get(doctorSchemeBloodSugger.getCode()).add(doctorSchemeBloodSugger);
|
|
|
} else {
|
|
|
List<DoctorSchemeBloodSugger> list = new ArrayList<>();
|
|
|
list.add(doctorSchemeBloodSugger);
|
|
|
mapresult.put(doctorSchemeBloodSugger.getCode(), list);
|
|
|
keys.add(doctorSchemeBloodSugger.getCode());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
for (String key : keys) {
|
|
|
DoctorSchemeBloodSuggerVO doctorSchemeBloodSuggerVO = new DoctorSchemeBloodSuggerVO();
|
|
|
doctorSchemeBloodSuggerVO.setCode(key);
|
|
|
doctorSchemeBloodSuggerVO.setName(mapresult.get(key).get(0).getName());
|
|
|
doctorSchemeBloodSuggerVO.setContent(mapresult.get(key).get(0).getContent());
|
|
|
doctorSchemeBloodSuggerVO.setList(mapresult.get(key));
|
|
|
result.add(doctorSchemeBloodSuggerVO);
|
|
|
}
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取医生的血压监测方案,根据创建时间降序排序,系统方案放最后
|
|
|
*
|
|
|
* @param doctorcode
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public List<DoctorSchemeBloodPressureVO> getDoctorSchemeBloodPressureList(String doctorcode) throws Exception {
|
|
|
|
|
|
List<DoctorSchemeBloodPressureVO> result = new ArrayList<>();
|
|
|
HashMap<String, List<DoctorSchemeBloodPressure>> mapresult = new HashMap<>();
|
|
|
List<DoctorSchemeBloodPressure> schemelist = doctoreSchemeBloodPressureDao.getListByDoctorcode(doctorcode);
|
|
|
LinkedList<String> keys = new LinkedList<>();
|
|
|
|
|
|
if (!schemelist.isEmpty()) {
|
|
|
for (DoctorSchemeBloodPressure doctorSchemeBloodPressure : schemelist) {
|
|
|
if (keys.contains(doctorSchemeBloodPressure.getCode())) {
|
|
|
mapresult.get(doctorSchemeBloodPressure.getCode()).add(doctorSchemeBloodPressure);
|
|
|
} else {
|
|
|
List<DoctorSchemeBloodPressure> list = new ArrayList<>();
|
|
|
list.add(doctorSchemeBloodPressure);
|
|
|
mapresult.put(doctorSchemeBloodPressure.getCode(), list);
|
|
|
keys.add(doctorSchemeBloodPressure.getCode());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
for (String key : keys) {
|
|
|
DoctorSchemeBloodPressureVO doctorSchemeBloodPressureVO = new DoctorSchemeBloodPressureVO();
|
|
|
doctorSchemeBloodPressureVO.setCode(key);
|
|
|
doctorSchemeBloodPressureVO.setName(mapresult.get(key).get(0).getName());
|
|
|
doctorSchemeBloodPressureVO.setContent(mapresult.get(key).get(0).getContent());
|
|
|
doctorSchemeBloodPressureVO.setList(mapresult.get(key));
|
|
|
result.add(doctorSchemeBloodPressureVO);
|
|
|
}
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 医生保存血糖监测方案
|
|
|
*
|
|
|
* @param data
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public void saveDoctorSchemeBloodSugger(String data) throws Exception {
|
|
|
JSONObject dataObj = JSON.parseObject(data);
|
|
|
List<DoctorSchemeBloodSugger> results = new ArrayList<>();
|
|
|
String code = dataObj.getString("code");
|
|
|
if (StringUtils.isBlank(code)) {
|
|
|
code = UUID.randomUUID().toString();
|
|
|
}
|
|
|
String name = dataObj.getString("name");
|
|
|
String content = dataObj.getString("content");
|
|
|
String doctorcode = dataObj.getString("doctorcode");
|
|
|
JSONArray datalist = dataObj.getJSONArray("list");
|
|
|
|
|
|
for (int i = 0; i < datalist.size(); i++) {
|
|
|
DoctorSchemeBloodSugger doctorSchemeBloodSugger = new DoctorSchemeBloodSugger();
|
|
|
long id = 0;
|
|
|
if (datalist.getJSONObject(i).containsKey("id")) {
|
|
|
id = datalist.getJSONObject(i).getLong("id");
|
|
|
}
|
|
|
if (id != 0) {
|
|
|
doctorSchemeBloodSugger.setId(datalist.getJSONObject(i).getLong("id"));
|
|
|
}
|
|
|
doctorSchemeBloodSugger.setName(name);
|
|
|
doctorSchemeBloodSugger.setCode(code);
|
|
|
doctorSchemeBloodSugger.setDoctorcode(doctorcode);
|
|
|
doctorSchemeBloodSugger.setDayofweek(datalist.getJSONObject(i).getShort("dayofweek"));
|
|
|
doctorSchemeBloodSugger.setBeforeBreakfast(datalist.getJSONObject(i).getShort("beforeBreakfast"));
|
|
|
doctorSchemeBloodSugger.setBeforeBreakfastTime(DateUtil.hhmmStrToTime(datalist.getJSONObject(i).getString("beforeBreakfastTime")));
|
|
|
doctorSchemeBloodSugger.setAfterBreakfast(datalist.getJSONObject(i).getShort("afterBreakfast"));
|
|
|
doctorSchemeBloodSugger.setAfterBreakfastTime(DateUtil.hhmmStrToTime(datalist.getJSONObject(i).getString("afterBreakfastTime")));
|
|
|
doctorSchemeBloodSugger.setBeforeLunch(datalist.getJSONObject(i).getShort("beforeLunch"));
|
|
|
doctorSchemeBloodSugger.setBeforeLunchTime(DateUtil.hhmmStrToTime(datalist.getJSONObject(i).getString("beforeLunchTime")));
|
|
|
doctorSchemeBloodSugger.setAfterLunch(datalist.getJSONObject(i).getShort("afterLunch"));
|
|
|
doctorSchemeBloodSugger.setAfterLunchTime(DateUtil.hhmmStrToTime(datalist.getJSONObject(i).getString("afterLunchTime")));
|
|
|
doctorSchemeBloodSugger.setBeforeDinner(datalist.getJSONObject(i).getShort("beforeDinner"));
|
|
|
doctorSchemeBloodSugger.setBeforeDinnerTime(DateUtil.hhmmStrToTime(datalist.getJSONObject(i).getString("beforeDinnerTime")));
|
|
|
doctorSchemeBloodSugger.setAfterDinner(datalist.getJSONObject(i).getShort("afterDinner"));
|
|
|
doctorSchemeBloodSugger.setAfterDinnerTime(DateUtil.hhmmStrToTime(datalist.getJSONObject(i).getString("afterDinnerTime")));
|
|
|
doctorSchemeBloodSugger.setBeforeSleep(datalist.getJSONObject(i).getShort("beforeSleep"));
|
|
|
doctorSchemeBloodSugger.setBeforeSleepTime(DateUtil.hhmmStrToTime(datalist.getJSONObject(i).getString("beforeSleepTime")));
|
|
|
|
|
|
doctorSchemeBloodSugger.setAlertTag(datalist.getJSONObject(i).getShort("alertTag"));
|
|
|
doctorSchemeBloodSugger.setContent(content);
|
|
|
doctorSchemeBloodSugger.setCreateTime(DateUtil.getNowTimestamp());
|
|
|
doctorSchemeBloodSugger.setDel(0);
|
|
|
results.add(doctorSchemeBloodSugger);
|
|
|
}
|
|
|
if (!results.isEmpty()) {
|
|
|
doctroSchemeBloodSuggerDao.saveAll(results);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 医生保存血压监测方案
|
|
|
*
|
|
|
* @param data
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public void saveDoctorSchemeBloodPressure(String data) throws Exception {
|
|
|
JSONObject dataObj = JSON.parseObject(data);
|
|
|
List<DoctorSchemeBloodPressure> results = new ArrayList<>();
|
|
|
String code = dataObj.getString("code");
|
|
|
if (StringUtils.isBlank(code)) {
|
|
|
code = UUID.randomUUID().toString();
|
|
|
}
|
|
|
String name = dataObj.getString("name");
|
|
|
String content = dataObj.getString("content");
|
|
|
String doctorcode = dataObj.getString("doctorcode");
|
|
|
JSONArray datalist = dataObj.getJSONArray("list");
|
|
|
|
|
|
for (int i = 0; i < datalist.size(); i++) {
|
|
|
DoctorSchemeBloodPressure doctorSchemeBloodPressure = new DoctorSchemeBloodPressure();
|
|
|
long id = 0;
|
|
|
if (datalist.getJSONObject(i).containsKey("id")) {
|
|
|
id = datalist.getJSONObject(i).getLong("id");
|
|
|
}
|
|
|
if (id != 0) {
|
|
|
doctorSchemeBloodPressure.setId(datalist.getJSONObject(i).getLong("id"));
|
|
|
}
|
|
|
doctorSchemeBloodPressure.setName(name);
|
|
|
doctorSchemeBloodPressure.setCode(code);
|
|
|
doctorSchemeBloodPressure.setDoctorcode(doctorcode);
|
|
|
doctorSchemeBloodPressure.setDayofweek(datalist.getJSONObject(i).getShort("dayofweek"));
|
|
|
doctorSchemeBloodPressure.setEarlyMorning(datalist.getJSONObject(i).getShort("earlyMorning"));
|
|
|
doctorSchemeBloodPressure.setEarlyMorningTime(DateUtil.hhmmStrToTime(datalist.getJSONObject(i).getString("earlyMorningTime")));
|
|
|
doctorSchemeBloodPressure.setMorning(datalist.getJSONObject(i).getShort("morning"));
|
|
|
doctorSchemeBloodPressure.setMorningTime(DateUtil.hhmmStrToTime(datalist.getJSONObject(i).getString("morningTime")));
|
|
|
doctorSchemeBloodPressure.setNoon(datalist.getJSONObject(i).getShort("noon"));
|
|
|
doctorSchemeBloodPressure.setNoonTime(DateUtil.hhmmStrToTime(datalist.getJSONObject(i).getString("noonTime")));
|
|
|
doctorSchemeBloodPressure.setAfterNoon(datalist.getJSONObject(i).getShort("afterNoon"));
|
|
|
doctorSchemeBloodPressure.setAfterNoonTime(DateUtil.hhmmStrToTime(datalist.getJSONObject(i).getString("afterNoonTime")));
|
|
|
doctorSchemeBloodPressure.setNight(datalist.getJSONObject(i).getShort("night"));
|
|
|
doctorSchemeBloodPressure.setNightTime(DateUtil.hhmmStrToTime(datalist.getJSONObject(i).getString("nightTime")));
|
|
|
doctorSchemeBloodPressure.setAlertTag(datalist.getJSONObject(i).getShort("alertTag"));
|
|
|
doctorSchemeBloodPressure.setContent(content);
|
|
|
doctorSchemeBloodPressure.setCreateTime(DateUtil.getNowTimestamp());
|
|
|
doctorSchemeBloodPressure.setDel(0);
|
|
|
results.add(doctorSchemeBloodPressure);
|
|
|
}
|
|
|
if (!results.isEmpty()) {
|
|
|
doctoreSchemeBloodPressureDao.saveAll(results);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 医生保存居民监测方案
|
|
|
*
|
|
|
* @param doctorcode
|
|
|
* @param schemecode
|
|
|
* @param patientcodes
|
|
|
* @param type
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
@Transactional
|
|
|
public void savePatientScheme(String doctorcode, String schemecode, String type, String patientcodes) throws Exception {
|
|
|
List<String> patientcodeList = new ArrayList<>();
|
|
|
String[] codes = patientcodes.split(",");
|
|
|
if (patientcodes.contains(",")) {
|
|
|
for (String code : codes) {
|
|
|
patientcodeList.add(code);
|
|
|
}
|
|
|
} else {
|
|
|
patientcodeList.add(patientcodes);
|
|
|
}
|
|
|
|
|
|
if (!patientcodeList.isEmpty()) {
|
|
|
//使用事务控制批量更新
|
|
|
DefaultTransactionDefinition def = new DefaultTransactionDefinition();
|
|
|
def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); // 事物隔离级别,开启新事务
|
|
|
TransactionStatus status = transactionManager.getTransaction(def); // 获得事务状态
|
|
|
try {
|
|
|
for (String patientcode : patientcodeList) {
|
|
|
patientSchemeListDao.delByPatientCode(patientcode, Integer.parseInt(type));
|
|
|
PatientSchemeList patientSchemeListObj = new PatientSchemeList();
|
|
|
patientSchemeListObj.setCode(UUID.randomUUID().toString());
|
|
|
patientSchemeListObj.setPatientcode(patientcode);
|
|
|
patientSchemeListObj.setSchemecode(schemecode);
|
|
|
patientSchemeListObj.setDoctorcode(doctorcode);
|
|
|
patientSchemeListObj.setType(Integer.parseInt(type));
|
|
|
patientSchemeListObj.setCreateTime(DateUtil.getNowTimestamp());
|
|
|
patientSchemeListDao.save(patientSchemeListObj);
|
|
|
}
|
|
|
//事务提交
|
|
|
transactionManager.commit(status);
|
|
|
} catch (Exception ex) {
|
|
|
ex.printStackTrace();
|
|
|
//报错事务回滚
|
|
|
transactionManager.rollback(status);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 医生端-获取慢病管理居民管理端数据
|
|
|
*
|
|
|
* @param teamCode
|
|
|
* @param getcolor
|
|
|
* @param getstands
|
|
|
* @param gethealthindex
|
|
|
* @param startdate
|
|
|
* @param enddate
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject getSlowDiseaseTeaminfos(String teamCode, int getcolor, int getstands, int gethealthindex, String startdate, String enddate, String doctorcode) throws Exception {
|
|
|
List<PatientVO> patients = new ArrayList<>();
|
|
|
String patientsql = "SELECT DISTINCT\n" +
|
|
|
" a.id 'code',\n" +
|
|
|
" a.standard_status ,\n" +
|
|
|
" a.disease,\n" +
|
|
|
" a.disease_condition \n" +
|
|
|
"FROM\n" +
|
|
|
" base_patient a \n" +
|
|
|
" INNER JOIN base_patient_doctor_relation b ON a.id=b.patient_id\n" +
|
|
|
"WHERE 1=1\n" +
|
|
|
"AND a.disease_condition IN('1','2','3')\n" +
|
|
|
"AND a.disease IN ('1','2','1,2','2,1')\n" +
|
|
|
"AND b.doctor_id ='" + doctorcode + "'";
|
|
|
|
|
|
patients = jdbcTemplate.query(patientsql, new BeanPropertyRowMapper(PatientVO.class));
|
|
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
JSONObject green = new JSONObject();//绿标
|
|
|
JSONObject yellow = new JSONObject();//黄标
|
|
|
JSONObject red = new JSONObject();//红标
|
|
|
JSONObject pressure_standard = new JSONObject();//血压预警
|
|
|
JSONObject sugar_standard = new JSONObject();//血糖预警
|
|
|
|
|
|
JSONObject pressure_count = new JSONObject();//血压体征总数
|
|
|
JSONObject pressure_unusual_ount = new JSONObject();//血压体征总数
|
|
|
JSONObject sugar_count = new JSONObject();//血糖体征总数
|
|
|
JSONObject sugar_unusual_count = new JSONObject();//血糖体征总数
|
|
|
|
|
|
int count = patients.size();
|
|
|
//绿标居民
|
|
|
List<PatientVO> green_patients = new ArrayList<>();
|
|
|
//黄标居民
|
|
|
List<PatientVO> yellow_patients = new ArrayList<>();
|
|
|
//红标居民
|
|
|
List<PatientVO> red_patients = new ArrayList<>();
|
|
|
//高血压居民预警居民CODE
|
|
|
List<String> bloodpressure_patientcodes = new ArrayList<>();
|
|
|
//高血糖居民预警居民CODE
|
|
|
List<String> bloodsugar_patientcodes = new ArrayList<>();
|
|
|
|
|
|
if (!patients.isEmpty()) {
|
|
|
for (PatientVO patient : patients) {
|
|
|
//获取居民颜色标签
|
|
|
if (1 == getcolor && patient.getDiseaseCondition() != null) {
|
|
|
switch (patient.getDiseaseCondition()) {
|
|
|
case 0:
|
|
|
green_patients.add(patient);
|
|
|
break;
|
|
|
case 1:
|
|
|
yellow_patients.add(patient);
|
|
|
break;
|
|
|
case 2:
|
|
|
red_patients.add(patient);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//获取预警居民CODES
|
|
|
if (1 == getstands && (patient.getStandardStatus() != null && patient.getStandardStatus() == 1)) {
|
|
|
|
|
|
if (patient.getDisease() != null) {
|
|
|
if ("1".equals(patient.getDisease()) || "1,2".equals(patient.getDisease()) || "2,1".equals(patient.getDisease())) {
|
|
|
bloodpressure_patientcodes.add(patient.getCode());
|
|
|
}
|
|
|
|
|
|
if ("2".equals(patient.getDisease()) || "1,2".equals(patient.getDisease()) || "2,1".equals(patient.getDisease())) {
|
|
|
bloodsugar_patientcodes.add(patient.getCode());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (1 == getcolor) {
|
|
|
result.put("greencount", green_patients.size());
|
|
|
result.put("yellowcount", yellow_patients.size());
|
|
|
result.put("redcount", red_patients.size());
|
|
|
}
|
|
|
|
|
|
if (1 == getstands) {
|
|
|
result.put("pressure_standard", bloodpressure_patientcodes);
|
|
|
result.put("sugar_standard", bloodsugar_patientcodes);
|
|
|
|
|
|
}
|
|
|
if (1 == gethealthindex) {
|
|
|
Date start = DateUtil.strToDate(startdate);
|
|
|
Date end = DateUtil.strToDate(enddate);
|
|
|
// List<DevicePatientHealthIndex> devicePatientHealthIndices = devicePatientHealthIndexDao.findByTeamcodeAndRecordDate(start,end,teamCode,doctorcode);
|
|
|
List<DevicePatientHealthIndex> devicePatientHealthIndices = devicePatientHealthIndexDao.findByDoctor(start, end, doctorcode);
|
|
|
|
|
|
int sugar = 0;
|
|
|
int sugar_unusual = 0;
|
|
|
|
|
|
int pressure = 0;
|
|
|
int pressure_unusual = 0;
|
|
|
|
|
|
if (!devicePatientHealthIndices.isEmpty()) {
|
|
|
for (DevicePatientHealthIndex devicePatientHealthIndex : devicePatientHealthIndices) {
|
|
|
if (1 == devicePatientHealthIndex.getType()) {
|
|
|
sugar++;
|
|
|
if (devicePatientHealthIndex.getStatus() != null && 0 == devicePatientHealthIndex.getStatus()) {
|
|
|
sugar_unusual++;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (2 == devicePatientHealthIndex.getType()) {
|
|
|
pressure++;
|
|
|
if (devicePatientHealthIndex.getStatus() != null && 0 == devicePatientHealthIndex.getStatus()) {
|
|
|
pressure_unusual++;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
result.put("pressure_count", pressure);
|
|
|
result.put("pressure_unusual_count", pressure_unusual);
|
|
|
result.put("sugar_count", sugar);
|
|
|
result.put("sugar_unusual_count", sugar_unusual);
|
|
|
}
|
|
|
|
|
|
//1.4.2 重点关注居民
|
|
|
List<TrackPatient> list = trackPatientDao.findByDoctor(doctorcode, "1");
|
|
|
if (list != null && list.size() > 0) {
|
|
|
result.put("trackPatientCount", list.size());
|
|
|
} else {
|
|
|
result.put("trackPatientCount", 0);
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 删除医生监测方案
|
|
|
*
|
|
|
* @param doctorcode
|
|
|
* @param schemecode
|
|
|
* @param type
|
|
|
*/
|
|
|
@Transactional
|
|
|
public void delDoctorScheme(String doctorcode, String schemecode, String type) throws Exception {
|
|
|
|
|
|
if ("1".equals(type)) {
|
|
|
doctroSchemeBloodSuggerDao.updateDelStatus(1, doctorcode, schemecode);
|
|
|
}
|
|
|
|
|
|
if ("2".equals(type)) {
|
|
|
doctoreSchemeBloodPressureDao.updateDelStatus(1, doctorcode, schemecode);
|
|
|
}
|
|
|
List<PatientSchemeList> list = patientSchemeListDao.findBySchemecode(schemecode);
|
|
|
|
|
|
if (list != null && list.size() > 0) {
|
|
|
patientSchemeListDao.deleteAll(list);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public Map<String, Object> getPatientHealthIndex(String patient, String startDate, String endDate, String type) {
|
|
|
|
|
|
startDate = startDate + " 00:00:00";
|
|
|
endDate = endDate + " 23:59:59";
|
|
|
String highSql = "SELECT " +
|
|
|
" (bf.befHighCount + aft.aftHighCount) AS highCount " +
|
|
|
" FROM " +
|
|
|
" ( " +
|
|
|
" SELECT " +
|
|
|
" COUNT(1) AS befHighCount " +
|
|
|
" FROM " +
|
|
|
" device.wlyy_patient_health_index i " +
|
|
|
" WHERE " +
|
|
|
" i.type = '1' " +
|
|
|
" AND i.del = '1' " +
|
|
|
" AND i.value2 in(1,3,5,7) " +
|
|
|
" AND i.value1 > 7 " +
|
|
|
" AND i.record_date >='" + startDate + "'" +
|
|
|
" AND i.record_date <='" + endDate + "'" +
|
|
|
" AND i.user ='" + patient + "'" +
|
|
|
" ) bf, " +
|
|
|
" ( " +
|
|
|
" SELECT " +
|
|
|
" COUNT(1) AS aftHighCount " +
|
|
|
" FROM " +
|
|
|
" device.wlyy_patient_health_index i " +
|
|
|
" WHERE " +
|
|
|
" i.type = '1' " +
|
|
|
" AND i.del = '1' " +
|
|
|
" AND i.value2 in(2,4,6) " +
|
|
|
" AND i.value1 > 11.1 " +
|
|
|
" AND i.record_date >='" + startDate + "'" +
|
|
|
" AND i.record_date <='" + endDate + "'" +
|
|
|
" AND i.user ='" + patient + "'" +
|
|
|
" ) aft";
|
|
|
String stdSql = "SELECT " +
|
|
|
" (bf.befHighCount + aft.aftHighCount) AS stdCount " +
|
|
|
" FROM " +
|
|
|
" ( " +
|
|
|
" SELECT " +
|
|
|
" COUNT(1) AS befHighCount " +
|
|
|
" FROM " +
|
|
|
" device.wlyy_patient_health_index i " +
|
|
|
" WHERE " +
|
|
|
" i.type = '1' " +
|
|
|
" AND i.del = '1' " +
|
|
|
" AND i.value2 in(1,3,5,7) " +
|
|
|
" AND i.value1 <= 7 " +
|
|
|
" AND i.value1 >= 4 " +
|
|
|
" AND i.record_date >='" + startDate + "'" +
|
|
|
" AND i.record_date <='" + endDate + "'" +
|
|
|
" AND i.user ='" + patient + "'" +
|
|
|
" ) bf, " +
|
|
|
" ( " +
|
|
|
" SELECT " +
|
|
|
" COUNT(1) AS aftHighCount " +
|
|
|
" FROM " +
|
|
|
" device.wlyy_patient_health_index i " +
|
|
|
" WHERE " +
|
|
|
" i.type = '1' " +
|
|
|
" AND i.del = '1' " +
|
|
|
" AND i.value2 in(2,4,6) " +
|
|
|
" AND i.value1 <= 11.1 " +
|
|
|
" AND i.value1 >= 4 " +
|
|
|
" AND i.record_date >='" + startDate + "'" +
|
|
|
" AND i.record_date <='" + endDate + "'" +
|
|
|
" AND i.user ='" + patient + "'" +
|
|
|
" ) aft";
|
|
|
String lowSql = "SELECT " +
|
|
|
" (bf.befHighCount + aft.aftHighCount) AS lowCount " +
|
|
|
" FROM " +
|
|
|
" ( " +
|
|
|
" SELECT " +
|
|
|
" COUNT(1) AS befHighCount " +
|
|
|
" FROM " +
|
|
|
" device.wlyy_patient_health_index i " +
|
|
|
" WHERE " +
|
|
|
" i.type = '1' " +
|
|
|
" AND i.del = '1' " +
|
|
|
" AND i.value2 in(1,3,5,7) " +
|
|
|
" AND i.value1 < 4 " +
|
|
|
" AND i.record_date >='" + startDate + "'" +
|
|
|
" AND i.record_date <='" + endDate + "'" +
|
|
|
" AND i.user ='" + patient + "'" +
|
|
|
" ) bf, " +
|
|
|
" ( " +
|
|
|
" SELECT " +
|
|
|
" COUNT(1) AS aftHighCount " +
|
|
|
" FROM " +
|
|
|
" device.wlyy_patient_health_index i " +
|
|
|
" WHERE " +
|
|
|
" i.type = '1' " +
|
|
|
" AND i.del = '1' " +
|
|
|
" AND i.value2 in(2,4,6) " +
|
|
|
" AND i.value1 < 4 " +
|
|
|
" AND i.record_date >='" + startDate + "'" +
|
|
|
" AND i.record_date <='" + endDate + "'" +
|
|
|
" AND i.user ='" + patient + "'" +
|
|
|
" ) aft";
|
|
|
|
|
|
String pHighSql = "SELECT " +
|
|
|
" count(1) AS highCount " +
|
|
|
" FROM " +
|
|
|
" device.wlyy_patient_health_index i " +
|
|
|
" WHERE " +
|
|
|
" i.del = '1' " +
|
|
|
" AND i.type = '2' " +
|
|
|
" AND i.value1 > 139 " +
|
|
|
" AND i.record_date >='" + startDate + "'" +
|
|
|
" AND i.record_date <='" + endDate + "'" +
|
|
|
" AND i.user ='" + patient + "'";
|
|
|
String pStdSql = "SELECT " +
|
|
|
" count(1) AS stdCount " +
|
|
|
" FROM " +
|
|
|
" device.wlyy_patient_health_index i " +
|
|
|
" WHERE " +
|
|
|
" i.del = '1' " +
|
|
|
" AND i.type = '2' " +
|
|
|
" AND i.value1 <= 139 " +
|
|
|
" AND i.value1 >= 90 " +
|
|
|
" AND i.record_date >='" + startDate + "'" +
|
|
|
" AND i.record_date <='" + endDate + "'" +
|
|
|
" AND i.user ='" + patient + "'";
|
|
|
String pLowSql = "SELECT " +
|
|
|
" count(1) AS lowCount " +
|
|
|
" FROM " +
|
|
|
" device.wlyy_patient_health_index i " +
|
|
|
" WHERE " +
|
|
|
" i.del = '1' " +
|
|
|
" AND i.type = '2' " +
|
|
|
" AND i.value1 < 90 " +
|
|
|
" AND i.record_date >='" + startDate + "'" +
|
|
|
" AND i.record_date <='" + endDate + "'" +
|
|
|
" AND i.user ='" + patient + "'";
|
|
|
|
|
|
Map<String, Object> rs = new HashedMap();
|
|
|
//0血檀
|
|
|
if ("0".equals(type)) {
|
|
|
//1.高
|
|
|
List<Map<String, Object>> high = jdbcTemplate.queryForList(highSql);
|
|
|
if (high != null && high.size() > 0) {
|
|
|
Map<String, Object> h = high.get(0);
|
|
|
rs.put("highCount", h.get("highCount"));
|
|
|
}
|
|
|
//2.正常
|
|
|
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(lowSql);
|
|
|
if (low != null && low.size() > 0) {
|
|
|
Map<String, Object> lw = low.get(0);
|
|
|
rs.put("lowCount", lw.get("lowCount"));
|
|
|
}
|
|
|
//其他血压
|
|
|
} else {
|
|
|
//1.高
|
|
|
List<Map<String, Object>> high = jdbcTemplate.queryForList(pHighSql);
|
|
|
if (high != null && high.size() > 0) {
|
|
|
Map<String, Object> h = high.get(0);
|
|
|
rs.put("highCount", h.get("highCount"));
|
|
|
}
|
|
|
//2.正常
|
|
|
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(pLowSql);
|
|
|
if (low != null && low.size() > 0) {
|
|
|
Map<String, Object> lw = low.get(0);
|
|
|
rs.put("lowCount", lw.get("lowCount"));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return rs;
|
|
|
}
|
|
|
|
|
|
public Map<String, Object> getPatientHealthIndexNew(String startDate, String endDate, String type, String doctor) {
|
|
|
|
|
|
startDate = startDate + " 00:00:00";
|
|
|
endDate = endDate + " 23:59:59";
|
|
|
String highSql = "SELECT " +
|
|
|
" (bf.befHighCount + aft.aftHighCount) AS highCount " +
|
|
|
" FROM " +
|
|
|
" ( " +
|
|
|
" SELECT " +
|
|
|
" COUNT(1) AS befHighCount " +
|
|
|
" FROM " +
|
|
|
" device.wlyy_patient_health_index i " +
|
|
|
" WHERE " +
|
|
|
" i.type = '1' " +
|
|
|
" AND i.del = '1' " +
|
|
|
" AND i.value2 in(1,3,5,7) " +
|
|
|
" AND i.value1 > 7 " +
|
|
|
" 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.del='1' AND t.doctor_code ='" + doctor + "' )" +
|
|
|
" ) bf, " +
|
|
|
" ( " +
|
|
|
" SELECT " +
|
|
|
" COUNT(1) AS aftHighCount " +
|
|
|
" FROM " +
|
|
|
" device.wlyy_patient_health_index i " +
|
|
|
" WHERE " +
|
|
|
" i.type = '1' " +
|
|
|
" AND i.del = '1' " +
|
|
|
" AND i.value2 in(2,4,6) " +
|
|
|
" AND i.value1 > 11.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.del='1' AND t.doctor_code ='" + doctor + "' )" +
|
|
|
" ) aft";
|
|
|
String stdSql = "SELECT " +
|
|
|
" (bf.befHighCount + aft.aftHighCount) AS stdCount " +
|
|
|
" FROM " +
|
|
|
" ( " +
|
|
|
" SELECT " +
|
|
|
" COUNT(1) AS befHighCount " +
|
|
|
" FROM " +
|
|
|
" device.wlyy_patient_health_index i " +
|
|
|
" WHERE " +
|
|
|
" i.type = '1' " +
|
|
|
" AND i.del = '1' " +
|
|
|
" AND i.value2 in(1,3,5,7) " +
|
|
|
" AND i.value1 <= 7 " +
|
|
|
" AND i.value1 >= 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.del='1' AND t.doctor_code ='" + doctor + "' )" +
|
|
|
" ) bf, " +
|
|
|
" ( " +
|
|
|
" SELECT " +
|
|
|
" COUNT(1) AS aftHighCount " +
|
|
|
" FROM " +
|
|
|
" device.wlyy_patient_health_index i " +
|
|
|
" WHERE " +
|
|
|
" i.type = '1' " +
|
|
|
" AND i.del = '1' " +
|
|
|
" AND i.value2 in(2,4,6) " +
|
|
|
" AND i.value1 <= 11.1 " +
|
|
|
" AND i.value1 >= 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.del='1' AND t.doctor_code ='" + doctor + "' )" +
|
|
|
" ) aft";
|
|
|
String lowSql = "SELECT " +
|
|
|
" (bf.befHighCount + aft.aftHighCount) AS lowCount " +
|
|
|
" FROM " +
|
|
|
" ( " +
|
|
|
" SELECT " +
|
|
|
" COUNT(1) AS befHighCount " +
|
|
|
" FROM " +
|
|
|
" device.wlyy_patient_health_index i " +
|
|
|
" WHERE " +
|
|
|
" i.type = '1' " +
|
|
|
" AND i.del = '1' " +
|
|
|
" AND i.value2 in(1,3,5,7) " +
|
|
|
" AND i.value1 < 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.del='1' AND t.doctor_code ='" + doctor + "' )" +
|
|
|
" ) bf, " +
|
|
|
" ( " +
|
|
|
" SELECT " +
|
|
|
" COUNT(1) AS aftHighCount " +
|
|
|
" FROM " +
|
|
|
" device.wlyy_patient_health_index i " +
|
|
|
" WHERE " +
|
|
|
" i.type = '1' " +
|
|
|
" AND i.del = '1' " +
|
|
|
" AND i.value2 in(2,4,6) " +
|
|
|
" AND i.value1 < 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.del='1' AND t.doctor_code ='" + doctor + "' )" +
|
|
|
" ) aft";
|
|
|
|
|
|
String pHighSql = "SELECT " +
|
|
|
" count(1) AS highCount " +
|
|
|
" FROM " +
|
|
|
" device.wlyy_patient_health_index i " +
|
|
|
" WHERE " +
|
|
|
" i.del = '1' " +
|
|
|
" AND i.type = '2' " +
|
|
|
" 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.del='1' AND t.doctor_code ='" + doctor + "' )";
|
|
|
String pStdSql = "SELECT " +
|
|
|
" count(1) AS stdCount " +
|
|
|
" FROM " +
|
|
|
" device.wlyy_patient_health_index i " +
|
|
|
" WHERE " +
|
|
|
" i.del = '1' " +
|
|
|
" AND i.type = '2' " +
|
|
|
" AND i.value1 <= 139 " +
|
|
|
" 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.del='1' AND t.doctor_code ='" + doctor + "' )";
|
|
|
String pLowSql = "SELECT " +
|
|
|
" count(1) AS lowCount " +
|
|
|
" FROM " +
|
|
|
" device.wlyy_patient_health_index i " +
|
|
|
" WHERE " +
|
|
|
" i.del = '1' " +
|
|
|
" AND i.type = '2' " +
|
|
|
" 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.del='1' AND t.doctor_code ='" + doctor + "')";
|
|
|
|
|
|
Map<String, Object> rs = new HashedMap();
|
|
|
//0血檀
|
|
|
if ("0".equals(type)) {
|
|
|
//1.高
|
|
|
List<Map<String, Object>> high = jdbcTemplate.queryForList(highSql);
|
|
|
if (high != null && high.size() > 0) {
|
|
|
Map<String, Object> h = high.get(0);
|
|
|
rs.put("highCount", h.get("highCount"));
|
|
|
}
|
|
|
//2.正常
|
|
|
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(lowSql);
|
|
|
if (low != null && low.size() > 0) {
|
|
|
Map<String, Object> lw = low.get(0);
|
|
|
rs.put("lowCount", lw.get("lowCount"));
|
|
|
}
|
|
|
//其他血压
|
|
|
} else {
|
|
|
//1.高
|
|
|
List<Map<String, Object>> high = jdbcTemplate.queryForList(pHighSql);
|
|
|
if (high != null && high.size() > 0) {
|
|
|
Map<String, Object> h = high.get(0);
|
|
|
rs.put("highCount", h.get("highCount"));
|
|
|
}
|
|
|
//2.正常
|
|
|
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(pLowSql);
|
|
|
if (low != null && low.size() > 0) {
|
|
|
Map<String, Object> lw = low.get(0);
|
|
|
rs.put("lowCount", lw.get("lowCount"));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return rs;
|
|
|
}
|
|
|
|
|
|
public Map<String, Object> getTrackPatientInfo(String patient) {
|
|
|
Map<String, Object> rs = new HashedMap();
|
|
|
|
|
|
rs.put("wxSport", 0);
|
|
|
|
|
|
String hsql = "SELECT " +
|
|
|
" i.value1 AS weight, " +
|
|
|
" i.value2 AS height, " +
|
|
|
" i.value3 AS BMI " +
|
|
|
" FROM " +
|
|
|
" device.wlyy_patient_health_index i " +
|
|
|
" WHERE " +
|
|
|
" i.del = '1' " +
|
|
|
" AND i.type = '3' " +
|
|
|
" AND i.user ='" + patient + "'" +
|
|
|
" ORDER BY " +
|
|
|
" i.record_date DESC LIMIT 0,1";
|
|
|
String xtSchSql = "SELECT " +
|
|
|
" l.*," +
|
|
|
" s.name " +
|
|
|
" 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 + "'";
|
|
|
String xySchSql = "SELECT " +
|
|
|
" l.*," +
|
|
|
" s.name " +
|
|
|
" 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 + "'";
|
|
|
List<Map<String, Object>> hList = jdbcTemplate.queryForList(hsql);
|
|
|
|
|
|
if (hList != null && hList.size() > 0) {
|
|
|
Map<String, Object> body = hList.get(0);
|
|
|
rs.put("body", body);
|
|
|
} else {
|
|
|
rs.put("body", null);
|
|
|
}
|
|
|
|
|
|
List<Map<String, Object>> xtList = jdbcTemplate.queryForList(xtSchSql);
|
|
|
if (xtList != null && xtList.size() > 0) {
|
|
|
rs.put("sugger", xtList.get(0));
|
|
|
} else {
|
|
|
rs.put("sugger", null);
|
|
|
}
|
|
|
|
|
|
List<Map<String, Object>> xyList = jdbcTemplate.queryForList(xySchSql);
|
|
|
if (xyList != null && xyList.size() > 0) {
|
|
|
rs.put("pressure", xyList.get(0));
|
|
|
} else {
|
|
|
rs.put("pressure", null);
|
|
|
}
|
|
|
|
|
|
return rs;
|
|
|
}
|
|
|
|
|
|
|
|
|
public Map<String, Object> getControlObjectives(String patient) {
|
|
|
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;
|
|
|
}
|
|
|
|
|
|
public List<Map<String, Object>> getBodyInfo(String patient, String startDate, String endDate, Integer page, Integer size) {
|
|
|
startDate = startDate + " 00:00:00";
|
|
|
endDate = endDate + " 23:59:59";
|
|
|
String sql = "SELECT " +
|
|
|
" i.record_date, " +
|
|
|
" i.value1 AS weight, " +
|
|
|
" i.value2 AS height, " +
|
|
|
" i.value3 AS BMI " +
|
|
|
" FROM " +
|
|
|
" device.wlyy_patient_health_index i " +
|
|
|
" WHERE " +
|
|
|
" i.del = '1' " +
|
|
|
" AND i.type = 3 " +
|
|
|
" AND i.`user` = '" + patient + "' " +
|
|
|
" AND i.record_date >='" + startDate + "'" +
|
|
|
" AND i.record_date <='" + endDate + "'" +
|
|
|
" ORDER BY " +
|
|
|
" i.record_date DESC LIMIT " + (page - 1) * size + "," + size;
|
|
|
List<Map<String, Object>> rs = jdbcTemplate.queryForList(sql);
|
|
|
return rs;
|
|
|
}
|
|
|
|
|
|
public String setDoctorSwitchTrackPatient(String doctor, String state) {
|
|
|
DoctorSwitch doctorSwitch = doctorSwitchDao.findByDoctor(doctor);
|
|
|
if (doctorSwitch != null) {
|
|
|
doctorSwitch.setAlertPatientSwitch(state);
|
|
|
} else {
|
|
|
DoctorSwitch dw = new DoctorSwitch();
|
|
|
dw.setDoctor(doctor);
|
|
|
dw.setAlertPatientSwitch(state);
|
|
|
dw.setCreateTime(new Date());
|
|
|
doctorSwitchDao.save(dw);
|
|
|
}
|
|
|
return "0";
|
|
|
}
|
|
|
|
|
|
public Map<String, Object> getDoctorSwitchTrackPatient(String doctor) {
|
|
|
DoctorSwitch doctorSwitch = doctorSwitchDao.findByDoctor(doctor);
|
|
|
Map<String, Object> rs = new HashedMap();
|
|
|
if (doctorSwitch != null) {
|
|
|
rs.put("alertPatientSwitch", doctorSwitch.getAlertPatientSwitch());
|
|
|
} else {
|
|
|
|
|
|
DoctorSwitch dw = new DoctorSwitch();
|
|
|
dw.setDoctor(doctor);
|
|
|
dw.setAlertPatientSwitch("0");
|
|
|
dw.setCreateTime(new Date());
|
|
|
doctorSwitchDao.save(dw);
|
|
|
|
|
|
rs.put("alertPatientSwitch", "0");
|
|
|
}
|
|
|
|
|
|
return rs;
|
|
|
}
|
|
|
|
|
|
public Map<String, Object> getTrackPatientCountTitle(String doctor, String startDate, String endDate) {
|
|
|
// List<TrackPatient> trackPatients = trackPatientDao.findByDoctorCodeAndTeamCodeAndDel(doctor, teamCode, "1");
|
|
|
List<TrackPatient> trackPatients = trackPatientDao.findByDoctor(doctor, "1");
|
|
|
Map<String, Object> rs = new HashedMap();
|
|
|
rs.put("trackPatientCount", trackPatients.size());
|
|
|
String sql = "SELECT " +
|
|
|
" COUNT(1) AS total " +
|
|
|
" FROM " +
|
|
|
" wlyy_track_patient t " +
|
|
|
" WHERE " +
|
|
|
" t.del='1' " +
|
|
|
" AND t.doctor_code = '" + doctor + "' " +
|
|
|
// " AND t.team_code = " + teamCode +
|
|
|
" AND t.create_time >= '" + startDate + " 00:00:00' " +
|
|
|
" AND t.create_time <= '" + endDate + " 23:59:59'";
|
|
|
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
if (list != null && list.size() > 0) {
|
|
|
Long total = (Long) list.get(0).get("total");
|
|
|
rs.put("trackPatientAddCount", total);
|
|
|
} else {
|
|
|
rs.put("trackPatientAddCount", 0);
|
|
|
}
|
|
|
return rs;
|
|
|
|
|
|
}
|
|
|
|
|
|
public Map<String, Object> getTrackPatientServerCount(Long teamCode, String doctor, String startDate, String endDate) {
|
|
|
startDate = startDate + " 00:00:00";
|
|
|
endDate = endDate + " 23:59:59";
|
|
|
|
|
|
Map<String, Object> rs = new HashedMap();
|
|
|
//咨询
|
|
|
rs.put("consultCount", getConsultByteam(teamCode, doctor, startDate, endDate));
|
|
|
//随访
|
|
|
rs.put("followupCount", getFollowByTeam(teamCode, doctor, startDate, endDate));
|
|
|
//获取健康指导
|
|
|
rs.put("guidanceCount", getGuidanceByTeam(teamCode, doctor, startDate, endDate));
|
|
|
//获取待预约
|
|
|
rs.put("reservationCount", getReservationByteam(teamCode, doctor, startDate, endDate));
|
|
|
//续方审核
|
|
|
rs.put("reviewedCount", getPresCount(teamCode, doctor, startDate, endDate));
|
|
|
|
|
|
return rs;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 获取咨询数
|
|
|
*
|
|
|
* @param id
|
|
|
* @param startDate
|
|
|
* @param endDate
|
|
|
* @return
|
|
|
*/
|
|
|
public Long getConsultByteam(Long id, String doctor, String startDate, String endDate) {
|
|
|
String imDataBaseName = im_dataBase_name;
|
|
|
//咨询量
|
|
|
String consult_sql = "SELECT " +
|
|
|
" COUNT(1) consultCount " +
|
|
|
" FROM " +
|
|
|
" wlyy_admin_team_member m JOIN(" +
|
|
|
" SELECT d.id,t.create_time FROM " +
|
|
|
" " + imDataBaseName + ".Topics t, " +
|
|
|
" " + imDataBaseName + ".Participants p, " +
|
|
|
" " + imDataBaseName + ".Doctors d, " +
|
|
|
" Wlyy_Consult_Team c, " +
|
|
|
" " + imDataBaseName + ".Patients s " +
|
|
|
" WHERE " +
|
|
|
" d.id = p.participant_id " +
|
|
|
" AND c.type <> 8 " +
|
|
|
" AND c.consult = t.id " +
|
|
|
" AND c.patient = s.id " +
|
|
|
" AND p.session_id = t.session_id " +
|
|
|
" AND c.admin_team_code =" + id +
|
|
|
" 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.del='1' AND t.doctor_code ='" + doctor + "' AND t.team_code = " + id +
|
|
|
" )" +
|
|
|
" )c ON c.id = m.doctor_code " +
|
|
|
" WHERE " +
|
|
|
" m.team_id = " + id +
|
|
|
" AND m.doctor_code ='" + doctor + "'";
|
|
|
//获取咨詢數
|
|
|
Map<String, Object> consultCout = jdbcTemplate.queryForMap(consult_sql);
|
|
|
if (consultCout.get("consultCount") == null) {
|
|
|
consultCout.put("consultCount", 0);
|
|
|
}
|
|
|
return (Long) consultCout.get("consultCount");
|
|
|
}
|
|
|
|
|
|
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.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) {
|
|
|
reservationCout.put("reservationCount", 0);
|
|
|
}
|
|
|
return (Long) reservationCout.get("reservationCount");
|
|
|
}
|
|
|
|
|
|
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.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) {
|
|
|
articleCout.put("articleCount", 0);
|
|
|
}
|
|
|
return (Long) articleCout.get("articleCount");
|
|
|
}
|
|
|
|
|
|
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.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) {
|
|
|
guidanceCout.put("guidanceCount", 0);
|
|
|
}
|
|
|
return (Long) guidanceCout.get("guidanceCount");
|
|
|
}
|
|
|
|
|
|
|
|
|
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.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) {
|
|
|
followupCout.put("followupCount", 0);
|
|
|
}
|
|
|
return (Long) followupCout.get("followupCount");
|
|
|
}
|
|
|
|
|
|
public Long getPresCount(Long id, String doctor, String startDate, String endDate) {
|
|
|
String sql = "SELECT " +
|
|
|
" count(1) AS reviewedCount " +
|
|
|
" FROM " +
|
|
|
" wlyy_prescription p " +
|
|
|
" JOIN wlyy_prescription_reviewed r ON r.prescription_code = p.`code` " +
|
|
|
" WHERE " +
|
|
|
" r.doctor = '" + doctor + "' " +
|
|
|
" AND p.admin_team_id = " + id +
|
|
|
" AND r.reviewed_time >= '" + startDate + "' " +
|
|
|
" AND r.reviewed_time <= '" + endDate + "' " +
|
|
|
" AND p.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> reviewedCount = jdbcTemplate.queryForMap(sql);
|
|
|
if (reviewedCount.get("reviewedCount") == null) {
|
|
|
reviewedCount.put("reviewedCount", 0);
|
|
|
}
|
|
|
return (Long) reviewedCount.get("reviewedCount");
|
|
|
}
|
|
|
|
|
|
public Map<String, Object> getTrackPatientAimByteam(String doctor, 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.del='1' AND p.doctor_code='" + doctor + "' ) " +
|
|
|
" 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.del='1' AND p.doctor_code='" + doctor + "' ) " +
|
|
|
" AND i.value1 <= cast(p.sbp as SIGNED INTEGER) " +
|
|
|
" AND i.value1 >= cast(p.sbp_min as SIGNED INTEGER) " +
|
|
|
" 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(getXTAimSQL(doctor, startDate, endDate));
|
|
|
Long dbSuggerCount;
|
|
|
if (cqXT != null && cqXT.size() > 0) {
|
|
|
dbSuggerCount = (Long) cqXT.get(0).get("total");
|
|
|
} else {
|
|
|
dbSuggerCount = 0L;
|
|
|
}
|
|
|
|
|
|
rs.put("dbSuggerCount", dbSuggerCount);
|
|
|
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 value1 = "cast(p.fbg as SIGNED INTEGER)";
|
|
|
String value1min = "cast(p.fbg_min as SIGNED INTEGER)";
|
|
|
String value2 = "1,3,5,7";
|
|
|
if ("1".equals(state)) {
|
|
|
value2 = "2,4,6";
|
|
|
value1 = "cast(p.hpg AS SIGNED INTEGER)";
|
|
|
value1min = "cast(p.hpg_min AS SIGNED INTEGER)";
|
|
|
}
|
|
|
//餐前血糖达标数
|
|
|
String xtSql = "SELECT " +
|
|
|
" tt.`user` " +
|
|
|
" 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.del='1' AND p.doctor_code='" + doctor + "' AND p.team_code =" + teamCode +
|
|
|
" ) " +
|
|
|
" AND i.del ='1' " +
|
|
|
" AND i.value2 in(" + value2 + ") " +
|
|
|
" 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.del='1' AND p.doctor_code='" + doctor + "' AND p.team_code =" + teamCode +
|
|
|
" ) " +
|
|
|
" AND " +
|
|
|
" i.value1 <= " + value1 +
|
|
|
" AND " +
|
|
|
" i.value1 >= " + value1min +
|
|
|
" 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 String getXTAimSQL(String doctor, String startDate, String endDate) {
|
|
|
String sql = "SELECT " +
|
|
|
" COUNT(1) total " +
|
|
|
" 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.del = '1' " +
|
|
|
" AND 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.del = '1' " +
|
|
|
" AND p.doctor_code = '" + doctor + "' " +
|
|
|
// " AND p.team_code = " + teamCode +
|
|
|
" ) " +
|
|
|
" AND i.value1 <= cast(p.fbg AS SIGNED INTEGER) " +
|
|
|
" AND i.value1 >= cast(p.fbg_min AS SIGNED INTEGER) " +
|
|
|
" AND i.value2 IN (1,3,5,7) " +
|
|
|
" 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` " +
|
|
|
" 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.del = '1' " +
|
|
|
" AND p.doctor_code = '" + doctor + "' " +
|
|
|
// " AND p.team_code = " + teamCode +
|
|
|
" ) " +
|
|
|
" AND i.value1 <= cast(p.hpg AS SIGNED INTEGER) " +
|
|
|
" AND i.value1 >= cast(p.hpg_min AS SIGNED INTEGER) " +
|
|
|
" AND i.value2 IN (2,4,6) " +
|
|
|
" AND i.del = '1' " +
|
|
|
" AND i.type = 1 " +
|
|
|
" AND i.record_date >= '" + startDate + "' " +
|
|
|
" AND i.record_date <= '" + endDate + "' " +
|
|
|
" GROUP BY " +
|
|
|
" i.`user` " +
|
|
|
" ) cht ON tt.`user` = cht.`user` " +
|
|
|
" WHERE " +
|
|
|
" (IFNULL(dbt.dbtotal,0)+IFNULL(cht.dbtotal,0))/ tt.total > 0.7";
|
|
|
return sql;
|
|
|
}
|
|
|
|
|
|
public Map<String, Object> getDeviceStateByTeam(String doctor) {
|
|
|
String sql = "SELECT " +
|
|
|
" COUNT(1) AS total " +
|
|
|
" FROM " +
|
|
|
" wlyy_patient_device d JOIN " +
|
|
|
" wlyy_track_patient t ON t.patient_code = d.`user` " +
|
|
|
" WHERE " +
|
|
|
" t.del='1' " +
|
|
|
" AND 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 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 Map<String, Object> getPatientScheme(String patient, String type) {
|
|
|
Map<String, Object> rs = new HashedMap();
|
|
|
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);
|
|
|
|
|
|
if (list != null && list.size() > 0) {
|
|
|
rs.put("code", list.get(0).get("code"));
|
|
|
rs.put("name", list.get(0).get("name"));
|
|
|
rs.put("content", list.get(0).get("content"));
|
|
|
rs.put("list", list);
|
|
|
}
|
|
|
return rs;
|
|
|
}
|
|
|
|
|
|
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," +
|
|
|
" p.sex " +
|
|
|
" 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 > 11.1 " +
|
|
|
" AND i.record_date >='" + startDate + "'" +
|
|
|
" AND 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 > 7 " +
|
|
|
" AND i.record_date >='" + startDate + "'" +
|
|
|
" AND 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 " +
|
|
|
" AND i.record_date >='" + startDate + "'" +
|
|
|
" AND 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 < 4 " +
|
|
|
" AND i.record_date >='" + startDate + "'" +
|
|
|
" AND 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 " +
|
|
|
" AND i.value1 <= 11.1 " +
|
|
|
" AND i.record_date >='" + startDate + "'" +
|
|
|
" AND 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 >= 4 " +
|
|
|
" AND i.value1 <= 7 " +
|
|
|
" AND i.record_date >='" + startDate + "'" +
|
|
|
" AND 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)) {
|
|
|
BasePatientDO 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, " +
|
|
|
" p.sex" +
|
|
|
" 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.record_date >='" + startDate + "'" +
|
|
|
" AND 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.record_date >='" + startDate + "'" +
|
|
|
" AND 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.record_date >='" + startDate + "'" +
|
|
|
" AND 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)) {
|
|
|
BasePatientDO 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 Map<String, Object> getDefaultScheme(String type) {
|
|
|
Map<String, Object> rs = new HashedMap();
|
|
|
//1. 血糖2.血压
|
|
|
if ("1".equals(type)) {
|
|
|
String sql = " SELECT p.* FROM wlyy_doctor_scheme_blood_sugger p where p.code='default' and p.del=0 order by p.doctorcode,p.code desc,p.dayofweek asc";
|
|
|
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
rs.put("code", "default");
|
|
|
rs.put("name", list.get(0).get("name"));
|
|
|
rs.put("content", list.get(0).get("content"));
|
|
|
rs.put("list", list);
|
|
|
} else {
|
|
|
String sql = " SELECT p.* FROM wlyy_doctor_scheme_blood_pressure p where p.code='default' and p.del=0 order by p.doctorcode,p.code desc,p.dayofweek asc";
|
|
|
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
rs.put("code", "default");
|
|
|
rs.put("name", list.get(0).get("name"));
|
|
|
rs.put("content", list.get(0).get("content"));
|
|
|
rs.put("list", list);
|
|
|
}
|
|
|
return rs;
|
|
|
}
|
|
|
|
|
|
@Transactional
|
|
|
public String setPatientDefaultScheme(String patient, String type) {
|
|
|
PatientSchemeList pl = new PatientSchemeList();
|
|
|
if ("1".equals(type)) {
|
|
|
List<PatientSchemeList> list = patientSchemeListDao.findByPatientcodeAndSchemecodeAndType(patient, "default", 1);
|
|
|
if (list != null && list.size() > 0) {
|
|
|
return "-1";
|
|
|
}
|
|
|
pl.setType(1);
|
|
|
} else {
|
|
|
List<PatientSchemeList> list = patientSchemeListDao.findByPatientcodeAndSchemecodeAndType(patient, "default", 2);
|
|
|
if (list != null && list.size() > 0) {
|
|
|
return "-1";
|
|
|
}
|
|
|
pl.setType(2);
|
|
|
}
|
|
|
|
|
|
pl.setPatientcode(patient);
|
|
|
pl.setCode(getCode());
|
|
|
|
|
|
pl.setSchemecode("default");
|
|
|
pl.setCreateTime(new Date());
|
|
|
patientSchemeListDao.save(pl);
|
|
|
return "0";
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查看指定医生是否开启分派订单功能
|
|
|
*
|
|
|
* @param doctor
|
|
|
* @return
|
|
|
*/
|
|
|
public String findDispatchStatusByDoctor(String doctor) {
|
|
|
DoctorSwitch doctorSwitch = doctorSwitchDao.findByDoctor(doctor);
|
|
|
if (null == doctorSwitch) {
|
|
|
return "0";
|
|
|
}
|
|
|
return StringUtils.isNotEmpty(doctorSwitch.getDispatchOrderSwitch()) ? doctorSwitch.getDispatchOrderSwitch() : "0";
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 修改指定医生的分派订单开关,不存在该医生的开关,则创建
|
|
|
*
|
|
|
* @param doctor
|
|
|
* @param dispatchOrderStatus
|
|
|
*/
|
|
|
public void updateDispatchStatusByDoctor(String doctor, String dispatchOrderStatus) {
|
|
|
DoctorSwitch doctorSwitch = doctorSwitchDao.findByDoctor(doctor);
|
|
|
if (null != doctorSwitch) {
|
|
|
doctorSwitch.setDispatchOrderSwitch(dispatchOrderStatus);
|
|
|
doctorSwitch.setUpdateTime(new Date());
|
|
|
} else {
|
|
|
doctorSwitch = new DoctorSwitch();
|
|
|
doctorSwitch.setDoctor(doctor);
|
|
|
doctorSwitch.setDispatchOrderSwitch(dispatchOrderStatus);
|
|
|
doctorSwitch.setCreateTime(new Date());
|
|
|
}
|
|
|
doctorSwitchDao.save(doctorSwitch);
|
|
|
}
|
|
|
|
|
|
public JSONObject patientsByDoctorAndLabelCode(String labelCode, String doctorCode) {//1,2改变。
|
|
|
StringBuilder sqlLabelStr = new StringBuilder();
|
|
|
sqlLabelStr.append(" sp.label in ('").append(labelCode.replace(",", "','")).append("') ");
|
|
|
List<PatientVO> patients = new ArrayList<>();
|
|
|
String patientsql = "select * from (select p.code,p.standard_status,p.disease_condition,group_concat(DISTINCT sp.label order by sp.label asc ) as disease from wlyy_patient p " +
|
|
|
" LEFT JOIN wlyy_sign_family s on s.patient = p.code " +
|
|
|
" RIGHT JOIN wlyy_sign_patient_label_info sp on sp.patient = p.code and sp.label_type = 3 and " + sqlLabelStr.toString() + " and sp.status =1" +
|
|
|
" WHERE s.status > 0 and (s.doctor = '" + doctorCode + "' or s.doctor_health ='" + doctorCode + "') GROUP BY p.code " +
|
|
|
"order by sp.label asc)tmp where tmp.disease='" + labelCode + "'";
|
|
|
|
|
|
patients = jdbcTemplate.query(patientsql, new BeanPropertyRowMapper(PatientVO.class));
|
|
|
JSONObject result = new JSONObject();
|
|
|
//绿标居民
|
|
|
List<PatientVO> green_patients = new ArrayList<>();
|
|
|
//黄标居民
|
|
|
List<PatientVO> yellow_patients = new ArrayList<>();
|
|
|
//红标居民
|
|
|
List<PatientVO> red_patients = new ArrayList<>();
|
|
|
if (!patients.isEmpty()) {
|
|
|
for (PatientVO patient : patients) {
|
|
|
//获取居民颜色标签
|
|
|
if (patient.getDiseaseCondition() != null) {
|
|
|
switch (patient.getDiseaseCondition()) {
|
|
|
case 0:
|
|
|
green_patients.add(patient);
|
|
|
break;
|
|
|
|
|
|
case 1:
|
|
|
yellow_patients.add(patient);
|
|
|
break;
|
|
|
|
|
|
case 2:
|
|
|
red_patients.add(patient);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
result.put("greencount", green_patients.size());
|
|
|
result.put("yellowcount", yellow_patients.size());
|
|
|
result.put("redcount", red_patients.size());
|
|
|
// 重点关注居民
|
|
|
List<TrackPatient> list = trackPatientDao.findByDoctorCodeAndDel(doctorCode, "1");
|
|
|
if (list != null && list.size() > 0) {
|
|
|
result.put("trackPatientCount", list.size());
|
|
|
} else {
|
|
|
result.put("trackPatientCount", 0);
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public String getCode() {
|
|
|
return UUID.randomUUID().toString().replaceAll("-", "");
|
|
|
}
|
|
|
|
|
|
public static ExecutorService execute = Executors.newFixedThreadPool(20);
|
|
|
|
|
|
/**
|
|
|
* 获取红黄绿标高血压糖尿病的指标人数
|
|
|
* disease 1高血压,2糖尿病,3高血压+糖尿病
|
|
|
* 预警数量 a.standard_status='1'
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
public HashMap<String, Object> getLabelCount(String doctorId) throws ExecutionException, InterruptedException {
|
|
|
// 高血压预警
|
|
|
String sql01 = "SELECT count(DISTINCT a.id)\n" +
|
|
|
"FROM base_patient a \n" +
|
|
|
"INNER JOIN base_patient_doctor_relation b ON a.id=b.patient_id\n" +
|
|
|
"WHERE 1=1\n" +
|
|
|
"AND a.standard_status='1'\n" +
|
|
|
"AND a.disease_condition IN('1','2','3')\n" +
|
|
|
"AND a.disease IN ('1','3') \n" +
|
|
|
"AND b.doctor_id ='" + doctorId + "'";
|
|
|
// 高血压
|
|
|
String sql02 = "SELECT count(DISTINCT a.id)\n" +
|
|
|
"FROM base_patient a \n" +
|
|
|
"INNER JOIN base_patient_doctor_relation b ON a.id=b.patient_id\n" +
|
|
|
"WHERE 1=1\n" +
|
|
|
"AND a.disease_condition IN('1','2','3')\n" +
|
|
|
"AND a.disease IN ('1','3') \n" +
|
|
|
"AND b.doctor_id ='" + doctorId + "'";
|
|
|
|
|
|
// 糖尿病预警
|
|
|
String sql03 = "SELECT count(DISTINCT a.id)\n" +
|
|
|
"FROM base_patient a \n" +
|
|
|
"INNER JOIN base_patient_doctor_relation b ON a.id=b.patient_id\n" +
|
|
|
"WHERE 1=1\n" +
|
|
|
"AND a.standard_status='1'\n" +
|
|
|
"AND a.disease_condition IN('1','2','3')\n" +
|
|
|
"AND a.disease IN ('2','3') \n" +
|
|
|
"AND b.doctor_id ='" + doctorId + "'";
|
|
|
// 糖尿病
|
|
|
String sql04 = "SELECT count(DISTINCT a.id)\n" +
|
|
|
"FROM base_patient a \n" +
|
|
|
"INNER JOIN base_patient_doctor_relation b ON a.id=b.patient_id\n" +
|
|
|
"WHERE 1=1\n" +
|
|
|
"AND a.disease_condition IN('1','2','3')\n" +
|
|
|
"AND a.disease IN ('2','3') \n" +
|
|
|
"AND b.doctor_id ='" + doctorId + "'";
|
|
|
|
|
|
CompletableFuture<Integer> future01 = CompletableFuture.supplyAsync(() -> {
|
|
|
Integer count = jdbcTemplate.queryForObject(sql01, Integer.class);
|
|
|
return count;
|
|
|
}, execute);
|
|
|
CompletableFuture<Integer> future02 = CompletableFuture.supplyAsync(() -> {
|
|
|
Integer count = jdbcTemplate.queryForObject(sql02, Integer.class);
|
|
|
return count;
|
|
|
}, execute);
|
|
|
CompletableFuture<Integer> future03 = CompletableFuture.supplyAsync(() -> {
|
|
|
Integer count = jdbcTemplate.queryForObject(sql03, Integer.class);
|
|
|
return count;
|
|
|
}, execute);
|
|
|
CompletableFuture<Integer> future04 = CompletableFuture.supplyAsync(() -> {
|
|
|
Integer count = jdbcTemplate.queryForObject(sql04, Integer.class);
|
|
|
return count;
|
|
|
}, execute);
|
|
|
|
|
|
|
|
|
CompletableFuture.allOf(future01, future02, future03, future04).get();
|
|
|
Integer count1 = future01.get();// 高血压预警
|
|
|
Integer count2 = future02.get();// 高血压
|
|
|
Integer count3 = future03.get();// 糖尿病预警
|
|
|
Integer count4 = future04.get();// 糖尿病
|
|
|
|
|
|
HashMap<String, Object> map = new HashMap<>();
|
|
|
map.put("gxy_yj", count1);// 高血压预警
|
|
|
map.put("gxy", count2);// 高血压预警
|
|
|
map.put("tnb_yj", count3);// 高血压预警
|
|
|
map.put("tnb", count4);// 高血压预警
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* labelType 1高血压 2糖尿病
|
|
|
*/
|
|
|
public List<Map<String, Object>> getLabelDetail(String doctorId, String labelType, String searchContent, int page, int pageSize) {
|
|
|
String sql = "SELECTDISTINCT a.id,a.`name`,a.idcard,a.mobile,a.ssc, TIMESTAMPDIFF(YEAR, a.birthday, CURDATE()) AS age ,a.sex \n" +
|
|
|
"FROM base_patient a \n" +
|
|
|
"INNER JOIN base_patient_doctor_relation b ON a.id=b.patient_id\n" +
|
|
|
"WHERE 1=1\n" +
|
|
|
"AND a.disease_condition IN('1','2','3')\n" +
|
|
|
"AND b.doctor_id ='" + doctorId + "'";
|
|
|
if (StringUtils.isNotBlank(labelType)) {
|
|
|
if ("1".equals(labelType)) {
|
|
|
sql += "AND a.disease IN ('1','3') \n";
|
|
|
}
|
|
|
if ("2".equals(labelType)) {
|
|
|
sql += "AND a.disease IN ('2','3') \n";
|
|
|
}
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(searchContent)) {
|
|
|
sql += " AND a.`name` LIKE '%" + searchContent + "%' ";
|
|
|
}
|
|
|
sql += " LIMIT " + (page - 1) * pageSize + "," + pageSize + "";
|
|
|
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
return list;
|
|
|
}
|
|
|
}
|