Parcourir la source

慢病管理:居民列表,分类数据,监测方案相关接口代码提交

huangwenjie il y a 7 ans
Parent
commit
addc921291
24 fichiers modifiés avec 1189 ajouts et 77 suppressions
  1. 15 8
      common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/scheme/DoctorSchemeBloodPressure.java
  2. 13 4
      common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/scheme/DoctorSchemeBloodSugger.java
  3. 50 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/scheme/vo/DoctorSchemeBloodPressureVO.java
  4. 50 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/scheme/vo/DoctorSchemeBloodSuggerVO.java
  5. 1 1
      common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/team/sign/SignPatientLabel.java
  6. 1 1
      common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/Patient.java
  7. 1 1
      common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/PatientSchemeList.java
  8. 2 1
      patient-co/patient-co-statistics/src/main/resources/application.yml
  9. 24 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/DoctoreSchemeBloodPressureDao.java
  10. 15 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/DoctoreSchemeBloodSuggerDao.java
  11. 29 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/DoctroSchemeBloodSuggerDao.java
  12. 19 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/scheme/PatientSchemeListDao.java
  13. 1 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionExpressageDao.java
  14. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/PatientHealthIndexService.java
  15. 466 10
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/label/SignPatientLabelInfoService.java
  16. 372 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/scheme/DoctorSchemeService.java
  17. 7 27
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/SignWebService.java
  18. 10 8
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/account/PatientService.java
  19. 30 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/DateUtil.java
  20. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthEduArticleController.java
  21. 76 9
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/SignPatientLabelInfoController.java
  22. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorSignController.java
  23. 2 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/health/PatientHealthController.java
  24. 2 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/controller/doctor/GcLableController.java

+ 15 - 8
common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/scheme/DoctorSchemeBloodPressure.java

