Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix URL of JS client

  • Loading branch information...
commit 0c9c2dc8fe3a272cf8fdf72713359213053fdc9e 1 parent ee0c4c2
@arjunsanyal arjunsanyal authored
Showing with 811 additions and 1,100 deletions.
  1. +2 −2 _site/downloads/vm/index.html
  2. +12 −16 _site/howto/background_and_helper_apps/index.html
  3. +37 −48 _site/howto/build_a_rest_app/index.html
  4. +27 −34 _site/howto/build_a_smart_app/index.html
  5. +16 −19 _site/howto/build_smart_frame_ui_apps/index.html
  6. +10 −15 _site/howto/deferred/index.html
  7. +8 −9 _site/howto/filters/index.html
  8. +11 −15 _site/howto/got_statins/index.html
  9. +10 −13 _site/howto/intro_to_jsonld/index.html
  10. +55 −63 _site/howto/intro_to_rdf/index.html
  11. +19 −23 _site/howto/rx_reminder/index.html
  12. +18 −21 _site/howto/smart_data/index.html
  13. +20 −22 _site/howto/sparql_examples/index.html
  14. +14 −14 _site/index.html
  15. +78 −115 _site/install/linux/index.html
  16. +36 −61 _site/install/os_x/index.html
  17. +32 −43 _site/libraries/container_javascript/index.html
  18. +1 −1  _site/libraries/dotnet/index.html
  19. +35 −47 _site/libraries/java/index.html
  20. +33 −44 _site/libraries/javascript/index.html
  21. +24 −37 _site/libraries/python/index.html
  22. +12 −15 _site/reference/app_manifest/index.html
  23. +148 −255 _site/reference/data_model/index.html
  24. +12 −22 _site/reference/filters/index.html
  25. +97 −82 _site/reference/rest_api/index.html
  26. +14 −20 _site/updates/smart_0.4/app/index.html
  27. +17 −27 _site/updates/smart_0.4/container/index.html
  28. +12 −16 _site/updates/smart_0.5/index.html
  29. +1 −1  libraries/javascript/index.md
