Ejemplo n.º 1
0
	# -------------------------------------------------------------------------- Record Scoped
	smart.record_id = '665677'
	ts = TokenStore()
	known_token = ts.tokenForRecord(ep_url, smart.record_id)
	
	# request a token for a specific record id
	if known_token is None:
		token = smart.fetch_request_token()
		ts.storeTokenForRecord(ep_url, smart.record_id, token)
		
		print "->  Now visit:  %s" % smart.auth_redirect_url
		Popen(['open', smart.auth_redirect_url])
		oauth_verifier = raw_input("Enter the oauth_verifier: ")
		
		# exchange and store the token
		token = smart.exchange_token(oauth_verifier)
		if token and token.get('oauth_token') and token.get('oauth_token_secret'):
			ts.storeTokenForRecord(ep_url, smart.record_id, token)
	else:
		print "->  Reusing existing access token"
		smart.update_token(known_token)
	
	# create a patient
	record = TestRecord(smart)
	print "->  Record", record.record_id
	
	# run or just retrieve existing results?
	if not _RUN:
		do_run = raw_input("Run the rules? ")
		_RUN = True if len(do_run) > 0 and 'y' == do_run[:1] else False