Example #1
0
def forward_api(forwarded_url):
    forward_args = request.args.to_dict(flat=False)
    forward_args['_format'] = 'json'
    api_url = '/%s?%s' % (forwarded_url, urlencode(forward_args, doseq=True))
    api_resp = api_call(api_url)
    bundle = api_resp.json()

    # Here should install the privacy policy for patient
    # not bundle but plain resource
    # There is a sudden change in server so this is modified to avoid throw TypeError
    if 'type' in bundle and bundle['type'] != 'searchset':
        #Here is the trick
        #Note that identifer is seeming not found in some recieved data
        #Instead, it might change to be shown in url when get posted data
        identifier = get_resource_identifier(forwarded_url, bundle)
        resource = tr.check_private_policy(bundle, identifier, CLIENT_ID)
        bundle = {
            'resourceType':
            resource['resourceType'],
            'entry': [{
                'content': resource,
                'id': forwarded_url,
                'identifier': identifier
            }],
            'is_single_resource':
            True,
            'code_snippet':
            get_code_snippet(resource)
        }
    elif 'resourceType' in bundle and bundle['resourceType'] != 'bundle':
        #Here is the trick
        identifier = get_resource_identifier(forwarded_url, bundle)
        resource = tr.check_private_policy(bundle, identifier, CLIENT_ID)
        bundle = {
            'resourceType':
            resource['resourceType'],
            'entry': [{
                'content': resource,
                'id': forwarded_url,
                'identifier': identifier
            }],
            'is_single_resource':
            True,
            'code_snippet':
            get_code_snippet(resource)
        }
    elif len(bundle.get('entry', [])) > 0:
        bundle['resourceType'] = bundle['entry'][0]['content']['resourceType']

    return render_fhir_extended(bundle)
Example #2
0
def forward_api(forwarded_url):
    forward_args = request.args.to_dict(flat=False)
    forward_args['_format'] = 'json'
    api_url = '/%s?%s'% (forwarded_url, urlencode(forward_args, doseq=True))
    api_resp = api_call(api_url)
    bundle = api_resp.json()
    
    # Here should install the privacy policy for patient
    # not bundle but plain resource
    # There is a sudden change in server so this is modified to avoid throw TypeError
    if 'type' in bundle and bundle['type'] != 'searchset':
	#Here is the trick        
	#Note that identifer is seeming not found in some recieved data
	#Instead, it might change to be shown in url when get posted data
  	identifier = get_resource_identifier(forwarded_url,bundle)
	resource = tr.check_private_policy(bundle,identifier,CLIENT_ID) 
	bundle = {
            'resourceType': resource['resourceType'],

            'entry': [{
                'content': resource,
                'id': forwarded_url,
		'identifier' : identifier		
            }],
            'is_single_resource': True,
            'code_snippet': get_code_snippet(resource) 
        }
    elif 'resourceType' in bundle and bundle['resourceType']!='bundle':
	#Here is the trick        
  	identifier = get_resource_identifier(forwarded_url,bundle)
	resource = tr.check_private_policy(bundle,identifier,CLIENT_ID) 
        bundle = {
            'resourceType': resource['resourceType'],
            'entry': [{
                'content': resource,
                'id': forwarded_url,
		'identifier' : identifier
            }],
            'is_single_resource': True,
            'code_snippet': get_code_snippet(resource) 
        }
    elif len(bundle.get('entry', [])) > 0:
        bundle['resourceType'] = bundle['entry'][0]['content']['resourceType']

    return render_fhir_extended(bundle)
def render_fhir_extended(resource):

    #Here we implement privacy policy issue before we render a FHIR bundle
    #We call function to check each type resource and cover those
    #protected data
    
    for i in range(len(resource['entry'])):
        #print resource['entry'][i]
        resource_id = resource['entry'][i]['resource']['id']
        resource['entry'][i]['resource'] = tr.check_private_policy(resource['entry'][i]['resource'],resource_id,CLIENT_ID)
        resource['entry'][i]['resource']['id'] = to_internal_id(resource['resourceType']+'/'+resource['entry'][i]['resource'].get('id', ''))
    
    return render_template('bundle_view.html', **resource)
Example #4
0
def render_fhir_extended(resource):

    #Here we implement privacy policy issue before we render a FHIR bundle
    #We call function to check each type resource and cover those
    #protected data

    for i in range(len(resource['entry'])):
        #print resource['entry'][i]
        resource_id = resource['entry'][i]['resource']['id']
        resource['entry'][i]['resource'] = tr.check_private_policy(resource['entry'][i]['resource'],resource_id,CLIENT_ID)
        resource['entry'][i]['resource']['id'] = to_internal_id(resource['resourceType']+'/'+resource['entry'][i]['resource'].get('id', ''))

    return render_template('bundle_view.html', **resource)
Example #5
0
def render_fhir_extended(resource):
    '''
    render a "nice" view of a FHIR bundle
    '''
    #Here we implement privacy policy issue before we render a FHIR bundle
    #We call function to check each type resource and cover those 
    #protected data 
    for i in range(len(resource['entry'])):
	resource_id = get_resource_identifier(resource['entry'][i]['id'],resource['entry'][i]['content'])
 	resource['entry'][i]['content']=tr.check_private_policy(resource['entry'][i]['content'],10000,CLIENT_ID)
 	resource['entry'][i]['id'] = to_internal_id(resource['entry'][i].get('id', ''))  
    '''with open('log.txt', 'wt') as f:
        s= repr(json.dumps(resource,separators=(',',':'),indent=2))
	f.write(s)
        f.close()'''
    return render_template('bundle_view.html', **resource)
Example #6
0
def render_fhir_extended(resource):
    '''
    render a "nice" view of a FHIR bundle
    '''
    #Here we implement privacy policy issue before we render a FHIR bundle
    #We call function to check each type resource and cover those
    #protected data
    for i in range(len(resource['entry'])):
        resource_id = get_resource_identifier(resource['entry'][i]['id'],
                                              resource['entry'][i]['content'])
        resource['entry'][i]['content'] = tr.check_private_policy(
            resource['entry'][i]['content'], 10000, CLIENT_ID)
        resource['entry'][i]['id'] = to_internal_id(resource['entry'][i].get(
            'id', ''))
    '''with open('log.txt', 'wt') as f:
        s= repr(json.dumps(resource,separators=(',',':'),indent=2))
	f.write(s)
        f.close()'''
    return render_template('bundle_view.html', **resource)