Creating/updating a resource using SMART API

420 views
Skip to first unread message

Shamil Ng

unread,
Jan 18, 2017, 11:40:06 AM1/18/17
to SMART on FHIR
I'm trying to find any sample how to write a resource (assuming <resource>.write was requested in the patient scope during the SMART app registration with an EHR) using SMART API, rather than a direct AJAX call. Is that possible?

Nikolai Schwertner

unread,
Jan 18, 2017, 11:41:25 AM1/18/17
to smart-...@googlegroups.com


On 1/18/17 11:05, Shamil Ng wrote:
I'm trying to find any sample how to write a resource (assuming <resource>.write was requested in the patient scope during the SMART app registration with an EHR) using SMART API, rather than a direct AJAX call. Is that possible?
--
You received this message because you are subscribed to the Google Groups "SMART on FHIR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to smart-on-fhi...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Shamil Ng

unread,
Jan 18, 2017, 5:12:46 PM1/18/17
to SMART on FHIR
Thank you Nikolai, that's exactly what I was looking for.


PS. One more question not related to write() but I don't want to create a separate thread for that - is it possible to develop a desktop SMART app using Chromium (CEF) or HTA?

Pascal Pfiffner

unread,
Jan 19, 2017, 4:42:05 AM1/19/17
to SMART on FHIR
Hi Shamil,

SMART apps can be developed in virtually any environment, all you need to be able to is talk to a REST service after authenticating with OAuth2. What would be your use-case for a CEF-based app, as opposed to simply using your SMART app in a browser?

Besides the JS client we also have a Python and a Swift client, the latter for native iOS and macOS development. So while you can certainly wrap a JS-based SMART app in CEF, there's also other ways to provide SMART apps.

Pascal

Shamil Ng

unread,
Jan 19, 2017, 6:32:33 PM1/19/17
to SMART on FHIR
Is there any difference if create() or update() calls are performer from non-context or context aware scope, i.e., smart.api.create() vs. smart.patient.api.create()?
And if I'm doing multiple API calls what is the best practice - to retrieve the FHIR.client for each call, i.e. by calling FHIR.oauth2.ready(), or to store it globally after the first call and reuse?

Nikolai Schwertner

unread,
Jan 19, 2017, 7:20:40 PM1/19/17
to smart-...@googlegroups.com
You should use smart.api.create in apps that are granted `user/*.write` or similar scope and smart.patient.api.create for apps using `patient/*.write` or similar scope. FHIR.js is the library used by the SMART JS client (and exposed via the .api properties), so you may want to check out their page on GitHub to learn more about its capabilities.

I would recommend storing the client object globally and reusing it to avoid expensive token exchange and initialization with each call.

-Nikolai
Reply all
Reply to author
Forward
0 new messages