Browse Source

健康指标bug修复

hzp 8 years ago
parent
commit
5eeb2aa662

+ 108 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/SignFamilyMapping.java

@ -0,0 +1,108 @@
package com.yihu.wlyy.entity.patient;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * 家庭签约
 */
@Entity
@Table(name = "wlyy_sign_family_mapping")
public class SignFamilyMapping extends IdEntity {
	// 签约标识
	private String code;
	// 映射ID
	private String proId;
	// 身份证
	private String idcard;
	// 创建时间
	private Date createTime;
	// 是否需要更新 0否 1是
	private String needUpdate;
	// 更新时间
	private Date updateTime;
	// 是否需要上传 0否 1是
	private String needUpload;
	// 上传时间
	private Date uploadTime;
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	@Column(name = "pro_id")
	public String getProId() {
		return proId;
	}
	public void setProId(String proId) {
		this.proId = proId;
	}
	@Column(name = "need_update")
	public String getNeedUpdate() {
		return needUpdate;
	}
	public void setNeedUpdate(String needUpdate) {
		this.needUpdate = needUpdate;
	}
	@Column(name = "create_time")
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getCreateTime() {
		return createTime;
	}
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	@Column(name = "update_time")
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getUpdateTime() {
		return updateTime;
	}
	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}
	@Column(name = "upload_time")
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getUploadTime() {
		return uploadTime;
	}
	public void setUploadTime(Date uploadTime) {
		this.uploadTime = uploadTime;
	}
	public String getIdcard() {
		return idcard;
	}
	public void setIdcard(String idcard) {
		this.idcard = idcard;
	}
	@Column(name = "need_upload")
	public String getNeedUpload() {
		return needUpload;
	}
	public void setNeedUpload(String needUpload) {
		this.needUpload = needUpload;
	}
}

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

