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

Meditech NPR Pad String Left with Zeros

 

Meditech Format StringAn Allscripts Extract recently called for a Drg Code padded with zeros to a length of 3.  Instead of a kludge like this: "000"_@ABS.PAT.drg.final^/DRG,L(/DRG)-(3-1)^POS,/DRG%POS^/DRG; I thought it would be more fun to write a procedure that could left or right pad any text string with any character to any length.

Here's what I came up with ... you can find this code at the Meditech Open Source Project.  

{@ABS.PAT.drg.final,0,"LEFT",3}^@PAD.CHARACTERS^/ICD9DIAGNOSISCODE,

PAD.CHARACTERS
; Pad left or right with any character.
{/TEXT.STRING.IN,/PAD.CHARACTER,/PAD.LEFT.RIGHT,/LENGTH},
DO{L(/TEXT.STRING.IN)</LENGTH IF{/PAD.LEFT.RIGHT="LEFT" /PAD.CHARACTER_/TEXT.STRING.IN;
                                 /PAD.LEFT.RIGHT="RIGHT" /TEXT.STRING.IN_/PAD.CHARACTER}^/TEXT.STRING.IN},
/TEXT.STRING.IN^/PAD.CHARACTERS

Now if you have a particular piece of Meditech NPR Report or SQL Extract, code you're proud of, that makes your life easier, might you think about sharing it with the rest of us? 

contribute-to-meditech-open-source
                                         

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

I could have used Zero Fill as well, but this will work nice when I want to fill with a character other than zero.
Posted @ Wednesday, August 03, 2011 10:13 AM by John Sharpe
Post Comment
Name
 *
Email
 *
Website (optional)
Comment
 *

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