def from_state(self, state): assert state self.app_id = state.get('app_id') or self.app_id self.scope = state.get('scope') or self.scope self.redirect = state.get('redirect') or self.redirect self.patient_id = state.get('patient_id') or self.patient_id self.launch_context = state.get( 'launch_context') or self.launch_context self.server = FHIRServer(self, state=state.get('server'))
def __init__(self, settings=None, state=None, save_func=lambda x: x): self.app_id = None self.app_secret = None """ The app-id for the app this client is used in. """ self.server = None self.scope = scope_default self.redirect = None """ The redirect-uri that will be used to redirect after authorization. """ self.launch_token = None """ The token/id provided at launch, if any. """ self.launch_context = None """ Context parameters supplied by the server during launch. """ self.wants_patient = True """ If true and launched without patient, will add the correct scope to indicate that the server should prompt for a patient after login. """ self.patient_id = None self._patient = None #Handle downscoping. self.authorized_scopes = None if save_func is None: raise Exception( "Must supply a save_func when initializing the SMART client") self._save_func = save_func # init from state if state is not None: self.from_state(state) # init from settings dict elif settings is not None: if not 'app_id' in settings: raise Exception("Must provide 'app_id' in settings dictionary") if not 'api_base' in settings: raise Exception( "Must provide 'api_base' in settings dictionary") self.app_id = settings['app_id'] self.app_secret = settings.get('app_secret') self.redirect = settings.get('redirect_uri') self.patient_id = settings.get('patient_id') self.scope = settings.get('scope', self.scope) self.launch_token = settings.get('launch_token') self.server = FHIRServer(self, base_uri=settings['api_base']) else: raise Exception( "Must either supply settings or a state upon client initialization" )
def from_state(self, state): assert state self.app_id = state.get('app_id') or self.app_id self.app_secret = state.get('app_secret') or self.app_secret self.scope = state.get('scope') or self.scope self.redirect = state.get('redirect') or self.redirect self.patient_id = state.get('patient_id') or self.patient_id self.launch_token = state.get('launch_token') or self.launch_token self.launch_context = state.get( 'launch_context') or self.launch_context self.authorized_scopes = state.get( 'authorized_scopes') or self.authorized_scopes self.server = FHIRServer(self, state=state.get('server'))
def __init__(self, settings=None, state=None, save_func=lambda x: x): self.app_id = None self.server = None self.scope = None self.redirect = None self.launch_context = None """ Context parameters supplied by the server during launch. """ self.wants_patient = True """ If true and launched without patient, will add the correct scope to indicate that the server should prompt for a patient after login. """ self.patient_id = None self._patient = None if save_func is None: raise Exception( "Must supply a save_func when initializing the SMART client") self._save_func = save_func # init from state if state is not None: self.from_state(state) # init from settings dict elif settings is not None: self.app_id = settings['app_id'] self.redirect = settings.get('redirect_uri') self.patient_id = settings.get('patient_id') scope = scope_default if 'launch_token' in settings: self.scope = ' launch:'.join([scope, settings['launch_token']]) elif self.patient_id is None and self.wants_patient: self.scope = ' '.join([scope_nolaunch, scope]) else: self.scope = scope self.server = FHIRServer(self, base_uri=settings['api_base']) else: raise Exception( "Must either supply settings or a state upon client initialization" )