private ErrorData validate() { if ((errorData = ValueValidate.valueExistValidate(request, "token")) != null) { logger.warn(LogUtils.Msg(errorData, request)); } else if ((errorData = ValueValidate.idValidation(request.getId_number(), "id_number")) != null) { logger.warn(LogUtils.Msg(errorData, request)); } else if ((errorData = PhoneValidate.validatePhoneNumber(request.getPhone())) != null) { logger.warn(LogUtils.Msg(errorData, request)); } return null; }
private ErrorData preAdd() { Account account; Patient patient; if ((account = (Account) CacheUtils.getObject4Cache(request.getToken())) == null) { errorData = new ErrorData(ErrorConst.IDX_TOKENEXPIRED_ERROR); logger.warn(LogUtils.Msg(errorData, request)); } else if (account.getIs_exp_user() == CommonConst.TRUE) { errorData = new ErrorData(ErrorConst.IDX_ISEXPUSER); logger.warn(LogUtils.Msg(errorData, request)); } else { patient = PatientServiceUtils.select(driver, request.getId_number()); if (patient == null) { // Patient Not Exists responseData.setCode( SendCodeService.getCodeAndSave2Cache( CateConst.ADD_PATIENT, request.getToken(), request.getPhone(), request.getId_number())); responseData.setIs_exist(0L); } else { // Patient Already Exists responseData.setIs_exist(1L); if (AccountPatientServiceUtils.select(driver, account.getId(), patient.getId()) != null) { // already Manger responseData.setUnder_manager(1L); } else { // Patient Not Under Manage responseData.setCode( SendCodeService.getCodeAndSave2Cache( CateConst.ADD_PATIENT, request.getToken(), patient.getPhone(), request.getId_number())); responseData.setUnder_manager(0L); responseData.setPatient(patient); responseData.setManagers( driver.accountPatientDao.selectAll( TypeUtils.getWhereHashMap( "patient_id", patient.getId(), "is_patient_validate", CommonConst.TRUE))); } } } return errorData; }