🚧
The eRx Service is currently in beta.
Prescribing
The eRx Service allows you to prescribe medications to your patients via Photon's embedded UI Elements (opens in a new tab).
Getting Started
To prescribe your first medication, you'll need to install the photon elements package from NPM:
npm install @photonhealth/elements
Wrap your application with the photon-client
:
import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App.jsx';
import("@photonhealth/elements").catch((e) => {console.error(e)});
import './index.css';
ReactDOM.createRoot(document.getElementById('root')).render(
<React.StrictMode>
<photon-client
id={"your-photon-client-id"}
org={"your-photon-org-id"}
auto-login="true"
redirect-uri="http://localhost:3000"
>
<App />
</photon-client>
</React.StrictMode>
);
Now it is time to add the prescribe element (opens in a new tab) to your application:
import { createRef, useState, useEffect } from 'react';
import './Page.css';
function Patient() {
const id = 'the_patient_id';
const photonPrescribeRef = createRef();
useEffect(() => {
const log = () => {
console.log("treatment prescribed!");
}
if (photonPrescribeRef.current) {
photonPrescribeRef.current.addEventListener("photon-prescribe-success", log);
const removal = () => photonPrescribeRef.current.removeEventListener("photon-prescribe-success", log);
return () => removal()
}
}, []);
return (
<div>
<h1>Prescribe</h1>
<photon-prescribe-workflow ref={photonPrescribeRef} enable-order={true} patient-id={id} />
</div>
);
}
export default Patient;