wangzhinan 1 місяць тому
батько
коміт
d274d87783

+ 3 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/healthCare/YlzMedicailRelationDao.java

@ -18,6 +18,9 @@ public interface YlzMedicailRelationDao extends PagingAndSortingRepository<YlzMe
    @Query("from YlzMedicalRelationDO a where   a.relationCode = ?1 and a.state=0 ")
    YlzMedicalRelationDO findByOutpatient(String outpatientId);
    @Query("from YlzMedicalRelationDO a where   a.relationCode = ?1 and a.logNo = ?2 and a.state=0 ")
    YlzMedicalRelationDO findByOutpatientAndlogNo(String outpatientId,String logNo);
    @Query("from YlzMedicalRelationDO a where   a.relationCode = ?1 and a.state=1 ")
    List<YlzMedicalRelationDO> findByOutpatientStatus(String outpatientId);

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

@ -3439,7 +3439,6 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
     * @param jsonData
     * @param doctorMappingDO
     * @param outpatientDO
     * @param info
     * @param Icd10
     */
    public void setIcd10JsonParam(com.alibaba.fastjson.JSONArray jsonData, DoctorMappingDO doctorMappingDO, WlyyOutpatientDO outpatientDO,  String Icd10) {
@ -14868,6 +14867,23 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        }
    }
    /**
     * 获取待结算列表
     * @param outpatientId
     * @param flag
     * @return
     * @throws Exception
     */
    public List<YlzMedicalRelationDO> getSettleList(String outpatientId,Integer flag) throws Exception {
        WlyyOutpatientDO outpatientDO = outpatientDao.findById(outpatientId);
        if(outpatientDO==null){
            throw new Exception("门诊信息为空");
        }
        return entranceService.getSettleList(outpatientDO.getCardNo(),outpatientDO.getIdcard(),outpatientDO.getId());
    }
    /**
     * 获取患者待结算信息页面
@ -14875,7 +14891,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
     * @return
     * @throws Exception
     */
    public com.alibaba.fastjson.JSONObject getSettlementInfo(String outpatientId,Integer flag) throws Exception {
    public com.alibaba.fastjson.JSONObject getSettlementInfo(String outpatientId,String realOrder,Integer flag) throws Exception {
        logger.info("获取患者待结算信息开始!");
        WlyyOutpatientDO outpatientDO = outpatientDao.findById(outpatientId);
        if(outpatientDO==null){
@ -15220,7 +15236,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            com.alibaba.fastjson.JSONObject object = new com.alibaba.fastjson.JSONObject();
            logger.info("获取患者待结算信息开始!");
            YlzMedicalRelationDO ylzMedicalRelationDO = new YlzMedicalRelationDO();
            ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(outpatientId);
            ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatientAndlogNo(outpatientId,realOrder);
            if (ylzMedicalRelationDO!=null&&StringUtils.isNoneBlank(ylzMedicalRelationDO.getPageCode())){
                String result = confirmSettlementInfo(outpatientId,ylzMedicalRelationDO.getPageCode());
                com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject.parseObject(result);
@ -15302,7 +15318,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                object.put("getSettleInfo",ylzMedicalRelationDO);
                return object;
            }
            ylzMedicalRelationDO = entranceService.getSettleInfo(outpatientDO.getCardNo(),outpatientDO.getIdcard(),outpatientDO.getId());
            ylzMedicalRelationDO = entranceService.getSettleInfo(outpatientDO.getCardNo(),outpatientDO.getIdcard(),outpatientDO.getId(),realOrder);
            if (ylzMedicalRelationDO==null){
                throw new Exception("无待结算信息");
            }
@ -15427,17 +15443,17 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
     * @return
     * @throws Exception
     */
    public String confirmSettlementService(String outpatientId) throws Exception {
    public String confirmSettlementService(String outpatientId,String realOrder) throws Exception {
        WlyyOutpatientDO outpatientDO = outpatientDao.findById(outpatientId);
        if (outpatientDO==null){
            throw new Exception("未找到待结算记录");
        }
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(outpatientId);
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatientAndlogNo(outpatientId,realOrder);
        if (ylzMedicalRelationDO.getState()!=null&&ylzMedicalRelationDO.getState()==1){
            return "已结算";
        }
        //用医保结算直接调用确认结算
        confirmSettlement(outpatientId);
        confirmSettlement(outpatientId,realOrder);
        return "结算成功";
    }
@ -15448,12 +15464,12 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
     * @return
     * @throws Exception
     */
    public String confirmSettlement(String outpatientId) throws Exception {
    public String confirmSettlement(String outpatientId,String realOrder) throws Exception {
        WlyyOutpatientDO outpatientDO = outpatientDao.findById(outpatientId);
        if (outpatientDO==null){
            throw new Exception("未找到待结算记录");
        }
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(outpatientId);
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatientAndlogNo(outpatientId,realOrder);
        PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(outpatientDO.getPatient());
        BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(ylzMedicalRelationDO.getId());
        String depositType = "";
@ -15562,8 +15578,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                    }
                }
                logger.info("变更医保结算状态成功");
                String realOrder = msgInfoJson.getString("xtgzh0");
                List<WlyyPrescriptionDO> wlyyPrescriptionDOS = prescriptionDao.findByRealOrderAndStatusList(realOrder);
                String realOrder1 = msgInfoJson.getString("xtgzh0");
                List<WlyyPrescriptionDO> wlyyPrescriptionDOS = prescriptionDao.findByRealOrderAndStatusList(realOrder1);
                WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(ylzMedicalRelationDO.getRelationCode());
                String title = "";
                if (wlyyOutpatientDO.getHisStatus()==null){
@ -15605,7 +15621,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                    Double medicarePrice = Double.parseDouble(ylzMedicalRelationDO.getMedicalPrice())+Double.parseDouble(ylzMedicalRelationDO.getPersonAccount());
                    try{
                        String pushPayLog =  payInfoNoticeService.pushPrescriptionPayMedicare(wlyyOutpatientDO.getConsumer(),prescriptionDO.getDoctorName(),prescriptionDO.getRealOrder(),prescriptionDO.getOutpatientId(),prescriptionDO.getId(),fee,medicarePrice+"",ylzMedicalRelationDO.getPersonCash(),title,null);
                        logger.info("处方结算成功"+pushPayLog+"====="+realOrder);
                        logger.info("处方结算成功"+pushPayLog+"====="+realOrder1);
                    }catch (Exception e){
                        e.printStackTrace();
                    }
@ -15623,7 +15639,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                }
                logger.info("电子发票开具开始");
                try {
                    entranceService.dzpjServer(patientMappingDO.getMappingCode(),realOrder);
                    entranceService.dzpjServer(patientMappingDO.getMappingCode(),realOrder1);
                }catch (Exception e){
                    e.printStackTrace();
                }

+ 997 - 268
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/EntranceService.java

@ -3616,159 +3616,121 @@ public class EntranceService {
        return ConvertUtil.convertListEnvelop(resp);
    }
    public YlzMedicalRelationDO getSettleInfo(String cardno,String idcard,String outpatientId) throws Exception {
    public List<YlzMedicalRelationDO> getSettleList(String cardno,String idcard,String outpatientId) throws Exception {
        List<YlzMedicalRelationDO>  relationDOList = new ArrayList<>();
        WlyyOutpatientDO outpatientDO = outpatientDao.findById(outpatientId);
        net.sf.json.JSONObject object1 = qutpatientBalance(outpatientDO.getCardNo(), false);
        Double cardFee = object1.getDouble("ZHYE");
/*        Double cardFee = 0.0;*/
        net.sf.json.JSONArray result = BS10108(cardno,idcard,"1",null,null,null,outpatientDO.getRegisterNo(),false);
        if (result!=null&&result.size()!=0){
            net.sf.json.JSONObject object = result.getJSONObject(0);
            net.sf.json.JSONObject jsonObject = object.getJSONObject("retInfo");
            if (jsonObject.getString("retCode").equalsIgnoreCase("00")){
                net.sf.json.JSONObject msgInfoJson = object.getJSONObject("msgInfo");
                if (msgInfoJson!=null){
                    net.sf.json.JSONObject resultJSON = msgInfoJson.getJSONObject("receipt");
                    if (resultJSON!=null){
                        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByLog_no(resultJSON.getString("xtgzh0"));
                        List<WlyyPrescriptionDO> prescriptionDOList = prescriptionDao.findByRealOrderAndStatusList(resultJSON.getString("xtgzh0"));
                        String diseaseCode = "";
                        if (prescriptionDOList!=null&&prescriptionDOList.size()!=0){
                            diseaseCode= prescriptionDOList.get(0).getDiseaseCode();
                        }
                        List<YlzMedicalIcdDO> icdDOList = new ArrayList<>();
                        List<YlzMedicalMxDO> mxDOList = new ArrayList<>();
                        if (ylzMedicalRelationDO==null){
                            ylzMedicalRelationDO = new YlzMedicalRelationDO();
                            ylzMedicalRelationDO.setLogNo(resultJSON.getString("xtgzh0"));
                            ylzMedicalRelationDO.setOrgCode("3502000303");
                            ylzMedicalRelationDO.setRegionCode("350200");
                            ylzMedicalRelationDO.setIdcard(outpatientDO.getIdcard());
                            ylzMedicalRelationDO.setName(resultJSON.getString("xming0"));
                            ylzMedicalRelationDO.setCertType("01");
                            ylzMedicalRelationDO.setMedicalMode("10");
                            if (StringUtils.isNoneBlank(outpatientDO.getDiseaseCode())){
                                ylzMedicalRelationDO.setMedicalType("13");
                            }else {
                                ylzMedicalRelationDO.setMedicalType("11");
                            }
                            ylzMedicalRelationDO.setCardNo(cardno);
                            ylzMedicalRelationDO.setHisSerial(outpatientDO.getRegisterNo());
                            ylzMedicalRelationDO.setHisSettleNo(resultJSON.getString("xtgzh0"));
                            ylzMedicalRelationDO.setDeptCode(resultJSON.getString("ksbm00"));
                            ylzMedicalRelationDO.setDeptName(resultJSON.getString("ghksmc"));
                            ylzMedicalRelationDO.setHisDeptCode(resultJSON.getString("ksbm00"));
                            ylzMedicalRelationDO.setHisDeptName(resultJSON.getString("ghksmc"));
                            ylzMedicalRelationDO.setEmergencySign("0");
                            ylzMedicalRelationDO.setTraumaSign("0");
                            ylzMedicalRelationDO.setDate(outpatientDO.getRegisterDate());
                            ylzMedicalRelationDO.setItemCount(resultJSON.getString("cfxms0"));
                            ylzMedicalRelationDO.setTotalAmount(resultJSON.getString("bcfyze"));
                            ylzMedicalRelationDO.setPreCharges(resultJSON.getString("bcfyze"));
                            ylzMedicalRelationDO.setBcwkje(resultJSON.getString("bcwkje"));
                            ylzMedicalRelationDO.setPersonAccount("0");
                            ylzMedicalRelationDO.setDataSource("53");
                            ylzMedicalRelationDO.setBalance(cardFee+"");
                            ylzMedicalRelationDO.setDiseaseCode(diseaseCode);
                            ylzMedicalRelationDO.setPreCount(resultJSON.getString("cfxms0"));
                            BaseDoctorDO baseDoctorDO = baseDoctorDao.findById(outpatientDO.getDoctor());
                            if (baseDoctorDO!=null){
                                String jobTitle = baseDoctorDO.getJobTitleCode();
                Object obj = com.alibaba.fastjson.JSON.parse(object.getString("msgInfo"));
                if (obj instanceof JSONObject){
                    net.sf.json.JSONObject msgInfoJson = object.getJSONObject("msgInfo");
                    if (msgInfoJson!=null){
                        net.sf.json.JSONObject resultJSON = msgInfoJson.getJSONObject("receipt");
                        if (resultJSON!=null){
                            YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByLog_no(resultJSON.getString("xtgzh0"));
                            List<WlyyPrescriptionDO> prescriptionDOList = prescriptionDao.findByRealOrderAndStatusList(resultJSON.getString("xtgzh0"));
                            String diseaseCode = "";
                            if (prescriptionDOList!=null&&prescriptionDOList.size()!=0){
                                diseaseCode= prescriptionDOList.get(0).getDiseaseCode();
                            }
                            ylzMedicalRelationDO.setDoctorLevel("02");
                            ylzMedicalRelationDO.setDel(1);
                            ylzMedicalRelationDO.setStatus(0);
                            ylzMedicalRelationDO.setState(0);
                            ylzMedicalRelationDO.setRelationCode(outpatientDO.getId());
                            ylzMedicalRelationDO.setCreateTime(new Date());
                            ylzMedicalRelationDO.setMedicalPrice("0");
                            if (outpatientDO.getMedicalState()==null){
                                ylzMedicalRelationDO.setMedicalState(0);
                                ylzMedicalRelationDO.setPersonCash(resultJSON.getString("bcfyze"));
                            }else {
                                if (outpatientDO.getMedicalState().equalsIgnoreCase("0")){
                            List<YlzMedicalIcdDO> icdDOList = new ArrayList<>();
                            List<YlzMedicalMxDO> mxDOList = new ArrayList<>();
                            if (ylzMedicalRelationDO==null){
                                ylzMedicalRelationDO = new YlzMedicalRelationDO();
                                ylzMedicalRelationDO.setLogNo(resultJSON.getString("xtgzh0"));
                                ylzMedicalRelationDO.setOrgCode("3502000303");
                                ylzMedicalRelationDO.setRegionCode("350200");
                                ylzMedicalRelationDO.setIdcard(outpatientDO.getIdcard());
                                ylzMedicalRelationDO.setName(resultJSON.getString("xming0"));
                                ylzMedicalRelationDO.setCertType("01");
                                ylzMedicalRelationDO.setMedicalMode("10");
                                if (StringUtils.isNoneBlank(outpatientDO.getDiseaseCode())){
                                    ylzMedicalRelationDO.setMedicalType("13");
                                }else {
                                    ylzMedicalRelationDO.setMedicalType("11");
                                }
                                ylzMedicalRelationDO.setCardNo(cardno);
                                ylzMedicalRelationDO.setHisSerial(outpatientDO.getRegisterNo());
                                ylzMedicalRelationDO.setHisSettleNo(resultJSON.getString("xtgzh0"));
                                ylzMedicalRelationDO.setDeptCode(resultJSON.getString("ksbm00"));
                                ylzMedicalRelationDO.setDeptName(resultJSON.getString("ghksmc"));
                                ylzMedicalRelationDO.setHisDeptCode(resultJSON.getString("ksbm00"));
                                ylzMedicalRelationDO.setHisDeptName(resultJSON.getString("ghksmc"));
                                ylzMedicalRelationDO.setEmergencySign("0");
                                ylzMedicalRelationDO.setTraumaSign("0");
                                ylzMedicalRelationDO.setDate(outpatientDO.getRegisterDate());
                                ylzMedicalRelationDO.setItemCount(resultJSON.getString("cfxms0"));
                                ylzMedicalRelationDO.setTotalAmount(resultJSON.getString("bcfyze"));
                                ylzMedicalRelationDO.setPreCharges(resultJSON.getString("bcfyze"));
                                ylzMedicalRelationDO.setBcwkje(resultJSON.getString("bcwkje"));
                                ylzMedicalRelationDO.setPersonAccount("0");
                                ylzMedicalRelationDO.setDataSource("53");
                                ylzMedicalRelationDO.setBalance(cardFee+"");
                                ylzMedicalRelationDO.setDiseaseCode(diseaseCode);
                                ylzMedicalRelationDO.setPreCount(resultJSON.getString("cfxms0"));
                                BaseDoctorDO baseDoctorDO = baseDoctorDao.findById(outpatientDO.getDoctor());
                                if (baseDoctorDO!=null){
                                    String jobTitle = baseDoctorDO.getJobTitleCode();
                                }
                                ylzMedicalRelationDO.setDoctorLevel("02");
                                ylzMedicalRelationDO.setDel(1);
                                ylzMedicalRelationDO.setStatus(0);
                                ylzMedicalRelationDO.setState(0);
                                ylzMedicalRelationDO.setRelationCode(outpatientDO.getId());
                                ylzMedicalRelationDO.setCreateTime(new Date());
                                ylzMedicalRelationDO.setMedicalPrice("0");
                                if (outpatientDO.getMedicalState()==null){
                                    ylzMedicalRelationDO.setMedicalState(0);
                                    ylzMedicalRelationDO.setPersonCash(resultJSON.getString("bcfyze"));
                                }else {
                                    if (outpatientDO.getMedicalState().equalsIgnoreCase("0")){
                                        ylzMedicalRelationDO.setPersonCash(resultJSON.getString("bcfyze"));
                                    }
                                    ylzMedicalRelationDO.setMedicalState(Integer.parseInt(outpatientDO.getMedicalState()));
                                }
                                ylzMedicalRelationDO.setMedicalState(Integer.parseInt(outpatientDO.getMedicalState()));
                            }
                            ylzMedicalRelationDO = ylzMedicailRelationDao.save(ylzMedicalRelationDO);
                            if (resultJSON.get("zdlists")!=null){
                                Object json = new JSONTokener(resultJSON.getString("zdlists")).nextValue();
                                if(json instanceof net.sf.json.JSONObject){
                                    net.sf.json.JSONObject icdJSON = (net.sf.json.JSONObject)json;
                                    net.sf.json.JSONObject icdJson = icdJSON.getJSONObject("zdlist");
                                    YlzMedicalIcdDO ylzMedicalIcdDO = new YlzMedicalIcdDO();
                                    ylzMedicalIcdDO.setMedicalId(ylzMedicalRelationDO.getId());
                                    ylzMedicalIcdDO.setDel(1);
                                    ylzMedicalIcdDO.setCreateTime(new Date());
                                    ylzMedicalIcdDO.setDiseaseType(icdJson.getString("zdlx"));
                                    ylzMedicalIcdDO.setDiseaseCodeIcd10(icdJson.getString("zdbm"));
                                    ylzMedicalIcdDO.setDiseaseNameIcd10(icdJson.getString("zdmc"));
                                    ylzMedicalIcdDO.setDiseaseOrder(icdJson.getString("zdxh"));
                                    ylzMedicalIcdDO = ylzMedicailIcdDao.save(ylzMedicalIcdDO);
                                    icdDOList.add(ylzMedicalIcdDO);
                                } else if (json instanceof JSONArray) {
                                    JSONArray icdArray = (JSONArray)json;
                                    for (int k=0;k<icdArray.size();k++) {
                                        net.sf.json.JSONObject icdObject = icdArray.getJSONObject(k);
                                ylzMedicalRelationDO = ylzMedicailRelationDao.save(ylzMedicalRelationDO);
                                if (resultJSON.get("zdlists")!=null){
                                    Object json = new JSONTokener(resultJSON.getString("zdlists")).nextValue();
                                    if(json instanceof net.sf.json.JSONObject){
                                        net.sf.json.JSONObject icdJSON = (net.sf.json.JSONObject)json;
                                        net.sf.json.JSONObject icdJson = icdJSON.getJSONObject("zdlist");
                                        YlzMedicalIcdDO ylzMedicalIcdDO = new YlzMedicalIcdDO();
                                        ylzMedicalIcdDO.setMedicalId(ylzMedicalRelationDO.getId());
                                        ylzMedicalIcdDO.setDel(1);
                                        ylzMedicalIcdDO.setCreateTime(new Date());
                                        ylzMedicalIcdDO.setDiseaseType(icdObject.getString("zdlx"));
                                        ylzMedicalIcdDO.setDiseaseCodeIcd10(icdObject.getString("zdbm"));
                                        ylzMedicalIcdDO.setDiseaseNameIcd10(icdObject.getString("zdmc"));
                                        ylzMedicalIcdDO.setDiseaseOrder(icdObject.getString("zdxh"));
                                        ylzMedicalIcdDO.setDiseaseType(icdJson.getString("zdlx"));
                                        ylzMedicalIcdDO.setDiseaseCodeIcd10(icdJson.getString("zdbm"));
                                        ylzMedicalIcdDO.setDiseaseNameIcd10(icdJson.getString("zdmc"));
                                        ylzMedicalIcdDO.setDiseaseOrder(icdJson.getString("zdxh"));
                                        ylzMedicalIcdDO = ylzMedicailIcdDao.save(ylzMedicalIcdDO);
                                        icdDOList.add(ylzMedicalIcdDO);
                                    } else if (json instanceof JSONArray) {
                                        JSONArray icdArray = (JSONArray)json;
                                        for (int k=0;k<icdArray.size();k++) {
                                            net.sf.json.JSONObject icdObject = icdArray.getJSONObject(k);
                                            YlzMedicalIcdDO ylzMedicalIcdDO = new YlzMedicalIcdDO();
                                            ylzMedicalIcdDO.setMedicalId(ylzMedicalRelationDO.getId());
                                            ylzMedicalIcdDO.setDel(1);
                                            ylzMedicalIcdDO.setCreateTime(new Date());
                                            ylzMedicalIcdDO.setDiseaseType(icdObject.getString("zdlx"));
                                            ylzMedicalIcdDO.setDiseaseCodeIcd10(icdObject.getString("zdbm"));
                                            ylzMedicalIcdDO.setDiseaseNameIcd10(icdObject.getString("zdmc"));
                                            ylzMedicalIcdDO.setDiseaseOrder(icdObject.getString("zdxh"));
                                            ylzMedicalIcdDO = ylzMedicailIcdDao.save(ylzMedicalIcdDO);
                                            icdDOList.add(ylzMedicalIcdDO);
                                        }
                                    }
                                }
                            }
                            Object json = new JSONTokener(resultJSON.getString("mxlists")).nextValue();
                            if(json instanceof net.sf.json.JSONObject){
                                net.sf.json.JSONObject mxListJSON = (net.sf.json.JSONObject)json;
                                net.sf.json.JSONObject mxObject = mxListJSON.getJSONObject("mxlist");
                                YlzMedicalMxDO ylzMedicalMxDO = new YlzMedicalMxDO();
                                ylzMedicalMxDO.setMedicalId(ylzMedicalRelationDO.getId());
                                ylzMedicalMxDO.setDel(1);
                                ylzMedicalMxDO.setPrescriptionCode(resultJSON.getString("xtgzh0"));
                                ylzMedicalMxDO.setHisDetailSn(outpatientDO.getRegisterNo());
                                ylzMedicalMxDO.setItemCode(mxObject.getString("xmbh00"));
                                ylzMedicalMxDO.setItemName(mxObject.getString("xmmc00"));
                                ylzMedicalMxDO.setInvoiceType("01");
                                ylzMedicalMxDO.setSpecificationType(mxObject.getString("xmgg00"));
                                ylzMedicalMxDO.setDosageForm(mxObject.getString("jx0000"));
                                ylzMedicalMxDO.setChargeUnit(mxObject.getString("xmdw00"));
                                ylzMedicalMxDO.setPrice(mxObject.getString("xmdj00"));
                                ylzMedicalMxDO.setAmount(mxObject.getString("xmsl00"));
                                ylzMedicalMxDO.setTotalMoney(mxObject.getString("xmje00"));
                                ylzMedicalMxDO.setSingleDose(mxObject.getString("ypyl00"));
                                ylzMedicalMxDO.setUseFrequency(mxObject.getString("yppl00"));
                                ylzMedicalMxDO.setMedicalWay(mxObject.getString("gytj00"));
                                ylzMedicalMxDO.setPrescriptionDate(DateUtil.strToYmdDateLong(mxObject.getString("xmrq00")+" "+mxObject.getString("xmsj00")));
                                ylzMedicalMxDO.setMedicationDays(mxObject.getString("ylts00"));
                                ylzMedicalMxDO.setDeptCode(resultJSON.getString("ksbm00"));
                                ylzMedicalMxDO.setDeptName(resultJSON.getString("ghksmc"));
                                ylzMedicalMxDO.setHisDeptCode(resultJSON.getString("ksbm00"));
                                ylzMedicalMxDO.setHisDeptName(resultJSON.getString("ghksmc"));
                                ylzMedicalMxDO.setMedicalPerName(resultJSON.getString("ysxm00"));
                                ylzMedicalMxDO.setMedicalPerId(baseDoctorDO.getAtddrNo());
                                ylzMedicalMxDO.setLimitType(mxObject.getString("sfybxm"));
                                ylzMedicalMxDO.setActgDate(DateUtil.strToYmdDateLong(mxObject.getString("xmrq00")+" "+mxObject.getString("xmsj00")));
                                ylzMedicalMxDO.setHisItemName(mxObject.getString("xmmc00"));
                                ylzMedicalMxDO.setHisItemCode(mxObject.getString("xmbh00"));
                                ylzMedicalMxDO.setClerkDays(DateUtil.strToYmdDateLong(mxObject.getString("xmrq00")+" "+mxObject.getString("xmsj00")));
                                ylzMedicalMxDO.setPeopleType(null);
                                ylzMedicalMxDO = ylzMedicailMxDao.save(ylzMedicalMxDO);
                                mxDOList.add(ylzMedicalMxDO);
                            }else if (json instanceof JSONArray){
                                JSONArray mxArray = (JSONArray)json;
                                for (int k=0;k<mxArray.size();k++){
                                    net.sf.json.JSONObject mxObject = mxArray.getJSONObject(k);
                                Object json = new JSONTokener(resultJSON.getString("mxlists")).nextValue();
                                if(json instanceof net.sf.json.JSONObject){
                                    net.sf.json.JSONObject mxListJSON = (net.sf.json.JSONObject)json;
                                    net.sf.json.JSONObject mxObject = mxListJSON.getJSONObject("mxlist");
                                    YlzMedicalMxDO ylzMedicalMxDO = new YlzMedicalMxDO();
                                    ylzMedicalMxDO.setMedicalId(ylzMedicalRelationDO.getId());
                                    ylzMedicalMxDO.setDel(1);
@ -3802,106 +3764,743 @@ public class EntranceService {
                                    ylzMedicalMxDO.setPeopleType(null);
                                    ylzMedicalMxDO = ylzMedicailMxDao.save(ylzMedicalMxDO);
                                    mxDOList.add(ylzMedicalMxDO);
                                }else if (json instanceof JSONArray){
                                    JSONArray mxArray = (JSONArray)json;
                                    for (int k=0;k<mxArray.size();k++){
                                        net.sf.json.JSONObject mxObject = mxArray.getJSONObject(k);
                                        YlzMedicalMxDO ylzMedicalMxDO = new YlzMedicalMxDO();
                                        ylzMedicalMxDO.setMedicalId(ylzMedicalRelationDO.getId());
                                        ylzMedicalMxDO.setDel(1);
                                        ylzMedicalMxDO.setPrescriptionCode(resultJSON.getString("xtgzh0"));
                                        ylzMedicalMxDO.setHisDetailSn(outpatientDO.getRegisterNo());
                                        ylzMedicalMxDO.setItemCode(mxObject.getString("xmbh00"));
                                        ylzMedicalMxDO.setItemName(mxObject.getString("xmmc00"));
                                        ylzMedicalMxDO.setInvoiceType("01");
                                        ylzMedicalMxDO.setSpecificationType(mxObject.getString("xmgg00"));
                                        ylzMedicalMxDO.setDosageForm(mxObject.getString("jx0000"));
                                        ylzMedicalMxDO.setChargeUnit(mxObject.getString("xmdw00"));
                                        ylzMedicalMxDO.setPrice(mxObject.getString("xmdj00"));
                                        ylzMedicalMxDO.setAmount(mxObject.getString("xmsl00"));
                                        ylzMedicalMxDO.setTotalMoney(mxObject.getString("xmje00"));
                                        ylzMedicalMxDO.setSingleDose(mxObject.getString("ypyl00"));
                                        ylzMedicalMxDO.setUseFrequency(mxObject.getString("yppl00"));
                                        ylzMedicalMxDO.setMedicalWay(mxObject.getString("gytj00"));
                                        ylzMedicalMxDO.setPrescriptionDate(DateUtil.strToYmdDateLong(mxObject.getString("xmrq00")+" "+mxObject.getString("xmsj00")));
                                        ylzMedicalMxDO.setMedicationDays(mxObject.getString("ylts00"));
                                        ylzMedicalMxDO.setDeptCode(resultJSON.getString("ksbm00"));
                                        ylzMedicalMxDO.setDeptName(resultJSON.getString("ghksmc"));
                                        ylzMedicalMxDO.setHisDeptCode(resultJSON.getString("ksbm00"));
                                        ylzMedicalMxDO.setHisDeptName(resultJSON.getString("ghksmc"));
                                        ylzMedicalMxDO.setMedicalPerName(resultJSON.getString("ysxm00"));
                                        ylzMedicalMxDO.setMedicalPerId(baseDoctorDO.getAtddrNo());
                                        ylzMedicalMxDO.setLimitType(mxObject.getString("sfybxm"));
                                        ylzMedicalMxDO.setActgDate(DateUtil.strToYmdDateLong(mxObject.getString("xmrq00")+" "+mxObject.getString("xmsj00")));
                                        ylzMedicalMxDO.setHisItemName(mxObject.getString("xmmc00"));
                                        ylzMedicalMxDO.setHisItemCode(mxObject.getString("xmbh00"));
                                        ylzMedicalMxDO.setClerkDays(DateUtil.strToYmdDateLong(mxObject.getString("xmrq00")+" "+mxObject.getString("xmsj00")));
                                        ylzMedicalMxDO.setPeopleType(null);
                                        ylzMedicalMxDO = ylzMedicailMxDao.save(ylzMedicalMxDO);
                                        mxDOList.add(ylzMedicalMxDO);
                                    }
                                }
                            }
                        }else {
                            ylzMedicalRelationDO.setOrgCode("3502000303");
                            ylzMedicalRelationDO.setRegionCode("350200");
                            ylzMedicalRelationDO.setDiseaseCode(diseaseCode);
                            ylzMedicalRelationDO.setIdcard(outpatientDO.getIdcard());
                            ylzMedicalRelationDO.setName(resultJSON.getString("xming0"));
                            ylzMedicalRelationDO.setCertType("01");
                            ylzMedicalRelationDO.setMedicalMode("10");
                            if (StringUtils.isNoneBlank(outpatientDO.getDiseaseCode())){
                                ylzMedicalRelationDO.setMedicalType("13");
                            }else {
                                ylzMedicalRelationDO.setMedicalType("11");
                            }
                            ylzMedicalRelationDO.setHisSerial(outpatientDO.getRegisterNo());
                            ylzMedicalRelationDO.setHisSettleNo(resultJSON.getString("xtgzh0"));
                            ylzMedicalRelationDO.setDeptCode(resultJSON.getString("ksbm00"));
                            ylzMedicalRelationDO.setDeptName(resultJSON.getString("ghksmc"));
                            ylzMedicalRelationDO.setHisDeptCode(resultJSON.getString("ksbm00"));
                            ylzMedicalRelationDO.setHisDeptName(resultJSON.getString("ghksmc"));
                            ylzMedicalRelationDO.setEmergencySign("0");
                            ylzMedicalRelationDO.setTraumaSign("0");
                            ylzMedicalRelationDO.setCardNo(cardno);
                            ylzMedicalRelationDO.setDate(outpatientDO.getRegisterDate());
                            ylzMedicalRelationDO.setItemCount(resultJSON.getString("cfxms0"));
                            ylzMedicalRelationDO.setTotalAmount(resultJSON.getString("bcfyze"));
                            ylzMedicalRelationDO.setPreCharges(resultJSON.getString("bcfyze"));
                            ylzMedicalRelationDO.setBcwkje(resultJSON.getString("bcwkje"));
                            ylzMedicalRelationDO.setDataSource("53");
                            ylzMedicalRelationDO.setPreCount(resultJSON.getString("cfxms0"));
                            ylzMedicalRelationDO.setBalance(cardFee+"");
                            ylzMedicalRelationDO.setMedicalPrice("0");
                            BaseDoctorDO baseDoctorDO = baseDoctorDao.findById(outpatientDO.getDoctor());
                            if (baseDoctorDO!=null){
                                String jobTitle = baseDoctorDO.getJobTitleCode();
                            }
                            if (outpatientDO.getMedicalState()==null){
                                ylzMedicalRelationDO.setMedicalState(0);
                                ylzMedicalRelationDO.setPersonCash(resultJSON.getString("bcfyze"));
                            }else {
                                if (outpatientDO.getMedicalState().equalsIgnoreCase("0")){
                                ylzMedicalRelationDO.setOrgCode("3502000303");
                                ylzMedicalRelationDO.setRegionCode("350200");
                                ylzMedicalRelationDO.setDiseaseCode(diseaseCode);
                                ylzMedicalRelationDO.setIdcard(outpatientDO.getIdcard());
                                ylzMedicalRelationDO.setName(resultJSON.getString("xming0"));
                                ylzMedicalRelationDO.setCertType("01");
                                ylzMedicalRelationDO.setMedicalMode("10");
                                if (StringUtils.isNoneBlank(outpatientDO.getDiseaseCode())){
                                    ylzMedicalRelationDO.setMedicalType("13");
                                }else {
                                    ylzMedicalRelationDO.setMedicalType("11");
                                }
                                ylzMedicalRelationDO.setHisSerial(outpatientDO.getRegisterNo());
                                ylzMedicalRelationDO.setHisSettleNo(resultJSON.getString("xtgzh0"));
                                ylzMedicalRelationDO.setDeptCode(resultJSON.getString("ksbm00"));
                                ylzMedicalRelationDO.setDeptName(resultJSON.getString("ghksmc"));
                                ylzMedicalRelationDO.setHisDeptCode(resultJSON.getString("ksbm00"));
                                ylzMedicalRelationDO.setHisDeptName(resultJSON.getString("ghksmc"));
                                ylzMedicalRelationDO.setEmergencySign("0");
                                ylzMedicalRelationDO.setTraumaSign("0");
                                ylzMedicalRelationDO.setCardNo(cardno);
                                ylzMedicalRelationDO.setDate(outpatientDO.getRegisterDate());
                                ylzMedicalRelationDO.setItemCount(resultJSON.getString("cfxms0"));
                                ylzMedicalRelationDO.setTotalAmount(resultJSON.getString("bcfyze"));
                                ylzMedicalRelationDO.setPreCharges(resultJSON.getString("bcfyze"));
                                ylzMedicalRelationDO.setBcwkje(resultJSON.getString("bcwkje"));
                                ylzMedicalRelationDO.setDataSource("53");
                                ylzMedicalRelationDO.setPreCount(resultJSON.getString("cfxms0"));
                                ylzMedicalRelationDO.setBalance(cardFee+"");
                                ylzMedicalRelationDO.setMedicalPrice("0");
                                BaseDoctorDO baseDoctorDO = baseDoctorDao.findById(outpatientDO.getDoctor());
                                if (baseDoctorDO!=null){
                                    String jobTitle = baseDoctorDO.getJobTitleCode();
                                }
                                if (outpatientDO.getMedicalState()==null){
                                    ylzMedicalRelationDO.setMedicalState(0);
                                    ylzMedicalRelationDO.setPersonCash(resultJSON.getString("bcfyze"));
                                }else {
                                    if (outpatientDO.getMedicalState().equalsIgnoreCase("0")){
                                        ylzMedicalRelationDO.setPersonCash(resultJSON.getString("bcfyze"));
                                    }
                                    ylzMedicalRelationDO.setMedicalState(Integer.parseInt(outpatientDO.getMedicalState()));
                                }
                                ylzMedicalRelationDO.setMedicalState(Integer.parseInt(outpatientDO.getMedicalState()));
                            }
                            ylzMedicalRelationDO.setDoctorLevel("02");
                            ylzMedicalRelationDO.setDel(1);
                            ylzMedicalRelationDO.setRelationCode(outpatientDO.getId());
                            ylzMedicalRelationDO.setCreateTime(new Date());
                            ylzMedicalRelationDO.setStatus(0);
                            ylzMedicalRelationDO = ylzMedicailRelationDao.save(ylzMedicalRelationDO);
                            ylzMedicailIcdDao.deleteByMedicalId(ylzMedicalRelationDO.getId());
                            /*YlzMedicalIcdDO ylzMedicalIcdDO = new YlzMedicalIcdDO();
                            ylzMedicalIcdDO.setMedicalId(ylzMedicalRelationDO.getId());
                            ylzMedicalIcdDO.setDel(1);
                            ylzMedicalIcdDO.setCreateTime(new Date());
                            ylzMedicalIcdDO.setDiseaseType("01");
                            ylzMedicalIcdDO.setDiseaseCodeIcd10(resultJSON.getString("bqzdbm"));
                            ylzMedicalIcdDO.setDiseaseNameIcd10(resultJSON.getString("bqzdms"));
                            ylzMedicalIcdDO.setDiseaseOrder("01");
                            ylzMedicalIcdDO = ylzMedicailIcdDao.save(ylzMedicalIcdDO);
                            icdDOList.add(ylzMedicalIcdDO);*/
                            if (resultJSON.get("zdlists")!=null){
                                Object json = new JSONTokener(resultJSON.getString("zdlists")).nextValue();
                                if(json instanceof net.sf.json.JSONObject){
                                    net.sf.json.JSONObject icdJSON = (net.sf.json.JSONObject)json;
                                    net.sf.json.JSONObject icdJson = icdJSON.getJSONObject("zdlist");
                                    YlzMedicalIcdDO ylzMedicalIcdDO = new YlzMedicalIcdDO();
                                    ylzMedicalIcdDO.setMedicalId(ylzMedicalRelationDO.getId());
                                    ylzMedicalIcdDO.setDel(1);
                                    ylzMedicalIcdDO.setCreateTime(new Date());
                                    ylzMedicalIcdDO.setDiseaseType(icdJson.getString("zdlx"));
                                    ylzMedicalIcdDO.setDiseaseCodeIcd10(icdJson.getString("zdbm"));
                                    ylzMedicalIcdDO.setDiseaseNameIcd10(icdJson.getString("zdmc"));
                                    ylzMedicalIcdDO.setDiseaseOrder(icdJson.getString("zdxh"));
                                    ylzMedicalIcdDO = ylzMedicailIcdDao.save(ylzMedicalIcdDO);
                                    icdDOList.add(ylzMedicalIcdDO);
                                } else if (json instanceof JSONArray) {
                                    JSONArray icdArray = (JSONArray)json;
                                    for (int k=0;k<icdArray.size();k++) {
                                        net.sf.json.JSONObject icdObject = icdArray.getJSONObject(k);
                                ylzMedicalRelationDO.setDoctorLevel("02");
                                ylzMedicalRelationDO.setDel(1);
                                ylzMedicalRelationDO.setRelationCode(outpatientDO.getId());
                                ylzMedicalRelationDO.setCreateTime(new Date());
                                ylzMedicalRelationDO.setStatus(0);
                                ylzMedicalRelationDO = ylzMedicailRelationDao.save(ylzMedicalRelationDO);
                                ylzMedicailIcdDao.deleteByMedicalId(ylzMedicalRelationDO.getId());
                                if (resultJSON.get("zdlists")!=null){
                                    Object json = new JSONTokener(resultJSON.getString("zdlists")).nextValue();
                                    if(json instanceof net.sf.json.JSONObject){
                                        net.sf.json.JSONObject icdJSON = (net.sf.json.JSONObject)json;
                                        net.sf.json.JSONObject icdJson = icdJSON.getJSONObject("zdlist");
                                        YlzMedicalIcdDO ylzMedicalIcdDO = new YlzMedicalIcdDO();
                                        ylzMedicalIcdDO.setMedicalId(ylzMedicalRelationDO.getId());
                                        ylzMedicalIcdDO.setDel(1);
                                        ylzMedicalIcdDO.setCreateTime(new Date());
                                        ylzMedicalIcdDO.setDiseaseType(icdObject.getString("zdlx"));
                                        ylzMedicalIcdDO.setDiseaseCodeIcd10(icdObject.getString("zdbm"));
                                        ylzMedicalIcdDO.setDiseaseNameIcd10(icdObject.getString("zdmc"));
                                        ylzMedicalIcdDO.setDiseaseOrder(icdObject.getString("zdxh"));
                                        ylzMedicalIcdDO.setDiseaseType(icdJson.getString("zdlx"));
                                        ylzMedicalIcdDO.setDiseaseCodeIcd10(icdJson.getString("zdbm"));
                                        ylzMedicalIcdDO.setDiseaseNameIcd10(icdJson.getString("zdmc"));
                                        ylzMedicalIcdDO.setDiseaseOrder(icdJson.getString("zdxh"));
                                        ylzMedicalIcdDO = ylzMedicailIcdDao.save(ylzMedicalIcdDO);
                                        icdDOList.add(ylzMedicalIcdDO);
                                    } else if (json instanceof JSONArray) {
                                        JSONArray icdArray = (JSONArray)json;
                                        for (int k=0;k<icdArray.size();k++) {
                                            net.sf.json.JSONObject icdObject = icdArray.getJSONObject(k);
                                            YlzMedicalIcdDO ylzMedicalIcdDO = new YlzMedicalIcdDO();
                                            ylzMedicalIcdDO.setMedicalId(ylzMedicalRelationDO.getId());
                                            ylzMedicalIcdDO.setDel(1);
                                            ylzMedicalIcdDO.setCreateTime(new Date());
                                            ylzMedicalIcdDO.setDiseaseType(icdObject.getString("zdlx"));
                                            ylzMedicalIcdDO.setDiseaseCodeIcd10(icdObject.getString("zdbm"));
                                            ylzMedicalIcdDO.setDiseaseNameIcd10(icdObject.getString("zdmc"));
                                            ylzMedicalIcdDO.setDiseaseOrder(icdObject.getString("zdxh"));
                                            ylzMedicalIcdDO = ylzMedicailIcdDao.save(ylzMedicalIcdDO);
                                            icdDOList.add(ylzMedicalIcdDO);
                                        }
                                    }
                                }
                                ylzMedicailMxDao.deleteByMedicalId(ylzMedicalRelationDO.getId());
                                Object json = new JSONTokener(resultJSON.getString("mxlists")).nextValue();
                                if(json instanceof net.sf.json.JSONObject){
                                    net.sf.json.JSONObject mxListJSON = (net.sf.json.JSONObject)json;
                                    net.sf.json.JSONObject mxObject = mxListJSON.getJSONObject("mxlist");
                                    YlzMedicalMxDO ylzMedicalMxDO = new YlzMedicalMxDO();
                                    ylzMedicalMxDO.setMedicalId(ylzMedicalRelationDO.getId());
                                    ylzMedicalMxDO.setDel(1);
                                    ylzMedicalMxDO.setPrescriptionCode(resultJSON.getString("xtgzh0"));
                                    ylzMedicalMxDO.setHisDetailSn(outpatientDO.getRegisterNo());
                                    ylzMedicalMxDO.setItemCode(mxObject.getString("xmbh00"));
                                    ylzMedicalMxDO.setItemName(mxObject.getString("xmmc00"));
                                    ylzMedicalMxDO.setInvoiceType("01");
                                    ylzMedicalMxDO.setSpecificationType(mxObject.getString("xmgg00"));
                                    ylzMedicalMxDO.setDosageForm(mxObject.getString("jx0000"));
                                    ylzMedicalMxDO.setChargeUnit(mxObject.getString("xmdw00"));
                                    ylzMedicalMxDO.setPrice(mxObject.getString("xmdj00"));
                                    ylzMedicalMxDO.setAmount(mxObject.getString("xmsl00"));
                                    ylzMedicalMxDO.setTotalMoney(mxObject.getString("xmje00"));
                                    ylzMedicalMxDO.setSingleDose(mxObject.getString("ypyl00"));
                                    ylzMedicalMxDO.setUseFrequency(mxObject.getString("yppl00"));
                                    ylzMedicalMxDO.setMedicalWay(mxObject.getString("gytj00"));
                                    ylzMedicalMxDO.setPrescriptionDate(DateUtil.strToYmdDateLong(mxObject.getString("xmrq00")+" "+mxObject.getString("xmsj00")));
                                    ylzMedicalMxDO.setMedicationDays(mxObject.getString("ylts00"));
                                    ylzMedicalMxDO.setDeptCode(resultJSON.getString("ksbm00"));
                                    ylzMedicalMxDO.setDeptName(resultJSON.getString("ghksmc"));
                                    ylzMedicalMxDO.setHisDeptCode(resultJSON.getString("ksbm00"));
                                    ylzMedicalMxDO.setHisDeptName(resultJSON.getString("ghksmc"));
                                    ylzMedicalMxDO.setMedicalPerName(resultJSON.getString("ysxm00"));
                                    ylzMedicalMxDO.setMedicalPerId(baseDoctorDO.getAtddrNo());
                                    ylzMedicalMxDO.setLimitType(mxObject.getString("sfybxm"));
                                    ylzMedicalMxDO.setActgDate(DateUtil.strToYmdDateLong(mxObject.getString("xmrq00")+" "+mxObject.getString("xmsj00")));
                                    ylzMedicalMxDO.setHisItemName(mxObject.getString("xmmc00"));
                                    ylzMedicalMxDO.setHisItemCode(mxObject.getString("xmbh00"));
                                    ylzMedicalMxDO.setClerkDays(DateUtil.strToYmdDateLong(mxObject.getString("xmrq00")+" "+mxObject.getString("xmsj00")));
                                    ylzMedicalMxDO.setPeopleType(null);
                                    ylzMedicalMxDO = ylzMedicailMxDao.save(ylzMedicalMxDO);
                                    mxDOList.add(ylzMedicalMxDO);
                                }else if (json instanceof JSONArray){
                                    JSONArray mxArray = (JSONArray)json;
                                    for (int k=0;k<mxArray.size();k++){
                                        net.sf.json.JSONObject mxObject = mxArray.getJSONObject(k);
                                        YlzMedicalMxDO ylzMedicalMxDO = new YlzMedicalMxDO();
                                        ylzMedicalMxDO.setMedicalId(ylzMedicalRelationDO.getId());
                                        ylzMedicalMxDO.setDel(1);
                                        ylzMedicalMxDO.setPrescriptionCode(resultJSON.getString("xtgzh0"));
                                        ylzMedicalMxDO.setHisDetailSn(outpatientDO.getRegisterNo());
                                        ylzMedicalMxDO.setItemCode(mxObject.getString("xmbh00"));
                                        ylzMedicalMxDO.setItemName(mxObject.getString("xmmc00"));
                                        ylzMedicalMxDO.setInvoiceType("01");
                                        ylzMedicalMxDO.setSpecificationType(mxObject.getString("xmgg00"));
                                        ylzMedicalMxDO.setDosageForm(mxObject.getString("jx0000"));
                                        ylzMedicalMxDO.setChargeUnit(mxObject.getString("xmdw00"));
                                        ylzMedicalMxDO.setPrice(mxObject.getString("xmdj00"));
                                        ylzMedicalMxDO.setAmount(mxObject.getString("xmsl00"));
                                        ylzMedicalMxDO.setTotalMoney(mxObject.getString("xmje00"));
                                        ylzMedicalMxDO.setSingleDose(mxObject.getString("ypyl00"));
                                        ylzMedicalMxDO.setUseFrequency(mxObject.getString("yppl00"));
                                        ylzMedicalMxDO.setMedicalWay(mxObject.getString("gytj00"));
                                        ylzMedicalMxDO.setPrescriptionDate(DateUtil.strToYmdDateLong(mxObject.getString("xmrq00")+" "+mxObject.getString("xmsj00")));
                                        ylzMedicalMxDO.setMedicationDays(mxObject.getString("ylts00"));
                                        ylzMedicalMxDO.setDeptCode(resultJSON.getString("ksbm00"));
                                        ylzMedicalMxDO.setDeptName(resultJSON.getString("ghksmc"));
                                        ylzMedicalMxDO.setHisDeptCode(resultJSON.getString("ksbm00"));
                                        ylzMedicalMxDO.setHisDeptName(resultJSON.getString("ghksmc"));
                                        ylzMedicalMxDO.setMedicalPerName(resultJSON.getString("ysxm00"));
                                        ylzMedicalMxDO.setMedicalPerId(baseDoctorDO.getAtddrNo());
                                        if (mxObject.getString("xmbh00").equalsIgnoreCase("XA11GAW043A001010202251")){
                                            ylzMedicalMxDO.setLimitType("N");
                                        }else {
                                            ylzMedicalMxDO.setLimitType(mxObject.getString("sfybxm"));
                                        }
                                        ylzMedicalMxDO.setActgDate(DateUtil.strToYmdDateLong(mxObject.getString("xmrq00")+" "+mxObject.getString("xmsj00")));
                                        ylzMedicalMxDO.setHisItemName(mxObject.getString("xmmc00"));
                                        ylzMedicalMxDO.setHisItemCode(mxObject.getString("xmbh00"));
                                        ylzMedicalMxDO.setClerkDays(DateUtil.strToYmdDateLong(mxObject.getString("xmrq00")+" "+mxObject.getString("xmsj00")));
                                        ylzMedicalMxDO.setPeopleType(null);
                                        ylzMedicalMxDO = ylzMedicailMxDao.save(ylzMedicalMxDO);
                                        mxDOList.add(ylzMedicalMxDO);
                                    }
                                }
                            }
                            ylzMedicailMxDao.deleteByMedicalId(ylzMedicalRelationDO.getId());
                            Object json = new JSONTokener(resultJSON.getString("mxlists")).nextValue();
                            ylzMedicalRelationDO.setYlzMedicalIcdDOList(icdDOList);
                            ylzMedicalRelationDO.setYlzMedicalMxDOList(mxDOList);
                            relationDOList.add(ylzMedicalRelationDO);
                        }
                    }
                }else if (obj instanceof com.alibaba.fastjson.JSONArray){
                    JSONArray msgInfoJson = object.getJSONArray("msgInfo");
                    if (msgInfoJson!=null){
                        for (int i=0;i<msgInfoJson.size();i++){
                            net.sf.json.JSONObject resultJSON = msgInfoJson.getJSONObject(i);
                            if (resultJSON!=null){
                                YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByLog_no(resultJSON.getString("xtgzh0"));
                                List<WlyyPrescriptionDO> prescriptionDOList = prescriptionDao.findByRealOrderAndStatusList(resultJSON.getString("xtgzh0"));
                                String diseaseCode = "";
                                if (prescriptionDOList!=null&&prescriptionDOList.size()!=0){
                                    diseaseCode= prescriptionDOList.get(0).getDiseaseCode();
                                }
                                List<YlzMedicalIcdDO> icdDOList = new ArrayList<>();
                                List<YlzMedicalMxDO> mxDOList = new ArrayList<>();
                                if (ylzMedicalRelationDO==null){
                                    ylzMedicalRelationDO = new YlzMedicalRelationDO();
                                    ylzMedicalRelationDO.setLogNo(resultJSON.getString("xtgzh0"));
                                    ylzMedicalRelationDO.setOrgCode("3502000303");
                                    ylzMedicalRelationDO.setRegionCode("350200");
                                    ylzMedicalRelationDO.setIdcard(outpatientDO.getIdcard());
                                    ylzMedicalRelationDO.setName(resultJSON.getString("xming0"));
                                    ylzMedicalRelationDO.setCertType("01");
                                    ylzMedicalRelationDO.setMedicalMode("10");
                                    if (StringUtils.isNoneBlank(outpatientDO.getDiseaseCode())){
                                        ylzMedicalRelationDO.setMedicalType("13");
                                    }else {
                                        ylzMedicalRelationDO.setMedicalType("11");
                                    }
                                    ylzMedicalRelationDO.setCardNo(cardno);
                                    ylzMedicalRelationDO.setHisSerial(outpatientDO.getRegisterNo());
                                    ylzMedicalRelationDO.setHisSettleNo(resultJSON.getString("xtgzh0"));
                                    ylzMedicalRelationDO.setDeptCode(resultJSON.getString("ksbm00"));
                                    ylzMedicalRelationDO.setDeptName(resultJSON.getString("ghksmc"));
                                    ylzMedicalRelationDO.setHisDeptCode(resultJSON.getString("ksbm00"));
                                    ylzMedicalRelationDO.setHisDeptName(resultJSON.getString("ghksmc"));
                                    ylzMedicalRelationDO.setEmergencySign("0");
                                    ylzMedicalRelationDO.setTraumaSign("0");
                                    ylzMedicalRelationDO.setDate(outpatientDO.getRegisterDate());
                                    ylzMedicalRelationDO.setItemCount(resultJSON.getString("cfxms0"));
                                    ylzMedicalRelationDO.setTotalAmount(resultJSON.getString("bcfyze"));
                                    ylzMedicalRelationDO.setPreCharges(resultJSON.getString("bcfyze"));
                                    ylzMedicalRelationDO.setBcwkje(resultJSON.getString("bcwkje"));
                                    ylzMedicalRelationDO.setPersonAccount("0");
                                    ylzMedicalRelationDO.setDataSource("53");
                                    ylzMedicalRelationDO.setBalance(cardFee+"");
                                    ylzMedicalRelationDO.setDiseaseCode(diseaseCode);
                                    ylzMedicalRelationDO.setPreCount(resultJSON.getString("cfxms0"));
                                    BaseDoctorDO baseDoctorDO = baseDoctorDao.findById(outpatientDO.getDoctor());
                                    if (baseDoctorDO!=null){
                                        String jobTitle = baseDoctorDO.getJobTitleCode();
                                    }
                                    ylzMedicalRelationDO.setDoctorLevel("02");
                                    ylzMedicalRelationDO.setDel(1);
                                    ylzMedicalRelationDO.setStatus(0);
                                    ylzMedicalRelationDO.setState(0);
                                    ylzMedicalRelationDO.setRelationCode(outpatientDO.getId());
                                    ylzMedicalRelationDO.setCreateTime(new Date());
                                    ylzMedicalRelationDO.setMedicalPrice("0");
                                    if (outpatientDO.getMedicalState()==null){
                                        ylzMedicalRelationDO.setMedicalState(0);
                                        ylzMedicalRelationDO.setPersonCash(resultJSON.getString("bcfyze"));
                                    }else {
                                        if (outpatientDO.getMedicalState().equalsIgnoreCase("0")){
                                            ylzMedicalRelationDO.setPersonCash(resultJSON.getString("bcfyze"));
                                        }
                                        ylzMedicalRelationDO.setMedicalState(Integer.parseInt(outpatientDO.getMedicalState()));
                                    }
                                    ylzMedicalRelationDO = ylzMedicailRelationDao.save(ylzMedicalRelationDO);
                                    if (resultJSON.get("zdlists")!=null){
                                        Object json = new JSONTokener(resultJSON.getString("zdlists")).nextValue();
                                        if(json instanceof net.sf.json.JSONObject){
                                            net.sf.json.JSONObject icdJSON = (net.sf.json.JSONObject)json;
                                            net.sf.json.JSONObject icdJson = icdJSON.getJSONObject("zdlist");
                                            YlzMedicalIcdDO ylzMedicalIcdDO = new YlzMedicalIcdDO();
                                            ylzMedicalIcdDO.setMedicalId(ylzMedicalRelationDO.getId());
                                            ylzMedicalIcdDO.setDel(1);
                                            ylzMedicalIcdDO.setCreateTime(new Date());
                                            ylzMedicalIcdDO.setDiseaseType(icdJson.getString("zdlx"));
                                            ylzMedicalIcdDO.setDiseaseCodeIcd10(icdJson.getString("zdbm"));
                                            ylzMedicalIcdDO.setDiseaseNameIcd10(icdJson.getString("zdmc"));
                                            ylzMedicalIcdDO.setDiseaseOrder(icdJson.getString("zdxh"));
                                            ylzMedicalIcdDO = ylzMedicailIcdDao.save(ylzMedicalIcdDO);
                                            icdDOList.add(ylzMedicalIcdDO);
                                        } else if (json instanceof JSONArray) {
                                            JSONArray icdArray = (JSONArray)json;
                                            for (int k=0;k<icdArray.size();k++) {
                                                net.sf.json.JSONObject icdObject = icdArray.getJSONObject(k);
                                                YlzMedicalIcdDO ylzMedicalIcdDO = new YlzMedicalIcdDO();
                                                ylzMedicalIcdDO.setMedicalId(ylzMedicalRelationDO.getId());
                                                ylzMedicalIcdDO.setDel(1);
                                                ylzMedicalIcdDO.setCreateTime(new Date());
                                                ylzMedicalIcdDO.setDiseaseType(icdObject.getString("zdlx"));
                                                ylzMedicalIcdDO.setDiseaseCodeIcd10(icdObject.getString("zdbm"));
                                                ylzMedicalIcdDO.setDiseaseNameIcd10(icdObject.getString("zdmc"));
                                                ylzMedicalIcdDO.setDiseaseOrder(icdObject.getString("zdxh"));
                                                ylzMedicalIcdDO = ylzMedicailIcdDao.save(ylzMedicalIcdDO);
                                                icdDOList.add(ylzMedicalIcdDO);
                                            }
                                        }
                                    }
                                    Object json = new JSONTokener(resultJSON.getString("mxlists")).nextValue();
                                    if(json instanceof net.sf.json.JSONObject){
                                        net.sf.json.JSONObject mxListJSON = (net.sf.json.JSONObject)json;
                                        net.sf.json.JSONObject mxObject = mxListJSON.getJSONObject("mxlist");
                                        YlzMedicalMxDO ylzMedicalMxDO = new YlzMedicalMxDO();
                                        ylzMedicalMxDO.setMedicalId(ylzMedicalRelationDO.getId());
                                        ylzMedicalMxDO.setDel(1);
                                        ylzMedicalMxDO.setPrescriptionCode(resultJSON.getString("xtgzh0"));
                                        ylzMedicalMxDO.setHisDetailSn(outpatientDO.getRegisterNo());
                                        ylzMedicalMxDO.setItemCode(mxObject.getString("xmbh00"));
                                        ylzMedicalMxDO.setItemName(mxObject.getString("xmmc00"));
                                        ylzMedicalMxDO.setInvoiceType("01");
                                        ylzMedicalMxDO.setSpecificationType(mxObject.getString("xmgg00"));
                                        ylzMedicalMxDO.setDosageForm(mxObject.getString("jx0000"));
                                        ylzMedicalMxDO.setChargeUnit(mxObject.getString("xmdw00"));
                                        ylzMedicalMxDO.setPrice(mxObject.getString("xmdj00"));
                                        ylzMedicalMxDO.setAmount(mxObject.getString("xmsl00"));
                                        ylzMedicalMxDO.setTotalMoney(mxObject.getString("xmje00"));
                                        ylzMedicalMxDO.setSingleDose(mxObject.getString("ypyl00"));
                                        ylzMedicalMxDO.setUseFrequency(mxObject.getString("yppl00"));
                                        ylzMedicalMxDO.setMedicalWay(mxObject.getString("gytj00"));
                                        ylzMedicalMxDO.setPrescriptionDate(DateUtil.strToYmdDateLong(mxObject.getString("xmrq00")+" "+mxObject.getString("xmsj00")));
                                        ylzMedicalMxDO.setMedicationDays(mxObject.getString("ylts00"));
                                        ylzMedicalMxDO.setDeptCode(resultJSON.getString("ksbm00"));
                                        ylzMedicalMxDO.setDeptName(resultJSON.getString("ghksmc"));
                                        ylzMedicalMxDO.setHisDeptCode(resultJSON.getString("ksbm00"));
                                        ylzMedicalMxDO.setHisDeptName(resultJSON.getString("ghksmc"));
                                        ylzMedicalMxDO.setMedicalPerName(resultJSON.getString("ysxm00"));
                                        ylzMedicalMxDO.setMedicalPerId(baseDoctorDO.getAtddrNo());
                                        ylzMedicalMxDO.setLimitType(mxObject.getString("sfybxm"));
                                        ylzMedicalMxDO.setActgDate(DateUtil.strToYmdDateLong(mxObject.getString("xmrq00")+" "+mxObject.getString("xmsj00")));
                                        ylzMedicalMxDO.setHisItemName(mxObject.getString("xmmc00"));
                                        ylzMedicalMxDO.setHisItemCode(mxObject.getString("xmbh00"));
                                        ylzMedicalMxDO.setClerkDays(DateUtil.strToYmdDateLong(mxObject.getString("xmrq00")+" "+mxObject.getString("xmsj00")));
                                        ylzMedicalMxDO.setPeopleType(null);
                                        ylzMedicalMxDO = ylzMedicailMxDao.save(ylzMedicalMxDO);
                                        mxDOList.add(ylzMedicalMxDO);
                                    }else if (json instanceof JSONArray){
                                        JSONArray mxArray = (JSONArray)json;
                                        for (int k=0;k<mxArray.size();k++){
                                            net.sf.json.JSONObject mxObject = mxArray.getJSONObject(k);
                                            YlzMedicalMxDO ylzMedicalMxDO = new YlzMedicalMxDO();
                                            ylzMedicalMxDO.setMedicalId(ylzMedicalRelationDO.getId());
                                            ylzMedicalMxDO.setDel(1);
                                            ylzMedicalMxDO.setPrescriptionCode(resultJSON.getString("xtgzh0"));
                                            ylzMedicalMxDO.setHisDetailSn(outpatientDO.getRegisterNo());
                                            ylzMedicalMxDO.setItemCode(mxObject.getString("xmbh00"));
                                            ylzMedicalMxDO.setItemName(mxObject.getString("xmmc00"));
                                            ylzMedicalMxDO.setInvoiceType("01");
                                            ylzMedicalMxDO.setSpecificationType(mxObject.getString("xmgg00"));
                                            ylzMedicalMxDO.setDosageForm(mxObject.getString("jx0000"));
                                            ylzMedicalMxDO.setChargeUnit(mxObject.getString("xmdw00"));
                                            ylzMedicalMxDO.setPrice(mxObject.getString("xmdj00"));
                                            ylzMedicalMxDO.setAmount(mxObject.getString("xmsl00"));
                                            ylzMedicalMxDO.setTotalMoney(mxObject.getString("xmje00"));
                                            ylzMedicalMxDO.setSingleDose(mxObject.getString("ypyl00"));
                                            ylzMedicalMxDO.setUseFrequency(mxObject.getString("yppl00"));
                                            ylzMedicalMxDO.setMedicalWay(mxObject.getString("gytj00"));
                                            ylzMedicalMxDO.setPrescriptionDate(DateUtil.strToYmdDateLong(mxObject.getString("xmrq00")+" "+mxObject.getString("xmsj00")));
                                            ylzMedicalMxDO.setMedicationDays(mxObject.getString("ylts00"));
                                            ylzMedicalMxDO.setDeptCode(resultJSON.getString("ksbm00"));
                                            ylzMedicalMxDO.setDeptName(resultJSON.getString("ghksmc"));
                                            ylzMedicalMxDO.setHisDeptCode(resultJSON.getString("ksbm00"));
                                            ylzMedicalMxDO.setHisDeptName(resultJSON.getString("ghksmc"));
                                            ylzMedicalMxDO.setMedicalPerName(resultJSON.getString("ysxm00"));
                                            ylzMedicalMxDO.setMedicalPerId(baseDoctorDO.getAtddrNo());
                                            ylzMedicalMxDO.setLimitType(mxObject.getString("sfybxm"));
                                            ylzMedicalMxDO.setActgDate(DateUtil.strToYmdDateLong(mxObject.getString("xmrq00")+" "+mxObject.getString("xmsj00")));
                                            ylzMedicalMxDO.setHisItemName(mxObject.getString("xmmc00"));
                                            ylzMedicalMxDO.setHisItemCode(mxObject.getString("xmbh00"));
                                            ylzMedicalMxDO.setClerkDays(DateUtil.strToYmdDateLong(mxObject.getString("xmrq00")+" "+mxObject.getString("xmsj00")));
                                            ylzMedicalMxDO.setPeopleType(null);
                                            ylzMedicalMxDO = ylzMedicailMxDao.save(ylzMedicalMxDO);
                                            mxDOList.add(ylzMedicalMxDO);
                                        }
                                    }
                                }else {
                                    ylzMedicalRelationDO.setOrgCode("3502000303");
                                    ylzMedicalRelationDO.setRegionCode("350200");
                                    ylzMedicalRelationDO.setDiseaseCode(diseaseCode);
                                    ylzMedicalRelationDO.setIdcard(outpatientDO.getIdcard());
                                    ylzMedicalRelationDO.setName(resultJSON.getString("xming0"));
                                    ylzMedicalRelationDO.setCertType("01");
                                    ylzMedicalRelationDO.setMedicalMode("10");
                                    if (StringUtils.isNoneBlank(outpatientDO.getDiseaseCode())){
                                        ylzMedicalRelationDO.setMedicalType("13");
                                    }else {
                                        ylzMedicalRelationDO.setMedicalType("11");
                                    }
                                    ylzMedicalRelationDO.setHisSerial(outpatientDO.getRegisterNo());
                                    ylzMedicalRelationDO.setHisSettleNo(resultJSON.getString("xtgzh0"));
                                    ylzMedicalRelationDO.setDeptCode(resultJSON.getString("ksbm00"));
                                    ylzMedicalRelationDO.setDeptName(resultJSON.getString("ghksmc"));
                                    ylzMedicalRelationDO.setHisDeptCode(resultJSON.getString("ksbm00"));
                                    ylzMedicalRelationDO.setHisDeptName(resultJSON.getString("ghksmc"));
                                    ylzMedicalRelationDO.setEmergencySign("0");
                                    ylzMedicalRelationDO.setTraumaSign("0");
                                    ylzMedicalRelationDO.setCardNo(cardno);
                                    ylzMedicalRelationDO.setDate(outpatientDO.getRegisterDate());
                                    ylzMedicalRelationDO.setItemCount(resultJSON.getString("cfxms0"));
                                    ylzMedicalRelationDO.setTotalAmount(resultJSON.getString("bcfyze"));
                                    ylzMedicalRelationDO.setPreCharges(resultJSON.getString("bcfyze"));
                                    ylzMedicalRelationDO.setBcwkje(resultJSON.getString("bcwkje"));
                                    ylzMedicalRelationDO.setDataSource("53");
                                    ylzMedicalRelationDO.setPreCount(resultJSON.getString("cfxms0"));
                                    ylzMedicalRelationDO.setBalance(cardFee+"");
                                    ylzMedicalRelationDO.setMedicalPrice("0");
                                    BaseDoctorDO baseDoctorDO = baseDoctorDao.findById(outpatientDO.getDoctor());
                                    if (baseDoctorDO!=null){
                                        String jobTitle = baseDoctorDO.getJobTitleCode();
                                    }
                                    if (outpatientDO.getMedicalState()==null){
                                        ylzMedicalRelationDO.setMedicalState(0);
                                        ylzMedicalRelationDO.setPersonCash(resultJSON.getString("bcfyze"));
                                    }else {
                                        if (outpatientDO.getMedicalState().equalsIgnoreCase("0")){
                                            ylzMedicalRelationDO.setPersonCash(resultJSON.getString("bcfyze"));
                                        }
                                        ylzMedicalRelationDO.setMedicalState(Integer.parseInt(outpatientDO.getMedicalState()));
                                    }
                                    ylzMedicalRelationDO.setDoctorLevel("02");
                                    ylzMedicalRelationDO.setDel(1);
                                    ylzMedicalRelationDO.setRelationCode(outpatientDO.getId());
                                    ylzMedicalRelationDO.setCreateTime(new Date());
                                    ylzMedicalRelationDO.setStatus(0);
                                    ylzMedicalRelationDO = ylzMedicailRelationDao.save(ylzMedicalRelationDO);
                                    ylzMedicailIcdDao.deleteByMedicalId(ylzMedicalRelationDO.getId());
                                    if (resultJSON.get("zdlists")!=null){
                                        Object json = new JSONTokener(resultJSON.getString("zdlists")).nextValue();
                                        if(json instanceof net.sf.json.JSONObject){
                                            net.sf.json.JSONObject icdJSON = (net.sf.json.JSONObject)json;
                                            net.sf.json.JSONObject icdJson = icdJSON.getJSONObject("zdlist");
                                            YlzMedicalIcdDO ylzMedicalIcdDO = new YlzMedicalIcdDO();
                                            ylzMedicalIcdDO.setMedicalId(ylzMedicalRelationDO.getId());
                                            ylzMedicalIcdDO.setDel(1);
                                            ylzMedicalIcdDO.setCreateTime(new Date());
                                            ylzMedicalIcdDO.setDiseaseType(icdJson.getString("zdlx"));
                                            ylzMedicalIcdDO.setDiseaseCodeIcd10(icdJson.getString("zdbm"));
                                            ylzMedicalIcdDO.setDiseaseNameIcd10(icdJson.getString("zdmc"));
                                            ylzMedicalIcdDO.setDiseaseOrder(icdJson.getString("zdxh"));
                                            ylzMedicalIcdDO = ylzMedicailIcdDao.save(ylzMedicalIcdDO);
                                            icdDOList.add(ylzMedicalIcdDO);
                                        } else if (json instanceof JSONArray) {
                                            JSONArray icdArray = (JSONArray)json;
                                            for (int k=0;k<icdArray.size();k++) {
                                                net.sf.json.JSONObject icdObject = icdArray.getJSONObject(k);
                                                YlzMedicalIcdDO ylzMedicalIcdDO = new YlzMedicalIcdDO();
                                                ylzMedicalIcdDO.setMedicalId(ylzMedicalRelationDO.getId());
                                                ylzMedicalIcdDO.setDel(1);
                                                ylzMedicalIcdDO.setCreateTime(new Date());
                                                ylzMedicalIcdDO.setDiseaseType(icdObject.getString("zdlx"));
                                                ylzMedicalIcdDO.setDiseaseCodeIcd10(icdObject.getString("zdbm"));
                                                ylzMedicalIcdDO.setDiseaseNameIcd10(icdObject.getString("zdmc"));
                                                ylzMedicalIcdDO.setDiseaseOrder(icdObject.getString("zdxh"));
                                                ylzMedicalIcdDO = ylzMedicailIcdDao.save(ylzMedicalIcdDO);
                                                icdDOList.add(ylzMedicalIcdDO);
                                            }
                                        }
                                    }
                                    ylzMedicailMxDao.deleteByMedicalId(ylzMedicalRelationDO.getId());
                                    Object json = new JSONTokener(resultJSON.getString("mxlists")).nextValue();
                                    if(json instanceof net.sf.json.JSONObject){
                                        net.sf.json.JSONObject mxListJSON = (net.sf.json.JSONObject)json;
                                        net.sf.json.JSONObject mxObject = mxListJSON.getJSONObject("mxlist");
                                        YlzMedicalMxDO ylzMedicalMxDO = new YlzMedicalMxDO();
                                        ylzMedicalMxDO.setMedicalId(ylzMedicalRelationDO.getId());
                                        ylzMedicalMxDO.setDel(1);
                                        ylzMedicalMxDO.setPrescriptionCode(resultJSON.getString("xtgzh0"));
                                        ylzMedicalMxDO.setHisDetailSn(outpatientDO.getRegisterNo());
                                        ylzMedicalMxDO.setItemCode(mxObject.getString("xmbh00"));
                                        ylzMedicalMxDO.setItemName(mxObject.getString("xmmc00"));
                                        ylzMedicalMxDO.setInvoiceType("01");
                                        ylzMedicalMxDO.setSpecificationType(mxObject.getString("xmgg00"));
                                        ylzMedicalMxDO.setDosageForm(mxObject.getString("jx0000"));
                                        ylzMedicalMxDO.setChargeUnit(mxObject.getString("xmdw00"));
                                        ylzMedicalMxDO.setPrice(mxObject.getString("xmdj00"));
                                        ylzMedicalMxDO.setAmount(mxObject.getString("xmsl00"));
                                        ylzMedicalMxDO.setTotalMoney(mxObject.getString("xmje00"));
                                        ylzMedicalMxDO.setSingleDose(mxObject.getString("ypyl00"));
                                        ylzMedicalMxDO.setUseFrequency(mxObject.getString("yppl00"));
                                        ylzMedicalMxDO.setMedicalWay(mxObject.getString("gytj00"));
                                        ylzMedicalMxDO.setPrescriptionDate(DateUtil.strToYmdDateLong(mxObject.getString("xmrq00")+" "+mxObject.getString("xmsj00")));
                                        ylzMedicalMxDO.setMedicationDays(mxObject.getString("ylts00"));
                                        ylzMedicalMxDO.setDeptCode(resultJSON.getString("ksbm00"));
                                        ylzMedicalMxDO.setDeptName(resultJSON.getString("ghksmc"));
                                        ylzMedicalMxDO.setHisDeptCode(resultJSON.getString("ksbm00"));
                                        ylzMedicalMxDO.setHisDeptName(resultJSON.getString("ghksmc"));
                                        ylzMedicalMxDO.setMedicalPerName(resultJSON.getString("ysxm00"));
                                        ylzMedicalMxDO.setMedicalPerId(baseDoctorDO.getAtddrNo());
                                        ylzMedicalMxDO.setLimitType(mxObject.getString("sfybxm"));
                                        ylzMedicalMxDO.setActgDate(DateUtil.strToYmdDateLong(mxObject.getString("xmrq00")+" "+mxObject.getString("xmsj00")));
                                        ylzMedicalMxDO.setHisItemName(mxObject.getString("xmmc00"));
                                        ylzMedicalMxDO.setHisItemCode(mxObject.getString("xmbh00"));
                                        ylzMedicalMxDO.setClerkDays(DateUtil.strToYmdDateLong(mxObject.getString("xmrq00")+" "+mxObject.getString("xmsj00")));
                                        ylzMedicalMxDO.setPeopleType(null);
                                        ylzMedicalMxDO = ylzMedicailMxDao.save(ylzMedicalMxDO);
                                        mxDOList.add(ylzMedicalMxDO);
                                    }else if (json instanceof JSONArray){
                                        JSONArray mxArray = (JSONArray)json;
                                        for (int k=0;k<mxArray.size();k++){
                                            net.sf.json.JSONObject mxObject = mxArray.getJSONObject(k);
                                            YlzMedicalMxDO ylzMedicalMxDO = new YlzMedicalMxDO();
                                            ylzMedicalMxDO.setMedicalId(ylzMedicalRelationDO.getId());
                                            ylzMedicalMxDO.setDel(1);
                                            ylzMedicalMxDO.setPrescriptionCode(resultJSON.getString("xtgzh0"));
                                            ylzMedicalMxDO.setHisDetailSn(outpatientDO.getRegisterNo());
                                            ylzMedicalMxDO.setItemCode(mxObject.getString("xmbh00"));
                                            ylzMedicalMxDO.setItemName(mxObject.getString("xmmc00"));
                                            ylzMedicalMxDO.setInvoiceType("01");
                                            ylzMedicalMxDO.setSpecificationType(mxObject.getString("xmgg00"));
                                            ylzMedicalMxDO.setDosageForm(mxObject.getString("jx0000"));
                                            ylzMedicalMxDO.setChargeUnit(mxObject.getString("xmdw00"));
                                            ylzMedicalMxDO.setPrice(mxObject.getString("xmdj00"));
                                            ylzMedicalMxDO.setAmount(mxObject.getString("xmsl00"));
                                            ylzMedicalMxDO.setTotalMoney(mxObject.getString("xmje00"));
                                            ylzMedicalMxDO.setSingleDose(mxObject.getString("ypyl00"));
                                            ylzMedicalMxDO.setUseFrequency(mxObject.getString("yppl00"));
                                            ylzMedicalMxDO.setMedicalWay(mxObject.getString("gytj00"));
                                            ylzMedicalMxDO.setPrescriptionDate(DateUtil.strToYmdDateLong(mxObject.getString("xmrq00")+" "+mxObject.getString("xmsj00")));
                                            ylzMedicalMxDO.setMedicationDays(mxObject.getString("ylts00"));
                                            ylzMedicalMxDO.setDeptCode(resultJSON.getString("ksbm00"));
                                            ylzMedicalMxDO.setDeptName(resultJSON.getString("ghksmc"));
                                            ylzMedicalMxDO.setHisDeptCode(resultJSON.getString("ksbm00"));
                                            ylzMedicalMxDO.setHisDeptName(resultJSON.getString("ghksmc"));
                                            ylzMedicalMxDO.setMedicalPerName(resultJSON.getString("ysxm00"));
                                            ylzMedicalMxDO.setMedicalPerId(baseDoctorDO.getAtddrNo());
                                            if (mxObject.getString("xmbh00").equalsIgnoreCase("XA11GAW043A001010202251")){
                                                ylzMedicalMxDO.setLimitType("N");
                                            }else {
                                                ylzMedicalMxDO.setLimitType(mxObject.getString("sfybxm"));
                                            }
                                            ylzMedicalMxDO.setActgDate(DateUtil.strToYmdDateLong(mxObject.getString("xmrq00")+" "+mxObject.getString("xmsj00")));
                                            ylzMedicalMxDO.setHisItemName(mxObject.getString("xmmc00"));
                                            ylzMedicalMxDO.setHisItemCode(mxObject.getString("xmbh00"));
                                            ylzMedicalMxDO.setClerkDays(DateUtil.strToYmdDateLong(mxObject.getString("xmrq00")+" "+mxObject.getString("xmsj00")));
                                            ylzMedicalMxDO.setPeopleType(null);
                                            ylzMedicalMxDO = ylzMedicailMxDao.save(ylzMedicalMxDO);
                                            mxDOList.add(ylzMedicalMxDO);
                                        }
                                    }
                                }
                                ylzMedicalRelationDO.setYlzMedicalIcdDOList(icdDOList);
                                ylzMedicalRelationDO.setYlzMedicalMxDOList(mxDOList);
                                relationDOList.add(ylzMedicalRelationDO);
                            }
                        }
                    }
                }
            }
        }
        return relationDOList;
    }
    public YlzMedicalRelationDO getSettleInfo(String cardno,String idcard,String outpatientId,String realOrder) throws Exception {
        WlyyOutpatientDO outpatientDO = outpatientDao.findById(outpatientId);
        net.sf.json.JSONObject object1 = qutpatientBalance(outpatientDO.getCardNo(), false);
        Double cardFee = object1.getDouble("ZHYE");
/*        Double cardFee = 0.0;*/
        net.sf.json.JSONArray result = BS10108(cardno,idcard,"1",null,null,null,outpatientDO.getRegisterNo(),false);
        if (result!=null&&result.size()!=0){
            net.sf.json.JSONObject object = result.getJSONObject(0);
            net.sf.json.JSONObject jsonObject = object.getJSONObject("retInfo");
            if (jsonObject.getString("retCode").equalsIgnoreCase("00")){
                Object obj = com.alibaba.fastjson.JSON.parse(object.getString("msgInfo"));
                net.sf.json.JSONObject msgInfoJson = new net.sf.json.JSONObject();
                net.sf.json.JSONObject resultJSON = new net.sf.json.JSONObject();
                if (obj instanceof JSONObject){
                    msgInfoJson = object.getJSONObject("msgInfo");
                    resultJSON = msgInfoJson.getJSONObject("receipt");
                }else if (obj instanceof com.alibaba.fastjson.JSONArray){
                    JSONArray array =  object.getJSONArray("msgInfo");
                    for (int i=0;i<array.size();i++){
                        net.sf.json.JSONObject msgObj = array.getJSONObject(i);
                        if (msgObj.getString("xtgzh0").equalsIgnoreCase(realOrder)){
                            resultJSON = msgObj;
                            break;
                        }
                    }
                }
                System.out.println("1111111111111111111111"+resultJSON);
                if (resultJSON!=null){
                    YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByLog_no(resultJSON.getString("xtgzh0"));
                    List<WlyyPrescriptionDO> prescriptionDOList = prescriptionDao.findByRealOrderAndStatusList(resultJSON.getString("xtgzh0"));
                    String diseaseCode = "";
                    if (prescriptionDOList!=null&&prescriptionDOList.size()!=0){
                        diseaseCode= prescriptionDOList.get(0).getDiseaseCode();
                    }
                    List<YlzMedicalIcdDO> icdDOList = new ArrayList<>();
                    List<YlzMedicalMxDO> mxDOList = new ArrayList<>();
                    if (ylzMedicalRelationDO==null){
                        ylzMedicalRelationDO = new YlzMedicalRelationDO();
                        ylzMedicalRelationDO.setLogNo(resultJSON.getString("xtgzh0"));
                        ylzMedicalRelationDO.setOrgCode("3502000303");
                        ylzMedicalRelationDO.setRegionCode("350200");
                        ylzMedicalRelationDO.setIdcard(outpatientDO.getIdcard());
                        ylzMedicalRelationDO.setName(resultJSON.getString("xming0"));
                        ylzMedicalRelationDO.setCertType("01");
                        ylzMedicalRelationDO.setMedicalMode("10");
                        if (StringUtils.isNoneBlank(outpatientDO.getDiseaseCode())){
                            ylzMedicalRelationDO.setMedicalType("13");
                        }else {
                            ylzMedicalRelationDO.setMedicalType("11");
                        }
                        ylzMedicalRelationDO.setCardNo(cardno);
                        ylzMedicalRelationDO.setHisSerial(outpatientDO.getRegisterNo());
                        ylzMedicalRelationDO.setHisSettleNo(resultJSON.getString("xtgzh0"));
                        ylzMedicalRelationDO.setDeptCode(resultJSON.getString("ksbm00"));
                        ylzMedicalRelationDO.setDeptName(resultJSON.getString("ghksmc"));
                        ylzMedicalRelationDO.setHisDeptCode(resultJSON.getString("ksbm00"));
                        ylzMedicalRelationDO.setHisDeptName(resultJSON.getString("ghksmc"));
                        ylzMedicalRelationDO.setEmergencySign("0");
                        ylzMedicalRelationDO.setTraumaSign("0");
                        ylzMedicalRelationDO.setDate(outpatientDO.getRegisterDate());
                        ylzMedicalRelationDO.setItemCount(resultJSON.getString("cfxms0"));
                        ylzMedicalRelationDO.setTotalAmount(resultJSON.getString("bcfyze"));
                        ylzMedicalRelationDO.setPreCharges(resultJSON.getString("bcfyze"));
                        ylzMedicalRelationDO.setBcwkje(resultJSON.getString("bcwkje"));
                        ylzMedicalRelationDO.setPersonAccount("0");
                        ylzMedicalRelationDO.setDataSource("53");
                        ylzMedicalRelationDO.setBalance(cardFee+"");
                        ylzMedicalRelationDO.setDiseaseCode(diseaseCode);
                        ylzMedicalRelationDO.setPreCount(resultJSON.getString("cfxms0"));
                        BaseDoctorDO baseDoctorDO = baseDoctorDao.findById(outpatientDO.getDoctor());
                        if (baseDoctorDO!=null){
                            String jobTitle = baseDoctorDO.getJobTitleCode();
                        }
                        ylzMedicalRelationDO.setDoctorLevel("02");
                        ylzMedicalRelationDO.setDel(1);
                        ylzMedicalRelationDO.setStatus(0);
                        ylzMedicalRelationDO.setState(0);
                        ylzMedicalRelationDO.setRelationCode(outpatientDO.getId());
                        ylzMedicalRelationDO.setCreateTime(new Date());
                        ylzMedicalRelationDO.setMedicalPrice("0");
                        if (outpatientDO.getMedicalState()==null){
                            ylzMedicalRelationDO.setMedicalState(0);
                            ylzMedicalRelationDO.setPersonCash(resultJSON.getString("bcfyze"));
                        }else {
                            if (outpatientDO.getMedicalState().equalsIgnoreCase("0")){
                                ylzMedicalRelationDO.setPersonCash(resultJSON.getString("bcfyze"));
                            }
                            ylzMedicalRelationDO.setMedicalState(Integer.parseInt(outpatientDO.getMedicalState()));
                        }
                        ylzMedicalRelationDO = ylzMedicailRelationDao.save(ylzMedicalRelationDO);
                        if (resultJSON.get("zdlists")!=null){
                            Object json = new JSONTokener(resultJSON.getString("zdlists")).nextValue();
                            if(json instanceof net.sf.json.JSONObject){
                                net.sf.json.JSONObject mxListJSON = (net.sf.json.JSONObject)json;
                                net.sf.json.JSONObject mxObject = mxListJSON.getJSONObject("mxlist");
                                net.sf.json.JSONObject icdJSON = (net.sf.json.JSONObject)json;
                                net.sf.json.JSONObject icdJson = icdJSON.getJSONObject("zdlist");
                                YlzMedicalIcdDO ylzMedicalIcdDO = new YlzMedicalIcdDO();
                                ylzMedicalIcdDO.setMedicalId(ylzMedicalRelationDO.getId());
                                ylzMedicalIcdDO.setDel(1);
                                ylzMedicalIcdDO.setCreateTime(new Date());
                                ylzMedicalIcdDO.setDiseaseType(icdJson.getString("zdlx"));
                                ylzMedicalIcdDO.setDiseaseCodeIcd10(icdJson.getString("zdbm"));
                                ylzMedicalIcdDO.setDiseaseNameIcd10(icdJson.getString("zdmc"));
                                ylzMedicalIcdDO.setDiseaseOrder(icdJson.getString("zdxh"));
                                ylzMedicalIcdDO = ylzMedicailIcdDao.save(ylzMedicalIcdDO);
                                icdDOList.add(ylzMedicalIcdDO);
                            } else if (json instanceof JSONArray) {
                                JSONArray icdArray = (JSONArray)json;
                                for (int k=0;k<icdArray.size();k++) {
                                    net.sf.json.JSONObject icdObject = icdArray.getJSONObject(k);
                                    YlzMedicalIcdDO ylzMedicalIcdDO = new YlzMedicalIcdDO();
                                    ylzMedicalIcdDO.setMedicalId(ylzMedicalRelationDO.getId());
                                    ylzMedicalIcdDO.setDel(1);
                                    ylzMedicalIcdDO.setCreateTime(new Date());
                                    ylzMedicalIcdDO.setDiseaseType(icdObject.getString("zdlx"));
                                    ylzMedicalIcdDO.setDiseaseCodeIcd10(icdObject.getString("zdbm"));
                                    ylzMedicalIcdDO.setDiseaseNameIcd10(icdObject.getString("zdmc"));
                                    ylzMedicalIcdDO.setDiseaseOrder(icdObject.getString("zdxh"));
                                    ylzMedicalIcdDO = ylzMedicailIcdDao.save(ylzMedicalIcdDO);
                                    icdDOList.add(ylzMedicalIcdDO);
                                }
                            }
                        }
                        Object json = new JSONTokener(resultJSON.getString("mxlists")).nextValue();
                        if(json instanceof net.sf.json.JSONObject){
                            net.sf.json.JSONObject mxListJSON = (net.sf.json.JSONObject)json;
                            net.sf.json.JSONObject mxObject = mxListJSON.getJSONObject("mxlist");
                            YlzMedicalMxDO ylzMedicalMxDO = new YlzMedicalMxDO();
                            ylzMedicalMxDO.setMedicalId(ylzMedicalRelationDO.getId());
                            ylzMedicalMxDO.setDel(1);
                            ylzMedicalMxDO.setPrescriptionCode(resultJSON.getString("xtgzh0"));
                            ylzMedicalMxDO.setHisDetailSn(outpatientDO.getRegisterNo());
                            ylzMedicalMxDO.setItemCode(mxObject.getString("xmbh00"));
                            ylzMedicalMxDO.setItemName(mxObject.getString("xmmc00"));
                            ylzMedicalMxDO.setInvoiceType("01");
                            ylzMedicalMxDO.setSpecificationType(mxObject.getString("xmgg00"));
                            ylzMedicalMxDO.setDosageForm(mxObject.getString("jx0000"));
                            ylzMedicalMxDO.setChargeUnit(mxObject.getString("xmdw00"));
                            ylzMedicalMxDO.setPrice(mxObject.getString("xmdj00"));
                            ylzMedicalMxDO.setAmount(mxObject.getString("xmsl00"));
                            ylzMedicalMxDO.setTotalMoney(mxObject.getString("xmje00"));
                            ylzMedicalMxDO.setSingleDose(mxObject.getString("ypyl00"));
                            ylzMedicalMxDO.setUseFrequency(mxObject.getString("yppl00"));
                            ylzMedicalMxDO.setMedicalWay(mxObject.getString("gytj00"));
                            ylzMedicalMxDO.setPrescriptionDate(DateUtil.strToYmdDateLong(mxObject.getString("xmrq00")+" "+mxObject.getString("xmsj00")));
                            ylzMedicalMxDO.setMedicationDays(mxObject.getString("ylts00"));
                            ylzMedicalMxDO.setDeptCode(resultJSON.getString("ksbm00"));
                            ylzMedicalMxDO.setDeptName(resultJSON.getString("ghksmc"));
                            ylzMedicalMxDO.setHisDeptCode(resultJSON.getString("ksbm00"));
                            ylzMedicalMxDO.setHisDeptName(resultJSON.getString("ghksmc"));
                            ylzMedicalMxDO.setMedicalPerName(resultJSON.getString("ysxm00"));
                            ylzMedicalMxDO.setMedicalPerId(baseDoctorDO.getAtddrNo());
                            ylzMedicalMxDO.setLimitType(mxObject.getString("sfybxm"));
                            ylzMedicalMxDO.setActgDate(DateUtil.strToYmdDateLong(mxObject.getString("xmrq00")+" "+mxObject.getString("xmsj00")));
                            ylzMedicalMxDO.setHisItemName(mxObject.getString("xmmc00"));
                            ylzMedicalMxDO.setHisItemCode(mxObject.getString("xmbh00"));
                            ylzMedicalMxDO.setClerkDays(DateUtil.strToYmdDateLong(mxObject.getString("xmrq00")+" "+mxObject.getString("xmsj00")));
                            ylzMedicalMxDO.setPeopleType(null);
                            ylzMedicalMxDO = ylzMedicailMxDao.save(ylzMedicalMxDO);
                            mxDOList.add(ylzMedicalMxDO);
                        }else if (json instanceof JSONArray){
                            JSONArray mxArray = (JSONArray)json;
                            for (int k=0;k<mxArray.size();k++){
                                net.sf.json.JSONObject mxObject = mxArray.getJSONObject(k);
                                YlzMedicalMxDO ylzMedicalMxDO = new YlzMedicalMxDO();
                                ylzMedicalMxDO.setMedicalId(ylzMedicalRelationDO.getId());
                                ylzMedicalMxDO.setDel(1);
@ -3935,59 +4534,189 @@ public class EntranceService {
                                ylzMedicalMxDO.setPeopleType(null);
                                ylzMedicalMxDO = ylzMedicailMxDao.save(ylzMedicalMxDO);
                                mxDOList.add(ylzMedicalMxDO);
                            }else if (json instanceof JSONArray){
                                JSONArray mxArray = (JSONArray)json;
                                for (int k=0;k<mxArray.size();k++){
                                    net.sf.json.JSONObject mxObject = mxArray.getJSONObject(k);
                                    YlzMedicalMxDO ylzMedicalMxDO = new YlzMedicalMxDO();
                                    ylzMedicalMxDO.setMedicalId(ylzMedicalRelationDO.getId());
                                    ylzMedicalMxDO.setDel(1);
                                    ylzMedicalMxDO.setPrescriptionCode(resultJSON.getString("xtgzh0"));
                                    ylzMedicalMxDO.setHisDetailSn(outpatientDO.getRegisterNo());
                                    ylzMedicalMxDO.setItemCode(mxObject.getString("xmbh00"));
                                    ylzMedicalMxDO.setItemName(mxObject.getString("xmmc00"));
                                    ylzMedicalMxDO.setInvoiceType("01");
                                    ylzMedicalMxDO.setSpecificationType(mxObject.getString("xmgg00"));
                                    ylzMedicalMxDO.setDosageForm(mxObject.getString("jx0000"));
                                    ylzMedicalMxDO.setChargeUnit(mxObject.getString("xmdw00"));
                                    ylzMedicalMxDO.setPrice(mxObject.getString("xmdj00"));
                                    ylzMedicalMxDO.setAmount(mxObject.getString("xmsl00"));
                                    ylzMedicalMxDO.setTotalMoney(mxObject.getString("xmje00"));
                                    ylzMedicalMxDO.setSingleDose(mxObject.getString("ypyl00"));
                                    ylzMedicalMxDO.setUseFrequency(mxObject.getString("yppl00"));
                                    ylzMedicalMxDO.setMedicalWay(mxObject.getString("gytj00"));
                                    ylzMedicalMxDO.setPrescriptionDate(DateUtil.strToYmdDateLong(mxObject.getString("xmrq00")+" "+mxObject.getString("xmsj00")));
                                    ylzMedicalMxDO.setMedicationDays(mxObject.getString("ylts00"));
                                    ylzMedicalMxDO.setDeptCode(resultJSON.getString("ksbm00"));
                                    ylzMedicalMxDO.setDeptName(resultJSON.getString("ghksmc"));
                                    ylzMedicalMxDO.setHisDeptCode(resultJSON.getString("ksbm00"));
                                    ylzMedicalMxDO.setHisDeptName(resultJSON.getString("ghksmc"));
                                    ylzMedicalMxDO.setMedicalPerName(resultJSON.getString("ysxm00"));
                                    ylzMedicalMxDO.setMedicalPerId(baseDoctorDO.getAtddrNo());
                                    if (mxObject.getString("xmbh00").equalsIgnoreCase("XA11GAW043A001010202251")){
                                        ylzMedicalMxDO.setLimitType("N");
                                    }else {
                                        ylzMedicalMxDO.setLimitType(mxObject.getString("sfybxm"));
                                    }
                                    ylzMedicalMxDO.setActgDate(DateUtil.strToYmdDateLong(mxObject.getString("xmrq00")+" "+mxObject.getString("xmsj00")));
                                    ylzMedicalMxDO.setHisItemName(mxObject.getString("xmmc00"));
                                    ylzMedicalMxDO.setHisItemCode(mxObject.getString("xmbh00"));
                                    ylzMedicalMxDO.setClerkDays(DateUtil.strToYmdDateLong(mxObject.getString("xmrq00")+" "+mxObject.getString("xmsj00")));
                                    ylzMedicalMxDO.setPeopleType(null);
                                    ylzMedicalMxDO = ylzMedicailMxDao.save(ylzMedicalMxDO);
                                    mxDOList.add(ylzMedicalMxDO);
                            }
                        }
                    }else {
                        ylzMedicalRelationDO.setOrgCode("3502000303");
                        ylzMedicalRelationDO.setRegionCode("350200");
                        ylzMedicalRelationDO.setDiseaseCode(diseaseCode);
                        ylzMedicalRelationDO.setIdcard(outpatientDO.getIdcard());
                        ylzMedicalRelationDO.setName(resultJSON.getString("xming0"));
                        ylzMedicalRelationDO.setCertType("01");
                        ylzMedicalRelationDO.setMedicalMode("10");
                        if (StringUtils.isNoneBlank(outpatientDO.getDiseaseCode())){
                            ylzMedicalRelationDO.setMedicalType("13");
                        }else {
                            ylzMedicalRelationDO.setMedicalType("11");
                        }
                        ylzMedicalRelationDO.setHisSerial(outpatientDO.getRegisterNo());
                        ylzMedicalRelationDO.setHisSettleNo(resultJSON.getString("xtgzh0"));
                        ylzMedicalRelationDO.setDeptCode(resultJSON.getString("ksbm00"));
                        ylzMedicalRelationDO.setDeptName(resultJSON.getString("ghksmc"));
                        ylzMedicalRelationDO.setHisDeptCode(resultJSON.getString("ksbm00"));
                        ylzMedicalRelationDO.setHisDeptName(resultJSON.getString("ghksmc"));
                        ylzMedicalRelationDO.setEmergencySign("0");
                        ylzMedicalRelationDO.setTraumaSign("0");
                        ylzMedicalRelationDO.setCardNo(cardno);
                        ylzMedicalRelationDO.setDate(outpatientDO.getRegisterDate());
                        ylzMedicalRelationDO.setItemCount(resultJSON.getString("cfxms0"));
                        ylzMedicalRelationDO.setTotalAmount(resultJSON.getString("bcfyze"));
                        ylzMedicalRelationDO.setPreCharges(resultJSON.getString("bcfyze"));
                        ylzMedicalRelationDO.setBcwkje(resultJSON.getString("bcwkje"));
                        ylzMedicalRelationDO.setDataSource("53");
                        ylzMedicalRelationDO.setPreCount(resultJSON.getString("cfxms0"));
                        ylzMedicalRelationDO.setBalance(cardFee+"");
                        ylzMedicalRelationDO.setMedicalPrice("0");
                        BaseDoctorDO baseDoctorDO = baseDoctorDao.findById(outpatientDO.getDoctor());
                        if (baseDoctorDO!=null){
                            String jobTitle = baseDoctorDO.getJobTitleCode();
                        }
                        if (outpatientDO.getMedicalState()==null){
                            ylzMedicalRelationDO.setMedicalState(0);
                            ylzMedicalRelationDO.setPersonCash(resultJSON.getString("bcfyze"));
                        }else {
                            if (outpatientDO.getMedicalState().equalsIgnoreCase("0")){
                                ylzMedicalRelationDO.setPersonCash(resultJSON.getString("bcfyze"));
                            }
                            ylzMedicalRelationDO.setMedicalState(Integer.parseInt(outpatientDO.getMedicalState()));
                        }
                        ylzMedicalRelationDO.setDoctorLevel("02");
                        ylzMedicalRelationDO.setDel(1);
                        ylzMedicalRelationDO.setRelationCode(outpatientDO.getId());
                        ylzMedicalRelationDO.setCreateTime(new Date());
                        ylzMedicalRelationDO.setStatus(0);
                        ylzMedicalRelationDO = ylzMedicailRelationDao.save(ylzMedicalRelationDO);
                        ylzMedicailIcdDao.deleteByMedicalId(ylzMedicalRelationDO.getId());
                        /*YlzMedicalIcdDO ylzMedicalIcdDO = new YlzMedicalIcdDO();
                        ylzMedicalIcdDO.setMedicalId(ylzMedicalRelationDO.getId());
                        ylzMedicalIcdDO.setDel(1);
                        ylzMedicalIcdDO.setCreateTime(new Date());
                        ylzMedicalIcdDO.setDiseaseType("01");
                        ylzMedicalIcdDO.setDiseaseCodeIcd10(resultJSON.getString("bqzdbm"));
                        ylzMedicalIcdDO.setDiseaseNameIcd10(resultJSON.getString("bqzdms"));
                        ylzMedicalIcdDO.setDiseaseOrder("01");
                        ylzMedicalIcdDO = ylzMedicailIcdDao.save(ylzMedicalIcdDO);
                        icdDOList.add(ylzMedicalIcdDO);*/
                        if (resultJSON.get("zdlists")!=null){
                            Object json = new JSONTokener(resultJSON.getString("zdlists")).nextValue();
                            if(json instanceof net.sf.json.JSONObject){
                                net.sf.json.JSONObject icdJSON = (net.sf.json.JSONObject)json;
                                net.sf.json.JSONObject icdJson = icdJSON.getJSONObject("zdlist");
                                YlzMedicalIcdDO ylzMedicalIcdDO = new YlzMedicalIcdDO();
                                ylzMedicalIcdDO.setMedicalId(ylzMedicalRelationDO.getId());
                                ylzMedicalIcdDO.setDel(1);
                                ylzMedicalIcdDO.setCreateTime(new Date());
                                ylzMedicalIcdDO.setDiseaseType(icdJson.getString("zdlx"));
                                ylzMedicalIcdDO.setDiseaseCodeIcd10(icdJson.getString("zdbm"));
                                ylzMedicalIcdDO.setDiseaseNameIcd10(icdJson.getString("zdmc"));
                                ylzMedicalIcdDO.setDiseaseOrder(icdJson.getString("zdxh"));
                                ylzMedicalIcdDO = ylzMedicailIcdDao.save(ylzMedicalIcdDO);
                                icdDOList.add(ylzMedicalIcdDO);
                            } else if (json instanceof JSONArray) {
                                JSONArray icdArray = (JSONArray)json;
                                for (int k=0;k<icdArray.size();k++) {
                                    net.sf.json.JSONObject icdObject = icdArray.getJSONObject(k);
                                    YlzMedicalIcdDO ylzMedicalIcdDO = new YlzMedicalIcdDO();
                                    ylzMedicalIcdDO.setMedicalId(ylzMedicalRelationDO.getId());
                                    ylzMedicalIcdDO.setDel(1);
                                    ylzMedicalIcdDO.setCreateTime(new Date());
                                    ylzMedicalIcdDO.setDiseaseType(icdObject.getString("zdlx"));
                                    ylzMedicalIcdDO.setDiseaseCodeIcd10(icdObject.getString("zdbm"));
                                    ylzMedicalIcdDO.setDiseaseNameIcd10(icdObject.getString("zdmc"));
                                    ylzMedicalIcdDO.setDiseaseOrder(icdObject.getString("zdxh"));
                                    ylzMedicalIcdDO = ylzMedicailIcdDao.save(ylzMedicalIcdDO);
                                    icdDOList.add(ylzMedicalIcdDO);
                                }
                            }
                        }
                        ylzMedicailMxDao.deleteByMedicalId(ylzMedicalRelationDO.getId());
                        Object json = new JSONTokener(resultJSON.getString("mxlists")).nextValue();
                        if(json instanceof net.sf.json.JSONObject){
                            net.sf.json.JSONObject mxListJSON = (net.sf.json.JSONObject)json;
                            net.sf.json.JSONObject mxObject = mxListJSON.getJSONObject("mxlist");
                            YlzMedicalMxDO ylzMedicalMxDO = new YlzMedicalMxDO();
                            ylzMedicalMxDO.setMedicalId(ylzMedicalRelationDO.getId());
                            ylzMedicalMxDO.setDel(1);
                            ylzMedicalMxDO.setPrescriptionCode(resultJSON.getString("xtgzh0"));
                            ylzMedicalMxDO.setHisDetailSn(outpatientDO.getRegisterNo());
                            ylzMedicalMxDO.setItemCode(mxObject.getString("xmbh00"));
                            ylzMedicalMxDO.setItemName(mxObject.getString("xmmc00"));
                            ylzMedicalMxDO.setInvoiceType("01");
                            ylzMedicalMxDO.setSpecificationType(mxObject.getString("xmgg00"));
                            ylzMedicalMxDO.setDosageForm(mxObject.getString("jx0000"));
                            ylzMedicalMxDO.setChargeUnit(mxObject.getString("xmdw00"));
                            ylzMedicalMxDO.setPrice(mxObject.getString("xmdj00"));
                            ylzMedicalMxDO.setAmount(mxObject.getString("xmsl00"));
                            ylzMedicalMxDO.setTotalMoney(mxObject.getString("xmje00"));
                            ylzMedicalMxDO.setSingleDose(mxObject.getString("ypyl00"));
                            ylzMedicalMxDO.setUseFrequency(mxObject.getString("yppl00"));
                            ylzMedicalMxDO.setMedicalWay(mxObject.getString("gytj00"));
                            ylzMedicalMxDO.setPrescriptionDate(DateUtil.strToYmdDateLong(mxObject.getString("xmrq00")+" "+mxObject.getString("xmsj00")));
                            ylzMedicalMxDO.setMedicationDays(mxObject.getString("ylts00"));
                            ylzMedicalMxDO.setDeptCode(resultJSON.getString("ksbm00"));
                            ylzMedicalMxDO.setDeptName(resultJSON.getString("ghksmc"));
                            ylzMedicalMxDO.setHisDeptCode(resultJSON.getString("ksbm00"));
                            ylzMedicalMxDO.setHisDeptName(resultJSON.getString("ghksmc"));
                            ylzMedicalMxDO.setMedicalPerName(resultJSON.getString("ysxm00"));
                            ylzMedicalMxDO.setMedicalPerId(baseDoctorDO.getAtddrNo());
                            ylzMedicalMxDO.setLimitType(mxObject.getString("sfybxm"));
                            ylzMedicalMxDO.setActgDate(DateUtil.strToYmdDateLong(mxObject.getString("xmrq00")+" "+mxObject.getString("xmsj00")));
                            ylzMedicalMxDO.setHisItemName(mxObject.getString("xmmc00"));
                            ylzMedicalMxDO.setHisItemCode(mxObject.getString("xmbh00"));
                            ylzMedicalMxDO.setClerkDays(DateUtil.strToYmdDateLong(mxObject.getString("xmrq00")+" "+mxObject.getString("xmsj00")));
                            ylzMedicalMxDO.setPeopleType(null);
                            ylzMedicalMxDO = ylzMedicailMxDao.save(ylzMedicalMxDO);
                            mxDOList.add(ylzMedicalMxDO);
                        }else if (json instanceof JSONArray){
                            JSONArray mxArray = (JSONArray)json;
                            for (int k=0;k<mxArray.size();k++){
                                net.sf.json.JSONObject mxObject = mxArray.getJSONObject(k);
                                YlzMedicalMxDO ylzMedicalMxDO = new YlzMedicalMxDO();
                                ylzMedicalMxDO.setMedicalId(ylzMedicalRelationDO.getId());
                                ylzMedicalMxDO.setDel(1);
                                ylzMedicalMxDO.setPrescriptionCode(resultJSON.getString("xtgzh0"));
                                ylzMedicalMxDO.setHisDetailSn(outpatientDO.getRegisterNo());
                                ylzMedicalMxDO.setItemCode(mxObject.getString("xmbh00"));
                                ylzMedicalMxDO.setItemName(mxObject.getString("xmmc00"));
                                ylzMedicalMxDO.setInvoiceType("01");
                                ylzMedicalMxDO.setSpecificationType(mxObject.getString("xmgg00"));
                                ylzMedicalMxDO.setDosageForm(mxObject.getString("jx0000"));
                                ylzMedicalMxDO.setChargeUnit(mxObject.getString("xmdw00"));
                                ylzMedicalMxDO.setPrice(mxObject.getString("xmdj00"));
                                ylzMedicalMxDO.setAmount(mxObject.getString("xmsl00"));
                                ylzMedicalMxDO.setTotalMoney(mxObject.getString("xmje00"));
                                ylzMedicalMxDO.setSingleDose(mxObject.getString("ypyl00"));
                                ylzMedicalMxDO.setUseFrequency(mxObject.getString("yppl00"));
                                ylzMedicalMxDO.setMedicalWay(mxObject.getString("gytj00"));
                                ylzMedicalMxDO.setPrescriptionDate(DateUtil.strToYmdDateLong(mxObject.getString("xmrq00")+" "+mxObject.getString("xmsj00")));
                                ylzMedicalMxDO.setMedicationDays(mxObject.getString("ylts00"));
                                ylzMedicalMxDO.setDeptCode(resultJSON.getString("ksbm00"));
                                ylzMedicalMxDO.setDeptName(resultJSON.getString("ghksmc"));
                                ylzMedicalMxDO.setHisDeptCode(resultJSON.getString("ksbm00"));
                                ylzMedicalMxDO.setHisDeptName(resultJSON.getString("ghksmc"));
                                ylzMedicalMxDO.setMedicalPerName(resultJSON.getString("ysxm00"));
                                ylzMedicalMxDO.setMedicalPerId(baseDoctorDO.getAtddrNo());
                                if (mxObject.getString("xmbh00").equalsIgnoreCase("XA11GAW043A001010202251")){
                                    ylzMedicalMxDO.setLimitType("N");
                                }else {
                                    ylzMedicalMxDO.setLimitType(mxObject.getString("sfybxm"));
                                }
                                ylzMedicalMxDO.setActgDate(DateUtil.strToYmdDateLong(mxObject.getString("xmrq00")+" "+mxObject.getString("xmsj00")));
                                ylzMedicalMxDO.setHisItemName(mxObject.getString("xmmc00"));
                                ylzMedicalMxDO.setHisItemCode(mxObject.getString("xmbh00"));
                                ylzMedicalMxDO.setClerkDays(DateUtil.strToYmdDateLong(mxObject.getString("xmrq00")+" "+mxObject.getString("xmsj00")));
                                ylzMedicalMxDO.setPeopleType(null);
                                ylzMedicalMxDO = ylzMedicailMxDao.save(ylzMedicalMxDO);
                                mxDOList.add(ylzMedicalMxDO);
                            }
                        }
                        ylzMedicalRelationDO.setYlzMedicalIcdDOList(icdDOList);
                        ylzMedicalRelationDO.setYlzMedicalMxDOList(mxDOList);
                        return ylzMedicalRelationDO;
                    }else {
                        return null;
                    }
                    ylzMedicalRelationDO.setYlzMedicalIcdDOList(icdDOList);
                    ylzMedicalRelationDO.setYlzMedicalMxDOList(mxDOList);
                    return ylzMedicalRelationDO;
                }else {
                    return null;
                }

+ 17 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/core/userdetails/jdbc/WlyyUserDetailsService.java

@ -1138,6 +1138,23 @@ public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetail
                    patientWechatDo.setWechatId("xm_hcyy_wx");
                    patientWechatDo.setCreateTime(new Date());
                    basePatientWechatDao.save(patientWechatDo);
                    //保存就诊人信息
                    WlyyPatientFamilyMemberDO basePatientFamilyMemberDO = familyMemberDao.findFamilyMemberByPatientAndRelationCode(patient1.getId(),"7");
                    if (basePatientFamilyMemberDO==null){
                        basePatientFamilyMemberDO = new WlyyPatientFamilyMemberDO();
                        basePatientFamilyMemberDO.setPatient(patient1.getId());
                        basePatientFamilyMemberDO.setFamilyRelation("7");
                        basePatientFamilyMemberDO.setFamilyRelationName("自己");
                        basePatientFamilyMemberDO.setCardType("身份证");
                        basePatientFamilyMemberDO.setCardNo(patient1.getIdcard());
                        basePatientFamilyMemberDO.setCreateTime(new Date());
                        basePatientFamilyMemberDO.setUpdateTime(new Date());
                        basePatientFamilyMemberDO.setIsAuthorize(1);
                        basePatientFamilyMemberDO.setIsDel(1);
                        basePatientFamilyMemberDO.setFamilyMember(patient1.getId());
                        familyMemberDao.save(basePatientFamilyMemberDO);
                    }
                    logger.info("结束同步患者数据");
                }
            }

+ 1 - 1
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/patient/PatientNoLoginEndPoint.java

@ -775,7 +775,7 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
                            }if (wxId.equalsIgnoreCase("xm_ykyy_wx")){
                                ykyyPrescriptionService.confirmSettlement(ylzMedicalRelationDO.getRelationCode());
                            }else {
                                prescriptionService.confirmSettlementService(ylzMedicalRelationDO.getRelationCode());
                                prescriptionService.confirmSettlementService(ylzMedicalRelationDO.getRelationCode(),ylzMedicalRelationDO.getLogNo());
                            }
                        }

+ 29 - 17
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/PrescriptionEndpoint.java

@ -18,6 +18,7 @@ import com.yihu.jw.entity.base.area.BaseTownDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.im.ConsultDo;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.entity.hospital.healthCare.YlzMedicalRelationDO;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.entity.hospital.prescription.*;
import com.yihu.jw.entity.order.BusinessOrderDO;
@ -3672,14 +3673,26 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
        }
    }*/
    @PostMapping("/getSettlementList")
    @ApiOperation(value = "获取患者待结算信息列表页面", notes = "获取患者待结算信息列表页面")
    public ListEnvelop getSettleList(
            @ApiParam(name = "outpatientId", value = "outpatientId")
            @RequestParam(value = "outpatientId", required = false) String outpatientId,
            @ApiParam(name = "flag", value = "flag")
            @RequestParam(value = "flag", required = false) Integer flag) throws Exception {
        return success("操作成功", prescriptionService.getSettleList(outpatientId,flag));
    }
    @PostMapping("/getSettlementInfo")
    @ApiOperation(value = "获取患者待结算信息页面", notes = "获取患者待结算信息页面")
    public Envelop getSettlementInfo(
            @ApiParam(name = "outpatientId", value = "outpatientId")
            @RequestParam(value = "outpatientId", required = false) String outpatientId,
            @ApiParam(name = "realOrder", value = "处方号")
            @RequestParam(value = "realOrder", required = false) String realOrder,
            @ApiParam(name = "flag", value = "flag")
            @RequestParam(value = "flag", required = false) Integer flag) throws Exception {
        return success("操作成功", prescriptionService.getSettlementInfo(outpatientId,flag));
        return success("操作成功", prescriptionService.getSettlementInfo(outpatientId,realOrder,flag));
    }
    @PostMapping("/confirmSettlementInfo")
@ -3696,29 +3709,28 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
    @ApiOperation(value = "确认费用结算", notes = "确认费用结算")
    public Envelop confirmSettlement(
            @ApiParam(name = "outpatientId", value = "outpatientId")
            @RequestParam(value = "outpatientId", required = false) String outpatientId) throws Exception {
        try {
            return success("操作成功", prescriptionService.confirmSettlement(outpatientId));
        } catch (Exception e) {
            return Envelop.getError(e.getMessage());
        }
            @RequestParam(value = "outpatientId", required = false) String outpatientId,
            @ApiParam(name = "realOrder", value = "realOrder")
            @RequestParam(value = "realOrder", required = false) String realOrder) throws Exception {
        return success("操作成功", prescriptionService.confirmSettlement(outpatientId,realOrder));
    }
    @PostMapping("/confirmSettlementService")
    @ApiOperation(value = "确认费用结算", notes = "确认费用结算")
    public Envelop confirmSettlementService(
            @ApiParam(name = "outpatientId", value = "outpatientId")
            @RequestParam(value = "outpatientId", required = false) String outpatientId) throws Exception {
        try {
            if (wxId.equalsIgnoreCase("xm_hcyy_wx")){
                return success("操作成功", hcyyPrescriptionService.confirmSettlement(outpatientId));
            }else if (wxId.equalsIgnoreCase("xm_ykyy_wx")){
                return success("操作成功", ykyyPrescriptionService.confirmSettlement(outpatientId));
            }
            return success("操作成功", prescriptionService.confirmSettlementService(outpatientId));
        } catch (Exception e) {
            return Envelop.getError(e.getMessage());
            @RequestParam(value = "outpatientId", required = false) String outpatientId,
            @ApiParam(name = "realOrder", value = "realOrder")
            @RequestParam(value = "realOrder", required = false) String realOrder) throws Exception {
        if (wxId.equalsIgnoreCase("xm_hcyy_wx")){
            return success("操作成功", hcyyPrescriptionService.confirmSettlement(outpatientId));
        }else if (wxId.equalsIgnoreCase("xm_ykyy_wx")){
            return success("操作成功", ykyyPrescriptionService.confirmSettlement(outpatientId));
        }
        return success("操作成功", prescriptionService.confirmSettlementService(outpatientId,realOrder));
    }