Skip to main content

Troubleshooting: Event Not Always Honoring Edit Form

I had this issue come up for me recently while working on making placement disruptions more secure. By the nature of placement disruptions, we needed to allow users to go back in and edit the placement disruption to add an end date but we did not want other fields to be editable at that point so I copied the placement disruption forms, made the fields we wanted to lock down not-modifiable and then linked the new forms to the event as the form to use on Edit.

While testing, we noticed that if we saved a new placement disruption and then immediately edited it, the Add form was being used. If we refreshed the list of placement disruptions and then edited the placement disruption, the Edit form was being used as intended. Based on how placement disruptions actually get used, this probably would not be a problem because typically staff will set them up one day and edit them another day, which means that they will have gone through at least one refresh. Still, I was annoyed about this and wanted to figure out how to make it behave. While I used this fix specifically to get the Edit form to be used, you could apply this in any situation where you need the event information to update in the list so that other form functionality works properly as well.

The Problem

I noticed that after saving the placement disruption, the list of placement disruptions did not refresh itself. The most recent placement disruption should be showing at the top of the list but it was being appended at the bottom of the list and the list never refreshed itself to fix the order like it typically does. Also the placement disruption type did not fill in on the list indicating that the list refresh was necessary to update the event information enough to indicate that the edit form should be used on edit instead of the add. A manual refresh made all this happen. So the problem was related to the event listing not refreshing after save.

This is the list of placement disruptions before adding one.
After I added a placement disruption, the list did not refresh. The new placement disruption is at the bottom.
After clicking the Refresh button, the list updated to fill in missing information and list in the proper order.

The Solution

I went through the formfunctions.js file looking for any code snippet that would refresh the listing after save and found one. If you have any forms that do no automatically refresh the event listing after save, you can add the following code to the After Save Code property of the form:

self.refreshCallerWindow = true;

With this code on the form, after I save the form, the list of event automatically refreshed itself rather than requiring me to click the Refresh button. When I click to edit the newly created placement disruption, the Edit form opened.

With the code on the form, after saving, the list displayed with the proper information filled in and in correct order.

How To: Default a Date Field Value Based on Another Date Field

NOTE: THIS POST IS AN UPDATED VERSION OF THIS POST

When working on treatment plans in myEvolv, you will notice that many of the treatment plan component forms contain both a start date and a target completion date.  One of the programs I was building a treatment plan for wanted to have the target completion date on the form but always wanted it to be 90 days from the start date.  Instead of making each clinician calculate 90 days from the start date and fill it in themselves, I used this method to take the date value from the start date and update the target completion date field with a value that is 90 days later.  I will walk you through the JavaScript that I used so that you can make adjustments based on your needs.  The full snippet of JavaScript will be at the end.

two-fields

Where does the code go?

The first consideration is where to put the JavaScript.  In this case, used the ‘On Change Script’ field property on the field that will be modified by the clinician, ‘start_date’.  myEvolv provides us with access to 3 events that we can use to trigger our JavaScript handlers (the code we want to execute):  ‘On Change’, ‘On Click’ and ‘On Load’.  The ‘On Change’ event is fired when the value of the field has been changed.  This is the most suitable event to use in this situation since I do not want the new date value to calculate until there is a value in the first date field.  Furthermore, if a clinician makes a mistake entering the start date, I want the new date to recalculate when the clinician makes an adjustment.  Both of these scenarios are covered when using the ‘On Change’ event.

Get the ‘start_date’

The first line of JavaScript code’s purpose is to get the value that has been placed into the ‘start_date’ field and convert it into a proper JavaScript Date object so that we can manipulate the date easily. I declared a variable named date and set it to be a new Date object passing the value of the ‘start_date’ field as its argument:

var date = new Date(getFormElement('start_date'));

Calculate the ‘target_date’

Now with the date entered by the clinician converted to a Date object, I can perform some calculations on the date using the ‘getter’ and ‘setter’ methods built in to JavaScript Date objects. In my scenario, I need the ‘target_date’ field to be +90 days from the ‘start_date’ so I used the getDate() and setDate() methods:

date.setDate(date.getDate() + 90);

If I wanted to do +3 months instead, I would use the getMonth() and setMonth() methods:

date.setMonth(date.getMonth() + 3);

If I wanted to do +1 year, I would use the getFullYear() and setFullYear() methods:

date.setFullYear(date.getFullYear() + 1);

There are also methods for getting and setting hours, minutes, seconds, and milliseconds, but I am dealing with Date Only fields in this scenario.

Format the ‘target_date’

Now that the date object has my new date stored in it, I need to put that value into the ‘target_date’ field. However, the date in the date object is not formatted in a way that myEvolv’s date fields like so I need to pull the individual date elements from the object and build a string value to place in the date field. I accomplish this first by declaring variables for the month, day and year:

var mm = date.getMonth() + 1;//+1 is needed because in JavaScript Date objects, January is 0
var dd = date.getDate();
var yyyy = date.getFullYear();

Now I declare a new variable called formatted_date and set its value to a concatenated myEvolv-friendly string:

var formatted_date = mm + '/' + dd + '/' + yyyy;

Set the ‘target_date’

setFormElement(‘target_date’, formatted_date);

 

One Caveat

You may be inclined to disable the ‘target_date’ form field so that clinicians cannot change the value after it has been calculated. I was unable to get that to work, however. When a form field is disabled, it is excluded from being saved so for now it would seem that you have to keep the form field modifiable. If you used this same similar* code in the ‘On Change Script’ property for ‘target_date’, you could prevent the ‘target_date’ from being changed by effectively reverting any attempts at changing the ‘target_date’ manually.

