瀏覽代碼

对接ca、短信、his

wangzhinan 1 年之前
父節點
當前提交
f9cc2cb3cd

+ 409 - 4
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/DsyyPrescriptionService.java

@ -4,19 +4,23 @@ package com.yihu.jw.hospital.prescription.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.patient.BasePatientDO;
import com.yihu.jw.entity.base.patient.PatientMedicareCardDO;
import com.yihu.jw.entity.base.wx.BasePatientWechatDo;
import com.yihu.jw.entity.base.wx.WxTemplateConfigDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.entity.hospital.httplog.WlyyHttpLogDO;
import com.yihu.jw.entity.hospital.prescription.BaseNatAppointmentDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionDO;
import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
import com.yihu.jw.entity.hospital.mapping.PatientMappingDO;
import com.yihu.jw.entity.hospital.prescription.*;
import com.yihu.jw.entity.order.BusinessOrderDO;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.hospital.httplog.dao.WlyyHttpLogDao;
import com.yihu.jw.hospital.prescription.dao.BaseNatAppointmentDao;
import com.yihu.jw.hospital.prescription.dao.PrescriptionDao;
import com.yihu.jw.hospital.mapping.dao.DoctorMappingDao;
import com.yihu.jw.hospital.mapping.dao.PatientMappingDao;
import com.yihu.jw.hospital.prescription.dao.*;
import com.yihu.jw.hospital.prescription.service.entrance.DsyyEntranceService;
import com.yihu.jw.mysql.query.BaseJpaService;
import com.yihu.jw.order.dao.BusinessOrderDao;
@ -25,6 +29,8 @@ import com.yihu.jw.patient.dao.BasePatientMedicareCardDao;
import com.yihu.jw.restmodel.hospital.prescription.*;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.jw.util.network.HttpResponse;
import com.yihu.jw.util.network.HttpUtils;
import com.yihu.jw.utils.WebserviceUtil;
import com.yihu.jw.wechat.dao.BasePatientWechatDao;
import com.yihu.jw.wechat.dao.WxTemplateConfigDao;
@ -52,6 +58,23 @@ public class DsyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
    private BasePatientDao patientDao;
    @Autowired
    private BasePatientMedicareCardDao patientMedicareCardDao;
    @Autowired
    private PatientMappingDao patientMappingDao;
    @Autowired
    private OutpatientDao outpatientDao;
    @Autowired
    private PrescriptionExpressageDao prescriptionExpressageDao;
    @Autowired
    private BaseDoctorDao baseDoctorDao;
    @Autowired
    private DoctorMappingDao doctorMappingDao;
    @Autowired
    private PatientRegisterDao patientRegisterDao;
    @Autowired
    private WlyyHttpLogDao wlyyHttpLogDao;
    //请求内网服务
    public static String entranceUrl = "http://192.168.101.2:10024/dsyy/";
    //=============查询视图========================
    /**
@ -78,6 +101,7 @@ public class DsyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
            return str;
        }
    }
    /**
     * 获取门诊下所有处方信息
     * @param registerSn 流水号
@ -310,4 +334,385 @@ public class DsyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
    public JSONArray getDrugUse(String pydm) throws Exception {
        return dsyyEntranceService.getDrugUse(pydm);
    }
    //========================调用内网服务开始=========================
    /**
     * 挂号--调用内网服务
     *
     * @return
     */
    public JSONObject register(String doctor,String dept,String sickId,String clinicclass,String courierflag) throws Exception {
        String url = entranceUrl +"registered";
        JSONObject object = new JSONObject();
        Map<String,Object> params = new HashedMap();
        params.put("doctor",doctor);
        params.put("dept",dept);
        params.put("sickId",sickId);
        params.put("clinicclass",clinicclass);
        params.put("courierflag",courierflag);
        HttpResponse response = HttpUtils.doPost(url,params);
        String content = response.getContent();
        logger.info("response:"+content);
        JSONObject rs = JSON.parseObject(content);
        Integer status = rs.getInteger("status");
        if (status==200){
            object = rs.getJSONObject("obj");
        }
        return object;
    }
    /**
     * 退号--调用内网服务
     *
     * @return
     */
    public JSONObject refundConsultation(String applyNo,String PayCardNo) throws Exception {
        String url = entranceUrl +"refundConsultation";
        JSONObject object = new JSONObject();
        Map<String,Object> params = new HashedMap();
        params.put("applyNo",applyNo);
        params.put("PayCardNo",PayCardNo);
        HttpResponse response = HttpUtils.doPost(url,params);
        String content = response.getContent();
        logger.info("response:"+content);
        JSONObject rs = JSON.parseObject(content);
        Integer status = rs.getInteger("status");
        if (status==200){
            object = rs.getJSONObject("obj");
        }
        return object;
    }
    /**
     * 互联网医院开处方信息更新到his ---调用内网服务
     *
     * @param IoFlag 门诊住院标志
     * @param PayCardNo 就诊卡号
     * @param NullahNumber 挂号流水号
     * @param ApplyDept 执行科室
     * @param ApplyDoctor 开单医生
     * @param ExecuteDept 执行科室(药房)
     * @param infoJson 药品列表
     * @return
     * @throws Exception
     */
    public JSONObject savePrescriptionToHospital(String IoFlag,String PayCardNo,String NullahNumber,String ApplyDept,String ApplyDoctor,String ExecuteDept,List<WlyyPrescriptionInfoDO> wlyyPrescriptionInfoDOS) throws Exception {
        String url = entranceUrl +"savePrescriptionToHospital";
        JSONObject object = new JSONObject();
        Map<String,Object> params = new HashedMap();
        params.put("IoFlag",IoFlag);
        params.put("PayCardNo",PayCardNo);
        params.put("NullahNumber",NullahNumber);
        params.put("ApplyDept",ApplyDept);
        params.put("ApplyDoctor",ApplyDoctor);
        params.put("ExecuteDept",ExecuteDept);
        JSONArray array = new JSONArray();
        for (WlyyPrescriptionInfoDO prescriptionInfoDO:wlyyPrescriptionInfoDOS){
            array.add(prescriptionInfoDO);
        }
        params.put("infoJson",array.toJSONString());
        HttpResponse response = HttpUtils.doPost(url,params);
        String content = response.getContent();
        logger.info("response:"+content);
        JSONObject rs = JSON.parseObject(content);
        Integer status = rs.getInteger("status");
        if (status==200){
            object = rs.getJSONObject("obj");
        }
        return object;
    }
    /**
     *
     * 作废处方 ---调用内网服务
     *
     * @param IoFlag 门诊住院标志
     * @param PayCardNo 就诊卡号
     * @param NullahNumber 挂号流水号
     * @param ApplyDept 执行科室
     * @param ApplyDoctor 开单医生
     * @param ExecuteDept 执行科室(药房)
     * @param PresNo 必填,医嘱号
     * @return
     * @throws Exception
     */
    public JSONObject delHisPrescriptionByHisNo(String IoFlag,String PayCardNo,String NullahNumber,String ApplyDept,String ApplyDoctor,String ExecuteDept,String PresNo) throws Exception {
        String url = entranceUrl +"delHisPrescriptionByHisNo";
        JSONObject object = new JSONObject();
        Map<String,Object> params = new HashedMap();
        params.put("IoFlag",IoFlag);
        params.put("PayCardNo",PayCardNo);
        params.put("NullahNumber",NullahNumber);
        params.put("ApplyDept",ApplyDept);
        params.put("ApplyDoctor",ApplyDoctor);
        params.put("ExecuteDept",ExecuteDept);
        params.put("PresNo",PresNo);
        HttpResponse response = HttpUtils.doPost(url,params);
        String content = response.getContent();
        logger.info("response:"+content);
        JSONObject rs = JSON.parseObject(content);
        Integer status = rs.getInteger("status");
        if (status==200){
            object = rs.getJSONObject("obj");
        }
        return object;
    }
    /**
     * 保存诊断
     * @param applyNo 挂号号
     * @param DiagnosisName 诊断名称
     * @param DiagnosisCode 诊断编码
     * @return
     * @throws Exception
     */
    public JSONObject saveDiagnosis(String applyNo,String DiagnosisName,String DiagnosisCode) throws Exception {
        String url = entranceUrl +"saveDiagnosis";
        JSONObject object = new JSONObject();
        Map<String,Object> params = new HashedMap();
        params.put("applyNo",applyNo);
        params.put("DiagnosisName",DiagnosisName);
        params.put("DiagnosisCode",DiagnosisCode);
        HttpResponse response = HttpUtils.doPost(url,params);
        String content = response.getContent();
        logger.info("response:"+content);
        JSONObject rs = JSON.parseObject(content);
        Integer status = rs.getInteger("status");
        if (status==200){
            object = rs.getJSONObject("obj");
        }
        return object;
    }
    /**
     * 组装检查检验项目参数到his ---调用内网服务
     *
     * @param IoFlag 门诊住院标志
     * @param PayCardNo 就诊卡号
     * @param NullahNumber 挂号流水号
     * @param ApplyDept 执行科室
     * @param ApplyDoctor 开单医生
     * @param inspectJson 检查项目
     * @return
     * @throws Exception
     */
    public JSONObject saveInspectToHospital(String IoFlag,String PayCardNo,String NullahNumber,String ApplyDept,String ApplyDoctor,String inspectJson) throws Exception {
        String url = entranceUrl +"saveInspectToHospital";
        JSONObject object = new JSONObject();
        Map<String,Object> params = new HashedMap();
        params.put("IoFlag",IoFlag);
        params.put("PayCardNo",PayCardNo);
        params.put("NullahNumber",NullahNumber);
        params.put("ApplyDept",ApplyDept);
        params.put("ApplyDoctor",ApplyDoctor);
        params.put("inspectJson",inspectJson);
        HttpResponse response = HttpUtils.doPost(url,params);
        String content = response.getContent();
        logger.info("response:"+content);
        JSONObject rs = JSON.parseObject(content);
        Integer status = rs.getInteger("status");
        if (status==200){
            object = rs.getJSONObject("obj");
        }
        return object;
    }
    //========================调用内网服务结束===================
    //============================业务服务调用================================
    /**
     * 挂号接口
     * @param outPatientId
     * @param doctor
     * @return
     */
    public JSONObject registerOutPatient(String outPatientId, String doctor){
        WlyyOutpatientDO outpatientDO = outpatientDao.findById(outPatientId).orElse(null);
        List<WlyyPrescriptionExpressageDO> expressageDOS =prescriptionExpressageDao.findByOutpatientId(outPatientId);
        DoctorMappingDO doctorMappingDO = doctorMappingDao.findByDoctor(doctor);
        BaseDoctorDO doctorDO = baseDoctorDao.findByIdAndDel(doctor);
        if (doctorMappingDO == null) {
            throw new RuntimeException("未找到医生映射信息");
        }
        PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(outpatientDO.getPatient());
        if (patientMappingDO==null){
            throw new RuntimeException("未找到居民映射信息");
        }
        //查找居民当天挂号记录
        String date = DateUtil.dateToStr(new Date(), "yyyy-MM-dd");
        List<WlyyPatientRegisterDO> patientRegisterDOs = patientRegisterDao.findByPatientAndDateAndDoctorAndDel(outpatientDO.getPatient(), date, doctor,1);
        if (patientRegisterDOs != null && patientRegisterDOs.size() > 0) {
            WlyyPatientRegisterDO registerDO = patientRegisterDOs.get(0);
            //判断是否已经挂号,如果已经挂号
            if (StringUtils.isNotBlank(registerDO.getRegisterNo())) {
                JSONObject res = new JSONObject();
                res.put("@RESULT", "0");
                logger.info("已经挂号 res: " + res.toString());
                //更新挂号流水号
                outpatientDO.setConNo(registerDO.getConNo());
                outpatientDO.setRegisterNo(registerDO.getRegisterNo());
                outpatientDO.setAdmDate(registerDO.getCreateTime());
                outpatientDO.setAdmNo(registerDO.getRegisterNo());
                outpatientDao.save(outpatientDO);
                return res;
            }
        }
        String doctorFlag =  doctorMappingDO.getDoctorName()+"/"+doctorMappingDO.getMappingCode();
        String courierflag = "N";
        if (expressageDOS!=null&&expressageDOS.size()!=0){
            WlyyPrescriptionExpressageDO expressageDO = expressageDOS.get(0);
            if (expressageDO.getOneselfPickupFlg()!=null&&expressageDO.getOneselfPickupFlg()==1){
                courierflag="N";
            }else if (expressageDO.getOneselfPickupFlg()!=null&&expressageDO.getOneselfPickupFlg()==0){
                courierflag="Y";
            }
        }
        String chargeType = "";
        if ("1".equalsIgnoreCase(outpatientDO.getOutpatientType())&&"1".equalsIgnoreCase(outpatientDO.getType())){
            chargeType = doctorDO.getTwfzChargeType();
        }else if ("1".equalsIgnoreCase(outpatientDO.getOutpatientType())&&"2".equalsIgnoreCase(outpatientDO.getType())){
            chargeType = doctorDO.getSpfzChargeType();
        }else if ("3".equalsIgnoreCase(outpatientDO.getOutpatientType())&&"1".equalsIgnoreCase(outpatientDO.getType())){
            chargeType = doctorDO.getTwzxChargeType();
        }else if ("3".equalsIgnoreCase(outpatientDO.getOutpatientType())&&"2".equalsIgnoreCase(outpatientDO.getType())){
            chargeType = doctorDO.getSpzxChargeType();
        }else if ("3".equalsIgnoreCase(outpatientDO.getOutpatientType())&&"3".equalsIgnoreCase(outpatientDO.getType())){
            chargeType = doctorDO.getJyzxChargeType();
        }else if ("2".equalsIgnoreCase(outpatientDO.getOutpatientType())){
            chargeType = doctorDO.getXtfzChargeType();
        }else {
            chargeType = doctorDO.getChargeType();
        }
        JSONObject res = null;
        try {
            res = register(doctorFlag,outpatientDO.getDept(),patientMappingDO.getMappingCode(),chargeType,courierflag);
        } catch (Exception e) {
            e.printStackTrace();
        }
        JSONObject result = new JSONObject();
        logger.info("挂号结果 res: " + res.toString());
        String rsCode = "";
        String serialNo = "";
        if (res!=null){
            JSONObject object = res.getJSONObject("returnContents");
            serialNo = object.getString("registerNo");
            if (object!=null){
                result.put("@RESULT", "0");
                result.put("@MSG","挂号成功!");
                rsCode = object.getString("registerNo");
            }
        }else {
            result.put("@RESULT", "-1");
            result.put("@MSG","挂号失败");
        }
        if (StringUtils.isNoneBlank(rsCode)) {
            //存储挂号号
            outpatientDO.setRegisterNo(serialNo);
            outpatientDO.setAdmDate(new Date());
            outpatientDO.setAdmNo(serialNo);
            logger.info("挂号流水 registerNo: ");
            outpatientDao.save(outpatientDO);
            //存储就诊记录
            WlyyPatientRegisterDO registerDO = new WlyyPatientRegisterDO();
            // 存储挂号医生与挂号科室
            registerDO.setDoctor(outpatientDO.getDoctor());
            registerDO.setDoctorName(outpatientDO.getDoctorName());
            registerDO.setDept(outpatientDO.getDept());
            registerDO.setDeptName(outpatientDO.getDeptName());
            registerDO.setDel(1);
            registerDO.setPatient(outpatientDO.getPatient());
            registerDO.setPatientName(outpatientDO.getPatientName());
            //挂号流水号与挂号次数
            registerDO.setRegisterNo(serialNo);
            registerDO.setCreateTime(new Date());
            registerDO.setDate(DateUtil.dateToStr(new Date(), "yyyy-MM-dd"));
            patientRegisterDao.save(registerDO);
        } else if ("-2".equals(rsCode)) {
            outpatientDO.setRegisterNo(serialNo);
            outpatientDO.setAdmDate(new Date());
            outpatientDO.setAdmNo(serialNo);
            logger.info("挂号流水 registerNo: " + serialNo );
            outpatientDao.save(outpatientDO);
            //存储就诊记录
            WlyyPatientRegisterDO registerDO = new WlyyPatientRegisterDO();
            registerDO.setDoctor(outpatientDO.getDoctor());
            registerDO.setDoctorName(outpatientDO.getDoctorName());
            registerDO.setDept(outpatientDO.getDept());
            registerDO.setDeptName(outpatientDO.getDeptName());
            registerDO.setDel(1);
            registerDO.setPatient(outpatientDO.getPatient());
            registerDO.setPatientName(outpatientDO.getPatientName());
            registerDO.setRegisterNo(serialNo);
            registerDO.setCreateTime(new Date());
            registerDO.setDate(DateUtil.dateToStr(new Date(), "yyyy-MM-dd"));
            patientRegisterDao.save(registerDO);
        }
        //保存日志
        WlyyHttpLogDO log = new WlyyHttpLogDO();
        log.setCode("registerOutPatient");
        log.setName("挂号");
        log.setPatient(outpatientDO.getPatient());
        log.setDoctor(doctor);
        log.setResponse(res.toString());
        log.setRequest("outPatientId=" + outPatientId + "&doctor=" + doctor);
        log.setStatus("1");
        log.setCreateTime(new Date());
        wlyyHttpLogDao.save(log);
        return result;
    }
    /**
     * 退号
     * @param outpatientId
     * @return
     * @throws Exception
     */
    public JSONObject refundRegisterNo(String outpatientId) throws Exception {
        JSONObject object = new JSONObject();
        WlyyOutpatientDO outpatientDO = outpatientDao.findById(outpatientId).orElse(null);
        if(outpatientDO!=null){
            DoctorMappingDO doctorMappingDO = doctorMappingDao.findByDoctor(outpatientDO.getDoctor());
            if (StringUtils.isNoneBlank(outpatientDO.getRegisterNo())){
                object = refundConsultation(outpatientDO.getRegisterNo(), outpatientDO.getCardNo());
                logger.info("退号结果 res: " + object.toString());
                if (object!=null&&object.getString("code").equalsIgnoreCase("0")){
                    WlyyPatientRegisterDO wlyyPatientRegisterDO = patientRegisterDao.findByRegisterNo(outpatientDO.getRegisterNo());
                    wlyyPatientRegisterDO.setDel(0);
                    patientRegisterDao.save(wlyyPatientRegisterDO);
                    outpatientDO.setHisStatus(-1);
                    outpatientDao.save(outpatientDO);
                }
                //保存日志
                WlyyHttpLogDO log = new WlyyHttpLogDO();
                log.setCode("refundregisterOutPatient");
                log.setName("退号");
                log.setPatient(outpatientDO.getPatient());
                log.setDoctor(outpatientDO.getDoctor());
                log.setResponse(object.toString());
                log.setRequest("outPatientId=" + outpatientId + "&doctor=" + outpatientDO.getDoctor());
                log.setStatus(object.getString("code"));
                log.setCreateTime(new Date());
                wlyyHttpLogDao.save(log);
            }
        }
        return  object;
    }
}

