Blogs Home
Thursday, October 27, 2011 3:30 PM

NPR Tip: Overcoming the 255 Character Limit to Browse to a Long URL from MAGIC

Written by Joe Cocuzzo, Senior VP of Report Writing Services - iatricSystems

The MAGIC (and Client/Server) 255 character limit makes it difficult to handle a value that exceeds this length. A reasonably common example is a URL that exceeds 255 characters.

You can use the @Call.windows or @Shell.execute macro in C/S or the %Z.link.to.shell Z program in MAGIC to pass a URL to the C/S client or MT Report Workstation and cause the PC to use the default browser to go to a website. How can you handle a case where the URL is longer than 255 characters?

There are browser add-ons (tinyurl.com) that allow you to map a small private URL to some longer URL, but this won’t work for cases where the information is dynamic, such as sending patient information to Thomson-Reuters/Micromedex to print discharge instructions. Also, a browser add-on requires installation at each PC.

One method I have used in the past is to write out a VB script file to the local PC and execute it. Security or user access restrictions on the local PC can thwart this approach.

Another method I showed in our MUSE 2011 NPR Tips and Tricks session was to write out a small “redirect” page to the PC and then use either @Shell.execute (C/S) or %Z.link.to.shell (Magic) to cause your browser to use the nice short URL of that page to then be re-directed to the true URL you need to use.

Details for this approach can be found on our website at: http://www.iatric.com/MUSE2011 in the zip file here:http://www.iatric.com/download/MUSE/MUSE2011/MUSE2011_Tips_and_Tricks.zip

For the MAGIC platform, the %Z.link.to.shell program has a new(ish) option that allows you to pass a path or URL that exceeds 255 by loading it into an array and then passing a pointer to the array to the Z program, rather than passing the URL itself.

This involves calling the Z program and passing values to it by reference instead of by value. Those of you who have taken a programming class in just about any language learned how to pass values to a procedure or function by reference. This is an essential technique for any situation in which you do not want to make a copy of some large structure or long variable and instead want to send a program a reference to an existing structure so the program works on the exact same thing, not on a copy passed by value.

In MAGIC (or C/S), you use the “name of” operator ⇒ to pass a reference to a structure, rather than its value. (The ⇒ prints as the caret ^ in a program listing, but shows up as a right pointing arrow on your Workstation screen). This is the same character as the “goes to” or “assignment” operator, but when used in the “name of” syntax, it serves as a way to pass a reference or “pointer” to a structure in a program call as one of the program arguments.

Let’s see how to load a long URL into an array and pass it to the Z.link.to.shell utility. We will create a report that has a program call in the title, and suppress the print on prompt and all message displays, so we can have a report that provides a link to the URL from a MEDITECH menu, without a confusing “Print On” prompt or “End of Report” message.

Step one is to write a dummy report. Everything happens in the title program call, so you don’t need anything in the index or detail segment fields on page 1:

NPR Tip 1 image

In the “d” macro, you put a 1 into /Z.SCHED.LOG (this suppresses the “Print On:” prompt) and put a 1 into /R.NO.PRT.MSGS (this gets rid of the “End of Report” message).

Then you build a list in /URL[n] (where n is an integer counter that goes 1,2,3..) of the data needed to be used as the path, URL, or command line.

NPR Tip 2 image

If you are an especially sharp-eyed reader, you might notice that the URL example is only 139 characters in length, but using a list /URL[n] structure allows us to build a URL of any length.

When the report runs, you go directly to the Gaylord Hotel URL in the default browser:

NPR Tip 3 image

This example magic report MIS.USER.zcus.is.eupdate.long.url has been posted to our report library: http://www.iatric.com/information/NPRReportLibrarySearch.aspx.

You can find additional NPR Tips on our website athttp://www.iatric.com/Information/NPRTips.aspx, as well as information about our on-site NPR Report Writer Training and NPR Report Writing Services.

Read Joe's blog posts at MEDI-Talk

To subscribe for email notifications for new classes, please follow this link:
http://www.iatric.com/Information/Classes.aspx

For more information or to reserve a seat, please contact our NPR report writing team at reportwriting@iatric.com.

(This article originally appeared in the October 2011 issue of Iatric Systems’ Updates! newsletter.)