*You will need to also add some JavaScript to validate that the ‘target_date’ has been changed because if you just put this exact same code in the ‘On Change Script’ property for ‘target_date’, you will end up in an infinite loop when ‘actual_date’ is changed on the form and you will crash the browser.

The Full Code

var date = new Date(getFormElement('start_date'));
date.setDate(date.getDate() + 90);
var mm = date.getMonth() + 1;
var dd = date.getDate();
var yyyy = date.getFullYear();
var formatted_date = mm + '/' + dd + '/' +yyyy;
setFormElement('target_date', formatted_date);

How To: Launch Forms from Other Forms

I have found that it is often small things that can make all the difference in how user-friendly our myEvolv processes are. One problem that we ran into with myEvolv was that if you were in the middle of working with a form where you needed to select, say, a collateral but that collateral had not yet been added for the client, you would need to save the form as a draft (if allowed), navigate to the collaterals formset member to add one and then return to the original form to select the collateral. If you have experienced this, then you know how annoying it can be.

My solution to this issue was to add urls to our forms that would launch the collaterals wizard without the need to close the form at all. Users are then able to add collaterals on the fly. This could be used for other relationships like health providers or families and possibly even things outside of the relationships formset. This post will demonstrate how to create a URL form variable to launch the collaterals wizard but you should be able to apply the same steps to other formset members and achieve the same results.

Adjust Your Browser Settings

myEvolv creates popup windows just like any other website by opening a new browser window with it’s own URL. The default browser settings for Internet Explorer allow myEvolv to hide the URL of those popups but we want to examine the URL because we want create our own URL’s to display on our forms that will open the same windows. To make the URL visible on popups:

1) In Internet Explorer, go to Internet Options
2) Click on the “Security” tab
3) Make sure you are in the “Trusted Sites” zone and click “Custom level…”
4) In the “Miscellaneous” section of the “Security Settings”, DISABLE “Allow websites to open windows without address or status bars”
5) Click “OK” and then close Internet Explorer Settings

security-settings

With this setting disabled, you will now see the URL for all popups that myEvolv creates. See the image below for the before (top) and after (bottom).

url-vs-no-url

What’s in a myEvolv URL?

I am interested in getting the URL for the popup window that is created when I go to create a New Manual Event for a Personal Collateral so I pick any client and open the form to add a new personal collateral. The URL for that window is long so let’s break it down and see what we can determine about it. Below, I have the URL and have added a line break before each &

https://myagency.netsmartcloud.com/new_person_form.asp?process_code=COLLATERAL
&form_id=NEW_COLLAT_SEARCH
&parentValue=CA333940-AC8A-4DB0-962D-5E70C6DFB13B
&key_value=
&addAllowed=true
&editAllowed=true
&deleteAllowed=true
&isAmendment=false
&isCompleteScheduledEvent=false
&mode=ADD
&sessionID=309a0ab9-74a9-495f-bb67-9b0789939d57
&data=SERVER
&serviceTrack=EE353446-DEC8-4ECF-81AA-D97CA183B0D5
&event_id={2274E0EF-10D8-4341-A75B-490F7947B922}

We want to keep this URL the same as much as we can but there are some variables we need to identify in here so that we can generate a unique URL for each form instance based on whose client record we are working on. If I just dumped this URL onto a form statically, I would always be creating collaterals for the client whose record I had open when I grabbed this URL along with some other problems. The parts we need to examine more closely are anything with a GUID.

The pieces of this URL that we will need to generate dynamically on our form are

  • parentValue – this is the people_id of the client for whom we would be creating the collateral
  • sessionID – this is the id of your current session. If this is not updated for each login session, the popup window will take you to a myEvolv login screen
  • serviceTrack – this is a client-related id similar to the parentValue

event_id does not need to be changed. I am not sure what it is but the value stays the same no matter which client record so its safe to bet you can keep it static.

Form Design – Adding a URL Variable

On your form, insert a new variable wherever you want it to display on your form. You can name the variable whatever you would like and caption it however you would like. I typically make the field not modifiable so that users can’t make changes to the url that might have an adverse effect. You might also want to shorten the display length so that it looks better on the form.

url-properties

We then need to concentrate on generating the URL string that will be our default value for this variable. For those of you who have not done URL string building, it just involves a lot of string concatenation. We first create a variable and assign it a string value that is equal to the first chunk of static text. Then we concatenate our first variable. Then concatenate the next chunk of string that is static and so on until we have our full url.

The first section of the url that is completely static is https://myagency.netsmartcloud.com/new_person_form.asp?process_code=COLLATERAL&form_id=NEW_COLLAT_SEARCH&parentValue= so the first line of our code will be

var myUrl = 'https://myagency.netsmartcloud.com/new_person_form.asp?process_code=COLLATERAL&form_id=NEW_COLLAT_SEARCH&parentValue=';

Then we need to append our variable for parentValue, which is the people_id of the client whose record we are in. That comes to the current form already loaded in a variable called parentValue so we can just plug that in here

myUrl += parentValue;

Then we can append the next chunk of static url

myUrl += '&key_value=&addAllowed=true&editAllowed=true&deleteAllowed=true&isAmendment=false&isCompleteScheduledEvent=false&mode=ADD&sessionID=';

And now we have to append our sessionID, which is also already loaded into a variable by the same name

myUrl += sessionID;

Then the next static chunk

myUrl += '&data=SERVER&serviceTrack=';

And the serviceTrack variable (again, handily available in a variable already)

myUrl += serviceTrack;

And then the last bit of the url

myUrl += '&event_id={2274E0EF-10D8-4341-A75B-490F7947B922}';

Now that we have our url loaded into a variable, we just need to output it so our final line is simply

myUrl;

url-field-on-form

