@photon-rx/core, the JavaScript client, so you don’t install that separately.
⚠️ Not published to npm yet.
PhotonProvider
Wrap the cards in one provider. It signs the prescriber in and gives every card inside it a client.
Providers can nest. A nested provider inherits what it doesn’t set, and providers with the same
clientId share one sign-in.
Signing in
On load, the provider signs in by itself when it can: it finishes a sign-in returning from Photon, or renews a stored session. It never redirects on its own. Otherwise, the first card on the page shows Sign in to Photon, and the prescriber clicks it. Inside an iframe, sign-in opens a popup. The cards don’t offer sign-out. Your app can sign out withusePhoton().session.signOut().
useSession() gives your own chrome the prescriber’s name, email and organization.
The session is stored in your page’s
localStorage, so treat any script injection on that page as a token leak. Moving it out of localStorage is on our roadmap.PhotonOrder
The patient, a card for each prescription, then Send. Send appears once the patient is found, every prescription is signed, and everything is saved.
Without prescriptions, the order starts with one empty line. Add another prescription starts from the same template as the first line.
PhotonPatient
Find or add a patient, then edit them. Each field the prescriber fills in is synced, and Photon decides whether that’s a match, a list of candidates, or a new patient.PhotonPrescription
One prescription: the drug, sig and dispense, screening, and Sign. A signed prescription is final.Events
Every event gets the live object.obj.id is the record’s id, and obj.state is the record itself, with the same fields as the API. Events fire when Photon has a record and when that record changes. They don’t fire while a save is in flight.