Sidebar

How can I pad the value in PID-3 with zeros so that the value is a specified legnth

0 votes
375 views
asked Sep 18, 2013 by gary-t-8719 (14,860 points)
In some cases we need to left pad the patient id in PID-3 with leading zeros so that the patient id is a specifed length.

1 Answer

0 votes
 
Best answer

You can use StringUtils to pad a string to a specified length.  Do something like this:
 
var pid3 = "129018";
var desiredDigits = 10;
var padChar = "0";
StringUtils.leftPad(pid3, desiredDigits, padChar);
answered Sep 26, 2013 by mike-r-7535 (13,830 points)
selected Dec 17, 2013 by ron-s-6919
...