Full Code Block

***Remember to change myagency at the beginning of the url to match your agency’s url if you are copying and pasting this code.***

var myUrl = 'https://myagency.netsmartcloud.com/new_person_form.asp?process_code=COLLATERAL&form_id=NEW_COLLAT_SEARCH&parentValue=';
myUrl += parentValue;
myUrl += '&key_value=&addAllowed=true&editAllowed=true&deleteAllowed=true&isAmendment=false&isCompleteScheduledEvent=false&mode=ADD&sessionID=';
myUrl += sessionID;
myUrl += '&data=SERVER&serviceTrack=';
myUrl += serviceTrack;
myUrl += '&event_id={2274E0EF-10D8-4341-A75B-490F7947B922}';
myUrl;

Troubleshooting Tip

You can see the results of your concatenation in the URL variable on the form so if you keep it modifiable and give yourself a generous display size, you can check to see where you might have left pieces out by mistake.

launching-form-url

Quirky Behavior

If you built your URL string correctly, you should launch the Add Collateral window from your form. One thing I have noticed is that after you fill out the form and hit save, the form does not close or give any indication that the collateral had been added successfully. One challenge in getting the form to behave any different is that these forms are system not-modifiable so we don’t have the ability to go in and add a window.closeAfterSave = true snippet to them. Users must be trained to close the window manually after they have saved the form without triggering an error for things like blank required fields.

How To: Carry Referral Source and Referral Reason Forward on Intake from Accepted Referral

This post comes from a reader request. The scenario she was facing is that when a referral is created in myEvolv, you must enter a referral source and a referral reason on the form. When you go to perform an intake from the referrals, this information is not pulled into the client record. She wanted to have the Referral Source and Referral Reason fields on the client initial enrollment AND also have those fields pre-populate with the options that were selected on the referral.

Intake Form Setup

The Initial Enrollment from Accepted Referral form is in the Agency Intake form family. Agency intake events are not user modifiable so we have to modify the system form to add the fields for Referral Source and Referral Reason.

Referral forms use the refrerrals_to_agency table and the intake forms use the service_track table, so we will need to add new database fields to the intake form to hold our Referral Source and Referral Reason values. We will set them up just as they are on the referral form, using the same picklist and and dependencies.

Referral Source

We add a new database field called udf_referral_source and give it the following attributes:
Data Type: Foreign Key ID
Foreign Key Column: group_profile: group_profile_id
Look-up Table Used: Referral Source – Referral In
Formset to call: Outside Organizations Stand Alone
Depends On: Agency

Referral Reason

We add a new database field called udf_referral_reason and give it the following attributes:
Data Type: Foreign Key ID
Foreign Key Column: referral_reason: referral_reason_id
Look-up Table Used: Referral Reason Table

Default Values

At this point, the intake form has a place to store the referral source and referral reason but the user would have to manually re-select those values, which is a pain and also error-prone. We know the information is in the referrals_to_agency table, so we can use the getDataValue() form function to obtain the data but how do we know which row to select.

When you perform a client intake from accepted referral, the intake event “belongs to” the referral made event. The referral made events are the subform entries for Program Recommendations on the Referral form. In turn, those referrals made events “belong to” the referral form that houses the referral source and referral reason data we need. Once you have selected the accepted referral from which you are completing the intake, myEvolv sends a belongs2Event parameter to the intake form so that when the intake is saved, the intake is linked to the parent referral made. That value is equal to the event_log_id of the referral made event, which means we can plug it into the getDataValue() form function to get the value that referral made event’s parent event_log_id and then use that value to return the referral source and referral reason values.

referral-form-explanation

Referral Source

We use this code in the Default Value attribute:
var parent = getDataValue('event_log', 'event_log_id', belongs2Event, 'belongs_to_event');
getDataValue('referrals_to_agency', 'event_log_id', parent, 'referral_source');

Referral Reason

We use this code in the Default Value attribute:
var parent = getDataValue('event_log', 'event_log_id', belongs2Event, 'belongs_to_event');
getDataValue('referrals_to_agency', 'event_log_id', parent, 'reason_id');

Explanation of Code

First we use the belongs2Event value that is passed to the intake form from the referral made event so that myEvolv can properly link the two events in the tables. We use that value to get the event_log_id of the referral made event’s parent event which is the referral event using the form function getDataValue()

We then use referral event’s event_log_id to get the value of the referral source and referral reason fields on that referral event again using getDataValue()

Conclusion

With this setup in place, when you perform an intake from accepted referral, the referral reason and referral source from the related referral should be on our intake form. Note that this setup enters duplicate data to what is on the referrals_to_agency table into your service_track_x table. If we wish to avoid saving duplicate data to the database, we can setup the new fields on the Intake form as variables instead. This will allow us to display the referral source and referral reason on the intake form when it is opened in myEvolv but no data from the variables will be saved to tables when the intake is saved.

How To: Use a Default Value on a Progress Note

EDIT 8/3/2018: Reader Rosemary asked about using text templates in conjunction with this code rather than including the raw HTML in the JavaScript code. Indeed there is a way to do that, so I have included that method at the bottom of the post. Reviewing the post also exposed that my code had a syntax error so I fixed that. Thank you, Rosemary!

Progress notes in Evolv are system fields in myEvolv that have special properties that make them particularly useful in certain situations. For example, the Progress note field is included in many of the views available to subreports so being able to use the progress note column on a form allows the data contained therein to be fed back on other forms via subreport.

Unlike other form fields, however, you do not add a progress_note field to your form in the form designer. Instead, you add the progress note in the Event Setup area by checking the “Has Single Note” checkbox.

has-single-note-checkbox

