Creates an instance of PrescriptionWidget.
The DOM element where the widget will be injected.
The options of the widget.
OptionalauthToken?: stringThe authentication token (JWT) for the widget.
OptionalbaseUrl?: stringThe base URL of the widget.
Optionaldebug?: booleanWhether to enable debug mode.
Optionalenv?: "preprod" | "production"The widget environment.
OptionalframeHeight?: numberThe height of the widget’s iframe (in pixels).
OptionalframeWidth?: numberThe width of the widget’s iframe (in pixels).
Optionallocale?: stringThe language for the user interface of the widget.
OptionalsigningKey?: stringThe base64-encoded signing key using the ES256 algorithm.
Please use the new authentication flow with authToken.
Check out the documentation for more information.
OptionalsoftwareId?: stringThe software identifier making the widget call.
Please use the new authentication flow with authToken.
Check out the documentation for more information.
Optionaltheme?: stringThe widget’s user interface theme.
OptionaluserId?: stringThe identifier of the user making the widget call.
Please use the new authentication flow with authToken.
Check out the documentation for more information.
Imports a list of elements to the current prescription.
The list of elements to be imported.
Optionaloptions: PrescriptionImportOptionsThe import options.
widget.importPrescriptionElements([
{
coding: {
code: "64620722",
terminology: "cis",
},
dosage: {
sequences: [
{
doseAndRate: [
{
doseQuantity: {
code: "428641000",
system: "snomed",
unit: "gélule(s)",
value: 3,
},
},
],
sequence: 0,
timing: {
repeat: {
boundsDuration: {
code: "d",
system: "http://hl7.org/fhir/ValueSet/duration-units",
unit: "day",
value: 4,
},
frequency: 1,
period: 1,
periodUnit: "d",
},
},
},
],
text: "3 gélules 4 fois par jour"
},
type: "branded_drug",
},
{
designation: "A free text item",
type: "free_text",
},
]);
Registers a callback to handle authentication token refresh requests.
This function is invoked when the widget detects that a new token is needed, for example when the current token is about to expire or has expired.
A function that returns a fresh authentication token.
Registers a callback that will be invoked when the prescription is ready.
This event is triggered by the widget once the prescription is available for viewing or interaction.
A function to be called when the prescription becomes ready.
Registers a callback that will be invoked when a prescription is saved.
This event is triggered when the user (or the widget) initiates a save action, and the prescription export data becomes available.
A function that receives the saved prescription payload.
Programmatically requests to save the current prescription and returns its payload.
This method will reject if the widget is not ready or if the operation times out (5s).
A promise that resolves with the prescription export payload.
// Example by processing the payload directly
try {
const payload = await widget.savePrescription();
console.log('Prescription saved:', payload);
} catch (err) {
console.error('Failed to save prescription:', err);
}
// Example using the `onPrescriptionSave` callback
widget.onPrescriptionSave((payload) => {
// This will trigger everytime the `savePrescription` method is called
console.log('Prescription saved:', payload);
});
try {
// Do not process the payload directly and let the `onPrescriptionSave` callback handle it
await widget.savePrescription();
} catch (err) {
console.error('Failed to save prescription:', err);
}
Sets the contextual data required by the widget.
This method must be called before the widget can complete its loading phase. Without it, the widget will remain in a loading state and will not be interactive.
The contextual data to apply to the widget.
Optionalcomment?: string | nullIf provided, the prescription comment will be set to the specified value.
Optionalelements?: (The list of elements to be imported to the ongoing prescription.
The unique patient identifier.
The patient’s profile data.
The unique identifier of the ongoing prescription session.
widget.setContext({
patientId: "ed8c3c7b-3313-470f-b706-84a3e127c7cf",
patientProfile: {
allergies: [
{
coding: {
code: "47703008",
terminology: "snomed",
},
},
],
birthDate: "1983-11-22",
concurrentTreatments: [
{
coding: {
code: "MV00001487",
terminology: "posos",
},
},
],
conditions: [
{
coding: {
code: "186963008",
terminology: "snomed",
},
isLongTermIllness: false,
modifiers: [],
},
],
gfr: 110,
height: 185,
sex: "male",
weight: 81,
},
sessionId: "189ea8f1-1030-4ba8-83a2-526cc6671b06",
});
Class representing a prescription widget.