コード例 #1
0
ファイル: main.py プロジェクト: simmy-cims/smart_sample_apps
def get_smart_client():
    """Initializes and returns a new SMART Client
    
    Expects an OAUTH header as a REST parameter
    """
    smart_oauth_header = web.input().oauth_header
    smart_oauth_header = urllib.unquote(smart_oauth_header)
    oa_params = oauth.parse_header(smart_oauth_header)
    SMART_SERVER_PARAMS["api_base"] = oa_params["smart_container_api_base"]
    SMART_SERVER_OAUTH["consumer_key"] = oa_params["smart_app_id"]

    oa_params = oauth.parse_header(smart_oauth_header)

    resource_tokens = {
        "oauth_token": oa_params["smart_oauth_token"],
        "oauth_token_secret": oa_params["smart_oauth_token_secret"],
    }

    ret = SmartClient(SMART_SERVER_OAUTH["consumer_key"], SMART_SERVER_PARAMS, SMART_SERVER_OAUTH, resource_tokens)

    ret.record_id = oa_params["smart_record_id"]
    ret.user_id = oa_params["smart_user_id"]
    ret.smart_app_id = oa_params["smart_app_id"]

    return ret
コード例 #2
0
ファイル: main.py プロジェクト: CyberMD/smart_sample_apps
def get_smart_client():
    '''Initializes and returns a new SMART Client
    
    Expects an OAUTH header as a REST parameter
    '''
    smart_oauth_header = web.input().oauth_header
    smart_oauth_header = urllib.unquote(smart_oauth_header)
    oa_params = oauth.parse_header(smart_oauth_header)
    SMART_SERVER_PARAMS['api_base'] = oa_params['smart_container_api_base']
    SMART_SERVER_OAUTH['consumer_key'] = oa_params['smart_app_id']

    oa_params = oauth.parse_header(smart_oauth_header)
    
    resource_tokens={'oauth_token':       oa_params['smart_oauth_token'],
                     'oauth_token_secret':oa_params['smart_oauth_token_secret']}

    ret = SmartClient(SMART_SERVER_OAUTH['consumer_key'], 
                       SMART_SERVER_PARAMS, 
                       SMART_SERVER_OAUTH, 
                       resource_tokens)
                       
    ret.record_id=oa_params['smart_record_id']
    ret.user_id=oa_params['smart_user_id']
    ret.smart_app_id=oa_params['smart_app_id']
    
    return ret
コード例 #3
0
def get_smart_client(ontology=None):
    '''Initializes and returns a new SMART Client
    
    Expects an OAUTH header as a REST parameter
    '''
    smart_oauth_header = web.input().oauth_header
    smart_oauth_header = urllib.unquote(smart_oauth_header)
    oa_params = oauth.parse_header(smart_oauth_header)
    SMART_SERVER_PARAMS['api_base'] = oa_params['smart_container_api_base']
    SMART_SERVER_OAUTH['consumer_key'] = oa_params['smart_app_id']

    oa_params = oauth.parse_header(smart_oauth_header)

    resource_tokens = {
        'oauth_token': oa_params['smart_oauth_token'],
        'oauth_token_secret': oa_params['smart_oauth_token_secret']
    }

    ret = SmartClient(SMART_SERVER_OAUTH['consumer_key'], SMART_SERVER_PARAMS,
                      SMART_SERVER_OAUTH, resource_tokens, ontology)

    ret.record_id = oa_params['smart_record_id']
    ret.user_id = oa_params['smart_user_id']
    ret.smart_app_id = oa_params['smart_app_id']

    return ret
コード例 #4
0
def get_smart_client(request):
    oa_params = oauth.parse_header(request.META['HTTP_AUTHORIZATION'])
    resource_tokens={'oauth_token':       oa_params['smart_oauth_token'],
                     'oauth_token_secret':oa_params['smart_oauth_token_secret']}

    ret = smart.SmartClient(settings.AC_OAUTH['consumer_key'], settings.SMART_SERVER_PARAMS, settings.AC_OAUTH, resource_tokens)
    ret.record_id = oa_params['smart_record_id']
    return ret
