Showing posts with label Scripts. Show all posts
Showing posts with label Scripts. Show all posts

Show / Hide Elements based on a Checkbox

One of the best ways to save space on a busy iForm and make it easier to read is to only show certain pieces of information when they are relevant. For instance, if you have an order with prompts that need to be filled in, you can hide the supporting prompts until the order is selected and in most iForms, that means checking a checkbox.

So today, we'll look at how to hide and show an element on your iForm based on when a checkbox is checked / unchecked. Up until this point on the blog, I've mainly focused on how to get things done using the jQuery JavaScript framework, but today I've decided to be more inclusive and include the instructions on how to do this using "native JavaScript" as well. For each method, I've included two examples: one example of showing / hiding an inline prompt and one example of showing / hiding whole orders.

Clinical Decision Support - Using Lab Dates in JavaScript

This blog post was inspired by a question raised by Scantron (Michael) on the HEO iForms Google Group. He writes:

Hello all,

I was wondering if anyone is working with dates in java script? I have some criteria to order a CBC if one has not been completed in the past 24 hours. I can get it to subtract the dates and order the tests when I hard code the dates, but when using the @@patient.lab_result.Plt.date@@, the value brings in a carriage return symbol, and I get an unterminated string constant error. anyone have a solution for this?

My js:

var dt1 = new Date(Date.parse("@@patient.lab_result.Plt.date@@"));
var one_day=1000*60*60*24;
var time_diff1 = (parseInt(dt1.getTime()-dt2.getTime())/(one_day));

if (time_diff1 > 1 || isNaN(time_diff1)){
 $('#PtInr').val(1);
}

What comes in:

var dt1 = new Date(Date.parse("03/13/2013 09:46 AM
"));

Placing Orders with a Multi-Select Prompt

In HEO, some prompts are known as "Multiple Choice" prompts. In other contexts, "Multiple Choice" might mean that you have to choose only one from a list of options. In HEO, that's known as a "List of Values" prompt; the "Multiple Choice" type prompt gives the user the option to choose multiple options from the list that is given.

How jQuery Can Help Your iForms

You may have noticed that all of my code snippets up to this point have required something called "jQuery" and I've been remiss in not giving a more basic background of what this thing really is, what it can do for you and your iForms, and (maybe even more importantly) what it can't do for you.

jQuery is what is called a "javascript framework." That is to say, it's a library that helps make some javascript functions easier. If you at a facility that is not using javascript in your iForms and don't have plans (or the ability) to do so, then this has no bearing on your processes and, unfortunately, most of the "code" things that you'll see on this site will be out of your scope. However, if your facility is using javascript, but would like to expand your functionality, I'd recommend using a javascript framework / library such as jQuery (and there are others) to enhance your capabilities.

Happy 2013 - jQuery iForm Library, Anyone?

Happy New Year, everyone! The year 2012 was quite a year, wasn't it? And with 2013 just now beginning, I see a world of possibilities ahead of us. There are some exciting and scary things coming ahead in the world of CPOE; if your facility has attested for Meaningful Use phase 1, you have an idea of what I'm talking about.

I have some projects that I would love to unveil at some point this year. One of which I'd like to get some community feedback first. I've created a jQuery plug-in specifically geared toward iForms.

Diagnosis Keyword Search

Had a neat question come up the other day and it lead to an even neater script that I thought I might share with you. The question was; if a patient is diabetic, can we indicate that on the diet iForm for...(some medical reason, I kinda blank out on those)...? But the problem was really interesting and got me to thinking.

Common Lab iForm

Common Lab iForm

So rather than focus on just one thing at a time, I figure I'd show an exert from my common lab iForm. That way you can see many of the scripts and functions I'm using, feel free to take of the code from it you like and feel free to ask any questions you have.

Help Your Users With Quick Orders - Uncheck All

Part of the convenience of iForms is the ability to "pre-check" items, meaning that when the iForm is opened, some checkboxes start with the check mark already in it.  This makes an iForm work like an orderset that has a number of "order with previous" items.

However, when we first started making iForms, especially long or complicated ones, we felt like we had to tread a thin line regarding what items were pre-checked, not because we doubted the clinical necessity or contribution, but because we foresaw situations in which a physician may want to order just a few common things instead of the entire she-bang.

Hiding Dropdowns

The Problem

So you're condensing your form and you come to an item that can be taken orally or via IV but each option has a different set of frequencies. You don't want to create one large frequency dropdown with some options that would be wrong for each. So what do you do?

Lose the Tedium - Automate VGR Variable Initiation

Have you ever put together a long iForm with what feels like hundreds of checkboxes, radio buttons, dropdowns, text boxes, and buttons only to realize:
"Oh wait, now I have to map this monster."

I know I've been there, so I decided to do something about it.

Create Multi-item Checklists


The Problem

Checkboxes are great on iForms, wonderful, but our doctors want even less clicking. So we need a way to select a group of checkboxes with one click.

Trim Your VGR - Clear Default Text


The Problem

You know what always annoyed me?  Having to have multiple @LOAD_ORDER strings in my VGR just to check whether a textbox was left blank (and let's not even talk about when there is more than one textbox).

So, for example:

# ED CHEST AP PORTABLE
EDIT,IF,,chkChestAPportable,EQ,"true",AND
EDIT,IF,,txtChestAPportableComments,NE,,THEN
EDIT,SET,,orderstring,CAT,"@LOAD_ORDER=OIS=123456^^^OOS=0^^^7810=`cboChestAPportableReason^^^53=`txtChestAPportableComments"

EDIT,IF,,chkChestAPportable,EQ,"true",AND
EDIT,IF,,txtChestAPportableComments,EQ,,THEN
EDIT,SET,,orderstring,CAT,"@LOAD_ORDER=OIS=123456^^^OOS=0^^^7810=`cboChestAPportableReason^^^53=..."

I knew that there had to be a better way, and through some trial and error, I came up with a solution that's worked really well for us. But before we get to that, let's take a quick walk through the process and see why some of the early solutions didn't quite work right.

Easy Order Selection - rowSelector

The Problem

If you've spent much time at all creating iForms for HEO, you've come across a list of orders that have all kinds of prompts associated with them.  Take meds, for example, you may have a long list of meds, all with options for dose, route, priority, and frequency.  If you're like me, you may have wanted them all aligned nice and neatly.

For me (especially given the restrictions of HEO's formatting, but that's whole other rant), I will generally use a table.

List of Statin Medications, all with their own Dose, Route, and Frequency options

Now, other than using the "grid" formatting that "comes with" the iForms that McKesson provides, I wanted to figure out how to help the customer see which order they were looking at when they were fiddling around with the doses, frequencies, etc.  If you have enough doses, routes, or whatever that all look similar enough, the user may accidentally make their choice on the wrong med.