MEDITECH Reports, MEDITECH NPR Reports, NPR Report Writing, NPR Report Writer, NPR Report, MEDITECH Reporting, MEDITECH Report MEDITECH Reports, NPR Reports, NPR Report Writing, NPR Report Writer, MEDITECH NPR

Wednesday, June 03, 2009

MEDITECH REPORT WRITING Online Workshop

Join Comstock Software for a free workshop on NPR Fundamentals - Session Two on July 31st.

Attendance is FREE. Seats are limited, sign up to receive the MEDITECH Reports Blog via EMAIL.

This month's workshop will be hosted on July 31st @ 1:00 PT, 2:00 MT, 3:00 CT, & 4:00 ET.

Workshop details will be sent out to email subscribers of the MEDITECH Reports Blog on Wednesday, July 29th.

Monday, June 01, 2009

Use a File as Selection Criteria

Remember our BAR report? The one where we used the List Builder to build the list of /ACCOUNTS, instead of hand-keying each account into the run time SELECT Prompt? For a once-in-a-while report, that is a fine solution. But what if someone without programming experience at the business office wants an ad-hoc report for a large number of accounts on a regular basis?

Read the rest in the latest issue of the Meditech Community Bulletin: here.

For a complete list of Meditech Community Bulletin Tips & Tricks,

click here
.

Labels:

Sunday, May 17, 2009

Querying MEDITECH Using SQL Syntax

Every now and then someone will ask what options are available in using SQL to query the MEDITECH platform.

Below I've listed 3 options that I know of:

- OpenGate, Blue Elm's ADO.NET solution, read the white paper.
- DR, MEDITECH's Data Repository
- IPeople Connect

If you have a favorite not listed here OR if you use one of these products, please email me at jsharpe@comstock-software.com. Your experience might make for an interesting story, unless you prefer otherwise.

Friday, May 15, 2009

Stripping a Dash

You've added the dashes '-' to a field; but what about removing them?

To remove the dashes from a field (social security number, or phone number), you can use tokens and the NOT operator like this:

"123-45-6789"^/SSN,
/SSN'#1A'#1A^/SSN
Result: /SSN = 123456789

OR

/SSN'#1A^/SSN
Result: /SSN = 12345-6789

/SSN'#1A^/SSN
Result: /SSN = 123456789

OR

DO{/SSN#L(/SSN,"-") /SSN'#1A^/SSN}
Result: /SSN = 123456789

Labels:

Thursday, May 14, 2009

Removing a Space

/VARIABLE:0S^/VARIABLE trims the LEADING & TRAILING spaces from a variable. But what if that last character looks like a space? And /VARIABLE still appears to have a space at the end of it?

Try /VARIABLE:0XS^/VARIABLE. The :0X will replace non-printable characters with a space. Adding the 'S' to :0X trims the space added by :0X.

Next time you're trying to remove spaces from the beginning or end of a value in NPR, try something like this: /VARIABLE:0XS^/VARIABLE.

Example 1: VAL=(@pt.first.name:0XS)_" "_(@pt.last.name:0XS)

Example 2: IF{@rich.text.line:0XS^/REPORT.LINE_.'=. /REPORT.LINE;"NO TEXT FOUND"}

Labels:

Thursday, May 07, 2009

Using Find and Replace to Reformat Output

The billing extract you’ve just sent to a payer has been rejected. There are quotes in the data, and they must be removed in order for your file to be processed.



You update the NPR extract and resend. This time everything goes through.

Read the rest here in the latest issue of the Meditech Bulletin: Reformatting NPR Report Output Using Find & Replace.

Labels:

Wednesday, May 06, 2009

OE Site Selection - Meditech Client Server

Are you trying to limit a Meditech CS Report down to results for a single site?



Try using a SELECT for OE.ORD.entry.site EQ /["c.site"].

Tuesday, May 05, 2009

More on MEDITECH 6.0

Researching your MEDITECH 6.0 Integration Strategy? See Tara's article on MEDITECH 6.0 Integration in MUSE Matters on page 42.

Looking for First Impressions on MEDITECH 6.0? Read Arthur's musings from his visit to Doylestown MUSE here.

Labels:

Sunday, May 03, 2009

Want to Focus Your Resources on New Report Requests?

By their very nature, Meditech macros can become unreadable. The more code I write, the more I appreciate clean, organized code that can be easily maintained at a future date.



If you're tired of going blurry, reading code written in the traditional 'nested DO Loop' style; try the Reverse DO Loop Builder. The Reverse DO Loop Builder will automatically generate source code to navigate Meditech data structures in a much more readable format. As a result, you'll be spending less on visine and have more resources for things that matter. All seriousness aside, clean and readable code leads to quicker maintenance of older reports and allows you to move forward on the new report requests.




Have a suggestion? Post it here.

Q: I'm not sure what a Reverse DO Loop is, and why I should care.
A: Learn more by reading Writing Readable MEDITECH NPR Macros.

Q: How do Reverse DO Loops actually work?
A: Take the tour Reverse DO Loops - Step by Step.

Wednesday, April 22, 2009

Use Documentation to Build Confidence

When the documentation for an NPR report has been maintained, it gives future programmers confidence in the quality of the code already written.







Bookmarking via the 'Documentation' area in NPR is a great way to keep track of your changes; and more importantly communicate confidence in the changes to others.

Friday, April 03, 2009

A Good List of Articles on NPR Report Writing

If you haven't seen it, here's a good list of articles written by Brian: http://tinyurl.com/npr-report-writing.

Meditech Magic & Client Server Keyboards










While I haven't used one of these yet; the Meditech Keyboard is an interesting idea. Read more here: http://www.man-machine.com/meditech.htm.

Tuesday, March 24, 2009

Find And Replace String

Ever needed to replace a character in a report's output?

Next time you do, try something like this:

{";",":",/TXT}^@STRING.FIND.REPLACE^/TXT

STRING.FIND.REPLACE
; Input(s): /PARAMS
; Output(s): /STRING
; Author: John Sharpe
; Usage: {@QUOTE,"`",/TXT}^@STRING.FIND.REPLACE^/TXT
/PARAMS,/PARAMS|0^FIND,/PARAMS|1^REPLACE,/PARAMS|2^STRING,
DO{STRING#(L(STRING,FIND)^P) (STRING$P)_REPLACE_(STRING%P)^STRING},
STRING^/STRING

QUOTE
D(34)

Labels:

Tuesday, March 10, 2009

Meditech Magic to Client Server Migrations

If you're looking to keep abreast of Meditech Magic, Client Server & 6.0 news; Perot Systems has authored some interesting content on Meditech Migrations here.

Labels:

Monday, March 09, 2009

Easier Reporting Using the List Builder


Read all about Saving Time on Repetitive Tasks using the List Builder in the March 2009 Meditech Bulletin.

Sunday, February 01, 2009

Using NPR to Keep Everyone on the Same Page

People agree on common definitions; except when they don’t. Example, healthcare professionals might define a PEDS patient as: a) a person under the age of 18, OR b) a person under the age of 14, OR c) another range. Without clearly defined terms, even the simplest and most common of things can get confusing.

Hospitals using the Meditech Client Server System use NPR Reports as a primary source of information. As NPR report writers, we can help by clarifying these terms at report run time...

Read the rest of Using Meditech Client Server NPR to Keep Everyone on the Same Page in the February MEDITECH Bulletin.

Tuesday, January 13, 2009

MEDITECH NPR - Reverse DO Loop Builder

Using Reverse DO Loops, yet wishing there was an easier way to code them?    Try the 'Reverse DO Loop Builder'.    See if it doesn't open up new possibilities for you.    Best of all it's free!



Utility - NPR Reverse DO Loop Builder
Manual - Reverse DO Loop Building Manual

Q: I'm not sure what a Reverse DO Loop is, and why I should care.
A: Learn more by reading Writing Readable MEDITECH NPR Macros.

Q: How do Reverse DO Loops actually work?
A: Take the tour Reverse DO Loops - Step by Step.

Saturday, December 13, 2008

MEDITECH FOCUS Report Writer

If you're interested in learning more about MEDITECH FOCUS (C/S 6.0) Report Writing, a great place to start is John Shipman's article http://tinyurl.com/focus-report-writer on this exciting topic.

Labels:

Tuesday, December 02, 2008

Common Object Code and Local Variables

You've probably noticed ... ccdqr.query and td.query compile to the same local variable: ggv.

MEDITECH MAGIC 5.5:

ADM.PAT.clinical.cus.defined.queries (ccdqr)
[ccdqr.patient,ccdqr.query]
*AA.CCDQR[aa,ggv]

NUR.PC.WORK.nur.documented.results (td.results)
[patient,int.base,int.urn,td.act.date,td.act.time,td.act.ctr, td.query]
:NPCW[aa]I[nib]O[niu]TD[nod,not,noc]Q[ggv]

MEDITECH CLIENT SERVER 5.5:

ADM.PAT.ccdqr
[ccdqr.patient,ccdqr.query]
*(A1)AA.CCDQR[aa,ggv]

NUR.PC.WORK.td.results
[patient,int.base,int.urn,td.act.date,td.act.time,td.act.ctr, td.query]
$(N1)NPCW[aa]I[nib]O[niu]TD[nod,not,noc]Q[ggv]

Accessing the Admitting CCDQR queries from Nursing module is pretty common. Careful not to let this one trip you up when you're looping thru the NUR.PC.WORK.td.results segment. One way to access CCDQR responses from within the loop might be:

Original Code:
"SOME.QUERY.123"^ADM.PAT.ccdqr.query,
@ADM.PAT.ccdqr.response
^/VARIABLE

Workaround Code:
"SOME.QUERY.123"^/CCDQR.QUERY,
@ADM.PAT.ccdqr.response[/CCDQR.QUERY]/
^VARIABLE

Sunday, November 30, 2008

Writing Readable MEDITECH NPR Macros (Part 3 of 3)

This is Part 3 in a series on ‘Writing Readable Meditech NPR Macros’. In Part 1 and Part 2 of this series, we examined ways to fit more code on the screen within the confines of the Meditech Macro Editor. When the code fits on the screen, programmers can read and understand the code quickly.

In examining the program below, we can learn a lot. The program does include great documentation on how to use the program. But the actual code will take a new member of the team a while to read and understand before they can maintain or improve it.

Read the rest of Writing Readable MEDITECH NPR Macros (Part 3 of 3) in the December MEDITECH Bulletin.

Monday, November 10, 2008

Writing Readable MEDITECH NPR Macros (Part 2 of 3)

In Part 1 of this series, we put the standard DO Loop under the microscope and found a way without changing the function of the code, to make it readable at first glance. Restructuring the standard DO Loop into a Reverse DO Loop, improved our ability to see all the code at once in the NPR Macro Editor. In Part 2, the macro in question has been implemented with a Reverse DO Loop; but in spite of our initial effort, the code still runs off the screen. Let’s see what can be done to improve the readability of the code at first glance.

Read the rest of Writing Readable MEDITECH NPR Macros (Part 2 of 3) in the November MEDITECH Bulletin.

Wednesday, October 22, 2008

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

Labels:

Wednesday, October 01, 2008

Writing Readable MEDITECH NPR Macros (Part 1 of 3)

Readable code costs less than code that is hard to read. If you can’t read the code, you can’t easily identify: errors in logic (aka bugs), ways to reorganize it or change it to meet enhancement requests. Readable code on the other hand allows you and your programmers to understand and repurpose the code.

