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

0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Home