Just like with the Service Related Encounter Information that I addressed in another post, checking this checkbox will append fields to your form at the time that the event is launched. Unlike the Service Related Encounter Information, however, there is no way to add the progress note field to your form in the form designer so that you can manipulate its attributes. It is therefore tricky to set a default value for the progress note, but not impossible. The following guide will show how you can use jQuery and the form header attributes to simulate the use of the default value attribute on a progress note field. This can be useful for defaulting in a template when you know only one template would be used and you want decrease the risk that the clinician forgets to apply the template.

How Memo Fields Render

One of the things that makes manipulating a Memo field more difficult in myEvolv is that they are a much more complex field being rendered on the form. With a custom_string type of field, for example, there is just a label/caption and an html input field so you can use some pretty basic javascript to get and set the value of the field or use some of the formfunctions.js functions to get or set the form elements.

Memo fields, on the other hand, have their own menus for manipulating the formatting of the text and spellcheckers, etc. When you are dealing with a Memo field, you are actually dealing with an iframe element that contains a series of div elements that hold those buttons and then finally, buried deep in the iframe you will find a div with the id of “Composition”. That is where the text value of the memo resides.

Further complicating things is the fact that unlike other types of fields that you can easily target by column name, Memo fields must be targeted by their id, which is the GUID that represents their form_lines_id.

Accessing the Text Value of a Memo Field

To target the divelement that contains the text value of your memo field, you must turn to jQuery and use the following code:

var memo_text = $(form_lines_id).contents().find('#Composition').html();

Since the Progress Note field is a system column that has existed for a long time, it has the same form_lines_id in everyone’s system, so to get the memo text of a Progress Note memo field, plug in the form_lines_id:

var memo_text = $('#BFE6BE66-7983-4C3B-8374-1606E7D909A5').contents().find('#Composition').html()

Explanation of Code

var memo_text =
This creates a variable called “memo_text” that will hold the value of the memo field we target.

$('#BFE6BE66-7983-4C3B-8374-1606E7D909A5')
This targets the element on the form that has and id of ‘BFE6BE66-7983-4C3B-8374-1606E7D909A5’, which is the progress note’s iframe. If you want to target a different memo field, you will need to determine the form_lines_id of that field and plug it in here.

.contents()
This gets all of the contents of the iframe targeted above.

.find('#Composition')
This searches the contents above for an element with an id of “Composition”. This is the element that contains the Memo field’s text.

.html()
This gets the html value contained inside the “Composition” div targeted above. We use the html() method because this will preserve the rich text formatting that has been applied to the text in the box.

Setting the Value of the Progress Note

You can set the value of the progress note field with very little changes to the above code. if I want to set the text inside the progress note to “Hello”, I use this code:

$('#BFE6BE66-7983-4C3B-8374-1606E7D909A5').contents().find('#Composition').html('Hello');

Since we are using the html() method, you can insert HTML markup with your text, which is what will allow you to insert a nice template. Remember that you have to escape your >’s and <‘s

Replicating the Default Behavior

Using the code above, we are able to manipulate the text inside the Memo field with On Change and On Click events on the loaded form just fine, but what can we do if we want to default a specific value into the progress note field when the form loads?

We can use the code above to set the value but we need that code to fire AFTER the form has been loaded. Fortunately, there is an attribute on the form called After Load Code that we can use as the trigger for this code.

after-load-form-attribute

But, it’s not as simple as just dropping the code in there because while the code in this field will fire after the form loads, it does not necessarily fire after the memo field iframes are loaded. it is therefore necessary to wrap the code in a javascript setTimeout() function.

setTimeout(function(){$('#BFE6BE66-7983-4C3B-8374-1606E7D909A5').contents().find('#Composition').html('Hello');}, 5000);

The setTimeout() function takes two arguments. The first is the code that you want to execute. In the example above, I wrapped the code into an anonymous function. The second is the number of milliseconds it should wait before executing the code. In my example, I set the timer for 5000 milliseconds or 5 seconds. You can tweak this number as desired to achieve what you want it to do. With this code in place in the After Load Code attribute of the form, 5 seconds after the form loads, ‘Hello’ fills in on the progress note field.

Using A Text Template

You can use a text template in myEvolv to make this all a little easier, especially when it comes to formatting your progress note text. Create your default text in the text templates area of myEvolv.

Then within the setTimeout function, before the line of code that sets the progress note html, add the following line of code:

var myTextTemplate = getDataValue('text_template', 'description', '<text template description>', 'template_text');
where <text template description> is the description you have given your text template (beware of special characters). This line of code will grab your text template, then you can just use the variable you just created in the html() method.

Here’s what the final code would look like if you wanted to use your Incident Narrative text template.

setTimeout(function(){
var myTextTemplate = getDataValue('text_template', 'description', 'Incident Narrative', 'template_text');
$('#BFE6BE66-7983-4C3B-8374-1606E7D909A5').contents().find('#Composition').html(myTextTemplate);
}, 5000);

How To: Calculate Units Based on Duration

Many programs bill for units that are calculated based on duration. For example, programs may bill where 1 unit = 15 minutes of service time. The myEvolv Finance module handles those calculations to generate an accurate claim based on the duration entered in the service documentation but there may be times when you would like the calculated units to display on the form itself. There are no system form fields that do this for you but you can calculate the value with JavaScript and put it into a custom string field for display on the form.

calculated-units-form-fields

Duration Fields

The first step is to obtain the value in the duration field and we want to do this every time the duration changes on the form so in the On Change code for the duration field, we will use the following code:

var dur = getFormElement('duration');

