trick9191 7 anni fa
parent
commit
b989446561

+ 9 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/TrackPatient.java

@ -20,6 +20,7 @@ public class TrackPatient extends IdEntity {
    private Integer teamCode;//居民签约团队
    private String idcard;//身份证号
    private String ssc;//社保卡号
    private String del;//删除
    private Date createTime;//创建时间
    private Date updateTime;//更新时间
@ -94,4 +95,12 @@ public class TrackPatient extends IdEntity {
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
    public String getDel() {
        return del;
    }
    public void setDel(String del) {
        this.del = del;
    }
}

+ 5 - 0
patient-co-service/wlyy_device/pom.xml

@ -145,6 +145,11 @@
            <artifactId>springfox-swagger-ui</artifactId>
            <version>2.4.0</version>
        </dependency>
        <dependency>
            <groupId>com.yihu</groupId>
            <artifactId>patient-co-wlyy</artifactId>
            <version>1.0.0</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>

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

@ -0,0 +1,12 @@
package com.yihu.hos.device.common.dao;
import com.yihu.hos.device.model.DoctorSwitch;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Trick on 2018/1/8.
 */
public interface DoctorSwitchDao extends PagingAndSortingRepository<DoctorSwitch, Long>, JpaSpecificationExecutor<DoctorSwitch> {
    public DoctorSwitch findByDoctor(String doctor);
}

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

@ -0,0 +1,17 @@
package com.yihu.hos.device.common.dao;
import com.yihu.hos.device.model.TrackPatient;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by Trick on 2018/1/4.
 */
public interface TrackPatientDao extends PagingAndSortingRepository<TrackPatient, String>, JpaSpecificationExecutor<TrackPatient> {
    public TrackPatient findByDoctorCodeAndPatientCode(String doctorCode, String patientCode);
    public List<TrackPatient> findByDoctorCodeAndTeamCode(String doctorCode, Integer teamCode);
}

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

@ -0,0 +1,50 @@
package com.yihu.hos.device.model;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by Trick on 2018/1/4.
 */
@Entity
@Table(name = "wlyy_doctor_switch")
public class DoctorSwitch extends IdEntity{
    private String doctor;//关联医生
    private String alertPatientSwitch;//0不自动跟踪居民,1自动跟踪预警居民
    private Date createTime;//创建时间
    private Date updateTime;//更新时间
    public String getDoctor() {
        return doctor;
    }
    public void setDoctor(String doctor) {
        this.doctor = doctor;
    }
    public String getAlertPatientSwitch() {
        return alertPatientSwitch;
    }
    public void setAlertPatientSwitch(String alertPatientSwitch) {
        this.alertPatientSwitch = alertPatientSwitch;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
}

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

@ -0,0 +1,104 @@
package com.yihu.hos.device.model;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by Trick on 2018/1/4.
 */
@Entity
@Table(name = "wlyy_track_patient")
public class TrackPatient extends IdEntity {
    private String patientCode;//关联居民code,医生的重点关注对象
    private String patientName;//患者姓名
    private String doctorCode;//所属医生
    private String doctorName;//所属医生名
    private Integer teamCode;//居民签约团队
    private String idcard;//身份证号
    private String ssc;//社保卡号
    private String del;//1正常,0删除
    private Date createTime;//创建时间
    private Date updateTime;//更新时间
    public String getPatientCode() {
        return patientCode;
    }
    public void setPatientCode(String patientCode) {
        this.patientCode = patientCode;
    }
    public String getPatientName() {
        return patientName;
    }
    public void setPatientName(String patientName) {
        this.patientName = patientName;
    }
    public String getDoctorCode() {
        return doctorCode;
    }
    public void setDoctorCode(String doctorCode) {
        this.doctorCode = doctorCode;
    }
    public String getDoctorName() {
        return doctorName;
    }
    public void setDoctorName(String doctorName) {
        this.doctorName = doctorName;
    }
    public Integer getTeamCode() {
        return teamCode;
    }
    public void setTeamCode(Integer teamCode) {
        this.teamCode = teamCode;
    }
    public String getIdcard() {
        return idcard;
    }
    public void setIdcard(String idcard) {
        this.idcard = idcard;
    }
    public String getSsc() {
        return ssc;
    }
    public void setSsc(String ssc) {
        this.ssc = ssc;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
    public String getDel() {
        return del;
    }
    public void setDel(String del) {
        this.del = del;
    }
}

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

@ -68,6 +68,10 @@ public class DeviceService {
    private ImUtill ImUtill;
    @Autowired
    private MessageService messageService;
    @Autowired
    private DoctorSwitchDao doctorSwitchDao;
    @Autowired
    private TrackPatientDao trackPatientDao;
    private ObjectMapper objectMapper = new ObjectMapper();
    private Integer aStart;
@ -511,6 +515,8 @@ public class DeviceService {
            //连续3次异常,修改用户为预警状态
            if( (bloodPressureBbnormalCount >=3 || bloodSuggurBbnormalCount >=3) && (patient.getStandardStatus() == null || 0 == patient.getStandardStatus())){
                patient.setStandardStatus(1);
                //1.4.2加入重点关注逻辑
                setTrackPatientByDoctor(patientCode);
            }else{
                Date end = new Date();
                Date start = DateUtil.setDateTime(end,-7);
@ -518,6 +524,8 @@ public class DeviceService {
                int errorCount = patientHealthIndexDao.getCountByTimeAndStatus(start,end,1,patientCode);
                if(errorCount >= 5){//超过5次,记为预警状态
                    patient.setStandardStatus(1);
                    //1.4.2加入重点关注逻辑
                    setTrackPatientByDoctor(patientCode);
                }
            }
@ -526,18 +534,26 @@ public class DeviceService {
                if("1".equals(patientdisease)){
                    if(0 == bloodPressureBbnormalCount && (patient.getStandardStatus() == null || 1 == patient.getStandardStatus())){
                        patient.setStandardStatus(0);
                        //1.4.2加入重点关注逻辑
                        cancalTrackPatientByDoctor(patientCode);
                    }
                }else if("2".equals(patientdisease)){
                    if(0 == bloodSuggurBbnormalCount && (patient.getStandardStatus() == null || 1 == patient.getStandardStatus())){
                        patient.setStandardStatus(0);
                        //1.4.2加入重点关注逻辑
                        cancalTrackPatientByDoctor(patientCode);
                    }
                }else if( "1,2".equals(patientdisease) || "2,1".equals(patientdisease)){
                    if( 0 == bloodSuggurBbnormalCount && 0 == bloodPressureBbnormalCount && (patient.getStandardStatus() == null || 1 == patient.getStandardStatus())){
                        patient.setStandardStatus(0);
                        //1.4.2加入重点关注逻辑
                        cancalTrackPatientByDoctor(patientCode);
                    }
                }
            }else{
                patient.setStandardStatus(0);
                //1.4.2加入重点关注逻辑
                cancalTrackPatientByDoctor(patientCode);
            }
            patientDao.save(patient);
@ -547,7 +563,134 @@ public class DeviceService {
        }
    }
    
    /**
     * 设置
     * @param patient
     * @return
     */
    public int setTrackPatientByDoctor(String patient){
        SignFamily signFamily = signFamilyDao.findByjiatingPatientYes(patient);
        if(signFamily==null){
            return -1;
        }
        Patient p = patientDao.findByCode(patient);
        if(p==null){
            return -1;
        }
        //医生是否自动追踪居民
        DoctorSwitch sw =  doctorSwitchDao.findByDoctor(signFamily.getDoctor());
        DoctorSwitch swh =  doctorSwitchDao.findByDoctor(signFamily.getDoctorHealth());
        if(sw!=null){
            if("1".equals(sw.getAlertPatientSwitch())){
                //查询是否与医生建立重点跟踪关系,诺无关系则建立
                TrackPatient trackPatient = trackPatientDao.findByDoctorCodeAndPatientCode(signFamily.getDoctor(),patient);
                if(trackPatient == null){
                    TrackPatient t = new TrackPatient();
                    t.setCreateTime(new Date());
                    t.setDoctorCode(signFamily.getDoctor());
                    t.setDoctorName(signFamily.getDoctorName());
                    t.setIdcard(signFamily.getIdcard());
                    t.setSsc(signFamily.getSsc());
                    t.setTeamCode(signFamily.getAdminTeamId().intValue());
                    t.setPatientCode(patient);
                    t.setPatientName(p.getName());
                    t.setDel("1");
                    trackPatientDao.save(t);
                }else{
                    trackPatient.setDel("1");
                    trackPatientDao.save(trackPatient);
                }
            }
        }
        if(swh!=null){
            if("1".equals(sw.getAlertPatientSwitch())){
                //查询是否与医生建立重点跟踪关系,诺无关系则建立
                TrackPatient trackPatient = trackPatientDao.findByDoctorCodeAndPatientCode(signFamily.getDoctorHealth(),patient);
                if(trackPatient == null){
                    TrackPatient t = new TrackPatient();
                    t.setCreateTime(new Date());
                    t.setDoctorCode(signFamily.getDoctorHealth());
                    t.setDoctorName(signFamily.getDoctorHealthName());
                    t.setIdcard(signFamily.getIdcard());
                    t.setSsc(signFamily.getSsc());
                    t.setTeamCode(signFamily.getAdminTeamId().intValue());
                    t.setPatientCode(patient);
                    t.setPatientName(p.getName());
                    t.setDel("1");
                    trackPatientDao.save(t);
                }else{
                    trackPatient.setDel("1");
                    trackPatientDao.save(trackPatient);
                }
            }
        }
        return 1;
    }
    public int cancalTrackPatientByDoctor(String patient){
        SignFamily signFamily = signFamilyDao.findByjiatingPatientYes(patient);
        if(signFamily==null){
            return -1;
        }
        Patient p = patientDao.findByCode(patient);
        if(p==null){
            return -1;
        }
        //医生是否自动追踪居民
        DoctorSwitch sw =  doctorSwitchDao.findByDoctor(signFamily.getDoctor());
        DoctorSwitch swh =  doctorSwitchDao.findByDoctor(signFamily.getDoctorHealth());
        if(sw!=null){
            if("1".equals(sw.getAlertPatientSwitch())){
                //查询是否与医生建立重点跟踪关系,诺无关系则建立
                TrackPatient trackPatient = trackPatientDao.findByDoctorCodeAndPatientCode(signFamily.getDoctor(),patient);
                if(trackPatient == null){
                    TrackPatient t = new TrackPatient();
                    t.setCreateTime(new Date());
                    t.setDoctorCode(signFamily.getDoctor());
                    t.setDoctorName(signFamily.getDoctorName());
                    t.setIdcard(signFamily.getIdcard());
                    t.setSsc(signFamily.getSsc());
                    t.setTeamCode(signFamily.getAdminTeamId().intValue());
                    t.setPatientCode(patient);
                    t.setPatientName(p.getName());
                    t.setDel("0");
                    trackPatientDao.save(t);
                }else{
                    trackPatient.setDel("0");
                    trackPatientDao.save(trackPatient);
                }
            }
        }
        if(swh!=null){
            if("1".equals(sw.getAlertPatientSwitch())){
                //查询是否与医生建立重点跟踪关系,诺无关系则建立
                TrackPatient trackPatient = trackPatientDao.findByDoctorCodeAndPatientCode(signFamily.getDoctorHealth(),patient);
                if(trackPatient == null){
                    TrackPatient t = new TrackPatient();
                    t.setCreateTime(new Date());
                    t.setDoctorCode(signFamily.getDoctorHealth());
                    t.setDoctorName(signFamily.getDoctorHealthName());
                    t.setIdcard(signFamily.getIdcard());
                    t.setSsc(signFamily.getSsc());
                    t.setTeamCode(signFamily.getAdminTeamId().intValue());
                    t.setPatientCode(patient);
                    t.setPatientName(p.getName());
                    t.setDel("0");
                    trackPatientDao.save(t);
                }else{
                    trackPatient.setDel("0");
                    trackPatientDao.save(trackPatient);
                }
            }
        }
        return 1;
    }
    /**
     * 保存设备数据
     */

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

@ -251,10 +251,9 @@ public class SignPatientLabelInfoService extends BaseService {
        //1.4.2 是否追踪居民健康体征
        if(StringUtils.isNotBlank(doctor)){
            String trackSql = "SELECT t.id FROM wlyy_track_patient t WHERE t,patient_code = '"+patient+"' AND t.doctor_code ='"+doctor+"'";
            List<Map<String,Object>> list = jdbcTemplate.queryForList(trackSql);
            if(list!=null&&list.size()>0){
                json.put("isTrack","1");
            TrackPatient tp = trackPatientDao.findByDoctorCodeAndPatientCode(doctor,patient);
            if(tp!=null){
                json.put("isTrack",tp.getDel());
            }else{
                json.put("isTrack","0");
            }
@ -262,10 +261,11 @@ public class SignPatientLabelInfoService extends BaseService {
        return json;
    }
    public String setTrackPatient(String patient,String doctor){
    public String setTrackPatient(String patient,String doctor,String state){
        TrackPatient tp  = trackPatientDao.findByDoctorCodeAndPatientCode(doctor,patient);
        if(tp!=null){
            trackPatientDao.delete(tp);
            tp.setDel(state);
            trackPatientDao.save(tp);
        }else{
            Doctor d = doctorDao.findByCode(doctor);
            Patient p = patientDao.findByCode(patient);
@ -277,6 +277,7 @@ public class SignPatientLabelInfoService extends BaseService {
            tkp.setPatientName(p.getName());
            tkp.setSsc(p.getSsc());
            tkp.setIdcard(p.getIdcard());
            tkp.setDel(state);
            String signSql = "SELECT f.admin_team_code FROM wlyy_sign_family f WHERE (f.doctor = '"+doctor+"' OR f.doctor_health ='"+doctor+"') AND f.patient = '"+patient+"' AND f.status >0 ";
            List<Map<String,Object>> list = jdbcTemplate.queryForList(signSql);
            if(list!=null&&list.size()>0){
@ -286,9 +287,19 @@ public class SignPatientLabelInfoService extends BaseService {
            }else{
                return "-1";
            }
            trackPatientDao.save(tkp);
        }
        return "1";
    }
    public String getTrackFlag(String patient,String doctor){
        TrackPatient tp  = trackPatientDao.findByDoctorCodeAndPatientCode(doctor,patient);
        if(tp!=null){
            return  tp.getDel();
        }else{
            return "0";
        }
    }
    /**
     * 根据标签查询患者信息
     *
@ -404,7 +415,7 @@ public class SignPatientLabelInfoService extends BaseService {
                sql += "  AND p.openid IS NOT NULL AND p.openid <>'' ";
            }
            if(StringUtils.isNotBlank(trackFlag)&&"1".equals(trackFlag)){
                sql = sql + " AND tp.doctor_code ='"+doctor+"' AND tp.team_code"+teamCode;
                sql = sql + " AND tp.del='1'  AND tp.doctor_code ='"+doctor+"' AND tp.team_code"+teamCode;
            }
    
            sql = sql + " order by p.standard_status DESC ,p.disease_condition DESC,t2.label DESC,t1.openid DESC ,convert(t1.name using gbk) ";
@ -1200,7 +1211,7 @@ public class SignPatientLabelInfoService extends BaseService {
                                "     AND t3.disease_condition = ? ";
                                //1.4.2新增重点居民跟踪过滤
                                if(StringUtils.isNotBlank(trackFlag)&&"1".equals(trackFlag)){
                                    sql = sql + " AND tp.doctor_code='"+doctor+"' AND tp.team_code ="+teamCode;
                                    sql = sql + " AND tp.del='1' AND tp.doctor_code='"+doctor+"' AND tp.team_code ="+teamCode;
                                }
                        if (teamCode > 0) {

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

@ -136,7 +136,7 @@ public class DoctorSchemeService extends BaseService{
        //1.4.2加入跟踪居民过滤
        if(StringUtils.isNotBlank(trackFlag)&&"1".equals(trackFlag)){
            sql = sql + " AND pt.doctor_code = '"+doctorcode+"' AND pt.teamCode = "+teamCode;
            sql = sql + "pt.del='1' AND pt.doctor_code = '"+doctorcode+"' AND pt.teamCode = "+teamCode;
        }
@ -792,7 +792,7 @@ public class DoctorSchemeService extends BaseService{
                " AND i.value1 > 6.1 " +
                " AND i.record_date >='"+startDate+"'" +
                " AND i.record_date <='"+endDate+"'" +
                " AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")" +
                " AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")" +
                " ) bf, " +
                " (  " +
                " SELECT " +
@ -806,7 +806,7 @@ public class DoctorSchemeService extends BaseService{
                " AND i.value1 > 7.8 " +
                " AND i.record_date >='"+startDate+"'" +
                " AND i.record_date <='"+endDate+"'" +
                " AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")" +
                " AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")" +
                " ) aft";
        String stdSql ="SELECT  " +
                " (bf.befHighCount + aft.aftHighCount) AS stdCount " +
@ -824,7 +824,7 @@ public class DoctorSchemeService extends BaseService{
                " AND i.value1 >= 3.9 " +
                " AND i.record_date >='"+startDate+"'" +
                " AND i.record_date <='"+endDate+"'" +
                " AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")" +
                " AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")" +
                " ) bf, " +
                " (  " +
                " SELECT " +
@ -839,7 +839,7 @@ public class DoctorSchemeService extends BaseService{
                " AND i.value1 >= 4.4 " +
                " AND i.record_date >='"+startDate+"'" +
                " AND i.record_date <='"+endDate+"'" +
                " AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")" +
                " AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")" +
                " ) aft";
        String lowSql ="SELECT  " +
                " (bf.befHighCount + aft.aftHighCount) AS lowCount " +
@ -856,7 +856,7 @@ public class DoctorSchemeService extends BaseService{
                " AND i.value1 <= 3.9 " +
                " AND i.record_date >='"+startDate+"'" +
                " AND i.record_date <='"+endDate+"'" +
                " AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")" +
                " AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")" +
                " ) bf, " +
                " (  " +
                " SELECT " +
@ -870,7 +870,7 @@ public class DoctorSchemeService extends BaseService{
                " AND i.value1 <= 4.4 " +
                " AND i.record_date >='"+startDate+"'" +
                " AND i.record_date <='"+endDate+"'" +
                " AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")" +
                " AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")" +
                " ) aft";
        String pHighSql ="SELECT " +
@ -883,7 +883,7 @@ public class DoctorSchemeService extends BaseService{
                " AND i.value1 >= 139 " +
                " AND i.record_date >='"+startDate+"'" +
                " AND i.record_date <='"+endDate+"'" +
                " AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")";
                " AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")";
        String  pStdSql ="SELECT " +
                " count(1) AS stdCount " +
                " FROM " +
@ -895,7 +895,7 @@ public class DoctorSchemeService extends BaseService{
                " AND i.value1 >= 90 " +
                " AND i.record_date >='"+startDate+"'" +
                " AND i.record_date <='"+endDate+"'" +
                " AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")";
                " AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")";
        String pLowSql ="SELECT " +
                " count(1) AS lowCount " +
                " FROM " +
@ -906,7 +906,7 @@ public class DoctorSchemeService extends BaseService{
                " AND i.value1 <= 90 " +
                " AND i.record_date >='"+startDate+"'" +
                " AND i.record_date <='"+endDate+"'" +
                " AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")";
                " AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")";
        Map<String,Object> rs = new HashedMap();
        //0血檀
@ -1074,7 +1074,8 @@ public class DoctorSchemeService extends BaseService{
                " FROM " +
                " wlyy_track_patient t " +
                " WHERE " +
                " t.doctor_code = '"+doctor+"' " +
                " t.del='1' " +
                " AND t.doctor_code = '"+doctor+"' " +
                " AND t.team_code = '"+teamCode+"' " +
                " AND t.create_time >= '"+startDate+"' " +
                " AND t.create_time <= '"+endDate+"'";
@ -1140,7 +1141,7 @@ public class DoctorSchemeService extends BaseService{
                " AND t.create_time >= '" + startDate + "' " +
                " AND t.create_time <= '" + endDate + "'" +
                " AND c.patient IN(" +
                "  SELECT t.patient_code FROM wlyy_track_patient t WHERE t.doctor_code ='"+doctor+"' AND t.team_code = " +id+
                "  SELECT t.patient_code FROM wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='"+doctor+"' AND t.team_code = " +id+
                " )" +
                " )c ON c.id = m.doctor_code " +
                " WHERE " +
@ -1157,7 +1158,7 @@ public class DoctorSchemeService extends BaseService{
    public Long getReservationByteam(Long id,String doctor, String startDate, String endDate) {
        //获取待预约
        String reservation_sql = "SELECT COUNT(1) AS reservationCount FROM wlyy_patient_reservation  w WHERE w.admin_team_code =" + id + " AND w.czrq <='" + endDate + "' AND w.czrq >='" + startDate + "' " +
                " AND w.doctor ='"+doctor+"' AND w.patient IN (SELECT t.patient_code FROM wlyy_track_patient t WHERE t.doctor_code ='"+doctor+"' AND t.team_code = " +id+") ";
                " AND w.doctor ='"+doctor+"' AND w.patient IN (SELECT t.patient_code FROM wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='"+doctor+"' AND t.team_code = " +id+") ";
        //获取待预约
        Map<String, Object> reservationCout = jdbcTemplate.queryForMap(reservation_sql);
        if (reservationCout.get("reservationCount") == null) {
@ -1169,7 +1170,7 @@ public class DoctorSchemeService extends BaseService{
    public Long getEduArticleByTeam(Long id,String doctor, String startDate, String endDate) {
        //获取健康教育
        String article_sql = "SELECT COUNT(1) AS articleCount FROM wlyy_health_edu_article_patient w WHERE  w.admin_team_code =" + id + " AND w.czrq <='" + endDate + "' AND w.czrq >='" + startDate + "'" +
                " AND w.doctor ='"+doctor+"' AND w.patient IN (SELECT t.patient_code FROM wlyy_track_patient t WHERE t.doctor_code ='"+doctor+"' AND t.team_code = " +id+") ";
                " AND w.doctor ='"+doctor+"' AND w.patient IN (SELECT t.patient_code FROM wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='"+doctor+"' AND t.team_code = " +id+") ";
        //获取健康教育
        Map<String, Object> articleCout = jdbcTemplate.queryForMap(article_sql);
        if (articleCout.get("articleCount") == null) {
@ -1181,7 +1182,7 @@ public class DoctorSchemeService extends BaseService{
    public Long getGuidanceByTeam(Long id,String doctor, String startDate, String endDate) {
        //获取健康指导
        String guidance_sql = "SELECT COUNT(1) AS guidanceCount  FROM wlyy_patient_health_guidance w WHERE w.admin_team_code =" + id + " AND w.czrq <='" + endDate + "' AND w.czrq >='" + startDate + "' " +
                " AND w.doctor ='"+doctor+"' AND w.patient IN (SELECT t.patient_code FROM wlyy_track_patient t WHERE t.doctor_code ='"+doctor+"' AND t.team_code = " +id+") ";
                " AND w.doctor ='"+doctor+"' AND w.patient IN (SELECT t.patient_code FROM wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='"+doctor+"' AND t.team_code = " +id+") ";
        //获取健康指导
        Map<String, Object> guidanceCout = jdbcTemplate.queryForMap(guidance_sql);
        if (guidanceCout.get("guidanceCount") == null) {
@ -1194,7 +1195,7 @@ public class DoctorSchemeService extends BaseService{
    public Long getFollowByTeam(Long id,String doctor, String startDate, String endDate) {
        //随访数目
        String followup_sql = "SELECT COUNT(1) AS followupCount from wlyy_followup w WHERE w.admin_team_code=" + id + " AND  w.create_time >='" + startDate + "' AND w.create_time<='" + endDate + "' " +
                " AND w.doctor_code ='"+doctor+"' AND w.patient_code IN (SELECT t.patient_code FROM wlyy_track_patient t WHERE t.doctor_code ='"+doctor+"' AND t.team_code = " +id+") ";
                " AND w.doctor_code ='"+doctor+"' AND w.patient_code IN (SELECT t.patient_code FROM wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='"+doctor+"' AND t.team_code = " +id+") ";
        //随访数目
        Map<String, Object> followupCout = jdbcTemplate.queryForMap(followup_sql);
        if (followupCout.get("followupCount") == null) {
@ -1217,7 +1218,7 @@ public class DoctorSchemeService extends BaseService{
                " AND p.patient IN ( " +
                " SELECT t.patient_code " +
                " FROM wlyy_track_patient t " +
                " WHERE t.doctor_code ='"+doctor+"' " +
                " WHERE t.del='1' AND t.doctor_code ='"+doctor+"' " +
                " AND t.team_code = " +id+")";
        //审核数目
        Map<String, Object> reviewedCount = jdbcTemplate.queryForMap(sql);
@ -1243,7 +1244,7 @@ public class DoctorSchemeService extends BaseService{
                "    WHERE  " +
                "   i.`user` in  " +
                "    ( " +
                "     SELECT p.patient_code AS `user` FROM wlyy_track_patient p WHERE p.doctor_code='"+doctor+"' AND p.team_code =" +teamCode+
                "     SELECT p.patient_code AS `user` FROM wlyy_track_patient p WHERE p.del='1' AND p.doctor_code='"+doctor+"' AND p.team_code =" +teamCode+
                "    ) " +
                "  AND i.del ='1' " +
                "  AND i.type = 2  " +
@ -1263,7 +1264,7 @@ public class DoctorSchemeService extends BaseService{
                " WHERE " +
                "  i.`user` in  " +
                "    ( " +
                "     SELECT p.patient_code AS `user` FROM wlyy_track_patient p WHERE p.doctor_code='"+doctor+"' AND p.team_code =" +teamCode+
                "     SELECT p.patient_code AS `user` FROM wlyy_track_patient p WHERE p.del='1' AND p.doctor_code='"+doctor+"' AND p.team_code =" +teamCode+
                "    ) " +
                "  AND " +
                "  i.value1 <= p.sbp  " +
@ -1335,7 +1336,7 @@ public class DoctorSchemeService extends BaseService{
                "    WHERE  " +
                "   i.`user` in  " +
                "    ( " +
                "     SELECT p.patient_code AS `user` FROM wlyy_track_patient p WHERE p.doctor_code='"+doctor+"' AND p.team_code =" +teamCode+
                "     SELECT p.patient_code AS `user` FROM wlyy_track_patient p WHERE p.del='1' AND p.doctor_code='"+doctor+"' AND p.team_code =" +teamCode+
                "    ) " +
                "  AND i.del ='1' " +
                "  AND i.type = 1  " +
@ -1355,7 +1356,7 @@ public class DoctorSchemeService extends BaseService{
                " WHERE " +
                "  i.`user` in  " +
                "    ( " +
                "     SELECT p.patient_code AS `user` FROM wlyy_track_patient p WHERE p.doctor_code='"+doctor+"' AND p.team_code =" +teamCode+
                "     SELECT p.patient_code AS `user` FROM wlyy_track_patient p WHERE p.del='1' AND p.doctor_code='"+doctor+"' AND p.team_code =" +teamCode+
                "    ) " +
                "  AND " +
                "  i.value1 <= p.fbg  " +
@ -1380,7 +1381,8 @@ public class DoctorSchemeService extends BaseService{
                " wlyy_patient_device d JOIN  " +
                " wlyy_track_patient t ON t.patient_code = d.`user` " +
                " WHERE  " +
                " d.category_code = ? " +
                " t.del='1' " +
                " AND d.category_code = ? " +
                " AND t.doctor_code = '"+doctor+"' " +
                " AND t.team_code = "+teamCode;
        Map<String,Object> rs = new HashedMap();

+ 15 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/SignPatientLabelInfoController.java

@ -137,12 +137,25 @@ public class SignPatientLabelInfoController extends BaseController {
        }
    }
    @RequestMapping(value = "/getTrackFlag", method = RequestMethod.POST)
    @ApiOperation("获取重点关注居民状态")
    public String getTrackFlag(@ApiParam(name="patient",value="患者Code")@RequestParam(required = true)String patient){
        try {
            String rs =  labelInfoService.getTrackFlag(patient,getUID());
            return write(200, "查询成功", "data", rs);
        } catch (Exception e) {
            return error(-1, "查询失败");
        }
    }
    @RequestMapping(value = "/setTrackPatient", method = RequestMethod.POST)
    @ApiOperation("设置居民重点关注")
    public String setTrackPatient(@ApiParam(name="patient",value="患者Code")@RequestParam(required = false)String patient){
    public String setTrackPatient(@ApiParam(name="patient",value="患者Code")@RequestParam(required = true)String patient,
                                  @ApiParam(name="state",value="1开启,0删除")@RequestParam(required = true)String state){
        try {
            String rs =  labelInfoService.setTrackPatient(patient,getUID());
            String rs =  labelInfoService.setTrackPatient(patient,getUID(),state);
            if("-1".equals(rs)){
                return error(-1, "查询失败,未找到签约关系");
            }