| 
					
				 | 
			
			
				@ -9,6 +9,8 @@ import com.yihu.jw.entity.base.doctor.BaseDoctorDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.base.patient.BasePatientDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.hospital.healthCare.YlzMedicalBillDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.hospital.healthCare.YlzMedicalRelationDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.hospital.httplog.YlzHttpLogDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.hospital.prescription.WlyyOutpatientDO; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -18,6 +20,8 @@ import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionInfoDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.healthCare.utils.AES; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.healthCare.utils.SafeUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.hospital.healthCare.YlzMedicailBillDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.hospital.healthCare.YlzMedicailRelationDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.hospital.httplog.dao.YlzHttpLogDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.hospital.mapping.dao.PatientMappingDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.hospital.prescription.dao.OutpatientDao; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -68,6 +72,10 @@ public class HealthCareService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private PatientMappingDao patientMappingDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private PrescriptionInfoDao prescriptionInfoDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private YlzMedicailRelationDao ylzMedicailRelationDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private YlzMedicailBillDao ylzMedicailBillDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private String ylzConfigUrl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private String ylzConfigAppid; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -579,7 +587,7 @@ public class HealthCareService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("zdlist",icdArray); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONArray infoArray = new JSONArray(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for (WlyyPrescriptionDO wlyyPrescriptionDO:wlyyPrescriptionDOS){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<WlyyPrescriptionInfoDO> prescriptionInfoDOS = prescriptionInfoDao.findByPrescriptionId(wlyyPrescriptionDO.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<WlyyPrescriptionInfoDO> prescriptionInfoDOS = prescriptionInfoDao.findByPrescriptionId(wlyyPrescriptionDO.getId(),1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for (WlyyPrescriptionInfoDO wlyyPrescriptionInfoDO:prescriptionInfoDOS){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                JSONObject infoObj = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                infoObj.put("prescription_code",wlyyPrescriptionDO.getRealOrder());//医院处方编号 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -606,8 +614,360 @@ public class HealthCareService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                infoArray.add(infoObj); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("mxlist",infoArray); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String result = requestYlz(data,funid,"医保费用明细上传"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (result==null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            throw new Exception("医保费用明细上传失败!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONObject object = JSONObject.parseObject(result); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (object.getString("flag").equalsIgnoreCase("1")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            JSONObject encryptData = object.getJSONObject("encrypt_data"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String detailSerial = encryptData.getString("detail_serial"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for (WlyyPrescriptionDO presDo:wlyyPrescriptionDOS){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                presDo.setDetailSerial(detailSerial); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                presDo.setMedicalStatus(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                prescriptionDao.save(presDo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            logger.info("医保费用明细上传失败保存成功"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 2.5.4医保费用明细上传冲销(N20.17.04.04) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 返回值 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param outpatientId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @throws Exception 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public String feeDetailRefund(String outpatientId,String prescriptionId,String remark) throws Exception{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String funid = "N20.17.04.04"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        WlyyOutpatientDO outpatientDO = outpatientDao.findById(outpatientId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (outpatientDO==null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            throw new Exception("上传医保失败:门诊为空!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONObject data = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("region_code","");//参保地区划代码 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("idcard",outpatientDO.getIdcard());//证件号码 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("name",outpatientDO.getPatientName());//姓名 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("medical_mode","");//医疗就诊方式 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("medical_type","");//医疗类别 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNoneBlank(prescriptionId)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            WlyyPrescriptionDO wlyyPrescriptionDO = prescriptionDao.findOne(prescriptionId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            data.put("detail_serial",wlyyPrescriptionDO.getDetailSerial());//医保明细流水号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("insurance_serial",outpatientDO.getInsuranceSerial());//医保流水号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("invalidation_reason",remark);//作废原因 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("data_source","");//数据来源 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String result = requestYlz(data,funid,"医保费用明细上传冲销"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (result==null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            throw new Exception("医保费用明细上传冲销失败!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONObject object = JSONObject.parseObject(result); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (object.getString("flag").equalsIgnoreCase("1")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (StringUtils.isNoneBlank(prescriptionId)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                WlyyPrescriptionDO wlyyPrescriptionDO = prescriptionDao.findOne(prescriptionId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                wlyyPrescriptionDO.setMedicalStatus(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                prescriptionDao.save(wlyyPrescriptionDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                List<WlyyPrescriptionDO> prescriptionDOList = prescriptionDao.findByOutPatientIdListAndMedical(outpatientId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                for (WlyyPrescriptionDO preDo:prescriptionDOList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    preDo.setMedicalStatus(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    prescriptionDao.save(preDo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            logger.info("医保费用明细上传冲销保存成功"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 2.5.5医保预结算服务(N20.17.04.05) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 返回值 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param outpatientId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @throws Exception 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public String preSettlement(String outpatientId) throws Exception{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String funid = "N20.17.04.05"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        WlyyOutpatientDO outpatientDO = outpatientDao.findById(outpatientId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (outpatientDO==null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            throw new Exception("上传医保失败:门诊为空!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONObject data = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("region_code","");//参保地区划代码 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("idcard",outpatientDO.getIdcard());//证件号码 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("name",outpatientDO.getPatientName());//姓名 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("cert_type","");//证件类型 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("medical_mode","");//医疗就诊方式 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("medical_type","");//医疗类别 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("his_bill_serial",outpatientDO.getXtgzh());//his收费单据流水号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("insurance_serial",outpatientDO.getInsuranceSerial());//医保流水号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("settlement_sign",0);//结算标识 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("date",outpatientDO.getAdmDate());//实际就诊日期 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("leave_method","");//离院方式 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("pre_count","");//处方项目数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("total_amount","");//医疗费总金额 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("data_source","");//数据来源 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("his_serial",outpatientDO.getRegisterNo());//his流水号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("doctor_level","");//医师诊查费等级 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("dept_code",outpatientDO.getDept());//科室编码 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("charge_qty","");//本次收费次数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("trt_fee_level","");//医师诊查费等级 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String result = requestYlz(data,funid,"医保预结算服务"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (result==null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            throw new Exception("医保预结算服务失败!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONObject object = JSONObject.parseObject(result); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (object.getString("flag").equalsIgnoreCase("1")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            JSONObject encryptData = object.getJSONObject("encrypt_data"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String billSerial = encryptData.getString("bill_serial"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            outpatientDO.setBillSerial(billSerial); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            outpatientDao.save(outpatientDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            YlzMedicalRelationDO ylzMr = new YlzMedicalRelationDO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            ylzMr.setCardNo(encryptData.getString("card_no")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            ylzMr.setInsuranceSerial(encryptData.getString("insurance_serial")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            ylzMr.setBillSerial(encryptData.getString("bill_serial")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            ylzMr.setHisBillSerial(encryptData.getString("his_bill_serial")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            ylzMr.setMedicalMode(encryptData.getString("medical_mode")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            ylzMr.setMedicalType(encryptData.getString("medical_type")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            ylzMr.setPersonalCode(encryptData.getString("personal_code")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            ylzMr.setName(encryptData.getString("name")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            ylzMr.setSex(encryptData.getString("sex")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            ylzMr.setSexMc(encryptData.getString("sex_mc")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            ylzMr.setTotalAmount(encryptData.getString("total_amount")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            ylzMr.setPersonCash(encryptData.getString("person_cash")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            ylzMr.setPersonAccount(encryptData.getString("person_account")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            ylzMr.setFundPrice(encryptData.getString("fund_price")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            ylzMr.setJkzhPay(encryptData.getString("jkzh_pay")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            ylzMr.setOwnPay(encryptData.getString("own_pay")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            ylzMr.setAccountBalance(encryptData.getString("account_balance")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            ylzMr.setHospitalizationQty(encryptData.getString("hospitalization_qty")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            ylzMr.setDate(DateUtil.strToDateLong(encryptData.getString("date"))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            ylzMr.setPayDate(DateUtil.strToDateLong(encryptData.getString("pay_date"))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            ylzMr.setInvoiceJj(encryptData.getString("invoice_jj")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            ylzMr.setInvoiceXj(encryptData.getString("invoice_xj")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            ylzMr.setInvoiceZh(encryptData.getString("invoice_zh")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            ylzMr.setDel(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            ylzMr.setRelationCode(outpatientId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            ylzMr.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            ylzMr = ylzMedicailRelationDao.save(ylzMr); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            JSONArray jsonArray = encryptData.getJSONArray("fplist"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for (int i=0;i<jsonArray.size();i++){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                JSONObject jsonObject = jsonArray.getJSONObject(i); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                YlzMedicalBillDO ylzMb = new YlzMedicalBillDO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                ylzMb.setMedicalId(ylzMr.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                ylzMb.setInvoicePay(jsonObject.getString("invoice_pay")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                ylzMb.setInvoiceType(jsonObject.getString("invoice_type")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                ylzMb.setInvoiceTypeName(jsonObject.getString("invoice_type_name")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                ylzMb.setProjectPay(jsonObject.getString("project_pay")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                ylzMb.setOwnPay(jsonObject.getString("own_pay")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                ylzMb.setSpecialPay(jsonObject.getString("special_pay")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                ylzMb.setUninsurancePay(jsonObject.getString("uninsurance_pay")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                ylzMb.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                ylzMedicailBillDao.save(ylzMb); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            logger.info("医保预结算服务保存成功"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 2.5.6医保结算冲销服务(N20.17.04.06) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 返回值 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param outpatientId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @throws Exception 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public String preSettlementRefund(String outpatientId) throws Exception{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String funid = "N20.17.04.06"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        WlyyOutpatientDO outpatientDO = outpatientDao.findById(outpatientId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (outpatientDO==null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            throw new Exception("上传医保失败:门诊为空!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONObject data = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("region_code","");//参保地区划代码 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("idcard",outpatientDO.getIdcard());//证件号码 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("name",outpatientDO.getPatientName());//姓名 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("cert_type","");//证件类型 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("medical_mode","");//医疗就诊方式 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("bill_serial",outpatientDO.getBillSerial());//医保收费流水号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("his_bill_serial",outpatientDO.getXtgzh());//his收费单据流水号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("insurance_serial",outpatientDO.getInsuranceSerial());//医保流水号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("data_source","");//数据来源 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("refund_serial","");//医院退费操作流水号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String result = requestYlz(data,funid,"医保结算冲销服务"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (result==null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            throw new Exception("医保结算冲销服务失败!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONObject object = JSONObject.parseObject(result); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (object.getString("flag").equalsIgnoreCase("1")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            JSONObject encryptData = object.getJSONObject("encrypt_data"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            logger.info("医保结算冲销服务保存成功"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 2.5.7获取医保结算页面地址(N20.17.04.07) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 返回值 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param outpatientId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @throws Exception 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public String getSettlementResultUrl(String outpatientId) throws Exception{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String funid = "N20.17.04.07"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONObject data = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        WlyyOutpatientDO outpatientDO = outpatientDao.findById(outpatientId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (outpatientDO==null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            throw new Exception("获取医保结算页面地址失败:门诊为空!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        YlzMedicalRelationDO ylzMedicalRelationDO =ylzMedicailRelationDao.findByOutpatient(outpatientId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (ylzMedicalRelationDO==null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            throw new Exception("获取医保结算页面地址失败:预结算信息为空"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = hospitalSysDictDao.findById("ResultRedirectUrl"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (wlyyHospitalSysDictDO==null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            throw new Exception("获取医保结算页面地址失败:回调地址为空"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("region_code","");//参保地区划代码 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("name",outpatientDO.getPatientName());//姓名 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("idcard",outpatientDO.getIdcard());//证件号码 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("cert_type","");//证件类型 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("medical_mode",ylzMedicalRelationDO.getMedicalMode());//医疗就诊方式 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("medical_type",ylzMedicalRelationDO.getMedicalType());//医疗类别 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("insurance_serial",ylzMedicalRelationDO.getInsuranceSerial());// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("his_bill_serial",ylzMedicalRelationDO.getHisBillSerial());//his收费单据流水号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("date",ylzMedicalRelationDO.getDate());//实际就诊日期 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("leave_method","");//离院方式 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("pre_count","");//处方项目数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("total_amount",ylzMedicalRelationDO.getTotalAmount());//医疗费总金额 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("person_cash",ylzMedicalRelationDO.getPersonCash());//个人现金支付金额(实付现金) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("person_account",ylzMedicalRelationDO.getPersonAccount());//个人账户支付金额 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("fund_price",ylzMedicalRelationDO.getFundPrice());//基金支付总额 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("data_source","");//数据来源 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("his_serial",outpatientDO.getRegisterNo());//his流水号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("doctor_level","");//医师诊查费等级 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("redirect_url",wlyyHospitalSysDictDO.getDictValue());//回调地址 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String result = requestYlz(data,funid,"获取医保结算结果"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (result==null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            throw new Exception("获取医保结算结果失败!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 2.5.8获取医保结算结果(N20.17.04.08) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 返回值 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param code 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @throws Exception 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public String getSettlementResult(String code) throws Exception{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String funid = "N20.17.04.08"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONObject data = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("code",code);//参保地区划代码 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String result = requestYlz(data,funid,"获取医保结算结果"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (result==null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            throw new Exception("获取医保结算结果失败!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 2.7.1上传用户病史病情及医学报告(N20.17.06.01) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 返回值 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param code 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @throws Exception 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public String uploadMedicalHistory(String code) throws Exception{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String funid = "N20.17.06.01"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONObject data = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("region_code","");//参保地区划代码 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("idcard","");//身份证号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("name","");//姓名 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("cert_type","");//证件类型 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("insurance_serial","");//医保流水号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("blood_type","");//血型 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("allergy","");//过敏史 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("diagnosis","");//病理诊断 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("describe","");//病情描述 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("difficult_cases","");//疑难病例 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("file_list_count",0);//医学报告附件数量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("data_source","");//数据来源 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String result = requestYlz(data,funid,"上传用户病史病情及医学报告"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (result==null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            throw new Exception("上传用户病史病情及医学报告失败!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 2.7.2作废用户病史病情及医学报告(N20.17.06.06) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 返回值 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param code 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @throws Exception 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public String RefundMedicalHistory(String code,String remark) throws Exception{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String funid = "N20.17.06.06"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONObject data = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("insurance_serial","");//医保流水号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("insurance_med_hist_serial","");//医保病史上传流水号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("invalid_reason",remark);//作废原因 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("data_source","");//数据来源 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String result = requestYlz(data,funid,"作废用户病史病情及医学报告"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (result==null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            throw new Exception("作废用户病史病情及医学报告失败!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 2.7.3获取问诊过程数据(N20.17.06.02) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 返回值 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param code 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @throws Exception 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public String uploadIcdProcess(String code) throws Exception{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String funid = "N20.17.06.02"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONObject data = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("region_code","");//参保地区划代码 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("idcard","");//身份证号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("name","");//姓名 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("cert_type","");//证件类型 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("service_serial_id","");//问诊流水号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("doctor_id_card","");//医师身份证 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("doctor_name","");//医师姓名 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("file_list_count","");//附件总数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("filelist","");//附件列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("file_bytes","");//二进制字节流 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("file_name","");//文件名 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("order_num",0);//顺序号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String result = requestYlz(data,funid,"获取问诊过程数据"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (result==null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            throw new Exception("获取问诊过程数据失败!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				} 
			 |