NPR report writers at MAGIC sites probably know that you can write code anywhere in a MAGIC report to put a file name into /ZFTP.TITLE and if the report is scheduled to Auto FTP, the file name created by the report code will be used instead of the default file name based on the report title.
The Client/Server scheduler offers download file naming options: “Replace (using a hardcoded path),” “Append (using a hardcoded path)” or “Unique (adding a timestamp to a hardcoded path).” This is often not sufficiently flexible to suit dynamic file naming needs. There is a KB article (38192) that describes a method to imbed a program call in the title of a report to force it directly to download, but it is cumbersome, and in 5.6 and 6.0 you cannot imbed a local macro in a report that is to be run from a menu unless the macro is in Z or MIS. This is because when the M-AT front end displays the report screen, it does not open the application until after the title is displayed (so your call to a program in the title will crash).
This month we will show an easier way to include a macro with your scheduled report that will allow you to build a dynamic file name with code, rather than being restricted to the options provided by the scheduler.
All you need to do is add a macro (written as a program) called “sched.report” to your report, and in it set the path into @t.MIS.RPT.SCHED.share.file[@t.MIS.RPT.SCHED.mnemonic].
The code looks like this:
What makes this a program is that the last expression (last line) is terminated with a semicolon. There is nothing special about using the variable EXIT as the last expression, that is just a convention in MAGIC programming to show that the program returns nothing, since the variable EXIT is nil (since it is not defined anywhere in the macro).
You might be interested in how we figured out this easier way. The trick is to look at the MEDITECH source code for the Report Scheduler programs to see if there is a way to control the filename from code in the report being run by the scheduler.
I went into a report macro (any report will do) and used the F(5) “Get” key in a macro and looked through the MIS DPM’s to find “MIS.RPT.SCHED” and then poked around (view only) in the three bkg programs to find the one that set up the download path for a scheduled report. The procedure is: MIS.RPT.SCHED.bkg.start.
Looking at the top of that procedure, I saw the scheduler would obligingly run any macro attached to the report called “sched.report,” provided that macro is written as a program. This would happen after the data from the MIS.RPT.SCHED dictionary was transferred from permanent to temporary (slash) variables, but before the report itself was run.
Further down in the report I could tell that if I set up my report schedule to “overwrite,” I could be sure that the background job program would just use whatever path was sitting in @t.share.file. Because my macro “sched.report” will get called after the @t.share.file is fetched from the schedule dictionary, but before the file is opened for report output, I can write a new value to @t.share.file and have that path be used instead.
In the scheduler dictionary, I set my report up as follows:
After the scheduler runs my report, we can see in the destination folder that the macro named the file:
A sample report has been added to our C/S report library: ADM.PAT.zcus.is.dynamic.filename
Search our report library for more Report Writing tips:http://www.iatric.com/Information/NPRReportLibrarySearch.aspx (search for fishbone – only 1 hit per platform and likely to stay that way).
You can find additional Report Writing Tips on our website athttp://www.iatric.com/Information/NPRTips.aspx, as well as information about our on-site Report Writer Training and Report Writing Services.
Read Joe's blog posts at MEDI-Talk.
Upcoming Report Writer Training Opportunities:
We are pleased to offer Report Writer training sessions at host sites. Details and a course description are available on our website athttp://www.iatric.com/Information/Classes.aspx.
|Salinas Valley Memorial HealthCare
|Report Designer for 6.x: Beginner/Intermediate||Philip Sherry||September
|Fee for Seat|
|Valley Presbyterian Hospital
|C/S NPR Report Writer: Intermediate/Advanced||Richard Serrano||September
|Fee for Seat|
To subscribe for email notifications for new classes, please follow this link:
For more information or to reserve a seat, please contact Karen Roemer at 978-805-3142 or email firstname.lastname@example.org.
(This article originally appeared in the August 2012 issue of Iatric Systems Updates! newsletter.)