Read the rest of Writing Readable MEDITECH NPR Macros (Part 1 of 3) in the October MEDITECH Bulletin.

Monday, September 08, 2008

MEDITECH CDS Attribute Resource

Need to know the ASCII value for a MEDITECH key stroke?

Try the Online MEDITECH Key Code Dictionary.

Monday, August 25, 2008

Reverse DO Loop Walk Thru (MEDITECH NPR)

GET.DETAIL
; EDM.PAT.daily.log.x[ADM.PAT.facility,registration.date,registration.time,urn]
; ?(HE)HEAADL[gqb,heRDT,heRTM,aa]
""^ADM.PAT.facility^registration.date^registration.time^urn,
DO{@Next(urn,daily.log.x) @RECORD;
@Next(registration.time,daily.log.x) ""^urn;
@Next(registration.date,daily.log.x) ""^registration.time;
@Next(ADM.PAT.facility,daily.log.x) b.registration.date^registration.date}

Reverse DO Loop Walk Thru:

Line 1
Code: DO{@Next(urn,daily.log.x) @RECORD;
Explained: Try to get the next urn from the EDM.PAT.daily.log.x index. This is the first time thru, the facility, registration.date & registration.time subscripts won’t be set up. So, nothing happens and we proceed thru down to Line 2.

Line 2:
Code: @Next(registration.time,daily.log.x) ""^urn;
Explained: Try to get the next registration time. This is the first time thru, the other subscripts are NIL, so proceed to Line 3.

Line 3:
Code: @Next(registration.date,daily.log.x) ""^registration.time;
Explained: Try to get the next registration date. This is the first time thru, the other subscripts are NIL, so proceed to Line 4.

Line 4:
Code: @Next(ADM.PAT.facility,daily.log.x) b.registration.date^registration.date}
Explained: Get the next facility in the index. Set the starting registration.date. Go to Line 1.

Line 1:
Explained: Try to get the next urn. We have 2 (ADM.PAT.facility,registration.date) of the 3 subscripts required to next on urn. Fall down to Line 2.

Line 2:
Explained: Get the next registration.time. Set the urn subscript to NIL.

Line 1:
Get the next urn. Go RECORD some data.

At each level of @Next processing, processing starts over at the top and proceeds until there are no more records for the subscripts in play.

Monday, August 04, 2008

First Class Denizens of the Universe (Part 3 of 3)

In Part 1 of this series, we wrote a report to keep an eye on our use of MEDITECH Server Resources. In Part 2, we looked at a way to keep server resource usage to a minimum. In Part 3, we look at an important NPR change control problem and solution.

One evening you’re dining on the town, you jump as your cell phone rings unexpectedly. It’s the Help Desk; seems your new NPR report in the ED is crashing. Your plans for the evening fade away like an ice cube on the sidewalk on a summer day. Hours later, you discover the problem with the report. It seems you forgot about a macro that is called when the patient is under 2 years old. This code never made it LIVE. How could this have been prevented?

Read the rest of First Class Denizens of the Universe (Part 3 of 3) in the August MEDITECH Bulletin.

Saturday, August 02, 2008

MEDITECH NPR Change Process for Problem Tickets

Like most people, you want to do things right the first time. But in the event something doesn't go as planned, you need a standardized Change Process in place so the change can be backed out. Let's examine a Change Process we can use in MEDITECH NPR to work a problem ticket to completion.

1) Login to LIVE & backup the BAR.PAT.zcus.duplicate.charges.npr.report to BAR.PAT.zcus.duplicate.charges.npr.report.0.

2) Test the report BAR.PAT.zcus.duplicate.charges.npr.report in LIVE.

3) If the problem can be reproduced in LIVE, create another copy of the report named BAR.PAT.zcus.duplicate.charges.npr.report.dev in LIVE.

4) Put trap code in the .DEV report and resolve the problem.

5) Put the .DEV report on a testing menu in LIVE and have the reporting party test and approve the changes. This is big. Do this step, and it will take care of a lot of problems.

6) Enter an Emergency Change Control request.

7) Check TEST and make sure there isn't a .DEV report already there. If there is a .DEV report in TEST, backup as BAR.PAT.zcus.duplicate.charges.npr.report.dev.0. Someone might be making report modifications per another change request, we don't want to lose the work that might already be in progress.

8) Move the .DEV version from LIVE to TEST.

9) Remove the .DEV report from the testing menu in LIVE.

10) Delete the .DEV report in LIVE.

11) Delete BAR.PAT.zcus.duplicate.charges.npr.report in TEST.

12) Rename the .DEV report in TEST to BAR.PAT.zcus.duplicate.charges.npr.report.

13) Move BAR.PAT.zcus.duplicate.charges.npr.report LIVE.

14) Validate changes in LIVE production report.

15) Request the reporting party validate the change in the production report as well.

I'd like to hear from you via email at: jsharpe@comstock-software.com on how you would improve this process.

Tuesday, July 22, 2008

MEDITECH NPR Report Performance Improvement

NPR Report Performance Improvement Tips from a recent BAR Report:

1. Review the data definitions from page 1 on the report.

- BAR.PAT.discharge.x[bar.dis.ser,account]
?(B)BZDDX[bzds,bz]

- BAR.PAT.top[account]
$(B1)BZ[bz]

2. Order the subscripts from the index in the SELECTs first.

3. Remove report fragments that execute for every record.

Last week a client challenged me to improve the performance of a BAR report. I was able to reduce the run time of the report by about 75% using the steps above. While this is not an exhaustive list of improvements tips, it will make a good article in the future.

If you are looking for such a list, email me at: jsharpe@comstock-software.com; depending on interest, the list could come out sooner than later.

Saturday, July 19, 2008

@Root in the MEDITECH NPR Report Writer

You've initialized a standard MEDITECH NPR report, at once you recognize the infamous @Root macro.    What does it do?    The @Root macro is used to refer to a segment's top level segment also known as the root.    @Root(@edm.data.doc) translates to *(HE)HEAA[aa] which is the main segment.    Examine these MEDITECH data definitions for the segments below.

EDM.PAT.main[urn]
*(HE)HEAA[aa]

EDM.PAT.edm.data.doc[urn,doc.q]
*(HE)HEAA[aa]D[heDOC]

Saturday, July 05, 2008

Using @ to Access Data Fields in MEDITECH NPR

Consider the RAD.ORD.main segment.

main[urn]
$(R)RO[ro]

urn
arrive.time $(R)RO[ro]EX|11

RAD.ORD.urn is a subscript, you can access its value in your MEDITECH NPR report referring to it as @urn or urn. RAD.ORD.arrive.time does not translate to a local variable. This value requires a subscript to access the data. If you leave the @ symbol off of arrive.time you'll get this error:



To get MEDITECH NPR to translate to the correct object code, you want to reference this field as @arrive.time.

Friday, July 04, 2008

Runtime Selection Variables for your NPR Report?



Find the runtime variables for your selections after the report is translated.



To define the custom fields for your report's picture in NPR:

xx.date.selection.from
DAT=FREE
LEN=8
VAL=b.operation.date

xx.date.selection.thru
DAT=FREE
LEN=8
VAL=e.operation.date

Notice how the runtime variables b.operation.date & e.operation.date are translated as /b.operation.date & /e.operation.date by the NPR Report Writer.

MEDITECH Client Server Reference: http://meditech.com/prrw/pages/RWcbASvariables.htm

MEDITECH Magic Reference: http://meditech.com/prrw/pages/RWmbASvariables.htm

Tuesday, July 01, 2008

Finding What You're Looking For?

Have you ever been at a loss for a data definition that you see in the NPR Report Writer, but couldn't find in the MEDITECH Data Definitions for your release of MEDITECH?

Try looking at the Data Definitions that comes after the release you are currently on. If your hospital runs Client Server 5.55 SR2; try looking at the CS 5.6 SR data definitions.

GL Budget Period Totals

This question came in this morning, but for some reason I can't get back to you because the email message bounces back. Here's your question and my answer:

=== QUESTION ===

this is not a tech guy, far from it, yet i know that this should be simple.

GL.Budget

One file gives me the annual amounts found in my budget file and I can see how to get the annual numbers.
then next file will give me the period (12 monthly) amounts that total to the annual amount.

So how do I return the 12 period amounts from the detail file?

Thanks for any help.

=== ANSWER ===

If you are in CS you'll want to use the 'gl.period.budgets.file' as your segment; if you are MAGIC you'll use the 'periods' as your segment. To get the amount for period 1, you'll return budget.ytd. For the other periods, you'll take the budget.ytd and subtract the previous budget.ytd.

If you need help coding this, I can setup a time to WebEx with you.

Great question, thanks for asking,
John

Saturday, June 14, 2008

Turn Off Buffering in NPR Reports (Client Server)








"To turn off buffering, enter BUF=NONE in the report’s footnote section. If a report has a VAL statement that attempts to replace elements with buffered results increasing a line’s length longer than 255 characters, a translation error message appears." - Meditech Client Server NPR Manual

Updated 12/13/2008: Try 'BUF NONE' instead.

Thursday, June 12, 2008

ABS.PAT Dxs

abs.pat.dxs[urn, dx.seq.no]
:DZ[dz]D["DX",dzDXN]

Field Name Offset/Local/VAL
dx.seq.no dzDXN
dx :DZ[dz]D["DX",dzDXN]|0

To hard code and print 10 dxs side by side from the ABS.PAT.main segment define your VAL statements in your fields as follows.

NPR DX Field 1:
VAL=IF{""^dx.seq.no,@Next(dx.seq.no) @dx;""}

NPR DX Fields 2 - 10:
VAL=IF{@dx.seq.no @Next(dx.seq.no),@dx;""}

Saturday, June 07, 2008

Details Worktools

Get Organized: http://www.details-worktools.com

Thursday, June 05, 2008

One Way to Simplify IF Statments

Assume Q has a value of 1 or 2.

This: IF{(0<Q<3) 1;0} is simpler than this: IF{(Q=1)!(Q=2) 1;0}.

MEDITECH Magic Reports with Style

I just joined the forum at http://rwpgx.org. Looks like a great place to meet like minded developers. More later...

Wednesday, June 04, 2008

Sorting Strings By Delimiter

I love a great text editor. My favorite is Textpad.   There are times when I'm working on a computer where installing Textpad is not an option.   That's where this tool comes in.   Ever need to sort a string by delimiter or change delimiters?   Maybe and its a BIG maybe, you'll keep this free tool in mind if you do.   Here it is in action.















Try it here: http://comstock-software.com/SortDelimitedList.aspx

Please leave suggestions as comments to this post.

Populating the RL Select with KEYWORDs






"END"^c.patient.gl.account["BEGINNING"]

Code From the Footnotes





Do you have occasions where you'd like CS code to run right out of the gate in your NPR report? Try adding a footnote with only code (no AL keyword).

This footnote: %Z.rw.fragment("","MRI.PAT") translated to the second line of object code in the report as: %(Z)rw.fragment("","MRI.PAT").

Tuesday, June 03, 2008

NPR Field Attribute - SIZEV

NPR Field Attribute SIZEV for vertical:

DAT=FREE
FONT=n
JFY=L
LEN=1
SIZE=3.0
SIZEV=3.0
VAL="+"

Labels:

Tuesday, May 27, 2008

Requiring an NPR Select in a Custom Field

I've got an NPR report in Client Server with a custom defined field as a SELECT. The field is used to capture a value which determines the format, content & layout of the report. The field is set up on page 2 as:

