WANT the MEDITECH Reports BLOG via EMAIL?

Your email:

About MEDITECH Reports

MEDITECH Reports is an online reference for NPR Report Writing and not affiliated with MEDITECH, Inc @ http://meditech.com. To learn more about NPR report development using the Meditech Report Writer read more here.

View John Sharpe's profile on LinkedInI'm your host, John Sharpe, a MEDITECH Report Writing Consultant in Spokane, WA. More about me.


Email John

Follow Comstock Software on Twitter 

Sign up for the MEDITECH Reports Blog; details to attend MEDITECH workshops are sent out 1 week in advance to all MEDITECH Report blog subscribers.

These MEDITECH Workshops are sponsored by Donna Carroll at the MEDITECH Community Bulletin

MEDITECH NPR & RW RESOURCES:

Ascii Table: For NPR Report Writer
Loop Builder: For NPR Macros
Key Codes: For CDS Attributes
List Builder: For NPR Macros
MT Report Names: For NPR Reports
MT Structure Viewer: For Physicals
Strings: Format & Sort

MEDITECH Reports

Current Articles | RSS Feed RSS Feed

Buffer Overflow in the MEDITECH NPR Report Writer


For months - this bug ran undetected. One day the right conditions allowed it to crash the report.


In this case, /PROC[SU,6] was printed in a custom field:

xx.proc.6
DAT=FREE
LEN=40
VAL=/PROC[SU,6]

The vendor, who'd requested the extract, didn't need data beyond procedure 5 and requested that any remaining data reported in field xx.proc.6. The values in xx.proc.6 would likely be used for manual review if needed. The field only reported the value to a length of 40 characters.

As you know, MEDITECH variables on the Client Server & Magic platforms are limited to 255 characters. However, this code allowed more than 255 characters to be assigned to a variable (/PROC[SU,6]): /PROC[SU,6]_", "_@actual.op^/PROC[SU,6].

To resolve this overflow, the IF statement can be modified to stop processing when the length of the existing variable (/PROC[SU,6]) and field (@actual.op) will be greater than 255 characters when strung together:

IF{L(/PROC[SU,6]_", "_@actual.op)>255 0^/CONTINUE; ...

By implementing a condition based on the value /CONTINUE; the variable /PROC[SU,6] will never contain more than 255 characters. Now our DO{@PROC.NXT stops; this prevents inaccurate reporting if the next value for @actual.op is short enough to print in a field of 40 characters.

PROC.NXT
(/CONTINUE=1)&(@Next(actual.op.urn))

PROCEDURES
""^actual.op.urn,1^/CONTINUE,
DO{@PROC.NXT IF{actual.op.urn<6 @actual.op^/PROC[SU,actual.op.urn];
IF{L(/PROC[SU,6]_", "_@actual.op)>255 0^/CONTINUE;
/PROC[SU,6] /PROC[SU,6]_", "_@actual.op^/PROC[SU,6];
@actual.op^/PROC[SU,6]}}},
IF{/CONTINUE=0 (/PROC[SU,6]_", "_@actual.op):40TL^/PROC[SU,6]}

When you've inherited a report from another report writer, it is tempting to re-design and re-write the report from scratch. There's a saying in the programmer / developer world that goes something like this: if you can come back a year from now and review code you wrote today ... and not want to change anything, you're an expert.

Question: What could be more important than writing expert code in every report you work on?

Answer: Keeping your time focused on those reports that most 1) improve patient outcomes OR 2) contribute to the bottom line.

Have questions? Need answers? Join some of the smartest MEDITECH people in the industry at the Meditech Knowledge Exchange

 

 


Implementing Parameters NPR Macros (CS)


Ever wished you could use parameters in MEDITECH NPR sub-routines? For now - here's the implementation below.

{@FLD.NO,"A"}^@SEND.DATA

SEND.DATA
{/FIELD,/TXT},
/FIELDS[/REC.TYPE,/FIELD]|1_"TL"^SIZE,
/TXT:SIZE^@PRINTER

FLD.NO
/FLD+1^/FLD

Keep an eye on the MEDITECH Community Bulletin Tips & Tricks in November; I'll be writing about why this makes your life, as an NPR Report Writer, easier.

CS NPR - Overwrite Existing File?




Calling a macro from the report title, like the one below, will suppress the 'Overwrite Existing File' message in a Client Server NPR Report.

Report Title: "_%(APP)DPM..zcus.report.name.M..start(0)_"

[start macro]
"d:\test.txt"^Z.c.cust.rw.download.path,
%Z.on.device("","",DEV,{1,1}),
"Report Title";



If you're using Summit's CS Print Manager; bookmark this for later, you'll be glad you did.

[Please ignore this information posted earlier in the day; it does not work.]

