| 
					
				 | 
			
			
				@ -448,7 +448,6 @@ public class PrescriptionStatusUpdateService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    logger.info(wlyyOutpatientDO.getId()+"的门诊记录设置为取消"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                outpatientDao.save(outpatientDOs); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -499,5 +498,105 @@ public class PrescriptionStatusUpdateService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        logger.info("setOutPatientOver end "); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Set set = new HashSet(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public  String  singelCancel(String outpatientId){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        logger.info("进入结束超时未接诊的门诊"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(outpatientId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String msgReturn = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (null!=wlyyOutpatientDO){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            logger.info("开始结束超时未接诊的门诊"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String cancelValue = "超时订单系统自动取消"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String cancelRemark = "当天未接诊的门诊订单自动取消"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String outPatientId = wlyyOutpatientDO.getId(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //判断医生是否接诊 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<WlyyHospitalWaitingRoomDO> roomDOs = hospitalWaitingRoomDao.findByOutpatientId(outPatientId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (roomDOs != null && roomDOs.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                for (WlyyHospitalWaitingRoomDO roomDO : roomDOs) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (roomDO.getVisitStatus() == 2) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        logger.info("id为:"+outPatientId+"的门诊已被医生接诊"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        roomDO.setVisitStatus(-1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        logger.info("修改候诊室状态,将候诊病人移除候诊室"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        hospitalWaitingRoomDao.save(roomDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //更改门诊状态 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            wlyyOutpatientDO.setStatus("-1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String description = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            wlyyOutpatientDO.setDoctorCancelRemark("6"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            wlyyOutpatientDO.setDoctorCancelType(cancelValue); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            wlyyOutpatientDO.setDoctorCancelValue(cancelRemark); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            wlyyOutpatientDO.setEndTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            description = cancelValue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //系统消息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            SystemMessageDO messageDO = new SystemMessageDO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            messageDO.setTitle("超时订单系统自动取消"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            messageDO.setType("13"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            messageDO.setSender(wlyyOutpatientDO.getDoctor()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            messageDO.setSenderName(wlyyOutpatientDO.getDoctorName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            messageDO.setRelationCode(wlyyOutpatientDO.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            messageDO.setReceiver(wlyyOutpatientDO.getPatient()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            messageDO.setReceiverName(wlyyOutpatientDO.getPatientName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            net.sf.json.JSONObject data = new net.sf.json.JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                data.put("name", wlyyOutpatientDO.getPatientName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                data.put("age", IdCardUtil.getAgeForIdcard(wlyyOutpatientDO.getIdcard())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                data.put("gender", IdCardUtil.getSexForIdcard(wlyyOutpatientDO.getIdcard())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                data.put("question", wlyyOutpatientDO.getIcd10Name()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String msg = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if ("1".equalsIgnoreCase(wlyyOutpatientDO.getType())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    data.put("type", "9"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    msg += wlyyOutpatientDO.getPatientName() + ",您好! 您有一个图文复诊已被系统取消,取消原因:" + cancelValue + "。取消说明:" + cancelRemark + "。"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    prescriptionService.sendWxTemplateMsg(wechatId, wlyyOutpatientDO.getId(),null, "9", "systemCancelRemind", cancelRemark); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if ("2".equalsIgnoreCase(wlyyOutpatientDO.getType())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    data.put("type", "16"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    msg += wlyyOutpatientDO.getPatientName() + ",您好! 您有一个视频复诊已被系统取消,取消原因:" + cancelValue + "。取消说明:" + cancelRemark + "。"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    prescriptionService.sendWxTemplateMsg(wechatId, wlyyOutpatientDO.getId(),null, "16", "systemCancelRemind", cancelRemark); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                data.put("msg", msg); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                messageDO.setData(data.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                systemMessageService.saveMessage(messageDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //推送消息到眼科通 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            BasePatientDO patient = basePatientDao.findById(wlyyOutpatientDO.getPatient()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                logger.info("推送消息到眼科通"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                ykyyService.pushNotificationToYktPatient(patient.getYktId(), messageDO.getTitle(), data.get("msg").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            outpatientDao.save(wlyyOutpatientDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            logger.info("修改保存的门诊记录:"+wlyyOutpatientDO.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //删除门诊号源 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<WlyyPatientRegisterTimeDO> list = patientRegisterTimeDao.findByOutpatientId(wlyyOutpatientDO.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (list != null && list.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                patientRegisterTimeDao.delete(list); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(outPatientId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (wechatId.equalsIgnoreCase("xm_ykyy_wx")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    businessOrderService.orderRefund(wechatId, wlyyOutpatientDO.getConsumer(), businessOrderDO.getOrderNo(), businessOrderDO.getPayPrice(), description); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    //眼科接诊时更新眼科通状态 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (businessOrderDO!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        ykyyService.updateYktOrderStatus(businessOrderDO.getOrderNo(),"2"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				/* 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    businessOrderService.ylzOrderRefund(wechatId, wlyyOutpatientDO.getPatient(), businessOrderDO.getOrderNo(), businessOrderDO.getPayPrice(), description); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                msgReturn = "success"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                msgReturn = "failed"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            logger.info(wlyyOutpatientDO.getId()+"的门诊记录设置为取消"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return msgReturn; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				} 
			 |