xx.type IG Enter Report Type of T (TX) or D (DC)

The clinicians want the SELECT to be required. Here's one way to handle this:

- AL START IF{(c.xx.type@tr.12u'="T"'="D") @W.display("Select T or D as Report Type"),H(5);
- AL CLOSE.UP 1}

When the report type SELECTION is T or D, the report runs and returns results.

ADM.PAT CCDQR File

ADM.PAT.ccdqr[ccdqr.patient,ccdqr.query]
*(A1)AA.CCDQR[aa,ggv]

MAGIC NUR custom queries will not file a blank over a filed query unless there is a custom attribute to clear the previous value.

In CS 5.5 the OE Custom Queries on the 'Enter / Edit Patient Data' screen will in fact file a blank value over a previous value.

Wednesday, May 14, 2008

First Class Denizens of the Universe (Part 2 of 3)

As a MEDITECH Client Server Analyst who is aspiring to greater responsibilities, no doubt you’ll find yourself writing NPR reports. This article is the second in a series of three (see the April 2008 issue for Part 1) where we examine strategies to keep you in the limelight for all the right reasons.

In Part 1 of this series, we wrote a report to keep an eye on our use of MEDITECH Server Resources. In Part 2, we look at another way to keep server resource usage to a minimum.

Recently, I was challenged to improve the performance of a report in the NUR.PC.WORK DPM. This was challenging because the NUR module didn’t have the index I needed. It was also challenging because the report was already using an index. ...


Read the rest of First Class Denizens of the Universe (Part 2 of 3) in the May/June MEDITECH Bulletin.

Monday, April 28, 2008

Pre-Loading NPR Selects

You have an NPR report, you'd like to autopopulate the following SELECT on.



Create a macro and call it from the NPR Title: "_%(BAR)PAT..zcus.report.name.M..preload("")_"

Define the following in a macro named preload:

1^c.bar.status["FB"],
1^c.bar.status["IB"],
1^c.bar.status["UB"],
"Billing Report";

Run the report and you'll see that the SELECT for bar.status is populated with the items from the macro.

Tuesday, April 01, 2008

First Class Denizens of the Universe (Part 1 of 3)

"As a MEDITECH Client Server Analyst who is aspiring to greater responsibilities, no doubt you’ll find yourself writing NPR reports. This article is the first in a series of three where we examine strategies to keep you in the lime light for all the right reasons."

Read the rest of First Class Denizens of the Universe (Part 1 of 3) in the April MEDITECH Bulletin.

Tuesday, March 25, 2008

IS.NOT.NUMBER

This elegant solution was posted by an astute, anonymous reader:

/TXT?0N


My original solution:

--IS.NOT.NUMBER
--; Input(s): /TXT
--; Output(s): /SKIP as nil
--; If /TXT is not a number return /SKIP as 1.
--0^Q,""^/SKIP,
--DO{(/TXT#Q^/CHR)&(/SKIP_.=.) E(/CHR)^/ASCII,
--IF{/ASCII<46 @SKIP;
--/ASCII>57 @SKIP;
--/ASCII=47 @SKIP},
--Q+1^Q},/SKIP
--
--SKIP
--1^/SKIP

Thursday, March 20, 2008

Binary Programming

Shayne Nelson on Binary Programming.

Thursday, March 13, 2008

Readable MEDITECH NPR Code

Today's topic is related to a recent post titled Meaningful Arrays The Easy Way which focused on improving the readability of NPR code.    Reading Steve Litt's article Code Readability Throughout The Ages I had to reflect on what I've been learning in the past few weeks.    I've been learning that Client Server really lends itself to code readability because you can assign values to subroutines:

@ACCOUNTS.PER.USER+1^@ACCOUNTS.PER.USER

ACCOUNT.PER.USER
/ACCOUNTS[@USER]

USER
IF{/USER;"SOME.OTHER.VALUE"}

While MAGIC doesn't allow us to assign to subroutines, we still benefit from the use of subroutines in our efforts to improve the readability of the code.

IF{@TXN.IS.CHARGE @GET.CHARGE.SECTION;
" "}^/MV.TXT,@WRITE.TO.MV

TXN.IS.CHARGE
@BAR.PROC.type[@item.procedure]="CHG"

WRITE.TO.MV
/MV.TXT^/R.MV[/MV.NAME,/LINE,@FIELD],""^/MV.TXT

FIELD
/FN+1^/FN

Without using a single comment, the intent of the code is clear. The next programmer will be able to read and follow along with ease. Properly named subroutines are not only more readable, they're also re-usable resulting in less code. Less code ... fewer bugs. Fewer bugs ... happier customers.

Tuesday, March 11, 2008

Google Health

Eric Schmidt @ HIMSS 2008: http://www.youtube.com/watch?v=dTZKNcx9sBA on Google Health.

Monday, March 10, 2008

NPR Doesn't Have To Be A Resource Intense Process

"If your healthcare organization is like most, even the simplest of NPR reports include graphics. A report writer can consume a lot of paper (and toner) printing to the printer, during the development and testing of a report."

Read the rest of NPR Doesn't Have To Be A Resource Intense Process in the March MEDITECH Bulletin.

Tuesday, March 04, 2008

Upper Casing NPR Selects

When users of an NPR report need to enter a known free text value in a select and you want to make sure the value is always upper-cased:

MAGIC: c.xx.type~$L.TO.U^c.xx.type
CS: c.xx.type@Tr.l2u^c.xx.type

Labels:

Wednesday, February 20, 2008

MIS.SCREEN.print Parameters

A = MIS.SCREEN.mnemonic where info was documented.
B = Structure where query responses live.
C = Nil (omit blank lines) or Non-Nil (print blank lines)
D = Left Margin

Tuesday, February 19, 2008

Joel On Microsoft Word File Formats

This article provides insight into why NPR seems like it should be easy; but isn't: http://www.joelonsoftware.com/items/2008/02/19.html.

Tuesday, February 12, 2008

NPR Report - Backup Convention & Strategy

Everybody has their own style, this is simple and works for me.

Original Report:
APP.DPM.zcus.report.name

Backup Copies:
APP.DPM.zcus.report.name.0
APP.DPM.zcus.report.name.1
APP.DPM.zcus.report.name.2
APP.DPM.zcus.report.name.3

Other backup conventions I've seen:
APP.DPM.zcus.report.name.bkp
APP.DPM.zcus.report.name.bkp.1
APP.DPM.zcus.report.name.20071201
APP.DPM.zcus.report.name.20071201.0700

Pick a convention that's simple and allows you to reliably restore a report when you need to. Using the .0,.1,.2,.3 strategy allows me to quickly select the last backup without doing any thinking should a restore of a report be needed. That's not a time, when I want to be wondering which one was the last one.

Monday, February 11, 2008

NPR Reports - Changing Print Tray

Changing the tray for the entire report:

From a start macro or AL START footnote: %Z.switch.tray(xx)

1 = Tray 1 (Upper)
2 = Manual Feed
3 = Manual Envelope Feed
4 = Tray 2 (Lower)
5 = Feed from Paper Deck

Example: %Z.switch.tray(5) would send to the paper deck. For more information: http://pcl.to/reference/.

If you need various sections to go different paper, it is possible to call Z.switch.tray and send various sections to various trays.

Friday, February 08, 2008

Formatting MEDITECH Time as HHMMSS

$TIME(@.sd)^TIME,(TIME$2^HH)_((TIME%2)$2^MM)_(TIME%5^SS)^TIME

Labels:

Wednesday, January 30, 2008

Auditing MAGIC Scheduled Reports

"A recent audit request prompted me to write an NPR Report to identify current extracts for a BAR Third Party Administrator (TPA). While a standard MEDITECH report did exist off the MIS Spooling menu; it was not targeted towards the information I needed. Let’s retrace my steps by writing such a report in the MIS.JOB data procedure module (DPM) in the ‘mis.job.day.list’ Detail Segment."

Read the rest of Auditing Magic Scheduled Reports in the February MEDITECH Bulletin.

Monday, January 21, 2008

MEDITECH Tightening Up The Magic NPR Syntax?

A programmer up at Newton Wellesley came up with this workaround for the NPR syntax checker: "S"^S,([S](0)) replacing an S(0) call for system time in some NPR macro code.

Apparently an S(0) call prevented the NPR Report Writer from transferring the object code from the master NPR segment to the satellite segments.

Is MEDITECH tightening up the MAGIC NPR Syntax Checker in the 5.6x releases? Its possible. Something to keep an eye out for if you hear of NPR object code not transferring from the master to satellite segments.

Friday, January 18, 2008

Choosing the Correct NPR Segment

A friend from Providence Healthcare Toronto recently wanted to know how to tell the difference between parent & child segments when reading MEDITECH Data Definitions.

Let’s consider 3 common Radiology Order fields from Client Server 5.6:

- accession.number $(R)RO[ro]ASN|0
- cc doc $(R)RO[ro]CD[cd]|0
- order status $(R)RO[ro]|2

So ... how can we determine if these 3 fields are in the same segment? It comes down to subscripts. Subscripts are the values that live between the pairs of brackets ([ro] for example). If there is one set of brackets, and the subscripts are the same, then we can assume that the segment is the same. Applying that rule to the definitions above, we can ascertain that accession.number and status are in the same segment...

- accession.number $(R)RO[ro]ASN|0
- status $(R)RO[ro]|2

... because they only have 1 set of brackets and subscript(s) are the same.

The cc doctor is in the child segment because both physical addresses have the same base address in common: $(R)RO[ro]; yet the address has another set of brackets (subscript) which define the child segment.

- cc doc $(R)RO[ro]CD[cd]|0

So ... why isn't accession.number ($(R)RO[ro]ASN) in a separate segment than status ($(R)RO[ro])? These two structures share the same physical address and subscripts. The only difference is the constant. I think of a constant as a way to keep the base file clean; without using more subscripts. This makes the data easier to access in the NPR Report Writer.

Your emailed questions and responses to this post will be rolled back in to this post to make this information more digestible.

Thursday, January 17, 2008

MEDITECH Magic Workstation Connectivity

MEDITECH Workstation Connections are stored in the Registry:

\HKEY_CURRENT_USER\Software\Meditech\Wrkstn\"Connection Name"

Most MEDITECH users won't run into this; but if you ever cannot get connected to MEDITECH check to make sure you don't have more than 50 connections.

Wednesday, January 16, 2008

Meaningful Arrays The Easy Way

Once upon a time ... there was an NPR Report Writer in a cool, dark basement working on a better way to build NPR Arrays.

BUILD.RPT.STATUS.LIST
; C = Cancelled
1^/RPT.STATUS["C"],
; D = Draft
1^/RPT.STATUS["D"],
; F = Final
1^/RPT.STATUS["F"],
; H = Held
1^/RPT.STATUS["H"],
; S = Signed
1^/RPT.STATUS["S"],
1

Including documentation with the code meant another NPR Report Writer could follow along without too much effort.   This improved the maintainability and support of the code which the users appreciated when they needed a change.   However ... this required the programmer to hit the end key at every line to make a change or modify the subscripts in an array.   To solve this problem, the value and the subscript were made the same.   This meant the programmer could work from the left to modify the subscripts which resulted in a time savings:

BUILD.RPT.STATUS.LIST
; C = Cancelled
"C"^/Q^/RPT.STATUS[/Q],
; D = Draft
"D"^/Q^/RPT.STATUS[/Q],
; F = Final
"F"^/Q^/RPT.STATUS[/Q],
; H = Held
"H"^/Q^/RPT.STATUS[/Q],
; S = Signed
"S"^/Q^/RPT.STATUS[/Q],
1

Next, the programmer decided that his code would be cleaner and easier to maintain if the programmer could paste it into a text editor like TextPad and sort it.   But alas, that separated the comments from the code.

BUILD.RPT.STATUS.LIST
"C"^/Q^/RPT.STATUS[/Q],
"D"^/Q^/RPT.STATUS[/Q],
"F"^/Q^/RPT.STATUS[/Q],
"H"^/Q^/RPT.STATUS[/Q],
"S"^/Q^/RPT.STATUS[/Q],
; C = Cancelled
; D = Draft
; F = Final
; H = Held
; S = Signed
1

Realizing this could be improved by making the code self documenting, the programmer hypothesized that the comment be part of the code.   Using the #0 on the value, would keep the array's contents the same as before yet make the code more readable:

BUILD.RPT.STATUS.LIST
"Cancelled"#0^/Q^/RPT.STATUS[/Q],
"Draft"#0^/Q^/RPT.STATUS[/Q],
"Final"#0^/Q^/RPT.STATUS[/Q],
"Held"#0^/Q^/RPT.STATUS[/Q],
"Signed"#0^/Q^/RPT.STATUS[/Q],
1

‘AH HA’ the programmer thought ... I will post this to the internet and listen. For surely the blog readers will help find an even happier ending to this tale.

Monday, January 07, 2008

Combining Multiple NPR Fields into One Field

Have you ever had a vendor request a list of NPR fields as 1 field? A teammate of mine did and here's how you can do it:

VAL = (@location:0XS)_(@room:0XS)_(@bed:0XS)

:0XS is actually 2 steps. The :0X will remove characters outside the printable range. Characters outside the printable range look like a space when printed. ASCII Characters 33 - 126 are printable characters. The :0X removes 0 - 31, 127 - 255. Next the S portion strips the remaining spaces; as you know 32 is the code for a space.

The :0XS is a bit of overkill; but I expect invisible characters and spaces and then I'm never disappointed.

Lets assume these values:

@location = "HMD"
@room = "101"
@bed = "B"

The VAL statement above will print like this:

"HMD101B"

Combining these fields can be a preferred way to store location room and bed in a system outside of MEDITECH where they don't have to keep track of all room/bed details like MEDITECH does. Its definitely not 3NF; but suitable for reporting purposes & analysis.

Sunday, January 06, 2008

Commented Out NPR Code

Until reading Neal Ford's 10 Ways to Improve Your Code (www.nealford.com); I hadn't consciously thought about how often NPR Report Writers encounter commented out code in NPR & $T macros.

At times programmers can feel that commenting out code and then leaving it in place is good backup. But ... it makes the MEDITECH NPR code harder to maintain:

- A find and replace in the macro will update the commented code unless you step thru each replacement. That's not fun.
- Commented out code is easy to confuse with production code.
- Backups of the macro OR/AND NPR program preserve the code in its original state.

Neal says it succinctly: "Lots of commented out code is a smell -- get rid of it." Of course he's using the term 'smell' coined by Kent Beck: http://martinfowler.com/bliki/CodeSmell.html.

Tuesday, January 01, 2008

Not Equal Operator Quiz

Which of the following is the 'Not Equal' operator in NPR?
a) '=
b) !=
c) <>
d) all of the above.

