Populate text boxes with template / short codes

Experts,
I'm writing a page for doctors and nurses to enter some notes about a recent patient visit.  While we initially though we could use drop down boxes to help automate the population of text boxes, the users (clinical staff) are asking if "short codes" are a possibility.  I guess this would be similar to how WordPress uses short codes.

For example:  In the large text box that says "Diet Recommendations", instead of typing this paragraph 20 times a day:
"Patient should follow a low-carb diet and avoid foods containing sugar."

The user would simply like to type something like [diet.lc].
Then the paragraph above would be displayed.

Are there any plugins or existing scripts that would make this less difficult.  I'm not even sure where to begin here.

Any feedback or suggestions would be welcome.

-dsg
dsg138Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ess KayEntrapenuerCommented:
i would suggest making a stored procedure in the database.  

The insert / update function should be a stored procedure,  and the field entered should go through a function.  The function would go through the ' note/text'  and do a find/ replace

The find replace would need a new table in the database with a few columns:  Find and Replace

Find column would have your shortcodes,  replace column would have the replace text


So basically,  you would do something like this in stored procedure :


INSERT ID,  REPLACEFUNCTION( NOTETEXT)
INTO YourTable
Ess KayEntrapenuerCommented:
to make it quicker,  you can use regular expression to find anything between the [ ]
Lee SavidgeCommented:
Ideally this would be done in the code behind but if you wanted it live updated on the screen as they type this this would work.

Use a replace function on the onkeydown event. Obviously there is some admin overhead here if they want to be able to add short codes to the available list. I haven't tested the code, so it may have errors. I wrote it straight out.

// in your html header
<script>
function replaceShortCodes(sFieldText)
{
  var sDietLC = "Patient should follow a low-carb diet and avoid foods containing sugar.";
  var sOtherShortCode = "Some other dietary recommendations";
  var sReturn = "";

  switch(sFieldText)
  {
    case "diet.lc":
        sReturn = sDietLC;
        break;
    case "osc":
        sReturn = sOtherShortCode;
        break;
    default:
        sReturn = "";
  }
  replaceShortCodes = sFieldText.replace(sFieldText, sReturn);
}
<script>


// Then in the onkeydownevent of the input control

onkeydown="replaceShortCodes(this.value);"

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dsg138Author Commented:
Thank you.  This is exactly the advice I was looking for!  Appreciate the help!
-Dan
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.