浏览代码

Merge branch 'dev' of trick9191/patient-co-management into dev

trick9191 7 年之前
父节点
当前提交
c8c62ba9cf

+ 12 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/DoctorSwitchDao.java

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

+ 12 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/PatientAimBloodPressureDao.java

@ -0,0 +1,12 @@
package com.yihu.wlyy.repository.doctor;
import com.yihu.wlyy.entity.patient.PatientAimBloodPressure;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Trick on 2018/1/5.
 */
public interface PatientAimBloodPressureDao extends PagingAndSortingRepository<PatientAimBloodPressure, Integer>, JpaSpecificationExecutor<PatientAimBloodPressure> {
    public  PatientAimBloodPressure findByPatientcode(String patientcode);
}

+ 14 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/PatientAimBloodSuggerDao.java

@ -0,0 +1,14 @@
package com.yihu.wlyy.repository.doctor;
import com.yihu.wlyy.entity.doctor.OperatorLog;
import com.yihu.wlyy.entity.patient.PatientAimBloodSugger;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Trick on 2018/1/5.
 */
public interface PatientAimBloodSuggerDao extends PagingAndSortingRepository<PatientAimBloodSugger, Integer>, JpaSpecificationExecutor<PatientAimBloodSugger> {
    public PatientAimBloodSugger findByPatientcode(String patientcode);
}

+ 17 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/TrackPatientDao.java

@ -0,0 +1,17 @@
package com.yihu.wlyy.repository.patient;
import com.yihu.wlyy.entity.patient.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);
}

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

