wangzhinan 2 лет назад
Родитель
Сommit
188211c7c9

+ 9 - 8
business/base-service/src/main/java/com/yihu/jw/healthCare/service/HealthCareNewService.java

@ -149,9 +149,10 @@ public class HealthCareNewService {
            initConfig();
            WlyyHospitalSysDictDO systemDict =  hospitalSysDictDao.findOneByDictNameAndDictCode("ylzConfig","testFlag");
            if (null!=systemDict&&"1".equals(systemDict.getDictValue())){//测试环境
            if (null!=systemDict&&"1".equalsIgnoreCase(systemDict.getDictValue())){//测试环境
                //N00.00.00.01接口外其他的接口在服务号前加个T就是测试
                funid ="N00.00.00.01".equals(funid)?funid:"T"+funid;
                funid ="N00.00.00.01".equalsIgnoreCase(funid)?funid:"T"+funid;
                System.out.println("funid="+funid);
            }
            JSONObject object = new JSONObject();
@ -167,8 +168,8 @@ public class HealthCareNewService {
            data.put("org_code",ylzConfigOrgCode);
            object.put("data",data);
            obj = YibaoJiaMi.encryptData(object,ylzConfigSignKey,ylzConfigEncryptKey);
            String signResult = SafeUtil.sign(object.toJSONString(),ylzConfigSignKey);
            obj = SafeUtil.encrypt(signResult,ylzConfigEncryptKey);
            JSONObject jsonObject = JSONObject.parseObject(obj);
            logger.info("请求前funid=="+funid+"data="+data.toJSONString());
            String response = httpClientUtil.postBody(ylzConfigUrl,jsonObject);
@ -179,7 +180,7 @@ public class HealthCareNewService {
                    String dataResult = result.getString("encrypt_data");
                    result.remove("encrypt_data");
                    if (dataResult!=null&&dataResult!=""){
                        String decryptResult = YibaoJiaMi.decrypt(dataResult,ylzConfigEncryptKey);
                        String decryptResult = AES.aesDecrypt(dataResult,ylzConfigEncryptKey);
                        JSONObject dataObject = JSONObject.parseObject(decryptResult);
                        result.put("encrypt_data",dataObject);
                        response = result.toJSONString();
@ -1052,7 +1053,7 @@ public class HealthCareNewService {
            throw new Exception("患者his信息不存在");
        }
        JSONObject data = new JSONObject();
        data.put("service_id","100000");
        data.put("service_id","350203");
        data.put("name",patientDO.getName());
        data.put("idcard",patientDO.getIdcard());
        data.put("cert_type","01");//TODO
@ -1105,7 +1106,7 @@ public class HealthCareNewService {
            throw new Exception("患者his信息不存在");
        }
        JSONObject data = new JSONObject();
        data.put("service_id","100000");
        data.put("service_id","350203");
        data.put("name",patientDO.getName());
        data.put("idcard",patientDO.getIdcard());
        data.put("cert_type","01");//TODO
@ -1159,7 +1160,7 @@ public class HealthCareNewService {
            throw new Exception("患者his信息不存在");
        }
        JSONObject data = new JSONObject();
        data.put("service_id","100000");
        data.put("service_id","350203");
        data.put("name",patientDO.getName());
        data.put("idcard",patientDO.getIdcard());
        data.put("cert_type","01");//TODO

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

@ -529,6 +529,11 @@ public class HcyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
        if (StringUtils.isNoneBlank(realOrder)){
            params +="&realOrder="+realOrder;
        }
        PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(patNo);
        if (patientMappingDO==null){
            throw new Exception("his用户编码为空!");
        }
        patNo = patientMappingDO.getMappingCode();
        logger.info("处方request:"+registerSn+"=="+patNo+"==="+admNo+"===="+realOrder);
        String obj = hcyyEntranceService.getOriginPrescriptionList(registerSn,patNo,admNo,realOrder,null,null);
        if (StringUtils.isNoneBlank(obj)){
@ -1611,6 +1616,12 @@ public class HcyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
    public YlzMedicalRelationDO getSettlementInfo(String cardno,String outpatientId) throws Exception {
        YlzMedicalRelationDO ylzMedicalRelationDO =new YlzMedicalRelationDO();
        WlyyOutpatientDO outpatientDO = outpatientDao.findById(outpatientId);
        //查询余额
        String balance = "";
        JSONObject jsonObject = selectCardInfo(cardno);
        if (jsonObject!=null){
            balance = jsonObject.getString("ZHYE");
        }
        String resNo = outpatientDO.getRegisterNo();
        //请求his获取待结算存储
        Map<String,Object> params = new HashedMap();
@ -1649,6 +1660,7 @@ public class HcyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
                            ylzMedicalRelationDO.setHisDeptName(object.getString("DEPT_NAME"));
                            ylzMedicalRelationDO.setStatus(0);
                            ylzMedicalRelationDO.setState(0);
                            ylzMedicalRelationDO.setBalance(balance);
                            ylzMedicalRelationDO.setPersonAccount("0");
                            ylzMedicalRelationDO.setMedicalPrice("0");
                            ylzMedicalRelationDO.setHisSettleNo(object.getString("IPT_OTP_NO"));
@ -1669,6 +1681,7 @@ public class HcyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
                            ylzMedicalRelationDO.setHisDeptName(object.getString("DEPT_NAME"));
                            ylzMedicalRelationDO.setPersonAccount("0");
                            ylzMedicalRelationDO.setMedicalPrice("0");
                            ylzMedicalRelationDO.setBalance(balance);
                            ylzMedicalRelationDO.setHisSettleNo(object.getString("IPT_OTP_NO"));
                            ylzMedicalRelationDO.setCardNo(object.getString("CARD_NO"));
                            ylzMedicalRelationDO.setDate(DateUtil.strToDate(object.getString("BEGNTIME")));

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

@ -14453,17 +14453,71 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            object.put("cardNo",outpatientDO.getCardNo());
            object.put("deptName",outpatientDO.getPatientName());
            return object;
        } else if (wechatId.equalsIgnoreCase("xm_hcyy_wx")){
        } else if (wechatId.equalsIgnoreCase("xm_hcyy_wx")) {
            com.alibaba.fastjson.JSONObject object = new com.alibaba.fastjson.JSONObject();
            logger.info("获取患者待结算信息开始!");
            YlzMedicalRelationDO ylzMedicalRelationDO = new YlzMedicalRelationDO();
            ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(outpatientId);
            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 payDateStr = object1.getString("pay_date");
                    Date payDate = DateUtil.strToDate(payDateStr);
                    Date now = DateUtil.getDateShort(new Date());
                    if (payDate.compareTo(now) == 0) {
                        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 {
                        ylzMedicalRelationDO.setStatus(0);
                        ylzMedicailRelationDao.save(ylzMedicalRelationDO);
                    }
                }
            }
            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());//医保总金额
                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);
                return object;
            }
            try {
                ylzMedicalRelationDO = hcyyPrescriptionService.getSettlementInfo(outpatientDO.getCardNo(),outpatientDO.getId());
            }catch (Exception e){
                ylzMedicalRelationDO = hcyyPrescriptionService.getSettlementInfo(outpatientDO.getCardNo(), outpatientDO.getId());
            } catch (Exception e) {
                throw new Exception(e.getMessage());
            }
            BigDecimal b1 = new BigDecimal(ylzMedicalRelationDO.getPersonCash());//个人现金
            if (ylzMedicalRelationDO==null){
                throw new Exception("无待结算信息");
            }
            /*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();
@ -14474,9 +14528,62 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            }else {
                object.put("code","200");
                object.put("message","核对金额无误!");
            }*/
            if(outpatientDO!=null&&outpatientDO.getMedicalState().equalsIgnoreCase("1")){
                logger.info("医保挂号开始!");
                String register = healthCareNewService.register(outpatientId);
                logger.info("医保挂号结束!");
                logger.info("医保费用明细上传开始!");
                String feeDetailUpload= healthCareNewService.feeDetailUpload(outpatientId);
                logger.info("医保费用明细上传结束!");
                logger.info("医保预结算信息开始!");
                ylzMedicalRelationDO =  healthCareNewService.preSettlement(outpatientId);
                logger.info("医保预结算信息结束!");
                if (flag==1){
                    logger.info("获取医保结算页面地址开始!");
                    String getSettlementResultUrl = healthCareNewService.getSettlementResultUrl(outpatientId);
                    logger.info("获取医保结算页面地址结束!");
                    object.put("getSettlementResultUrl",getSettlementResultUrl);
                }else if (flag==2){
                    logger.info("获取医保结算页面地址开始!");
                    String getSettlementResultUrlBase64 = healthCareService.getSettlementResultUrlBase64(outpatientId);
                    logger.info("获取医保结算页面地址结束!");
                    object.put("getSettlementResultUrlBase64",getSettlementResultUrlBase64);
                }
                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","核对金额无误!");
                    }
                }
                object.put("getSettleInfo",ylzMedicalRelationDO);
                return object;
            }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","核对金额无误!");
                }
                object.put("getSettleInfo",ylzMedicalRelationDO);
                return object;
            }
            object.put("getSettleInfo",ylzMedicalRelationDO);
            return object;
        } else {
            com.alibaba.fastjson.JSONObject object = new com.alibaba.fastjson.JSONObject();
            logger.info("获取患者待结算信息开始!");
@ -14634,10 +14741,18 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            throw new Exception("门诊信息为空");
        }
        if (StringUtils.isNoneBlank(code)){
            logger.info("医保结算结果获取start!");
            result = healthCareService.getSettlementResult(code);
            logger.info("医保结算结果获取end!");
            com.alibaba.fastjson.JSONObject object = com.alibaba.fastjson.JSONObject.parseObject(result);
            if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
                logger.info("医保结算结果获取start!");
                result = healthCareService.getSettlementResult(code);
                logger.info("医保结算结果获取end!");
                com.alibaba.fastjson.JSONObject object = com.alibaba.fastjson.JSONObject.parseObject(result);
            }else {
                logger.info("医保结算结果获取start!");
                result = healthCareNewService.getSettlementResult(code);
                logger.info("医保结算结果获取end!");
                com.alibaba.fastjson.JSONObject object = com.alibaba.fastjson.JSONObject.parseObject(result);
            }
        }/*else{
            logger.info("医保结算页面start!");
            String registerNo = outpatientDO.getRegisterNo();

+ 14 - 1
business/base-service/src/main/java/com/yihu/jw/patient/service/BasePatientService.java

@ -11,6 +11,7 @@ import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.entity.hospital.prescription.WlyyInspectionDO;
import com.yihu.jw.entity.hospital.prescription.WlyyOutpatientDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionInfoDO;
import com.yihu.jw.healthCare.service.HealthCareNewService;
import com.yihu.jw.healthCare.service.HealthCareService;
import com.yihu.jw.hospital.mapping.dao.PatientMappingDao;
import com.yihu.jw.hospital.prescription.dao.OutpatientDao;
@ -108,6 +109,8 @@ public class BasePatientService<T, R extends CrudRepository> extends BaseJpaServ
    private HospitalSysDictDao hospitalSysDictDao;
    @Autowired
    private HealthCareService healthCareService;
    @Autowired
    private HealthCareNewService healthCareNewService;
    /**
     * 居民id
     * @param patientId
@ -419,7 +422,7 @@ public class BasePatientService<T, R extends CrudRepository> extends BaseJpaServ
                        basePatientDO.setMedicalState(state);
                        basePatientDO = basePatientDao.save(basePatientDO);
                    }
                }else {
                }else if (wxId.equalsIgnoreCase("xm_zsyy_wx")){
                    String result = healthCareService.authorized(basePatientDO.getId());
                    JSONObject object = JSONObject.parseObject(result);
                    if (object.getString("flag").equalsIgnoreCase("1")){
@ -429,6 +432,16 @@ public class BasePatientService<T, R extends CrudRepository> extends BaseJpaServ
                        basePatientDO.setMedicalState(state);
                        basePatientDO = basePatientDao.save(basePatientDO);
                    }
                }else {
                    String result = healthCareNewService.authorized(basePatientDO.getId());
                    JSONObject object = JSONObject.parseObject(result);
                    if (object.getString("flag").equalsIgnoreCase("1")){
                        JSONObject encryptData = object.getJSONObject("encrypt_data");
                        String state = encryptData.getString("state");
                        String auth_date = encryptData.getString("auth_date");
                        basePatientDO.setMedicalState(state);
                        basePatientDO = basePatientDao.save(basePatientDO);
                    }
                }
            }
        }catch (Exception e){