Quellcode durchsuchen

Merge branch '2.0' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into 2.0

wangzhinan vor 9 Monaten
Ursprung
Commit
e6ac2847f4
28 geänderte Dateien mit 1260 neuen und 445 gelöschten Zeilen
  1. 10 3
      business/base-service/src/main/java/com/yihu/jw/device/dao/DevicePatientHealthIndexDao.java
  2. 20 0
      business/base-service/src/main/java/com/yihu/jw/hospital/family/service/WlyyFamilyMemberService.java
  3. 3 0
      business/base-service/src/main/java/com/yihu/jw/label/WlyyPatientLabelDao.java
  4. 2 3
      business/base-service/src/main/java/com/yihu/jw/patient/service/BasePatientService.java
  5. 3 0
      business/base-service/src/main/java/com/yihu/jw/sign/dao/WlyySignDao.java
  6. 9 0
      business/base-service/src/main/java/com/yihu/jw/wlyy/service/WlyyBusinessService.java
  7. 1 12
      business/base-service/src/main/java/com/yihu/jw/wlyy/wlyyhttp/WlyyHttpService.java
  8. 77 9
      common/common-entity/src/db/2024.sql
  9. 1 1
      common/common-entity/src/main/java/com/yihu/jw/entity/base/patient/BasePatientDO.java
  10. 0 53
      common/common-entity/src/main/java/com/yihu/jw/entity/base/patient/PatientDoctorRelationEntity.java
  11. 253 0
      common/common-entity/src/main/java/com/yihu/jw/entity/door/WlyySign.java
  12. 0 212
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/conf/SystemConf.java
  13. 15 0
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/hospital/WlyyFamilyMemberController.java
  14. 20 0
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/specialist/BaseDiseaseHospitalController.java
  15. 3 3
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/service/consult/KnowledgeCategoryService.java
  16. 8 14
      svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/controller/doctor/DoctorRehabilitationManageController.java
  17. 2 2
      svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/controller/patient/PatientRehabilitationManageController.java
  18. 48 0
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/common/LabelController.java
  19. 25 0
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/common/StatisticsController.java
  20. 142 0
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/common/service/LabelService.java
  21. 199 2
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/common/service/StatisticsService.java
  22. 21 36
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/followup/controller/DoctorFollowUpController.java
  23. 69 11
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/controller/ChronicDiseaseController.java
  24. 2 0
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/controller/PatientHealthController.java
  25. 2 2
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/dao/TrackPatientDao.java
  26. 86 3
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/service/DeviceUploadService.java
  27. 99 0
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/service/PatientHealthIndexService.java
  28. 140 79
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/service/scheme/DoctorSchemeService.java

+ 10 - 3
business/base-service/src/main/java/com/yihu/jw/device/dao/DevicePatientHealthIndexDao.java

@ -23,17 +23,24 @@ public interface DevicePatientHealthIndexDao
	@Query(value = "select DATE_FORMAT(a.record_date,'%Y-%m-%d') from device.wlyy_patient_health_index a where a.user = ?1 and a.del = '1' group by DATE_FORMAT(a.record_date,'%Y-%m-%d') order by DATE_FORMAT(a.record_date,'%Y-%m-%d') desc limit ?2 ,?3",nativeQuery = true)
	List<String> findDateList1(String patient,int currentSize,int pageSize);
	@Query(value="select * from wlyy_patient_health_index where user = ?1 and type = ?2 ORDER BY record_date desc limit 0 ,5",nativeQuery = true)
	List<DevicePatientHealthIndex> findByPatientAndTypeByPage(String patientCode, int type);
	@Query("select count(a) from DevicePatientHealthIndex a where a.recordDate >= ?1 and a.recordDate <= ?2 and a.type in (1,2) and a.status = ?3 and a.del = '1' and a.user = ?4")
	int getCountByTimeAndStatus(Date start, Date end, int status, String patientCode);
	@Query(value= "SELECT DISTINCT\n" +
			"	a.* \n" +
			"FROM\n" +
			"	wlyy_patient_health_index  a \n" +
			"	INNER JOIN base_patient b ON a.`user`=b.id \n" +
			"	INNER JOIN base_patient_doctor_relation c ON b.id=c.patient_id\n" +
			"	INNER JOIN wlyy_outpatient c ON b.id=c.patient\n" +
			"WHERE\n" +
			"	a.type IN ('1', '2' ) \n" +
			"	AND a.record_date BETWEEN ?1 AND ?2 \n" +
			"	AND c.doctor_id =?3 \n" +
			"	AND c.doctor =?3 \n" +
			"	AND b.disease IN('1','2','3')\n" +
			"	AND b.disease_condition IN ('1','2','1,2')",nativeQuery = true)
			"	AND b.disease_condition IN ('1','2','0')",nativeQuery = true)
	List<DevicePatientHealthIndex> findByDoctor(Date start, Date end, String doctorcode);
}

+ 20 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/family/service/WlyyFamilyMemberService.java

@ -1166,4 +1166,24 @@ public class WlyyFamilyMemberService extends BaseJpaService<WlyyPatientFamilyMem
        }
        return list;
    }
    public void defaultPatient(String patient, String verifyCode) {
        BasePatientDO patientDO = basePatientDao.findById(patient).orElse(null);
        if (patientDO != null) {
            patientDO.setVerifyCode(verifyCode);
            basePatientDao.save(patientDO);
            if (!patient.equals(verifyCode)) {
                BasePatientDO p = basePatientDao.findById(verifyCode).orElse(null);
                String openid = patientDO.getOpenid();
                String appletOpenid = patientDO.getResidentialArea();
                if (org.apache.commons.lang3.StringUtils.isNotBlank(openid) && !"null".equals(openid) && !"undefined".equals(openid)) {
                    p.setOpenid(openid);
                }
                if (org.apache.commons.lang3.StringUtils.isNotBlank(appletOpenid) && !"null".equals(appletOpenid) && !"undefined".equals(appletOpenid)) {
                    p.setResidentialArea(appletOpenid);
                }
                basePatientDao.save(p);
            }
        }
    }
}

+ 3 - 0
business/base-service/src/main/java/com/yihu/jw/label/WlyyPatientLabelDao.java

@ -27,6 +27,9 @@ public interface WlyyPatientLabelDao extends JpaRepository<WlyyPatientLabelDO, S
    @Query("from WlyyPatientLabelDO w where  w.patient=?1 and w.labelCode=?2 and w.labelType=?3 ")
    List<WlyyPatientLabelDO> findByPatient(String patient, String labelCode, String labelType);
    @Query("from WlyyPatientLabelDO w where  w.patient=?1 and w.labelType='2' and w.labelName in ('高血压','糖尿病')")
    List<WlyyPatientLabelDO> findByPatient2(String patient);
    @Query("from WlyyPatientLabelDO w where w.labelType='4' and w.labelName=?1 ")
    List<WlyyPatientLabelDO> findByPatientLablelName(String labelName);
}

+ 2 - 3
business/base-service/src/main/java/com/yihu/jw/patient/service/BasePatientService.java

@ -3,7 +3,6 @@ package com.yihu.jw.patient.service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.entity.base.im.ConsultDo;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.patient.PatientMedicareCardDO;
import com.yihu.jw.entity.hospital.prescription.WlyyInspectionDO;
@ -890,9 +889,9 @@ public class BasePatientService<T, R extends CrudRepository> extends BaseJpaServ
        String sql="SELECT DISTINCT a.*\n" +
                "FROM\n" +
                "	base_patient a \n" +
                "	INNER JOIN base_patient_doctor_relation b ON a.id=b.patient_id\n" +
                "	INNER JOIN wlyy_outpatient b ON a.id=b.patient\n" +
                "WHERE 1=1\n" +
                "AND a.disease_condition IN('1','2','3')\n" +
                "AND a.disease_condition IN('1','2','0')\n" +
                "AND a.disease IN ('1','2','1,2','2,1')\n" +
                "AND b.doctor_id ='"+doctorId+"'";
        List<BasePatientDO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(BasePatientDO.class));

+ 3 - 0
business/base-service/src/main/java/com/yihu/jw/sign/dao/WlyySignDao.java

@ -3,10 +3,13 @@ package com.yihu.jw.sign.dao;
import com.yihu.jw.entity.door.WlyySign;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
/**
 * Created by yeshijie on 2024/7/16.
 */
public interface WlyySignDao extends JpaRepository<WlyySign, Long>, JpaSpecificationExecutor<WlyySign> {
    @Query("from WlyySign a where a.idcard = ?1")
    WlyySign findByIdcard(String idcard);
}

+ 9 - 0
business/base-service/src/main/java/com/yihu/jw/wlyy/service/WlyyBusinessService.java

@ -1098,4 +1098,13 @@ public class WlyyBusinessService {
        JSONObject re = wlyyHttpService.sendWlyyMesGet("calendarPlanDetailBypatient_IJK", param);
        return re;
    }
    /**
     * 门诊病例
     */
    public JSONObject getOutpatientRecords_IJK(String planId, String idcard, String eventNo, String findType) {
        String param = "?planId=" + nullToTransfor(planId) + "&idcard=" + nullToTransfor(idcard) + "&eventNo=" + nullToTransfor(eventNo)+ "&findType=" + nullToTransfor(findType);
        JSONObject re = wlyyHttpService.sendWlyyMesGet("getOutpatientRecords_IJK", param);
        return re;
    }
}

Datei-Diff unterdrückt, da er zu groß ist
+ 1 - 12
business/base-service/src/main/java/com/yihu/jw/wlyy/wlyyhttp/WlyyHttpService.java


+ 77 - 9
common/common-entity/src/db/2024.sql