@ -1,5 +1,6 @@
package com.yihu.wlyy.entity.doctor.scheme;
package com.yihu.wlyy.entity.doctor.scheme;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.*;
import javax.persistence.*;
@ -14,10 +15,10 @@ import java.sql.Timestamp;
@Entity
@Entity
@Table(name = "wlyy_doctor_scheme_blood_pressure")
@Table(name = "wlyy_doctor_scheme_blood_pressure")
public class DoctorSchemeBloodPressure extends IdEntity {
public class DoctorSchemeBloodPressure extends IdEntity {
    private String name;
    private String name;                //方案名称
    private String code;
    private String code;
    private String doctorcode;
    private short dayofweek;
    private String doctorcode;          //医生CODE
    private Short dayofweek;            //星期几
    private Short earlyMorning;
    private Short earlyMorning;
    private Time earlyMorningTime;
    private Time earlyMorningTime;
    private Short morning;
    private Short morning;
@ -28,9 +29,9 @@ public class DoctorSchemeBloodPressure extends IdEntity {
    private Time afterNoonTime;
    private Time afterNoonTime;
    private Short night;
    private Short night;
    private Time nightTime;
    private Time nightTime;
    private Timestamp createTime;
    private Short alertTag;
    private String content;
    private Timestamp createTime;      //创建时间
    private Short alertTag;            //是否提醒用户
    private String content;            //方案说明
    @Basic
    @Basic
    @Column(name = "name")
    @Column(name = "name")
@ -64,11 +65,11 @@ public class DoctorSchemeBloodPressure extends IdEntity {
    @Basic
    @Basic
    @Column(name = "dayofweek")
    @Column(name = "dayofweek")
    public short getDayofweek() {
    public Short getDayofweek() {
        return dayofweek;
        return dayofweek;
    }
    }
    public void setDayofweek(short dayofweek) {
    public void setDayofweek(Short dayofweek) {
        this.dayofweek = dayofweek;
        this.dayofweek = dayofweek;
    }
    }
@ -84,6 +85,7 @@ public class DoctorSchemeBloodPressure extends IdEntity {
    @Basic
    @Basic
    @Column(name = "early_morning_time")
    @Column(name = "early_morning_time")
    @JsonFormat(pattern = "HH:mm", timezone = "GMT+08:00")
    public Time getEarlyMorningTime() {
    public Time getEarlyMorningTime() {
        return earlyMorningTime;
        return earlyMorningTime;
    }
    }
@ -104,6 +106,7 @@ public class DoctorSchemeBloodPressure extends IdEntity {
    @Basic
    @Basic
    @Column(name = "morning_time")
    @Column(name = "morning_time")
    @JsonFormat(pattern = "HH:mm", timezone = "GMT+08:00")
    public Time getMorningTime() {
    public Time getMorningTime() {
        return morningTime;
        return morningTime;
    }
    }
@ -124,6 +127,7 @@ public class DoctorSchemeBloodPressure extends IdEntity {
    @Basic
    @Basic
    @Column(name = "noon_time")
    @Column(name = "noon_time")
    @JsonFormat(pattern = "HH:mm", timezone = "GMT+08:00")
    public Time getNoonTime() {
    public Time getNoonTime() {
        return noonTime;
        return noonTime;
    }
    }
@ -144,6 +148,7 @@ public class DoctorSchemeBloodPressure extends IdEntity {
    @Basic
    @Basic
    @Column(name = "after_noon_time")
    @Column(name = "after_noon_time")
    @JsonFormat(pattern = "HH:mm", timezone = "GMT+08:00")
    public Time getAfterNoonTime() {
    public Time getAfterNoonTime() {
        return afterNoonTime;
        return afterNoonTime;
    }
    }
@ -164,6 +169,7 @@ public class DoctorSchemeBloodPressure extends IdEntity {
    @Basic
    @Basic
    @Column(name = "night_time")
    @Column(name = "night_time")
    @JsonFormat(pattern = "HH:mm", timezone = "GMT+08:00")
    public Time getNightTime() {
    public Time getNightTime() {
        return nightTime;
        return nightTime;
    }
    }
@ -174,6 +180,7 @@ public class DoctorSchemeBloodPressure extends IdEntity {
    @Basic
    @Basic
    @Column(name = "create_time")
    @Column(name = "create_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Timestamp getCreateTime() {
    public Timestamp getCreateTime() {
        return createTime;
        return createTime;
    }
    }

+ 13 - 4
common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/scheme/DoctorSchemeBloodSugger.java

@ -1,5 +1,6 @@
package com.yihu.wlyy.entity.doctor.scheme;
package com.yihu.wlyy.entity.doctor.scheme;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.*;
import javax.persistence.*;
@ -14,10 +15,10 @@ import java.sql.Timestamp;
@Entity
@Entity
@Table(name = "wlyy_doctor_scheme_blood_sugger")
@Table(name = "wlyy_doctor_scheme_blood_sugger")
public class DoctorSchemeBloodSugger extends IdEntity {
public class DoctorSchemeBloodSugger extends IdEntity {
    private String name;
    private String name;                    //方案名称
    private String code;
    private String code;
    private String doctorcode;
    private String doctorcode;
    private Short dayofweek;
    private Short dayofweek;                //星期几:1-7,1代表周日,7代表周六
    private Short beforeBreakfast;
    private Short beforeBreakfast;
    private Time beforeBreakfastTime;
    private Time beforeBreakfastTime;
    private Short afterBreakfast;
    private Short afterBreakfast;
@ -33,8 +34,8 @@ public class DoctorSchemeBloodSugger extends IdEntity {
    private Short beforeSleep;
    private Short beforeSleep;
    private Time beforeSleepTime;
    private Time beforeSleepTime;
    private Timestamp createTime;
    private Timestamp createTime;
    private Short alertTag;
    private String content;
    private Short alertTag;                 //是否提醒用户
    private String content;                 //方案说明
    @Basic
    @Basic
    @Column(name = "name")
    @Column(name = "name")
@ -88,6 +89,7 @@ public class DoctorSchemeBloodSugger extends IdEntity {
    @Basic
    @Basic
    @Column(name = "before_breakfast_time")
    @Column(name = "before_breakfast_time")
    @JsonFormat(pattern = "HH:mm", timezone = "GMT+08:00")
    public Time getBeforeBreakfastTime() {
    public Time getBeforeBreakfastTime() {
        return beforeBreakfastTime;
        return beforeBreakfastTime;
    }
    }
@ -108,6 +110,7 @@ public class DoctorSchemeBloodSugger extends IdEntity {
    @Basic
    @Basic
    @Column(name = "after_breakfast_time")
    @Column(name = "after_breakfast_time")
    @JsonFormat(pattern = "HH:mm", timezone = "GMT+08:00")
    public Time getAfterBreakfastTime() {
    public Time getAfterBreakfastTime() {
        return afterBreakfastTime;
        return afterBreakfastTime;
    }
    }
@ -128,6 +131,7 @@ public class DoctorSchemeBloodSugger extends IdEntity {
    @Basic
    @Basic
    @Column(name = "before_lunch_time")
    @Column(name = "before_lunch_time")
    @JsonFormat(pattern = "HH:mm", timezone = "GMT+08:00")
    public Time getBeforeLunchTime() {
    public Time getBeforeLunchTime() {
        return beforeLunchTime;
        return beforeLunchTime;
    }
    }
@ -148,6 +152,7 @@ public class DoctorSchemeBloodSugger extends IdEntity {
    @Basic
    @Basic
    @Column(name = "after_lunch_time")
    @Column(name = "after_lunch_time")
    @JsonFormat(pattern = "HH:mm", timezone = "GMT+08:00")
    public Time getAfterLunchTime() {
    public Time getAfterLunchTime() {
        return afterLunchTime;
        return afterLunchTime;
    }
    }
@ -168,6 +173,7 @@ public class DoctorSchemeBloodSugger extends IdEntity {
    @Basic
    @Basic
    @Column(name = "before_dinner_time")
    @Column(name = "before_dinner_time")
    @JsonFormat(pattern = "HH:mm", timezone = "GMT+08:00")
    public Time getBeforeDinnerTime() {
    public Time getBeforeDinnerTime() {
        return beforeDinnerTime;
        return beforeDinnerTime;
    }
    }
@ -188,6 +194,7 @@ public class DoctorSchemeBloodSugger extends IdEntity {
    @Basic
    @Basic
    @Column(name = "after_dinner_time")
    @Column(name = "after_dinner_time")
    @JsonFormat(pattern = "HH:mm", timezone = "GMT+08:00")
    public Time getAfterDinnerTime() {
    public Time getAfterDinnerTime() {
        return afterDinnerTime;
        return afterDinnerTime;
    }
    }
@ -208,6 +215,7 @@ public class DoctorSchemeBloodSugger extends IdEntity {
    @Basic
    @Basic
    @Column(name = "before_sleep_time")
    @Column(name = "before_sleep_time")
    @JsonFormat(pattern = "HH:mm", timezone = "GMT+08:00")
    public Time getBeforeSleepTime() {
    public Time getBeforeSleepTime() {
        return beforeSleepTime;
        return beforeSleepTime;
    }
    }
@ -218,6 +226,7 @@ public class DoctorSchemeBloodSugger extends IdEntity {
    @Basic
    @Basic
    @Column(name = "create_time")
    @Column(name = "create_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Timestamp getCreateTime() {
    public Timestamp getCreateTime() {
        return createTime;
        return createTime;
    }
    }

+ 50 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/scheme/vo/DoctorSchemeBloodPressureVO.java

@ -0,0 +1,50 @@
package com.yihu.wlyy.entity.doctor.scheme.vo;
import com.yihu.wlyy.entity.doctor.scheme.DoctorSchemeBloodPressure;
import java.util.List;
/**
 * 医生血压监测VO类
 * @author huangwenjie
 * @date 2017/9/13 21:28
 */
public class DoctorSchemeBloodPressureVO {
    private String                          code;
    private String                          name;       //名字
    private String                          content;    //说明
    private List<DoctorSchemeBloodPressure> list;       //详情
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getContent() {
        return content;
    }
    public void setContent(String content) {
        this.content = content;
    }
    public List<DoctorSchemeBloodPressure> getList() {
        return list;
    }
    public void setList(List<DoctorSchemeBloodPressure> list) {
        this.list = list;
    }
}

+ 50 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/scheme/vo/DoctorSchemeBloodSuggerVO.java

@ -0,0 +1,50 @@
package com.yihu.wlyy.entity.doctor.scheme.vo;
import com.yihu.wlyy.entity.doctor.scheme.DoctorSchemeBloodSugger;
import java.util.List;
/**
 * 医生血糖VO类
 * @author huangwenjie
 * @date 2017/9/13 21:40
 */
public class DoctorSchemeBloodSuggerVO {
    private String                          code;
    private String                          name;       //名字
    private String                          content;    //说明
    private List<DoctorSchemeBloodSugger> list;       //详情
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getContent() {
        return content;
    }
    public void setContent(String content) {
        this.content = content;
    }
    public List<DoctorSchemeBloodSugger> getList() {
        return list;
    }
    public void setList(List<DoctorSchemeBloodSugger> list) {
        this.list = list;
    }
}

+ 1 - 1
common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/team/sign/SignPatientLabel.java

@ -16,7 +16,7 @@ public class SignPatientLabel extends IdEntity {
    private String labelCode;
    private String labelCode;
    // 标签名称
    // 标签名称
    private String labelName;
    private String labelName;
    // 标签类型 1:卫计委三大分组 2:健康情况 3:疾病类型 4:自定义
    // 标签类型 1:服务类型 2:健康情况 3:疾病类型 4:自定义
    private String labelType;
    private String labelType;
    // 是否系统标签
    // 是否系统标签
    private Integer isSystem;
    private Integer isSystem;

+ 1 - 1
common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/Patient.java

@ -72,7 +72,7 @@ public class Patient extends IdEntity implements Serializable {
	private String address;
	private String address;
	// 疾病类型,0健康,1高血压,2糖尿病,3高血压+糖尿病
	// 疾病类型,0健康,1高血压,2糖尿病,3高血压+糖尿病
	private Integer disease;
	private Integer disease;
	// 病情:0绿标,1黄标,2红标,3重点关注
	// 病情:0绿标,1黄标,2红标
	private Integer diseaseCondition;
	private Integer diseaseCondition;
	// 病历记录总数
	// 病历记录总数
	private Integer recordAmount;
	private Integer recordAmount;

+ 1 - 1
common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/PatientSchemeList.java

@ -16,7 +16,7 @@ public class PatientSchemeList extends IdEntity {
    private String code;
    private String code;
    private String patientcode;
    private String patientcode;
    private String schemecode;
    private String schemecode;
    private Short type;
    private Short type;//方案类型:0为血压,1为血糖
    private String doctorcode;
    private String doctorcode;
    private Timestamp createTime;
    private Timestamp createTime;

+ 2 - 1
patient-co/patient-co-statistics/src/main/resources/application.yml

@ -218,8 +218,9 @@ spring:
      password: 123456
      password: 123456
  redis:
  redis:
    host: 172.19.103.47 # Redis server host.
    host: 172.19.103.88 # Redis server host.
    port: 6379 # Redis server port.
    port: 6379 # Redis server port.
#    password: jkzl_ehr
  followupMessage:
  followupMessage:
    cron : 0 5 0 * * ?
    cron : 0 5 0 * * ?

+ 24 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/DoctoreSchemeBloodPressureDao.java

@ -0,0 +1,24 @@
package com.yihu.wlyy.repository.doctor;
import com.yihu.wlyy.entity.doctor.scheme.DoctorSchemeBloodPressure;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * 血压监测方案底层相关方法
 * @author huangwenjie
 * @date 2017/9/13 20:24
 */
public interface DoctoreSchemeBloodPressureDao extends
        PagingAndSortingRepository<DoctorSchemeBloodPressure, Long>,
        JpaSpecificationExecutor<DoctorSchemeBloodPressure> {
    @Query(" from DoctorSchemeBloodPressure p where p.doctorcode=?1 ORDER BY createTime DESC ")
    List<DoctorSchemeBloodPressure> getListByDoctorcode(String doctorCode);
    @Query(" from DoctorSchemeBloodPressure p where p.code=?1")
    DoctorSchemeBloodPressure findByCode(String code);
}

+ 15 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/DoctoreSchemeBloodSuggerDao.java

@ -0,0 +1,15 @@
package com.yihu.wlyy.repository.doctor;
import com.yihu.wlyy.entity.doctor.scheme.DoctorSchemeBloodSugger;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * 血糖监测方案底层相关方法
 * @author huangwenjie
 * @date 2017/9/14 00:04
 */
public interface DoctoreSchemeBloodSuggerDao extends
        PagingAndSortingRepository<DoctorSchemeBloodSugger, Long>,
        JpaSpecificationExecutor<DoctorSchemeBloodSugger> {
}

+ 29 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/DoctroSchemeBloodSuggerDao.java

@ -0,0 +1,29 @@
package com.yihu.wlyy.repository.doctor;
import com.yihu.wlyy.entity.doctor.scheme.DoctorSchemeBloodSugger;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.List;
/**
 * 医生血糖监测方案底层相关方法
 * @author huangwenjie
 * @date 2017/9/13 20:08
 */
@Entity
@Table(name = "wlyy_doctor_scheme_blood_sugger")
public interface DoctroSchemeBloodSuggerDao extends
        PagingAndSortingRepository<DoctorSchemeBloodSugger, Long>,
        JpaSpecificationExecutor<DoctorSchemeBloodSugger> {
    @Query(" from DoctorSchemeBloodSugger p where p.doctorcode=?1 ORDER BY createTime DESC ")
    List<DoctorSchemeBloodSugger> getListByDoctorcode(String doctorcode);
    @Query(" from DoctorSchemeBloodSugger p where p.code=?1")
    DoctorSchemeBloodSugger findByCode(String code);
}

+ 19 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/scheme/PatientSchemeListDao.java

@ -0,0 +1,19 @@
package com.yihu.wlyy.repository.patient.scheme;
import com.yihu.wlyy.entity.patient.PatientSchemeList;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * 监测方案关联关系表
 * @author huangwenjie
 * @date 2017/9/13 23:21
 */
public interface PatientSchemeListDao extends
        PagingAndSortingRepository<PatientSchemeList, Long>,
        JpaSpecificationExecutor<PatientSchemeList> {
    @Query("delete from PatientSchemeList where patientcode=?1 and type=?2 and schemecode=?3")
    void delByPatientCodeAndSchemeCode(String patientcode, int i, String code);
}

+ 1 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionExpressageDao.java

@ -15,6 +15,7 @@ public interface PrescriptionExpressageDao extends PagingAndSortingRepository<Pr
    @Query("from PrescriptionExpressage p where p.mailno=?1")
    @Query("from PrescriptionExpressage p where p.mailno=?1")
    PrescriptionExpressage findByPrescriptionExpressMailno(String mailno);
    PrescriptionExpressage findByPrescriptionExpressMailno(String mailno);
    @Query(" from PrescriptionExpressage p where p.prescriptionCode=?1 and p.del=1")
    @Query(" from PrescriptionExpressage p where p.prescriptionCode=?1 and p.del=1")
    PrescriptionExpressage findByPrescriptionCode(String prescriptionCode);
    PrescriptionExpressage findByPrescriptionCode(String prescriptionCode);
}
}

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

@ -642,7 +642,7 @@ public class PatientHealthIndexService extends BaseService {
     * 新增患者指标
     * 新增患者指标
     * 【血糖】{"time":"2016-09-09 17:00:00","gi":"血糖值(mmol/L)"}
     * 【血糖】{"time":"2016-09-09 17:00:00","gi":"血糖值(mmol/L)"}
     * 【血压】{"time":"2016-09-09 17:00:00","sys":"收缩压(mmHg)","dia":"舒张压(mmHg)","pul":"脉搏(次/分)","ano":"有无心率不齐0否 1是","user":"身份标识"}
     * 【血压】{"time":"2016-09-09 17:00:00","sys":"收缩压(mmHg)","dia":"舒张压(mmHg)","pul":"脉搏(次/分)","ano":"有无心率不齐0否 1是","user":"身份标识"}
     * 【体重】{"time":"2016-09-09 17:00:00","weight":"体重值(kg)"}
     * 【体重/身高】{"time":"2016-09-09 17:00:00","weight":"体重值(kg)","height":"身高(cm)"}
     * 【腰围】{"time":"2016-09-09 17:00:00","waistline":"腰围值(cm)"}
     * 【腰围】{"time":"2016-09-09 17:00:00","waistline":"腰围值(cm)"}
     *
     *
     * @return
     * @return

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

@ -240,10 +240,11 @@ public class SignPatientLabelInfoService extends BaseService {
     * @param labelType 标签类型
     * @param labelType 标签类型
     * @param page      第几页
     * @param page      第几页
     * @param pagesize  页大小
     * @param pagesize  页大小
     * @param sortByStandardStatus
     * @param isSlowDisease 是否是慢病管理
     * @param diseaseCondition
     * @return
     * @return
     */
     */
    public JSONArray getPatientByLabel(String doctor, String labelCode, String labelType, Long teamCode, int page, int pagesize, boolean sortByStandardStatus) throws Exception {
    public JSONArray getPatientByLabel(String doctor, String labelCode, String labelType, Long teamCode, int page, int pagesize, boolean isSlowDisease, String diseaseCondition) throws Exception {
        Doctor doc = doctorDao.findByCode(doctor);
        Doctor doc = doctorDao.findByCode(doctor);
        if (doc == null) {
        if (doc == null) {
@ -310,10 +311,16 @@ public class SignPatientLabelInfoService extends BaseService {
                    " ) f " +
                    " ) f " +
                    "WHERE " +
                    "WHERE " +
                    " f. CODE = s.sign_code " +
                    " f. CODE = s.sign_code " +
                    " AND s.server_type ='"+labelCode+"' " +
                    " ORDER BY " +
                    " AND s.server_type ='"+labelCode+"' ";
            if(StringUtils.isNotBlank(diseaseCondition)){
                sql = sql + " AND p.diseaseCondition = ?";
                args = new Object[]{doctor, doctor, teamCode,diseaseCondition};
            }else{
                args = new Object[]{doctor, doctor, teamCode};
            }
            sql = sql + " ORDER BY " +
                    " f.ptOpenid DESC";
                    " f.ptOpenid DESC";
            args = new Object[]{doctor, doctor, teamCode};
        } else {
        } else {
            if (labelCode.equals("0")) {
            if (labelCode.equals("0")) {
                sql = "SELECT " +
                sql = "SELECT " +
@ -353,7 +360,7 @@ public class SignPatientLabelInfoService extends BaseService {
        signList = jdbcTemplate.queryForList(sql, args);
        signList = jdbcTemplate.queryForList(sql, args);
        //查询患者设备绑定情况
        //查询患者设备绑定情况
        if(sortByStandardStatus){
        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";
            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);
            patientDeviceTypeMap = jdbcTemplate.queryForMap(_pdsql);
        }
        }
@ -506,7 +513,7 @@ public class SignPatientLabelInfoService extends BaseService {
                    int re = 0;
                    int re = 0;
                    //是否根据预警字段优先排序
                    //是否根据预警字段优先排序
                    if(sortByStandardStatus){
                    if(isSlowDisease){
                        int standardStatus1 = o1.has("standardStatus")?o1.getInt("standardStatus"):0;
                        int standardStatus1 = o1.has("standardStatus")?o1.getInt("standardStatus"):0;
                        int standardStatus2 = o2.has("standardStatus")?o2.getInt("standardStatus"):0;
                        int standardStatus2 = o2.has("standardStatus")?o2.getInt("standardStatus"):0;
@ -3552,10 +3559,11 @@ public class SignPatientLabelInfoService extends BaseService {
     * @param page
     * @param page
     * @param pagesize
     * @param pagesize
     * @param sortByStandardStatus 是否根据预警状态排序,如果true, 需要附带查询患者设备绑定情况
     * @param sortByStandardStatus 是否根据预警状态排序,如果true, 需要附带查询患者设备绑定情况
     * @param diseaseCondition
     * @return
     * @return
     * @throws Exception
     * @throws Exception
     */
     */
    public JSONArray getPatientByTeamCodeExitDoctor(long teamCode, String labelCode, String labelType, int page, int pagesize, boolean sortByStandardStatus) throws Exception {
    public JSONArray getPatientByTeamCodeExitDoctor(long teamCode, String labelCode, String labelType, int page, int pagesize, boolean sortByStandardStatus, String diseaseCondition) throws Exception {
        Map<String, JSONObject> result = new TreeMap<>();
        Map<String, JSONObject> result = new TreeMap<>();
        List<Map<String, Object>> signList = new ArrayList<>();
        List<Map<String, Object>> signList = new ArrayList<>();
@ -3608,14 +3616,21 @@ public class SignPatientLabelInfoService extends BaseService {
                    "  WHERE " +
                    "  WHERE " +
                    "  p. CODE = t1.patient " +
                    "  p. CODE = t1.patient " +
                    "  AND t1. STATUS > 0 " +
                    "  AND t1. STATUS > 0 " +
                    "  AND t1.admin_team_code = ?" +
                    "  AND t1.admin_team_code = ?";
            if(StringUtils.isNotBlank(diseaseCondition)){
                sql = sql + " AND p.diseaseCondition = ?";
                args = new Object[]{teamCode,diseaseCondition};
            }else{
                args = new Object[]{teamCode};
            }
            sql = sql +
                    " ) f " +
                    " ) f " +
                    "WHERE " +
                    "WHERE " +
                    " f. CODE = s.sign_code " +
                    " f. CODE = s.sign_code " +
                    " AND s.server_type ='"+labelCode+"' " +
                    " AND s.server_type ='"+labelCode+"' " +
                    " ORDER BY " +
                    " ORDER BY " +
                    " f.ptOpenid DESC";
                    " f.ptOpenid DESC";
                args = new Object[]{teamCode};
        }else {
        }else {
            if ("0".equals(labelCode)) {
            if ("0".equals(labelCode)) {
                sql = "SELECT " +
                sql = "SELECT " +
@ -3992,4 +4007,445 @@ public class SignPatientLabelInfoService extends BaseService {
        }
        }
    }
    }
    /**
     * 慢病管理-根据患者姓名或标签名称查询
     *
     * @param doctor
     * @param filter
     * @param diseaseCondition
     * @return
     * @throws Exception
     */
    public JSONArray searchSlowDiseasePatientByNameOrLabel(String doctor, String filter,
                                                           String labelCode, String labelType, long teamCode,
                                                           String exLabelCode,
                                                           String exLabelType,
                                                           int page, int pagesize, String diseaseCondition) throws Exception {
        Doctor doc = doctorDao.findByCode(doctor);
        Map<String,Object> patientDeviceTypeMap = new HashMap<>();//用于存储患者设备绑定情况
        if (doc == null) {
            throw new Exception("doctor info can not find");
        }
        Map<String, JSONObject> result = new HashMap<>();
        List<Map<String, Object>> signList = new ArrayList<>();
        page = page * pagesize;
        Object[] args = null;
        String sql = "";
        //String reg = "(^\\d{15}$)|(^\\d{17}([0-9]|X)$)";
//        String reg = "^(\\d+)([0-9]|X|x)$";
//        匹配数字字符串
        String reg = "[0-9]{1,}";
        Pattern pattern = Pattern.compile(reg);
        Matcher matcher = pattern.matcher(filter);
        sql = "select " +
                "    DISTINCT t1.* " +
                " FROM " +
                "    wlyy_sign_family t1 " +
                " JOIN wlyy_sign_patient_label_info t2 ON t1.patient = t2.patient " +
                " JOIN wlyy_patiend t3 ON t1.patient = t3.code " +
                (teamCode > 0 ? " join (select * from wlyy_sign_patient_label where label_type != '4' or team_code = " + teamCode + " or (label_type = '4' and (label_code in (1,2)))) lb on t2.label = lb.label_code and t2.label_type = lb.label_type " : "") +
                " WHERE " +
                "    (t1.doctor = ? or t1.doctor_health = ?) " +
                "    AND t1.status > 0 " +
                "    AND t2.status = 1) " +
                (StringUtils.isNotEmpty(labelCode) ? " AND t2.label = ? " : " AND (t2.label = 4 or t2.label = 5 )") +
                (StringUtils.isNotEmpty(labelType) ? " AND t2.label_type = ? " : "") +
                (teamCode > 0 ? (" AND admin_team_code = " + teamCode) : "")+
                (StringUtils.isNotEmpty(diseaseCondition) ? " AND t3.diseaseCondition = ? " : "");
        if (matcher.find()) {
            sql = sql + "  AND (t1.idcard like ?) ";
            if (StringUtils.isNotEmpty(labelCode)) {
                args = new Object[]{doctor, doctor, labelCode, labelType, "%" + filter + "%"};
            } else if (StringUtils.isEmpty(labelCode) && StringUtils.isNotEmpty(labelType)) {
                args = new Object[]{doctor, doctor, labelType, "%" + filter + "%"};
            } else {
                args = new Object[]{doctor, doctor, "%" + filter + "%"};
            }
        } else {
            sql = sql + "  AND (t1.name like ? or t2.label_name like ?) ";
            if (StringUtils.isNotEmpty(labelCode)) {
                args = new Object[]{doctor, doctor, labelCode, labelType, "%" + filter + "%", "%" + filter + "%"};
            } else if (StringUtils.isEmpty(labelCode) && StringUtils.isNotEmpty(labelType)) {
                args = new Object[]{doctor, doctor, labelType, "%" + filter + "%", "%" + filter + "%"};
            } else {
                args = new Object[]{doctor, doctor, "%" + filter + "%", "%" + filter + "%"};
            }
        }
        if(StringUtils.isNotEmpty(diseaseCondition)){
            Object[] argsnew = new Object[args.length+1];
            for (int i = 0; i < argsnew.length; i++) {
                if(i == (argsnew.length-1)){
                    argsnew[i] = diseaseCondition;
                }else{
                    argsnew[i] = args[i];
                }
            }
            sql = sql + " order by 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;
            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);
        if (signList != null && signList.size() > 0) {
            for (Map<String, Object> sign : signList) {
                Patient p = patientDao.findByCode(sign.get("patient") == null ? "" : sign.get("patient").toString());
                if (p == null) {
                    continue;
                }
                if (result.containsKey(p.getCode())) {
                    JSONObject jsonP = result.get(p.getCode());
                    if (!String.valueOf(jsonP.get("signType")).equals(String.valueOf(sign.get("type")))) {
                        jsonP.put("signType", 3);
                    }
                    if (String.valueOf(sign.get("type")).equals("2")) {
                        jsonP.put("qyrq", sign.get("apply_date") != null ? DateUtil.dateToStr((Date) sign.get("apply_date"), DateUtil.YYYY_MM_DD) : "");
                        // 缴费情况
                        jsonP.put("expensesStatus", sign.get("expenses_status") != null ? String.valueOf(sign.get("expenses_status")) : "0");
                        // 缴费时间
                        jsonP.put("expensesTime", sign.get("expenses_time") != null ? DateUtil.dateToStr((Date) sign.get("expenses_time"), DateUtil.YYYY_MM_DD_HH_MM) : "");
                        // 缴费类型
                        jsonP.put("expensesType", sign.get("expenses_type") != null ? String.valueOf(sign.get("expenses_type")) : "");
                        if (StringUtils.isEmpty(String.valueOf(jsonP.get("expensesStatus"))) || String.valueOf(jsonP.get("expensesStatus")).equals("0")) {
                            boolean epTime = false;
                            try {
                                epTime = redisTemplate.opsForSet().isMember("expenses:remind:set", p.getCode());
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                            if (!epTime) {
                                jsonP.put("expensesRemindStatus", 0);
                            } else {
                                jsonP.put("expensesRemindStatus", 1);
                            }
                        }
                        boolean epTime = false;
                        try {
                            epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", p.getCode());
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        if (!epTime) {
                            jsonP.put("wechatFocusRemind", 0);
                        } else {
                            jsonP.put("wechatFocusRemind", 1);
                        }
                    }
                    continue;
                }
                if (StringUtils.isNotEmpty(exLabelCode)) {
                    SignPatientLabelInfo labelInfoEx = labelInfoDao.findByPatientAndLabelAndLabelTypeAndStatus(p.getCode(), exLabelCode, exLabelType, 1);
                    if (labelInfoEx != null) {
                        continue;
                    }
                } else if (StringUtils.isNotEmpty(exLabelType)) {
                    List<SignPatientLabelInfo> labelExs = labelInfoDao.findByPatientAndLabelTypeAndStatus(p.getCode(), exLabelType, 1);
                    if (labelExs != null && labelExs.size() > 0) {
                        continue;
                    }
                }
                List<SignPatientLabelInfo> labels = null;
                if (teamCode > 0) {
                    labels = labelInfoDao.findByPatientAndStatusByTeam(sign.get("patient").toString(), 1, teamCode);
                } else {
                    labels = labelInfoDao.findByPatientAndStatus(sign.get("patient").toString(), 1);
                }
                JSONObject json = new JSONObject();
                // 设置患者标识
                json.put("code", p.getCode());
                // 设置患者姓名
                json.put("name", p.getName());
                // 设置患者手机号
                json.put("mobile", p.getMobile());
                // 设置患者微信openid
                json.put("openid", StringUtils.isNotEmpty(p.getOpenid()) ? p.getOpenid() : "");
                // 设置患者联系电话
                json.put("phone", p.getPhone());
                // 设置患者紧急联系人
                json.put("emerMobile", sign.get("emer_mobile") == null ? "" : String.valueOf(sign.get("emer_mobile")));
                // 设置患者头像
                json.put("photo", p.getPhoto());
                // 设置患者年龄
                json.put("age", IdCardUtil.getAgeForIdcard(p.getIdcard()));
                // 设置患者性别
                json.put("sex", p.getSex());
                // 设置签约日期
                json.put("qyrq", sign.get("apply_date") != null ? DateUtil.dateToStr((Date) sign.get("apply_date"), DateUtil.YYYY_MM_DD) : "");
                // 设置签约类型
                json.put("signType", sign.get("type") == null ? "" : sign.get("type"));
                // 身份证号
                json.put("idcard", p.getIdcard());
                // 社保号
                json.put("ssc", p.getSsc());
                if (String.valueOf(sign.get("type")).equals("2")) {
                    // 缴费情况
                    json.put("expensesStatus", sign.get("expenses_status") != null ? String.valueOf(sign.get("expenses_status")) : "0");
                    // 缴费时间
                    json.put("expensesTime", sign.get("expenses_time") != null ? DateUtil.dateToStr((Date) sign.get("expenses_time"), DateUtil.YYYY_MM_DD_HH_MM) : "");
                    // 缴费类型
                    json.put("expensesType", sign.get("expenses_type") != null ? String.valueOf(sign.get("expenses_type")) : "");
//                if("2".equals(String.valueOf(sign.get("type"))) && "1".equals(String.valueOf(sign.get("expenses_status")))){
//                    json.put("qyrq", sign.get("expenses_time") != null ? DateUtil.dateToStr((Date) sign.get("expenses_time"), DateUtil.YYYY_MM_DD) : "");
//                }
                    if (StringUtils.isEmpty(String.valueOf(json.get("expensesStatus"))) || String.valueOf(json.get("expensesStatus")).equals("0")) {
                        boolean epTime = false;
                        try {
                            epTime = redisTemplate.opsForSet().isMember("expenses:remind:set", p.getCode());
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        if (!epTime) {
                            json.put("expensesRemindStatus", 0);
                        } else {
                            json.put("expensesRemindStatus", 1);
                        }
                    }
                } else {
                    // 缴费情况
                    json.put("expensesStatus", "1");
                }
                //病情类型:0健康,1高血压,2糖尿病,3高血压+糖尿病
                json.put("disease",p.getDisease());
                // 病情:0绿标,1黄标,2红标,
                json.put("diseaseCondition",p.getDiseaseCondition());
                //预警状态
                json.put("standardStatus",p.getStandardStatus());
                //设备状态:0未绑定,1血糖仪,2血压仪,3血糖仪+血压仪
                Integer deviceType = 0;
                if(!patientDeviceTypeMap.isEmpty() && patientDeviceTypeMap.keySet().contains(p.getCode())){
                    deviceType = (Integer) patientDeviceTypeMap.get(p.getCode());
                }
                json.put("deviceType",deviceType);
                boolean epTime = false;
                try {
                    epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", p.getCode());
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (!epTime) {
                    json.put("wechatFocusRemind", 0);
                } else {
                    json.put("wechatFocusRemind", 1);
                }
                // 患者标签
                json.put("labels", labels == null ? "" : labels);
                result.put(p.getCode(), json);
            }
        }
        return result.size() > 0 ? new JSONArray(result.values()) : new JSONArray();
    }
    /**
     * "慢病管理-查询所有团队下患者
     *
     * @param filter 搜索关键字
     * @param diseaseCondition
     * @return
     */
    public JSONArray searchSlowDiseaseTeamsPatients(String filter, long teamCode, int page, int pagesize, String diseaseCondition) throws Exception {
        Map<String, JSONObject> result = new HashMap<>();
        List<Map<String, Object>> signList = new ArrayList<>();
        Map<String,Object> patientDeviceTypeMap = new HashMap<>();//用于存储患者设备绑定情况
        page = page * pagesize;
        //String reg = "(^\\d{15}$)|(^\\d{17}([0-9]|X)$)";
        String reg = "^(\\d+)([0-9]|X|x)$";
        Pattern pattern = Pattern.compile(reg);
        Matcher matcher = pattern.matcher(filter);
        boolean isIdcard = matcher.find();
        Object[] args = new Object[]{teamCode, "%" + filter + "%"};
        String sqlTemp = "select " +
                "    DISTINCT t1.* " +
                " FROM " +
                "    wlyy_sign_family t1 " +
                " JOIN wlyy_patiend t2 ON t1.patient = t2.code " +
                (isIdcard ? ",wlyy_patient p " : "") +
                " WHERE " +
                (isIdcard ? " t1.patient = p.code  and " : "") +
                "    t1.status > 0 " +
                " AND t1.admin_team_code = ? " +
                "  AND" +
                (isIdcard ? " p.idcard like ? " : " t1.name like ? ");
        String sql = sqlTemp + " order by 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);
        if (signList != null && signList.size() > 0) {
            for (Map<String, Object> sign : signList) {
                Patient p = patientDao.findByCode(sign.get("patient") == null ? "" : sign.get("patient").toString());
                if (p == null) {
                    continue;
                }
                if (result.containsKey(p.getCode())) {
                    JSONObject jsonP = result.get(p.getCode());
                    if (!String.valueOf(jsonP.get("signType")).equals(String.valueOf(sign.get("type")))) {
                        jsonP.put("signType", 3);
                    }
                    if (String.valueOf(sign.get("type")).equals("2")) {
                        jsonP.put("qyrq", sign.get("apply_date") != null ? DateUtil.dateToStr((Date) sign.get("apply_date"), DateUtil.YYYY_MM_DD) : "");
                        // 缴费情况
                        jsonP.put("expensesStatus", sign.get("expenses_status") != null ? String.valueOf(sign.get("expenses_status")) : "0");
                        // 缴费时间
                        jsonP.put("expensesTime", sign.get("expenses_time") != null ? DateUtil.dateToStr((Date) sign.get("expenses_time"), DateUtil.YYYY_MM_DD_HH_MM) : "");
                        // 缴费类型
                        jsonP.put("expensesType", sign.get("expenses_type") != null ? String.valueOf(sign.get("expenses_type")) : "");
                        if (StringUtils.isEmpty(String.valueOf(jsonP.get("expensesStatus"))) || String.valueOf(jsonP.get("expensesStatus")).equals("0")) {
                            boolean epTime = false;
                            try {
                                epTime = redisTemplate.opsForSet().isMember("expenses:remind:set", p.getCode());
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                            if (!epTime) {
                                jsonP.put("expensesRemindStatus", 0);
                            } else {
                                jsonP.put("expensesRemindStatus", 1);
                            }
                        }
                        boolean epTime = false;
                        try {
                            epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", p.getCode());
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        if (!epTime) {
                            jsonP.put("wechatFocusRemind", 0);
                        } else {
                            jsonP.put("wechatFocusRemind", 1);
                        }
                    }
                    continue;
                }
                List<SignPatientLabelInfo> labels = null;
                if (teamCode > 0) {
                    labels = labelInfoDao.findByPatientAndStatusByTeam(sign.get("patient").toString(), 1, teamCode);
                } else {
                    labels = labelInfoDao.findByPatientAndStatus(sign.get("patient").toString(), 1);
                }
                JSONObject json = new JSONObject();
                // 设置患者标识
                json.put("code", p.getCode());
                // 设置患者姓名
                json.put("name", p.getName());
                // 设置患者手机号
                json.put("mobile", p.getMobile());
                // 设置患者微信openid
                json.put("openid", StringUtils.isNotEmpty(p.getOpenid()) ? p.getOpenid() : "");
                // 设置患者联系电话
                json.put("phone", p.getPhone());
                // 设置患者紧急联系人
                json.put("emerMobile", sign.get("emer_mobile") == null ? "" : String.valueOf(sign.get("emer_mobile")));
                // 设置患者头像
                json.put("photo", p.getPhoto());
                // 设置患者年龄
                json.put("age", IdCardUtil.getAgeForIdcard(p.getIdcard()));
                // 设置患者性别
                json.put("sex", p.getSex());
                // 设置签约日期
                json.put("qyrq", sign.get("apply_date") != null ? DateUtil.dateToStr((Date) sign.get("apply_date"), DateUtil.YYYY_MM_DD) : "");
                // 设置签约类型
                json.put("signType", sign.get("type") == null ? "" : sign.get("type"));
                // 身份证号
                json.put("idcard", p.getIdcard());
                // 社保号
                json.put("ssc", p.getSsc());
                if (String.valueOf(sign.get("type")).equals("2")) {
                    // 缴费情况
                    json.put("expensesStatus", sign.get("expenses_status") != null ? String.valueOf(sign.get("expenses_status")) : "0");
                    // 缴费时间
                    json.put("expensesTime", sign.get("expenses_time") != null ? DateUtil.dateToStr((Date) sign.get("expenses_time"), DateUtil.YYYY_MM_DD_HH_MM) : "");
                    // 缴费类型
                    json.put("expensesType", sign.get("expenses_type") != null ? String.valueOf(sign.get("expenses_type")) : "");
                    if (StringUtils.isEmpty(String.valueOf(json.get("expensesStatus"))) || String.valueOf(json.get("expensesStatus")).equals("0")) {
                        boolean epTime = false;
                        try {
                            epTime = redisTemplate.opsForSet().isMember("expenses:remind:set", p.getCode());
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        if (!epTime) {
                            json.put("expensesRemindStatus", 0);
                        } else {
                            json.put("expensesRemindStatus", 1);
                        }
                    }
                } else {
                    // 缴费情况
                    json.put("expensesStatus", "1");
                }
                //病情类型:0健康,1高血压,2糖尿病,3高血压+糖尿病
                json.put("disease",p.getDisease());
                // 病情:0绿标,1黄标,2红标,
                json.put("diseaseCondition",p.getDiseaseCondition());
                //预警状态
                json.put("standardStatus",p.getStandardStatus());
                //设备状态:0未绑定,1血糖仪,2血压仪,3血糖仪+血压仪
                Integer deviceType = 0;
                if(!patientDeviceTypeMap.isEmpty() && patientDeviceTypeMap.keySet().contains(p.getCode())){
                    deviceType = (Integer) patientDeviceTypeMap.get(p.getCode());
                }
                json.put("deviceType",deviceType);
                boolean epTime = false;
                try {
                    epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", p.getCode());
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (!epTime) {
                    json.put("wechatFocusRemind", 0);
                } else {
                    json.put("wechatFocusRemind", 1);
                }
                // 患者标签
                json.put("labels", labels == null ? "" : labels);
                result.put(p.getCode(), json);
            }
        }
        return result.size() > 0 ? new JSONArray(result.values()) : new JSONArray();
    }
}
}

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

@ -0,0 +1,372 @@
package com.yihu.wlyy.service.app.scheme;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.entity.doctor.scheme.DoctorSchemeBloodPressure;
import com.yihu.wlyy.entity.doctor.scheme.DoctorSchemeBloodSugger;
import com.yihu.wlyy.entity.doctor.scheme.vo.DoctorSchemeBloodPressureVO;
import com.yihu.wlyy.entity.doctor.scheme.vo.DoctorSchemeBloodSuggerVO;
import com.yihu.wlyy.entity.patient.PatientSchemeList;
import com.yihu.wlyy.repository.doctor.DoctoreSchemeBloodPressureDao;
import com.yihu.wlyy.repository.doctor.DoctoreSchemeBloodSuggerDao;
import com.yihu.wlyy.repository.doctor.DoctroSchemeBloodSuggerDao;
import com.yihu.wlyy.repository.patient.scheme.PatientSchemeListDao;
import com.yihu.wlyy.util.DateUtil;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.stereotype.Service;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.DefaultTransactionDefinition;
import java.util.*;
/**
 * 医生监测方案相关业务层方法
 * @author huangwenjie
 * @date 2017/9/13 15:46
 */
@Service
public class DoctorSchemeService {
    private static Logger logger = LoggerFactory.getLogger(DoctorSchemeService.class);
    @Autowired
    JdbcTemplate jdbcTemplate;
    @Autowired
    private DoctroSchemeBloodSuggerDao doctroSchemeBloodSuggerDao;
    @Autowired
    private DoctoreSchemeBloodPressureDao doctoreSchemeBloodPressureDao;
    @Autowired
    private JpaTransactionManager transactionManager;
    @Autowired
    private PatientSchemeListDao patientSchemeListDao;
    @Autowired
    private DoctoreSchemeBloodSuggerDao doctoreSchemeBloodSuggerDao;
    /**
     * 根据团队CODE/居民标签/病情/设备绑定状态查询团队具名CODE列表
     * @param teamCode 团队CODE
     * @param disease  病情
     * @param diseaseCondition 居民标签
     * @param deviceType 设备绑定状态
     * @author huangwenjie
     * @date 2017/9/13 16:23
     * @return
     */
    public List<String> getPatientsByDiseaseConditionDiseaseDeviceType(String teamCode, Integer disease, Integer diseaseCondition, Integer deviceType) throws Exception{
        String sql = "select p.code from wlyy_patient p ";
        if(-1 != deviceType){
            sql = sql + " LEFT JOIN wlyy_patient_device dev on dev.user = p.code ";
        }
        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;
        }
        if(-1 != diseaseCondition){
            sql = sql + " and p.diseaseCondition ="+diseaseCondition;
        }
        if(-1 != deviceType){
            if( 0 == deviceType){
                sql = sql + " and dev.user is null ";
            }else{
                sql = sql + " and dev.user is not null ";
            }
        }
        List<String> result = jdbcTemplate.queryForList(sql,new Object[]{},String.class);
        return result;
    }
    /**
     * 获取医生的血糖监测方案,根据创建时间降序排序,系统方案放最后
     * @param doctorcode
     * @return
     * @throws Exception
     */
    public List<DoctorSchemeBloodSuggerVO> getDoctorScheBloodSuggerList(String doctorcode)  throws Exception {
        List<DoctorSchemeBloodSuggerVO> result = new ArrayList<>();
        HashMap<String,List<DoctorSchemeBloodSugger>> mapresult = new HashMap<>();
        List<DoctorSchemeBloodSugger> schemelist = doctroSchemeBloodSuggerDao.getListByDoctorcode(doctorcode);
        DoctorSchemeBloodSugger defaultSchemeBloodSugger = doctroSchemeBloodSuggerDao.findByCode("default");
        schemelist.add(defaultSchemeBloodSugger);
        for (DoctorSchemeBloodSugger doctorSchemeBloodSugger : schemelist) {
            if(mapresult.keySet().contains(doctorSchemeBloodSugger.getCode())){
                mapresult.get(doctorSchemeBloodSugger.getCode()).add(doctorSchemeBloodSugger);
            }else{
                List<DoctorSchemeBloodSugger> list = new ArrayList<>();
                list.add(doctorSchemeBloodSugger);
                mapresult.put(doctorSchemeBloodSugger.getCode(),list);
            }
        }
        for (String key :mapresult.keySet()) {
            DoctorSchemeBloodSuggerVO doctorSchemeBloodSuggerVO = new DoctorSchemeBloodSuggerVO();
            doctorSchemeBloodSuggerVO.setCode(key);
            doctorSchemeBloodSuggerVO.setName(mapresult.get(key).get(0).getName());
            doctorSchemeBloodSuggerVO.setContent(mapresult.get(key).get(0).getContent());
            doctorSchemeBloodSuggerVO.setList(mapresult.get(key));
            result.add(doctorSchemeBloodSuggerVO);
        }
        return result;
    }
    /**
     * 获取医生的血压监测方案,根据创建时间降序排序,系统方案放最后
     * @param doctorcode
     * @return
     * @throws Exception
     */
    public  List<DoctorSchemeBloodPressureVO>  getDoctorSchemeBloodPressureList(String doctorcode) throws Exception{
        List<DoctorSchemeBloodPressureVO> result = new ArrayList<>();
        HashMap<String,List<DoctorSchemeBloodPressure>> mapresult = new HashMap<>();
        List<DoctorSchemeBloodPressure> schemelist = doctoreSchemeBloodPressureDao.getListByDoctorcode(doctorcode);
        DoctorSchemeBloodPressure defaultSchemeBloodPressure = doctoreSchemeBloodPressureDao.findByCode("default");
        schemelist.add(defaultSchemeBloodPressure);
        for (DoctorSchemeBloodPressure doctorSchemeBloodPressure : schemelist) {
            if(mapresult.keySet().contains(doctorSchemeBloodPressure.getCode())){
                mapresult.get(doctorSchemeBloodPressure.getCode()).add(doctorSchemeBloodPressure);
            }else{
                List<DoctorSchemeBloodPressure> list = new ArrayList<>();
                list.add(doctorSchemeBloodPressure);
                mapresult.put(doctorSchemeBloodPressure.getCode(),list);
            }
        }
        for (String key :mapresult.keySet()) {
            DoctorSchemeBloodPressureVO doctorSchemeBloodPressureVO = new DoctorSchemeBloodPressureVO();
            doctorSchemeBloodPressureVO.setCode(key);
            doctorSchemeBloodPressureVO.setName(mapresult.get(key).get(0).getName());
            doctorSchemeBloodPressureVO.setContent(mapresult.get(key).get(0).getContent());
            doctorSchemeBloodPressureVO.setList(mapresult.get(key));
            result.add(doctorSchemeBloodPressureVO);
        }
        return result;
    }
    /**
     * 医生保存居民的血糖监测方案
     * @param data
     * @throws Exception
     */
    public void saveDoctorSchemeBloodSugger(String data) {
        JSONObject dataObj =  JSON.parseObject(data);
        List<DoctorSchemeBloodSugger> results = new ArrayList<>();
        List<String> patientcodeList = new ArrayList<>();
        String code = dataObj.getString("code");
        if(StringUtils.isBlank(code)){
            code = UUID.randomUUID().toString();
        }
        String name = dataObj.getString("name");
        String content = dataObj.getString("content");
        String doctorcode = dataObj.getString("doctorcode");
        JSONArray datalist = dataObj.getJSONArray("list");
        JSONArray patientcodes = dataObj.getJSONArray("patientcodes");
        for (int i = 0; i < patientcodes.size(); i++) {
            patientcodeList.add(datalist.getJSONObject(i).toString());
        }
        for (int i = 0; i < datalist.size(); i++) {
            DoctorSchemeBloodSugger doctorSchemeBloodSugger = new DoctorSchemeBloodSugger();
            Long id = datalist.getJSONObject(i).getLong("id");
            if(id != 0){
                doctorSchemeBloodSugger.setId(datalist.getJSONObject(i).getLong("id"));
            }
            doctorSchemeBloodSugger.setName(name);
            doctorSchemeBloodSugger.setCode(code);
            doctorSchemeBloodSugger.setDoctorcode(doctorcode);
            doctorSchemeBloodSugger.setDayofweek(datalist.getJSONObject(i).getShort("dayofweek"));
            doctorSchemeBloodSugger.setBeforeBreakfast(datalist.getJSONObject(i).getShort("beforeBreakfast"));
            doctorSchemeBloodSugger.setBeforeBreakfastTime(DateUtil.hhmmStrToTime(datalist.getJSONObject(i).getString("beforeBreakfastTime")));
            doctorSchemeBloodSugger.setAfterBreakfast(datalist.getJSONObject(i).getShort("afterBreakfast"));
            doctorSchemeBloodSugger.setAfterBreakfastTime(DateUtil.hhmmStrToTime(datalist.getJSONObject(i).getString("afterBreakfastTime")));
            doctorSchemeBloodSugger.setBeforeLunch(datalist.getJSONObject(i).getShort("beforeLunch"));
            doctorSchemeBloodSugger.setBeforeLunchTime(DateUtil.hhmmStrToTime(datalist.getJSONObject(i).getString("beforeLunchTime")));
            doctorSchemeBloodSugger.setAfterLunch(datalist.getJSONObject(i).getShort("afterLunch"));
            doctorSchemeBloodSugger.setAfterLunchTime(DateUtil.hhmmStrToTime(datalist.getJSONObject(i).getString("afterLunchTime")));
            doctorSchemeBloodSugger.setBeforeDinner(datalist.getJSONObject(i).getShort("beforeDinner"));
            doctorSchemeBloodSugger.setBeforeDinnerTime(DateUtil.hhmmStrToTime(datalist.getJSONObject(i).getString("beforeDinnerTime")));
            doctorSchemeBloodSugger.setAfterDinner(datalist.getJSONObject(i).getShort("afterDinner"));
            doctorSchemeBloodSugger.setAfterDinnerTime(DateUtil.hhmmStrToTime(datalist.getJSONObject(i).getString("afterDinnerTime")));
            doctorSchemeBloodSugger.setBeforeSleep(datalist.getJSONObject(i).getShort("beforeSleep"));
            doctorSchemeBloodSugger.setBeforeSleepTime(DateUtil.hhmmStrToTime(datalist.getJSONObject(i).getString("beforeSleepTime")));
            doctorSchemeBloodSugger.setAlertTag(datalist.getJSONObject(i).getShort("alertTag"));
            doctorSchemeBloodSugger.setContent(content);
            doctorSchemeBloodSugger.setCreateTime(DateUtil.getNowTimestamp());
            results.add(doctorSchemeBloodSugger);
        }
        if(!results.isEmpty()) {
            //使用事务控制批量更新
            DefaultTransactionDefinition def = new DefaultTransactionDefinition();
            def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); // 事物隔离级别,开启新事务
            TransactionStatus status = transactionManager.getTransaction(def); // 获得事务状态
            try {
                for (DoctorSchemeBloodSugger doctorSchemeBloodSugger  : results) {
                    doctoreSchemeBloodSuggerDao.save(doctorSchemeBloodSugger);
                }
                PatientSchemeList patientSchemeListObj = new PatientSchemeList();
                for (String patientcode : patientcodeList) {
                    patientSchemeListDao.delByPatientCodeAndSchemeCode(patientcode,1,code);
                    patientSchemeListObj.setCode(UUID.randomUUID().toString());
                    patientSchemeListObj.setPatientcode(patientcode);
                    patientSchemeListObj.setSchemecode(code);
                    patientSchemeListObj.setDoctorcode(doctorcode);
                    Short _type = new Short("0");
                    patientSchemeListObj.setType(_type);
                    patientSchemeListObj.setCreateTime(DateUtil.getNowTimestamp());
                    patientSchemeListDao.save(patientSchemeListObj);
                }
                //事务提交
                transactionManager.commit(status);
            } catch (Exception ex) {
                //报错事务回滚
                transactionManager.rollback(status);
            }
        }
    }
    /**
     * 医生保存居民的血压监测方案
     * @param data
     * @throws Exception
     */
    public void saveDoctorSchemeBloodPressure(String data) throws Exception{
        JSONObject dataObj =  JSON.parseObject(data);
        List<DoctorSchemeBloodPressure> results = new ArrayList<>();
        List<String> patientcodeList = new ArrayList<>();
        String code = dataObj.getString("code");
        if(StringUtils.isBlank(code)){
            code = UUID.randomUUID().toString();
        }
        String name = dataObj.getString("name");
        String content = dataObj.getString("content");
        String doctorcode = dataObj.getString("doctorcode");
        JSONArray datalist = dataObj.getJSONArray("list");
        JSONArray patientcodes = dataObj.getJSONArray("patientcodes");
        for (int i = 0; i < patientcodes.size(); i++) {
            patientcodeList.add(datalist.getJSONObject(i).toString());
        }
        for (int i = 0; i < datalist.size(); i++) {
            DoctorSchemeBloodPressure doctorSchemeBloodPressure = new DoctorSchemeBloodPressure();
            Long id = datalist.getJSONObject(i).getLong("id");
            if(id != 0){
                doctorSchemeBloodPressure.setId(datalist.getJSONObject(i).getLong("id"));
            }
            doctorSchemeBloodPressure.setName(name);
            doctorSchemeBloodPressure.setCode(code);
            doctorSchemeBloodPressure.setDoctorcode(doctorcode);
            doctorSchemeBloodPressure.setDayofweek(datalist.getJSONObject(i).getShort("dayofweek"));
            doctorSchemeBloodPressure.setEarlyMorning(datalist.getJSONObject(i).getShort("earlyMorning"));
            doctorSchemeBloodPressure.setEarlyMorningTime(DateUtil.hhmmStrToTime(datalist.getJSONObject(i).getString("earlyMorningTime")));
            doctorSchemeBloodPressure.setMorning(datalist.getJSONObject(i).getShort("morning"));
            doctorSchemeBloodPressure.setMorningTime(DateUtil.hhmmStrToTime(datalist.getJSONObject(i).getString("morningTime")));
            doctorSchemeBloodPressure.setNoon(datalist.getJSONObject(i).getShort("noon"));
            doctorSchemeBloodPressure.setNoonTime(DateUtil.hhmmStrToTime(datalist.getJSONObject(i).getString("noonTime")));
            doctorSchemeBloodPressure.setAfterNoon(datalist.getJSONObject(i).getShort("afterNoon"));
            doctorSchemeBloodPressure.setAfterNoonTime(DateUtil.hhmmStrToTime(datalist.getJSONObject(i).getString("afterNoonTime")));
            doctorSchemeBloodPressure.setNight(datalist.getJSONObject(i).getShort("night"));
            doctorSchemeBloodPressure.setNightTime(DateUtil.hhmmStrToTime(datalist.getJSONObject(i).getString("nightTime")));
            doctorSchemeBloodPressure.setAlertTag(datalist.getJSONObject(i).getShort("alertTag"));
            doctorSchemeBloodPressure.setContent(content);
            doctorSchemeBloodPressure.setCreateTime(DateUtil.getNowTimestamp());
            results.add(doctorSchemeBloodPressure);
        }
        if(!results.isEmpty()) {
            //使用事务控制批量更新
            DefaultTransactionDefinition def = new DefaultTransactionDefinition();
            def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); // 事物隔离级别,开启新事务
            TransactionStatus status = transactionManager.getTransaction(def); // 获得事务状态
            try {
                for (DoctorSchemeBloodPressure doctorSchemeBloodPressure : results) {
                    doctoreSchemeBloodPressureDao.save(doctorSchemeBloodPressure);
                }
                PatientSchemeList patientSchemeListObj = new PatientSchemeList();
                for (String patientcode : patientcodeList) {
                    patientSchemeListDao.delByPatientCodeAndSchemeCode(patientcode,0,code);
                    patientSchemeListObj.setCode(UUID.randomUUID().toString());
                    patientSchemeListObj.setPatientcode(patientcode);
                    patientSchemeListObj.setSchemecode(code);
                    patientSchemeListObj.setDoctorcode(doctorcode);
                    Short _type = new Short("0");
                    patientSchemeListObj.setType(_type);
                    patientSchemeListObj.setCreateTime(DateUtil.getNowTimestamp());
                    patientSchemeListDao.save(patientSchemeListObj);
                }
                //事务提交
                transactionManager.commit(status);
            } catch (Exception ex) {
                //报错事务回滚
                transactionManager.rollback(status);
            }
        }
    }
}

+ 7 - 27
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/SignWebService.java

@ -1875,22 +1875,13 @@ public class SignWebService extends BaseService {
     *
     *
     * @return
     * @return
     */
     */
    public JSONObject getOverDuePatients(String year, Long teamCode, String doctor, Integer page, Integer pageSize, boolean sortByStandardStatus) {
    public JSONObject getOverDuePatients(String year, Long teamCode, String doctor, Integer page, Integer pageSize) {
        StringBuffer sql = new StringBuffer("SELECT IFNULL(year( from_days( datediff( now(), p.birthday))),'未知') age," +
        StringBuffer sql = new StringBuffer("SELECT IFNULL(year( from_days( datediff( now(), p.birthday))),'未知') age," +
                "t.patient code,t.idcard,t.name,t.mobile,t.openid," +
                "t.patient code,t.idcard,t.name,t.mobile,t.openid," +
                "t.ssc,t.type signType,p.sex ,t.expenses_status expensesStatus " );
        if(sortByStandardStatus){
            sql.append(",(SELECT sum(d.category_code)  from wlyy_patient_device d WHERE p.code = d.`user`) deviceType ");
        }
        sql.append("FROM wlyy_sign_family t " +
                "t.ssc,t.type signType,p.sex ,t.expenses_status expensesStatus " +
                " FROM wlyy_sign_family t " +
                " LEFT JOIN wlyy_patient p ON t.patient = p.code " +
                " LEFT JOIN wlyy_patient p ON t.patient = p.code " +
                " WHERE t.doctor ='" + doctor + "' AND t.admin_team_code =" + teamCode + " AND t.sign_year ='" + year + "' AND t.status =-4 LIMIT " + page * pageSize + "," + pageSize);
                " WHERE t.doctor ='" + doctor + "' AND t.admin_team_code =" + teamCode + " AND t.sign_year ='" + year + "' AND t.status =-4 LIMIT " + page * pageSize + "," + pageSize);
        if (sortByStandardStatus){
            sql.append("order by p.standardStatus desc ");
        }
        List<Map<String, Object>> rs = jdbcTemplate.queryForList(sql.toString());
        List<Map<String, Object>> rs = jdbcTemplate.queryForList(sql.toString());
        JSONObject json = new JSONObject();
        JSONObject json = new JSONObject();
        json.put("result", rs);
        json.put("result", rs);
@ -1902,24 +1893,13 @@ public class SignWebService extends BaseService {
     *
     *
     * @return
     * @return
     */
     */
    public JSONObject getOverDuePatientsByTeam(String year, Long teamCode, Integer page, Integer pageSize, boolean sortByStandardStatus) {
    public JSONObject getOverDuePatientsByTeam(String year, Long teamCode, Integer page, Integer pageSize) {
        StringBuffer sql = new StringBuffer("SELECT IFNULL(year( from_days( datediff( now(), p.birthday))),'未知') age," +
        StringBuffer sql = new StringBuffer("SELECT IFNULL(year( from_days( datediff( now(), p.birthday))),'未知') age," +
                "t.patient code,t.idcard,t.name,t.mobile,t.openid," +
                "t.patient code,t.idcard,t.name,t.mobile,t.openid," +
                "t.ssc,t.type signType,p.sex ,t.expenses_status expensesStatus,p.disease, p.diseaseCondition, p.standardStatus ");
        if(sortByStandardStatus){
            sql.append(",(SELECT sum(d.category_code)  from wlyy_patient_device d WHERE p.code = d.`user`) deviceType ");
        }
        sql.append(" FROM wlyy_sign_family t " +
                "t.ssc,t.type signType,p.sex ,t.expenses_status expensesStatus " +
                " FROM wlyy_sign_family t " +
                " LEFT JOIN wlyy_patient p ON t.patient = p.code " +
                " LEFT JOIN wlyy_patient p ON t.patient = p.code " +
                " WHERE t.admin_team_code =" + teamCode + " AND t.sign_year ='" + year + "' AND t.status =-4 ");
        if (sortByStandardStatus){
            sql.append("order by p.standardStatus desc ");
        }
        sql.append("LIMIT " + page * pageSize + ", "+ pageSize);
                " WHERE t.admin_team_code =" + teamCode + " AND t.sign_year ='" + year + "' AND t.status =-4 LIMIT " + page * pageSize + "," + pageSize);
        List<Map<String, Object>> rs = jdbcTemplate.queryForList(sql.toString());
        List<Map<String, Object>> rs = jdbcTemplate.queryForList(sql.toString());
        JSONObject json = new JSONObject();
        JSONObject json = new JSONObject();
        json.put("result", rs);
        json.put("result", rs);

+ 10 - 8
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/account/PatientService.java

@ -24,7 +24,6 @@ import com.yihu.wlyy.util.EncodesUtil;
import com.yihu.wlyy.util.IdcardInfoExtractor;
import com.yihu.wlyy.util.IdcardInfoExtractor;
import com.yihu.wlyy.util.SystemData;
import com.yihu.wlyy.util.SystemData;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.json.JSONArray;
import org.json.JSONArray;
import org.json.JSONObject;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
@ -36,8 +35,6 @@ import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.annotation.Transactional;
import org.springside.modules.utils.Clock;
import org.springside.modules.utils.Clock;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.*;
/**
/**
@ -789,7 +786,7 @@ public class PatientService extends TokenService {
     *
     *
     * @return
     * @return
     */
     */
    public JSONArray getSignByDoctorCodeGpbyServer(String doctor, String teamCode) {
    public JSONArray getSignByDoctorCodeGpbyServer(String doctor, String teamCode, boolean isSlowDisease) {
        String teamCodeSql = "";
        String teamCodeSql = "";
        if (!org.springframework.util.StringUtils.isEmpty(teamCode)) {
        if (!org.springframework.util.StringUtils.isEmpty(teamCode)) {
            teamCodeSql = " and f.admin_team_code=" + teamCode + " ";
            teamCodeSql = " and f.admin_team_code=" + teamCode + " ";
@ -831,7 +828,6 @@ public class PatientService extends TokenService {
        List<Map<String, Object>> totalG = jdbcTemplate.queryForList(totalGSql);
        List<Map<String, Object>> totalG = jdbcTemplate.queryForList(totalGSql);
        //获取关注量分组数量
        String fousGSql = "SELECT " +
        String fousGSql = "SELECT " +
                " d.`code` AS serverType, " +
                " d.`code` AS serverType, " +
                " d.`name` AS serverTypeName, " +
                " d.`name` AS serverTypeName, " +
@ -849,9 +845,15 @@ public class PatientService extends TokenService {
                "   FROM " +
                "   FROM " +
                "    wlyy_sign_family f ,wlyy_patient p " +
                "    wlyy_sign_family f ,wlyy_patient p " +
                "   WHERE " +
                "   WHERE " +
                "   f.patient = p.code " +
                "   AND p.openid IS NOT NULL " +
                "   AND p.openid <>'' " +
                "   f.patient = p.code ";
        if(isSlowDisease){
            //获取预警分组数量
            fousGSql = fousGSql +"   AND p.standard_status = 1 ";
        }else{
            //获取微信关注量分组数量
            fousGSql = fousGSql +"   AND p.openid IS NOT NULL AND p.openid <>'' " ;
        }
        fousGSql = fousGSql +
                "   AND ( " +
                "   AND ( " +
                "     f.doctor = '" + doctor + "' " +
                "     f.doctor = '" + doctor + "' " +
                "     OR f.doctor_health = '" + doctor + "' " +
                "     OR f.doctor_health = '" + doctor + "' " +

+ 30 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/DateUtil.java

@ -2,6 +2,8 @@ package com.yihu.wlyy.util;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.StringUtils;
import java.sql.Time;
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.DateFormat;
import java.text.ParsePosition;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.text.SimpleDateFormat;
@ -840,4 +842,32 @@ public class DateUtil {
		cal.add(Calendar.DAY_OF_YEAR,day);
		cal.add(Calendar.DAY_OF_YEAR,day);
		return cal.getTime();
		return cal.getTime();
	}
	}
	/**
	 * 将HH:MM格式的字符串转TIME
	 * @param hhmm
	 * @return
	 */
	public static Time hhmmStrToTime(String hhmm){
		Time time = null;
		DateFormat sdf = new SimpleDateFormat("hh:mm");
		try {
			Date date = sdf.parse(hhmm);
			time = new Time(date.getTime());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return time;
	}
	/**
	 * 获取当前时间的Timestamp
	 * @return
	 */
	public static Timestamp getNowTimestamp(){
		Date date = new Date();
		Timestamp nousedate = new Timestamp(date.getTime());
		return nousedate;
	}
}
}

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

@ -497,7 +497,7 @@ public class DoctorHealthEduArticleController extends WeixinBaseController {
    }
    }
    private void getPatientByGroup(String labelCode, String labelType, Long teamCode, Set<String> patientSet, int page, int pagesize) throws Exception {
    private void getPatientByGroup(String labelCode, String labelType, Long teamCode, Set<String> patientSet, int page, int pagesize) throws Exception {
        JSONArray result = signPatientLabelInfoService.getPatientByLabel(getUID(), labelCode, labelType, teamCode, page, pagesize, false);
        JSONArray result = signPatientLabelInfoService.getPatientByLabel(getUID(), labelCode, labelType, teamCode, page, pagesize, false, "");
        for (Object o : result) {
        for (Object o : result) {
            JSONObject json = (JSONObject) o;
            JSONObject json = (JSONObject) o;
            String patient = (String) json.get("code");
            String patient = (String) json.get("code");

+ 76 - 9
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/SignPatientLabelInfoController.java

@ -149,7 +149,8 @@ public class SignPatientLabelInfoController extends BaseController {
                                        @RequestParam(required = false) Long teamCode,
                                        @RequestParam(required = false) Long teamCode,
                                        @RequestParam(required = false) int page,
                                        @RequestParam(required = false) int page,
                                        @RequestParam(required = false) int pagesize,
                                        @RequestParam(required = false) int pagesize,
                                        @RequestParam(required = false) boolean sortByStandardStatus) {
                                        @RequestParam(required = false) String diseaseCondition,
                                        @RequestParam(required = false) boolean isSlowDisease) {
        try {
        try {
            if (StringUtils.isEmpty(labelCode)) {
            if (StringUtils.isEmpty(labelCode)) {
                return error(-1, "标签cdoe不能为空");
                return error(-1, "标签cdoe不能为空");
@ -166,11 +167,11 @@ public class SignPatientLabelInfoController extends BaseController {
            //labelType=9 签约过期的居民列表
            //labelType=9 签约过期的居民列表
            if (labelType.equals("9")) {
            if (labelType.equals("9")) {
                JSONObject jsonObject = signWebService.getOverDuePatients(labelCode, teamCode, getUID(), page, pagesize,sortByStandardStatus);
                JSONObject jsonObject = signWebService.getOverDuePatients(labelCode, teamCode, getUID(), page, pagesize);
                return write(200, "查询成功", "data", jsonObject);
                return write(200, "查询成功", "data", jsonObject);
            }
            }
            JSONArray result = labelInfoService.getPatientByLabel(getUID(), labelCode, labelType, teamCode, page, pagesize,sortByStandardStatus);
            JSONArray result = labelInfoService.getPatientByLabel(getUID(), labelCode, labelType, teamCode, page, pagesize,isSlowDisease,diseaseCondition);
            //JSONArray result = labelInfoService.getPatientByLabel("xh1D201703150222", labelCode, labelType, teamCode, page, pagesize);
            //JSONArray result = labelInfoService.getPatientByLabel("xh1D201703150222", labelCode, labelType, teamCode, page, pagesize);
            return write(200, "查询成功", "data", result);
            return write(200, "查询成功", "data", result);
@ -228,7 +229,8 @@ public class SignPatientLabelInfoController extends BaseController {
                                 @RequestParam(required = false) String labelType,
                                 @RequestParam(required = false) String labelType,
                                 @RequestParam(required = true) int page,
                                 @RequestParam(required = true) int page,
                                 @RequestParam(required = true) int pagesize,
                                 @RequestParam(required = true) int pagesize,
                                 @RequestParam(required = false) boolean sortByStandardStatus) {
                                 @RequestParam(required = false) String diseaseCondition,
                                 @RequestParam(required = false) boolean isSlowDisease) {
        try {
        try {
            if (teamCode == null || teamCode < 1) {
            if (teamCode == null || teamCode < 1) {
                return error(-1, "团队cdoe不能为空");
                return error(-1, "团队cdoe不能为空");
@ -242,12 +244,12 @@ public class SignPatientLabelInfoController extends BaseController {
            //labelType=9 签约过期的居民列表
            //labelType=9 签约过期的居民列表
            if ("9".equals(labelType)) {
            if ("9".equals(labelType)) {
                JSONObject jsonObject = signWebService.getOverDuePatientsByTeam(labelCode, teamCode, page, pagesize,sortByStandardStatus);
                JSONObject jsonObject = signWebService.getOverDuePatientsByTeam(labelCode, teamCode, page, pagesize);
                return write(200, "查询成功", "data", jsonObject);
                return write(200, "查询成功", "data", jsonObject);
            }
            }
            JSONArray result = labelInfoService.getPatientByTeamCodeExitDoctor(teamCode, labelCode, labelType, page, pagesize,sortByStandardStatus);
            JSONArray result = labelInfoService.getPatientByTeamCodeExitDoctor(teamCode, labelCode, labelType, page, pagesize,isSlowDisease,diseaseCondition);
            return write(200, "查询成功", "data", result);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
        } catch (Exception e) {
@ -277,11 +279,15 @@ public class SignPatientLabelInfoController extends BaseController {
     *
     *
     * @param labelType 标签类型
     * @param labelType 标签类型
     * @param teamCode  团队code
     * @param teamCode  团队code
     * @param isSlowDisease 是否是慢病管理
     * @return
     * @return
     */
     */
    @RequestMapping(value = "/label_patient_amount")
    @RequestMapping(value = "/label_patient_amount")
    @ApiOperation("查询某个团队的某个标签类型下各标签患者数")
    @ApiOperation("查询某个团队的某个标签类型下各标签患者数")
    public String getPatientAmountByLabelType(@RequestParam(required = false) String labelType, @RequestParam(required = false) Long teamCode) {
    public String getPatientAmountByLabelType(
            @RequestParam(required = false) String labelType,
            @RequestParam(required = false) Long teamCode,
            @RequestParam(required = false) boolean isSlowDisease) {
        try {
        try {
            if (StringUtils.isEmpty(labelType)) {
            if (StringUtils.isEmpty(labelType)) {
                return error(-1, "标签类型不能为空");
                return error(-1, "标签类型不能为空");
@ -298,7 +304,7 @@ public class SignPatientLabelInfoController extends BaseController {
            }
            }
            if (labelType.equals("1") && teamCode != 0L) {
            if (labelType.equals("1") && teamCode != 0L) {
                JSONArray r = patientService.getSignByDoctorCodeGpbyServer(getUID(), teamCode + "");
                JSONArray r = patientService.getSignByDoctorCodeGpbyServer(getUID(), teamCode + "",isSlowDisease);
                //JSONArray r= patientService.getSignByDoctorCodeGpbyServer("xh1D201703150222",teamCode+"");
                //JSONArray r= patientService.getSignByDoctorCodeGpbyServer("xh1D201703150222",teamCode+"");
                return write(200, "查询成功", "data", r);
                return write(200, "查询成功", "data", r);
            }
            }
@ -465,7 +471,8 @@ public class SignPatientLabelInfoController extends BaseController {
                                             @RequestParam(required = false) Long teamCode,
                                             @RequestParam(required = false) Long teamCode,
                                             @RequestParam(required = false) String exLabelCode,
                                             @RequestParam(required = false) String exLabelCode,
                                             @RequestParam(required = false) String exLabelType,
                                             @RequestParam(required = false) String exLabelType,
                                             @RequestParam(required = true) int page, @RequestParam(required = true) int pagesize) {
                                             @RequestParam(required = true) int page,
                                             @RequestParam(required = true) int pagesize) {
        try {
        try {
            if (StringUtils.isEmpty(filter)) {
            if (StringUtils.isEmpty(filter)) {
                return error(-1, "搜索字段不能为空");
                return error(-1, "搜索字段不能为空");
@ -762,4 +769,64 @@ public class SignPatientLabelInfoController extends BaseController {
        }
        }
    }
    }
    @RequestMapping(value = "/slow_disease_patient_search")
    @ApiOperation("慢病管理:查询某个患者的某类标签根据团队和当前医生")
    public String searchSlowDiseasePatientByNameOrLabel(@RequestParam(required = true) String filter,
                                             @RequestParam(required = false) String labelCode,
                                             @RequestParam(required = false) String labelType,
                                             @RequestParam(required = false) Long teamCode,
                                             @RequestParam(required = false) String exLabelCode,
                                             @RequestParam(required = false) String exLabelType,
                                             @RequestParam(required = true) int page,
                                             @RequestParam(required = true) int pagesize,
                                             @RequestParam(required = false) String diseaseCondition) {
        try {
            if (StringUtils.isEmpty(filter)) {
                return error(-1, "搜索字段不能为空");
            }
            if (!StringUtils.isEmpty(labelCode) && StringUtils.isEmpty(labelType)) {
                return error(-1, "标签参数不为空时标签类型不能为空");
            }
            if (!StringUtils.isEmpty(exLabelCode) && StringUtils.isEmpty(exLabelType)) {
                return error(-1, "过滤标签参数不为空时过滤标签类型不能为空");
            }
            if (teamCode == null) {
                teamCode = 0L;
            }
            page = page - 1;
            JSONArray result = labelInfoService.searchSlowDiseasePatientByNameOrLabel(getUID(), filter, labelCode, labelType, teamCode, exLabelCode, exLabelType, page, pagesize,diseaseCondition);
            //JSONArray result = labelInfoService.searchPatientByNameOrLabel("test00000000005", filter, labelCode, labelType, teamCode, exLabelCode, exLabelType, page, pagesize);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            return error(-1, "查询失败");
        }
    }
    @RequestMapping(value = "/slow_disease_patient_search_all_exitdoc", method = RequestMethod.GET)
    @ApiOperation("慢病管理:根据姓名搜索所有团队下居民(根据团队)")
    public String searchSlowDiseasePatientsExitDoc(@RequestParam(required = true) String filter,
                                        @RequestParam(required = true, defaultValue = "0") long teamCode,
                                        @RequestParam(required = false, defaultValue = "0") int page,
                                        @RequestParam(required = false, defaultValue = "15") int pagesize,
                                        @RequestParam(required = false) String diseaseCondition) {
        try {
            if (StringUtils.isEmpty(filter)) {
                return error(-1, "查询参数不能为空");
            }
            page = page > 0 ? page - 1 : 0;
            JSONArray result = labelInfoService.searchSlowDiseaseTeamsPatients(filter, teamCode, page, pagesize,diseaseCondition);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
}
}

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorSignController.java

@ -669,7 +669,7 @@ public class DoctorSignController extends WeixinBaseController {
    @ResponseBody
    @ResponseBody
    public String getSignByDoctorCodeGpbyServer(){
    public String getSignByDoctorCodeGpbyServer(){
        try {
        try {
            JSONArray result = patientService.getSignByDoctorCodeGpbyServer(getUID(),null);
            JSONArray result = patientService.getSignByDoctorCodeGpbyServer(getUID(),null, false);
            //JSONArray result = patientService.getSignByDoctorCodeGpbyServer("xh1D201703150222");
            //JSONArray result = patientService.getSignByDoctorCodeGpbyServer("xh1D201703150222");
            return write(200, "查询成功", "data", result);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
        } catch (Exception e) {

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

@ -385,7 +385,7 @@ public class PatientHealthController extends BaseController {
                                        @RequestParam(value = "data", required = true) String data,
                                        @RequestParam(value = "data", required = true) String data,
                                        @ApiParam(name = "type", value = "指标类型", defaultValue = "1")
                                        @ApiParam(name = "type", value = "指标类型", defaultValue = "1")
                                        @RequestParam(value = "type", required = true) String type,
                                        @RequestParam(value = "type", required = true) String type,
                                        @ApiParam(name = "patient", value = "居民code", defaultValue = "1")
                                        @ApiParam(name = "patient", value = "patient", defaultValue = "1")
                                        @RequestParam(value = "patient", required = false) String patient) {
                                        @RequestParam(value = "patient", required = false) String patient) {
        try {
        try {
//            DevicePatientHealthIndex obj = healthIndexService.addPatientHealthIndex(data, type, getUID(), null);
//            DevicePatientHealthIndex obj = healthIndexService.addPatientHealthIndex(data, type, getUID(), null);
@ -450,7 +450,7 @@ public class PatientHealthController extends BaseController {
    @RequestMapping(value = "list", method = RequestMethod.POST)
    @RequestMapping(value = "list", method = RequestMethod.POST)
    @ResponseBody
    @ResponseBody
    @ApiOperation("患者获取健康指标")
    @ApiOperation("患者获取健康指标")
    public String getHealthIndexByPatient(@ApiParam(name = "type", value = "指标类型(1血糖,2血压,3体重,4腰围)", defaultValue = "1")
    public String getHealthIndexByPatient(@ApiParam(name = "type", value = "指标类型(1血糖,2血压,3体重/身高,4腰围)", defaultValue = "1")
                                          @RequestParam(value = "type", required = true) int type,
                                          @RequestParam(value = "type", required = true) int type,
                                          @ApiParam(name = "start", value = "开始时间", defaultValue = "2016-07-23 00:00:00")
                                          @ApiParam(name = "start", value = "开始时间", defaultValue = "2016-07-23 00:00:00")
                                          @RequestParam(value = "start", required = true) String start,
                                          @RequestParam(value = "start", required = true) String start,

+ 2 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/controller/doctor/GcLableController.java

@ -96,10 +96,10 @@ public class GcLableController extends BaseController {
            @ApiParam(name = "teamCode", value = "所属团队", required = true) @RequestParam(value = "teamCode", required = true) Long teamCode,
            @ApiParam(name = "teamCode", value = "所属团队", required = true) @RequestParam(value = "teamCode", required = true) Long teamCode,
            @ApiParam(name = "page", value = "当前页(1开始)", required = true) @RequestParam(value = "page", required = true, defaultValue = "1") Integer page,
            @ApiParam(name = "page", value = "当前页(1开始)", required = true) @RequestParam(value = "page", required = true, defaultValue = "1") Integer page,
            @ApiParam(name = "pageSize", value = "每页大小", required = true) @RequestParam(value = "pageSize", required = true, defaultValue = "10") Integer pageSize,
            @ApiParam(name = "pageSize", value = "每页大小", required = true) @RequestParam(value = "pageSize", required = true, defaultValue = "10") Integer pageSize,
            @ApiParam(name = "sortByStandardStatus", value = "是否按照预警状态排序", required = true) @RequestParam(value="sortByStandardStatus",required = false,defaultValue = "false") boolean sortByStandardStatus
            @ApiParam(name = "isSlowDisease", value = "是否是慢病管理", required = true) @RequestParam(value="isSlowDisease",required = false,defaultValue = "false") boolean isSlowDisease
    ) {
    ) {
        try {
        try {
            JSONArray result = signPatientLabelInfoService.getPatientByLabel(getUID(), labelCode, labelType, teamCode, page-1, pageSize, sortByStandardStatus);
            JSONArray result = signPatientLabelInfoService.getPatientByLabel(getUID(), labelCode, labelType, teamCode, page-1, pageSize, isSlowDisease, "");
            List<PatientModel> patientLabelModels = new ArrayList<>();
            List<PatientModel> patientLabelModels = new ArrayList<>();
            for (int i = 0; i < result.length(); i++) {
            for (int i = 0; i < result.length(); i++) {
                JSONObject jo = result.getJSONObject(i);
                JSONObject jo = result.getJSONObject(i);