Who is our client and what problem did they want to solve?
The RHM team had the opportunity to work with a customer in the medical field. Our client needed us to develop an online patient intake process. Our mission was to digitize what was previously an in-person, manual process.
What solution did we provide?
Our client wanted the new digital process to allow the patient to take an online questionnaire. Based on the answers they provided they could be registered as a new patient and then contacted by staff. Alternatively, they could also be informed if the company did not provide care at the level they needed, or if they needed more information about the patient and would be in contact.
After a successfully filled out and submitted form, the patient's answers and information were saved to a Wix Content Manager database. The information was then transformed into a PDF and attached to an email. The email was sent to the email address the company uses to gather patient intake data.
How did we do it?
To do this, we used two different integrations. One was with SendGrid, a service that allows you to send custom emails. And PDF Generator API, a service that allows you to design a PDF template in a WYSIWYG editor and then send the service data and it will generate a PDF based on the template you designed and send you the data back in a format you can attach to a SendGrid email.
Prior to finding PDF Generator API, we were unable to create integrations where we send customized emails with custom PDFs, but now, it's just one of the many services we can offer.
Check out the code we used below:
import { insertNewPatientIntake } from "backend/NewPatientIntake";
import { generatePDFAndSendEmail } from "backend/EmailAndPDF";
import wixWindow from "wix-window";
import wixLocation from "wix-location";
$w.onReady(function () {
const formFactor = wixWindow.formFactor;
const statebox = $w("#statebox");
const continueButton = $w("#continueButton");
const startUploadButton = $w("#startUpload");
const backButton = $w("#backButton");
let stateNumber = 1;
const redFlags = {
six: false,
nine: false,
eleven: false,
thirteen: false,
};
const orangeFlags = {
six: false,
twelve: false,
thirteen: false,
};
let paymentType = "";
const patientIntake = {
firstName: "N/A",
lastName: "N/A",
preferredName: "N/A",
pronouns: "N/A",
email: "N/A",
phoneNumber: "N/A",
gender: "N/A",
dob: "N/A",
addressLine1: "N/A",
addressLine2: "N/A",
city: "N/A",
state: "N/A",
zipCode: "N/A",
currentPsychiatricCare: "N/A",
patientSeekingServices: "N/A",
patientMainConcern: "N/A",
patientDiagnoses: "N/A",
patientSuicidalThought: "N/A",
patientSuicidalPlan: "N/A",
insurer: "N/A",
selfPay: "false",
exitQuestionnaire: false,
patientSixteenYearsOrYounger: "N/A",
isPatientTakingPrescriptions: "N/A",
patientPrescriptions: "N/A",
patientRedflagMedications: "N/A",
weeklyAlcoholicBeverages: "N/A",
nonPrescribedDrugsUsed: "N/A",
otherNonPrescribedDrugsUsed: "N/A",
wasPatientRequiredToStayOvernightAtHospitalDueToMentalHealth: "N/A",
patientOvernightHospitalStayExplanation: "N/A",
possibleRedFlagBehaviors: "N/A",
patientProviderPreference: "N/A",
insuranceFullName: "N/A",
insuranceDob: "N/A",
insurancePolicyId: "N/A",
relationToPatient: "N/A",
insuranceCardImageFront: null,
insuranceCardImageBack: null,
};
// state 3 input
const currentPsychiatricCareInput = $w("#state3Input");
currentPsychiatricCareInput.onChange((e) => {
patientIntake.currentPsychiatricCare = e.target.value;
});
// state 4 input
const patientSeekingServicesInput = $w("#state4Input");
const patientSeekingServicesTextbox = $w("#state4TextBox");
patientSeekingServicesInput.onChange((e) => {
patientIntake.patientSeekingServices = e.target.value;
});
patientSeekingServicesTextbox.onChange((e) => {
patientIntake.patientSeekingServices.push(e.target.value);
});
// state 5 input
const patientMainConcernTextbox = $w("#state5TextBox");
patientMainConcernTextbox.onChange((e) => {
patientIntake.patientMainConcern = e.target.value;
});
const patientDiagnosesInput = $w("#state5Input");
patientDiagnosesInput.onChange((e) => {
patientIntake.patientDiagnoses = e.target.value;
});
// state 6 input
const patientSuicidalThoughtInput = $w("#state6Input");
patientSuicidalThoughtInput.onChange((e) => {
patientIntake.patientSuicidalThought = e.target.value;
});
const patientSuicidalPlanInput = $w("#state6AdditionalInput");
patientSuicidalPlanInput.onChange((e) => {
patientIntake.patientSuicidalPlan = e.target.value;
});
// state 7 input
const insurerInput = $w("#insurerDropdown");
insurerInput.onChange((e) => {
patientIntake.insurer = e.target.value;
});
const selfPayCheckbox = $w("#selfPayCheckbox");
selfPayCheckbox.onChange((e) => {
patientIntake.insurer = "N/A";
patientIntake.selfPay = "true";
});
const exitQuestionnaireCheckbox = $w("#exitQuestionnaireCheckbox");
exitQuestionnaireCheckbox.onChange((e) => {
patientIntake.exitQuestionnaire = true;
wixLocation.to(`${wixLocation.baseUrl}`);
});
// state 8 input
const patientSixteenYearsOrYoungerInput = $w("#state8Input");
patientSixteenYearsOrYoungerInput.onChange((e) => {
patientIntake.patientSixteenYearsOrYounger = e.target.value;
});
// state 9 input
const isPatientTakingPrescriptionsInput = $w("#state9RadioInput");
isPatientTakingPrescriptionsInput.onChange((e) => {
patientIntake.isPatientTakingPrescriptions = e.target.value;
});
const patientPrescriptionsTextbox = $w("#prescriptionList");
patientPrescriptionsTextbox.onChange((e) => {
patientIntake.patientPrescriptions = e.target.value;
});
const patientRedflagMedicationsInput = $w("#state9Input2");
patientRedflagMedicationsInput.onChange((e) => {
patientIntake.patientRedflagMedications = e.target.value;
});
// state 10 input
const weeklyAlcoholicBeveragesInput = $w("#state10Input");
weeklyAlcoholicBeveragesInput.onChange((e) => {
patientIntake.weeklyAlcoholicBeverages = e.target.value;
});
// state 11 input
const nonPrescribedDrugsUsedInput = $w("#state11Input");
nonPrescribedDrugsUsedInput.onChange((e) => {
patientIntake.nonPrescribedDrugsUsed = e.target.value;
});
const otherNonPrescribedDrugsUsed = $w("#state11TextBox");
otherNonPrescribedDrugsUsed.onChange((e) => {
patientIntake.otherNonPrescribedDrugsUsed = e.target.value;
});
// state 12 input
const wasPatientRequiredToStayOvernightAtHospitalDueToMentalHealthInput =
$w("#state12Input");
wasPatientRequiredToStayOvernightAtHospitalDueToMentalHealthInput.onChange(
(e) => {
patientIntake.wasPatientRequiredToStayOvernightAtHospitalDueToMentalHealth =
e.target.value;
}
);
const patientOvernightHospitalStayExplanation = $w("#state12TextBox");
patientOvernightHospitalStayExplanation.onChange((e) => {
patientIntake.patientOvernightHospitalStayExplanation = e.target.value;
});
// state 13 input
const possibleRedFlagBehaviorsInput = $w("#state13Input");
possibleRedFlagBehaviorsInput.onChange((e) => {
patientIntake.possibleRedFlagBehaviors = e.target.value;
});
// state 14 input
const patientProviderPreferenceInput = $w("#state14Input");
patientProviderPreferenceInput.onChange((e) => {
patientIntake.patientProviderPreference = e.target.value;
});
// state 15 inputs
const firstNameInput = $w("#firstName");
const lastNameInput = $w("#lastName");
const preferredNameInput = $w("#preferredName");
const pronounsInput = $w("#pronouns");
const emailInput = $w("#email");
const phoneNumberInput = $w("#phoneNumber");
const genderInput = $w("#gender");
const dobInput = $w("#dob");
// state 16 inputs
const addressLine1Input = $w("#addressLine1");
const addressLine2Input = $w("#addressLine2");
const cityInput = $w("#city");
const stateInput = $w("#state");
const zipCodeInput = $w("#zipCode");
const inputs = [
firstNameInput,
lastNameInput,
preferredNameInput,
pronounsInput,
emailInput,
phoneNumberInput,
genderInput,
dobInput,
addressLine1Input,
addressLine2Input,
cityInput,
stateInput,
zipCodeInput,
];
inputs.forEach((input) => {
input.onChange((e) => {
if (e.target.id === "dob") {
patientIntake[e.target.id] = e.target.value.toISOString().split("T")[0];
} else {
patientIntake[e.target.id] = e.target.value;
}
});
});
// state 17 inputs
const insuranceFullName = $w("#insuranceFullName");
const relationToPatient = $w("#relationToPatient");
const insuranceDob = $w("#insuranceDob");
const insurancePolicyId = $w("#insurancePolicyId");
const insuranceCardFrontUpload = $w("#insuranceCardFrontUpload");
const insuranceCardBackUpload = $w("#insuranceCardBackUpload");
const insuranceInputs = [
insuranceFullName,
relationToPatient,
insuranceDob,
insurancePolicyId,
];
insuranceInputs.forEach((input) => {
input.onChange((e) => {
if (e.target.id === "insuranceDob") {
patientIntake[e.target.id] = e.target.value.toISOString().split("T")[0];
} else {
patientIntake[e.target.id] = e.target.value;
}
});
});
$w("#state2Input").onChange((e) => {
if (e.target.checked) {
continueButton.enable();
} else {
continueButton.disable();
}
});
$w("#state3Input").onChange((e) => {
if (e.target.value !== "") {
continueButton.enable();
} else {
continueButton.disable();
}
});
$w("#state4Input").onChange((e) => {
if (e.target.value.includes("Not Sure")) {
patientSeekingServicesTextbox.show();
} else if (e.target.value !== "") {
continueButton.enable();
} else {
patientSeekingServicesTextbox.hide();
continueButton.disable();
}
});
$w("#state4TextBox").onChange((e) => {
continueButton.enable();
});
$w("#state5TextBox").onChange((e) => {
if (e.target.value !== "") {
continueButton.enable();
} else {
continueButton.disable();
}
});
$w("#state6Input").onChange((e) => {
if (e.target.value === "Yes") {
$w("#state6AdditionalInputQuestion").show();
$w("#state6AdditionalInput").show();
} else {
orangeFlags.six = false;
redFlags.six = false;
$w("#state6AdditionalInputQuestion").hide();
$w("#state6AdditionalInput").hide();
continueButton.enable();
}
});
$w("#state6AdditionalInput").onChange((e) => {
if (e.target.value === "Yes") {
redFlags.six = true;
} else {
orangeFlags.six = true;
}
continueButton.enable();
});
$w("#insurerDropdown").onChange((e) => {
if (e.target.value !== "") {
continueButton.enable();
paymentType = "in_network";
}
});
$w("#selfPayCheckbox").onChange((e) => {
if (e.target.checked) {
continueButton.enable();
paymentType = "self_pay";
} else {
paymentType = "";
continueButton.disable();
}
});
$w("#state8Input").onChange((e) => {
if (e.target.value !== "") {
continueButton.enable();
}
});
$w("#state9RadioInput").onChange((e) => {
if (e.target.value === "Yes") {
$w("#prescriptionList").show();
$w("#prescriptionList").expand();
} else {
$w("#prescriptionList").hide();
$w("#prescriptionList").collapse();
}
if (e.target.value !== "" && $w("#state9Input2").value.length > 0) {
continueButton.enable();
}
});
$w("#state9Input2").onChange((e) => {
if (e.target.value.length > 0 && $w("#state9RadioInput").value !== "") {
continueButton.enable();
if (
e.target.value.includes("Clozapine") ||
e.target.value.includes("Methadone")
) {
redFlags.nine = true;
} else {
redFlags.nine = false;
}
}
});
$w("#state10Input").onChange((e) => {
if (e.target.value !== "") {
continueButton.enable();
}
});
$w("#state11Input").onChange((e) => {
if (e.target.value.length > 0) {
continueButton.enable();
}
if (
e.target.value.includes("Heroin (Opioids)") ||
e.target.value.includes("Cocaine (stimulants)") ||
e.target.value.includes("Meth") ||
e.target.value.includes("Hallucinogens") ||
e.target.value.includes("Benzodiazepines")
) {
redFlags.eleven = true;
} else {
redFlags.eleven = false;
}
if (e.target.value.includes("Other")) {
$w("#state11TextBox").show();
} else {
$w("#state11TextBox").hide();
}
});
$w("#state12Input").onChange((e) => {
if (e.target.value !== "") {
continueButton.enable();
}
if (e.target.value === "Yes") {
$w("#state12TextBox").show();
orangeFlags.twelve = true;
} else {
orangeFlags.twelve = false;
$w("#state12TextBox").hide();
}
});
$w("#state13Input").onChange((e) => {
if (e.target.value.length > 0) {
continueButton.enable();
if (e.target.value.includes("Aggressive behavior")) {
if (patientIntake.patientSixteenYearsOrYounger === "Yes") {
orangeFlags.thirteen = true;
} else {
redFlags.thirteen = true;
}
}
}
});
$w("#state14Input").onChange((e) => {
if (e.target.value.length > 0) {
continueButton.enable();
}
});
const state15Inputs = [
firstNameInput,
lastNameInput,
preferredNameInput,
pronounsInput,
emailInput,
phoneNumberInput,
genderInput,
dobInput,
];
const state16Inputs = [
addressLine1Input,
cityInput,
stateInput,
zipCodeInput,
];
const state17Inputs = [
insuranceFullName,
insuranceDob,
insurancePolicyId,
relationToPatient,
];
state15Inputs.forEach((input) => {
input.onChange((e) => {
if (checkToUnlockContinueButton(15)) {
continueButton.enable();
}
});
});
state16Inputs.forEach((input) => {
input.onChange((e) => {
if (checkToUnlockContinueButton(16)) {
continueButton.enable();
}
});
});
state17Inputs.forEach((input) => {
input.onChange((e) => {
if (checkToUnlockContinueButton(17)) {
continueButton.enable();
}
});
});
backButton.onClick((e) => {
stateNumber = 15;
statebox.changeState(`state${stateNumber}`);
});
insuranceCardFrontUpload.onChange((e) => {
if (e.target.value.length > 0) {
continueButton.disable();
startUploadButton.show();
} else {
if (insuranceCardBackUpload.value.length === 0) {
continueButton.enable();
startUploadButton.hide();
}
}
});
insuranceCardBackUpload.onChange((e) => {
if (e.target.value.length > 0) {
continueButton.disable();
startUploadButton.show();
} else {
if (insuranceCardFrontUpload.value.length === 0) {
continueButton.enable();
startUploadButton.hide();
}
}
});
startUploadButton.onClick(async () => {
if (insuranceCardFrontUpload.value.length > 0) {
const insuranceCardFrontURL = await insuranceCardFrontUpload
.uploadFiles()
.then((files) => files[0].fileUrl)
.catch((err) => err);
if (typeof insuranceCardFrontURL.errorCode === "undefined") {
patientIntake.insuranceCardImageFront = insuranceCardFrontURL;
}
}
if (insuranceCardBackUpload.value.length > 0) {
const insuranceCardBackURL = await insuranceCardBackUpload
.uploadFiles()
.then((files) => files[0].fileUrl)
.catch((err) => err);
if (typeof insuranceCardBackURL.errorCode === "undefined") {
patientIntake.insuranceCardImageBack = insuranceCardBackURL;
}
}
continueButton.enable();
});
continueButton.onClick(async () => {
stateNumber += 1;
if (formFactor !== "Desktop") {
statebox.scrollTo();
}
if (exitQuestionnaireCheckbox.checked) {
return wixLocation.to(`${wixLocation.baseUrl}`);
}
if (statebox.currentState.id === "state6") {
if (redFlags.six) {
continueButton.hide();
return statebox.changeState("redFlagSuicidal");
}
}
if (statebox.currentState.id === "state14") {
if (redFlags.nine || redFlags.eleven || redFlags.thirteen) {
continueButton.hide();
return statebox.changeState("redFlag");
}
}
if (statebox.currentState.id === "state16") {
$w(
"#nameText"
).text = `${patientIntake.firstName} ${patientIntake.lastName}`;
$w("#preferredNameText").text = `${patientIntake.preferredName}`;
$w("#emailText").text = patientIntake.email;
$w("#phoneNumberText").text = patientIntake.phoneNumber;
$w("#dobText").text = patientIntake.dob;
$w("#genderText").text = patientIntake.gender;
$w("#pronounsText").text = patientIntake.pronouns;
let addressText = patientIntake.addressLine1;
if (patientIntake.addressLine2 !== "N/A") {
addressText += `, ${patientIntake.addressLine2}`;
}
addressText = `${addressText}
${patientIntake.city}, ${patientIntake.state}, ${patientIntake.zipCode}`;
$w("#addressText").text = addressText;
}
if (statebox.currentState.id === "state17") {
$w("#insuranceInformation").show();
$w("#insuranceFullNameText").text = patientIntake.insuranceFullName;
$w("#insuranceDobText").text = patientIntake.insuranceDob;
$w("#insurancePolicyIdText").text = patientIntake.insurancePolicyId;
$w("#relationToPatientText").text = patientIntake.relationToPatient;
}
if (statebox.currentState.id === "state18") {
patientIntake.currentPsychiatricCare =
patientIntake.currentPsychiatricCare.join(",");
patientIntake.patientSeekingServices =
patientIntake.patientSeekingServices.join(",");
patientIntake.patientDiagnoses = patientIntake.patientDiagnoses.join(",");
patientIntake.patientRedflagMedications =
patientIntake.patientRedflagMedications.join(",");
patientIntake.nonPrescribedDrugsUsed =
patientIntake.nonPrescribedDrugsUsed.join(",");
patientIntake.possibleRedFlagBehaviors =
patientIntake.possibleRedFlagBehaviors.join(",");
patientIntake.patientProviderPreference =
patientIntake.patientProviderPreference.join(",");
console.log("Attempting to create new patient", patientIntake);
const createPatientIntake = await insertNewPatientIntake(patientIntake);
if (createPatientIntake._id) {
console.log(
"Patient Intake created, attempting to generate PDF and send email"
);
const generatePDFAndSendEmailResult = await generatePDFAndSendEmail(
patientIntake
);
if (generatePDFAndSendEmailResult.message === "success") {
console.log("Email sent successfully");
const hasOrangeFlags = Object.keys(orangeFlags).some(
(key) => orangeFlags[key] === true
);
if (hasOrangeFlags) {
continueButton.hide();
return statebox.changeState("orangeFlag");
} else {
continueButton.hide();
return statebox.changeState("greenFlag");
}
}
}
}
if (statebox.currentState.id === "state7") {
if (paymentType === "in_network") {
statebox.changeState("inNetwork");
} else {
stateNumber = 8;
statebox.changeState(`state${stateNumber}`);
}
} else if (statebox.currentState.id === "inNetwork") {
stateNumber = 8;
statebox.changeState(`state${stateNumber}`);
} else if (
statebox.currentState.id === "state16" &&
paymentType !== "in_network"
) {
stateNumber = 18;
statebox.changeState(`state${stateNumber}`);
} else {
statebox.changeState(`state${stateNumber}`);
}
});
statebox.onChange((e) => {
console.log("Orange Flags", orangeFlags);
console.log("Red Flags", redFlags);
if (e.target.currentState.id === "state15") {
if (!checkToUnlockContinueButton(15)) {
continueButton.disable();
}
} else if (e.target.currentState.id === "state16") {
if (!checkToUnlockContinueButton(16)) {
continueButton.disable();
}
} else if (e.target.currentState.id === "state17") {
if (!checkToUnlockContinueButton(17)) {
continueButton.disable();
}
} else if (e.target.currentState.id === "state18") {
continueButton.enable();
} else if (
e.target.currentState.id !== "inNetwork" &&
e.target.currentState !== "state18"
) {
continueButton.disable();
}
console.log(patientIntake);
});
function checkToUnlockContinueButton(state) {
if (state === 15) {
const inputs = [
firstNameInput,
lastNameInput,
emailInput,
phoneNumberInput,
genderInput,
dobInput,
];
return inputs.every((input) => input.value !== "");
} else if (state === 16) {
const inputs = [addressLine1Input, cityInput, stateInput, zipCodeInput];
return inputs.every((input) => input.value !== "");
} else if (state === 17) {
const inputs = [
insuranceFullName,
insuranceDob,
insurancePolicyId,
relationToPatient,
];
return inputs.every((input) => input.value !== "");
}
}
});
Interested in setting up something like this for your website? Contact us at 225-250-1888 or email robert@roberthebertmedia.com.
About our company
RHM specializes in helping businesses of all sizes and across all industries achieve their digital and web marketing needs. Whether you are designing a new website, building an app, performing custom development, or running Google Ads, our goal is to showcase how you are the best at what you do and help people connect with you. Contact us at 225-250-1888 to get started!
网课帮手专注于留学生网课代修、网课代上等国外留学服务,我们致力于网课代修代上,期望成为本行业最靠谱、最具影响力的网站。我们把客户的需求放在首位,将策略和执行紧密结合,且不断的沟通评估并优化我们的方案,为客户提供一站式的网课辅助服务!我们拥有网课代修 http://www.wangkedaixiu.com/ 保分和分期付款等方案,客户可以根据自身不同的情况代上网课。我们的写手都是经过层层筛选,经验丰富。帮助客户考出好成绩,赢得了良好的口碑。
Deadlines stressing you out? Nursing writing essays services from NursingWriting.org are here to save the day. Specializing in nursing essay writing, their team of qualified experts guarantees 0% plagiarism and adherence to your instructions. Available 24/7, they offer help with assignments, discussion posts, and essays. Enjoy a 15% discount on your first order and achieve your academic goals effortlessly with NursingWriting.org.