瀏覽代碼

代码修改

LAPTOP-KB9HII50\70708 10 月之前
父節點
當前提交
2d92336629

+ 4 - 6
business/base-service/src/main/java/com/yihu/jw/article/service/BaseMenuManageService.java

@ -791,10 +791,11 @@ public class BaseMenuManageService {
                menuIds.add(str[i]);
            }
        }
        if (StringUtils.isBlank(menuId)) {
            menuId = "";
        }
        if (StringUtils.isNotBlank(articleType)) {
            if (StringUtils.isBlank(menuId)) {
                menuId = "";
            }
            String sqlType = "select * from base_menu_dict where article_type='" + articleType + "' and is_del='1' and status=1";
            List<BaseMenuDictDO> menuDictDOS = jdbcTemplate.query(sqlType, new BeanPropertyRowMapper<>(BaseMenuDictDO.class));
            if (menuDictDOS.size() > 0) {
@ -806,9 +807,6 @@ public class BaseMenuManageService {
            }
        }
        if (StringUtils.isNotBlank(categoryFirst)) {
            if (StringUtils.isBlank(menuId)) {
                menuId = "";
            }
            String sqlType = "select * from base_menu_dict where parent_id='" + categoryFirst + "' and is_del='1' and status=1";
            List<BaseMenuDictDO> menuDictDOS = jdbcTemplate.query(sqlType, new BeanPropertyRowMapper<>(BaseMenuDictDO.class));
            if (menuDictDOS.size() > 0) {

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

@ -896,6 +896,11 @@ public class WlyyBusinessService {
            return null;
        }
    }
    public JSONObject getThirdNum(String templateCode,String idcard) {
        String param = "?templateCode=" + nullToTransfor(templateCode) + "&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)

+ 0 - 2
business/es-service/src/main/java/com/yihu/jw/es/service/StatisticsEsService.java

@ -4076,12 +4076,10 @@ public class StatisticsEsService {
            List<SaveModel> concleTotal = elasticsearchUtil.findListDateQuotaLevel2(startTime, endTime, area, level, index, SaveModel.timeLevel_ZL, lowLevel, lowCode, "-1");
            //咨询总数
            List<SaveModel> total = elasticsearchUtil.findListDateQuotaLevel1(startTime, endTime, area, level, index1, SaveModel.timeLevel_ZL, lowLevel, lowCode);
            logger.info("total" + total == null ? "0" : String.valueOf(total.size()) + ";" + total.get(0).getResult1());
            //已接诊
            List<SaveModel> haveReceiveTotal = elasticsearchUtil.findListDateQuotaLevel2(startTime, endTime, area, level, index1, SaveModel.timeLevel_ZL, lowLevel, lowCode, "1");
            //未接诊
            List<SaveModel> noReceiveTotal = elasticsearchUtil.findListDateQuotaLevel2(startTime, endTime, area, level, index1, SaveModel.timeLevel_ZL, lowLevel, lowCode, "0");
            logger.info("noReceiveTotal" + noReceiveTotal == null ? "0" : String.valueOf(noReceiveTotal.size()) + ";" + noReceiveTotal.get(0).getResult1());
            result.put("resultList", getCoutListPC1(level, lowLevel, endTotal, total, haveReceiveTotal, noReceiveTotal, concleTotal));
        }

+ 10 - 2
common/common-entity/src/db/2024.sql

@ -351,11 +351,19 @@ INSERT INTO `base`.`wlyy_job_config_new` (`id`, `job_name`, `job_info`, `job_typ
`sql_count`, `sql_day`, `sql_year`, `cache_key`, `quartz_cron`, `status`, `quota_id`, `del`, `extract_type`,
`time_level`, `increment_interval`) VALUES ('78', '护理咨询-门诊状态', '护理咨询-门诊状态', '2', '6',
 'com.yihu.jw.statistics.job.business.MysqlToEsQuotaJob', 'SELECT c.id AS business_id, c.doctor AS doctor,CONCAT(c.outpatient_status,\'\') AS slaveKey2 , CONCAT(c.type,\'\') as slaveKey1 FROM wlyy_consult_outpatient_info c WHERE c.type =18 ', 'SELECT COUNT(c.id) FROM wlyy_consult_outpatient_info c WHERE c.type =18 ', 'AND c.create_time <:endTime  AND c.create_time  >=:startTime ', NULL, NULL, '0 30 0 * * ?', '0', '78', '1', NULL, '3', '1');
INSERT INTO `base`.`wlyy_job_config_new` (`id`, `job_name`, `job_info`, `job_type`, `area_level`, `job_class`, `sql`,
 `sql_count`, `sql_day`, `sql_year`, `cache_key`, `quartz_cron`, `status`, `quota_id`, `del`, `extract_type`,
  `time_level`, `increment_interval`) VALUES ('79', '护理咨询-就诊状态', '护理咨询-就诊状态', '2', '6',
'com.yihu.jw.statistics.job.business.MysqlToEsQuotaJob', 'SELECT c.id AS business_id, c.doctor AS doctor,CONCAT(c.visite_status,\'\') AS slaveKey1 FROM wlyy_consult_outpatient_info c WHERE c.type =18', 'SELECT COUNT(c.id) FROM wlyy_consult_outpatient_info c WHERE c.type=18', 'AND c.create_time <:endTime  AND c.create_time  >=:startTime ', NULL, NULL, '0 31 0 * * ?', '0', '79', '1', NULL, '3', '1');
INSERT INTO `base`.`dimension_quota` (`id`, `quota_code`, `dimension_code`, `dict_sql`, `convert_clazz`, `sort`, `key`)
VALUES ('64', '78', '8', 'select s.dict_code code,s.dict_value name from wlyy_hospital_sys_dict s where  s.dict_name=\'OUT_PATIENT_STATUS\'', NULL, '2', 'slaveKey2');
INSERT INTO `base`.`dimension_quota` (`id`, `quota_code`, `dimension_code`, `dict_sql`, `convert_clazz`, `sort`, `key`) VALUES ('64', '78', '8', 'select s.dict_code code,s.dict_value name from wlyy_hospital_sys_dict s where  s.dict_name=\'OUT_PATIENT_STATUS\'', NULL, '2', 'slaveKey2');
INSERT INTO `base`.`dimension_quota` (`id`, `quota_code`, `dimension_code`, `dict_sql`, `convert_clazz`, `sort`, `key`) VALUES ('65', '79', '7', 'select s.dict_code code,s.dict_value name from wlyy_hospital_sys_dict s where  s.dict_name=\'VISITE_STATUS\'', NULL, '2', 'slaveKey2');
INSERT INTO `base`.`dimension_quota` (`id`, `quota_code`, `dimension_code`, `dict_sql`, `convert_clazz`, `sort`, `key`) VALUES ('66', '79', '6', 'select s.dict_code code,s.dict_value name from wlyy_hospital_sys_dict s where  s.dict_name=\'NEW_OUTPATIENT_TYPE\'', NULL, '1', 'slaveKey1');
INSERT INTO `base`.`dimension_quota` (`id`, `quota_code`, `dimension_code`, `dict_sql`, `convert_clazz`, `sort`, `key`) VALUES ('67', '78', '6', 'select s.dict_code code,s.dict_value name from wlyy_hospital_sys_dict s where  s.dict_name=\'NEW_OUTPATIENT_TYPE\'', NULL, '1', 'slaveKey1');
INSERT INTO `oauth_wlyy_config` (`id`, `app_id`, `app_secret`, `token_url`, `url`, `remark`) VALUES
    ('findThirdScreenList', '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/findThirdScreenList', '厦门I健康获取同安筛查记录');
INSERT INTO `oauth_wlyy_config` (`id`, `app_id`, `app_secret`, `token_url`, `url`, `remark`) VALUES
    ('addSurveyThird', '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/addSurveyThird', '厦门I健康新增三院疾病筛查管理记录');
INSERT INTO `oauth_wlyy_config` (`id`, `app_id`, `app_secret`, `token_url`, `url`, `remark`) VALUES
    ('getThirdNum', '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/getThirdNum', '厦门I健康三院疾病筛查数量');

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

@ -2,11 +2,14 @@ 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.specialist.BaseDiseaseHospitalDO;
import com.yihu.jw.hospital.disease.service.BaseDiseaseHospitalService;
import com.yihu.jw.restmodel.web.Envelop;
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.wlyy.service.WlyyBusinessService;
@ -33,6 +36,8 @@ public class BaseDiseaseHospitalController extends EnvelopRestEndpoint {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private BaseDoctorDao doctorDao;
    @Autowired
    WlyyBusinessService wlyyBusinessService;
    @ApiOperation("疾病筛查管理发送短信")
@ -60,6 +65,29 @@ public class BaseDiseaseHospitalController extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = "getThirdNum")
    @ApiOperation(value = "三院疾病筛查数量")
    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(survey_code) survey_code from base_disease_survey";
            sql += " where 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()));
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError("失败");
        }
    }
    @GetMapping(value = "findThirdScreenList")
    @ApiOperation(value = "同安筛查记录")
    public Envelop findThirdScreenList(

+ 0 - 40
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/rehabilitation/controller/PatientRehabilitationManageController.java

@ -128,46 +128,6 @@ public class PatientRehabilitationManageController extends EnvelopRestEndpoint {
        }
    }
    /**
     * doctorCode: 361aef4891de492cb0e6a47cf9fe31f3
     * patientInfo:
     * level: 1
     * area: 350200
     * diseaseCode:
     * turnDownState: 0
     * page: 1
     * pageSize: 10
     * doctorType: 2
     * filterPlan: 1
     */
    @RequestMapping(value = "selectBySpecialistDoctor", method = RequestMethod.GET)
    @ApiOperation("康复管理-获取签约专科居民")
    public String selectBySpecialistDoctor(
            @ApiParam(name = "doctorCode", value = "医生code", required = false) @RequestParam(value = "doctorCode", required = false) String doctorCode,
            @ApiParam(name = "doctorType", value = "医生类型(1专科2家医)", required = false) @RequestParam(value = "doctorType", required = false) String doctorType,
            @ApiParam(name = "patientInfo", value = "身份证或者姓名", required = false) @RequestParam(value = "patientInfo", required = false) String patientInfo,
            @ApiParam(name = "diseaseCode", value = "疾病类型code", required = false) @RequestParam(value = "diseaseCode", required = false) String diseaseCode,
            @ApiParam(name = "level", value = "1市2区3社区", required = false) @RequestParam(value = "level", required = false) String level,
            @ApiParam(name = "area", value = "区域", required = false) @RequestParam(value = "area", required = false) String area,
            @ApiParam(name = "page", value = "第几页,从1开始", required = true) @RequestParam(value = "page", required = false, defaultValue = "1") Integer page,
            @ApiParam(name = "pageSize", value = "每页分页大小", required = true) @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize,
            @ApiParam(name = "filterPlan", value = "是否过滤康复计划,1过滤,0或者放空不过滤", required = false) @RequestParam(value = "filterPlan", required = false) String filterPlan,
            @ApiParam(name = "turnDownState", value = "下转状态 0全部;1已下转;2已接受;3未下转", required = false) @RequestParam(value = "turnDownState", required = false, defaultValue = "0") String turnDownState
    ) {
        try {
            if (!StringUtils.isNotEmpty(doctorCode)) {
                doctorCode = getRepUID();
            }
            JSONObject result = rehabilitationManageService.selectBySpecialistDoctor(level, area, doctorCode, diseaseCode, page, pageSize, doctorType, patientInfo, filterPlan, turnDownState);
            JSONArray showList = result.getJSONArray("showList");
            JSONObject turnDownStateObj = result.getJSONObject("turnDownState");
            return write(200, "获取成功", "data", showList, "data2", turnDownStateObj);
        } catch (Exception e) {
            return error(-1, e.getMessage());
        }
    }
    /**
     * 获取为某患者创建康复计划的专科医生列表,家庭医生,
     *

+ 0 - 218
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/rehabilitation/service/PatientRecordService.java

@ -665,204 +665,6 @@ public class PatientRecordService {
        return patient;
    }
//    public String areaMedicalDetail(String areaCode, String patientId, Boolean demoFlag) throws Exception {
//        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//        SimpleDateFormat shortFormat = new SimpleDateFormat("yyyyMMdd");
//        if (demoFlag) {
//            String json = patientRecordService.getJosnFileResullt("list_medical");
//            com.alibaba.fastjson.JSONObject jsonObject = JSON.parseObject(json);
//            com.alibaba.fastjson.JSONArray list = jsonObject.getJSONArray("list");
//
//            List<MedicalVo> medicalList = com.alibaba.fastjson.JSONObject.parseArray(JSON.toJSONString(list), MedicalVo.class);
//            for (MedicalVo medicalVo : medicalList) {
//                String medicalId = findMedicalId(medicalVo.getMedicalNo());
//                if (StringUtils.isNotBlank(medicalId)) {
//                    medicalDao.delete(medicalId);
//                }
//                String detailJsonStr = patientRecordService.getJosnFileResullt("medical_detail");
//                String medicalTime = medicalVo.getMedicalTime();
//                MedicalInfo resultVo = new MedicalInfo();
//                resultVo.setOrgName(medicalVo.getOrgName());
//                resultVo.setName("测试");
//                resultVo.setIdcard("8888888888888888");
//                resultVo.setMedicalTime(dateFormat.parse(medicalTime));
//                resultVo.setMedicalTimeShot(shortFormat.format(dateFormat.parse(medicalTime)));
//                resultVo.setMedicalNo(medicalVo.getMedicalNo());
//                resultVo.setDetailJson(detailJsonStr);
//                resultVo.setCjsj(new Date());
//                resultVo.setXgsj(new Date());
//                medicalDao.save(resultVo);
//                saveMedicalDetail(detailJsonStr, resultVo.getMedicalNo(), medicalId, "2");
//            }
//        } else {
//            List<SignPatientVo> patientList = findPatientByAreaCode(patientId, areaCode);
//            if (patientList.isEmpty()) {
//                return "没有查询到签约居民";
//            }
//            for (SignPatientVo vo : patientList) {
//                try {
//                    String idCard = vo.getIdcard();
//                    JSONArray medicalArray = jwArchivesService.getEhrSickMedicalList(idCard, 0, 0);
//                    for (int i = 0; i < medicalArray.length(); i++) {
//                        JSONObject object = medicalArray.getJSONObject(i);
//                        //是否存在
//                        String medicalId = findMedicalId(object.getString("medicalNo"));
//                        if (StringUtils.isNotBlank(medicalId)) {
//                            medicalDao.delete(medicalId);
//                        }
//                        JSONObject jsonObject = jwArchivesService.getEhrSickMedicalRecord(object.getString("medicalNo"));
//                        String detailJsonStr = jsonObject.toString();
//                        String medicalTime = object.getString("medicalTime");
//                        MedicalInfo resultVo = new MedicalInfo();
//                        resultVo.setOrgName(object.getString("orgName"));
//                        resultVo.setName(vo.getName());
//                        resultVo.setIdcard(idCard);
//                        resultVo.setMedicalTime(DateUtil.strToDateLong(medicalTime));
//                        resultVo.setMedicalTimeShot(DateUtil.strToDateShort(medicalTime).getTime() + "");
//                        resultVo.setDetailJson(detailJsonStr);
//                        resultVo.setMedicalNo(object.getString("medicalNo"));
//                        resultVo.setCjsj(new Date());
//                        resultVo.setXgsj(new Date());
//                        medicalDao.save(resultVo);
//                        saveMedicalDetail(detailJsonStr, resultVo.getMedicalNo(), medicalId, "2");
//                    }
//                } catch (Exception e) {
//                    writeFile(vo.getIdcard(), e.getMessage());
//                    e.printStackTrace();
//                }
//            }
//        }
//        return "保存完成";
//    }
    /**
     * 保存详情数据
     */
//    public String saveMedicalDetail(String json, String MedicalNo, String medicalId, String findType) throws Exception {
//        if (StringUtils.isBlank(MedicalNo)) {
//            return "参数为空";
//        }
//        MedicalDetailVo detailVo = null;
//        MedicalDetail detailEntity = new MedicalDetail();
//        String drugListJson = null;
//        String inhospitalListJson = null;
//        String niVaccinationListJson = null;
//
//        if (StringUtils.isNotBlank(json)) {
//            detailVo = com.alibaba.fastjson.JSONObject.parseObject(json, MedicalDetailVo.class);
//        } else {
//            if ("1".equals(findType)) {
//                //查库
//                MedicalInfo info = medicalDao.findInfoByMedicalNo(MedicalNo);
//                if (info != null) {
//                    drugListJson = JSON.parseObject(info.getDetailJson()).getString("drugList");
//                    inhospitalListJson = JSON.parseObject(info.getDetailJson()).getString("inhospitalList");
//                    niVaccinationListJson = JSON.parseObject(info.getDetailJson()).getString("niVaccinationList");
//                    detailVo = com.alibaba.fastjson.JSONObject.parseObject(info.getDetailJson(), MedicalDetailVo.class);
//                } else {
//                    return "查无数据,请核对体检号";
//                }
//            } else {
//                //远程
//                JSONObject jsonObject = jwArchivesService.getEhrSickMedicalRecord(MedicalNo);
//                System.out.println("medical_detail==>" + JSON.toJSONString(jsonObject));
//                drugListJson = jsonObject.getString("drugList");
//                inhospitalListJson = jsonObject.getString("inhospitalList");
//                niVaccinationListJson = jsonObject.getString("niVaccinationList");
//                detailVo = com.alibaba.fastjson.JSONObject.parseObject(JSON.toJSONString(jsonObject), MedicalDetailVo.class);
//            }
//        }
//        if (StringUtils.isBlank(medicalId)) {
//            medicalId = findMedicalId(MedicalNo);
//        }
//        String medicalDetailId = findMedicalDetailId(medicalId);
//        if (StringUtils.isNotBlank(medicalDetailId)) {
//            medicalDetailDao.delete(medicalDetailId);
//        }
//        BeanUtils.copyProperties(detailVo, detailEntity);
//
//        detailEntity.setMedicalInfoId(medicalId);
//        detailEntity.setMedicalNo(MedicalNo);
//        detailEntity.setDrugList(drugListJson);
//        detailEntity.setInhospitalList(inhospitalListJson);
//        detailEntity.setNiVaccinationList(niVaccinationListJson);
//        detailEntity.setFpList(detailVo.getFpList().isEmpty() ? null : JSON.toJSONString(detailVo.getFpList()));
//        detailEntity.setExaminationList(detailVo.getExaminationList().isEmpty() ? null : JSON.toJSONString(detailVo.getExaminationList()));
//        medicalDetailDao.save(detailEntity);
//        return "保存成功";
//    }
//    public String saveMedicalDetailMethod(String findType, String findAll) throws Exception {
//        if ("yes".equals(findAll)) {
//            //查全部
//            List<MedicalInfo> infoList = medicalDao.findAllMedicalInfo();
//            int q = 0;
//            for (MedicalInfo info : infoList) {
//                try {
//                    if ("1".equals(findType) && StringUtils.isNotBlank(info.getDetailJson())) {
//                        saveMedicalDetail(info.getDetailJson(), info.getMedicalNo(), info.getId(), findType);
//                    } else {
//                        saveMedicalDetail(null, info.getMedicalNo(), info.getId(), findType);
//                    }
//                    q++;
//                    System.out.println("进度:" + q + "/" + infoList.size());
//                } catch (Exception e) {
//                    e.printStackTrace();
//                }
//            }
//        } else {
//            List<MedicalVo> list = findMedicalTemp();
//            int q = 0;
//            for (MedicalVo vo : list) {
//                try {
//                    patientRecordService.saveMedicalDetail(null, vo.getMedicalNo(), null, findType);
//                } catch (Exception e) {
//                    e.printStackTrace();
//                }
//            }
//        }
//
//        return "执行完成";
//    }
//    private MedicalDetail medicalDicCodeToValue(MedicalDetail detailEntity) throws Exception {
//        //查出字典表进行替换
//        Field[] fields = detailEntity.getClass().getDeclaredFields();
//        for (Field field : fields) {
//            field.setAccessible(true);
//        }
//        return detailEntity;
//    }
    /**
     * 查询区域的签约人
     */
//    public List<SignPatientVo> findPatientByAreaCode(String patient, String areaCode) throws Exception {
//        HashMap<String, Object> map = new HashMap<>();
//        String sql = "SELECT DISTINCT q.patient,q.`name`,q.idcard,q.ssc,q.mobile,q.hospital_name as hospitalName " +
//                "FROM wlyy_sign_family q " +
//                "WHERE 1=1 " +
//                "AND q.`status`>0  ";
//        if (StringUtils.isNotBlank(patient)) {
//            sql += "AND  q.patient=:patientId ";
//            map.put("patientId", patient);
//        }
//
//        if (StringUtils.isNotBlank(areaCode)) {
//            sql += "AND q.hospital IN(SELECT dm.`code` from dm_hospital dm where dm.town=:areaCode  and dm.`level`=2) ";
//            map.put("areaCode", areaCode);
//        }
//        List<SignPatientVo> list = findSqlMapRvo(sql, map, SignPatientVo.class);
//        if (list.isEmpty()) {
//            return null;
//        } else {
//            return list;
//        }
//    }
    /**
     * 查根据medicalNo查询 wlyy_medical_info 主键
     */
@ -874,26 +676,6 @@ public class PatientRecordService {
        return result;
    }
//    public MedicalInfo findMedicalInfo(String medicalNo) throws Exception {
//        String sql = "SELECT q.* FROM wlyy_medical_info q WHERE q.medical_no=:medicalNo ";
//        HashMap<String, Object> map = new HashMap<>();
//        map.put("medicalNo", medicalNo);
//        MedicalInfo info = (MedicalInfo) findSqlObject(sql, map);
//        return info;
//    }
    /**
     * 查出temp表
     */
//    public List<MedicalVo> findMedicalTemp() throws Exception {
//        HashMap<String, Object> map = new HashMap<>();
//        String sql = "SELECT medical_no \"medicalNo\" FROM medical_temp ";
//        List<MedicalVo> list = findSqlMapRvo(sql, map, MedicalVo.class);
//        return list;
//    }
    /**
     * 查根据medicalNo查询wlyy_medical_info 主键
     */

+ 0 - 208
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/rehabilitation/service/RehabilitationManageService.java

@ -2308,214 +2308,6 @@ public class RehabilitationManageService {
        return medicalRecordsRehabilitationDao.findByPatient(patient);
    }
    /**
     * @param doctorType    1专科2家医
     * @param level         1市2区3社区
     * @param turnDownState 下转状态 0全部;1已下转;2已接受;3未下转
     * @param area
     * @param doctor
     * @return
     */
    public org.json.JSONObject selectBySpecialistDoctor(String level, String area, String doctor, String disease, Integer page, Integer pageSize, String doctorType, String patientInfo, String filterPlan, String turnDownState) {
        Integer turnDownStateTotal_0 = 0;//全部
        Integer turnDownStateTotal_1 = 0;//已下转
        Integer turnDownStateTotal_2 = 0;//已接受
        Integer turnDownStateTotal_3 = 0;//未下转
        org.json.JSONObject resultObj = new org.json.JSONObject();
        BaseDoctorDO doctorObj = doctorDao.findById(doctor).orElse(null);
        List<Map<String, Object>> result = new ArrayList<>();
        String sqlCount = "SELECT count(distinct pr.id) total,count(distinct pr.id,IF(pr.is_manage=1,pr.is_manage,null) ) 'manageTotal' FROM" +
                " wlyy_doctor doc,`wlyy_specialist_patient_relation` pr" +
                " LEFT JOIN wlyy_patient p ON p.`code` = pr.patient ";
        String sql = "SELECT DISTINCT pr.id,p.`name`, p.`code`, p.idcard,p.photo, YEAR (now()) - YEAR (substring(p.idcard, 7, 8)) as age," +
                "p.sex,pr.doctor AS specialist,pr.doctor_name AS specialistName,doc.hospital AS specialHospital,doc.hospital_name AS specialHospitalName,pr.disease_code,sf.doctor_name ," +
                "sf.doctor, sf.doctor_health, sf.doctor_health_name, sf.hospital, sf.hospital_name,pr.is_manage,pr.manage_user,pr.manage_time FROM" +
                " wlyy_doctor doc,`wlyy_specialist_patient_relation` pr" +
                " LEFT JOIN wlyy_patient p ON p.`code` = pr.patient ";
        //关联居民计划表
        if ("1".equals(filterPlan)) {
            sql = sql + " INNER JOIN `wlyy_patient_rehabilitation_plan` plan on plan.patient = pr.patient ";
            sqlCount = sqlCount + " INNER JOIN `wlyy_patient_rehabilitation_plan` plan on plan.patient = pr.patient ";
        }
        sql = sql + " LEFT JOIN wlyy_sign_family sf ON sf.patient=pr.patient AND sf.`status`=1 AND sf.type =2" +
                " WHERE  doc.`code` = pr.doctor AND pr.sign_status > 0 AND pr.`status` = 1 ";
        sqlCount = sqlCount + " LEFT JOIN wlyy_sign_family sf ON sf.patient=pr.patient AND sf.`status`=1 AND sf.type =2" +
                " WHERE  doc.`code` = pr.doctor AND pr.sign_status > 0 AND pr.`status` = 1 ";
        String sqlCondition = "";
        if (doctorType.equalsIgnoreCase("1")) {
            sqlCondition += " AND pr.doctor = '" + doctor + "'";
        } else {
            // todo 这个后面在改20231116
//            if (doctorObj.getHospital().equals("ac02a9b87a3611e69f7c005056850d66")) {
//                //测试医院
//                sqlCondition += " AND (sf.doctor = '" + doctor + "' or sf.doctor_health = '" + doctor + "')";
//            } else {
//                //排除测试医院的数据
//                sqlCondition += " AND (sf.doctor = '" + doctor + "' or sf.doctor_health = '" + doctor + "') AND doc.hospital <>'ac02a9b87a3611e69f7c005056850d66'";
//            }
        }
        if (StringUtils.isNoneBlank(patientInfo)) {
            sqlCondition += " AND (p.idcard like '%" + patientInfo + "%' OR p.`name`like '%" + patientInfo + "%') ";
        }
        if ("1".equalsIgnoreCase(level)) {
//            sqlCondition +=" and sf.hospital IN ( SELECT dh.`code` FROM `dm_hospital` dh where dh.city='"+area+"' and dh.del=1 )";
        } else if ("2".equalsIgnoreCase(level)) {
            sqlCondition += " and sf.hospital IN ( SELECT dh.`code` FROM `dm_hospital` dh where dh.town='" + area + "' and dh.del=1 )";
        } else if ("3".equalsIgnoreCase(level)) {
            sqlCondition += " and sf.hospital = '" + area + "' ";
        }
        if (StringUtils.isNoneBlank(disease)) {
            sqlCondition += " and pr.id IN (SELECT pds.specialist_relation_code FROM wlyy_patient_disease_server pds WHERE  pds.del=1 and pds.disease ='" + disease + "')";
        }
        sqlCount += sqlCondition;
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sqlCount);
        Map<String, Object> tmp = list.get(0);
        turnDownStateTotal_0 = Integer.valueOf(tmp.get("total").toString());
        turnDownStateTotal_2 += Integer.valueOf(tmp.get("manageTotal").toString());
        turnDownStateTotal_1 = turnDownStateTotal_0 - turnDownStateTotal_2;
        if ("1".equals(filterPlan)) {
            sqlCondition += " ORDER BY pr.create_time DESC,plan.create_time desc limit " + (page - 1) * pageSize + "," + pageSize + " ";
        } else {
            sqlCondition += " ORDER BY pr.create_time DESC limit " + (page - 1) * pageSize + "," + pageSize + " ";
        }
        sql += sqlCondition;
        //字典翻译
        Map<String, String> changeStatusMap = systemDictService.getDictMap("changeStatusName");
        sql = TransforSqlUtl.wlyySpecialistPatientRelationPatientName(sql, "pr.doctor_name");
        Map<String, Integer> countMap = new HashMap<>();
        List<Map<String, Object>> mapList = jdbcTemplate.queryForList(sql);
        for (Map<String, Object> map : mapList) {
            String patient = map.get("code").toString();
            BasePatientDO patientDo = patientDao.findById(patient).orElse(null);
            Integer age = IdCardUtil.getAgeByIdcardOrBirthday(patientDo.getIdcard(), patientDo.getBirthday());
            map.put("age", age);
            String specialistRelationCode = map.get("id").toString();
            String relationManageState = map.get("is_manage") == null ? "0" : map.get("is_manage").toString();//管理状态
            List<PatientDiseaseServer> diseaseServers = patientDiseaseServerDao.findBySpecialistRelationCodeAndDel(specialistRelationCode, "1");
            StringBuffer diseaseName = new StringBuffer();
            for (int i = 0; i < diseaseServers.size(); i++) {
                diseaseName.append(diseaseServers.get(i).getDiseaseName() + ",");
            }
            if (StringUtils.isNoneBlank(diseaseName)) {
                diseaseName.deleteCharAt(diseaseName.length() - 1);
            }
            map.put("disease_name", diseaseName);
            if (countMap.containsKey(patient)) {
                map.put("unCompleteCount", countMap.get(patient));
            } else {
                //计算待完成任务数
                String unCompleteCountSql = "SELECT COUNT(*) from ( SELECT COUNT(pd.id) AS total,pd.hospital_service_item_id,p.id  , COUNT( IF(pd.`status` = 1,1,null)) AS compeletTotal" +
                        " FROM wlyy_patient_rehabilitation_plan p,wlyy_rehabilitation_plan_detail pd WHERE p.status=1 and " +
                        " p.patient = '" + patient + "' and pd.plan_id = p.id  AND  pd.frequency_code <> '' and pd.doctor='" + doctor + "' and pd.execute_time<'" + DateUtil.getStringDateShort() + " 23:59:59' " +
                        "  GROUP BY pd.hospital_service_item_id,p.id HAVING total>compeletTotal) a";
                Integer unCompleteCount = jdbcTemplate.queryForObject(unCompleteCountSql, Integer.class);
                map.put("unCompleteCount", unCompleteCount);
                countMap.put(patient, unCompleteCount);
            }
            //新增特殊标识-获取最近一条记录的特殊标识
            String changeStatus = findLastPlanChangeStatus(patient);
            map.put("changeStatus", changeStatus);
            map.put("changeStatusName", changeStatusMap.get(changeStatus));
            if (StringUtils.isBlank(relationManageState) || !relationManageState.equals("1")) {//未进行管理
                map.put("turnDownState", 1);//已下转
                if ("1".equals(turnDownState) || "0".equals(turnDownState)) {
                    result.add(map);
                }
            } else {
                map.put("turnDownState", 2);//已管理
                if (turnDownState.equals("2") || turnDownState.equals("0")) {
                    result.add(map);
                }
            }
        }
        //家医端未下转(签约居民,但是还未下转的居民) 专科医生端未下转(与未下转列表同-去除未家签)
        if ("1".equalsIgnoreCase(doctorType)) {//专科
            sql = "select null as id,p.`name`,p.`code`,p.idcard,p.photo,YEAR (now()) - YEAR (substring(p.idcard, 7, 8)) AS age, p.sex,d.create_user AS specialist,d.create_user_name AS specialistName,\n" +
                    "doc.hospital AS specialHospital,doc.hospital_name AS specialHospitalName,s.doctor_name,s.doctor,s.doctor_health,s.doctor_health_name, s.hospital,s.hospital_name,null as is_manage,null as manage_user,null as manage_time \n" +
                    "from wlyy_patient_discharge d LEFT JOIN ( SELECT distinct i.patient FROM wlyy_patient_rehabilitation_plan i,wlyy_sign_family s,wlyy_patient p  " +
                    "WHERE i.create_user='" + doctor + "' AND i. STATUS != 0 AND i.patient = s.patient AND p. CODE = i.patient AND s. STATUS = 1 AND s.type =2 AND s.expenses_status = 1 )A on d.patient =A.patient " +
                    " ,wlyy_sign_family s,wlyy_patient p ,wlyy_doctor doc where doc.`code` = d.create_user AND d.create_user='" + doctor + "' ";
            sqlCount = "select count(distinct d.patient) " +
                    "from wlyy_patient_discharge d LEFT JOIN ( SELECT distinct i.patient FROM wlyy_patient_rehabilitation_plan i,wlyy_sign_family s,wlyy_patient p  " +
                    "WHERE i.create_user='" + doctor + "' AND i. STATUS != 0 AND i.patient = s.patient AND p. CODE = i.patient AND s. STATUS = 1 AND s.type =2 AND s.expenses_status = 1 )A on d.patient =A.patient " +
                    " ,wlyy_sign_family s,wlyy_patient p ,wlyy_doctor doc where doc.`code` = d.create_user AND d.create_user='" + doctor + "' ";
        } else {//家庭
            sql = "select null as id,p.`name`,p.`code`,p.idcard,p.photo,YEAR (now()) - YEAR (substring(p.idcard, 7, 8)) AS age, p.sex,d.create_user AS specialist,d.create_user_name AS specialistName,\n" +
                    "doc.hospital AS specialHospital,doc.hospital_name AS specialHospitalName,s.doctor_name,s.doctor,s.doctor_health,s.doctor_health_name, s.hospital,s.hospital_name,null as is_manage,null as manage_user,null as manage_time \n" +
                    "from wlyy_patient_discharge d LEFT JOIN ( SELECT distinct i.patient FROM wlyy_patient_rehabilitation_plan i,wlyy_sign_family s,wlyy_patient p " +
                    "WHERE s.doctor='" + doctor + "' AND i. STATUS != 0 AND i.patient = s.patient AND p. CODE = i.patient AND s. STATUS = 1 AND s.type =2 AND s.expenses_status = 1 )A on d.patient =A.patient " +
                    ",wlyy_sign_family s,wlyy_patient p ,wlyy_doctor doc where doc.`code` = d.create_user AND s.doctor='" + doctor + "' ";
            sqlCount = "select count(distinct d.patient) " +
                    "from wlyy_patient_discharge d LEFT JOIN ( SELECT distinct i.patient FROM wlyy_patient_rehabilitation_plan i,wlyy_sign_family s,wlyy_patient p " +
                    "WHERE s.doctor='" + doctor + "' AND i. STATUS != 0 AND i.patient = s.patient AND p. CODE = i.patient AND s. STATUS = 1 AND s.type =2 AND s.expenses_status = 1 )A on d.patient =A.patient " +
                    ",wlyy_sign_family s,wlyy_patient p ,wlyy_doctor doc where doc.`code` = d.create_user AND s.doctor='" + doctor + "' ";
        }
        sqlCondition = "";
        if (StringUtils.isNoneBlank(patientInfo)) {
            sqlCondition += " AND (p.idcard like '%" + patientInfo + "%' OR p.`name`like '%" + patientInfo + "%') ";
        }
        if ("1".equalsIgnoreCase(level)) {
//            sqlCondition +=" and s.hospital IN ( SELECT dh.`code` FROM `dm_hospital` dh where dh.city='"+area+"' and dh.del=1 )";
        } else if ("2".equalsIgnoreCase(level)) {
            sqlCondition += " and s.hospital IN ( SELECT dh.`code` FROM `dm_hospital` dh where dh.town='" + area + "' and dh.del=1 )";
        } else if ("3".equalsIgnoreCase(level)) {
            sqlCondition += " and s.hospital = '" + area + "' ";
        }
//        if (!doctorObj.getHospital().equals("ac02a9b87a3611e69f7c005056850d66")) {//测试医院数据排除
//            sqlCondition += " AND doc.hospital <>'ac02a9b87a3611e69f7c005056850d66'";
//        }
        if (StringUtils.isNoneBlank(disease)) {
            sqlCondition += " AND s.patient in (select patient from wlyy_patient_disease_server pds where pds.del=1 and pds.disease ='" + disease + "') ";
        }
        sql = sql + sqlCondition;
        sql = sql + "and ( ISNULL(d.type) or d.type=2)  \n" +
                "and d.sign_status=1 AND d.patient = s.patient AND p. CODE = d.patient AND s. STATUS = 1 AND s.expenses_status = 1\n" +
                "AND A.patient is null GROUP BY d.patient ORDER BY d.create_time DESC limit " + (page - 1) * pageSize + "," + pageSize + " ";
        sqlCount = sqlCount + sqlCondition;
        sqlCount = sqlCount + "and ( ISNULL(d.type) or d.type=2)  \n" +
                "and d.sign_status=1 AND d.patient = s.patient AND p. CODE = d.patient AND s. STATUS = 1 AND s.expenses_status = 1\n" +
                "AND A.patient is null ";
        turnDownStateTotal_3 = jdbcTemplate.queryForObject(sqlCount, Integer.class);
        turnDownStateTotal_0 += turnDownStateTotal_3;
        List<Map<String, Object>> mapList12 = jdbcTemplate.queryForList(sql);
        for (Map<String, Object> map : mapList12) {
            String patient = map.get("code").toString();
            BasePatientDO patientDo = patientDao.findById(patient).orElse(null);
            Integer age = IdCardUtil.getAgeByIdcardOrBirthday(patientDo.getIdcard(), patientDo.getBirthday());
            map.put("age", age);
            map.put("disease_name", "暂无");
            map.put("turnDownState", 3);//未下
            //新增特殊标识-获取最近一条记录的特殊标识
            String changeStatus = findLastPlanChangeStatus(patient);
            map.put("changeStatus", changeStatus);
            if ("3".equals(turnDownState) || "0".equals(turnDownState)) {
                result.add(map);
            }
        }
        //计算各数量
        org.json.JSONObject turnDownStateObj = new org.json.JSONObject();
        turnDownStateObj.put("stateAll", turnDownStateTotal_0);//全部
        turnDownStateObj.put("stateDown", turnDownStateTotal_1);//已下转
        turnDownStateObj.put("stateReceive", turnDownStateTotal_2);//已接受
        turnDownStateObj.put("stateNotDown", turnDownStateTotal_3);//未下转
        resultObj.put("showList", result);
        resultObj.put("turnDownState", turnDownStateObj);
        return resultObj;
    }
    //获取最近一条康复计划记录的特殊标识
    public String findLastPlanChangeStatus(String patient) {