|
@ -30,10 +30,14 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.PageRequest;
|
|
|
import org.springframework.data.domain.Sort;
|
|
|
import org.springframework.data.domain.Sort.Direction;
|
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.jdbc.core.RowMapper;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.sql.ResultSet;
|
|
|
import java.sql.SQLException;
|
|
|
import java.text.DecimalFormat;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
@ -740,14 +744,17 @@ public class PatientHealthIndexService {
|
|
|
public List<Map<String, Object>> findDataByPatient(String sql,String patient,Integer type){
|
|
|
return jdbcTemplate.queryForList(sql, patient, type);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 患者最近填写的健康指标
|
|
|
* @param patient
|
|
|
* @return
|
|
|
*/
|
|
|
public List<DevicePatientHealthIndex> findRecentByPatientIterable(String patient){
|
|
|
return patientHealthIndexDao.findRecentByPatient(patient);
|
|
|
String sql = "select a.* from wlyy_patient_health_index a where a.user = '"+patient+"' " +
|
|
|
"and a.del = '1' order by record_date desc ";
|
|
|
List<DevicePatientHealthIndex> list = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(DevicePatientHealthIndex.class));
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@ -770,13 +777,19 @@ public class PatientHealthIndexService {
|
|
|
* @return
|
|
|
*/
|
|
|
public List<String> findDateListIot(String patient,int type,Date startDate,Date endDate, Long page, Integer size){
|
|
|
return patientHealthIndexDao.findDateList(patient,type,startDate,endDate,page,size);
|
|
|
String sql = "select DATE_FORMAT(a.record_date,'%Y-%m-%d') from wlyy_patient_health_index a where a.user = '"+patient+"'" +
|
|
|
" and a.type="+type+" and a.record_date >= '"+DateUtil.dateToStrLong(startDate)+"' and a.record_date <= '"+DateUtil.dateToStrLong(endDate)+"' " +
|
|
|
"and a.del = '1' group by DATE_FORMAT(a.record_date,'%Y-%m-%d')" +
|
|
|
" order by DATE_FORMAT(a.record_date,'%Y-%m-%d') desc limit "+page+" ,"+size;
|
|
|
return jdbcTemplate.query(sql, new RowMapper<String>() {
|
|
|
@Override
|
|
|
public String mapRow(ResultSet resultSet, int i) throws SQLException {
|
|
|
return null;
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
|
|
|
public List<String> findDateListIot1(String patient,Date startDate,Date endDate, Long page, Integer size){
|
|
|
return patientHealthIndexDao.findDateList(patient,startDate,endDate,page,size);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 按时间查找
|
|
@ -1057,17 +1070,6 @@ public class PatientHealthIndexService {
|
|
|
return "1";
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 按录入时间和患者标识查询健康记录
|
|
|
*
|
|
|
* @param patientCode
|
|
|
* @param date
|
|
|
* @return
|
|
|
*/
|
|
|
public Iterable<DevicePatientHealthIndex> findByPatienDate(String patientCode, int type, Date date) {
|
|
|
return patientHealthIndexDao.findByPatienDate(patientCode, type, date);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 按时间段查询患者健康指标
|
|
@ -1668,7 +1670,7 @@ public class PatientHealthIndexService {
|
|
|
*/
|
|
|
public JSONArray findRecentByPatient(String patient) {
|
|
|
JSONArray array = new JSONArray();
|
|
|
List<DevicePatientHealthIndex> iterable = patientHealthIndexDao.findRecentByPatient(patient);
|
|
|
List<DevicePatientHealthIndex> iterable = findRecentByPatientIterable(patient);
|
|
|
if (iterable != null) {
|
|
|
Iterator<DevicePatientHealthIndex> iterator = iterable.iterator();
|
|
|
while (iterator != null && iterator.hasNext()) {
|
|
@ -1750,13 +1752,22 @@ public class PatientHealthIndexService {
|
|
|
public DevicePatientHealthIndex findLastByPatien(String patientCode, int type) {
|
|
|
//最新血糖指标
|
|
|
if (type == 1) {
|
|
|
DevicePatientHealthIndex obj = patientHealthIndexDao.findLastData(patientCode, 1);
|
|
|
DevicePatientHealthIndex obj = findLastData(patientCode, 1);
|
|
|
return obj;
|
|
|
} else if (type == 2) { //其他指标
|
|
|
return patientHealthIndexDao.findLastData(patientCode, 2);
|
|
|
return findLastData(patientCode, 2);
|
|
|
} else {
|
|
|
return patientHealthIndexDao.findLastData(patientCode, type);
|
|
|
return findLastData(patientCode, type);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public DevicePatientHealthIndex findLastData(String patientCode, int type) {
|
|
|
String sql = "select a.* from wlyy_patient_health_index a where a.user=?1 and a.type=?2 and a.del='1' order by a.record_date desc limit 0,1";
|
|
|
List<DevicePatientHealthIndex> list = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(DevicePatientHealthIndex.class));
|
|
|
if(list.size()>0){
|
|
|
return list.get(0);
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@ -1765,11 +1776,11 @@ public class PatientHealthIndexService {
|
|
|
*/
|
|
|
public List<Map<String, String>> getHealthIndexHistory(String patientCode, int type, int page, int pagesize) throws Exception {
|
|
|
List<Map<String, String>> re = new ArrayList<>();
|
|
|
|
|
|
// 排序
|
|
|
Sort sort = Sort.by(Direction.DESC, "recordDate");
|
|
|
PageRequest pageRequest = PageRequest.of(page, pagesize, sort);
|
|
|
List<DevicePatientHealthIndex> list = patientHealthIndexDao.findIndexByPatient(patientCode, type, pageRequest);
|
|
|
|
|
|
String sql = "select a.* from wlyy_patient_health_index a where a.user = '"+patientCode+"' and a.type = "+type+" " +
|
|
|
"and a.del = '1' order by record_date desc limit "+(page-1)*pagesize+","+pagesize;
|
|
|
|
|
|
List<DevicePatientHealthIndex> list = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(DevicePatientHealthIndex.class));
|
|
|
|
|
|
if (list != null && list.size() > 0) {
|
|
|
for (DevicePatientHealthIndex item : list) {
|
|
@ -1870,13 +1881,16 @@ public class PatientHealthIndexService {
|
|
|
|
|
|
// 排序
|
|
|
List<DevicePatientHealthIndex> list = new ArrayList<>();
|
|
|
|
|
|
|
|
|
String record_date = "";
|
|
|
if(choseDate.length() == 7){
|
|
|
list = patientHealthIndexDao.findByDateMonthAndType(type,patientCode,choseDate,deviceSn);
|
|
|
record_date = " AND DATE_FORMAT(a.record_date,'%Y-%m')='"+choseDate+"' ";
|
|
|
}else{
|
|
|
list = patientHealthIndexDao.findByDateAndType(type,patientCode,choseDate,deviceSn);
|
|
|
record_date = " AND DATE_FORMAT(a.record_date,'%Y-%m-%d')='"+choseDate+"' ";
|
|
|
}
|
|
|
|
|
|
String sql = "SELECT a.* FROM wlyy_patient_health_index a WHERE a.type="+type+" AND a.user='"+patientCode+"' " +record_date+
|
|
|
" AND a.device_sn='"+deviceSn+"' AND a.del='1' ORDER BY a.record_date,a.id";
|
|
|
list = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(DevicePatientHealthIndex.class));
|
|
|
if (list != null && list.size() > 0) {
|
|
|
for (DevicePatientHealthIndex item : list) {
|
|
|
Map<String, String> map = new HashMap<>();
|