|
@ -36,6 +36,15 @@ public class HealthIndexService extends BaseService {
|
|
|
|
|
|
private DecimalFormat df = new DecimalFormat("#.0");
|
|
private DecimalFormat df = new DecimalFormat("#.0");
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 统计居民体征数据
|
|
|
|
* @param patient
|
|
|
|
*/
|
|
|
|
public void statistics(String patient){
|
|
|
|
statisticsXT(patient);
|
|
|
|
statisticsXY(patient);
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 获取居民体征数据
|
|
* 获取居民体征数据
|
|
* @param patient
|
|
* @param patient
|
|
@ -85,7 +94,7 @@ public class HealthIndexService extends BaseService {
|
|
"where user = '"+patient+"' " +
|
|
"where user = '"+patient+"' " +
|
|
"and time_type="+timeType+" " +
|
|
"and time_type="+timeType+" " +
|
|
"and blood_type='"+bloodType+"' " +
|
|
"and blood_type='"+bloodType+"' " +
|
|
"limit 1";
|
|
|
|
|
|
"order by czrq desc limit 1";
|
|
List<Map<String,Object>> list2 = jdbcTemplate.queryForList(sql2);
|
|
List<Map<String,Object>> list2 = jdbcTemplate.queryForList(sql2);
|
|
Map<String,Object> map = null;
|
|
Map<String,Object> map = null;
|
|
if(list2.size()>0){
|
|
if(list2.size()>0){
|
|
@ -144,15 +153,15 @@ public class HealthIndexService extends BaseService {
|
|
* @param idcard
|
|
* @param idcard
|
|
*/
|
|
*/
|
|
public List<HealthIndex> xuetang(String patient, String deviceSn, String idcard, List<HealthIndex> list){
|
|
public List<HealthIndex> xuetang(String patient, String deviceSn, String idcard, List<HealthIndex> list){
|
|
String startTime = DateUtil.getStringDateShort()+" 00:00:00";
|
|
|
|
String endTime = DateUtil.getStringDateShort()+" 23:59:59";
|
|
|
|
|
|
Calendar cal = Calendar.getInstance();
|
|
|
|
cal.add(Calendar.DAY_OF_YEAR,-1);
|
|
|
|
String startTime = DateUtil.dateToStrShort(cal.getTime())+" 00:00:00";
|
|
|
|
String endTime = DateUtil.dateToStrShort(cal.getTime())+" 23:59:59";
|
|
HealthIndex healthIndex = healthIndexDao.findByPatientAndType(patient,"1",startTime,endTime);
|
|
HealthIndex healthIndex = healthIndexDao.findByPatientAndType(patient,"1",startTime,endTime);
|
|
if(healthIndex!=null){//判断是否已经生成过数据
|
|
if(healthIndex!=null){//判断是否已经生成过数据
|
|
return list;
|
|
return list;
|
|
}
|
|
}
|
|
|
|
|
|
Calendar cal = Calendar.getInstance();
|
|
|
|
|
|
|
|
String fasting = "07:00:00";
|
|
String fasting = "07:00:00";
|
|
String afterBreakfast = "09:00:00";
|
|
String afterBreakfast = "09:00:00";
|
|
String beforeLunch = "11:00:00";
|
|
String beforeLunch = "11:00:00";
|
|
@ -488,6 +497,200 @@ public class HealthIndexService extends BaseService {
|
|
return list;
|
|
return list;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 统计血压
|
|
|
|
* @param patient
|
|
|
|
* @param type 健康指标类型(1血糖,2血压)
|
|
|
|
// * @param bloodType 测试类型(8舒张压,9收缩压,10心率)
|
|
|
|
* @param timeType 时间类型(1近1个月,2近半年,3近1年)
|
|
|
|
* @param list
|
|
|
|
* @param statisticsList
|
|
|
|
*/
|
|
|
|
private void statisticsXY(String patient,Integer type, Integer timeType,List<HealthIndex> list,List<HealthIndexStatistics> statisticsList){
|
|
|
|
int high1=0,low1=0,normal1=0;//舒张压
|
|
|
|
int high2=0,low2=0,normal2=0;//收缩压
|
|
|
|
int high3=0,low3=0,normal3=0;//心率
|
|
|
|
for (HealthIndex healthIndex:list){
|
|
|
|
//统计数据
|
|
|
|
Double value1 = Double.parseDouble(healthIndex.getValue1());
|
|
|
|
Double value2 = Double.parseDouble(healthIndex.getValue2());
|
|
|
|
Double value3 = Double.parseDouble(healthIndex.getValue3());
|
|
|
|
int flag1 = ETLConstantData.ssy(value1);
|
|
|
|
int flag2 = ETLConstantData.szy(value2);
|
|
|
|
int flag3 = ETLConstantData.heartRate(value3);
|
|
|
|
if(flag1>0){
|
|
|
|
high1 ++;
|
|
|
|
}else if(flag1<0){
|
|
|
|
low1 ++;
|
|
|
|
}else {
|
|
|
|
//正常
|
|
|
|
normal1 ++;
|
|
|
|
}
|
|
|
|
if(flag2>0){
|
|
|
|
high2 ++;
|
|
|
|
}else if(flag2<0){
|
|
|
|
low2 ++;
|
|
|
|
}else {
|
|
|
|
//正常
|
|
|
|
normal2 ++;
|
|
|
|
}
|
|
|
|
if(flag3>0){
|
|
|
|
high3 ++;
|
|
|
|
}else if(flag3<0){
|
|
|
|
low3 ++;
|
|
|
|
}else {
|
|
|
|
//正常
|
|
|
|
normal3 ++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
HealthIndexStatistics healthIndexStatistics1 = new HealthIndexStatistics(patient,high1,normal1,low1,type,8,timeType,new Date());
|
|
|
|
HealthIndexStatistics healthIndexStatistics2 = new HealthIndexStatistics(patient,high2,normal2,low2,type,9,timeType,new Date());
|
|
|
|
HealthIndexStatistics healthIndexStatistics3 = new HealthIndexStatistics(patient,high3,normal3,low3,type,10,timeType,new Date());
|
|
|
|
statisticsList.add(healthIndexStatistics1);
|
|
|
|
statisticsList.add(healthIndexStatistics2);
|
|
|
|
statisticsList.add(healthIndexStatistics3);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 统计血压
|
|
|
|
* @param patient
|
|
|
|
* @param timeType 时间类型(1近1个月,2近半年,3近1年)
|
|
|
|
* @param startTime
|
|
|
|
* @param endTime
|
|
|
|
* @param statisticsList
|
|
|
|
*/
|
|
|
|
private void statisticsXY(String patient,Integer timeType,Date startTime,Date endTime,List<HealthIndexStatistics> statisticsList){
|
|
|
|
List<HealthIndex> list = healthIndexDao.findByUserAndRecordDate(patient,2,startTime,endTime);
|
|
|
|
statisticsXY(patient,2,timeType,list,statisticsList);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 统计血压
|
|
|
|
* @param patient
|
|
|
|
*/
|
|
|
|
private void statisticsXY(String patient){
|
|
|
|
Calendar cal = Calendar.getInstance();
|
|
|
|
cal.add(Calendar.DAY_OF_YEAR,-29);
|
|
|
|
String startMonth = DateUtil.dateToStrShort(cal.getTime())+" 00:00:00";
|
|
|
|
cal.add(Calendar.DAY_OF_YEAR,-(182-30));
|
|
|
|
String startHalfYear = DateUtil.dateToStrShort(cal.getTime())+" 00:00:00";
|
|
|
|
cal.add(Calendar.DAY_OF_YEAR,-(365-182));
|
|
|
|
String startYear = DateUtil.dateToStrShort(cal.getTime())+" 00:00:00";
|
|
|
|
String endTime = DateUtil.getStringDateShort() + " 23:59:59";
|
|
|
|
Date start1 = DateUtil.strToDate(startMonth);
|
|
|
|
Date start2 = DateUtil.strToDate(startHalfYear);
|
|
|
|
Date start3 = DateUtil.strToDate(startYear);
|
|
|
|
Date end = DateUtil.strToDate(endTime);
|
|
|
|
|
|
|
|
List<HealthIndexStatistics> statisticsList = new ArrayList<>();
|
|
|
|
statisticsXY(patient,1,start1,end,statisticsList);
|
|
|
|
statisticsXY(patient,2,start2,end,statisticsList);
|
|
|
|
statisticsXY(patient,3,start3,end,statisticsList);
|
|
|
|
healthIndexStatisticsDao.save(statisticsList);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 统计血糖
|
|
|
|
* @param patient
|
|
|
|
* @param type 健康指标类型(1血糖,2血压)
|
|
|
|
* @param bloodType 测试类型(1空腹血糖 2早餐后血糖 3午餐前血糖 4午餐后血糖 5晚餐前血糖 6晚餐后血糖 7睡前血糖)
|
|
|
|
* @param timeType 时间类型(1近1个月,2近半年,3近1年)
|
|
|
|
* @param list
|
|
|
|
* @param statisticsList
|
|
|
|
*/
|
|
|
|
private void statisticsXT(String patient,Integer type, Integer bloodType, Integer timeType,List<HealthIndex> list,List<HealthIndexStatistics> statisticsList){
|
|
|
|
int high=0,low=0,normal=0;
|
|
|
|
for (HealthIndex healthIndex:list){
|
|
|
|
//统计数据
|
|
|
|
Double value = Double.parseDouble(healthIndex.getValue1());
|
|
|
|
int flag = 0;
|
|
|
|
if(type%2==1){
|
|
|
|
flag = ETLConstantData.xueTangBefore(value);
|
|
|
|
}else{
|
|
|
|
flag = ETLConstantData.xueTangAfter(value);
|
|
|
|
}
|
|
|
|
if(flag>0){
|
|
|
|
high ++;
|
|
|
|
}else if(flag<0){
|
|
|
|
low ++;
|
|
|
|
}else {
|
|
|
|
//正常
|
|
|
|
normal ++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
HealthIndexStatistics healthIndexStatistics = new HealthIndexStatistics(patient,high,normal,low,type,bloodType,timeType,new Date());
|
|
|
|
statisticsList.add(healthIndexStatistics);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 统计血糖
|
|
|
|
* @param patient
|
|
|
|
* @param timeType 时间类型(1近1个月,2近半年,3近1年)
|
|
|
|
* @param startTime
|
|
|
|
* @param endTime
|
|
|
|
* @param statisticsList
|
|
|
|
*/
|
|
|
|
private void statisticsXT(String patient,Integer timeType,Date startTime,Date endTime,List<HealthIndexStatistics> statisticsList){
|
|
|
|
List<HealthIndex> list = healthIndexDao.findByUserAndRecordDate(patient,1,startTime,endTime);
|
|
|
|
List<HealthIndex> list1 = new ArrayList<>();
|
|
|
|
List<HealthIndex> list2 = new ArrayList<>();
|
|
|
|
List<HealthIndex> list3 = new ArrayList<>();
|
|
|
|
List<HealthIndex> list4 = new ArrayList<>();
|
|
|
|
List<HealthIndex> list5 = new ArrayList<>();
|
|
|
|
List<HealthIndex> list6 = new ArrayList<>();
|
|
|
|
List<HealthIndex> list7 = new ArrayList<>();
|
|
|
|
for (HealthIndex healthIndex:list){
|
|
|
|
String value2 = healthIndex.getValue2();
|
|
|
|
if("1".equals(value2)){
|
|
|
|
list1.add(healthIndex);
|
|
|
|
}else if("2".equals(value2)){
|
|
|
|
list2.add(healthIndex);
|
|
|
|
}else if("3".equals(value2)){
|
|
|
|
list3.add(healthIndex);
|
|
|
|
}else if("4".equals(value2)){
|
|
|
|
list4.add(healthIndex);
|
|
|
|
}else if("5".equals(value2)){
|
|
|
|
list5.add(healthIndex);
|
|
|
|
}else if("6".equals(value2)){
|
|
|
|
list6.add(healthIndex);
|
|
|
|
}else if("7".equals(value2)){
|
|
|
|
list7.add(healthIndex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
statisticsXT(patient,1,1,timeType,list1,statisticsList);
|
|
|
|
statisticsXT(patient,1,2,timeType,list2,statisticsList);
|
|
|
|
statisticsXT(patient,1,3,timeType,list3,statisticsList);
|
|
|
|
statisticsXT(patient,1,4,timeType,list4,statisticsList);
|
|
|
|
statisticsXT(patient,1,5,timeType,list5,statisticsList);
|
|
|
|
statisticsXT(patient,1,6,timeType,list6,statisticsList);
|
|
|
|
statisticsXT(patient,1,7,timeType,list7,statisticsList);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 统计血糖
|
|
|
|
* @param patient
|
|
|
|
*/
|
|
|
|
private void statisticsXT(String patient){
|
|
|
|
Calendar cal = Calendar.getInstance();
|
|
|
|
cal.add(Calendar.DAY_OF_YEAR,-29);
|
|
|
|
String startMonth = DateUtil.dateToStrShort(cal.getTime())+" 00:00:00";
|
|
|
|
cal.add(Calendar.DAY_OF_YEAR,-(182-30));
|
|
|
|
String startHalfYear = DateUtil.dateToStrShort(cal.getTime())+" 00:00:00";
|
|
|
|
cal.add(Calendar.DAY_OF_YEAR,-(365-182));
|
|
|
|
String startYear = DateUtil.dateToStrShort(cal.getTime())+" 00:00:00";
|
|
|
|
String endTime = DateUtil.getStringDateShort() + " 23:59:59";
|
|
|
|
Date start1 = DateUtil.strToDate(startMonth);
|
|
|
|
Date start2 = DateUtil.strToDate(startHalfYear);
|
|
|
|
Date start3 = DateUtil.strToDate(startYear);
|
|
|
|
Date end = DateUtil.strToDate(endTime);
|
|
|
|
|
|
|
|
List<HealthIndexStatistics> statisticsList = new ArrayList<>();
|
|
|
|
statisticsXT(patient,1,start1,end,statisticsList);
|
|
|
|
statisticsXT(patient,2,start2,end,statisticsList);
|
|
|
|
statisticsXT(patient,3,start3,end,statisticsList);
|
|
|
|
healthIndexStatisticsDao.save(statisticsList);
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 血压
|
|
* 血压
|
|
* @param patient
|
|
* @param patient
|
|
@ -495,15 +698,15 @@ public class HealthIndexService extends BaseService {
|
|
* @param idcard
|
|
* @param idcard
|
|
*/
|
|
*/
|
|
public List<HealthIndex> xueya(String patient, String deviceSn, String idcard, int age, String sex, List<HealthIndex> list){
|
|
public List<HealthIndex> xueya(String patient, String deviceSn, String idcard, int age, String sex, List<HealthIndex> list){
|
|
String startTime = DateUtil.getStringDateShort()+" 00:00:00";
|
|
|
|
String endTime = DateUtil.getStringDateShort()+" 23:59:59";
|
|
|
|
|
|
Calendar cal = Calendar.getInstance();
|
|
|
|
cal.add(Calendar.DAY_OF_YEAR,-1);
|
|
|
|
String startTime = DateUtil.dateToStrShort(cal.getTime())+" 00:00:00";
|
|
|
|
String endTime = DateUtil.dateToStrShort(cal.getTime())+" 23:59:59";
|
|
HealthIndex healthIndex = healthIndexDao.findByPatientAndType(patient,"2",startTime,endTime);
|
|
HealthIndex healthIndex = healthIndexDao.findByPatientAndType(patient,"2",startTime,endTime);
|
|
if(healthIndex!=null){//判断是否已经生成过数据
|
|
if(healthIndex!=null){//判断是否已经生成过数据
|
|
return list;
|
|
return list;
|
|
}
|
|
}
|
|
|
|
|
|
Calendar cal = Calendar.getInstance();
|
|
|
|
|
|
|
|
int value1,value2,value3,value4,intValue1,intValue2;
|
|
int value1,value2,value3,value4,intValue1,intValue2;
|
|
//140/90mmHg至160/95mmHg之间,不能确定为高血压
|
|
//140/90mmHg至160/95mmHg之间,不能确定为高血压
|
|
//成年人收缩压90-139.舒张压60-89为正常
|
|
//成年人收缩压90-139.舒张压60-89为正常
|
|
@ -588,11 +791,11 @@ public class HealthIndexService extends BaseService {
|
|
high32 += i<halfYear?1:0;
|
|
high32 += i<halfYear?1:0;
|
|
high33 ++;
|
|
high33 ++;
|
|
}
|
|
}
|
|
// else if(flag3<0){
|
|
|
|
// low31 += i<month?1:0;
|
|
|
|
// low31 += i<halfYear?1:0;
|
|
|
|
// low31 ++;
|
|
|
|
// }
|
|
|
|
|
|
else if(flag3<0){
|
|
|
|
low31 += i<month?1:0;
|
|
|
|
low31 += i<halfYear?1:0;
|
|
|
|
low31 ++;
|
|
|
|
}
|
|
else{
|
|
else{
|
|
normal31 += i<month?1:0;
|
|
normal31 += i<month?1:0;
|
|
normal32 += i<halfYear?1:0;
|
|
normal32 += i<halfYear?1:0;
|