2 Ревизии 1b4b6c33af ... c19cd0701d

Автор SHA1 Съобщение Дата
  LAPTOP-KB9HII50\70708 c19cd0701d Merge branch '2.0' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into 2.0 преди 2 месеца
  LAPTOP-KB9HII50\70708 68f86449b3 代码修改 преди 2 месеца
променени са 20 файла, в които са добавени 1581 реда и са изтрити 642 реда
  1. 320 9
      business/base-service/src/main/java/com/yihu/jw/hospital/disease/service/BaseDiseaseHospitalService.java
  2. 3 0
      business/base-service/src/main/java/com/yihu/jw/hospital/survey/dao/BaseDiseaseSurveyDao.java
  3. 14 0
      business/base-service/src/main/java/com/yihu/jw/hospital/survey/dao/SurveyScreenResultSynDao.java
  4. 11 0
      business/base-service/src/main/java/com/yihu/jw/hospital/survey/dao/SurveyThirdDao.java
  5. 11 0
      business/base-service/src/main/java/com/yihu/jw/hospital/survey/dao/WlyySurveyRecordDao.java
  6. 5 8
      business/base-service/src/main/java/com/yihu/jw/wlyy/service/WlyyBusinessService.java
  7. 96 1
      common/common-entity/src/db/2024.sql
  8. 1 0
      common/common-entity/src/main/java/com/yihu/jw/entity/followup/Followup.java
  9. 468 0
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/survey/SurveyScreenResultSyn.java
  10. 55 0
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/survey/SurveyThird.java
  11. 128 0
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/survey/WlyySurveyRecordDO.java
  12. 38 2
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/utils/ExportUtl.java
  13. 10 0
      svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/event/ApplicationEvent.java
  14. 35 0
      svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/job/ijk/SurveyScreenResultSynJob.java
  15. 17 0
      svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/web/quota/JobController.java
  16. 120 49
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/specialist/BaseDiseaseHospitalController.java
  17. 1 1
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/common/StatisticsController.java
  18. 108 37
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/followup/controller/DoctorFollowUpController.java
  19. 131 399
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/followup/service/FollowUpService.java
  20. 9 136
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/rehabilitation/service/SynchronizePatientService.java

+ 320 - 9
business/base-service/src/main/java/com/yihu/jw/hospital/disease/service/BaseDiseaseHospitalService.java

