GetHealthy.js
gethealthy js is a pre built client side library which leverages our public and private apis to to alleviate the produce of wring custom frontent logic for the recommendation process the only things required to get started are an api key generated by our integration team an instance code and store code same as are used / require for our rest api sercices embedding the app after receiving your integration api key follow these simple steps to use the recommendation tool inside your application adding the script in the head section of your html document add the following script component preparing a container at the appropriate place within your markup in the body section of the page, create an empty div container to use a target area for the recommendation client, e g note the ui client will consume the entire space, attempting to responsively adjust for smaller areas although it has not been optimized to support small screen devices and is not yet intended for use on mobile phones the minimum recommended device width is 1200px initializing the client to initialize the client component you will need to obtain 3 parameters from gethealthy access token instance identifer store code the rest will be handled transparently by the application example create and initialzie a new client instance using your token , instance and store identifiers \<script> document addeventlistener("domcontentloaded", () => { // create a new instance and initialize const ins = new ghembeddable({ token "{{your access token}}", instance "{{your instance identifier}}", store "{{your store code}}", }); // prepare specific feature currently only // recommendation buidler is supported ins create('recommendation builder'); // display the ui ins mount('recommendation client'); }); \</script> after completing the above steps the builder should be displaying on your page additional init parameters in addition to the required parameters token , instance and store you can initialize the instance with an existing recommendation for editing purposes, e g const ins = new ghembeddable({ token "{{your access token}}", instance "{{your instance identifier}}", store "{{your store code}}", recommendationid "{{saved recommendation id}}", disablepatientcreate true, disablepatientselect true, patientdata , }); optional parameters recommedationid when you have save a reference to a recommendation in your system, you can pass the recommendationid patientdata you can initialize a patient record for recommendation with data from your system to have a patient record created along with the recommendation the minimal structure from patient data consists of firstname , lastname and email optional patient data fields include phone main phone number in e 164 standard format https //www twilio com/docs/glossary/what e164 gender one of m , f , male , female dob birthdate formatted as yyyy mm dd persistent discount one of 0 , 5 , 10 , 15 , 20 patientdata { firstname "john", lastname "doe", email "john doe\@example com", } disablepatientselect true/false defaults to false if true, this will prevent the user from switching the patient to a different one in the ux disablepatientcreate true/false defaults to false if true, this will prevent the user from creating a new patient record via the ux theme object this is a json object to support certain paramaters for the adaption of our app into your theme enviroment currently the only supported parameter is zindex zindex this allows adjustment of the sheet dialogs layering the sheets always take the full screen height and elements of your page may interfere with the layering usually you'd increase the value to something higher pass a value that would correspond to the layering of your page stylesheet patient initialization when initializing a patient and subsequently saving the recommendation, the email address is the primary unique key if the email already exists, the recommendation will be associated with the patient record using this email address, else a new patient record will be created prior to saving the recommendation events to integrate the recommendation tool with your application, the tool provides continuous event output for a variety of user interactions you can add listeners for these events like this const callback = (value) => { console log("callback value ", value); }; ins on("{{event key}}", callback); each available event will provide a contextual event object returning true from any of the event handlers means that your application handled the event, i e if you want to send notifications using your own system and the client will not proceed with its default behavior emitted events recommendation save when the user clicks the save button the event detail will contain entire recommendation object, to be saved/referenced in your application recommendation getlink when the use clicks the get link button the event detail will contain entire recommendation object, to be saved/referenced in your application recommendation send when the use clicks the send button the event detail will contain entire recommendation object, to be saved/referenced in your application recommendation add when an item is added to the recommendation object the event detail will contain information about the sku that was added recommendation delete when an item is deleted from the recommendation object the event detail will contain information about the sku that was deleted patient select when the user selected patient for the recommendation the event detail will contain relevant information about the patient, along with relation to doctors and locations patient create when the user creates a new patient for this recommendation the event detail will contain relevant information about the patient, along with relation to doctors and locations