Being an NPR Report Writer, C# and SQL programmer I confuse the syntax from the 3 all the time.

Monday, December 31, 2007

Formatting A Social Security Number

STRIP.SSN.ALPHAS
; Inputs: /SSN
; Outputs: /SSN
; Process: Strip non-numerics. Format in XXX-XX-XXXX.
; Platform: NPR Report Writer
(/SSN'~((D(255):48)_("0123456789")_(D(255):70)))^/SSN,
(/SSN$3)_"-"_(/SSN%2$2)_"-"_(/SSN%4)^/SSN

Friday, December 21, 2007

Physical Structure Viewer - NPR Structures

Comstock Software has released a FREE Physical Structure Viewer for NPR Packed Structures. This is free to all MEDITECH NPR Report Writers in the MEDITECH NPR community at large.

If you have suggestions, please leave them as a comment on this blog.

Thursday, December 20, 2007

Change Control Form Elements

1) Hospital / Facility
2) NPR Report Writer / Programmer
3) Change Request Submission Date
4) Change Description
5) Impact Analysis
6) Service Line / Department
7) Primary Change Date & Time
8) Alernate Change Date & Time
9) Approved By (Hospital Analyst / Project Manager / Site Executive)
10) Approved Date & Time

Sunday, December 09, 2007

MIS Query Types

B: Blood Pressure - NNN/NNN
C: Comment - Free Text, No Word Wrap
D: Date - MM/DD/YY (not bday)
E: Text - Free Text, Word Wrap
G: Group Response
L: Label - No Response
M: Money - NNNNN.NN
N: Number - Whole Number (75 length limit)
O: Group Response or Free Text
P: Entry from Dictionary or Free Text
Q: Quantity - NNNNN.NNNN
T: Time - HHMM (military)
V: View Standard Fields
X: Birthdate - MM/DD/YY (bdays only)
Y: (Y)es or (N)o

Friday, December 07, 2007

Excluding Cancelled NUR Documentation

NUR.PC.WORK.activity segment:

Documented: [NPCW,V1000000717,I,9999999,O,1,A,20071206,1708,2]
Edit: [NPCW,V1000000717,I,9999999,O,1,A,20071206,1708,2.01]
Edit: [NPCW,V1000000717,I,9999999,O,1,A,20071206,1708,2.02]
Undone: [NPCW,V1000000717,I,9999999,O,1,A,20071206,1708,2.99]

To grab the documentation by documentation instance, you want to pick up the last documentation or edit in the file; but not return anything if the last subscript ends in a .99.

You can implement a SELECT on Page 2 of NPR:

xx.cancelled EQ 0

Field: xx.cancelled
DAT=FREE
JFY=L
LEN=1
VAL=IF{@times.done[patient,int.base,int.urn,td.act.date,td.act.time,
VAL=(td.act.ctr_.99)] 1;0}

Tuesday, December 04, 2007

Magic - Line Check Range (LCR)

Say you have 2 DETAIL lines on your NPR Report. You only want these lines to print when the patient is younger than 18. Using a LCR keeps you from having to code a separate line check for each line.

LCR=IF{@patient's.age>17 "";1}
DETAIL This detail 1 will not print when the patient is older than 17.
DETAIL This detail 2 will not print when the patient is older than 17.
DETAIL This detail 3 will not print when the patient is older than 17.
DETAIL This detail 4 will not print when the patient is older than 17.
LCR=END

Thank you Denise Morrill at Perot Systems for showing me this one.

Saturday, December 01, 2007

Access Index Value as a Data Element

Do you ever find that you've been looking at something one way; only to have the light bulb come on and see things in a different light? I do.

What I am about to share is one of the basest of concepts. And yet I'd missed it until modifying another programmer's NPR report. That is the fun in keeping your eyes open while you work. You find you're always learning and fine tweaking what you know.

room.bed.index
[facility,room,bed] = urn
?(A)AARB[gqb,ggr,ggrB]

schedule.index
[facility,status.type,date,urn] = 1
?(A)AASI[gqb,aaST,aaDT,aa]

Consider both indexes above. Until now, I would loop thru the @room.bed.index using a DO LOOP and then assign the value to a variable and go on my way:

"MAIN.FAC"^facility,""^/Q,
DO{>?(A)AARB[@facility,/Q],/X)^/Q /Q#0S^/ROOM,/Q#1S^BED,/X^urn,@DO.SOMETHING}

What I never thought about is using the name of the structure like this: @room.bed.index^urn.

"MAIN.FAC"^facility,""^room^bed,
DO{+?(A)AARB[@facility,@room,@bed]^bed @room.bed.index^urn,@DO.SOMETHING;
+?(A)AARB[@facility,@room]^room ""^bed}

Until today, it hadn't occurred to me to use the index @room.bed.index to get the value for @urn. You could even use this principle with the @schedule.index to check for the existence of a record.

IF{@schedule.index @DO.SOMETHING;@DO.SOMETHING.ELSE}

Wednesday, November 28, 2007

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.

Monday, November 26, 2007

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.

Saturday, November 24, 2007

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

=== QUESTION ===
I have a main report that calls a 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

Wednesday, November 21, 2007

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.

Tuesday, November 20, 2007

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:

Monday, November 19, 2007

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"

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!

Labels:

Friday, November 16, 2007

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.

Wednesday, November 14, 2007

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.

Labels:

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.

Sunday, November 11, 2007

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.

Labels:

Friday, November 09, 2007

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}

Labels:

Wednesday, November 07, 2007

PHA Rules & Line Checks

I was working with a friend on a PHA rule today when it hit me.  PHA 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.

Saturday, November 03, 2007

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..

Friday, November 02, 2007

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.

Thursday, November 01, 2007

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.

Saturday, October 27, 2007

Z.link.db - CS