Duration fields have masked inputs. When you put in ’30’, the myEvolv converts that to 00:30. When you put in ’90’, myEvolv converts it to 01:30. Therefore when you go to retrieve the value in the field, you are given an HH:MM string. The first task in calculating units is to convert this value back to an integer representing the number of minutes.

Split the String

We know the mask for the time is HH:MM so all we need to do is break the string into hours and minutes. We can do this using JavaScript’s split method:

var a = dur.split(':');

Here we have created a new variable that is an array containing hours and minutes. If the initial input was ’02:45′, a is now equal to an array that looks like this:

('2', '45')

Calculate Minutes

Now we have to perform a little math to get the number of minutes.

var mins = (+a[0] * 60 + (+a[1]));

Here, we take the hours in a and multiply that by 60 to get the number of minutes and then add it to the minutes in a. The ‘+’ signs tell JavaScript to cast the values in the array as numerical values so that math can be performed on them. Remember that the value we got from the duration field was a string.

Calculate Units

For the sake of this example, we will use 15 minutes = 1 unit. We simply need to divide mins by the number of minutes that makes 1 unit to get the number of units. However, there is one tricky bit. Often these billing scenarios do not allow for the billing of partial units. That means if the duration is ’00:35′, we want to calculate 2 units, not 2.333333333 units. So in addition to the division, we will also use JavaScript’s Math.floor method so that partial units are rounded down to the nearest whole.

var units = Math.floor(mins / 15);

If you need to calculate a different unit formula, you can do that by changing the number of minutes. For 1 hour = 1 unit, you just make the ’15’ into a ’60’.

Set the Units Value

Finally, we just need to put the calculated units into our units field. I am using a custom string type field.

setFormElement('udf_calculated_units', units);

With this code in place for the On Change event on the duration field, the correct number of units should calculate into the udf_calculated_units field whenever the duration value changes.

Full Code Block

var dur = getFormElement('duration');
var a = dur.split(':');
var mins = (+a[0] * 60 + (+a[1]));
var units = Math.floor(mins / 15);
setFormElement('udf_calculated_units', units);

Tips & Tricks: Use Images in Memo Fields

The following post outlines how to use images in memo fields as was shown in my presentation at CONNECTIONS2016.

memo-field-after-save

Memo fields in myEvolv are unique because they are rich text fields. This means that they will retain any markup that is done to them so that you can do things like change the font size and underline text that is being input into the field. When you are changing the formatting of the fields, HTML markup is being applied to the text behind the scenes. Because of this fact, we can use other HTML tags in a Memo field and have the browser render them just like it renders the rest of the webpage. One place where this can be useful is in adding images to treatment plans for individuals with intellectual and developmental disabilities.

With the Memo fields, you can just enter the HTML markup in the field itself and after saving, you will see the result. The challenge is therefore not in manipulating myEvolv to allow HTML but rather figuring out a way for clinicians who are not web developers to use pictures in their treatment plans.

Form Setup

There isn’t a lot to setting up the form but you have to keep this in mind: When you setup a text template, you must designate the table and columns for which the template will be available. In my agency’s case, the treatment plan had three fields where we wanted to use images: Likes/Interests, Dislikes/Fears, and Strengths/Skills. Each of these has it’s own user defined Memo field so that other programs using the progress_note field would not have the option of choosing one of my image text templates. It was also important to separate them so that someone didn’t accidentally put an image from the wrong category into the wrong field.

Note: If you setup a new Memo field before you setup the text templates for it, the template button on the Memo field may be disabled. You can fix that by making a change to the form so that it rebuilds the Form XML or run the Create Forms XML utility to awaken the button once a text template is linked to the field.

Preparing the Markup

The first step is to find the image that you want to use. The image needs to be on a web server somewhere because you are going to link to it rather than upload it. Ideally, your agency would set one up so that you could be sure the images that you use won’t ever disappear from the internet, leaving your old plans with broken image links. If that is not an option, you can use images from anywhere on the web. You will need the URL for the image itself. You can get that by finding an image on a website, right clicking it and selecting “Open Image in New Tab” or a similar option, depending on browser. Then you simply put the url into an img tag:

<img src='http://blog.corbinet.com/wp-content/uploads/2016/10/bunny.jpeg' />

bunny

The image tag that I created above will render an image is that is 543 pixels wide… too big for my plan, so I need to add some CSS styling to the image tag to make it smaller. Again, if you are hosting your own images, you could just make the raw image the size that you want and avoid this step. Another thing that I wanted to do is have the pictures site next to one another if I put multiple in a row so I am going to have the images styled to display inline.

<img src='http://blog.corbinet.com/wp-content/uploads/2016/10/bunny.jpeg' style='width: 150px; display: inline' />

bunny

You can add other styling as you see fit using inline CSS.

Setting up the Text Template

text-template-setup

Give your text template a descriptive name since this is all the clinician will see in the list of templates when they must choose.

At the bottom, link your template to the correct table and column that you setup on your form.

For the template text, you will enter the img tag that you created. Note: I have found that you cannot type this img tag into the field because it will begin to add markup to the url that you are using for the src and that breaks the image. Instead you must paste the img into the Template Text field and save without making any changes.

If you have entered syntactically correct HTML, after saving, you should see the image and not the text:

text-template-saved

If you see this, then you need to start again:

text-template-broken-image

When you revisit the Text Templates area in the future, you may or may not seethe image rendered in the list of text templates but you should when you open a text template for editing or viewing.

Applying Text Template in Memo Field

When the clinician goes to add the image to the Memo field, they can select the text template that contains the image. Unfortunately, when they select the text template, they will see the markup that will render the image once the form has been saved and not the image.

memo-field-before-save

After saving, the image should appear. You can also add text in the same field to label the pictures or explain them.

memo-field-with-captions

How To: Make a Field Required Based on Client Age

