wangzhinan пре 1 година
родитељ
комит
0f8f9b04d9

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

@ -8,16 +8,24 @@ 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.hospital.healthCare.YlzMedicalIcdDO;
import com.yihu.jw.entity.hospital.healthCare.YlzMedicalMxDO;
import com.yihu.jw.entity.hospital.healthCare.YlzMedicalRelationDO;
import com.yihu.jw.entity.hospital.httplog.WlyyHttpLogDO;
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.healthCare.YlzMedicailIcdDao;
import com.yihu.jw.hospital.healthCare.YlzMedicailMxDao;
import com.yihu.jw.hospital.healthCare.YlzMedicailRelationDao;
import com.yihu.jw.hospital.httplog.dao.WlyyHttpLogDao;
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;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.patient.dao.BasePatientMedicareCardDao;
import com.yihu.jw.restmodel.hospital.prescription.WlyyOutpatientVO;
@ -84,6 +92,17 @@ public class DsyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
    private PrescriptionDao prescriptionDao;
    @Autowired
    private PrescriptionExpressageService sfexpressService;
    @Autowired
    private YlzMedicailRelationDao ylzMedicailRelationDao;
    @Autowired
    private YlzMedicailMxDao ylzMedicailMxDao;
    @Autowired
    private YlzMedicailIcdDao ylzMedicailIcdDao;
    @Autowired
    private BusinessOrderDao businessOrderDao;
    @Autowired
    private PrescriptionLogDao prescriptionLogDao;
    //=============查询视图========================
    /**
@ -1323,4 +1342,337 @@ public class DsyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
            return "处方号未空!";
        }
    }
    /**
     * 获取待结算列表
     *
     *
     * @param cardno
     * @param outpatientId
     * @return
     * @throws Exception
     */
    public YlzMedicalRelationDO getSettlementInfo(String cardno, String outpatientId) throws Exception {
        YlzMedicalRelationDO ylzMedicalRelationDO =new YlzMedicalRelationDO();
        WlyyOutpatientDO outpatientDO = outpatientDao.findById(outpatientId).get();
        //查询余额
        String balance = "";
        JSONObject jsonObject = dsyyEntranceService.selectCardInfo(cardno);
        String cardType= "";
        if (jsonObject!=null){
            balance = jsonObject.getString("ZHYE");
            cardType = jsonObject.getString("CARD_TYPE");
        }
        String resNo = outpatientDO.getRegisterNo();
        //请求his获取待结算存储
        Map<String,Object> params = new HashedMap();
        String url =entranceUrl +"getSettlement";
        params.put("cardType","cardType");
        params.put("cardNo",cardno);
        params.put("hismzlsh",outpatientDO.getRegisterNo());
        params.put("operatorId","HLWYY");
        params.put("operatorName","互联网医院");
        params.put("termNo","DSYYHLWYY");
        HttpResponse response = HttpUtils.doPost(url,params);
        String content = response.getContent();
        logger.info("response:"+content);
        JSONObject rs3 = JSON.parseObject(content);
        Integer resStatus = rs3.getInteger("status");
        JSONObject resObj = new JSONObject();
        if (resStatus==200){
            resObj = rs3.getJSONObject("obj");
        }
        //获取his结算基本信息表
        String basicSql ="select * from SST_JSDP_JBXX_GJYB where CARD_NO ='"+cardno+"'";
        String res = dsyyEntranceService.getSql(basicSql);
        if (StringUtils.isNoneBlank(res)){
            JSONObject rs = JSONObject.parseObject(res);
            Integer status = rs.getInteger("status");
            if(status!=null&&status == 200){
                JSONArray array = rs.getJSONArray("detailModelList");
                for (int i=0;i<array.size();i++){
                    JSONObject object = array.getJSONObject(i);
                    String logNo = object.getString("LOG_NO");
                    String registerNo = object.getString("IPT_OTP_NO");
                    logger.info("logNo=="+logNo +"registerNo=="+registerNo);
                    if (registerNo.equalsIgnoreCase(resNo)){
                        logger.info("logNo=="+logNo +"registerNo=="+registerNo);
                        ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(outpatientId);
                        if (ylzMedicalRelationDO==null){
                            ylzMedicalRelationDO = new YlzMedicalRelationDO();
                            ylzMedicalRelationDO.setLogNo(logNo);
                            ylzMedicalRelationDO.setMedicalState(Integer.parseInt(outpatientDO.getMedicalState()));
                            ylzMedicalRelationDO.setRelationCode(outpatientId);
                            ylzMedicalRelationDO.setName(object.getString("PSN_NAME"));
                            ylzMedicalRelationDO.setTotalAmount(object.getString("COST"));
                            ylzMedicalRelationDO.setPersonCash(object.getString("ORIGIN_CHARGES"));
                            ylzMedicalRelationDO.setHisSerial(object.getString("RESIDENCE_NO"));
                            ylzMedicalRelationDO.setHisBillSerial(object.getString("SETTLE_NO"));
                            ylzMedicalRelationDO.setDeptCode(object.getString("DEPT_CODE"));
                            ylzMedicalRelationDO.setDeptName(object.getString("DEPT_NAME"));
                            ylzMedicalRelationDO.setHisDeptCode(object.getString("DEPT_CODE"));
                            ylzMedicalRelationDO.setHisDeptName(object.getString("DEPT_NAME"));
                            ylzMedicalRelationDO.setStatus(0);
                            ylzMedicalRelationDO.setState(0);
                            ylzMedicalRelationDO.setDel(1);
                            ylzMedicalRelationDO.setDataSource("54");
                            ylzMedicalRelationDO.setIdcard(outpatientDO.getIdcard());
                            ylzMedicalRelationDO.setBalance(balance);
                            ylzMedicalRelationDO.setPersonAccount("0");
                            ylzMedicalRelationDO.setMedicalPrice("0");
                            ylzMedicalRelationDO.setCertType("01");
                            ylzMedicalRelationDO.setMedicalMode("10");
                            ylzMedicalRelationDO.setRegionCode("350200");
                            if (StringUtils.isNoneBlank(outpatientDO.getDiseaseCode())){
                                ylzMedicalRelationDO.setMedicalType("13");
                            }else {
                                ylzMedicalRelationDO.setMedicalType("11");
                            }
                            ylzMedicalRelationDO.setHisSettleNo(object.getString("IPT_OTP_NO"));
                            ylzMedicalRelationDO.setCardNo(object.getString("CARD_NO"));
                            ylzMedicalRelationDO.setDate(DateUtil.strToDate(object.getString("BEGNTIME")));
                            ylzMedicalRelationDO.setBcwkje(object.getString("YKFJE0"));
                        }else {
                            ylzMedicalRelationDO.setLogNo(logNo);
                            ylzMedicalRelationDO.setRelationCode(outpatientId);
                            ylzMedicalRelationDO.setDataSource("54");
                            ylzMedicalRelationDO.setDel(1);
                            ylzMedicalRelationDO.setMedicalState(Integer.parseInt(outpatientDO.getMedicalState()));
                            ylzMedicalRelationDO.setName(object.getString("PSN_NAME"));
                            ylzMedicalRelationDO.setTotalAmount(object.getString("COST"));
                            ylzMedicalRelationDO.setPersonCash(object.getString("ORIGIN_CHARGES"));
                            ylzMedicalRelationDO.setHisSerial(object.getString("RESIDENCE_NO"));
                            ylzMedicalRelationDO.setHisBillSerial(object.getString("SETTLE_NO"));
                            ylzMedicalRelationDO.setDeptCode(object.getString("DEPT_CODE"));
                            ylzMedicalRelationDO.setDeptName(object.getString("DEPT_NAME"));
                            ylzMedicalRelationDO.setHisDeptCode(object.getString("DEPT_CODE"));
                            ylzMedicalRelationDO.setHisDeptName(object.getString("DEPT_NAME"));
                            ylzMedicalRelationDO.setPersonAccount("0");
                            ylzMedicalRelationDO.setMedicalPrice("0");
                            ylzMedicalRelationDO.setBalance(balance);
                            ylzMedicalRelationDO.setCertType("01");
                            ylzMedicalRelationDO.setMedicalMode("10");
                            ylzMedicalRelationDO.setRegionCode("350200");
                            if (StringUtils.isNoneBlank(outpatientDO.getDiseaseCode())){
                                ylzMedicalRelationDO.setMedicalType("13");
                            }else {
                                ylzMedicalRelationDO.setMedicalType("11");
                            }
                            ylzMedicalRelationDO.setIdcard(outpatientDO.getIdcard());
                            ylzMedicalRelationDO.setHisSettleNo(object.getString("IPT_OTP_NO"));
                            ylzMedicalRelationDO.setCardNo(object.getString("CARD_NO"));
                            ylzMedicalRelationDO.setDate(DateUtil.strToDate(object.getString("BEGNTIME")));
                            ylzMedicalRelationDO.setBcwkje(object.getString("YKFJE0"));
                        }
                        ylzMedicalRelationDO = ylzMedicailRelationDao.save(ylzMedicalRelationDO);
                        ylzMedicailMxDao.deleteByMedicalId(ylzMedicalRelationDO.getId());
                        //获取结算明细
                        String detailSql =" select * from SST_JSDP_JSMX_GJYB where LOG_NO ='"+logNo+"' ";
                        String detailRes = dsyyEntranceService.getSql(detailSql);
                        List<YlzMedicalMxDO> mxDOList = new ArrayList<>();
                        Integer itemCount = 0;
                        if (StringUtils.isNoneBlank(detailRes)) {
                            JSONObject drs = JSONObject.parseObject(detailRes);
                            Integer dstatus = drs.getInteger("status");
                            if (dstatus != null && dstatus == 200) {
                                JSONArray darray = drs.getJSONArray("detailModelList");
                                itemCount=darray.size();
                                for (int j = 0; j < darray.size(); j++) {
                                    JSONObject dobject = darray.getJSONObject(j);
                                    YlzMedicalMxDO medicalMxDO = new YlzMedicalMxDO();
                                    medicalMxDO.setDel(1);
                                    medicalMxDO.setMedicalId(ylzMedicalRelationDO.getId());
                                    medicalMxDO.setCreateTime(new Date());
                                    medicalMxDO.setInvoiceType("01");
                                    medicalMxDO.setItemName(dobject.getString("XMMC00"));
                                    medicalMxDO.setHisDetailSn(dobject.getString("FEEDETL_SN"));
                                    medicalMxDO.setItemCode(dobject.getString("MED_LIST_CODG"));
                                    medicalMxDO.setPrescriptionCode(dobject.getString(""));
                                    medicalMxDO.setChargeUnit(dobject.getString("PRCUNT"));
                                    medicalMxDO.setSpecificationType(dobject.getString(""));
                                    medicalMxDO.setAmount(dobject.getString("CNT"));
                                    medicalMxDO.setPrice(dobject.getString("PRIC"));
                                    medicalMxDO.setPrescriptionCode(dobject.getString("RXNO"));
                                    medicalMxDO.setSpecificationType(dobject.getString("SPECIFICATION_TYPE"));
                                    medicalMxDO.setDosageForm(dobject.getString("DOSAGE_FORM"));
                                    medicalMxDO.setPrescriptionDate(DateUtil.strToDate(object.getString("BEGNTIME")));
                                    medicalMxDO.setActgDate(DateUtil.strToDate(object.getString("BEGNTIME")));
                                    medicalMxDO.setClerkDays(DateUtil.strToDate(object.getString("BEGNTIME")));
                                    medicalMxDO.setPeopleType(null);
                                    medicalMxDO.setSingleDose(dobject.getString("SIN_DOS_DSCR"));
                                    medicalMxDO.setUseFrequency(dobject.getString("USED_FRQU_DSCR"));
                                    medicalMxDO.setMedicationDays(dobject.getString("PRD_DAYS"));
                                    medicalMxDO.setMedicalWay(dobject.getString("MEDC_WAY_DSCR"));
                                    medicalMxDO.setDeptCode(dobject.getString("BILG_DEPT_CODG"));
                                    medicalMxDO.setDeptName(dobject.getString("BILG_DEPT_NAME"));
                                    medicalMxDO.setHisDeptCode(dobject.getString("BILG_DEPT_CODG"));
                                    medicalMxDO.setHisDeptName(dobject.getString("BILG_DEPT_NAME"));
                                    medicalMxDO.setMedicalPerId(dobject.getString("BILG_DR_CODG"));
                                    medicalMxDO.setMedicalPerName(dobject.getString("BILG_DR_NAME"));
                                    if (StringUtils.isNoneBlank(dobject.getString("HOSP_APPR_FLAG"))){
                                        if (dobject.getString("HOSP_APPR_FLAG").equalsIgnoreCase("0")||dobject.getString("HOSP_APPR_FLAG").equalsIgnoreCase("2")){
                                            medicalMxDO.setLimitType("N");
                                        } else if (dobject.getString("HOSP_APPR_FLAG").equalsIgnoreCase("1")) {
                                            medicalMxDO.setLimitType("Y");
                                        }
                                    }
                                    medicalMxDO.setHisItemCode(dobject.getString("MED_LIST_CODG"));
                                    medicalMxDO.setHisItemName(dobject.getString("XMMC00"));
                                    medicalMxDO.setTotalMoney(dobject.getString("DET_ITEM_FEE_SUMAMT"));
                                    medicalMxDO = ylzMedicailMxDao.save(medicalMxDO);
                                    mxDOList.add(medicalMxDO);
                                }
                            }
                        }
                        ylzMedicalRelationDO.setItemCount(itemCount+"");
                        ylzMedicalRelationDO = ylzMedicailRelationDao.save(ylzMedicalRelationDO);
                        ylzMedicalRelationDO.setYlzMedicalMxDOList(mxDOList);
                        List<YlzMedicalIcdDO> icdDOS = new ArrayList<>();
                        ylzMedicailIcdDao.deleteByMedicalId(ylzMedicalRelationDO.getId());
                        //获取诊断
                        String icdSql =" select * from SST_JSDP_DZMX_GJYB where LOG_NO ='"+logNo+"' ";
                        String icdRes = dsyyEntranceService.getSql(icdSql);
                        if (StringUtils.isNoneBlank(icdRes)) {
                            JSONObject drs = JSONObject.parseObject(icdRes);
                            Integer dstatus = drs.getInteger("status");
                            if (dstatus != null && dstatus == 200) {
                                JSONArray darray = drs.getJSONArray("detailModelList");
                                for (int j = 0; j < darray.size(); j++) {
                                    JSONObject dobject = darray.getJSONObject(j);
                                    YlzMedicalIcdDO icdDO = new YlzMedicalIcdDO();
                                    icdDO.setCreateTime(new Date());
                                    icdDO.setDel(1);
                                    icdDO.setDiseaseCodeIcd10(dobject.getString("DIAG_CODE"));
                                    icdDO.setDiseaseNameIcd10(dobject.getString("DIAG_NAME"));
                                    icdDO.setDiseaseType(dobject.getString("DIAG_TYPE"));
                                    icdDO.setDiseaseOrder(dobject.getString("DIAG_SRT_NO"));
                                    icdDO.setMedicalId(ylzMedicalRelationDO.getId());
                                    icdDO = ylzMedicailIcdDao.save(icdDO);
                                    icdDOS.add(icdDO);
                                }
                            }
                        }
                        ylzMedicalRelationDO.setYlzMedicalIcdDOList(icdDOS);
                    }
                }
            }
        }
        return  ylzMedicalRelationDO;
    }
    /**
     * 确认医保结算
     *
     * @param outpatientId
     * @return
     * @throws Exception
     */
    public String confirmSettlement(String outpatientId) throws Exception {
        try {
            WlyyOutpatientDO outpatientDO = outpatientDao.findById(outpatientId).get();
            if (outpatientDO==null){
                throw new Exception("未找到待结算记录");
            }
            YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(outpatientId);
            if (ylzMedicalRelationDO!=null&&ylzMedicalRelationDO.getState()!=null&&ylzMedicalRelationDO.getState()==1){
                return "已结算";
            }
            if (ylzMedicalRelationDO==null){
                return "已结算";
            }
            BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(ylzMedicalRelationDO.getId());
            String depositType = "";
            String depositAmount = "";
            String outChargeNo = "";
            String orderNo="";
            if (businessOrderDO!=null){
                depositType = businessOrderDO.getDepositType();
                depositAmount = businessOrderDO.getPayPrice()+"";
                outChargeNo = businessOrderDO.getTraceNo();
                orderNo = businessOrderDO.getOrderNo();
            }
            if (ylzMedicalRelationDO.getMedicalState()==null||(ylzMedicalRelationDO.getMedicalState()!=null&&ylzMedicalRelationDO.getMedicalState()==0)){
            }else {
            }
            Map<String,Object> params = new HashedMap();
            String url ="" +"comfirmSettleMent";
            params.put("mct","03");
            params.put("mcn",ylzMedicalRelationDO.getCardNo());
            params.put("xtgzh0",ylzMedicalRelationDO.getLogNo());
            HttpResponse response = HttpUtils.doGet(url,params);
            System.out.println("response=="+response.getContent());
            String res = response.getContent();
            boolean flag = true;
            if (StringUtils.isNoneBlank(res)){
                JSONObject jsonObject = JSONObject.parseObject(res);
                String status = jsonObject.getString("status");
                if (status.equalsIgnoreCase("200")){
                    JSONObject obj = jsonObject.getJSONObject("obj");
                    String rs = obj.getString("rs");
                    JSONObject rsObj = JSONObject.parseObject(rs);
                    String retCode = rsObj.getString("retCode");
                    if (retCode.equalsIgnoreCase("99")){
                        flag=false;
                        throw new Exception(rsObj.getString("retMsg"));
                    }
                }else {
                    flag = false;
                }
            }
            if (flag){
                ylzMedicalRelationDO.setState(1);
                ylzMedicalRelationDO.setSettleDate(new Date());
                ylzMedicalRelationDO = ylzMedicailRelationDao.save(ylzMedicalRelationDO);
                List<WlyyPrescriptionDO> wlyyPrescriptionDOS = prescriptionDao.findByOutPatientIdList(ylzMedicalRelationDO.getRelationCode());
                /*String */
                String realOrder = "";
                for (WlyyPrescriptionDO prescriptionDO:wlyyPrescriptionDOS){
                    if (prescriptionDO.getStatus()==20){
                        WlyyPrescriptionLogDO prescriptionLogDO = new WlyyPrescriptionLogDO();
                        prescriptionLogDO.setCreateTime(new Date());
                        prescriptionLogDO.setStatus(30);
                        prescriptionLogDO.setOutpatientId(prescriptionDO.getOutpatientId());
                        prescriptionLogDO.setPrescriptionCode(prescriptionDO.getId());
                        prescriptionLogDO.setUserCode(prescriptionDO.getPatientCode());
                        prescriptionLogDO.setUserName(prescriptionDO.getPatientName());
                        prescriptionLogDO.setUserType(1);
                        prescriptionLogDO.setDatajson("处方结算");
                        prescriptionLogDao.save(prescriptionLogDO);
                        prescriptionDO.setStatus(30);
                        prescriptionDO.setVoucherNo(ylzMedicalRelationDO.getHisBillSerial());
                        prescriptionDO.setPayTime(new Date());
                        prescriptionDao.save(prescriptionDO);
                        logger.info("变更处方结算状态成功");
                        realOrder = prescriptionDO.getRealOrder();
                    }
                    try {
                        sfToHis(outpatientId, realOrder);
                    }catch (Exception e){
                        e.printStackTrace();
                    }
                }
                try {
                    logger.info("=================电子发票开具开始=================");
               /*     dsyyEntranceService.OutpatientInvoicing(ylzMedicalRelationDO.getHisBillSerial(),"lb");*/
                    logger.info("=================电子发票开具结束=================");
                }catch (Exception e){
                    e.printStackTrace();
                }
                return "结算成功!";
            }else {
                throw new Exception("结算失败!");
            }
        }catch (Exception e){
            e.printStackTrace();
            throw new Exception(e.getMessage());
        }
    }
}

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