Open OE current MIS: %Z.link.db(Q("OE."_(/.DB#"1.")),Q("O","B",1))
Close OE current MIS: %Z.link.db(Q("OE."_(/.DB#"1.")),Q("C","B",1))

Parameters:
A0 = database (ADM.NLB)
B0 = "O" open prefixes, "C" close prefixes
B1 = "" do DB checks
..... "B" bypass DB checks
..... "W" do DB checks don't set the error code, but warn if error
B2 = "" display messages, 1 suppress messages other than DB checks
B3 = 1 set use.for.switch.flag (use only when B0 = "O")
B4 = 1 don't open prefixes, just do DB checks.
B5 = check if server resources available before opening prefixes

Notes of interest: %(MIS), %(Z), %(NPR), UNV data files are not affected by this program.

Saturday, October 20, 2007

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

Labels:

Tuesday, October 16, 2007

NPR Syntax Workarounds

The NPR report writer was written to protect us from damaging the MEDITECH HCIS. Unless you are a very experienced programmer, do not attempt to workaround the syntax checker. The MEDITECH languages (CS & Magic) are very powerful; meaning, it takes very little code to do a lot (good or bad). If you make a mistake it could cost you your career as a MEDITECH NPR Report Writer / Programmer.

Question: How do you perform a KILL in NPR Report Writer?
Answer: You can do a kill, but you shouldn't this is just too dangerous.
Workaround: ""^Q,DO{>/ECT[Q]^Q ""^/ECT[Q]}

Question: How do you seg in the report writer?
Workaround: $["SEGS"]("A","LIVE.MIS")

Question: How do you open prefixes in the NPR report writer?
Workaround:
;If the prefix is open like / is, stack it using the S.
;When you are done with the / prefix, unstack using the U.
@OPEN(/S,"P"),
@CLOSE(/U)

OPEN
O

CLOSE
C

Source: K@SETUP.TEMP.U,M([B],[U])
Object: K([U]),M([B],[U])}

V@HL.PRINT.LINE

HL.PRINT.LINE
(@hl.print.line)

Stacking / Unstacking Prefixes

$T Example - Stacking the Slash File:

ZCUS.SLASH,
; Instantiate/Open slash file.
O(/,"P"),
1^/SLASH,
; Instantiate new / file, while stacking the current one.
O(/S,"P"),
2^/SLASH,
; Close the current / file, while unstacking the previous / file.
C(/U),
; Check to see if / is open; X is equal to "P".
O(/)^X,
; Check the value of /SLASH, it will be 1
NN(/SLASH)^#,
N("")^#;

MEDITECH does not stack the /.. variables in the slash file with their Z.stack.slash which is used in their CDSs.

NPR Report Writer Solution from Michael Laban at ECHN:

1^/X,
%Z.stack.slash("N"),
2^/X,
%Z.stack.slash("U"),
%Z.ddc(" slash"),
END;

Elegant solution from Joe Cocuzzo at Iatric Systems:

You can also do C(/X) to exchange the current slash for the stacked slash file, then do C(/X) again to put things “back”. This is handy for the Non MEDITECH data source option in PCI when you need to know more than just a unit number (like the user mnemonic, account number selected etc).

Monday, October 15, 2007

ASCII Table

I've been consolidating online & offline resources I use for the NPR Report Writer into one location.

The Ascii Table is now hosted over at Comstock Software.

Saturday, October 13, 2007

Great 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.

Labels:

Friday, October 12, 2007

Head Start for your NPR Report

I have an ABS report that was looping thru the abs.pat.abs.status.x index.

The physical structure for that index looks like this:

?DZS["FINAL",1]
?DZS["IN PROCESS",100]
?DZS["NONE",125]

The report criteria require records where the status is not equal to "FINAL". So the natural thing for some of us is to put this in our page 2 SELECT:

abs.status NE "FINAL"

The problem is, the NPR report writer will loop thru all the "FINAL" records even though it just wants the "IN PROCESS" & "NONE" records in the index.

What you want to do is set your SELECT like this:

abs.status GT "FINAL"

Now the report writer starts looking in the index at the "IN PROCESS" records and skips all the "FINAL" records in that index.

The proof is in the pudding (object code):

IF{"FINAL"'=D(127)}^dzS,
DO{+?DZS[dzS]^dzS&'/R.LIMIT ""^dz,
DO{+?DZS[dzS,dz]^dz&'/R.LIMIT

This approach will not work in all situations; but that's why you are writing the NPR report and its not writing itself.

NPR Macro with ANS as Parameter

There was a question on the MEDITECH-L the other day regarding the LOCAL ANS variable. I thought I'd elaborate more today:

ANS = 7RESP 166 20071012 0540 1

The value of ANS will vary from MEDITECH module & screen where it is being used.

In the NUR module, the MEDITECH screen filer uses /RESP for filing responses to NUR.PC.WORK which falls under the physical file :NPCW. Astute readers will notice that I've translated 7RESP to /RESP. The other values in ANS are used as subscripts when filing the data into the database.

If you have a CDS attribute that is too long, greater than 249 - 254 characters in length, you will not be able to compile the attribute into your screen. That's when I resort to an NPR macro. The macro will be called as a progam like this:
%MIS.zcus.nur.attributes.M.calculate.average.temperature(ANS).

We put our macro under MIS because all modules open to MIS by default. If another application were to call your NUR screen, the NPR report macro could crash the screen because the NPR code is not on that segment. Using MIS as our DPM eliminates this problem.

When you get to the macro, you can work with data under the / prefix using /ANS OR /[ANS,"YOUR.QUERY"]|0. The one caveat to this can occur if the / prefix were stacked when your macro was called; I believe this only happens in ADM query screens. In that case, you'll need to unstack / at the beginning and unstack / at the end of your macro.

Thursday, October 11, 2007

New Local Symbol Table

%DPM.zcus.report.name.M.macro(A,B,C)X

When calling a program from a macro; you might want to append an X on the end. This starts the new program with a new local symbol table for that program.

Tuesday, October 09, 2007

WorkAround for Moving NPR Reports

I was trying to move an NPR report from LIVE to TEST; when the NPR move reports & menus didn't move the report from LIVE to TEST.

I called MEDITECH, who suggested I download the report to my pc and then upload it to the TEST directory. Meanwhile, they'll address the issue with the MOVE routine.

What a good idea.

Friday, October 05, 2007

MEDITECH NPR LIST BUILDER For Macros

Today Comstock Software released a FREE List Builder for NPR Macros for the NPR Report Writing community at large. This is free to all MEDITECH NPR Report Writers.

If you have suggestions, please leave them as a comment on this blog.

How Can You Write Better NPR Code?

"Great code doesn't just function: It clearly and consistently communicates your intentions, allowing other programmers to understand your code, rely on it, and modify it with confidence. But great code doesn't just happen. It is the outcome of hundreds of small but critical decisions programmers make every single day." - Kent Beck

One of the best things you can do for your code is clarify what it does. If the code just "works" but noone else can maintain it; your organization won't get much value from it.

Good Software Takes 10 Years. Get Used to It.

Wednesday, September 26, 2007

NPR Report Parser - MAGIC

Today Comstock Software released a FREE new MEDITECH NPR Report Parser for the NPR Report Writing community at large. This is free to all MEDITECH NPR Report Writers.

During my adventures as an NPR Report Writer, I've experienced frustration finding all reports, fragments & macros associated with an NPR report. This tends to happen at the worst moment (GO LIVE, using the report at another facility, etc...).

I've authored this web based utility to allow you to quickly list all reports associated with a report you are working with.

If you have suggestions, please leave them as a comment on this blog.

Tuesday, September 25, 2007

How You Can Improve Your NPR Skills

- Read the MEDITECH NPR Manuals from MEDITECH.
- Attend Quality NPR Report Writer Training.
- Mentor under programmers recognized for producing results.
- Write about the things you are learning.
- Take on difficult projects.

Best of luck!

PG - Page Break Line Attribute

PG=6 tells the report writer to issue a page break if fewer than 6 lines are left on the page.

If your page length is set to 60 lines; PG=99 tells the report to issue a page break when the line attribute PG=99 is read. You might do this on a NUR report to put allergies on its own page for instance.

I enjoy faking the page break line attribute when using variable length page trailers with MV arrays. To replicate the functionality in the PG line attribute: count the lines in your MV array for the footer. Subtract the lines in the MV array from the /.LL lines left variable. When the /.LL minus your MV line count exceeds the number of lines on the page (say 66); set /.LL to zero (0).


.: This article applies to Meditech NPR Reports :.

Labels:

LS - Line Space Attribute

Place this attribute on your report picture in lieu of blank report rows.

The line attribute LS=3 will add 3 blank rows to your report.

Where would I use this? I might use this to keep the report picture on a single screen instead of scrolling up and down to view the various fields on the picture.


.: This article applies to Meditech CS Client Server NPR :.

Labels:

Why Do MEDITECH NPR Reports Crash?

Why do MEDITECH NPR Reports crash? There are quite a few reasons your NPR reports can crash; but today I want to focus on the local symbol table. Crashing due to symbol table overflow can be hard to pin down. The reason is due to the variable nature of the information your report, attributes or screen load into the local symbol table from record to record.

Everytime you use a variable without a prefix (:,#,!,%) you are loading that information into a very small memory space called the symbol table. Local symbol table variables look like this: A, B, X, ANS.

== Local Symbol Table Limitations ==
The local symbol table has a 1024 byte limit. MEDITECH screens and reports use the local symbol table. If you load enough small amount of information into the local symbol table: "Caffeine"^ALLERGY, "Mother"^NOK, "123-45-6789"^SSN; your screen or report can crash at random.

I have found that using /SLASH variables almost exclusively to store my information when I'm programming a MEDITECH Screen or Report makes the program more robust. The term /SLASH variable or /SLASH file is really programmer's slang for: global variables. In this case the global variable is preceded by a "/" prefix. Global variables must be a minimum of 3 upper case letters in length: /PRE or /ANS or /R.FRAG.VAL are good examples of properly named slash variables.

== Slash File Limitations ==
1) The slash file as it's known does not have a technical limit. Because there is no limit; you could load enough information into the slash file to crash the entire MEDITECH HCIS. That would occur when you'd managed to use up the entire hard disk space allocated for MEDITECH.
2) MEDITECH Z programs require local variables be used to pass parameters:
- %Z.debug(/ALLERGY) probably won't pass the value in /ALLERGY to the Z program.
- %Z.debug(ALLERGY) will pass the value in ALLERGY as the A parameter to the Z program.

Evaluating a Dynamic Value in Report Detail Once

If you included a bit information on your report's detail that would be the same for every record on the report; you might want to consider using the WITH field attribute. In your custom defined report field add: WITH=START to the list of field attributes.

WITH can also be used to count or total various report regions on the page.


.: This applies to NPR Reports. :.

Open DPM Applications

Almost every MEDITECH module opens to MIS in either CS or MAGIC.

CS Modules Open to ADM: EDM, LAB, MRI, NUR, OE, PHA, RAD, SCH
MAGIC Modules Open to ADM: EDM, LAB, MRI, NUR, OE, PHA, RXM, SCH

CS Modules Open to MRI: ADM, EDM, EPS, NUR, OE, PHA, RAD
Magic Modules Open to MRI: ADM, EDM, RADRW

CS Modules Open to MM: PHA

It goes without saying that you won't need a fragment to open these modules MEDITECH opens for you.

Monday, September 24, 2007

Font Formatting in NPR Reports

FC OPTIONS:
- BLACK
- AQUA
- BLUE
- FUCHSIA
- GRAY
- GREEN
- LIME
- MAROON
- NAVY
- OLIVE
- PURPLE
- RED
- SILVER
- TEAL
- WHITE
- YELLOW

FF OPTIONS:
- Regular - n or "" or " "
- Underline - U
- Bold - b
- Bold & Underline - B
- Italic - i
- Italic & Underline - I
- Bold & Italic - t
- Bold & Italic & Underline - T
- White On Black - r
- Black On White - R

Font Spacing:
- Fixed - F
- Proportional - P

/R.F[" "] = ^(s0s0B^&d@^&k7.162H
/R.F["B"] = ^(s0s1B^&dD^&k7.162H
/R.F["D"] = ^^&k7.162H
/R.F["I"] = ^(s1s0B^&dD^&k7.162H
/R.F["P"] = ^(8U^(s0p16.67h8v0T^)10U^)s0p16.67h8v0T
/R.F["R"] = ^(s0s0B^&d@^&k7.162H^*v0o0T
/R.F["T"] = ^(s1s1B^&dD^&k7.162H
/R.F["U"] = ^(s0s0B^&dD^&k7.162H
/R.F["b"] = ^(s0s1B^&d@^&k7.162H
/R.F["d"] = ^^&k7.162H
/R.F["i"] = ^(s1s0B^&d@^&k7.162H
/R.F["n"] = ^(s0s0B^&d@^&k7.162H
/R.F["r"] = ^(s0s0B^&d@^&k7.162H^*v1o1T
/R.F["t"] = ^(s1s1B^&d@^&k7.162H
/R.F["u"] = ^(s0s0B^&d@^&k7.162H

.: This applies to NPR Reports. :.

Using Page Renumbering

Use Case: print all patient and their prescriptions/drugs for a location.

Using page renumbering on the patient's account allows each patient's rx record to appear as if it were printed individually. If you only print 20 rx records per page; a patient with 30 medications would have 2 pages. You wouldn't want a patient's page 2 to be numbered as 15. So using page renumbering allows that patient's second page to be labeled as page 2.


.: This article applies to the NPR Report Writer. :.

Not NIL

NIL defined: the absence of a value. NIL is not NULL. NULL is a value. NIL is nothing or no value. NIL can be represented by an empty string: "".

To check for NIL I usually evaluate like this:

IF{@discharge.date_.="." "";1}

To do that in the NPR report select required a custom xx.field on the report picture.

To simplify your SELECT in the NPR report selects screen:

- set select field to: discharge.date
- set operator to: NE
- set prompt/value to: ""

Wow... much nicer than a custom field in the select.


.: This applies to NPR Report Writing :.

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 :.

Labels:

Defaulting # of Copies to Print - CS

To default the number of copies to be printed in a Client Server NPR report:

- set a macro in the report title
- set the number in /R.WIN.COPIES


.: This applies to Meditech Client Server NPR Report Writer :.

Saturday, September 22, 2007

Magic Equivalents in Client Server (CS)

$DDC(A) in Magic is %Z.debug(A) in Client Server.
$GE(A) in Magic is %G("") in Client Server.

G - Global
CH - Change Directories

CS Global: %Z.g("")

CS Launch App from CS NPR; in report title do:
"_%Z.zcus.launch.app.M.shell(0)_"

Call MS Word from CS NPR:
%Z.link.to.shell(PGM)

Open APP in CS: %Z.link.db({"NUR.CVI"},{"0"})
Open APP in Magic: %Z.link({"NUR.CVI"},{"0"})

Open DB in CS: %Z.rw.fragment("","RXM."_(@.db))

Magic MV Array Structure: /MV
CS MV Array Structure: /R.MV

Print an entire MEDITECH screen:
%MIS.SCREEN.print("screen",^@Root(customer.defined.queries),1,0)

CS Move Menus & Reports is under Updates in NPR.

NPR Keyboard: (these were discovered over a Citrix Connection)
- F1 to find or search in Magic is F2 in CS.
- Search & Replace trigger by the GREEN CHECK on the MEDITECH menu.
- Line attributes in CS: SHIFT + F2 instead of the usual F10 in Magic.
- Switch from picture to report regions. CTRL + < (left arrow). - Switch from report picture to report regions. CTRL + > (right arrow).
- Move left in report picture: SHIFT+CTRL + < (left arrow). - Move right in report picture: SHIFT+CTRL + > (right arrow).
- View all line attributes from report region. CTRL + F2.
- Insert report line below current line: CTRL + SHIFT + INSERT.
- Insert report line above current line: INSERT.
- CTRL + F3 from report picture in CS gives you cursor COL & ROW.
- CTRL + F6 convert case (UPPER to lower) and (lower to UPPER)
- SHIFT + F1 in a macro to FORMAT macro or FILE.
- SHIFT + F4 pull next macro line up to current line.
- CTRL + DEL removes fields from report picture (CS).

GET FILE:
Magic: F4
ObjectCode: %APP.DPM.zcus.report.M.macro
SourceCode: \APP.DPM.zcus.report.M.macro
CS: F5
DPM: APP.DPM
PROCEDURE: zcus.report.M.macro

MAGIC - Page Banner

@Z.rpt.no.ask.bn.ff - /R.NO.ASK.BN.FF
@Z.rpt.no.bn.ff - /R.NO.BN.FF

P - Page Banner
F - Suppress Formfeeds
B - Suppress Both
N - None

.: Originally posted to the Meditech-L by James Purvins for NPR Reporting :.

Friday, September 21, 2007

Reverse DO Loop

Do you detest messy code? I do. Reverse DO LOOPS are one tool in our box that help keep NPR code easy to read.

Normal Nested DO Loop:
""^Q,
DO{+/STRUCTURE[Q]^Q ""^QQ,
DO{+/ANOTHER.STRUCTURE[Q,QQ]^QQ "DO.SOMETHING"^#}}

Reverse DO Loop (same as a nested do loop, but cleaner):
""^Q,
DO{+/ANOTHER.STRUCTURE[Q,QQ]^QQ "DO.SOMETHING"^#;
+/STRUCTURE[Q]^Q ""^QQ,
}


.: This applies to NPR Report Macros. :.

MIS Report Scheduler

Report Schedule:
MIS
40 MIS Spooling
50 Report Schedules
51 Enter/Edit Report Schedule

To schedule date prompts MIS 4.8 #DTS 3398 says:

T/S Today
T-n/S Today minus "n" days
T+n/S Today plus "n" days
P/S Current Period
P-n/S Current Period minus "n" periods
P+n/S Current Period plus "n" periods
MB/S First Day of Current Month
MB-n/S First Day of Current Month minus "n" months
MB+n/s First Day of Current Month plus "n" months
ME/S Last Day of Current Month
ME-n/S Last Day of Current Month minus "n" months
ME+n/S Last Day of Current Month plus "n" months

The spool groups are configured under MIS.SPOOL.GROUP.
The scheduled reports are jobbed under MIS.JOB.mis.print.jobs.

NPR Report Writer - Date Prompt for the Scheduler

Minusing on a CS Data Structure

Minusing in CS: -(:(VIT)VITALS[""],D0)^X,D

Field Formatting

Until recently I'd perform field formatting (bold,italics,underline) in a LC line check. Next time I have a need to format fields conditionally, I'm going to try the CON field attribute.

The basic syntax is:

CON=IF{"some.value"="some.value" /R.F["b"];/R.F["i"]}^!

The attribute above prints the field in italics unless the condition above is true; then the field will be bolded.

You probably have to follow up the field with a line check to reset the text format? Then again, each field might do that on its own with a /R.F[""]^!. I'll check the object code next time I'm coding a report.


.: This article applies to Meditech NPR Report Writing :.

Pulling MEDITECH Code into Your Report

Use F4 (MAGIC) or F5 (Client Server) with a value of "\MIS.APPL.program.name" if you want to look at or retrieve source code for MIS.APPL.program.name. To retrieve the object code use the value: "%MIS.APPL.program.name".


.: This article applies to MEDITECH NPR Report Writing :.

All Application Databases No Fragging

To run a report for all application databases without fragging, put a sort field in your report picture: MIS.APPL.multi.database. Set:

Order="ASC"
Header="PAGE"
Trailer="Y"
Renumber Pages="N"

For frags embedded in your reports; use the MIS.APPL.multi.database as parameter B in your Z.rw.fragment call.


.: This article applies to Meditech NPR Report Writing :.

Seg Directory / Open Database

Set the local variable SEG to the system value for machine: $MAC^SEG

To SEG directories: $["SEGS"]("A","TEST.5.6.MIS")

To open database: %Z.link(":","BAR","%.BAR.data","BAR.XXX")

Dynamic Location/Database

If you need to run a report in a multi-location, multi-database hospital system; you want to code the logic for the database once and have it work everywhere.

One way to do this is use the database for the application you are in. Example: you have an ADM fragment call to NUR. You want the NUR fragment to dynamically know which database to use. You are running the ADM report in the ADM.CHW database. You want the frag to run in the NUR.CHW database.

Next time try this code to populate your database variable in the code:

@.db#1."^DATABASE

This will set the value of DATABASE to: CHW.

Then append the DATABASE to the module you want to work with: "NUR."_DATABASE^APP

The APP variable now contains the value: NUR.CHW


.: This article applies to Meditech NPR Report Writing :.

NPR - Setup MV Array in Footer

Joe Cocuzzo of Iatric Systems recently wrote about getting diets in a Z report.

I thought it particularly clever how he called the MV array from a FOOTNOTE instead of from the LINE where the MV array resided in the report picture. The footnote syntax is:

MV 3 MV.NAME

The 3 tells the report writer which report line to begin the MV array at. The MV.NAME would be the name of your MV array: DIET in Joe's example.


.: This article applies to Meditech NPR Report Writing :.

Wednesday, September 19, 2007

Printing a New Page When Calling a Fragment

This trick was originally posted here by Jim Prandi @ CRH Consulting.

I think Jim is saying to use the following code, when you want a fragment to print more than just detail; but a whole new page.

For CS:
^@Pgm.trans(%LAB.M.SPEC.zcus.mm.get.micro.results.RP)^@Z.rpt.new.page.pgm,
@CALL.REPORT.FRAGMENT,
^@Pgm.trans(%PHA.RX.zcus.mm.test.loc.RP)^@Z.rpt.new.page.pgm;

For MAGIC:
%LAB.M.SPEC.zcus.mm.get.micro.results.RP^@Z.rpt.new.page.pgm,
@CALL.REPORT.FRAGMENT,
%PHA.RX.zcus.mm.test.loc.RP^@Z.rpt.new.page.pgm;

A friend of mine was showing me a PHA Big Board and had a need to:

- have the report run continuously as a status board
- print PHA orders to the screen every few minutes
- print a fragment to a physical printer

We couldn't get the printer to switch in the fragment; next time we look at the PHA Big Board, we'll have to see if this resolves that issue.

Rotating a BarCode

QUESTION: Can anyone please tell me how to rotate a barcode on a label? Our wristband labels are looking a little too tight.

ANSWER: You might try sending a PCL code to the printer: http://pcl.to/reference/ before and after the barcode. Depending on how this report is setup; that could work.

The basic syntax before your barcode: (D(27)_("&a90P")^! which sends a 90 degree flip to the printer.

The basic syntax after your barcode: (D(27)_("&a270P")^! which sends a 270 degree flip to the printer.


.: This article applies to Meditech NPR Report Writing :.

Monday, September 17, 2007

Boosting Fragment Peformance in NPR

Jim Purvins at INHS posted this to the Meditech-L recently:

"Most of the time just replacing the priming /R.FRAG.ARG slash file with the
/R.TF temp file and subsequently doing a one time call can increase
optimization many fold."

I can't wait to try it.

Identifying Report Performance Issues

Overview:

Most programming gurus agree that you should get something to work before addressing performance issues. After you have the working program, try this approach to address performance issues.

Instructions:

1. Open your NPR report. On page 1 define a report trailer. On page 3 setup 2 report trailer lines for an MV array.

2. On page 3, add a new FIELD. Set the field up as an MV array.
xx.log.entries
JFY=L
LEN=75
VAL=xx.log.entries

3. Set the MV line attribute = LOGGING

4. Send the name of your routine and time to your MV array.

Sample usage:

“GETPATIENTLIST”^/ROUTINE,@LOG.TIME,@GET.PATIENTS,

Code for your macro where you’ll be logging:

LOG.TIME
%Z.time.lapse((@GETTIME(0))\86400)^/MV.TEXT,
(/MV.TEXT_","_/ROUTINE):0X^/MV.TEXT,
/MV.TEXT^/MV[“LOGGING”,/MV.TEXT,/FIELD.NUMBER],
1

GETTIME
S


.: This is in reference to NPR Report Performance. :.

Labels:

MAGIC - Shortcuts on PC

Control F2: Toggle Insert/Replace as you type.
Control F3: Display all attributes.
Control Left Arrow: Scroll to the left of the report picture.
Control Right Arrow: Scroll to the right of the report picture.
End: Place cursor on right of screen.
F1: Mark Beginning of Copy Block
F2: Mark End of Copy Block
F3: Edit Line Attributes
Home: Place cursor at left of screen.
Insert (in region): Insert new line in region above current line
Insert: Insert Block
Shift Delete: Delete Line or Data in Field
F10: Delete Line or Data in Field
Shift Insert: Insert new line in region below current line
Shift Left Arrow: Move cursor from report picture to the regions.
Shift Right Arrow: Move cursor from report regions to the picture.
Shift Up Arrow (in a field): Scroll to beginning of field.
Shift Down Arrow (in a field): Scroll to end of field.
Shift Up Arrow (on report picture): Move cursor up on picture.
Shift Down Arrow (on report picture): Move cursor down on picture.

MEDITECH - Open Printer / Close Printer

Open Printer:
$DEV.O(^!,printer)

Send Data to Printer:
; NPR Report Writer
DATA^!

Close Printer
$DEV.C(^!)

Friday, September 07, 2007

IPeople Forums

IPeople Forums

Thursday, September 06, 2007

Sum Ascii Values for Characters in a String

ZS(STRING) returns the ASCII total for all bytes in the variable STRING.

If STRING = "ABC" the returned value will be 198

I think of this as the .NET equivalent of a hash for the NPR Report Writer.

Patient Expired (MEDITECH MAGIC)

; PID 30 Patient Death Indicator
?EA[*AA[P.urn]]|22^/EXPIRED.DATE,
IF{/EXPIRED.DATE "Y";"N"}^/EXPIRED

Wednesday, September 05, 2007

MEDITECH Validation Guides

Link: MEDITECH Validation Guides (Hospital Access Required)

Tuesday, September 04, 2007

Suppress NPR "Print On" Prompt

1^/Z.SCHED.LOG

Suppress NPR "No Records Found" Prompt

To suppress the no records found prompt in the NPR Report Writer:

Add a footnote: AL START 1^/R.FOUND^/R.PAGE.NUM

OR

Put this in a macro:

1^/R.FOUND^/R.PAGE.NUM

Tuesday, August 28, 2007

MEDITECH Knowledge Base

Link: MEDITECH KB (Hospital Access Required)

MEDITECH String Manipulation

Why re-write it? Double T already did it: http://www.thomast357.com/magic_str.htm for the NPR Report Writer.

Saturday, August 25, 2007

Z.debug

%Z.debug("Debug Text","Device Optional")

This program returns a nil after invoking the debugger screen.

Monday, May 21, 2007

NPR Macro Template (Example)

;*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#
;
; Purpose: Centralize most used code from NPR reports NUR.
; Created: John Sharpe on August 13th, 2005
; Last Modified: John Sharpe on December 17th, 2005
; Name: write.data
; Macro Type: Program (Program / Footnote)
; Parameters: A as routine: 1=write.dynamic.text
; 2=write.to.mv
; 3=flatten.mv.tracker
; B as mv array
; C as field number
; D as line length
; E as number of spaces to indent
; F as data order
;
;*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#;
B^/MV.ARRAY,
C^/FN,
D^/LINE.LENGTH,
E^/INDENT.SPACES,
F+1^/DATA.ORDER,
;
IF{A=1 @WRITE.DYNAMIC.TEXT;
A=2 @WRITE.TO.MV;
A=3 @FLATTEN.MV.TRACKER},
;
1;

WRITE.DYNAMIC.TEXT
; Purpose: Write dynamic strings of text to /MV[] as MS Word would.
; Programmer: JNS12 on January 26th, 2005
; Inputs: /RESPO (Strings), /LINE.LENGTH (Integer), /INDENT.SPACES (String)
; Outputs: /MV[]
;
""^NXT.STR,
""^NXT.CHAR,
""^/W.CTR,
DO{+/RESPO[/W.CTR] @GET.NXT.STR,
@PROCESS.NXT.STR;
IF{L(STOR.LIN:0S)>0 STOR.LIN^/MV.TEXT,
""^STOR.LIN,@WRITE.TO.MV}}


.: This relates to Meditech Programming. :.

Thursday, May 10, 2007

Bypassing Syntax Checker From Screens

This is how MEDITECH does it for the NPR Report Writer:

%["MIS.APPL.ee.check.npr"](0)

Tuesday, May 08, 2007

OE Account Look Up after ADM Purge

When the patient for an OE report has already been purged from ADM, you can use the ADM MRI Pointer structure to find the account for OE.

You can use ?PT[ (OE.RES.oe.report) offset 2 to look up the account in the MRI Pointer structure.

?PT[5008] = ^MR^ER^V5337787678^Draft^20060201^0201-0105^1^^20060201^1542

+:AAMP[?PT[5008]|2,""]^Q,
+:AAMP[?PT[5008]|2,Q]|1^ACCOUNT.NUMBER

Thursday, April 19, 2007

Download $T Code to PC

$COPY2DOS.TEXT(%DOLLART.PROGRAM.NAME,"FILE.PATH.ON.PC")

Wednesday, March 21, 2007

Calling Report Values Not Crossing to Fragment

=== QUESTION ===
I’m trying to send a 'select' order.date the user puts in over to a frag so that it runs the frag for the same date range:

b.order.date^/STARTDATE
e.order.date^/ENDDATE


And then in the fragment:

start.date EQ /STARTDATE

It doesn’t like that at all not sure if it’s the b.order.date or what.

=== ANSWER ===
The NPR report writer cleans up variables that don't start with /R.FRAG.VAL.

In the calling report:
b.order.date^/R.FRAG.STARTDATE,
e.order.date^/R.FRAG.ENDDATE,

In the report fragment:
start.date EQ /R.FRAG.STARTDATE
end.date EQ /R.FRAG.ENDDATE


.: This relates to NPR Fragment. :.

Tuesday, March 13, 2007

MEDITECH Date Formatting & Other Date Solutions

Return current time: %Z.time.out(S(0))

Return yesterday’s date as YYYYMMDD: %Z.date.in("T-1").

Return yesterday’s date as: MM/DD/YY: %Z.date.out(%Z.date.in("T-1")).

Return a date from 4 days ago as YYYYMMDD: %Z.date.in.magic(@.sd-(86400*4)).

Return first day of the current month: %Z.date.in.magic(@.sd)^/D,/D$6_"01"^/DATE.

Return the number of days since the first day of the current month:
%Z.date.in.magic(@.sd)$6_"01"^/MON.START.DATE,
%Z.date.in.magic(@.sd)^/TODAY,
%Z.date.sub(/TODAY,/MON.START.DATE)^/MTD.DAYS

Return Start & Stop Date for Last 3 Months:
%Z.date.add(@.today$6_"01","0-1")^DATE^STOP.DATE,
%Z.date.add(DATE$6_"01","0-1")^DATE,
%Z.date.add(DATE$6_"01","0-1")^DATE,
DATE$6_"01"^START.DATE

Labels:

Thursday, March 08, 2007

NPR Report Request Form Elements

1) Report Title
2) Priority on a 10 scale.
3) Facility
4) Service Line / Department
5) Contact Information for Point Person on Requesting Side
6) Hard copy of form or report you use now? Screen Shots? Mockup/
7) Report Purpose
8) Report Description
9) Report Criteria / Sort Criteria / Data Elements / Applications
10) Report Scheduling (daily,weekly,monthly)
11) Does the report need subtotals, totals or summary information?
12) Submission Date
13) Date report is needed.
14) Date report request is submitted.

Printing Variable Number of Report Copies

Allowing the user to print a variable number of copies for an NPR report is easy. Add a report header line to the report. Update the user’s SELECTs. Add a LINE CHECK to send the PCL sequences with the number of copies to be printed to the printer. Add a new custom field to the report.

1) Open NPR report
2) Go to page 1 and enter Report Header = Y. If the report already contains a report header,leave the header alone.
3) Go to page 2 and add a new SELECT FIELD: xx.num.copies IG Number of Copies: “1” This defaults the number of copies to 1.
4) Go to page 3. If a header existed without you adding it, then insert a new header line; otherwise continue on.
5) Add a line check to the 1st report header line. LC=(D(27)_"&l"_(c.xx.num.copies)_"X")^!,"" 6) Add a new field to the report: xx.num.copiesDAT=PINTJFY=RLEN=2VAL=c.xx.num.copies

Friday, March 02, 2007

Using Kill in NPR

Question:

I’ve got this line of code in a macro: @Kill(@Root(@med.temp)). Won’t file with that – what can I replace it with, or do I even need it?

Response:

I would look at the object code and you'll see it translates to K(some structure). Instead of doing a kill, do a loop thru the structure if you really want to get rid of it. ""^Q,DO{>:SOME.STRUCTURE[Q]^Q ""^{>:SOME.STRUCTURE[Q]} That's the safe way to do a kill. I use Kill all day long, but it is very dangerous. If you do this K(:STRUCTURE[""]) to kill all records like :STRUCTURE["",SECOND.SUB] that kill would really kill the whole structure, which is very bad in some cases. So its best to just go after the data you really want to get rid of.

Its best not to bypass the syntax checker in the NPR Report Writer; unless its your only option.

Friday, November 17, 2006

Open Slash File

Open command to a slash file, do the following: O(\,"P") is changed to @O.OPEN(\,"P") with the subroutine defined below:

O.OPEN
O

Monday, October 09, 2006

NPR.LF

- Error: Customer R/W - Edits to Data Structures not allowed!
- Error: Customer R/W - Invalid syntax found!

.: NPR Report Writer Syntax Checker :.

Monday, February 20, 2006

Queuing & Unqueuing Values in MEDITECH MAGIC

Queuing Values:
(Slash variable /VAL|0 will equal 1, /VAL|1 will equal 2, /VAL = ^1^2)
Example 1) {1,2}^/VAL
Example 2) Q(1,2)^/VAL
Example 3) 1^/VAL|0,2^/VAL|1

Unqueuing Values:
(/ONE will equal 1, /TWO will equal 2)
Example 1) ""^/ONE^/TWO,/VAL^{/ONE,/TWO}
Example 2) ""^/ONE^/TWO,U(/VAL)^/ONE,U(/VAL)^/TWO
Example 3) /VAL|0^/ONE,/VAL|0^/TWO

