Browse Source

代码修改

LAPTOP-KB9HII50\70708 10 months ago
parent
commit
5b9c068e57

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

@ -31,29 +31,31 @@ public class StatisticsService {
     * 4、【家签门诊数】= 时间范围内,同安区的家签居民通过i健康进行预约线下门诊的次数; i健康
     * 5、【本院门诊数】= 时间范围内,同安区的家签居民通过i健康预约本院就诊的次数; i健康
     * 6、【外院门诊数】= 时间范围内,同安区的家签居民通过i健康预约其他医院就诊的次数;i健康
     * 7、【康复下转数】= 时间范围内,三院产生的康复下转总次数;
     * 7、【康复下转数】= 时间范围内,三院产生的康复下转总次数;=8+9
     * 8、【本院管理数】= 时间范围内,三院产生的康复下转中属于本院管理的次数;
     * 9、【社区管理数】= 时间范围内,三院产生的康复下转中属于社区管理的次数;
     * 10、【在线问诊数】= 时间范围内,三院完成的图文咨询、图文复诊、视频咨询、视频复诊、社区协诊总次数;
     * 11、【家签问诊数】= 时间范围内,同安区的家签居民在三院进行图文咨询、图文复诊、视频咨询、视频复诊、社区协诊的次数;
     * 11、【家签问诊数】= 时间范围内,同安区的家签居民在三院进行图文咨询、图文复诊、视频咨询、视频复诊、社区协诊的次数;=3_1
     * 12、【普患问诊数】= 时间范围内,普通患者三院进行图文咨询、图文复诊、视频咨询、视频复诊、社区协诊的次数;
     */
    public void medicalCommunityTop(String startDate,String endDate){
        String sql3 = "SELECT COUNT(DISTINCT s.id) from base_team_relation r,wlyy_sign s WHERE  r.admin_team_id=s.admin_team_id and s.status>0 ";
        String sql7 = "select count(s.id) from wlyy_sign_family s,dm_hospital h " +
                " where s.status>0 and s.hospital=h.`code` and h.town='350212'";
        String sql8 = "select count(s.id) from wlyy_sign_family s,dm_hospital h,wlyy_patient_reservation r " +
                "  where s.status>0 and s.hospital=h.`code` and h.town='350212' and r.patient=s.patient and r.czrq>s.czrq";
        String sql10 = "select count(s.id) from wlyy_sign_family s,dm_hospital h,wlyy_patient_reservation r " +
                "      where s.status>0 and s.hospital=h.`code` and h.town='350212' and r.patient=s.patient " +
                " and r.czrq>s.czrq and r.org_code='350211A1004' ";
        String sql3_1 = "SELECT COUNT(DISTINCT s.id) from wlyy_outpatient r,wlyy_sign s WHERE  r.patient=s.patient and s.status>0 ";
        String sql8 = "select count(s.id) from wlyy_patient_rehabilitation_plan s ";
        String sql10 = "select count(s.id) from wlyy_outpatient s";
        if(StringUtils.isNotBlank(startDate)){
            sql3 += " and s.czrq>'"+startDate+"' ";
            sql3 += " and r.create_time>'"+startDate+"' ";
            sql3_1 += " and r.create_time>'"+startDate+"' ";
            sql8 += " and s.create_time>'"+startDate+"' ";
            sql10 += " and s.create_time>'"+startDate+"' ";
        }
        if(StringUtils.isNotBlank(endDate)){
            sql3 += " and s.czrq<='"+endDate+" 23:59:59' ";
            sql3 += " and r.create_time<='"+endDate+" 23:59:59' ";
            sql3_1 += " and r.create_time<='"+endDate+" 23:59:59' ";
            sql8 += " and s.create_time<='"+endDate+" 23:59:59' ";
            sql10 += " and s.create_time<='"+endDate+" 23:59:59' ";
        }

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

@ -29,6 +29,32 @@ public class ChronicDiseaseController extends EnvelopRestEndpoint {
    @Autowired
    private DoctorSchemeService doctorSchemeService;
    @GetMapping(value = "healthDataStatic")
    @ApiOperation("健康画像统计-线上服务")
    public Envelop healthDataStatic(
            @ApiParam(name = "patient", value = "居民id") @RequestParam(value = "patient", required = true) String patient
    ) {
        try {
            return ObjEnvelop.getSuccess("取消成功",doctorSchemeService.healthDataStatic(patient));
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError("取消失败");
        }
    }
    @GetMapping(value = "healthData")
    @ApiOperation("健康画像")
    public Envelop healthData(
            @ApiParam(name = "patient", value = "居民id") @RequestParam(value = "patient", required = true) String patient
    ) {
        try {
            return ObjEnvelop.getSuccess("取消成功",doctorSchemeService.healthData(patient));
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError("取消失败");
        }
    }
    @GetMapping(value = "isTrack")
    @ApiOperation("是否关注")
    public Envelop isTrack(

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

@ -3,24 +3,26 @@ package com.yihu.jw.hospital.module.health.service.scheme;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.device.dao.DevicePatientHealthIndexDao;
import com.yihu.jw.device.dao.PatientAimBloodPressureDao;
import com.yihu.jw.device.dao.PatientAimBloodSuggerDao;
import com.yihu.jw.device.dao.PatientAimSportsDao;
import com.yihu.jw.device.dao.*;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.device.PatientAimBloodPressure;
import com.yihu.jw.entity.base.device.PatientAimBloodSugger;
import com.yihu.jw.entity.base.device.PatientAimSports;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.entity.care.device.DevicePatientHealthIndex;
import com.yihu.jw.entity.door.WlyySign;
import com.yihu.jw.entity.scheme.*;
import com.yihu.jw.entity.scheme.vo.DoctorSchemeBloodPressureVO;
import com.yihu.jw.entity.scheme.vo.DoctorSchemeBloodSuggerVO;
import com.yihu.jw.hospital.module.health.dao.*;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.patient.PatientVO;
import com.yihu.jw.sign.dao.WlyySignDao;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.wlyy.wlyyhttp.WlyyHttpService;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
@ -78,19 +80,147 @@ public class DoctorSchemeService {
    @Autowired
    private PatientAimBloodPressureDao patientAimBloodPressureDao;
    @Autowired
    private WlyyHttpService wlyyHttpService;
    @Autowired
    private DoctorSwitchDao doctorSwitchDao;
    @Autowired
    private WlyySignDao wlyySignDao;
    @Autowired
    private TrackPatientDao trackPatientDao;
    @Autowired
    private PatientDeviceDao patientDeviceDao;
    @Autowired
    private PatientAimSportsDao patientAimSportsDao;
    @Value("${im.data_base_name}")
    private String im_dataBase_name;
    /**
     * 健康画像统计-线上服务
     * 1、健康咨询次数 = 该居民发起并完成的图文咨询+视频咨询次数总和;
     * 2、在线复诊次数 = 该居民发起并完成的图文复诊+视频复诊次数总和;
     * 3、在线处方次数 = 该居民通过图文复诊、视频复诊收到并完成支付的处方数量;
     * 4、上转(基层)次数 = 该居民的家庭医生通过i健康为该居民代预约等级医院的次数总和;
     * 5、下转(基层)次数 = 三院医生为该居民康复下转至社区的次数总和;
     * 6、远程协诊发起次数 = 该居民通过社区发起专科协统的次数总和。
     */
    public JSONObject healthDataStatic(String patient){
        JSONObject json = new JSONObject();
        String sql = "SELECT count(if(outpatient_type='3',1,null)) zxNum,count(if(outpatient_type='1',1,null)) fzNum" +
                " from wlyy_outpatient where patient='"+patient+"'";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        String sql2 = "select count(1) from wlyy_prescription where patient_code='"+patient+"' and status>=30 ";
        int preNum = jdbcTemplate.queryForObject(sql2,Integer.class);
        json.put("zxNum",list.get(0).get("zxNum"));//健康咨询次数
        json.put("fzNum",list.get(0).get("fzNum"));//在线复诊次数
        json.put("preNum",preNum);//在线处方次数
        int turnUpNum=0;//上转(基层)次数
        int turnDownNum=0;//下转(基层)次数
        int coNum=0;//下转(基层)次数
        //请求i健康
        try{
            BasePatientDO patientDO = patientDao.findByIdAndDel(patient,"1");
            String configId = "commonGet";
            String param = "?idcard="+patientDO.getIdcard();
            JSONObject re = wlyyHttpService.sendWlyyMesGet(configId, "healthDataStatic" + param);
            if(re!=null&&re.getInteger("status")==200){
                JSONObject data = re.getJSONObject("data");
                turnUpNum = data.getInteger("turnUpNum");
                turnDownNum = data.getInteger("turnDownNum");
                coNum = data.getInteger("coNum");
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        json.put("turnUpNum",turnUpNum);//上转(基层)次数
        json.put("turnDownNum",turnDownNum);//下转(基层)次数
        json.put("coNum",coNum);//下转(基层)次数
        return json;
    }
    //健康画像
    public JSONObject healthData(String patient){
        JSONObject json = new JSONObject();
        BasePatientDO patientDO = patientDao.findByIdAndDel(patient,"1");
        json.put("id",patientDO.getId());//居民id
        json.put("name",patientDO.getName());//姓名
        json.put("idcard",patientDO.getIdcard());//身份证
        json.put("mobile",patientDO.getMobile());//手机号
        json.put("photo",patientDO.getPhoto());//头像
        json.put("sex",patientDO.getSex());//性别
        json.put("birthday",DateUtil.dateToStrShort(patientDO.getBirthday()));//出生日期
        json.put("age", IdCardUtil.getAgeByIdcardOrBirthday(patientDO.getIdcard(),patientDO.getBirthday()));//年龄
        String isDrug = "0";
        String sql2 = "select count(1) from wlyy_prescription where patient_code='"+patient+"' ";
        int preNum = jdbcTemplate.queryForObject(sql2,Integer.class);
        if(preNum>0){
            isDrug = "1";
        }
        String sql3 = "select count(1) from wlyy_patient_rehabilitation_plan where patient='"+patient+"' ";
        String isZb = "0";
        int zbNum = jdbcTemplate.queryForObject(sql3,Integer.class);
        if(zbNum>0){
            isZb = "1";
        }
        json.put("isZb",isZb);//是否专病 1是0否
        json.put("isDrug",isDrug);//是否用药 1是0否
        String xtDevice = "0";//
        String xyDevice = "1";//
        List<DevicePatientDevice> deviceList = patientDeviceDao.findByPatient(patient);
        for (DevicePatientDevice device:deviceList){
            if("1".equals(device.getCategoryCode())){
                xtDevice = "1";
            }
            if("2".equals(device.getCategoryCode())){
                xyDevice = "1";
            }
        }
        String isSign = "0";//
        String doctorName = "";//
        String hospitalName = "";//
        WlyySign sign = wlyySignDao.findByPatient(patient);
        if(sign!=null&&"1".equals(sign.getStatus())){
            isSign = "1";
            doctorName = sign.getDoctorName();
            hospitalName = sign.getHospitalName();
        }
        json.put("xtDevice",xtDevice);//是否绑定血糖仪 1是0否
        json.put("xyDevice",xyDevice);//是否绑定血压计 1是0否
        json.put("isSign",isSign);//是否签约家庭医生 1是0否
        json.put("doctorName",doctorName);//家庭医生
        json.put("hospitalName",hospitalName);//签约社区
        String sql1 = "SELECT DISTINCT dept_name from wlyy_outpatient where patient='"+patient+"' order by create_time desc LIMIT 4";
        List<Map<String,Object>> deptList = jdbcTemplate.queryForList(sql1);
        json.put("deptList",deptList);//门诊科室
        DevicePatientHealthIndex healthIndex1 = findLatelyIndex(patient,"1");
        DevicePatientHealthIndex healthIndex2 = findLatelyIndex(patient,"2");
        DevicePatientHealthIndex healthIndex3 = findLatelyIndex(patient,"3");
        json.put("healthIndex1",healthIndex1);//最近一次血糖数据
        json.put("healthIndex2",healthIndex2);//最近一次血压数据
        json.put("healthIndex3",healthIndex3);//最近一次身高体征数据
        String labelSql = "SELECT label_name disease from wlyy_patient_label WHERE patient = '"+patient+"' and label_type='2' ";
        List<Map<String,Object>> diseaseList = jdbcTemplate.queryForList(labelSql);
        json.put("diseaseList",diseaseList);//慢病类型
        String zbSql = "SELECT distinct disease_name zbName from wlyy_patient_rehabilitation_plan WHERE patient = '"+patient+"' and status='1' ";
        List<Map<String,Object>> zbList = jdbcTemplate.queryForList(labelSql);
        json.put("zbList",zbList);//专病类型
        String sql5 = "SELECT DISTINCT doctor_name from wlyy_outpatient where patient='"+patient+"' order by create_time desc LIMIT 6";
        List<Map<String,Object>> doctorList = jdbcTemplate.queryForList(sql5);
        json.put("doctorList",doctorList);//专科医生
        return json;
    }
    //取消重点关注
    public void delTrack(String patient,String doctor){
        synchronized (patient.intern()){