@plasmahealth/smart-on-fhir-rn
v0.1.1
Published
SMART-on-FHIR authentication library for React Native and Expo
Maintainers
Readme
fhir-ui-rn
Installation
npx expo install @plasmaheatlh/smart-on0fhir-rn expo-auth-session expo-secure-store expo-web-browserSetup
- Add a URL scheme to
app.json
The library redirects back to your app after the EHR login using a deep link. You must declare a scheme:
{
"expo": {
"scheme": "myapp"
}
}- Register the redirect URI with your EHR vendor
The redirect URI your app should use is:
myapp://sof-oauth- Wrap your app with
SmartAuthProvider
In your root layout (e.g. app/_layout.tsx):
import { SmartAuthProvider, SmartConfig } from '@plasmahealth/smart-on-fhir-rn';
const config: SmartCOnfig = {
fhirBsaeUrl: '',
clientId: 'your-client-id',
scopes: ['openid', 'fhirUser', 'profile', 'offline_access', 'launch/patient', 'patient/*.*'],
scheme: 'myapp',
}
export default function RootLayout() {
return (
<SmartAuthProvider config={config}>
{/* Rest of your app */}
</SmartAuthProvider>
)
}- Use the
useSmarthook
import { useSmart } from '@plasmahealth/smart-on-fhir-rn';
export default function MyScreen() {
const { isAuthenticated, isLoading, patientId, login, logout, fhirFetch } = useSmart();
const fetchPatient = async () => {
const rest = await fhirFetch(`/Patient/${patientId}`);
const patient = await res.json();
console.log(patient);
}
return (
<>
{/* Your Screen */}
</>
)
}Publish
- pnpm install
- pnpm build
- npm publish --access public