.: This relates to NPR Reports & Macros. :.

Wednesday, February 08, 2006

Remove Corrupted Macro NPR Report

Earlier in the week, we had a corrupted macro that would crash the MediTech session when that macro was edited.

Steps to resolve the problem were:

- backed up the report
- downloaded the report to my pc
- deleted the offending macro
- uploaded the macro
- compiled the macro

This has resolved the problem with minimal effort on my part.

Tuesday, January 31, 2006

Printing MV Arrays In Page Trailers

If you want to print an MV array or structure in an NPR report page trailer, keep the following in mind.

MediTech's MV array logic always clears the MV array once it has been processed. This means the MV array will only print on the first page. You want the MV array to print on all pages.

Using the NPR Report Writer, create a blank NPR report. Setup the fields you will need to print in the trailer. Setup your MV array line attribute. Print the object code. Write your own macro and using the object code as your guide. Call the macro from the report picture in the page trailer region where you want the MV array to print. Do not decrement your line counter in the page trailer (/.LL-1^/.LL). Don't clear the MV array in the macro you use to print the MV array.

Labels:

Friday, January 27, 2006

Regular Magic Expressions

To strip all non-numerics from a string:
(STRING'~(D(255):48_("0123456789")_(D(255):70)))^STRING

To strip all non-alphas from a string:
(STRING'~(D(255):65_"ABCDEFGHIJKLMNOPQRSTUVWXYZ"_(D(255):6)_"abcdefghijklmnopqrstuvwxyz"_(D(255):5)))^STRING

To upper case a string:
Magic: (STRING~$L.TO.U)^STRING
CS: STRING@Trl2u^STRING

To lower case a string:
(STRING~$U.TO.L)^STRING

Wednesday, January 25, 2006

Reordering Comma Delimited Name

(@patient's.name#"1, ")_" "_(@patient's.name#"0, ")

Tuesday, January 24, 2006

Optional Group Response Query

NUR APPLICATION:
VAL=IF{"QUERY-1234"^td.query^MIS.QUERY.mnemonic,
VAL=@MIS.QUERY.group.resp^MIS.GROUP.RESP.mnemonic,
VAL=@td.value^MIS.GROUP.RESP.element.mnemonic
VAL= IF{@MIS.GROUP.RESP.element.response;@td.value}}

ADM APPLICATION:
VAL=IF{"QUERY-1234"^ADM.PAT.ccdqr.query^MIS.QUERY.mnemonic,
VAL=@MIS.QUERY.group.resp^MIS.GROUP.RESP.mnemonic,
VAL=@ADM.PAT.ccdqr.response^MIS.GROUP.RESP.element.mnemonic
VAL= IF{@MIS.GROUP.RESP.element.response;@ADM.PAT.ccdqr.response}}

Printing CCDQR response with query text for NUR in CS:
VAL=IF{"SOME.QUERY"^ccdqr.query,@ccdqr.response^X_.=.;@MIS.QUERY.text_" "_X}

Monday, January 23, 2006

Default MEDITECH NURSING NPR Report Setup

Accept all NPR defaults other than:

DPM: NUR.PC.WORK
Detail Segment: nur.pc.work.file
Index: None, the nur.pc.work.file is subscripted by patient.
Chars/Line: 130
Lines/Page: 66
Page Size: 66

Saturday, January 21, 2006

MEDITECH NPR Download Tips

If you want a report to download to your pc or server; you aren't tied to the size limitations inherent in using standard paper.

1) Set Lines/Page = Page Size Note: in CS you can use PFF NO as a footnote.
2) Add a report header with column headings delimited by your delimiter: a "," comma for example.
3) Set FootNote FD 44 (44 is the ASCII value for a comma ",")
4) Set FootNote SFF NO (Starting Form Feed = NO)
5) Set FootNote EFF NO (Ending Form Feed = NO)
6) Set FootNote PFF NO (Page Feed = NO) Note: PFF is CS only.
7) RL 900 combined with NL=NO allows you to place fields on multiple lines;
while achieving a line length of 900 characters. If you need more length;
change the FootNote RL value to 3600 or whatever you need. NL=NO should be
placed on all lines except the last line where you have fields.

