React Hooks for fhirclient. Use fhirclient with an easy React Hook.
- Install it using NPM or Yarn
npm i react-fhirclient
or:
yarn add react-fhirclient
- 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 its documentation.
Supporting any FHIR client would be beneficial to the community. If you have a FHIR client that you want supported, raise an Issue describing it.