Переглянути джерело

Merge branch 'dev' of http://192.168.1.220:10080/Amoy/patient-co-management into dev

Conflicts:
	patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statisticsES/StatisticsESService.java
zd_123 7 роки тому
батько
коміт
accb0416c1
53 змінених файлів з 2560 додано та 868 видалено
  1. 14 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/consult/ConsultTeam.java
  2. 20 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/reply/DoctorQuickReply.java
  3. 1 1
      common/common-entity/src/main/java/com/yihu/wlyy/entity/followup/FollowupDrugs.java
  4. 1 1
      common/common-entity/src/main/java/com/yihu/wlyy/entity/message/Message.java
  5. 411 401
      common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/Patient.java
  6. 89 11
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/feedback/FeedbackService.java
  7. 7 2
      patient-co-manage/wlyy-manage/src/main/resources/application.yml
  8. 19 0
      patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/common/dao/ConsultTeamDao.java
  9. 14 0
      patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/common/util/DateUtil.java
  10. 341 0
      patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/model/ConsultTeam.java
  11. 53 7
      patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/service/DeviceService.java
  12. 31 21
      patient-co/patient-co-doctor-assistant/src/main/resources/application-dev.yml
  13. 0 111
      patient-co/patient-co-doctor-assistant/src/main/resources/application-devbak.yml
  14. 0 4
      patient-co/patient-co-statistics-es/pom.xml
  15. 77 0
      patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/controller/QueryController.java
  16. 29 17
      patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/etl/convert/wlyy/ConsultTimeConvert.java
  17. 31 21
      patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/etl/convert/wlyy/DiseaseAndAgeConvert.java
  18. 20 20
      patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/util/ElasticsearchUtil.java
  19. 1 0
      patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/util/IdCardUtil.java
  20. 61 0
      patient-co/patient-co-statistics-es/src/main/resources/application-devtest.yml
  21. 21 21
      patient-co/patient-co-statistics-es/src/main/resources/application-test.yml
  22. 1 1
      patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/etl/mycache/CachePool.java
  23. 1 1
      patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/CurrentDayAllQuotaJob.java
  24. 51 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/SicardQueryJob.java
  25. 4 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/patient/PatientDao.java
  26. 53 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/charge/BindCard.java
  27. 81 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/charge/OnePayService.java
  28. 5 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/DoctorQuickReplyDao.java
  29. 4 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowUpDao.java
  30. 80 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/consult/ConsultTeamService.java
  31. 174 119
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/followup/FollowUpService.java
  32. 47 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/PatientHealthIndexService.java
  33. 348 4
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionFollowupContentService.java
  34. 21 4
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/reply/DoctorQuickReplyService.java
  35. 137 59
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statisticsES/StatisticsESService.java
  36. 7 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/DateUtil.java
  37. 6 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/ElasticsearchUtil.java
  38. 40 4
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/consult/DoctorConsultController.java
  39. 55 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/feedback/DoctorFeedbackTemplateController.java
  40. 19 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/followup/DoctorFollowUpController.java
  41. 79 4
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/DoctorPrescriptionFollowupContentController.java
  42. 12 7
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/reply/DoctorQuickReplyController.java
  43. 4 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/consult/ConsultController.java
  44. 61 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/feedback/PatientFeedbackTemplateController.java
  45. 2 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/health/PatientHealthController.java
  46. 4 9
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/prescription/PatientPrescriptionFollowupContentController.java
  47. 7 4
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/EsStatisticsController.java
  48. 11 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/vo/PatientModel.java
  49. 1 1
      patient-co/patient-co-wlyy/src/main/resources/application-devtest.yml
  50. 1 1
      patient-co/patient-co-wlyy/src/main/resources/application-local.yml
  51. 1 1
      patient-co/patient-co-wlyy/src/main/resources/application-localtest.yml
  52. 1 1
      patient-co/patient-co-wlyy/src/main/resources/application-prod.yml
  53. 1 1
      patient-co/patient-co-wlyy/src/main/resources/application-test.yml

+ 14 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/consult/ConsultTeam.java

