Skip to main content

How To: Anchor Sub Report Data to the Parent Event

myEvolv sub reports can be very useful despite their limitations. Their most useful out-of-the-box application is in something like a face sheet, where you want to bring in the current information available, perhaps with some filtering.

In the first draft of some of our form designs, we used the current location sub report to display a client address. What we did not anticipate was that the address on previously entered notes would change when the individual’s address changed. We wanted that address to be locked on the form once it was saved. A few years later some of the Audit Snapshot functionality came out but that still didn’t work for us because of how audit snapshots worked. We needed a way to have the data on the sub report be based on the date of that event, not today’s date.

In subsequent years, I have figured out a few ways to accomplish this, depending on what columsn the sub report views provide and what we are trying to accomplish. I will try to lay out a few different methods below as I have time.

Method 1: Using a Join Column as a Parameter in the SQL Code

This method is good for when you want a sub report that will show you events within a time range from the parent event’s date. For example, you are creating a monthly report type event and need to list all of the progress notes from the 30 days prior to the monthly report date so that you can display them for the monthly report writers to summarize without running a separate report or opening them individually.

In this example, I will create a sub report using the physical_characteristics_view. I want to only show the physical characteristics from any and all events that occurred in the 30 days leading up to the event on which the sub report will display.

Configure Join Columns

When I first copy the system sub report to make my user sub report, the only join column is the people_id. If I display the sub report with this as the only join column, the subreport will show all of the physical characteristics in the system for all time for that person. If I save the event today, when I open it in a year, it will have an additional year’s worth of physical characteristics showing. The first thing we need to do is also use actual_date as a join field.

Check the box for Join Field? and select Less Than or Equal To for Operator.

With this step done, the subreport will now only ever show the physical characteristics for this client that have an actual_date prior to the actual date of the event it is being displayed on. Half of the problem is solved but this report does not cut off at 30 days prior– it would show all of the events prior, going back to the first one entered for this client.

Custom SQL Code

Values entered in the SQL Code field act as a WHERE clause in a SQL query. We already took care of filtering future events through a Less Than or Equal To join so now we just need to limit the past events in the WHERE clause.

I found that if you are using a field as a join field in the previous step, you can actually bring it in as a parameter value (though I have not used it enough to be sure this will hold for all cases, it seems to work here consistently). This allows us to use the same date value that we are using to filter on the join in our WHERE clause. We will combine it with the DATEADD function to go back 30 days and filter for those physical characteristics with an actual_date Greater Than or Equal To that date.

The first actual_date is the actual_date of events in the physical characteristics view. The @actual_date is a parameter that will get its value from the actual_date field on the parent form at the time the form is generated.

The DATEADD calculates thirty days prior to that parameter value and we are looking for anything that happened after that 30-days-ago-date and the parent event’s date.

actual_date >= DATEADD(day, -30, @actual_date)

More Methods to Come!

How To: Create an Events to Complete Subreport

EDIT 3/16/2018: Reader Jen G. pointed out that a staff member’s staff_id != people_id in all cases and therefore my approach would not always work for all staff. She proposed a different form to copy for this setup that will work 100% of the time so I have updated the post to reflect her proposed changes and fix my approach. Thank you, Jen!

This comes from a reader request. The goal was to create a subreport in the Agency > Staff & Security > Staff Information formset that would list the service events that a selected staff member had not fully completed. The subreport could be useful for supervisors to follow up on events that their supervisees needed to e-sign or otherwise complete, especially in the event where a staff member was transitioning out of the agency. The following is my proposed solution to that problem:

Step One: Create a User Sub Report

Navigate to Setup > User Tools > Sub Reports – User > User Sub Reports and create a new User Sub Report. Give the sub report whatever name and code you wish. For System Sub Report, select any report that has event_view as a Data Source Name. In my case, I chose the “Compass (Initial) Peer Delivered Services” report.

When you are selecting from this list, the only critical thing is the data source name. Everything else only speaks to how that particular report had been configured with the data source for that particular system report. It will tell you which columns were used to join and the remarks column will give you and idea of how it might be used “out of the box” but you can change all of those properties once you have the data source linked to your user sub report.

On your new sub report, change the following properties:

SQL Code: is_service_event = 1 AND is_locked = 0

This will filter the event log to only show events that are service event and only those that are not locked. The event_view has many columns in it that will allow you to customize this filtering to get exactly what you want to see. Some other options are: completed, is_amended, is_billed, is_deleted, is_e_signed, is_final

Report Fields: Pick any that you want to display. For my subreport, I wanted to show the client (full_name), the event (event_name), and the date of the event (actual_date).

The one that you need to have for sure is staff_id, which we will mark as a join column. In the Overwrite Form Field to Join, put some value (I used “staff”) and for the operator, choose “Equal”. Remember the Form Field to Join that you used for later. Below is a screenshot of my setup:

Step Two: Create Form

You don’t have to create a whole new form to house this subreport. You might choose to add the subreport to one of the already existing forms in the Staff Information formset. The important thing for this step is that the form you end up putting this subreport on MUST have the staff’s people_id staff_id on it. Maybe the form already has it on there or maybe you need to add it in the form of a variable. I will show you how to add it if it doesn’t already exist.

In my case, I am adding the subform to a custom version of the Personal Info formset member. So in form designer, under the Personal Information form family, I copied the Staff Personal Information Form. On my custom form, I hid all of the fields that I did not want users to see and I added the subreport that I created in part one. Now I need to make sure there is a staff_id named “staff” for the subreport to join on.

To do this, add a regular string variable to the form. Caption it whatever you want but give the variable name the same name as your used for your Overwrite Form Field to Join on the subreport created above. We need this variable to default in with the staff member you select’s staff_id so in the default value field, we will put the following code:

keyValue

Edit: Because I used a form from the Personal Information form family, the keyValue in this case will be a people_id and not a staff_id. Therefore it will only work right on those staff who have the same value for their staff_id as they do for their people_id and this is not always the case. If you copy a form from the Staff form family, you can simply use keyValue because it is the staff_id. But if you are copying a Personal Information form, use the following code to get the staff_id:

getDataValue('staff', 'people_id', keyValue, 'staff_id');

Here is a screenshot of my variable’s configuration:

Once you have confirmed that this field is pulling in a GUID, you can make this field invisible on the form.

Step Three: Create a New Formset Member

With your new form created, you can now associate it with a new formset member so that you can display it for users.

Navigate to Setup > User Tools > Formset Maintenance > FormSet Members and select the Staff Information Formset from the Agency module.

Create a new formset member, name it what you’d like and then select the Personal Information form Family and your new form as the Default Form. Make sure Is Active is checked and then save. Remember to go through the Navigation scheme setup and turn on the new formset for the users who will need access.

The Final Product

With everything setup above, you can navigate to your new formset member and select a staff member. Your form variable should get a default value of the staff you selected’s staff_id and your sub report should be joining on the that staff_id, thereby filtering the event_view to that staff member’s events. Your SQL Code statement on the user sub report will further filter the event_view to just those you are interested in seeing. In our case, the service events that are not locked.

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.