|
@ -93,97 +93,101 @@ public class PatientHealthIndexService {
|
|
* @param obj
|
|
* @param obj
|
|
*/
|
|
*/
|
|
public void handlePatientStandarStatus(DevicePatientHealthIndex obj) {
|
|
public void handlePatientStandarStatus(DevicePatientHealthIndex obj) {
|
|
//连续5次体征值正常,则修改为非预警状态;连续5次异常,修改为预警状态-----START
|
|
|
|
String patientCode = obj.getUser();
|
|
|
|
//患者信息
|
|
|
|
BasePatientDO p = patientDao.findById(patientCode).orElse(null);
|
|
|
|
|
|
try {
|
|
|
|
//连续5次体征值正常,则修改为非预警状态;连续5次异常,修改为预警状态-----START
|
|
|
|
String patientCode = obj.getUser();
|
|
|
|
//患者信息
|
|
|
|
BasePatientDO p = patientDao.findById(patientCode).orElse(null);
|
|
|
|
|
|
String patientsql = "select group_concat(label_code) disease from wlyy_patient_label " +
|
|
|
|
"where patient = '" + p.getId() + "' and label_type = 2 and (label_code = 1 or label_code = 2) GROUP BY patient";
|
|
|
|
|
|
String patientsql = "select group_concat(label_code) disease from wlyy_patient_label " +
|
|
|
|
"where patient = '" + p.getId() + "' and label_type = 2 and (label_code = 1 or label_code = 2) GROUP BY patient";
|
|
|
|
|
|
String patientdisease = "";
|
|
|
|
List<Map<String, Object>> diseases = jdbcTemplate.queryForList(patientsql);
|
|
|
|
if (diseases.size() > 0) {
|
|
|
|
patientdisease = (String) diseases.get(0).get("disease");
|
|
|
|
}
|
|
|
|
|
|
String patientdisease = "";
|
|
|
|
List<Map<String, Object>> diseases = jdbcTemplate.queryForList(patientsql);
|
|
|
|
if (diseases.size() > 0) {
|
|
|
|
patientdisease = (String) diseases.get(0).get("disease");
|
|
|
|
}
|
|
|
|
|
|
int bloodPressureBbnormalCount = 0;//血压异常次数
|
|
|
|
int bloodSuggurBbnormalCount = 0;//血糖异常次数
|
|
|
|
int stdbloodPressureBbnormalCount = 0;//血压次数
|
|
|
|
int stdbloodSuggurBbnormalCount = 0;//血糖次数
|
|
|
|
|
|
int bloodPressureBbnormalCount = 0;//血压异常次数
|
|
|
|
int bloodSuggurBbnormalCount = 0;//血糖异常次数
|
|
|
|
int stdbloodPressureBbnormalCount = 0;//血压次数
|
|
|
|
int stdbloodSuggurBbnormalCount = 0;//血糖次数
|
|
|
|
|
|
List<DevicePatientHealthIndex> bloodPressurepatientHealthIndices = new ArrayList<>();
|
|
|
|
List<DevicePatientHealthIndex> bloodSuggurpatientHealthIndices = new ArrayList<>();
|
|
|
|
|
|
List<DevicePatientHealthIndex> bloodPressurepatientHealthIndices = new ArrayList<>();
|
|
|
|
List<DevicePatientHealthIndex> bloodSuggurpatientHealthIndices = new ArrayList<>();
|
|
|
|
|
|
bloodPressurepatientHealthIndices = patientHealthIndexDao.findByPatientAndTypeByPage(patientCode, 2);
|
|
|
|
bloodSuggurpatientHealthIndices = patientHealthIndexDao.findByPatientAndTypeByPage(patientCode, 1);
|
|
|
|
|
|
bloodPressurepatientHealthIndices = patientHealthIndexDao.findByPatientAndTypeByPage(patientCode, 2);
|
|
|
|
bloodSuggurpatientHealthIndices = patientHealthIndexDao.findByPatientAndTypeByPage(patientCode, 1);
|
|
|
|
|
|
if (!bloodPressurepatientHealthIndices.isEmpty()) {
|
|
|
|
stdbloodPressureBbnormalCount = bloodPressurepatientHealthIndices.size();
|
|
|
|
}
|
|
|
|
|
|
if (!bloodPressurepatientHealthIndices.isEmpty()) {
|
|
|
|
stdbloodPressureBbnormalCount = bloodPressurepatientHealthIndices.size();
|
|
|
|
}
|
|
|
|
|
|
if (!bloodSuggurpatientHealthIndices.isEmpty()) {
|
|
|
|
stdbloodSuggurBbnormalCount = bloodSuggurpatientHealthIndices.size();
|
|
|
|
}
|
|
|
|
|
|
if (!bloodSuggurpatientHealthIndices.isEmpty()) {
|
|
|
|
stdbloodSuggurBbnormalCount = bloodSuggurpatientHealthIndices.size();
|
|
|
|
}
|
|
|
|
|
|
for (DevicePatientHealthIndex index1 : bloodPressurepatientHealthIndices) {
|
|
|
|
if (index1.getStatus() != null && 1 == index1.getStatus()) {
|
|
|
|
bloodPressureBbnormalCount++;
|
|
|
|
|
|
for (DevicePatientHealthIndex index1 : bloodPressurepatientHealthIndices) {
|
|
|
|
if (index1.getStatus() != null && 1 == index1.getStatus()) {
|
|
|
|
bloodPressureBbnormalCount++;
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
for (DevicePatientHealthIndex index2 : bloodSuggurpatientHealthIndices) {
|
|
|
|
if (index2.getStatus() != null && 1 == index2.getStatus()) {
|
|
|
|
bloodSuggurBbnormalCount++;
|
|
|
|
|
|
for (DevicePatientHealthIndex index2 : bloodSuggurpatientHealthIndices) {
|
|
|
|
if (index2.getStatus() != null && 1 == index2.getStatus()) {
|
|
|
|
bloodSuggurBbnormalCount++;
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//连续3次异常,修改用户为预警状态 ||计算血糖或者血压一周内的异常记录数量(超过5次,记为预警状态)
|
|
|
|
Date end = new Date();
|
|
|
|
Date start = DateUtil.setDateTime(end, -7);
|
|
|
|
int errorCount1 = patientHealthIndexDao.getCountByTimeAndStatus(start, end, 1,2, patientCode);
|
|
|
|
int errorCount2 = patientHealthIndexDao.getCountByTimeAndStatus(start, end, 1,1, patientCode);
|
|
|
|
if (bloodPressureBbnormalCount >= 3 || errorCount1 >= 5) {
|
|
|
|
if(p.getStandardStatus()==0){
|
|
|
|
p.setStandardStatus(1);
|
|
|
|
}else if(p.getStandardStatus()==2){
|
|
|
|
p.setStandardStatus(3);
|
|
|
|
|
|
//连续3次异常,修改用户为预警状态 ||计算血糖或者血压一周内的异常记录数量(超过5次,记为预警状态)
|
|
|
|
Date end = new Date();
|
|
|
|
Date start = DateUtil.setDateTime(end, -7);
|
|
|
|
int errorCount1 = patientHealthIndexDao.getCountByTimeAndStatus(start, end, 1,2, patientCode);
|
|
|
|
int errorCount2 = patientHealthIndexDao.getCountByTimeAndStatus(start, end, 1,1, patientCode);
|
|
|
|
if (bloodPressureBbnormalCount >= 3 || errorCount1 >= 5) {
|
|
|
|
if(p.getStandardStatus()==0){
|
|
|
|
p.setStandardStatus(1);
|
|
|
|
}else if(p.getStandardStatus()==2){
|
|
|
|
p.setStandardStatus(3);
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (bloodSuggurBbnormalCount >= 3 || errorCount2 >= 5) {
|
|
|
|
if(p.getStandardStatus()==0){
|
|
|
|
p.setStandardStatus(2);
|
|
|
|
}else if(p.getStandardStatus()==1){
|
|
|
|
p.setStandardStatus(3);
|
|
|
|
|
|
if (bloodSuggurBbnormalCount >= 3 || errorCount2 >= 5) {
|
|
|
|
if(p.getStandardStatus()==0){
|
|
|
|
p.setStandardStatus(2);
|
|
|
|
}else if(p.getStandardStatus()==1){
|
|
|
|
p.setStandardStatus(3);
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//连续5次正常,修改用户为非预警状态
|
|
|
|
if (StringUtils.isNotBlank(patientdisease)) {
|
|
|
|
if ("1".equals(patientdisease)||"3".equals(patientdisease)) {
|
|
|
|
if (stdbloodPressureBbnormalCount == 5) {
|
|
|
|
if(p.getStandardStatus()==1){
|
|
|
|
p.setStandardStatus(0);
|
|
|
|
}else if(p.getStandardStatus()==3){
|
|
|
|
p.setStandardStatus(2);
|
|
|
|
}
|
|
|
|
|
|
//连续5次正常,修改用户为非预警状态
|
|
|
|
if (StringUtils.isNotBlank(patientdisease)) {
|
|
|
|
if ("1".equals(patientdisease)||"3".equals(patientdisease)) {
|
|
|
|
if (stdbloodPressureBbnormalCount == 5) {
|
|
|
|
if(p.getStandardStatus()==1){
|
|
|
|
p.setStandardStatus(0);
|
|
|
|
}else if(p.getStandardStatus()==3){
|
|
|
|
p.setStandardStatus(2);
|
|
|
|
}
|
|
// cancalTrackPatientByDoctor(patientCode);
|
|
// cancalTrackPatientByDoctor(patientCode);
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if ("2".equals(patientdisease)||"3".equals(patientdisease)) {
|
|
|
|
if (stdbloodSuggurBbnormalCount == 5 ) {
|
|
|
|
if(p.getStandardStatus()==2){
|
|
|
|
p.setStandardStatus(0);
|
|
|
|
}else if(p.getStandardStatus()==3){
|
|
|
|
p.setStandardStatus(1);
|
|
|
|
|
|
if ("2".equals(patientdisease)||"3".equals(patientdisease)) {
|
|
|
|
if (stdbloodSuggurBbnormalCount == 5 ) {
|
|
|
|
if(p.getStandardStatus()==2){
|
|
|
|
p.setStandardStatus(0);
|
|
|
|
}else if(p.getStandardStatus()==3){
|
|
|
|
p.setStandardStatus(1);
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
} else {
|
|
|
|
p.setStandardStatus(0);
|
|
|
|
|
|
} else {
|
|
|
|
p.setStandardStatus(0);
|
|
// cancalTrackPatientByDoctor(patientCode);
|
|
// cancalTrackPatientByDoctor(patientCode);
|
|
|
|
}
|
|
|
|
patientDao.save(p);
|
|
|
|
//连续5次体征值正常,则修改为非预警状态;连续5次异常,修改为预警状态-----END
|
|
|
|
}catch (Exception e){
|
|
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
patientDao.save(p);
|
|
|
|
//连续5次体征值正常,则修改为非预警状态;连续5次异常,修改为预警状态-----END
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|