/
Use the fhir-client.js in a Multi-page Architecture
Use the fhir-client.js in a Multi-page Architecture
Introduction
This sample will show using a FHIR Client in a multi-state architecture.
Saving the FHIR Client's State
After the FHIR Client has completed the authorization flow (after redirect), save the state in the windows session.
Saving FHIR Client State
FHIR.oauth2.ready(function (fhirClient) { // save the fhirClient state for subsequent page calls window.sessionStorage.smartServiceUrl = fhirClient.server.serviceUrl; window.sessionStorage.smartPatientId = fhirClient.patient.id; window.sessionStorage.smartAuthToken = fhirClient.server.auth.token; window.sessionStorage.smartAuthType = fhirClient.server.auth.type; });
Instantiating a FHIR Client from Saved State
Subsequent web pages can instantiate an instance of the FHIR Client.
Instantiating FHIR Client from Saved State
var fhirClient = FHIR.client({ serviceUrl: window.sessionStorage.smartServiceUrl, patientId: window.sessionStorage.smartPatientId, auth: { token: window.sessionStorage.smartAuthToken, type: window.sessionStorage.smartAuthType } }); var patient = fhirClient.patient;
, multiple selections available,
Related content
How to Get the Current User
How to Get the Current User
More like this
How to Update a Patient Record
How to Update a Patient Record
More like this
Logica Reference Implementation
Logica Reference Implementation
Read with this
Authorization using OAuth2
Authorization using OAuth2
More like this
For Developers
For Developers
Read with this
Migrating from DSTU1 to DSTU2
Migrating from DSTU1 to DSTU2
More like this