The treatment plan feature embeds the Fullscript treatment plan onto your page. To use this feature, your app must tell Fullscript who is performing the task, and for which patient.
Since the current user is logged into your app, you know which practitioner or clinic staff member is performing the operation. Remember that session grant code you implemented earlier in your back end? Go ahead and use that method to get a session grant and related secret token for your user.
When the secret token belongs to a clinic staff member (someone who’s Fullscript user type is ‘Staff’) or to the user configured as the store owner, the treatment plan feature shows a practitioner picker. This way, they can select which practitioner the treatment plan is written on behalf of.
It’s OK if you don’t know which Fullscript patient the treatment plan is for. You can pass along information you know about the patient, and Fullscript searches for a match. The Treatment Plan feature will show your user a list of patient matches, and give them the option to create a Fullscript patient record one if no match is found or if the practitioner decides none is the correct match.
When it comes to specifying the patient, you can rely on searching as proposed above, then saving the resulting id for the next time, or you can use Fullscript RESTful APIs such as clinic/search/patients
to search behind the scenes to get the Fullscript patient id.
secretToken
REQUIRED
A single-use token that is used to authenticate the practitioner or clinic staff member using the treatment plan feature. Retrieved from the Fullscript RESTful API, see Codify user session grants.
patient
OBJECT
An object describing the patient. Specify the patient’s id for an exact match, or some of the other parameters to trigger a search. Leave empty to prompt the user to create a new patient.
Child attributes:
id
(string) Fullscript patient id.
If specifying the id, there’s no need to specify other attributes - they are ignored, even if they differ from what’s stored with Fullscript.firstName
(string) The patient’s first name.lastName
(string) The patient’s last name / family name.email
(string) The patient’s email address.dateOfBirth
(string) The patient’s birth date, in the format yyyy-mm-dd.biologicalSex
(string) The patient’s assigned sex.
Options are: male, female, or prefer not to say.mobileNumber
(string) Patient's mobile number in the format +12223334444.discount
(number) Patient discount level (in percentage). This discount does not include the clinic discount. Defaults to 0.Let’s look at a couple examples for initializing the treatment plan, and how the treatment plan feature behaves based on the detail level given for the patient.
var treatmentPlanFeature = fullscriptClient.create("treatmentPlan", {
secretToken: "xxxxx",
patient: {
id: "xxxxx",
},
});
If there’s a match on patient id, the patient selection screen is skipped and the treatment plan explicitly sets the patient to the one specified.
Unlike other ways to match the patient, this method doesn’t trigger the patient.selected
event.
If there’s no match on patient id, the patient selector is shown and the user can search for or create a new patient.
If there’s a match on a specified patient id, all other patient data is ignored. Even if your data differs from the data Fullscript has for this patient. The practitioner can update the patient’s details in the treatment plan feature.
var treatmentPlanFeature = fullscriptClient.create("treatmentPlan", {
secretToken: "xxxxx",
patient: {
firstName: “Amos”,
lastName: “Burton”
},
});
Fullscript tries to find a patient match based on the provided data. If one (or more) is found, suggestions are shown to the user. They can choose a suggested patient or create a new one. If the user creates a new Fullscript patient, the treatment plan feature auto-populates the new patient form with the data you used in your search.
For a seamless integration, be sure to send all applicable patient information. This avoids unnecessary manual entry and also stops the practitioner from looking it up elsewhere or asking the client for information they should already have.
When the patient is selected or created, you’ll receive a patient.selected
event with their Fullscript patient id.
var treatmentPlanFeature = fullscriptClient.create("treatmentPlan", {
secretToken: "xxxxx",
});
The user is prompted to create a new patient.
You’ll receive a patient.selected
event with the new Fullscript patient id.