Browse Source

智业院内结算修改,多笔订单需一次性结算 多笔一起传给his院内结算。

bing 2 years ago
parent
commit
52216acdad

+ 17 - 19
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/a4endpoint/MedicineOrderDrugsEndpoint.java

@ -166,27 +166,10 @@ public class MedicineOrderDrugsEndpoint extends EnvelopRestEndpoint {
        }
    }
    @GetMapping("/open/executeSickSettleMultiNew")
    @ApiOperation(value = "续方确认结算-智业", notes = "续方确认结算-智业")
    public Envelop executeSickSettleMultiNew(
            @ApiParam(name = "recipe_no", value = "处方号")
            @RequestParam(value = "recipe_no", required = true) String recipe_no,
            @ApiParam(name="equ_num",value="药柜设备号",defaultValue = "")
            @RequestParam(value = "equ_num",required = true) String equ_num){
        try {
            return success("结算成功", medOrderService.executeSickSettleMultiNew(recipe_no,equ_num));
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError(e.getMessage());
        }
    }
    @GetMapping("/open/hlwyyRecharge")
    @ApiOperation(value = "预缴金充值", notes = "预缴金充值")
    @ApiOperation(value = "院内确认结算", notes = "院内确认结算")
    public Envelop hlwyyRecharge(
                @ApiParam(name = "recipe_no", value = "处方号,多笔结算逗号隔开")
                @ApiParam(name = "recipe_no", value = "处方号,多笔结算逗号隔开(患者所有待结算订单需全部传入)")
                @RequestParam(value = "recipe_no", required = true) String recipe_no,
                @ApiParam(name="equ_num",value="药柜设备号",defaultValue = "")
                @RequestParam(value = "equ_num",required = false) String equ_num,
@ -314,4 +297,19 @@ public class MedicineOrderDrugsEndpoint extends EnvelopRestEndpoint {
        }
    }
    @GetMapping("/open/executeSickSettleMultiNew")
    @ApiOperation(value = "院内确认结算-智业(未使用)", notes = "续方确认结算-智业")
    public Envelop executeSickSettleMultiNew(
            @ApiParam(name = "recipe_no", value = "处方号,多笔结算逗号隔开(患者所有待结算订单需全部传入) ")
            @RequestParam(value = "recipe_no", required = true) String recipe_no,
            @ApiParam(name="equ_num",value="药柜设备号",defaultValue = "")
            @RequestParam(value = "equ_num",required = true) String equ_num){
        try {
            return success("结算成功", medOrderService.executeSickSettleMultiNew(recipe_no,equ_num));
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError(e.getMessage());
        }
    }
}

+ 184 - 181
svr/svr-base/src/main/java/com/yihu/jw/base/service/a3service/JwService.java

