|
@ -35,8 +35,8 @@ public class DeviceService extends BaseService{
|
|
private PatientDeviceDao patientDeviceDao;
|
|
private PatientDeviceDao patientDeviceDao;
|
|
@Autowired
|
|
@Autowired
|
|
private DeviceDetailDao deviceDetailDao;
|
|
private DeviceDetailDao deviceDetailDao;
|
|
@Autowired
|
|
|
|
private PatientHealthIndexDao patientHealthIndexDao;
|
|
|
|
|
|
// @Autowired
|
|
|
|
// private PatientHealthIndexDao patientHealthIndexDao;
|
|
/*@Autowired
|
|
/*@Autowired
|
|
private BloodSuggerConfiguration bloodSuggerConfiguration;*/
|
|
private BloodSuggerConfiguration bloodSuggerConfiguration;*/
|
|
@Autowired
|
|
@Autowired
|
|
@ -79,6 +79,8 @@ public class DeviceService extends BaseService{
|
|
private PatientAimBloodSuggerDao patientAimBloodSuggerDao;
|
|
private PatientAimBloodSuggerDao patientAimBloodSuggerDao;
|
|
@Autowired
|
|
@Autowired
|
|
private PatientAimBloodPressureDao patientAimBloodPressureDao;
|
|
private PatientAimBloodPressureDao patientAimBloodPressureDao;
|
|
|
|
@Autowired
|
|
|
|
private IotDeviceService iotDeviceService;
|
|
|
|
|
|
private ObjectMapper objectMapper = new ObjectMapper();
|
|
private ObjectMapper objectMapper = new ObjectMapper();
|
|
private Integer aStart;
|
|
private Integer aStart;
|
|
@ -507,8 +509,10 @@ public class DeviceService extends BaseService{
|
|
List<PatientHealthIndex> bloodPressurepatientHealthIndices = new ArrayList<>();
|
|
List<PatientHealthIndex> bloodPressurepatientHealthIndices = new ArrayList<>();
|
|
List<PatientHealthIndex> bloodSuggurpatientHealthIndices = new ArrayList<>();
|
|
List<PatientHealthIndex> bloodSuggurpatientHealthIndices = new ArrayList<>();
|
|
|
|
|
|
bloodPressurepatientHealthIndices = patientHealthIndexDao.findByPatientAndTypeByPage(patientCode,2);
|
|
|
|
bloodSuggurpatientHealthIndices = patientHealthIndexDao.findByPatientAndTypeByPage(patientCode,1);
|
|
|
|
|
|
// bloodPressurepatientHealthIndices = patientHealthIndexDao.findByPatientAndTypeByPage(patientCode,2);
|
|
|
|
// bloodSuggurpatientHealthIndices = patientHealthIndexDao.findByPatientAndTypeByPage(patientCode,1);
|
|
|
|
bloodPressurepatientHealthIndices = iotDeviceService.findByPatientAndTypeByPage(patientCode,2);
|
|
|
|
bloodSuggurpatientHealthIndices = iotDeviceService.findByPatientAndTypeByPage(patientCode,1);
|
|
|
|
|
|
if(!bloodPressurepatientHealthIndices.isEmpty()){
|
|
if(!bloodPressurepatientHealthIndices.isEmpty()){
|
|
stdbloodPressureBbnormalCount = bloodPressurepatientHealthIndices.size();
|
|
stdbloodPressureBbnormalCount = bloodPressurepatientHealthIndices.size();
|
|
@ -538,7 +542,8 @@ public class DeviceService extends BaseService{
|
|
Date end = new Date();
|
|
Date end = new Date();
|
|
Date start = DateUtil.setDateTime(end,-7);
|
|
Date start = DateUtil.setDateTime(end,-7);
|
|
//计算血糖或者血压一周内的异常记录数量
|
|
//计算血糖或者血压一周内的异常记录数量
|
|
int errorCount = patientHealthIndexDao.getCountByTimeAndStatus(start,end,1,patientCode);
|
|
|
|
|
|
// int errorCount = patientHealthIndexDao.getCountByTimeAndStatus(start,end,1,patientCode);
|
|
|
|
int errorCount = iotDeviceService.getCountByTimeAndStatus(start,end,1,patientCode);
|
|
if(errorCount >= 5){//超过5次,记为预警状态
|
|
if(errorCount >= 5){//超过5次,记为预警状态
|
|
patient.setStandardStatus(1);
|
|
patient.setStandardStatus(1);
|
|
//1.4.2加入重点关注逻辑
|
|
//1.4.2加入重点关注逻辑
|
|
@ -776,7 +781,8 @@ public class DeviceService extends BaseService{
|
|
value1 = value[0]; //收缩压
|
|
value1 = value[0]; //收缩压
|
|
}
|
|
}
|
|
}
|
|
}
|
|
List<PatientHealthIndex> list = patientHealthIndexDao.findByType(device.getUser(),deviceSn,value1,Integer.parseInt(type),time);
|
|
|
|
|
|
// List<PatientHealthIndex> list = patientHealthIndexDao.findByType(device.getUser(),deviceSn,value1,Integer.parseInt(type),time);
|
|
|
|
List<PatientHealthIndex> list = iotDeviceService.findByType(device.getUser(),deviceSn,value1,Integer.parseInt(type),time);
|
|
if(list!=null&&list.size()>0){
|
|
if(list!=null&&list.size()>0){
|
|
DeviceInfo deviceInfo = new DeviceInfo();
|
|
DeviceInfo deviceInfo = new DeviceInfo();
|
|
deviceInfo.setDeviceData(json.toString());
|
|
deviceInfo.setDeviceData(json.toString());
|
|
@ -833,7 +839,8 @@ public class DeviceService extends BaseService{
|
|
default:
|
|
default:
|
|
throw new Exception("Can not support the metric!");
|
|
throw new Exception("Can not support the metric!");
|
|
}
|
|
}
|
|
obj = patientHealthIndexDao.save(obj);
|
|
|
|
|
|
// obj = patientHealthIndexDao.save(obj);
|
|
|
|
obj = iotDeviceService.save(obj);
|
|
return obj;
|
|
return obj;
|
|
} else {
|
|
} else {
|
|
DeviceInfo deviceInfo = new DeviceInfo();
|
|
DeviceInfo deviceInfo = new DeviceInfo();
|
|
@ -909,7 +916,8 @@ public class DeviceService extends BaseService{
|
|
throw new Exception("This device is not relate patient!");
|
|
throw new Exception("This device is not relate patient!");
|
|
}
|
|
}
|
|
|
|
|
|
patientHealthIndexDao.save(obj);
|
|
|
|
|
|
// patientHealthIndexDao.save(obj);
|
|
|
|
iotDeviceService.save(obj);
|
|
|
|
|
|
return obj;
|
|
return obj;
|
|
}
|
|
}
|
|
@ -956,16 +964,18 @@ public class DeviceService extends BaseService{
|
|
msgContent += patient.getName() + "血糖异常(" + value1 + "mmol/L),请处理";
|
|
msgContent += patient.getName() + "血糖异常(" + value1 + "mmol/L),请处理";
|
|
|
|
|
|
//体征异常,更新体征数据状态
|
|
//体征异常,更新体征数据状态
|
|
data.setStatus(1);
|
|
|
|
patientHealthIndexDao.save(data);
|
|
|
|
|
|
// data.setStatus(1);
|
|
|
|
// patientHealthIndexDao.save(data);
|
|
|
|
iotDeviceService.updateStatus(data);
|
|
}
|
|
}
|
|
} else { //餐前
|
|
} else { //餐前
|
|
if (!checkHealthIndex(NumberUtils.toDouble(value1), maxValueBefore, minValueBefore)) {
|
|
if (!checkHealthIndex(NumberUtils.toDouble(value1), maxValueBefore, minValueBefore)) {
|
|
msgContent += patient.getName() + "血糖异常(" + value1 + "mmol/L),请处理";
|
|
msgContent += patient.getName() + "血糖异常(" + value1 + "mmol/L),请处理";
|
|
|
|
|
|
//体征异常,更新体征数据状态
|
|
//体征异常,更新体征数据状态
|
|
data.setStatus(1);
|
|
|
|
patientHealthIndexDao.save(data);
|
|
|
|
|
|
// data.setStatus(1);
|
|
|
|
// patientHealthIndexDao.save(data);
|
|
|
|
iotDeviceService.updateStatus(data);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@ -998,8 +1008,9 @@ public class DeviceService extends BaseService{
|
|
msgContent = patient.getName() + "血压异常(舒张压 " + value2 + "mmHg、收缩压 " + value1 + "mmHg),请处理";
|
|
msgContent = patient.getName() + "血压异常(舒张压 " + value2 + "mmHg、收缩压 " + value1 + "mmHg),请处理";
|
|
|
|
|
|
//体征异常,更新体征数据状态
|
|
//体征异常,更新体征数据状态
|
|
data.setStatus(1);
|
|
|
|
patientHealthIndexDao.save(data);
|
|
|
|
|
|
// data.setStatus(1);
|
|
|
|
// patientHealthIndexDao.save(data);
|
|
|
|
iotDeviceService.updateStatus(data);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@ -1205,96 +1216,4 @@ public class DeviceService extends BaseService{
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/******************************体征上传 start**************************************************/
|
|
|
|
private String bloodSugarUnit = "mmol/L";
|
|
|
|
private String bloodPressureUnit = "mmHg";
|
|
|
|
private String pulseUnit = "bpm";
|
|
|
|
private String heightUnit = "cm";
|
|
|
|
private String weightUnit = "kg";
|
|
|
|
private String bmiUnit = "kg/m^2";
|
|
|
|
private String waistUnit = "cm";
|
|
|
|
|
|
|
|
public void upload(PatientDevice patientDevice,PatientHealthIndex obj,String userType){
|
|
|
|
com.alibaba.fastjson.JSONObject json = new com.alibaba.fastjson.JSONObject();
|
|
|
|
if(patientDevice!=null){
|
|
|
|
//未绑定居民
|
|
|
|
Patient patient = patientDao.findByCode(patientDevice.getUser());
|
|
|
|
json.put("idcard",patient.getIdcard());
|
|
|
|
json.put("username",patient.getName());
|
|
|
|
json.put("usercode",patient.getCode());
|
|
|
|
json.put("device_name",patientDevice.getDeviceName());
|
|
|
|
json.put("device_model",patientDevice.getDeviceName());
|
|
|
|
}
|
|
|
|
json.put("sn",obj.getDeviceSn());
|
|
|
|
json.put("ext_code",userType);
|
|
|
|
|
|
|
|
|
|
|
|
com.alibaba.fastjson.JSONArray jsonArray = new com.alibaba.fastjson.JSONArray();
|
|
|
|
com.alibaba.fastjson.JSONObject js = new com.alibaba.fastjson.JSONObject();
|
|
|
|
js.put("measure_time",obj.getRecordDate());
|
|
|
|
switch (obj.getType()){
|
|
|
|
case 1:
|
|
|
|
//血糖
|
|
|
|
js.put("blood_sugar",obj.getValue1());
|
|
|
|
js.put("blood_sugar_unit",bloodSugarUnit);
|
|
|
|
js.put("blood_sugar_result",obj.getValue2());
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
//血压
|
|
|
|
js.put("systolic",obj.getValue1());
|
|
|
|
js.put("systolic_unit",bloodPressureUnit);
|
|
|
|
js.put("diastolic",obj.getValue2());
|
|
|
|
js.put("diastolic_unit",bloodPressureUnit);
|
|
|
|
if(StringUtils.isNotBlank(obj.getValue3())){
|
|
|
|
js.put("pulse",obj.getValue3());
|
|
|
|
js.put("pulse_unit",pulseUnit);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
//体重/身高/BMI
|
|
|
|
js.put("height",obj.getValue1());
|
|
|
|
js.put("height_unit",heightUnit);
|
|
|
|
js.put("weight",obj.getValue2());
|
|
|
|
js.put("weight_unit",weightUnit);
|
|
|
|
if(StringUtils.isNotBlank(obj.getValue3())){
|
|
|
|
js.put("bmi",obj.getValue3());
|
|
|
|
js.put("bmi_unit",bmiUnit);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
//腰围
|
|
|
|
js.put("waist",obj.getValue1());
|
|
|
|
js.put("waist_unit",waistUnit);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
jsonArray.add(js);
|
|
|
|
json.put("data",jsonArray);
|
|
|
|
|
|
|
|
try {
|
|
|
|
String url = wlyyService + "/iot/upload";
|
|
|
|
|
|
|
|
Map<String, Object> params = new HashedMap();
|
|
|
|
params.put("jsonStr", json.toString());
|
|
|
|
|
|
|
|
HttpResponse response = httpHelper.post(url, params);
|
|
|
|
|
|
|
|
if (response != null && response.getStatusCode() == 200) {
|
|
|
|
JSONObject jsonObject = JSONObject.fromObject(response.getBody());
|
|
|
|
if (!"200".equals(jsonObject.optString("status"))) {
|
|
|
|
throw new Exception(jsonObject.optString("msg"));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
throw new Exception("接口调用错误!" + response.getBody());
|
|
|
|
}
|
|
|
|
} catch (Exception ex) {
|
|
|
|
ex.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/******************************体征上传 end****************************************************/
|
|
|
|
}
|
|
}
|