@ -5,10 +5,7 @@ import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabel;
import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabelInfo;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.PatientDisease;
import com.yihu.wlyy.entity.patient.PatientRemindRecords;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.patient.*;
import com.yihu.wlyy.entity.patient.vo.PatientVO;
import com.yihu.wlyy.entity.statistics.WlyyQuotaResult;
import com.yihu.wlyy.logs.BusinessLogs;
@ -22,6 +19,7 @@ import com.yihu.wlyy.service.app.account.PatientInfoService;
import com.yihu.wlyy.service.app.team.AdminTeamService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.IdCardUtil;
import io.swagger.models.auth.In;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
@ -77,6 +75,8 @@ public class SignPatientLabelInfoService extends BaseService {
    SignPatientLabelInfoDao signPatientLabelInfoDao;
    @Autowired
    PatientInfoService patientInfoService;
    @Autowired
    TrackPatientDao trackPatientDao;
    private final Logger logger = LoggerFactory.getLogger(this.getClass());
@ -87,7 +87,7 @@ public class SignPatientLabelInfoService extends BaseService {
     * @return
     * @throws Exception
     */
    public JSONObject getPatient(String patient) throws Exception {
    public JSONObject getPatient(String patient,String doctor) throws Exception {
        JSONObject json = new JSONObject();
//        Patient p = patientDao.findByCode(patient);
        PatientVO p = patientInfoService.getPatientVOByCode(patient);
@ -249,9 +249,46 @@ public class SignPatientLabelInfoService extends BaseService {
        json.put("countryCode",p.getSickVillage()==null?"":p.getSickVillage());
        json.put("countryName",p.getSickVillageName()==null?"":p.getSickVillageName());
        //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");
            }else{
                json.put("isTrack","0");
            }
        }
        return json;
    }
    public String setTrackPatient(String patient,String doctor){
        TrackPatient tp  = trackPatientDao.findByDoctorCodeAndPatientCode(doctor,patient);
        if(tp!=null){
            trackPatientDao.delete(tp);
        }else{
            Doctor d = doctorDao.findByCode(doctor);
            Patient p = patientDao.findByCode(patient);
            TrackPatient tkp = new TrackPatient();
            tkp.setCreateTime(new Date());
            tkp.setDoctorCode(doctor);
            tkp.setDoctorName(d.getName());
            tkp.setPatientCode(patient);
            tkp.setPatientName(p.getName());
            tkp.setSsc(p.getSsc());
            tkp.setIdcard(p.getIdcard());
            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){
                Map<String,Object> map = list.get(0);
                Integer adminTeamId = (Integer) map.get("admin_team_code");
                tkp.setTeamCode(adminTeamId);
            }else{
                return "-1";
            }
        }
        return "1";
    }
    /**
     * 根据标签查询患者信息
     *

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

@ -3,24 +3,27 @@ package com.yihu.wlyy.service.app.scheme;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.sun.media.jfxmedia.track.Track;
import com.yihu.device.entity.DevicePatientHealthIndex;
import com.yihu.wlyy.entity.doctor.DoctorSwitch;
import com.yihu.wlyy.entity.doctor.scheme.DoctorSchemeBloodPressure;
import com.yihu.wlyy.entity.doctor.scheme.DoctorSchemeBloodSugger;
import com.yihu.wlyy.entity.doctor.scheme.vo.DoctorSchemeBloodPressureVO;
import com.yihu.wlyy.entity.doctor.scheme.vo.DoctorSchemeBloodSuggerVO;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.PatientSchemeList;
import com.yihu.wlyy.entity.patient.*;
import com.yihu.wlyy.entity.patient.vo.PatientVO;
import com.yihu.wlyy.health.repository.DevicePatientHealthIndexDao;
import com.yihu.wlyy.repository.doctor.DoctoreSchemeBloodPressureDao;
import com.yihu.wlyy.repository.doctor.DoctrorSchemeBloodSuggerDao;
import com.yihu.wlyy.repository.doctor.*;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.TrackPatientDao;
import com.yihu.wlyy.repository.patient.scheme.PatientSchemeListDao;
import com.yihu.wlyy.util.DateUtil;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.orm.jpa.JpaTransactionManager;
@ -62,6 +65,21 @@ public class DoctorSchemeService {
    @Autowired
    private DevicePatientHealthIndexDao devicePatientHealthIndexDao;
    @Autowired
    private PatientAimBloodSuggerDao patientAimBloodSuggerDao;
    @Autowired
    private PatientAimBloodPressureDao patientAimBloodPressureDao;
    @Autowired
    private DoctorSwitchDao doctorSwitchDao;
    @Autowired
    private TrackPatientDao trackPatientDao;
    @Value("${im.data_base_name}")
    private String im_dataBase_name;
    /**
     * 根据团队CODE/居民标签/病情/设备绑定状态查询团队具名CODE列表
@ -532,7 +550,13 @@ public class DoctorSchemeService {
//            result.add(sugar_unusual_count);
        }
        //1.4.2 重点关注居民
        List<TrackPatient> list = trackPatientDao.findByDoctorCodeAndTeamcode(doctorcode,Integer.parseInt(teamCode));
        if(list!=null&&list.size()>0){
            result.put("trackPatientCount",list.size());
        }else{
            result.put("trackPatientCount",0);
        }
        return result;
    }
@ -554,4 +578,639 @@ public class DoctorSchemeService {
            doctoreSchemeBloodPressureDao.updateDelStatus(1,doctorcode,schemecode);
        }
    }
    public Map<String,Object> getPatientHealthIndex(String patient,String startDate,String endDate,String type){
        startDate = startDate+" 00:00:00";
        endDate = endDate+" 23:59:59";
        String highSql ="SELECT  " +
                " (bf.befHighCount + aft.aftHighCount) AS highCount " +
                " FROM " +
                " ( " +
                " SELECT " +
                " COUNT(1) AS befHighCount " +
                " FROM " +
                " device.wlyy_patient_health_index i " +
                " WHERE " +
                " i.type = '1' " +
                " AND i.del = '1' " +
                " AND i.value2 in(1,3,5,7) " +
                " AND i.value1 > 6.1 " +
                " AND i.record_date >='"+startDate+"'" +
                " AND i.record_date <='"+endDate+"'" +
                " AND i.user ='"+patient+"'" +
                " ) bf, " +
                " (  " +
                " SELECT " +
                " COUNT(1) AS aftHighCount " +
                " FROM " +
                " device.wlyy_patient_health_index i " +
                " WHERE " +
                " i.type = '1' " +
                " AND i.del = '1' " +
                " AND i.value2 in(2,4,6) " +
                " AND i.value1 > 7.8 " +
                " AND i.record_date >='"+startDate+"'" +
                " AND i.record_date <='"+endDate+"'" +
                " AND i.user ='"+patient+"'" +
                " ) aft";
        String stdSql ="SELECT  " +
                " (bf.befHighCount + aft.aftHighCount) AS stdCount " +
                " FROM " +
                " ( " +
                " SELECT " +
                " COUNT(1) AS befHighCount " +
                " FROM " +
                " device.wlyy_patient_health_index i " +
                " WHERE " +
                " i.type = '1' " +
                " AND i.del = '1' " +
                " AND i.value2 in(1,3,5,7) " +
                " AND i.value1 <= 6.1 " +
                " AND i.value1 >= 3.9 " +
                " AND i.record_date >='"+startDate+"'" +
                " AND i.record_date <='"+endDate+"'" +
                " AND i.user ='"+patient+"'" +
                " ) bf, " +
                " (  " +
                " SELECT " +
                " COUNT(1) AS aftHighCount " +
                " FROM " +
                " device.wlyy_patient_health_index i " +
                " WHERE " +
                " i.type = '1' " +
                " AND i.del = '1' " +
                " AND i.value2 in(2,4,6) " +
                " AND i.value1 <= 7.8 " +
                " AND i.value1 >= 4.4 " +
                " AND i.record_date >='"+startDate+"'" +
                " AND i.record_date <='"+endDate+"'" +
                " AND i.user ='"+patient+"'" +
                " ) aft";
        String lowSql ="SELECT  " +
                " (bf.befHighCount + aft.aftHighCount) AS lowCount " +
                " FROM " +
                " ( " +
                " SELECT " +
                " COUNT(1) AS befHighCount " +
                " FROM " +
                " device.wlyy_patient_health_index i " +
                " WHERE " +
                " i.type = '1' " +
                " AND i.del = '1' " +
                " AND i.value2 in(1,3,5,7) " +
                " AND i.value1 <= 3.9 " +
                " AND i.record_date >='"+startDate+"'" +
                " AND i.record_date <='"+endDate+"'" +
                " AND i.user ='"+patient+"'" +
                " ) bf, " +
                " (  " +
                " SELECT " +
                " COUNT(1) AS aftHighCount " +
                " FROM " +
                " device.wlyy_patient_health_index i " +
                " WHERE " +
                " i.type = '1' " +
                " AND i.del = '1' " +
                " AND i.value2 in(2,4,6) " +
                " AND i.value1 <= 4.4 " +
                " AND i.record_date >='"+startDate+"'" +
                " AND i.record_date <='"+endDate+"'" +
                " AND i.user ='"+patient+"'" +
                " ) aft";
        String pHighSql ="SELECT " +
                " count(1) AS highCount " +
                " FROM " +
                " device.wlyy_patient_health_index i " +
                " WHERE " +
                " i.del = '1' " +
                " AND i.type = '2' " +
                " AND i.value1 >= 139 " +
                " AND i.record_date >='"+startDate+"'" +
                " AND i.record_date <='"+endDate+"'" +
                " AND i.user ='"+patient+"'";
        String  pStdSql ="SELECT " +
                " count(1) AS stdCount " +
                " FROM " +
                " device.wlyy_patient_health_index i " +
                " WHERE " +
                " i.del = '1' " +
                " AND i.type = '2' " +
                " AND i.value1 <= 139 " +
                " AND i.value1 >= 90 " +
                " AND i.record_date >='"+startDate+"'" +
                " AND i.record_date <='"+endDate+"'" +
                " AND i.user ='"+patient+"'";
        String pLowSql ="SELECT " +
                " count(1) AS lowCount " +
                " FROM " +
                " device.wlyy_patient_health_index i " +
                " WHERE " +
                " i.del = '1' " +
                " AND i.type = '2' " +
                " AND i.value1 <= 90 " +
                " AND i.record_date >='"+startDate+"'" +
                " AND i.record_date <='"+endDate+"'" +
                " AND i.user ='"+patient+"'";
        Map<String,Object> rs = new HashedMap();
        //0血檀
        if ("0".equals(type)){
            //1.高
            List<Map<String,Object>> high = jdbcTemplate.queryForList(highSql);
            if(high!=null&&high.size()>0){
                Map<String,Object> h = high.get(0);
                rs.put("highCount",h.get("highCount"));
            }
            //2.正常
            List<Map<String,Object>> std = jdbcTemplate.queryForList(pStdSql);
            if(std!=null&&std.size()>0){
                Map<String,Object> st = std.get(0);
                rs.put("stdCount",st.get("stdCount"));
            }
            //3.偏低
            List<Map<String,Object>> low = jdbcTemplate.queryForList(pLowSql);
            if(low!=null&&low.size()>0){
                Map<String,Object> lw = low.get(0);
                rs.put("lowCount",lw.get("lowCount"));
            }
            //其他血压
        }else{
            //1.高
            List<Map<String,Object>> high = jdbcTemplate.queryForList(pHighSql);
            if(high!=null&&high.size()>0){
                Map<String,Object> h = high.get(0);
                rs.put("highCount",h.get("highCount"));
            }
            //2.正常
            List<Map<String,Object>> std = jdbcTemplate.queryForList(stdSql);
            if(std!=null&&std.size()>0){
                Map<String,Object> st = std.get(0);
                rs.put("stdCount",st.get("stdCount"));
            }
            //3.偏低
            List<Map<String,Object>> low = jdbcTemplate.queryForList(lowSql);
            if(low!=null&&low.size()>0){
                Map<String,Object> lw = low.get(0);
                rs.put("lowCount",lw.get("lowCount"));
            }
        }
        return rs;
    }
    public Map<String,Object> getPatientHealthIndex(String startDate,String endDate,String type,Long teamCode,String doctor){
        startDate = startDate+" 00:00:00";
        endDate = endDate+" 23:59:59";
        String highSql ="SELECT  " +
                " (bf.befHighCount + aft.aftHighCount) AS highCount " +
                " FROM " +
                " ( " +
                " SELECT " +
                " COUNT(1) AS befHighCount " +
                " FROM " +
                " device.wlyy_patient_health_index i " +
                " WHERE " +
                " i.type = '1' " +
                " AND i.del = '1' " +
                " AND i.value2 in(1,3,5,7) " +
                " 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+")" +
                " ) bf, " +
                " (  " +
                " SELECT " +
                " COUNT(1) AS aftHighCount " +
                " FROM " +
                " device.wlyy_patient_health_index i " +
                " WHERE " +
                " i.type = '1' " +
                " AND i.del = '1' " +
                " AND i.value2 in(2,4,6) " +
                " 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+")" +
                " ) aft";
        String stdSql ="SELECT  " +
                " (bf.befHighCount + aft.aftHighCount) AS stdCount " +
                " FROM " +
                " ( " +
                " SELECT " +
                " COUNT(1) AS befHighCount " +
                " FROM " +
                " device.wlyy_patient_health_index i " +
                " WHERE " +
                " i.type = '1' " +
                " AND i.del = '1' " +
                " AND i.value2 in(1,3,5,7) " +
                " AND i.value1 <= 6.1 " +
                " 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+")" +
                " ) bf, " +
                " (  " +
                " SELECT " +
                " COUNT(1) AS aftHighCount " +
                " FROM " +
                " device.wlyy_patient_health_index i " +
                " WHERE " +
                " i.type = '1' " +
                " AND i.del = '1' " +
                " AND i.value2 in(2,4,6) " +
                " AND i.value1 <= 7.8 " +
                " 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+")" +
                " ) aft";
        String lowSql ="SELECT  " +
                " (bf.befHighCount + aft.aftHighCount) AS lowCount " +
                " FROM " +
                " ( " +
                " SELECT " +
                " COUNT(1) AS befHighCount " +
                " FROM " +
                " device.wlyy_patient_health_index i " +
                " WHERE " +
                " i.type = '1' " +
                " AND i.del = '1' " +
                " AND i.value2 in(1,3,5,7) " +
                " 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+")" +
                " ) bf, " +
                " (  " +
                " SELECT " +
                " COUNT(1) AS aftHighCount " +
                " FROM " +
                " device.wlyy_patient_health_index i " +
                " WHERE " +
                " i.type = '1' " +
                " AND i.del = '1' " +
                " AND i.value2 in(2,4,6) " +
                " 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+")" +
                " ) aft";
        String pHighSql ="SELECT " +
                " count(1) AS highCount " +
                " FROM " +
                " device.wlyy_patient_health_index i " +
                " WHERE " +
                " i.del = '1' " +
                " 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.wlyy_track_patient t WHERE t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")";
        String  pStdSql ="SELECT " +
                " count(1) AS stdCount " +
                " FROM " +
                " device.wlyy_patient_health_index i " +
                " WHERE " +
                " i.del = '1' " +
                " AND i.type = '2' " +
                " 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.wlyy_track_patient t WHERE t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")";
        String pLowSql ="SELECT " +
                " count(1) AS lowCount " +
                " FROM " +
                " device.wlyy_patient_health_index i " +
                " WHERE " +
                " i.del = '1' " +
                " 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.wlyy_track_patient t WHERE t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")";
        Map<String,Object> rs = new HashedMap();
        //0血檀
        if ("0".equals(type)){
            //1.高
            List<Map<String,Object>> high = jdbcTemplate.queryForList(highSql);
            if(high!=null&&high.size()>0){
                Map<String,Object> h = high.get(0);
                rs.put("highCount",h.get("highCount"));
            }
            //2.正常
            List<Map<String,Object>> std = jdbcTemplate.queryForList(pStdSql);
            if(std!=null&&std.size()>0){
                Map<String,Object> st = std.get(0);
                rs.put("stdCount",st.get("stdCount"));
            }
            //3.偏低
            List<Map<String,Object>> low = jdbcTemplate.queryForList(pLowSql);
            if(low!=null&&low.size()>0){
                Map<String,Object> lw = low.get(0);
                rs.put("lowCount",lw.get("lowCount"));
            }
        //其他血压
        }else{
            //1.高
            List<Map<String,Object>> high = jdbcTemplate.queryForList(pHighSql);
            if(high!=null&&high.size()>0){
                Map<String,Object> h = high.get(0);
                rs.put("highCount",h.get("highCount"));
            }
            //2.正常
            List<Map<String,Object>> std = jdbcTemplate.queryForList(stdSql);
            if(std!=null&&std.size()>0){
                Map<String,Object> st = std.get(0);
                rs.put("stdCount",st.get("stdCount"));
            }
            //3.偏低
            List<Map<String,Object>> low = jdbcTemplate.queryForList(lowSql);
            if(low!=null&&low.size()>0){
                Map<String,Object> lw = low.get(0);
                rs.put("lowCount",lw.get("lowCount"));
            }
        }
        return rs;
    }
    public Map<String,Object> getTrackPatientInfo(String patient){
        Map<String,Object> rs = new HashedMap();
        rs.put("wxSport",0);
        String hsql = "SELECT " +
                " i.value1 AS weight, " +
                " i.value2 AS height, " +
                " i.value3 AS BMI " +
                " FROM " +
                " device.wlyy_patient_health_index i " +
                " WHERE " +
                " i.del = '1' " +
                " AND i.type = '3'  " +
                " AND i.user ='"+patient+"'" +
                " ORDER BY " +
                " i.record_date DESC LIMIT 1,1";
        String xtSchSql="SELECT " +
                " l.id " +
                " FROM " +
                " wlyy_patient_scheme_list l " +
                " WHERE " +
                " l.type = 1 " +
                " AND l.patientcode = '"+patient+"'";
        String xySchSql="SELECT " +
                " l.id " +
                " FROM " +
                " wlyy_patient_scheme_list l " +
                " WHERE " +
                " l.type = 2 " +
                " AND l.patientcode = '"+patient+"'";
        List<Map<String,Object>> hList = jdbcTemplate.queryForList(hsql);
        if(hList!=null&&hList.size()>0){
            Map<String,Object> body = hList.get(0);
            rs.put("body",body);
        }else{
            rs.put("body",null);
        }
        List<Map<String,Object>> xtList = jdbcTemplate.queryForList(xtSchSql);
        if(xtList!=null&&xtList.size()>0){
            rs.put("sugger","1");
        }else{
            rs.put("sugger","0");
        }
        List<Map<String,Object>> xyList = jdbcTemplate.queryForList(xySchSql);
        if(xyList!=null&&xyList.size()>0){
            rs.put("pressure","1");
        }else{
            rs.put("pressure","0");
        }
        return  rs;
    }
    public Map<String,Object> getControlObjectives(String patient){
        Map<String,Object> rs = new HashedMap();
        PatientAimBloodSugger patientAimBloodSugger =  patientAimBloodSuggerDao.findByPatientcode(patient);
        PatientAimBloodPressure patientAimBloodPressure = patientAimBloodPressureDao.findByPatientcode(patient);
        rs.put("patientAimBloodSugger",patientAimBloodSugger);
        rs.put("patientAimBloodPressure",patientAimBloodPressure);
        return rs;
    }
    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";
        String sql = "SELECT " +
                " i.record_date, " +
                " i.value1 AS weight, " +
                " i.value2 AS height, " +
                " i.value3 AS BMI " +
                " FROM " +
                " device.wlyy_patient_health_index i " +
                " WHERE " +
                " i.del = '1' " +
                " AND i.type = 3 " +
                " AND i.`user` = '"+patient+"' " +
                " AND i.record_date >='"+startDate+"'" +
                " AND i.record_date <='"+endDate+"'"+
                " ORDER BY " +
                " i.record_date DESC LIMIT "+(page-1)*size+","+size;
        List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql);
        return rs;
    }
    public String setDoctorSwitchTrackPatient(String doctor,String state){
        DoctorSwitch doctorSwitch =doctorSwitchDao.findByDoctor(doctor);
        if(doctorSwitch!=null){
            doctorSwitch.setAlertPatientSwitch(state);
        }else{
            DoctorSwitch dw = new DoctorSwitch();
            dw.setDoctor(doctor);
            dw.setAlertPatientSwitch(state);
            dw.setCreateTime(new Date());
            doctorSwitchDao.save(dw);
        }
        return "0";
    }
    public Map<String,Object> getDoctorSwitchTrackPatient(String doctor){
        DoctorSwitch doctorSwitch = doctorSwitchDao.findByDoctor(doctor);
        Map<String,Object> rs = new HashedMap();
        rs.put("alertPatientSwitch",doctorSwitch.getAlertPatientSwitch());
        return rs;
    }
    public Map<String,Object> getTrackPatientCountTitle(Integer teamCode,String doctor,String startDate,String endDate){
        List<TrackPatient> trackPatients = trackPatientDao.findByDoctorCodeAndTeamcode(doctor,teamCode);
        Map<String,Object> rs = new HashedMap();
        rs.put("trackPatientCount",trackPatients.size());
        String sql = "SELECT " +
                " COUNT(1) AS total " +
                " FROM " +
                " wlyy_track_patient t " +
                " WHERE " +
                " t.doctor_code = '"+doctor+"' " +
                " AND t.team_code = '"+teamCode+"' " +
                " AND t.create_time >= '"+startDate+"' " +
                " AND t.create_time <= '"+endDate+"'";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        if(list!=null&&list.size()>0){
            Long total = (Long)list.get(0).get("total");
            rs.put("trackPatientAddCount",total);
        }else{
            rs.put("trackPatientAddCount",0);
        }
        return rs;
    }
    public  Map<String,Object> getTrackPatientServerCount(Long teamCode,String patient,String doctor,String startDate,String endDate){
        startDate = startDate + " 00:00:00";
        endDate = endDate + " 23:59:59";
        Map<String,Object> rs = new  HashedMap();
        //咨询
        rs.put("consultCount",getConsultByteam(teamCode,doctor,startDate,endDate));
        //随访
        rs.put("followupCount",getFollowByTeam(teamCode,doctor,startDate,endDate));
        //获取健康指导
        rs.put("guidanceCount",getGuidanceByTeam(teamCode,doctor,startDate,endDate));
        //获取待预约
        rs.put("reservationCount",getReservationByteam(teamCode,doctor,startDate,endDate));
        //续方审核
        rs.put("reviewedCount",getPresCount(teamCode,doctor,startDate,endDate));
        return rs;
    }
    /**
     * 获取咨询数
     *
     * @param id
     * @param startDate
     * @param endDate
     * @return
     */
    public Long getConsultByteam(Long id, String doctor,String startDate, String endDate) {
        String imDataBaseName = im_dataBase_name;
        //咨询量
        String consult_sql = "SELECT " +
                "  COUNT(1) consultCount " +
                "  FROM " +
                " wlyy_admin_team_member m JOIN(" +
                " SELECT d.id,t.create_time FROM " +
                "  " + imDataBaseName + ".Topics t, " +
                "  " + imDataBaseName + ".Participants p, " +
                "  " + imDataBaseName + ".Doctors d, " +
                "  Wlyy_Consult_Team c, " +
                "  " + imDataBaseName + ".Patients s " +
                "  WHERE " +
                "  d.id = p.participant_id " +
                " AND c.type <> 8  " +
                " AND c.consult = t.id " +
                " AND c.patient = s.id " +
                " AND p.session_id = t.session_id " +
                " AND c.admin_team_code =" + id +
                " 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+
                " )" +
                " )c ON c.id = m.doctor_code " +
                " WHERE " +
                " m.team_id = "  + id+
                " m.doctor_code ='"+doctor+"'" ;
        //获取咨詢數
        Map<String, Object> consultCout = jdbcTemplate.queryForMap(consult_sql);
        if (consultCout.get("consultCount") == null) {
            consultCout.put("consultCount", 0);
        }
        return (Long)consultCout.get("consultCount");
    }
    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+") ";
        //获取待预约
        Map<String, Object> reservationCout = jdbcTemplate.queryForMap(reservation_sql);
        if (reservationCout.get("reservationCount") == null) {
            reservationCout.put("reservationCount", 0);
        }
        return (Long)reservationCout.get("reservationCount");
    }
    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+") ";
        //获取健康教育
        Map<String, Object> articleCout = jdbcTemplate.queryForMap(article_sql);
        if (articleCout.get("articleCount") == null) {
            articleCout.put("articleCount", 0);
        }
        return (Long)articleCout.get("articleCount");
    }
    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+") ";
        //获取健康指导
        Map<String, Object> guidanceCout = jdbcTemplate.queryForMap(guidance_sql);
        if (guidanceCout.get("guidanceCount") == null) {
            guidanceCout.put("guidanceCount", 0);
        }
        return (Long)guidanceCout.get("guidanceCount");
    }
    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+") ";
        //随访数目
        Map<String, Object> followupCout = jdbcTemplate.queryForMap(followup_sql);
        if (followupCout.get("followupCount") == null) {
            followupCout.put("followupCount", 0);
        }
        return (Long)followupCout.get("followupCount");
    }
    public Long getPresCount(Long id,String doctor, String startDate, String endDate){
        String sql ="SELECT " +
                " count(1) AS reviewedCount " +
                " FROM " +
                " wlyy_prescription p " +
                " JOIN wlyy_prescription_reviewed r ON r.prescription_code = p.`code` " +
                " WHERE " +
                " r.doctor = '"+doctor+"' " +
                " AND p.admin_team_id = " + id +
                " AND r.reviewed_time >= '"+startDate+"' " +
                " AND r.reviewed_time <= '"+endDate+"' " +
                " AND p.patient IN ( " +
                " SELECT t.patient_code " +
                " FROM wlyy_track_patient t " +
                " WHERE t.doctor_code ='"+doctor+"' " +
                " AND t.team_code = " +id+")";
        //审核数目
        Map<String, Object> reviewedCount = jdbcTemplate.queryForMap(sql);
        if (reviewedCount.get("reviewedCount") == null) {
            reviewedCount.put("reviewedCount", 0);
        }
        return (Long)reviewedCount.get("reviewedCount");
    }
}

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java

