Blogs Home
Monday, August 30, 2010 3:45 PM

Syntax Checker Issues (MAGIC or Client/Server)

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

If you copy a programmer’s NPR report (a MEDITECH standard report) into a customer R/W version (if the “INIT REPORT FROM STD” will cooperate) or if you make your own version and then copy the macros from the standard report into your own versions, there are often syntax violations such as:

 

Syntax Errors

The MEDITECH Customer Report Writer translator includes a check of source code for certain strings that could (although they may not) indicate that your code writes to the database or writes to certain structures that MEDITECH prefers be left alone. The checking is not perfect, and when you copy a standard macro, the coding often triggers the syntax checker and you cannot file the macro and proceed with programming the changes you want to make to the standard report until you eliminate the “violations.” The MEDITECH code you copied does not usually actually write to the database (a few standard reports do log activity or flag a report as printed but those are unusual exceptions). Typically, the MEDITECH programmers have just done programming in a style that triggers the Customer R/W syntax checker.

Additionally, a recent change to the translator checks object code for syntax violations, eliminating the possibility of using sub-macros in a way to get around syntax checker issues. When this checker is triggered, the translator will say “expunging object code” and your report will crash if run without a fix to get your macro code to successfully translate. These types of violations are not included in the “syntax checker” report discussed in this tip, but the error message will show the line of code as it is detected so you will have less trouble finding the spot to change.

Unfortunately, the checker only reports one error per filing attempt, and does not show you the line of code where the error occurred. It is possible, but tedious, to try to pick these out by eye, but sometimes they are difficult to find and you would need to resort to deleting more and more of the copied source code to narrow down to the line of code triggering the checker.

Of course, with some NPR programming, there is a better way.

We have a report in NPR.REP called NPR.REP.zcus.is.rw.syntax.review.updated (MAGIC version) or NPR.REP.zcus.is (C/S version) that will list all the syntax violations and the line of code in one easy step.

The “updated” version for MAGIC has a change which fixes a problem with the lookup on the macro due to a MEDITECH change to the id program since an original version was written as part of our MUSE tips and tricks from 2005. You enter the name of your report (lookup available) and then identify the macro to check (lookup also available of the report’s macros):

Review Report Macro Syntax

View Temp

How do you fix the syntax violations? Here are some general methods:

For @Kill or K or $K, the MEDITECH standard report was most likely cleaning up some temp structure, and you can substitute a DO loop as follows:

K(/SOME.LIST) or @Kill(/SOME.LIST) should be replaced by DO{>/SOME.LIST[SUB]^SUB “”^/SOME.LIST[SUB]}

The > syntax will loop thru all levels of a structure and by looping this way and writing “” to / you will do exactly the same thing that the Kill did in MEDITECH's code, except it runs a bit more slowly.

The syntax checker will let you write to / except for /.

For DO{@Next(@ event.date) The syntax checker (MAGIC only is fooled in this way) thinks that you are going to do ^@, but since @ event.date translates as a subscript, you really are not.

Just remove the @ signs of the subscripts and the syntax checker will be happy.

For ^/. “not allowed!”, just put the structure you want to write to in a variable, like so:

“.PHA.SITE”^XXX,

“MAIN”^/[XXX]

If you need to call a fragment report in PHA or LAB, you sometimes need to specify a site or the fragment will not work. While the syntax checker programmers at MEDITECH are busy trying to stop you, the NPR Report Writer group (for years) has been showing you how to get around the syntax checker so your fragments will work.

For the @Cursor.on and @ Cursor.off commands, replace with D(14,14)^# for @ Cursor.on and D(14,0)^# for @ Cursor.off. The NPR translator macros write to /.P in some fashion and that is why the syntax checker will no longer let you use them as ^/.P would be a syntax violation.

We hope you find this utility program and these tips on dealing with “syntax violations” useful. You can find the syntax checker utility report in our report library.

You can find additional NPR Tips on our website at http://www.iatric.com/information/npr-tips.asp, 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.

Upcoming NPR Training Opportunities:

We are pleased to offer NPR Report Writer training sessions at host sites this fall. Details and a course description are available on our website at http//www.iatric.com/npr/class-schedule.asp.

Location Level Instructor Date Cost
John Muir Health
1400 Treat Blvd.
Walnut Creek, CA
(Oakland area)
Beginner/Intermediate Richard Serrano Sept. 22-24, 2010 $750
Children's Specialized Hospital
New Brunswick, NJ
Beginner/Intermediate Joe Cocuzzo Oct. 20-22, 2010 $750

To subscribe for email notifications for new classes, please follow this link: http://www.iatric.com/npr/class-schedule.asp.