Well, it depends what you want it to do. If it works for you, then great.
I’ve given it a quick try and it seems functional in the way I might expect. But I can make a few suggestions.
- You may wish to account for cancelling.
- I think you want to change the title of the first prompt to something more appropriate.
- Presumably all of your patients/clients are not called “Mr. XX”, so how about capturing the desired details for that?
I’ve taken a quick round at picking up all three of those, and renaming the example prompt too. Given it is using multiple prompts, I’ve switched up the code a little to use some functions to wrap each of the prompts. It could potentially give you some flexibility and re-use if you continue taking this further.
Here’s the code feel free to ignore, or to tailor/build on it should it happen to help in any way. It starts with the three functions, and then it’s actually the code beneath that which will control the flow of what is happening, by first prompting for the ‘who’ details. Then if it get’s a non-empty result (which a cancel produces), it will prompt for the ‘criteria’ details. Then, assuming a non-empty result, it will prompt for the ‘classification’. If this third and final result gives a non-empty result, the output of the three prompts will be combined and inserted into the current cursor position in the editor. As well as reactivating the editor, I’ve also added a line that will move the cursor to the end of the selection so you can continue writing straight away if any further details are required.
function checkWho()
{
let prWho = Prompt.create();
prWho.title = "Patient Information";
prWho.addButton("OK");
prWho.addSelect("optTitle", "Title", ["Mr", "Miss", "Ms", "Mrs", "Dr", "Rev"], ["Mr"], false)
prWho.addTextField("optName", "Surname of Patient", "XX");
if (prWho.show())
{
return prWho.fieldValues["optTitle"] + " " + prWho.fieldValues["optName"] + "'s";
}
else return "";
}
function checkCriteria()
{
//Set-up a basic prompt
let prCriteria = Prompt.create();
prCriteria.title = "Criteria Selection";
prCriteria.addButton("OK");
prCriteria.message = "Toggle on the entries you would like to insert.";
prCriteria.addSwitch("opt1", "Other Specified Trauma-and Stressor-Related Disorder", false);
prCriteria.addSwitch("opt2", "AD, with Mixed Anxiety and Depressed Mood", false);
prCriteria.addSwitch("opt3", "AD, with anxiety", false);
prCriteria.addSwitch("opt4", "AD, With depressed mood", false);
prCriteria.addSwitch("opt5", "AD, Unspecified", false);
prCriteria.addSwitch("opt6", "Specific Phobia (driver related)", false);
prCriteria.addSwitch("opt7", "Specific Phobia (passenger related)", false);
prCriteria.addSwitch("opt8", "Specific Phobia (driver and passenger related)", false);
prCriteria.addSwitch("opt9", "Major Depressive Disorder", false);
prCriteria.addSwitch("opt10", "Somatic Symptom Disorder", false);
if (prCriteria.show())
{
let astrOutput = [];
if (prCriteria.fieldValues["opt1"]) astrOutput.push("F43.8 Other Specified Trauma-and Stressor-Related Disorder (Adjustment-like disorder with prolonged duration of more than six months)");
if (prCriteria.fieldValues["opt2"]) astrOutput.push("F43.23 Adjustment Disorder, with Mixed Anxiety and Depressed Mood");
if (prCriteria.fieldValues["opt3"]) astrOutput.push("F43.22 Adjustment Disorder, with anxiety");
if (prCriteria.fieldValues["opt4"]) astrOutput.push("F43.21 Adjustment Disorder, With depressed mood");
if (prCriteria.fieldValues["opt5"]) astrOutput.push("F43.20 Adjustment Disorder, Unspecified");
if (prCriteria.fieldValues["opt6"]) astrOutput.push("F40.248 Specific Phobia, Situational Type (driver related)");
if (prCriteria.fieldValues["opt7"]) astrOutput.push("F40.248 Specific Phobia Situational Type (passenger related)");
if (prCriteria.fieldValues["opt8"]) astrOutput.push("F40.248 Specific Phobia Situational Type (driver and passenger related)");
if (prCriteria.fieldValues["opt9"]) astrOutput.push("F32.1 Major Depressive Disorder, Single Episode, moderate, with anxious distress");
if (prCriteria.fieldValues["opt10"]) astrOutput.push("F45.1 Somatic Symptom Disorder, With predominant pain, Persistent, (Moderate)");
return "interview data as well as the psychometric testing support the ICD-10 and DSM-5 criteria of " + astrOutput.join(" and ") + ".";
}
else return "";
}
function checkClass()
{
//Set-up a basic prompt - Impairment Level
let prClass = Prompt.create();
prClass.title = "Impairment Level";
prClass.addButton("OK");
prClass.message = "Toggle on the entries you would like to insert.";
prClass.addSwitch("opt1", "Class 2 - Mild impairment", false);
prClass.addSwitch("opt2", "Class 3 - Moderate impairment", false);
prClass.addSwitch("opt3", "Class 4 - Marked impairment", false);
if (prClass.show())
{
let classOutput = [];
if (prClass.fieldValues["opt1"]) classOutput.push("Class 2 - Mild Impairment (impairment levels are compatible with most useful functioning");
if (prClass.fieldValues["opt2"]) classOutput.push("Class 3 - Moderate Impairment (impairment levels are compatible with some, but not all, useful functioning)");
if (prClass.fieldValues["opt3"]) classOutput.push("Class 4 - Marked Impairment (impairment levels significantly prevent useful functioning");
return "According to the American Medical Association Classification Table of Impairments Due to Mental and Behavioural Disorders, his condition is consistent with " + classOutput + ".";
}
else return "";
}
//Enter the person's details
let strWho = checkWho();
//If we didn't cancel then we'll continue with classification
if (strWho.length > 0)
{
//Select the criteria
let strCriteria = checkCriteria();
//If we didn't cancel then we'll continue with classification
if (strCriteria.length > 0)
{
//Select the classification
let strClass = checkClass();
//If we didn't cancel then we'll continue with outputting
if (strClass.length > 0) editor.setSelectedText(strWho + " " + strCriteria + "\n\n" + strClass);
}
}
//Reposition the cursor at the end of the inserted selection and activate the editor.
editor.setSelectedRange(editor.getSelectedRange()[0] + editor.getSelectedRange()[1], 0);
editor.activate();
Hope that helps.