Download File Variable: /MIS.SPOOL.c.filename = P:\Report.txt

Ftp File Variable:
"Pymt&Adj"_(%Z.date.in.magic(@.sd))_".txt"^/ZFTP.TITLE

.: This refers to MEDITECH Downloads in the NPR Report Writer. :.

Labels:

Thursday, January 19, 2006

Matching Report Picture Page Starting Points

Do you want a clear flow from report to report fragment and back? If so... don't forget to make sure all pages for a report start at the same coordinates, set your Lines/Page & Page Size are set to the same value.


.: This topic relates to Meditech NPR Report Fragments. :.

Wednesday, January 18, 2006

MEDITECH Date & Time Stamp

"Report Printed: "_(%Z.date.out(@.today))_" "_/R.TIME)

Labels:

Monday, January 16, 2006

Reducing Time to Find a Report

One thing that can delay resolving a user's NPR report problem is not knowing which report they need assistance with. By concatenating text like: "Report: " with one of the lines below you can print the report name on the report. I like putting mine on the page footer section of the NPR report.

- (/R.NEW.PAGE.PGM^PGM$(L(PGM)-3))
- /R.NEW.PAGE.PGM^/RPT$L(/RPT,".RP")

Thursday, January 12, 2006

Magic Operators

SUBSTRING
------------------
$n left of n
#n unit of n "on"
%n right of n