コード例 #5
0
    def GET(self):
        # Obtain the oauth header
        try:
            smart_oauth_header = web.input().oauth_header
            smart_oauth_header = urllib.unquote(smart_oauth_header)
        except:
            return "Couldn't find a parameter to match the name 'oauth_header'"

        # Pull out OAuth params from the header
        oa_params = oauth.parse_header(smart_oauth_header)

        # This is how we know...
        # 1. what container we're talking to
        try:
            SMART_SERVER_PARAMS['api_base'] = oa_params[
                'smart_container_api_base']
        except:
            return "Couldn't find 'smart_contianer_api_base' in %s" % smart_oauth_header

        # 2. what our app ID is
        try:
            SMART_SERVER_OAUTH['consumer_key'] = oa_params['smart_app_id']
        except:
            return "Couldn't find 'smart_app_id' in %s" % smart_oauth_header

        # (For demo purposes, we're assuming a hard-coded consumer secret, but
        #  in real life we'd look this up in some config or DB now...)
        client = get_smart_client(smart_oauth_header)

        # Represent the list as an RDF graph
        meds = client.get_medications()

        # Find a list of all fulfillments for each med.
        q = """
            PREFIX dcterms:<http://purl.org/dc/terms/>
            PREFIX sp:<http://smartplatforms.org/terms#>
            PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
               SELECT  ?med ?name ?quant ?when
               WHERE {
                      ?med rdf:type sp:Medication .
                      ?med sp:drugName ?medc.
                      ?medc dcterms:title ?name.
                      ?med sp:fulfillment ?fill.
                      ?fill sp:dispenseDaysSupply ?quant.
                      ?fill dcterms:date ?when.
               }
            """
        pills = meds.graph.query(q)

        # Find the last fulfillment date for each medication
        self.last_pill_dates = {}

        for pill in pills:
            self.update_pill_dates(*pill)

        #Print a formatted list
        return header + self.format_last_dates() + footer
コード例 #6
0
ファイル: reminder.py プロジェクト: CyberMD/smart_sample_apps
    def GET(self):
        # Obtain the oauth header
        try:
            smart_oauth_header = web.input().oauth_header
            smart_oauth_header = urllib.unquote(smart_oauth_header)
        except:
            return "Couldn't find a parameter to match the name 'oauth_header'"
        
        # Pull out OAuth params from the header
        oa_params = oauth.parse_header(smart_oauth_header)

        # This is how we know...
        # 1. what container we're talking to
        try:
            SMART_SERVER_PARAMS['api_base'] = oa_params['smart_container_api_base']
        except: return "Couldn't find 'smart_contianer_api_base' in %s"%smart_oauth_header

        # 2. what our app ID is
        try:
            SMART_SERVER_OAUTH['consumer_key'] = oa_params['smart_app_id']
        except: return "Couldn't find 'smart_app_id' in %s"%smart_oauth_header

        # (For demo purposes, we're assuming a hard-coded consumer secret, but 
        #  in real life we'd look this up in some config or DB now...)
        client = get_smart_client(smart_oauth_header)

        # Represent the list as an RDF graph
        meds = client.get_medications()

        # Find a list of all fulfillments for each med.
        q = """
            PREFIX dcterms:<http://purl.org/dc/terms/>
            PREFIX sp:<http://smartplatforms.org/terms#>
            PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
               SELECT  ?med ?name ?quant ?when
               WHERE {
                      ?med rdf:type sp:Medication .
                      ?med sp:drugName ?medc.
                      ?medc dcterms:title ?name.
                      ?med sp:fulfillment ?fill.
                      ?fill sp:dispenseDaysSupply ?quant.
                      ?fill dcterms:date ?when.
               }
            """
        pills = meds.graph.query(q)

        # Find the last fulfillment date for each medication
        self.last_pill_dates = {}

        for pill in pills:
            self.update_pill_dates(*pill)

        #Print a formatted list
        return header + self.format_last_dates() + footer
コード例 #7
0
ファイル: reminder.py プロジェクト: CyberMD/smart_sample_apps
def get_smart_client(authorization_header, resource_tokens=None):
    oa_params = oauth.parse_header(authorization_header)
    
    resource_tokens={'oauth_token':       oa_params['smart_oauth_token'],
                     'oauth_token_secret':oa_params['smart_oauth_token_secret']}

    ret = SmartClient(SMART_SERVER_OAUTH['consumer_key'], 
                       SMART_SERVER_PARAMS, 
                       SMART_SERVER_OAUTH, 
                       resource_tokens)
    
    ret.record_id=oa_params['smart_record_id']
    return ret
コード例 #8
0
def get_smart_client(authorization_header, resource_tokens=None):
    oa_params = oauth.parse_header(authorization_header)

    resource_tokens = {
        'oauth_token': oa_params['smart_oauth_token'],
        'oauth_token_secret': oa_params['smart_oauth_token_secret']
    }

    ret = SmartClient(SMART_SERVER_OAUTH['consumer_key'], SMART_SERVER_PARAMS,
                      SMART_SERVER_OAUTH, resource_tokens)

    ret.record_id = oa_params['smart_record_id']
    return ret
コード例 #9
0
def get_smart_client(authorization_header, resource_tokens=None):
    """ Initialize a new SmartClient"""
    oa_params = oauth.parse_header(authorization_header)
    
    resource_tokens={'oauth_token':       oa_params['smart_oauth_token'],
                     'oauth_token_secret':oa_params['smart_oauth_token_secret']}
                     
    SMART_SERVER_PARAMS['api_base'] = oa_params['smart_container_api_base']
    SMART_SERVER_OAUTH['consumer_key'] = oa_params['smart_app_id']

    ret = smart.SmartClient(SMART_SERVER_OAUTH['consumer_key'], 
                       SMART_SERVER_PARAMS, 
                       SMART_SERVER_OAUTH, 
                       resource_tokens)
    ret.record_id=oa_params['smart_record_id']
    return oa_params, ret