@ -73,98 +73,49 @@ public class PatientHealthIndexService extends BaseService {
    private PatientDeviceDao patientDeviceDao;
    @Autowired
    private DoctorWorkTimeService doctorWorkTimeService;
    @Autowired
    private PatientHealthRecordDietDao patientHealthRecordDietDao;
    @Autowired
    private PatientHealthRecordSportsDao patientHealthRecordSportsDao;
    @Autowired
    private PatientHealthRecordMedicationDao patientHealthRecordMedicationDao;
    @Autowired
    private SportsTypeDao sportsTypeDao;
    @Autowired
    private SportsDao sportsDao;
    @Autowired
    private MedicinesDao medicinesDao;
    /**
     * 更改保健记录(包括手动记录的修改和所有的删除)
     *
     * @param id
     * @param type   饮食1,运动2,用药3
     * @param value1 记录时间
     * @param value2 饮食内容CONTETN  时长 用药
     * @param value3 上传图片 强度
     * @param value4 运动项目
     */
    public void modifyHealthCare(long id, int type, String value1, String value2, String value3, String value4) throws Exception {
        //value类字段值均为空为删除
        if (StringUtils.isEmpty(value1) && StringUtils.isEmpty(value2) && StringUtils.isEmpty(value3) && StringUtils.isEmpty(value4)) {
            switch (type) {
                case 1:
                    patientHealthRecordDietDao.deleteDiet(id);
                    break;
                case 2:
                    patientHealthRecordSportsDao.deleteSports(id);
                    break;
                case 3:
                    patientHealthRecordMedicationDao.deleteMedication(id);
                    break;
            }
        } else {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            Date recordDate = sdf.parse(value1);
            switch (type) {
                case 1:
                    patientHealthRecordDietDao.modifyDiet(id, recordDate, value2, value3);
                    break;
                case 2:
                    SportsType sportsType = sportsTypeDao.findByCode(value3);
                    String typeName = sportsType.getName();
                    Sports sport = sportsDao.findByCode(value4);
                    String sportName = sport.getName();
                    Double sportsTime = Double.parseDouble(value2);
                    patientHealthRecordSportsDao.modifySports(id, recordDate, sportsTime, value3, typeName, value4, sportName);
                    break;
                case 3:
                    Medicines medicines = medicinesDao.findByCode(value2);
                    String medicinesName = medicines.getName();
                    patientHealthRecordMedicationDao.modifyMedication(id, recordDate, value2, medicinesName);
                    break;
            }
        }
    }
    //更改接口(包括手动记录的修改和所有的删除)
    public void modify(long id, String recordDate, String value1, String value2, String value3, String value4) throws Exception {
        Date record = null;
        Date time = new Date();
        String sql = "";
//            字段值均为空为删除
        if (StringUtils.isEmpty(value1) && StringUtils.isEmpty(value2) && StringUtils.isEmpty(value3) && StringUtils.isEmpty(value4)) {
            sql = " update device.wlyy_patient_health_index a set a.del = 0 where a.id =? ";
            jdbcTemplate.update(sql, id);
        }
        sql = " update device.wlyy_patient_health_index a set ";
        if (StringUtils.isNotEmpty(recordDate)) {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
            record = sdf.parse(recordDate);
        }
        if (StringUtils.isNotEmpty(value1)) {
            sql += " a.value1 = " + value1 + " , ";
        }
        if (StringUtils.isNotEmpty(value2)) {
            sql += " a.value2 = " + value2 + " , ";
        }
        if (StringUtils.isNotEmpty(value3)) {
            sql += " a.value3 = " + value3 + " , ";
        DevicePatientHealthIndex result =  patientHealthIndexDao.findOne(id);
        if(result!=null)
        {
            //字段值均为空为删除
            if (StringUtils.isEmpty(value1) && StringUtils.isEmpty(value2) && StringUtils.isEmpty(value3) && StringUtils.isEmpty(value4)) {
                result.setDel("0");
            }
            else{
                if (StringUtils.isNotEmpty(recordDate)) {
                    result.setRecordDate(DateUtil.strToDate(recordDate));
                }
                else{
                    throw new Exception("Record date can not be null!");
                }
                result.setDel("1");
                if (StringUtils.isNotEmpty(value1)) {
                    result.setValue1(value1);
                }
                if (StringUtils.isNotEmpty(value2)) {
                    result.setValue2(value2);
                }
                if (StringUtils.isNotEmpty(value3)) {
                    result.setValue3(value3);
                }
                if (StringUtils.isNotEmpty(value4)) {
                    result.setValue4(value4);
                }
            }
            patientHealthIndexDao.save(result);
        }
        if (StringUtils.isNotEmpty(value4)) {
            sql += " a.value4 = " + value4 + ", ";
        else{
           throw new Exception("Result not exit!");
        }
        sql += "  a.record_date = ? ,a.czrq = ?  where a.device_sn is null and a.id =? ";
        jdbcTemplate.update(sql, record, time, id);
    }
    /**

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

@ -1,11 +1,17 @@
package com.yihu.wlyy.service.app.health;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import com.alibaba.fastjson.JSON;
import com.yihu.wlyy.entity.dict.Medicines;
import com.yihu.wlyy.entity.education.Sports;
import com.yihu.wlyy.entity.education.SportsType;
import com.yihu.wlyy.repository.dict.MedicinesDao;
import com.yihu.wlyy.util.DateUtil;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
@ -39,6 +45,9 @@ public class PatientHealthRecordService extends BaseService {
	@Autowired
	private SportsDao sportsDao;
	@Autowired
	private MedicinesDao medicinesDao;
	@Autowired
	private PatientHealthRecordMedicationDao patientHealthRecordMedicationDao;
@ -48,6 +57,55 @@ public class PatientHealthRecordService extends BaseService {
	@Autowired
	private PatientHealthRecordSportsDao patientHealthRecordSportsDao;
	/**
	 * 更改保健记录(包括手动记录的修改和所有的删除)
	 *
	 * @param id
	 * @param type   饮食1,运动2,用药3
	 * @param value1 记录时间
	 * @param value2 饮食内容CONTETN  时长 用药
	 * @param value3 上传图片 强度
	 * @param value4 运动项目
	 */
	public void modifyHealthCare(long id, int type, String value1, String value2, String value3, String value4) throws Exception {
		//value类字段值均为空为删除
		if (StringUtils.isEmpty(value1) && StringUtils.isEmpty(value2) && StringUtils.isEmpty(value3) && StringUtils.isEmpty(value4)) {
			switch (type) {
				case 1:
					patientHealthRecordDietDao.deleteDiet(id);
					break;
				case 2:
					patientHealthRecordSportsDao.deleteSports(id);
					break;
				case 3:
					patientHealthRecordMedicationDao.deleteMedication(id);
					break;
			}
		} else {
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			Date recordDate = sdf.parse(value1);
			switch (type) {
				case 1:
					patientHealthRecordDietDao.modifyDiet(id, recordDate, value2, value3);
					break;
				case 2:
					SportsType sportsType = sportsTypeDao.findByCode(value3);
					String typeName = sportsType.getName();
					Sports sport = sportsDao.findByCode(value4);
					String sportName = sport.getName();
					Double sportsTime = Double.parseDouble(value2);
					patientHealthRecordSportsDao.modifySports(id, recordDate, sportsTime, value3, typeName, value4, sportName);
					break;
				case 3:
					Medicines medicines = medicinesDao.findByCode(value2);
					String medicinesName = medicines.getName();
					patientHealthRecordMedicationDao.modifyMedication(id, recordDate, value2, medicinesName);
					break;
			}
		}
	}
	/**
	 * 添加运动记录
	 * @param record 运动记录对象

+ 3 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/QrcodeService.java

@ -262,6 +262,9 @@ public class QrcodeService extends BaseService {
                } else if (doctor.getLevel() == 3) {
                    doctorLevel = "健康管理师";
                }
                else{
                    doctorLevel = "未知";
                }
                // 二维码图片文件名
                String fileName = doctor.getName() + "_" + doctor.getMobile() + "_" + doctorLevel;

+ 17 - 22
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthController.java

@ -33,14 +33,11 @@ public class DoctorHealthController extends BaseController {
	@Autowired
	private PatientHealthIndexService healthIndexService;
	/**
	 * 患者最近填写的健康指标
	 * @param patient 患者标识
	 * @return
	 */
	@RequestMapping(value = "recent")
	@RequestMapping(value = "recent",method = RequestMethod.GET)
	@ResponseBody
	public String recent(String patient) {
	@ApiOperation("患者最近填写的健康指标")
	public String recent(@ApiParam("患者代码")
						  @RequestParam String patient) {
		try {
			JSONArray array = healthIndexService.findRecentByPatient(patient);
			if (array != null) {
@ -63,15 +60,15 @@ public class DoctorHealthController extends BaseController {
	@RequestMapping(value = "chart",method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation("根据患者标志获取健康指标(图表)")
	public String getHealthIndexChartByPatient(@ApiParam(name="patient",value="指标类型",defaultValue = "P20160902002")
	public String getHealthIndexChartByPatient(@ApiParam(name="patient",value="患者代码",defaultValue = "eb0b478fbe9245428ecf63cd7517206f")
												   @RequestParam(value="patient",required = true) String patient,
											   @ApiParam(name="type",value="指标类型",defaultValue = "1")
											   @RequestParam(value="type",required = true) int type,
											   @ApiParam(name="gi_type",value="就餐类型",defaultValue = "1")
												   @RequestParam(value = "gi_type",required = false) int gi_type,
											   @ApiParam(name="begin",value="开始时间",defaultValue = "2016-08-23 00:00:00")
											   @ApiParam(name="begin",value="开始时间",defaultValue = "2017-05-22 00:00:00")
											   @RequestParam(value="begin",required = true) String begin,
											   @ApiParam(name="end",value="结束时间",defaultValue = "2016-09-23 00:00:00")
											   @ApiParam(name="end",value="结束时间",defaultValue = "2017-06-02 00:00:00")
												   @RequestParam(value="end",required = true) String end) {
		try {
			Iterable<DevicePatientHealthIndex> list = healthIndexService.findChartByPatient(patient,type,gi_type,begin,end);
@ -163,13 +160,14 @@ public class DoctorHealthController extends BaseController {
	}
	/**
	 * 患者健康指标预警值查询
	 *
	 * @param patient 患者标识
	 * @return
	 */
	@RequestMapping(value = "standard")
	@RequestMapping(value = "standard",method = RequestMethod.GET)
	@ResponseBody
	public String standard(String patient) {
	@ApiOperation("患者健康指标预警值查询")
	public String standard(@ApiParam("患者代码") @RequestParam String patient) {
		try {
			JSONArray standardArray = new JSONArray();
			JSONArray userArray = new JSONArray();
@ -220,15 +218,12 @@ public class DoctorHealthController extends BaseController {
		}
	}
	/**
	 * 保存患者健康指标预警值
	 * @param patient 患者标识
	 * @param json 预警值
	 * @return
	 */
	@RequestMapping(value = "standard_save")
	@RequestMapping(value = "standard_save",method = RequestMethod.POST)
	@ResponseBody
	public String standardSave(String patient, String json) {
	@ApiOperation("保存患者健康指标预警值")
	public String standardSave(@ApiParam("患者代码") @RequestParam String patient,
							    @ApiParam("预警值Json") @RequestParam String json) {
		try {
			JSONArray array = new JSONArray(json);
			if (StringUtils.isEmpty(patient) || array == null || array.length() == 0) {
@ -268,7 +263,7 @@ public class DoctorHealthController extends BaseController {
	}
	@RequestMapping(value = "last",method = RequestMethod.POST)
	@RequestMapping(value = "last",method = RequestMethod.GET)
	@ResponseBody
	@ApiOperation("患者最新健康指标信息")
	public String getHealthIndexByPatient(@ApiParam(name="patient",value="患者代码",defaultValue = "")

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

@ -42,14 +42,11 @@ public class PatientHealthController extends BaseController {
     * 血压  value1 高压 value2 低压 value3脉搏 value4心率不齐(0否 1是)
     * 体重 value1 体重值
     * 腰围 value1 腰围值
     *
     * @param id
     * @param recordDate 记录时间
     * @param value1 字段值
     * @return
     *  @param recordDate 记录时间
     */
    @RequestMapping(value = "/modify", method = RequestMethod.GET)
    @RequestMapping(value = "/modify", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("患者最近的各项健康信息")
    public String modify(@RequestParam long id,
                         @RequestParam(required = false) String recordDate,
                         @RequestParam(required = false) String value1,
@ -65,41 +62,11 @@ public class PatientHealthController extends BaseController {
        }
    }
    /**
     * 保健记录更改接口(包括手动记录的修改和所有的删除)
     *
     * @param id
     * @param type   饮食1,运动2,用药3
     * @param value1 记录时间
     * @param value2 饮食内容CONTETN  时长 用药
     * @param value3 上传图片 强度
     * @param value4 运动项目
     * @return
     */
    @RequestMapping(value = "/modifyHealthCare", method = RequestMethod.GET)
    @ResponseBody
    public String modifyHealthCare(@RequestParam long id,
                                   @RequestParam int type,
                                   @RequestParam(required = false) String value1,
                                   @RequestParam(required = false) String value2,
                                   @RequestParam(required = false) String value3,
                                   @RequestParam(required = false) String value4) {
        try {
            healthIndexService.modifyHealthCare(id, type, value1, value2, value3, value4);
            return write(200, "更改成功!");
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "更改失败!");
        }
    }
    /**
     * 患者最近的各项健康信息
     *
     * @return
     */
    @RequestMapping(value = "/getRecentData")
    @RequestMapping(value = "/getRecentData", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("患者最近的各项健康信息")
    public String getRecentData() {
        try {
            List list = new ArrayList();
@ -276,13 +243,10 @@ public class PatientHealthController extends BaseController {
        }
    }
    /**
     * 患者最近填写的健康指标
     *
     * @return
     */
    @RequestMapping(value = "recent")
    @RequestMapping(value = "recent", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("患者最近填写的健康指标")
    public String recent() {
        try {
            JSONArray array = healthIndexService.findRecentByPatient(getUID());
@ -297,13 +261,10 @@ public class PatientHealthController extends BaseController {
        }
    }
    /**
     * 获取患者最后填写的健康指标(新)
     *
     * @return
     */
    @RequestMapping(value = "last")
    @RequestMapping(value = "last", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("获取患者最后填写的健康指标(新)")
    public String last() {
        try {
            Map<String, Object> map = new HashMap<>();
@ -330,23 +291,10 @@ public class PatientHealthController extends BaseController {
        }
    }
    /**
     * 保存患者健康指标 (旧)
     *
     * @param intervene 干预标志
     * @param time      记录时间
     * @param value1    血糖/收缩压/体重/腰围/早餐前空腹
     * @param value2    舒张压/早餐后空腹
     * @param value3    午餐空腹
     * @param value4    午餐后
     * @param value5    晚餐空腹
     * @param value6    晚餐后
     * @param value7    睡前
     * @param type      健康指标类型(1血糖,2血压,3体重,4腰围)
     * @return 操作结果
     */
    @RequestMapping(value = "add")
    /*@RequestMapping(value = "add")
    @ResponseBody
    @ApiOperation("保存患者健康指标(旧)")
    public String add(@RequestParam(required = false) String intervene, String time, String value1, String value2, String value3, String value4, String value5, String value6, String value7, int type) {
        try {
@ -433,7 +381,7 @@ public class PatientHealthController extends BaseController {
            return invalidUserException(ex, -1, "保存失败!");
        }
    }
*/
    @RequestMapping(value = "addPatientHealthIndex", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("新增患者指标")
@ -469,26 +417,20 @@ public class PatientHealthController extends BaseController {
        }
    }
    /**
     * 根据患者标志获取健康指标
     *
     * @param type 健康指标类型(1血糖,2血压,3体重,4腰围)
     * @return 操作结果
     */
    @RequestMapping(value = "chart", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("根据患者标志获取健康指标(图表)")
    public String getHealthIndexChartByPatient(@ApiParam(name = "type", value = "指标类型", defaultValue = "1")
    public String getHealthIndexChartByPatient(@ApiParam(name = "type", value = "指标类型(1血糖,2血压,3体重,4腰围)", defaultValue = "1")
                                               @RequestParam(value = "type", required = true) int type,
                                               @ApiParam(name = "gi_type", value = "就餐类型", defaultValue = "1")
                                               @ApiParam(name = "gi_type", value = "就餐类型0全部", defaultValue = "1")
                                               @RequestParam(value = "gi_type", required = false) int gi_type,
                                               @ApiParam(name = "begin", value = "开始时间", defaultValue = "2016-08-23 00:00:00")
                                               @ApiParam(name = "begin", value = "开始时间", defaultValue = "2017-05-22 00:00:00")
                                               @RequestParam(value = "begin", required = true) String begin,
                                               @ApiParam(name = "end", value = "结束时间", defaultValue = "2016-09-23 00:00:00")
                                               @ApiParam(name = "end", value = "结束时间", defaultValue = "2017-06-02 00:00:00")
                                               @RequestParam(value = "end", required = true) String end) {
        try {
            List<DevicePatientHealthIndex> list =
                    healthIndexService.findChartByPatient(getUID(), type, gi_type, begin, end);
            List<DevicePatientHealthIndex> list = healthIndexService.findChartByPatient(getUID(), type, gi_type, begin, end);
            if (list == null) {
                return success("查询成功!");
@ -520,17 +462,11 @@ public class PatientHealthController extends BaseController {
        }
    }
    /**
     * 根据患者标志获取健康指标
     *
     * @param type     健康指标类型(1血糖,2血压,3体重,4腰围)
     * @param pagesize 页数
     * @return 操作结果
     */
    @RequestMapping(value = "list", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("患者获取健康指标")
    public String getHealthIndexByPatient(@ApiParam(name = "type", value = "指标类型", defaultValue = "1")
    public String getHealthIndexByPatient(@ApiParam(name = "type", value = "指标类型(1血糖,2血压,3体重,4腰围)", defaultValue = "1")
                                          @RequestParam(value = "type", required = true) int type,
                                          @ApiParam(name = "start", value = "开始时间", defaultValue = "2016-07-23 00:00:00")
                                          @RequestParam(value = "start", required = true) String start,
@ -580,13 +516,10 @@ public class PatientHealthController extends BaseController {
        }
    }
    /**
     * 患者健康指标预警值查询
     *
     * @return
     */
    @RequestMapping(value = "standard")
    @RequestMapping(value = "standard", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("患者健康指标预警值查询")
    public String standard() {
        try {
            JSONArray standardArray = new JSONArray();

+ 30 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/health/PatientHealthRecordController.java

@ -48,6 +48,36 @@ public class PatientHealthRecordController extends WeixinBaseController {
	@Autowired
	private PatientHealthRecordService patientHealthRecordService;
	/**
	 * 保健记录更改接口(包括手动记录的修改和所有的删除)
	 *
	 * @param id
	 * @param type   饮食1,运动2,用药3
	 * @param value1 记录时间
	 * @param value2 饮食内容CONTETN  时长 用药
	 * @param value3 上传图片 强度
	 * @param value4 运动项目
	 * @return
	 */
	@RequestMapping(value = "/modifyHealthCare", method = RequestMethod.POST)
	@ResponseBody
	public String modifyHealthCare(@RequestParam long id,
								   @RequestParam int type,
								   @RequestParam(required = false) String value1,
								   @RequestParam(required = false) String value2,
								   @RequestParam(required = false) String value3,
								   @RequestParam(required = false) String value4) {
		try {
			patientHealthRecordService.modifyHealthCare(id, type, value1, value2, value3, value4);
			return write(200, "更改成功!");
		} catch (Exception e) {
			error(e);
			return invalidUserException(e, -1, "更改失败!");
		}
	}
	/**
	 * 运动强度查询接口
	 * @return

+ 2 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/wx/OnePayController.java

@ -78,4 +78,6 @@ public class OnePayController extends WeixinBaseController {
            return error(-1, e.getMessage());
        }
    }
}