react-fhirclient
v0.1.1
Published
> React Hooks for fhirclient. Use fhirclient with an easy React Hook.
Downloads
140
Readme
React FHIR Client
React Hooks for fhirclient. Use fhirclient with an easy React Hook.
Getting started
- Add your
FhirClientProvider
to your ReactDOM tree.
ReactDOM.render(
<React.StrictMode>
<FhirClientProvider>
<App />
</FhirClientProvider>
</React.StrictMode>,
document.getElementById('root')
);
- Use
useFhirClient()
in your hooks.
import { useState, useEffect } from 'react';
import { useFhirClient } from 'react-fhirclient';
function App() {
const [patient, setPatient] = useState();
const fhirclient = useFhirClient();
useEffect(() => {
const getPatient = async () => {
if (fhirclient) {
const patient = await fhirclient.request(`Patient/${fhirclient.patient.id}`);
setPatient(patient);
}
};
getPatient();
}, []);
return (
<div className="App">
<pre>
<code>{JSON.stringify(patient, null, 2)}</code>
</pre>
</div>
);
}
export default App;
- Learn
fhirclient
.
This project uses fhirclient under the hood. Check out it's documentation.