@ -144,42 +144,36 @@ public class JwService {
    /**
     * 确认结算-智业--自助机
     * 患者待结算订单需要一次性结清,一次性进行院内结算
     * @param
     * @return
     */
    @Transactional(propagation= Propagation.NOT_SUPPORTED)
    public boolean executeSickSettleMultiNew(String recipe_no,String equ_num) throws Exception {
        String   sql = " select dict_code,dict_value from wlyy_hospital_sys_dict where dict_name='his_settlement' ";
    public boolean executeSickSettleMultiNew(String recipe_nos,String equ_num) throws Exception {
        String sql = " select dict_code,dict_value from wlyy_hospital_sys_dict where dict_name='his_settlement' ";
        List<Map<String,Object>> AnalogFlags = jdbcTemplate.queryForList(sql);
        String AnalogFlag = "0";
        if (AnalogFlags.size()>0){
            AnalogFlag = AnalogFlags.get(0).get("dict_code").toString();
        }
        if ("1".equals(AnalogFlag)) {//获取调式模拟数据
            YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByLog_no(recipe_no);
            if(null==ylzMedicalRelationDO){
               return true;
            for (String recipe_no:recipe_nos.split(",")){
                YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByLog_no(recipe_no);
                if(null==ylzMedicalRelationDO){
                    throw new Exception("未找到待结算订单");
                }
                ylzMedicalRelationDO.setState(1);
                ylzMedicailRelationDao.save(ylzMedicalRelationDO);
            }
            ylzMedicalRelationDO.setState(1);
            ylzMedicailRelationDao.save(ylzMedicalRelationDO);
            return true;
        }
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByLog_no(recipe_no);
        if (null==ylzMedicalRelationDO){
           return true;
        }
        if (ylzMedicalRelationDO.getState()==1){
            return true;
        }
        List<YlzMedicalMxDO> ylzMedicalMxDOList = ylzMedicailMxDao.findByMedicalId(ylzMedicalRelationDO.getId());
        List<YlzMedicalIcdDO> ylzMedicalIcdDOList = ylzMedicailIcdDao.findByMedicalId(ylzMedicalRelationDO.getId());
        JSONObject msgBody = new JSONObject();
        JSONArray insurVisitInfo = new JSONArray();
        JSONArray insurResult = new JSONArray(); //自费病人没有产生医保收费记录,insurResult节点不传自费结算信息
        msgBody.put("cardNo",ylzMedicalRelationDO.getCardNo());//病人卡号
        /**
         * 获取结算科室编码
         */
@ -191,180 +185,186 @@ public class JwService {
        }else {
            throw new Exception("未找到结算科室编码");
        }
        msgBody.put("visitNo","");//结算人员编码
        if (0==ylzMedicalRelationDO.getMedicalState()){//自费
            msgBody.put("insurResult",insurResult);
        }else if (1==ylzMedicalRelationDO.getMedicalState()){//医保
            YlzMedicalResponse ylzMedicalResponse = ylzMedicalResponseDao.findByMedicalId(ylzMedicalRelationDO.getId());
            if (null==ylzMedicalResponse){
                throw new Exception("未查询到医保结算信息");
        msgBody.put("visitNo","");//院内挂号号,取费用列表中最小的院内挂号号,可传空
        String orgCode = "";
        for (String recipe_no:recipe_nos.split(",")){
            YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByLog_no(recipe_no);
            if (null==ylzMedicalRelationDO){
                continue;
            }
            if (ylzMedicalRelationDO.getState()==1){
                continue;
            }
            orgCode = ylzMedicalRelationDO.getOrgCode();
            List<YlzMedicalMxDO> ylzMedicalMxDOList = ylzMedicailMxDao.findByMedicalId(ylzMedicalRelationDO.getId());
            List<YlzMedicalIcdDO> ylzMedicalIcdDOList = ylzMedicailIcdDao.findByMedicalId(ylzMedicalRelationDO.getId());
            msgBody.put("cardNo",ylzMedicalRelationDO.getCardNo());//病人卡号
            JSONArray ylzResponse = JSONArray.parseArray(ylzMedicalResponse.getValue());
            JSONObject ylzResponseData = null;
            JSONObject ylzResponseOutPut = null;
            JSONObject setlinfo = null;
            if (ylzResponse.size()>0){
                for (int i=0;i<ylzResponse.size();i++){
                    JSONObject ylzResponse0 = ylzResponse.getJSONObject(i);
                    ylzResponseData = ylzResponse0.getJSONObject("data");
                    ylzResponseOutPut = ylzResponseData.getJSONObject("output");
                    setlinfo =  ylzResponseOutPut.getJSONObject("setlinfo");
                    JSONArray outPutSetldetail = ylzResponseOutPut.getJSONArray("setldetail");
                    JSONArray outPutResult = ylzResponseOutPut.getJSONArray("result");
                    YlzMedicalMxDO medicalMxDO = ylzMedicalMxDOList.get(0);
                    JSONObject insurResultTmp = new JSONObject();
                    insurResultTmp.put("visitNo",ylzMedicalRelationDO.getLogNo().split("_")[0]); //院内挂号号
                    insurResultTmp.put("insurSettleSort",medicalMxDO.getInsurSettleSort()); //医保结算序号
                    insurResultTmp.put("setl_msgid",medicalMxDO.getSetlMsgid()); //发送方报文ID
                    insurResultTmp.put("fee_msgid",medicalMxDO.getFeeMsgid()); //费用上传发送方报文ID
                    insurResultTmp.put("dise_msgid",ylzMedicalIcdDOList.get(0).getDiseMsgid()); //就诊信息上传发送方报文ID
                    insurResultTmp.put("chrg_bchno",medicalMxDO.getChrgBchno());   //收费批次号
                    insurResultTmp.put("insuplc_admdvs",ylzMedicalRelationDO.getRegionCode()); //参保地医保区划【窗口冲销有用】
                    insurResultTmp.put("card_sn",null==ylzMedicalRelationDO.getCardSn()?"":ylzMedicalRelationDO.getCardSn()); //卡识别码
                    insurResultTmp.put("mdtrt_cert_no",ylzMedicalRelationDO.getCardNo()); //就诊凭证编号
                    JSONObject setlinfoEexpContent = JSONObject.parseObject(setlinfo.getString("exp_content"));
                    insurResultTmp.put("fm_acct_balc",null==setlinfoEexpContent.get("fm_acct_balc")?"":setlinfoEexpContent.get("fm_acct_balc").toString()); //家庭共济账户余额
                    insurResultTmp.put("hl_acct_balc",setlinfoEexpContent.get("hl_acct_balc").toString()); //健康账户余额
                    insurResultTmp.put("cvl_acct_balc",setlinfoEexpContent.get("cvl_acct_balc").toString()); //公务员账户余额
                    insurResultTmp.put("acct_used_flag","1"); //个人账户使用标志【窗口目前默认固定1,后续可开放前端选择传入】
                    insurResultTmp.put("mdtrt_id",setlinfo.get("mdtrt_id")); //就诊 ID
                    insurResultTmp.put("setl_id",setlinfo.get("setl_id")); //结算ID
                    insurResultTmp.put("psn_no",setlinfo.get("psn_no")); //人员编号   医保人员基本信息获取接口返回
                    insurResultTmp.put("psn_name",setlinfo.get("psn_name")); //人员姓名
                    insurResultTmp.put("psn_cert_type",setlinfo.get("psn_cert_type")); //人员证件类型
                    insurResultTmp.put("certno",setlinfo.get("certno")); //证件号码
                    insurResultTmp.put("gend",setlinfo.get("gend")); //性别
                    insurResultTmp.put("naty",null==setlinfo.get("naty")?"":setlinfo.get("naty")); //民族
                    insurResultTmp.put("brdy",setlinfo.get("brdy")); //出生日期
                    insurResultTmp.put("age",setlinfo.get("age").toString()); //年龄
                    insurResultTmp.put("insutype",ylzMedicalRelationDO.getInsuranceType()); //险种类型 //医保读卡or结算返回
                    insurResultTmp.put("psn_type",setlinfo.get("psn_type")); //人员类别" //医保结算返回
                    insurResultTmp.put("cvlserv_flag",setlinfo.get("cvlserv_flag")); //公务员标志 //医保结算返回
                    insurResultTmp.put("setl_time", setlinfo.get("setl_time"));    //结算时间
                    insurResultTmp.put("mdtrt_cert_type",setlinfo.get("mdtrt_cert_type"));  //就诊凭证类型 取医保结算返回
                    insurResultTmp.put("med_type",setlinfo.get("med_type")); //医疗类别
                    insurResultTmp.put("medfee_sumamt",setlinfo.get("medfee_sumamt").toString());  //医疗费总额
                    insurResultTmp.put("fulamt_ownpay_amt",setlinfo.get("fulamt_ownpay_amt").toString()); //全自费金额
                    insurResultTmp.put("overlmt_selfpay",setlinfo.get("overlmt_selfpay").toString());  //超限价自费费用
                    insurResultTmp.put("preselfpay_amt",setlinfo.get("preselfpay_amt").toString());   //先行自付金额
                    insurResultTmp.put("inscp_scp_amt",setlinfo.get("inscp_scp_amt").toString());    //符合政策范围金额
                    insurResultTmp.put("act_pay_dedc",setlinfo.get("act_pay_dedc").toString()); //实际支付起付线
                    insurResultTmp.put("hifp_pay",setlinfo.get("hifp_pay").toString()); //基本医疗保险统筹基金支出
                    insurResultTmp.put("pool_prop_selfpay",setlinfo.get("pool_prop_selfpay").toString());    //基本医疗保险统筹基金支付比例
                    insurResultTmp.put("cvlserv_pay",setlinfo.get("cvlserv_pay").toString());  //公务员医疗补助资金支出
                    insurResultTmp.put("hifes_pay",setlinfo.get("hifes_pay").toString());    //企业补充医疗保险基金支出
                    insurResultTmp.put("hifmi_pay",setlinfo.get("hifmi_pay").toString());    //居民大病保险资金支出
                    insurResultTmp.put("hifob_pay",setlinfo.get("hifob_pay").toString());    //职工大额医疗费用补助基金支出
                    insurResultTmp.put("maf_pay",setlinfo.get("maf_pay").toString());  //医疗救助基金支出
                    insurResultTmp.put("oth_pay",setlinfo.get("oth_pay").toString());  //其他支出
                    insurResultTmp.put("fund_pay_sumamt",setlinfo.get("fund_pay_sumamt").toString());  //基金支付总额
                    insurResultTmp.put("psn_part_amt",setlinfo.get("psn_part_amt").toString()); //个人负担总金额
                    insurResultTmp.put("acct_pay",setlinfo.get("acct_pay").toString()); //个人账户支出
                    insurResultTmp.put("psn_cash_pay",setlinfo.get("psn_cash_pay").toString()); //个人现金支出
                    insurResultTmp.put("hosp_part_amt",setlinfo.get("hosp_part_amt").toString());    //医院负担金额
                    insurResultTmp.put("balc",setlinfo.get("balc").toString()); //余额
                    insurResultTmp.put("acct_mulaid_pay",setlinfo.get("acct_mulaid_pay").toString());  //个人账户共济支付金额
                    insurResultTmp.put("medins_setl_id",setlinfo.get("medins_setl_id"));   //医药机构结算ID(应跟setl_msgid值一致)
                    insurResultTmp.put("clr_optins",setlinfo.get("clr_optins"));   //清算经办机构
                    insurResultTmp.put("clr_way",setlinfo.get("clr_way"));  //清算方式
                    insurResultTmp.put("clr_type",setlinfo.get("clr_type")); //清算类别
                    insurResultTmp.put("hifdm_pay",setlinfo.get("hifdm_pay").toString());    //伤残人员医疗保障基金支出
                    insurResultTmp.put("exp_content",setlinfo.get("exp_content"));
                    JSONArray setldetail  = new JSONArray();
                    for (int j=0;j<outPutSetldetail.size();j++){
                        JSONObject outPutSetldetailTmp = outPutSetldetail.getJSONObject(j);
                        JSONObject setldetailTmp = new JSONObject();
                        setldetailTmp.put("fund_pay_type",null==outPutSetldetailTmp.get("fund_pay_type")?"":outPutSetldetailTmp.get("fund_pay_type").toString());  //基金支付类型
                        setldetailTmp.put("inscp_scp_amt",null==outPutSetldetailTmp.get("inscp_scp_amt")?"0":outPutSetldetailTmp.get("inscp_scp_amt").toString());  //符合政策范围金额
                        setldetailTmp.put("crt_payb_lmt_amt",null==outPutSetldetailTmp.get("crt_payb_lmt_amt")?"0":outPutSetldetailTmp.get("crt_payb_lmt_amt").toString());   //本次可支付限额金额
                        setldetailTmp.put("fund_payamt",null==outPutSetldetailTmp.get("fund_payamt")?"0":outPutSetldetailTmp.get("fund_payamt").toString());    //基金支付金额
                        setldetailTmp.put("fund_pay_type_name",null==outPutSetldetailTmp.get("fund_pay_type_name")?"":outPutSetldetailTmp.get("fund_pay_type_name").toString()); //基金支付类型名称
                        setldetailTmp.put("setl_proc_info",null==outPutSetldetailTmp.get("setl_proc_info")?"":outPutSetldetailTmp.get("setl_proc_info").toString()); //结算过程信息
                        setldetail.add(setldetailTmp);
                    }
            if (0==ylzMedicalRelationDO.getMedicalState()){//自费病人没有产生医保收费记录,insurResult节点不传自费结算信息,insurVisitInfo也不用传
                    JSONArray fpdetail  = new JSONArray();
                    JSONArray fplists =  setlinfoEexpContent.getJSONArray("fplist");
                    for (int j=0;j<fplists.size();j++){
                        JSONObject fplistTmp = fplists.getJSONObject(j);
                        JSONObject fpdetailTmp  = new JSONObject();
                        fpdetailTmp.put("chrgitmType",null==fplistTmp.get("medChrgitmType")?"":fplistTmp.get("medChrgitmType").toString()); //发票项目类别
                        fpdetailTmp.put("chrgitmTypeName",null==fplistTmp.get("medChrgitmName")?"":fplistTmp.get("medChrgitmName").toString());  //发票项目类别名称
                        fpdetailTmp.put("itemSumamt",null==fplistTmp.get("itemSumamt")?"0":fplistTmp.get("itemSumamt").toString());   //发票项目费用
                        fpdetailTmp.put("itemClaaAmt",null==fplistTmp.get("itemClaaAmt")?"0":fplistTmp.get("itemClaaAmt").toString());  //医保发票费用
                        fpdetailTmp.put("itemClabAmt",null==fplistTmp.get("itemClabAmt")?"0":fplistTmp.get("itemClabAmt").toString());  //医保个人费用
                        fpdetailTmp.put("itemOthAmt",null==fplistTmp.get("itemOthAmt")?"0":fplistTmp.get("itemOthAmt").toString());   //特殊项目发票费用
                        fpdetailTmp.put("itemOwnpayAmt",null==fplistTmp.get("itemOwnpayAmt")?"0":fplistTmp.get("itemOwnpayAmt").toString());    //非医保发票费用
                        fpdetail.add(fpdetailTmp);
                    }
            }else if (1==ylzMedicalRelationDO.getMedicalState()){//医保
                YlzMedicalResponse ylzMedicalResponse = ylzMedicalResponseDao.findByMedicalId(ylzMedicalRelationDO.getId());
                if (null==ylzMedicalResponse){
                    throw new Exception("未查询到医保结算信息");
                }
                    JSONArray feedetail_result  = new JSONArray();
                    for (int j=0;j<outPutResult.size();j++){
                        JSONObject outPutResultTmp = outPutResult.getJSONObject(j);
                        JSONObject feedetail_resultTmp  = new JSONObject();
                        feedetail_resultTmp.put("feedetl_sn",null==outPutResultTmp.get("feedetl_sn")?"":outPutResultTmp.get("feedetl_sn").toString());   // 费用明细流水
                        feedetail_resultTmp.put("det_item_fee_sumamt",null==outPutResultTmp.get("det_item_fee_sumamt")?"":outPutResultTmp.get("det_item_fee_sumamt").toString()); //明细项目费用总额
                        feedetail_resultTmp.put("cnt",null==outPutResultTmp.get("cnt")?"":outPutResultTmp.get("cnt").toString()); //数量
                        feedetail_resultTmp.put("pric",null==outPutResultTmp.get("pric")?"":outPutResultTmp.get("pric").toString()); //单价
                        feedetail_resultTmp.put("pric_uplmt_amt",null==outPutResultTmp.get("pric_uplmt_amt")?"":outPutResultTmp.get("pric_uplmt_amt").toString()); //定价上限金额
                        feedetail_resultTmp.put("selfpay_prop",null==outPutResultTmp.get("selfpay_prop")?"":outPutResultTmp.get("selfpay_prop").toString()); //自付比例
                        feedetail_resultTmp.put("fulamt_ownpay_amt",null==outPutResultTmp.get("fulamt_ownpay_amt")?"":outPutResultTmp.get("fulamt_ownpay_amt").toString()); //全自费金额
                        feedetail_resultTmp.put("overlmt_amt",null==outPutResultTmp.get("overlmt_amt")?"":outPutResultTmp.get("overlmt_amt").toString()); //超限价金额
                        feedetail_resultTmp.put("preselfpay_amt",null==outPutResultTmp.get("preselfpay_amt")?"":outPutResultTmp.get("preselfpay_amt").toString()); //先行自付金额
                        feedetail_resultTmp.put("inscp_scp_amt",null==outPutResultTmp.get("inscp_scp_amt")?"":outPutResultTmp.get("inscp_scp_amt").toString()); //符合政策范围金额
                        feedetail_resultTmp.put("chrgitm_lv",null==outPutResultTmp.get("chrgitm_lv")?"":outPutResultTmp.get("chrgitm_lv").toString()); //收费项目等级
                        feedetail_resultTmp.put("med_chrgitm_type",null==outPutResultTmp.get("med_chrgitm_type")?"":outPutResultTmp.get("med_chrgitm_type").toString()); //医疗收费项目类别
                        feedetail_resultTmp.put("bas_medn_flag",null==outPutResultTmp.get("bas_medn_flag")?"":outPutResultTmp.get("bas_medn_flag").toString()); //基本药物标志
                        feedetail_resultTmp.put("hi_nego_drug_flag",null==outPutResultTmp.get("hi_nego_drug_flag")?"":outPutResultTmp.get("hi_nego_drug_flag").toString()); //医保谈判药品标志
                        feedetail_resultTmp.put("chld_medc_flag",null==outPutResultTmp.get("chld_medc_flag")?"":outPutResultTmp.get("chld_medc_flag").toString()); //儿童用药标志
                        feedetail_resultTmp.put("list_sp_item_flag",null==outPutResultTmp.get("list_sp_item_flag")?"":outPutResultTmp.get("list_sp_item_flag").toString()); //目录特项标志
                        feedetail_resultTmp.put("lmt_used_flag",null==outPutResultTmp.get("lmt_used_flag")?"":outPutResultTmp.get("lmt_used_flag").toString()); //限制使用标志
                        feedetail_resultTmp.put("drt_reim_flag",null==outPutResultTmp.get("drt_reim_flag")?"":outPutResultTmp.get("drt_reim_flag").toString()); //直报标志
                        feedetail_resultTmp.put("memo",null==outPutResultTmp.get("memo")?"":outPutResultTmp.get("memo").toString()); //备注
                        feedetail_resultTmp.put("exp_content",null==outPutResultTmp.get("exp_content")?"":outPutResultTmp.get("exp_content").toString()); //字段扩展
                        feedetail_result.add(feedetail_resultTmp);
                JSONArray ylzResponse = JSONArray.parseArray(ylzMedicalResponse.getValue());
                JSONObject ylzResponseData = null;
                JSONObject ylzResponseOutPut = null;
                JSONObject setlinfo = null;
                if (ylzResponse.size()>0){
                    for (int i=0;i<ylzResponse.size();i++){
                        JSONObject ylzResponse0 = ylzResponse.getJSONObject(i);
                        ylzResponseData = ylzResponse0.getJSONObject("data");
                        ylzResponseOutPut = ylzResponseData.getJSONObject("output");
                        setlinfo =  ylzResponseOutPut.getJSONObject("setlinfo");
                        JSONArray outPutSetldetail = ylzResponseOutPut.getJSONArray("setldetail");
                        JSONArray outPutResult = ylzResponseOutPut.getJSONArray("result");
                        YlzMedicalMxDO medicalMxDO = ylzMedicalMxDOList.get(0);
                        JSONObject insurResultTmp = new JSONObject();
                        insurResultTmp.put("visitNo",ylzMedicalRelationDO.getLogNo().split("_")[0]); //院内挂号号
                        insurResultTmp.put("insurSettleSort",medicalMxDO.getInsurSettleSort()); //医保结算序号
                        insurResultTmp.put("setl_msgid",medicalMxDO.getSetlMsgid()); //发送方报文ID
                        insurResultTmp.put("fee_msgid",medicalMxDO.getFeeMsgid()); //费用上传发送方报文ID
                        insurResultTmp.put("dise_msgid",ylzMedicalIcdDOList.get(0).getDiseMsgid()); //就诊信息上传发送方报文ID
                        insurResultTmp.put("chrg_bchno",medicalMxDO.getChrgBchno());   //收费批次号
                        insurResultTmp.put("insuplc_admdvs",ylzMedicalRelationDO.getRegionCode()); //参保地医保区划【窗口冲销有用】
                        insurResultTmp.put("card_sn",null==ylzMedicalRelationDO.getCardSn()?"":ylzMedicalRelationDO.getCardSn()); //卡识别码
                        insurResultTmp.put("mdtrt_cert_no",ylzMedicalRelationDO.getCardNo()); //就诊凭证编号
                        JSONObject setlinfoEexpContent = JSONObject.parseObject(setlinfo.getString("exp_content"));
                        insurResultTmp.put("fm_acct_balc",null==setlinfoEexpContent.get("fm_acct_balc")?"":setlinfoEexpContent.get("fm_acct_balc").toString()); //家庭共济账户余额
                        insurResultTmp.put("hl_acct_balc",setlinfoEexpContent.get("hl_acct_balc").toString()); //健康账户余额
                        insurResultTmp.put("cvl_acct_balc",setlinfoEexpContent.get("cvl_acct_balc").toString()); //公务员账户余额
                        insurResultTmp.put("acct_used_flag","1"); //个人账户使用标志【窗口目前默认固定1,后续可开放前端选择传入】
                        insurResultTmp.put("mdtrt_id",setlinfo.get("mdtrt_id")); //就诊 ID
                        insurResultTmp.put("setl_id",setlinfo.get("setl_id")); //结算ID
                        insurResultTmp.put("psn_no",setlinfo.get("psn_no")); //人员编号   医保人员基本信息获取接口返回
                        insurResultTmp.put("psn_name",setlinfo.get("psn_name")); //人员姓名
                        insurResultTmp.put("psn_cert_type",setlinfo.get("psn_cert_type")); //人员证件类型
                        insurResultTmp.put("certno",setlinfo.get("certno")); //证件号码
                        insurResultTmp.put("gend",setlinfo.get("gend")); //性别
                        insurResultTmp.put("naty",null==setlinfo.get("naty")?"":setlinfo.get("naty")); //民族
                        insurResultTmp.put("brdy",setlinfo.get("brdy")); //出生日期
                        insurResultTmp.put("age",setlinfo.get("age").toString()); //年龄
                        insurResultTmp.put("insutype",ylzMedicalRelationDO.getInsuranceType()); //险种类型 //医保读卡or结算返回
                        insurResultTmp.put("psn_type",setlinfo.get("psn_type")); //人员类别" //医保结算返回
                        insurResultTmp.put("cvlserv_flag",setlinfo.get("cvlserv_flag")); //公务员标志 //医保结算返回
                        insurResultTmp.put("setl_time", setlinfo.get("setl_time"));    //结算时间
                        insurResultTmp.put("mdtrt_cert_type",setlinfo.get("mdtrt_cert_type"));  //就诊凭证类型 取医保结算返回
                        insurResultTmp.put("med_type",setlinfo.get("med_type")); //医疗类别
                        insurResultTmp.put("medfee_sumamt",setlinfo.get("medfee_sumamt").toString());  //医疗费总额
                        insurResultTmp.put("fulamt_ownpay_amt",setlinfo.get("fulamt_ownpay_amt").toString()); //全自费金额
                        insurResultTmp.put("overlmt_selfpay",setlinfo.get("overlmt_selfpay").toString());  //超限价自费费用
                        insurResultTmp.put("preselfpay_amt",setlinfo.get("preselfpay_amt").toString());   //先行自付金额
                        insurResultTmp.put("inscp_scp_amt",setlinfo.get("inscp_scp_amt").toString());    //符合政策范围金额
                        insurResultTmp.put("act_pay_dedc",setlinfo.get("act_pay_dedc").toString()); //实际支付起付线
                        insurResultTmp.put("hifp_pay",setlinfo.get("hifp_pay").toString()); //基本医疗保险统筹基金支出
                        insurResultTmp.put("pool_prop_selfpay",setlinfo.get("pool_prop_selfpay").toString());    //基本医疗保险统筹基金支付比例
                        insurResultTmp.put("cvlserv_pay",setlinfo.get("cvlserv_pay").toString());  //公务员医疗补助资金支出
                        insurResultTmp.put("hifes_pay",setlinfo.get("hifes_pay").toString());    //企业补充医疗保险基金支出
                        insurResultTmp.put("hifmi_pay",setlinfo.get("hifmi_pay").toString());    //居民大病保险资金支出
                        insurResultTmp.put("hifob_pay",setlinfo.get("hifob_pay").toString());    //职工大额医疗费用补助基金支出
                        insurResultTmp.put("maf_pay",setlinfo.get("maf_pay").toString());  //医疗救助基金支出
                        insurResultTmp.put("oth_pay",setlinfo.get("oth_pay").toString());  //其他支出
                        insurResultTmp.put("fund_pay_sumamt",setlinfo.get("fund_pay_sumamt").toString());  //基金支付总额
                        insurResultTmp.put("psn_part_amt",setlinfo.get("psn_part_amt").toString()); //个人负担总金额
                        insurResultTmp.put("acct_pay",setlinfo.get("acct_pay").toString()); //个人账户支出
                        insurResultTmp.put("psn_cash_pay",setlinfo.get("psn_cash_pay").toString()); //个人现金支出
                        insurResultTmp.put("hosp_part_amt",setlinfo.get("hosp_part_amt").toString());    //医院负担金额
                        insurResultTmp.put("balc",setlinfo.get("balc").toString()); //余额
                        insurResultTmp.put("acct_mulaid_pay",setlinfo.get("acct_mulaid_pay").toString());  //个人账户共济支付金额
                        insurResultTmp.put("medins_setl_id",setlinfo.get("medins_setl_id"));   //医药机构结算ID(应跟setl_msgid值一致)
                        insurResultTmp.put("clr_optins",setlinfo.get("clr_optins"));   //清算经办机构
                        insurResultTmp.put("clr_way",setlinfo.get("clr_way"));  //清算方式
                        insurResultTmp.put("clr_type",setlinfo.get("clr_type")); //清算类别
                        insurResultTmp.put("hifdm_pay",setlinfo.get("hifdm_pay").toString());    //伤残人员医疗保障基金支出
                        insurResultTmp.put("exp_content",setlinfo.get("exp_content"));
                        JSONArray setldetail  = new JSONArray();
                        for (int j=0;j<outPutSetldetail.size();j++){
                            JSONObject outPutSetldetailTmp = outPutSetldetail.getJSONObject(j);
                            JSONObject setldetailTmp = new JSONObject();
                            setldetailTmp.put("fund_pay_type",null==outPutSetldetailTmp.get("fund_pay_type")?"":outPutSetldetailTmp.get("fund_pay_type").toString());  //基金支付类型
                            setldetailTmp.put("inscp_scp_amt",null==outPutSetldetailTmp.get("inscp_scp_amt")?"0":outPutSetldetailTmp.get("inscp_scp_amt").toString());  //符合政策范围金额
                            setldetailTmp.put("crt_payb_lmt_amt",null==outPutSetldetailTmp.get("crt_payb_lmt_amt")?"0":outPutSetldetailTmp.get("crt_payb_lmt_amt").toString());   //本次可支付限额金额
                            setldetailTmp.put("fund_payamt",null==outPutSetldetailTmp.get("fund_payamt")?"0":outPutSetldetailTmp.get("fund_payamt").toString());    //基金支付金额
                            setldetailTmp.put("fund_pay_type_name",null==outPutSetldetailTmp.get("fund_pay_type_name")?"":outPutSetldetailTmp.get("fund_pay_type_name").toString()); //基金支付类型名称
                            setldetailTmp.put("setl_proc_info",null==outPutSetldetailTmp.get("setl_proc_info")?"":outPutSetldetailTmp.get("setl_proc_info").toString()); //结算过程信息
                            setldetail.add(setldetailTmp);
                        }
                        JSONArray fpdetail  = new JSONArray();
                        JSONArray fplists =  setlinfoEexpContent.getJSONArray("fplist");
                        for (int j=0;j<fplists.size();j++){
                            JSONObject fplistTmp = fplists.getJSONObject(j);
                            JSONObject fpdetailTmp  = new JSONObject();
                            fpdetailTmp.put("chrgitmType",null==fplistTmp.get("medChrgitmType")?"":fplistTmp.get("medChrgitmType").toString()); //发票项目类别
                            fpdetailTmp.put("chrgitmTypeName",null==fplistTmp.get("medChrgitmName")?"":fplistTmp.get("medChrgitmName").toString());  //发票项目类别名称
                            fpdetailTmp.put("itemSumamt",null==fplistTmp.get("itemSumamt")?"0":fplistTmp.get("itemSumamt").toString());   //发票项目费用
                            fpdetailTmp.put("itemClaaAmt",null==fplistTmp.get("itemClaaAmt")?"0":fplistTmp.get("itemClaaAmt").toString());  //医保发票费用
                            fpdetailTmp.put("itemClabAmt",null==fplistTmp.get("itemClabAmt")?"0":fplistTmp.get("itemClabAmt").toString());  //医保个人费用
                            fpdetailTmp.put("itemOthAmt",null==fplistTmp.get("itemOthAmt")?"0":fplistTmp.get("itemOthAmt").toString());   //特殊项目发票费用
                            fpdetailTmp.put("itemOwnpayAmt",null==fplistTmp.get("itemOwnpayAmt")?"0":fplistTmp.get("itemOwnpayAmt").toString());    //非医保发票费用
                            fpdetail.add(fpdetailTmp);
                        }
                        JSONArray feedetail_result  = new JSONArray();
                        for (int j=0;j<outPutResult.size();j++){
                            JSONObject outPutResultTmp = outPutResult.getJSONObject(j);
                            JSONObject feedetail_resultTmp  = new JSONObject();
                            feedetail_resultTmp.put("feedetl_sn",null==outPutResultTmp.get("feedetl_sn")?"":outPutResultTmp.get("feedetl_sn").toString());   // 费用明细流水
                            feedetail_resultTmp.put("det_item_fee_sumamt",null==outPutResultTmp.get("det_item_fee_sumamt")?"":outPutResultTmp.get("det_item_fee_sumamt").toString()); //明细项目费用总额
                            feedetail_resultTmp.put("cnt",null==outPutResultTmp.get("cnt")?"":outPutResultTmp.get("cnt").toString()); //数量
                            feedetail_resultTmp.put("pric",null==outPutResultTmp.get("pric")?"":outPutResultTmp.get("pric").toString()); //单价
                            feedetail_resultTmp.put("pric_uplmt_amt",null==outPutResultTmp.get("pric_uplmt_amt")?"":outPutResultTmp.get("pric_uplmt_amt").toString()); //定价上限金额
                            feedetail_resultTmp.put("selfpay_prop",null==outPutResultTmp.get("selfpay_prop")?"":outPutResultTmp.get("selfpay_prop").toString()); //自付比例
                            feedetail_resultTmp.put("fulamt_ownpay_amt",null==outPutResultTmp.get("fulamt_ownpay_amt")?"":outPutResultTmp.get("fulamt_ownpay_amt").toString()); //全自费金额
                            feedetail_resultTmp.put("overlmt_amt",null==outPutResultTmp.get("overlmt_amt")?"":outPutResultTmp.get("overlmt_amt").toString()); //超限价金额
                            feedetail_resultTmp.put("preselfpay_amt",null==outPutResultTmp.get("preselfpay_amt")?"":outPutResultTmp.get("preselfpay_amt").toString()); //先行自付金额
                            feedetail_resultTmp.put("inscp_scp_amt",null==outPutResultTmp.get("inscp_scp_amt")?"":outPutResultTmp.get("inscp_scp_amt").toString()); //符合政策范围金额
                            feedetail_resultTmp.put("chrgitm_lv",null==outPutResultTmp.get("chrgitm_lv")?"":outPutResultTmp.get("chrgitm_lv").toString()); //收费项目等级
                            feedetail_resultTmp.put("med_chrgitm_type",null==outPutResultTmp.get("med_chrgitm_type")?"":outPutResultTmp.get("med_chrgitm_type").toString()); //医疗收费项目类别
                            feedetail_resultTmp.put("bas_medn_flag",null==outPutResultTmp.get("bas_medn_flag")?"":outPutResultTmp.get("bas_medn_flag").toString()); //基本药物标志
                            feedetail_resultTmp.put("hi_nego_drug_flag",null==outPutResultTmp.get("hi_nego_drug_flag")?"":outPutResultTmp.get("hi_nego_drug_flag").toString()); //医保谈判药品标志
                            feedetail_resultTmp.put("chld_medc_flag",null==outPutResultTmp.get("chld_medc_flag")?"":outPutResultTmp.get("chld_medc_flag").toString()); //儿童用药标志
                            feedetail_resultTmp.put("list_sp_item_flag",null==outPutResultTmp.get("list_sp_item_flag")?"":outPutResultTmp.get("list_sp_item_flag").toString()); //目录特项标志
                            feedetail_resultTmp.put("lmt_used_flag",null==outPutResultTmp.get("lmt_used_flag")?"":outPutResultTmp.get("lmt_used_flag").toString()); //限制使用标志
                            feedetail_resultTmp.put("drt_reim_flag",null==outPutResultTmp.get("drt_reim_flag")?"":outPutResultTmp.get("drt_reim_flag").toString()); //直报标志
                            feedetail_resultTmp.put("memo",null==outPutResultTmp.get("memo")?"":outPutResultTmp.get("memo").toString()); //备注
                            feedetail_resultTmp.put("exp_content",null==outPutResultTmp.get("exp_content")?"":outPutResultTmp.get("exp_content").toString()); //字段扩展
                            feedetail_result.add(feedetail_resultTmp);
                        }
                        insurResultTmp.put("setldetail",setldetail);//直接取医保的返回值
                        insurResultTmp.put("fpdetail",fpdetail);
                        insurResultTmp.put("feedetail_result",feedetail_result);
                        insurResult.add(insurResultTmp);
                    }
                    insurResultTmp.put("setldetail",setldetail);//直接取医保的返回值
                    insurResultTmp.put("fpdetail",fpdetail);
                    insurResultTmp.put("feedetail_result",feedetail_result);
                    insurResult.add(insurResultTmp);
                }
                msgBody.put("insurResult",insurResult);
                JSONObject insurVisitTmp = new JSONObject();
                insurVisitTmp.put("visit_msgid",ylzMedicalRelationDO.getVisitMsgid());//发送方报文ID"
                insurVisitTmp.put("insuplc_admdvs",ylzMedicalRelationDO.getRegionCode());//参保地医保区划【窗口冲销有用】
                insurVisitTmp.put("insutype",ylzMedicalRelationDO.getInsuranceType());//医保读卡返回
                insurVisitTmp.put("mdtrt_id",ylzMedicalRelationDO.getHisSerial());//就诊ID  医保挂号接口返回
                insurVisitTmp.put("psn_no",ylzMedicalRelationDO.getPsnNo());//人员编号   医保人员基本信息获取接口返回
                insurVisitTmp.put("ipt_otp_no",ylzMedicalRelationDO.getLogNo().split("_")[0]);//门诊号
                insurVisitTmp.put("exp_content","");//字段扩展【应需要解决转义字符反斜杠被过滤问题,否则要将里面的扩展节点独立字段出
                insurVisitInfo.add(insurVisitTmp);
            }
        }
        JSONObject insurVisitTmp = new JSONObject();
        insurVisitTmp.put("visit_msgid",ylzMedicalRelationDO.getVisitMsgid());//发送方报文ID"
        insurVisitTmp.put("insuplc_admdvs",ylzMedicalRelationDO.getRegionCode());//参保地医保区划【窗口冲销有用】
        insurVisitTmp.put("insutype",ylzMedicalRelationDO.getInsuranceType());//医保读卡返回
        insurVisitTmp.put("mdtrt_id",ylzMedicalRelationDO.getHisSerial());//就诊ID  医保挂号接口返回
        insurVisitTmp.put("psn_no",ylzMedicalRelationDO.getPsnNo());//人员编号   医保人员基本信息获取接口返回
        insurVisitTmp.put("ipt_otp_no",ylzMedicalRelationDO.getLogNo().split("_")[0]);//门诊号
        insurVisitTmp.put("exp_content","");//字段扩展【应需要解决转义字符反斜杠被过滤问题,否则要将里面的扩展节点独立字段出
        sql = " select dict_code,dict_value from wlyy_hospital_sys_dict where dict_name='insurVisitInfo' ";
        AnalogFlags = jdbcTemplate.queryForList(sql);
        AnalogFlag = "0";
        if (AnalogFlags.size()>0){
            AnalogFlag = AnalogFlags.get(0).get("dict_code").toString();
        }
        if ("1".equals(AnalogFlag)) {//获取调式模拟数据
        }else {
            insurVisitInfo.add(insurVisitTmp);
        }
        msgBody.put("insurResult",insurResult);
        msgBody.put("insurVisitInfo",insurVisitInfo);
        Map<String,String> param = new HashMap<>();
        param.put("interfaceStr","executeSickSettleMultiNew");//接口方法
        param.put("orgCode",ylzMedicalRelationDO.getOrgCode());
        param.put("orgCode",orgCode);
        param.put("msgBody",msgBody.toJSONString());
        JSONObject re = null;
        if ("jwtest".equals(springProfiles)){
@ -389,8 +389,11 @@ public class JwService {
            JSONObject responseDataTmp = re.getJSONObject("data");
            String codeTMP = responseDataTmp.getString("CODE");//智业返回值 0失败 1成功
            if (codeTMP.equalsIgnoreCase("1")) {
                ylzMedicalRelationDO.setState(1);
                ylzMedicailRelationDao.save(ylzMedicalRelationDO);
                for (String recipe_no:recipe_nos.split(",")){
                    YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByLog_no(recipe_no);
                    ylzMedicalRelationDO.setState(1);
                    ylzMedicailRelationDao.save(ylzMedicalRelationDO);
                }
                return true;
            }else {
                throw new Exception("结算失败"+responseDataTmp.getString("MESSAGE"));

+ 21 - 41
svr/svr-base/src/main/java/com/yihu/jw/base/service/a3service/MedOrderService.java

@ -1087,7 +1087,8 @@ public class MedOrderService {
    }
    /**
     * 预缴金支付
     * 院内确认结算,
     * 者待结算订单需要一次性结清,一次性进行院内结算
     * @param
     * @return
     */
@ -1102,31 +1103,16 @@ public class MedOrderService {
        String orgCode = "";
        String idcard = "";
        String patientName = "";
        Set<String> settledErrors = new HashSet<>();//结算失败订单
        List<String> chargeSettle = new ArrayList<>();//预交金关联订单
        for (String recipe_no:recipeNos){
            YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByLog_no(recipe_no);
            if (null==ylzMedicalRelationDO){
                continue;
                throw new Exception("未查询到医保结算信息");
            }
            cardNo = ylzMedicalRelationDO.getCardNo();
            orgCode = ylzMedicalRelationDO.getOrgCode();
            BigDecimal personCashTmp =  new BigDecimal(ylzMedicalRelationDO.getPersonCash());//10.35
            BigDecimal personCashTmp =  new BigDecimal(ylzMedicalRelationDO.getPersonCash());
            personCash =  personCash.add(personCashTmp);//个人现金支付
            if (0==personCashTmp.doubleValue()){//费用为0
                try {
                  if (!jwService.executeSickSettleMultiNew(recipe_no,equ_num)){
                      chargeSettle.add(recipe_no);
                  }
                }catch (Exception e){
                    e.printStackTrace();
                    chargeSettle.add(recipe_no);
                    settledErrors.add(recipe_no);
                }
            }
            if (personCashTmp.doubleValue()>0){
                chargeSettle.add(recipe_no);
            }
        }
        //获取预缴金余额
        String balance =null;
@ -1152,30 +1138,22 @@ public class MedOrderService {
            String needPayAmountStr =amountDf.format(needPayAmount);//医保支付下,sumCost=0 当作自费号处理
            result.put("settleFlag",false);
            result.put("payUrl",ylzService.hlwyyRecharge(orgCode,equ_num,cardNo,
                    depositType,needPayAmountStr,idcard,patientName,returnUrl,chargeSettle.stream().map(String::valueOf).collect(Collectors.joining(","))));
                    depositType,needPayAmountStr,idcard,patientName,returnUrl,recipe_nos));
            result.put("needPay",true);
            return result;
        }
        else{
            for (String recipe_no:chargeSettle){
                try {
                    if (jwService.executeSickSettleMultiNew(recipe_no,equ_num)){
                        if (settledErrors.contains(recipe_no)){
                            settledErrors.remove(recipe_no);
                        }
                    }else {
                        settledErrors.add(recipe_no);
                    }
                }catch (Exception e){
                    e.printStackTrace();
            try {
                if (jwService.executeSickSettleMultiNew(recipe_nos,equ_num)){
                }
            }catch (Exception e){
                e.printStackTrace();
                throw new Exception(e.getMessage());
            }
            result.put("settleFlag",true);
            result.put("payUrl","");
            result.put("needPay",false);
            if(settledErrors.size()>0){
                result.put("errorMsg","以下处方订单结算失败,请联系管理员处理! 处方号:"+settledErrors.stream().map(String::valueOf).collect(Collectors.joining("、")));
            }
            return result;
        }
@ -1214,7 +1192,7 @@ public class MedOrderService {
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    public boolean executeSickSettleMultiNew(String recipe_no,String equ_num) throws Exception {
    public boolean executeSickSettleMultiNew(String recipe_nos,String equ_num) throws Exception {
        String   sql = " select dict_code,dict_value from wlyy_hospital_sys_dict where dict_name='his_settlement' ";
        List<Map<String,Object>> AnalogFlags = jdbcTemplate.queryForList(sql);
        String AnalogFlag = "0";
@ -1222,15 +1200,17 @@ public class MedOrderService {
            AnalogFlag = AnalogFlags.get(0).get("dict_code").toString();
        }
        if ("1".equals(AnalogFlag)) {//获取调式模拟数据
            YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByLog_no(recipe_no);
            if(null==ylzMedicalRelationDO){
                throw new Exception("未找到待结算订单");
            for (String recipe_no:recipe_nos.split(",")){
                YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByLog_no(recipe_no);
                if(null==ylzMedicalRelationDO){
                    throw new Exception("未找到待结算订单");
                }
                ylzMedicalRelationDO.setState(1);
                ylzMedicailRelationDao.save(ylzMedicalRelationDO);
            }
            ylzMedicalRelationDO.setState(1);
            ylzMedicailRelationDao.save(ylzMedicalRelationDO);
            return true;
        }
        return jwService.executeSickSettleMultiNew(recipe_no,equ_num);
        return jwService.executeSickSettleMultiNew(recipe_nos,equ_num);
    }
    /**

+ 1 - 4
svr/svr-base/src/main/java/com/yihu/jw/base/service/a3service/YlzService.java

@ -323,11 +323,8 @@ public class YlzService {
                                medicineServive.sendSocketMessage(ylzMedicalRecharge.getEquNum()+"_T","medical_recharge", URLEncoder.encode(chargeNotice.toJSONString(),"UTF-8"));
                                String recipeNoStr = ylzMedicalRecharge.getValue();
                                if (StringUtils.isNoneBlank(recipeNoStr)){//关联处方号
                                    String[] recipeNos = recipeNoStr.split(",");
                                    try {
                                        for (String recipeNo:recipeNos){
                                            medOrderService.executeSickSettleMultiNew(recipeNo,ylzMedicalRecharge.getEquNum());
                                        }
                                        medOrderService.executeSickSettleMultiNew(recipeNoStr,ylzMedicalRecharge.getEquNum());
                                    }catch (Exception e){
                                        e.printStackTrace();
                                    }