@ -213,14 +213,30 @@ INSERT INTO `base`.`oauth_wlyy_config` (`id`, `app_id`, `app_secret`, `token_url
INSERT INTO `base`.`oauth_wlyy_config` (`id`, `app_id`, `app_secret`, `token_url`, `url`, `remark`) VALUES ('uploadImg', '019bd04d-3cb2-433f-a530-03f0cdb083e5', '08cc3ec2-736b-4732-a8f0-f99eb6f9d311', 'https://www.xmtyw.cn/wlyytest/gc/accesstoken', 'https://www.xmtyw.cn/wlyytest/wlyygc/upload/file', '图片上传');
CREATE TABLE `wlyy_sign` (
    `id` int NOT NULL AUTO_INCREMENT,
    `idcard` varchar(50) DEFAULT NULL,
    `admin_team_id` int DEFAULT NULL,
    `create_time` datetime DEFAULT NULL,
    PRIMARY KEY (`id`),
    KEY `index1` (`idcard`),
    KEY `index2` (`admin_team_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8mb4 ;
   `id` int NOT NULL AUTO_INCREMENT,
   `idcard` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '身份证',
   `admin_team_id` int DEFAULT NULL COMMENT '签约团队',
   `name` varchar(50) DEFAULT NULL COMMENT '姓名',
   `address` varchar(50) DEFAULT NULL COMMENT '地址',
   `hospital_name` varchar(50) DEFAULT NULL COMMENT '签约社区',
   `doctor_name` varchar(50) DEFAULT NULL COMMENT '全科医生',
   `health_doctor_name` varchar(50) DEFAULT NULL COMMENT '健管师',
   `begin` varchar(10) DEFAULT NULL COMMENT '签约开始时间',
   `end` varchar(10) DEFAULT NULL COMMENT '签约结束时间',
   `sign_year` varchar(1) DEFAULT NULL COMMENT '签约年限',
   `status` varchar(4) DEFAULT NULL COMMENT '状态',
   `sign_source` varchar(1) DEFAULT NULL COMMENT '签约类型',
   `disease_condition` varchar(5) DEFAULT NULL COMMENT '病情',
   `sys_time` varchar(30) DEFAULT NULL COMMENT '同步时间',
   `create_time` datetime DEFAULT NULL COMMENT '创建时间',
   PRIMARY KEY (`id`),
   KEY `index2` (`admin_team_id`),
   KEY `index3` (`sys_time`),
   KEY `index4` (`hospital_name`,`doctor_name`,`health_doctor_name`),
   KEY `index1` (`patient`,`idcard`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
CREATE TABLE `wlyy_patient_aim_blood_pressure` (
      `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'id主键,与业务逻辑无关',
@ -249,4 +265,56 @@ CREATE TABLE `wlyy_patient_aim_blood_sugger` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='患者-血糖目标';
INSERT INTO `wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`,
  `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES
('ijk_sign_source1', NULL, 'ijk_sign_source', '1', '线下', NULL, '1', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '签约类型');
INSERT INTO `wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`,
                                      `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES
  ('ijk_sign_source2', NULL, 'ijk_sign_source', '2', '线上', NULL, '2', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '签约类型');
INSERT INTO `wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`,
                                      `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES
    ('ijk_sign_status1', NULL, 'ijk_sign_status', '-1', '患者已取消', NULL, '1', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '签约状态');
INSERT INTO `wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`,
                                      `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES
    ('ijk_sign_status2', NULL, 'ijk_sign_status', '-2', '已拒绝', NULL, '2', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '签约状态');
INSERT INTO `wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`,
                                      `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES
    ('ijk_sign_status3', NULL, 'ijk_sign_status', '-3', '已解约', NULL, '3', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '签约状态');
INSERT INTO `wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`,
                                      `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES
    ('ijk_sign_status4', NULL, 'ijk_sign_status', '-4', '已到期', NULL, '4', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '签约状态');
INSERT INTO `wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`,
                                      `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES
    ('ijk_sign_status5', NULL, 'ijk_sign_status', '0', '待签约', NULL, '5', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '签约状态');
INSERT INTO `wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`,
                                      `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES
    ('ijk_sign_status6', NULL, 'ijk_sign_status', '1', '已签约', NULL, '6', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '签约状态');
INSERT INTO `wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`,
                                      `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES
    ('ijk_sign_status7', NULL, 'ijk_sign_status', '2', '患者申请取消签约', NULL, '7', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '签约状态');
INSERT INTO `wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`,
                                      `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES
    ('ijk_sign_status8', NULL, 'ijk_sign_status', '3', '医生申请取消签约', NULL, '8', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '签约状态');
INSERT INTO `wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`,
                                      `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES
    ('synChronicDiseaseSign', NULL, 'syn_date', '同步时间', '2024-07-24', NULL, '1', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '同步慢病签约信息时间');
SELECT s.name,s.idcard,s.ssc,s.mobile,s.hospital_name,s.doctor_name,s.doctor_health_name,s.`begin`,s.`end`,s.sign_source
     ,s.sign_year,s.`status`,s.year_num,p.address,p.sex,p.birthday
     ,GROUP_CONCAT(l2.label_name) health,GROUP_CONCAT(l.label_name) disease
from wlyy_sign_family s
         INNER JOIN dm_hospital h on s.hospital=h.code and h.town='350212'
         INNER JOIN wlyy_patient p on p.code=s.patient
         INNER JOIN wlyy_sign_patient_label_info l on s.patient=l.patient and l.`status`=1 and l.label_type='3'
         LEFT  JOIN wlyy_sign_patient_label_info l2 on s.patient=l.patient and l2.`status`=1 and l2.label_type='2'
WHERE s.`status`>0  GROUP BY s.patient ;
SELECT s.name,s.idcard,s.ssc,s.mobile,s.hospital_name,s.doctor_name,s.doctor_health_name,s.`begin`,s.`end`,s.sign_source
     ,s.sign_year,s.`status`,s.year_num,p.address,p.sex,p.birthday
from wlyy_sign_family s
         INNER JOIN dm_hospital h on s.hospital=h.code and h.town='350212'
         INNER JOIN wlyy_patient p on p.code=s.patient
WHERE s.`status`>0  ;

+ 1 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/base/patient/BasePatientDO.java

@ -301,7 +301,7 @@ public class BasePatientDO extends UuidIdentityEntityWithOperator {
    private String homeLatLon;//家庭经纬度
    private Integer homeState;//居家状态 1居家0离家;
    private String verifyCode;//眼科token
    private String verifyCode;//眼科token---//默认就诊人的居民code
    private String disease ;//'疾病类型,0健康,1高血压,2糖尿病,3高血压+糖尿病',

+ 0 - 53
common/common-entity/src/main/java/com/yihu/jw/entity/base/patient/PatientDoctorRelationEntity.java

@ -1,53 +0,0 @@
package com.yihu.jw.entity.base.patient;
import com.yihu.jw.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * @author suqinyi
 * @Date 2024/3/5
 */
@Entity
@Table(name = "base_patient_doctor_relation")
public class PatientDoctorRelationEntity extends IdEntity {
    private String patientId;  //患者id
    private String doctorId; // 医生id
    private String sourceType;//来源类型,1线上就诊 , 2i健康签约
    private Date createTime;//创建时间
    public String getPatientId() {
        return patientId;
    }
    public void setPatientId(String patientId) {
        this.patientId = patientId;
    }
    public String getDoctorId() {
        return doctorId;
    }
    public void setDoctorId(String doctorId) {
        this.doctorId = doctorId;
    }
    public String getSourceType() {
        return sourceType;
    }
    public void setSourceType(String sourceType) {
        this.sourceType = sourceType;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

+ 253 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/door/WlyySign.java

@ -5,6 +5,7 @@ import com.yihu.jw.entity.IdEntityWithCreateTime;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
/**
 * i健康同安签约居民
@ -14,8 +15,37 @@ import javax.persistence.Table;
@Table(name = "wlyy_sign")
public class WlyySign extends IdEntityWithCreateTime {
    private String patient;
    private String idcard;
    private String mobile;//手机号
    private String ssc;//社保卡
    private String sex;//性别
    private String birthday;//初生日期
    private String yearNum;//签约年限
    private String healthIjk;//i健康健康情况
    private String diseaseIjk;//i健康疾病类型
    private Integer isNcd;//是否慢病 1是0否
    private String adminTeamId;
    private String name;//姓名
    private String address;//地址
    private String hospitalName;//签约社区
    private String doctorName;//全科医生
    private String healthDoctorName;//健管师
    private String begin;//签约开始时间
    private String end;//签约结束时间
    private String signYear;//签约年度
    private String status;//状态
    private String signSource;//签约类型
    private String diseaseCondition;//病情
    private String sysTime;//同步时间
    //非数据库字段
    private String statusName;//状态名称
    private String signSourceName;//签约来源
    private String health;//健康情况
    private String disease;//疾病标签
    private String zbType;//专病类型
    private String zdyGroup;//自定义分组
    @Column(name = "idcard")
    public String getIdcard() {
@ -34,4 +64,227 @@ public class WlyySign extends IdEntityWithCreateTime {
    public void setAdminTeamId(String adminTeamId) {
        this.adminTeamId = adminTeamId;
    }
    @Column(name = "patient")
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    @Column(name = "name")
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    @Column(name = "address")
    public String getAddress() {
        return address;
    }
    public void setAddress(String address) {
        this.address = address;
    }
    @Column(name = "hospital_name")
    public String getHospitalName() {
        return hospitalName;
    }
    public void setHospitalName(String hospitalName) {
        this.hospitalName = hospitalName;
    }
    @Column(name = "doctor_name")
    public String getDoctorName() {
        return doctorName;
    }
    public void setDoctorName(String doctorName) {
        this.doctorName = doctorName;
    }
    @Column(name = "health_doctor_name")
    public String getHealthDoctorName() {
        return healthDoctorName;
    }
    public void setHealthDoctorName(String healthDoctorName) {
        this.healthDoctorName = healthDoctorName;
    }
    @Column(name = "begin")
    public String getBegin() {
        return begin;
    }
    public void setBegin(String begin) {
        this.begin = begin;
    }
    @Column(name = "end")
    public String getEnd() {
        return end;
    }
    public void setEnd(String end) {
        this.end = end;
    }
    @Column(name = "sign_year")
    public String getSignYear() {
        return signYear;
    }
    public void setSignYear(String signYear) {
        this.signYear = signYear;
    }
    @Column(name = "status")
    public String getStatus() {
        return status;
    }
    public void setStatus(String status) {
        this.status = status;
    }
    @Column(name = "sign_source")
    public String getSignSource() {
        return signSource;
    }
    public void setSignSource(String signSource) {
        this.signSource = signSource;
    }
    @Column(name = "disease_condition")
    public String getDiseaseCondition() {
        return diseaseCondition;
    }
    public void setDiseaseCondition(String diseaseCondition) {
        this.diseaseCondition = diseaseCondition;
    }
    @Column(name = "sys_time")
    public String getSysTime() {
        return sysTime;
    }
    public void setSysTime(String sysTime) {
        this.sysTime = sysTime;
    }
    @Column(name = "mobile")
    public String getMobile() {
        return mobile;
    }
    public void setMobile(String mobile) {
        this.mobile = mobile;
    }
    @Column(name = "ssc")
    public String getSsc() {
        return ssc;
    }
    public void setSsc(String ssc) {
        this.ssc = ssc;
    }
    @Column(name = "sex")
    public String getSex() {
        return sex;
    }
    public void setSex(String sex) {
        this.sex = sex;
    }
    @Column(name = "birthday")
    public String getBirthday() {
        return birthday;
    }
    public void setBirthday(String birthday) {
        this.birthday = birthday;
    }
    @Column(name = "year_num")
    public String getYearNum() {
        return yearNum;
    }
    public void setYearNum(String yearNum) {
        this.yearNum = yearNum;
    }
    @Column(name = "health_ijk")
    public String getHealthIjk() {
        return healthIjk;
    }
    public void setHealthIjk(String healthIjk) {
        this.healthIjk = healthIjk;
    }
    @Column(name = "disease_ijk")
    public String getDiseaseIjk() {
        return diseaseIjk;
    }
    public void setDiseaseIjk(String diseaseIjk) {
        this.diseaseIjk = diseaseIjk;
    }
    @Column(name = "is_ncd")
    public Integer getIsNcd() {
        return isNcd;
    }
    public void setIsNcd(Integer isNcd) {
        this.isNcd = isNcd;
    }
    @Transient
    public String getHealth() {
        return health;
    }
    public void setHealth(String health) {
        this.health = health;
    }
    @Transient
    public String getDisease() {
        return disease;
    }
    public void setDisease(String disease) {
        this.disease = disease;
    }
    @Transient
    public String getZbType() {
        return zbType;
    }
    public void setZbType(String zbType) {
        this.zbType = zbType;
    }
    @Transient
    public String getZdyGroup() {
        return zdyGroup;
    }
    public void setZdyGroup(String zdyGroup) {
        this.zdyGroup = zdyGroup;
    }
    @Transient
    public String getStatusName() {
        return statusName;
    }
    public void setStatusName(String statusName) {
        this.statusName = statusName;
    }
    @Transient
    public String getSignSourceName() {
        return signSourceName;
    }
    public void setSignSourceName(String signSourceName) {
        this.signSourceName = signSourceName;
    }
}

+ 0 - 212
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/conf/SystemConf.java

@ -1,212 +0,0 @@
package com.yihu.jw.restmodel.conf;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
@Component
public class SystemConf {
    // 别处登录
    public static final int LOGIN_OTHER = 999;
    // 登录超时
    public static final int LOGIN_TIMEOUT = 998;
    // 未登录
    public static final int NOT_LOGIN = 997;
    //未认证
    public static final int NOT_CERTIFIED = 996;
    //未修改默认密码
    public static final int NOT_UPD_PWD = 995;
    // 文件保存临时路径
    private static final String TEMP_PATH = "upload_temp_path";
    // 血糖餐前最小值
    public static final double HEALTH_STANDARD_ST_MIN_BEFORE = 4;
    // 血糖餐前最大值
    public static final double HEALTH_STANDARD_ST_MAX_BEFORE = 7;
    // 血糖餐后最小值
    public static final double HEALTH_STANDARD_ST_MIN_AFTER = 4;
    // 血糖餐后最大值
    public static final double HEALTH_STANDARD_ST_MAX_AFTER = 11.1;
    // 舒张压最小值
    public static final double HEALTH_STANDARD_SZY_MIN = 60;
    // 舒张压最大值
    public static final double HEALTH_STANDARD_SZY_MAX = 90;
    // 收缩压最小值
    public static final double HEALTH_STANDARD_SSY_MIN = 90;
    // 收缩压最大值
    public static final double HEALTH_STANDARD_SSY_MAX = 140;
    // 同一手机号大最短信数
    public static final int MAX_SMS_MOBILE = 5;
    // 发送短信验证码间隔(分钟)
    public static final int SMS_INTERVAL = 2;
    private static Object lock = new Object();
    // 全局系统配置信息
    private static SystemConf systemConf;
    // 系统配置文件
    private Properties systemProperties;
    //im列表
    private String imListGet;
    public static SystemConf getInstance() {
        if (systemConf == null) {
            synchronized (lock) {
                systemConf = new SystemConf();
            }
        }
        return systemConf;
    }
    /**
     * 加载系统配置文件
     *
     * @return
     */
    public Properties getSystemProperties() {
        if (systemProperties == null) {
            InputStream is = null;
            try {
                is = this.getClass().getResourceAsStream("/system.properties");
                systemProperties = new Properties();
                systemProperties.load(is);
            } catch (IOException e1) {
                e1.printStackTrace();
            } finally {
                if (is != null) {
                    try {
                        is.close();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }
        }
        return systemProperties;
    }
    /**
     * 短信接口地址
     */
    public String getSmsUrl() {
        return getSystemProperties().getProperty("yihu_sms_url");
    }
    /**
     * 短信企业编号
     */
    public String getSmsCode() {
        return getSystemProperties().getProperty("yihu_sms_code");
    }
    /**
     * 短信用户名
     */
    public String getSmsName() {
        return getSystemProperties().getProperty("yihu_sms_name");
    }
    /**
     * 短信登录密码
     */
    public String getSmsPassword() {
        return getSystemProperties().getProperty("yihu_sms_password");
    }
    ;
    /**
     * 挂号接口地址
     */
    public String getGuahaoUrl() {
        return getSystemProperties().getProperty("yihu_guahao_url");
    }
    /**
     * 挂号接口对接appid
     */
    public String getGuahaoAppid() {
        return getSystemProperties().getProperty("yihu_guahao_appid");
    }
    /**
     * 挂号接口对接app secret
     */
    public String getGuahaoSecret() {
        return getSystemProperties().getProperty("yihu_guahao_secret");
    }
    /**
     * 获取文件保存的临时路径
     *
     * @return
     */
    public String getTempPath() {
        return getSystemProperties().getProperty(TEMP_PATH);
    }
    /**
     * 获取图片存在地址
     *
     * @return
     */
    /**
     * 获取服务全路径
     *
     * @return
     */
    /******************************** 挂号配置 ********************************************/
    /**
     * 获取厦门预约服务地址
     */
    public String getXMGuahaoUrl() {
        return getSystemProperties().getProperty("guahao_url");
    }
    /**
     * 获取厦门预约服务命名空间
     */
    public String getXMGuahaoNamespace() {
        return getSystemProperties().getProperty("guahao_namespace");
    }
    /****************************************************************************************/
    /********************************* EHR配置 **********************************************/
    /**
     * 是否启用EHR演示
     */
    public Boolean getEhrUsed() {
        return Boolean.valueOf(getSystemProperties().getProperty("ehr_used"));
    }
    /**
     * EHR档案服务地址
     */
    public String getEhrServices() {
        return getSystemProperties().getProperty("ehr_services");
    }
    /**
     * EHR底层地址
     */
    public String getEhrServicesBase() {
        return getSystemProperties().getProperty("ehr_services_base");
    }
    /**************************************************************************************/
    /**************************************************************************************/
}

+ 15 - 0
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/hospital/WlyyFamilyMemberController.java

@ -729,6 +729,21 @@ public class WlyyFamilyMemberController extends EnvelopRestEndpoint {
        }
    }
    @PostMapping(value = "defaultPatient")
    @ApiOperation(value = "设置默认就诊人", notes = "设置默认就诊人")
    public Envelop defaultPatient(
            @ApiParam(name = "patient", value = "居民ID") @RequestParam(value = "patient", required = true) String patient,
            @ApiParam(name = "verifyCode", value = "默认就诊人的居民id") @RequestParam(value = "verifyCode", required = true) String verifyCode) {
        try {
            wlyyFamilyMemberService.defaultPatient(patient,verifyCode);
            return Envelop.getSuccess("设置成功");
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError("设置失败");
        }
    }
    @ApiOperation("删除就诊人")
    @PostMapping(value = BaseHospitalRequestMapping.WlyyFamilyMember.delFamilyMumber)
    public Envelop delFamilyMumber(@ApiParam(name = "id", value = "id", required = false)

+ 20 - 0
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/specialist/BaseDiseaseHospitalController.java

@ -542,6 +542,26 @@ public class BaseDiseaseHospitalController extends EnvelopRestEndpoint {
    }
    /**
     * 获取门诊病例数据
     */
    @RequestMapping(value = "getOutpatientRecords_IJK", method = RequestMethod.GET)
    @ApiOperation(value = "获取门诊病例数据")
    public Envelop getOutpatientRecords_IJK(
            @ApiParam(name = "planId", value = "康复计划id", required = false) @RequestParam(value = "planId", required = false) String planId,
            @ApiParam(name = "idcard", value = "身份证", required = false) @RequestParam(value = "idcard", required = false) String idcard,
            @ApiParam(name = "eventNo", value = "就诊号", required = false) @RequestParam(value = "eventNo", required = false) String eventNo,
            @ApiParam(name = "findType", value = "查1条传1 ,查全部传2", required = false) @RequestParam(value = "findType", required = false) String findType
    ) {
        try {
            JSONObject result = wlyyBusinessService.getOutpatientRecords_IJK(planId,idcard,eventNo,findType);
            return success(result);
        } catch (Exception e) {
            return failedException(e);
        }
    }
}

+ 3 - 3
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/service/consult/KnowledgeCategoryService.java

@ -91,12 +91,12 @@ public class KnowledgeCategoryService extends BaseJpaService<KnowledgeCategoryDO
    }
    public MixEnvelop findCategoryByIdOrName(String id, String name) {
        String sql = " select * from wlyy_knowledge_category where 1=1 ";
        String sql = " select b.* from wlyy_knowledge_category a INNER JOIN wlyy_knowledge_category b ON a.id=b.pid where 1=1 and a.del='1'  and b.del='1'  ";
        if (StringUtils.isNotBlank(id)) {
            sql += " and id='" + id + "'";
            sql += " and a.id='" + id + "'";
        }
        if (StringUtils.isNotBlank(name)) {
            sql += " and name='" + name + "'";
            sql += " and a.name='" + name + "'";
        }
        List<KnowledgeCategoryDO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(KnowledgeCategoryDO.class));
        MixEnvelop envelop = new MixEnvelop();

+ 8 - 14
svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/controller/doctor/DoctorRehabilitationManageController.java

@ -106,20 +106,14 @@ public class DoctorRehabilitationManageController extends EnvelopRestEndpoint {
    @RequestMapping(value = RehabilitationRequestMapping.DoctorRehabilitationManage.calendarPlanDetail, method = RequestMethod.GET)
    @ApiOperation("康复管理-康复计划按日历展示")
    public ObjEnvelop calendarPlanDetail(@ApiParam(name = "executeStartTime", value = "日历开始时间(格式:yyyy-MM-dd HH:mm:ss)")
                                     @RequestParam(value = "executeStartTime", required = false)String executeStartTime,
                                     @ApiParam(name = "executeEndTime", value = "日历结束时间(格式:yyyy-MM-dd HH:mm:ss)")
                                     @RequestParam(value = "executeEndTime", required = false)String executeEndTime,
                                     @ApiParam(name = "planId", value = "计划id", required = true)
                                     @RequestParam(value = "planId")String planId,
                                     @ApiParam(name = "searchTask", value = "快速查找任务:(1、我的任务,2、健康教育,3、健康指导,4、随访,5、复诊)", required = false)
                                     @RequestParam(value = "searchTask", required = false)Integer searchTask,
                                     @ApiParam(name = "doctorCode", value = "医生code(专科医生、家庭医生)", required = false)
                                     @RequestParam(value = "doctorCode", required = false)String doctorCode,
                                         @ApiParam(name = "taskExecutor", value = "1是本人任务", required = false)
                                             @RequestParam(value = "taskExecutor", required = false)String taskExecutor,
                                     @ApiParam(name = "status", value = "任务状态(0未完成,1已完成,2已预约)", required = false)
                                     @RequestParam(value = "status", required = false)Integer status){
    public ObjEnvelop calendarPlanDetail(
            @ApiParam(name = "executeStartTime", value = "日历开始时间(格式:yyyy-MM-dd HH:mm:ss)") @RequestParam(value = "executeStartTime", required = false)String executeStartTime,
            @ApiParam(name = "executeEndTime", value = "日历结束时间(格式:yyyy-MM-dd HH:mm:ss)") @RequestParam(value = "executeEndTime", required = false)String executeEndTime,
            @ApiParam(name = "planId", value = "计划id", required = true) @RequestParam(value = "planId")String planId,
            @ApiParam(name = "searchTask", value = "快速查找任务:(1、我的任务,2、健康教育,3、健康指导,4、随访,5、复诊)", required = false) @RequestParam(value = "searchTask", required = false)Integer searchTask,
            @ApiParam(name = "doctorCode", value = "医生code(专科医生、家庭医生)", required = false) @RequestParam(value = "doctorCode", required = false)String doctorCode,
            @ApiParam(name = "taskExecutor", value = "1是本人任务", required = false) @RequestParam(value = "taskExecutor", required = false)String taskExecutor,
            @ApiParam(name = "status", value = "任务状态(0未完成,1已完成,2已预约)", required = false) @RequestParam(value = "status", required = false)Integer status){
        try {
            if(!StringUtils.isNotEmpty(doctorCode)){
                doctorCode = getUID();

+ 2 - 2
svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/controller/patient/PatientRehabilitationManageController.java

@ -155,11 +155,11 @@ public class PatientRehabilitationManageController extends EnvelopRestEndpoint {
        try {
            JSONObject json = new JSONObject(dataJson);
            if(json.has("patientCode")){
                BasePatientDO patient = basePatientDao.findById(json.get("patientCode")+"");
                BasePatientDO patient = basePatientDao.findById(json.get("patientCode")+"").orElse(null);
                json.put("patientName",patient!=null?patient.getName():"");
            }
            if(json.has("doctorCode")){
                BaseDoctorDO doctor = baseDoctorDao.findById(json.get("doctorCode")+"");
                BaseDoctorDO doctor = baseDoctorDao.findById(json.get("doctorCode")+"").orElse(null);
                json.put("doctorName",doctor!=null?doctor.getName():"");
            }
            RehabilitationOperateRecordsDO rehabilitationOperateRecordsDO= toEntity(json.toString(), RehabilitationOperateRecordsDO.class);

+ 48 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/common/LabelController.java

@ -28,6 +28,54 @@ public class LabelController extends EnvelopRestEndpoint {
    @Autowired
    private LabelService labelService;
    @GetMapping(value = "synSign")
    @ApiOperation(value = "同步签约信息")
    public Envelop synSign(@ApiParam(name = "idcards", value = "身份证多个逗号间隔")
                              @RequestParam(value = "idcards", required = true) String idcards) {
        try {
            labelService.synSign(idcards);
            return Envelop.getSuccess("同步成功");
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError("同步失败");
        }
    }
    @GetMapping(value = "signPage")
    @ApiOperation(value = "慢病管理", notes = "慢病管理")
    public Envelop signPage(@ApiParam(name = "page", value = "第几页")
                             @RequestParam(value = "page", required = true) Integer page,
                             @ApiParam(name = "size", value = "每页大小")
                             @RequestParam(value = "size", required = true) Integer size,
                            @ApiParam(name = "name", value = "居民姓名")
                                @RequestParam(value = "name", required = false) String name,
                            @ApiParam(name = "idcard", value = "身份证")
                                @RequestParam(value = "idcard", required = false) String idcard,
                            @ApiParam(name = "address", value = "地址")
                                @RequestParam(value = "address", required = false) String address,
                            @ApiParam(name = "hospitalName", value = "签约社区")
                                @RequestParam(value = "hospitalName", required = false) String hospitalName,
                            @ApiParam(name = "doctorName", value = "签约医生")
                                @RequestParam(value = "doctorName", required = false) String doctorName,
                            @ApiParam(name = "health", value = "健康情况")
                                @RequestParam(value = "health", required = false) String health,
                            @ApiParam(name = "disease", value = "疾病类型")
                                @RequestParam(value = "disease", required = false) String disease,
                            @ApiParam(name = "zbType", value = "专病类型")
                                @RequestParam(value = "zbType", required = false) String zbType,
                            @ApiParam(name = "zdyGroup", value = "自定义分组")
                                @RequestParam(value = "zdyGroup", required = false) String zdyGroup,
                            @ApiParam(name = "diseaseCondition", value = "病情")
                                @RequestParam(value = "diseaseCondition", required = false) String diseaseCondition) {
        try {
            return labelService.signPage(page, size, name, idcard, address, hospitalName, doctorName, health, disease,
                    zbType, zdyGroup, diseaseCondition);
        } catch (Exception e) {
            return failedException(e);
        }
    }
    @GetMapping(value = "patientLabelLogPage")
    @ApiOperation(value = "查询标签新增日志", notes = "查询标签新增日志")
    public Envelop patientLabelLogPage(@ApiParam(name = "patient", value = "居民id")

+ 25 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/common/StatisticsController.java

@ -8,12 +8,14 @@ import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.OutputStream;
import java.util.List;
@ -32,6 +34,29 @@ public class StatisticsController extends EnvelopRestEndpoint {
    @Autowired
    private ExportUtl exportUtl;
    @ApiOperation(value = "服务情况明细")
    @GetMapping(value = "serviceSituationDetail")
    public ObjEnvelop serviceSituationDetail(
            @ApiParam(name = "startDate", value = "开始时间", required = false) @RequestParam(required = false) String startDate,
            @ApiParam(name = "endDate", value = "结束时间", required = false) @RequestParam(required = false) String endDate,
            HttpServletRequest request
    ) {
        try {
            if (org.apache.commons.lang.StringUtils.isBlank(startDate)) {
                return ObjEnvelop.getError("请选择开始时间");
            }
            if ("2023-01-01".compareTo(startDate) > 0) {
                return ObjEnvelop.getError("开始时间不能早于2023-01-01");
            }
            return ObjEnvelop.getSuccess("查询成功", statisticsService.serviceSituationDetail(request));
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError("查询失败");
        }
    }
    @GetMapping(value = "uploadAnalysis")
    @ApiOperation(value = "设备上传次数趋势")
    public ObjEnvelop uploadAnalysis(@RequestParam(required = false) String startDate,

+ 142 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/common/service/LabelService.java

@ -1,16 +1,26 @@
package com.yihu.jw.hospital.module.common.service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.label.WlyyPatientLabelDO;
import com.yihu.jw.entity.care.label.WlyyPatientLabelLogDO;
import com.yihu.jw.entity.door.WlyySign;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.label.WlyyPatientLabelDao;
import com.yihu.jw.label.WlyyPatientLabelLogDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.sign.dao.WlyySignDao;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.entity.ServiceException;
import com.yihu.jw.wlyy.wlyyhttp.WlyyHttpService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
@ -25,16 +35,126 @@ import java.util.*;
@Service
public class LabelService {
    private static final Logger logger = LoggerFactory.getLogger(LabelService.class);
    @Autowired
    private WlyyHospitalSysDictDao wlyyHospitalSysDictDao;
    @Autowired
    private WlyyPatientLabelDao patientLabelDao;
    @Autowired
    private BasePatientDao patientDao;
    @Autowired
    private WlyyPatientLabelLogDao logDao;
    @Autowired
    private BaseDoctorDao doctorDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private WlyyHttpService wlyyHttpService;
    @Autowired
    private WlyySignDao wlyySignDao;
    //同步签约信息
    public void synSign(String idcards){
        try {
            String configId = "commonGet";
            String param = "?type=2&idcards="+idcards;
            JSONObject re = wlyyHttpService.sendWlyyMesGet(configId, "findSignAll" + param);
            if(re!=null&&re.getInteger("status")==200){
                String idcardTmp = idcards.replaceAll(",","','");
                String sql = "select * from wlyy_sign where idcard in ('"+idcardTmp+"')";
                List<WlyySign> list = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(WlyySign.class));
                JSONArray jsonArray = re.getJSONArray("data");
                if(jsonArray.size()>0){
                    for (WlyySign sign:list){
                        sign.setStatus("-4");
                        sign.setSysTime(DateUtil.getStringDate());
                        for (int i=0;i<jsonArray.size();i++){
                            JSONObject json = jsonArray.getJSONObject(i);
                            String idcard = json.getString("idcard");
                            if(sign.getIdcard().equals(idcard)){
                                sign.setStatus(json.getString("status"));
                                sign.setYearNum(json.getString("year_num"));
                                sign.setHospitalName(json.getString("hospital_name"));
                                sign.setDoctorName(json.getString("doctor_name"));
                                sign.setHealthDoctorName(json.getString("doctor_health_name"));
                                sign.setBegin(json.getString("begin"));
                                sign.setEnd(json.getString("end"));
                                sign.setSignYear(json.getString("sign_year"));
                                sign.setSignSource(json.getString("sign_source"));
                                sign.setDiseaseCondition(json.getString("disease_condition"));
                                sign.setAdminTeamId(json.getString("admin_team_id"));
                                jsonArray.remove(i);
                                break;
                            }
                        }
                    }
                }else {
                    for (WlyySign sign:list){
                        sign.setStatus("-4");
                        sign.setSysTime(DateUtil.getStringDate());
                    }
                }
                wlyySignDao.saveAll(list);
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }
    /**
     * 慢病管理
     */
    public PageEnvelop signPage(Integer page,Integer size,String name,String idcard,String address,String hospitalName,String doctorName
            ,String health,String disease,String zbType,String zdyGroup,String diseaseCondition){
        String sql = "select distinct a.*,GROUP_CONCAT(if(l.label_type='1',l.label_name,null)) health " +
                ",GROUP_CONCAT(if(l.label_type='2',l.label_name,null)) disease " +
                ",GROUP_CONCAT(if(l.label_type='3',l.label_name,null)) zhType " +
                ",GROUP_CONCAT(if(l.label_type='4',l.label_name,null)) zdyGroup,d1.dict_value signSourceName,d2.dict_value statusName ";
        String countSql = "select count(distinct a.id)";
        String filter = " from wlyy_sign a inner join base_patient p on a.patient=p.id " +
                " left join wlyy_patient_label l on l.patient = p.id "+
                " left join wlyy_hospital_sys_dict d1 on d1.dict_name='ijk_sign_source' and d1.dict_code = a.sign_source "+
                " left join wlyy_hospital_sys_dict d2 on d2.dict_name='ijk_sign_status' and d2.dict_code = a.status " +
                " where a.is_ncd=1 ";
        String orderBy = " limit "+(page-1)*size+","+size;
        if(StringUtils.isNotBlank(name)){
            filter += " and a.name like '%"+name+"%' ";
        }
        if(StringUtils.isNotBlank(idcard)){
            filter += " and a.idcard like '%"+idcard+"%' ";
        }
        if(StringUtils.isNotBlank(address)){
            filter += " and a.address like '%"+address+"%' ";
        }
        if(StringUtils.isNotBlank(hospitalName)){
            filter += " and a.hospital_name like '%"+hospitalName+"%' ";
        }
        if(StringUtils.isNotBlank(doctorName)){
            filter += " and a.doctor_name like '%"+doctorName+"%' ";
        }
        if(StringUtils.isNotBlank(diseaseCondition)){
            filter += " and a.diseaseCondition = '"+diseaseCondition+"' ";
        }
        //1健康情况 2疾病类型 3专病类型 4自定义标签
        if(StringUtils.isNotBlank(health)){
            filter += " and l.label_type='1' and l.label_name = '"+health+"' ";
        }
        if(StringUtils.isNotBlank(disease)){
            filter += " and l.label_type='2' and l.label_name = '"+disease+"' ";
        }
        if(StringUtils.isNotBlank(zbType)){
            filter += " and l.label_type='3' and l.label_name = '"+zbType+"' ";
        }
        if(StringUtils.isNotBlank(zdyGroup)){
            filter += " and l.label_type='4' and l.label_name = '"+zdyGroup+"' ";
        }
        List<WlyySign> list = jdbcTemplate.query(sql+filter+" GROUP BY a.id "+orderBy,new BeanPropertyRowMapper<>(WlyySign.class));
        long count = jdbcTemplate.queryForObject(countSql+filter,Long.class);
        return PageEnvelop.getSuccessListWithPage("查询成功",list,page,size,count);
    }
    public List<WlyyPatientLabelDO> findByPatient(String patient) {
        return patientLabelDao.findByPatient(patient);
@ -123,6 +243,28 @@ public class LabelService {
                logDao.saveAll(labelLogDOS);
            }
        }
        //更新居民慢病标签
        List<WlyyPatientLabelDO> labelDOS1 = patientLabelDao.findByPatient2(patient);
        BasePatientDO patientDO = patientDao.findByIdAndDel(patient,"1");
        if(labelDOS1.size()==0){
            patientDO.setDisease("0");
        }else {
            //1高血压,2糖尿病
            int gxy = 0;
            int tnb = 0;
            for (WlyyPatientLabelDO labelDO:labelDOS1){
                if("高血压".equals(labelDO.getLabelName())){
                    gxy = 1;
                }
                if("糖尿病".equals(labelDO.getLabelName())){
                    tnb = 2;
                }
            }
            int disease = gxy+tnb;
            patientDO.setDisease(disease+"");
        }
        patientDao.save(patientDO);
    }
    //添加自定义标签字典

+ 199 - 2
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/common/service/StatisticsService.java

@ -1,14 +1,17 @@
package com.yihu.jw.hospital.module.common.service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.wlyy.service.WlyyBusinessService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
import java.text.DecimalFormat;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
 * Created by yeshijie on 2024/6/3.
@ -17,6 +20,200 @@ import java.util.Map;
public class StatisticsService {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private WlyyBusinessService wlyyBusinessService;
    /**
     * 医共体分析-头部
     * 1、【新签约人数】= 查询时间范围内,同安区新签约、续签的家签患者人数; i健康
     * 2、【签约患者数】= 时间范围内,同安区的家签患者总数; i健康
     * 3、【共管患者数】 = 时间范围内,签约三院专科团队的家签患者数+与三院医生产生业务交集的家签患者数;【共同管率】 = 共管患者数/签约患者数 X 100%;
     * 4、【家签门诊数】= 时间范围内,同安区的家签居民通过i健康进行预约线下门诊的次数; i健康
     * 5、【本院门诊数】= 时间范围内,同安区的家签居民通过i健康预约本院就诊的次数; i健康
     * 6、【外院门诊数】= 时间范围内,同安区的家签居民通过i健康预约其他医院就诊的次数;i健康
     * 7、【康复下转数】= 时间范围内,三院产生的康复下转总次数;
     * 8、【本院管理数】= 时间范围内,三院产生的康复下转中属于本院管理的次数;
     * 9、【社区管理数】= 时间范围内,三院产生的康复下转中属于社区管理的次数;
     * 10、【在线问诊数】= 时间范围内,三院完成的图文咨询、图文复诊、视频咨询、视频复诊、社区协诊总次数;
     * 11、【家签问诊数】= 时间范围内,同安区的家签居民在三院进行图文咨询、图文复诊、视频咨询、视频复诊、社区协诊的次数;
     * 12、【普患问诊数】= 时间范围内,普通患者三院进行图文咨询、图文复诊、视频咨询、视频复诊、社区协诊的次数;
     */
    public void medicalCommunityTop(String startDate,String endDate){
        String sql3 = "SELECT COUNT(DISTINCT s.id) from base_team_relation r,wlyy_sign s WHERE  r.admin_team_id=s.admin_team_id and s.status>0 ";
        String sql7 = "select count(s.id) from wlyy_sign_family s,dm_hospital h " +
                " where s.status>0 and s.hospital=h.`code` and h.town='350212'";
        String sql8 = "select count(s.id) from wlyy_sign_family s,dm_hospital h,wlyy_patient_reservation r " +
                "  where s.status>0 and s.hospital=h.`code` and h.town='350212' and r.patient=s.patient and r.czrq>s.czrq";
        String sql10 = "select count(s.id) from wlyy_sign_family s,dm_hospital h,wlyy_patient_reservation r " +
                "      where s.status>0 and s.hospital=h.`code` and h.town='350212' and r.patient=s.patient " +
                " and r.czrq>s.czrq and r.org_code='350211A1004' ";
        if(StringUtils.isNotBlank(startDate)){
            sql3 += " and s.czrq>'"+startDate+"' ";
        }
        if(StringUtils.isNotBlank(endDate)){
            sql3 += " and s.czrq<='"+endDate+" 23:59:59' ";
        }
    }
    //服务情况明细
    public List<Map<String,Object>> serviceSituationDetail(HttpServletRequest request){
        String sql = "SELECT DISTINCT d.idcard,d.name,h.dept_code dept,h.dept_name deptName,0 collaborateNum,0 inviteNum" +
                ",0 replyNum,0 turnUpNum,0 turnDownNum  from base_doctor_hospital h,base_doctor d " +
                "WHERE h.del='1' and d.del='1' and h.doctor_code=d.id and d.idcard is not null and h.dept_name is not null order by h.dept_name";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        JSONObject jsonObject = wlyyBusinessService.commonGet(request,"serviceSituationDetail");
        JSONArray jsonArray = null;
        int collaborateNumTotal = 0;
        int inviteNumTotal = 0;
        int replyNumTotal = 0;
        int turnUpNumTotal = 0;
        int turnDownNumTotal = 0;
        List<Map<String,Object>> listTmp = new ArrayList<>();
        Map<String, List<Map<String,Object>>> deptMap = new HashMap<>();
        if(jsonObject!=null&&jsonObject.getInteger("status")==200){
            jsonArray = jsonObject.getJSONArray("list");
            for (Map<String,Object> map:list){
                String idcard1 = map.get("idcard")+"";
                for (int i=0;i<jsonArray.size();i++){
                    JSONObject json = jsonArray.getJSONObject(i);
                    String idcard = json.getString("code");
                    int collaborateNum = json.getInteger("collaborateNum");
                    int inviteNum = json.getInteger("inviteNum");
                    int replyNum = json.getInteger("replyNum");
                    int turnUpNum = json.getInteger("turnUpNum");
                    int turnDownNum = json.getInteger("turnDownNum");
                    int total = collaborateNum + inviteNum + replyNum + turnUpNum + turnDownNum;
                    if(total==0){
                        jsonArray.remove(i);
                        break;
                    }
                    collaborateNumTotal += collaborateNum;
                    inviteNumTotal += inviteNum;
                    replyNumTotal += replyNum;
                    turnUpNumTotal += turnUpNum;
                    turnDownNumTotal += turnDownNum;
                    if(idcard1.equals(idcard)){
                        String dept = map.get("dept")+"";
                        map.put("collaborateNum",collaborateNum);
                        map.put("inviteNum",inviteNum);
                        map.put("replyNum",replyNum);
                        map.put("turnUpNum",turnUpNum);
                        map.put("turnDownNum",turnDownNum);
                        map.put("replyRate",getRange(replyNum, inviteNum));
                        listTmp.add(map);
                        jsonArray.remove(i);
                        break;
                    }
                }
            }
        }
        Map<String,Object> totalMap = new HashMap<>();
        totalMap.put("code","");
        totalMap.put("name","合计");
        totalMap.put("collaborateNum",collaborateNumTotal);
        totalMap.put("inviteNum",inviteNumTotal);
        totalMap.put("replyNum",replyNumTotal);
        totalMap.put("turnUpNum",turnUpNumTotal);
        totalMap.put("turnDownNum",turnDownNumTotal);
        totalMap.put("replyRate",getRange(replyNumTotal, inviteNumTotal));
        totalMap.put("list",new ArrayList<>());
        List<Map<String,Object>> result = new ArrayList<>();
        result.add(totalMap);
        Map<String, List<Map<String,Object>>> resList = listTmp.stream().collect(Collectors.groupingBy(e -> e.get("deptName").toString()));
        for (Map.Entry<String, List<Map<String,Object>>> entry:resList.entrySet()){
            String key = entry.getKey();
            int collaborateNumDept = 0;
            int inviteNumDept = 0;
            int replyNumDept = 0;
            int turnUpNumDept = 0;
            int turnDownNumDept = 0;
            Map<String,Object> deptTmp = new HashMap<>();
            List<Map<String,Object>> value = entry.getValue();
            String dept = "";
            for (Map<String,Object> map:value){
                dept = map.get("dept")+"";
                int collaborateNum = Integer.parseInt(map.get("collaborateNum")+"");
                int inviteNum = Integer.parseInt(map.get("inviteNum")+"");
                int replyNum = Integer.parseInt(map.get("replyNum")+"");
                int turnUpNum = Integer.parseInt(map.get("turnUpNum")+"");
                int turnDownNum = Integer.parseInt(map.get("turnDownNum")+"");
                collaborateNumDept += collaborateNum;
                inviteNumDept += inviteNum;
                replyNumDept += replyNum;
                turnUpNumDept += turnUpNum;
                turnDownNumDept += turnDownNum;
            }
            deptTmp.put("code",dept);
            deptTmp.put("name",key);
            deptTmp.put("collaborateNum",collaborateNumDept);
            deptTmp.put("inviteNum",inviteNumDept);
            deptTmp.put("replyNum",replyNumDept);
            deptTmp.put("turnUpNum",turnUpNumDept);
            deptTmp.put("turnDownNum",turnDownNumDept);
            deptTmp.put("replyRate",getRange(replyNumDept, inviteNumDept));
            value.sort(Comparator.comparingInt(a->Integer.parseInt(a.get("replyNum")+"")));
            deptTmp.put("list",value);
            result.add(deptTmp);
        }
        List<Map<String,Object>> other = new ArrayList<>();
        if(jsonArray!=null&&jsonArray.size()>0){
            int collaborateNumOther = 0;
            int inviteNumOther = 0;
            int replyNumOther = 0;
            int turnUpNumOther = 0;
            int turnDownNumOther = 0;
            for (int i=0;i<jsonArray.size();i++){
                Map<String,Object> map = new HashMap<>();
                JSONObject json = jsonArray.getJSONObject(i);
                String idcard = json.getString("code");
                String name = json.getString("name");
                int collaborateNum = json.getInteger("collaborateNum");
                int inviteNum = json.getInteger("inviteNum");
                int replyNum = json.getInteger("replyNum");
                int turnUpNum = json.getInteger("turnUpNum");
                int turnDownNum = json.getInteger("turnDownNum");
                map.put("code",idcard);
                map.put("name",name);
                map.put("collaborateNum",collaborateNum);
                map.put("inviteNum",inviteNum);
                map.put("replyNum",replyNum);
                map.put("turnUpNum",turnUpNum);
                map.put("turnDownNum",turnDownNum);
                map.put("replyRate",getRange(replyNum, inviteNum));
                other.add(map);
                collaborateNumOther += collaborateNum;
                inviteNumOther += inviteNum;
                replyNumOther += replyNum;
                turnUpNumOther += turnUpNum;
                turnDownNumOther += turnDownNum;
            }
            Map<String,Object> otherMap = new HashMap<>();
            otherMap.put("code","-");
            otherMap.put("name","其他");
            otherMap.put("collaborateNum",collaborateNumOther);
            otherMap.put("inviteNum",inviteNumOther);
            otherMap.put("replyNum",replyNumOther);
            otherMap.put("turnUpNum",turnUpNumOther);
            otherMap.put("turnDownNum",turnDownNumOther);
            otherMap.put("replyRate",getRange(replyNumOther, inviteNumOther));
            other.sort(Comparator.comparingInt(a->Integer.parseInt(a.get("replyNum")+"")));
            otherMap.put("list",other);
            result.add(otherMap);
        }
        return result;
    }
    /**
     * 设备上传次数趋势

+ 21 - 36
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/followup/controller/DoctorFollowUpController.java

@ -447,24 +447,17 @@ public class DoctorFollowUpController extends BaseController {
    @RequestMapping(value = "/findFollowupByMonth",produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ApiOperation("获取访视计划按月日历形式")
    public String findFollowupByMonth(@ApiParam(name = "doctor", value = "医生", defaultValue = "zjm20190214")
                                          @RequestParam(value = "doctor", required = true) String doctor,
                                      @ApiParam(name = "patient", value = "居民")
                                          @RequestParam(value = "patient", required = false) String patient,
                                      @ApiParam(name = "followupClass", value = "随访类别,多类别“,”分割")
                                          @RequestParam(value = "followupClass", required = false) String followupClass,
                                      @ApiParam(name = "patientName", value = "居民姓名")
                                          @RequestParam(value = "patientName", required = false) String patientName,
                                      @ApiParam(value = "开始时间,格式(yyyy-MM-dd)", name = "startDate",required = false)
                                          @RequestParam(value = "startDate", required = false) String startDate,
                                      @ApiParam(value = "结束时间,格式(yyyy-MM-dd)", name = "endDate",required = false)
                                          @RequestParam(value = "endDate", required = false) String endDate,
                                      @ApiParam(name = "flag", value = "区分上门访视(1-是)")
                                          @RequestParam(value = "flag", required = false) String flag,
                                      @ApiParam(name = "type", value = "区分随访计划1、新增随访2、临时随访3、入户随访")
                                          @RequestParam(value = "type", required = false) Integer type,
                                      @ApiParam(name = "status", value = "随访状态")
                                          @RequestParam(value = "status", required = false) String status){
    public String findFollowupByMonth(
            @ApiParam(name = "doctor", value = "医生", defaultValue = "zjm20190214") @RequestParam(value = "doctor", required = true) String doctor,
            @ApiParam(name = "patient", value = "居民") @RequestParam(value = "patient", required = false) String patient,
            @ApiParam(name = "followupClass", value = "随访类别,多类别“,”分割") @RequestParam(value = "followupClass", required = false) String followupClass,
            @ApiParam(name = "patientName", value = "居民姓名") @RequestParam(value = "patientName", required = false) String patientName,
            @ApiParam(value = "开始时间,格式(yyyy-MM-dd)", name = "startDate",required = false) @RequestParam(value = "startDate", required = false) String startDate,
            @ApiParam(value = "结束时间,格式(yyyy-MM-dd)", name = "endDate",required = false) @RequestParam(value = "endDate", required = false) String endDate,
            @ApiParam(name = "flag", value = "区分上门访视(1-是)") @RequestParam(value = "flag", required = false) String flag,
            @ApiParam(name = "type", value = "区分随访计划1、新增随访2、临时随访3、入户随访") @RequestParam(value = "type", required = false) Integer type,
            @ApiParam(name = "status", value = "随访状态") @RequestParam(value = "status", required = false) String status
    ){
        try {
            return write(200, "操作成功!","data",followUpService.findFollowupByMonth(doctor,patient,followupClass,patientName,startDate,endDate,flag,type,status));
        }catch (Exception e){
@ -476,24 +469,16 @@ public class DoctorFollowUpController extends BaseController {
    @RequestMapping(value = "/findFollowupList",produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ApiOperation("获取访视列表形式")
    public String findFollowupList(@ApiParam(name = "doctor", value = "医生", defaultValue = "zjm20190214")
                                       @RequestParam(value = "doctor", required = true) String doctor,
                                   @ApiParam(name = "patient", value = "居民")
                                       @RequestParam(value = "patient", required = false) String patient,
                                   @ApiParam(name = "followupClass", value = "随访类别,多类别“,”分割")
                                       @RequestParam(value = "followupClass", required = false) String followupClass,
                                   @ApiParam(name = "patientName", value = "居民姓名")
                                       @RequestParam(value = "patientName", required = false) String patientName,
                                   @ApiParam(value = "开始时间,格式(yyyy-MM-dd)", name = "startDate",required = false)
                                       @RequestParam(value = "startDate", required = false) String startDate,
                                   @ApiParam(value = "结束时间,格式(yyyy-MM-dd)", name = "endDate",required = false)
                                       @RequestParam(value = "endDate", required = false) String endDate,
                                   @ApiParam(name = "flag", value = "区分上门访视(1-是)")
                                       @RequestParam(value = "flag", required = false) String flag,
                                   @ApiParam(name = "type", value = "")
                                       @RequestParam(value = "type", required = false) Integer type,
                                   @ApiParam(name = "status", value = "随访状态")
                                       @RequestParam(value = "status", required = false) String status){
    public String findFollowupList(
            @ApiParam(name = "doctor", value = "医生", defaultValue = "zjm20190214") @RequestParam(value = "doctor", required = true) String doctor,
            @ApiParam(name = "patient", value = "居民") @RequestParam(value = "patient", required = false) String patient,
            @ApiParam(name = "followupClass", value = "随访类别,多类别“,”分割") @RequestParam(value = "followupClass", required = false) String followupClass,
            @ApiParam(name = "patientName", value = "居民姓名") @RequestParam(value = "patientName", required = false) String patientName,
            @ApiParam(value = "开始时间,格式(yyyy-MM-dd)", name = "startDate",required = false) @RequestParam(value = "startDate", required = false) String startDate,
            @ApiParam(value = "结束时间,格式(yyyy-MM-dd)", name = "endDate",required = false) @RequestParam(value = "endDate", required = false) String endDate,
            @ApiParam(name = "flag", value = "区分上门访视(1-是)") @RequestParam(value = "flag", required = false) String flag,
            @ApiParam(name = "type", value = "") @RequestParam(value = "type", required = false) Integer type,
            @ApiParam(name = "status", value = "随访状态") @RequestParam(value = "status", required = false) String status){
        try {
            return write(200, "操作成功!","data",followUpService.findFollowupList(null,doctor,patient,followupClass,patientName,startDate,endDate,flag,type,status));
        }catch (Exception e){

+ 69 - 11
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/controller/ChronicDiseaseController.java

@ -3,16 +3,15 @@ package com.yihu.jw.hospital.module.health.controller;
import com.yihu.jw.entity.scheme.vo.DoctorSchemeBloodPressureVO;
import com.yihu.jw.entity.scheme.vo.DoctorSchemeBloodSuggerVO;
import com.yihu.jw.hospital.module.health.service.scheme.DoctorSchemeService;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
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.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.List;
@ -30,6 +29,49 @@ public class ChronicDiseaseController extends EnvelopRestEndpoint {
    @Autowired
    private DoctorSchemeService doctorSchemeService;
    @GetMapping(value = "isTrack")
    @ApiOperation("是否关注")
    public Envelop isTrack(
            @ApiParam(name = "doctor", value = "医生id") @RequestParam(value = "doctor", required = true) String doctor,
            @ApiParam(name = "patient", value = "居民id") @RequestParam(value = "patient", required = true) String patient
    ) {
        try {
            return ObjEnvelop.getSuccess("取消成功",doctorSchemeService.isTrack(patient,doctor));
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError("取消失败");
        }
    }
    @PostMapping(value = "delTrack")
    @ApiOperation("取消重点关注")
    public Envelop delTrack(
            @ApiParam(name = "doctor", value = "医生id") @RequestParam(value = "doctor", required = true) String doctor,
            @ApiParam(name = "patient", value = "居民id") @RequestParam(value = "patient", required = true) String patient
    ) {
        try {
            doctorSchemeService.delTrack(patient,doctor);
            return Envelop.getSuccess("取消成功");
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError("取消失败");
        }
    }
    @PostMapping(value = "addTrack")
    @ApiOperation("添加重点关注")
    public Envelop addTrack(
            @ApiParam(name = "doctor", value = "医生id") @RequestParam(value = "doctor", required = true) String doctor,
            @ApiParam(name = "patient", value = "居民id") @RequestParam(value = "patient", required = true) String patient
    ) {
        try {
            doctorSchemeService.addTrack(patient,doctor);
            return Envelop.getSuccess("添加成功");
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError("添加失败");
        }
    }
    /**
     * 获取i健康的数据-同安签约居民,并且是三院关系的,有慢病的
@ -227,7 +269,20 @@ public class ChronicDiseaseController extends EnvelopRestEndpoint {
        try {
            return write(200, "查询成功", "data", doctorSchemeService.getControlObjectives(patient));
        } catch (Exception e) {
            return error(-1, e.getMessage());
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
    @RequestMapping(value = "findLatelyIndex", method = RequestMethod.GET)
    @ApiOperation("获取居民最近一次体征记录")
    public Envelop findLatelyIndex(@ApiParam(name = "patient", value = "居民code") @RequestParam(value = "patient", required = true) String patient,
                              @ApiParam(name = "type", value = "类型(1血糖,2血压,3体重/身高/BMI,4腰围,5心率,6体温,7呼吸)") @RequestParam(value = "type", required = true) String type) {
        try {
            return ObjEnvelop.getSuccess( "查询成功", doctorSchemeService.findLatelyIndex(patient, type));
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError("查询失败");
        }
    }
@ -285,12 +340,13 @@ public class ChronicDiseaseController extends EnvelopRestEndpoint {
            @ApiParam(name = "startDate", value = "开始时间,YYYY-MM-dd") @RequestParam(value = "startDate", required = true) String startDate,
            @ApiParam(name = "endDate", value = "结束时间,YYYY-MM-dd") @RequestParam(value = "endDate", required = true) String endDate,
            @ApiParam(name = "type", value = "0血糖,1.血压") @RequestParam(value = "type", required = true) String type,
            @ApiParam(name = "doctorId", value = "医生id") @RequestParam(value = "doctorId", required = true) String doctorId) {
            @ApiParam(name = "patient", value = "居民id") @RequestParam(value = "patient", required = false) String patient,
            @ApiParam(name = "doctorId", value = "医生id") @RequestParam(value = "doctorId", required = false) String doctorId) {
        try {
            if (StringUtils.isBlank(doctorId)) {
                doctorId = getUID();
            }
            return write(200, "查询成功", "data", doctorSchemeService.getPatientHealthIndexNew(startDate, endDate, type, doctorId));
            return write(200, "查询成功", "data", doctorSchemeService.getPatientHealthIndexNew(startDate, endDate, type,patient, doctorId));
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, e.getMessage());
@ -385,12 +441,13 @@ public class ChronicDiseaseController extends EnvelopRestEndpoint {
    @RequestMapping(value = "getLabelCount", method = RequestMethod.GET)
    @ApiOperation("获取红黄绿标高血压糖尿病的指标人数")
    public String getLabelCount(
            @ApiParam(name = "doctorId", value = "医生id") @RequestParam(value = "doctorId", required = false) String doctorId) {
            @ApiParam(name = "doctorId", value = "医生id") @RequestParam(value = "doctorId", required = false) String doctorId,
            @ApiParam(name = "diseaseCondition", value = "病情") @RequestParam(value = "diseaseCondition", required = false) String diseaseCondition) {
        try {
            if (StringUtils.isBlank(doctorId)) {
                doctorId = getUID();
            }
            HashMap<String, Object> result = doctorSchemeService.getLabelCount(doctorId);
            HashMap<String, Object> result = doctorSchemeService.getLabelCount(doctorId,diseaseCondition);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            return error(-1, e.getMessage());
@ -402,7 +459,8 @@ public class ChronicDiseaseController extends EnvelopRestEndpoint {
    public String getLabelDetail(
            @ApiParam(name = "doctorId", value = "医生id") @RequestParam(value = "doctorId", required = false) String doctorId,
            @ApiParam(name = "labelType", value = "1高血压 2糖尿病 空全部") @RequestParam(value = "labelType", required = false) String labelType,
            @ApiParam(name = "searchContent", value = "检索内容") @RequestParam(value = "labelType", required = false) String searchContent,
            @ApiParam(name = "searchContent", value = "检索内容") @RequestParam(value = "searchContent", required = false) String searchContent,
            @ApiParam(name = "diseaseCondition", value = "病情") @RequestParam(value = "diseaseCondition", required = false) String diseaseCondition,
            @ApiParam(name = "page", value = "页码") @RequestParam(value = "page", required = false) int page,
            @ApiParam(name = "pageSize", value = "数量") @RequestParam(value = "pageSize", required = false) int pageSize
    ) {
@ -410,7 +468,7 @@ public class ChronicDiseaseController extends EnvelopRestEndpoint {
            if (StringUtils.isBlank(doctorId)) {
                doctorId = getUID();
            }
            List<Map<String, Object>> result = doctorSchemeService.getLabelDetail(doctorId, labelType, searchContent, page, pageSize);
            List<Map<String, Object>> result = doctorSchemeService.getLabelDetail(doctorId, labelType,diseaseCondition, searchContent, page, pageSize);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            e.printStackTrace();

+ 2 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/controller/PatientHealthController.java

@ -318,6 +318,8 @@ public class PatientHealthController extends BaseController {
            if (type.equals("1") || type.equals("2")) {
                healthIndexService.verifyHealthIndex(obj.getId());
            }
            //判断居民的体征预警状态
            healthIndexService.handlePatientStandarStatus(obj);
            return success("新增患者指标成功!");
        } catch (ServiceException se) {
            return write(-1,se.getMessage());

+ 2 - 2
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/dao/TrackPatientDao.java

@ -22,9 +22,9 @@ public interface TrackPatientDao extends PagingAndSortingRepository<TrackPatient
    @Query(value= "SELECT DISTINCT a.*\n" +
            "FROM wlyy_track_patient a  \n" +
            "INNER JOIN base_patient b ON a.patient_code=b.id \n" +
            "INNER JOIN base_patient_doctor_relation c ON b.id=c.patient_id  \n" +
            "INNER JOIN wlyy_outpatient c ON b.id=c.patient  \n" +
            "WHERE 1=1\n" +
            "AND c.doctor_id=?1 \n" +
            "AND c.doctor=?1 \n" +
            "AND a.del=?2 ",nativeQuery = true)
    List<TrackPatient> findByDoctor(String doctor,String del);
}

+ 86 - 3
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/service/DeviceUploadService.java

@ -136,9 +136,7 @@ public class DeviceUploadService {
                                +result.getValue2()+"mmHg,脉搏:"+result.getValue3()+"次/min";
                        break;
                }
                if (StringUtils.isNotBlank(typeName)){
                }
                yujing(result.getUser(),patientDO);
            }
        } catch (Exception e) {
            e.printStackTrace();
@ -148,6 +146,91 @@ public class DeviceUploadService {
        return Result.success("Device data incoming success");
    }
    /**
     * 预警.
     * @param patientCode
     * @param patient
     */
    public void yujing(String patientCode,BasePatientDO patient){
        try{
            String patientsql = "select group_concat(label) disease from wlyy_sign_patient_label_info where label_type = 3 and status=1 " +
                    "and (label = 1 or label = 2) and patient = '"+patientCode+"' GROUP BY patient";
            String patientdisease = jdbcTemplate.queryForObject(patientsql,String.class);
            //连续5次体征值正常,则修改为非预警状态;连续5次异常,修改为预警状态-----START
            int bloodPressureBbnormalCount = 0;//血压异常次数
            int bloodSuggurBbnormalCount = 0;//血糖异常次数
            int stdbloodPressureBbnormalCount = 0;//血压次数
            int stdbloodSuggurBbnormalCount = 0;//血糖次数
            List<DevicePatientHealthIndex> bloodPressurepatientHealthIndices = patientHealthIndexDao.findByPatientAndTypeByPage(patientCode,2);
            List<DevicePatientHealthIndex> bloodSuggurpatientHealthIndices = patientHealthIndexDao.findByPatientAndTypeByPage(patientCode,1);
            if(!bloodPressurepatientHealthIndices.isEmpty()){
                stdbloodPressureBbnormalCount = bloodPressurepatientHealthIndices.size();
            }
            if(!bloodSuggurpatientHealthIndices.isEmpty()){
                stdbloodSuggurBbnormalCount = bloodSuggurpatientHealthIndices.size();
            }
            for (DevicePatientHealthIndex index1 : bloodPressurepatientHealthIndices) {
                if(index1.getStatus() != null && 1 == index1.getStatus()){
                    bloodPressureBbnormalCount++;
                }
            }
            for (DevicePatientHealthIndex index2 : bloodSuggurpatientHealthIndices) {
                if(index2.getStatus() != null && 1 == index2.getStatus()){
                    bloodSuggurBbnormalCount++;
                }
            }
            //连续3次异常,修改用户为预警状态
            if( (bloodPressureBbnormalCount >=3 || bloodSuggurBbnormalCount >=3)){
                patient.setStandardStatus(1);
//                setTrackPatientByDoctor(patientCode);
            }else{
                Date end = new Date();
                Date start = DateUtil.setDateTime(end,-7);
                //计算血糖或者血压一周内的异常记录数量
                int errorCount = patientHealthIndexDao.getCountByTimeAndStatus(start,end,1,patientCode);
                if(errorCount >= 5){//超过5次,记为预警状态
                    patient.setStandardStatus(1);
//                    setTrackPatientByDoctor(patientCode);
                }
            }
            //连续5次正常,修改用户为非预警状态
            if(StringUtils.isNotBlank(patientdisease)){
                if("1".equals(patientdisease)){
                    if(stdbloodPressureBbnormalCount==5&&0 == bloodPressureBbnormalCount){
                        patient.setStandardStatus(0);
//                        cancalTrackPatientByDoctor(patientCode);
                    }
                }else if("2".equals(patientdisease)){
                    if(stdbloodSuggurBbnormalCount==5&&0 == bloodSuggurBbnormalCount){
                        patient.setStandardStatus(0);
//                        cancalTrackPatientByDoctor(patientCode);
                    }
                }else if( "1,2".equals(patientdisease) || "2,1".equals(patientdisease)){
                    if(stdbloodSuggurBbnormalCount==5&&stdbloodPressureBbnormalCount==5&&0 == bloodSuggurBbnormalCount && 0 == bloodPressureBbnormalCount){
                        patient.setStandardStatus(0);
//                        cancalTrackPatientByDoctor(patientCode);
                    }
                }
            }else{
                patient.setStandardStatus(0);
//                cancalTrackPatientByDoctor(patientCode);
            }
            patientDao.save(patient);
            //连续5次体征值正常,则修改为非预警状态;连续5次异常,修改为预警状态-----END
        }catch (Exception e){
            e.printStackTrace();
        }
    }
    /**
     * 保存设备数据
     * @param type 设备类型 4 智能手表

+ 99 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/service/PatientHealthIndexService.java

@ -10,12 +10,14 @@ import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.device.DeviceDetail;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.entity.care.device.DevicePatientHealthIndex;
import com.yihu.jw.hospital.module.health.dao.DoctorSwitchDao;
import com.yihu.jw.im.dao.ConsultTeamDao;
import com.yihu.jw.im.util.ImUtil;
import com.yihu.jw.message.dao.MessageDao;
import com.yihu.jw.message.service.MessageService;
import com.yihu.jw.message.service.WxMessageUtil;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.patient.PatientVO;
import com.yihu.jw.util.common.CommonUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.entity.ServiceException;
@ -50,6 +52,8 @@ public class PatientHealthIndexService {
    @Autowired
    private BaseDoctorDao doctorDao;
    @Autowired
    private DoctorSwitchDao doctorSwitchDao;
    @Autowired
    private DevicePatientHealthIndexDao patientHealthIndexDao;
    @Autowired
    private PatientHealthStandardDao patientHealthStandardDao;
@ -84,6 +88,101 @@ public class PatientHealthIndexService {
        return patientHealthIndexDao.findById(id).orElse(null);
    }
    /**
     * 判断居民的体征预警状态
     *
     * @param obj
     */
    public void handlePatientStandarStatus(DevicePatientHealthIndex obj) {
        //连续5次体征值正常,则修改为非预警状态;连续5次异常,修改为预警状态-----START
        String patientCode = obj.getUser();
        //患者信息
        BasePatientDO p = patientDao.findById(patientCode).orElse(null);
        PatientVO patient = new PatientVO();
        String patientsql = "select group_concat(label) disease from wlyy_sign_patient_label_info " +
                "where label_type = 3 and status=1 and (label = 1 or label = 2) and patient = '" + p.getId() + "' GROUP BY patient";
        String patientdisease = "";
        List<Map<String, Object>> diseases = jdbcTemplate.queryForList(patientsql);
        if (diseases != null && diseases.size() > 0) {
            patientdisease = (String) diseases.get(0).get("disease");
        }
        int bloodPressureBbnormalCount = 0;//血压异常次数
        int bloodSuggurBbnormalCount = 0;//血糖异常次数
        int stdbloodPressureBbnormalCount = 0;//血压次数
        int stdbloodSuggurBbnormalCount = 0;//血糖次数
        List<DevicePatientHealthIndex> bloodPressurepatientHealthIndices = new ArrayList<>();
        List<DevicePatientHealthIndex> bloodSuggurpatientHealthIndices = new ArrayList<>();
        bloodPressurepatientHealthIndices = patientHealthIndexDao.findByPatientAndTypeByPage(patientCode, 2);
        bloodSuggurpatientHealthIndices = patientHealthIndexDao.findByPatientAndTypeByPage(patientCode, 1);
        if (!bloodPressurepatientHealthIndices.isEmpty()) {
            stdbloodPressureBbnormalCount = bloodPressurepatientHealthIndices.size();
        }
        if (!bloodSuggurpatientHealthIndices.isEmpty()) {
            stdbloodSuggurBbnormalCount = bloodSuggurpatientHealthIndices.size();
        }
        for (DevicePatientHealthIndex index1 : bloodPressurepatientHealthIndices) {
            if (index1.getStatus() != null && 1 == index1.getStatus()) {
                bloodPressureBbnormalCount++;
            }
        }
        for (DevicePatientHealthIndex index2 : bloodSuggurpatientHealthIndices) {
            if (index2.getStatus() != null && 1 == index2.getStatus()) {
                bloodSuggurBbnormalCount++;
            }
        }
        //连续3次异常,修改用户为预警状态
        if ((bloodPressureBbnormalCount >= 3 || bloodSuggurBbnormalCount >= 3)) {
            p.setStandardStatus(1);
//            setTrackPatientByDoctor(patientCode);
        } else {
            Date end = new Date();
            Date start = DateUtil.setDateTime(end, -7);
            //计算血糖或者血压一周内的异常记录数量
            int errorCount = patientHealthIndexDao.getCountByTimeAndStatus(start, end, 1, patientCode);
            if (errorCount >= 5) {//超过5次,记为预警状态
                p.setStandardStatus(1);
//                setTrackPatientByDoctor(patientCode);
            }
        }
        //连续5次正常,修改用户为非预警状态
        if (StringUtils.isNotBlank(patientdisease)) {
            if ("1".equals(patientdisease)) {
                if (stdbloodPressureBbnormalCount == 5 && 0 == bloodPressureBbnormalCount) {
                    p.setStandardStatus(0);
//                    cancalTrackPatientByDoctor(patientCode);
                }
            } else if ("2".equals(patientdisease)) {
                if (stdbloodSuggurBbnormalCount == 5 && 0 == bloodSuggurBbnormalCount) {
                    p.setStandardStatus(0);
//                    cancalTrackPatientByDoctor(patientCode);
                }
            } else if ("1,2".equals(patientdisease) || "2,1".equals(patientdisease)) {
                if (stdbloodPressureBbnormalCount == 5 && stdbloodSuggurBbnormalCount == 5 && 0 == bloodSuggurBbnormalCount && 0 == bloodPressureBbnormalCount) {
                    p.setStandardStatus(0);
//                    cancalTrackPatientByDoctor(patientCode);
                }
            }
        } else {
            p.setStandardStatus(0);
//            cancalTrackPatientByDoctor(patientCode);
        }
        patientDao.save(p);
        //连续5次体征值正常,则修改为非预警状态;连续5次异常,修改为预警状态-----END
    }
    /**
     * 获取居民标准预警值
     *

+ 140 - 79
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/service/scheme/DoctorSchemeService.java

@ -7,9 +7,11 @@ import com.yihu.jw.device.dao.DevicePatientHealthIndexDao;
import com.yihu.jw.device.dao.PatientAimBloodPressureDao;
import com.yihu.jw.device.dao.PatientAimBloodSuggerDao;
import com.yihu.jw.device.dao.PatientAimSportsDao;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.device.PatientAimBloodPressure;
import com.yihu.jw.entity.base.device.PatientAimBloodSugger;
import com.yihu.jw.entity.base.device.PatientAimSports;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.device.DevicePatientHealthIndex;
import com.yihu.jw.entity.scheme.*;
@ -35,7 +37,6 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.DefaultTransactionDefinition;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@ -47,7 +48,6 @@ import java.util.concurrent.Executors;
 * @date 2017/9/13 15:46
 */
@Service
@Transactional
public class DoctorSchemeService {
    private static Logger logger = LoggerFactory.getLogger(DoctorSchemeService.class);
@ -68,7 +68,8 @@ public class DoctorSchemeService {
    @Autowired
    private BasePatientDao patientDao;
    @Autowired
    private BaseDoctorDao doctorDao;
    @Autowired
    private DevicePatientHealthIndexDao devicePatientHealthIndexDao;
@ -90,6 +91,65 @@ public class DoctorSchemeService {
    @Value("${im.data_base_name}")
    private String im_dataBase_name;
    //取消重点关注
    public void delTrack(String patient,String doctor){
        synchronized (patient.intern()){
            //查询是否与医生建立重点跟踪关系,诺无关系则建立
            TrackPatient trackPatient = trackPatientDao.findByDoctorCodeAndPatientCode(doctor,patient);
            if(trackPatient == null){
                BaseDoctorDO doctorDO = doctorDao.findByIdAndDel(doctor);
                BasePatientDO patientDO = patientDao.findByIdAndDel(patient,"1");
                TrackPatient t = new TrackPatient();
                t.setCreateTime(new Date());
                t.setDoctorCode(doctorDO.getId());
                t.setDoctorName(doctorDO.getName());
                t.setIdcard(patientDO.getIdcard());
                t.setSsc(patientDO.getSsc());
                t.setPatientCode(patient);
                t.setPatientName(patientDO.getName());
                t.setDel("0");
                trackPatientDao.save(t);
            }else {
                trackPatient.setDel("0");
                trackPatientDao.save(trackPatient);
            }
        }
    }
    //是否关注
    public String isTrack(String patient,String doctor){
        TrackPatient trackPatient = trackPatientDao.findByDoctorCodeAndPatientCode(doctor,patient);
        if(trackPatient==null){
            return "0";
        }
        return trackPatient.getDel();
    }
    //添加重点关注
    public void addTrack(String patient,String doctor){
        synchronized (patient.intern()){
            //查询是否与医生建立重点跟踪关系,诺无关系则建立
            TrackPatient trackPatient = trackPatientDao.findByDoctorCodeAndPatientCode(doctor,patient);
            if(trackPatient == null){
                BaseDoctorDO doctorDO = doctorDao.findByIdAndDel(doctor);
                BasePatientDO patientDO = patientDao.findByIdAndDel(patient,"1");
                TrackPatient t = new TrackPatient();
                t.setCreateTime(new Date());
                t.setDoctorCode(doctorDO.getId());
                t.setDoctorName(doctorDO.getName());
                t.setIdcard(patientDO.getIdcard());
                t.setSsc(patientDO.getSsc());
                t.setPatientCode(patient);
                t.setPatientName(patientDO.getName());
                t.setDel("1");
                trackPatientDao.save(t);
            }else {
                trackPatient.setDel("1");
                trackPatientDao.save(trackPatient);
            }
        }
    }
    /**
     * 根据团队CODE/居民标签/病情/设备绑定状态查询团队具名CODE列表
@ -105,7 +165,7 @@ public class DoctorSchemeService {
    public List<String> getPatientsByDiseaseConditionDiseaseDeviceType(String teamCode, Integer disease, String diseaseCondition, Integer deviceType, String doctorcode, String trackFlag) throws Exception {
        String sql = "SELECT  a.id\n" +
                "FROM base_patient a \n" +
                "INNER JOIN base_patient_doctor_relation b ON a.id=b.patient_id\n";
                "INNER JOIN wlyy_outpatient b ON a.id=b.patient\n";
        //1.4.2加入跟踪居民过滤
        if (StringUtils.isNotBlank(trackFlag) && "1".equals(trackFlag)) {
@ -138,7 +198,7 @@ public class DoctorSchemeService {
                sql = sql + " and dev.user is not null ";
            }
        }
        sql += " AND b.doctor_id ='" + doctorcode + "' ";
        sql += " AND b.doctor ='" + doctorcode + "' ";
        //1.4.2加入跟踪居民过滤
        if (StringUtils.isNotBlank(trackFlag) && "1".equals(trackFlag)) {
            sql += " AND tp.del='1' AND tp.doctor_code = '" + doctorcode + "' ";
@ -409,11 +469,11 @@ public class DoctorSchemeService {
                "	a.disease_condition \n" +
                "FROM\n" +
                "	base_patient a \n" +
                "	INNER JOIN base_patient_doctor_relation b ON a.id=b.patient_id\n" +
                "	INNER JOIN wlyy_outpatient b ON a.id=b.patient\n" +
                "WHERE 1=1\n" +
                "AND a.disease_condition IN('1','2','3')\n" +
                "AND a.disease_condition IN('1','2','0')\n" +
                "AND a.disease IN ('1','2','1,2','2,1')\n" +
                "AND b.doctor_id ='" + doctorcode + "'";
                "AND b.doctor ='" + doctorcode + "'";
        patients = jdbcTemplate.query(patientsql, new BeanPropertyRowMapper(PatientVO.class));
@ -735,10 +795,16 @@ public class DoctorSchemeService {
        return rs;
    }
    public Map<String, Object> getPatientHealthIndexNew(String startDate, String endDate, String type, String doctor) {
    public Map<String, Object> getPatientHealthIndexNew(String startDate, String endDate, String type,String patient, String doctor) {
        startDate = startDate + " 00:00:00";
        endDate = endDate + " 23:59:59";
        String filter = "";
        if(StringUtils.isNotBlank(patient)){
            filter += " AND i.user = '"+patient+"' ";
        }
        if(StringUtils.isNotBlank(patient)){
            filter += " AND i.user IN (SELECT t.patient_code FROM wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='" + doctor + "' ) ";
        }
        String highSql = "SELECT  " +
                " (bf.befHighCount + aft.aftHighCount) AS highCount " +
                " FROM " +
@ -753,9 +819,7 @@ public class DoctorSchemeService {
                " AND i.value2 in(1,3,5,7) " +
                " AND i.value1 > 7 " +
                " AND i.record_date >='" + startDate + "'" +
                " AND i.record_date <='" + endDate + "'" +
                " AND i.user IN (" +
                "SELECT t.patient_code FROM wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='" + doctor + "' )" +
                " AND i.record_date <='" + endDate + "'" + filter +
                " ) bf, " +
                " (  " +
                " SELECT " +
@ -768,8 +832,7 @@ public class DoctorSchemeService {
                " AND i.value2 in(2,4,6) " +
                " AND i.value1 > 11.1 " +
                " AND i.record_date >='" + startDate + "'" +
                " AND i.record_date <='" + endDate + "'" +
                " AND i.user IN (SELECT t.patient_code FROM wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='" + doctor + "' )" +
                " AND i.record_date <='" + endDate + "'" + filter +
                " ) aft";
        String stdSql = "SELECT  " +
                " (bf.befHighCount + aft.aftHighCount) AS stdCount " +
@ -786,8 +849,7 @@ public class DoctorSchemeService {
                " AND i.value1 <= 7 " +
                " AND i.value1 >= 4 " +
                " AND i.record_date >='" + startDate + "'" +
                " AND i.record_date <='" + endDate + "'" +
                " AND i.user IN (SELECT t.patient_code FROM wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='" + doctor + "' )" +
                " AND i.record_date <='" + endDate + "'" + filter +
                " ) bf, " +
                " (  " +
                " SELECT " +
@ -801,8 +863,7 @@ public class DoctorSchemeService {
                " AND i.value1 <= 11.1 " +
                " AND i.value1 >= 4 " +
                " AND i.record_date >='" + startDate + "'" +
                " AND i.record_date <='" + endDate + "'" +
                " AND i.user IN (SELECT t.patient_code FROM wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='" + doctor + "' )" +
                " AND i.record_date <='" + endDate + "'" + filter +
                " ) aft";
        String lowSql = "SELECT  " +
                " (bf.befHighCount + aft.aftHighCount) AS lowCount " +
@ -818,8 +879,7 @@ public class DoctorSchemeService {
                " AND i.value2 in(1,3,5,7) " +
                " AND i.value1 < 4 " +
                " AND i.record_date >='" + startDate + "'" +
                " AND i.record_date <='" + endDate + "'" +
                " AND i.user IN (SELECT t.patient_code FROM wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='" + doctor + "' )" +
                " AND i.record_date <='" + endDate + "'" +filter +
                " ) bf, " +
                " (  " +
                " SELECT " +
@ -832,8 +892,7 @@ public class DoctorSchemeService {
                " AND i.value2 in(2,4,6) " +
                " AND i.value1 < 4 " +
                " AND i.record_date >='" + startDate + "'" +
                " AND i.record_date <='" + endDate + "'" +
                " AND i.user IN (SELECT t.patient_code FROM wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='" + doctor + "' )" +
                " AND i.record_date <='" + endDate + "'" +filter +
                " ) aft";
        String pHighSql = "SELECT " +
@ -845,8 +904,7 @@ public class DoctorSchemeService {
                " AND i.type = '2' " +
                " AND i.value1 > 139 " +
                " AND i.record_date >='" + startDate + "'" +
                " AND i.record_date <='" + endDate + "'" +
                " AND i.user IN (SELECT t.patient_code FROM wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='" + doctor + "' )";
                " AND i.record_date <='" + endDate + "'" +filter ;
        String pStdSql = "SELECT " +
                " count(1) AS stdCount " +
                " FROM " +
@ -857,8 +915,7 @@ public class DoctorSchemeService {
                " AND i.value1 <= 139 " +
                " AND i.value1 >= 90 " +
                " AND i.record_date >='" + startDate + "'" +
                " AND i.record_date <='" + endDate + "'" +
                " AND i.user IN (SELECT t.patient_code FROM wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='" + doctor + "' )";
                " AND i.record_date <='" + endDate + "'" +filter ;
        String pLowSql = "SELECT " +
                " count(1) AS lowCount " +
                " FROM " +
@ -868,8 +925,7 @@ public class DoctorSchemeService {
                " AND i.type = '2' " +
                " AND i.value1 < 90 " +
                " AND i.record_date >='" + startDate + "'" +
                " AND i.record_date <='" + endDate + "'" +
                " AND i.user IN (SELECT t.patient_code FROM wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='" + doctor + "')";
                " AND i.record_date <='" + endDate + "'" +filter ;
        Map<String, Object> rs = new HashedMap();
        //0血檀
@ -925,7 +981,8 @@ public class DoctorSchemeService {
        String hsql = "SELECT " +
                " i.value1 AS weight, " +
                " i.value2 AS height, " +
                " i.value3 AS BMI " +
                " i.value3 AS BMI, " +
                " i.value4 " +
                " FROM " +
                " wlyy_patient_health_index i " +
                " WHERE " +
@ -988,6 +1045,16 @@ public class DoctorSchemeService {
        return rs;
    }
    //获取居民最近一次体征记录
    public DevicePatientHealthIndex findLatelyIndex(String patient,String type){
        String sql = "select * from wlyy_patient_health_index where user='"+patient+"' and type="+type+" order by id desc limit 1 ";
        List<DevicePatientHealthIndex> list = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(DevicePatientHealthIndex.class));
        if(list.size()>0){
            return list.get(0);
        }
        return null;
    }
    public List<Map<String, Object>> getBodyInfo(String patient, String startDate, String endDate, Integer page, Integer size) {
        startDate = startDate + " 00:00:00";
        endDate = endDate + " 23:59:59";
@ -1044,7 +1111,6 @@ public class DoctorSchemeService {
    }
    public Map<String, Object> getTrackPatientCountTitle(String doctor, String startDate, String endDate) {
//        List<TrackPatient> trackPatients = trackPatientDao.findByDoctorCodeAndTeamCodeAndDel(doctor, teamCode, "1");
        List<TrackPatient> trackPatients = trackPatientDao.findByDoctor(doctor, "1");
        Map<String, Object> rs = new HashedMap();
        rs.put("trackPatientCount", trackPatients.size());
@ -2128,66 +2194,56 @@ public class DoctorSchemeService {
     *
     * @return
     */
    public HashMap<String, Object> getLabelCount(String doctorId) throws ExecutionException, InterruptedException {
    public HashMap<String, Object> getLabelCount(String doctorId,String diseaseCondition) throws ExecutionException, InterruptedException {
        // 高血压预警
        String sql01 = "SELECT count(DISTINCT  a.id)\n" +
                "FROM base_patient a \n" +
                "INNER JOIN base_patient_doctor_relation b ON a.id=b.patient_id\n" +
                "INNER JOIN wlyy_outpatient b ON a.id=b.patient " +
                "INNER join wlyy_patient_label l on l.patient=a.id AND l.label_type='2' " +
                "WHERE 1=1\n" +
                "AND a.standard_status='1'\n" +
                "AND a.disease_condition IN('1','2','3')\n" +
                "AND a.disease IN ('1','3') \n" +
                "AND b.doctor_id ='" + doctorId + "'";
                "AND a.disease_condition IN('1','2','0')\n" +
                "and l.label_name='高血压' " +
                "AND b.doctor ='" + doctorId + "'";
        // 高血压
        String sql02 = "SELECT count(DISTINCT  a.id)\n" +
                "FROM base_patient a \n" +
                "INNER JOIN base_patient_doctor_relation b ON a.id=b.patient_id\n" +
                "INNER JOIN wlyy_outpatient b ON a.id=b.patient\n" +
                "INNER join wlyy_patient_label l on l.patient=a.id AND l.label_type='2' " +
                "WHERE 1=1\n" +
                "AND a.disease_condition IN('1','2','3')\n" +
                "AND a.disease IN ('1','3') \n" +
                "AND b.doctor_id ='" + doctorId + "'";
                "AND a.disease_condition IN('1','2','0')\n" +
                "and l.label_name='高血压' " +
                "AND b.doctor ='" + doctorId + "'";
        // 糖尿病预警
        String sql03 = "SELECT count(DISTINCT  a.id)\n" +
                "FROM base_patient a \n" +
                "INNER JOIN base_patient_doctor_relation b ON a.id=b.patient_id\n" +
                "INNER JOIN wlyy_outpatient b ON a.id=b.patient\n" +
                "INNER join wlyy_patient_label l on l.patient=a.id AND l.label_type='2' " +
                "WHERE 1=1\n" +
                "AND a.standard_status='1'\n" +
                "AND a.disease_condition IN('1','2','3')\n" +
                "AND a.disease IN ('2','3') \n" +
                "AND b.doctor_id ='" + doctorId + "'";
                "AND a.disease_condition IN('1','2','0')\n" +
                "and l.label_name='糖尿病' " +
                "AND b.doctor ='" + doctorId + "'";
        // 糖尿病
        String sql04 = "SELECT count(DISTINCT  a.id)\n" +
                "FROM base_patient a \n" +
                "INNER JOIN base_patient_doctor_relation b ON a.id=b.patient_id\n" +
                "INNER JOIN wlyy_outpatient b ON a.id=b.patient\n" +
                "INNER join wlyy_patient_label l on l.patient=a.id AND l.label_type='2' " +
                "WHERE 1=1\n" +
                "AND a.disease_condition IN('1','2','3')\n" +
                "AND a.disease IN ('2','3') \n" +
                "AND b.doctor_id ='" + doctorId + "'";
        CompletableFuture<Integer> future01 = CompletableFuture.supplyAsync(() -> {
            Integer count = jdbcTemplate.queryForObject(sql01, Integer.class);
            return count;
        }, execute);
        CompletableFuture<Integer> future02 = CompletableFuture.supplyAsync(() -> {
            Integer count = jdbcTemplate.queryForObject(sql02, Integer.class);
            return count;
        }, execute);
        CompletableFuture<Integer> future03 = CompletableFuture.supplyAsync(() -> {
            Integer count = jdbcTemplate.queryForObject(sql03, Integer.class);
            return count;
        }, execute);
        CompletableFuture<Integer> future04 = CompletableFuture.supplyAsync(() -> {
            Integer count = jdbcTemplate.queryForObject(sql04, Integer.class);
            return count;
        }, execute);
        CompletableFuture.allOf(future01, future02, future03, future04).get();
        Integer count1 = future01.get();// 高血压预警
        Integer count2 = future02.get();// 高血压
        Integer count3 = future03.get();// 糖尿病预警
        Integer count4 = future04.get();// 糖尿病
                "AND a.disease_condition IN('1','2','0')\n" +
                "and l.label_name='糖尿病' " +
                "AND b.doctor ='" + doctorId + "'";
        if(StringUtils.isNotBlank(diseaseCondition)){
            sql01 += " and a.disease_condition = '"+diseaseCondition+"' ";
            sql02 += " and a.disease_condition = '"+diseaseCondition+"' ";
            sql03 += " and a.disease_condition = '"+diseaseCondition+"' ";
            sql04 += " and a.disease_condition = '"+diseaseCondition+"' ";
        }
        Integer count1 = jdbcTemplate.queryForObject(sql01, Integer.class);// 高血压预警
        Integer count2 = jdbcTemplate.queryForObject(sql02, Integer.class);// 高血压
        Integer count3 = jdbcTemplate.queryForObject(sql03, Integer.class);// 糖尿病预警
        Integer count4 = jdbcTemplate.queryForObject(sql04, Integer.class);// 糖尿病
        HashMap<String, Object> map = new HashMap<>();
        map.put("gxy_yj", count1);// 高血压预警
@ -2200,21 +2256,26 @@ public class DoctorSchemeService {
    /**
     * labelType 1高血压 2糖尿病
     */
    public List<Map<String, Object>> getLabelDetail(String doctorId, String labelType, String searchContent, int page, int pageSize) {
        String sql = "SELECT DISTINCT a.id,a.`name`,a.idcard,a.mobile,a.ssc, TIMESTAMPDIFF(YEAR, a.birthday, CURDATE()) AS age ,a.sex \n" +
    public List<Map<String, Object>> getLabelDetail(String doctorId, String labelType,String diseaseCondition, String searchContent, int page, int pageSize) {
        String sql = "SELECT DISTINCT a.id,a.`name`,a.idcard,a.mobile,a.ssc, TIMESTAMPDIFF(YEAR, a.birthday, CURDATE()) AS age " +
                ",a.sex,a.disease,CAST(a.disease_condition AS CHAR) diseaseCondition,a.photo,CAST(a.standard_status AS CHAR) standardStatus " +
                "FROM base_patient a \n" +
                "INNER JOIN base_patient_doctor_relation b ON a.id=b.patient_id\n" +
                "INNER JOIN wlyy_outpatient b ON a.id=b.patient\n" +
                "INNER join wlyy_patient_label l on l.patient=a.id AND l.label_type='2' " +
                "WHERE 1=1\n" +
                "AND a.disease_condition IN('1','2','3')\n" +
                "AND b.doctor_id ='" + doctorId + "'";
                "AND a.disease_condition IN('1','2','0') " +
                "AND b.doctor ='" + doctorId + "'";
        if (StringUtils.isNotBlank(labelType)) {
            if ("1".equals(labelType)) {
                sql += "AND a.disease IN ('1','3') \n";
                sql += "AND l.label_name='高血压' \n";
            }
            if ("2".equals(labelType)) {
                sql += "AND a.disease IN ('2','3') \n";
                sql += "AND l.label_name='糖尿病' \n";
            }
        }
        if(StringUtils.isNotBlank(diseaseCondition)){
            sql += "AND a.disease_condition = '"+diseaseCondition+"' " ;
        }
        if (StringUtils.isNotBlank(searchContent)) {
            sql += " AND a.`name` LIKE '%" + searchContent + "%' ";
        }