فهرست منبع

慢病管理,医生监测方案提交,居民列表相关BUG修改

huangwenjie 7 سال پیش
والد
کامیت
14f6b4ab51

+ 96 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/health/DoctorHealthStandard.java

@ -0,0 +1,96 @@
package com.yihu.wlyy.entity.doctor.health;
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;
/**
 * 医生预警值方案
 * @author huangwenjie
 * @date 2017/9/14 21:08
 */
@Entity
@Table(name = "wlyy_doctor_health_standard")
public class DoctorHealthStandard extends IdEntity {
    private static final long serialVersionUID = -8343925049051333359L;
    // 患者标识
    private String doctor;
    // 健康指标类型:1血糖,2血压,3体重,4腰围
    private Integer type;
    // 最低安全值(血糖餐前\收缩压\体重\腰围)
    private Double minValue1;
    // 最高安全值(血糖餐前\收缩压\体重\腰围)
    private Double maxValue1;
    // 最低安全值(血糖餐后\舒张压)
    private Double minValue2;
    // 最高安全值(血糖餐后\舒张压)
    private Double maxValue2;
    // 设置时间
    private Date czrq;
    public String getDoctor() {
        return doctor;
    }
    public void setDoctor(String doctor) {
        this.doctor = doctor;
    }
    public Integer getType() {
        return type;
    }
    public void setType(Integer type) {
        this.type = type;
    }
    @Column(name = "min_value_1")
    public Double getMinValue1() {
        return minValue1;
    }
    public void setMinValue1(Double minValue) {
        this.minValue1 = minValue;
    }
    @Column(name = "max_value_1")
    public Double getMaxValue1() {
        return maxValue1;
    }
    public void setMaxValue1(Double maxValue) {
        this.maxValue1 = maxValue;
    }
    @Column(name = "min_value_2")
    public Double getMinValue2() {
        return minValue2;
    }
    public void setMinValue2(Double minValue) {
        this.minValue2 = minValue;
    }
    @Column(name = "max_value_2")
    public Double getMaxValue2() {
        return maxValue2;
    }
    public void setMaxValue2(Double maxValue) {
        this.maxValue2 = maxValue;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getCzrq() {
        return czrq;
    }
    public void setCzrq(Date czrq) {
        this.czrq = czrq;
    }
}

+ 29 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/vo/PatientCodeDeviceType.java

@ -0,0 +1,29 @@
package com.yihu.wlyy.entity.patient.vo;
/**
 * 患者CODE,设备类型VO类
 * @author huangwenjie
 * @date 2017/9/14 22:44
 */
public class PatientCodeDeviceType {
    private String user;            //患者CODE
    private Integer deviceType;     //患者设备类型
    public String getUser() {
        return user;
    }
    public void setUser(String user) {
        this.user = user;
    }
    public Integer getDeviceType() {
        return deviceType;
    }
    public void setDeviceType(Integer deviceType) {
        this.deviceType = deviceType;
    }
}

+ 3 - 1
patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/common/dao/PatientHealthIndexDao.java

@ -51,5 +51,7 @@ public interface PatientHealthIndexDao
	@Query("select a from PatientHealthIndex a where a.user = ?1 and a.deviceSn = ?2 and a.value1 = ?3 and a.type = ?4 and a.recordDate = ?5 and a.del = '1' ")
	List<PatientHealthIndex> findByType(String patient, String deviceSn, String value1, Integer type, Date recordDate);
	
	@Query("select a from PatientHealthIndex a where a.user = ?1 and a.type =?2  order by recordDate desc ")
    List<PatientHealthIndex> findByPatientAndType(String patientCode, String diseaseType, Pageable pageable);
}

+ 8 - 0
patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/model/Patient.java

@ -325,4 +325,12 @@ public class Patient extends IdEntity implements Serializable {
	public static long getSerialVersionUID() {
		return serialVersionUID;
	}
	public Integer getStandardStatus() {
		return standardStatus;
	}
	public void setStandardStatus(Integer standardStatus) {
		this.standardStatus = standardStatus;
	}
}

+ 71 - 1
patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/service/DeviceService.java

