Skip to content

Commit

Permalink
implement SMART Container Manifest
Browse files Browse the repository at this point in the history
- SMART /version and /capabilities consolidated into /manifest
- fixes chb#27
  • Loading branch information
Travers Franckle committed Dec 31, 2012
1 parent 64a7cc8 commit 0288bba
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 86 deletions.
2 changes: 1 addition & 1 deletion indivo/accesscontrol/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def basic_access(principal, **unused_args):
pha,
app_manifest,
smart_ontology,
smart_capabilities,]
smart_manifest,]
AccessRule('Basic Access', basic_access, views)

# Account-related views
Expand Down
4 changes: 2 additions & 2 deletions indivo/tests/api/smart_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def test_get_smart_ontology(self):
response = self.client.get('/ontology')
self.assertEqual(response.status_code, 200)

def test_get_smart_capabilities(self):
response = self.client.get('/capabilities/')
def test_get_smart_manifest(self):
response = self.client.get('/manifest')
self.assertEqual(response.status_code, 200)

2 changes: 1 addition & 1 deletion indivo/urls/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

# SMART container calls
(r'^ontology$', MethodDispatcher({'GET': smart_ontology})),
(r'^capabilities/$', MethodDispatcher({'GET': smart_capabilities})),
(r'^manifest$', MethodDispatcher({'GET': smart_manifest})),

# static
(r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': 'static'}),
Expand Down
186 changes: 104 additions & 82 deletions indivo/views/smart_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
from base import *
import urllib2

from django.conf import settings

def smart_ontology(request):
"""Fetch the SMART ontology as RDF/XML."""

Expand All @@ -19,85 +21,105 @@ def smart_ontology(request):
ontology = urllib2.urlopen(url).read()
return HttpResponse(ontology, mimetype="application/rdf+xml")

def smart_capabilities(request):
"""SMART Capabilities"""
capabilites = '''{
"http://smartplatforms.org/terms#Alert": {
"methods": [
"POST"
]
},
"http://smartplatforms.org/terms#Allergy": {
"methods": [
"GET"
]
},
"http://smartplatforms.org/terms#AppManifest": {
"methods": [
"GET"
]
},
"http://smartplatforms.org/terms#Capabilities": {
"methods": [
"GET"
]
},
"http://smartplatforms.org/terms#Demographics": {
"methods": [
"GET"
]
},
"http://smartplatforms.org/terms#Encounter": {
"methods": [
"GET"
]
},
"http://smartplatforms.org/terms#Fulfillment": {
"methods": [
"GET"
]
},
"http://smartplatforms.org/terms#Immunization": {
"methods": [
"GET"
]
},
"http://smartplatforms.org/terms#LabResult": {
"methods": [
"GET"
]
},
"http://smartplatforms.org/terms#Medication": {
"methods": [
"GET"
]
},
"http://smartplatforms.org/terms#Ontology": {
"methods": [
"GET"
]
},
"http://smartplatforms.org/terms#Problem": {
"methods": [
"GET"
]
},
"http://smartplatforms.org/terms#User": {
"methods": [
"GET"
]
},
"http://smartplatforms.org/terms#UserPreferences": {
"methods": [
"DELETE",
"GET",
"PUT"
]
},
"http://smartplatforms.org/terms#VitalSignSet": {
"methods": [
"GET"
]
}
}'''
return HttpResponse(capabilites, mimetype='application/json')
def smart_manifest(request):
"""SMART Container Manifest"""

manifest = '''
{{
"smart_version": "0.5.0",
"api_base": "{api_base}",
"name": "SMART v0.5 Sandbox",
"description": "{site_description}",
"admin": "{admin}",
"launch_urls": {{
"authorize_token": "{ui_base}/oauth/authorize",
"exchange_token": "{api_base}/oauth/access_token",
"request_token": "{api_base}/oauth/request_token"
}},
"capabilities": {{
"http://smartplatforms.org/terms#Allergy": {{
"methods": [
"GET"
]
}},
"http://smartplatforms.org/terms#AppManifest": {{
"methods": [
"GET"
]
}},
"http://smartplatforms.org/terms#ClinicalNote": {{
"methods": [
"GET"
]
}},
"http://smartplatforms.org/terms#ContainerManifest": {{
"methods": [
"GET"
]
}},
"http://smartplatforms.org/terms#Demographics": {{
"methods": [
"GET"
]
}},
"http://smartplatforms.org/terms#Encounter": {{
"methods": [
"GET"
]
}},
"http://smartplatforms.org/terms#Fulfillment": {{
"methods": [
"GET"
]
}},
"http://smartplatforms.org/terms#Immunization": {{
"methods": [
"GET"
]
}},
"http://smartplatforms.org/terms#LabResult": {{
"methods": [
"GET"
]
}},
"http://smartplatforms.org/terms#Medication": {{
"methods": [
"GET"
]
}},
"http://smartplatforms.org/terms#Ontology": {{
"methods": [
"GET"
]
}},
"http://smartplatforms.org/terms#Problem": {{
"methods": [
"GET"
]
}},
"http://smartplatforms.org/terms#Procedure": {{
"methods": [
"GET"
]
}},
"http://smartplatforms.org/terms#SocialHistory": {{
"methods": [
"GET"
]
}},
"http://smartplatforms.org/terms#VitalSignSet": {{
"methods": [
"GET"
]
}}
}}
}}'''

processed_manifest = manifest.format(api_base=settings.SITE_URL_PREFIX,
ui_base=settings.UI_SERVER_URL,
site_description=settings.SITE_DESCRIPTION,
admin=settings.EMAIL_SUPPORT_ADDRESS)

return HttpResponse(processed_manifest, mimetype='application/json')
3 changes: 3 additions & 0 deletions settings.py.default
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ SAMPLE_DATA_DIR = APP_HOME + '/sample_data'
# URL prefix (where indivo_server will be accessible from the web)
SITE_URL_PREFIX = "http://localhost:8000"

# Description to show in SMART manifest call
SITE_DESCRIPTION = "Indivo Server"

# URL prefix for the UI server
# (usually port 80 on the same machine)
UI_SERVER_URL = 'http://localhost'
Expand Down

0 comments on commit 0288bba

Please sign in to comment.