I haven’t yet figured out a great way to only toggle the required attribute for a form field so the typical workaround for a conditionally required field to be used on a form is to toggle the form field to be required all of the time but enable or disable the field based on the condition you want. myEvolv ignores disabled fields when it goes to save, even if they are required so you can get most of the functionality you would want in this way. The one scenario you don’t get is if you want the field to remain enable but no longer be required. That’s where being able to have a ‘required rule’ attribute in the form designer would be nice. I am not convinced that there isn’t a way to do this through some clever JavaScript but I haven’t had the opportunity to try anything out yet.

Form Setup

The nice thing about this approach to the problem is that you don’t need to add any additional information to the form itself. A lot of the disable rules that you might learn will involve checking the value of other fields on the form. In this case, we are going to use a form function to check a value in the database behind the scenes.

All you need to do then is setup the field that you want to make required. Be sure to check “Required” for the form field.

required-form-attribute

Disable Rule

The key to using the Disable Rule attribute in the form designer is that you have to put in a conditional statement that will resolve to true when you want the field to be disabled. It’s somewhat counterintuitive but basically true = disabled and false = enabled.

For this example, we want to figure out if the client is under the age of 18. If the client is under the age of 18, we want to enable the field and require that the clinician enter some data. If the client is over 18, we want to disable the field. So our statement should look something like this:

[[client_age]] > 18

If [[client_age]] is under 18, the statement resolves to false, so the field will be enable. If the client is over 18, the statement resolves to true and the field will be disabled. Now we just need to get the client’s age.

The getDataValue Form Function

One of the JavaScript form functions that myEvolv has included in it is the getDataValue() function. It is used to get a value from a column in the database based on the value of another column in the same table. It takes five arguments, one is an optional conditional statement that we will not get into here. For our purposes, we need to supply it with 4 things:

  1. the table we want to get data from
  2. the column we will match on
  3. the column value we will match on
  4. the column value we want returned

myEvolv has a view called the client_personal_view which contains a calculated column for the client’s age, so the work of calculating an age has been done for us already.

So to get the age of the client we are entering a service for, we call the function like this:

getDataValue('client_personal_view', 'people_id', keyValue, 'age')

Here we are saying, get the value in the age column from the client_personal_view table in the row where the value of people_id column is equal to client_id of our current client. keyValue is a variable that myEvolv creates to hold the client_id when a service event is launched so we can use that in our JavaScript here instead of getting the value from the people_id form field, though that is also a valid option.

The full code for our disable rule is now:

getDataValue('client_personal_view', 'people_id', keyValue, 'age') &gt; 18

Remember, the “>” and “<" signs are special characters so we have to use the ascii codes or else you will throw an error when the form loads in myEvolv.

How To: Prevent Backdated Entries

This may not be the only or even best way of preventing backdated entries in myEvolv but this method worked for me in a recent configuration.

Scenario

We wanted our prescribers to be able to provide a Script for Therapy Services to children in our preschool services program from myEvolv. Scripts for Service must have a start date on them and that start date needs to be no earlier than the date indicated on the child’s IEP but cannot but previous to the date that the script is being signed.

Further, an administrative assistant was going to be setting up the scripts in myEvolv and then the prescribers were going to be reviewing and e-signing them. We could imagine a scenario where the administrative assistant put a date, for example (9/1) on the script, believing that the prescriber would e-sign it on or before that date but the prescriber does not get into myEvolv to sign it until after that date has passed and then the script gets e-signed as though it were backdated. We needed a way to prevent the start date from ever being previous to the approved date while also allowing the start date to be in the future.

Form Design

script-for-service-form

The actual_date field was not suitable for use as the script start date since we needed to be able have multiple scripts that start on the same day for an individual. If I set the actual date as ‘Date Only’ Display Type Code, then two scripts in the same day would overlap at 00:00 AM. In this case I ended up creating a new database field for my Start Date and kept actual date on the form, receiving todaysDate() as the default value. This more or less prevents the service overlap problem. My new database field is named udf_rx_4_svc_start and is Date Only.

The end date on the script is using the expiration_date column and is also using the Display Type Code “Date Only”.

Before Save Code

The first task to accomplish is to prevent a user from saving the form with a backdate on it. For this I used the Before Save code property on the form. This code executes every time that the form is saved BUT because of the algorithm myEvolv uses to save form data, the udf_rx_4_svc_start column in the database will only be updated if the form field has been flagged as being modified. This is something that I was not able to figure out how to do in the Before Save code yet and is largely responsible for what feels like a more-complex-than-is-strictly-necessary-solution — more on that later.

First step is to get the value that is on the form field and turn it into a JavaScript date object.
var start = new Date(getFormElement('udf_rx_4_svc_start'));

Second step is to get today’s date and turn it into a JavaScript date object. todaysDate() is a myEvolv form function that you can use to get today’s date in a format suitable for placing in a myEvolv form field.
var today = new Date (todaysDate());

With that accomplished, we can compare the two date objects to see if the date on the form is previous to today’s date and if so, set the form field’s value to today’s date.
if(start <= today){{setFormElement('udf_rx_4_svc_start', todaysDate())}};

Note that the { and } brackets are doubled up in the conditional statement. This will prevent the “Not a Valid XSLT or XPath Function” error previously discussed here.

With this code in place, when a new Script for Service is entered or a draft Script for Service has it’s udf_rx_4_svc_start field modified, myEvolv will check to make sure that the start date is not not in the past and if it is, update the start date to today’s date. If the date is today’s date or a future date, it is left as it is.

Full Code Block

var start = new Date(getFormElement('udf_rx_4_svc_start'));
var today = new Date (todaysDate());
if(start <= today){{setFormElement('udf_rx_4_svc_start', todaysDate())}};