+ 100 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java

@ -331,6 +331,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    @Autowired
    private HcyyEntranceService hcyyEntranceService;
    @Autowired
    private DsyyPrescriptionService dsyyPrescriptionService;
    @Autowired
    private BasePatientMedicareCardDao patientMedicareCardDao;
    @Autowired
    private ZhongShanSMSService zhongShanSMSService;
@ -10342,6 +10344,104 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                        e.printStackTrace();
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }else if (wxId.equalsIgnoreCase("xm_dsyy_wx")){
                try {
                    if (prescriptionDiagnosisDOS!=null&&prescriptionDiagnosisDOS.size()!=0){
                        String diagnosisName = prescriptionDiagnosisDOS.get(0).getName();
                        String diagnosisCode = prescriptionDiagnosisDOS.get(0).getCode();
                        //同步诊断
                        com.alibaba.fastjson.JSONObject jsonObject2 = dsyyPrescriptionService.saveDiagnosis(outpatientDO.getRegisterNo(),diagnosisName,diagnosisCode);
                        logger.info("上传诊断返回参数"+jsonObject2);
                        //{"msg":"交易成功","code":"0","data":{"PresDetail":{"PresNo":"16151365"}},"success":"True"}
                        if (jsonObject2!=null){
                            if (jsonObject2.getString("code").equalsIgnoreCase("0")){
                                com.alibaba.fastjson.JSONObject jsonObject = jsonObject2.getJSONObject("data");
                                logger.info("上传诊断成功"+jsonObject2);
                            }
                        }
                    }
                    //同步处方
                    String applyDoctor = doctorMappingDO.getDoctorName()+"/"+doctorMappingDO.getMappingCode();
                    com.alibaba.fastjson.JSONObject object = dsyyPrescriptionService.savePrescriptionToHospital("0",outpatientDO.getCardNo(),outpatientDO.getRegisterNo(),outpatientDO.getDept(),applyDoctor,"50400",infoDOS);
                    logger.info("成功上传处方"+object);
                    //{"msg":"交易成功","code":"0","data":{"PresDetail":{"PresNo":"16151365"}},"success":"True"}
                    if (object!=null){
                        if (object.getString("code").equalsIgnoreCase("0")){
                            com.alibaba.fastjson.JSONObject jsonObject = object.getJSONObject("data");
                            com.alibaba.fastjson.JSONObject jsonObject1 = jsonObject.getJSONObject("PresDetail");
                            String realOrder = jsonObject1.getString("PresNo");
                            wlyyPrescriptionDO.setAdmNo(outpatientDO.getAdmNo());
                            wlyyPrescriptionDO.setSerialNo(outpatientDO.getAdmNo());
                            wlyyPrescriptionDO.setRealOrder(realOrder);
                        }
                    }
                /*    logger.info("进入处方签名");
                    //电子病例签名
                    String baseSign=hcyyEntranceService.initiateDataSign(wlyyPrescriptionDO.getId(),2,ip);
                    //同步电子病历
                    WlyyPrescriptionEmrDO prescriptionEmrDO = prescriptionEmrDao.findEmrByPrescriptionId(prescriptionId);
                    try {
                        if (prescriptionEmrDO != null) {
                            logger.info("电子病历同步");
                            hcyyPrescriptionService.saveEmrToEntrance(prescriptionId,baseSign);
                            logger.info("电子病历同步");
                            logger.info("电子病历签名");
                            hcyyEntranceService.initiateDataSign(wlyyPrescriptionDO.getId(),1,ip);
                        }
                    }catch (Exception e){
                        e.printStackTrace();
                    }*/
                    try {
                        if (object!=null){
                            if (object.getString("code").equalsIgnoreCase("0")){
                                //  * @param applyDepaName @param applyDoctorName
                                WlyyPrescriptionDO prescriptionDO = prescriptionDao.findById(prescriptionId).orElse(null);
                                String patientCode = outpatientDO.getConsumer();
                                String realerOrder = prescriptionDO.getRealOrder();
                                String recipeTime = DateUtil.dateToStr(prescriptionDO.getCreateTime(), "yyyyMMddHHmmss");
                                List<BaseDoctorHospitalDO> doctorHospitalDOS = baseDoctorHospitalDao.findByDoctorCode(prescriptionDO.getDoctor());
                                String applyDepaName = null;
                                if (doctorHospitalDOS != null && doctorHospitalDOS.size() != 0) {
                                    applyDepaName = doctorHospitalDOS.get(0).getDeptName();
                                }
                                String voucherNo = outpatientDO.getRegisterNo();
                                String applyDoctorName = prescriptionDO.getDoctorName();
                                BasePatientDO patientDO = basePatientDao.findById(patientCode).orElse(null);
                                String userName = null;
                                String idcard = null;
                                if (patientDO != null) {
                                    userName = patientDO.getName();
                                    idcard = patientDO.getIdcard();
                                }
                                PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(patientCode);
                                String userNo = null;
                                if (patientMappingDO != null) {
                                    userNo = patientMappingDO.getMappingCode();
                                }
                                String cardNo = null;
                                if (StringUtils.isNoneBlank(outpatientDO.getCardNo())) {
                                    cardNo = outpatientDO.getCardNo();
                                }
                                logger.info("cardNo:" + cardNo);
                               /* JSONObject jsonObject =entranceService.BS15054(patientMappingDO.getMappingCode(),prescriptionDO.getRealOrder(),demoFlag);
                                net.sf.json.JSONObject res = jsonObject.getJSONObject("resquest");
                                logger.info("获取待结算数据 res: " + res.toString());
                                String rsCode = res.getString("@RESULT");
                                String free= 0+"";
                                if ("0".equals(rsCode)) {
                                    free = res.getString("@total_charge");
                                }*/
                                /*ylzPayService.msgPush("01", cardNo, "01", patientDO.getMobile(), "00", userNo, userName, idcard, voucherNo, applyDepaName, applyDoctorName, recipeTime, "", "","WX_PUB");
                                 */}
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }

+ 55 - 49
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/DsyyEntranceService.java

@ -439,7 +439,7 @@ public class DsyyEntranceService {
    }
    public String isEmty(String str){
        if (str.equalsIgnoreCase("[]")){
        if (StringUtils.isNoneBlank(str)&&str.equalsIgnoreCase("[]")){
            return null;
        }else {
            return str;
@ -457,34 +457,37 @@ public class DsyyEntranceService {
        patient = updatePatientMapping(patient,cardNo);
        String sql = "SELECT\n" +
                "\tadmNo AS \"ADMNO\",\n" +
                "\toriginAdmNo AS \"ORIGINADMNO\",\n" +
                "\tregisterNo AS \"REGISTERNO\",\n" +
                "\tCONNO AS \"CONNO\",\n" +
                "\toriginRegisterNo AS \"ORIGINREGISTERNO\",\n" +
                "\toriginConNo as \"ORIGINCONNO\",\n" +
                "\tdept as \"DEPT\",\n" +
                "\tDEPTNAME as \"DEPTNAME\",\n" +
                "  PATIENT as \"PATIENT\",\n" +
                "\tPATIENTNAME as \"PATIENTNAME\",\n" +
                "\tDOCTOR as \"DOCTOR\",\n" +
                "\tDOCTORNAME as \"DOCTORNAME\",\n" +
                "\tIDCARD as \"IDCARD\",\n" +
                "\tMJZ as \"MJZ\",\n" +
                "\tICDCODE as \"ICDCODE\",\n" +
                "\tICDNAME as \"ICDNAME\",\n" +
                "\tADMDATE as \"ADMDATE\",\n" +
                "\tCONDATE as \"CONDATE\",\n" +
                "\tDESCRIPTION as \"DESCRIPTION\",\n" +
                "\tDISEASEIMG as \"DISEASEIMG\",\n" +
                "\tCREATETIME as \"CREATETIME\",\n" +
                "\tSTATUS as \"STATUS\",\n" +
                "\tVISITNUM as \"VISITNUM\"\n" +
                "\toriginConNo AS \"ORIGINCONNO\",\n" +
                "\tdept AS \"DEPT\",\n" +
                "\tDEPTNAME AS \"DEPTNAME\",\n" +
                "\tPATIENT AS \"PATIENT\",\n" +
                "\tPATIENTNAME AS \"PATIENTNAME\",\n" +
                "\tDOCTOR AS \"DOCTOR\",\n" +
                "\tDOCTORNAME AS \"DOCTORNAME\",\n" +
                "\tIDCARD AS \"IDCARD\",\n" +
                "\tMJZ AS \"MJZ\",\n" +
                "\tADMDATE AS \"ADMDATE\",\n" +
                "\tCONDATE AS \"CONDATE\",\n" +
                "\tDESCRIPTION AS \"DESCRIPTION\",\n" +
                "\tDISEASEIMG AS \"DISEASEIMG\",\n" +
                "\tCREATETIME AS \"CREATETIME\",\n" +
                "\tSTATUS AS \"STATUS\",\n" +
                "\tICD10 as \"ICD10\",\n" +
                "\tICD10NAME as \"ICD10NAME\",\n" +
                "\tHISGISTERTYPECODE as \"HISGISTERTYPECODE\",\n" +
                "\tHISRATETYPECODE as \"HISRATETYPECODE\",\n" +
                "\tHISREGISTERFEE as \"HISREGISTERFEE\"\n" +
                "FROM\n" +
                "\tv_internet_dispensary_cure where 1=1 ";
                "\tv_internet_dispensary_cure\n" +
                " where 1=1 ";
        if (StringUtils.isNoneBlank(startTime)){
            sql +=" and CREATETIME >= to_date('"+startTime+"','yyyy-MM-dd HH24:mi:ss') ";
            sql +=" and CREATETIME >='"+startTime+"' ";
        }
        if (StringUtils.isNoneBlank(endTime)){
            sql +=" and CREATETIME <= to_date('"+endTime+"','yyyy-MM-dd HH24:mi:ss') ";
            sql +=" and CREATETIME <= '"+endTime+"' ";
        }
        if (StringUtils.isNoneBlank(patient)){
            sql +=" and PATIENT ='"+patient+"' ";
@ -517,15 +520,15 @@ public class DsyyEntranceService {
                outpatientVO.setDoctorName(isEmty(object.getString("DOCTORNAME")));
                outpatientVO.setIdcard(isEmty(object.getString("IDCARD")));
                outpatientVO.setMjz(isEmty(object.getString("MJZ")));
                outpatientVO.setIcd10(isEmty(object.getString("ICDCODE")));
                outpatientVO.setIcd10Name(isEmty(object.getString("ICDNAME")));
                outpatientVO.setIcd10(isEmty(object.getString("ICD10")));
                outpatientVO.setIcd10Name(isEmty(object.getString("ICD10NAME")));
                outpatientVO.setAdmDate(DateUtil.strToDate(object.getString("ADMDATE")));
                outpatientVO.setConDate(DateUtil.strToDate(object.getString("CONDATE")));
                outpatientVO.setDescription(isEmty(object.getString("DESCRIPTION")));
                outpatientVO.setDiseaseImg(isEmty(object.getString("DISEASEIMG")));
                outpatientVO.setCreateTime(DateUtil.strToDate(object.getString("CREATETIME")));
                outpatientVO.setStatus(isEmty(object.getString("STATUS")));
                outpatientVO.setConNo(isEmty(object.getString("VISITNUM")));
                outpatientVO.setConNo(isEmty(object.getString("CONNO")));
                outpatientVO.setPatient(patient);
                wlyyOutpatientVOList.add(outpatientVO);
            }
@ -551,29 +554,32 @@ public class DsyyEntranceService {
        }
        String sql = "SELECT\n" +
                "\tadmNo AS \"ADMNO\",\n" +
                "\toriginAdmNo AS \"ORIGINADMNO\",\n" +
                "\tregisterNo AS \"REGISTERNO\",\n" +
                "\tCONNO AS \"CONNO\",\n" +
                "\toriginRegisterNo AS \"ORIGINREGISTERNO\",\n" +
                "\toriginConNo as \"ORIGINCONNO\",\n" +
                "\tdept as \"DEPT\",\n" +
                "\tDEPTNAME as \"DEPTNAME\",\n" +
                "  PATIENT as \"PATIENT\",\n" +
                "\tPATIENTNAME as \"PATIENTNAME\",\n" +
                "\tDOCTOR as \"DOCTOR\",\n" +
                "\tDOCTORNAME as \"DOCTORNAME\",\n" +
                "\tIDCARD as \"IDCARD\",\n" +
                "\tMJZ as \"MJZ\",\n" +
                "\tICDCODE as \"ICDCODE\",\n" +
                "\tICDNAME as \"ICDNAME\",\n" +
                "\tADMDATE as \"ADMDATE\",\n" +
                "\tCONDATE as \"CONDATE\",\n" +
                "\tDESCRIPTION as \"DESCRIPTION\",\n" +
                "\tDISEASEIMG as \"DISEASEIMG\",\n" +
                "\tCREATETIME as \"CREATETIME\",\n" +
                "\tSTATUS as \"STATUS\",\n" +
                "\tVISITNUM as \"VISITNUM\"\n" +
                "\toriginConNo AS \"ORIGINCONNO\",\n" +
                "\tdept AS \"DEPT\",\n" +
                "\tDEPTNAME AS \"DEPTNAME\",\n" +
                "\tPATIENT AS \"PATIENT\",\n" +
                "\tPATIENTNAME AS \"PATIENTNAME\",\n" +
                "\tDOCTOR AS \"DOCTOR\",\n" +
                "\tDOCTORNAME AS \"DOCTORNAME\",\n" +
                "\tIDCARD AS \"IDCARD\",\n" +
                "\tMJZ AS \"MJZ\",\n" +
                "\tADMDATE AS \"ADMDATE\",\n" +
                "\tCONDATE AS \"CONDATE\",\n" +
                "\tDESCRIPTION AS \"DESCRIPTION\",\n" +
                "\tDISEASEIMG AS \"DISEASEIMG\",\n" +
                "\tCREATETIME AS \"CREATETIME\",\n" +
                "\tSTATUS AS \"STATUS\",\n" +
                "\tICD10 as \"ICD10\",\n" +
                "\tICD10NAME as \"ICD10NAME\",\n" +
                "\tHISGISTERTYPECODE as \"HISGISTERTYPECODE\",\n" +
                "\tHISRATETYPECODE as \"HISRATETYPECODE\",\n" +
                "\tHISREGISTERFEE as \"HISREGISTERFEE\"\n" +
                "FROM\n" +
                "\tv_internet_dispensary_cure where 1=1 ";
                "\tv_internet_dispensary_cure\n" +
                " where 1=1 ";
        if (StringUtils.isNoneBlank(patient)){
            sql +=" and PATIENT ='"+patient+"' ";
        }
@ -603,15 +609,15 @@ public class DsyyEntranceService {
                outpatientVO.setDoctorName(isEmty(object.getString("DOCTORNAME")));
                outpatientVO.setIdcard(isEmty(object.getString("IDCARD")));
                outpatientVO.setMjz(isEmty(object.getString("MJZ")));
                outpatientVO.setIcd10(isEmty(object.getString("ICDCODE")));
                outpatientVO.setIcd10Name(isEmty(object.getString("ICDNAME")));
                outpatientVO.setIcd10(isEmty(object.getString("ICD10")));
                outpatientVO.setIcd10Name(isEmty(object.getString("ICD10NAME")));
                outpatientVO.setAdmDate(DateUtil.strToDate(object.getString("ADMDATE")));
                outpatientVO.setConDate(DateUtil.strToDate(object.getString("CONDATE")));
                outpatientVO.setDescription(isEmty(object.getString("DESCRIPTION")));
                outpatientVO.setDiseaseImg(isEmty(object.getString("DISEASEIMG")));
                outpatientVO.setCreateTime(DateUtil.strToDate(object.getString("CREATETIME")));
                outpatientVO.setStatus(isEmty(object.getString("STATUS")));
                outpatientVO.setConNo(isEmty(object.getString("VISITNUM")));
                outpatientVO.setConNo(isEmty(object.getString("CONNO")));
                outpatientVO.setHospitalName("厦门市第三医院");
                outpatientVO.setHospital("350211A1004");
                outpatientVO.setSex(patientDO.getSex() + "");

+ 1 - 1
server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyLoginEndpoint.java

@ -1768,7 +1768,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
                return ObjEnvelop.getSuccess("error",rs);
            }
            username = jsonObject.getString("userIdcardNum");
            openId = jsonObject.getString("uniqueid");
            openId = jsonObject.getString("openId");
            jsonObject.put("qrCodeStatus","LoginQrCodeBeenScan");
            rs.put("code",1000);
        }else if (wechatId.equalsIgnoreCase("xm_ykyy_wx")){

+ 26 - 28
svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/controller/DsyyController.java

@ -6,15 +6,13 @@ import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionInfoDO;
import com.yihu.jw.hospital.prescription.service.entrance.DsyyEntranceService;
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 io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
@ -51,33 +49,33 @@ public class DsyyController extends EnvelopRestEndpoint {
        return success(dsyyEntranceService.jdbcSQLQuery(sql));
    }
    @GetMapping(value = "/registered")
    @PostMapping(value = "/registered")
    @ApiOperation(value = "挂号(调his后台包)")
    public Envelop registered(@ApiParam(name = "doctor", value = "医生ID(必填)", required = false)
    public ObjEnvelop registered(@ApiParam(name = "doctor", value = "医生ID(必填)", required = false)
                                    @RequestParam(value = "doctor",required = false)String doctor,
                                    @ApiParam(name = "dept", value = "科室编码(必填)", required = false)
                                 @ApiParam(name = "dept", value = "科室编码(必填)", required = false)
                                    @RequestParam(value = "dept",required = false)String dept,
                                    @ApiParam(name = "sickId", value = "病人id", required = false)
                                 @ApiParam(name = "sickId", value = "病人id", required = false)
                                        @RequestParam(value = "sickId",required = false)String sickId,
                                    @ApiParam(name = "clinicclass", value = "挂号类别(必填)", required = false)
                                 @ApiParam(name = "clinicclass", value = "挂号类别(必填)", required = false)
                                        @RequestParam(value = "clinicclass",required = false)String clinicclass,
                                    @ApiParam(name = "courierflag", value = "courierflag", required = false)
                                 @ApiParam(name = "courierflag", value = "courierflag", required = false)
                                        @RequestParam(value = "courierflag",required = false)String courierflag) throws Exception {
        return success(dsyyEntranceService.registered( doctor,dept,sickId,clinicclass,courierflag));
        return success("请求成功",dsyyEntranceService.registered( doctor,dept,sickId,clinicclass,courierflag));
    }
    @GetMapping(value = "/refundConsultation")
    @PostMapping(value = "/refundConsultation")
    @ApiOperation(value = "发送退号信息到his")
    public Envelop refundConsultation(@ApiParam(name = "applyNo", value = "挂号号", required = false)
    public ObjEnvelop refundConsultation(@ApiParam(name = "applyNo", value = "挂号号", required = false)
                              @RequestParam(value = "applyNo",required = false)String applyNo,
                              @ApiParam(name = "PayCardNo", value = "就诊卡号", required = false)
                              @RequestParam(value = "PayCardNo",required = false)String PayCardNo) throws Exception {
        return success(dsyyEntranceService.refundConsultation(applyNo,PayCardNo));
        return success("请求成功",dsyyEntranceService.refundConsultation(applyNo,PayCardNo));
    }
    @GetMapping(value = "/savePrescriptionToHospital")
    @PostMapping(value = "/savePrescriptionToHospital")
    @ApiOperation(value = "互联网医院开处方信息更新到his")
    public Envelop savePrescriptionToHospital(@ApiParam(name = "IoFlag", value = "门诊住院标志", required = false)
    public ObjEnvelop savePrescriptionToHospital(@ApiParam(name = "IoFlag", value = "门诊住院标志", required = false)
                                @RequestParam(value = "IoFlag",required = false)String IoFlag,
                                @ApiParam(name = "PayCardNo", value = "就诊卡号", required = false)
                                @RequestParam(value = "PayCardNo",required = false)String PayCardNo,
@ -97,14 +95,14 @@ public class DsyyController extends EnvelopRestEndpoint {
            WlyyPrescriptionInfoDO infoDO = objectMapper.readValue(array.getJSONObject(i).toJSONString(),WlyyPrescriptionInfoDO.class);
            prescriptionInfoDOList.add(infoDO);
        }
        return success(dsyyEntranceService.savePrescriptionToHospital(IoFlag,PayCardNo,NullahNumber,
        return success("请求成功",dsyyEntranceService.savePrescriptionToHospital(IoFlag,PayCardNo,NullahNumber,
                ApplyDept,ApplyDoctor,ExecuteDept,prescriptionInfoDOList));
    }
    @GetMapping(value = "/delHisPrescriptionByHisNo")
    @PostMapping(value = "/delHisPrescriptionByHisNo")
    @ApiOperation(value = "作废处方")
    public Envelop delHisPrescriptionByHisNo(@ApiParam(name = "IoFlag", value = "门诊住院标志", required = false)
    public ObjEnvelop delHisPrescriptionByHisNo(@ApiParam(name = "IoFlag", value = "门诊住院标志", required = false)
                                @RequestParam(value = "IoFlag",required = false)String IoFlag,
                                @ApiParam(name = "PayCardNo", value = "就诊卡号", required = false)
                                @RequestParam(value = "PayCardNo",required = false)String PayCardNo,
@ -118,25 +116,25 @@ public class DsyyController extends EnvelopRestEndpoint {
                                @RequestParam(value = "ExecuteDept",required = false)String ExecuteDept,
                                @ApiParam(name = "PresNo", value = "必填,医嘱号", required = false)
                                @RequestParam(value = "PresNo",required = false)String PresNo) throws Exception {
        return success(dsyyEntranceService.delHisPrescriptionByHisNo(IoFlag,PayCardNo,NullahNumber,
        return success("请求成功",dsyyEntranceService.delHisPrescriptionByHisNo(IoFlag,PayCardNo,NullahNumber,
                ApplyDept,ApplyDoctor,ExecuteDept,PresNo));
    }
    @GetMapping(value = "/saveDiagnosis")
    @PostMapping(value = "/saveDiagnosis")
    @ApiOperation(value = "保存诊断到his")
    public Envelop saveDiagnosis(@ApiParam(name = "applyNo", value = "挂号号", required = false)
    public ObjEnvelop saveDiagnosis(@ApiParam(name = "applyNo", value = "挂号号", required = false)
                                             @RequestParam(value = "applyNo",required = false)String applyNo,
                                             @ApiParam(name = "DiagnosisName", value = "诊断名称", required = false)
                                            @ApiParam(name = "DiagnosisName", value = "诊断名称", required = false)
                                             @RequestParam(value = "DiagnosisName",required = false)String DiagnosisName,
                                             @ApiParam(name = "DiagnosisCode", value = "诊断编码", required = false)
                                            @ApiParam(name = "DiagnosisCode", value = "诊断编码", required = false)
                                             @RequestParam(value = "DiagnosisCode",required = false)String DiagnosisCode) throws Exception {
        return success(dsyyEntranceService.saveDiagnosis(applyNo,DiagnosisName,DiagnosisCode));
        return success("请求成功",dsyyEntranceService.saveDiagnosis(applyNo,DiagnosisName,DiagnosisCode));
    }
    @GetMapping(value = "/saveInspectToHospital")
    @PostMapping(value = "/saveInspectToHospital")
    @ApiOperation(value = "组装检查检验项目参数到his")
    public Envelop saveInspectToHospital(@ApiParam(name = "IoFlag", value = "门诊住院标志", required = false)
    public ObjEnvelop saveInspectToHospital(@ApiParam(name = "IoFlag", value = "门诊住院标志", required = false)
                                              @RequestParam(value = "IoFlag",required = false)String IoFlag,
                                              @ApiParam(name = "PayCardNo", value = "就诊卡号", required = false)
                                              @RequestParam(value = "PayCardNo",required = false)String PayCardNo,
@ -154,7 +152,7 @@ public class DsyyController extends EnvelopRestEndpoint {
            WlyyInspectionDO inspectionDO = objectMapper.readValue(array.getJSONObject(i).toJSONString(),WlyyInspectionDO.class);
            inspectionDOList.add(inspectionDO);
        }
        return success(dsyyEntranceService.saveInspectToHospital(IoFlag,PayCardNo,NullahNumber,
        return success("请求成功",dsyyEntranceService.saveInspectToHospital(IoFlag,PayCardNo,NullahNumber,
                ApplyDept,ApplyDoctor,inspectionDOList));
    }

+ 39 - 1
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/DoctorConsultEndpoint.java

@ -17,6 +17,7 @@ import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionEmrDO;
import com.yihu.jw.hospital.mapping.dao.PatientMappingDao;
import com.yihu.jw.hospital.prescription.dao.OutpatientDao;
import com.yihu.jw.hospital.prescription.dao.PrescriptionDao;
import com.yihu.jw.hospital.prescription.service.DsyyPrescriptionService;
import com.yihu.jw.hospital.prescription.service.HcyyPrescriptionService;
import com.yihu.jw.hospital.prescription.service.PrescriptionService;
import com.yihu.jw.hospital.prescription.service.XzyyPrescriptionService;
@ -113,6 +114,8 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
	private EntranceService entranceService;
	@Autowired
	private HcyyPrescriptionService hcyyPrescriptionService;
	@Autowired
	private DsyyPrescriptionService dsyyPrescriptionService;
	
	@Value("${wechat.id}")
	private String wxId;
@ -306,6 +309,26 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
							}
						}*/
					}else if("xm_dsyy_wx".equals(wxId)){ //dsyy医院挂号
						if (!outpatientDO.getOutpatientType().equalsIgnoreCase("2")&&!outpatientDO.getOutpatientType().equalsIgnoreCase("3")){
							JSONObject res = dsyyPrescriptionService.registerOutPatient(outpatientCode,doctorCode);
							rsCode = res.getString("@RESULT");
							mes = res.getString("@MSG");
						}else  {
							rsCode="0";
							mes="已挂号";
						}
						/*if ("1".equalsIgnoreCase(outpatientDO.getOutpatientType())){
							if ("2".equalsIgnoreCase(outpatientDO.getType())){
								prescriptionService.sendWxTemplateMsg(wxId,outpatientCode,null,"16","outpatientMsgRemind","");
							}
						}
						if ("3".equalsIgnoreCase(outpatientDO.getOutpatientType())){
							if ("2".equalsIgnoreCase(outpatientDO.getType())){
								prescriptionService.sendWxTemplateMsg(wxId,outpatientCode,null,"17","outpatientMsgRemind","");
							}
						}*/
					}else {
						if (demoFlag.equalsIgnoreCase("true")){
							rsCode="0";
@ -375,7 +398,7 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
						}
					}
				}else if("xm_hcyy_wx".equals(wxId)){ //心脏中心挂号
				}else if("xm_hcyy_wx".equals(wxId)){ //海沧中心退号
					if (demoFlag.equalsIgnoreCase("true")){
						rsCode="0";
						mes="已退号";
@ -390,6 +413,21 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
						}
					}
				}else if("xm_dsyy_wx".equals(wxId)){ //第三医院退号
					if (demoFlag.equalsIgnoreCase("true")){
						rsCode="0";
						mes="已退号";
					}else {
						JSONObject res = dsyyPrescriptionService.refundRegisterNo(outpatientCode);
						if (res!=null&&res.getString("code").equalsIgnoreCase("0")){
							rsCode = "0";
							mes="已退号";
						}else {
							rsCode = "-1";
							mes=res.getString("msg");
						}
					}
				}else {
					if (demoFlag.equalsIgnoreCase("true")){
						rsCode="0";