suffixes #nx

" " characters
S subscripts
A tokens
P packed ()
(queued)
------------------
FORMAT :
n = repeat
nR right n long
nL left n long
nT truncate to n
nC center in n
nM money
nD n decimal
nP n sig. digits
"S" strip spaces
"X" strip non-prt
nA amount n long
------------------
Boolean
& Minimum "and"
! Maximum "or"
------------------
Pattern Match ?
nA Alphabetic
nN Numeric
nP Punctuation
nM Money nnn.nn
nD Decimal nnn.n
nI Numeric
------------------
File Access
> Next Physical
< Prev Physical
+ Next Logical
- Prev Logical

Wednesday, January 11, 2006

Dynamic MEDITECH Value Truncation

Typically, programmers truncate magic values like this: /DATA:10TL^/VARIABLE. The report writer will not translate this attempt at dynamic truncation: /DATA:/LENTL because /LENTL is now the name of a variable. To dynamically truncate a value based on a previously defined length, use the following method.

1) Get the length. Here we are retrieving the length of the data from the MIS Query Dictionary.
- @MIS.QUERY.length^/LEN
2) Truncate the data and store in another variable.
- /DATA:(/LEN_"TL")^/VARIABLE

Sunday, January 08, 2006

MEDITECH Pop Up Windows

MacroSyntaxDescription
Display@Display(fld,screen or *,value)Used in procedure logic to display a value for a field on the screen.
W.return@W.return(“Message”)Displays message to the screen and waits for the user to press
W.err@W.err(“Message”)Same as above, but rings the bell first
W.display@W.display(“Message”)Displays message but does not wait for
@W.display(“”)Closes the window
W.yes.no@W.yes.no(“Message”)Displays message and waits for the user to enter either Y or N
W.yes.no.nil@W.yes.no.nil(“Message”)Same as above but a nil response is also valid
W.yes.no.y@W.yes.no.y(“Message”)Same as W.yes.no, but defaults a “Y”
W.yes.no.y.nil@W.yes.no.y.nil(“Message”)Same as above but a nil is valid
W.yes.no.n@W.yes.no.n(“Message”)Same as W.yes.no, but defaults a “N”
W.yes.no.n.nil@W.yes.no.n.nil(“Message”)Same as W.yes.no.n, but a nil is valid

Friday, January 06, 2006

MEDITECH Macro Naming Conventions

For a while now, I've been consolidating standard logic from reports into a single report. I call this single report a code library.

I have an allergy/medication routine that until now existed in our Adult & Peds Anesthesia Summary & Adult, Newborn, Obstetrics & Pediatrics Admission Summary reports. Over time this routine has evolved into something generic and very useful. The next step in the process is to move this routine to the code library. I have to ask myself how I will manage changes between facilities and service lines at those facilities.

The last thing I want to do is implement a centrally managed, generic solution and then move the logic back to reports as problems surface. The first problem I can see is a need to change medications but not allergies or vice versa.

The solution may be to implement a set of 2 macros for each set of information (allergies, meds):

1. a setup routine and a data processing routine for allergies
2. a setup routine and a data processing routine for medications

The setup routine would specify queries, data elements or screen ranges to be processed. The data processing routine would gather data to a specified array.

At this time, all facilities I support currently have similar needs. In the future, a facility may need a different solution than the majority of facilities I support.

The solution to this problem may be resolved using a naming convention:

DPM.report.M.allergies.1
DPM.report.M.medications.1

If a facility needs changes that differs from the majority:

DPM.report.M.allergies.facility.1
DPM.report.M.medications.facility.1

If a single department or line of service requires a solution different from the majority of departments at that facility:

DPM.report.M.allergies.facility.dept.1
DPM.report.M.medications.facility.dept.1


.: This relates to NPR Report Writer - Macros. :.

Thursday, January 05, 2006

MEDITECH Magic Case Conversion

The MEDITECH System does not have regular expressions, but it does have translation strings which function much like regular expressions.

Upper Case Conversion: "Alphabet"~$L.TO.U results in "ALPHABET"

Lower Case Conversion: "Alphabet"~$U.TO.L results in "alphabet"

Labels:

Sunday, January 01, 2006

Nexting Vs Physicals

Get value using physical address:

To get the name of the first account type in the bar account type dictionary; you could use a physical get like this: ""^Q,+(&BA[Q],X)^Q,X|1^NAME.

Get value using the NPR Report Writer syntax:

Assuming you have the bar.acct.type.dict segment defined as your detail segment, next on the subscript for that segment. ""^mnemonic,@Next(mnemonic),@name^NAME.

In both examples NAME would then contain the name of the first account type. You might choose to use the physical address if you are tight on the maximum number of character in a MEDITECH CDS attribute for example. But using the NPR Report Writer syntax allows less experienced programmers to maintain the code.


.: Physicals vs Standard NPR Report Writer Syntax :.

Friday, December 30, 2005

MEDITECH Function Macros

MacroSyntaxDescription
Add@Add(A,B)B+A^A
Sub@Sub(A,B)B-A^A
Sub0@Sub0(A,B)B-A!0^B; Makes sure we get a positive number
Max@Max(A,B)A!B
Min@Min(A,B)A&B
Not@Not(arg)Reverses the boolean logic of the argument
Title@Title(arg1,arg2)Makes data conversions and concatenates arguments
Quote@Quote(arg)Yields the passed in ‘arg’ in quotes.

MEDITECH Constant Variables from Slash


MacroDirect ReferenceExplanation
@.appl/.APPLName of application
@.db/.DBName of application database
@.copy/copyMulti-page screen variable
@.country/.CNTRYCountry of MIS (US,CANADA,OTHER)
@.device/.DEVUser’s input terminal
@.dir/.DIRCurrent directory
@.exit.nks/exit.nksIf true, slash remains when the user exits
@.facility/.FACCurrent facility in multi-facility system
@.logical.device/.LOCLocation of user’s terminal
@.lookup/.LK# of entries to display in lookup
@.menu.arg/.MENU.ARGUsed by menus to pass arguments
@.mis/.MISName of MIS database
@.mri.pfx/.MPXMedical records prefix
@.job/.JOBThe process’ job number
**Can also use S(“J”)
@.on.device/.PRTLast response to “On Device” prompt
@.today/.DATCurrent date in YYYYMMDD format
@.user/.USRUser’s mnemonic

Thursday, December 29, 2005

NPR Report Writer Object Code Outline

1. INITIALIZATIONS
- set up "slash" variables (such as /.USR, /.DEV, etc.)
- interpret report picture
- call setup program
- call graphics program
2. INCORPORATE AL START
3. INCORPORATE AL HR
4. PRINT HR REGIONS (gets executed no matter what -
records or no records)
5. PROCESS INDEX FILE
- no temp sort file specified
- temp sort file specified
6. PROCESS MASTER FILE SEGMENTS
7. GENERATE CODE TO ACCESS DATA FIELD
8. INCORPORATE AL AFTER.GET.MAIN
9. TOTALLING MULTIPLES
10. INCORPORATE AL BEFORE.PRINT
11. INCORPORATE AL HKn
12. PRINT HKn
13. INCORPORATE AL D
14. PRINT D REGION
15. PRINT MULTIPLES
16. INCORPORATE AL AFTER.D
17. INCORPORATE AL TKn
18. PRINT TKn REGIONS
19. INCORPORATE AL TR
20. PRINT TR REGIONS
21. PRINT TP REGIONS
22. INCORPORATE AL CLOSE.UP
23. CALL CLOSE UP PROGRAM
24. WRITE THE NEW PAGE PROGRAM

Wednesday, December 28, 2005

View MEDITECH Source Code for Z Programs

From the NPR Report Writer open a macro and perform an F4: \Z.age for example. This will return a view only representation of the code used in the Z.age routine.

MEDITECH Prefix Convention

PrefixOpens To
%Programs (Current Directory)
$O.S. System Utilities
#Input Device
/Temp File
\MIS Common Dictionaries
&Application Database Dictionaries
:Application Database File(s)
*Application Database File(s)
?Application Database File(s)
!Input

Introduction

Interesting problems and their solutions for the MEDITECH NPR Report Writer will be posted as they arise.