On Load Script

Just the Before Save Code alone would not be enough to prevent backdating. We still have the possibility of someone simply opening the draft and e-signing the form as in our scenario where the prescriber gets into myEvolv to e-sign scripts later than intended. Even if the form is edited in some way, if the Start Date is not touched, the Before Save code will execute but the column will not be flagged as modified and myEvolv will ignore it when updating the database. My approach here was to try to update the form as it loads upon viewing or editing so that myEvolv would see the column as modified when saving. I was unable to get the toolbar containing the ‘Save’ button to recongize the change, however, I was able to still get the desired effect another way.

The first thing to keep in mind with the On Load Script is that the form DOM has not loaded yet when this code runs. You can not therefore target the form field with JavaScript, update its value and focus/blur to make myEvolv notice a change to the value as we can with the On Click and On Change Scripts. Instead, you have to manipulate the Record XML Data before it gets loaded into the form.

The first step here is to determine whether the script had been signed. If it has been signed, it will have a non-null date_locked value. We check for this by using the myEvolv form function getDataValue() and then seeing if the form is being opened for viewing or editing.

var locked = getDataValue('event_log', 'event_log_id', keyValue, 'date_locked');
if(locked == '' && formXML.documentElement.getAttribute('formAction') == 'EDIT'){{
...
}}

This code gets the value of date_locked from the event_log table where the event_log_id is equal to keyValue which is a variable equal to the event log id of the current event you are looking at.

Then the code checks to see if there is a locked_date. If the locked date is blank AND the form is opened for editing, then it will execute the rest of the code. So basically, only perform a date manipulation if we are still working with a draft. If you leave this piece out then every time you look at a completed script for service in the future, myEvolv will overwrite the form field value for start date to be today’s date and you will be scratching your head.

Inside the ellipses we start the date manipulation. First we load the node for udf_rx_4_svc_start from the XML Record so that we can manipulate it.
node = formXML.documentElement.selectNodes("form_group/form_item [@column_name = 'udf_rx_4_svc_start']");
node = node[0];
This code returns an Array of all of the nodes in the XML documents with the column_name “udf_rx_svc_start”. There is only one but it is in an array so we load it into our variable directly on the next line.

Then we get the start date value and turn it into a JavaScript date object.
var start = new Date(node.text);

Then we do the same for today’s date.
var today = new Date(todaysDate());

Now we check to see if start date is before today’s date and if so, we will update the text of the node to be today’s date.

if(start < today){{
node.text = todaysDate();
node.setAttribute('modified', 'true');
...
}}

I also set the “modified” attribute to ‘true’ for this node. I don’t know if that makes a difference in this setup but I am including it since that is how my code is and it works.

If you leave the code as it is like this, when the form loads, if the start date is previous to today’s date, the value on the form will have been updated to today’s date AND the form field will be maroon like it is when a form field is changed. However, you will also notice that the “Save” button is nevertheless disabled and a user would be able to e-sign the service without being forced to hit save. And apparently, even though a “saving…” dialog pops up upon e-signing, the form is not saved. I tried a bunch of things to try to get the save button to enable and the e-sign button to disable but it is difficult since the form DOM is not loaded at the time that the On Load script runs. In the end, I decided to just call the save form function directly.

So where the ellipses above are, I put
SaveForm2();

The end result here is that when the form is opened for editing, if the start date is before today’s date, myEvolv will update the start date to be today’s date and then save. The users will see the form start to open and then abruptly close if the conditions are met. When they reopen it, they will find that today’s date has been updated to today’s date and they are free to e-sign.

Full Code Block

var locked = getDataValue('event_log', 'event_log_id', keyValue, 'date_locked');
if(locked == '' && formXML.documentElement.getAttribute('formAction') == 'EDIT'){{
node = formXML.documentElement.selectNodes("form_group/form_item [@column_name = 'udf_rx_4_svc_start']");
node = node[0];
var start = new Date(node.text);
var today = new Date(todaysDate());
if(start < today){{
node.text = todaysDate();
node.setAttribute('modified', 'true');
SaveForm2();
}}
}}

Bonus: After Save Code

Since the form is going to be auto-saving itself, I also added a snippet of code to the After Save Code that keeps the form from closing after save:
window.closeAfterSave = false;

myEvolv Sub Reports MEGAPOST

Last Updated: September 10th, 2016

Sub reports were one of the most confusing things to me when I started out with myEvolv. They represent one of the best ways by which you can pull data that is already in the system onto your event forms but they are also one of the parts of myEvolv that are frustratingly limited. Knowing how they work and their limitations can save you some headaches when you go about configuring forms.
This post will be an attempt to layout everything I know about sub reports in myEvolv. As with all MEGAPOSTS, I will update this post with new information as I come across is. If you have any additions, corrections or elucidations, please send them along!

Table of Contents
Use & Purpose
Limitations & Security Considerations
Sub Report Maintenance
Creating a New user Defined Sub Report
Customizing a Sub Report

Use & Purpose

Sub reports are used to pull data that is already in myEvolv onto forms. In the form designer, you can add a UDF Report to any form as a method of displaying relevant information from other areas of the system. Some basic examples of when you might use a sub report are to list a person’s active diagnoses, allergies or demographic information that is fairly static. You might also have sub reports that are more dynamic and pull in service notes for a date range based on fields on the form.

Limitations & Security Considerations

All sub reports in myEvolv are based on views that were created by Netsmart, therefore you cannot pull data from user defined fields into a subreport because your user-defined fields are not known by Netsmart and were not included in the select statement that generates the view. In other words, none of the views available for sub reports include any columns from an _x table, where your user defined columns live.

