Permalink
Browse files

Updated sample_container to SMART 0.4

  • Loading branch information...
1 parent 208e5d1 commit cb90d4c40cf14b9d404828a7f726bce3289f8b21 @jmandel jmandel committed Apr 27, 2012
Showing with 35 additions and 49 deletions.
  1. +35 −13 static/sample_container/sample_container.html
  2. +0 −36 static/sample_container/sample_data.xml
@@ -115,30 +115,52 @@
callback(iframe[0]);
};
-SMART.handle_api = function(app_instance, api_call, callback)
+SMART.handle_api = function(app_instance, api_call, callback_success, callback_error)
{
+ var success = function(data, status_code, xhr) {
+ var ct = xhr.getResponseHeader("Content-Type") || "unknown";
+ callback_success({
+ contentType: ct.split(";")[0],
+ data: data});
+ };
+
+ var error = function(xhr, textStatus, error) {
+ console.log(textStatus);
+ console.log(error);
+ var ct = xhr.getResponseHeader("Content-Type") || "unknown";
+ callback_error (xhr.status, {
+ contentType: ct.split(";")[0],
+ data: xhr.responseText});
+ };
+
// Return a fake medication list containing just simvastatin...
- if (api_call.method=="GET" && api_call.func.match(/^.*\/records\/search/))
- $.get('sample_demographics.xml', callback, 'text');
- else if (api_call.method=="GET" && api_call.func.match(/^.*\/demographics$/))
- $.get('sample_demographics.xml', callback, 'text');
- else if (api_call.method=="GET" && api_call.func.match(/^.*\/medications\/$/))
- $.get('sample_data.xml', callback, 'text');
- else if (api_call.method=="GET" && api_call.func.match(/^\/apps\/manifests$/))
- callback(JSON.stringify(all_manifests));
+ if (api_call.method=="GET" && api_call.func.match(/^.*\/records\/search/)) {
+ $.ajax({type: 'get', url: 'sample_demographics.xml', dataType: 'text'})
+ .success(success).error(error);
+ }
+ else if (api_call.method=="GET" && api_call.func.match(/^.*\/demographics$/)) {
+ $.ajax({type: 'get', url: 'sample_demographics.xml', dataType: 'text'})
+ .success(success).error(error);
+ }
+ else if (api_call.method=="GET" && api_call.func.match(/^.*\/medications\/$/)) {
+ $.ajax({type: 'get', url: 'sample_data.xml', dataType: 'text'})
+ .success(success).error(error);
+ }
+ else if (api_call.method=="GET" && api_call.func.match(/^\/apps\/manifests$/)) {
+ callback(JSON.stringify(all_manifests));
+ }
else if (api_call.method=="GET" && api_call.func.match(/^\/apps\/(.+)\/manifest$/))
{
var app_id = api_call.func.match(/^\/apps\/(.+)\/manifest$/)[1];
var manifest = manifest_hash[app_id];
if (!manifest) return;
- callback(JSON.stringify(manifest));
+ callback(JSON.stringify(manifest));
}
- else
+ else {
alert("Function " + api_call.func + " not implemented yet.");
-
+ }
};
-
var clicked = function(app_id) {
SMART.launch_app(manifest_hash[app_id], simple_context);
};
@@ -7,11 +7,7 @@
<route xmlns="http://smartplatforms.org/terms#">oral</route>
<startDate xmlns="http://smartplatforms.org/terms#">2001-07-25</startDate>
<endDate xmlns="http://smartplatforms.org/terms#">2001-07-25</endDate>
- <doseUnit xmlns="http://smartplatforms.org/terms#">mg</doseUnit>
- <strength xmlns="http://smartplatforms.org/terms#">4</strength>
- <strengthUnit xmlns="http://smartplatforms.org/terms#">mg</strengthUnit>
<frequency xmlns="http://smartplatforms.org/terms#">daily</frequency>
- <dose xmlns="http://smartplatforms.org/terms#">2</dose>
<drugName xmlns="http://smartplatforms.org/terms#" rdf:nodeID="r1294169778r21765r5619"/>
</rdf:Description>
@@ -26,11 +22,7 @@
<route xmlns="http://smartplatforms.org/terms#">injectable</route>
<startDate xmlns="http://smartplatforms.org/terms#">2002-07-01</startDate>
<endDate xmlns="http://smartplatforms.org/terms#">2002-07-01</endDate>
- <doseUnit xmlns="http://smartplatforms.org/terms#">mg/ml</doseUnit>
- <strength xmlns="http://smartplatforms.org/terms#">40</strength>
- <strengthUnit xmlns="http://smartplatforms.org/terms#">mg/mL</strengthUnit>
<frequency xmlns="http://smartplatforms.org/terms#">daily</frequency>
- <dose xmlns="http://smartplatforms.org/terms#">40</dose>
<drugName xmlns="http://smartplatforms.org/terms#" rdf:nodeID="r1294169778r21765r5621"/>
</rdf:Description>
@@ -45,11 +37,7 @@
<route xmlns="http://smartplatforms.org/terms#">oral</route>
<startDate xmlns="http://smartplatforms.org/terms#">2003-02-07</startDate>
<endDate xmlns="http://smartplatforms.org/terms#">2003-02-07</endDate>
- <doseUnit xmlns="http://smartplatforms.org/terms#">mg</doseUnit>
- <strength xmlns="http://smartplatforms.org/terms#">2</strength>
- <strengthUnit xmlns="http://smartplatforms.org/terms#">mg</strengthUnit>
<frequency xmlns="http://smartplatforms.org/terms#">daily</frequency>
- <dose xmlns="http://smartplatforms.org/terms#">2</dose>
<drugName xmlns="http://smartplatforms.org/terms#" rdf:nodeID="r1294169778r21765r5623"/>
</rdf:Description>
@@ -64,11 +52,7 @@
<route xmlns="http://smartplatforms.org/terms#">rectal</route>
<startDate xmlns="http://smartplatforms.org/terms#">2003-02-07</startDate>
<endDate xmlns="http://smartplatforms.org/terms#">2003-02-07</endDate>
- <doseUnit xmlns="http://smartplatforms.org/terms#">mg/ml</doseUnit>
- <strength xmlns="http://smartplatforms.org/terms#">5</strength>
- <strengthUnit xmlns="http://smartplatforms.org/terms#">mg</strengthUnit>
<frequency xmlns="http://smartplatforms.org/terms#">daily</frequency>
- <dose xmlns="http://smartplatforms.org/terms#">2</dose>
<code xmlns="http://smartplatforms.org/terms#" rdf:nodeID="r1294169778r21765r5625"/>
</rdf:Description>
@@ -83,11 +67,7 @@
<route xmlns="http://smartplatforms.org/terms#">oral</route>
<startDate xmlns="http://smartplatforms.org/terms#">2006-03-06</startDate>
<endDate xmlns="http://smartplatforms.org/terms#">2006-03-06</endDate>
- <doseUnit xmlns="http://smartplatforms.org/terms#">mg</doseUnit>
- <strength xmlns="http://smartplatforms.org/terms#">4</strength>
- <strengthUnit xmlns="http://smartplatforms.org/terms#">mg</strengthUnit>
<frequency xmlns="http://smartplatforms.org/terms#">daily</frequency>
- <dose xmlns="http://smartplatforms.org/terms#">4</dose>
<code xmlns="http://smartplatforms.org/terms#" rdf:nodeID="r1294169778r21765r5627"/>
</rdf:Description>
@@ -102,11 +82,7 @@
<route xmlns="http://smartplatforms.org/terms#">rectal</route>
<startDate xmlns="http://smartplatforms.org/terms#">2006-05-30</startDate>
<endDate xmlns="http://smartplatforms.org/terms#">2006-05-30</endDate>
- <doseUnit xmlns="http://smartplatforms.org/terms#">mg</doseUnit>
- <strength xmlns="http://smartplatforms.org/terms#">120</strength>
- <strengthUnit xmlns="http://smartplatforms.org/terms#">mg</strengthUnit>
<frequency xmlns="http://smartplatforms.org/terms#">daily</frequency>
- <dose xmlns="http://smartplatforms.org/terms#">2</dose>
<code xmlns="http://smartplatforms.org/terms#" rdf:nodeID="r1294169778r21765r5629"/>
</rdf:Description>
@@ -121,11 +97,7 @@
<route xmlns="http://smartplatforms.org/terms#">oral</route>
<startDate xmlns="http://smartplatforms.org/terms#">2007-02-15</startDate>
<endDate xmlns="http://smartplatforms.org/terms#">2007-02-15</endDate>
- <doseUnit xmlns="http://smartplatforms.org/terms#">MG</doseUnit>
- <strength xmlns="http://smartplatforms.org/terms#">100</strength>
- <strengthUnit xmlns="http://smartplatforms.org/terms#">mg</strengthUnit>
<frequency xmlns="http://smartplatforms.org/terms#">daily</frequency>
- <dose xmlns="http://smartplatforms.org/terms#">100</dose>
<code xmlns="http://smartplatforms.org/terms#" rdf:nodeID="r1294169778r21765r5631"/>
</rdf:Description>
@@ -140,11 +112,7 @@
<route xmlns="http://smartplatforms.org/terms#">oral</route>
<startDate xmlns="http://smartplatforms.org/terms#">2009-02-13</startDate>
<endDate xmlns="http://smartplatforms.org/terms#">2009-02-13</endDate>
- <doseUnit xmlns="http://smartplatforms.org/terms#">mg</doseUnit>
- <strength xmlns="http://smartplatforms.org/terms#">4</strength>
- <strengthUnit xmlns="http://smartplatforms.org/terms#">mg</strengthUnit>
<frequency xmlns="http://smartplatforms.org/terms#">daily</frequency>
- <dose xmlns="http://smartplatforms.org/terms#">2</dose>
<code xmlns="http://smartplatforms.org/terms#" rdf:nodeID="r1294169778r21765r5633"/>
</rdf:Description>
@@ -159,11 +127,7 @@
<route xmlns="http://smartplatforms.org/terms#">intravenous</route>
<startDate xmlns="http://smartplatforms.org/terms#">2009-06-19</startDate>
<endDate xmlns="http://smartplatforms.org/terms#">2009-06-19</endDate>
- <doseUnit xmlns="http://smartplatforms.org/terms#">mg</doseUnit>
- <strength xmlns="http://smartplatforms.org/terms#">500</strength>
- <strengthUnit xmlns="http://smartplatforms.org/terms#">mg</strengthUnit>
<frequency xmlns="http://smartplatforms.org/terms#">daily</frequency>
- <dose xmlns="http://smartplatforms.org/terms#">500</dose>
<code xmlns="http://smartplatforms.org/terms#" rdf:nodeID="r1294169778r21765r5635"/>
</rdf:Description>

0 comments on commit cb90d4c

Please sign in to comment.