@ -19,6 +19,10 @@ import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
@ -390,6 +394,59 @@ public class DeviceService {
                uploadHealthIndex(result);
                System.out.println(result);
                //连续5次体征值正常,则修改为非预警状态;连续5次异常,修改为预警状态-----START
                String patientCode = result.getUser();
                //患者信息
                Patient patient = patientDao.findByCode(patientCode);
                int bloodPressureBbnormalCount = 0;//血压异常次数
                int bloodSuggurBbnormalCount = 0;//血糖异常次数
                // 排序
                Sort sort = new Sort(Sort.Direction.DESC, "recordDate");
                // 分页信息
                Pageable pageRequest = new PageRequest(0, 5, sort);
                Pageable pageable = new PageRequest(1, 5);
                List<PatientHealthIndex> bloodPressurepatientHealthIndices = new ArrayList<>();
                List<PatientHealthIndex> bloodSuggurpatientHealthIndices = new ArrayList<>();
                if( 1 == patient.getDisease()){
                    bloodPressurepatientHealthIndices = patientHealthIndexDao.findByPatientAndType(patientCode,"2",pageable);
                } else if( 2 == patient.getDisease()){
                    bloodSuggurpatientHealthIndices = patientHealthIndexDao.findByPatientAndType(patientCode,"1",pageable);
                } else {
                    bloodPressurepatientHealthIndices = patientHealthIndexDao.findByPatientAndType(patientCode,"2",pageable);
                    bloodSuggurpatientHealthIndices = patientHealthIndexDao.findByPatientAndType(patientCode,"1",pageable);
                }
                for (PatientHealthIndex patientHealthIndex : bloodPressurepatientHealthIndices) {
                    if(1 == patientHealthIndex.getStatus()){
                        bloodPressureBbnormalCount++;
                    }
                }
                for (PatientHealthIndex patientHealthIndex : bloodSuggurpatientHealthIndices) {
                    if(1 == patientHealthIndex.getStatus()){
                        bloodSuggurBbnormalCount++;
                    }
                }
                //连续5次异常,修改用户为预警状态
                if( (5 == bloodPressureBbnormalCount || 5 == bloodSuggurBbnormalCount) && 0 == patient.getStandardStatus()){
                    patient.setStandardStatus(1);
                }
                //连续5次正常,修改用户为非预警状态
                if((0 == bloodPressureBbnormalCount && 0 == bloodSuggurBbnormalCount) && 1 == patient.getStandardStatus()){
                    patient.setStandardStatus(0);
                }
                //连续5次体征值正常,则修改为非预警状态;连续5次异常,修改为预警状态-----END
            }
        } catch (Exception e) {
            e.printStackTrace();
@ -451,6 +508,7 @@ public class DeviceService {
            obj.setUser(user);
            obj.setIdcard(device.getUserIdcard());
            obj.setStatus(0);
            //  1血糖 2血压 3体重 4腰围
            switch (type) {
                case "1":
@ -485,7 +543,7 @@ public class DeviceService {
                default:
                    throw new Exception("Can not support the metric!");
            }
            patientHealthIndexDao.save(obj);
            obj = patientHealthIndexDao.save(obj);
            return obj;
        } else {
            DeviceInfo deviceInfo = new DeviceInfo();
@ -592,10 +650,18 @@ public class DeviceService {
            if (index % 2 == 0) {
                if (!checkHealthIndex(NumberUtils.toDouble(value1), maxValueBefore, minValueBefore)) {
                    msgContent += patient.getName() + "血糖异常(" + value1 + "mmol/L),请处理";
                    //体征异常,更新体征数据状态
                    data.setStatus(1);
                    patientHealthIndexDao.save(data);
                }
            } else { //餐前
                if (!checkHealthIndex(NumberUtils.toDouble(value1), maxValueAfter, minValueAfter)) {
                    msgContent += patient.getName() + "血糖异常(" + value1 + "mmol/L),请处理";
                    //体征异常,更新体征数据状态
                    data.setStatus(1);
                    patientHealthIndexDao.save(data);
                }
            }
        }
@ -626,6 +692,10 @@ public class DeviceService {
            // 收缩压/舒张压校验
            if (!checkHealthIndex(NumberUtils.toDouble(value1), maxValueSSY, minValueSSY) || !checkHealthIndex(NumberUtils.toDouble(value2), maxValueSZY, minValueSZY)) {
                msgContent = patient.getName() + "血压异常(舒张压 " + value2 + "mmHg、收缩压 " + value1 + "mmHg),请处理";
                //体征异常,更新体征数据状态
                data.setStatus(1);
                patientHealthIndexDao.save(data);
            }
        }

+ 27 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/health/DoctorHealthStandardDao.java

@ -0,0 +1,27 @@
package com.yihu.wlyy.repository.doctor.health;
import com.yihu.wlyy.entity.doctor.health.DoctorHealthStandard;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * @author huangwenjie
 * @date 2017/9/14 21:43
 */
public interface DoctorHealthStandardDao extends
		PagingAndSortingRepository<DoctorHealthStandard, Long>,
        JpaSpecificationExecutor<DoctorHealthStandard>{
    // 查询医生健康指标预警值方案
    Iterable<DoctorHealthStandard> findByDoctor(String code);
    @Modifying
    @Query("delete DoctorHealthStandard a where a.doctor = ?1")
    int deleteByDoctor(String doctorcode);
    @Query("select a from DoctorHealthStandard a where a.doctor = ?1 and a.type = ?2")
    DoctorHealthStandard findByDoctorType(String patient, int type);
}

+ 4 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientHealthStandardDao.java

@ -12,7 +12,10 @@ import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.wlyy.entity.patient.PatientHealthStandard;
public interface PatientHealthStandardDao extends PagingAndSortingRepository<PatientHealthStandard, Long>, JpaSpecificationExecutor<PatientHealthStandard> {
public interface PatientHealthStandardDao extends
		PagingAndSortingRepository<PatientHealthStandard, Long>,
		JpaSpecificationExecutor<PatientHealthStandard> {
	// 查询患者健康指标预警值
	Iterable<PatientHealthStandard> findByPatient(String patient);

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

@ -4,12 +4,14 @@ import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.device.entity.DevicePatientHealthIndex;
import com.yihu.wlyy.entity.device.PatientDevice;
import com.yihu.wlyy.entity.doctor.health.DoctorHealthStandard;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.PatientAimSports;
import com.yihu.wlyy.entity.patient.PatientHealthStandard;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.health.repository.DevicePatientHealthIndexDao;
import com.yihu.wlyy.repository.doctor.health.DoctorHealthStandardDao;
import com.yihu.wlyy.repository.message.MessageDao;
import com.yihu.wlyy.repository.patient.*;
import com.yihu.wlyy.service.BaseService;
@ -72,6 +74,8 @@ public class PatientHealthIndexService extends BaseService {
    private PushMsgTask pushMsgTask;
    @Autowired
    private PatientAimSportsDao patientAimSportsDao;
    @Autowired
    private DoctorHealthStandardDao doctorHealthStandardDao;
@ -1322,4 +1326,25 @@ public class PatientHealthIndexService extends BaseService {
        return re;
    }
    /**
     * 保存医生预警值方案
     * @param doclist
     * @param uid
     * @return
     */
    public Iterable<DoctorHealthStandard> saveDocStandard(List<DoctorHealthStandard> doclist, String uid)  throws Exception  {
        // 先删除
        doctorHealthStandardDao.deleteByDoctor(uid);
        return doctorHealthStandardDao.save(doclist);
    }
    /**
     * 查询患者健康指标预警值
     *
     * @param code
     * @return
     */
    public Iterable<DoctorHealthStandard> findDoctorStandardByDoctor(String code) {
        return doctorHealthStandardDao.findByDoctor(code);
    }
}

+ 88 - 35
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/label/SignPatientLabelInfoService.java

@ -8,6 +8,7 @@ import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabelInfo;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.PatientDisease;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.patient.vo.PatientCodeDeviceType;
import com.yihu.wlyy.logs.BusinessLogs;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.doctor.DoctorPatientGroupInfoDao;
@ -360,9 +361,13 @@ public class SignPatientLabelInfoService extends BaseService {
        signList = jdbcTemplate.queryForList(sql, args);
        //查询患者设备绑定情况
        if(isSlowDisease){
            String _pdsql = "SELECT p.code,(SELECT sum(d.category_code)  from wlyy_patient_device d WHERE p.code = d.`user`) device from wlyy_patient p";
            patientDeviceTypeMap = jdbcTemplate.queryForMap(_pdsql);
        String _pdsql = "select user,sum(category_code) deviceType FROM wlyy_patient_device GROUP BY user";
        List<PatientCodeDeviceType> patientCodeDeviceTypes =  jdbcTemplate.queryForList(_pdsql,PatientCodeDeviceType.class);
        if(!patientCodeDeviceTypes.isEmpty()){
            for (PatientCodeDeviceType patientCodeDeviceType : patientCodeDeviceTypes) {
                patientDeviceTypeMap.put(patientCodeDeviceType.getUser(),patientCodeDeviceType.getDeviceType());
            }
        }
        if (signList != null && signList.size() > 0) {
@ -508,26 +513,43 @@ public class SignPatientLabelInfoService extends BaseService {
            Collections.sort(list, new Comparator<JSONObject>() {
                @Override
                public int compare(JSONObject o1, JSONObject o2) {
                    //微信綁定情況
                    String openid1 = o1.has("openid") ? o1.getString("openid") : "";
                    String openid2 = o2.has("openid") ? o2.getString("openid") : "";
                    int re = 0;
                    //是否根据预警字段优先排序
                    if(isSlowDisease){
                        int standardStatus1 = o1.has("standardStatus")?o1.getInt("standardStatus"):0;
                        int standardStatus2 = o2.has("standardStatus")?o2.getInt("standardStatus"):0;
                    //患者預警狀態
                    int standardStatus1 = o1.has("standardStatus")?o1.getInt("standardStatus"):0;
                    int standardStatus2 = o2.has("standardStatus")?o2.getInt("standardStatus"):0;
                    //疾病种类
                    int disease1 = o1.has("disease")?o1.getInt("disease"):0;
                    int disease2 = o2.has("disease")?o2.getInt("disease"):0;
                    //颜色标签
                    int diseaseCondition1 = o1.has("diseaseCondition")?o1.getInt("diseaseCondition"):0;
                    int diseaseCondition2 = o2.has("diseaseCondition")?o2.getInt("diseaseCondition"):0;
                    //判断预警状态
                    if(standardStatus1 == standardStatus2){
                        //判断病种种类
                        if(disease1 == disease2){
                            //判断颜色标签
                            if(diseaseCondition1 == diseaseCondition2){
                                //判断微信绑定情况
                                re = openid1.compareTo(openid2);
                            }else{
                                re = diseaseCondition1 - diseaseCondition2;
                            }
                        if(standardStatus1 == standardStatus2){
                            re = openid1.compareTo(openid2);
                        }else{
                            re = standardStatus1 - standardStatus1;
                            re = disease1 - disease2;
                        }
                    }else{
                        re = openid1.compareTo(openid2);
                        re = standardStatus1 - standardStatus2;
                    }
                    if (re > 0) {
                        return -1;
                    } else if (re < 0) {
@ -3558,7 +3580,7 @@ public class SignPatientLabelInfoService extends BaseService {
     * @param teamCode
     * @param page
     * @param pagesize
     * @param sortByStandardStatus 是否根据预警状态排序,如果true, 需要附带查询患者设备绑定情况
     * @param isSlowDisease 是否是慢病管理,如果true
     * @param diseaseCondition
     * @return
     * @throws Exception
@ -3679,11 +3701,14 @@ public class SignPatientLabelInfoService extends BaseService {
        signList = jdbcTemplate.queryForList(sql, args);
        //查询患者设备绑定情况
        if(sortByStandardStatus){
            String _pdsql = "SELECT p.code,(SELECT sum(d.category_code)  from wlyy_patient_device d WHERE p.code = d.`user`) device from wlyy_patient p";
            patientDeviceTypeMap = jdbcTemplate.queryForMap(_pdsql);
        }
        String _pdsql = "select user,sum(category_code) deviceType FROM wlyy_patient_device GROUP BY user";
        List<PatientCodeDeviceType> patientCodeDeviceTypes =  jdbcTemplate.queryForList(_pdsql,PatientCodeDeviceType.class);
        if(!patientCodeDeviceTypes.isEmpty()){
            for (PatientCodeDeviceType patientCodeDeviceType : patientCodeDeviceTypes) {
                patientDeviceTypeMap.put(patientCodeDeviceType.getUser(),patientCodeDeviceType.getDeviceType());
            }
        }
        if (signList != null && signList.size() > 0) {
            for (Map<String, Object> sign : signList) {
@ -3830,27 +3855,43 @@ public class SignPatientLabelInfoService extends BaseService {
            Collections.sort(list, new Comparator<JSONObject>() {
                @Override
                public int compare(JSONObject o1, JSONObject o2) {
                    //微信綁定情況
                    String openid1 = o1.has("openid") ? o1.getString("openid") : "";
                    String openid2 = o2.has("openid") ? o2.getString("openid") : "";
                    int re = 0;
                    //是否根据预警字段优先排序
                    if(sortByStandardStatus){
                        int standardStatus1 = o1.has("standardStatus")?o1.getInt("standardStatus"):0;
                        int standardStatus2 = o2.has("standardStatus")?o2.getInt("standardStatus"):0;
                    //患者預警狀態
                    int standardStatus1 = o1.has("standardStatus")?o1.getInt("standardStatus"):0;
                    int standardStatus2 = o2.has("standardStatus")?o2.getInt("standardStatus"):0;
                    //疾病种类
                    int disease1 = o1.has("disease")?o1.getInt("disease"):0;
                    int disease2 = o2.has("disease")?o2.getInt("disease"):0;
                    //颜色标签
                    int diseaseCondition1 = o1.has("diseaseCondition")?o1.getInt("diseaseCondition"):0;
                    int diseaseCondition2 = o2.has("diseaseCondition")?o2.getInt("diseaseCondition"):0;
                    //判断预警状态
                    if(standardStatus1 == standardStatus2){
                        //判断病种种类
                        if(disease1 == disease2){
                            //判断颜色标签
                            if(diseaseCondition1 == diseaseCondition2){
                                //判断微信绑定情况
                                re = openid1.compareTo(openid2);
                            }else{
                                re = diseaseCondition1 - diseaseCondition2;
                            }
                        if(standardStatus1 == standardStatus2){
                            re = openid1.compareTo(openid2);
                        }else{
                            re = standardStatus1 - standardStatus1;
                            re = disease1 - disease2;
                        }
                    }else{
                        re = openid1.compareTo(openid2);
                        re = standardStatus1 - standardStatus2;
                    }
                    if (re > 0) {
                        return -1;
                    } else if (re < 0) {
@ -4088,18 +4129,23 @@ public class SignPatientLabelInfoService extends BaseService {
                }
            }
            sql = sql + " order by t3.diseaseCondition,t3.openid desc limit " + page + "," + pagesize;
            sql = sql + " order by t3.diseaseCondition,t3.disease,t3.diseaseCondition,t3.openid desc limit " + page + "," + pagesize;
            signList = jdbcTemplate.queryForList(sql, argsnew);
        }else{
            sql = sql + " order by t3.diseaseCondition,t3.openid desc limit " + page + "," + pagesize;
            sql = sql + " order by t3.diseaseCondition,t3.disease,t3.diseaseCondition,t3.openid desc limit " + page + "," + pagesize;
            signList = jdbcTemplate.queryForList(sql, args);
        }
        String _pdsql = "SELECT p.code,(SELECT sum(d.category_code)  from wlyy_patient_device d WHERE p.code = d.`user`) device from wlyy_patient p";
        patientDeviceTypeMap = jdbcTemplate.queryForMap(_pdsql);
        //查询患者设备绑定情况
        String _pdsql = "select user,sum(category_code) deviceType FROM wlyy_patient_device GROUP BY user";
        List<PatientCodeDeviceType> patientCodeDeviceTypes =  jdbcTemplate.queryForList(_pdsql,PatientCodeDeviceType.class);
        if(!patientCodeDeviceTypes.isEmpty()){
            for (PatientCodeDeviceType patientCodeDeviceType : patientCodeDeviceTypes) {
                patientDeviceTypeMap.put(patientCodeDeviceType.getUser(),patientCodeDeviceType.getDeviceType());
            }
        }
        if (signList != null && signList.size() > 0) {
            for (Map<String, Object> sign : signList) {
                Patient p = patientDao.findByCode(sign.get("patient") == null ? "" : sign.get("patient").toString());
@ -4296,11 +4342,18 @@ public class SignPatientLabelInfoService extends BaseService {
                "  AND" +
                (isIdcard ? " p.idcard like ? " : " t1.name like ? ");
        String sql = sqlTemp + " order by t2.diseaseCondition,t2.openid desc  limit " + page + "," + pagesize;
        String sql = sqlTemp + " order by t2.diseaseCondition,t2.disease,t2,diseaseCondition,t2.openid desc  limit " + page + "," + pagesize;
        signList = jdbcTemplate.queryForList(sql, args);
        String _pdsql = "SELECT p.code,(SELECT sum(d.category_code)  from wlyy_patient_device d WHERE p.code = d.`user`) device from wlyy_patient p";
        patientDeviceTypeMap = jdbcTemplate.queryForMap(_pdsql);
        //查询患者设备绑定情况
        String _pdsql = "select user,sum(category_code) deviceType FROM wlyy_patient_device GROUP BY user";
        List<PatientCodeDeviceType> patientCodeDeviceTypes =  jdbcTemplate.queryForList(_pdsql,PatientCodeDeviceType.class);
        if(!patientCodeDeviceTypes.isEmpty()){
            for (PatientCodeDeviceType patientCodeDeviceType : patientCodeDeviceTypes) {
                patientDeviceTypeMap.put(patientCodeDeviceType.getUser(),patientCodeDeviceType.getDeviceType());
            }
        }
        if (signList != null && signList.size() > 0) {
            for (Map<String, Object> sign : signList) {

+ 4 - 4
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/scheme/DoctorSchemeService.java

@ -65,7 +65,7 @@ public class DoctorSchemeService {
     * @date 2017/9/13 16:23
     * @return
     */
    public List<String> getPatientsByDiseaseConditionDiseaseDeviceType(String teamCode, Integer disease, Integer diseaseCondition, Integer deviceType) throws Exception{
    public List<String> getPatientsByDiseaseConditionDiseaseDeviceType(String teamCode, Integer disease, String diseaseCondition, Integer deviceType) throws Exception{
        String sql = "select p.code from wlyy_patient p ";
@ -76,11 +76,11 @@ public class DoctorSchemeService {
        sql = sql+ " JOIN wlyy_sign_family sf on sf.patient = p.code where sf.admin_team_code = "+teamCode;
        if(-1 != disease){
            sql = sql + " p.disease ="+disease;
            sql = sql + " and p.disease ="+disease;
        }
        if(-1 != diseaseCondition){
            sql = sql + " and p.diseaseCondition ="+diseaseCondition;
        if(StringUtils.isNotBlank(diseaseCondition)){
            sql = sql + " and p.diseaseCondition IN ("+diseaseCondition +")";
        }
        if(-1 != deviceType){

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

@ -2,6 +2,7 @@ package com.yihu.wlyy.web.doctor.health;
import com.yihu.device.entity.DevicePatientHealthIndex;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.entity.doctor.health.DoctorHealthStandard;
import com.yihu.wlyy.entity.patient.PatientHealthStandard;
import com.yihu.wlyy.service.app.health.PatientHealthIndexService;
import com.yihu.wlyy.util.SystemConf;
@ -201,36 +202,68 @@ public class DoctorHealthController extends BaseController {
	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) {
				return error(-1, "保存失败!");
			}
			// 生成数据对象
			List<PatientHealthStandard> list = new ArrayList<PatientHealthStandard>();
			for (int i = 0; i < array.length(); i++) {
				JSONObject obj = array.getJSONObject(i);
				if (obj == null) {
					continue;
			if(patient.contains(",")){
				String[] pcodeArray = patient.split(",");
				if(pcodeArray != null && pcodeArray.length > 0){
					// 生成数据对象
					List<PatientHealthStandard> list = new ArrayList<>();
					//保存患者的数据时,同时医生的预警值方案
					List<DoctorHealthStandard> doclist = new ArrayList<>();
					for (int i = 0; i < array.length(); i++) {
						JSONObject obj = array.getJSONObject(i);
						if (obj == null) {
							continue;
						}
						for (String patientCode: pcodeArray) {
							PatientHealthStandard standard = new PatientHealthStandard();
							standard.setDoctor(getUID());
							standard.setMaxValue1(obj.has("max_value1") ? NumberUtils.toDouble(obj.getString("max_value1"), 0) : 0);
							standard.setMaxValue2(obj.has("max_value2") ? NumberUtils.toDouble(obj.getString("max_value2"), 0) : 0);
							standard.setMinValue1(obj.has("min_value1") ? NumberUtils.toDouble(obj.getString("min_value1"), 0) : 0);
							standard.setMinValue2(obj.has("min_value2") ? NumberUtils.toDouble(obj.getString("min_value2"), 0) : 0);
							standard.setType(obj.getInt("type"));
							standard.setPatient(patientCode);
							standard.setCzrq(new Date());
							list.add(standard);
						}
						DoctorHealthStandard doctorHealthStandard = new DoctorHealthStandard();
						doctorHealthStandard.setDoctor(getUID());
						doctorHealthStandard.setMaxValue1(obj.has("max_value1") ? NumberUtils.toDouble(obj.getString("max_value1"), 0) : 0);
						doctorHealthStandard.setMaxValue2(obj.has("max_value2") ? NumberUtils.toDouble(obj.getString("max_value2"), 0) : 0);
						doctorHealthStandard.setMinValue1(obj.has("min_value1") ? NumberUtils.toDouble(obj.getString("min_value1"), 0) : 0);
						doctorHealthStandard.setMinValue2(obj.has("min_value2") ? NumberUtils.toDouble(obj.getString("min_value2"), 0) : 0);
						doctorHealthStandard.setType(obj.getInt("type"));
						doctorHealthStandard.setCzrq(new Date());
						doclist.add(doctorHealthStandard);
					}
					if (list.size() == 0) {
						return error(-1, "保存失败!");
					}
					// 保存数据库
					Iterable<PatientHealthStandard> iterable = healthIndexService.saveStandard(list, patient);
					if (iterable == null || iterable.iterator() == null || !iterable.iterator().hasNext()) {
						return error(-1, "保存失败!");
					}
					Iterable<DoctorHealthStandard> dociterable = healthIndexService.saveDocStandard(doclist, getUID());
					if (dociterable == null || dociterable.iterator() == null || !dociterable.iterator().hasNext()) {
						return error(-1, "保存失败!");
					}
				}
				PatientHealthStandard standard = new PatientHealthStandard();
				standard.setDoctor(getUID());
				standard.setMaxValue1(obj.has("max_value1") ? NumberUtils.toDouble(obj.getString("max_value1"), 0) : 0);
				standard.setMaxValue2(obj.has("max_value2") ? NumberUtils.toDouble(obj.getString("max_value2"), 0) : 0);
				standard.setMinValue1(obj.has("min_value1") ? NumberUtils.toDouble(obj.getString("min_value1"), 0) : 0);
				standard.setMinValue2(obj.has("min_value2") ? NumberUtils.toDouble(obj.getString("min_value2"), 0) : 0);
				standard.setType(obj.getInt("type"));
				standard.setPatient(patient);
				standard.setCzrq(new Date());
				list.add(standard);
			}
			if (list.size() == 0) {
				return error(-1, "保存失败!");
			}
			// 保存数据库
			Iterable<PatientHealthStandard> iterable = healthIndexService.saveStandard(list, patient);
			if (iterable == null || iterable.iterator() == null || !iterable.iterator().hasNext()) {
				return error(-1, "保存失败!");
			}
			return write(200, "保存成功");
		} catch (Exception e) {
			error(e);
@ -292,4 +325,67 @@ public class DoctorHealthController extends BaseController {
	@RequestMapping(value = "doctorstandard",method = RequestMethod.GET)
	@ResponseBody
	@ApiOperation("医生健康指标预警值方案查询")
	public String doctorstandard(@ApiParam("医生") @RequestParam String doctor) {
		try {
			JSONArray standardArray = new JSONArray();
			JSONArray userArray = new JSONArray();
			if(StringUtils.isBlank(doctor)){
				doctor = getUID();
			}
			Iterable<DoctorHealthStandard> iterable = healthIndexService.findDoctorStandardByDoctor(doctor);
			if(iterable == null){
				//如果获取不到,则获取系统默认方案
				iterable = healthIndexService.findDoctorStandardByDoctor("default");
			}
			Iterator<DoctorHealthStandard> iterator = null;
			if (iterable != null) {
				iterator = iterable.iterator();
			}
			// 预警值未设置,返回默认值
			StringBuffer sb = new StringBuffer();
			sb.append("[");
			// 默认血糖(餐前,餐后二小时)
			sb.append("{min_value_1:"+ SystemConf.HEALTH_STANDARD_ST_MIN_BEFORE +", max_value_1: "+ SystemConf.HEALTH_STANDARD_ST_MAX_BEFORE +", " +
					"min_value_2:"+ SystemConf.HEALTH_STANDARD_ST_MIN_AFTER +", max_value_2:"+ SystemConf.HEALTH_STANDARD_ST_MAX_AFTER +", type:1},");
			// 默认血压(收缩压,舒张压)
			sb.append("{min_value_1:"+ SystemConf.HEALTH_STANDARD_SSY_MIN +", max_value_1:"+ SystemConf.HEALTH_STANDARD_SSY_MAX +", " +
					"min_value_2:"+ SystemConf.HEALTH_STANDARD_SZY_MIN +", max_value_2:"+ SystemConf.HEALTH_STANDARD_SZY_MAX +", type:2}");
			sb.append("]");
			standardArray = new JSONArray(sb.toString());
			if (iterator != null) {
				while (iterator.hasNext()) {
					DoctorHealthStandard phs = iterator.next();
					if (phs == null) {
						continue;
					}
					JSONObject json = new JSONObject();
					// 最低安全值(血糖餐前\收缩压\体重\腰围)
					json.put("min_value_1", phs.getMinValue1());
					// 最高安全值(血糖餐前\收缩压\体重\腰围)
					json.put("max_value_1", phs.getMaxValue1());
					// 最低安全值(血糖餐后\舒张压)
					json.put("min_value_2", phs.getMinValue2());
					// 最高安全值(血糖餐后\舒张压)
					json.put("max_value_2", phs.getMaxValue2());
					// 健康指标类型:1血糖,2血压,3体重,4腰围
					json.put("type", phs.getType());
					userArray.put(json);
				}
			}
			JSONObject json = new JSONObject();
			json.put("standard", standardArray);
			json.put("custom", userArray);
			return write(200, "查询成功", "data", json);
		} catch (Exception e) {
			error(e);
			return invalidUserException(e, -1, "查询失败!");
		}
	}
}

+ 5 - 5
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/scheme/DoctroSchemeController.java

@ -20,7 +20,7 @@ import java.util.List;
 * @date 2017/9/13 15:39
 */
@RestController
@RequestMapping(value = "/doctor/scheme/")
@RequestMapping(value = "/doctor/scheme")
@Api(description = "医生端-监测方案相关接口")
public class DoctroSchemeController extends BaseController {
@ -32,10 +32,10 @@ public class DoctroSchemeController extends BaseController {
    @RequestMapping(value="/get/disease/patientcodes",method = RequestMethod.GET)
    @ApiOperation("医生端-根据居民标签/病情/设备绑定状态查询团队居民CODE列表")
    public String getDiseasePatientCodes (
            @ApiParam(name="teamCode", value="团队CODE") @RequestParam(value = "teamCode",required = true) String teamCode,
            @ApiParam(name="disease", value="疾病类型,-1全部,0健康,1高血压,2糖尿病,3高血压+糖尿病") @RequestParam(value = "disease",required = true) Integer disease,
            @ApiParam(name="diseaseCondition", value="居民标签:-1全部,0绿标,1黄标,2红标") @RequestParam(value = "diseaseCondition",required = true) Integer diseaseCondition,
            @ApiParam(name="deviceType", value="设备类型:-1全部,0未绑定,1已绑定") @RequestParam(value = "deviceType",required = true) Integer deviceType
            @ApiParam(name="teamCode", value="团队CODE") @RequestParam(value = "teamCode",required = true,defaultValue = "642") String teamCode,
            @ApiParam(name="disease", value="疾病类型,-1全部,0健康,1高血压,2糖尿病,3高血压+糖尿病",defaultValue = "-1") @RequestParam(value = "disease",required = true) Integer disease,
            @ApiParam(name="diseaseCondition", value="居民标签:0绿标,1黄标,2红标",defaultValue = "0,1,2") @RequestParam(value = "diseaseCondition",required = true) String diseaseCondition,
            @ApiParam(name="deviceType", value="设备类型:-1全部,0未绑定,1已绑定",defaultValue = "-1") @RequestParam(value = "deviceType",required = true) Integer deviceType
            ){
        try {