Hello,
I am building a Javascript client to ultimately access data from our own private, future OAuth2 protected server.
First I'd like to share the experience of a brand new user, hoping this will be useful for you.
I am stuck at the end of this process:
1. I started with the
FHIR/fhir.js GitHub project, but could never understand how to set that up from the docs, in particular what that "adapter" was.
2. I decided to take inspiration from a working project, so I went to the cardiac-risk-app source code and discovered this
smart-on-fhir/client-js project - that uses the one above.
3. From the client-js docs, we are redirected to the "Clients/Javascript" docs page, that says we should use `FHIR.oauth2.ready()` with a callback, which is what the cardiac-risk-app uses, although it did nothing in my case (with a console.debug print in the callback). I it supposed to?
4. Fortunately, this same page links to the "Tutorial - Building a JavaScript App" docs page, which illustrates the use of `FHIR.client({ <config> })`, although it writes "In a typical workflow, you won’t instantiate this object yourself – it will be created by `FHIR.oauth2.launch()`". But
* There is no indication of how to write a full <config> for authentication;
* "FHIR.oauth2.launch() is not a function";
* `FHIR.oauth2.authorize({...})` says "str is undefined", because the real error (missing URL arguments) is not caught.
5. Using `FHIR.client({serviceUrl: '
https://fhir-open-api-dstu2.smarthealthit.org'})`, I could execute a request to this test server and read the response successfully.
So with that I read the "10 mL bid" medication for example patient 103888 or whatever from the test server.
At this point I am stuck. I don't know where to find docs to configure the client for my own FHIR server without deciphering the source code of client-js; I don't know what FHIR.method (.ready, .authorize, .launch, .client - are some of them calling the others?) I should use to start and how.
Am I even supposed to bother about Autorization, if the description for tutorial "Simple Authorization App" says "If you would rather start with writing SMART on FHIR apps as quickly as possible, you can use our client libraries which handle the authorization process for you."? At some point, I will have to choose which type of OAuth workflow I want to use, and enter some configuration for it.
Please give me a clue for the next step.