Mistakes break us out of our usual workflow and given a little curiosity, help us discover things we might not take time to learn on our own. When you're new to something, everything you see, looks like an option. What's this do? How's this work?
As we become proficient at our work, our brains develop routines that we execute without consciously thinking about each step. Without mistakes and deliberate practice, it is easy to develop tunnel vision.
Today I found the Recent and Frequent buttons on the right of my MEDITECH NPR Desktop. The buttons were there all along, but until I accidentally clicked the wrong button, I never saw them. Some days I seek out deliberate practice, on other days my mistakes create unexpected learning opportunities.

Sidebar: if you've used Windows XP, these features remind me of the personalized Start Menu. Frequently accessed application menu items float to the top of the Frequently Used list. Recently accessed menu items, appear in the Most Recent list. Recommend this time saving feature to your MEDITECH physicians and clinicians, you know the ones, who email you about how many mouse clicks it takes to do something.

It has been said, "whoever makes the most mistakes wins". While I can't recommend making mistakes as a strategy, I can say that learning from our mistakes is underrated. Learn more here in Eric's amazing post, titled: Career Calculus.

MEDITECH reports often contain business rules for your organization. When changes are requested, they are usually needed right away. To implement changes, report writers have to understand what a report does.
Business rules are typically expressed in code, known as NPR macros. Macros are used to break up code into logical groups. Common practice has been to implement code as inline macros often using the @Macro syntax or a footnote.
Business rules while often straightforward to implement, can be challenging to understand once converted to code. Understanding existing business logic is required before you can make changes; it follows that organized, de-duplicated code is faster to read, understand and therefore to change.
When you implement an inline macro, your ability to reuse code is limited. Macros implemented as programs differ from inline macros in 3 ways, they: 1) accept parameters (a,b,c), 2) end in a semi-colon <;>, and 3) code is not compiled into the report.
Parameters facilitate fewer lines of code by making it easy to organize and reuse groups of subroutines, also referred to as blocks of code. Code reuse equals less code. Less code means fewer lines of code to understand, before adding or changing report functionality.
@Macro provides a way to separate code in a report without an update to macro calls when the report's name changes. One downside to this approach is that you have to Translate the report, each time a change is made to a macro. If the macro or report is a lengthy one, report translation can take a long time.
Instead of for example, @Macro(detail), you can implement your detail macro as a program and call it dynamically. To implement an inline macro as a program:
1) identify and define your parameters in the macro A^urn for example
2) terminate the macro with a semi-colon <;>
3) call the macro as a program, only dynamically like this:
%(ADM)["PAT.."_(c.procedure.name)_".M..detail"](urn)
Use the dynamic macro technique and your reports will be better organized, clear and adaptable to changing business rules.
NOTE: for those using CS 5.6 and greater, the c.procedure.name variable may not be available. Please try this approach instead.
@REPORT.NAME^/REPORT.NAME,
%(NUR)[/REPORT.NAME_".M..init"](0)
REPORT.NAME
/R.NEW.PAGE.PGM^/REPORT.NAME,
/REPORT.NAME%L(/REPORT.NAME,".zcus")^/REPORT.NAME,
"PC.WORK.."_/REPORT.NAME^/REPORT.NAME,
/REPORT.NAME$(L(/REPORT.NAME)-3)^/REPORT.NAME
MEDITECH Data Definitions often truncated on the MEDITECH web site can be difficult to decipher. That is until David showed me this workaround.

Build an NPR using that segment. Complete the section shown below, you don't need to fill out anything else in the report. File.

List the source code.

Download to a text file.

Open the text file in a text editor. Look for your sort fields; this list of fields contains all the subscripts for the truncated segment on the MEDITECH web site.

MEDITECH Report Utilities >> MEDITECH.Data.Definitions.WildCard()
Wildcarding the subscripts in a long data definition in the past; you manually replaced the lower case subscripts from this:
$(N1)NPCW[aa]I[nib]O[niu]TD[nod,not,noc]Q[ggv]
until you had:
$(N1)NPCW[:]I[:]O[:]TD[:,:,:]Q[:].

Your days of tedious data definition editing are gone. Try MEDITECH.Data.Definitions.WildCard().
Initializing a MEDITECH standard report never works when you really need it to. That's not a knock on NPR; NPR does what it was intended to do very well, maybe even better than it was designed to ... its that converting code is a very tough thing to do.

When Initializing Report from Standard fails ... print off the report's source & object code.




Reviewing MEDITECH's standard report code usually yields enough ideas for you to write a new custom report that meets your needs.
Think of this as SELECT * FROM tblName when you're querying the MEDITECH Data Repository; only this is for MEDITECH NPR.
If you've ever wanted to build a quick and dirty NPR Download, to dump a dictionary, or a segment; and you don't enjoy creating xx.custom.fields for each data element header, you might be interested in the NPR Download Factory.
Try to create a DOWNLOAD macro for MIS.FIN.CLASS.main in Client Server; then implement as a start macro in a new blank report.
- data segment:
main[mnemonic]
- fields:
mnemonic
active
ask.sign
comment.if.reject
file.if.not.signed
form
form.phys
hospital.code.to
name
print.if.unk
resp.for.pay.code
You'll only need an NPR Report title, a footnote to call your start macro and a start macro, the NPR Download Factory does the rest.

For future reference, bookmark: MEDITECH Report Utilities.
In Making Software I found this first bullet point ringing particularly true for me. Most of my reporting mistakes are based in using the wrong data structure OR my knowledge of how the documentation is used. Learning opportunities surface more often for me in the workflow, instead of the report writing language.

As MEDITECH Report Writers mature and grow, there is less and less to learn about the reporting tools, in comparison to how much there is to learn about how hospitals and their people use MEDITECH.
I'm learning to:
- Watch an experienced user document the data being used in the report.
- Ask the people who use my reports more questions.
- Double check the MEDITECH Data Definitions across multiple MEDITECH applications and DPMs, even when I'm sure I know the best source for the data.
Whether you use SQL for the Data Repository, NPR for Client Server and Magic, or the Report Designer for 6.x Advanced Technology. The best way to prevent reporting errors is to be knowledgeable about the business domain for your reports.
When getting the job done right, is absolutely essential; checklists can be a boon to task accuracy and productivity.
Key point: your team is more likely to use a checklist, when the people who have to live with the checklist, are encouraged to make changes that suit their skills, environment and desired outcomes.

Read more here in the MEDITECH Community Bulletin article titled: MEDITECH NPR Change Checklist for CS & MAGIC 5.6 (A Pragmatic Approach).
Reports that are called from MEDITECH screens instead of a menu, usually have a select like the one below.

When the report is called from a MEDITECH screen, the /urn value is provided by MEDITECH. As the report developer, you can look up the /urn and populate it like this.

When you're ready to move the report into production use, remove the AL START Footnote; and MEDITECH will take it from there.