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

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

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.

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.

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

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="+"

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

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

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