@ -58,6 +58,8 @@ public class ConsultTeam extends IdEntity {
	private Date evaluateTime;
	private String relationCode;//关联业务表的code
	
	private Integer healthindexType;//体征数据上传发送IM消息:1血压 2血糖 3血压+血糖
	public Integer getEvaluate() {
		return evaluate;
@ -325,4 +327,16 @@ public class ConsultTeam extends IdEntity {
	public void setRelationCode(String relationCode) {
		this.relationCode = relationCode;
	}
	
	public static long getSerialVersionUID() {
		return serialVersionUID;
	}
	
	public Integer getHealthindexType() {
		return healthindexType;
	}
	
	public void setHealthindexType(Integer healthindexType) {
		this.healthindexType = healthindexType;
	}
}

+ 20 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/reply/DoctorQuickReply.java

@ -23,6 +23,10 @@ public class DoctorQuickReply extends IdEntity {
    private Date updateTime;
    // 状态 1:有效  0:无效
    private Integer status;
    // 类型 0为健康教育,1为续方咨询
    private Integer type;
    // 1为默认消息,0为自定义消息
    private Integer systag;
    public String getDoctor() {
        return doctor;
@ -59,4 +63,20 @@ public class DoctorQuickReply extends IdEntity {
    public void setStatus(Integer status) {
        this.status = status;
    }
    
    public Integer getType() {
        return type;
    }
    
    public void setType(Integer type) {
        this.type = type;
    }
    
    public Integer getSystag() {
        return systag;
    }
    
    public void setSystag(Integer systag) {
        this.systag = systag;
    }
}

+ 1 - 1
common/common-entity/src/main/java/com/yihu/wlyy/entity/followup/FollowupDrugs.java

@ -23,7 +23,7 @@ public class FollowupDrugs extends IdEntity {
	private String drugsCode;
	//药品名称
	private String drugsName;
	//药品分组(糖尿病--胰岛特殊处理)
	//药品分组(糖尿病--胰岛特殊处理)胰岛素分类insulin,其他药品为normal
	private String drugsGroup;
	//次剂量
	private String dose;

Різницю між файлами не показано, бо вона завелика
+ 1 - 1
common/common-entity/src/main/java/com/yihu/wlyy/entity/message/Message.java


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

@ -15,8 +15,8 @@ import java.util.List;
/**
 * 患者信息
 * @author George
 *
 * @author George
 */
@Entity
@ -24,419 +24,429 @@ import java.util.List;
public class Patient extends IdEntity implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 8358924836164389434L;
	// 业务主键
	private String code;
	// 身份证号
	private String idcard;
	// 登录密码
	private String password;
	private String salt;
	// 姓名
	private String name;
	// 生日
	private Date birthday;
	// 性別,1男,2女
	private Integer sex;
	// 手機號
	private String mobile;
	// (基卫)手機號
	private String mobileRemarks;
	// 聯繫電話
	private String phone;
	// 社保卡號
	private String ssc;
	// 頭像HTTP地址
	private String photo;
	// 省代碼
	private String province;
	// 城市代碼
	private String city;
	// 區縣代碼
	private String town;
	// 街道代码
	private String street;
	// 省名
	private String provinceName;
	// 市名
	private String cityName;
	// 區縣名
	private String townName;
	// 街道名称
	private String streetName;
	// 地址
	private String address;
	// 疾病类型,0健康,1高血压,2糖尿病,3高血压+糖尿病
	private Integer disease;
	// 病情:0绿标,1黄标,2红标
	private Integer diseaseCondition;
	// 病历记录总数
	private Integer recordAmount;
	// 總積分
	private Integer points;
	// 更新時間
	private Date czrq;
	// 微信编号
	private String openid;
	//微信时间
	private Date openidTime;
	// 用户状态:1正常,0禁用,-1恶意注册,2审核中
	private Integer status;
	// 居委会字段id
	private String sickVillage;
	// 居委会字段名称
	private String sickVillageName;
//	是否绑定电子社保卡
	private Integer sicardStatus;
//	绑定电子社保卡时间
	private Date sicardTime;
	//是否分配过微信标签  1分配过 0或者空没有
	private Integer isWxtag;
	//微信iagId
	private Integer wxtagid;
	//居民预警状态:0为标准,1为预警状态
	private Integer standardStatus;
	public Integer getSicardStatus() {
		return sicardStatus;
	}
	public void setSicardStatus(Integer sicardStatus) {
		this.sicardStatus = sicardStatus;
	}
	public Date getSicardTime() {
		return sicardTime;
	}
	public void setSicardTime(Date sicardTime) {
		this.sicardTime = sicardTime;
	}
	private List<SignPatientLabelInfo> labelInfos=new ArrayList<>();//患者的疾病标签list
	public Patient() {
	}
	public Patient(Long id) {
		this.id = id;
	}
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public String getIdcard() {
		return idcard;
	}
	public void setIdcard(String idcard) {
		this.idcard = idcard;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String getSalt() {
		return salt;
	}
	public void setSalt(String salt) {
		this.salt = salt;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+08:00")
	public Date getBirthday() {
		return birthday;
	}
	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	}
	public Integer getSex() {
		return sex;
	}
	public void setSex(Integer sex) {
		this.sex = sex;
	}
	public String getMobile() {
		return mobile;
	}
	public void setMobile(String mobile) {
		this.mobile = mobile;
	}
	public String getPhone() {
		return phone;
	}
	public void setPhone(String phone) {
		this.phone = phone;
	}
    /**
     *
     */
    private static final long serialVersionUID = 8358924836164389434L;
    // 业务主键
    private String code;
    // 身份证号
    private String idcard;
    // 登录密码
    private String password;
    private String salt;
    // 姓名
    private String name;
    // 生日
    private Date birthday;
    // 性別,1男,2女
    private Integer sex;
    // 手機號
    private String mobile;
    // (基卫)手機號
    private String mobileRemarks;
    // 聯繫電話
    private String phone;
    // 社保卡號
    private String ssc;
    // 頭像HTTP地址
    private String photo;
    // 省代碼
    private String province;
    // 城市代碼
    private String city;
    // 區縣代碼
    private String town;
    // 街道代码
    private String street;
    // 省名
    private String provinceName;
    // 市名
    private String cityName;
    // 區縣名
    private String townName;
    // 街道名称
    private String streetName;
    // 地址
    private String address;
    // 疾病类型,0健康,1高血压,2糖尿病,3高血压+糖尿病
    private Integer disease;
    // 病情:0绿标,1黄标,2红标
    private Integer diseaseCondition;
    // 病历记录总数
    private Integer recordAmount;
    // 總積分
    private Integer points;
    // 更新時間
    private Date czrq;
    // 微信编号
    private String openid;
    //微信时间
    private Date openidTime;
    // 用户状态:1正常,0禁用,-1恶意注册,2审核中
    private Integer status;
    // 居委会字段id
    private String sickVillage;
    // 居委会字段名称
    private String sickVillageName;
    //	绑定电子社保卡主体(本人为本人code,共济为操作人code)
    private String principalCode;
    //	是否绑定电子社保卡
    private Integer sicardStatus;
    //	绑定电子社保卡时间
    private Date sicardTime;
    //是否分配过微信标签  1分配过 0或者空没有
    private Integer isWxtag;
    //微信iagId
    private Integer wxtagid;
    //居民预警状态:0为标准,1为预警状态
    private Integer standardStatus;
    public String getPrincipalCode() {
        return principalCode;
    }
    public void setPrincipalCode(String principalCode) {
        this.principalCode = principalCode;
    }
    public Integer getSicardStatus() {
        return sicardStatus;
    }
    public void setSicardStatus(Integer sicardStatus) {
        this.sicardStatus = sicardStatus;
    }
    public Date getSicardTime() {
        return sicardTime;
    }
    public void setSicardTime(Date sicardTime) {
        this.sicardTime = sicardTime;
    }
    private List<SignPatientLabelInfo> labelInfos = new ArrayList<>();//患者的疾病标签list
    public Patient() {
    }
    public Patient(Long id) {
        this.id = id;
    }
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getIdcard() {
        return idcard;
    }
    public void setIdcard(String idcard) {
        this.idcard = idcard;
    }
    public String getPassword() {
        return password;
    }
    public void setPassword(String password) {
        this.password = password;
    }
    public String getSalt() {
        return salt;
    }
    public void setSalt(String salt) {
        this.salt = salt;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+08:00")
    public Date getBirthday() {
        return birthday;
    }
    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }
    public Integer getSex() {
        return sex;
    }
    public void setSex(Integer sex) {
        this.sex = sex;
    }
    public String getMobile() {
        return mobile;
    }
    public void setMobile(String mobile) {
        this.mobile = mobile;
    }
    public String getPhone() {
        return phone;
    }
    public void setPhone(String phone) {
        this.phone = phone;
    }
    public String getSsc() {
        return ssc;
    }
    public void setSsc(String ssc) {
        this.ssc = ssc;
    }
    @Column(name = "photo", insertable = false)
    public String getPhoto() {
        return photo;
    }
    public void setPhoto(String photo) {
        this.photo = photo;
    }
    public String getProvince() {
        return province;
    }
    public void setProvince(String province) {
        this.province = province;
    }
    public String getCity() {
        return city;
    }
    public void setCity(String city) {
        this.city = city;
    }
    public String getTown() {
        return town;
    }
    public void setTown(String town) {
        this.town = town;
    }
    public String getStreet() {
        return street;
    }
    public void setStreet(String street) {
        this.street = street;
    }
    @Column(name = "province_name")
    public String getProvinceName() {
        return provinceName;
    }
    public void setProvinceName(String provinceName) {
        this.provinceName = provinceName;
    }
    @Column(name = "city_name")
    public String getCityName() {
        return cityName;
    }
    public void setCityName(String cityName) {
        this.cityName = cityName;
    }
    @Column(name = "town_name")
    public String getTownName() {
        return townName;
    }
    public void setTownName(String townName) {
        this.townName = townName;
    }
    @Column(name = "street_name")
    public String getStreetName() {
        return streetName;
    }
    public void setStreetName(String streetName) {
        this.streetName = streetName;
    }
    public static long getSerialversionuid() {
        return serialVersionUID;
    }
    public String getAddress() {
        return address;
    }
    public void setAddress(String address) {
        this.address = address;
    }
    public Integer getDisease() {
        return disease;
    }
    public void setDisease(Integer disease) {
        this.disease = disease;
    }
    @Column(name = "disease_condition")
    public Integer getDiseaseCondition() {
        return diseaseCondition;
    }
    public void setDiseaseCondition(Integer diseaseCondition) {
        this.diseaseCondition = diseaseCondition;
    }
    @Column(name = "record_amount")
    public Integer getRecordAmount() {
        return recordAmount;
    }
    public void setRecordAmount(Integer recordAmount) {
        this.recordAmount = recordAmount;
    }
    public Integer getPoints() {
        return points;
    }
    public void setPoints(Integer points) {
        this.points = points;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getCzrq() {
        return czrq;
    }
    public void setCzrq(Date czrq) {
        this.czrq = czrq;
    }
    public String getOpenid() {
        return openid;
    }
    public void setOpenid(String openid) {
        this.openid = openid;
    }
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    @Transient
    public List<SignPatientLabelInfo> getLabelInfos() {
        return labelInfos;
    }
    public void setLabelInfos(List<SignPatientLabelInfo> labelInfos) {
        this.labelInfos = labelInfos;
    }
    public String getMobileRemarks() {
        return mobileRemarks;
    }
    public void setMobileRemarks(String mobileRemarks) {
        this.mobileRemarks = mobileRemarks;
    }
    public Date getOpenidTime() {
        return openidTime;
    }
    public void setOpenidTime(Date openidTime) {
        this.openidTime = openidTime;
    }
	public String getSsc() {
		return ssc;
	}
	public void setSsc(String ssc) {
		this.ssc = ssc;
	}
	@Column(name = "photo", insertable = false)
	public String getPhoto() {
		return photo;
	}
	public void setPhoto(String photo) {
		this.photo = photo;
	}
	public String getProvince() {
		return province;
	}
	public void setProvince(String province) {
		this.province = province;
	}
	public String getCity() {
		return city;
	}
	public void setCity(String city) {
		this.city = city;
	}
	public String getTown() {
		return town;
	}
	public void setTown(String town) {
		this.town = town;
	}
	public String getStreet() {
		return street;
	}
	public void setStreet(String street) {
		this.street = street;
	}
	@Column(name = "province_name")
	public String getProvinceName() {
		return provinceName;
	}
	public void setProvinceName(String provinceName) {
		this.provinceName = provinceName;
	}
	@Column(name = "city_name")
	public String getCityName() {
		return cityName;
	}
	public void setCityName(String cityName) {
		this.cityName = cityName;
	}
	@Column(name = "town_name")
	public String getTownName() {
		return townName;
	}
	public void setTownName(String townName) {
		this.townName = townName;
	}
	@Column(name = "street_name")
	public String getStreetName() {
		return streetName;
	}
	public void setStreetName(String streetName) {
		this.streetName = streetName;
	}
	public static long getSerialversionuid() {
		return serialVersionUID;
	}
	public String getAddress() {
		return address;
	}
	public void setAddress(String address) {
		this.address = address;
	}
	public Integer getDisease() {
		return disease;
	}
	public void setDisease(Integer disease) {
		this.disease = disease;
	}
	@Column(name = "disease_condition")
	public Integer getDiseaseCondition() {
		return diseaseCondition;
	}
	public void setDiseaseCondition(Integer diseaseCondition) {
		this.diseaseCondition = diseaseCondition;
	}
	@Column(name = "record_amount")
	public Integer getRecordAmount() {
		return recordAmount;
	}
	public void setRecordAmount(Integer recordAmount) {
		this.recordAmount = recordAmount;
	}
	public Integer getPoints() {
		return points;
	}
	public void setPoints(Integer points) {
		this.points = points;
	}
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getCzrq() {
		return czrq;
	}
	public void setCzrq(Date czrq) {
		this.czrq = czrq;
	}
	public String getOpenid() {
		return openid;
	}
	public void setOpenid(String openid) {
		this.openid = openid;
	}
	public Integer getStatus() {
		return status;
	}
	public void setStatus(Integer status) {
		this.status = status;
	}
	@Transient
	public List<SignPatientLabelInfo> getLabelInfos() {
		return labelInfos;
	}
	public void setLabelInfos(List<SignPatientLabelInfo> labelInfos) {
		this.labelInfos = labelInfos;
	}
	public String getMobileRemarks() {
		return mobileRemarks;
	}
	public void setMobileRemarks(String mobileRemarks) {
		this.mobileRemarks = mobileRemarks;
	}
	public Date getOpenidTime() {
		return openidTime;
	}
	public void setOpenidTime(Date openidTime) {
		this.openidTime = openidTime;
	}
    public String getSickVillage() {
        return sickVillage;
    }
	public String getSickVillage() {
		return sickVillage;
	}
    public void setSickVillage(String sickVillage) {
        this.sickVillage = sickVillage;
    }
	public void setSickVillage(String sickVillage) {
		this.sickVillage = sickVillage;
	}
    public String getSickVillageName() {
        return sickVillageName;
    }
	public String getSickVillageName() {
		return sickVillageName;
	}
    public void setSickVillageName(String sickVillageName) {
        this.sickVillageName = sickVillageName;
    }
	public void setSickVillageName(String sickVillageName) {
		this.sickVillageName = sickVillageName;
	}
    public Integer getIsWxtag() {
        return isWxtag;
    }
	public Integer getIsWxtag() {
		return isWxtag;
	}
    public void setIsWxtag(Integer isWxtag) {
        this.isWxtag = isWxtag;
    }
	public void setIsWxtag(Integer isWxtag) {
		this.isWxtag = isWxtag;
	}
    public Integer getWxtagid() {
        return wxtagid;
    }
	public Integer getWxtagid() {
		return wxtagid;
	}
    public void setWxtagid(Integer wxtagid) {
        this.wxtagid = wxtagid;
    }
	public void setWxtagid(Integer wxtagid) {
		this.wxtagid = wxtagid;
	}
    //---------------------------常量----------------------------
    public enum isWchatTage {
        yes(1), no(0);
	//---------------------------常量----------------------------
	public enum isWchatTage{
		yes(1),no(0);
        isWchatTage(Integer value) {
            this.value = value;
        }
		isWchatTage(Integer value) {
			this.value = value;
		}
        private Integer value;
		private Integer value;
        public Integer getValue() {
            return value;
        }
		public Integer getValue() {
			return value;
		}
        public void setValue(Integer value) {
            this.value = value;
        }
    }
		public void setValue(Integer value) {
			this.value = value;
		}
	}
	public Integer getStandardStatus() {
		return standardStatus;
	}
    public Integer getStandardStatus() {
        return standardStatus;
    }
	public void setStandardStatus(Integer standardStatus) {
		this.standardStatus = standardStatus;
	}
    public void setStandardStatus(Integer standardStatus) {
        this.standardStatus = standardStatus;
    }
}

+ 89 - 11
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/feedback/FeedbackService.java

@ -1,13 +1,21 @@
package com.yihu.wlyy.service.manager.feedback;
import com.yihu.wlyy.entity.Doctor;
import com.yihu.wlyy.entity.Followup;
import com.yihu.wlyy.entity.Message;
import com.yihu.wlyy.entity.Patient;
import com.yihu.wlyy.entity.feedback.Feedback;
import com.yihu.wlyy.repository.DoctorDao;
import com.yihu.wlyy.repository.MessageDao;
import com.yihu.wlyy.repository.PatientDao;
import com.yihu.wlyy.repository.feedback.FeedbackDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.util.HttpClientUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
@ -17,10 +25,8 @@ import org.springframework.transaction.annotation.Transactional;
import org.springside.modules.persistence.DynamicSpecifications;
import org.springside.modules.persistence.SearchFilter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.text.SimpleDateFormat;
import java.util.*;
/**
 * Created by Reece on 2017/5/6.
@ -34,6 +40,10 @@ public class FeedbackService extends BaseService {
    private PatientDao patientDao;
    @Autowired
    private DoctorDao doctorDao;
    @Value("${wlyyService.api}")
    private String wlyyService;
    @Autowired
    private MessageDao messageDao;
    /**
     * 分页查找问题
@ -55,13 +65,13 @@ public class FeedbackService extends BaseService {
        PageRequest pageRequest = new PageRequest(page - 1, rows, sort);
        // 设置查询条件
        Map<String, SearchFilter> filters = new HashMap<>();
        if (type!=-1) {
        if (type != -1) {
            filters.put("type", new SearchFilter("type", SearchFilter.Operator.EQ, type));
        }
        if (identity!=-1) {
        if (identity != -1) {
            filters.put("identity", new SearchFilter("identity", SearchFilter.Operator.EQ, identity));
        }
        if (status!=-1) {
        if (status != -1) {
            filters.put("status", new SearchFilter("status", SearchFilter.Operator.EQ, status));
        }
        // 未删除
@ -126,7 +136,7 @@ public class FeedbackService extends BaseService {
        int status = feedback.getStatus();
//        identity 1、患者 2、医生
        String name = null;
        if(StringUtils.isNotBlank(creater)) {
        if (StringUtils.isNotBlank(creater)) {
            if (identity == 1) {
                name = patientDao.findNameByCode(creater);
            } else {
@ -148,9 +158,9 @@ public class FeedbackService extends BaseService {
    public void delfeedback(String ids) {
        if(ids!=null){
        if (ids != null) {
            String[] _ids = ids.split(",");
            for(String id:_ids){
            for (String id : _ids) {
                Long _id = Long.valueOf(id);
                feedbackDao.delFeedback(_id);
            }
@ -163,10 +173,78 @@ public class FeedbackService extends BaseService {
     * @param result
     * @throws Exception
     */
    public void dealFeedback(Long id,String result) throws Exception {
    public void dealFeedback(Long id, String result) throws Exception {
        Feedback feedback = feedbackDao.findFeedbackById(id);
        feedback.setResult(result);
        feedback.setStatus(2);
        int identity = feedback.getIdentity();
        int type = feedback.getType();
        String typeName = null;
        String creater = feedback.getCreater();
        switch (type) {
            case 1:
                typeName = "优化建议";
                break;
            case 2:
                typeName = "提交bug";
                break;
            case 3:
                typeName = "新功能建议";
                break;
            case 4:
                typeName = "其他";
                break;
        }
        if (identity == 1) {
            //wlyy给患者发送模板消息
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            Patient patient = patientDao.findByCode(creater);
            String patientName = patient.getName();
            String patientOpendID = patient.getOpenid();
            if (StringUtils.isNotEmpty(patientOpendID)) {
                String url = wlyyService + "/patient/feedback/sendTemplate";
                List<NameValuePair> params = new ArrayList<>();
                params.add(new BasicNameValuePair("toUser", patientOpendID));
                params.add(new BasicNameValuePair("url", null));
                params.add(new BasicNameValuePair("first", "您好!您提交的意见反馈已处理"));
                params.add(new BasicNameValuePair("remark", "感谢你的意见"));
                SimpleDateFormat formatDate = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
                String newDate = formatDate.format(new Date());
                String keywords = patientName + "," + typeName + "," + result + "," + newDate;
                params.add(new BasicNameValuePair("keywords", keywords));
                HttpClientUtil.post(url, params, "UTF-8");
            }
        } else if (identity == 2) {
            SimpleDateFormat formatDate = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
            String newDate = formatDate.format(new Date());
            String title = "新增系统消息";
            String content = "您在" + newDate + "提交的意见反馈已处理,您可点此查看处理结果";
            Message message = new Message();
            message.setType(10);
            message.setCode(UUID.randomUUID().toString());
            message.setCzrq(new Date());
            message.setCreateTime(new Date());
            message.setContent(content);
            message.setRead(1);//设置未读
            message.setReceiver(creater);//设置接受医生的code
            message.setSender("system");//设置发送的用户
            message.setTitle(title);
            message.setReadonly(1);//是否只读消息
            //wlyy给医生发送系统消息
            Doctor doctor = doctorDao.findByCode(creater);
            String doctorOpenID = doctor.getOpenid();
            String url = wlyyService + "/patient/feedback/sendMessage";
            List<NameValuePair> params = new ArrayList<>();
            params.add(new BasicNameValuePair("receiver", creater));
            params.add(new BasicNameValuePair("title", title));
            params.add(new BasicNameValuePair("content",content));
            HttpClientUtil.post(url, params, "UTF-8");
            messageDao.save(message);
        }
        feedbackDao.save(feedback);
    }

+ 7 - 2
patient-co-manage/wlyy-manage/src/main/resources/application.yml

@ -75,7 +75,8 @@ yueren:
  api: http://120.77.209.211:8080
doctorAssistant:
  api: http://192.168.131.113:8080
#  api: http://172.19.103.88:10090/wlyy
wlyyService:
  api: http://10.95.22.10:8011/wlyy/
---
spring:
@ -108,6 +109,8 @@ yueren:
  api: http://120.77.209.211:8080
doctorAssistant:
  api: http://172.19.103.88:10090/wlyy
wlyyService:
  api: http://ehr.yihu.com/wlyy/
---
spring:
@ -137,4 +140,6 @@ im-service:
yueren:
  api: http://120.77.209.211:8080
doctorAssistant:
  api: http://www.xmtyw.cn/assistant
  api: http://www.xmtyw.cn/assistant
wlyyService:
  api: http://www.xmtyw.cn/wlyy/

+ 19 - 0
patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/common/dao/ConsultTeamDao.java

@ -0,0 +1,19 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.hos.device.common.dao;
import com.yihu.hos.device.model.ConsultTeam;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface ConsultTeamDao extends PagingAndSortingRepository<ConsultTeam, Long>, JpaSpecificationExecutor<ConsultTeam> {
	@Query("select a from ConsultTeam a where a.patient = ?1 and a.del = '1' and a.status = 0")
	List<ConsultTeam> findUnfinishedConsult(String patient);
}

+ 14 - 0
patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/common/util/DateUtil.java

@ -1544,4 +1544,18 @@ public class DateUtil {
            return null;
        }
    }
    
    /**
     * 将长时间格式时间转换为字符串 yyyy-MM-dd HH:mm:ss
     *
     * @param dateDate
     * @return
     */
    public static String dateToStrLong(java.util.Date dateDate) {
        if (dateDate == null) {
            return "";
        }
        SimpleDateFormat formatter = new SimpleDateFormat(DEFAULT_YMDHMSDATE_FORMAT);
        return formatter.format(dateDate);
    }
}

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

@ -0,0 +1,341 @@
package com.yihu.hos.device.model;
import com.fasterxml.jackson.annotation.JsonFormat;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.Date;
/**
 * 三师咨询
 * @author George
 */
@Entity
@Table(name = "wlyy_consult_team")
public class ConsultTeam extends IdEntity {
	private static final long serialVersionUID = -7644448339473861513L;
	private String consult;         // 咨询标识
	private String doctor;          // 医生标识
	private String team;            // 三师团队标识
	private Integer type;           //  1、三师咨询,2、家庭医生咨询,6、患者名医咨询 7医生名医咨询 8续方咨询
	private String patient;         // 提问者标识
	private String name;            // 患者姓名
	private Integer sex;            // 患者性别
	private Date birthday;          // 患者生日
	private String photo;           // 患者头像
	private String when;            // 发病日期
	private String symptoms;        // 主要症状
	private Integer status;         // 咨询状态(0进行中,1已完成,-1患者取消,-2超时未响应自动关闭)
	private String images;          // 咨询图片URL,多图以逗号分隔
	private String voice;           // 咨询语音URL
	private String comment;         // 用户评价标识
	private String commentContent;  // 用户评价内容
	private Integer commentStar;    // 用户评价星级
	private Integer doctorRead;     // 医生未读数量
	private Integer patientRead;    // 患者未读数量
	private Date czrq;              // 咨询时间
	private String del;             // 作废标识,1正常,0作废
	private Long adminTeamId;//行政团队ID
	private Long guidance;   //关联指导
	private String doctorName;//醫生名字
	//起始消息id
	private String startMsgId;
	//结束消息id
	private String endMsgId;
	// 结束人
	private String endOperator;
	// 结束人类型
	private Integer endType;
	// 结束时间
	private Date endTime;
	//是否评价 1、已评价 0、未评价'
	private Integer evaluate;
	//评价时间
	private Date evaluateTime;
	private String relationCode;//关联业务表的code
	
	private Integer healthindexType;//体征数据上传发送IM消息:1血压 2血糖 3血压+血糖
	public Integer getEvaluate() {
		return evaluate;
	}
	public void setEvaluate(Integer evaluate) {
		this.evaluate = evaluate;
	}
	public Date getEvaluateTime() {
		return evaluateTime;
	}
	public void setEvaluateTime(Date evaluateTime) {
		this.evaluateTime = evaluateTime;
	}
	@Column(name = "admin_team_code")
	public Long getAdminTeamId() {
		return adminTeamId;
	}
	public void setAdminTeamId(Long adminTeamId) {
		this.adminTeamId = adminTeamId;
	}
	public String getConsult() {
		return consult;
	}
	public void setConsult(String consult) {
		this.consult = consult;
	}
	public ConsultTeam() {
	}
	public String getDoctor() {
		return doctor;
	}
	public void setDoctor(String doctor) {
		this.doctor = doctor;
	}
	public String getTeam() {
		return team;
	}
	public void setTeam(String team) {
		this.team = team;
	}
	public Integer getType() {
		return type;
	}
	public void setType(Integer type) {
		this.type = type;
	}
	public String getPatient() {
		return patient;
	}
	public void setPatient(String patient) {
		this.patient = patient;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+08:00")
	public Date getBirthday() {
		return birthday;
	}
	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	}
	public String getPhoto() {
		return photo;
	}
	public void setPhoto(String photo) {
		this.photo = photo;
	}
	@Column(name = "fbsj")
	public String getWhen() {
		return when;
	}
	public void setWhen(String when) {
		this.when = when;
	}
	public Integer getStatus() {
		return status;
	}
	public void setStatus(Integer status) {
		this.status = status;
	}
	public String getImages() {
		return images;
	}
	public void setImages(String images) {
		this.images = images;
	}
	public String getVoice() {
		return voice;
	}
	public void setVoice(String voice) {
		this.voice = voice;
	}
	public String getComment() {
		return comment;
	}
	public void setComment(String comment) {
		this.comment = comment;
	}
	@Column(name = "comment_content")
	public String getCommentContent() {
		return commentContent;
	}
	public void setCommentContent(String commentContent) {
		this.commentContent = commentContent;
	}
	@Column(name = "comment_star")
	public Integer getCommentStar() {
		return commentStar;
	}
	public void setCommentStar(Integer commentStar) {
		this.commentStar = commentStar;
	}
	@Column(name = "doctor_read")
	public Integer getDoctorRead() {
		return doctorRead;
	}
	public void setDoctorRead(Integer doctorRead) {
		this.doctorRead = doctorRead;
	}
	@Column(name = "patient_read")
	public Integer getPatientRead() {
		return patientRead;
	}
	public void setPatientRead(Integer patientRead) {
		this.patientRead = patientRead;
	}
	// 设定JSON序列化时的日期格式
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getCzrq() {
		return czrq;
	}
	public void setCzrq(Date czrq) {
		this.czrq = czrq;
	}
	// 设定JSON序列化时的日期格式
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getEndTime() {
		return endTime;
	}
	public void setEndTime(Date endTime) {
		this.endTime = endTime;
	}
	public String getSymptoms() {
		return symptoms;
	}
	public void setSymptoms(String symptoms) {
		this.symptoms = symptoms;
	}
	public String getDel() {
		return del;
	}
	public void setDel(String del) {
		this.del = del;
	}
	public Integer getSex() {
		return sex;
	}
	public void setSex(Integer sex) {
		this.sex = sex;
	}
	@Transient
	public String getDoctorName() {
		return doctorName;
	}
	public void setDoctorName(String doctorName) {
		this.doctorName = doctorName;
	}
	public Long getGuidance() {
		return guidance;
	}
	public void setGuidance(Long guidance) {
		this.guidance = guidance;
	}
	public String getStartMsgId() {
		return startMsgId;
	}
	public void setStartMsgId(String startMsgId) {
		this.startMsgId = startMsgId;
	}
	public String getEndMsgId() {
		return endMsgId;
	}
	public void setEndMsgId(String endMsgId) {
		this.endMsgId = endMsgId;
	}
	public String getEndOperator() {
		return endOperator;
	}
	public void setEndOperator(String endOperator) {
		this.endOperator = endOperator;
	}
	public Integer getEndType() {
		return endType;
	}
	public void setEndType(Integer endType) {
		this.endType = endType;
	}
	public String getRelationCode() {
		return relationCode;
	}
	public void setRelationCode(String relationCode) {
		this.relationCode = relationCode;
	}
	
	public static long getSerialVersionUID() {
		return serialVersionUID;
	}
	
	public Integer getHealthindexType() {
		return healthindexType;
	}
	
	public void setHealthindexType(Integer healthindexType) {
		this.healthindexType = healthindexType;
	}
}

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

@ -7,10 +7,7 @@ import com.yihu.hos.device.common.dao.*;
import com.yihu.hos.device.common.http.HttpClientUtil;
import com.yihu.hos.device.common.http.HttpHelper;
import com.yihu.hos.device.common.http.HttpResponse;
import com.yihu.hos.device.common.util.DateUtil;
import com.yihu.hos.device.common.util.ETLConstantData;
import com.yihu.hos.device.common.util.MessageType;
import com.yihu.hos.device.common.util.StringUtil;
import com.yihu.hos.device.common.util.*;
import com.yihu.hos.device.model.*;
import com.yihu.hos.device.task.PushMsgTask;
import net.sf.json.JSONArray;
@ -65,6 +62,10 @@ public class DeviceService {
    private PatientHealthTimeDao patientHealthTimeDao;
    @Autowired
    private PushMsgTask pushMsgTask;
    @Autowired
    private ConsultTeamDao consultTeamDao;
    @Autowired
    private ImUtill ImUtill;
    private ObjectMapper objectMapper = new ObjectMapper();
    private Integer aStart;
@ -383,11 +384,19 @@ public class DeviceService {
            if (result == null) {
                throw new Exception("This device is not relate patient!");
            } else {
    
                //患者信息
                String patientCode = result.getUser();
                Patient patient = patientDao.findByCode(patientCode);
                
                //血糖、血压数据需校验,如果超标,需要发送消息给医生
                if (1 == deviceType || 2 == deviceType) {
                    verifyHealthIndex(result);
                    //发送华三demo推送
//                    messagePush(result);
                    
                    //判断是否有未结束的续方咨询,发送消息给对应的医生----huangwenjie--2017.11.06
                    sendPrescriptionHealthIndexMsgresult(result,patient);
                }
                //指标数据上传基卫
@ -397,9 +406,6 @@ public class DeviceService {
                //连续5次体征值正常,则修改为非预警状态;连续5次异常,修改为预警状态-----START
                String patientCode = result.getUser();
                //患者信息
                Patient patient = patientDao.findByCode(patientCode);
                int bloodPressureBbnormalCount = 0;//血压异常次数
                int bloodSuggurBbnormalCount = 0;//血糖异常次数
@ -465,6 +471,7 @@ public class DeviceService {
        return Result.success("Device data incoming success");
    }
    
    /**
     * 保存设备数据
     */
@ -890,4 +897,43 @@ public class DeviceService {
            ex.printStackTrace();
        }
    }
    
    /**
     * 判断是否有未结束的续方咨询,发送消息给对应的医生
     * @param result
     * @param patient
     */
    private void sendPrescriptionHealthIndexMsgresult(PatientHealthIndex result, Patient patient) {
        
        List<ConsultTeam> consultTeams = consultTeamDao.findUnfinishedConsult(patient.getCode());
    
        if(1 == result.getType()){
            for (ConsultTeam consultTeam:consultTeams) {
                if(1 == consultTeam.getHealthindexType() || 3 == consultTeam.getHealthindexType()){
                    org.json.JSONObject contentPatient = new org.json.JSONObject();
                    //患者发送的消息
                    contentPatient.put("title", "【本消息为系统提醒】:");
                    contentPatient.put("tzMsg", "体征记录:血糖 "+result.getValue1());
                    contentPatient.put("tzTime", "检测时间:"+DateUtil.dateToStrLong(result.getRecordDate()));
                    contentPatient.put("tzAlert","温馨提示:本条体征为居民上传的健康体征数据,您可以自动填入本次随访记录");
                    //患者发送Im消息
                    ImUtill.sendTopicIM(patient.getCode(), patient.getName(), consultTeam.getConsult(), "16", contentPatient.toString(), null);
                }
            }
        }else if(2 == result.getType()){
            for (ConsultTeam consultTeam:consultTeams) {
                if(2 == consultTeam.getHealthindexType() || 3 == consultTeam.getHealthindexType()){
                    org.json.JSONObject contentPatient = new org.json.JSONObject();
                    //患者发送的消息
                    contentPatient.put("title", "【本消息为系统提醒】:");
                    contentPatient.put("tzMsg", "体征记录:血压 "+result.getValue1()+"/"+result.getValue2()+" mmHg");
                    contentPatient.put("tzTime", "检测时间:"+DateUtil.dateToStrLong(result.getRecordDate()));
                    contentPatient.put("tzAlert","温馨提示:本条体征为居民上传的健康体征数据,您可以自动填入本次随访记录");
                    //患者发送Im消息
                    ImUtill.sendTopicIM(patient.getCode(), patient.getName(), consultTeam.getConsult(), "16", contentPatient.toString(), null);
                }
            }
        }
    }
}

+ 31 - 21
patient-co/patient-co-doctor-assistant/src/main/resources/application-dev.yml

@ -26,30 +26,40 @@ im:
  data_base_name: ichat
wechat:
  appId: wxb3827510b2e15012
  appSecret: c5bdedd909ded9c2ee08028487e6f50d
  appId: wxd03f859efdf0873d
  appSecret: 2935b54b53a957d9516c920a544f2537
  wechat_token: 27eb3bb24f149a7760cf1bb154b08040
  wechat_base_url: http%3a%2f%2fweixin.xmtyw.cn%2fwlyy-dev
  accId: gh_aa9cd602b84b
  accId: gh_ffd64560fb21
  message:
   ##处方待处理提醒
      template_prescription_pending: 2MKI4j9rGQoXg6-8KMbR7PrPipzz5Su8QUBqWySno2U
      ##服务状态提醒
      template_consult_notice: fgYiMntj1amEkE8_GLUPmAIyssUAroJrNSHqvydt-PQ
      #居民体征异常提醒
      template_abnormal_signs: G3UNiiqf3T_0E_ULP59iGl4_ecAqAlOAuJReDDlv0_w
      #咨询请求通知
      template_consult_request: O-bJ4Hkd-ehWmCkVaiOJjmYTAbJB6FL8_LJHCLYrTH8
      #签约申请通知
      template_sign_request: T54W9ky7NxO9WGqwwJP1YHlP-Q2LNZiE-QXTE0i9Ep8
      #随访提醒
      template_followup_success:  YmTqucDGmergNWh4D1XkokV6m04H6yTKQv23xdu_vKM
      #处理结果通知
      template_treatment_result:  _AuCuXOKlVrG3ro65q0nXyfZKmLpraSYFiskahajHro
      #咨询回复提醒
      template_consult_reply:  sjnflOikO0WqMp4e338G8I0eFUXd6h8ljwgAlPZj5Tw
      #代办事项提醒
      template_schedule_remind:  sjnflOikO0WqMp4e338G8I0eFUXd6h8ljwgAlPZj5Tw
   ##医生追加建议提醒 --签约邀请
   doctor_invitel_template: TLWrBtNE2kBJaFCdVzDOOnQC8N2TtRY9ZxEzwZXQcR0
   #咨询回复
   template_consult_notice: qSOW0DBxO3qEBm4ucG0Ial0jxsOyD7_f2TFK5e-mQEc
   #签约成功
   template_sign_success: hDWV_sknKlhxhOwR5h68OCXbAhRpcgnx9INrT8BybE8
   #签约失败
   template_sign_failed: ezgttXE7rG4rAboQK2ituG1dKq4PeyCj3LxGJWO_vOA
   #健康指导提醒
   template_health_notice: 128RCfyCHi22jW8PZzo7vabKMsA3SBv5VeHaDPr2Bhw
   #解约提醒
   template_termination:  LrrzHjnIF67ww5uQUvSiv3_pVKJiIK4ZE3fKrvsT0AE
   #预约成功
   template_appoint_success:  Bo2yqNczSU9zkg4wXoouv9tSeefZ6TziggWL3dTXPYE
   #预约取消
   template_appoint_failed:  pErTBTdweIdrNRf_1Oo62YtQC0aHwPvtLaCzw44JzCQ
   #缴费提醒
   template_expenses_remind:  BkTGJ8S18qZ3DfaptAXnZznAk8RJjx9v93og5vyO0bs
   #健康教育
   template_healthy_article: LA7erINJ0CSsG2G_ZCrgsDaX3krhsI4qg_NSHEyL_l4
   #医生变更
   template_doctor_change:  TNIDMjduVKgVL4-k71umYLpHROvFB8K6mmm8aZC_EH8
   #问卷调查
   template_doctor_survey:  IjQvzBy0PLeft2kN9mdBhACXPE9I_jyJywJ6B-JRxsY
   #审核结果通知
   template_doctor_audit:  OFyLUeBW3r9trWw-i6pbB1sPSTD4J2recCv_mc-gKxA
   #服务结果通知
   template_doctor_service:  ezr5RlX0nvh7bGU9aVsGDMJbjKDp1uMKP-AGGYXwI5g
yihu:
  yihu_OpenPlatform_url: http://ssotest.yihu.cn/OpenPlatform/cgiBin/1.0/

+ 0 - 111
patient-co/patient-co-doctor-assistant/src/main/resources/application-devbak.yml

@ -1,111 +0,0 @@
##开发的配置
spring:
  profiles: dev
  datasource:
    wlyy:
      url: jdbc:mysql://172.19.103.77/wlyy?useUnicode:true&amp;characterEncoding=utf-8&amp;autoReconnect=true
      username: root
      password: 123456
    health:
      url: jdbc:mysql://172.19.103.77/device?useUnicode=true&amp;characterEncoding=utf-8&amp;autoReconnect=true
      username: root
      password: 123456
  redis:
    host: 172.19.103.88 # Redis server host.
    port: 6379 # Redis server port.
#    password: jkzl_ehr
server:
  server_url: http://weixin.xmtyw.cn/wlyy-dev/
im:
  im_list_get: http://172.19.103.88:3000/
  data_base_name: ichat
wechat:
  appId: wxd03f859efdf0873d
  appSecret: 2935b54b53a957d9516c920a544f2537
  wechat_token: 27eb3bb24f149a7760cf1bb154b08040
  wechat_base_url: http%3a%2f%2fweixin.xmtyw.cn%2fwlyy-dev
  accId: gh_ffd64560fb21
  message:
   ##医生追加建议提醒 --签约邀请
   doctor_invitel_template: TLWrBtNE2kBJaFCdVzDOOnQC8N2TtRY9ZxEzwZXQcR0
   #咨询回复
   template_consult_notice: qSOW0DBxO3qEBm4ucG0Ial0jxsOyD7_f2TFK5e-mQEc
   #签约成功
   template_sign_success: hDWV_sknKlhxhOwR5h68OCXbAhRpcgnx9INrT8BybE8
   #签约失败
   template_sign_failed: ezgttXE7rG4rAboQK2ituG1dKq4PeyCj3LxGJWO_vOA
   #健康指导提醒
   template_health_notice: 128RCfyCHi22jW8PZzo7vabKMsA3SBv5VeHaDPr2Bhw
   #解约提醒
   template_termination:  LrrzHjnIF67ww5uQUvSiv3_pVKJiIK4ZE3fKrvsT0AE
   #预约成功
   template_appoint_success:  Bo2yqNczSU9zkg4wXoouv9tSeefZ6TziggWL3dTXPYE
   #预约取消
   template_appoint_failed:  pErTBTdweIdrNRf_1Oo62YtQC0aHwPvtLaCzw44JzCQ
   #缴费提醒
   template_expenses_remind:  BkTGJ8S18qZ3DfaptAXnZznAk8RJjx9v93og5vyO0bs
   #健康教育
   template_healthy_article: LA7erINJ0CSsG2G_ZCrgsDaX3krhsI4qg_NSHEyL_l4
   #医生变更
   template_doctor_change:  TNIDMjduVKgVL4-k71umYLpHROvFB8K6mmm8aZC_EH8
   #问卷调查
   template_doctor_survey:  IjQvzBy0PLeft2kN9mdBhACXPE9I_jyJywJ6B-JRxsY
   #审核结果通知
   template_doctor_audit:  OFyLUeBW3r9trWw-i6pbB1sPSTD4J2recCv_mc-gKxA
   #服务结果通知
   template_doctor_service:  ezr5RlX0nvh7bGU9aVsGDMJbjKDp1uMKP-AGGYXwI5g
yihu:
  yihu_OpenPlatform_url: http://ssotest.yihu.cn/OpenPlatform/cgiBin/1.0/
  yihu_OpenPlatform_appId: 9000276
  yihu_OpenPlatform_secret: OKC8BS1KGXTDE9GPP1EO4VYLUXF8DJ7QUP72H613ZXA
fastDFS:
  fastdfs_file_url: http://172.19.103.54:80/
message:
  messageServerUrl: http://10.0.1.3:8080/OpenPlatform/cgiBin/1.0/smsgw/smsSendWS/send
  messageAppId: 9000286
  messageSecret: NW63YK778QPRUD2A6K5SNF7LYRQ888BWOVD6R4FG2VF
images:
  path: /var/local/upload/images
  renew_path: /usr/local/apache-tomcat-8.0.26/webapps/wlyy/images/renew.png
  sign_path: /usr/local/apache-tomcat-8.0.26/webapps/wlyy/images/familycontract.png
sign:
  check_upload: http://172.19.103.87:8011/wlyy_service
express:
  sf_url: http://218.17.248.244:11080/bsp-oisp/sfexpressService
#  sf_url: https://bsp-ois.sit.sf-express.com:9443/bsp-ois/sfexpressServic
  sf_code: SDDF
  sf_check_word: ttzlgGyOQu4L
pushMes:
  # 1为推送redis,0为推送消息队列
  method: 0
  # redis队列名称
  redis_prescription_title: redisPrescription
es:
  index:
    HealthEduArticlePatient: health_edu_article_patient_dev
  type:
    HealthEduArticlePatient: health_edu_article_patient_dev
  host: 172.19.103.68
  port: 9200
  tPort: 9300
  clusterName: jkzl
#消息队列
activemq:
  username: admin
  password: admin
  url: tcp://172.19.103.87:61616
  queue:
    healtHarticleQueue: healthArticleChannel_dev  #健康文章推送

+ 0 - 4
patient-co/patient-co-statistics-es/pom.xml

@ -445,10 +445,6 @@
            <groupId>com.yihu</groupId>
            <artifactId>common-entity</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu</groupId>
            <artifactId>common-entity</artifactId>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>

+ 77 - 0
patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/controller/QueryController.java

@ -10,15 +10,21 @@ import com.yihu.wlyy.statistics.etl.save.es.ElasticFactory;
import com.yihu.wlyy.statistics.util.DateUtil;
import com.yihu.wlyy.statistics.util.ElasticsearchUtil;
import com.yihu.wlyy.statistics.vo.SaveModel;
import io.searchbox.client.JestClient;
import io.searchbox.core.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.json.JSONArray;
import org.json.JSONObject;
import org.nlpcn.es4sql.jdbc.ObjectResult;
import org.nlpcn.es4sql.jdbc.ObjectResultsExtractor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@ -47,6 +53,13 @@ public class QueryController {
    @Autowired
    private ElasticsearchUtil elasticsearchUtil;
    @Autowired
    private ElasticFactory elasticFactory;
    @Value("${es.type}")
    private String esType;
    @Value("${es.index}")
    private String esIndex;
    @ApiOperation(value = "执行sql")
    @RequestMapping(value = "/excuteSQL", method = RequestMethod.GET)
    public List<SaveModel> excuteSQL(
@ -144,4 +157,68 @@ public class QueryController {
        return returnMap;
    }
    @ApiOperation(value = "删除某一天的某一个指标的数据")
    @RequestMapping(value = "/deleteQuotaWithId", method = RequestMethod.DELETE)
    public String deleteQuota(
            @ApiParam(name = "id", value = "指标id", required = true) @RequestParam(value = "id", required = true) String id,
            @ApiParam(name = "date", value = "时间(yyyy-MM-dd)", required = true) @RequestParam(value = "date", required = true) String date) {
        return  deleteData(DateUtil.strToDate(date, "yyyy-MM-dd"),id).toString();
    }
    @ApiOperation(value = "删除某一天的数据")
    @RequestMapping(value = "/deleteQuota", method = RequestMethod.DELETE)
    public String deleteQuota(
            @ApiParam(name = "date", value = "时间(yyyy-MM-dd)", required = true) @RequestParam(value = "date", required = true) String date) {
        return deleteData(DateUtil.strToDate(date, "yyyy-MM-dd"),null).toString();
    }
    /**
     * 删除 某个指标某一天的某个timelevel的数据
     *
     * @param quotaDate
     * @param quotaCode
     */
    private net.sf.json.JSONObject deleteData(Date quotaDate, String quotaCode) {
        net.sf.json.JSONObject jsonObject = new net.sf.json.JSONObject();
        try {
            JestClient jestClient = elasticFactory.getJestClient();
            //先根据条件查找出来
            SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
            BoolQueryBuilder boolQueryBuilder = new BoolQueryBuilder();
            if (quotaDate != null) {
                boolQueryBuilder.must(QueryBuilders.matchQuery("quotaDate", quotaDate));
            }
            if (!StringUtils.isEmpty(quotaCode)) {
                boolQueryBuilder.must(QueryBuilders.matchQuery("quotaCode", quotaCode));
            }
            searchSourceBuilder.query(boolQueryBuilder
            ).size(500000);//一次取10000条
            Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
                    .build();
            SearchResult result = jestClient.execute(search);
            List<SaveModel> saveModels = result.getSourceAsObjectList(SaveModel.class);
            //根据id批量删除
            Bulk.Builder bulk = new Bulk.Builder().defaultIndex(esIndex).defaultType(esType);
            for (SaveModel obj : saveModels) {
                Delete index = new Delete.Builder(obj.getId()).build();
                bulk.addAction(index);
            }
            BulkResult br = jestClient.execute(bulk.build());
            jsonObject.put("flag", br.isSucceeded());
            jsonObject.put("count", saveModels.size());
            return jsonObject;
        } catch (Exception e) {
            jsonObject.put("flag", false);
            jsonObject.put("message", e.getMessage());
            return jsonObject;
        }
    }
}

+ 29 - 17
patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/etl/convert/wlyy/ConsultTimeConvert.java

@ -3,12 +3,16 @@ package com.yihu.wlyy.statistics.etl.convert.wlyy;
import com.yihu.wlyy.entity.dimension.WlyyDimensionQuota;
import com.yihu.wlyy.statistics.etl.convert.Convert;
import com.yihu.wlyy.statistics.util.DateUtil;
import com.yihu.wlyy.statistics.util.IdCardUtil;
import com.yihu.wlyy.statistics.vo.DataModel;
import org.omg.PortableInterceptor.SYSTEM_EXCEPTION;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.util.StringUtils;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
/**
@ -24,26 +28,13 @@ public class ConsultTimeConvert implements Convert {
    public List<DataModel> convert(JdbcTemplate jdbcTemplate, List<DataModel> oneList, String slaveLevel, WlyyDimensionQuota temp) {
        oneList.stream().forEach(one -> {
            try {
                String value =one.getSlaveKey1();
                String valueStr = "1";
                if (!StringUtils.isEmpty(value)) {
                    try {
                        Integer valueInt = Integer.parseInt(value);
                        if (valueInt <= 28800) {
                            valueStr = "1";
                        }
                        if (valueInt > 28800 && valueInt <= 43200) {
                            valueStr = "2";
                        }
                        if (valueInt > 43200 && valueInt <= 46800) {
                            valueStr = "3";
                        }
                        if (valueInt > 46800 && valueInt <= 64800) {
                            valueStr = "4";
                        }
                        if (valueInt > 64800 && valueInt <= 86400) {
                            valueStr = "5";
                        }
                        Date time= DateUtil.strToDate(one.getSlaveKey1(),"yyyy-MM-dd HH:mm:ss");
                        valueStr= paserReplyTime(time);
                    } catch (Exception e) {
                    }
@ -55,5 +46,26 @@ public class ConsultTimeConvert implements Convert {
        });
        return oneList;
    }
    public String paserReplyTime(Date date){
        if(date!=null){
            Calendar calendar  =  new GregorianCalendar();
            calendar.setTime(date);
            //获取小时
            int hour = calendar.get(calendar.HOUR_OF_DAY);
            if(hour>=0&&hour<8){
                return "1";
            }else if(hour>=8&&hour<12){
                return "2";
            }else if(hour>=12&&hour<13){
                return "3";
            }else if(hour>=13&&hour<18){
                return "4";
            }else if(hour>=18&&hour<24){
                return"5";
            }else{
                return "";
            }
        }
        return "";
    }
}

+ 31 - 21
patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/etl/convert/wlyy/DiseaseAndAgeConvert.java

@ -3,6 +3,7 @@ package com.yihu.wlyy.statistics.etl.convert.wlyy;
import com.yihu.wlyy.entity.dimension.WlyyDimensionQuota;
import com.yihu.wlyy.statistics.etl.convert.Convert;
import com.yihu.wlyy.statistics.etl.convert.wlyy.model.HealthLable;
import com.yihu.wlyy.statistics.util.IdCardUtil;
import com.yihu.wlyy.statistics.vo.DataModel;
import org.springframework.beans.BeanUtils;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
@ -24,8 +25,10 @@ public class DiseaseAndAgeConvert implements Convert {
        List<DataModel> returnList = new ArrayList<>();
        Map<String, List<String>> healthLablesMap = new HashMap<>();//key是患者code value是患者标签 1高血压 2糖尿病 3 65岁以上
        //初始化标签Map
        initHealthLabesMap(jdbcTemplate, healthLablesMap);
        initHealthLabesMap(jdbcTemplate, healthLablesMap, oneList);
        //把标签Map设置到对应的维度里面
        for (DataModel dataModel : oneList) {
            List<String> labels = healthLablesMap.get(dataModel.getPatient());
            if (labels != null && labels.size() > 0) {
@ -40,11 +43,23 @@ public class DiseaseAndAgeConvert implements Convert {
                    }
                });
            }
            //判断患者是否是老年人是
            int age = IdCardUtil.getAgeForIdcard(dataModel.getIdcard());
            if (age >= 65) {
                try {
                    DataModel dataModelTemp = new DataModel();
                    BeanUtils.copyProperties(dataModel, dataModelTemp);
                    DataModel.class.getMethod("setSlaveKey" + slaveLevel, String.class).invoke(dataModelTemp, "3");
                    returnList.add(dataModelTemp);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
        return returnList;
    }
    private void initHealthLabesMap(JdbcTemplate jdbcTemplate, Map<String, List<String>> healthLablesMap) {
    private void initHealthLabesMap(JdbcTemplate jdbcTemplate, Map<String, List<String>> healthLablesMap, List<DataModel> oneList) {
        //得到患者的疾病标签(只要高血压 糖尿病)
        String sql = "SELECT " +
                "  spli.label AS health_lable, " +
@ -64,24 +79,19 @@ public class DiseaseAndAgeConvert implements Convert {
            labels.add(one.getHealthLable());
            healthLablesMap.put(one.getPatient(), labels);
        });
        //-得到患者的老年人标签
        sql = " SELECT " +
                "  spli.label AS health_lable, " +
                "  spli.patient " +
                " FROM " +
                "  wlyy_sign_patient_label_info spli " +
                " WHERE " +
                "  spli.label_type = '1' " +
                " AND spli. STATUS = '1' " +
                " AND spli.label = 3 ";
        healthLables = jdbcTemplate.query(sql, new BeanPropertyRowMapper(HealthLable.class));
        healthLables.stream().forEach(one -> {
            List<String> labels = healthLablesMap.get(one.getPatient());
            if (labels == null) {
                labels = new ArrayList<String>();
            }
            labels.add(one.getHealthLable());
            healthLablesMap.put(one.getPatient(), labels);
        });
//        //-得到患者的老年人标签
//        oneList.stream().forEach(one->{
//            int age = IdCardUtil.getAgeForIdcard(one.getIdcard());
//            if(age>=65){
//                num++;
//                List<String> labels = healthLablesMap.get(one.getPatient());
//                if (labels == null) {
//                    labels = new ArrayList<String>();
//                }
//                labels.add("3");
//                healthLablesMap.put(one.getPatient(), labels);
//            }
//        });
//        System.out.println("num:" + num);
    }
}

+ 20 - 20
patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/util/ElasticsearchUtil.java

@ -69,15 +69,15 @@ public class ElasticsearchUtil {
        StringBuffer sql = new StringBuffer();
        StringBuffer groupBy = new StringBuffer();
        if (SaveModel.teamLevel.equals(areaLevel)) {
            sql.append("select team,teamName,result1,result2 from wlyy_quota_test where team='" + code + "'");
            sql.append("select team,teamName,result1,result2 from "+esType+" where team='" + code + "'");
        } else if (SaveModel.OrgLevel.equals(areaLevel)) {
            sql.append("select hospital,hospitalName,sum(result1) result1,sum(result2) result2 from wlyy_quota_test where hospital='" + code + "'");
            sql.append("select hospital,hospitalName,sum(result1) result1,sum(result2) result2 from "+esType+" where hospital='" + code + "'");
            groupBy.append(" group by hospital,hospitalName");
        } else if (SaveModel.townLevel.equals(areaLevel)) {
            sql.append("select town,townName,sum(result1) result1,sum(result2) result2 from wlyy_quota_test where town='" + code + "'");
            sql.append("select town,townName,sum(result1) result1,sum(result2) result2 from "+esType+" where town='" + code + "'");
            groupBy.append(" group by town,townName");
        } else if (SaveModel.cityLevel.equals(areaLevel)) {
            sql.append("select city,cityName,sum(result1) result1,sum(result2) result2 from wlyy_quota_test where city='" + code + "'");
            sql.append("select city,cityName,sum(result1) result1,sum(result2) result2 from "+esType+" where city='" + code + "'");
            groupBy.append(" group by city,cityName");
        }
@ -120,15 +120,15 @@ public class ElasticsearchUtil {
        StringBuffer sql = new StringBuffer();
        StringBuffer groupBy = new StringBuffer();
        if (SaveModel.teamLevel.equals(areaLevel)) {
            sql.append("select team,teamName,result1,result2 from wlyy_quota_test where team='" + code + "'");
            sql.append("select team,teamName,result1,result2 from "+esType+" where team='" + code + "'");
        } else if (SaveModel.OrgLevel.equals(areaLevel)) {
            sql.append("select hospital,hospitalName,sum(result1) result1,sum(result2) result2 from wlyy_quota_test where hospital='" + code + "'");
            sql.append("select hospital,hospitalName,sum(result1) result1,sum(result2) result2 from "+esType+" where hospital='" + code + "'");
            groupBy.append(" group by hospital,hospitalName");
        } else if (SaveModel.townLevel.equals(areaLevel)) {
            sql.append("select town,townName,sum(result1) result1,sum(result2) result2 from wlyy_quota_test where town='" + code + "'");
            sql.append("select town,townName,sum(result1) result1,sum(result2) result2 from "+esType+" where town='" + code + "'");
            groupBy.append(" group by town,townName");
        } else if (SaveModel.cityLevel.equals(areaLevel)) {
            sql.append("select city,cityName,sum(result1) result1,sum(result2) result2 from wlyy_quota_test where city='" + code + "'");
            sql.append("select city,cityName,sum(result1) result1,sum(result2) result2 from "+esType+" where city='" + code + "'");
            groupBy.append(" group by city,cityName");
        }
@ -163,16 +163,16 @@ public class ElasticsearchUtil {
        StringBuffer sql = new StringBuffer();
        StringBuffer groupBy = new StringBuffer();
        if (SaveModel.teamLevel.equals(areaLevel)) {
            sql.append("select team,teamName,slaveKey1,slaveKey1Name,slaveKey2,slaveKey2Name,result1,result2 from wlyy_quota_test where team='" + code + "'");
            sql.append("select team,teamName,slaveKey1,slaveKey1Name,slaveKey2,slaveKey2Name,result1,result2 from "+esType+" where team='" + code + "'");
            groupBy.append("  group by slaveKey1,slaveKey1Name,slaveKey2,slaveKey2Name");
        } else if (SaveModel.OrgLevel.equals(areaLevel)) {
            sql.append("select hospital,hospitalName,slaveKey1,slaveKey1Name,slaveKey2,slaveKey2Name,sum(result1) result1,sum(result2) result2 from wlyy_quota_test where hospital='" + code + "'");
            sql.append("select hospital,hospitalName,slaveKey1,slaveKey1Name,slaveKey2,slaveKey2Name,sum(result1) result1,sum(result2) result2 from "+esType+" where hospital='" + code + "'");
            groupBy.append("  group by slaveKey1,slaveKey1Name,slaveKey2,slaveKey2Name");
        } else if (SaveModel.townLevel.equals(areaLevel)) {
            sql.append("select town,townName,slaveKey1,slaveKey1Name,slaveKey2,slaveKey2Name,sum(result1) result1,sum(result2) result2 from wlyy_quota_test where town='" + code + "'");
            sql.append("select town,townName,slaveKey1,slaveKey1Name,slaveKey2,slaveKey2Name,sum(result1) result1,sum(result2) result2 from "+esType+" where town='" + code + "'");
            groupBy.append("  group by slaveKey1,slaveKey1Name,slaveKey2,slaveKey2Name");
        } else if (SaveModel.cityLevel.equals(areaLevel)) {
            sql.append("select city,cityName,slaveKey1,slaveKey1Name,slaveKey2,slaveKey2Name,sum(result1) result1,sum(result2) result2 from wlyy_quota_test where city='" + code + "'");
            sql.append("select city,cityName,slaveKey1,slaveKey1Name,slaveKey2,slaveKey2Name,sum(result1) result1,sum(result2) result2 from "+esType+" where city='" + code + "'");
            groupBy.append("  group by slaveKey1,slaveKey1Name,slaveKey2,slaveKey2Name");
        }
@ -208,16 +208,16 @@ public class ElasticsearchUtil {
        StringBuffer sql = new StringBuffer();
        StringBuffer groupBy = new StringBuffer();
        if (SaveModel.teamLevel.equals(areaLevel)) {
            sql.append("select team,teamName,slaveKey1,slaveKey1Name,result1,result2 from wlyy_quota_test where team='" + code + "'");
            sql.append("select team,teamName,slaveKey1,slaveKey1Name,result1,result2 from "+esType+" where team='" + code + "'");
            groupBy.append("  group by team,teamName,slaveKey1,slaveKey1Name");
        } else if (SaveModel.OrgLevel.equals(areaLevel)) {
            sql.append("select hospital,hospitalName,slaveKey1,slaveKey1Name,sum(result1) result1,sum(result2) result2 from wlyy_quota_test where hospital='" + code + "'");
            sql.append("select hospital,hospitalName,slaveKey1,slaveKey1Name,sum(result1) result1,sum(result2) result2 from "+esType+" where hospital='" + code + "'");
            groupBy.append("  group by hospital,hospitalName,slaveKey1,slaveKey1Name");
        } else if (SaveModel.townLevel.equals(areaLevel)) {
            sql.append("select town,townName,slaveKey1,slaveKey1Name,sum(result1) result1,sum(result2) result2 from wlyy_quota_test where town='" + code + "'");
            sql.append("select town,townName,slaveKey1,slaveKey1Name,sum(result1) result1,sum(result2) result2 from "+esType+" where town='" + code + "'");
            groupBy.append("  group by town,townName,slaveKey1,slaveKey1Name");
        } else if (SaveModel.cityLevel.equals(areaLevel)) {
            sql.append("select city,cityName,slaveKey1,slaveKey1Name,sum(result1) result1,sum(result2) result2 from wlyy_quota_test where city='" + code + "'");
            sql.append("select city,cityName,slaveKey1,slaveKey1Name,sum(result1) result1,sum(result2) result2 from "+esType+" where city='" + code + "'");
            groupBy.append("  group by city,cityName,slaveKey1,slaveKey1Name");
        }
@ -258,15 +258,15 @@ public class ElasticsearchUtil {
        StringBuffer groupBy = new StringBuffer();
        //根据 childAreaLevel   group by
        if (SaveModel.teamLevel.equals(childAreaLevel)) {
            sql.append("select team,teamName,result1,result2 from wlyy_quota_test where  ");
            sql.append("select team,teamName,result1,result2 from "+esType+" where  ");
        } else if (SaveModel.OrgLevel.equals(childAreaLevel)) {
            sql.append("select hospital,hospitalName,sum(result1) result1,sum(result2) result2 from wlyy_quota_test where  ");
            sql.append("select hospital,hospitalName,sum(result1) result1,sum(result2) result2 from "+esType+" where  ");
            groupBy.append(" group by hospital,hospitalName");
        } else if (SaveModel.townLevel.equals(childAreaLevel)) {
            sql.append("select town,townName,sum(result1) result1,sum(result2) result2 from wlyy_quota_test where ");
            sql.append("select town,townName,sum(result1) result1,sum(result2) result2 from "+esType+" where ");
            groupBy.append(" group by town,townName");
        } else if (SaveModel.cityLevel.equals(childAreaLevel)) {
            sql.append("select city,cityName,sum(result1) result1,sum(result2) result2 from wlyy_quota_test where  ");
            sql.append("select city,cityName,sum(result1) result1,sum(result2) result2 from "+esType+" where  ");
            groupBy.append(" group by city,cityName");
        }

+ 1 - 0
patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/util/IdCardUtil.java

@ -92,6 +92,7 @@ public class IdCardUtil {
        }
    }
    /**
     * 根据身份证的号码算出当前身份证持有者的年龄
     *

+ 61 - 0
patient-co/patient-co-statistics-es/src/main/resources/application-devtest.yml

@ -0,0 +1,61 @@
spring:
  profiles: test
  datasource:
    primaryReadWrite:
      url: jdbc:mysql://172.19.103.85/wlyy?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
      username: linzhou
      password: linzhou
    primaryRead:
      url: jdbc:mysql://172.19.103.85/wlyy?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
      username: linzhou
      password: linzhou
    im: #im库
      url: jdbc:mysql://172.19.103.85/wlyy?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
      username: linzhou
      password: linzhou
#    primaryReadWrite:
#      url: jdbc:mysql://172.19.103.77/wlyy_quota?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
#      username: root
#      password: 123456
#    primaryRead:
#      url: jdbc:mysql://172.19.103.77/wlyy_quota?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
#      username: root
#      password: 123456
#    im: #im库
#      url: jdbc:mysql://172.19.103.77/wlyy_quota?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
#      username: root
#      password: 123456
  redis:
    host: 172.19.103.88 # Redis server host.
    port: 6379 # Redis server port.
  followupMessage:
    cron : 0 5 0 * * ?
    jobId : FOLLOWUP_PLAN_JOB
fv:
  jdbc:
    driver: com.mysql.jdbc.Driver
    url: jdbc:mysql://172.17.110.160/fv?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
    username: ssgg
    password: ssgg
systemConfig:
  msg_push_server: http://127.0.0.1:3000
es:
  index: wlyy_quota_test
  type: wlyy_quota_test
  host: 172.19.103.68
  port: 9200
  tPort: 9300
  clusterName: jkzl
wlyy:
  im:
    databaseName: im_new
quartz:
  name: schedulerFactoryBean_cwd

+ 21 - 21
patient-co/patient-co-statistics-es/src/main/resources/application-test.yml

@ -2,30 +2,30 @@ spring:
  profiles: test
  datasource:
#    primaryReadWrite:
#      url: jdbc:mysql://172.19.103.85/data_for_stats?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
#      username: linzhou
#      password: linzhou
#    primaryRead:
#      url: jdbc:mysql://172.19.103.85/data_for_stats?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
#      username: linzhou
#      password: linzhou
#    im: #im库
#      url: jdbc:mysql://172.17.110.160/im_new?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
#      username: linzhou
#      password: linzhou
    primaryReadWrite:
      url: jdbc:mysql://172.19.103.77/wlyy_quota?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
      username: root
      password: 123456
      url: jdbc:mysql://172.19.103.85/wlyy?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
      username: linzhou
      password: linzhou
    primaryRead:
      url: jdbc:mysql://172.19.103.77/wlyy_quota?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
      username: root
      password: 123456
      url: jdbc:mysql://172.19.103.85/wlyy?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
      username: linzhou
      password: linzhou
    im: #im库
      url: jdbc:mysql://172.19.103.77/wlyy_quota?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
      username: root
      password: 123456
      url: jdbc:mysql://172.19.103.85/wlyy?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
      username: linzhou
      password: linzhou
#    primaryReadWrite:
#      url: jdbc:mysql://172.19.103.77/wlyy_quota?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
#      username: root
#      password: 123456
#    primaryRead:
#      url: jdbc:mysql://172.19.103.77/wlyy_quota?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
#      username: root
#      password: 123456
#    im: #im库
#      url: jdbc:mysql://172.19.103.77/wlyy_quota?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
#      username: root
#      password: 123456
  redis:
    host: 172.19.103.88 # Redis server host.

+ 1 - 1
patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/etl/mycache/CachePool.java

@ -345,7 +345,7 @@ public class CachePool {
            model = new RenewCacheModel();
            String sql=" select fr.sign_code code,fr.hospital ,fr.admin_team_id ,fr.patient " +
            String sql=" select fr.sign_code code,fr.hospital ,fr.admin_team_id ,fr.patient,fr.idcard " +
                    "   from wlyy_sign_family_renew_log fr " +
                    "   where " +
                    "   fr.apply_date<'"+ date + Constant.quota_date_last+"' " +

+ 1 - 1
patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/CurrentDayAllQuotaJob.java

@ -147,7 +147,7 @@ public class CurrentDayAllQuotaJob implements Job {
     */
    public Map<String,Object> getCityRenewTotals(){
        try{
            String sql=" select fr.sign_code code,fr.old_hospital hospital,fr.old_admin_team_id admin_team_id ,fr.patient " +
            String sql=" select fr.sign_code code,fr.old_hospital hospital,fr.old_admin_team_id admin_team_id ,fr.patient,fr.idcard " +
                    " from wlyy_sign_family_renew_log fr " +
                    " where  " +
                    " fr.apply_date<'"+ tomorrow+"' and " +

+ 51 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/SicardQueryJob.java

@ -0,0 +1,51 @@
package com.yihu.wlyy.job;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.repository.charge.ChargeDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.service.app.charge.OnePayService;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
/**
 * 处理电子社保卡绑定业务
 * Created by Reece on 2017/9/26/029.
 */
public class SicardQueryJob implements Job {
    private static final Logger logger = LoggerFactory.getLogger(SicardQueryJob.class);
    @Autowired
    private OnePayService payService;
    @Autowired
    private PatientDao patientDao;
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        logger.info("SicardQueryJob start ..........");
        try {
            List<Patient> patientList = patientDao.listNotupdated();
            if (patientList != null && patientList.size() > 0) {
                for (Patient patient : patientList) {
                    try {
                        payService.bindCardList(patient.getOpenid());
                    } catch (Exception e) {
                        logger.info("SicardQueryJob error ..........continue this JOB,CODE:" + patient.getCode() + ",message:" + e.getMessage());
                        continue;
                    }
                }
            }
            logger.info("SicardQueryJob end ..........");
        } catch (Exception e) {
            e.printStackTrace();
            logger.info("SicardQueryJob error ..........,message:" + e.getMessage());
        }
    }
}

+ 4 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/patient/PatientDao.java

@ -69,4 +69,8 @@ public interface PatientDao extends PagingAndSortingRepository<Patient, Long> {
    @Modifying
    @Query("update Patient p set p.diseaseCondition = ?2 where p.idcard = ?1")
    void updatePatientDiseascontionByIdcard(String idcard, Integer diseaseCondition);
    //获取已绑定社保卡但状态未更新数据(过滤掉为空情况)
    @Query(" select p from Patient p where password is null ")
    List<Patient> listNotupdated();
}

+ 53 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/charge/BindCard.java

@ -0,0 +1,53 @@
package com.yihu.wlyy.service.app.charge;
/**
 * 社保卡绑定信息
 * add by hzp at 20170524
 */
public class BindCard {
    private String attachCardNo;
    private String attachIdType;
    private String attachIdNo;
    private String attachName;
    private String attachRelation;   //01配偶 02父母 03子女  98本人 99未知
    public String getAttachCardNo() {
        return attachCardNo;
    }
    public void setAttachCardNo(String attachCardNo) {
        this.attachCardNo = attachCardNo;
    }
    public String getAttachIdType() {
        return attachIdType;
    }
    public void setAttachIdType(String attachIdType) {
        this.attachIdType = attachIdType;
    }
    public String getAttachIdNo() {
        return attachIdNo;
    }
    public void setAttachIdNo(String attachIdNo) {
        this.attachIdNo = attachIdNo;
    }
    public String getAttachName() {
        return attachName;
    }
    public void setAttachName(String attachName) {
        this.attachName = attachName;
    }
    public String getAttachRelation() {
        return attachRelation;
    }
    public void setAttachRelation(String attachRelation) {
        this.attachRelation = attachRelation;
    }
}

+ 81 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/charge/OnePayService.java

@ -2,9 +2,11 @@ package com.yihu.wlyy.service.app.charge;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.entity.charge.WlyyCharge;
import com.yihu.wlyy.entity.organization.HospitalMapping;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.ylz.PayConfigura;
import com.yihu.wlyy.repository.charge.ChargeDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
@ -441,4 +443,83 @@ public class OnePayService {
        charge.setUpdateTime(new Date());
        chargeDao.save(charge);
    }
    /**
     * 查询绑卡信息(所有卡)
     */
    public void bindCardList(String openid) throws Exception {
        Boolean isSuccess = true;
        String error = "";
        PayConfigura config = configuraDao.findWorkConfigura();
        try {
            String appId = config.getOnepayAppId();
            String appSecret = config.getOnepayAppSecret();
            OnepayDefaultClient onepayClient = new OnepayDefaultClient(config.getOnepayApi(), appId, appSecret, signType, encryptType);
            RequestParams requestParams = new RequestParams();
            requestParams.setAppId(appId);
            requestParams.setTimestamp(DateUtil.getCurrentDateTime());
            requestParams.setSignType(signType);
            requestParams.setEncryptType(encryptType);
            // 请求报文体参数,详见接口文档各接口——请求参数定义
            // 如医保绑卡信息请求参数
            JSONObject params = new JSONObject();
            params.put("openId", openid);
            params.put("accId", accId); //微信公众号开发者ID
            requestParams.setParam(params);
            requestParams.setTransType(config.getBindCardType());
            ResponseParams<JSONObject> res = onepayClient.execute(requestParams);
            // 如医保卡绑卡信息返回参数
            if (OnepayDefaultClient.isSuccessful(res)) {
                JavaType javaType = objectMapper.getTypeFactory().constructParametricType(List.class, BindCard.class);
                //获取本人绑卡情况
                String idNo = res.getParam().getString("idNo");
                Patient user = patientDao.findByIdcard(idNo);
                String userCode = user.getCode();
                List<BindCard> result = objectMapper.readValue(objectMapper.writeValueAsString(res.getParam().get("attachList")), javaType);
                //更新患者信息
                if (result != null && result.size() > 0) {
                    for (BindCard card : result) {
                        if (!"98".equals(card.getAttachRelation())) {
                            String idcard = card.getAttachIdNo();
                            Patient patient = patientDao.findByIdcard(idcard);
                            patient.setSicardStatus(1);
//                            ********************以绑定时为主****************
                            patient.setSicardTime(new Date());
//                            ************************************
                            patient.setPrincipalCode(userCode);
                            patientDao.save(patient);
                        }
                    }
                }
                user.setSicardStatus(1);
//                            ********************以绑定时为主****************
                user.setSicardTime(new Date());
//                            ************************************
                user.setPrincipalCode(userCode);
                patientDao.save(user);
            } else {
                isSuccess = false;
                error = "请求失败,返回结果:" + res.getRespCode() + "," + res.getRespMsg();
            }
        } catch (Exception ex) {
            isSuccess = false;
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            ex.printStackTrace(pw);
            error = sw.toString();
        }
        if (!isSuccess) {
            throw new Exception(error);
        }
        LOGGER.info(error);
    }
}

+ 5 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/DoctorQuickReplyDao.java

@ -2,6 +2,7 @@ package com.yihu.wlyy.repository.doctor;
import com.yihu.wlyy.entity.doctor.reply.DoctorQuickReply;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
@ -11,7 +12,7 @@ import java.util.List;
/**
 * Created by lyr-pc on 2016/12/28.
 */
public interface DoctorQuickReplyDao extends PagingAndSortingRepository<DoctorQuickReply, Long> {
public interface DoctorQuickReplyDao extends PagingAndSortingRepository<DoctorQuickReply, Long> ,JpaSpecificationExecutor<DoctorQuickReply> {
    @Query("select max(q.sort) from DoctorQuickReply q where q.doctor = ?1 and q.status = 1")
    Integer findMaxSort(String doctor);
@ -30,4 +31,7 @@ public interface DoctorQuickReplyDao extends PagingAndSortingRepository<DoctorQu
    @Query("select q from DoctorQuickReply q where q.doctor = ?1 and q.status = 1")
    List<DoctorQuickReply> findDoctorReplies(String doctor, Sort sort);
    
    @Query("select q from DoctorQuickReply q where q.doctor = ?1 and q.status = 1")
    List<DoctorQuickReply> findDoctorRepliesByType(String doctor, Integer type ,Sort sort);
}

+ 4 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowUpDao.java

@ -23,6 +23,10 @@ public interface FollowUpDao extends PagingAndSortingRepository<Followup, Long>,
    @Query("select a from Followup a where a.doctorCode = ?1 and a.followupDate between ?2 and ?3 and a.status <> '0'")
    List<Followup> findByDoctor(String doctor, Date begin, Date end) throws Exception;
    //查询未完成有效随访记录
    @Query("select a from Followup a where a.doctorCode = ?1 and a.followupDate between ?2 and ?3 and a.status NOT IN ('0', '1') ")
    List<Followup> getByDoctor(String doctor, Date begin, Date end) throws Exception;
    @Query("select a from Followup a where a.creater = ?1 and a.followupDate between ?2 and ?3 and a.status <> '0'")
    List<Followup> findByCreater(String creater, Date begin, Date end, Pageable pageRequest) throws Exception;

+ 80 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/consult/ConsultTeamService.java

@ -32,6 +32,8 @@ import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.prescription.*;
import com.yihu.wlyy.service.app.health.HealthEduArticleService;
import com.yihu.wlyy.service.app.health.PatientHealthGuidanceService;
import com.yihu.wlyy.service.app.health.PatientHealthIndexService;
import com.yihu.wlyy.service.app.prescription.PrescriptionFollowupContentService;
import com.yihu.wlyy.service.app.prescription.PrescriptionInfoService;
import com.yihu.wlyy.service.app.prescription.PrescriptionLogService;
import com.yihu.wlyy.service.app.talk.TalkGroupService;
@ -142,10 +144,17 @@ public class ConsultTeamService extends ConsultService {
    private PatientService patientService;
    @Autowired
    private FollowUpDao followupDao;
    @Autowired
    private PrescriptionFollowupContentDao prescriptionFollowupContentDao;
    @Autowired
    private PatientHealthIndexService healthIndexService;
    //健康问题 高血压
    private static final String gxy = "HP0093";
    //健康问题 糖尿病
    private static final String tnb ="HP0047";
    
    @Autowired
    private PrescriptionFollowupContentService prescriptionFollowupContentService;
    Map<Integer, String> relations = new HashMap<>();
@ -984,7 +993,7 @@ public class ConsultTeamService extends ConsultService {
            //1、获取基位处方详情(保存续方表、药品续方信息表、续方疾病类型表)
            Prescription prescription = new Prescription();
            savePrescription(prescription,jwCode,doctor,p,ct,reason);
            prescription = savePrescription(prescription,jwCode,doctor,p,ct,reason);
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("title",p.getName()+"申请续方");
@ -999,6 +1008,42 @@ public class ConsultTeamService extends ConsultService {
            }
            //3、获取上次续方时间:与平安的“智慧医保的审方系统”对接,判断居民上次续方时间,点击跳转上次续方记录。(此功能需与第三方系统对接,如果本次版本无法实现,则消息中不显示此条信息)
            jsonObject.put("lastTime","");
    
            //--增加问卷填写情况---huangwenjie--2017.11.01
            List<PrescriptionFollowupContent> prescriptionFollowupContents =prescriptionFollowupContentDao.findByPrescriptionCode(prescription.getCode());
            boolean zzFlag = false;//是否填写症状问卷
            boolean tzssFlag = false;//是否填写体征和生活问卷
            for (PrescriptionFollowupContent prescriptionFollowupContent: prescriptionFollowupContents) {
                if(!zzFlag && "1".equals(prescriptionFollowupContent.getFollowupProject())){
                    zzFlag = true;
                }
    
                if(!tzssFlag &&
                        ("2".equals(prescriptionFollowupContent.getFollowupProject())
                                || "4".equals(prescriptionFollowupContent.getFollowupProject()))
                        ){
                    zzFlag = true;
                }
                
                if(zzFlag && tzssFlag){
                    break;
                }
            }
            if(zzFlag){
                jsonObject.put("zzMsg","居民已填写问卷");
            }else{
                jsonObject.put("zzMsg","居民未填写问卷");
            }
            if(tzssFlag){
                jsonObject.put("tzssMsg","居民已填写问卷");
            }else{
                jsonObject.put("tzssMsg","居民未填写问卷");
            }
            jsonObject.put("zzFlag",zzFlag);
            jsonObject.put("tzssFlag",tzssFlag);
            
            
            
            String content = jsonObject.toString();
            //4、创建咨询
@ -1153,7 +1198,7 @@ public class ConsultTeamService extends ConsultService {
     * @param reason
     * @return
     */
    public void savePrescription(Prescription prescription,String jwCode,Doctor doctor,Patient p,ConsultTeam ct,String reason) throws Exception{
    public Prescription savePrescription(Prescription prescription,String jwCode,Doctor doctor,Patient p,ConsultTeam ct,String reason) throws Exception{
        //获取智业处方详细
        String response = jwPrescriptionService.getRecipe(jwCode,p.getSsc());
        com.alibaba.fastjson.JSONObject jsonObject = presModeAdapter.modelToSinglePrescription(response);
@ -1290,6 +1335,7 @@ public class ConsultTeamService extends ConsultService {
        //添加保存日志
        prescriptionLogService.addLog(prescription, PrescriptionLog.PrescriptionLogType.create.getValue(),1,1);
        return prescription;
    }
    public String getZyCommonDictName(String code){
@ -2571,4 +2617,36 @@ public class ConsultTeamService extends ConsultService {
            }
        }
    }
    
    /**
     * 医生发送血糖血压快捷回复咨询
     * @param prescriptionCode
     * @param type
     */
    public void addPrescriptionBloodStatusConsult(String prescriptionCode, String type,String followupid) throws Exception {
        if("1".equals(type)){//血压
            prescriptionFollowupContentService.importPatientBloodPressureToFollowup(prescriptionCode,followupid,true);
        }else if("2".equals(type)){//血糖
            prescriptionFollowupContentService.importPatientBloodSugarToFollowup(prescriptionCode,followupid,true);
        }
    }
    
    /**
     * 医生发送症状、体征及生活方式回复咨询
     * @param prescriptionCode
     * @param type
     */
    public void addPrescriptionFollowupContentConsult(String prescriptionCode, String type, String followupid) throws Exception {
        Prescription prescription = prescriptionDao.findByCode(prescriptionCode);
        org.json.JSONObject contentDoctor = new org.json.JSONObject();
        //医生发送的消息
        if("1".equals(type)){
            contentDoctor.put("text", "请填写您近期身份异常症状问卷");
        }else{
            contentDoctor.put("text", "请填写您近期体征及生活方式调查问卷");
        }
        contentDoctor.put("type",type);
        //医生发送Im消息
        ImUtill.sendTopicIM(prescription.getDoctor(), prescription.getDoctorName(), prescription.getConsult(), "17", contentDoctor.toString(), null);
    }
}

+ 174 - 119
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/followup/FollowUpService.java

@ -9,6 +9,7 @@ import com.yihu.wlyy.entity.dict.SystemDict;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.followup.Followup;
import com.yihu.wlyy.entity.followup.FollowupContent;
import com.yihu.wlyy.entity.followup.FollowupDrugs;
import com.yihu.wlyy.entity.followup.FollowupMapping;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.entity.patient.Patient;
@ -17,6 +18,7 @@ import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.followup.FollowUpDao;
import com.yihu.wlyy.repository.followup.FollowUpMappingDao;
import com.yihu.wlyy.repository.followup.FollowupContentDao;
import com.yihu.wlyy.repository.followup.FollowupDrugsDao;
import com.yihu.wlyy.repository.message.MessageDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
@ -103,6 +105,8 @@ public class FollowUpService extends BaseService {
    private PushMsgTask pushMsgTask;
    @Autowired
    private FollowUpMappingDao followUpMappingDao;
    @Autowired
    private FollowupDrugsDao followupDrugsDao;
    @Value("${doctorAssistant.api}")
    private String doctorAssistant;
    @Value("${doctorAssistant.target_url}")
@ -154,22 +158,22 @@ public class FollowUpService extends BaseService {
        re.put("followupTypeName", followupTypeName);
        //随访类别转译
        
        String followupClass = followup.getFollowupClass();
        re.put("followupClass", followupClass);
    
        String followupClassName = systemDictService.getDictValue("FOLLOWUP_CLASS_DICT", followup.getFollowupClass());
        if(StringUtils.isNoneBlank(followupClass) && followupClass.contains(",")){
        if (StringUtils.isNoneBlank(followupClass) && followupClass.contains(",")) {
            String[] followupClassArray = followupClass.split(",");
            followupClassName = "";
            for (int i = 0; i < followupClassArray.length; i++) {
                followupClassName += systemDictService.getDictValue("FOLLOWUP_CLASS_DICT", followupClassArray[i]);
                if(i != followupClassArray.length -1){
                    followupClassName +=",";
                if (i != followupClassArray.length - 1) {
                    followupClassName += ",";
                }
            }
        }
        
        re.put("followupClassName", followupClassName);
        //随访管理状态转译
@ -202,23 +206,23 @@ public class FollowUpService extends BaseService {
            for (Followup followup : list) {
                String date = DateUtil.dateToStrShort(followup.getFollowupDate());
                Map<String, String> map = getFollowupDetail(followup);
                if(temp.containsKey(date)){
                if (temp.containsKey(date)) {
                    Map<String, Object> vo = temp.get(date);
                    vo.put("num",Integer.parseInt(vo.get("num").toString())+1);
                    ((List<Map<String, String>>)vo.get("list")).add(map);
                    temp.put(date,vo);
                }else{
                    vo.put("num", Integer.parseInt(vo.get("num").toString()) + 1);
                    ((List<Map<String, String>>) vo.get("list")).add(map);
                    temp.put(date, vo);
                } else {
                    Map<String, Object> vo = new HashMap<>();
                    List<Map<String, String>> list1 = new ArrayList<>();
                    vo.put("date",date);
                    vo.put("num",1);
                    vo.put("date", date);
                    vo.put("num", 1);
                    list1.add(map);
                    vo.put("list",list1);
                    temp.put(date,vo);
                    vo.put("list", list1);
                    temp.put(date, vo);
                }
            }
            for (Map<String, Object> map:temp.values()){
            for (Map<String, Object> map : temp.values()) {
                re.add(map);
            }
        }
@ -233,25 +237,26 @@ public class FollowUpService extends BaseService {
     * @param teamCode
     * @param page
     * @param pageSize
     * @param type 类型:0全部,1计划,2记录
     * @param type     类型:0全部,1计划,2记录
     * @return
     */
    public JSONArray getListByPatientAndTeam(String patient, Long teamCode, int page, int pageSize, String type) {
        Sort sort = new Sort(Sort.Direction.DESC,"createTime");
        PageRequest pageRequest = new PageRequest(page, pageSize,sort);
        Sort sort = new Sort(Sort.Direction.DESC, "createTime");
        PageRequest pageRequest = new PageRequest(page, pageSize, sort);
        Page<Object> result = null;
        
        if(StringUtils.isBlank(type)){
        if (StringUtils.isBlank(type)) {
            result = followupDao.findByPatientAndTeam(patient, teamCode, pageRequest);
        }else if("1".equals(type)){
        } else if ("1".equals(type)) {
            //已经开始的就是记录
            result = followupDao.findPlanByPatientAndTeam(patient, teamCode, pageRequest);
        }else if("2".equals(type)){
        } else if ("2".equals(type)) {
            //未开始的就是计划
            result = followupDao.findRecordByPatientAndTeam(patient, teamCode, pageRequest);
        }else{}
                
        
        } else {
        }
        JSONArray array = new JSONArray();
        if (result != null && result.getContent().size() > 0) {
@ -281,10 +286,10 @@ public class FollowUpService extends BaseService {
                Object[] objArr = (Object[]) obj;
//              返回值增加居民信息
                Patient patientDetail = patientDao.findByCode(patient);
                followup.put("patientName", patientDetail.getName()!=null?patientDetail.getName():"");
                followup.put("photo", patientDetail.getPhoto()!=null?patientDetail.getPhoto():"");
                followup.put("sex", patientDetail.getSex()!=null?patientDetail.getSex():"");
                followup.put("birthday", patientDetail.getBirthday()!=null?patientDetail.getBirthday():"");
                followup.put("patientName", patientDetail.getName() != null ? patientDetail.getName() : "");
                followup.put("photo", patientDetail.getPhoto() != null ? patientDetail.getPhoto() : "");
                followup.put("sex", patientDetail.getSex() != null ? patientDetail.getSex() : "");
                followup.put("birthday", patientDetail.getBirthday() != null ? patientDetail.getBirthday() : "");
                followup.put("id", objArr[15]);
                followup.put("followupNo", objArr[16]);
@ -294,34 +299,35 @@ public class FollowUpService extends BaseService {
                followup.put("followupType", objArr[3] == null ? "" : objArr[3]);
                followup.put("followupTypeName", objArr[3] == null ? "" : (dictMap.get(objArr[3].toString()) != null ? dictMap.get(objArr[3].toString()) : ""));
                followup.put("followupClass", objArr[4] == null ? "" : objArr[4]);
    
//                followup.put("followupClassName", objArr[4] == null ? "" : (objArr[4].toString().equals("1") ? "高血压" : "糖尿病"));
               
                if( objArr[4] == null){
                if (objArr[4] == null) {
                    followup.put("followupClassName", "");
                }else{
                    if(objArr[4].toString().equals("1")){
                } else {
                    if (objArr[4].toString().equals("1")) {
                        followup.put("followupClassName", "高血压");
                    }else if(objArr[4].toString().equals("2")){
                    } else if (objArr[4].toString().equals("2")) {
                        followup.put("followupClassName", "糖尿病");
                    }else if(objArr[4].toString().equals("3")){
                    } else if (objArr[4].toString().equals("3")) {
                        followup.put("followupClassName", "高血压,糖尿病");
                    }else{}
                    } else {
                    }
                }
                
                
                followup.put("status", objArr[5] == null ? "" : objArr[5]);
                followup.put("statusName", objArr[5] == null ? "" : (statusMap.get(objArr[5].toString()) != null ? statusMap.get(objArr[5].toString()) : ""));
                followup.put("createTime", objArr[6] != null ? DateUtil.dateToStrLong((Date)objArr[6]) : "");
                followup.put("updateTime", objArr[7] != null ? DateUtil.dateToStrLong((Date)objArr[7]) : "");
                followup.put("createTime", objArr[6] != null ? DateUtil.dateToStrLong((Date) objArr[6]) : "");
                followup.put("updateTime", objArr[7] != null ? DateUtil.dateToStrLong((Date) objArr[7]) : "");
                followup.put("followupManagerStatus", objArr[8] == null ? "" : objArr[8]);
                followup.put("followupManagerStatusName", objArr[8] == null ? "" : (mngStatusMap.get(objArr[8].toString()) != null ? mngStatusMap.get(objArr[8].toString()) : ""));
                followup.put("creatorCode", objArr[9]);
                followup.put("creatorName", objArr[10]);
                followup.put("creatorPhoto", objArr[11]);
                followup.put("followupDate", objArr[12] != null ? DateUtil.dateToStrLong((Date)objArr[12]) : "");
                followup.put("followupPlanDate", objArr[13] != null ? DateUtil.dateToStrLong((Date)objArr[13]) : "");
                followup.put("followupNextDate", objArr[14] != null ? DateUtil.dateToStrLong((Date)objArr[14]) : "");
                followup.put("followupDate", objArr[12] != null ? DateUtil.dateToStrLong((Date) objArr[12]) : "");
                followup.put("followupPlanDate", objArr[13] != null ? DateUtil.dateToStrLong((Date) objArr[13]) : "");
                followup.put("followupNextDate", objArr[14] != null ? DateUtil.dateToStrLong((Date) objArr[14]) : "");
                array.put(followup);
            }
        }
@ -369,7 +375,7 @@ public class FollowUpService extends BaseService {
            SignFamily signFamily = signFamilyDao.findByjiatingPatient(patientCode);
            if (signFamily == null) {
                signFamily = signFamilyDao.findBySanshiPatient(patientCode);
                if(signFamily==null){
                if (signFamily == null) {
                    throw new Exception("can not find patient's family sign info");
                }
            }
@ -434,12 +440,12 @@ public class FollowUpService extends BaseService {
    /**
     * 开始随访记录
     */
    public void startFollowup(String id, String date, String followupType, String followupClass, String followupManagerStatus,String plandate,String prescriptioncode) throws Exception {
    public void startFollowup(String id, String date, String followupType, String followupClass, String followupManagerStatus, String plandate, String prescriptioncode) throws Exception {
        Followup followup = followupDao.findOne(Long.valueOf(id));
        if (followup != null) {
            followup.setFollowupDate(DateUtil.strToDate(date));
            //计划下次随访时间--huangwenjie.2017.10.19
            if(StringUtils.isNoneBlank(plandate)){
            if (StringUtils.isNoneBlank(plandate)) {
                followup.setFollowupNextDate(DateUtil.strToDate(plandate));
                Followup nextFollowup = new Followup();
                nextFollowup.setDataFrom(followup.getDataFrom());
@ -466,7 +472,7 @@ public class FollowUpService extends BaseService {
                nextFollowup.setIdcard(followup.getIdcard());
                nextFollowup.setSignType(followup.getSignType());
                followupDao.save(nextFollowup);
                
            }
            followup.setFollowupType(followupType);
            followup.setFollowupClass(followupClass);
@ -483,7 +489,7 @@ public class FollowUpService extends BaseService {
    /**
     * 新增临时随访记录(返回ID)
     */
    public String addFollowup(String doctorCode, String patientCode, String date, String followupType, String followupClass, String followupManagerStatus,String plandate,String prescriptioncode) throws Exception {
    public String addFollowup(String doctorCode, String patientCode, String date, String followupType, String followupClass, String followupManagerStatus, String plandate, String prescriptioncode) throws Exception {
        String re = "";
        //获取医生信息
@ -500,8 +506,8 @@ public class FollowUpService extends BaseService {
        SignFamily signFamily = signFamilyDao.findByjiatingPatient(patientCode);
        if (signFamily == null) {
            signFamily = signFamilyDao.findBySanshiPatient(patientCode);
            if(signFamily==null)
               throw new Exception("can not find patient's family sign info");
            if (signFamily == null)
                throw new Exception("can not find patient's family sign info");
        }
        Followup followup = new Followup();
@ -526,14 +532,14 @@ public class FollowUpService extends BaseService {
        followup.setSignType(2);
        //保存质询code
        followup.setSignCode(patientService.getSignCodeByPatient(patientCode));
        
        //如果有填入续方CODE,则添加续方关联--huangwenjie.2017.11.02
        if(StringUtils.isNotBlank(prescriptioncode)){
        if (StringUtils.isNotBlank(prescriptioncode)) {
            followup.setPrescriptionCode(prescriptioncode);
        }
        //计划下次随访时间--ysj.2017.10.26
        if(StringUtils.isNoneBlank(plandate)){
        if (StringUtils.isNoneBlank(plandate)) {
            followup.setFollowupNextDate(DateUtil.strToDate(plandate));
            Followup nextFollowup = new Followup();
            nextFollowup.setDataFrom(followup.getDataFrom());
@ -589,22 +595,22 @@ public class FollowUpService extends BaseService {
        if (followup != null) {
            followup.setStatus("1");  //状态 0取消 1已完成 2未开始 3进行中
            followup = followupDao.save(followup);
    
            //上传随访计划映射表记录
            FollowupMapping followupMapping = followUpMappingDao.findByFollowupId(Integer.parseInt(String.valueOf(followup.getId())));
            
            if(followupMapping == null){
            if (followupMapping == null) {
                followupMapping = new FollowupMapping();
            }
    
            followupMapping.setFollowupId(Integer.parseInt(String.valueOf(followup.getId())));
            followupMapping.setCode(UUID.randomUUID().toString());
            followupMapping.setCreateTime(DateUtil.getNowTimestamp());
            followupMapping.setUpdateTime(DateUtil.getNowTimestamp());
            followupMapping.setNeedUpload(1);
            
            followUpMappingDao.save(followupMapping);
           
//            new Thread(new FollowupUploadTask(String.valueOf(followup.getId()))).start();
        } else {
            throw new Exception("not exit follow:" + id + ".\r\n");
@ -693,13 +699,13 @@ public class FollowUpService extends BaseService {
            followupContentDao.save(newList);
        }
    
        Followup followup = followupDao.findOne(Long.valueOf(id));
    
        //如果该随访是已完成的,则添加随访信息上传映射,上传到基卫
        if("1".equals(followup.getStatus())){
        if ("1".equals(followup.getStatus())) {
            FollowupMapping followupMapping = followUpMappingDao.findByFollowupId(Integer.parseInt(id));
            if(followupMapping == null){
            if (followupMapping == null) {
                followupMapping = new FollowupMapping();
                followupMapping.setCode(UUID.randomUUID().toString());
                followupMapping.setFollowupId(Integer.parseInt(id));
@ -857,7 +863,10 @@ public class FollowUpService extends BaseService {
                    // 推送消息给医生
                    pushMsgTask.put(doctor, "4", title, content, "");
                    //            新增发送医生助手模板消息 v1.4.0 by wujunjie
                    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                    List<Followup> followups = followupDao.getByDoctor(doctor, format.parse(start), format.parse(end));
                    Doctor doctor1 = doctorDao.findByCode(doctor);
                    String doctorOpenID = doctor1.getOpenid();
                    if (StringUtils.isNotEmpty(doctorOpenID)) {
@ -868,8 +877,8 @@ public class FollowUpService extends BaseService {
                        params.add(new BasicNameValuePair("url", targetUrl));
                        params.add(new BasicNameValuePair("first", "您今日有1个随访计划待处理"));
                        params.add(new BasicNameValuePair("remark", ""));
                        SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
                        String newDate = format.format(new Date());
                        SimpleDateFormat formatDate = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
                        String newDate = formatDate.format(new Date());
                        String keywords = "patientName" + newDate + "," + "请进入手机APP查看";
                        params.add(new BasicNameValuePair("keywords", keywords));
@ -885,15 +894,16 @@ public class FollowUpService extends BaseService {
            e.printStackTrace();
        }
    }
    
    /**
     *ES 保存随访记录详情
     *@author huangwenjie
     *@date 2017/11/1 14:57
     * ES 保存随访记录详情
     *
     * @author huangwenjie
     * @date 2017/11/1 14:57
     */
    @Transactional
    public void esSaveFollowupProjectData(String id, String followupProject, String followupProjectData) throws Exception {
        
        JestClient jestClient = elasticFactory.getJestClient();
        //先根据条件查找出来
        SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
@ -902,33 +912,33 @@ public class FollowUpService extends BaseService {
                        .must(QueryBuilders.matchQuery("followup_id", id))
                        .must(QueryBuilders.matchQuery("followup_project", followupProject))
        );
    
        Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
                .build();
        SearchResult result = jestClient.execute(search);
        List<FollowupContentESDO> dataList = result.getSourceAsObjectList(FollowupContentESDO.class);
        
        //删除原有记录
        this.esDeleteFollowUpContent(dataList);
        
        //保存新的随访详情信息
        List<FollowupContentESDO> newdatalist = new ArrayList<>();
        FollowupContentESDO followupContentESDO = new FollowupContentESDO();
    
        followupContentESDO = JSON.parseObject(followupProjectData,FollowupContentESDO.class);
    
        followupContentESDO = JSON.parseObject(followupProjectData, FollowupContentESDO.class);
        followupContentESDO.setFollowup_id(id);
        followupContentESDO.setFollowup_project(followupProject);
        followupContentESDO.setCreate_time(new Date());
        newdatalist.add(followupContentESDO);
        elastricSearchSave.save(newdatalist,esIndex,esType);
        
        
        elastricSearchSave.save(newdatalist, esIndex, esType);
        //如果该随访是已完成的,则添加随访信息上传映射,上传到基卫
        Followup followup = followupDao.findOne(Long.valueOf(id));
        if("1".equals(followup.getStatus())){
        if ("1".equals(followup.getStatus())) {
            FollowupMapping followupMapping = followUpMappingDao.findByFollowupId(Integer.parseInt(id));
            if(followupMapping == null){
            if (followupMapping == null) {
                followupMapping = new FollowupMapping();
                followupMapping.setCode(UUID.randomUUID().toString());
                followupMapping.setFollowupId(Integer.parseInt(id));
@ -939,13 +949,13 @@ public class FollowUpService extends BaseService {
            followUpMappingDao.save(followupMapping);
        }
    }
    
    /**
     * ES获取面访项目数据
     */
    public FollowupContentESDO esGetFollowupProjectData(String id, String followupProject) throws Exception {
        //根据随访ID、分类ID获取随访记录详情
    
        JestClient jestClient = elasticFactory.getJestClient();
        //先根据条件查找出来
        SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
@ -954,20 +964,21 @@ public class FollowUpService extends BaseService {
                        .must(QueryBuilders.matchQuery("followup_id", id))
                        .must(QueryBuilders.matchQuery("followup_project", followupProject))
        );
    
        Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
                .build();
        SearchResult result = jestClient.execute(search);
        FollowupContentESDO followupContentESDO  = result.getSourceAsObject(FollowupContentESDO.class);
        FollowupContentESDO followupContentESDO = result.getSourceAsObject(FollowupContentESDO.class);
        return followupContentESDO;
    }
    
    /**
     *ES 删除随访详情信息
     *@author huangwenjie
     *@date 2017/11/1 15:17
     * ES 删除随访详情信息
     *
     * @author huangwenjie
     * @date 2017/11/1 15:17
     */
    public void esDeleteFollowUpContent(List<FollowupContentESDO> datalist) throws Exception{
    public void esDeleteFollowUpContent(List<FollowupContentESDO> datalist) throws Exception {
        try {
            JestClient jestClient = elasticFactory.getJestClient();
            //根据id批量删除
@ -977,25 +988,26 @@ public class FollowUpService extends BaseService {
                bulk.addAction(index);
            }
            BulkResult br = jestClient.execute(bulk.build());
    
            logger.info("delete data count:" + datalist.size());
            logger.info("delete flag:" + br.isSucceeded());
        }catch (Exception e){
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    
    /**
     * ES获取面访项目数据列表
     *@author huangwenjie
     *@date 2017/11/1 19:41
     *
     * @author huangwenjie
     * @date 2017/11/1 19:41
     */
    public List<String>  esfindProjectByFollowupId(String id) throws Exception {
    public List<String> esfindProjectByFollowupId(String id) throws Exception {
        //根据随访ID、分类ID获取随访记录详情
        
        List<String> resultList = new ArrayList<>();
        
        JestClient jestClient = elasticFactory.getJestClient();
        //先根据条件查找出来
        SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
@ -1003,33 +1015,34 @@ public class FollowUpService extends BaseService {
                new BoolQueryBuilder()
                        .must(QueryBuilders.matchQuery("followup_id", id))
        );
        
        Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
                .build();
        SearchResult result = jestClient.execute(search);
    
        List<FollowupContentESDO> followupContentESDOList = new ArrayList<>();
        
        followupContentESDOList  = result.getSourceAsObjectList(FollowupContentESDO.class);
        if(!followupContentESDOList.isEmpty()){
            for (FollowupContentESDO followupContentESDO: followupContentESDOList) {
        followupContentESDOList = result.getSourceAsObjectList(FollowupContentESDO.class);
        if (!followupContentESDOList.isEmpty()) {
            for (FollowupContentESDO followupContentESDO : followupContentESDOList) {
                resultList.add(followupContentESDO.getFollowup_project());
            }
        }
        
        return resultList;
    }
    
    /**
     * ES获取面访项目数据详情
     *@author huangwenjie
     *@date 2017/11/1 19:41
     *
     * @author huangwenjie
     * @date 2017/11/1 19:41
     */
    public List<FollowupContentESDO>  esfindFollowUpContestsByFollowupId(String id) throws Exception {
    public List<FollowupContentESDO> esfindFollowUpContestsByFollowupId(String id) throws Exception {
        //根据随访ID、分类ID获取随访记录详情
        
        List<String> resultList = new ArrayList<>();
        
        JestClient jestClient = elasticFactory.getJestClient();
        //先根据条件查找出来
        SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
@ -1037,22 +1050,64 @@ public class FollowUpService extends BaseService {
                new BoolQueryBuilder()
                        .must(QueryBuilders.matchQuery("followup_id", id))
        );
        
        Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
                .build();
        SearchResult result = jestClient.execute(search);
        
        List<FollowupContentESDO> followupContentESDOList = new ArrayList<>();
        
        return followupContentESDOList;
    }
    
    /**
     * 根据续方CODE获取随访记录信息
     * @param prescriptionCode
     * @return
     */
    public String getFollowupByPrescriptionCode(String prescriptionCode) {
        Followup followup = followupDao.getFollowupByPrescriptionCode(prescriptionCode);
    
        String jsonString = JSON.toJSONString(followup);
        
        return jsonString;
    }
    /**
     * 获取随访详情记录分类记录数
     * @param followupid
     * @param type
     * @return
     */
    public int getfollowupcontent(String followupid, String type) throws Exception {
        int count = 0;
        String[] typelist = null;
        if(type.contains(",")){
            typelist = type.split(",");
        }else{
            typelist = new String[]{type};
        }
        for (String typekey: typelist) {
            if(!"drug".equals(type)){
                FollowupContentESDO followupContentESDO = this.esGetFollowupProjectData(followupid,typekey);
                if(followupContentESDO != null){
                    count ++;
                }
            }else{
                //获取用药记录
                List<FollowupDrugs> drugsList = followupDrugsDao.findByFollowupId(Long.valueOf(followupid));
                if(!drugsList.isEmpty()){
                    count = count +drugsList.size();
                }
            }
        }
        return count;
    }
}

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

@ -3,6 +3,7 @@ package com.yihu.wlyy.service.app.health;
import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.device.entity.DevicePatientHealthIndex;
import com.yihu.wlyy.entity.consult.ConsultTeam;
import com.yihu.wlyy.entity.device.PatientDevice;
import com.yihu.wlyy.entity.doctor.health.DoctorHealthStandard;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
@ -12,6 +13,7 @@ import com.yihu.wlyy.entity.patient.PatientAimSports;
import com.yihu.wlyy.entity.patient.PatientHealthStandard;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.health.repository.DevicePatientHealthIndexDao;
import com.yihu.wlyy.repository.consult.ConsultTeamDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.doctor.health.DoctorHealthStandardDao;
import com.yihu.wlyy.repository.message.MessageDao;
@ -86,6 +88,10 @@ public class PatientHealthIndexService extends BaseService {
    private String targetUrl;
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Autowired
    private ImUtill ImUtill;
    @Autowired
    private ConsultTeamDao consultTeamDao;
    /**
     * 获取居民标准预警值
@ -880,8 +886,8 @@ public class PatientHealthIndexService extends BaseService {
                    throw new Exception("暂不支持该指标!");
                }
            }
            patientHealthIndexDao.save(obj);
    
            obj = patientHealthIndexDao.save(obj);
            //保存完后上传基卫
            new Thread(new HealthIndexUploadTask(String.valueOf(obj.getId()))).start();
@ -891,6 +897,45 @@ public class PatientHealthIndexService extends BaseService {
        return obj;
    }
    
    /**
     * 判断是否有未结束的续方咨询,发送消息给对应的医生
     * @param result
     * @param patient
     */
    private void sendPrescriptionHealthIndexMsgresult(DevicePatientHealthIndex result, Patient patient) {
        
        List<ConsultTeam> consultTeams = consultTeamDao.findUnfinishedConsult(patient.getCode());
        
        if(1 == result.getType()){
            for (ConsultTeam consultTeam:consultTeams) {
                if(1 == consultTeam.getHealthindexType() || 3 == consultTeam.getHealthindexType()){
                    org.json.JSONObject contentPatient = new org.json.JSONObject();
                    //患者发送的消息
                    contentPatient.put("title", "【本消息为系统提醒】:");
                    contentPatient.put("tzMsg", "体征记录:血糖 "+result.getValue1());
                    contentPatient.put("tzTime", "检测时间:"+DateUtil.dateToStrLong(result.getRecordDate()));
                    contentPatient.put("tzAlert","温馨提示:本条体征为居民上传的健康体征数据,您可以自动填入本次随访记录");
                    //患者发送Im消息
                    ImUtill.sendTopicIM(patient.getCode(), patient.getName(), consultTeam.getConsult(), "16", contentPatient.toString(), null);
                }
            }
        }else if(2 == result.getType()){
            for (ConsultTeam consultTeam:consultTeams) {
                if(2 == consultTeam.getHealthindexType() || 3 == consultTeam.getHealthindexType()){
                    org.json.JSONObject contentPatient = new org.json.JSONObject();
                    //患者发送的消息
                    contentPatient.put("title", "【本消息为系统提醒】:");
                    contentPatient.put("tzMsg", "体征记录:血压 "+result.getValue1()+"/"+result.getValue2()+" mmHg");
                    contentPatient.put("tzTime", "检测时间:"+DateUtil.dateToStrLong(result.getRecordDate()));
                    contentPatient.put("tzAlert","温馨提示:本条体征为居民上传的健康体征数据,您可以自动填入本次随访记录");
                    //患者发送Im消息
                    ImUtill.sendTopicIM(patient.getCode(), patient.getName(), consultTeam.getConsult(), "16", contentPatient.toString(), null);
                }
            }
        }
        
    }
    /**
     * 判断居民的体征预警状态

+ 348 - 4
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionFollowupContentService.java

@ -3,11 +3,24 @@ package com.yihu.wlyy.service.app.prescription;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.entity.followup.Followup;
import com.yihu.wlyy.entity.followup.FollowupDrugs;
import com.yihu.wlyy.entity.patient.prescription.Prescription;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionFollowupContent;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionInfo;
import com.yihu.wlyy.repository.followup.FollowUpDao;
import com.yihu.wlyy.repository.followup.FollowupDrugsDao;
import com.yihu.wlyy.repository.prescription.PrescriptionDao;
import com.yihu.wlyy.repository.prescription.PrescriptionFollowupContentDao;
import com.yihu.wlyy.repository.prescription.PrescriptionInfoDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.app.followup.FollowUpService;
import com.yihu.wlyy.service.app.health.PatientHealthIndexService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.ImUtill;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -26,6 +39,22 @@ public class PrescriptionFollowupContentService extends BaseService {
	
	@Autowired
	private PrescriptionFollowupContentDao prescriptionFollowupContentDao;
	@Autowired
	private PrescriptionInfoDao prescriptionInfoDao;
	@Autowired
	private FollowupDrugsDao followupDrugsDao;
	@Autowired
	private PrescriptionDao prescriptionDao;
	@Autowired
	private PatientHealthIndexService healthIndexService;
	@Autowired
	private FollowUpService followUpService;
	@Autowired
	private FollowUpDao followUpDao;
	@Autowired
	private ImUtill ImUtill;
	@Autowired
	JdbcTemplate jdbcTemplate;
	
	/**
	 * 根据续方CODE,文件类型获取数据
@ -55,9 +84,10 @@ public class PrescriptionFollowupContentService extends BaseService {
	 * 保存随访调查分类数据
	 * @param prescriptioncode
	 * @param followupProjectData
	 * @param sendIM
	 * @throws Exception
	 */
	public void saveInfo(String prescriptioncode, String followupProjectData,String patientCode) throws Exception{
	public void saveInfo(String prescriptioncode, String followupProjectData,String patientCode,boolean sendIM) throws Exception{
		JSONArray objects = JSON.parseArray(followupProjectData);
		
		if(objects!= null & objects.size() >0){
@ -67,7 +97,7 @@ public class PrescriptionFollowupContentService extends BaseService {
				String followupProject = jsonObject.getString("followupProject");
				String projectValueStr = jsonObject.getString("projectData");
				if(StringUtils.isNotBlank(projectValueStr)){
					HashMap<String,String> projectValueMap = (HashMap)JSON.parse(projectValueStr);
					Map<String,String> projectValueMap = (Map)JSON.parse(projectValueStr);
					if(!projectValueMap.isEmpty()){
						projectValueMap.forEach( (key,value)->{
							PrescriptionFollowupContent prescriptionFollowupContent = new PrescriptionFollowupContent();
@ -84,6 +114,19 @@ public class PrescriptionFollowupContentService extends BaseService {
				if(!savedatas.isEmpty()){
					prescriptionFollowupContentDao.deleteByPrescriptioncodeAndFollowupProject(prescriptioncode,followupProject);
					prescriptionFollowupContentDao.save(savedatas);
					
					if(sendIM){
						org.json.JSONObject content = new org.json.JSONObject();
						content.put("title", "【本消息为系统提醒】:");
						if("1".equals(followupProject)){
							content.put("text", "居民已填写《身份异常症状问卷》");
						}else{
							content.put("text", "居民已填写《体征及生活方式调查问卷》");
						}
						content.put("sysMsg","填写完成并提交后,医生将可以查看您的问卷内容");
						Prescription p = prescriptionDao.findByCode(prescriptioncode);
						ImUtill.sendTopicIM(p.getDoctor(), p.getDoctorName(), p.getConsult(), "17", content.toString(), null);
					}
				}
			}
			
@ -136,7 +179,7 @@ public class PrescriptionFollowupContentService extends BaseService {
			JSONObject jsonObject1 = new JSONObject();
			jsonObject1.put("type","1");
			jsonObject1.put("name","身份异常症状问卷");
			jsonObject1.put("statue","已填写");
			jsonObject1.put("statue","1");//1已填写,2未填写
			jsonObject1.put("createtime",prescriptionFollowupContent1.getCreateTime());
			result.add(jsonObject1);
		}
@ -145,11 +188,312 @@ public class PrescriptionFollowupContentService extends BaseService {
			JSONObject jsonObject2 = new JSONObject();
			jsonObject2.put("type","2");
			jsonObject2.put("name","体征及生活方式调查问卷");
			jsonObject2.put("statue","已填写");
			jsonObject2.put("statue","1");//1已填写,2未填写
			jsonObject2.put("createtime",prescriptionFollowupContent1.getCreateTime());
			result.add(jsonObject2);
		}
		
		return result;
	}
	
	/**
	 * 续方药品导入随访记录
	 * @param prescriptioncode
	 * @param followup_id
	 */
	public void importPrescriptionDrugsToFollowup(String prescriptioncode, String followup_id) throws Exception {
		
		
		
		Long followupId = Long.valueOf(followup_id);
		
		Followup followup =followUpDao.findOne(followupId);
		
		if(followup == null){
			throw new Exception("未找到随访记录!");
		}
		
		//删除原有用药记录
		followupDrugsDao.deleteByFollowupId(Long.valueOf(followupId));
		
		List<PrescriptionInfo> list = prescriptionInfoDao.findByPrescriptionCode(prescriptioncode);
		
		if(list!=null && list.size()>0)
		{
			List<FollowupDrugs> newList = new ArrayList<>();
			for(PrescriptionInfo prescriptionInfo:list)
			{
				FollowupDrugs drug = new FollowupDrugs();
				drug.setFollowupId(followupId);
				
				if(prescriptionInfo.getDrugName().contains("胰岛素") &&prescriptionInfo.getSubjectClass().contains("010")){
					drug.setDrugsGroup("insulin");
				}else{
					drug.setDrugsGroup("normal");
				}
				drug.setDrugsCode(prescriptionInfo.getDrugCode());
				drug.setDrugsName(prescriptionInfo.getDrugName());
				drug.setDose(prescriptionInfo.getPhysicDose());
				drug.setUnit(prescriptionInfo.getDrugNumUnit());
				drug.setFrequency(prescriptionInfo.getDrugRate());
				drug.setCreateTime(new Date());
				newList.add(drug);
			}
			followupDrugsDao.save(newList);
		}
	}
	
	/**
	 * 续方患者的血糖导入随访记录
	 * @param prescriptioncode
	 * @param followup_id
	 */
	public void importPatientBloodSugarToFollowup(String prescriptioncode, String followup_id,boolean sendIM) throws Exception {
		Long followupId = Long.valueOf(followup_id);
		
		Followup followup =followUpDao.findOne(followupId);
		
		if(followup == null){
			throw new Exception("未找到随访记录!");
		}
		
		Prescription prescription = prescriptionDao.findByCode(prescriptioncode);
		
		String patientCode = prescription.getParentCode();
		
		String stardate = DateUtil.getNextMonth(new Date(),-30)+" 00:00:00";
		String enddate = DateUtil.getStringDateShort()+" 23:59:59";
		
		List<Object> list = healthIndexService.findIndexByPatient2(patientCode, 1, stardate, enddate, 0, 2);
		
		
		String followupProjectData = "";
		
		org.json.JSONObject contentDoctor = new org.json.JSONObject();
		org.json.JSONObject contentPatient = new org.json.JSONObject();
		String imBloodSugarValue = "";
		String imBloodSugarDate = "";
		
		if(!list.isEmpty()){
			
			for (Object o: list) {
				
				JSONObject obj = (JSONObject)o;
				
				imBloodSugarDate = obj.getString("recordDate");
				
				int index = Integer.valueOf(obj.getString("value2"));
				String value1 = obj.getString("value1");
				// 餐后
				if (index % 2 == 0) {
					if(StringUtils.isNotBlank(value1)){
						followupProjectData = "{'BS_FPG':'"+obj.getString("value1")+"'}";
						break;
					}
				} else { //餐前
					followupProjectData = "{'NO_BS_FPG':'"+obj.getString("value1")+"'}";
					imBloodSugarValue = obj.getString("value1");
					break;
				}
			}
			
			followUpService.esSaveFollowupProjectData(followup_id, "3", followupProjectData);
			
			//是否需要发送IM消息
			if(sendIM){
				//医生发送的消息
				contentDoctor.put("text", "请提供您最近一次的血糖检测数值及检测时间");
				contentDoctor.put("needupload",false);
				contentDoctor.put("type",2);
				int total = 0;
				String sql = "select sum(category_code) amount deviceType FROM wlyy_patient_device WHERE user="+prescription.getPatient();
				List<Map<String,Object>> result =  jdbcTemplate.queryForList(sql);
				if (result != null && result.size() > 0) {
					total = (result.get(0).get("amount") != null ? Integer.parseInt(result.get(0).get("amount").toString()) : 0);
				}
				if(total != 1 || total != 3){
					contentDoctor.put("deviceMsg","您未绑定血糖智能设备,请手动上传体征数据,绑定设备后系统将会自动将您的体征数据上报给医生");
				}
				
				//医生发送Im消息
				ImUtill.sendTopicIM(prescription.getDoctor(), prescription.getDoctorName(), prescription.getConsult(), "16", contentDoctor.toString(), null);
				
				//患者发送的消息
				contentPatient.put("title", "【本消息为系统提醒】:");
				contentPatient.put("tzMsg", "体征记录:血糖"+imBloodSugarValue);
				contentPatient.put("tzTime", "检测时间:"+imBloodSugarDate);
				contentPatient.put("tzAlert","温馨提示:本条体征为居民上传的健康体征数据,您可以");
				contentPatient.put("type",2);
				
				//患者发送Im消息
				ImUtill.sendTopicIM(prescription.getPatient(), prescription.getPatientName(), prescription.getConsult(), "16", contentPatient.toString(), null);
			}
		}else{
			//是否需要发送IM消息
			if(sendIM){
				//医生发送的消息
				contentDoctor.put("text", "居民近30天未上传血糖体征数据,已通知居民上传数据,请耐心等待");
				contentDoctor.put("needupload",true);
				contentDoctor.put("type",2);
			}else{
				throw new Exception("未找到30天内的血糖记录!");
			}
		}
	}
	
	/**
	 * 续方患者的血压导入随访记录
	 * @param prescriptioncode
	 * @param followup_id
	 * @param sendIM 是否发送IM消息
	 */
	public void importPatientBloodPressureToFollowup(String prescriptioncode, String followup_id,boolean sendIM) throws Exception {
		
		Long followupId = Long.valueOf(followup_id);
		
		Followup followup =followUpDao.findOne(followupId);
		
		if(followup == null){
			throw new Exception("未找到随访记录!");
		}
		
		Prescription prescription = prescriptionDao.findByCode(prescriptioncode);
		
		String patientCode = prescription.getParentCode();
		
		String stardate = DateUtil.getNextMonth(new Date(),-30)+" 00:00:00";
		String enddate = DateUtil.getStringDateShort()+" 23:59:59";
		org.json.JSONArray jsonArray = healthIndexService.findIndexByPatient(patientCode, 2, stardate, enddate, 0, 2);
		
		String followupProjectData = "";
		
		org.json.JSONObject contentDoctor = new org.json.JSONObject();
		org.json.JSONObject contentPatient = new org.json.JSONObject();
		
		if(jsonArray.length() > 0){
			
			org.json.JSONObject jsonObject = jsonArray.getJSONObject(0);
			
			followupProjectData = "{'BP_D':'"+jsonObject.getString("value1")+"'BP_U':'"+jsonObject.getString("value2")+"'}";
			followUpService.esSaveFollowupProjectData(followup_id, "2", followupProjectData);
			
			//是否需要发送IM消息
			if(sendIM){
				//医生发送的消息
				contentDoctor.put("text", "请提供您最近一次的血压检测数值及检测时间");
				contentDoctor.put("needUpload",false);
				contentDoctor.put("type",1);
				
				int total = 0;
				String sql = "select sum(category_code) amount deviceType FROM wlyy_patient_device WHERE user="+prescription.getPatient();
				List<Map<String,Object>> result =  jdbcTemplate.queryForList(sql);
				if (result != null && result.size() > 0) {
					total = (result.get(0).get("amount") != null ? Integer.parseInt(result.get(0).get("amount").toString()) : 0);
				}
				if(total != 2 || total != 3){
					contentDoctor.put("deviceMsg","您未绑定血压智能设备,请手动上传体征数据,绑定设备后系统将会自动将您的体征数据上报给医生");
				}
				
				//医生发送Im消息
				ImUtill.sendTopicIM(prescription.getDoctor(), prescription.getDoctorName(), prescription.getConsult(), "16", contentDoctor.toString(), null);
				
				//患者发送的消息
				contentPatient.put("title", "【本消息为系统提醒】:");
				contentPatient.put("tzMsg", "体征记录:血压"+jsonObject.getString("value1")+"/"+jsonObject.getString("value2")+" mmHg");
				contentPatient.put("tzTime", "检测时间:"+jsonObject.getString("date"));
				contentPatient.put("tzAlert","温馨提示:本条体征为居民上传的健康体征数据,您可以");
				contentPatient.put("type",1);
				
				//患者发送Im消息
				ImUtill.sendTopicIM(prescription.getPatient(), prescription.getPatientName(), prescription.getConsult(), "16", contentPatient.toString(), null);
			}
		}else{
			//是否需要发送IM消息
			if(sendIM){
				//医生发送的消息
				contentDoctor.put("text", "居民近30天未上传血压体征数据,已通知居民上传数据,请耐心等待");
				contentDoctor.put("needupload",true);
				contentDoctor.put("type",1);
			}else{
				throw new Exception("未找到30天内的血压记录!");
			}
		}
	
	}
	
	/**
	 * 续方问卷导入随访记录
	 * @param prescriptioncode
	 * @param followup_id
	 * @param type
	 */
	public void importfollowupcontent(String prescriptioncode, String followup_id, String type) throws Exception {
		
		Long followupId = Long.valueOf(followup_id);
		
		Followup followup =followUpDao.findOne(followupId);
		
		if(followup == null){
			throw new Exception("未找到随访记录!");
		}
		
		Prescription prescription = prescriptionDao.findByCode(prescriptioncode);
		
		String patientCode = prescription.getParentCode();
		
		
		if("1".equals(type)){
		//1身份异常症状问卷
			List<PrescriptionFollowupContent>  list = prescriptionFollowupContentDao.findByPrescriptionCodeAndFollowupProject(prescriptioncode,type);
			
			Map<String, String> datamap = new HashMap<>();
			
			if(!list.isEmpty()){
				for (PrescriptionFollowupContent prescriptionFollowupContent: list) {
					datamap.put(prescriptionFollowupContent.getFollowupKey(),prescriptionFollowupContent.getFollowupValue());
				}
			}
			
			followUpService.esSaveFollowupProjectData(followup_id, type, JSON.toJSONString(datamap));
		}else if("2".equals(type)){
			//2体征
			Map<String, String> datamap2 = new HashMap<>();
			List<PrescriptionFollowupContent>  list2 = prescriptionFollowupContentDao.findByPrescriptionCodeAndFollowupProject(prescriptioncode,"2");
			
			if(!list2.isEmpty()){
				for (PrescriptionFollowupContent prescriptionFollowupContent: list2) {
					datamap2.put(prescriptionFollowupContent.getFollowupKey(),prescriptionFollowupContent.getFollowupValue());
				}
			}
			//近30天血压
			String stardate = DateUtil.getNextMonth(new Date(),-30)+" 00:00:00";
			String enddate = DateUtil.getStringDateShort()+" 23:59:59";
			org.json.JSONArray jsonArray = healthIndexService.findIndexByPatient(patientCode, 2, stardate, enddate, 0, 2);
			if(jsonArray.length() > 0){
				org.json.JSONObject jsonObject = jsonArray.getJSONObject(0);
				datamap2.put("BP_D",jsonObject.getString("value1"));
				datamap2.put("BP_U",jsonObject.getString("value2"));
			}
			followUpService.esSaveFollowupProjectData(followup_id, "2", JSON.toJSONString(datamap2));
			
			
			Map<String, String> datamap3 = new HashMap<>();
			List<PrescriptionFollowupContent>  list3 = prescriptionFollowupContentDao.findByPrescriptionCodeAndFollowupProject(prescriptioncode,"4");
			
			if(!list3.isEmpty()){
				for (PrescriptionFollowupContent prescriptionFollowupContent: list2) {
					datamap3.put(prescriptionFollowupContent.getFollowupKey(),prescriptionFollowupContent.getFollowupValue());
				}
			}
			followUpService.esSaveFollowupProjectData(followup_id, "4", JSON.toJSONString(datamap3));
		
		}else{}
	}
}

+ 21 - 4
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/reply/DoctorQuickReplyService.java

@ -3,6 +3,7 @@ package com.yihu.wlyy.service.app.reply;
import com.yihu.wlyy.entity.doctor.reply.DoctorQuickReply;
import com.yihu.wlyy.repository.doctor.DoctorQuickReplyDao;
import com.yihu.wlyy.service.BaseService;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
@ -10,6 +11,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.print.Doc;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@ -29,7 +31,7 @@ public class DoctorQuickReplyService extends BaseService {
     * @param content 快捷回复内容
     * @return
     */
    public DoctorQuickReply addReply(String doctor, String content) {
    public DoctorQuickReply addReply(String doctor, String content,String type) {
        DoctorQuickReply reply = new DoctorQuickReply();
        Integer sort = quickReplyDao.findMaxSort(doctor);
        sort = sort == null ? 1 : sort + 1;
@ -38,6 +40,7 @@ public class DoctorQuickReplyService extends BaseService {
        reply.setStatus(1);
        reply.setSort(sort);
        reply.setUpdateTime(new Date());
        reply.setType(Integer.parseInt(type));
        return quickReplyDao.save(reply);
    }
@ -49,7 +52,7 @@ public class DoctorQuickReplyService extends BaseService {
     * @param content 快捷回复内容
     * @return
     */
    public DoctorQuickReply modifyReply(long id, String content) throws Exception {
    public DoctorQuickReply modifyReply(long id, String content,String type) throws Exception {
        DoctorQuickReply reply = quickReplyDao.findOne(id);
        if (reply == null) {
@ -57,6 +60,7 @@ public class DoctorQuickReplyService extends BaseService {
        }
        reply.setContent(content);
        reply.setType(Integer.parseInt(type));
        return quickReplyDao.save(reply);
    }
@ -91,9 +95,22 @@ public class DoctorQuickReplyService extends BaseService {
     * @param doctor
     * @return
     */
    public List<DoctorQuickReply> getDoctorReplyList(String doctor) {
    public List<DoctorQuickReply> getDoctorReplyList(String doctor,String type) {
        Sort sort = new Sort(Sort.Direction.DESC, "sort");
        List<DoctorQuickReply> replies = quickReplyDao.findDoctorReplies(doctor, sort);
        List<DoctorQuickReply> replies = quickReplyDao.findDoctorRepliesByType(doctor, Integer.parseInt(type),sort);
        
        if("1".equals(type)){
            //如果是续方咨询,拿到的列表为空,则默认添加系统消息
            List<DoctorQuickReply> defaults = quickReplyDao.findDoctorReplies("default",sort);
            for (DoctorQuickReply doctorQuickReply:defaults) {
                doctorQuickReply.setId(null);
                doctorQuickReply.setDoctor(doctor);
            }
            quickReplyDao.save(defaults);
    
            replies = quickReplyDao.findDoctorRepliesByType(doctor, Integer.parseInt(type),sort);
        }
        
        return replies;
    }

+ 137 - 59
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statisticsES/StatisticsESService.java

@ -10,6 +10,7 @@ import com.yihu.wlyy.entity.statistics.PopulationBase;
import com.yihu.wlyy.repository.address.TownDao;
import com.yihu.wlyy.repository.doctor.DoctorAdminTeamDao;
import com.yihu.wlyy.repository.organization.HospitalDao;
import com.yihu.wlyy.service.app.statistics.StatisticsAllService;
import com.yihu.wlyy.service.system.SystemDictService;
import com.yihu.wlyy.util.Constant;
import com.yihu.wlyy.util.DateUtil;
@ -55,9 +56,9 @@ public class StatisticsESService {
    @Autowired
    TownDao townDao;
    @Autowired
    private StringRedisTemplate redisTemplate;
    @Autowired
    private SystemDictService systemDictService;
    @Autowired
    private StatisticsAllService statisticsAllService;
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    SimpleDateFormat dateFormat2 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXX");
@ -294,10 +295,10 @@ public class StatisticsESService {
        if (!org.springframework.util.StringUtils.isEmpty(year)) {
            startDate = year + "-06-30";
        }
        String levelTemp = level+"";
        if(StringUtils.isNotEmpty(lowLevel)){
            levelTemp = lowLevel;
        }
//        String levelTemp = level+"";
//        if(StringUtils.isNotEmpty(lowLevel)){
//            levelTemp = lowLevel;
//        }
        List<SaveModel>  list = null;
        if(StringUtils.isNotEmpty(level2_type)){
@ -309,28 +310,107 @@ public class StatisticsESService {
            year = Constant.getNowYear();
        }
        List<Map<String, Object>> resultList = new ArrayList<>();
        PopulationBase populationBase = getPopulationBase(area,year);
        DecimalFormat df = new DecimalFormat("0.0000");
        for (SaveModel saveModel:list) {
            Map<String, Object> map = new HashMap<>();
            if (SaveModel.OrgLevel.equals(levelTemp)) {
            if (SaveModel.OrgLevel.equals(lowLevel)) {
                map.put("code",saveModel.getHospital());
                map.put("name",saveModel.getHospitalName());
            } else if (SaveModel.townLevel.equals(levelTemp)) {
            } else if (SaveModel.townLevel.equals(lowLevel)) {
                map.put("code",saveModel.getTown());
                map.put("name",saveModel.getTownName());
            } else if (SaveModel.cityLevel.equals(levelTemp)) {
            } else if (SaveModel.cityLevel.equals(lowLevel)) {
                map.put("code",saveModel.getCity());
                map.put("name",saveModel.getCityName());
            } else if (SaveModel.teamLevel.equals(level+"")) {
            } else if (SaveModel.teamLevel.equals(lowLevel)) {
                map.put("code",saveModel.getTeam());
                map.put("name",saveModel.getCityName());
            }
            if (!SaveModel.teamLevel.equals(lowLevel)) {
                if (org.springframework.util.StringUtils.isEmpty(year)) {
                    year = Constant.getNowYear();
                }
                PopulationBase peopleNum = getPopulationBase(area,year);
                if (peopleNum != null) {
                    map.put("rate",df.format((saveModel.getResult2() * 1.0000) / peopleNum.getNum() * 100));
                    map.put("rateString",saveModel.getResult2().longValue()+"/"+peopleNum.getNum());
                }
            }
            map.put("amount",saveModel.getResult2().longValue());
            map.put("rate",df.format((saveModel.getResult2() * 1.0000) / populationBase.getNum() * 100));
            map.put("rateString",saveModel.getResult2().longValue()+"/"+populationBase.getNum());
            resultList.add(map);
        }
        // 结果为空时,自建结果集
        if (resultList == null || resultList.size() < 1) {
            resultList = new ArrayList<>();
            if (SaveModel.townLevel.equals(lowLevel)) {
                List<Town> towns = townDao.findByCityCode(area);
                if (towns != null) {
                    for (Town town : towns) {
                        Map<String, Object> obj = new HashMap<>();
                        obj.put("code", town.getCode());
                        obj.put("name", town.getName());
                        obj.put("amount", "0");
                        obj.put("rate", Double.valueOf("0.0000"));
                        obj.put("rateString", "0/0");
                        resultList.add(obj);
                    }
                }
            } else if (SaveModel.OrgLevel.equals(lowLevel)) {
                List<Town> towns = new ArrayList<>();
                if (SaveModel.cityLevel.equals(level+"")) {
                    towns = townDao.findByCityCode(area);
                } else if (SaveModel.townLevel.equals(level+"")) {
                    Town town = townDao.findByCode(area);
                    towns.add(town);
                }
                if (towns != null && towns.size() > 0) {
                    for (Town town : towns) {
                        List<Hospital> hospitals = hospitalDao.findByTownCode(town.getCode());
                        for (Hospital hos : hospitals) {
                            Map<String, Object> obj = new HashMap<>();
                            obj.put("code", hos.getCode());
                            obj.put("name", hos.getName());
                            obj.put("amount", "0");
                            resultList.add(obj);
                        }
                    }
                }
            } else if (SaveModel.teamLevel.equals(lowLevel)) {
                List<Hospital> hospitals = new ArrayList<>();
                if (SaveModel.cityLevel.equals(level+"")) {
                    hospitals = hospitalDao.findByCity(area);
                } else if (SaveModel.townLevel.equals(level+"")) {
                    hospitals = hospitalDao.findByTownCode(area);
                } else {
                    Hospital hos = hospitalDao.findByCode(area);
                    if (hos != null) {
                        hospitals.add(hos);
                    }
                }
                if (hospitals != null && hospitals.size() > 0) {
                    for (Hospital hos : hospitals) {
                        List<AdminTeam> teams = adminTeamDao.findByOrgCode(hos.getCode());
                        for (AdminTeam team : teams) {
                            Map<String, Object> obj = new HashMap<>();
                            obj.put("code", String.valueOf(team.getId()));
                            obj.put("name", team.getName());
                            obj.put("amount", "0");
                            resultList.add(obj);
                        }
                    }
                }
            }
        }
        if (SaveModel.OrgLevel.equals(level+"")) {
            statisticsAllService.translateTeamLeaderName(resultList);
        }
        Collections.sort(resultList, new Comparator<Map<String, Object>>() {
            public int compare(Map<String, Object> o1, Map<String, Object> o2) {
                long map1value = (long) o1.get("amount");
@ -367,14 +447,14 @@ public class StatisticsESService {
            map.put("amount",saveModel.getResult2().longValue());
            if (index.equals("7")) {
                // 分组指标总数算法
                String code = saveModel.getSlaveKey2();
                if (code.equals("0") || code.equals("1") || code.equals("2") || code.equals("3") || code.equals("7")) {
                String code = saveModel.getSlaveKey1();
                if ("0".equals(code) || "1".equals(code) || "2".equals(code) || "3".equals(code) || "7".equals(code)) {
                    total += saveModel.getResult2();
                }
            } else if (index.equals("16")) {
                String code = saveModel.getSlaveKey2();
            } else if ("16".equals(index)) {
                String code = saveModel.getSlaveKey1();
                if (!code.equals("2")) {
                if (!"2".equals(code)) {
                    total += saveModel.getResult2();
                }
            } else {
@ -382,13 +462,13 @@ public class StatisticsESService {
            }
            resultList.add(map);
        }
        if (!index.equals("8")) {
            if (index.equals("36")) {
        if (!"8".equals(index)) {
            if ("36".equals(index)) {
                //获取最新的统计时间
//                String updateTime = elasticsearchUtil.getQuotaTime();
                //如果是查询36的指标 那么除数是签约总数
                SaveModel saveModel = elasticsearchUtil.findOneDateQuotaLevel0(endDate,area,level,"1","2");
                Long num = Long.parseLong(saveModel.getResult2()+"");
                Long num = saveModel.getResult2().longValue();
                for (Map<String, Object> map:resultList) {
                    double rateG = (total > 0 ? ((long) map.get("amount")) * 1.0000 / num * 100 : 0);
                    map.put("rate", df.format(rateG));
@ -402,7 +482,7 @@ public class StatisticsESService {
                }
            }
        }
        if (index.equals("6") && resultList.size() > 0) {
        if ("6".equals(index) && resultList.size() > 0) {
            int i = 0;
            boolean flag = false;
            for (; i < resultList.size(); i++) {
@ -442,9 +522,7 @@ public class StatisticsESService {
     */
    public long getIndexTotal(String endDate, String area, int level, String index,String timeLevel) throws Exception{
        if (endDate.compareTo(dateFormat.format(new Date())) >= 0) {
            endDate = elasticsearchUtil.getQuotaTime();
        }
        endDate = elasticsearchUtil.changeTime(endDate);
        SaveModel saveModel = elasticsearchUtil.findOneDateQuotaLevel0(endDate,area,level,index,timeLevel);
        return saveModel.getResult2().longValue();
    }
@ -699,7 +777,7 @@ public class StatisticsESService {
        int taskNum = 0;
        JSONObject json = new JSONObject();
        if (level > 1 && org.springframework.util.StringUtils.isEmpty(lowCode)) {
        if (level < 5 && org.springframework.util.StringUtils.isEmpty(lowCode)) {
            PopulationBase peopleNum = getPopulationBase(area, year);
            if (peopleNum != null) {
@ -723,9 +801,9 @@ public class StatisticsESService {
        List<SaveModel> list = null;
        if(StringUtils.isNotEmpty(lowCode)){
            //一级维度
            list = elasticsearchUtil.findDateQuotaLevel1(startDate,endDate,area,level,index,"2",lowCode,interval+"",null);
            list = elasticsearchUtil.findLineChartDateQuotaLevel1(startDate,endDate,area,level,index,"2",lowCode,interval+"");
        }else{
            list = elasticsearchUtil.findDateQuotaLevel0(startDate,endDate,area,level,index,"2",interval+"",null);
            list = elasticsearchUtil.findLineChartDateQuotaLevel0(startDate,endDate,area,level,index,"2",interval+"");
        }
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        List<JSONObject> result = new ArrayList<>();
@ -750,7 +828,7 @@ public class StatisticsESService {
     */
    public List<Map<String, Object>> getLowLevelMapKey(int level, String lowLevel, String area) {
        List<Map<String, Object>> resultList = new ArrayList<>();
        if (lowLevel.equals("3")) {
        if (SaveModel.townLevel.equals(lowLevel)) {
            List<Town> towns = townDao.findByCityCode(area);
            if (towns != null) {
                for (Town town : towns) {
@ -763,9 +841,9 @@ public class StatisticsESService {
            }
        } else if (lowLevel.equals("4")) {
            List<Town> towns = new ArrayList<>();
            if (level == 2) {
            if (SaveModel.cityLevel.equals(level+"")) {
                towns = townDao.findByCityCode(area);
            } else if (level == 3) {
            } else if (SaveModel.townLevel.equals(level+"")) {
                Town town = townDao.findByCode(area);
                if (town != null) {
                    towns.add(town);
@ -788,11 +866,11 @@ public class StatisticsESService {
                    }
                }
            }
        } else if (lowLevel.equals("5")) {
        } else if (SaveModel.teamLevel.equals(lowLevel)) {
            List<Hospital> hospitals = new ArrayList<>();
            if (level == 2) {
                hospitals = hospitalDao.findByCity(area);
            } else if (level == 3) {
            } else if (SaveModel.townLevel.equals(level+"")) {
                hospitals = hospitalDao.findByTownCode(area);
            } else {
                Hospital hos = hospitalDao.findByCode(area);
@ -1487,13 +1565,13 @@ public class StatisticsESService {
     */
    public JSONArray getLowLevelIncrementDetail(String startDate, String endDate, String area, int level, String index, int sort, String low_level) throws Exception {
        List<Map<String, Object>> resultList = new ArrayList<>();
        List<SaveModel> esModelList = (List<SaveModel>) elasticsearchUtil.findListDateQuotaLevel0(startDate, area, level, index, SaveModel.timeLevel_DDL, low_level);
        List<SaveModel> esModelList = (List<SaveModel>) elasticsearchUtil.findListDateQuotaLevel0(startDate, endDate,area, level, index, SaveModel.timeLevel_ZL, low_level);
        if (esModelList != null && esModelList.size() > 0) {
            for (SaveModel one : esModelList) {
                Map<String, Object> maps = new HashMap<String, Object>();
                maps.put("amount", Long.parseLong(one.getResult2()+""));
                if (low_level.equals("3")) {
                maps.put("amount", one.getResult2().longValue());
                if (SaveModel.townLevel.equals(low_level)) {
                    maps.put("code", one.getTown());
                    maps.put("name", one.getTownName());
                } else if (low_level.equals("4")) {
@ -1510,7 +1588,7 @@ public class StatisticsESService {
        // 结果为空时,自建结果集
        if (resultList == null || resultList.size() < 1) {
            resultList = new ArrayList<>();
            if (low_level.equals("3")) {
            if (SaveModel.townLevel.equals(low_level)) {
                List<Town> towns = townDao.findByCityCode(area);
                if (towns != null) {
                    for (Town town : towns) {
@ -1616,13 +1694,13 @@ public class StatisticsESService {
                timeKey = coutYear+"-06-30";
            }
        }
//        timeKey= "2017-10-19 00:00:00";
//        timeKey= "2017-11-01 00:00:00";
        //及时回复数
        List<SaveModel> relyVal = elasticsearchUtil.findListDateQuotaLevel0(timeKey,area,level,"23","2",lowLevel);
        List<SaveModel> relyVal = elasticsearchUtil.findListDateQuotaLevel0( null,timeKey,area,level,"23","1",lowLevel);
        //咨询总数
        List<SaveModel> relyTotal = elasticsearchUtil.findListDateQuotaLevel0(timeKey,area,level,"25","2",lowLevel);
        List<SaveModel> relyTotal = elasticsearchUtil.findListDateQuotaLevel0(null,timeKey,area,level,"25","1",lowLevel);
        //未回复数
        List<SaveModel> noRelyTotal = elasticsearchUtil.findListDateQuotaLevel0(timeKey,area,level,"22","2",lowLevel);
        List<SaveModel> noRelyTotal = elasticsearchUtil.findListDateQuotaLevel0(null,timeKey,area,level,"22","1",lowLevel);
//        JSONArray rely = new JSONArray(relyVal);
//        JSONArray total = new JSONArray(relyTotal);
//        JSONArray noRely = new JSONArray(noRelyTotal);
@ -1647,32 +1725,32 @@ public class StatisticsESService {
        //转换回复数
        for(SaveModel saveModel:rely){
            if(level==4){
                relyMap.put(saveModel.getHospital(), saveModel);
                relyMap.put(saveModel.getTeam(), saveModel);
            }else if(level==3){
                relyMap.put(saveModel.getTown(), saveModel);
                relyMap.put(saveModel.getHospital(), saveModel);
            }else if(level==2){
                relyMap.put(saveModel.getCity(), saveModel);
                relyMap.put(saveModel.getTown(), saveModel);
            }
        };
        //转换总咨询数
        for(SaveModel saveModel:total){
            if(level==4){
                relyMap.put(saveModel.getHospital(), saveModel);
                totalMap.put(saveModel.getTeam(), saveModel);
            }else if(level==3){
                relyMap.put(saveModel.getTown(), saveModel);
                totalMap.put(saveModel.getHospital(), saveModel);
            }else if(level==2){
                relyMap.put(saveModel.getCity(), saveModel);
                totalMap.put(saveModel.getTown(), saveModel);
            }
        };
        //转换总咨询数
        for(SaveModel saveModel:onRely){
            if(level==4){
                relyMap.put(saveModel.getHospital(), saveModel);
                onRelyMap.put(saveModel.getTeam(), saveModel);
            }else if(level==3){
                relyMap.put(saveModel.getTown(), saveModel);
                onRelyMap.put(saveModel.getHospital(), saveModel);
            }else if(level==2){
                relyMap.put(saveModel.getCity(), saveModel);
                onRelyMap.put(saveModel.getTown(), saveModel);
            }
        };
        List<Map<String, Object>> resultMaps = new ArrayList<>();
@ -1690,11 +1768,11 @@ public class StatisticsESService {
            Integer noRelyNm = onRelyRs.getResult2().intValue();
//            rs.put("name", relyRs.get(area+"Name"));
            if(level==4){
                rs.put("name", relyRs.getHospitalName());
                rs.put("name", relyRs.getTeamName());
            }else if(level==3){
                rs.put("name", relyRs.getTownName());
                rs.put("name", relyRs.getHospitalName());
            }else if(level==2){
                rs.put("name", relyRs.getCityName());
                rs.put("name", relyRs.getTownName());
            }
            rs.put("noRelyCount", noRelyNm);
            rs.put("relyCount", relyNm);
@ -1809,9 +1887,9 @@ public class StatisticsESService {
//        List<SaveModel> relyTotal = elasticsearchUtil.findOneDateQuotaLevel1(quotaDate,area,level,"25","2");
//        List<SaveModel> onRelyTotal = elasticsearchUtil.findOneDateQuotaLevel1(quotaDate,area,level,"22","2");
        SaveModel relyVal = elasticsearchUtil.findOneDateQuotaLevel0(quotaDate,area,level,"23","2");
        SaveModel relyTotal = elasticsearchUtil.findOneDateQuotaLevel0(quotaDate,area,level,"25","2");
        SaveModel onRelyTotal = elasticsearchUtil.findOneDateQuotaLevel0(quotaDate,area,level,"22","2");
        SaveModel relyVal = elasticsearchUtil.findOneDateQuotaLevel0(null,quotaDate,area,level,"23","1");
        SaveModel relyTotal = elasticsearchUtil.findOneDateQuotaLevel0(null,quotaDate,area,level,"25","1");
        SaveModel onRelyTotal = elasticsearchUtil.findOneDateQuotaLevel0(null,quotaDate,area,level,"22","1");
//        JSONObject relyObject = new JSONObject(relyVal);
//        JSONObject totalObject = new JSONObject(relyTotal);
@ -2129,9 +2207,9 @@ public class StatisticsESService {
            jsonObject.put("name", expenseStatus1Sigjn.getCityName());
        }
        jsonObject.put("code", area);
        Long  weChatAmount0 =  Long.valueOf(expenseStatus0.getResult2().toString());
        Long  weChatAmount1 =  Long.valueOf(expenseStatus1.getResult2().toString());
        Long  signAccount =  Long.valueOf(expenseStatus1Sigjn.getResult2().toString());
        Long  weChatAmount0 =  expenseStatus0.getResult2().longValue();
        Long  weChatAmount1 =  expenseStatus1.getResult2().longValue();
        Long  signAccount =  expenseStatus1Sigjn.getResult2().longValue();
        jsonObject.put("weChatAmount0", weChatAmount0);//微信关注未交费数
        jsonObject.put("weChatAmount1", weChatAmount1);//微信关注已交费数
        jsonObject.put("bindRate", getRangeDouuble(weChatAmount1.intValue(), signAccount.intValue(), 2));//微信关注率

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

@ -424,6 +424,13 @@ public class DateUtil {
		c.add(Calendar.MONTH, months);
		return dateToStrShort(c.getTime());
	}
	
	public static Date getNextMonthReturnDate(Date d, int months) {
		Calendar c = Calendar.getInstance();
		c.setTime(d);
		c.add(Calendar.MONTH, months);
		return c.getTime();
	}
	public static String getNextYear(Date d, int year) {
		Calendar c = Calendar.getInstance();

+ 6 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/ElasticsearchUtil.java

@ -83,6 +83,7 @@ public class ElasticsearchUtil {
            temp.getLines().forEach(one -> {
                Object saveModel = null;
                try {
                    saveModel = clazz.newInstance();
                } catch (Exception e) {
                    logger.error(e.getMessage());
@ -524,7 +525,11 @@ public class ElasticsearchUtil {
    public String changeTime(String time){
        try {
            time = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXX").format(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(time));
            if(time.length()==10){
                time = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXX").format(new SimpleDateFormat("yyyy-MM-dd").parse(time));
            }else if(time.length()==19){
                time = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXX").format(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(time));
            }
        } catch (ParseException e) {
            e.printStackTrace();
        }

+ 40 - 4
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/consult/DoctorConsultController.java

@ -15,7 +15,6 @@ import com.yihu.wlyy.repository.patient.SignFamilyServerDao;
import com.yihu.wlyy.repository.prescription.PrescriptionDao;
import com.yihu.wlyy.service.app.account.DoctorInfoService;
import com.yihu.wlyy.service.app.account.PatientInfoService;
import com.yihu.wlyy.service.app.consult.ConsultService;
import com.yihu.wlyy.service.app.consult.ConsultTeamService;
import com.yihu.wlyy.service.app.followup.FollowUpService;
import com.yihu.wlyy.service.app.health.PatientHealthGuidanceService;
@ -1143,7 +1142,44 @@ public class DoctorConsultController extends WeixinBaseController {
            return error(-1, "查询失败!");
        }
    }
    
    @RequestMapping(value = "addPrescriptionBloodStatusConsult",method = RequestMethod.POST)
    @ResponseBody
    @ObserverRequired
    @ApiOperation("续方咨询-医生发送血糖血压快捷回复咨询")
    public String addPrescriptionBloodStatusConsult(
            @ApiParam(name = "prescriptionCode", value = "处方code", defaultValue = "")
            @RequestParam(value = "prescriptionCode", required = true) String prescriptionCode,
            @ApiParam(name = "type", value = "类型(1血压,2血糖)", defaultValue = "")
            @RequestParam(value = "type", required = true) String type,
            @ApiParam(name = "followupid", value = "随访记录ID", defaultValue = "")
            @RequestParam(value = "followupid", required = true) String followupid){
        try{
            consultTeamService.addPrescriptionBloodStatusConsult(prescriptionCode,type,followupid);
            return write(200, "添加成功!");
        }catch (Exception e){
            error(e);
            return error(-1,"添加失败");
        }
    }
    
    @RequestMapping(value = "addPrescriptionFollowupContentConsult",method = RequestMethod.POST)
    @ResponseBody
    @ObserverRequired
    @ApiOperation("续方咨询-医生发送问卷快捷回复咨询")
    public String addPrescriptionFollowupContentConsult(
            @ApiParam(name = "prescriptionCode", value = "处方code", defaultValue = "")
            @RequestParam(value = "prescriptionCode", required = true) String prescriptionCode,
            @ApiParam(name = "type", value = "类型(1症状,2体征及生活方式)", defaultValue = "")
            @RequestParam(value = "type", required = true) String type,
            @ApiParam(name = "followupid", value = "随访记录ID", defaultValue = "")
            @RequestParam(value = "followupid", required = true) String followupid){
        try{
            consultTeamService.addPrescriptionFollowupContentConsult(prescriptionCode,type,followupid);
            return write(200, "添加成功!");
        }catch (Exception e){
            error(e);
            return error(-1,"添加失败");
        }
    }
}

+ 55 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/feedback/DoctorFeedbackTemplateController.java

@ -0,0 +1,55 @@
package com.yihu.wlyy.web.doctor.feedback;
import com.alibaba.fastjson.JSONArray;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.entity.feedback.Feedback;
import com.yihu.wlyy.service.app.feedback.FeedbackService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.CommonUtil;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
/**
 * Created by Reece on 2017/5/6.
 */
@Controller
@RestController
@RequestMapping(value = "/doctor/feedback")
@Api(description = "医生端意见反馈")
public class DoctorFeedbackTemplateController extends BaseController {
    @Autowired
    private PushMsgTask pushMsgTask;
    @Autowired
    private CommonUtil CommonUtil;
    /**
     * 医生端发送系统消息
     * @param receiver 接受者
     * @param title 标题
     * @param content 内容
     * @return
     */
    @RequestMapping(value = "/sendMessage", method = RequestMethod.POST)
    @ApiOperation(value = "医生端发送系统消息")
    @ResponseBody
    @ObserverRequired
    public String saveFeedback(
            @RequestParam String receiver,
            @RequestParam String title,
            @RequestParam String content) {
        try {
            pushMsgTask.put(receiver, "8", title, content, "");
            return write(200, "发送成功!");
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "发送失败!");
        }
    }
}

+ 19 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/followup/DoctorFollowUpController.java

@ -400,5 +400,24 @@ public class DoctorFollowUpController extends BaseController {
            return invalidUserException(e, -1, "发送随访计划消息失败!" + e.getMessage());
        }
    }
    
    
    @RequestMapping(value = "/checkfollowupcontent", method = RequestMethod.GET)
    @ApiOperation("检查续方关联的随访记录是否对应的详情记录")
    public String getfollowupcontent(
            @ApiParam(name = "followupid", value = "随访ID", defaultValue = "")
            @RequestParam(value = "followupid", required = true) String followupid,
            @ApiParam(name = "type", value = "支持传多个以英文逗号连接,drug为药品,1-9为随访分类", defaultValue = "")
            @RequestParam(value = "type", required = true) String type){
        try {
            int count = followUpService.getfollowupcontent(followupid,type);
            return write(200, "操作成功!","data",count);
        }catch (Exception e){
            //日志文件中记录异常信息
            error(e);
            //返回接口异常信息处理结果
            return error(-1, "操作失败!");
        }
    }
}

+ 79 - 4
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/DoctorPrescriptionFollowupContentController.java

@ -35,9 +35,9 @@ public class DoctorPrescriptionFollowupContentController extends BaseController
	@RequestMapping(value = "/getinfo", method = RequestMethod.GET)
	@ApiOperation("根据续方CODE、类型CODE,获取随访调查分类数据")
	public String getinfoByPrescriptionCodeAndFollowupProject(
			@ApiParam(name = "prescriptioncode", value = "续方CODE", defaultValue = "续方CODE")
			@ApiParam(name = "prescriptioncode", value = "续方CODE", defaultValue = "")
			@RequestParam(value = "prescriptioncode", required = true) String prescriptioncode,
			@ApiParam(name = "followupProject", value = "续方CODE", defaultValue = "问卷类型(症状、体征和问卷)")
			@ApiParam(name = "followupProject", value = "问卷类型(症状、体征和问卷)", defaultValue = "")
			@RequestParam(value = "followupProject", required = true) String followupProject){
		try {
			
@ -64,11 +64,11 @@ public class DoctorPrescriptionFollowupContentController extends BaseController
	@RequestMapping(value = "/list", method = RequestMethod.GET)
	@ApiOperation("根据续方CODE获取随访调查问卷列表")
	public String getList(
			@ApiParam(name = "prescriptioncode", value = "续方CODE", defaultValue = "续方CODE")
			@ApiParam(name = "prescriptioncode", value = "续方CODE", defaultValue = "")
			@RequestParam(value = "prescriptioncode", required = true) String prescriptioncode){
		try {
			JSONArray result = prescriptionFollowupContentService.getList(prescriptioncode);
			return write(200, "请求成功!");
			return write(200, "请求成功!","data",result);
		}catch (Exception e){
			//日志文件中记录异常信息
			error(e);
@ -76,4 +76,79 @@ public class DoctorPrescriptionFollowupContentController extends BaseController
			return error(-1, "请求失败!"+e.getMessage());
		}
	}
	
	@RequestMapping(value = "/importdrugs", method = RequestMethod.POST)
	@ApiOperation("续方药品导入随访记录")
	public String importPrescriptionDrugsToFollowup(
			@ApiParam(name = "prescriptioncode", value = "续方CODE", defaultValue = "")
			@RequestParam(value = "prescriptioncode", required = true) String prescriptioncode,
			@ApiParam(name = "followupid", value = "随访ID", defaultValue = "")
			@RequestParam(value = "followupid", required = true) String followupid){
		try {
			prescriptionFollowupContentService.importPrescriptionDrugsToFollowup(prescriptioncode,followupid);
			return write(200, "操作成功!");
		}catch (Exception e){
			//日志文件中记录异常信息
			error(e);
			//返回接口异常信息处理结果
			return error(-1, "操作失败!");
		}
	}
	
	@RequestMapping(value = "/importbloodsugar", method = RequestMethod.POST)
	@ApiOperation("续方患者的血糖导入随访记录")
	public String importPatientBloodSugarToFollowup(
			@ApiParam(name = "prescriptioncode", value = "续方CODE", defaultValue = "")
			@RequestParam(value = "prescriptioncode", required = true) String prescriptioncode,
			@ApiParam(name = "followupid", value = "随访ID", defaultValue = "")
			@RequestParam(value = "followupid", required = true) String followupid){
		try {
			prescriptionFollowupContentService.importPatientBloodSugarToFollowup(prescriptioncode,followupid,false);
			return write(200, "操作成功!");
		}catch (Exception e){
			//日志文件中记录异常信息
			error(e);
			//返回接口异常信息处理结果
			return error(-1, "操作失败!");
		}
	}
	
	@RequestMapping(value = "/importbloodpressure", method = RequestMethod.POST)
	@ApiOperation("续方患者的血压导入随访记录")
	public String importPatientBloodPressureToFollowup(
			@ApiParam(name = "prescriptioncode", value = "续方CODE", defaultValue = "")
			@RequestParam(value = "prescriptioncode", required = true) String prescriptioncode,
			@ApiParam(name = "followupid", value = "随访ID", defaultValue = "")
			@RequestParam(value = "followupid", required = true) String followupid){
		try {
			prescriptionFollowupContentService.importPatientBloodPressureToFollowup(prescriptioncode,followupid,false);
			return write(200, "操作成功!");
		}catch (Exception e){
			//日志文件中记录异常信息
			error(e);
			//返回接口异常信息处理结果
			return error(-1, "操作失败!");
		}
	}
	
	@RequestMapping(value = "/importfollowupcontent", method = RequestMethod.POST)
	@ApiOperation("续方患者的生活问卷导入随访记录")
	public String importfollowupcontent(
			@ApiParam(name = "prescriptioncode", value = "续方CODE", defaultValue = "")
			@RequestParam(value = "prescriptioncode", required = true) String prescriptioncode,
			@ApiParam(name = "followupid", value = "随访ID", defaultValue = "")
			@RequestParam(value = "followupid", required = true) String followupid,
			@ApiParam(name = "type", value = "问卷类型:1身份异常症状问卷,2体征及生活方式调查问卷", defaultValue = "")
			@RequestParam(value = "type", required = true) String type){
		try {
			prescriptionFollowupContentService.importfollowupcontent(prescriptioncode,followupid,type);
			return write(200, "操作成功!");
		}catch (Exception e){
			//日志文件中记录异常信息
			error(e);
			//返回接口异常信息处理结果
			return error(-1, "操作失败!");
		}
	}
}

+ 12 - 7
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/reply/DoctorQuickReplyController.java

@ -1,6 +1,5 @@
package com.yihu.wlyy.web.doctor.reply;
import com.fasterxml.jackson.databind.deser.Deserializers;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.entity.doctor.reply.DoctorQuickReply;
import com.yihu.wlyy.service.app.reply.DoctorQuickReplyService;
@ -29,13 +28,16 @@ public class DoctorQuickReplyController extends BaseController {
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    @ApiOperation(value = "添加快捷回复")
    public String addReply(@RequestParam @ApiParam(value = "快捷回复内容") String content) {
    public String addReply(
            @RequestParam(value = "content", required = true) @ApiParam(value = "快捷回复内容") String content,
            @ApiParam(name = "type", value = "快捷回复类型(1为续方咨询)", defaultValue = "0")
            @RequestParam(value = "type", required = false, defaultValue = "0") String type) {
        try {
            if (StringUtils.isEmpty(content)) {
                return error(-1, "快捷回复内容不能为空");
            }
            DoctorQuickReply reply = quickReplyService.addReply(getUID(), content);
            DoctorQuickReply reply = quickReplyService.addReply(getUID(), content,type);
            if (reply != null) {
                return write(200, "添加成功", "data", reply);
@ -51,7 +53,9 @@ public class DoctorQuickReplyController extends BaseController {
    @ApiOperation(value = "修改快捷回复")
    @ObserverRequired
    public String modifyReply(@RequestParam @ApiParam(value = "快捷回复ID") Long id,
                              @RequestParam @ApiParam(value = "快捷回复内容") String content) {
                              @RequestParam @ApiParam(value = "快捷回复内容") String content,
                              @ApiParam(name = "type", value = "快捷回复类型(1为续方咨询)", defaultValue = "0")
                                  @RequestParam(value = "type", required = false, defaultValue = "0") String type) {
        try {
            if (id == null || id < 1) {
                return error(-1, "快捷回复ID不能为空");
@ -60,7 +64,7 @@ public class DoctorQuickReplyController extends BaseController {
                return error(-1, "快捷回复内容不能为空");
            }
            DoctorQuickReply reply = quickReplyService.modifyReply(id, content);
            DoctorQuickReply reply = quickReplyService.modifyReply(id, content,type);
            if (reply != null) {
                return write(200, "添加成功", "data", reply);
@ -151,9 +155,10 @@ public class DoctorQuickReplyController extends BaseController {
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    @ApiOperation(value = "快捷回复列表")
    public String replyList() {
    public String replyList(@ApiParam(name = "type", value = "快捷回复类型(1为续方咨询)", defaultValue = "0")
                                @RequestParam(value = "type", required = false, defaultValue = "0") String type) {
        try {
            List<DoctorQuickReply> replies = quickReplyService.getDoctorReplyList(getUID());
            List<DoctorQuickReply> replies = quickReplyService.getDoctorReplyList(getUID(),type);
            return write(200, "查询成功", "data", replies);
        } catch (Exception e) {
            e.printStackTrace();

+ 4 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/consult/ConsultController.java

@ -367,7 +367,7 @@ public class ConsultController extends WeixinBaseController {
                return error(-1, "还有咨询未结束,不允许再次提交咨询!");
            }
            Doctor doctor = doctorService.findDoctorByCode(consult.getDoctor());
//            Doctor doctor = doctorService.findDoctorByCode(consult.getDoctor());
            //创建咨询讨论组
            // JSONObject jo= talkGroupService.createConsultTalkGroup(consult.getDoctor(), doctor.getName(), doctor.getHospital(), doctor.getHospitalName(),
            //        consult.getPatient(), consult.getName(), consult.getConsult());
@ -1001,6 +1001,9 @@ public class ConsultController extends WeixinBaseController {
            ConsultTeam consult = new ConsultTeam();
            consult.setType(8);//续方咨询
            consult.setAdminTeamId(adminTeamId);
            
            //增加体征数据上传发送IM消息标识:1血压 2血糖 3血压+血糖---huangwenjie 2017.11.06
            consult.setHealthindexType(type);
            // 保存到数据库
//            int res = consultTeamService.addPrescriptionConsult(jwCode, "b02f132bfbfc45d287bcde18ad342522","b02f132bfbfc45d287bcde18ad342522",doctor,consult,reason,type);
            int res = 0;

+ 61 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/feedback/PatientFeedbackTemplateController.java

@ -0,0 +1,61 @@
package com.yihu.wlyy.web.patient.feedback;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.service.app.feedback.FeedbackService;
import com.yihu.wlyy.util.CommonUtil;
import com.yihu.wlyy.web.BaseController;
import com.yihu.wlyy.wechat.util.WeiXinTempMsgSendUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
/**
 * Created by Reece on 2017/5/6.
 */
@Controller
@RestController
@RequestMapping(value = "/patient/feedback")
@Api(description = "居民端意见反馈")
public class PatientFeedbackTemplateController extends BaseController {
    @Autowired
    private WeiXinTempMsgSendUtils tempMsgSendUtils;
    @Value("${wechat.message.template_consult_notice}")
    private String templateId;
    /**
     * 居民端发送模板消息
     * @param toUser  接受者openID
     * @param url      跳转路径
     * @param first
     * @param remark
     * @param keywords
     * @return
     */
    @RequestMapping(value = "/sendTemplate", method = RequestMethod.POST)
    @ApiOperation(value = "居民端端发送模板消息")
    @ResponseBody
    @ObserverRequired
    public String saveFeedback(
            @RequestParam(required = true) String toUser,
            @RequestParam(required = false) String url,
            @RequestParam(required = true) String first,
            @RequestParam(required = true) String remark,
            @RequestParam(required = true) String ... keywords) {
        try {
            JSONObject data = tempMsgSendUtils.packageTemplate(first,remark,keywords);
            tempMsgSendUtils.sendTemplateMessage(templateId,toUser,url,data);
            return write(200, "发送成功!");
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "发送失败!");
        }
    }
}

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

@ -471,11 +471,11 @@ public class PatientHealthController extends BaseController {
            JSONArray jsonArray = new JSONArray();
            if (type == 1) {
                List<Object> list = healthIndexService.findIndexByPatient2(getRepUID(), type, start, end, page, pagesize);
//                List<Object> list = healthIndexService.findIndexByPatient2(getUID(), type, start, end, page, pagesize);
//                List<Object> list = healthIndexService.findIndexByPatient2("ec7572875d27446cb4f067b13a85d72a", type, start, end, page, pagesize);
                jsonArray = new JSONArray(list);
            } else {
                jsonArray = healthIndexService.findIndexByPatient(getRepUID(), type, start, end, page, pagesize);
//                List<DevicePatientHealthIndex> list = healthIndexService.findIndexByPatient(getUID(), type, start, end, page, pagesize);
//                List<DevicePatientHealthIndex> list = healthIndexService.findIndexByPatient("ec7572875d27446cb4f067b13a85d72a", type, start, end, page, pagesize);
            }

+ 4 - 9
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/prescription/PatientPrescriptionFollowupContentController.java

@ -28,7 +28,6 @@ public class PatientPrescriptionFollowupContentController extends BaseController
	@Autowired
	private PrescriptionFollowupContentService prescriptionFollowupContentService;
	
	
	@RequestMapping(value = "/getinfo", method = RequestMethod.GET)
	@ApiOperation("根据续方CODE、类型CODE,获取随访调查分类数据")
	public String getinfoByPrescriptionCodeAndFollowupProject(
@ -37,19 +36,14 @@ public class PatientPrescriptionFollowupContentController extends BaseController
			@ApiParam(name = "followupProject", value = "续方CODE", defaultValue = "问卷类型(症状、体征和问卷)")
			@RequestParam(value = "followupProject", required = true) String followupProject){
		try {
			
			List<PrescriptionFollowupContent> result = prescriptionFollowupContentService.getByPrescriptionCodeAndFollowupProject(prescriptioncode,followupProject);
			
			Map<String, String> datamap = new HashMap<>();
			
			if(!result.isEmpty()){
				for (PrescriptionFollowupContent prescriptionFollowupContent: result) {
					datamap.put(prescriptionFollowupContent.getFollowupKey(),prescriptionFollowupContent.getFollowupValue());
				}
			}
			
			return write(200, "请求成功!","data",datamap);
			
		}catch (Exception e){
			//日志文件中记录异常信息
			error(e);
@ -63,9 +57,11 @@ public class PatientPrescriptionFollowupContentController extends BaseController
	public String saveInfo(@ApiParam(name = "prescriptioncode", value = "续方CODE", defaultValue = "续方CODE")
	                       @RequestParam(value = "prescriptioncode", required = true) String prescriptioncode,
	                       @ApiParam(name = "followupProjectData", value = "调查分类数据", defaultValue = "[{\"followupProject\":\"1\",\"projectData\":{\"WEIGHT\":\"76\",\"WEIGHT_EXP\":\"60\",\"BMI\":\"11\"}}]")
	                       @RequestParam(value = "followupProjectData", required = true) String followupProjectData){
	                       @RequestParam(value = "followupProjectData", required = true) String followupProjectData,
	                       @ApiParam(name = "sendIM", value = "是否发送IM消息", defaultValue = "false")
	                       @RequestParam(value = "sendIM", required = true) boolean sendIM){
		try {
			prescriptionFollowupContentService.saveInfo(prescriptioncode,followupProjectData,getUID());
			prescriptionFollowupContentService.saveInfo(prescriptioncode,followupProjectData,getUID(),false);
			return write(200, "请求成功!");
		}catch (Exception e){
			//日志文件中记录异常信息
@ -73,6 +69,5 @@ public class PatientPrescriptionFollowupContentController extends BaseController
			//返回接口异常信息处理结果
			return error(-1, "请求失败!"+e.getMessage());
		}
		
	}
}

+ 7 - 4
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/EsStatisticsController.java

@ -259,10 +259,10 @@ public class EsStatisticsController extends BaseController {
            /**旧版统计代码start**/
            JSONArray jsonArray2 = null;
            if (Constant.getNowYearByDate(endDate).equals(year)) {
                jsonArray2 = statisticsESService.getLowLevelIncrementDetail(endDate, endDate, area, level, indexes[1], sort, lowLevel);
                jsonArray2 = statisticsESService.getLowLevelIncrementDetail("", endDate, area, level, indexes[1], sort, lowLevel);
            } else {
                String date = Integer.valueOf(year) + 1 + "-06-30";
                jsonArray2 = statisticsESService.getLowLevelIncrementDetail(date, date, area, level, indexes[1], sort, lowLevel);
                jsonArray2 = statisticsESService.getLowLevelIncrementDetail("", date, area, level, indexes[1], sort, lowLevel);
            }
            jsonArrays.add(jsonArray2);
            /**旧版统计代码end**/
@ -312,7 +312,7 @@ public class EsStatisticsController extends BaseController {
                }
            }
            if (level == 2) {
            if (SaveModel.OrgLevel.equals(level)) {
                statisticsAllService.translateTeamLeaderNameByCode(returnJa);
            }
            result.put("index_" + indexes[0], returnJa);
@ -520,6 +520,8 @@ public class EsStatisticsController extends BaseController {
                                            @RequestParam(required = false) String lowLevel,
                                            @RequestParam(required = false) String lowCode) {
        try {
            lowLevel = String.valueOf(org.springframework.util.StringUtils.isEmpty(lowLevel) ? (level - 1) : lowLevel);
            int levelTemp = level;
            String lowLevelTemp = lowLevel;
            //新版与旧版统计适配
@ -668,7 +670,8 @@ public class EsStatisticsController extends BaseController {
                                              @RequestParam(required = false) String lowlevel,
                                              @RequestParam(required = false) String year) {
        try {
//新         版与旧版统计适配
            lowlevel = StringUtils.isEmpty(lowlevel)?String.valueOf(level-1):lowlevel;
            //新版与旧版统计适配
            level = elasticsearchUtil.changeLevel(level);
            if(StringUtils.isNotEmpty(lowlevel)){
                lowlevel = elasticsearchUtil.changeLevel(Integer.parseInt(lowlevel))+"";

+ 11 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/vo/PatientModel.java

@ -72,6 +72,9 @@ public class PatientModel {
    // 居委会字段名称
    @ApiModelProperty(value = "居委会字段名称", required = false, access = "response")
    private String sickVillageName;
    //	绑定电子社保卡主体
    @ApiModelProperty(value = "绑定电子社保卡主体", required = false, access = "response")
    private String principalCode;
    //	是否绑定电子社保卡
    @ApiModelProperty(value = "是否绑定电子社保卡", required = false, access = "response")
    private Integer sicardStatus;
@ -86,6 +89,14 @@ public class PatientModel {
    @ApiModelProperty(value = "年龄", required = false, access = "response")
    private Integer age;
    public String getPrincipalCode() {
        return principalCode;
    }
    public void setPrincipalCode(String principalCode) {
        this.principalCode = principalCode;
    }
    public String getCode() {
        return code;
    }

+ 1 - 1
patient-co/patient-co-wlyy/src/main/resources/application-devtest.yml

@ -22,7 +22,7 @@ server:
#医生助手服务器地址及模板跳转链接(医生未读消息统计页)
doctorAssistant:
  api: http://ehr.yihu.com/wlyy/
  target_url: /prescription/www.baidu.com
  target_url: home/html/unreadMessageStatistic.html
im:

+ 1 - 1
patient-co/patient-co-wlyy/src/main/resources/application-local.yml

@ -22,7 +22,7 @@ server:
#医生助手服务器地址及模板跳转链接(医生未读消息统计页)
doctorAssistant:
  api: http://10.95.22.10:8011/wlyy/
  target_url: /prescription/www.baidu.com
  target_url: home/html/unreadMessageStatistic.html
im:

+ 1 - 1
patient-co/patient-co-wlyy/src/main/resources/application-localtest.yml

@ -22,7 +22,7 @@ server:
#医生助手服务器地址及模板跳转链接(医生未读消息统计页)
doctorAssistant:
  api: http://ehr.yihu.com/wlyy/
  target_url: /prescription/www.baidu.com
  target_url: home/html/unreadMessageStatistic.html
im:

+ 1 - 1
patient-co/patient-co-wlyy/src/main/resources/application-prod.yml

@ -21,7 +21,7 @@ server:
#医生助手服务器地址及模板跳转链接(医生未读消息统计页)
doctorAssistant:
  api: http://www.xmtyw.cn/assistant/
  target_url: /prescription/www.baidu.com
  target_url: home/html/unreadMessageStatistic.html
im:

+ 1 - 1
patient-co/patient-co-wlyy/src/main/resources/application-test.yml

@ -22,7 +22,7 @@ server:
#医生助手服务器地址及模板跳转链接(医生未读消息统计页)
doctorAssistant:
  api: http://ehr.yihu.com/wlyy/
  target_url: /prescription/www.baidu.com
  target_url: home/html/unreadMessageStatistic.html
im:
  im_list_get: http://172.19.103.88:3000/