This turns out to be a very annoying limitation but one that you can sometimes get around if you don’t mind re-purposing Event Log fields. My post on How To: Filter Activity Type and Encounter With Picklists gets into this a little bit and I will post more about where I have used this in upcoming posts.

Another thing to keep in mind with subreports is that there is no security applied to the data that pulls in on the sub report besides the customization that you put into the report. It is therefore possible for users to see data for clients that they are not assigned to through sub reports. Be careful that you are only pulling in data that the end-user should be seeing when you use a sub report.

Sub Report Maintenance

sub-reports-nav-pane

There are two Formsets related to Sub Reports in the Setup module: Sub Reports – System and Sub Reports – User

Sub Report – System > System Sub Reports

This area will allow you to see all of the system sub reports that exist. These are the sub reports that are used on default system forms throughout the system. You cannot delete or create new system sub reports. You also cannot modify any of these sub reports and because of this, you also cannot see what additional Report Fields are available without creating a User Sub Report based on the same Data Source.

The Select Sub Reports picklist will show you the Report Name, Data Source Name, Remarks to explain the purpose of the sub report and a list of the Join Columns
select-sub-reports-picklist

Sub Report – User > User Sub Reports

This area is where you can view and edit user defined sub reports. The Select Sub Report picklist for this formset member will only show the Report Name and the Report Code, both of which are set by the user.
select-sub-reports-user-picklist

Creating a New User Defined Sub Report

When you create a user defined sub report, as when you create new user defined database fields, it is recommended that you use a prefix like ‘udr’ to distinguish it from system sub reports. The reason for this is avoiding name collisions in the event that Netsmart adds a new system sub report with the same name.

The trick with creating a new user defined sub report is finding a view that contains all of the columns that you would need for your sub report, again keeping in mind that you will not have access to anything in a user defined column. Since you cannot see all of the report fields available for each data source in the System Sub Reports area, you will either need to create a user defined sub report for each data source to see all of the columns available or if you can link to your database with Crystal Reports, you can check out all of the views to see what columns are included in each.

Customizing a Sub Report

User Report Name and User Report Code are editable so you can rename and recode your report as you like.
Remarks are useful for keeping notes about what the sub report is designed to do so I strongly using it.

SQL Code

sql-code

The SQL Code field allows you to add some customization to the SQL that is used to pull data into the subreport. From what I can tell, the SQL that you enter into this field executes as though it is the search condition of a WHERE clause in the SQL statement. This allows you to filter the results in a multitude of ways.

For example, a sub report related to services for a client would pull in all services for the client regardless of program so you may want to filter for a specific program. You can do that by using program_name = 'My Program' in the SQL Code box.

You might want to be more specific and select only services of a certain type so you could use event_name = 'My Service'.

You can create filters on any of the Report Fields available in the view and you can add complexity using AND and OR operators.

You can also use SQL Server functions. For example, if you want to get all of the services that have occurred within the last 3 months of today, you could use actual_date > DATEADD(MONTH, -3, GETDATE())

Report Fields

report-fields

This sub form allows you to customize the look of the sub report on the form and also allows you to do some more filtering of the data based on the parent form fields.

Column Name
The Column Name is used to select which columns from the data source will be used in the subreport. When you click the build button for this field, you will be able to see all of the columns that have been included in this view by Netsmart. These are all of the columns that you can include in the report. The picklist popup will show you the column name and the data type for the column. Many of the columns that are included in the views are uniqueidentifier data type. These are the GUIDs that are used for primary keys in myEvolv’s tables. These are not useful to be displayed but come into play if you want to filter data through a join.

Data Type
The Data Type allows you to display the data from the column in a different format. For the most part, you will want to display the data in your sub report using the same data type that the data is stored in. One place where this might be different is displaying a DateTime as Date Only if you do not wish to display the time.

Caption
The Caption allows you to determine the column header on the displayed sub report.

Field Order
The Field Order allows you to determine the order that the columns render in the sub report table.

Sorted Column
If this box is checked, the subreport will be sorted by this column in ascending order. If more than one column has this box checked in the subreport, the columns will be ordered in priority based on their Field Order.

Order is descending?
If this box is checked, the sort will be in descending order rather than ascending order for this column.

Is Visible?
If this checkbox is checked, the column will display in the sub report on the form.

Join Field
When this box is checked, the sub report will filter based on the value of this field on the parent form.
For example, if people_id is included in the sub report and used as a Join Field and this sub report is used on a form that has a people_id field on it, the sub report will only select rows from the view where the people_id‘s match, effectively filtering the sub report to display only data for the client that the form is for. people_id is a commonly used EventLog field on activities for people and is often configured to default to the value for the client whose record is selected.

Overwrite Form Field to Join
This field allows you to designate a different form field from the parent form to join on. If you simply check the Join Field checkbox, the sub report will look for a parent form field that matches the sub report form field. Instead, you can designate a different field here. As an example of where this might come into play, say you have a monthly summary event where the summary’s actual_date will be the month after that being summarized. The actual_date on the parent form will be June when you are summarizing May’s services. In order to filter the sub report to May’s notes, you will not be able to simply use actual_date as a Join Field since that would pull in June’s notes. Instead, you would add another date field to the summary (for example udf_summarized_date and then use it to overwrite the form field to join with the sub report’s actual_date.

Operator
The Operator allows you to choose a different operator to use with your join. By default, the operator is equal. You can use this to filter a sub report with a join on a date field using greater than or less than to get entries that occurred before or after a date field on the parent form.

We are using cookies on our website

Please confirm, if you accept our tracking cookies. You can also decline the tracking, so you can continue to visit our website without any data sent to third party services.