This combination of FOOTNOTES disables the 'Overwrite Existing File' message; but leaves the 'End of Report' message.

AL START 1^/(.S).QUIET
AL CLOSE.UP ""^/(.S).QUIET


Use Diff Merge to Compare / Validate MEDITECH Reports


From my latest MEDITECH Community Bulletin column: "Manually comparing 2 reports is hard on the eyes and tedious work. Like most IT workers, you know there must be an easier way. And, you're right" ...


Printing From a MEDITECH NPR Macro (CS)


Do you print your records in NPR Downloads from a macro? If so, the following may be of interest to you.

When printing records (I(/LINE)N^!) from a macro to your destination file, your macro should call the new page program (/R.NEW.PAGE.PGM) on a regular basis. If your file is small (under 10,000 records OR 1MB) you will probably be fine without calling the new page program.

If your file is large, the MEDITECH CS Client could slow to a crawl and may never complete. Because the records are held in memory, they are only released to the file when your report completes. Calling [/R.NEW.PAGE.PGM](0) releases records from memory to the print prefix (in this case a file) which allows the report to perform as if MEDITECH NPR were handling the printing.

To implement, drop this little routine below named 'NEW.PAGE' in where ever you send a new line in your macro:

NEW.PAGE
IF{/R.LL-1^/R.LL<1 [/R.NEW.PAGE.PGM](0)}

Note: Thank you Mitch Lawrence @ Christus Health for pointing out that the Page Parameters on the NPR General Tab will affect how many records will be accumulated before records are released.

MeditechPageParameters


DiffMerge: Comparing Object & Source Code


If you download NPR source & object code like I do, you probably want to quickly find the difference between one version and another (say a backup copy). I have never liked any of the text editor compare utilities out there. I know a lot of programmers find them extremely useful; but I never have found them to be intuitively useful.

I've been reading Eric Sink's blog on the Business of Software for about 3 years; so recently when his company tackled the file / folder comparison problem I noticed. The product is free and its called Diff Merge.



Give it a try, I think you'll like it.


MEDITECH Find Replace


I recently had a vendor request the comma "," as the delimiter for an NPR download. I prefer to use a # or | for the delimiter as they are unlikely to surface in normal data entry by end users.

However, I quickly used the following code to reformat patient name in a custom field:

^X,DO{X#(L(X,",")^P) (X$P)_" "_(X%P)^X},X

As a result, "NPR, REPORT WRITER" prints as "NPR REPORT WRITER" for the full name.
Here's the custom field:

DAT=FREE
JFY=L
LEN=80
VAL=IF{@cd.response["PAYER.NAME"]^X,DO{X#(L(X,",")^P) (X$P)_" "_(X%P)^X},X}


Multiples In Downloads - NPR Report Writer


I like to use the # sign in Downloads where free text will be printed. Its common practice to use a comma as the delimiter; but that can be a problem if a field like some.description has a comma you weren't expecting.

The particular Download I'm working with today has 20 fields on the picture. The last 4 fields are multiples. I've decided to let the NPR Report Writer handle looping thru the multiples in this scenario.





When I printed the Download, NPR put the multiples from the end of the first row at the wrong place in the following lines. The first 2 columns of my spreadsheet looked like this. The columns were not lining up properly in Excel. This was because there are no other fields on the second report detail line.

ACCOUNT TOTAL CHG
1223456 1248.3
162.9 ANOTHER-HMO
276.1

I decided to use an ECB line attribute on the second detail line to correct the problem:

ECB=0^Q,DO{Q<16 Q+1^Q,(D(34)_D(34)_D(35))^!},


Opening this Download with Excel and Formatting Text to Columns on the # DELIMITER allows Excel sees the data as hoped.






Now columns 17 & 18 line up perfectly:

DIAG INSURANCE
310.2 ANOTHER-HMO
162.9 INSURANCE-NO2
276.1


reat Text Editors, Every Report Writer Needs One


Most programmers I know, pride themselves on being well versed in a good text editor. I've been using TextPad for the past 5 years. Once you become skilled in a good Text Editor, you'll find its an extension of you.

So what does this have to do with NPR Report Writing?
- sorting and manipulating NPR downloads
- formatting information to include in an email
- building lists or arrays for a macro
- searching NPR object & source code

Superman wouldn't fly without his cape; and you shouldn't write reports without a good text editor. Find your favorite Text Editor here.


Defaulting the Download Path - CS


To default the file path for your MEDITECH Client Server Download Path:

- set select field to: Z.cust.rw.download.path
- set operator to: IG
- set prompt to: Report Path
- set value to: c:\downloads\download.txt
- variable is: /ZDOWN.PATH


.: This applies to the NPR Report Writer :.


All Posts