From 0abc9cde32ce0b46d12be0d17a8cec51325d3d68 Mon Sep 17 00:00:00 2001 From: Rod Roark Date: Fri, 3 Dec 2010 11:50:33 -0800 Subject: [PATCH] Added alpha option to formatting masks. --- interface/super/edit_list.php | 2 +- library/globals.inc.php | 6 +++--- library/textformat.js | 10 +++++++++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/interface/super/edit_list.php b/interface/super/edit_list.php index 7a937c114..db0f91de5 100644 --- a/interface/super/edit_list.php +++ b/interface/super/edit_list.php @@ -337,7 +337,7 @@ function writeCTLine($ct_array) { echo ctGenCell($opt_line_no, $ct_array, 'ct_just', 4, 15, xl('If billing justification is used enter the name of the diagnosis code type.')); echo ctGenCell($opt_line_no, $ct_array, 'ct_mask', 6, 9, - xl('Specifies formatting for codes. # = digit, * = any character. Empty if not used.')); + xl('Specifies formatting for codes. # = digit, @ = alpha, * = any character. Empty if not used.')); echo ctGenCBox($opt_line_no, $ct_array, 'ct_fee', xl('Are fees charged for this type?')); echo ctGenCBox($opt_line_no, $ct_array, 'ct_rel', diff --git a/library/globals.inc.php b/library/globals.inc.php index 72440a2fe..05de1a4b4 100644 --- a/library/globals.inc.php +++ b/library/globals.inc.php @@ -445,21 +445,21 @@ $GLOBALS_METADATA = array( xl('Mask for Patient IDs'), 'text', // data type '', // default - xl('Specifies formatting for the external patient ID. # = digit, * = any character. Empty if not used.') + xl('Specifies formatting for the external patient ID. # = digit, @ = alpha, * = any character. Empty if not used.') ), 'gbl_mask_invoice_number' => array( xl('Mask for Invoice Numbers'), 'text', // data type '', // default - xl('Specifies formatting for invoice reference numbers. # = digit, * = any character. Empty if not used.') + xl('Specifies formatting for invoice reference numbers. # = digit, @ = alpha, * = any character. Empty if not used.') ), 'gbl_mask_product_id' => array( xl('Mask for Product IDs'), 'text', // data type '', // default - xl('Specifies formatting for product NDC fields. # = digit, * = any character. Empty if not used.') + xl('Specifies formatting for product NDC fields. # = digit, @ = alpha, * = any character. Empty if not used.') ), 'force_billing_widget_open' => array( diff --git a/library/textformat.js b/library/textformat.js index 2d6a8b6ab..11fcec65a 100644 --- a/library/textformat.js +++ b/library/textformat.js @@ -239,13 +239,18 @@ function maskkeyup(elem, mask) { var ec = v.charAt(i); var mc = mask.charAt(i); if (mc == '#' && (ec < '0' || ec > '9')) { + // digit required but this is not one + break; + } + if (mc == '@' && ec.toLowerCase() == ec.toUpperCase()) { + // alpha character required but this is not one break; } } v = v.substring(0, i); while (i < mask.length) { var mc = mask.charAt(i++); - if (mc == '*' || mc == '#') break; + if (mc == '*' || mc == '#' || mc == '@') break; v += mc; } elem.value = v; @@ -257,15 +262,18 @@ function maskblur(elem, mask) { var v = elem.value; var i = mask.length; if (i > 0 && v.length > 0 && v.length != i) { + // there is a mask and a value but the value is not long enough for (; i > 0 && mask.charAt(i-1) == '#'; --i); // i is now index to first # in # string at end of mask if (i > v.length) { + // value is too short even if trailing digits in the mask are ignored if (confirm('Field entry is incomplete! Try again?')) elem.focus(); else elem.value = ''; return; } + // if the mask ends with digits then right-justify them in the value while (v.length < mask.length) { v = v.substring(0, i) + '0' + v.substring(i, v.length); } -- 2.11.4.GIT