|
@ -1,5 +1,6 @@
|
|
|
package com.yihu.wlyy.service.app.health;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.yihu.wlyy.entity.device.PatientDevice;
|
|
|
import com.yihu.wlyy.entity.message.Message;
|
|
@ -395,6 +396,7 @@ public class PatientHealthIndexService extends BaseService {
|
|
|
for (DevicePatientHealthIndex item : list) {
|
|
|
String data = item.getValue1();
|
|
|
String dataType = item.getValue2();
|
|
|
Date recordDate = item.getRecordDate();
|
|
|
if (data != null && dataType != null) {
|
|
|
if (dataType.equals("1")) {
|
|
|
obj.setValue1(data);
|
|
@ -428,6 +430,67 @@ public class PatientHealthIndexService extends BaseService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取患者某天血糖值
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
private com.alibaba.fastjson.JSONObject getPatientXT_Json(String patient, String dateString) {
|
|
|
com.alibaba.fastjson.JSONObject obj = new com.alibaba.fastjson.JSONObject();
|
|
|
obj.put("user",patient);
|
|
|
boolean hadData = false;
|
|
|
Date date = DateUtil.strToDateShort(dateString);
|
|
|
/***************** 按时间排序 ***************************/
|
|
|
List<DevicePatientHealthIndex> list = patientHealthIndexDao.findByDate(patient, dateString);
|
|
|
if (list != null && list.size() > 0) {
|
|
|
obj.put("type",1);
|
|
|
obj.put("czrq",date);
|
|
|
obj.put("recordDate",date);
|
|
|
obj.put("sortDate",date);
|
|
|
for (DevicePatientHealthIndex item : list) {
|
|
|
String data = item.getValue1();
|
|
|
String dataType = item.getValue2();
|
|
|
Date recordDate = item.getRecordDate();
|
|
|
if (data != null && dataType != null) {
|
|
|
if (dataType.equals("1")) {
|
|
|
obj.put("value1",data);
|
|
|
obj.put("time1",recordDate);
|
|
|
hadData = true;
|
|
|
} else if (dataType.equals("2")) {
|
|
|
obj.put("value2",data);
|
|
|
obj.put("time2",recordDate);
|
|
|
hadData = true;
|
|
|
} else if (dataType.equals("3")) {
|
|
|
obj.put("value3",data);
|
|
|
obj.put("time3",recordDate);
|
|
|
hadData = true;
|
|
|
} else if (dataType.equals("4")) {
|
|
|
obj.put("value4",data);
|
|
|
obj.put("time4",recordDate);
|
|
|
hadData = true;
|
|
|
} else if (dataType.equals("5")) {
|
|
|
obj.put("value5",data);
|
|
|
obj.put("time5",recordDate);
|
|
|
hadData = true;
|
|
|
} else if (dataType.equals("6")) {
|
|
|
obj.put("value6",data);
|
|
|
obj.put("time6",recordDate);
|
|
|
hadData = true;
|
|
|
} else if (dataType.equals("7")) {
|
|
|
obj.put("value7",data);
|
|
|
obj.put("time7",recordDate);
|
|
|
hadData = true;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (hadData) {
|
|
|
return obj;
|
|
|
} else {
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 校验指标是否超标,发送消息
|
|
|
*/
|
|
@ -570,9 +633,11 @@ public class PatientHealthIndexService extends BaseService {
|
|
|
case "1": {
|
|
|
obj.setType(1);
|
|
|
String value1 = map.get("gi"); //血糖值
|
|
|
String value2 = map.get("gi_type"); //血糖值类型
|
|
|
String gi_type = map.get("gi_type"); //血糖值类型对应1到7
|
|
|
String recordDate = map.get("recordDate");
|
|
|
obj.setValue1(value1);
|
|
|
obj.setValue2(value2);
|
|
|
obj.setValue2(gi_type);
|
|
|
obj.setRecordDate(DateUtil.strToDateAppendNowTime(recordDate, DateUtil.YYYY_MM_DD_HH_MM_SS));
|
|
|
break;
|
|
|
}
|
|
|
case "2": {
|
|
@ -658,6 +723,35 @@ public class PatientHealthIndexService extends BaseService {
|
|
|
return re;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 按时间段查询患者健康指标
|
|
|
*
|
|
|
* @param type 健康指标类型(1血糖,2血压,3体重,4腰围)
|
|
|
* @param gi_type 血糖就餐时间段(早餐前,早餐后等)
|
|
|
* @param begin 开始时间
|
|
|
* @param end 结束时间
|
|
|
* @return
|
|
|
*/
|
|
|
public List<DevicePatientHealthIndex> findChartByPatient(String patient, int type,int gi_type, String begin, String end) {
|
|
|
List<DevicePatientHealthIndex> re = new ArrayList<>();
|
|
|
|
|
|
Date startDate = DateUtil.strToDate(begin, DateUtil.YYYY_MM_DD_HH_MM_SS);
|
|
|
Date endDate = DateUtil.strToDate(end, DateUtil.YYYY_MM_DD_HH_MM_SS);
|
|
|
if(gi_type != 0){
|
|
|
Sort sort = new Sort(Direction.ASC, "recordDate");
|
|
|
PageRequest pageRequest = new PageRequest(0, 1000, sort);
|
|
|
re = patientHealthIndexDao.findIndexByPatient(patient, type,gi_type+"", startDate, endDate, pageRequest).getContent();
|
|
|
|
|
|
}else{
|
|
|
// 排序
|
|
|
Sort sort = new Sort(Direction.ASC, "recordDate");
|
|
|
PageRequest pageRequest = new PageRequest(0, 1000, sort);
|
|
|
re = patientHealthIndexDao.findIndexByPatient(patient, type, startDate, endDate, pageRequest).getContent();
|
|
|
}
|
|
|
|
|
|
return re;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询指标记录
|
|
|
*
|
|
@ -755,7 +849,7 @@ public class PatientHealthIndexService extends BaseService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询患者最近填写的运动、用药、饮食内容
|
|
|
* 查询患者最近填写的血糖、血压等记录
|
|
|
*
|
|
|
* @param patient
|
|
|
* @return
|
|
@ -773,20 +867,66 @@ public class PatientHealthIndexService extends BaseService {
|
|
|
JSONObject json = new JSONObject();
|
|
|
// 设置健康指标类型(1血糖,2血压,3体重,4腰围)
|
|
|
json.put("type", phi.getType());
|
|
|
// 设置血糖/收缩压/体重/腰围/早餐前空腹
|
|
|
json.put("value1", phi.getValue1());
|
|
|
// 设置舒张压/早餐后血糖
|
|
|
json.put("value2", phi.getValue2());
|
|
|
// 设置午餐前血糖
|
|
|
json.put("value3", phi.getValue3());
|
|
|
// 设置午餐后血糖
|
|
|
json.put("value4", phi.getValue4());
|
|
|
// 设置晚餐前血糖
|
|
|
json.put("value5", phi.getValue5());
|
|
|
// 设置晚餐后血糖
|
|
|
json.put("value6", phi.getValue6());
|
|
|
// 设置睡前血糖
|
|
|
json.put("value7", phi.getValue7());
|
|
|
if(1== phi.getType()&&StringUtils.isNotBlank(phi.getValue2())){
|
|
|
int gi_type = Integer.parseInt(phi.getValue2());
|
|
|
switch (gi_type) {
|
|
|
case 1:
|
|
|
// 设置血糖/收缩压/体重/腰围/早餐前空腹
|
|
|
json.put("value1", phi.getValue1());
|
|
|
json.put("time1",phi.getRecordDate());
|
|
|
break;
|
|
|
case 2:
|
|
|
// 设置舒张压/早餐后血糖
|
|
|
json.put("value2", phi.getValue2());
|
|
|
json.put("time2",phi.getRecordDate());
|
|
|
break;
|
|
|
case 3:
|
|
|
// 设置午餐前血糖
|
|
|
json.put("value3", phi.getValue3());
|
|
|
json.put("time3",phi.getRecordDate());
|
|
|
break;
|
|
|
case 4:
|
|
|
// 设置午餐后血糖
|
|
|
json.put("value4", phi.getValue4());
|
|
|
json.put("time4",phi.getRecordDate());
|
|
|
break;
|
|
|
case 5:
|
|
|
// 设置晚餐前血糖
|
|
|
json.put("value5", phi.getValue5());
|
|
|
json.put("time5",phi.getRecordDate());
|
|
|
break;
|
|
|
case 6:
|
|
|
// 设置晚餐后血糖
|
|
|
json.put("value6", phi.getValue6());
|
|
|
json.put("time6",phi.getRecordDate());
|
|
|
break;
|
|
|
case 7:
|
|
|
// 设置睡前血糖
|
|
|
json.put("value7", phi.getValue7());
|
|
|
json.put("time7",phi.getRecordDate());
|
|
|
break;
|
|
|
}
|
|
|
}else{
|
|
|
json.put("value1",phi.getValue1());
|
|
|
json.put("value2",phi.getValue2());
|
|
|
// 设置午餐前血糖
|
|
|
json.put("value3", phi.getValue3());
|
|
|
// 设置午餐后血糖
|
|
|
json.put("value4", phi.getValue4());
|
|
|
// 设置晚餐前血糖
|
|
|
json.put("value5", phi.getValue5());
|
|
|
// 设置晚餐后血糖
|
|
|
json.put("value6", phi.getValue6());
|
|
|
// 设置睡前血糖
|
|
|
json.put("value7", phi.getValue7());
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
json.put("date", DateUtil.dateToStrShort(phi.getRecordDate()));
|
|
|
array.put(json);
|
|
|
}
|
|
@ -852,11 +992,31 @@ public class PatientHealthIndexService extends BaseService {
|
|
|
} else {
|
|
|
return null;
|
|
|
}
|
|
|
} else { //其他指标
|
|
|
} else if(type ==2) { //其他指标
|
|
|
return patientHealthIndexDao.findLastData(patientCode, 2);
|
|
|
}else{
|
|
|
return patientHealthIndexDao.findLastData(patientCode, type);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public com.alibaba.fastjson.JSONObject findLastBypatient(String patientCode, int type){
|
|
|
if(type==1){
|
|
|
DevicePatientHealthIndex obj = patientHealthIndexDao.findLastData(patientCode, 1);
|
|
|
if (obj != null) {
|
|
|
String dateString = DateUtil.dateToStrShort(obj.getRecordDate());
|
|
|
return getPatientXT_Json(patientCode, dateString);
|
|
|
} else {
|
|
|
return null;
|
|
|
}
|
|
|
}else{
|
|
|
DevicePatientHealthIndex obj = patientHealthIndexDao.findLastData(patientCode, type);
|
|
|
if(obj != null){
|
|
|
return JSON.parseObject(JSON.toJSONString(obj));
|
|
|
}else {
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取患者健康指标历史记录
|