@ -53,6 +53,7 @@ import com.yihu.jw.entity.hospital.prescription.*;
import com.yihu.jw.entity.order.BusinessOrderDO;
import com.yihu.jw.entity.third.ylzinfo.OauthYlzConfigDO;
import com.yihu.jw.file_upload.FileUploadService;
import com.yihu.jw.healthCare.service.HealthCareNewService;
import com.yihu.jw.healthCare.service.HealthCareService;
import com.yihu.jw.hospital.consult.dao.BaseAdviceTreatmentDao;
import com.yihu.jw.hospital.consult.dao.HospitalWaitingRoomDao;
@ -358,6 +359,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    private boolean flag;
    @Autowired
    private OutpatientHospitalizationDao outpatientHospitalizationDao;
    @Autowired
    private HealthCareNewService healthCareNewService;
    /**
@ -14611,127 +14614,134 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        if(outpatientDO==null){
            throw new Exception("门诊信息为空");
        }
        WlyyHospitalSysDictDO sysDictDO = hospitalSysDictDao.findById("ylzConfigOrgCode").orElse(null);
        if (wechatId.equalsIgnoreCase("xm_xzzx_wx")){
            xzzxEntranceService.getSettleInfHospital(outpatientDO.getCardNo(),outpatientId,sysDictDO.getDictValue());
            logger.info("获取患者待结算信息结束!");
            logger.info("医保挂号开始!");
            String register = healthCareService.registerToEntrance(outpatientId);
            logger.info("医保挂号结束!");
            logger.info("医保费用明细上传开始!");
            String feeDetailUpload= healthCareService.feeDetailUploadToEntrance(outpatientId);
            logger.info("医保费用明细上传结束!");
            logger.info("医保预结算信息开始!");
            YlzMedicalRelationDO ylzMedicalRelationDO =  healthCareService.preSettlementToEntrance(outpatientId);
            logger.info("医保预结算信息结束!");
            com.alibaba.fastjson.JSONObject object = new com.alibaba.fastjson.JSONObject();
            if (flag==1){
                logger.info("获取医保结算页面地址开始!");
                String getSettlementResultUrl = healthCareService.getSettlementResultUrlToEntrance(outpatientId);
                logger.info("获取医保结算页面地址结束!");
                object.put("getSettlementResultUrl",getSettlementResultUrl);
            }else if (flag==2){
                logger.info("获取医保结算页面地址开始!");
                String getSettlementResultUrlBase64 = healthCareService.getSettlementResultUrlBase64ToEntrance(outpatientId);
                logger.info("获取医保结算页面地址结束!");
                object.put("getSettlementResultUrlBase64",getSettlementResultUrlBase64);
            }
            object.put("register",register);
            object.put("feeDetailUpload",feeDetailUpload);
            object.put("preSettlement",ylzMedicalRelationDO);
            object.put("cardNo",outpatientDO.getCardNo());
            object.put("deptName",outpatientDO.getPatientName());
            return object;
        }else {
        WlyyHospitalSysDictDO sysDictDO = hospitalSysDictDao.findById("ylzConfigOrgCode").get();
        if (wechatId.equalsIgnoreCase("xm_dsyy_wx")) {
            com.alibaba.fastjson.JSONObject object = new com.alibaba.fastjson.JSONObject();
            logger.info("获取患者待结算信息开始!");
            YlzMedicalRelationDO ylzMedicalRelationDO = new YlzMedicalRelationDO();
            ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(outpatientId);
            if (ylzMedicalRelationDO!=null&&ylzMedicalRelationDO.getStatus()==1){
            if (ylzMedicalRelationDO != null && StringUtils.isNoneBlank(ylzMedicalRelationDO.getPageCode())) {
                String result = confirmSettlementInfo(outpatientId, ylzMedicalRelationDO.getPageCode());
                com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject.parseObject(result);
                if (jsonObject.getString("flag").equalsIgnoreCase("1")) {
                    com.alibaba.fastjson.JSONObject object1 = jsonObject.getJSONObject("encrypt_data");
                    BigDecimal b1 = new BigDecimal(object1.getString("tcjj_pay"));
                    BigDecimal b2 = new BigDecimal(object1.getString("sbjj_pay"));
                    BigDecimal b3 = new BigDecimal(object1.getString("gwy_pay"));
                    BigDecimal b4 = new BigDecimal(object1.getString("jzfp_pay"));
                    BigDecimal b5 = new BigDecimal(object1.getString("yljz_pay"));
                    BigDecimal b6 = new BigDecimal(object1.getString("other_pay"));
                    String valiFlag = object1.getString("vali_flag");
                    if (valiFlag.equalsIgnoreCase("1")) {
                        BigDecimal b7 = new BigDecimal(object1.getString("enterprise_supplement"));
                        Double price = b1.add(b2).add(b3).add(b4).add(b5).add(b6).add(b7).doubleValue();
                        if (Double.parseDouble(ylzMedicalRelationDO.getMedicalPrice()) == price) {
                            ylzMedicalRelationDO.setStatus(1);
                            ylzMedicailRelationDao.save(ylzMedicalRelationDO);
                        } else {
                            if (StringUtils.isNoneBlank(ylzMedicalRelationDO.getDiseaseCode())) {
                                throw new Exception("已存在医保结算记录,请先处理后再结算!");
                            }
                            ylzMedicalRelationDO.setStatus(0);
                            ylzMedicailRelationDao.save(ylzMedicalRelationDO);
                        }
                    } else {
                        ylzMedicalRelationDO.setStatus(0);
                        ylzMedicailRelationDao.save(ylzMedicalRelationDO);
                    }
                } else {
                    if (jsonObject.getString("flag").equalsIgnoreCase("50204")) {
                        ylzMedicalRelationDO.setStatus(0);
                        ylzMedicailRelationDao.save(ylzMedicalRelationDO);
                    } else {
                        throw new Exception(jsonObject.getString("cause"));
                    }
                }
            }
            if (ylzMedicalRelationDO != null && ylzMedicalRelationDO.getStatus() == 1) {
                com.alibaba.fastjson.JSONObject object2 = hcyyPrescriptionService.selectCardInfo(outpatientDO.getCardNo());
                Double cardFee = object2.getDouble("ZHYE");
                //医保已结算直接返回数据
                List<YlzMedicalMxDO> mxDOList = ylzMedicailMxDao.findByMedicalId(ylzMedicalRelationDO.getId());
                ylzMedicalRelationDO.setYlzMedicalMxDOList(mxDOList);
                BigDecimal b1 = new BigDecimal(ylzMedicalRelationDO.getPersonCash());//个人现金
                BigDecimal b2 = new BigDecimal(ylzMedicalRelationDO.getPersonAccount());//个人账户
                BigDecimal b3 = new BigDecimal(ylzMedicalRelationDO.getMedicalPrice());//医保总金额
                Double totalPirce=b1.add(b2).add(b3).doubleValue();
                logger.info("总费用:"+totalPirce);
                if (totalPirce!=Double.parseDouble(ylzMedicalRelationDO.getTotalAmount())){
                    object.put("code","403");
                    object.put("message","金额不对无法结算!");
                }else {
                    object.put("code","200");
                    object.put("message","核对金额无误!");
                ylzMedicalRelationDO.setBalance(cardFee + "");
                ylzMedicalRelationDO = ylzMedicailRelationDao.save(ylzMedicalRelationDO);
                Double totalPirce = b1.add(b2).add(b3).doubleValue();
                logger.info("总费用:" + totalPirce);
                if (totalPirce != Double.parseDouble(ylzMedicalRelationDO.getTotalAmount())) {
                    object.put("code", "403");
                    object.put("message", "金额不对无法结算!");
                } else {
                    object.put("code", "200");
                    object.put("message", "核对金额无误!");
                }
                object.put("getSettleInfo",ylzMedicalRelationDO);
                object.put("getSettleInfo", ylzMedicalRelationDO);
                return object;
            }
            try {
                ylzMedicalRelationDO = entranceService.getSettleInfo(outpatientDO.getCardNo(),outpatientDO.getIdcard(),outpatientDO.getId());
            }catch (Exception e){
                throw new Exception(e.getMessage());
            }
            if (ylzMedicalRelationDO==null){
            ylzMedicalRelationDO = dsyyPrescriptionService.getSettlementInfo(outpatientDO.getCardNo(), outpatientDO.getId());
            if (ylzMedicalRelationDO == null) {
                throw new Exception("无待结算信息");
            }
            logger.info("获取患者待结算信息结束!");
            if(outpatientDO!=null&&outpatientDO.getMedicalState().equalsIgnoreCase("1")){
            if (outpatientDO != null && outpatientDO.getMedicalState().equalsIgnoreCase("1")) {
                logger.info("医保挂号开始!");
                String register = healthCareService.register(outpatientId,ylzMedicalRelationDO.getLogNo());
                String register = healthCareNewService.register(outpatientId);
                logger.info("医保挂号结束!");
                logger.info("医保费用明细上传开始!");
                String feeDetailUpload= healthCareService.feeDetailUpload(outpatientId,ylzMedicalRelationDO.getLogNo());
                String feeDetailUpload = healthCareNewService.feeDetailUpload(outpatientId);
                logger.info("医保费用明细上传结束!");
                logger.info("医保预结算信息开始!");
                ylzMedicalRelationDO =  healthCareService.preSettlement(outpatientId,ylzMedicalRelationDO.getLogNo());
                ylzMedicalRelationDO = healthCareNewService.preSettlement(outpatientId);
                logger.info("医保预结算信息结束!");
                if (flag==1){
                if (flag == 1) {
                    logger.info("获取医保结算页面地址开始!");
                    String getSettlementResultUrl = healthCareService.getSettlementResultUrl(outpatientId,ylzMedicalRelationDO.getLogNo());
                    String getSettlementResultUrl = healthCareNewService.getSettlementResultUrl(outpatientId);
                    logger.info("获取医保结算页面地址结束!");
                    object.put("getSettlementResultUrl",getSettlementResultUrl);
                }else if (flag==2){
                    object.put("getSettlementResultUrl", getSettlementResultUrl);
                } else if (flag == 2) {
                    logger.info("获取医保结算页面地址开始!");
                    String getSettlementResultUrlBase64 = healthCareService.getSettlementResultUrlBase64(outpatientId,ylzMedicalRelationDO.getLogNo());
                    String getSettlementResultUrlBase64 = healthCareNewService.getSettlementResultUrlBase64(outpatientId);
                    logger.info("获取医保结算页面地址结束!");
                    object.put("getSettlementResultUrlBase64",getSettlementResultUrlBase64);
                    object.put("getSettlementResultUrlBase64", getSettlementResultUrlBase64);
                }
                if (ylzMedicalRelationDO.getPersonCash()!=null){
                if (ylzMedicalRelationDO.getPersonCash() != null) {
                    BigDecimal b1 = new BigDecimal(ylzMedicalRelationDO.getPersonCash());//个人现金
                    BigDecimal b2 = new BigDecimal(ylzMedicalRelationDO.getPersonAccount());//个人账户
                    BigDecimal b3 = new BigDecimal(ylzMedicalRelationDO.getMedicalPrice());//医保总金额
                    Double totalPirce=b1.add(b2).add(b3).doubleValue();
                    logger.info("总费用:"+totalPirce);
                    if (totalPirce!=Double.parseDouble(ylzMedicalRelationDO.getTotalAmount())){
                        object.put("code","403");
                        object.put("message","金额不对无法结算!");
                    }else {
                        object.put("code","200");
                        object.put("message","核对金额无误!");
                    Double totalPirce = b1.add(b2).add(b3).doubleValue();
                    logger.info("总费用:" + totalPirce);
                    if (totalPirce != Double.parseDouble(ylzMedicalRelationDO.getTotalAmount())) {
                        object.put("code", "403");
                        object.put("message", "金额不对无法结算!");
                    } else {
                        object.put("code", "200");
                        object.put("message", "核对金额无误!");
                    }
                }
                object.put("getSettleInfo",ylzMedicalRelationDO);
                object.put("getSettleInfo", ylzMedicalRelationDO);
                return object;
            }else {
            } else {
                BigDecimal b1 = new BigDecimal(ylzMedicalRelationDO.getPersonCash());//个人现金
                BigDecimal b2 = new BigDecimal(ylzMedicalRelationDO.getPersonAccount());//个人账户
                BigDecimal b3 = new BigDecimal(ylzMedicalRelationDO.getMedicalPrice());//医保总金额
                Double totalPirce=b1.add(b2).add(b3).doubleValue();
                logger.info("总费用:"+totalPirce);
                if (totalPirce!=Double.parseDouble(ylzMedicalRelationDO.getTotalAmount())){
                    object.put("code","403");
                    object.put("message","金额不对无法结算!");
                }else {
                    object.put("code","200");
                    object.put("message","核对金额无误!");
                Double totalPirce = b1.add(b2).add(b3).doubleValue();
                logger.info("总费用:" + totalPirce);
                if (totalPirce != Double.parseDouble(ylzMedicalRelationDO.getTotalAmount())) {
                    object.put("code", "403");
                    object.put("message", "金额不对无法结算!");
                } else {
                    object.put("code", "200");
                    object.put("message", "核对金额无误!");
                }
                object.put("getSettleInfo",ylzMedicalRelationDO);
                object.put("getSettleInfo", ylzMedicalRelationDO);
                return object;
            }
        }else {
            return null;
        }
    }

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

@ -299,6 +299,23 @@ public class DsyyEntranceService {
    private final static String url="http://192.168.101.2:10023/dsyy/createSQLQuery";
    private final static String orgCode ="350211A1004";
    /**
     * 请求his服务查询数据
     * @param sql
     * @return
     * @throws Exception
     */
    public String getSql(String sql) throws Exception {
        Map<String,Object> params = new HashedMap();
        params.put("sql",sql);
        logger.info("sql语句:"+sql);
        HttpResponse response = HttpUtils.doGet(url,params);
        String content = response.getContent();
        logger.info("response:"+content);
        return content;
    }
    /**
     * 同步科室信息
     * @return
@ -1103,6 +1120,52 @@ public class DsyyEntranceService {
        return patientMappingDO.getMappingCode();
    }
    /**
     * 获取患者卡详情
     *
     *
     * @param cardno
     * @throws Exception
     */
    public JSONObject selectCardInfo(String cardno) throws Exception {
        String sql ="SELECT\n" +
                "\tPAT_NO AS \"PAT_NO\",\n" +
                "\tSICK_ID AS \"SICK_ID\",\n" +
                "\tCARD_NO AS \"CARD_NO\",\n" +
                "\tCARD_STAT AS \"CARD_STAT\",\n" +
                "\tOP_DATE AS \"OP_DATE\",\n" +
                "\tCARD_TYPE AS \"CARD_TYPE\",\n" +
                "\tXM AS \"XM\",\n" +
                "\tXB AS \"XB\",\n" +
                "\tLXDH AS \"LXDH\",\n" +
                "\tZJHM AS \"ZJHM\",\n" +
                "\tZHYE AS \"ZHYE\" \n" +
                "FROM\n" +
                "\tzhiydba.v_internet_patient_card_info \n" +
                "WHERE\n" +
                " 1=1 ";
        JSONObject object = new JSONObject();
        JSONArray array = new JSONArray();
        if (StringUtils.isNoneBlank(cardno)){
            sql +=" and CARD_NO = '"+cardno+"' ";
        }
        Map<String,Object> params = new HashedMap();
        params.put("sql",sql);
        logger.info("cardNo:"+sql);
        HttpResponse response = HttpUtils.doGet(url,params);
        String content = response.getContent();
        logger.info("response:"+content);
        JSONObject rs = JSON.parseObject(content);
        Integer status = rs.getInteger("status");
        if (status==200){
            array = rs.getJSONArray("detailModelList");
            if (array!=null&&array.size()!=0){
                object = array.getJSONObject(0);
            }
        }
        return object;
    }
    /**
     * 获取患者卡列表
     *
@ -1735,6 +1798,7 @@ public class DsyyEntranceService {
            object.put("hismzlsh",hismzlsh);
        }
        object.put("accountType","01");
        object.put("sfxsjs","Y");
        condition = object.toJSONString();
        String msgBody =condition;
        Map<String,String> params = new HashedMap();

+ 72 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/prescription/WlyyOutpatientDO.java

@ -303,6 +303,21 @@ public class WlyyOutpatientDO extends UuidIdentityEntity {
    private String planId;//康复执行计划关联id
    private String planDoctor;//康复执行计划负责人id
    private String diseaseCode;//特殊病种编码
    private String diseaseName;//特殊病种名称
    private Integer isPositive;//是否新冠阳性 1是0否
    private String inquirySign;//问诊标识1发热咨询0普通门诊
    private String visitType;//就诊类型:1首诊2复诊
    private String virusFlag;//新冠病毒:1阴性、2阳性、0无
    private String isDisease;//特殊病种1是0否
    @Column(name = "medical_state")
    public String getMedicalState() {
        return medicalState;
@ -847,4 +862,61 @@ public class WlyyOutpatientDO extends UuidIdentityEntity {
    public void setPlanDoctor(String planDoctor) {
        this.planDoctor = planDoctor;
    }
    public String getDiseaseCode() {
        return diseaseCode;
    }
    public void setDiseaseCode(String diseaseCode) {
        this.diseaseCode = diseaseCode;
    }
    public String getDiseaseName() {
        return diseaseName;
    }
    public void setDiseaseName(String diseaseName) {
        this.diseaseName = diseaseName;
    }
    public Integer getIsPositive() {
        return isPositive;
    }
    public void setIsPositive(Integer isPositive) {
        this.isPositive = isPositive;
    }
    public String getInquirySign() {
        return inquirySign;
    }
    public void setInquirySign(String inquirySign) {
        this.inquirySign = inquirySign;
    }
    public String getVisitType() {
        return visitType;
    }
    public void setVisitType(String visitType) {
        this.visitType = visitType;
    }
    public String getVirusFlag() {
        return virusFlag;
    }
    public void setVirusFlag(String virusFlag) {
        this.virusFlag = virusFlag;
    }
    public String getIsDisease() {
        return isDisease;
    }
    public void setIsDisease(String isDisease) {
        this.isDisease = isDisease;
    }
}

+ 1 - 1
svr/svr-internet-hospital-entrance/src/main/resources/application.yml

@ -667,7 +667,7 @@ express:
---
#马銮湾医院
#73医院
spring:
  profiles: qsyyProd
  datasource: