meditech report writing group

About MEDITECH Reports

 

View John Sharpe's profile on LinkedInI'm your host, John Sharpe, a MEDITECH Consultant living in Spokane, WA. Read more ...

Connect ...

Expand your network by connecting on these social media sites:

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

HIT Topics

MEDITECH Reports

Current Articles | RSS Feed RSS Feed

Multiple Forms

 

I received this tip over the MEDITECH-L from Robert White & can't wait to try it:


Link 2 forms/reports together.
You can try calling %Z.printer("NPR",R) - where R is the report name(for example "ADM.PAT.zcus.adm.form") - for each report you are running. This should format the report based on how you set it up.

Troubleshooting for Missing Data on an NPR Report

 

3 things to check when you aren't getting data FROM where you see it on the screen TO where you want it to be, on your NPR report:

1) No data exists where you are looking: a) data not entered in the first place OR b) data entered, but not where you think it was/should be.

2) You don't have all the subscripts populated to access the data: a) your report isn't processing the right segment, so your subscripts aren't populated OR b) the data you are trying to access is a multiple and you don't have the necessary code in place to get down to where the data lives (this is really the same thing as reason 2.a).

3) You are looking in the wrong structure: a) you think MEDITECH stores the data in one place (SCH.PAT.cd.response) but it stores the data in another location (SCH.PAT.pacu.cd.response).

You will find these 3 things to be invaluable in your troubleshooting process.

[MEDITECH-L] Evaluate if a Pharmacy Fragment Returns a Value

 

=== QUESTION ===
I have a MEDITECH report that calls a Pharmacy fragment report in a LC on HK7.  Sometimes the Fragment returns a value and sometimes not.  On my main report I want to count how many times a value is returned and how many times not. Here is the LC from the main report:

LC=@acct.number.display%5E/R.FRAG.ARG.1,
LC=%Z.rw.fragment("PHA.RX.zcus.sh.R","PHA.JOB"),1

Any suggestions ???

Terry

=== ANSWER ===
As you know, NPR fragments do not clean up the /R.FRAG.VAL.xx variables after fragments run. Which is why the /R.FRAG.VAL.xx structures are used to return your data. Here is one strategy that might work for you:

Set this value: 0^/R.FRAG.VAL.RESULT at the beginning of the fragment: at the top of your macro or another suitable place like a line attribute, footnote or custom field.

If the fragment has data to return, set this value: 1^/R.FRAG.VAL.RESULT near the end of the fragment: near the bottom of the macro that gets your data or another suitable place like a line attribute, footnote or custom field.

Extend your HK7 line check to calculate the total:

LC=@acct.number.display%5E/R.FRAG.ARG.1,
LC=%Z.rw.fragment("PHA.RX.zcus.sh.R","PHA.JOB"),
LC=/R.FRAG.VAL.RESULT+/HK7.TOTAL^/HK7.TOTAL,1

Depending on your report's setup; you could define an xx.total field and set VAL=/HL7.TOTAL.

John

Double T NPR Viewer

 

I recommend the TT NPR Viewer: http://www.thomast357.com/magic_nprv.htm


I use the 'Double T NPR Viewer' to download an NPR report and then only archive useful macro snippets in a few seconds instead of archiving the entire report.

FD 9 vs FD 11

 

I was working in CS 55 this morning and I wondered how my browser (IE7) and Excel (2007) would handle a horizontal tab (FD 9) vs a vertical tab (FD 11). If you're not familiar with FD, FD is the Footnote Attribute used to Delimit Fields in your NPR Downloads.

FD 9: "SOME.DATA" "10/08/07"

FD 11: "SOME.DATA""09/27/07"

Here's the observable difference in MS Excel 2007:

That clears it up, I'll be using FD 9, the horizontal tab to delimit this NPR Download. Labels:

Return Day (Monday) from Date (11/19/2007)

 

Today, we'll format a date (11/19/2007) into readable week day format (Monday) using Meditech's Magic programming language for the Client Server (CS) & Magic platforms.

Put this into a start macro:

"MONDAY"^/DAY^/DAY[/DAY:3T],
"TUESDAY"^/DAY^/DAY[/DAY:3T],
"WEDNESDAY"^/DAY^/DAY[/DAY:3T],
"THURSDAY"^/DAY^/DAY[/DAY:3T],
"FRIDAY"^/DAY^/DAY[/DAY:3T],
"SATURDAY"^/DAY^/DAY[/DAY:3T],
"SUNDAY"^/DAY^/DAY[/DAY:3T]

Call the start macro from the footnote: AL START start

When you run the report, this is what your array looks like in memory:

/DAY["MON"] = "MONDAY"
/DAY["TUE"] = "TUESDAY"
/DAY["WED"] = "WEDNESDAY"
/DAY["THU"] = "THURSDAY"
/DAY["FRI"] = "FRIDAY"
/DAY["SAT"] = "SATURDAY"
/DAY["SUN"] = "SUNDAY"

Put this in your xx.field which will be on the report picture to return a day from a date:

DAT=FREE
JFY=L
LEN=10
VAL=/DAY[%Z.day.out(%Z.day.from.date(@date))]

Walking thru the code:
- @date is returned from the SCH module I'm working in today as: 10/22/07.
- %Z.day.from.date(@date) OR %Z.day.from.date("10/22/07") returns: 2.
- %Z.day.out(%Z.day.from.date(@date)) OR %Z.day.from.date("2") returns: MON.
- /DAY[%Z.day.out(%Z.day.from.date(@date))] OR /DAY["MON"] returns: MONDAY.

You can change the format to match your business needs. Some reports look better with the day formatted as Monday. In that case, your start macro /DAY array would look more like this:

"MON"^/DAY.SUB,"Monday"^/DAY[/DAY.SUB],
"TUE"^/DAY.SUB,"Tuesday"^/DAY[/DAY.SUB],
"WED"^/DAY.SUB,"Wednesday"^/DAY[/DAY.SUB],
"THU"^/DAY.SUB,"Thursday"^/DAY[/DAY.SUB],
"FRI"^/DAY.SUB,"Friday"^/DAY[/DAY.SUB],
"SAT"^/DAY.SUB,"Saturday"^/DAY[/DAY.SUB],
"SUN"^/DAY.SUB,"Sunday"^/DAY[/DAY.SUB]

Your structure now looks like this:

/DAY["MON"] = "Monday"
/DAY["TUE"] = "Tuesday"
/DAY["WED"] = "Wednesday"
/DAY["THU"] = "Thursday"
/DAY["FRI"] = "Friday"
/DAY["SAT"] = "Saturday"
/DAY["SUN"] = "Sunday"

In review, we've formatted a date "11/19/2007" to print as a day in 2 formats "MONDAY" & "Monday". And we've done it only coding our xx.field once!


Happy Monday & Happy Thanksgiving!

Elegant Reader Follow Up to This Morning's Post

 

An anonymous reader posted this elegant tip:

",Sun,Mon,Tues,Wednes,Thurs,Fri,Satur"#(%Z.day.from.date(@date)_",")_"day"

NPR Reports - No Detail Segment

 

Check out these snapshots from page 1 of an NPR report I was modifying today. No detail segment, just an index. I checked the object code and the report literally does a DO Loop right thru the ?BZC structure.



At times, I've coded reports with no Detail Segment & no Index File. But until just now, I had no idea the Detail Segment wasn't required when using an Index File.

De-Duplicating Detail Using Sort Keys

 

At times you'll find you need your NPR report to use a segment with multiples; but not print the multiples.

Lets say you are using the following index for the BAR.PAT.bar.acct detail segment:

bar.acct.insurance.index ?BZIN[ggm,bzIO,bz]
ggm = insurance, bzIO = insurance.order, bz = account

?BZIN["ABC",1,ACCT1]
?BZIN["DEF",2,ACCT1]
?BZIN["JIK",3,ACCT1]
?BZIN["LMN",4,ACCT1]

You want to only print accounts for a particular list of insurance mnemonics.

1^/INSURANCE.LIST["ABC"],
1^/INSURANCE.LIST["DEF"],
1^/INSURANCE.LIST["JIK"],
1^/INSURANCE.LIST["LMN"],

Your select is insurance LI /INSURANCE.LIST.

Your report's output will have more than one account's detail due to the index having some accounts associated with more than one insurance.

To prevent duplicates, I like to set a sort KEY Header on NPR Page 2 for account or whatever, I'm trying to deduplicate. This puts an HKx line on the report picture. Since I don't actually want a blank line on my report every time the sort changes; I use the following LC line attribute on the HKx:

