About MEDITECH Reports

 

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

Connect ...

Expand your network by connecting on these social media sites:

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

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

MEDITECH NPR & RW RESOURCES:

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

HIT Topics

MEDITECH Reports

Current Articles | RSS Feed RSS Feed

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.

Want an alert when the next post is published? Click the phone and Subscribe to the MEDITECH Reports Blog!

Subscribe to the Meditech Blog     

                                                                                                                                                                                                          

Comments

Currently, there are no comments. Be the first to post one!
Post Comment
Name
 *
Email
 *
Website (optional)
Comment
 *

Allowed tags: <a> link, <b> bold, <i> italics