LAPTOP-KB9HII50\70708 10 ماه پیش
والد
کامیت
a77b9b0b67

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

@ -23,6 +23,13 @@ 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" +

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 1 - 12
business/base-service/src/main/java/com/yihu/jw/wlyy/wlyyhttp/WlyyHttpService.java


+ 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,

+ 162 - 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,163 @@ import java.util.Map;
public class StatisticsService {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private WlyyBusinessService wlyyBusinessService;
    //服务情况明细
    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;
    }
    /**
     * 设备上传次数趋势

+ 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());

+ 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
    }
    /**
     * 获取居民标准预警值
     *

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

@ -2201,11 +2201,12 @@ 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" +
        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,a.disease_condition diseaseCondition,a.photo,a.standard_status standardStatus" +
                "FROM base_patient a \n" +
                "INNER JOIN base_patient_doctor_relation b ON a.id=b.patient_id\n" +
                "WHERE 1=1\n" +
                "AND a.disease_condition IN('1','2','3')\n" +
                "AND a.disease_condition IN('1','2','3') " +
                "AND b.doctor_id ='" + doctorId + "'";
        if (StringUtils.isNotBlank(labelType)) {
            if ("1".equals(labelType)) {