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