Meditech NPR Pad String Left with Zeros
An 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?
Want an alert when the next post is published? Click the phone and Subscribe to the MEDITECH Reports Blog!