@ -1,28 +1,42 @@
package com.yihu.jw.hospital.disease.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.sms.SmsTemplateDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.entity.hospital.survey.BaseDiseaseSurveyDO;
import com.yihu.jw.entity.hospital.survey.SurveyScreenResultSyn;
import com.yihu.jw.entity.hospital.survey.SurveyThird;
import com.yihu.jw.entity.hospital.survey.WlyySurveyRecordDO;
import com.yihu.jw.entity.specialist.BaseDiseaseHospitalDO;
import com.yihu.jw.entity.specialist.rehabilitation.RehabilitationPlanTemplateDO;
import com.yihu.jw.entity.specialist.rehabilitation.RehabilitationTemplateDetailDO;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.hospital.disease.dao.BaseDiseaseHospitalDao;
import com.yihu.jw.hospital.disease.dao.RehabilitationPlanTemplateDao;
import com.yihu.jw.hospital.disease.dao.RehabilitationTemplateDetailDao;
import com.yihu.jw.hospital.prescription.service.DsyyPrescriptionService;
import com.yihu.jw.hospital.survey.dao.BaseDiseaseSurveyDao;
import com.yihu.jw.hospital.survey.dao.SurveyScreenResultSynDao;
import com.yihu.jw.hospital.survey.dao.SurveyThirdDao;
import com.yihu.jw.hospital.survey.dao.WlyySurveyRecordDao;
import com.yihu.jw.mysql.query.BaseJpaService;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.sms.dao.BaseSmsTemplateDao;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.utils.AES;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.jw.wlyy.service.WlyyBusinessService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.stereotype.Service;
@ -51,22 +65,322 @@ public class BaseDiseaseHospitalService extends BaseJpaService<BaseDiseaseHospit
    private BaseDoctorDao doctorDao;
    @Autowired
    private DsyyPrescriptionService dsyyPrescriptionService;
    @Autowired
    private WlyySurveyRecordDao wlyySurveyRecordDao;
    @Autowired
    private SurveyScreenResultSynDao surveyScreenResultSynDao;
    @Autowired
    private WlyyHospitalSysDictDao wlyyHospitalSysDictDao;
    @Autowired
    private SurveyThirdDao surveyThirdDao;
    @Value("${wechat.id}")
    private String wxId;
    public void manageSurveyReocrd(String id,String status,String doctor){
        WlyySurveyRecordDO recordDO = wlyySurveyRecordDao.findById(id).orElse(null);
        recordDO.setStatus(status);
        recordDO.setOperateTime(DateUtil.getStringDate());
        recordDO.setDoctor(doctor);
        BaseDoctorDO doctorDO = doctorDao.findByIdAndDel(doctor);
        recordDO.setDoctorName(doctorDO.getName());
        wlyySurveyRecordDao.save(recordDO);
    }
    public List<WlyySurveyRecordDO> surveyRecordList(String name, String idcard, String startDate, String endDate, String mobile,
                                        String status,String dept,String diseaseCode){
        String sql = "SELECT DISTINCT r.*,s.name diseaseName,s.dept_name deptName,d.dict_value statusName ";
        String filter = " FROM wlyy_survey_record r " +
                " inner join base_disease_survey s on r.disease_code=s.id " +
                " left join wlyy_hospital_sys_dict d on d.dict_name='surveyRecordStatus' and d.dict_code=r.status " +
                " WHERE 1=1 ";
        if(StringUtils.isNotBlank(status)){
            filter += " and r.status='"+status+"' ";
        }
        if(StringUtils.isNotBlank(dept)){
            filter += " and s.dept='"+dept+"' ";
        }
        if(StringUtils.isNotBlank(diseaseCode)){
            if(diseaseCode.contains(",")){
                diseaseCode = diseaseCode.replace(",","','");
                diseaseCode = " in ('"+diseaseCode+"') ";
            }else {
                diseaseCode = " = '"+diseaseCode+"' ";
            }
            filter += " and r.disease_code "+diseaseCode+" ";
        }
        if (StringUtils.isNotBlank(name)){
            filter += " and r.name like '%" + name + "%'   ";
        }
        if (StringUtils.isNotBlank(idcard)){
            filter += " and  r.idcard like '%" + idcard + "%'  ";
        }
        if (StringUtils.isNotBlank(mobile)){
            filter += " and  r.mobile like '%" + mobile + "%'  ";
        }
        if (StringUtils.isNotBlank(startDate)){
            filter += " and r.create_time>='"+startDate+"' ";
        }
        if (StringUtils.isNotBlank(endDate)){
            filter += " and r.create_time<='"+endDate+" 23:59:59' ";
        }
        String orderBy = " order by create_time desc ";
        List<WlyySurveyRecordDO> list = jdbcTemplate.query(sql+filter+orderBy,new BeanPropertyRowMapper<>(WlyySurveyRecordDO.class));
        return list;
    }
    //筛查患者管理
    public PageEnvelop surveyRecordPage(String name, String idcard, String startDate, String endDate, String mobile,
                                        String status, Integer page, Integer size,String dept,String diseaseCode){
        String sql = "SELECT DISTINCT r.*,s.name diseaseName,s.dept_name deptName,d.dict_value statusName ";
        String countSql = "select count(r.id) ";
        String filter = " FROM wlyy_survey_record r " +
                " inner join base_disease_survey s on r.disease_code=s.id " +
                " left join wlyy_hospital_sys_dict d on d.dict_name='surveyRecordStatus' and d.dict_code=r.status " +
                " WHERE 1=1 ";
        if(StringUtils.isNotBlank(status)){
            filter += " and r.status='"+status+"' ";
        }
        if(StringUtils.isNotBlank(dept)){
            filter += " and s.dept='"+dept+"' ";
        }
        if(StringUtils.isNotBlank(diseaseCode)){
            if(diseaseCode.contains(",")){
                diseaseCode = diseaseCode.replace(",","','");
                diseaseCode = " in ('"+diseaseCode+"') ";
            }else {
                diseaseCode = " = '"+diseaseCode+"' ";
            }
            filter += " and r.disease_code "+diseaseCode+" ";
        }
        if (StringUtils.isNotBlank(name)){
            filter += " and r.name like '%" + name + "%'   ";
        }
        if (StringUtils.isNotBlank(idcard)){
            filter += " and  r.idcard like '%" + idcard + "%'  ";
        }
        if (StringUtils.isNotBlank(mobile)){
            filter += " and  r.mobile like '%" + mobile + "%'  ";
        }
        if (StringUtils.isNotBlank(startDate)){
            filter += " and r.create_time>='"+startDate+"' ";
        }
        if (StringUtils.isNotBlank(endDate)){
            filter += " and r.create_time<='"+endDate+" 23:59:59' ";
        }
        String orderBy = " order by create_time desc limit "+(page-1)*size+","+size;
        List<WlyySurveyRecordDO> list = jdbcTemplate.query(sql+filter+orderBy,new BeanPropertyRowMapper<>(WlyySurveyRecordDO.class));
        long count = jdbcTemplate.queryForObject(countSql+filter,Long.class);
        return PageEnvelop.getSuccessListWithPage("查询成功",list,page,size,count);
    }
    /**
     * 同安筛查记录
     * @param hospital 社区code
     * @param patientName 居民姓名
     * @param startDate 开始时间
     * @param endDate 结束时间
     * @param templateCode 模板code
     * @param isDanger 是否高危预警(0不是  1是)
     * @param manageStatus 管理状态 0待处理 1已管理 2 日常健康管理
     * @param page 第几页
     * @param size 分页大小
     */
    public PageEnvelop findThirdScreenList(String hospital, String patientName, String startDate, String endDate, String templateCode,
                                           String isDanger, String manageStatus, Integer page, Integer size, String isManager,String doctor,String diseaseCode){
        String sql = "SELECT DISTINCT ssr.id,ssr.`code`,ssr.template_code templateCode,ssr.template_title templateTitle," +
                "s.id diseaseCode,s.name diseaseName,ssr.patient_name patientName,ssr.idcard,ssr.photo,ssr.sex," +
                "ssr.screen_result_code screenResultCode,ssr.screen_result_score screenResultScore,ssr.screen_result screenResult,ssr.is_danger isDanger,ssr.mobile," +
                "DATE_FORMAT(ssr.czrq, '%Y-%m-%d %H:%i:%s') czrq,ssr.third_advice thirdAdvice," +
                "if(ssr.is_danger=1,if(t.id is not null,'已管理','待处理'),'日常健康管理') manageStatus ";
        String countSql = "select count(ssr.id) ";
        String filter = " FROM wlyy_survey_screen_result_syn ssr " +
                " inner join base_disease_survey s on ssr.template_code=s.survey_code and s.status=1 " +
                " left join wlyy_survey_third t on ssr.code=t.survey_code and t.disease_code=s.id " +
                " WHERE ssr.is_over=1 and ssr.town='350212' ";
        if(StringUtils.isNotBlank(hospital)){
            filter += " and ssr.code='"+hospital+"' ";
        }
        if(StringUtils.isNotBlank(diseaseCode)){
            if(diseaseCode.contains(",")){
                diseaseCode = diseaseCode.replace(",","','");
                diseaseCode = " in ('"+diseaseCode+"') ";
            }else {
                diseaseCode = " = '"+diseaseCode+"' ";
            }
            filter += " and s.id "+diseaseCode+" ";
        }
        if (StringUtils.isNotBlank(patientName)){
            filter += " and (ssr.patient_name like '%" + patientName + "%' or ssr.idcard like '%" + patientName + "%')  ";
        }
        if (StringUtils.isNotBlank(templateCode)){
            if(templateCode.contains(",")){
                templateCode = templateCode.replace(",","','");
                templateCode = " in ('"+templateCode+"') ";
            }else {
                templateCode = " = '"+templateCode+"' ";
            }
            filter += " and ssr.template_code "+templateCode+" ";
        }
        if (StringUtils.isNotBlank(isDanger)){
            if("1".equals(isDanger)){
                filter += " and ssr.is_danger='1' ";
            }else {
                filter += " and (ssr.is_danger ='0' or ssr.is_danger is null) ";
            }
        }
        if("0".equals(isManager)){
            filter += " and s.doctor like '%"+doctor+"%' ";
        }
        if (StringUtils.isNotBlank(manageStatus)){
            if("0".equals(manageStatus)){
                filter += " and ssr.is_danger='1' and t.id is null ";
            }else if("1".equals(manageStatus)){
                filter += " and t.id is not null ";
            }else if("2".equals(manageStatus)){
                filter += " and (ssr.is_danger ='0' or ssr.is_danger is null) ";
            }
        }
        if (StringUtils.isNotBlank(startDate)){
            filter += " and ssr.czrq>='"+startDate+"' ";
        }
        if (StringUtils.isNotBlank(endDate)){
            filter += " and ssr.czrq<='"+endDate+" 23:59:59' ";
        }
        String orderBy = " order by id desc limit "+(page-1)*size+","+size;
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql+filter+orderBy);
        for (Map<String, Object> vo : list) {
            String idcard = vo.get("idcard")+"";
            String birthday = vo.get("birthday")+"";
            Integer age = IdCardUtil.getAgeByBirthdayOrIdcard(idcard,DateUtil.strToDate(birthday));
            vo.put("age", age);
        }
        long count = jdbcTemplate.queryForObject(countSql+filter,Long.class);
        return PageEnvelop.getSuccessListWithPage("查询成功",list,page,size,count);
    }
    public JSONObject getThirdNum(String doctorId){
        JSONObject json = new JSONObject();
        String countSql = "select count(ssr.id) FROM wlyy_survey_screen_result_syn ssr " +
                " inner join base_disease_survey s on ssr.template_code=s.survey_code and s.status=1 " +
                " left join wlyy_survey_third t on ssr.code=t.survey_code and t.disease_code=s.id " +
                " WHERE ssr.is_over=1 and ssr.town='350212' and ssr.is_danger='1' and t.id is null ";
        countSql += " and ssr.czrq>='"+ DateUtil.getCurMonthFirstDayShort() +"' ";
        long waitNum = jdbcTemplate.queryForObject(countSql,Long.class);
        json.put("waitNum",waitNum);
        BaseDoctorDO doctorDO = doctorDao.findByIdAndDel(doctorId);
        JSONObject jsonObj =  wlyyBusinessService.getThirdNum(doctorDO.getIdcard());
        if(jsonObj!=null){
            json.put("dangerNum",jsonObj.get("obj"));
        }else{
            json.put("dangerNum","0");
        }
        JSONObject result = new JSONObject();
        result.put("obj", json);
        result.put("status", 200);
        return result;
    }
    //同步i健康疾病筛查结果
    public void synIjkSurvryScreenResult(){
        WlyyHospitalSysDictDO dictDO = wlyyHospitalSysDictDao.findById("surveyScreenResultId").orElse(null);
        if(dictDO!=null){
            String surveyScreenResultId = dictDO.getDictCode();
            String size = dictDO.getPyCode();
            JSONObject json = wlyyBusinessService.findThirdScreenListSyn(surveyScreenResultId,size);
            if(json != null){
                JSONArray jsonArray = json.getJSONArray("detailModelList");
                if(jsonArray != null){
                    boolean isUsed = false;
                    for (int i=0;i<jsonArray.size();i++){
                        try {
                            SurveyScreenResultSyn resultSyn = JSON.parseObject(jsonArray.getJSONObject(i).toJSONString(), SurveyScreenResultSyn.class);
                            resultSyn.setIjkId(resultSyn.getId());
                            surveyScreenResultSynDao.save(resultSyn);
                            isUsed = true;
                        }catch (Exception e){
                            e.printStackTrace();
                        }
                    }
                    if(isUsed){
                        String sql = "select max(ijk_id) id from wlyy_survey_screen_result_syn ";
                        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
                        if(list.size()>0){
                            dictDO.setDictCode(list.get(0).get("id")+"");
                            dictDO.setDictValue(DateUtil.getStringDate());
                            wlyyHospitalSysDictDao.save(dictDO);
                        }
                    }
                }
            }
        }
    }
    //疾病筛查管理发送短信
    public void sendSms(String mobiles,String surveyCodes,String smsTemplateId,String content,String header,String doctor){
    public void sendSms(String jsonData,String smsTemplateId,String content,String header,String doctor){
        JSONArray jsonArray = JSON.parseArray(jsonData);
        BaseDoctorDO doctorDO = doctorDao.findByIdAndDel(doctor);
        Map<String,Integer> map = new HashMap<>();
        String mobile[] = mobiles.split(",");
        for (String key:mobile){
            if(!map.containsKey(key)){
                map.put(key,1);
        Map<String,Integer> mapRecord = new HashMap<>();
        Date now = new Date();
        for (int i =0;i<jsonArray.size();i++){
            JSONObject json = jsonArray.getJSONObject(i);
            String mobile = json.getString("mobile");
            String surveyCode = json.getString("surveyCode");
            String diseaseCode = json.getString("diseaseCode");
            //发送短信
            if(!map.containsKey(mobile)){
                map.put(mobile,1);
                try {
                    dsyyPrescriptionService.SendSms(key, content);
                    if("xm_dsyy_wx".equals(wxId)){
                        dsyyPrescriptionService.SendSms(mobile, content);
                    }
                }catch (Exception e){
                    e.printStackTrace();
                }
            }
            SurveyScreenResultSyn surveyScreenResult = surveyScreenResultSynDao.findByCode(surveyCode);
            String patient = surveyScreenResult.getPatientCode();
            String templateCode = surveyScreenResult.getTemplateCode();
            String value = patient+"_" +templateCode+"_"+diseaseCode;
            if(!mapRecord.containsKey(value)){
                mapRecord.put(value,1);
                //添加发送记录
                String sql = "select a.code as survey_code from  wlyy_survey_screen_result_syn a " +
                        " LEFT JOIN wlyy_survey_third t on a.`code`=t.survey_code and t.disease_code='"+diseaseCode+"' " +
                        " where a.patient_code='"+patient+"' and a.template_code='"+templateCode+"' and t.id is null";
                List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
                for (Map<String, Object> survey :list){
                    SurveyThird third = new SurveyThird();
                    third.setDoctor(doctor);
                    third.setPatient(patient);
                    third.setDiseaseCode(diseaseCode);
                    third.setSurveyCode(survey.get("survey_code")+"");
                    third.setCreateTime(now);
                    surveyThirdDao.save(third);
                }
                //添加管理记录
                WlyySurveyRecordDO recordDO = new WlyySurveyRecordDO();
                recordDO.setDiseaseCode(diseaseCode);
                recordDO.setDoctor(doctor);
                recordDO.setDoctorName(doctorDO.getName());
                recordDO.setIdcard(surveyScreenResult.getIdcard());
                recordDO.setMobile(surveyScreenResult.getMobile());
                recordDO.setName(surveyScreenResult.getPatientName());
                recordDO.setContent(content);
                recordDO.setCreateTime(new Date());
                recordDO.setStatus("0");
                wlyySurveyRecordDao.save(recordDO);
            }
        }
        //修改短信模板
        SmsTemplateDO smsTemplateDO = findSmsTemplate(smsTemplateId);
        if(smsTemplateDO==null){
            smsTemplateDO = new SmsTemplateDO();
@ -78,9 +392,6 @@ public class BaseDiseaseHospitalService extends BaseJpaService<BaseDiseaseHospit
        smsTemplateDO.setContent(content);
        smsTemplateDO.setHeader(header);
        baseSmsTemplateDao.save(smsTemplateDO);
        //添加i健康发送记录
        wlyyBusinessService.addSurveyThird(surveyCodes,doctorDO.getIdcard());
    }
    public SmsTemplateDO findSmsTemplate(String id){

+ 3 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/survey/dao/BaseDiseaseSurveyDao.java

@ -3,10 +3,13 @@ package com.yihu.jw.hospital.survey.dao;
import com.yihu.jw.entity.hospital.survey.BaseDiseaseSurveyDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
/**
 * Created by yeshijie on 2024/8/19.
 */
public interface BaseDiseaseSurveyDao extends JpaRepository<BaseDiseaseSurveyDO, String>, JpaSpecificationExecutor<BaseDiseaseSurveyDO> {
    @Query("from BaseDiseaseSurveyDO c WHERE c.surveyCode = ?1 and c.status ='1' ")
    BaseDiseaseSurveyDO findBySurveyCode(String surveyCode);
}

+ 14 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/survey/dao/SurveyScreenResultSynDao.java

@ -0,0 +1,14 @@
package com.yihu.jw.hospital.survey.dao;
import com.yihu.jw.entity.hospital.survey.SurveyScreenResultSyn;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
 * Created by yeshijie on 2024/8/30.
 */
public interface SurveyScreenResultSynDao extends JpaRepository<SurveyScreenResultSyn, String>,
        JpaSpecificationExecutor<SurveyScreenResultSyn> {
    SurveyScreenResultSyn findByCode(String code);
}

+ 11 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/survey/dao/SurveyThirdDao.java

@ -0,0 +1,11 @@
package com.yihu.jw.hospital.survey.dao;
import com.yihu.jw.entity.hospital.survey.SurveyThird;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by yeshijie on 2024/8/20.
 */
public interface SurveyThirdDao extends PagingAndSortingRepository<SurveyThird, String> {
}

+ 11 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/survey/dao/WlyySurveyRecordDao.java

@ -0,0 +1,11 @@
package com.yihu.jw.hospital.survey.dao;
import com.yihu.jw.entity.hospital.survey.WlyySurveyRecordDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
 * Created by yeshijie on 2024/8/29.
 */
public interface WlyySurveyRecordDao extends JpaRepository<WlyySurveyRecordDO, String>, JpaSpecificationExecutor<WlyySurveyRecordDO> {
}

+ 5 - 8
business/base-service/src/main/java/com/yihu/jw/wlyy/service/WlyyBusinessService.java

@ -896,17 +896,14 @@ public class WlyyBusinessService {
            return null;
        }
    }
    public JSONObject getThirdNum(String templateCode,String idcard) {
        String param = "?templateCode=" + nullToTransfor(templateCode) + "&idcard=" + nullToTransfor(idcard);
    public JSONObject getThirdNum(String idcard) {
        String param = "?idcard=" + nullToTransfor(idcard);
        JSONObject re = wlyyHttpService.sendWlyyMesGet("getThirdNum", param);
        return re;
    }
    public JSONObject findThirdScreenList(String hospital,String patientName,String startDate,String endDate,String templateCode,
                                          String isDanger,String manageStatus,Integer page,Integer size) {
        String param = "?hospital=" + nullToTransfor(hospital) + "&patientName=" + nullToTransfor(patientName) + "&startDate=" + nullToTransfor(startDate)
                + "&endDate=" + nullToTransfor(endDate)+ "&templateCode=" + nullToTransfor(templateCode)+ "&isDanger=" + nullToTransfor(isDanger)
                + "&manageStatus=" + nullToTransfor(manageStatus)+ "&page=" + page+ "&size=" + size;
        JSONObject re = wlyyHttpService.sendWlyyMesGet("findThirdScreenList", param);
    public JSONObject findThirdScreenListSyn(String id,String size) {
        String param = "?id=" + id+ "&size=" + nullToTransfor(size);
        JSONObject re = wlyyHttpService.sendWlyyMesGet("findThirdScreenListSyn", param);
        return re;
    }

+ 96 - 1
common/common-entity/src/db/2024.sql

@ -370,4 +370,99 @@ INSERT INTO `oauth_wlyy_config` (`id`, `app_id`, `app_secret`, `token_url`, `url
ALTER TABLE `dict_hospital_dept` ADD COLUMN `update_time` datetime NULL COMMENT '更新时间' ;
UPDATE dict_hospital_dept set update_time=create_time;
UPDATE dict_hospital_dept set saas_id='999' WHERE saas_id is null;
UPDATE dict_hospital_dept set saas_id='999' WHERE saas_id is null;
-- 2024-08-30
CREATE TABLE `wlyy_survey_screen_result_syn` (
      `id` int NOT NULL AUTO_INCREMENT,
      `ijk_id` int DEFAULT NULL,
      `code` varchar(50) DEFAULT NULL COMMENT '唯一标识code',
      `template_code` varchar(50) DEFAULT NULL COMMENT '筛查问卷code',
      `template_title` varchar(50) DEFAULT NULL COMMENT '筛查名称',
      `disease` int DEFAULT NULL COMMENT '疾病类型(根据模板表的疾病类型定义wlyy_special_disease)',
      `doctor` varchar(50) DEFAULT NULL COMMENT '医生code',
      `doctor_name` varchar(50) DEFAULT NULL,
      `doctor_idcard` varchar(50) DEFAULT NULL,
      `hospital` varchar(50) DEFAULT NULL,
      `hospital_name` varchar(50) DEFAULT NULL,
      `town` varchar(50) DEFAULT NULL,
      `patient_code` varchar(50) DEFAULT NULL COMMENT '居民code',
      `open_id` varchar(50) DEFAULT NULL COMMENT '居民openid',
      `patient_name` varchar(50) DEFAULT NULL COMMENT '居民名字',
      `idcard` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
      `mobile` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
      `photo` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
      `birthday` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
      `sex` varchar(1) DEFAULT NULL,
      `screen_result_code` varchar(50) DEFAULT NULL COMMENT '与wlyy_template_result的code对应',
      `screen_result_score` int DEFAULT NULL COMMENT '筛查结果分值',
      `screen_result` varchar(200) DEFAULT NULL,
      `is_danger` int DEFAULT '0' COMMENT '是否高危预警(0否 1是)',
      `is_order` int DEFAULT '0' COMMENT '是否预约(0未预约 1已预约(待接诊) 2已接诊)',
      `following` int DEFAULT '0' COMMENT '是否跟踪(0未跟踪 1已跟踪)',
      `is_educate` int DEFAULT '0' COMMENT '是否进行健康教育(0否 1是)',
      `is_over` int DEFAULT NULL COMMENT '是否完成(0未完成 1已完成)',
      `reservation_code` varchar(50) DEFAULT NULL COMMENT '关联预约记录code',
      `czrq` datetime DEFAULT NULL COMMENT '创建时间',
      `is_again` int DEFAULT NULL COMMENT '是否可以再次评估(0不可以 1可以)',
      `parent_code` varchar(50) DEFAULT NULL COMMENT '再次筛查的上一份记录code',
      `origin_code` varchar(50) DEFAULT NULL COMMENT '首份记录code',
      `advice_code` varchar(500) DEFAULT NULL COMMENT '建议code,多个逗号隔开',
      `other_advice` varchar(255) DEFAULT NULL COMMENT '其他建议',
      `source` int DEFAULT NULL COMMENT '来源(1医生发放 2自我评估)',
      `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
      `third_id` varchar(100) DEFAULT NULL COMMENT '第三方筛查结果返回的id',
      `third_source` varchar(5) DEFAULT '4' COMMENT '评估来源【1.前台三合一 2. 前台独立 3.后台自动 4.i健康】',
      `third_advice` varchar(255) DEFAULT NULL COMMENT '第三方返回的筛查建议',
      `patient_read_status` int DEFAULT '0' COMMENT '专病档案功能是否未读,0-未读  1-已读',
      `doctor_read_status` int DEFAULT '0' COMMENT '专病档案功能是否未读,0-未读  1-已读',
      `survey_status` varchar(10) DEFAULT NULL COMMENT '1已管理、2住院补筛',
      PRIMARY KEY (`id`) USING BTREE,
      KEY `idx_soucre_isdanger` (`source`,`is_danger`),
      KEY `index_1` (`code`),
      KEY `index2` (`ijk_id`),
      KEY `index3` (`hospital`,`town`),
      KEY `idx_doctor` (`template_code`) USING BTREE
) ENGINE=InnoDB COMMENT='筛查问卷结果表-同步i健康';
INSERT INTO `oauth_wlyy_config` (`id`, `app_id`, `app_secret`, `token_url`, `url`, `remark`) VALUES
    ('findThirdScreenListSyn', '019bd04d-3cb2-433f-a530-03f0cdb083e5', '08cc3ec2-736b-4732-a8f0-f99eb6f9d311', 'https://www.xmtyw.cn/wlyytest/gc/accesstoken', 'https://www.xmtyw.cn/wlyytest/wlyygc/tongan/hospital/findThirdScreenListSyn', '厦门I健康获取同安筛查记录');
INSERT INTO `wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`,
                                      `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES
    ('surveyScreenResultId', NULL, 'surveyScreenResultId', '1', '2024-07-24', '50', '1', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '同步i健康疾病筛查结果');
CREATE TABLE `wlyy_survey_third` (
     `id` varchar(50) NOT NULL,
     `survey_code` varchar(50) DEFAULT NULL,
     `doctor` varchar(50) DEFAULT NULL,
     `disease_code` varchar(50) DEFAULT NULL,
     `create_time` datetime DEFAULT NULL,
     PRIMARY KEY (`id`),
     KEY `index` (`survey_code`,`disease_code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
INSERT INTO `wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`,
                                      `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES
    ('surveyRecordStatus1', NULL, 'surveyRecordStatus', '0', '待接待', NULL, '1', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '疾病筛查接待状态');
INSERT INTO `wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`,
                                      `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES
    ('surveyRecordStatus2', NULL, 'surveyRecordStatus', '1', '已接待', NULL, '2', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '疾病筛查接待状态');
INSERT INTO `wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`,
                                      `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES
    ('surveyRecordStatus3', NULL, 'surveyRecordStatus', '2', '患者拒诊', NULL, '3', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '疾病筛查接待状态');
INSERT INTO `wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`,
                                      `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES
    ('followup_status1', NULL, 'followup_status', '1', '已完成', NULL, '1', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '随访状态');
INSERT INTO `wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`,
                                      `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES
    ('followup_status2', NULL, 'followup_status', '2', '未完成', NULL, '2', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '随访状态');
INSERT INTO `wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`,
                                      `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES
    ('followup_businessSource', NULL, 'followup_businessSource', '1', '诊后康复', NULL, '1', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '随访业务来源');

+ 1 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/followup/Followup.java

@ -63,6 +63,7 @@ public class Followup extends LongIdentityEntity {
	//数据来源 1基卫 2APP
	private String dataFrom;
	//状态 0取消 1已完成 2未开始 3进行中 4待审核
	//三院只有 1已完成 2未完成
	private String status;
	//电话随访内容
	private String followupContentPhone;

+ 468 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/survey/SurveyScreenResultSyn.java

@ -0,0 +1,468 @@
package com.yihu.jw.entity.hospital.survey;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.IdEntity;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
/**
 * 筛查问卷结果表-同步i健康
 */
@Entity
@Table(name = "wlyy_survey_screen_result_syn")
@SequenceGenerator(name="id_generated", sequenceName="wlyy_survey_screen_result_syn")
public class SurveyScreenResultSyn extends IdEntity implements Serializable{
    private Long ijkId;//i健康id
    //唯一标识
    private String code;
    //模板编码
    private String templateCode;
    //模板标题
    private  String templateTitle;
    //疾病类型(根据模板表的疾病类型定义)
    private Integer disease;
    //i健康医生code
    private String doctor;
    private String doctorName;//医生姓名
    private String doctorIdcard;//医生身份证
    private String hospital;//社区code
    private String hospitalName;//社区名称
    private String town;//区code
    private String idcard;//居民身份证
    private String mobile;//居民手机号
    private String photo;//居民头像
    private String birthday;//居民生日
    private String sex;//居民性别
    //i健康医居民code
    private String patientCode;
    //居民openid
    private String openId;
    //居民名字
    private String patientName;
    //筛查结果设置中相关code
    private String screenResultCode;
    //筛查结果分值SexConvert -1表示是厦心ascvd
    private Integer screenResultScore;
    //筛查结果
    private String screenResult;
    //是否高危预警(0不是  1是)
    private Integer isDanger;
    //是否预约(0未预约 1已预约(待接诊) 2已接诊)
    private Integer isOrder;
    private String surveyStatus;//1已管理、2住院补筛
    //是否跟踪(0未跟踪 1已跟踪)
    private Integer following;
    //是否进行健康教育(0没有  1有)
    private Integer isEducate;
    //是否完成(0未完成 1已完成)
    private Integer over;
    //预约记录code
    private String reservationCode;
    //创建时间
    private Date czrq;
    //是否可以再次评估(0不可以 1可以)
    private Integer isAgain;
    //再次筛查的上一份记录code
    private String parentCode;
    //首份记录code
    private String originCode;
    //建议code,多个逗号隔开
    private String adviceCode;
    //其他建议
    private String otherAdvice;
    //来源(1医生发放  2居民自我评估)
    private Integer source;
    //更新时间
    private Date updateTime;
    private String thirdId;//第三方筛查结果返回的id
    private String thirdSource;//评估来源【1.前台三合一 2. 前台独立 3.后台自动 4.i健康】
    private String thirdAdvice;//第三方返回的筛查建议
    @Transient
    private Integer age;
    private Integer doctorReadStatus;
    private Integer patientReadStatus;
    @Column(name = "ijk_id")
    public Long getIjkId() {
        return ijkId;
    }
    public void setIjkId(Long ijkId) {
        this.ijkId = ijkId;
    }
    public String getSurveyStatus() {
        return surveyStatus;
    }
    public void setSurveyStatus(String surveyStatus) {
        this.surveyStatus = surveyStatus;
    }
    @Column(name = "doctor_read_status")
    public Integer getDoctorReadStatus() {
        return doctorReadStatus;
    }
    public void setDoctorReadStatus(Integer doctorReadStatus) {
        this.doctorReadStatus = doctorReadStatus;
    }
    @Column(name = "patient_read_status")
    public Integer getPatientReadStatus() {
        return patientReadStatus;
    }
    public void setPatientReadStatus(Integer patientReadStatus) {
        this.patientReadStatus = patientReadStatus;
    }
    @Column(name = "code")
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    @Column(name = "template_code")
    public String getTemplateCode() {
        return templateCode;
    }
    public void setTemplateCode(String templateCode) {
        this.templateCode = templateCode;
    }
    @Column(name = "template_title")
    public String getTemplateTitle() {
        return templateTitle;
    }
    public void setTemplateTitle(String templateTitle) {
        this.templateTitle = templateTitle;
    }
    @Column(name = "disease")
    public Integer getDisease() {
        return disease;
    }
    public void setDisease(Integer disease) {
        this.disease = disease;
    }
    @Column(name = "doctor")
    public String getDoctor() {
        return doctor;
    }
    public void setDoctor(String doctor) {
        this.doctor = doctor;
    }
    @Column(name = "patient_code")
    public String getPatientCode() {
        return patientCode;
    }
    public void setPatientCode(String patientCode) {
        this.patientCode = patientCode;
    }
    @Column(name = "open_id")
    public String getOpenId() {
        return openId;
    }
    public void setOpenId(String openId) {
        this.openId = openId;
    }
    @Column(name = "patient_name")
    public String getPatientName() {
        return patientName;
    }
    public void setPatientName(String patientName) {
        this.patientName = patientName;
    }
    @Column(name = "screen_result_code")
    public String getScreenResultCode() {
        return screenResultCode;
    }
    public void setScreenResultCode(String screenResultCode) {
        this.screenResultCode = screenResultCode;
    }
    @Column(name = "screen_result_score")
    public Integer getScreenResultScore() {
        return screenResultScore;
    }
    public void setScreenResultScore(Integer screenResultScore) {
        this.screenResultScore = screenResultScore;
    }
    @Column(name = "screen_result")
    public String getScreenResult() {
        return screenResult;
    }
    public void setScreenResult(String screenResult) {
        this.screenResult = screenResult;
    }
    @Column(name = "is_danger")
    public Integer getIsDanger() {
        return isDanger;
    }
    public void setIsDanger(Integer isDanger) {
        this.isDanger = isDanger;
    }
    @Column(name = "is_order")
    public Integer getIsOrder() {
        return isOrder;
    }
    public void setIsOrder(Integer isOrder) {
        this.isOrder = isOrder;
    }
    @Column(name = "following")
    public Integer getFollowing() {
        return following;
    }
    public void setFollowing(Integer following) {
        this.following = following;
    }
    @Column(name = "is_educate")
    public Integer getIsEducate() {
        return isEducate;
    }
    public void setIsEducate(Integer isEducate) {
        this.isEducate = isEducate;
    }
    @Column(name = "is_over")
    public Integer getOver() {
        return over;
    }
    public void setOver(Integer over) {
        this.over = over;
    }
    @Column(name = "reservation_code")
    public String getReservationCode() {
        return reservationCode;
    }
    public void setReservationCode(String reservationCode) {
        this.reservationCode = reservationCode;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "czrq")
    public Date getCzrq() {
        return czrq;
    }
    public void setCzrq(Date czrq) {
        this.czrq = czrq;
    }
    @Column(name = "is_again")
    public Integer getIsAgain() {
        return isAgain;
    }
    public void setIsAgain(Integer isAgain) {
        this.isAgain = isAgain;
    }
    @Column(name = "parent_code")
    public String getParentCode() {
        return parentCode;
    }
    public void setParentCode(String parentCode) {
        this.parentCode = parentCode;
    }
    @Column(name = "origin_code")
    public String getOriginCode() {
        return originCode;
    }
    public void setOriginCode(String originCode) {
        this.originCode = originCode;
    }
    @Column(name = "advice_code")
    public String getAdviceCode() {
        return adviceCode;
    }
    public void setAdviceCode(String adviceCode) {
        this.adviceCode = adviceCode;
    }
    @Column(name = "other_advice")
    public String getOtherAdvice() {
        return otherAdvice;
    }
    public void setOtherAdvice(String otherAdvice) {
        this.otherAdvice = otherAdvice;
    }
    @Column(name = "source")
    public Integer getSource() {
        return source;
    }
    public void setSource(Integer source) {
        this.source = source;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "update_time")
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
    public String getThirdId() {
        return thirdId;
    }
    public void setThirdId(String thirdId) {
        this.thirdId = thirdId;
    }
    public String getThirdSource() {
        return thirdSource;
    }
    public void setThirdSource(String thirdSource) {
        this.thirdSource = thirdSource;
    }
    public String getPhoto() {
        return photo;
    }
    public void setPhoto(String photo) {
        this.photo = photo;
    }
    public String getSex() {
        return sex;
    }
    public void setSex(String sex) {
        this.sex = sex;
    }
    @Transient
    public Integer getAge() {
        return age;
    }
    public void setAge(Integer age) {
        this.age = age;
    }
    public String getIdcard() {
        return idcard;
    }
    public void setIdcard(String idcard) {
        this.idcard = idcard;
    }
    public String getThirdAdvice() {
        return thirdAdvice;
    }
    public void setThirdAdvice(String thirdAdvice) {
        this.thirdAdvice = thirdAdvice;
    }
    public String getDoctorName() {
        return doctorName;
    }
    public void setDoctorName(String doctorName) {
        this.doctorName = doctorName;
    }
    public String getDoctorIdcard() {
        return doctorIdcard;
    }
    public void setDoctorIdcard(String doctorIdcard) {
        this.doctorIdcard = doctorIdcard;
    }
    public String getHospital() {
        return hospital;
    }
    public void setHospital(String hospital) {
        this.hospital = hospital;
    }
    public String getHospitalName() {
        return hospitalName;
    }
    public void setHospitalName(String hospitalName) {
        this.hospitalName = hospitalName;
    }
    public String getTown() {
        return town;
    }
    public void setTown(String town) {
        this.town = town;
    }
    public String getMobile() {
        return mobile;
    }
    public void setMobile(String mobile) {
        this.mobile = mobile;
    }
    public String getBirthday() {
        return birthday;
    }
    public void setBirthday(String birthday) {
        this.birthday = birthday;
    }
}

+ 55 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/survey/SurveyThird.java

@ -0,0 +1,55 @@
package com.yihu.jw.entity.hospital.survey;
import com.yihu.jw.entity.UuidIdentityEntityWithCreateTime;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * Created by yeshijie on 2024/8/20.
 */
@Entity
@Table(name = "wlyy_survey_third")
public class SurveyThird extends UuidIdentityEntityWithCreateTime {
    private String surveyCode;//筛查code
    private String diseaseCode;//病种code
    private String patient;//i健康居民id
    private String doctor;//医生id
    @Column(name = "survey_code")
    public String getSurveyCode() {
        return surveyCode;
    }
    public void setSurveyCode(String surveyCode) {
        this.surveyCode = surveyCode;
    }
    @Column(name = "patient")
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    @Column(name = "disease_code")
    public String getDiseaseCode() {
        return diseaseCode;
    }
    public void setDiseaseCode(String diseaseCode) {
        this.diseaseCode = diseaseCode;
    }
    @Column(name = "doctor")
    public String getDoctor() {
        return doctor;
    }
    public void setDoctor(String doctor) {
        this.doctor = doctor;
    }
}

+ 128 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/survey/WlyySurveyRecordDO.java

@ -0,0 +1,128 @@
package com.yihu.jw.entity.hospital.survey;
import com.yihu.jw.entity.UuidIdentityEntityWithCreateTime;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
/**
 * Created by yeshijie on 2024/8/29.
 */
@Entity
@Table(name = "wlyy_survey_record")
public class WlyySurveyRecordDO extends UuidIdentityEntityWithCreateTime {
    private String name;//居民姓名
    private String mobile;//手机号
    private String idcard;//身份证
    private String diseaseCode;//病种code
    private String status;//状态0 待接待 1已接待 2患者拒诊
    private String content;//
    private String operateTime;//操作时间
    private String doctor;//操作人
    private String doctorName;
    private String statusName;//状态0 待接待 1已接待 2患者拒诊
    private String diseaseName;//病种名称
    private String deptName;//病种关联科室
    @Column(name = "name")
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    @Column(name = "mobile")
    public String getMobile() {
        return mobile;
    }
    public void setMobile(String mobile) {
        this.mobile = mobile;
    }
    @Column(name = "idcard")
    public String getIdcard() {
        return idcard;
    }
    public void setIdcard(String idcard) {
        this.idcard = idcard;
    }
    @Column(name = "disease_code")
    public String getDiseaseCode() {
        return diseaseCode;
    }
    public void setDiseaseCode(String diseaseCode) {
        this.diseaseCode = diseaseCode;
    }
    @Column(name = "status")
    public String getStatus() {
        return status;
    }
    public void setStatus(String status) {
        this.status = status;
    }
    @Column(name = "content")
    public String getContent() {
        return content;
    }
    public void setContent(String content) {
        this.content = content;
    }
    @Column(name = "operate_time")
    public String getOperateTime() {
        return operateTime;
    }
    public void setOperateTime(String operateTime) {
        this.operateTime = operateTime;
    }
    @Column(name = "doctor")
    public String getDoctor() {
        return doctor;
    }
    public void setDoctor(String doctor) {
        this.doctor = doctor;
    }
    @Column(name = "doctor_name")
    public String getDoctorName() {
        return doctorName;
    }
    public void setDoctorName(String doctorName) {
        this.doctorName = doctorName;
    }
    @Transient
    public String getStatusName() {
        return statusName;
    }
    public void setStatusName(String statusName) {
        this.statusName = statusName;
    }
    @Transient
    public String getDiseaseName() {
        return diseaseName;
    }
    public void setDiseaseName(String diseaseName) {
        this.diseaseName = diseaseName;
    }
    @Transient
    public String getDeptName() {
        return deptName;
    }
    public void setDeptName(String deptName) {
        this.deptName = deptName;
    }
}

+ 38 - 2
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/utils/ExportUtl.java

@ -1,6 +1,8 @@
package com.yihu.jw.hospital.utils;
package com.yihu.jw.util.excel;
import jxl.format.VerticalAlignment;
import jxl.write.*;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
import java.io.IOException;
@ -15,6 +17,10 @@ import java.util.Map;
@Component
public class ExportUtl {
    public String nullToTransfor(String str) {
        return StringUtils.isBlank(str) ? "" : str;
    }
    public void addHeader(WritableSheet ws,String[] header) throws WriteException {
        int i = 0;
        for (String h : header) {
@ -49,6 +55,25 @@ public class ExportUtl {
    //添加单元格内容
    public void addCell(WritableSheet ws, int row, int column, String data) throws WriteException {
        Label label = new Label(column ,row, data);
        WritableCellFormat cellFormat = new WritableCellFormat();
        cellFormat.setAlignment(jxl.format.Alignment.CENTRE);
        cellFormat.setVerticalAlignment(VerticalAlignment.CENTRE);
        label.setCellFormat(cellFormat);
        ws.addCell(label);
    }
    public void addCell(WritableSheet ws, int row, int column, Object obj) throws WriteException {
        String data = "";
        if(obj!=null){
            data = obj +"";
        }
        if("null".equals(data)){
            data = "";
        }
        Label label = new Label(column ,row, data);
        WritableCellFormat cellFormat = new WritableCellFormat();
        cellFormat.setAlignment(jxl.format.Alignment.CENTRE);
        cellFormat.setVerticalAlignment(VerticalAlignment.CENTRE);
        label.setCellFormat(cellFormat);
        ws.addCell(label);
    }
    //添加单元格内容
@ -61,7 +86,18 @@ public class ExportUtl {
            data = "";
        }
        Label label = new Label(column ,row, data);
        if(!org.springframework.util.StringUtils.isEmpty(memo)){
        if(!StringUtils.isEmpty(memo)){
            WritableCellFeatures cellFeatures = new WritableCellFeatures();
            cellFeatures.setComment(memo);
            label.setCellFeatures(cellFeatures);
        }
        ws.addCell(label);
    }
    //添加单元格内容
    public void addCell(WritableSheet ws, int row, int column, String data, String memo) throws WriteException {
        Label label = new Label(column, row, data);
        if (!StringUtils.isEmpty(memo)) {
            WritableCellFeatures cellFeatures = new WritableCellFeatures();
            cellFeatures.setComment(memo);
            label.setCellFeatures(cellFeatures);

+ 10 - 0
svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/event/ApplicationEvent.java

@ -1,6 +1,7 @@
package com.yihu.jw.event;
import com.yihu.jw.job.QuartzHelper;
import com.yihu.jw.job.ijk.SurveyScreenResultSynJob;
import com.yihu.jw.job.im.ImOnlineGuidanceJob;
import com.yihu.jw.util.SystemConf;
import org.slf4j.Logger;
@ -35,6 +36,15 @@ public class ApplicationEvent implements ApplicationListener<ContextRefreshedEve
                logger.info("im_online_guidance_job exist");
            }
            //同步i健康疾病筛查结果 每10分钟一次
            if (!quartzHelper.isExistJob("survey_screen_result_syn_job")) {
                String trigger = "0 */10 * * * ?";
                quartzHelper.addJob(SurveyScreenResultSynJob.class, trigger, "survey_screen_result_syn_job", new HashMap<>());
                logger.info("survey_screen_result_syn_job success");
            } else {
                logger.info("survey_screen_result_syn_job exist");
            }
//=================中山医院发布启动======================================================
//            //互联网医院处方状态更新job
//            if (!quartzHelper.isExistJob("prescriptionStatus_update_job")) {

+ 35 - 0
svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/job/ijk/SurveyScreenResultSynJob.java

@ -0,0 +1,35 @@
package com.yihu.jw.job.ijk;
import com.yihu.jw.hospital.disease.service.BaseDiseaseHospitalService;
import com.yihu.jw.job.im.ImOnlineGuidanceJob;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
/**
 * 同步i健康疾病筛查结果 10分钟跑一次
 * Created by yeshijie on 2024/8/30.
 */
@DisallowConcurrentExecution
public class SurveyScreenResultSynJob implements Job {
    private static final Logger logger = LoggerFactory.getLogger(ImOnlineGuidanceJob.class);
    @Autowired
    private BaseDiseaseHospitalService diseaseHospitalService;
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        try {
            logger.info("SurveyScreenResultSynJob start...");
            diseaseHospitalService.synIjkSurvryScreenResult();
            logger.info("SurveyScreenResultSynJob end.");
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}

+ 17 - 0
svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/web/quota/JobController.java

@ -2,6 +2,7 @@ package com.yihu.jw.web.quota;
import com.yihu.jw.entity.hospital.prescription.WlyyOutpatientDO;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.hospital.disease.service.BaseDiseaseHospitalService;
import com.yihu.jw.hospital.prescription.service.YkyyPrescriptionService;
import com.yihu.jw.im.service.ImService;
import com.yihu.jw.internet.service.DataGeneratorService;
@ -95,6 +96,8 @@ public class JobController extends BaseController {
    private HealthUploadService healthUploadService;
    @Autowired
    private TimeoutOverDueService timeoutOverDueService;
    @Autowired
    private BaseDiseaseHospitalService diseaseHospitalService;
    @Autowired
    public JobController(JobService jobService, QuartzHelper quartzHelper) {
@ -117,6 +120,20 @@ public class JobController extends BaseController {
        }
    }
    /**
     * 同步i健康疾病筛查结果
     */
    @GetMapping(value = "synIjkSurvryScreenResult")
    public String synIjkSurvryScreenResult() {
        try {
            diseaseHospitalService.synIjkSurvryScreenResult();
            return success("成功!");
        } catch (Exception e) {
            error(e);
            return error(-1,"失败:" + e.getMessage());
        }
    }
    /**
     * 同步签约信息
     */

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

@ -2,28 +2,31 @@ package com.yihu.jw.hospital.endpoint.specialist;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.sms.SmsTemplateDO;
import com.yihu.jw.entity.hospital.survey.BaseDiseaseSurveyDO;
import com.yihu.jw.entity.hospital.survey.WlyySurveyRecordDO;
import com.yihu.jw.entity.specialist.BaseDiseaseHospitalDO;
import com.yihu.jw.hospital.disease.service.BaseDiseaseHospitalService;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
import com.yihu.jw.util.excel.ExportUtl;
import com.yihu.jw.wlyy.service.WlyyBusinessService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
import java.util.Map;
@RestController
@ -34,20 +37,118 @@ public class BaseDiseaseHospitalController extends EnvelopRestEndpoint {
    @Autowired
    private BaseDiseaseHospitalService baseDiseaseHospitalService;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private BaseDoctorDao doctorDao;
    @Autowired
    WlyyBusinessService wlyyBusinessService;
    @Autowired
    private ExportUtl exportUtl;
    @GetMapping(value = "exportSurveyRecord")
    @ApiOperation(value = " 导出筛查患者管理")
    public ListEnvelop exportSurveyRecord(
            @ApiParam(value = "姓名") @RequestParam(value = "name", required = false) String name,
            @ApiParam(value = "病种id,多个用逗号隔开") @RequestParam(value = "diseaseCode", required = false) String diseaseCode,
            @ApiParam(value = "身份证") @RequestParam(value = "idcard", required = true) String idcard,
            @ApiParam(value = "手机号") @RequestParam(value = "mobile", required = false) String mobile,
            @ApiParam(value = "科室编码") @RequestParam(value = "dept", required = false) String dept,
            @ApiParam(value = "开始时间") @RequestParam(value = "startDate", required = false) String startDate,
            @ApiParam(value = "结束时间") @RequestParam(value = "endDate", required = false) String endDate,
            @ApiParam(value = "接待状态 0 待接待 1已接待 2患者拒诊") @RequestParam(value = "status", required = false) String status,
            HttpServletResponse response) {
        try {
            List<WlyySurveyRecordDO> list = baseDiseaseHospitalService.surveyRecordList(name, idcard, startDate, endDate, mobile,
                    status,dept,diseaseCode);
            response.setContentType("octets/stream");
            response.setHeader("Content-Disposition", "attachment; filename=" + new String("surveyRecordExcel.xls"));
            OutputStream os = response.getOutputStream();
            pushTotalExcel(os, list);
            return success(list);
        } catch (Exception e) {
            e.printStackTrace();
            return failedListEnvelopException(e);
        }
    }
    public void pushTotalExcel(OutputStream os, List<WlyySurveyRecordDO> list) throws Exception {
        WritableWorkbook wwb = jxl.Workbook.createWorkbook(os);
        try {
            WritableSheet ws;
            ws = wwb.createSheet("sheet", 1);
            String[] header = {"姓名", "联系电话", "证件号码", "病种名称", "关联科室", "接待状态", "操作时间","操作人"};
            int k = 0;
            for (String h : header) {
                exportUtl.addCell(ws, 0, k, h);//表名,行,列,header
                k++;
            }
            int i = 1;
            for (WlyySurveyRecordDO m : list) {
                exportUtl.addCell(ws, i, 0, m.getName());
                exportUtl.addCell(ws, i, 1, m.getMobile());
                exportUtl.addCell(ws, i, 2, m.getIdcard());
                exportUtl.addCell(ws, i, 3, m.getDiseaseName());
                exportUtl.addCell(ws, i, 4, m.getDeptName());
                exportUtl.addCell(ws, i, 5, m.getStatusName());
                exportUtl.addCell(ws, i, 6, m.getOperateTime());
                exportUtl.addCell(ws, i, 7, m.getDoctorName());
                i++;
            }
            wwb.write();
            wwb.close();
        } catch (IOException e) {
            e.printStackTrace();
            if (wwb != null) wwb.close();
            throw e;
        }
    }
    @ApiOperation("管理患者")
    @PostMapping(value = "manageSurveyReocrd")
    public Envelop manageSurveyReocrd(@ApiParam(name = "id", value = "记录id", required = true)
                           @RequestParam(value = "id", required = true) String id,
                           @ApiParam(name = "status", value = "接待状态 1确认接待 2患者拒诊", required = true)
                           @RequestParam(value = "status", required = true) String status,
                           @ApiParam(name = "doctor", value = "医生code", required = false)
                           @RequestParam(value = "doctor", required = false) String doctor) {
        try {
            if(StringUtils.isBlank(doctor)){
                doctor = getUID();
            }
            baseDiseaseHospitalService.manageSurveyReocrd(id,status,doctor);
            return success("管理成功");
        } catch (Exception e) {
            return failedException(e);
        }
    }
    @GetMapping(value = "surveyRecordPage")
    @ApiOperation(value = "筛查患者管理")
    public Envelop surveyRecordPage(
            @ApiParam(value = "姓名") @RequestParam(value = "name", required = false) String name,
            @ApiParam(value = "病种id,多个用逗号隔开") @RequestParam(value = "diseaseCode", required = false) String diseaseCode,
            @ApiParam(value = "身份证") @RequestParam(value = "idcard", required = false) String idcard,
            @ApiParam(value = "当前页") @RequestParam(value = "page") Integer page,
            @ApiParam(value = "显示记录数") @RequestParam(value = "size") Integer size,
            @ApiParam(value = "手机号") @RequestParam(value = "mobile", required = false) String mobile,
            @ApiParam(value = "科室编码") @RequestParam(value = "dept", required = false) String dept,
            @ApiParam(value = "开始时间") @RequestParam(value = "startDate", required = false) String startDate,
            @ApiParam(value = "结束时间") @RequestParam(value = "endDate", required = false) String endDate,
            @ApiParam(value = "接待状态 0 待接待 1已接待 2患者拒诊") @RequestParam(value = "status", required = false) String status) {
        try {
            return baseDiseaseHospitalService.surveyRecordPage(name, idcard, startDate, endDate, mobile,
                    status, page, size,dept,diseaseCode);
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError("查询失败");
        }
    }
    @ApiOperation("疾病筛查管理发送短信")
    @PostMapping(value = "sendSms")
    public Envelop sendSms(@ApiParam(name = "header", value = "模板名称", required = true)
                                   @RequestParam(value = "header", required = true) String header,
                                   @ApiParam(name = "surveyCodes", value = "筛查code,多个逗号间隔", required = true)
                                   @RequestParam(value = "surveyCodes", required = true) String surveyCodes,
                                   @ApiParam(name = "mobiles", value = "手机号,多个逗号间隔", required = true)
                                   @RequestParam(value = "mobiles", required = true) String mobiles,
                                   @ApiParam(name = "jsonData", value = "字符串格式数组", required = true)
                                   @RequestParam(value = "jsonData", required = true) String jsonData,
                                   @ApiParam(name = "doctor", value = "医生code", required = false)
                                   @RequestParam(value = "doctor", required = false) String doctor,
                                   @ApiParam(name = "smsTemplateId", value = "短信模板id", required = false)
@ -58,7 +159,7 @@ public class BaseDiseaseHospitalController extends EnvelopRestEndpoint {
            if(StringUtils.isBlank(doctor)){
                doctor = getUID();
            }
            baseDiseaseHospitalService.sendSms(mobiles,surveyCodes,smsTemplateId,content,header,doctor);
            baseDiseaseHospitalService.sendSms(jsonData,smsTemplateId,content,header,doctor);
            return success("发送成功");
        } catch (Exception e) {
            return failedException(e);
@ -67,21 +168,12 @@ public class BaseDiseaseHospitalController extends EnvelopRestEndpoint {
    @GetMapping(value = "getThirdNum")
    @ApiOperation(value = "三院疾病筛查数量")
    public Envelop getThirdNum(@ApiParam(value = "医生code") @RequestParam(value = "doctor", required = false) String doctor
    ) {
    public Envelop getThirdNum(@ApiParam(value = "医生code") @RequestParam(value = "doctor", required = false) String doctor) {
        try {
            if(StringUtils.isBlank(doctor)){
                doctor = getUID();
            }
            String templateCode = "";
            String sql = "SELECT GROUP_CONCAT(DISTINCT survey_code) survey_code from base_disease_survey where status=1 ";
            sql += " and doctor like '%"+doctor+"%' ";
            List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
            if(list.size()>0){
                templateCode = list.get(0).get("survey_code")+"";
            }
            BaseDoctorDO doctorDO = doctorDao.findByIdAndDel(doctor);
            return ObjEnvelop.getSuccess("成功",wlyyBusinessService.getThirdNum(templateCode, doctorDO.getIdcard()));
            return ObjEnvelop.getSuccess("成功",baseDiseaseHospitalService.getThirdNum(doctor));
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError("失败");
@ -92,7 +184,7 @@ public class BaseDiseaseHospitalController extends EnvelopRestEndpoint {
    @ApiOperation(value = "同安筛查记录")
    public Envelop findThirdScreenList(
            @ApiParam(value = "社区医院code") @RequestParam(value = "hospital", required = false) String hospital,
            @ApiParam(value = "病种类型code") @RequestParam(value = "diseaseSurveyCode", required = false) String diseaseSurveyCode,
            @ApiParam(value = "病种id,多个用逗号隔开") @RequestParam(value = "diseaseCode", required = false) String diseaseCode,
            @ApiParam(value = "是否管理员1是 0否") @RequestParam(value = "isManager", required = true) String isManager,
            @ApiParam(value = "当前页") @RequestParam(value = "page") Integer page,
            @ApiParam(value = "显示记录数") @RequestParam(value = "size") Integer size,
@ -104,29 +196,8 @@ public class BaseDiseaseHospitalController extends EnvelopRestEndpoint {
            @ApiParam(value = "管理状态 0未管理 1已管理 2 日常健康管理") @RequestParam(value = "manageStatus", required = false) String manageStatus
    ) {
        try {
            if(StringUtils.isBlank(templateCode)){
                String sql = "SELECT GROUP_CONCAT(DISTINCT survey_code) survey_code from base_disease_survey where status=1 ";
                if("0".equals(isManager)){
                    sql += " and doctor like '%"+getUID()+"%' ";
                }
                List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
                if(list.size()>0){
                    templateCode = list.get(0).get("survey_code")+"";
                }
            }
            if(StringUtils.isBlank(templateCode)){
                JSONObject json = new JSONObject();
                json.put("detailModelList",new ArrayList<>());
                json.put("currPage",page);
                json.put("totalPage",0);
                json.put("pageSize",size);
                json.put("message","查询成功");
                json.put("totalCount",0);
                json.put("status",200);
                return success(json);
            }
            return success(wlyyBusinessService.findThirdScreenList(hospital, patientName, startDate, endDate, templateCode,
                    isDanger, manageStatus, page, size));
            return baseDiseaseHospitalService.findThirdScreenList(hospital, patientName, startDate, endDate, templateCode,
                    isDanger, manageStatus, page, size,isManager,getUID(),diseaseCode);
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError("查询失败");

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

@ -2,10 +2,10 @@ package com.yihu.jw.hospital.module.common;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.hospital.module.common.service.StatisticsService;
import com.yihu.jw.hospital.utils.ExportUtl;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.util.excel.ExportUtl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

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

@ -4,20 +4,25 @@ import com.yihu.jw.entity.followup.Followup;
import com.yihu.jw.hospital.module.common.BaseController;
import com.yihu.jw.hospital.module.followup.service.FollowUpService;
import com.yihu.jw.hospital.module.followup.service.FollowupDrugsService;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.util.entity.ServiceException;
import com.yihu.jw.util.excel.ExportUtl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
import java.util.Map;
@ -37,6 +42,105 @@ public class DoctorFollowUpController extends BaseController {
    private FollowupDrugsService followupDrugsService;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private ExportUtl exportUtl;
    @GetMapping(value = "businessTypeList")
    @ApiOperation(value = "业务类型字典")
    public ListEnvelop businessTypeList() {
        try {
            return ListEnvelop.getSuccess("查询成功", followUpService.businessTypeList());
        } catch (Exception e) {
            e.printStackTrace();
            return ListEnvelop.getError("查询失败");
        }
    }
    @GetMapping(value = "followupPage")
    @ApiOperation(value = "随访记录列表")
    public Envelop followupPage(
            @ApiParam(value = "业务类型,全部及存在数据的专病名称") @RequestParam(value = "businessType", required = false) String businessType,
            @ApiParam(value = "业务来源的选项为:全部来源、诊后康复(其余选项待后期新增)") @RequestParam(value = "businessSource", required = false) String businessSource,
            @ApiParam(value = "居民姓名") @RequestParam(value = "patientName", required = false) String patientName,
            @ApiParam(value = "当前页") @RequestParam(value = "page") Integer page,
            @ApiParam(value = "显示记录数") @RequestParam(value = "size") Integer size,
            @ApiParam(value = "随访状态:全部状态、2未完成、1已完成") @RequestParam(value = "followupStatus", required = false) String followupStatus,
            @ApiParam(value = "医生姓名") @RequestParam(value = "doctorName", required = false) String doctorName,
            @ApiParam(value = "开始时间") @RequestParam(value = "startDate", required = false) String startDate,
            @ApiParam(value = "结束时间") @RequestParam(value = "endDate", required = false) String endDate) {
        try {
            return followUpService.followupPage(businessType, businessSource, startDate, endDate, patientName,
                    followupStatus,doctorName, page, size);
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError("查询失败");
        }
    }
    @GetMapping(value = "exportFollowupList")
    @ApiOperation(value = " 导出筛随访记录列表")
    public void exportFollowupList(
            @ApiParam(value = "业务类型,全部及存在数据的专病名称") @RequestParam(value = "businessType", required = false) String businessType,
            @ApiParam(value = "业务来源的选项为:全部来源、诊后康复(其余选项待后期新增)") @RequestParam(value = "businessSource", required = false) String businessSource,
            @ApiParam(value = "居民姓名") @RequestParam(value = "patientName", required = false) String patientName,
            @ApiParam(value = "随访状态:全部状态、未完成、已完成") @RequestParam(value = "followupStatus", required = false) String followupStatus,
            @ApiParam(value = "医生姓名") @RequestParam(value = "doctorName", required = false) String doctorName,
            @ApiParam(value = "开始时间") @RequestParam(value = "startDate", required = false) String startDate,
            @ApiParam(value = "结束时间") @RequestParam(value = "endDate", required = false) String endDate,
            HttpServletResponse response) {
        try {
            List<Map<String, Object>> list = followUpService.followupList(businessType, businessSource, startDate, endDate, patientName,
                    followupStatus,doctorName);
            response.setContentType("octets/stream");
            response.setHeader("Content-Disposition", "attachment; filename=" + new String("surveyRecordExcel.xls"));
            OutputStream os = response.getOutputStream();
            pushTotalExcel(os, list);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    public void pushTotalExcel(OutputStream os, List<Map<String, Object>> list) throws Exception {
        WritableWorkbook wwb = jxl.Workbook.createWorkbook(os);
        try {
            WritableSheet ws;
            ws = wwb.createSheet("sheet", 1);
            String[] header = {"姓名", "性别", "年龄", "联系电话", "家庭住址", "业务来源", "下转科室","下转医生","下转时间","专病名称","随访医生","所属科室","随访状态","计划完成时间","实际完成时间"};
            int k = 0;
            for (String h : header) {
                exportUtl.addCell(ws, 0, k, h);//表名,行,列,header
                k++;
            }
            int i = 1;
            for (Map<String, Object> m : list) {
                exportUtl.addCell(ws, i, 0, m.get("patientName"));
                exportUtl.addCell(ws, i, 1, m.get("sexName"));
                exportUtl.addCell(ws, i, 2, m.get("age"));
                exportUtl.addCell(ws, i, 3, m.get("mobile"));
                exportUtl.addCell(ws, i, 4, m.get("address"));
                exportUtl.addCell(ws, i, 5, m.get("businessSource"));
                exportUtl.addCell(ws, i, 6, m.get("turnDownDeptName"));
                exportUtl.addCell(ws, i, 7, m.get("planDoctorName"));
                exportUtl.addCell(ws, i, 8, m.get("turnDownDate"));
                exportUtl.addCell(ws, i, 9, m.get("businessTypeName"));
                exportUtl.addCell(ws, i, 10, m.get("doctorName"));
                exportUtl.addCell(ws, i, 11, m.get("deptName"));
                exportUtl.addCell(ws, i, 12, m.get("statusName"));
                exportUtl.addCell(ws, i, 13, m.get("followupPlanDate"));
                exportUtl.addCell(ws, i, 14, m.get("followupDate"));
                i++;
            }
            wwb.write();
            wwb.close();
        } catch (IOException e) {
            e.printStackTrace();
            if (wwb != null) wwb.close();
            throw e;
        }
    }
    /*************************************** 随访计划 ****************************************************************************/
    @ApiOperation("获取随访列表")
@ -399,39 +503,6 @@ public class DoctorFollowUpController extends BaseController {
            return invalidUserException(e, -1, "发送随访计划消息失败!" + e.getMessage());
        }
    }
    
    
//    @RequestMapping(value = "/checkfollowupcontent", method = RequestMethod.GET)
//    @ApiOperation("检查续方关联的随访记录是否对应的详情记录")
//    public String getfollowupcontent(
//            @ApiParam(name = "followupid", value = "随访ID", defaultValue = "")
//            @RequestParam(value = "followupid", required = true) String followupid,
//            @ApiParam(name = "type", value = "支持传多个以英文逗号连接,drug为药品,1-9为随访分类", defaultValue = "")
//            @RequestParam(value = "type", required = true) String type){
//        try {
//            int count = followUpService.getfollowupcontent(followupid,type);
//            return write(200, "操作成功!","data",count);
//        }catch (Exception e){
//            //日志文件中记录异常信息
//            //返回接口异常信息处理结果
//            return errorResult(e);
//        }
//    }
    
//    @RequestMapping(value = "/checkfollowupcompleted", method = RequestMethod.GET)
//    @ApiOperation("检查续方关联的随访记录是否对应的详情记录")
//    public String checkfollowupcompleted(
//            @ApiParam(name = "followupid", value = "随访ID", defaultValue = "")
//            @RequestParam(value = "followupid", required = true) String followupid){
//        try {
//            boolean completed = followUpService.checkfollowupcompleted(followupid);
//            return write(200, "操作成功!","data",completed);
//        }catch (Exception e){
//            //日志文件中记录异常信息
//            //返回接口异常信息处理结果
//            return errorResult(e);
//        }
//    }
    //=======================1.5.7上门访视相关接口====================================

+ 131 - 399
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/followup/service/FollowUpService.java

@ -11,28 +11,20 @@ import com.yihu.jw.entity.followup.Followup;
import com.yihu.jw.entity.followup.FollowupContent;
import com.yihu.jw.entity.followup.FollowupSign;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.entity.hospital.message.MessageNoticeSetting;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
import com.yihu.jw.hospital.message.service.SystemMessageService;
import com.yihu.jw.hospital.module.followup.dao.FollowUpDao;
import com.yihu.jw.hospital.module.followup.dao.FollowupContentDao;
import com.yihu.jw.hospital.module.followup.dao.FollowupDrugsDao;
import com.yihu.jw.hospital.module.followup.dao.FollowupSignDao;
import com.yihu.jw.hospital.module.rehabilitation.service.RehabilitationManageService;
import com.yihu.jw.hospital.prescription.dao.PrescriptionDao;
import com.yihu.jw.hospital.task.PushMsgTask;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.patient.service.BasePatientService;
import com.yihu.jw.rehabilitation.ServiceItemPlanDao;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.jw.util.idcard.IdCardUtil;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONObject;
import org.jsoup.Jsoup;
@ -40,7 +32,6 @@ import org.jsoup.nodes.Document;
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.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
@ -81,7 +72,6 @@ public class FollowUpService {
    @Autowired
    private FollowupContentDao followupContentDao;
    @Autowired
    private WlyyHospitalSysDictDao hospitalSysDictDao;
    @Autowired
@ -89,34 +79,144 @@ public class FollowUpService {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private PushMsgTask pushMsgTask;
    @Autowired
    private RehabilitationManageService rehabilitationManageService;
    @Autowired
    private ServiceItemPlanDao serviceItemPlanDao;
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Value("${doctorAssistant.api}")
    private String doctorAssistant;
    @Value("${doctorAssistant.target_url}")
    private String targetUrl;
//
//    @Value("${es.type.FollowUpContent}")
//    private String esType;
//    @Value("${es.index.FollowUp}")
//    private String esIndex;
    @Autowired
    private SystemMessageService messageService;
    @Autowired
    private ObjectMapper objectMapper;
    @Autowired
    private FollowupSignDao followupSignDao;
    @Autowired
    private PrescriptionDao prescriptionDao;
    //随访记录列表
    public PageEnvelop followupPage(String businessType, String businessSource, String startDate, String endDate, String patientName,
                                    String followupStatus,String doctorName, Integer page, Integer size){
        String sql = "SELECT DISTINCT f.id,f.patient_name patientName,f.patient_code patientCode,p.idcard,p.birthday,p.sex,p.mobile, " +
                "f.doctor_code doctorCode,f.doctor_name doctorName,pl.disease_name businessTypeName,pl.disease businessType, " +
                "h.dept_code deptCode,h.dept_name deptName,f.`status`,date_format(f.followup_date, '%Y-%m-%d %H:%i:%s') followupDate,'诊后康复' businessSource," +
                "date_format(f.followup_plan_date, '%Y-%m-%d %H:%i:%s') followupPlanDate,date_format(pl.create_time, '%Y-%m-%d %H:%i:%s') turnDownDate," +
                "pl.plan_doctor_name planDoctorName,h2.dept_name turnDownDeptName ";
        String countSql = "select count(DISTINCT f.id) ";
        String filter = " from wlyy_followup f " +
                "INNER JOIN base_service_item_plan ip on  f.id = ip.relation_code and ip.relation_type='6' " +
                "LEFT JOIN wlyy_patient_rehabilitation_plan pl on pl.id = ip.plan_id " +
                "INNER JOIN base_patient p on p.id = f.patient_code " +
                "LEFT JOIN base_doctor_hospital h on f.doctor_code=h.doctor_code and h.del=1 " +
                "LEFT JOIN base_doctor_hospital h2 on pl.plan_doctor=h2.doctor_code and h2.del=1 " +
                "WHERE 1=1 ";
        if(StringUtils.isNotBlank(businessType)){
            filter += " and pl.disease='"+businessType+"' ";
        }
        if(StringUtils.isNotBlank(businessSource)){
        }
        if (StringUtils.isNotBlank(patientName)){
            filter += " and f.patient_name like '%" + patientName + "%' ";
        }
        if(StringUtils.isNotBlank(followupStatus)){
            filter += " and f.status='"+followupStatus+"' ";
        }
        if(StringUtils.isNotBlank(doctorName)){
            sql += " and f.doctor_name like '%"+doctorName+"%' ";
        }
        if (StringUtils.isNotBlank(startDate)){
            filter += " and f.followup_date>='"+startDate+"' ";
        }
        if (StringUtils.isNotBlank(endDate)){
            filter += " and f.followup_date<='"+endDate+" 23:59:59' ";
        }
        String orderBy = " order by f.followup_date desc limit "+(page-1)*size+","+size;
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql+filter+orderBy);
        for (Map<String, Object> vo : list) {
            String idcard = vo.get("idcard")+"";
            String birthday = vo.get("birthday")+"";
            Integer age = com.yihu.jw.util.common.IdCardUtil.getAgeByBirthdayOrIdcard(idcard,DateUtil.strToDate(birthday));
            String status = vo.get("status")+"";
            if("1".equals(status)){
                vo.put("statusName", "已完成");
            }else {
                vo.put("statusName", "未完成");
            }
            vo.put("age", age);
            String sex = vo.get("sex")+"";
            if("1".equals(sex)){
                vo.put("sexName", "男");
            }else if("2".equals(sex)){
                vo.put("sexName", "女");
            }else {
                vo.put("sexName", "未知");
            }
        }
        long count = jdbcTemplate.queryForObject(countSql+filter,Long.class);
        return PageEnvelop.getSuccessListWithPage("查询成功",list,page,size,count);
    }
    //业务类型
    public List<Map<String, Object>> businessTypeList(){
        String sql = "select distinct disease code,disease_name name from wlyy_patient_rehabilitation_plan order by disease_name";
        return jdbcTemplate.queryForList(sql);
    }
    public List<Map<String, Object>> followupList(String businessType, String businessSource, String startDate, String endDate, String patientName,
                                    String followupStatus,String doctorName){
        String sql = "SELECT DISTINCT f.id,f.patient_name patientName,f.patient_code patientCode,p.idcard,p.birthday,p.sex,p.mobile,p.address, " +
                "f.doctor_code doctorCode,f.doctor_name doctorName,pl.disease_name businessTypeName,pl.disease businessType, " +
                "h.dept_code deptCode,h.dept_name deptName,f.`status`,date_format(f.followup_date, '%Y-%m-%d %H:%i:%s') followupDate,'诊后康复' businessSource," +
                "date_format(f.followup_plan_date, '%Y-%m-%d %H:%i:%s') followupPlanDate,date_format(pl.create_time, '%Y-%m-%d %H:%i:%s') turnDownDate,pl.plan_doctor_name planDoctorName,h2.dept_name turnDownDeptName ";
        String filter = " from wlyy_followup f " +
                "INNER JOIN base_service_item_plan ip on  f.id = ip.relation_code and ip.relation_type='6' " +
                "LEFT JOIN wlyy_patient_rehabilitation_plan pl on pl.id = ip.plan_id " +
                "INNER JOIN base_patient p on p.id = f.patient_code " +
                "LEFT JOIN base_doctor_hospital h on f.doctor_code=h.doctor_code and h.del=1 " +
                "LEFT JOIN base_doctor_hospital h2 on pl.plan_doctor=h2.doctor_code and h2.del=1 " +
                "WHERE 1=1 ";
        if(StringUtils.isNotBlank(businessType)){
            filter += " and pl.disease='"+businessType+"' ";
        }
        if(StringUtils.isNotBlank(businessSource)){
        }
        if (StringUtils.isNotBlank(patientName)){
            filter += " and f.patient_name like '%" + patientName + "%' ";
        }
        if(StringUtils.isNotBlank(followupStatus)){
            filter += " and f.status='"+followupStatus+"' ";
        }
        if(StringUtils.isNotBlank(doctorName)){
            sql += " and f.doctor_name like '%"+doctorName+"%' ";
        }
        if (StringUtils.isNotBlank(startDate)){
            filter += " and f.followup_date>='"+startDate+"' ";
        }
        if (StringUtils.isNotBlank(endDate)){
            filter += " and f.followup_date<='"+endDate+" 23:59:59' ";
        }
        String orderBy = " order by f.followup_date desc ";
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql+filter+orderBy);
        for (Map<String, Object> vo : list) {
            String idcard = vo.get("idcard")+"";
            String status = vo.get("status")+"";
            if("1".equals(status)){
                vo.put("statusName", "已完成");
            }else {
                vo.put("statusName", "未完成");
            }
            String sex = vo.get("sex")+"";
            if("1".equals(sex)){
                vo.put("sexName", "男");
            }else if("2".equals(sex)){
                vo.put("sexName", "女");
            }else {
                vo.put("sexName", "未知");
            }
            String birthday = vo.get("birthday")+"";
            Integer age = com.yihu.jw.util.common.IdCardUtil.getAgeByBirthdayOrIdcard(idcard,DateUtil.strToDate(birthday));
            vo.put("age", age);
        }
        return list;
    }
    //字典
    public String getDictValue(String dictName,String code){
@ -355,9 +455,7 @@ public class FollowUpService {
     */
    public JSONArray getListByPatient(
            String patient, int page, int pageSize, String type,String doctorCode) {
//        Sort sort = new Sort(Sort.Direction.DESC, "createTime");
        PageRequest pageRequest = PageRequest.of(page, pageSize);
        Page<Object> result = null;
        if (StringUtils.isBlank(type)) {
@ -473,11 +571,9 @@ public class FollowUpService {
    public List<Map<String, String>> getListByCreater(String doctorCode, String startTime, String endTime, String page, String pageSize) throws Exception {
        List<Map<String, String>> re = new ArrayList<>();
        // 排序
//        Sort sort = new Sort(Sort.Direction.ASC, "followupDate");
        // 分页信息
        int pageInt = Integer.valueOf(page) - 1;
        int pageSizeInt = Integer.valueOf(pageSize);
//        Pageable pageRequest = new PageRequest(pageInt, pageSizeInt, sort);
        PageRequest pageRequest = PageRequest.of(pageInt, pageSizeInt);
        List<Followup> list = followupDao.findByCreater(doctorCode, DateUtil.strToDate(startTime), DateUtil.strToDate(endTime), pageRequest);
@ -1076,37 +1172,6 @@ public class FollowUpService {
                    message.setType("4");//随访计划提醒
                    message.setReadonly(1);//是否只读消息
                    list.add(message);
                    if (messageService.getMessageNoticeSettingByMessageType(doctor, "1", MessageNoticeSetting.MessageTypeEnum.systemSwitch.getValue())) {
                        // 推送消息给医生
                        pushMsgTask.put(doctor, "4", title, content, "");
                        try {
                            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                            List<Followup> followups = followupDao.getByDoctorPlan(doctor, format.parse(start), format.parse(end));
                            for (Followup followup : followups) {
                                //            新增发送医生助手模板消息 v1.4.0 by wujunjie
                                BaseDoctorDO doctor1 = doctorDao.findById(doctor).orElse(null);
                                String doctorOpenID = doctor1.getOpenid();
                                if (StringUtils.isNotEmpty(doctorOpenID)) {
                                    String url = doctorAssistant + "/wlyy/feldsher/sendDoctorTemplates";
                                    List<NameValuePair> params = new ArrayList<>();
                                    params.add(new BasicNameValuePair("type", "6"));
                                    params.add(new BasicNameValuePair("openId", doctorOpenID));
                                    params.add(new BasicNameValuePair("url", targetUrl));
                                    params.add(new BasicNameValuePair("first", "您今日有" + count + "个随访计划待处理"));
                                    params.add(new BasicNameValuePair("remark", ""));
                                    SimpleDateFormat formatDate = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
                                    String newDate = formatDate.format(new Date());
                                    String keywords = followup.getPatientName() + newDate + "," + "请进入手机APP查看";
                                    params.add(new BasicNameValuePair("keywords", keywords));
                                    httpClientUtil.post(url, params, "UTF-8");
                                }
                            }
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                }
                messageDao.saveAll(list);
            }
@ -1117,236 +1182,6 @@ public class FollowUpService {
        }
    }
    /**
     * ES 保存随访记录详情
     *
     * @author huangwenjie
     * @date 2017/11/1 14:57
     */
//    @Transactional
//    public void esSaveFollowupProjectData(String id, String followupProject, String followupProjectData) throws Exception {
//        JestClient jestClient = null;
//        try {
//
//
//            jestClient = elasticFactory.getJestClient();
//            //先根据条件查找出来
//            SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
//            searchSourceBuilder.query(
//                    new BoolQueryBuilder()
//                            .must(QueryBuilders.matchQuery("followup_id", id))
//                            .must(QueryBuilders.matchQuery("followup_project", followupProject))
//            );
//
//            Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
//                    .build();
//            SearchResult result = jestClient.execute(search);
//            FollowupContentESDO followupContentESDO = result.getSourceAsObject(FollowupContentESDO.class);
//
//            List<FollowupContentESDO> dataList = new ArrayList<>();
//            if(followupContentESDO != null){
//                dataList.add(followupContentESDO);
//                //删除原有记录
//                this.esDeleteFollowUpContent(dataList);
//            }
//
//            //保存新的随访详情信息
//            List<FollowupContentESDO> newdatalist = new ArrayList<>();
//            followupContentESDO = new FollowupContentESDO();
//            followupContentESDO = JSON.parseObject(followupProjectData, FollowupContentESDO.class);
//            followupContentESDO.setFollowup_id(id);
//            followupContentESDO.setFollowup_project(followupProject);
//            followupContentESDO.setCreate_time(new Date());
//            newdatalist.add(followupContentESDO);
//            elastricSearchSave.save(newdatalist, esIndex, esType);
//
//
//            //如果该随访是已完成的,则添加随访信息上传映射,上传到基卫
//            Followup followup = followupDao.findOne(Long.valueOf(id));
//            if ("1".equals(followup.getStatus())) {
//                FollowupMapping followupMapping = followUpMappingDao.findByFollowupId(Integer.parseInt(id));
//                if (followupMapping == null) {
//                    followupMapping = new FollowupMapping();
//                    followupMapping.setCode(UUID.randomUUID().toString());
//                    followupMapping.setFollowupId(Integer.parseInt(id));
//                    followupMapping.setUpdateTime(DateUtil.getNowTimestamp());
//                    followupMapping.setCreateTime(DateUtil.getNowTimestamp());
//                }
//                followupMapping.setNeedUpload(1);
//                followUpMappingDao.save(followupMapping);
//                //随访完成,增加随访状态完成的标记
//                Prescription prescription = prescriptionDao.findByCode(followup.getPrescriptionCode());
//                if(prescription  != null){
//                    prescription.setViewSuifang(1);
//                    prescriptionDao.save(prescription);
//                }
//            }
//
//        } finally {
//            if (jestClient != null) {
//                jestClient.shutdownClient();
//            }
//        }
//    }
    /**
     * ES获取面访项目数据
     */
//    public FollowupContentESDO esGetFollowupProjectData(String id, String followupProject) throws Exception {
//        JestClient jestClient = null;
//        FollowupContentESDO followupContentESDO = null;
//        try {
//            //根据随访ID、分类ID获取随访记录详情
//            jestClient = elasticFactory.getJestClient();
//            //先根据条件查找出来
//            SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
//            searchSourceBuilder.query(
//                    new BoolQueryBuilder()
//                            .must(QueryBuilders.matchQuery("followup_id", id))
//                            .must(QueryBuilders.matchQuery("followup_project", followupProject))
//            );
//
//            Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
//                    .build();
//            SearchResult result = jestClient.execute(search);
//            followupContentESDO = result.getSourceAsObject(FollowupContentESDO.class);
//        } finally {
//            if (jestClient != null) {
//                jestClient.shutdownClient();
//            }
//        }
//        return followupContentESDO;
//    }
    /**
     * ES 删除随访详情信息
     *
     * @author huangwenjie
     * @date 2017/11/1 15:17
     */
//    public void esDeleteFollowUpContent(List<FollowupContentESDO> datalist) throws Exception {
//        JestClient jestClient = null;
//        try {
//            jestClient = elasticFactory.getJestClient();
//            //根据id批量删除
//            Bulk.Builder bulk = new Bulk.Builder().defaultIndex(esIndex).defaultType(esType);
//            for (FollowupContentESDO obj : datalist) {
//                Delete index = new Delete.Builder(obj.getId()).build();
//                bulk.addAction(index);
//            }
//            BulkResult br = jestClient.execute(bulk.build());
//
//            logger.info("delete data count:" + datalist.size());
//            logger.info("delete flag:" + br.isSucceeded());
//            jestClient.shutdownClient();
//        } finally {
//            if (jestClient != null) {
//                jestClient.shutdownClient();
//            }
//        }
//
//    }
    /**
     * ES获取面访项目数据列表
     *
     * @author huangwenjie
     * @date 2017/11/1 19:41
     */
//    public List<String> esfindProjectByFollowupId(String id) throws Exception {
//        JestClient jestClient = null;
//        List<String> resultList = new ArrayList<>();
//        try {
//            //根据随访ID、分类ID获取随访记录详情
//            jestClient = elasticFactory.getJestClient();
//            //先根据条件查找出来
//            SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
//            searchSourceBuilder.from(0).size(100);
//            searchSourceBuilder.query(
//                    new BoolQueryBuilder()
//                            .must(QueryBuilders.matchQuery("followup_id", id))
//            );
//
//            Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
//                    .build();
//            SearchResult result = jestClient.execute(search);
//
//            List<FollowupContentESDO> followupContentESDOList = new ArrayList<>();
//
//            followupContentESDOList = result.getSourceAsObjectList(FollowupContentESDO.class);
//            if (!followupContentESDOList.isEmpty()) {
//                for (FollowupContentESDO followupContentESDO : followupContentESDOList) {
//
//                    if("2".equals(followupContentESDO.getFollowup_project())){
////                        //判断血压必填
////                        if(StringUtils.isNotBlank(followupContentESDO.getBP_D()) && StringUtils.isNotBlank(followupContentESDO.getBP_U())
////                        &&StringUtils.isNotBlank(followupContentESDO.getBLOOD_SUGAR()) && StringUtils.isNotBlank(followupContentESDO.getBLOOD_SUGAR_TYPE())){
////                            resultList.add(followupContentESDO.getFollowup_project());
////                        } else if(StringUtils.isNotBlank(followupContentESDO.getBP_D()) && StringUtils.isNotBlank(followupContentESDO.getBP_U())){
////                            resultList.add(followupContentESDO.getFollowup_project());
////                        }
//                        if(StringUtils.isNotBlank(followupContentESDO.getBP_D()) && StringUtils.isNotBlank(followupContentESDO.getBP_U())){
//                            resultList.add(followupContentESDO.getFollowup_project());
//                        }
//                        if(StringUtils.isNotBlank(followupContentESDO.getBLOOD_SUGAR()) && StringUtils.isNotBlank(followupContentESDO.getBLOOD_SUGAR_TYPE())){
//                            resultList.add(followupContentESDO.getFollowup_project());
//                        }
//                    }else if("3".equals(followupContentESDO.getFollowup_project())){
//                        //判断血糖必填
//                        if(StringUtils.isNotBlank(followupContentESDO.getBS_FPG()) ||
//                                StringUtils.isNotBlank(followupContentESDO.getNO_BS_FPG())||
//                                    StringUtils.isNotBlank(followupContentESDO.getRANDOM_BLOOD_SUGAR())){
//                            resultList.add(followupContentESDO.getFollowup_project());
//                        }
//                    }else{
//                        resultList.add(followupContentESDO.getFollowup_project());
//                    }
//
//                }
//            }
//
//            jestClient.shutdownClient();
//        } finally {
//            if (jestClient != null) {
//                jestClient.shutdownClient();
//            }
//        }
//        return resultList;
//    }
    /**
     * ES获取面访项目数据详情
     *
     * @author huangwenjie
     * @date 2017/11/1 19:41
     */
//    public List<FollowupContentESDO> esfindFollowUpContestsByFollowupId(String id) throws Exception {
//        JestClient jestClient = null;
//        List<FollowupContentESDO> followupContentESDOList = new ArrayList<>();
//        try {
//            //根据随访ID、分类ID获取随访记录详情
//
//            List<String> resultList = new ArrayList<>();
//
//            jestClient = elasticFactory.getJestClient();
//            //先根据条件查找出来
//            SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
//            searchSourceBuilder.query(
//                    new BoolQueryBuilder()
//                            .must(QueryBuilders.matchQuery("followup_id", id))
//            );
//
//            Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
//                    .build();
//            SearchResult result = jestClient.execute(search);
//
//        } finally {
//            if (jestClient != null) {
//                jestClient.shutdownClient();
//            }
//        }
//        return followupContentESDOList;
//    }
    /**
     * 根据续方CODE获取随访记录信息
@ -1363,109 +1198,6 @@ public class FollowUpService {
        return jsonString;
    }
    /**
     * 获取随访详情记录分类记录数
     *
     * @param followupid
     * @param type
     * @return
     */
//    public int getfollowupcontent(String followupid, String type) throws Exception {
//
//        int count = 0;
//        String[] typelist = null;
//        if (type.contains(",")) {
//            typelist = type.split(",");
//        } else {
//            typelist = new String[]{type};
//        }
//
//        for (String typekey : typelist) {
//            if (!"drug".equals(type)) {
//
//                FollowupContentESDO followupContentESDO = this.esGetFollowupProjectData(followupid, typekey);
//                if (followupContentESDO != null) {
//                    count++;
//                }
//
//            } else {
//                //获取用药记录
//                List<FollowupDrugs> drugsList = followupDrugsDao.findByFollowupId(Long.valueOf(followupid));
//                if (!drugsList.isEmpty()) {
//                    count = count + drugsList.size();
//                }
//            }
//        }
//
//        return count;
//
//    }
    /**
     * 检查随访记录是否可完成
     * @param followupid
     * @return
     */
//    public boolean checkfollowupcompleted(String followupid)  throws Exception {
//        boolean result = true;
//
//        List<FollowupContentESDO> eslist = this.esfindFollowUpContestsByFollowupId(followupid);
//
//        if (!eslist.isEmpty()) {
//            for (FollowupContentESDO followupContentESDO : eslist) {
//
//                if("2".equals(followupContentESDO.getFollowup_project())){
//                    //判断血压必填
//                    if(StringUtils.isBlank(followupContentESDO.getBP_D()) || StringUtils.isBlank(followupContentESDO.getBP_U())){
//                        return false;
//                    }
//                }else if("3".equals(followupContentESDO.getFollowup_project())){
//                    //判断血糖必填
//                    if(StringUtils.isBlank(followupContentESDO.getBS_FPG()) &&
//                            StringUtils.isBlank(followupContentESDO.getNO_BS_FPG()) &&
//                            StringUtils.isBlank(followupContentESDO.getRANDOM_BLOOD_SUGAR())){
//                        return false;
//                    }
//                }else if("5".equals(followupContentESDO.getFollowup_project())){
//                    //判断评价
//                    if(StringUtils.isBlank(followupContentESDO.getDIA_FOLLOWUP_TYPE_CODE()) &&
//                            StringUtils.isBlank(followupContentESDO.getHYP_FOLLOWUP_TYPE_CODE())){
//                        return false;
//                    }
//                }else{}
//
//            }
//        }
//
//        return result;
//    }
//
    /**
     * 保存随访详情
     * followupContentESDO
     */
//    public void esSaveFollowupContentESDAO(FollowupContentESDO followupContentESDO)throws Exception{
//        JestClient jestClient = null;
//        try {
//
//
//            jestClient = elasticFactory.getJestClient();
//
//            List<FollowupContentESDO> dataList = new ArrayList<>();
//            if(followupContentESDO != null){
//                dataList.add(followupContentESDO);
//                //删除原有记录
//                this.esDeleteFollowUpContent(dataList);
//            }
//            elastricSearchSave.save(dataList, esIndex, esType);
//
//        } finally {
//            if (jestClient != null) {
//                jestClient.shutdownClient();
//            }
//        }
//    }
    public void updateFollowup(Long id) {
        Followup followup = followupDao.findById(id).orElse(null);
        followup.setStatus("1");

+ 9 - 136
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/rehabilitation/service/SynchronizePatientService.java

@ -1,31 +1,20 @@
package com.yihu.jw.hospital.module.rehabilitation.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.dict.dao.BaseFrequencyDictDao;
import com.yihu.jw.dict.dao.FrequencyDao;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.door.SignPatientLabelInfo;
import com.yihu.jw.entity.specialist.rehabilitation.*;
import com.yihu.jw.hospital.HospitalDao;
import com.yihu.jw.hospital.appointment.dao.SpecialDiseaseDao;
import com.yihu.jw.hospital.async.AsynService;
import com.yihu.jw.hospital.message.service.SystemMessageService;
import com.yihu.jw.hospital.module.followup.service.FollowUpService;
import com.yihu.jw.hospital.module.rehabilitation.dao.PatientDischargeDao;
import com.yihu.jw.hospital.module.rehabilitation.dao.PatientRehabilitationPlanDao;
import com.yihu.jw.hospital.module.rehabilitation.dao.RehabilitationDetailDao;
import com.yihu.jw.hospital.module.rehabilitation.dao.RehabilitationPatientInfoDao;
import com.yihu.jw.hospital.module.specialist.dao.PatientDiseaseServerDao;
import com.yihu.jw.hospital.team.dao.SignPatientLabelInfoDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.patient.service.BasePatientService;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.jw.wlyy.service.WlyyBusinessService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
@ -38,7 +27,10 @@ import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.ArrayList;
import java.util.Base64;
import java.util.Date;
import java.util.List;
/**
 * Created by liub on 2020/9/29.
@ -49,9 +41,7 @@ public class SynchronizePatientService  {
    private Logger logger = LoggerFactory.getLogger(SynchronizePatientService.class);
//    @Value("${specialist.url}")
    private String specialistUrl;
//    @Value("${demo.flag}")
    private Boolean demoFlag=true;
    @Autowired
    private BaseDoctorDao doctorDao;
@ -62,39 +52,13 @@ public class SynchronizePatientService  {
    @Autowired
    private BasePatientDao patientDao;
    @Autowired
    private RehabilitationPlanService rehabilitationPlanService;
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Autowired
    private SpecialDiseaseDao specialDiseaseDao;
    @Autowired
    private SystemMessageService messageService;
    @Autowired
    private HospitalDao hospitalDao;
    @Autowired
    private FollowUpService followUpService;
    @Autowired
    private BaseFrequencyDictDao baseFrequencyDao;
    @Autowired
    private FrequencyDao frequencyDao;
    @Autowired
    private AsynService asynService;
    @Autowired
    private RehabilitationPatientInfoDao rehabilitationPatientInfoDao;
    @Autowired
    private PatientDischargeDao patientDischargeDao;
    @Autowired
    private BasePatientService patientService;
    @Autowired
    private RehabilitationInfoService rehabilitationInfoService;
    @Autowired
    private PatientRecordService patientRecordService;
    @Autowired
    private PatientDiseaseServerDao patientDiseaseServerDao;
    @Autowired
    private SignPatientLabelInfoDao signPatientLabelInfoDao;
    @Autowired
@ -230,12 +194,10 @@ public class SynchronizePatientService  {
        pmr.setDiseaseCode(diseaseId);//疾病code
        pmr.setDiseaseName(diseaseName);//疾病名称
        String jsonData = JSON.toJSONString(pmr);
        //创建居民住院病历
        objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
        PatientMedicalRecordsDO patientMedicalRecordsDO = objectMapper.readValue(jsonData, PatientMedicalRecordsDO.class);
        PatientMedicalRecordsDO patientMedicalRecordsDO1 = rehabilitationInfoService.createMedicalRecords(planDoctorId, patient.getId(), patient.getName(), patientMedicalRecordsDO, null);
        PatientMedicalRecordsDO patientMedicalRecordsDO1 = rehabilitationInfoService.createMedicalRecords(planDoctorId, patient.getId(), patient.getName(), pmr, null);
        if (patientMedicalRecordsDO1 == null) {
            infoUpdate(tmpList,2,modifyList,null);
@ -270,27 +232,6 @@ public class SynchronizePatientService  {
                return  "创建康复计划失败";
            } else {//创建康复计划成功
                String planId = planDO.getId();
                String relationId = " ";
                ////创建患者疾病类型 wlyy_patient_disease_server
                //获取id
//                PatientDiseaseServer patientDiseaseServer = patientDiseaseServerDao.findBySpecialistRelationCodeAndDiseaseAndCode(relationId,diseaseObj.getString("disease"), "1");
                PatientDiseaseServer patientDiseaseServerUp = new PatientDiseaseServer();
                patientDiseaseServerUp.setSpecialistRelationCode(relationId);
                patientDiseaseServerUp.setPatient(patient.getId());
                patientDiseaseServerUp.setPatientName(patient.getName());
                patientDiseaseServerUp.setDisease(diseaseId);//疾病
                patientDiseaseServerUp.setDiseaseName(diseaseName);//疾病名称
                patientDiseaseServerUp.setDel("1");
                patientDiseaseServerUp.setUpdateTime(new Date());
                patientDiseaseServerUp.setCreateTime(new Date());
//                if (patientDiseaseServer == null) {//创建疾病类型
//                    patientDiseaseServerDao.save(patientDiseaseServerUp);
//                } else {
//                    patientDiseaseServerDao.updateBySpecialistRelationCodeAndDel(relationId);
//                    patientDiseaseServerDao.save(patientDiseaseServerUp);
//                }
                //居民专科标签。
                List<SignPatientLabelInfo> healthList = signPatientLabelInfoDao.findByPatientAndLabelTypeAndStatus(patient.getId(), "8", 1);
                if (healthList.size() > 0) {
@ -505,12 +446,10 @@ public class SynchronizePatientService  {
            }
            pmr.setDiseaseCode(diseaseId);//疾病code
            pmr.setDiseaseName(diseaseName);//疾病名称
            String jsonData = JSON.toJSONString(pmr);
            //创建居民住院病历
            objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
            PatientMedicalRecordsDO patientMedicalRecordsDO = objectMapper.readValue(jsonData, PatientMedicalRecordsDO.class);
            PatientMedicalRecordsDO patientMedicalRecordsDO1 = rehabilitationInfoService.createMedicalRecords(planDoctorId, patient.getId(), patient.getName(), patientMedicalRecordsDO, null);
            PatientMedicalRecordsDO patientMedicalRecordsDO1 = rehabilitationInfoService.createMedicalRecords(planDoctorId, patient.getId(), patient.getName(), pmr, null);
            if (patientMedicalRecordsDO1 == null) {
                results.append("创建病历请求:" + re.getIdcard() + "----创建病历失败\n");
@ -555,28 +494,7 @@ public class SynchronizePatientService  {
                    String planId = planDO.getId();
                    Date date = new Date();
                    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                    String updateTime = df.format(date);
                    String relationId = " ";
                    ////创建患者疾病类型 wlyy_patient_disease_server
                    //获取id
//                    PatientDiseaseServer patientDiseaseServer = patientDiseaseServerDao.findBySpecialistRelationCodeAndDiseaseAndCode(relationId,diseaseObj.getString("disease"), "1");
                    PatientDiseaseServer patientDiseaseServerUp = new PatientDiseaseServer();
                    patientDiseaseServerUp.setSpecialistRelationCode(relationId);
                    patientDiseaseServerUp.setPatient(patient.getId());
                    patientDiseaseServerUp.setPatientName(patient.getName());
                    patientDiseaseServerUp.setDisease(diseaseId);//疾病
                    patientDiseaseServerUp.setDiseaseName(diseaseName);//疾病名称
                    patientDiseaseServerUp.setDel("1");
                    patientDiseaseServerUp.setUpdateTime(new Date());
                    patientDiseaseServerUp.setCreateTime(new Date());
//                    if (patientDiseaseServer == null) {//创建疾病类型
//                        patientDiseaseServerDao.save(patientDiseaseServerUp);
//                    } else {
//                        patientDiseaseServerDao.updateBySpecialistRelationCodeAndDel(relationId);
//                        patientDiseaseServerDao.save(patientDiseaseServerUp);
//                    }
                    //居民专科标签。
                    List<SignPatientLabelInfo> healthList = signPatientLabelInfoDao.findByPatientAndLabelTypeAndStatus(patient.getId(), "8", 1);
                    if (healthList.size() > 0) {
@ -603,11 +521,7 @@ public class SynchronizePatientService  {
                }
            }
        }
//        for (int i = 0; i < successSync.size(); i++) {
//            JSONObject syncObject = (JSONObject) successSync.get(i);
//            sendMessageToDoctor(syncObject);//APP端发送消息通知
//            sendMessageToDoctorTemplates(syncObject);//i健康助手发送消息通知
//        }
        rehabilitationPatientInfoDao.saveAll(modifyList);
        return results;
    }
@ -786,12 +700,10 @@ public class SynchronizePatientService  {
            }
            pmr.setDiseaseCode(diseaseId);//疾病code
            pmr.setDiseaseName(diseaseName);//疾病名称
            String jsonData = JSON.toJSONString(pmr);
            //创建居民住院病历
            objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
            PatientMedicalRecordsDO patientMedicalRecordsDO = objectMapper.readValue(jsonData, PatientMedicalRecordsDO.class);
            PatientMedicalRecordsDO patientMedicalRecordsDO1 = rehabilitationInfoService.createMedicalRecords(planDoctorId, patient.getId(), patient.getName(), patientMedicalRecordsDO, null);
            PatientMedicalRecordsDO patientMedicalRecordsDO1 = rehabilitationInfoService.createMedicalRecords(planDoctorId, patient.getId(), patient.getName(), pmr, null);
            if (patientMedicalRecordsDO1 == null) {
                results.append("创建病历请求:" + re.getIdcard() + "----创建病历失败\n");
@ -836,25 +748,6 @@ public class SynchronizePatientService  {
                    String planId = planDO.getId();
                    ////创建患者疾病类型 wlyy_patient_disease_server
                    String relationId = "";
                    //获取id
//                    PatientDiseaseServer patientDiseaseServer = patientDiseaseServerDao.findBySpecialistRelationCodeAndDiseaseAndCode(relationId,diseaseObj.getString("disease"), "1");
                    PatientDiseaseServer patientDiseaseServerUp = new PatientDiseaseServer();
                    patientDiseaseServerUp.setSpecialistRelationCode(relationId);
                    patientDiseaseServerUp.setPatient(patient.getId());
                    patientDiseaseServerUp.setPatientName(patient.getName());
                    patientDiseaseServerUp.setDisease(diseaseId);//疾病
                    patientDiseaseServerUp.setDiseaseName(diseaseName);//疾病名称
                    patientDiseaseServerUp.setDel("1");
                    patientDiseaseServerUp.setUpdateTime(new Date());
                    patientDiseaseServerUp.setCreateTime(new Date());
//                    if (patientDiseaseServer == null) {//创建疾病类型
//                        patientDiseaseServerDao.save(patientDiseaseServerUp);
//                    } else {
//                        patientDiseaseServerDao.updateBySpecialistRelationCodeAndDel(relationId);
//                        patientDiseaseServerDao.save(patientDiseaseServerUp);
//                    }
                    //居民专科标签。
                    List<SignPatientLabelInfo> healthList = signPatientLabelInfoDao.findByPatientAndLabelTypeAndStatus(patient.getId(), "8", 1);
                    if (healthList.size() > 0) {
@ -899,27 +792,7 @@ public class SynchronizePatientService  {
        planDO = patientRehabilitationPlanDao.save(planDO);
        List<RehabilitationDetailDO> detailDOList = new ArrayList<>();
        for(RehabilitationTemplateDetailDO detailDO : templateDetail) {
//            String server_item_id = detailDO.getServerTimeType();
//            String plan_start_time_type = detailDO.getPlanStartTimeType();//计划开始时间类型
//            String server_count = detailDO.getServerCount();//服务次数
            String frequency_code = detailDO.getFrequencyCode();//频次
//            LocalDateTime localDateTime = LocalDateTime.now();
//            int addNum = Integer.parseInt(plan_start_time_type);
//            localDateTime = localDateTime.plusDays(addNum);
//            List<String>  timeList = CronUtils.getExecutionTimeByNum(frequency_code,Integer.parseInt(server_count),localDateTime);
//            for (String time :timeList){
//                ServiceItemPlanDO planDO = new ServiceItemPlanDO();
//                planDO.setPlanTime(time);
//                planDO.setPatient(patient);
//                planDO.setName(name);
//                planDO.setStatus("0");
//                planDO.setServicePackId(packageId);
//                planDO.setServiceItemId(server_item_id);
//                planDO.setItemConfigId(id);
//                planDO.setRelationType(code);
//                planDO.setSignId(signId);
//                planDOList.add(planDO);
//            }
            RehabilitationDetailDO detail = new RehabilitationDetailDO();
            detail.setHospitalServiceItemId(detailDO.getHospitalServiceItemId());
            detail.setCreateTime(new Date());