|  | @ -21,6 +21,7 @@ import com.yihu.jw.entity.hospital.doctor.WlyyPatientRegisterTimeDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.httplog.WlyyHttpLogDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.prescription.*;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.ylzinfo.OauthYlzConfigDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.file_upload.FileUploadService;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.consult.dao.HospitalWaitingRoomDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.dict.WlyyChargeDictDao;
 | 
	
	
		
			
				|  | @ -49,6 +50,7 @@ import com.yihu.jw.util.common.IdCardUtil;
 | 
	
		
			
				|  |  | import com.yihu.jw.util.common.QrcodeUtil;
 | 
	
		
			
				|  |  | import com.yihu.jw.util.date.DateUtil;
 | 
	
		
			
				|  |  | import com.yihu.mysql.query.BaseJpaService;
 | 
	
		
			
				|  |  | import com.yihu.utils.security.MD5;
 | 
	
		
			
				|  |  | import com.ylzinfo.ehc.EhcHandler;
 | 
	
		
			
				|  |  | import com.ylzinfo.ehc.common.utils.DateUtils;
 | 
	
		
			
				|  |  | import com.ylzinfo.ehc.trans.TransRequest;
 | 
	
	
		
			
				|  | @ -135,7 +137,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |     private PrescriptionExpressageService sfexpressService;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private WlyyDoctorOnlineTimeDao wlyyDoctorOnlineTimeDao;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private OauthYlzConfigDao oauthYlzConfigDao;
 | 
	
		
			
				|  |  |     
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @Value("${demo.flag}")
 | 
	
	
		
			
				|  | @ -2461,6 +2464,23 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |         return rs;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public Map<String,Object> getPatientInfoMap(BasePatientDO basePatientDO){
 | 
	
		
			
				|  |  |         Map<String,Object> rs = new HashedMap();
 | 
	
		
			
				|  |  |         rs.put("id",basePatientDO.getId());
 | 
	
		
			
				|  |  |         rs.put("name",basePatientDO.getName());
 | 
	
		
			
				|  |  |         rs.put("sex",basePatientDO.getSex());
 | 
	
		
			
				|  |  |         rs.put("provinceCode",basePatientDO.getProvinceCode());
 | 
	
		
			
				|  |  |         rs.put("provinceName",basePatientDO.getProvinceName());
 | 
	
		
			
				|  |  |         rs.put("cityCode",basePatientDO.getCityCode());
 | 
	
		
			
				|  |  |         rs.put("cityName",basePatientDO.getCityName());
 | 
	
		
			
				|  |  |         rs.put("townCode",basePatientDO.getTownCode());
 | 
	
		
			
				|  |  |         rs.put("townName",basePatientDO.getTownName());
 | 
	
		
			
				|  |  |         rs.put("idcard",basePatientDO.getIdcard());
 | 
	
		
			
				|  |  |         rs.put("age",IdCardUtil.getAgeForIdcard(basePatientDO.getIdcard()));
 | 
	
		
			
				|  |  |         rs.put("mobile",basePatientDO.getMobile());
 | 
	
		
			
				|  |  |         return rs;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private FileUploadService fileUploadService;
 | 
	
	
		
			
				|  | @ -2872,4 +2892,95 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         return outpatient;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 验证电子健康卡授权
 | 
	
		
			
				|  |  |      * @param authorizeNo
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public Map<String,Object> checkOauthQRCode(String authorizeNo){
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         Map<String,Object> rsMap = new HashedMap();
 | 
	
		
			
				|  |  |         OauthYlzConfigDO oauthYlzConfigDO = oauthYlzConfigDao.findOne("ylz_config");
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             TransRequest e = new TransRequest();
 | 
	
		
			
				|  |  |             e.setMethod("ehc.ehealthcard.auth.query");
 | 
	
		
			
				|  |  |             e.setApp_id(oauthYlzConfigDO.getAppId());
 | 
	
		
			
				|  |  |             e.setTerm_id(oauthYlzConfigDO.getTermId());
 | 
	
		
			
				|  |  |             e.setVersion(oauthYlzConfigDO.getVersion());
 | 
	
		
			
				|  |  |             e.setTimestamp(DateUtil.dateToStr(new Date(),"yyyyMMddHHmmss"));
 | 
	
		
			
				|  |  |             e.setSign_type(oauthYlzConfigDO.getSignType());
 | 
	
		
			
				|  |  |             e.setEnc_type(oauthYlzConfigDO.getEncType());
 | 
	
		
			
				|  |  |             com.alibaba.fastjson.JSONObject bizContent = new com.alibaba.fastjson.JSONObject();
 | 
	
		
			
				|  |  |             bizContent.put("out_authorize_no", authorizeNo);
 | 
	
		
			
				|  |  |             e.setBiz_content(JSON.toJSONString(bizContent));
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             EhcHandler ehcHandler = new EhcHandler(oauthYlzConfigDO.getUrl(), oauthYlzConfigDO.getAppId(), oauthYlzConfigDO.getTermId(), oauthYlzConfigDO.getAppKey());
 | 
	
		
			
				|  |  |             TransResponse re = ehcHandler.execute(e);
 | 
	
		
			
				|  |  |             String rs = com.alibaba.fastjson.JSONObject.toJSONString(re);
 | 
	
		
			
				|  |  |             com.alibaba.fastjson.JSONObject json = (com.alibaba.fastjson.JSONObject) com.alibaba.fastjson.JSONObject.parse(rs);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             String ret_code = json.getString("ret_code");
 | 
	
		
			
				|  |  |             if("0000".equals(ret_code)){
 | 
	
		
			
				|  |  |                 com.alibaba.fastjson.JSONObject biz = json.getJSONObject("biz_content");
 | 
	
		
			
				|  |  |                 String  auth_status = biz.getString("auth_status");
 | 
	
		
			
				|  |  |                 if("succ".equals(auth_status)){
 | 
	
		
			
				|  |  |                     String idcard = biz.getString("id_no");
 | 
	
		
			
				|  |  |                     BasePatientDO patientDO =  basePatientDao.findByIdcardAndDel(idcard,"1");
 | 
	
		
			
				|  |  |                     if(patientDO == null){
 | 
	
		
			
				|  |  |                         BasePatientDO patient = new BasePatientDO();
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                         String salt = UUID.randomUUID().toString().substring(0,5);
 | 
	
		
			
				|  |  |                         String mobile = biz.getString("mobile_phone");
 | 
	
		
			
				|  |  |                         String pw = idcard.substring(mobile.length()-6);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                         patient.setIdcard(idcard);
 | 
	
		
			
				|  |  |                         patient.setName(biz.getString("user_name"));
 | 
	
		
			
				|  |  |                         patient.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
 | 
	
		
			
				|  |  |                         patient.setSalt(salt);
 | 
	
		
			
				|  |  |                         patient.setMobile(mobile);
 | 
	
		
			
				|  |  |                         patient.setDel("1");
 | 
	
		
			
				|  |  |                         patient.setEnabled(1);
 | 
	
		
			
				|  |  |                         patient.setLocked(0);
 | 
	
		
			
				|  |  |                         patient.setCreateTime(new Date());
 | 
	
		
			
				|  |  |                         patient.setUpdateTime(new Date());
 | 
	
		
			
				|  |  |                         patient.setBirthday(DateUtil.strToDate(biz.getString("birthday"),"yyyyMMdd"));
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                         basePatientDao.save(patient);
 | 
	
		
			
				|  |  |                         rsMap.put("sCode",auth_status);
 | 
	
		
			
				|  |  |                         rsMap.put("sMes","success");
 | 
	
		
			
				|  |  |                         rsMap.put("patient",getPatientInfoMap(patient));
 | 
	
		
			
				|  |  |                         return rsMap;
 | 
	
		
			
				|  |  |                     }else{
 | 
	
		
			
				|  |  |                         rsMap.put("sCode",auth_status);
 | 
	
		
			
				|  |  |                         rsMap.put("sMes","success");
 | 
	
		
			
				|  |  |                         rsMap.put("patient",getPatientInfoMap(patientDO));
 | 
	
		
			
				|  |  |                         return rsMap;
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }else if("ing".equals(auth_status)){
 | 
	
		
			
				|  |  |                     rsMap.put("sCode",auth_status);
 | 
	
		
			
				|  |  |                     rsMap.put("sMes","正在授权");
 | 
	
		
			
				|  |  |                     return rsMap;
 | 
	
		
			
				|  |  |                 }else if("fail".equals(auth_status)){
 | 
	
		
			
				|  |  |                     rsMap.put("sCode",auth_status);
 | 
	
		
			
				|  |  |                     rsMap.put("sMes","授权失败");
 | 
	
		
			
				|  |  |                     return rsMap;
 | 
	
		
			
				|  |  |                 }else if("cancel".equals(auth_status)){
 | 
	
		
			
				|  |  |                     rsMap.put("sCode",auth_status);
 | 
	
		
			
				|  |  |                     rsMap.put("sMes","取消授权");
 | 
	
		
			
				|  |  |                     return rsMap;
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             rsMap.put("sCode","err");
 | 
	
		
			
				|  |  |             rsMap.put("sMes","请求失败");
 | 
	
		
			
				|  |  |             return rsMap;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         }catch (Exception e){
 | 
	
		
			
				|  |  |             e.printStackTrace();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         rsMap.put("sCode","err");
 | 
	
		
			
				|  |  |         rsMap.put("sMes","请求失败");
 | 
	
		
			
				|  |  |         return rsMap;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | }
 |