Browse Source

Merge branch 'dev' of yeyi/patient-co-management into dev

chenweida 8 years ago
parent
commit
b422fdd79f

+ 18 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/health/repository/DevicePatientHealthIndexDao.java

@ -83,4 +83,22 @@ public interface DevicePatientHealthIndexDao
	@Query(value = "select a.value1 from device.wlyy_patient_health_index a where a.type=1 and a.user = ?1 and a.id<?2 and a.value2 = ?3 order by a.record_date desc limit 0,1",nativeQuery = true)
	String getPreValue(String user,Long id,String value2);
	@Query(value = "select a.* from device.wlyy_patient_health_index a where a.user = ?1 and a.type = ?2 and a.value2 =?3 and a.record_date >= ?4 and a.record_date <= ?5 and a.del = '1' order by a.record_date desc limit ?6 ,?7",nativeQuery = true)
	List<DevicePatientHealthIndex> findIndexByPatientNative(String patient, int type,String gi_type, Date start, Date end,int currentSize,int pageSize);
	/**
	 * 获取患者某一天的血糖  普通sql写法
	 * @param patient
	 * @param date
	 * @return
	 */
	@Query(value = "select a.* from device.wlyy_patient_health_index a where a.type=1 and a.user = ?1 and DATE_FORMAT(a.record_date,'%Y-%m-%d') = ?2 order by a.record_date,a.id",nativeQuery = true)
	List<DevicePatientHealthIndex> findByDateNative(String patient, String date );
	@Query(value = "select a.* from device.wlyy_patient_health_index a where a.user = ?1 and a.type = ?2 and a.record_date >= ?3 and a.record_date <= ?4 and a.del = '1' order by a.record_date desc limit ?5 ,?6",nativeQuery = true)
	List<DevicePatientHealthIndex> findIndexByPatientNative(String patient, int type, Date start, Date end,int currentSize,int pageSize);
	@Query(value = "select DATE_FORMAT(a.record_date,'%Y-%m-%d') from device.wlyy_patient_health_index a where a.user = ?1 and a.record_date >= ?2 and a.record_date <= ?3 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 ?4,5?",nativeQuery = true)
	List<String> findDateList(String patient,Date start ,Date end,int currentSize,int pageSize);
}

+ 12 - 10
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/PatientHealthIndexService.java

@ -441,7 +441,8 @@ public class PatientHealthIndexService extends BaseService {
        boolean hadData = false;
        Date date = DateUtil.strToDateShort(dateString);
        /***************** 按时间排序 ***************************/
        List<DevicePatientHealthIndex> list = patientHealthIndexDao.findByDate(patient, dateString);
        List<DevicePatientHealthIndex> list = patientHealthIndexDao.findByDateNative(patient, dateString);
        if (list != null && list.size() > 0) {
            obj.put("type",1);
            obj.put("czrq",date);
@ -775,7 +776,7 @@ public class PatientHealthIndexService extends BaseService {
        {
            PageRequest pageRequest = new PageRequest(page, pageSize);
            //根据时间过滤排序
            List<String> dateList = patientHealthIndexDao.findDateList(patient, startDate, endDate, pageRequest);
            List<String> dateList = patientHealthIndexDao.findDateList(patient, startDate, endDate, pageRequest.getPageNumber(),pageRequest.getPageSize());
            if (dateList != null && dateList.size() > 0) {
                for (String dateString : dateList) {
                    DevicePatientHealthIndex obj = getPatientXT(patient, dateString);
@ -788,8 +789,8 @@ public class PatientHealthIndexService extends BaseService {
            // 排序
            Sort sort = new Sort(Direction.DESC, "recordDate");
            PageRequest pageRequest = new PageRequest(page, pageSize, sort);
            Page<DevicePatientHealthIndex> list = patientHealthIndexDao.findIndexByPatient(patient, type, startDate, endDate, pageRequest);
            re = list.getContent();
            List<DevicePatientHealthIndex> list = patientHealthIndexDao.findIndexByPatientNative(patient, type, startDate, endDate, pageRequest.getOffset(),pageRequest.getPageSize());
            re = list;
        }
        return re;
    }
@ -986,12 +987,13 @@ public class PatientHealthIndexService extends BaseService {
        //最新血糖指标
        if (type == 1) {
            DevicePatientHealthIndex obj = patientHealthIndexDao.findLastData(patientCode, 1);
            if (obj != null) {
                String dateString = DateUtil.dateToStrShort(obj.getRecordDate());
                return getPatientXT(patientCode, dateString);
            } else {
                return null;
            }
//            if (obj != null) {
//                String dateString = DateUtil.dateToStrShort(obj.getRecordDate());
//                return getPatientXT(patientCode, dateString);
//            } else {
//                return null;
//            }
            return obj;
        } else if(type ==2) {  //其他指标
            return patientHealthIndexDao.findLastData(patientCode, 2);
        }else{

+ 11 - 3
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/PatientHealthRecordService.java

@ -84,7 +84,7 @@ public class PatientHealthRecordService extends BaseService {
	/**
	 * 按分类查询患者运动记录
	 * @param patient 患者标识
	 * @param page 页码
	 * @param
	 * @param pageSize 分页大小
	 * @return
	 */
@ -209,7 +209,7 @@ public class PatientHealthRecordService extends BaseService {
	/**
	 * 按分类查询患者饮食记录
	 * @param patient 患者标识
	 * @param page 页码
	 * @param
	 * @param pageSize 分页大小
	 * @return
	 */
@ -250,16 +250,24 @@ public class PatientHealthRecordService extends BaseService {
		if (sports != null && sports.getSize() > 0) {
			for (PatientHealthRecordSports temp : sports) {
				jsonObject.put("sports", temp.getSportsName());
			}
				jsonObject.put("sports_time",temp.getSportsTime());
				jsonObject.put("sports_type",temp.getSportsType());
				jsonObject.put("sports_typeName",temp.getSportsTypeName());
				jsonObject.put("czrq",DateUtil.dateToStr(temp.getCzrq(), DateUtil.YYYY_MM_DD));
				jsonObject.put("sortDate",DateUtil.dateToStr(temp.getSortDate(), DateUtil.YYYY_MM_DD));
		}
		}
		if (medication != null) {
			for (PatientHealthRecordMedication temp : medication) {
				jsonObject.put("medication", temp.getMedicinesName());
				jsonObject.put("recordDate",DateUtil.dateToStr(temp.getRecordDate(), DateUtil.YYYY_MM_DD));
			}
		}
		if (diet != null) {
			for (PatientHealthRecordDiet temp : diet) {
				jsonObject.put("diet", temp.getContent());
				jsonObject.put("recordDate",DateUtil.dateToStr(temp.getRecordDate(), DateUtil.YYYY_MM_DD));
				jsonObject.put("images",temp.getImages());
			}
		}
		return jsonObject;

+ 1 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/health/PatientHealthController.java

@ -273,7 +273,7 @@ public class PatientHealthController extends BaseController {
		try {
			Map<String,Object> map = new HashMap<>();
			String patient = getUID();
			com.alibaba.fastjson.JSONObject xt = healthIndexService.findLastBypatient(patient,1);
			DevicePatientHealthIndex xt = healthIndexService.findLastByPatien(patient,1);
			if(xt!=null)
			{
				map.put("xt",xt.toString());