예제 #1
0
def generate_pid ():
    '''Returns a unique patient ID number in the range [100000-999999]'''
    
    # Keep generating random PIDs until a unique one is found
    while True:
    
        # Generate a new PID
        pid = str(random.randint(100000000, 999999999))
        isUnique = True
        
        print "Generated PID:", pid

        # Initialize a background app SMART client
        smart_client = SmartClient(PROXY_OAUTH['consumer_key'], PROXY_PARAMS, PROXY_OAUTH, None)

        # Check if the PID already exists
        try:
            target = '/apps/' + BACKGROUND_OAUTH['consumer_key'] + '/tokens/records/' + pid
            smart_client.get(target)
            isUnique = False
        except:
            pass

        # Kill the loop when the PID is determined to be unique        
        if isUnique:
            break

    # Return the fresh PID
    print "PID is unique"
    return pid
예제 #2
0
def generate_pid():
    '''Returns a unique patient ID number in the range [100000000-999999999]'''

    # Keep generating random PIDs until a unique one is found
    while True:

        # Generate a new PID
        pid = str(random.randint(100000000, 999999999))
        isUnique = True

        print "Generated PID:", pid

        # Initialize a background app SMART client
        smart_client = SmartClient(PROXY_OAUTH['consumer_key'], PROXY_PARAMS,
                                   PROXY_OAUTH, None)

        # Check if the PID already exists
        try:
            target = '/apps/' + BACKGROUND_OAUTH[
                'consumer_key'] + '/tokens/records/' + pid
            smart_client.get(target)
            isUnique = False
        except:
            pass

        # Kill the loop when the PID is determined to be unique
        if isUnique:
            break

    # Return the fresh PID
    print "PID is unique"
    return pid
예제 #3
0
def get_access_url (patientID, pin):
    '''Generates a secure SMART Proxy access URL to the patient record'''
    
    # Intialize a machine app SMART client
    smart_client = SmartClient(PROXY_OAUTH['consumer_key'], PROXY_PARAMS, PROXY_OAUTH, None)
    
    # Request and return the deep web URL
    return smart_client.get("/records/" + patientID + "/generate_direct_url", {'pin':pin})
예제 #4
0
def get_access_url(patientID, pin):
    '''Generates a secure SMART Proxy access URL to the patient record'''

    # Intialize a machine app SMART client
    smart_client = SmartClient(PROXY_OAUTH['consumer_key'], PROXY_PARAMS,
                               PROXY_OAUTH, None)

    # Request and return the deep web URL
    return smart_client.get("/records/" + patientID + "/generate_direct_url",
                            {'pin': pin})
예제 #5
0
def get_app_manifests():
        smart_client = SmartClient(PROXY_OAUTH['consumer_key'], PROXY_PARAMS, PROXY_OAUTH, None)
        res = smart_client.get("/apps/manifests/")
        apps = json.loads(res.body)
        apps = sorted(apps, key=lambda app: app['name'])
        return json.dumps(apps, indent=4)