View
4 _site/downloads/vm/index.html
@@ -128,9 +128,9 @@
<li><p>Restart Tomcat: <code>sudo service tomcat7 restart</code></p></li>
<li><p>Run the <code>./smart_manager.py -s</code> script to update the server settings
(substitute &quot;localhost&quot; with the DNS of the machine that you want).</p></li>
-<li><p>Take a look at the apache virtual servers' configurations in
+<li><p>Take a look at the apache virtual servers&#39; configurations in
&quot;/etc/apache2/sites-enabled&quot; and change any occurence of &quot;smart-vm&quot;
-with your server's DNS.</p></li>
+with your server&#39;s DNS.</p></li>
<li><p>Restart Apache: <code>sudo service apache2 restart</code></p></li>
<li><p>Reset the SMART servers and reload the sample patients: <code>./smart_manager.py -rl</code></p></li>
<li><p>If you need the SMART REST sample apps as well, then edit the manifest
View
28 _site/howto/background_and_helper_apps/index.html
@@ -121,12 +121,12 @@
<p>Importantly, a background app is not necessarily a web app, since it may not
have a user-facing web interface. In this example, we will demonstrate just
that: a simple Python program that acts as a SMART background app, but does not
-respond to any web requests. So, if you've figured out how to build a SMART REST
+respond to any web requests. So, if you&#39;ve figured out how to build a SMART REST
app, all you need to know now is how to obtain the credentials needed to cycle
-through all the SMART Container's medical records.</p>
+through all the SMART Container&#39;s medical records.</p>
<p>The first thing you need is, of course, a SmartClient instance to make REST API
-calls against the SMART container. If you don't have that library running yet,
+calls against the SMART container. If you don&#39;t have that library running yet,
check out the SMART Python Client. </p>
<p>Make sure you understand the warning about setting a strong <code>consumer_secret</code>
@@ -142,26 +142,24 @@
<span class="s">&#39;consumer_secret&#39;</span> <span class="p">:</span> <span class="s">&#39;smartapp-secret&#39;</span>
<span class="p">},</span>
<span class="bp">None</span><span class="p">)</span>
-</code></pre>
-</div>
+</code></pre></div>
<p>The important difference between this SmartClient and the one you created for
use in SMART REST API calls is that this one has no resource-specific
-credentials. That's because, at first, you're not going to make API calls
+credentials. That&#39;s because, at first, you&#39;re not going to make API calls
specific to any single medical record. In OAuth parlance, this is called a
-&quot;2-legged call.&quot; Now, it's time to iterate through all records available at that
+&quot;2-legged call.&quot; Now, it&#39;s time to iterate through all records available at that
SMART Container. The specific API calls to do this can be found in our REST API,
but the SMART Python client library makes it easy for you:</p>
<div class="highlight"><pre><code class="python"> <span class="k">for</span> <span class="n">record_id</span> <span class="ow">in</span> <span class="n">smart_client</span><span class="o">.</span><span class="n">loop_over_records</span><span class="p">():</span>
<span class="c"># do stuff with each record</span>
-</code></pre>
-</div>
+</code></pre></div>
-<p>Note that, in each iteration, the smart_client is modified to automatically use
+<p>Note that, in each iteration, the smart<em>client is modified to automatically use
the credentials needed to access this specific record. If you were to call the
API manually, you would have to extract the tokens you get from the container,
-and insert them into the smart_client object.</p>
+and insert them into the smart</em>client object.</p>
<p>So, using a simple query to read drug names:</p>
@@ -176,18 +174,16 @@
<span class="s"> ?drugname_code dcterms:title ?drugname .</span>
<span class="s"> }</span>
<span class="s"> &quot;&quot;&quot;</span>
-</code></pre>
-</div>
+</code></pre></div>
-<p>We can simply iterate through the records, retrieve each record's medications,
+<p>We can simply iterate through the records, retrieve each record&#39;s medications,
and print them to the screen:</p>
<div class="highlight"><pre><code class="python"> <span class="k">for</span> <span class="n">record_id</span> <span class="ow">in</span> <span class="n">smart_client</span><span class="o">.</span><span class="n">loop_over_records</span><span class="p">():</span>
<span class="n">medications</span> <span class="o">=</span> <span class="n">smart_client</span><span class="o">.</span><span class="n">get_medications</span><span class="p">(</span><span class="n">record_id</span> <span class="o">=</span> <span class="n">record_id</span><span class="p">)</span>
<span class="n">med_names</span> <span class="o">=</span> <span class="n">medications</span><span class="o">.</span><span class="n">graph</span><span class="o">.</span><span class="n">query</span><span class="p">(</span><span class="n">QUERY</span><span class="p">)</span>
<span class="k">print</span> <span class="s">&quot;</span><span class="si">%s</span><span class="s">: </span><span class="si">%s</span><span class="s">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">record_id</span><span class="p">,</span> <span class="s">&quot;, &quot;</span><span class="o">.</span><span class="n">join</span><span class="p">([</span><span class="nb">str</span><span class="p">(</span><span class="n">m</span><span class="p">)</span> <span class="k">for</span> <span class="n">m</span> <span class="ow">in</span> <span class="n">med_names</span><span class="p">]))</span>
-</code></pre>
-</div>
+</code></pre></div>
<h2>Helper Apps</h2>
View
85 _site/howto/build_a_rest_app/index.html
@@ -126,12 +126,12 @@
were entirely transparent to you, the app builder, because the SMART Container
was able to take care of it all: the JavaScript API call simply notified the
outer frame of the data request, and the outer-frame knows who the logged-in
-user is and what medical record they're currently considering.</p>
+user is and what medical record they&#39;re currently considering.</p>
<p>Now, we consider the case where you want the backend of your app to obtain data
directly from the SMART Container, e.g. the SMART Reference EMR, using the REST
-API. In that case, the SMART Container doesn't know a-priori who is making the
-call and whether they're authorized to do so. We need to authenticate the call
+API. In that case, the SMART Container doesn&#39;t know a-priori who is making the
+call and whether they&#39;re authorized to do so. We need to authenticate the call
somehow, and you, the app builder, need to know how to ensure that your calls
are properly authenticated.</p>
@@ -151,17 +151,17 @@
</ol>
<p>SMART employs (1), but implements a much simpler approach to (2), providing your
-app with the requisite token and secret. We'll describe this simpler approach
+app with the requisite token and secret. We&#39;ll describe this simpler approach
here. At a high-level, your app can simply look for a URL parameter called
<code>oauth_header</code> set by the SMART JavaScript client library. In this value, you
will find the OAuth token and secret you need.</p>
-<h2>Change Your App's OAuth Consumer Secret in Production (Important!)</h2>
+<h2>Change Your App&#39;s OAuth Consumer Secret in Production (Important!)</h2>
<p>Each SMART container your app runs against must first &quot;install&quot; your app
-by inserting your app's manifest into it's database. This data includes
-your app's OAuth <code>consumer-secret</code> which is the shared secret between
-your app and the container that <strong>ALL SECURITY</strong> of your app's
+by inserting your app&#39;s manifest into it&#39;s database. This data includes
+your app&#39;s OAuth <code>consumer-secret</code> which is the shared secret between
+your app and the container that <strong>ALL SECURITY</strong> of your app&#39;s
communication with the server relies on and is a basic requirement of
OAuth-signed REST API calls.</p>
@@ -176,35 +176,30 @@
<p>This secret is provisioned when your app is loaded into the smart
container with the following command:</p>
-
-<pre><code>manage.py load_app &lt;manifest-location&gt; &lt;secret&gt;
-</code></pre>
-
+<div class="highlight"><pre><code class="text">manage.py load_app &lt;manifest-location&gt; &lt;secret&gt;
+</code></pre></div>
<h2>Passing Tokens via URL Parameter</h2>
<p>The SMART container will pass all necessary fields to your app via the
<code>oauth_header</code> URL parameter. Specifically, the actual request sent to your
-app's backend server for index.html looks like this:</p>
+app&#39;s backend server for index.html looks like this:</p>
<div class="highlight"><pre><code class="javascript"> <span class="nx">GET</span> <span class="o">/</span><span class="nx">index</span><span class="p">.</span><span class="nx">html</span><span class="o">?</span><span class="nx">oauth_header</span><span class="o">=</span><span class="p">{</span><span class="nx">Header</span> <span class="nx">value</span> <span class="nx">here</span><span class="p">...}</span>
-</code></pre>
-</div>
+</code></pre></div>
<p>You need to first extract that header from the GET parameter:</p>
<div class="highlight"><pre><code class="javascript"> <span class="nx">oauth_header</span> <span class="o">=</span> <span class="nx">web</span><span class="p">.</span><span class="nx">input</span><span class="p">().</span><span class="nx">oauth_header</span>
-</code></pre>
-</div>
+</code></pre></div>
-<p>You'll also to need to URL-decode it:</p>
+<p>You&#39;ll also to need to URL-decode it:</p>
<div class="highlight"><pre><code class="javascript"> <span class="nx">oauth_header</span> <span class="o">=</span> <span class="nx">urllib</span><span class="p">.</span><span class="nx">unquote</span><span class="p">(</span><span class="nx">oauth_header</span><span class="p">)</span>
-</code></pre>
-</div>
+</code></pre></div>
<p>The field contains a complete OAuth Authorization header that includes a few
-extra fields, including notably smart_record_id, smart_oauth_token and
-smart_oauth_token_secret. smart_record_id indicates the medical record ID
+extra fields, including notably smart<em>record</em>id, smart<em>oauth</em>token and
+smart<em>oauth</em>token<em>secret. smart</em>record_id indicates the medical record ID
of the current context, while the OAuth token and secret are the credentials
your app needs to make REST API calls back into the SMART EMR. Why, then, are
they themselves delivered in OAuth authorization header format? So you can
@@ -212,24 +207,22 @@
<p>In other words, the SMART container is sending you credentials you can use to
sign your API request. Those credentials are, themselves, signed, so you know
-they're okay to use.</p>
+they&#39;re okay to use.</p>
-<p>Thankfully, you don't need to worry too much about the details, because we
+<p>Thankfully, you don&#39;t need to worry too much about the details, because we
provide you with the utilities you need to extract the fields you need quickly
and efficiently:</p>
<div class="highlight"><pre><code class="javascript"> <span class="err">#</span> <span class="nx">parse</span> <span class="nx">it</span> <span class="nx">into</span> <span class="nx">a</span> <span class="nx">python</span> <span class="nx">dictionary</span>
<span class="nx">oauth_params</span> <span class="o">=</span> <span class="nx">oauth</span><span class="p">.</span><span class="nx">parse_header</span><span class="p">(</span><span class="nx">oauth_header</span><span class="p">)</span>
-</code></pre>
-</div>
+</code></pre></div>
<p>Then get the specific parameters you need to sign your own API calls:</p>
<div class="highlight"><pre><code class="javascript"> <span class="nx">record_id</span> <span class="o">=</span> <span class="nx">oauth_params</span><span class="p">[</span><span class="s1">&#39;smart_record_id&#39;</span><span class="p">]</span>
<span class="nx">resource_credentials</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;oauth_token&#39;</span><span class="o">:</span> <span class="nx">oauth_params</span><span class="p">[</span><span class="s1">&#39;smart_oauth_token&#39;</span><span class="p">],</span>
<span class="s1">&#39;oauth_token_secret&#39;</span><span class="o">:</span> <span class="nx">oauth_params</span><span class="p">[</span><span class="s1">&#39;smart_oauth_token_secret&#39;</span><span class="p">]}</span>
-</code></pre>
-</div>
+</code></pre></div>
<p>The SMART Connect OAuth Header contains a few more parameters that will prove
useful:</p>
@@ -245,7 +238,7 @@
<p>In the simple case, yes, but in more advanced cases, your backend server might
support multiple simultaneous apps made available to multiple SMART Containers.
Thus, in a given setting, your app needs to know definitely which SMART
-Container it's connecting to and, if you're using one server to host multiple
+Container it&#39;s connecting to and, if you&#39;re using one server to host multiple
apps, which of your apps is being invoked in the first place.</p>
<h2>Using SMART Client Libraries</h2>
@@ -260,21 +253,19 @@
<span class="p">{</span><span class="s1">&#39;consumer_key&#39;</span> <span class="o">:</span> <span class="s1">&#39;my-app@apps.smartplatforms.org&#39;</span><span class="p">,</span>
<span class="s1">&#39;consumer_secret&#39;</span> <span class="o">:</span> <span class="s1">&#39;smartapp-secret&#39;</span><span class="p">},</span>
<span class="nx">resource_credentials</span><span class="p">)</span>
-</code></pre>
-</div>
+</code></pre></div>
-<p>Since we're working against the SMART Reference EMR Sandbox, the APP_ID and
+<p>Since we&#39;re working against the SMART Reference EMR Sandbox, the APP_ID and
consumer-level credentials are all fixed. Of course when connecting against a
different SMART Container (e.g. your own), those will probably change.</p>
<h1>Obtaining SMART Health Data</h1>
<p>With our smart_client instance ready to go, loaded with the right credentials,
-we can start making API calls. Let's get the medication list:</p>
+we can start making API calls. Let&#39;s get the medication list:</p>
<div class="highlight"><pre><code class="javascript"> <span class="nx">medications</span> <span class="o">=</span> <span class="nx">smart_client</span><span class="p">.</span><span class="nx">get_medications</span><span class="p">(</span><span class="nx">record_id</span> <span class="o">=</span> <span class="nx">record_id</span><span class="p">)</span>
-</code></pre>
-</div>
+</code></pre></div>
<p>Just like in the first SMART App we built, the result is an SMARTResponse object
containing an RDF graph of data, which we can query for just the fields we want:</p>
@@ -295,36 +286,34 @@
<span class="nx">med_names_and_cuis</span> <span class="o">=</span> <span class="nx">medications</span><span class="p">.</span><span class="nx">graph</span><span class="p">.</span><span class="nx">query</span><span class="p">(</span><span class="nx">query</span><span class="p">)</span>
<span class="nx">meds</span> <span class="o">=</span> <span class="p">[{</span><span class="s1">&#39;name&#39;</span><span class="o">:</span> <span class="nx">med</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="s1">&#39;rxcui&#39;</span><span class="o">:</span> <span class="nx">med</span><span class="p">[</span><span class="mi">1</span><span class="p">]}</span> <span class="k">for</span> <span class="nx">med</span> <span class="k">in</span> <span class="nx">med_names_and_cuis</span><span class="p">]</span>
-</code></pre>
-</div>
+</code></pre></div>
+
-<p>So far, we're not doing anything novel compared to our SMART Connect App. Let's
+<p>So far, we&#39;re not doing anything novel compared to our SMART Connect App. Let&#39;s
make use of this fully capable backend we have, and integrate this data with
-other information. We'll use <a href="http://rxnav.nlm.nih.gov/">RxNav</a>, the National
-Library of Medicine's resource for RxNorm. In particular, we'll pull out the
+other information. We&#39;ll use <a href="http://rxnav.nlm.nih.gov/">RxNav</a>, the National
+Library of Medicine&#39;s resource for RxNorm. In particular, we&#39;ll pull out the
ingredients for each medication:</p>
<div class="highlight"><pre><code class="javascript"> <span class="k">for</span> <span class="nx">med</span> <span class="k">in</span> <span class="nx">meds</span><span class="o">:</span>
<span class="nx">rxnav_info_xml</span> <span class="o">=</span> <span class="nx">urllib</span><span class="p">.</span><span class="nx">urlopen</span><span class="p">(</span><span class="s2">&quot;http://rxnav.nlm.nih.gov/REST/rxcui/%s/related?rela=has_ingredient&quot;</span> <span class="o">%</span> <span class="nx">med</span><span class="p">[</span><span class="s1">&#39;rxcui&#39;</span><span class="p">]).</span><span class="nx">read</span><span class="p">()</span>
<span class="nx">info</span> <span class="o">=</span> <span class="nx">ElementTree</span><span class="p">.</span><span class="nx">fromstring</span><span class="p">(</span><span class="nx">rxnav_info_xml</span><span class="p">)</span>
<span class="nx">med</span><span class="p">[</span><span class="s1">&#39;ingredients&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="nx">ing</span><span class="p">.</span><span class="nx">text</span> <span class="k">for</span> <span class="nx">ing</span> <span class="k">in</span> <span class="nx">info</span><span class="p">.</span><span class="nx">findall</span><span class="p">(</span><span class="s1">&#39;relatedGroup/conceptGroup/conceptProperties/name&#39;</span><span class="p">)]</span>
-</code></pre>
-</div>
+</code></pre></div>
<p>Most of that code above is to quickly parse the XML we get back from RxNav and
obtain the ingredient names.</p>
-<p>Now that we've combined the SMART record data with a third-party data source, we
+<p>Now that we&#39;ve combined the SMART record data with a third-party data source, we
can just render our HTML:</p>
<div class="highlight"><pre><code class="javascript"> <span class="nx">meds_html</span> <span class="o">=</span> <span class="s2">&quot;\n&quot;</span><span class="p">.</span><span class="nx">join</span><span class="p">([</span><span class="s2">&quot;&lt;li&gt;%s&lt;br /&gt;&lt;small&gt;ingredients: %s&lt;/small&gt;&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="nx">str</span><span class="p">(</span><span class="nx">med</span><span class="p">[</span><span class="s1">&#39;name&#39;</span><span class="p">]),</span> <span class="s2">&quot;, &quot;</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="nx">med</span><span class="p">[</span><span class="s1">&#39;ingredients&#39;</span><span class="p">]))</span> <span class="k">for</span> <span class="nx">med</span> <span class="k">in</span> <span class="nx">meds</span><span class="p">])</span>
-</code></pre>
-</div>
+</code></pre></div>
-<p>and we're done.</p>
+<p>and we&#39;re done.</p>
-<p>(Note that we're using clunky string concatenation to produce our HTML. Of
-course we recommend using a templating system, but we didn't want to burden the
+<p>(Note that we&#39;re using clunky string concatenation to produce our HTML. Of
+course we recommend using a templating system, but we didn&#39;t want to burden the
explanation with a templating language at this point.)</p>
<h2>What Next?</h2>
View
61 _site/howto/build_a_smart_app/index.html
@@ -109,7 +109,7 @@
<p>We are re-recording the screencast to catch up with the latest API old
<a href="http://vimeo.com/20113823">screencast</a>.</p>
-<iframe
+<p><iframe
src="http://player.vimeo.com/video/20113823"
width="500"
height="375"
@@ -117,7 +117,7 @@
webkitAllowFullScreen
mozallowfullscreen
allowFullScreen>
-</iframe>
+</iframe></p>
<h1>Setting up your Environment</h1>
@@ -126,17 +126,17 @@
SMART container.</p>
<p>You can choose any toolkit you want to write a web app: Java Spring, Ruby on
-Rails, Python/Django, etc. For the purposes of this documentation, we've chosen
+Rails, Python/Django, etc. For the purposes of this documentation, we&#39;ve chosen
webpy, a very simple, minimalist Python web framework, which helps us show you
the important SMART-related code more quickly. Also, if you want to get going
quickly with the more advanced app features, you probably want to stick with
Java or Python for now, as those are the two programming languages in which
-we've built client libraries. That said, if you're comfortable with OAuth and
+we&#39;ve built client libraries. That said, if you&#39;re comfortable with OAuth and
REST, you can use another programming language without fear.</p>
<p>We also provide you with a SMART EMR hosted at <code>sandbox.smartplatforms.org</code>. We
-call it the SMART Reference EMR, and we've loaded it with 50 patient records on
-which you can try out your app. To get going, you'll need to:</p>
+call it the SMART Reference EMR, and we&#39;ve loaded it with 50 patient records on
+which you can try out your app. To get going, you&#39;ll need to:</p>
<ol>
<li>Navigate to the [developers sandbox](http://sandbox.smartplatforms.org/login")</li>
@@ -147,8 +147,8 @@
<p>This will open a SMART app iframe pointing to <code>localhost:8000</code>, which is where
your app should be running. If you need an app with a different hostname (say,
-my_internal_server.net), just e-mail joshua dot mandel at childrens.harvard.edu
-with a manifest file and we'll set you up!</p>
+my<em>internal</em>server.net), just e-mail joshua dot mandel at childrens.harvard.edu
+with a manifest file and we&#39;ll set you up!</p>
<h1>Barebones App</h1>
@@ -159,8 +159,8 @@
</ul>
<p>You could set up Apache to serve these as static files. In this documentation,
-we're using webpy for everything, just for consistency. Also, you may find that,
-for putting up a couple of static files, it's easier to get going with webpy
+we&#39;re using webpy for everything, just for consistency. Also, you may find that,
+for putting up a couple of static files, it&#39;s easier to get going with webpy
than with Apache.</p>
<h2>Index</h2>
@@ -170,8 +170,7 @@
is where all the fun happens! Make sure to include the SMART page script:</p>
<div class="highlight"><pre><code class="html"> <span class="nt">&lt;script </span><span class="na">src=</span><span class="s">&quot;http://sample-apps.smartplatforms.org/framework/smart/scripts/smart-api-client.js&quot;</span><span class="nt">&gt;&lt;/script&gt;</span>
-</code></pre>
-</div>
+</code></pre></div>
<p>This script serves to connect your HTML page to the SMART JavaScript library.</p>
@@ -187,7 +186,7 @@
<p>For a complete reference of the app context, check out the JavaScript Library
reference.</p>
-<p>A more complete index file that displays the current patient's name might thus
+<p>A more complete index file that displays the current patient&#39;s name might thus
look like:</p>
<div class="highlight"><pre><code class="html"> <span class="cp">&lt;!DOCTYPE html&gt;</span>
@@ -206,23 +205,22 @@
<span class="nt">&lt;/script&gt;</span>
<span class="nt">&lt;/body&gt;</span>
<span class="nt">&lt;/html&gt;</span>
-</code></pre>
-</div>
+</code></pre></div>
<h1>Using the SMART API</h1>
<p>At this point, your SMART app is ready to make API calls to obtain health data.
Remember that your app is instantiated in an IFRAME for the specific purpose of
accessing a single medical record. This means that, from JavaScript, you can
-request medical data without specifying patient context, because it's already
+request medical data without specifying patient context, because it&#39;s already
determined by the JavaScript context.</p>
<h2>Asynchronous Calls</h2>
-<p>Let's load the patient's medications using SMART.get_medications(). The most
+<p>Let&#39;s load the patient&#39;s medications using SMART.get<em>medications(). The most
important thing you need to know about all SMART JavaScript APIs is that they
-are asynchronous: you won't get the meds as a result of the
-SMART.get_medications() call. Instead, you need to specify callback functions
+are asynchronous: you won&#39;t get the meds as a result of the
+SMART.get</em>medications() call. Instead, you need to specify callback functions
that will be invoked when the results are ready:</p>
<div class="highlight"><pre><code class="javascript"> <span class="nx">SMART</span><span class="p">.</span><span class="nx">get_medications</span><span class="p">().</span><span class="nx">success</span><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="nx">meds</span><span class="p">)</span> <span class="p">{</span>
@@ -230,8 +228,7 @@
<span class="p">}).</span><span class="nx">error</span><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">// handle the error</span>
<span class="p">});</span>
-</code></pre>
-</div>
+</code></pre></div>
<p>Why did we design the API this way? Because, in most cases, the SMART container
will need to make a call to a server to obtain the requested data. That could
@@ -247,18 +244,17 @@
passing it the resulting medications as a parameter. This result is in the form
of an SMARTResponse object containing the RDF graph. RDF (Resource Description
Framework) is an open and flexible approach to modeling all kinds of data in a
-graph structure. If you haven't used RDF, you should read our Quick Introduction
+graph structure. If you haven&#39;t used RDF, you should read our Quick Introduction
to RDF and SPARQL.</p>
<p>The bottom line is a SMART medication list is an RDF graph that can be easily
navigated and queried. For example, if meds is an RDF graph, then:</p>
<div class="highlight"><pre><code class="javascript"> <span class="nx">meds</span><span class="p">.</span><span class="nx">graph</span><span class="p">.</span><span class="nx">where</span><span class="p">(</span><span class="s2">&quot;?medication rdf:type sp:Medication&quot;</span><span class="p">)</span>
-</code></pre>
-</div>
+</code></pre></div>
<p>selects all of &quot;objects&quot; in the graph that have a datatype sp:Medication, where
-sp stands for <a href="http://smartplatforms.org/ns#"><a href="http://smartplatforms.org/ns#">http://smartplatforms.org/ns#</a></a>,
+sp stands for <a href="http://smartplatforms.org/ns#">http://smartplatforms.org/ns#</a>,
the location of the SMART vocabulary.</p>
<p>Of course, we want more than just the raw &quot;objects,&quot; we want their properties,
@@ -270,11 +266,10 @@
<span class="p">.</span><span class="nx">where</span><span class="p">(</span><span class="s2">&quot;?medication rdf:type sp:Medication&quot;</span><span class="p">)</span>
<span class="p">.</span><span class="nx">where</span><span class="p">(</span><span class="s2">&quot;?medication sp:drugName ?drug_name_code&quot;</span><span class="p">)</span>
<span class="p">.</span><span class="nx">where</span><span class="p">(</span><span class="s2">&quot;?drug_name_code dcterms:title ?drugname&quot;</span><span class="p">);</span>
-</code></pre>
-</div>
+</code></pre></div>
<p>This is effectively a JavaScript query on the RDF graph, and it returns a set of
-JavaScript objects with properties we're interested in, in particular drugname.
+JavaScript objects with properties we&#39;re interested in, in particular drugname.
We can then iterate over the list of returned objects and extract the drugname
property for each one:</p>
@@ -286,12 +281,11 @@
<span class="nx">med_names</span><span class="p">.</span><span class="nx">each</span><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="nx">i</span><span class="p">,</span> <span class="nx">single_med</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">// do something with single_med.drugname</span>
<span class="p">});</span>
-</code></pre>
-</div>
+</code></pre></div>
<h2>The Complete App</h2>
-<p>So, to display the patient's medications, we set up an HTML list, &lt;ul&gt;, and we
+<p>So, to display the patient&#39;s medications, we set up an HTML list, &lt;ul&gt;, and we
append to it with the name of each drug in our iteration:</p>
<div class="highlight"><pre><code class="html"> <span class="cp">&lt;!DOCTYPE html&gt;</span>
@@ -321,10 +315,9 @@
<span class="nt">&lt;/script&gt;</span>
<span class="nt">&lt;/body&gt;</span>
<span class="nt">&lt;/html&gt;</span>
-</code></pre>
-</div>
+</code></pre></div>
-<p>And that's it! In a few lines of HTML and JavaScript code, we've got ourselves
+<p>And that&#39;s it! In a few lines of HTML and JavaScript code, we&#39;ve got ourselves
an app that can request the medications from the current record and display
them.</p>
View
35 _site/howto/build_smart_frame_ui_apps/index.html
@@ -109,8 +109,8 @@
</div>
<p>SMART v0.4 allows developers to build a kind of meta-app, or &quot;Frame UI App&quot; that
-can lay out multiple traditional UI Apps at the same time. For example, let's
-say you'd like to display a medication list app right alongside a medication
+can lay out multiple traditional UI Apps at the same time. For example, let&#39;s
+say you&#39;d like to display a medication list app right alongside a medication
adherence app. You can accomplish this by writing a Frame UI app that lays them
both out on the screen simultaneously.</p>
@@ -132,12 +132,11 @@
fact, a Frame UI app include the following line in its SMART Manifest:</p>
<div class="highlight"><pre><code class="javascript"> <span class="s2">&quot;mode&quot;</span> <span class="o">:</span> <span class="s2">&quot;frame_ui&quot;</span>
-</code></pre>
-</div>
+</code></pre></div>
<h2>Building blocks</h2>
-<p>Frame UI apps occupy a unique place in the SMART architecture, since they're
+<p>Frame UI apps occupy a unique place in the SMART architecture, since they&#39;re
<em>apps</em> that also have some capabilities of <em>containers</em>. In other words,
they <em>are</em> apps and they can also <em>run</em> apps. To make this work, Frame UI
apps need to include three javascript libraries:</p>
@@ -150,8 +149,8 @@
<h2>Example Frame UI App</h2>
-<p>Let's work through an example of a simple Frame UI app that can display three
-SMART apps a time, and allows the user to select these apps. First off, let's
+<p>Let&#39;s work through an example of a simple Frame UI app that can display three
+SMART apps a time, and allows the user to select these apps. First off, let&#39;s
see what apps are available to launch and load them into a &quot;Carousel&quot; of choices
to display:</p>
@@ -170,26 +169,25 @@
<span class="p">});</span>
<span class="p">});</span>
<span class="p">});</span>
-</code></pre>
-</div>
+</code></pre></div>
<p>This code fetches a list of manifests from the container <code>SMART.get_manifests</code>,
loops through them, and displays an icon for each app available. It then
attaches a click handler to each icon: when clicked, we call
-SMART_HOST.launch_app to initiate the launch of this new app. We pass in the
-app's manifests <code>m</code> and our current context <code>SMART.context</code>, which specifies the
+SMART<em>HOST.launch</em>app to initiate the launch of this new app. We pass in the
+app&#39;s manifests <code>m</code> and our current context <code>SMART.context</code>, which specifies the
user and record.</p>
<h3>Handling an app launch:</h3>
-<p>When a user clicks on an app icon and SMART_HOST.launch_app is called, the
+<p>When a user clicks on an app icon and SMART<em>HOST.launch</em>app is called, the
SMART libraries take care of most details of the app launch process. But the
SMART libraries expect a little bit of &quot;help&quot; (in the form of a helper
function) to determine which IFRAME element to use in positioning the
newly-launched app. Since our Frame UI app will perform a pretty simple layout,
-this doesn't take much. We'll assume that three IFRAMES are available on the
-screen at all times, and we'll just populate them in order, looping back to the
-beginning when they're all full.</p>
+this doesn&#39;t take much. We&#39;ll assume that three IFRAMES are available on the
+screen at all times, and we&#39;ll just populate them in order, looping back to the
+beginning when they&#39;re all full.</p>
<div class="highlight"><pre><code class="javascript"> <span class="kd">var</span> <span class="nx">current_iframe</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
<span class="kd">var</span> <span class="nx">iframes_available</span> <span class="o">=</span> <span class="mi">3</span><span class="p">;</span>
@@ -198,17 +196,16 @@
<span class="nx">callback</span><span class="p">(</span><span class="nx">$</span><span class="p">(</span><span class="s2">&quot;iframe&quot;</span><span class="p">)[</span><span class="nx">current_iframe</span> <span class="o">%</span> <span class="nx">iframes_available</span><span class="p">]);</span>
<span class="nx">current_iframe</span><span class="o">++</span><span class="p">;</span>
<span class="p">};</span>
-</code></pre>
-</div>
+</code></pre></div>
<h2>See it live</h2>
<p>You can view the example app at:
-<a href="http://sandbox-dev.smartplatforms.org"><a href="http://sandbox-dev.smartplatforms.org">http://sandbox-dev.smartplatforms.org</a></a>
+<a href="http://sandbox-dev.smartplatforms.org">http://sandbox-dev.smartplatforms.org</a>
(just create an account and add the &quot;Frame UI Example&quot; app.)</p>
<p>You can see the code at:
-<a href="https://github.com/chb/smart_sample_apps/tree/dev/static/framework/frame_ui_example"><a href="https://github.com/chb/smart_sample_apps/tree/dev/static/framework/frame_ui_example">https://github.com/chb/smart_sample_apps/tree/dev/static/framework/frame_ui_example</a></a> </p>
+<a href="https://github.com/chb/smart_sample_apps/tree/dev/static/framework/frame_ui_example">https://github.com/chb/smart<em>sample</em>apps/tree/dev/static/framework/frame<em>ui</em>example</a> </p>
<h2>Learning more</h2>
View
25 _site/howto/deferred/index.html
@@ -120,7 +120,7 @@
the pattern, to avoid messy code structures like deeply nested callbacks.</p>
<p>Using this pattern is similar to attaching multiple callback functions to
-<a href="http://api.jquery.com/jQuery.ajax/">jQuery.ajax's</a> <code>.success</code>, <code>.error</code>, and
+<a href="http://api.jquery.com/jQuery.ajax/">jQuery.ajax&#39;s</a> <code>.success</code>, <code>.error</code>, and
<code>.complete</code> handlers, in fact, those handlers use Deferred Object under the
hood.</p>
@@ -134,15 +134,12 @@
<h2>A Real-World Example</h2>
-<p><a href="https://github.com/chb/smart_sample_apps/blob/master/static/framework/cardi
-o_risk_viz/load_data.js">The Cardiac Risk Visualiztion
+<p><a href="https://github.com/chb/smart_sample_apps/blob/master/static/framework/cardi%0Ao_risk_viz/load_data.js">The Cardiac Risk Visualiztion
App</a> requires both demographics (gender and age) and also
lab results (hsCRP, cholesterol, and HDL values) to compute a risk score. This
requires two calls to the SMART Connect API:
-<a href="http://wiki.chip.org/smart-project/index.php/Developers_Docum
-entation:_SMART_App_Javascript_Libraries#SMART.get_demographics">get_demographcis</a> and
-<a href="http://wiki.chip.org/smart-project/index.php/Developers_Docume
-ntation:_SMART_App_Javascript_Libraries#SMART.get_lab_results">get_lab_results</a>.</p>
+<a href="http://wiki.chip.org/smart-project/index.php/Developers_Docum%0Aentation:_SMART_App_Javascript_Libraries#SMART.get_demographics">get_demographcis</a> and
+<a href="http://wiki.chip.org/smart-project/index.php/Developers_Docume%0Antation:_SMART_App_Javascript_Libraries#SMART.get_lab_results">get<em>lab</em>results</a>.</p>
<p>In the code below each of these calls is wrapped in a function that is
registered with $.when. Once all the registered functions signal they have now
@@ -151,7 +148,7 @@
handler is executed. Which in this example draws the full visualization being
safe in the knowledge that all the required data is available.</p>
-<p>One detail to note is that both functions return the Deferred's promise object
+<p>One detail to note is that both functions return the Deferred&#39;s promise object
to the observer. A promise object is the read-only object that is used by the
observer function to query the current state of the function and therefore is
the required return value of the callbacks.</p>
@@ -223,12 +220,11 @@
<span class="nx">draw_visualization</span><span class="p">();</span>
<span class="p">});</span>
<span class="p">});</span>
-</code></pre>
-</div>
+</code></pre></div>
<h2>A Shorter Syntax</h2>
-<p>The get_demographics() and get_labs() functions above can also be written using
+<p>The get<em>demographics() and get</em>labs() functions above can also be written using
a more compact (but equivalent) syntax:</p>
<div class="highlight"><pre><code class="javascript"> <span class="kd">var</span> <span class="nx">get_demographics</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
@@ -249,14 +245,13 @@
<span class="p">});</span>
<span class="p">}).</span><span class="nx">promise</span><span class="p">();</span>
<span class="p">};</span>
-</code></pre>
-</div>
+</code></pre></div>
<h2>Further Reading</h2>
<ul>
-<li><a href="http://api.jquery.com/category/deferred-object/">Deferred Object</a> in jQuery's API docs</li>
-<li><a href="http://www.erichynds.com/jquery/using-deferreds-in-jquery/">Eric Hynds' article</a> for a further explanation and examples</li>
+<li><a href="http://api.jquery.com/category/deferred-object/">Deferred Object</a> in jQuery&#39;s API docs</li>
+<li><a href="http://www.erichynds.com/jquery/using-deferreds-in-jquery/">Eric Hynds&#39; article</a> for a further explanation and examples</li>
</ul>
View
17 _site/howto/filters/index.html
@@ -110,7 +110,7 @@
two data types: <a href="/reference/data_model/#Lab_Result">lab results</a> and <a href="/reference/data_model/#Vital_Sign_Set">vital
sign sets</a>. This allows you to
limit the results returned from these calls instead of the previous
-behavior of returning all of the record's labs or vitals which in many
+behavior of returning all of the record&#39;s labs or vitals which in many
real-world settings could return a large and unwieldy set of data.</p>
<p>Both the SMART REST and SMART Connect APIs expose this functionality, and
@@ -121,23 +121,23 @@
which provides your callback functions a set of useful metadata that can be
used to make further calls.</p>
-<p>We'll demonstrate this using the SMART Connect JSON-LD API and give an
+<p>We&#39;ll demonstrate this using the SMART Connect JSON-LD API and give an
brief code sample for the SMART REST Python client as well.</p>
<h2>An Javascript Example for Filtering Lab Results</h2>
-<p>For this example, we'll be using the SMART JSON-LD interface described
+<p>For this example, we&#39;ll be using the SMART JSON-LD interface described
<a href="../intro_to_jsonld/">here</a> to the SMART Connect Javascript library.</p>
-<p>To start let's set up a query with the following parameters:</p>
+<p>To start let&#39;s set up a query with the following parameters:</p>
<ul>
-<li>Filter the labs to find this patient's LDL results. LDL's have three
-LOINC codes that differ only in the method used to find the result. We'll
+<li>Filter the labs to find this patient&#39;s LDL results. LDL&#39;s have three
+LOINC codes that differ only in the method used to find the result. We&#39;ll
make a pipe (|) seperated string of these codes: <code>&quot;13457-7|2089-1|18262-6&quot;</code></li>
<li>Find the results from 2010-01-01 to 2012-01-01 using the <code>&quot;date_from&quot;</code>
and <code>&quot;date_to&quot;</code> parameters.</li>
-<li>Lastly, let's restrict the number of returned results to a &quot;page&quot;
+<li>Lastly, let&#39;s restrict the number of returned results to a &quot;page&quot;
of 10 results by setting the <code>limit</code> parameter to <code>10</code> and the
<code>offset</code> parameter to <code>0</code>. To fetch the next &quot;page&quot; of ten results,
you would set the <code>offset</code> to <code>10</code> and keep the limit at <code>10</code>.</li>
@@ -169,8 +169,7 @@
<span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s1">&#39;totalResultCount&#39;</span><span class="p">,</span> <span class="nx">rs</span><span class="p">.</span><span class="nx">totalResultCount</span><span class="p">);</span>
<span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s1">&#39;nextPageURL&#39;</span><span class="p">,</span> <span class="nx">rs</span><span class="p">.</span><span class="nx">nextPageURL</span><span class="p">);</span>
<span class="p">})</span>
-</code></pre>
-</div>
+</code></pre></div>
<h2>Filtering Vital Sign Sets</h2>
View
26 _site/howto/got_statins/index.html
@@ -101,34 +101,32 @@
<a class='githublink' href=''>here</a> to edit this page on Github.
</div>
-<p>If you haven't already, you should read <a href="../build_a_smart_app">HOWTO Build a SMART App</a> first.</p>
+<p>If you haven&#39;t already, you should read <a href="../build_a_smart_app">HOWTO Build a SMART App</a> first.</p>
<p>Here, we build a complete SMART Connect app from pure HTML and Javascript.
-Modeled on the uniquely popular, laser-focused chef-d'oeuvre
-<a href="http://isitchristmas.com/">isitchristmas.com</a>, this app obtains a patient's
+Modeled on the uniquely popular, laser-focused chef-d&#39;oeuvre
+<a href="http://isitchristmas.com/">isitchristmas.com</a>, this app obtains a patient&#39;s
medication list, determines whether there are statins on board, and relays the
-answer in large, bold typeface. Using the SMART Connect API, there's no need for
+answer in large, bold typeface. Using the SMART Connect API, there&#39;s no need for
explicit authentication, session-management, or AJAX calls.</p>
<p>Every SMART app exposes a URL at <code>index.html</code> where all the fun happens! First,
-don't forget to include:</p>
+don&#39;t forget to include:</p>
<div class="highlight"><pre><code class="html"> <span class="nt">&lt;script </span><span class="na">src=</span><span class="s">&quot;http://sample-apps.smartplatforms.org/framework/smart/scripts/smart-api-client.js&quot;</span><span class="nt">&gt;&lt;/script&gt;</span>
-</code></pre>
-</div>
+</code></pre></div>
<p>Inside index.html, we invoke SMART.ready() with a callback function so we can be
sure that the SMART client-side library has finished loading. At this point, a
SMART JavaScript object that provides some basic context (such as SMART.user,
-which provides the name and ID of the user who's running the app, and
+which provides the name and ID of the user who&#39;s running the app, and
SMART.record which provides the name and ID of the patient whose record is
loaded).</p>
<p>And now we can fetch some data from the patient record: </p>
<div class="highlight"><pre><code class="javascript"> <span class="nx">SMART</span><span class="p">.</span><span class="nx">get_medications</span><span class="p">().</span><span class="nx">success</span><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="nx">meds</span><span class="p">)</span> <span class="p">{</span> <span class="p">...</span> <span class="p">});</span>
-</code></pre>
-</div>
+</code></pre></div>
<p>As you may remember from the HOWTO, meds is a SMART Response object that
includes an RDF graph of medications (type sp:Medication). These medications
@@ -146,10 +144,9 @@
<span class="p">.</span><span class="nx">where</span><span class="p">(</span><span class="s2">&quot;?m rdf:type sp:Medication&quot;</span><span class="p">)</span>
<span class="p">.</span><span class="nx">where</span><span class="p">(</span><span class="s2">&quot;?m sp:drugName ?n&quot;</span><span class="p">)</span>
<span class="p">.</span><span class="nx">where</span><span class="p">(</span><span class="s2">&quot;?n dcterms:title ?drugname&quot;</span><span class="p">);</span>
-</code></pre>
-</div>
+</code></pre></div>
-<p>Here's how it all comes together:</p>
+<p>Here&#39;s how it all comes together:</p>
<div class="highlight"><pre><code class="html"> <span class="cp">&lt;!DOCTYPE html&gt;</span>
<span class="nt">&lt;html&gt;</span>
@@ -208,8 +205,7 @@
<span class="nt">&lt;/script&gt;</span>
<span class="nt">&lt;/body&gt;</span>
<span class="nt">&lt;/html&gt;</span>
-</code></pre>
-</div>
+</code></pre></div>
<p>This little app can be statically hosted anywhere. If a SMART container loads it
up in an iframe, it will have instant access to the in-context patient record
View
23 _site/howto/intro_to_jsonld/index.html
@@ -110,16 +110,16 @@
<p>The SMART JSON-LD API provides an additional interface to the SMART datamodel
based on Javascript objects in addition to the RDF/XML and the SPARQL
-interface. SMART's RDF-based interface will remain available for use as well.</p>
+interface. SMART&#39;s RDF-based interface will remain available for use as well.</p>
<h1>What is JSON?</h1>
<p><a href="http://json.org">JSON</a> is the highly popular lightweight data serialization and
-interchange format based on a simplified subset of Javascript objects. It's a
+interchange format based on a simplified subset of Javascript objects. It&#39;s a
natural fit for representing data for SMART Connect apps. All JSON objects are
valid Javascript objects so all Javascript tools and libraries &mdash;
including tools already built into most browsers &mdash; can be used to examine
-and manipulate them. We'll see examples of this below.</p>
+and manipulate them. We&#39;ll see examples of this below.</p>
<h1>What is JSON-LD?</h1>
@@ -129,7 +129,7 @@
further links to be fetched <em>ad infinitum</em>. In essence, a &quot;web of data&quot;.
<a href="http://json-ld.org">JSON-LD</a> is a leading standard to represent linked data in JSON.</p>
-<p>As a SMART app developer, you don't have to be concerned with creating
+<p>As a SMART app developer, you don&#39;t have to be concerned with creating
JSON-LD objects or even querying for them, since the SMART JavaScript
client library will provide you with JSON-LD objects automatically
each time you make usual API calls like <code>get_MEDICATIONS()</code>.</p>
@@ -156,12 +156,11 @@
<span class="p">])</span>
<span class="p">})</span>
<span class="p">})</span>
-</code></pre>
-</div>
+</code></pre></div>
<p>Looking into the first object in the <code>r.objects.of_type.Medication</code> array in a
-browser's developer tools (such as Chrome's Developer Tools or Firebug) you can
-see that it is a standard JSON object filled with the patient's data according
+browser&#39;s developer tools (such as Chrome&#39;s Developer Tools or Firebug) you can
+see that it is a standard JSON object filled with the patient&#39;s data according
to the SMART data model for a <a href="http://dev.smartplatforms.org/reference/data_model/#Medication">medication</a>.</p>
<div class="highlight"><pre><code class="javascript"> <span class="c1">// simplified to show only relevant properties</span>
@@ -185,8 +184,7 @@
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
-</code></pre>
-</div>
+</code></pre></div>
<h2>The SMART Convention for Property Names</h2>
@@ -281,12 +279,11 @@
<span class="nt">&lt;/script&gt;</span>
<span class="nt">&lt;/body&gt;</span>
<span class="nt">&lt;/html&gt;</span>
-</code></pre>
-</div>
+</code></pre></div>
<h1>Learning More</h1>
-<p>SMART's JSON-LD API gives you as a web developer an natural, familiar,
+<p>SMART&#39;s JSON-LD API gives you as a web developer an natural, familiar,
and interactively discoverable interface to SMART patient data. You can
start using this API in your apps today. For examples of this API in use
see the code (in <code>main.js</code>) for the SMART <a href="https://github.com/chb/smart_sample_apps/tree/master/static/framework/dm_monograph/js/main.js">Diabetes Monograph app</a>.</p>
View
118 _site/howto/intro_to_rdf/index.html
@@ -98,8 +98,8 @@
<div id="toc"> </div>
<p>The SMART API supplies patient record data in the form of an RDF graph. If
-you've never used (or even heard of!) RDF, this document should help you get up
-to speed. So let's jump right in!</p>
+you&#39;ve never used (or even heard of!) RDF, this document should help you get up
+to speed. So let&#39;s jump right in!</p>
<div class='simple_small_box'>Help us improve! You can correct errors or add to this page by clicking
<a class='githublink' href=''>here</a> to edit this page on Github.
@@ -108,10 +108,10 @@
<h2>What is RDF, anyway?</h2>
<p>RDF, the Resource Description Framework, is a web standard &quot;for representing
-information about resources&quot; (this according to the <a href="http://www.w3.org/TR/2004/REC-rdf-primer-20040210/">W3C's RDF
-Primer</a>). In brief, it's a
+information about resources&quot; (this according to the <a href="http://www.w3.org/TR/2004/REC-rdf-primer-20040210/">W3C&#39;s RDF
+Primer</a>). In brief, it&#39;s a
flexible way to represent data in the form of sentences or &quot;triples&quot; that link a
-subject, a predicate, and an object. For example, let's say we want to represent
+subject, a predicate, and an object. For example, let&#39;s say we want to represent
the idea that &quot;Mr. Smith takes atorvastatin&quot;. We might create the following
triple</p>
@@ -127,7 +127,7 @@
<li>Resources are related by triples</li>
</ol>
-<p>Let's explore each in more depth</p>
+<p>Let&#39;s explore each in more depth</p>
<h2>Everything (almost) is a resource</h2>
@@ -135,24 +135,23 @@
Smith a &quot;resource&quot; because he is a particular guy out there in the world. He is
not just the string of letters &quot;M-r-.-S-m-i-t-h.&quot; Importantly, if I know Mr.
Alex Smith and you know Mr. Bob Smith, we are not talking about the same
-resource! To prevent these kinds of mix-ups, resources in RDF aren't just
-identified by strings like &quot;Mr. Smith.&quot; Instead, they're represented by Uniform
+resource! To prevent these kinds of mix-ups, resources in RDF aren&#39;t just
+identified by strings like &quot;Mr. Smith.&quot; Instead, they&#39;re represented by Uniform
Resource Identifiers basically URLs that provide a built-in namespace. For
-example, let's say my Mr. Smith maintains a web site at
-<a href="http://alexsmith.somedomain.com"><a href="http://alexsmith.somedomain.com">http://alexsmith.somedomain.com</a></a>. I might
+example, let&#39;s say my Mr. Smith maintains a web site at
+<a href="http://alexsmith.somedomain.com">http://alexsmith.somedomain.com</a>. I might
refer to him by the URL
-<a href="http://alexsmith.somedomain.com/me]"><a href="http://alexsmith.somedomain.com/me">http://alexsmith.somedomain.com/me</a></a>. Now
-you certainly wouldn't confuse my Mr. Smith for yours! (Note there doesn't have
+<a href="http://alexsmith.somedomain.com/me%5D">http://alexsmith.somedomain.com/me</a>. Now
+you certainly wouldn&#39;t confuse my Mr. Smith for yours! (Note there doesn&#39;t have
to be an actual web page served at the address of a URI. The important thing is
that the URI identifies a resource. Uniformly.)</p>
<p>What about the predicate in our example, the word &quot;takes&quot;? Predicates in RDF are
triples, too. If we just used the string &quot;takes&quot; as our predicate, again we
might mean different things I might mean &quot;consumes a drug, as part of a daily
-regimen&quot;, and you (cynic!) might mean &quot;steals from his wife's pillbox on
-Thursday mornings.&quot; To resolve this ambiguity, I could represent 'takes' as
-<a href="http://joshuamandel.com/my_dr
-ug_vocabulary/takes"><a href="http://joshuamandel.com/my_drug_vocabulary/takes">http://joshuamandel.com/my_drug_vocabulary/takes</a></a>. Over time, I could build up a rich vocabulary with all
+regimen&quot;, and you (cynic!) might mean &quot;steals from his wife&#39;s pillbox on
+Thursday mornings.&quot; To resolve this ambiguity, I could represent &#39;takes&#39; as
+<a href="http://joshuamandel.com/my_dr%0Aug_vocabulary/takes">http://joshuamandel.com/my<em>drug</em>vocabulary/takes</a>. Over time, I could build up a rich vocabulary with all
kinds of terms, and use these as predicates in my RDF triples. In general,
things work best when people can agree on the meanings of terms and use a shared
vocabulary. So folks build up publically defined vocabularies such as
@@ -165,21 +164,20 @@
<p>And finally, what about &quot;atorvastatin&quot;? Again, the best way to represent a
concept like atorvastatin is as a URI that everyone can agree on. One
-possibility is to use the drug's RxNorm Concept ID (in this case, 83367) as part
+possibility is to use the drug&#39;s RxNorm Concept ID (in this case, 83367) as part
of the URI. For example, SMART uses the URI
-<a href="http://link.informat
-ics.stonybrook.edu/rxnorm/RXCUI/83367"><a href="http://link.informatics.stonybrook.edu/rxnorm/RXCUI/83367">http://link.informatics.stonybrook.edu/rxnorm/RXCUI/83367</a></a>, sharing a vocabulary with Stonybrook.
+<a href="http://link.informat%0Aics.stonybrook.edu/rxnorm/RXCUI/83367">http://link.informatics.stonybrook.edu/rxnorm/RXCUI/83367</a>, sharing a vocabulary with Stonybrook.
But recall we said almost everything is a resource. If we want, RDF lets us use
a simple string as the object of a triple. So, for example, consider this
representation of a Haiku</p>
<ul>
-<li>subject <a href="http://dilute.net/poems/25"><a href="http://dilute.net/poems/25">http://dilute.net/poems/25</a></a></li>
-<li>predicate dcterms title (Dublin Core Terms vocabulary's 'title' predicate)</li>
+<li>subject <a href="http://dilute.net/poems/25">http://dilute.net/poems/25</a></li>
+<li>predicate dcterms title (Dublin Core Terms vocabulary&#39;s &#39;title&#39; predicate)</li>
<li>object &quot;Haiku entitled Substitutability the SMART way to go.&quot;</li>
</ul>
-<p>In this case, I don't need to point to a resource as the title of my haiku. The
+<p>In this case, I don&#39;t need to point to a resource as the title of my haiku. The
title is really just a string, after all -- so I can just represent it as such. </p>
<h2>Resources are related by triples</h2>
@@ -191,11 +189,11 @@
In addition to the triple above, I could some more triples</p>
<ul>
-<li>subject <a href="http://dilute.net/poems/25"><a href="http://dilute.net/poems/25">http://dilute.net/poems/25</a></a></li>
-<li>predicate dc:creator (Dublin Core vocabulary's 'creator' predicate)</li>
-<li><p>object <a href="http://joshuamandel.com/me"><a href="http://joshuamandel.com/me">http://joshuamandel.com/me</a></a></p></li>
-<li><p>subject <a href="http://joshuamandel.com/me"><a href="http://joshuamandel.com/me">http://joshuamandel.com/me</a></a></p></li>
-<li><p>predicate foaf:name (FOAF vocabulary's 'name' predicate)</p></li>
+<li>subject <a href="http://dilute.net/poems/25">http://dilute.net/poems/25</a></li>
+<li>predicate dc:creator (Dublin Core vocabulary&#39;s &#39;creator&#39; predicate)</li>
+<li><p>object <a href="http://joshuamandel.com/me">http://joshuamandel.com/me</a></p></li>
+<li><p>subject <a href="http://joshuamandel.com/me">http://joshuamandel.com/me</a></p></li>
+<li><p>predicate foaf:name (FOAF vocabulary&#39;s &#39;name&#39; predicate)</p></li>
<li><p>object &quot;Josh Mandel&quot;</p></li>
</ul>
@@ -203,37 +201,37 @@
subject of another (as a person with a name)!</p>
<p>What about more complex relationships? For example, what if I want to represent
-the fact that my breakfast this morning consisted of Joe's O's, milk, and
-coffee? This is an open-ended data-modeling exercise, but I'll just point out
+the fact that my breakfast this morning consisted of Joe&#39;s O&#39;s, milk, and
+coffee? This is an open-ended data-modeling exercise, but I&#39;ll just point out
one approach which involves creaing a resource for &quot;the stuff I had for
breakfast this morning&quot;, and adding relations to that. So then (in sketch form)
-we'd have</p>
+we&#39;d have</p>
<ul>
<li>subject <a href="http://joshuamandel.com/me">http://joshuamandel.com/me</a></li>
<li>predicate <a href="http://joshuamandel.com/my_food_vocabulary/ate">http://joshuamandel.com/my_food_vocabulary/ate</a></li>
-<li><p>object _stuff_I_ate_this_morning </p></li>
-<li><p>subject _stuff_I_ate_this_morning</p></li>
-<li><p>predicate rdfli (RDF vocabulary's 'list item' predicate)</p></li>
-<li><p>object &quot;Joe's O's&quot;</p></li>
-<li><p>subject _stuff_I_ate_this_morning</p></li>
+<li><p>object <em>stuff</em>I<em>ate</em>this_morning </p></li>
+<li><p>subject <em>stuff</em>I<em>ate</em>this_morning</p></li>
+<li><p>predicate rdfli (RDF vocabulary&#39;s &#39;list item&#39; predicate)</p></li>
+<li><p>object &quot;Joe&#39;s O&#39;s&quot;</p></li>
+<li><p>subject <em>stuff</em>I<em>ate</em>this_morning</p></li>
<li><p>predicate rdf li</p></li>
<li><p>object &quot;milk&quot;</p></li>
-<li><p>subject <tt>_stuff_I_ate_this_morning </p></li>
+<li><p>subject <tt><em>stuff</em>I<em>ate</em>this_morning </p></li>
<li><p>predicate rdf li</p></li>
<li><p>object &quot;coffee&quot;</p></li>
</ul>
-<p>Notice that I've loosely referred to a resource here as the &quot;bunch of stuff I
-ate this morning&quot;. I didn't give it a formal URI, because it doesn't exist
-outside of the context of this particular RDF graph, and it's entirely defined
+<p>Notice that I&#39;ve loosely referred to a resource here as the &quot;bunch of stuff I
+ate this morning&quot;. I didn&#39;t give it a formal URI, because it doesn&#39;t exist
+outside of the context of this particular RDF graph, and it&#39;s entirely defined
by its relations above. For cases like this, RDF provides anonymous or blank
nodes whose identifiers have meaning only within the context of a particular
graph.</p>
<h2>Representing RDF Graphs</h2>
-<p>So far, we've been talking about RDF graphs as theoretical sets of triples. How
+<p>So far, we&#39;ve been talking about RDF graphs as theoretical sets of triples. How
do we write down or &quot;serialize&quot; an RDF graph in a way that lets us share it with
others? There are in fact several standard notations for representing an RDF
graph. The simplest representation is to write triples out, one per line, with a
@@ -256,36 +254,32 @@
go.<span class="nt">&lt;/terms:title&gt;</span>
<span class="nt">&lt;/rdf:Description&gt;</span>
<span class="nt">&lt;/rdf:RDF&gt;</span>
-</code></pre>
-</div>
+</code></pre></div>
<h1>And what about SPARQL?</h1>
<p>SPARQL is a query language for interacting with RDF graphs. The syntax is
designed to look a bit like SQL, the structured query language used with
relational databases. The W3C maintains an <a href="http://www.w3.org/TR/rdf-sparql-query/">extremely
-readable</a> standard that's peppered with
-examples. Here, we'll not even skim the surface...</p>
+readable</a> standard that&#39;s peppered with
+examples. Here, we&#39;ll not even skim the surface...</p>
<h2>A simple SPARQL query</h2>
-<p>Given our breakfast graph above, let's write a query to find all the things I
-ate! Here's a first attempt (not quite perfect)</p>
-
-<pre><code>PREFIX food: &lt;http://joshuamandel.com/my_food_vocabulary/&gt;
+<p>Given our breakfast graph above, let&#39;s write a query to find all the things I
+ate! Here&#39;s a first attempt (not quite perfect)</p>
+<div class="highlight"><pre><code class="text">PREFIX food: &lt;http://joshuamandel.com/my_food_vocabulary/&gt;
SELECT ?f WHERE
{
&lt;http://joshuamandel.com/me&gt; food:ate ?f.
}
-</code></pre>
-
-<p>A bit of syntax I've defined a prefix called &quot;food&quot; which I'll use to refer to
+</code></pre></div>
+<p>A bit of syntax I&#39;ve defined a prefix called &quot;food&quot; which I&#39;ll use to refer to
my personal food vocabulary. This is just for readability; it lets me later
write food:ate instead of the more verbose
-<a href="http://joshuamandel.com/my_food
-_vocabulary/ate"><a href="http://joshuamandel.com/my_food_vocabulary/ate">http://joshuamandel.com/my_food_vocabulary/ate</a></a>.</p>
+<a href="http://joshuamandel.com/my_food%0A_vocabulary/ate">http://joshuamandel.com/my<em>food</em>vocabulary/ate</a>.</p>
-<p>Now here's what the query does: it looks for triples that match the pattern
+<p>Now here&#39;s what the query does: it looks for triples that match the pattern
inside the WHERE clause. In this case, triples whose subject is me; whose
predicate is food:ate and whose object can be anything (indicated by the
question mark in ?f). My decision to use ?f as a variable name was completely
@@ -293,23 +287,21 @@
matters within the context of my query.</p>
<p>But this query has a problem it returns the blank node
-_stuff_I_ate_this_morning -- and not the actual foods! Let's fix it by
+<em>stuff</em>I<em>ate</em>this_morning -- and not the actual foods! Let&#39;s fix it by
adding to our WHERE clause</p>
-
-<pre><code>PREFIX food: &lt;http://joshuamandel.com/my_food_vocabulary/&gt;
+<div class="highlight"><pre><code class="text">PREFIX food: &lt;http://joshuamandel.com/my_food_vocabulary/&gt;
PREFIX rdf: &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#&gt;
SELECT ?individual_food WHERE
{
&lt;http://joshuamandel.com/me&gt; food:ate ?bunch_of_food.
?bunch_of_food rdf:li ?individual_food.
}
-</code></pre>
-
-<p>Now our where clause includes two statements we're looking for individual foods
-that are items in the list of foods eaten by me. In other words, now we're
+</code></pre></div>
+<p>Now our where clause includes two statements we&#39;re looking for individual foods
+that are items in the list of foods eaten by me. In other words, now we&#39;re
drilling down into the bunch of food to pull out individual items! This returns
-a list of three bindings for the ?individual_food &quot;coffee&quot;, &quot;milk&quot;, and &quot;Joe's
-O's&quot;.</p>
+a list of three bindings for the ?individual_food &quot;coffee&quot;, &quot;milk&quot;, and &quot;Joe&#39;s
+O&#39;s&quot;.</p>
<p>This was just the briefest introduction to the anatomy of a SPARQL query. For
lots more specific examples, try SPARQL examples for SMART.</p>
View
42 _site/howto/rx_reminder/index.html
@@ -106,12 +106,12 @@
<h2>Choosing the right tools</h2>
-<p>Since you can write a SMART REST app in any language using any toolkit, there's
-a lot of flexibility. In general, you'll want to look for a language with
+<p>Since you can write a SMART REST app in any language using any toolkit, there&#39;s
+a lot of flexibility. In general, you&#39;ll want to look for a language with
existing OAuth libraries to handle the details of signing requests to the SMART
-container. Here we'll illustrate the highlights with a simple python-based SMART
+container. Here we&#39;ll illustrate the highlights with a simple python-based SMART
REST app called <em>RxReminder. RxReminder</em> is written using the web.py HTTP
-Framework, but we won't delve into <a href="http://webpy.org/">web.py</a> here. All you
+Framework, but we won&#39;t delve into <a href="http://webpy.org/">web.py</a> here. All you
need to understand is that web.py provides a simple mechanism to map python
functions to URLs.</p>
@@ -121,7 +121,7 @@
<h2>App Structure</h2>
<p>First, recall that every SMART UI app must serve: <code>index.html</code> which loads
-smart-api-client.js to provide the app's functionality.</p>
+smart-api-client.js to provide the app&#39;s functionality.</p>
<p>Just like the app in the HOWTO, we serve the index file as follows in webpy:</p>
@@ -130,14 +130,13 @@
<span class="k">class</span> <span class="nc">RxReminder</span><span class="p">:</span>
<span class="k">def</span> <span class="nf">GET</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="c"># good stuff coming here</span>
-</code></pre>
-</div>
+</code></pre></div>
<h2>Initializing the SMART API Client</h2>
-<p>Now we're getting to the fun part: handling requests for index.html. We'll be
+<p>Now we&#39;re getting to the fun part: handling requests for index.html. We&#39;ll be
using the Python SMART API client libraries to interact with the SMART
-container. For authentication, we'll use the OAuth token and secret provided in
+container. For authentication, we&#39;ll use the OAuth token and secret provided in
a URL parameter that came along with the request for our index.html, just like
in the HOWTO.</p>
@@ -155,11 +154,10 @@
<span class="n">SMART_SERVER_PARAMS</span><span class="p">,</span>
<span class="n">SMART_SERVER_OAUTH</span><span class="p">,</span>
<span class="n">resource_tokens</span><span class="p">)</span>
-</code></pre>
-</div>
+</code></pre></div>
-<p>If you're building your application from scratch without using the sample code,
-you'll want to define SMART_SERVER_OAUTH and SMART_SERVER_PARAMS:</p>
+<p>If you&#39;re building your application from scratch without using the sample code,
+you&#39;ll want to define SMART<em>SERVER</em>OAUTH and SMART<em>SERVER</em>PARAMS:</p>
<div class="highlight"><pre><code class="python"> <span class="c"># Basic configuration: the consumer key and secret we&#39;ll use</span>
<span class="c"># to OAuth-sign requests.</span>
@@ -171,23 +169,22 @@
<span class="n">SMART_SERVER_PARAMS</span> <span class="o">=</span> <span class="p">{</span>
<span class="s">&#39;api_base&#39;</span> <span class="p">:</span> <span class="s">&#39;http://sandbox-api.smartplatforms.org&#39;</span>
<span class="p">}</span>
-</code></pre>
-</div>
+</code></pre></div>
<h2>Generating Reminders</h2>
-<p>Now that we've got access tokens, and initialized a client object, let's
+<p>Now that we&#39;ve got access tokens, and initialized a client object, let&#39;s
interact with some health data! <em>RxReminder</em> needs to get a list of medications
-due for refills. We'll accomplish this by finding the most recent fulfillment
-event for each medication. Then we'll look at how many days' supply of
+due for refills. We&#39;ll accomplish this by finding the most recent fulfillment
+event for each medication. Then we&#39;ll look at how many days&#39; supply of
medication were dispensed to find out on what day the patient will run out.</p>
<p>We use our SmartClient object called client to fetch a SMART Response object
including a list of medications, via <code>get_medications() (or, in more
verbose form, client.get(&quot;/records/%s/medications/{record_id}&quot;)</code> SMART API call.</p>
-<p>Then we'll get fancy with RDF, running a SPARQL query to find a list of fills
-for each medication in meds.graph. Finally, we'll loop through the fills to find
+<p>Then we&#39;ll get fancy with RDF, running a SPARQL query to find a list of fills
+for each medication in meds.graph. Finally, we&#39;ll loop through the fills to find
the most recent one, using the dispensed quantity to determine when the patient
will run out of medication.</p>
@@ -220,10 +217,9 @@
<span class="c">#Print a formatted list</span>
<span class="k">return</span> <span class="n">header</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">format_last_dates</span><span class="p">()</span> <span class="o">+</span> <span class="n">footer</span>
-</code></pre>
-</div>
+</code></pre></div>
-<p>The details of finding the most recent prescription are in the update_pill_dates
+<p>The details of finding the most recent prescription are in the update<em>pill</em>dates
function. Please <a href="http://github.com/chb/smart_rx_reminder">check out the source on github</a>
to see the whole picture!</p>
View
39 _site/howto/smart_data/index.html
@@ -106,12 +106,12 @@
<h2>Treat SMART data payloads as RDF</h2>
<p>SMART Containers supply your app with medical record data in the form of an RDF
-graph, with the structured specified in our data model. It's important to keep
+graph, with the structured specified in our data model. It&#39;s important to keep
in mind that this graph is a logical structure containing medical record data.
-Yes, it's serialized as RDF/XML --- but the appropriate way to work with this
+Yes, it&#39;s serialized as RDF/XML --- but the appropriate way to work with this
graph is by using purpose-built RDF processing tools, not generic XML processing
-tools. The important concept here is you can't count on details like element
-order, blank node IDs, or even XML structure to be consistent. So you shouldn't
+tools. The important concept here is you can&#39;t count on details like element
+order, blank node IDs, or even XML structure to be consistent. So you shouldn&#39;t
try to use xpath or DOM manipulation to pull data out of this graph.</p>
<p>But you can count on the logical structure: the RDF triples asserted in the
@@ -136,12 +136,11 @@
<span class="o">?</span><span class="nx">labName</span> <span class="nx">dcterms</span><span class="o">:</span><span class="nx">title</span> <span class="o">?</span><span class="nx">labTitle</span> <span class="p">.</span>
<span class="o">?</span><span class="nx">labName</span> <span class="nx">sp</span><span class="o">:</span><span class="nx">code</span> <span class="o">?</span><span class="nx">loincCode00</span><span class="p">.</span>
<span class="p">}</span>
-</code></pre>
-</div>
+</code></pre></div>
<h2>Build flexible queries to focus on the data you need</h2>
-<p>The query above works pretty well, but it doesn't do much. Let's build on it!
+<p>The query above works pretty well, but it doesn&#39;t do much. Let&#39;s build on it!
For example, say we want to pull out the &quot;abnormal interpretation&quot; flag for a
lab result. We could augment our query as follows</p>
@@ -153,11 +152,10 @@
<span class="o">?</span><span class="nx">labName</span> <span class="nx">sp</span><span class="o">:</span><span class="nx">code</span> <span class="o">?</span><span class="nx">loincCode00</span><span class="p">.</span>
<span class="o">?</span><span class="nx">lab</span> <span class="nx">sp</span><span class="o">:</span><span class="nx">abnormalInterpretation</span> <span class="o">?</span><span class="nx">abnormalInterpretation</span><span class="p">.</span>
<span class="p">}</span>
-</code></pre>
-</div>
+</code></pre></div>
<p>But now something funny happens: if some lab results are missing the &quot;abnormal
-interpretation&quot; flag, this SPARQL query won't find them! That's because we've
+interpretation&quot; flag, this SPARQL query won&#39;t find them! That&#39;s because we&#39;ve
build a rigid query that requires each field to be present. If we want to query
in a more flexible way, we can use the OPTIONAL keyword</p>
@@ -169,30 +167,29 @@
<span class="o">?</span><span class="nx">labName</span> <span class="nx">sp</span><span class="o">:</span><span class="nx">code</span> <span class="o">?</span><span class="nx">loincCode00</span><span class="p">.</span>
<span class="nx">OPTIONAL</span> <span class="p">{</span> <span class="o">?</span><span class="nx">lab</span> <span class="nx">sp</span><span class="o">:</span><span class="nx">abnormalInterpretation</span> <span class="o">?</span><span class="nx">abnormalInterpretation</span><span class="p">.}</span>
<span class="p">}</span>
-</code></pre>
-</div>
+</code></pre></div>
-<p>Now if some labs have an &quot;abnormal interpretation&quot; flag, we'll find it. But we
-won't ignore labs that happen to be missing that field: we'll still get their
+<p>Now if some labs have an &quot;abnormal interpretation&quot; flag, we&#39;ll find it. But we
+won&#39;t ignore labs that happen to be missing that field: we&#39;ll still get their
LOINC codes and be able to keep track of them.</p>
-<p>Because not every SMART data element will provide a value for every field, it's
+<p>Because not every SMART data element will provide a value for every field, it&#39;s
important to keep your queries flexible with OPTIONAL blocks, focusing on the
-data you need and layering on additional data that might be useful, but isn't
+data you need and layering on additional data that might be useful, but isn&#39;t
essential.</p>
<h2>Parse date fields as <a href="http://www.w3.org/TR/NOTE-datetime">W3C datetime / ISO-8601 strings</a></h2>
-<p>Let's say you're building a timeline application that displays the dates of
+<p>Let&#39;s say you&#39;re building a timeline application that displays the dates of
medication fulfillments. You make a SMART API call to get a list of
-fulfillments, you write a SPARQL query to pull out the dates, and now you're
-ready to plot them. It's important to treat dates as <a href="http://www.w3.org/TR/NOTE-datetime">W3C datetime / ISO-8601</a> strings without making further
+fulfillments, you write a SPARQL query to pull out the dates, and now you&#39;re
+ready to plot them. It&#39;s important to treat dates as <a href="http://www.w3.org/TR/NOTE-datetime">W3C datetime / ISO-8601</a> strings without making further
assumptions about their format. For example, depending on the granularity of
data available, one fulfillment might have the date &quot;2011-06-12&quot;, while another
might have the date &quot;2011-06-12T18:30Z&quot;. If you try to parse SMART date fields
-with a simple regular expression or by substring-matching, you'll have trouble
+with a simple regular expression or by substring-matching, you&#39;ll have trouble
maintaining the flexibility you need. Instead, you should use a library that
-handles ISO8601 dates. For javascript we'd recommend reading <a href="http://delete.me.uk/2005/03/iso8601.html">this for background</a>. And we'd recommend trying
+handles ISO8601 dates. For javascript we&#39;d recommend reading <a href="http://delete.me.uk/2005/03/iso8601.html">this for background</a>. And we&#39;d recommend trying
the <a href="http://arshaw.com/xdate/">xdate.js</a> library for a powerful set of
cross-platform date-parsing and arithmetic tools. Most other languages have
standard libraries for parsing ISO8601 dates.</p>
View
42 _site/howto/sparql_examples/index.html
@@ -104,17 +104,17 @@
</div>
<p>This page provides a set of example queries to help you get started
-interacting with SMART patient record data. We'll build out several
+interacting with SMART patient record data. We&#39;ll build out several
example SPARQL queries, but please feel free to add on new material as
you discover useful tidbits!</p>
<h2>Running Queries: Live In-browser or in Your Own Environment</h2>
<p>You can use the form below to try out queries right away. Please note
-that to use the live query tool, you'll need to include a <code>FROM &lt;graph&gt;</code>
-clause in your query to supply data. If you're running these queries in
-your own environment, you'll run them in the context of a particular
-graph (e.g. Patient Smith's medication graph), rather than specifying
+that to use the live query tool, you&#39;ll need to include a <code>FROM &lt;graph&gt;</code>
+clause in your query to supply data. If you&#39;re running these queries in
+your own environment, you&#39;ll run them in the context of a particular
+graph (e.g. Patient Smith&#39;s medication graph), rather than specifying
<code>FROM</code> directly in the query.</p>
<p>Or you could run these examples on your own via:</p>
@@ -124,7 +124,7 @@
<li>Python, Perl, PHP, or Ruby using <a href="http://librdf.org">librdf</a></li>
<li>Java using <a href="http://jena.sourceforge.net">Jena</a>,
<a href="http://www.openrdf.org">Sesame</a>, or <a href="http://www.mulgara.org">Mulgara</a></li>
-<li>Javascript - when possible, we'll also provide examples that will work with the
+<li>Javascript - when possible, we&#39;ll also provide examples that will work with the
<a href="http://code.google.com/p/rdfquery/">rdfquery</a> javascript library which is
automatically provided by the <a href="/libraries/javascript/">smart-api-client.js</a>.</li>
</ul>
@@ -133,8 +133,8 @@
<h2>Examining a Medication List</h2>
-<p>Let's work with some medication data, the kind returned by a SMART API call to
-<code>GET /records/{record_id}/medications/</code>. To start off, let's write a query to find
+<p>Let&#39;s work with some medication data, the kind returned by a SMART API call to
+<code>GET /records/{record_id}/medications/</code>. To start off, let&#39;s write a query to find
the name of each medication in the list:</p>
<h3>Find Medication Names</h3>
@@ -156,8 +156,7 @@
<span class="p">.</span><span class="nx">where</span><span class="p">(</span><span class="s2">&quot;?med sp:drugName ?medc&quot;</span><span class="p">)</span>
<span class="p">.</span><span class="nx">where</span><span class="p">(</span><span class="s2">&quot;?medc dcterms:title ?t&quot;</span><span class="p">);</span>
<span class="p">});</span>
-</code></pre>
-</div>
+</code></pre></div>
<h3>Find Medication Quantities + Frequencies</h3>
@@ -181,8 +180,7 @@
<span class="p">.</span><span class="nx">where</span><span class="p">(</span><span class="s2">&quot;?medc dcterms:title ?t&quot;</span><span class="p">)</span>
<span class="p">.</span><span class="nx">where</span><span class="p">(</span><span class="s2">&quot;?fill dcterms:date ?fill_date&quot;</span><span class="p">);</span>
<span class="p">});</span>
-</code></pre>
-</div>
+</code></pre></div>
<h3>Find Medications Fulfilled Since January 2009</h3>
@@ -204,15 +202,14 @@
<span class="k">return</span> <span class="nb">Date</span><span class="p">.</span><span class="nx">parse</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">fill_date</span><span class="p">.</span><span class="nx">value</span><span class="p">)</span> <span class="o">&gt;</span> <span class="nb">Date</span><span class="p">.</span><span class="nx">parse</span><span class="p">(</span><span class="s2">&quot;2009-01-01T00:00:00Z&quot;</span><span class="p">);</span>
<span class="p">});</span>
<span class="p">});</span>
-</code></pre>
-</div>
+</code></pre></div>
<h2>Getting some Demographics</h2>
-<p>Here's a query that pulls out the first and last name from a patient's
+<p>Here&#39;s a query that pulls out the first and last name from a patient&#39;s
demographics</p>
-<h3>Find Patient's Name</h3>
+<h3>Find Patient&#39;s Name</h3>
<p><textarea id='q_demographics'></textarea>
<button onclick='javascript:run_query($("#q_demographics"), "demographics");'>
@@ -228,14 +225,13 @@
<span class="p">.</span><span class="nx">where</span><span class="p">(</span><span class="s2">&quot;?name v:given-name ?fn&quot;</span><span class="p">)</span>
<span class="p">.</span><span class="nx">where</span><span class="p">(</span><span class="s2">&quot;?name v:family-name ?ln&quot;</span><span class="p">);</span>
<span class="p">});</span>
-</code></pre>
-</div>
+</code></pre></div>
<h2>Getting some Problems</h2>
-<p>Here's a query that pulls out the name of each problem</p>
+<p>Here&#39;s a query that pulls out the name of each problem</p>
-<h3>Find Patient's Problems</h3>
+<h3>Find Patient&#39;s Problems</h3>
<p><textarea id='q_problems'></textarea>
<button onclick='javascript:run_query($("#q_problems"), "problems");'>
@@ -250,8 +246,7 @@
<span class="p">.</span><span class="nx">where</span><span class="p">(</span><span class="s2">&quot;?pr sp:problemName ?pn&quot;</span><span class="p">)</span>
<span class="p">.</span><span class="nx">where</span><span class="p">(</span><span class="s2">&quot;?pn dcterms:title ?p&quot;</span><span class="p">);</span>
<span class="p">});</span>
-</code></pre>
-</div>
+</code></pre></div>
<h3>Finding Quantitative Labs</h3>
@@ -261,7 +256,9 @@
</button></p>
<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script>
+
<script src='examples.js'></script>
+
<script>
$.each(examples, function(i,e){
var tb = $("#"+e.id);
@@ -271,6 +268,7 @@
</script>
<script src='rdf_store.js'></script>
+
<script>
run_query = function(qta, store) {
var q = qta.val();
View
28 _site/index.html
@@ -119,11 +119,11 @@
by patients, or a data-analytics platform such as <a href="https://www.i2b2.org">i2b2</a>
used by researchers.</p>
-<p>For example, a SMART app might analyze a person's risk of heart disease based
+<p>For example, a SMART app might analyze a person&#39;s risk of heart disease based
on recent labs and demographic information. This app can then be deployed on
-Regenstrief's CareWeb EHR, Children Hospital Boston's Indivo PCHR, or Harvard
-Medical School's i2b2 analytics engine. As other EMR vendors adopt the SMART
-platform, the app's reach increases <em>without changing a single line of code</em>.</p>
+Regenstrief&#39;s CareWeb EHR, Children Hospital Boston&#39;s Indivo PCHR, or Harvard
+Medical School&#39;s i2b2 analytics engine. As other EMR vendors adopt the SMART
+platform, the app&#39;s reach increases <em>without changing a single line of code</em>.</p>
<p><a href="/images/smart_emr_screenshot.png"
target="_blank">
@@ -146,16 +146,16 @@
</a></p>
<p>A SMART app is a normal web application, embedded as a frame within the SMART
-Container's user interface, with access to the SMART API for interacting with
+Container&#39;s user interface, with access to the SMART API for interacting with
health data. A patient, Penny, may use a medication browser app within her
PCHR. Meanwhile, a primary care doctor Dave may use the same app within his
clinic-based EMR to view the medications of a patient scheduled for an
-appointment next week. Penny's PCHR and Dave's EMR are both SMART containers;
+appointment next week. Penny&#39;s PCHR and Dave&#39;s EMR are both SMART containers;
they both expose the SMART API; and they can both display the medication
browser app. Though they may function very differently behind the scenes, they
can both embed the exact same medication-list-manager app because they present
-the same API. Importantly, in any given user session (Penny's or Dave's), the
-medication-list-manager is connected to only ''one'' SMART container.</p>
+the same API. Importantly, in any given user session (Penny&#39;s or Dave&#39;s), the
+medication-list-manager is connected to only &#39;&#39;one&#39;&#39; SMART container.</p>
<p>The screenshots to the right demonstrate the same medication list application
running in the context of two different SMART containers: a simplified EMR, and
@@ -186,9 +186,9 @@
<p>Writing a purely browser-based app in HTML5 and JavaScript is as easy as
including the client-side JavaScript libraries and making API calls! Keep in
mind that SMART Connect calls can only access data while the end-user remains
-online, since authentication depends on that user's existing session with the
-SMART container. If your app needs to access data from your web application's
-backend or while the user is offline, you'll need to make some REST calls as
+online, since authentication depends on that user&#39;s existing session with the
+SMART container. If your app needs to access data from your web application&#39;s
+backend or while the user is offline, you&#39;ll need to make some REST calls as
well.</p>
<h2>SMART REST</h2>
@@ -221,11 +221,11 @@
<p>To simplify the job of working with SMART REST, we provide client libraries in
<a href="https://github.com/chb/smart_client_java">Java</a> and
-<a href="https://github.com/chb/smart_client_python python">Python</a>.</p>
+<a href="https://github.com/chb/smart_client_python%20python">Python</a>.</p>
-<h2>OK, I'm ready to code</h2>
+<h2>OK, I&#39;m ready to code</h2>
-<p>You'll want to follow our HOWTOs in order:</p>
+<p>You&#39;ll want to follow our HOWTOs in order:</p>
<ol>
<li><a href="howto/build_a_smart_app">HOWTO Build a SMART App</a>, which focused on SMART
View
193 _site/install/linux/index.html
@@ -109,7 +109,7 @@
<h1>Repositories</h1>
-<p>These instructions apply to each of three github repositories that you'll need
+<p>These instructions apply to each of three github repositories that you&#39;ll need
in order to run the SMART Reference EMR in your own environment:</p>
<ul>
@@ -125,43 +125,37 @@
<li>Recent Linux installation (Kernel 2.6+).We recommend an up-to-date version of
Ubuntu, and these instructions are written from that perspective.</li>
<li>Note: These instructions have been updated for Ubuntu 12.04</li>
-<li><p>Note: We recommend you do this by sudo'ing from a non-root user. If you
+<li><p>Note: We recommend you do this by sudo&#39;ing from a non-root user. If you
would like to do this as root make sure you create at least one non-root user
with <code>useradd -m {USER}</code> otherwise the default locale will not be set. This
issue is most common on a new OS build.</p></li>
<li><p>Update the apt-get manifests:</p>
-
-<pre><code>$ sudo apt-get update
-</code></pre></li>
+<div class="highlight"><pre><code class="text">$ sudo apt-get update
+</code></pre></div></li>
<li><p>Python 2.7 with package <code>psycopg2</code></p>
-
-<pre><code>$ sudo apt-get install python-psycopg2 python-m2crypto \
+<div class="highlight"><pre><code class="text">$ sudo apt-get install python-psycopg2 python-m2crypto \
python-simplejson python-argparse python-setuptools python-pyparsing
$ sudo easy_install -U &quot;rdflib==3.2.3&quot; &quot;rdfextras==0.2&quot;
-</code></pre></li>
+</code></pre></div></li>
<li><p>Django 1.3+</p>
-
-<pre><code>$ sudo apt-get install python-django
-</code></pre></li>
+<div class="highlight"><pre><code class="text">$ sudo apt-get install python-django
+</code></pre></div></li>
<li><p>PostgreSQL 8.3+</p>
-
-<pre><code>$ sudo apt-get install postgresql
-</code></pre></li>
+<div class="highlight"><pre><code class="text">$ sudo apt-get install postgresql
+</code></pre></div></li>
<li><p>git</p>
-
-<pre><code>$ sudo apt-get install git
-</code></pre></li>
+<div class="highlight"><pre><code class="text">$ sudo apt-get install git
+</code></pre></div></li>
</ul>
<h1>Setup Database</h1>
<ul>
<li><p>Create a PostgreSQL user for your SMART service, e.g. <code>smart</code> and
-setup a password. You'll have the easiest time if you name your
+setup a password. You&#39;ll have the easiest time if you name your
database <code>smart</code> as well.</p>
-
-<pre><code>$ sudo su - postgres
+<div class="highlight"><pre><code class="text">$ sudo su - postgres
$ pg_dropcluster --stop 9.1 main
$ pg_createcluster --start -e UTF-8 9.1 main
$ createuser --superuser smart
@@ -169,71 +163,62 @@
$ postgres=# \password smart
$ postgres=# \q
$ exit
-</code></pre></li>
+</code></pre></div></li>
<li><p>There are two ways to authenticate to PostgreSQL: use your Unix credentials,
or use a separate username and password. We strongly recommend the latter,
and our instructions are tailored appropriately. If you know how to use
PostgreSQL and want to use Unix-logins, go for it, just remember that when
you use Apache, it will usually try to log in using its username, <code>www-data</code>.</p></li>
<li><p>in <code>/etc/postgresql/9.1/main/pg_hba.conf</code>, find the line that reads:</p>
-
-<pre><code>local all all XXX
-</code></pre></li>
+<div class="highlight"><pre><code class="text">local all all XXX
+</code></pre></div></li>
</ul>
<p>This should be the second uncommented line in your default config. Note XXX
in this line could be <code>ident</code>, <code>peer</code>, or another name. Change XXX to <code>md5</code>:</p>
-
-<pre><code> local all all md5
-</code></pre>
-
+<div class="highlight"><pre><code class="text"> local all all md5
+</code></pre></div>
<ul>
<li><p>You will need to restart PostgreSQL:</p>
-
-<pre><code>$ sudo service postgresql restart
-</code></pre></li>
+<div class="highlight"><pre><code class="text">$ sudo service postgresql restart
+</code></pre></div></li>
</ul>
<h1>Install <code>openrdf-sesame</code> (and Tomcat)</h1>
<ul>
<li><p>get Tomcat and OpenRDF-Sesame:</p>
-
-<pre><code>$ sudo apt-get install tomcat7
+<div class="highlight"><pre><code class="text">$ sudo apt-get install tomcat7
$ wget http://downloads.sourceforge.net/project/sesame/Sesame%202/2.6.9/openrdf-sesame-2.6.9-sdk.tar.gz
-</code></pre></li>
+</code></pre></div></li>
<li><p>install OpenRDF Sesame as a Tomcat web application</p>
-
-<pre><code>$ tar -xzvf openrdf-sesame-2.6.9-sdk.tar.gz
+<div class="highlight"><pre><code class="text">$ tar -xzvf openrdf-sesame-2.6.9-sdk.tar.gz
$ sudo mkdir /usr/share/tomcat7/.aduna
$ sudo chown tomcat7.tomcat7 /usr/share/tomcat7/.aduna/
$ sudo cp -r openrdf-sesame-2.6.9/war/* /var/lib/tomcat7/webapps/
-</code></pre></li>
+</code></pre></div></li>
<li><p>restart Tomcat (optional since autoDeploy is typically enabled in Tomcat by default)</p>
-
-<pre><code>$ sudo service tomcat7 restart
-</code></pre></li>
+<div class="highlight"><pre><code class="text">$ sudo service tomcat7 restart
+</code></pre></div></li>
<li><p>check that Tomcat and OpenRDF Sesame are running by hitting
<a href="http://localhost:8080/openrdf-workbench/">http://localhost:8080/openrdf-workbench/</a>. You should see the main OpenRDF
status page.</p></li>
</ul>
-<p>The OpenRDF store doesn't support access control. You will probably want to
+<p>The OpenRDF store doesn&#39;t support access control. You will probably want to
limit access to just <code>localhost</code>. To limit servlet access to <code>localhost</code>, make two
tomcat configuration changes:</p>
<ul>
<li><p>in <code>/var/lib/tomcat7/conf/context.xml</code> add within the <code>&lt;Context&gt;</code> element:</p>
-
-<pre><code>&lt;Valve className=&quot;org.apache.catalina.valves.RemoteHostValve&quot; allow=&quot;localhost&quot;/&gt;
-</code></pre></li>
+<div class="highlight"><pre><code class="text">&lt;Valve className=&quot;org.apache.catalina.valves.RemoteHostValve&quot; allow=&quot;localhost&quot;/&gt;
+</code></pre></div></li>
<li><p>and in <code>/var/lib/tomcat7/conf/server.xml</code> next to the other <code>&lt;Connector&gt;</code> elements:</p>
-
-<pre><code>&lt;Connector port=&quot;8080&quot; protocol=&quot;HTTP/1.1&quot; enableLookups=&quot;true&quot;&gt;
-</code></pre></li>
+<div class="highlight"><pre><code class="text">&lt;Connector port=&quot;8080&quot; protocol=&quot;HTTP/1.1&quot; enableLookups=&quot;true&quot;&gt;
+</code></pre></div></li>
</ul>
-<p>You'll need to restart Tomcat again if you make these changes</p>
+<p>You&#39;ll need to restart Tomcat again if you make these changes</p>
<h1>Automated approach: Download, Install, and Configure SMART Server Components</h1>
@@ -242,36 +227,28 @@
or skip this step and follow the manual setup steps. If you complete the
installation via the automated script, there are no further steps that you need
to do after running the script (your SMART server will be fully functional).</p>
-
-<pre><code>$ wget https://raw.github.com/chb/smart_server/master/load_tools/smart_manager.py
+<div class="highlight"><pre><code class="text">$ wget https://raw.github.com/chb/smart_server/master/load_tools/smart_manager.py
$ python smart_manager.py -a
-</code></pre>
-
-<p>(Note: if you'd like to run the bleeding-edge SMART development branch, replace <code>master</code> with <code>dev</code> in the <code>wget</code>
-command above and pass the <code>-d</code> flag to <code>smart_manager.py</code>. If you're unsure, you probably want to stick with the
+</code></pre></div>
+<p>(Note: if you&#39;d like to run the bleeding-edge SMART development branch, replace <code>master</code> with <code>dev</code> in the <code>wget</code>
+command above and pass the <code>-d</code> flag to <code>smart_manager.py</code>. If you&#39;re unsure, you probably want to stick with the
master branch!)</p>
<h2>Usage examples for smart_manager.py</h2>
<p>Kill and restart the development servers</p>
-
-<pre><code>$ python smart_manager.py -k -v -w
-</code></pre>
-
+<div class="highlight"><pre><code class="text">$ python smart_manager.py -k -v -w
+</code></pre></div>
<p>Reset the SMART server, regenerate sample data, and reload:</p>
-
-<pre><code>$ python smart_manager.py -r -p -l
-</code></pre>
-
+<div class="highlight"><pre><code class="text">$ python smart_manager.py -r -p -l
+</code></pre></div>
<h2>Loading additional apps</h2>
-
-<pre><code>$ cd smart_server
+<div class="highlight"><pre><code class="text">$ cd smart_server
# file path can be a URL or local file; OAuth secret can be any string
$ python manage.py load_app http://path/to/manifest.json smartapp-secret
-</code></pre>
-
-<h1>Manual steps: if you don't take the automated approach...</h1>
+</code></pre></div>
+<h1>Manual steps: if you don&#39;t take the automated approach...</h1>
<h2>1. Download, Install, and Configure SMART Backend Server</h2>
@@ -284,7 +261,7 @@
<ul>