Ejemplo n.º 1
0
			for rule in rules:
				print "-->  Testing against", rule.name
				if rule.match_against(record):
					print "==>  Record %s matches rule %s" % (record_id, rule.name)
					print rule.perform_actions(record)
		sys.exit(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