コード例 #10
0
ファイル: views.py プロジェクト: simmy-cims/smart_sample_apps
def get_smart_client(authorization_header, resource_tokens=None):
    """ Initialize a new SmartClient"""
    oa_params = oauth.parse_header(authorization_header)

    resource_tokens = {
        'oauth_token': oa_params['smart_oauth_token'],
        'oauth_token_secret': oa_params['smart_oauth_token_secret']
    }

    SMART_SERVER_PARAMS['api_base'] = oa_params['smart_container_api_base']
    SMART_SERVER_OAUTH['consumer_key'] = oa_params['smart_app_id']

    ret = smart.SmartClient(SMART_SERVER_OAUTH['consumer_key'],
                            SMART_SERVER_PARAMS, SMART_SERVER_OAUTH,
                            resource_tokens)
    ret.record_id = oa_params['smart_record_id']
    return oa_params, ret
コード例 #11
0
ファイル: wsgi.py プロジェクト: bewest/smart_hv_merge_app
def _get_smart_client(smart_oauth_header):
    if smart_oauth_header == '':
        return "No smart_oauth_header"

    """Convenience function to initialize a new SmartClient"""
    try:
        smart_oauth_header = urllib.unquote(smart_oauth_header)
    except:
        return "Couldn't find a parameter to match the name 'oauth_header'"

    oa_params = oauth.parse_header(smart_oauth_header)

    # This is how we know...
    # 1. what container we're talking to
    try:
        SMART_SERVER_PARAMS['api_base'] = oa_params['smart_container_api_base']
        #SMART_SERVER_PARAMS['api_base'] = 'http://sandbox-api.smartplatforms.org'
    except:
        return "Couldn't find 'smart_contianer_api_base' in %s" % smart_oauth_header

    # 2. what our app ID is
    try:
        SMART_SERVER_OAUTH['consumer_key'] = oa_params['smart_app_id']
    except:
        return "Couldn't find 'smart_app_id' in %s" % smart_oauth_header

    # (For demo purposes, we're assuming a hard-coded consumer secret, but
    #  in real life we'd look this up in some config or DB now...)
    resource_tokens = {
        'oauth_token': oa_params['smart_oauth_token'],
        'oauth_token_secret': oa_params['smart_oauth_token_secret']
    }

    ret = SmartClient(
        SMART_SERVER_OAUTH['consumer_key'],
        SMART_SERVER_PARAMS,
        SMART_SERVER_OAUTH,
        resource_tokens
    )

    ret.record_id = oa_params['smart_record_id']
    return ret
コード例 #12
0
ファイル: views.py プロジェクト: luisibanez/smart_sample_apps
def get_smart_client(request):
    """ Initialize a new SmartClient and return oa_params, ret."""

    try:
        smart_oauth_header_quoted = request.GET.get('oauth_header')
        smart_oauth_header = urllib.unquote(smart_oauth_header_quoted)
    except:
        return "Couldn't find a parameter to match the name 'oauth_header'"

    oa_params = oauth.parse_header(smart_oauth_header)
    
    resource_tokens={'oauth_token':       oa_params['smart_oauth_token'],
                     'oauth_token_secret':oa_params['smart_oauth_token_secret']}
                     
    SMART_SERVER_PARAMS['api_base'] = oa_params['smart_container_api_base']
    SMART_SERVER_OAUTH['consumer_key'] = oa_params['smart_app_id']

    ret = smart.SmartClient(SMART_SERVER_OAUTH['consumer_key'], 
                       SMART_SERVER_PARAMS, 
                       SMART_SERVER_OAUTH, 
                       resource_tokens)
    ret.record_id=oa_params['smart_record_id']
    return oa_params, ret, smart_oauth_header
コード例 #13
0
def get_smart_client(request):
    """ Initialize a new SmartClient and return oa_params, ret."""

    try:
        smart_oauth_header_quoted = request.GET.get('oauth_header')
        smart_oauth_header = urllib.unquote(smart_oauth_header_quoted)
    except:
        return "Couldn't find a parameter to match the name 'oauth_header'"

    oa_params = oauth.parse_header(smart_oauth_header)

    resource_tokens = {
        'oauth_token': oa_params['smart_oauth_token'],
        'oauth_token_secret': oa_params['smart_oauth_token_secret']
    }

    SMART_SERVER_PARAMS['api_base'] = oa_params['smart_container_api_base']
    SMART_SERVER_OAUTH['consumer_key'] = oa_params['smart_app_id']

    ret = smart.SmartClient(SMART_SERVER_OAUTH['consumer_key'],
                            SMART_SERVER_PARAMS, SMART_SERVER_OAUTH,
                            resource_tokens)
    ret.record_id = oa_params['smart_record_id']
    return oa_params, ret, smart_oauth_header