LC=/DONE[@account]+1^/DONE[@account],""

That "" or nil as it is called keeps the line from printing. While the /DONE[@account]+1^/DONE[@account] part tallies up the times we've processed the account.

Next you'll want a LC attribute on your detail line(s):

LC=IF{/DONE[@account]>1 "";1}

The purpose of a line check is to print report lines based on a condition. Our condition is /DONE[@account] less than 1. In plain english, if we've seen the account once before don't print it.

NPR - CHEATING 101

 

Food for thought: NPR Report Writing is an Open Book Exam

Pareto's Law says that 80% of the effects are caused by 20% of the causes. I'd like to apply this law to NPR Report Writers and say that only 20% of the NPR report writers refer to the MEDITECH NPR Data Definitions on a regular basis. They accomplish what they set out to do in a timely manner. It would seem as if they cheat. The kind of cheating I'm referring to is more like: trickery OR unfair advantage.

Of course, the best NPR programmers really don't cheat; they DO realize that writing a report is an open book exam. I suggest that 80% of the people writing NPR Reports don't use the best resource available to them: the MEDITECH Online Data Definitions. You'll notice that experienced NPR Report Writers either have them memorized or refer to them on a constant basis. I sarcastically call this cheating; its really not cheating. Its just such an obvious thing to do; that a lot of people overlook it.

Next time you are stuck on an NPR report; try referring to MEDITECH Online Data Definitions and see if that doesn't unstick you.

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}

MEDITECH Pharmacy ( PHA ) Rules & Line Checks

 

I was working with a friend on a MEDITECH PHA rule today when it hit me. Pharmacy Rules and NPR Line Checks are very similiar.

You can use a Line Check (LC) to print or not print a report line. But LCs are often used to just run a macro or a piece of code and still print the report line. When the LC returns NIL as "", the line will not print. Any value other than NIL "" will allow it to print. Typically programmers return 1 to allow the line to print.

Often the LC will look like this when you just want to run some code, and have the line print:

LC=%APP.DPM.zcus.report.name.M.macro.name(""),1

A PHA rule can be used in the same way when you don't actually want to run the rule in a traditional sense. If your rule uses a keyword that runs code or a macro it must evaluate to a non-nil value for the drug order to go thru. If you just want to run some code and not affect the outcome of the order; then end your code with ,1 which returns the non-nil value. As you can see this is very similiar to the LC example from NPR above.

DPMS not Available in NPR

 

This is an MIS User Access Issue. To correct it, navigate to page 5 of the MIS.USER dictionary. Add ALL or just the DPMS you want..

Calling Another Report's Macro from a FootNote

 

I have always called macros in other reports as a program; it wasn't until I was this in a Magic report that I realized you could call it this way:

AL CLOSE.UP RADRW.REPORT.print.report.M.cleanup.for.report

NPR Report Writer brings this code into the report as it is translated. Interesting! If the code in the cleanup.for.report were changed, this report would not be affected until translated again.

Call New Page - Magic NPR

 

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

That line of code is the code NPR uses to manage page length based on the Lines/Page & Page Size parameters on Screen 1 of your NPR report. The /.LL variable is a slash variable used to tell the Report Writer how many LINES are LEFT. I call it the LINES.LEFT variable. From NPR you can access it as @.lines.left which translates to /.LL. @.line translates to IF{/.LL-1^/.LL<1 %[/R.NEW.PAGE.PGM](0)}.

If you want NPR to print a new page at a particular point in your report; set /.LL to 0:

0^/.LL

While you might be tempted to assign 0 to @.lines.left or .lines.left; you cannot. The NPR syntax checker won't allow you to assign values to something starting with an @ prefix. With a normal field like ADM.PAT.patient, you could take the @ symbol off and assign "A1234"^ADM.PAT.patient and that would translate to "A1234"^aa. Which is why you need to assign the value of 0 to /.LL instead of the .lines.left macro.

When /.LL is less than 1; we just set it to 0, the Report Writer calls the new page program:

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

Either way the /.LL will be decremented by one until /.LL = 0.

All Posts
Medical Information Technology, Inc., commonly known as MEDITECH, is a Massachusetts-based software and service company selling information systems, which are installed in health care organizations throughout the world. Comstock Software, Inc is an independent and impartial consulting firm.