| 
					
				 | 
			
			
				@ -10,17 +10,25 @@ import com.yihu.jw.entity.base.doctor.BaseDoctorDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.base.patient.BasePatientDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.ca.OauthCaConfigDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				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.dict.WlyyHospitalSysDictDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				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.HcyyEntranceService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.hospital.prescription.service.entrance.XzzxEntranceService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.order.dao.BusinessOrderDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.patient.dao.BasePatientDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.restmodel.hospital.prescription.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.util.common.IdCardUtil; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -28,6 +36,8 @@ import com.yihu.jw.util.date.DateUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.util.http.HttpClientUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.utils.StringUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.mysql.query.BaseJpaService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.utils.network.HttpResponse; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.utils.network.HttpUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.apache.commons.collections.map.HashedMap; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.apache.commons.lang3.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.slf4j.Logger; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -84,6 +94,19 @@ public class HcyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private HcyyEntranceService hcyyEntranceService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private PrescriptionDao prescriptionDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public static String entranceUrlLocal = "http://127.0.0.1:10023/hcyy/"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public YlzMedicailRelationDao ylzMedicailRelationDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public YlzMedicailMxDao ylzMedicailMxDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public YlzMedicailIcdDao ylzMedicailIcdDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public BusinessOrderDao businessOrderDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public PrescriptionLogDao prescriptionLogDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -191,12 +214,12 @@ public class HcyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param patient 居民id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public List<WlyyOutpatientVO> selectOutpatientList(String patient, String startTime, String endTime, String cardNo) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public List<WlyyOutpatientVO> selectOutpatientList(String patient,String startTime, String endTime,String ksdm, String cardNo) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<WlyyOutpatientVO> wlyyOutpatientVOList = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONArray array = new JSONArray(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String response=""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        patient = updatePatientMapping(patient,cardNo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String obj = hcyyEntranceService.findOutpatientInfo(patient,null,startTime,endTime); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String obj = hcyyEntranceService.findOutpatientInfo(patient,null,ksdm,startTime,endTime); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNoneBlank(obj)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            array = JSONArray.parseArray(obj).getJSONArray(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for (int i=0;i<array.size();i++){ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -248,7 +271,7 @@ public class HcyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            patient = savePatientMapping(patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNoneBlank(patient)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String obj = hcyyEntranceService.findOutpatientInfo(patient, conNo, null, null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String obj = hcyyEntranceService.findOutpatientInfo(patient, conNo, null,null, null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (StringUtils.isNoneBlank(obj)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                array = JSONArray.parseArray(obj).getJSONArray(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (array != null && array.size() != 0) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -743,7 +766,7 @@ public class HcyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                JSONArray array = JSONArray.parseArray(obj); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (array!=null&&array.size()!=0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    JSONObject jsonObject = array.getJSONObject(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    operatorId = jsonObject.getString("staffNo"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    operatorId = jsonObject.getString("SUPER_ADD"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(null!=doctorMappingDO){ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -766,8 +789,8 @@ public class HcyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                paramRequest.put("outpatientCode","R"+wlyyOutpatientDO.getRegisterNo()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                paramRequest.put("eventno","R"+wlyyOutpatientDO.getRegisterNo()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            paramRequest.put("templateid","1158"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            paramRequest.put("catalogid","50"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            paramRequest.put("templateid","2160"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            paramRequest.put("catalogid","74"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            paramRequest.put("emrtype","93"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            paramRequest.put("emrtitle","互联网医院"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1561,4 +1584,233 @@ public class HcyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        optPatient+="</opt_prescription_item>"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return optPatient; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public YlzMedicalRelationDO getSettlementInfo(String cardno,String outpatientId) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        YlzMedicalRelationDO ylzMedicalRelationDO =new YlzMedicalRelationDO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        WlyyOutpatientDO outpatientDO = outpatientDao.findById(outpatientId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String resNo = outpatientDO.getRegisterNo(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //请求his获取待结算存储 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map<String,Object> params = new HashedMap(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String url =entranceUrlLocal +"getSettleMent"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        params.put("mct","03"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        params.put("mcn",cardno); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        HttpResponse response = HttpUtils.doGet(url,params); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //获取his结算基本信息表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String basicSql ="select * from SST_JSDP_JBXX_GJYB where CARD_NO ='"+cardno+"'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String res = hcyyEntranceService.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.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.setPersonAccount("0"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            ylzMedicalRelationDO.setMedicalPrice("0"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            ylzMedicalRelationDO.setHisSettleNo(object.getString("IPT_OTP_NO")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            ylzMedicalRelationDO.setCardNo(object.getString("CARD_NO")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            ylzMedicalRelationDO.setDate(DateUtil.strToDate(object.getString("BEGNTIME"))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            ylzMedicalRelationDO.setBcwkje(object.getString("MEDFEE_SUMAMT")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            ylzMedicalRelationDO.setTotalAmount(object.getString("COST")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            ylzMedicalRelationDO.setPersonCash(object.getString("ORIGIN_CHARGES")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        ylzMedicalRelationDO = ylzMedicailRelationDao.save(ylzMedicalRelationDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        ylzMedicailMxDao.deleteByMedicalId(ylzMedicalRelationDO.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        //获取结算明细 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        String detailSql =" select * from SST_JSDP_JSMX_GJYB where LOG_NO ='"+logNo+"' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        String detailRes = hcyyEntranceService.getSql(detailSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        List<YlzMedicalMxDO> mxDOList = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        if (StringUtils.isNoneBlank(detailRes)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            JSONObject drs = JSONObject.parseObject(detailRes); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            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); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    YlzMedicalMxDO medicalMxDO = new YlzMedicalMxDO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    medicalMxDO.setDel(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    medicalMxDO.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    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.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")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    medicalMxDO.setLimitType(dobject.getString("HOSP_APPR_FLAG")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    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.setYlzMedicalMxDOList(mxDOList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        List<YlzMedicalIcdDO> icdDOS = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        ylzMedicailIcdDao.deleteByMedicalId(ylzMedicalRelationDO.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        //获取诊断 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        String icdSql =" select * from SST_JSDP_JSMX_GJYB where LOG_NO ='"+logNo+"' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        String icdRes = hcyyEntranceService.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; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public String confirmSettlement(String outpatientId) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            WlyyOutpatientDO outpatientDO = outpatientDao.findById(outpatientId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (outpatientDO==null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                throw new Exception("未找到待结算记录"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(outpatientId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (ylzMedicalRelationDO.getState()==1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                return "已结算"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(ylzMedicalRelationDO.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            ylzMedicalRelationDO.setState(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            ylzMedicalRelationDO.setSettleDate(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            ylzMedicalRelationDO = ylzMedicailRelationDao.save(ylzMedicalRelationDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String sql = "update SST_JSDP_JBXX_GJYB\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "   set SETL_ID           = '', \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "       ACCT_PAY          = '0',\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "       PSN_CASH_PAY      = '"+ylzMedicalRelationDO.getTotalAmount()+"',\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "       FUND_PAY_SUMAMT   = '0',\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "       CVLSERV_PAY       = '0',\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "       PSN_PART_AMT      = '0',\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "       HIFMI_PAY         = '0',\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "       MEDFEE_SUMAMT     = '"+ylzMedicalRelationDO.getBcwkje()+"',\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "       SETL_TIME         = '0',\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "       BALC              = '0',\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "       ACCT_MULAID_PAY   = '0',\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "       HIFOB_PAY         = '0',\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "       MDTRT_ID          = '',\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "       HIFP_PAY          = '0',\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "       MAF_PAY           = '',\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "       OTH_PAY           = '0',\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "       HIFES_PAY         = '0',\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "       OUTCHARGENO       = '"+businessOrderDO.getOrderNo()+"',\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "       PSN_CERT_TYPE     = '0',\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "       NATY              = '0',\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "       BRDY              = '0',\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "       CVLSERV_FLAG      = '0',\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "       ACT_PAY_DEDC      = '0',\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "       PSN_TYPE          = '0',\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "       HOSP_PART_AMT     = '0',\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "       CLR_OPTINS        = '0',\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "       CLR_WAY           = '0',\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "       CLR_TYPE          = '0',\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "       POOL_PROP_SELFPAY = '0',\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "       INSUPLC_ADMDVS    = '',\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "       INSUTYPE          = '',\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "       PSN_NO            = '',\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "       CHANNEL_TYPE      = '',\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "       ACSIGN_TYPE       = 'null',\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "       MDTRT_CERT_TYPE   = '03',\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "       CVL_ACCT_PAY      = '0',\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "       CVL_ACCT_BALC     = '0',\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "       HL_ACCT_PAY       = '0',\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "       HL_ACCT_BALC      = '0',\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "       FM_ACCT_BALC      = '0',\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "       PUR_ACCT_PAY      = '0'\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " where 1 = 1\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "   and LOG_NO = '"+ylzMedicalRelationDO.getLogNo()+"'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //结算更新 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            System.out.println("sql=="+sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String res = hcyyEntranceService.updateUrl(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Map<String,Object> params = new HashedMap(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String url =entranceUrlLocal +"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()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<WlyyPrescriptionDO> wlyyPrescriptionDOS = prescriptionDao.findByOutPatientIdList(ylzMedicalRelationDO.getRegionCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            /*String */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            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.setPayTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    prescriptionDao.save(prescriptionDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    logger.info("变更处方结算状态成功"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return "结算成功!"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }catch (Exception e){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return "结算失败"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				} 
			 |