@ -833,7 +833,7 @@ public class FamilyContractService extends BaseService {
     */
    public int unsignRenew(String patient, String doctor) throws Exception {
        if (DateUtil.getNowMonth() < 7) {
        if (4 < DateUtil.getNowMonth() && DateUtil.getNowMonth() < 7) {
            SignFamilyRenew sf = signFamilyRenewDao.findByDoctorPatient(doctor, patient);
            if (sf != null && sf.getStatus() != 0 && sf.getStatus() != 2) {
                return -2;

+ 16 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/SignPatientLabelInfoController.java

@ -130,13 +130,28 @@ public class SignPatientLabelInfoController extends BaseController {
            if (StringUtils.isEmpty(patient)) {
                return error(-1, "居民不能为空");
            }
            JSONObject p = labelInfoService.getPatient(patient);
            JSONObject p = labelInfoService.getPatient(patient,getUID());
            return write(200, "查询成功", "data", p);
        } 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){
        try {
            String rs =  labelInfoService.setTrackPatient(patient,getUID());
            if("-1".equals(rs)){
                return error(-1, "查询失败,未找到签约关系");
            }
            return write(200, "查询成功", "data", rs);
        } catch (Exception e) {
            return error(-1, "查询失败");
        }
    }
    /**
     * 查询某个团队的某个标签下的患者信息
     *

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

@ -153,4 +153,131 @@ public class DoctroSchemeController extends BaseController {
            return error(-1, "操作失败,"+e.getMessage());
        }
    }
    @RequestMapping(value="getPatientHealthIndex",method = RequestMethod.GET)
    @ApiOperation("获取最近一周血糖情况/血压情况")
    public String getPatientHealthIndex(@ApiParam(name="patient", value="居民code") @RequestParam(value = "patient",required = true) String patient,
                                        @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){
        try {
            return write(200, "查询成功", "data",doctorSchemeService.getPatientHealthIndex(patient,startDate, endDate, type));
        }catch (Exception e){
            error(e);
            //返回接口异常信息处理结果
            return error(-1, "查询失败");
        }
    }
    @RequestMapping(value="getTrackPatientInfo",method = RequestMethod.GET)
    @ApiOperation("获取:微信运动,身高体重,血糖监测方案,血压监测方案")
    public String getTrackPatientInfo(@ApiParam(name="patient", value="居民code") @RequestParam(value = "patient",required = true)String patient){
        try {
            return write(200, "查询成功", "data",doctorSchemeService.getTrackPatientInfo(patient));
        }catch (Exception e){
            error(e);
            //返回接口异常信息处理结果
            return error(-1, "查询失败");
        }
    }
    @RequestMapping(value="getControlObjectives",method = RequestMethod.GET)
    @ApiOperation("获取控制目标,血压,血糖")
    public String getControlObjectives(@ApiParam(name="patient", value="居民code") @RequestParam(value = "patient",required = true)String patient){
        try {
            return write(200, "查询成功", "data",doctorSchemeService.getControlObjectives(patient));
        }catch (Exception e){
            error(e);
            //返回接口异常信息处理结果
            return error(-1, "查询失败");
        }
    }
    @RequestMapping(value="getBodyInfo",method = RequestMethod.GET)
    @ApiOperation("获取身高体重详情列表")
    public String getBodyInfo(@ApiParam(name="patient", value="居民code") @RequestParam(value = "patient",required = true)String patient,
                              @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="page", value="起始页") @RequestParam(value = "page",required = true)Integer page,
                              @ApiParam(name="size", value="每页大小") @RequestParam(value = "size",required = true)Integer size){
        try {
            return write(200, "查询成功", "data",doctorSchemeService.getBodyInfo(patient,startDate,endDate,page,size));
        }catch (Exception e){
            error(e);
            //返回接口异常信息处理结果
            return error(-1, "查询失败");
        }
    }
    @RequestMapping(value="setDoctorSwitchTrackPatient",method = RequestMethod.GET)
    @ApiOperation("医生跟踪预警居民开关接口")
    public String setDoctorSwitchTrackPatient(@ApiParam(name="state", value="0不自动跟踪居民,1自动跟踪预警居民") @RequestParam(value = "state",required = true)String state){
        try {
            return write(200, "操作成功", "data",doctorSchemeService.setDoctorSwitchTrackPatient(getUID(),state));
        }catch (Exception e){
            error(e);
            //返回接口异常信息处理结果
            return error(-1, "操作失败");
        }
    }
    @RequestMapping(value="getDoctorSwitchTrackPatient",method = RequestMethod.GET)
    @ApiOperation("医生跟踪预警居民开关接口")
    public String getDoctorSwitchTrackPatient(){
        try {
            return write(200, "查询成功", "data",doctorSchemeService.getDoctorSwitchTrackPatient(getUID()));
        }catch (Exception e){
            error(e);
            //返回接口异常信息处理结果
            return error(-1, "操作失败");
        }
    }
    @RequestMapping(value="getTrackPatientCountTitle",method = RequestMethod.GET)
    @ApiOperation("获取重点跟踪居民数,近一周增加数")
    public String getTrackPatientCountTitle(@ApiParam(name="teamCode", value="团队ID") @RequestParam(value = "teamCode",required = true)Integer teamCode,
                                            @ApiParam(name="startDate", value="开始时间") @RequestParam(value = "startDate",required = true)String startDate,
                                            @ApiParam(name="endDate", value="结束时间") @RequestParam(value = "endDate",required = true)String endDate){
        try {
            return write(200, "查询成功", "data",doctorSchemeService.getTrackPatientCountTitle(teamCode,getUID(),startDate,endDate));
        }catch (Exception e){
            error(e);
            //返回接口异常信息处理结果
            return error(-1, "操作失败");
        }
    }
    @RequestMapping(value="getTrackPatientServerCount",method = RequestMethod.GET)
    @ApiOperation("团队医生下,居民近一周服务情况接口")
    public String getTrackPatientServerCount(@ApiParam(name="teamCode", value="团队ID") @RequestParam(value = "teamCode",required = true)Long teamCode,
                                             @ApiParam(name="patient", value="居民Code") @RequestParam(value = "patient",required = true)String patient,
                                             @ApiParam(name="startDate", value="开始时间") @RequestParam(value = "startDate",required = true)String startDate,
                                             @ApiParam(name="endDate", value="结束时间") @RequestParam(value = "endDate",required = true)String endDate){
        try {
            return write(200, "查询成功", "data",doctorSchemeService.getTrackPatientServerCount(teamCode,patient,getUID(),startDate,endDate));
        }catch (Exception e){
            error(e);
            //返回接口异常信息处理结果
            return error(-1, "操作失败");
        }
    }
    @RequestMapping(value="getPatientHealthIndexByTeam",method = RequestMethod.GET)
    @ApiOperation("获取医生团队最近一周血糖情况/血压情况")
    public String getPatientHealthIndexByTeam(@ApiParam(name="patient", value="居民code") @RequestParam(value = "patient",required = true) String patient,
                                        @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="teamCode", value="团队code") @RequestParam(value = "teamCode",required = true)Long teamCode){
        try {
            return write(200, "查询成功", "data",doctorSchemeService.getPatientHealthIndex(startDate, endDate, type,teamCode,getUID()));
        }catch (Exception e){
            error(e);
            //返回接口异常信息处理结果
            return error(-1, "查询失败");
        }
    }
}