Skip to content

Commit

Permalink
migration of route, interval, units, and form list for drugs/prescrip…
Browse files Browse the repository at this point in the history
…tions into lists and internationalization of drugs module
  • Loading branch information
bradymiller committed Jul 10, 2009
1 parent 15f562a commit 63c3803
Show file tree
Hide file tree
Showing 12 changed files with 260 additions and 214 deletions.
64 changes: 23 additions & 41 deletions interface/drugs/add_edit_drug.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
require_once("../globals.php");
require_once("$srcdir/acl.inc");
require_once("drugs.inc.php");
require_once("$srcdir/options.inc.php");

$alertmsg = '';
$drug_id = $_REQUEST['drug'];
$info_msg = "";
$tmpl_line_no = 0;

if (!acl_check('admin', 'drugs')) die("Not authorized!");
if (!acl_check('admin', 'drugs')) die(xl('Not authorized'));

// Format dollars for display.
//
Expand All @@ -30,40 +31,35 @@ function bucks($amount) {
// Write a line of data for one template to the form.
//
function writeTemplateLine($selector, $dosage, $period, $quantity, $refills, $prices, $taxrates) {
global $tmpl_line_no, $interval_array;
global $tmpl_line_no;
++$tmpl_line_no;

echo " <tr>\n";
echo " <td class='tmplcell drugsonly'>";
echo "<input type='text' name='tmpl[$tmpl_line_no][selector]' value='$selector' size='8' maxlength='100'>";
echo "<input type='text' name='form_tmpl[$tmpl_line_no][selector]' value='$selector' size='8' maxlength='100'>";
echo "</td>\n";
echo " <td class='tmplcell drugsonly'>";
echo "<input type='text' name='tmpl[$tmpl_line_no][dosage]' value='$dosage' size='6' maxlength='10'>";
echo "<input type='text' name='form_tmpl[$tmpl_line_no][dosage]' value='$dosage' size='6' maxlength='10'>";
echo "</td>\n";
echo " <td class='tmplcell drugsonly'>";
echo "<select name='tmpl[$tmpl_line_no][period]'>";
foreach ($interval_array as $key => $value) {
echo "<option value='$key'";
if ($key == $period) echo " selected";
echo ">$value</option>";
}
generate_form_field(array('data_type'=>1,'field_id'=>'tmpl['.$tmpl_line_no.'][period]','list_id'=>'drug_interval','empty_title'=>'SKIP'), $period);
echo "</td>\n";
echo " <td class='tmplcell drugsonly'>";
echo "<input type='text' name='tmpl[$tmpl_line_no][quantity]' value='$quantity' size='3' maxlength='7'>";
echo "<input type='text' name='form_tmpl[$tmpl_line_no][quantity]' value='$quantity' size='3' maxlength='7'>";
echo "</td>\n";
echo " <td class='tmplcell drugsonly'>";
echo "<input type='text' name='tmpl[$tmpl_line_no][refills]' value='$refills' size='3' maxlength='5'>";
echo "<input type='text' name='form_tmpl[$tmpl_line_no][refills]' value='$refills' size='3' maxlength='5'>";
echo "</td>\n";
foreach ($prices as $pricelevel => $price) {
echo " <td class='tmplcell'>";
echo "<input type='text' name='tmpl[$tmpl_line_no][price][$pricelevel]' value='$price' size='6' maxlength='12'>";
echo "<input type='text' name='form_tmpl[$tmpl_line_no][price][$pricelevel]' value='$price' size='6' maxlength='12'>";
echo "</td>\n";
}
$pres = sqlStatement("SELECT option_id FROM list_options " .
"WHERE list_id = 'taxrate' ORDER BY seq");
while ($prow = sqlFetchArray($pres)) {
echo " <td class='tmplcell'>";
echo "<input type='checkbox' name='tmpl[$tmpl_line_no][taxrate][" . $prow['option_id'] . "]' value='1'";
echo "<input type='checkbox' name='form_tmpl[$tmpl_line_no][taxrate][" . $prow['option_id'] . "]' value='1'";
if (strpos(":$taxrates", $prow['option_id']) !== false) echo " checked";
echo " /></td>\n";
}
Expand All @@ -84,7 +80,7 @@ function numericff($name) {
<html>
<head>
<?php html_header_show(); ?>
<title><?php echo $drug_id ? xl("Edit") : xl("Add New"); xl (' Drug','e'); ?></title>
<title><?php echo $drug_id ? xl("Edit") : xl("Add New"); xl('Drug','e',' '); ?></title>
<link rel="stylesheet" href='<?php echo $css_header ?>' type='text/css'>

<style>
Expand Down Expand Up @@ -148,7 +144,7 @@ function sel_related() {
"route = '" . escapedff('form_route') . "' AND " .
"drug_id != '$drug_id'");
if ($crow['count']) {
$alertmsg = "Cannot add this entry because it already exists!";
$alertmsg = xl('Cannot add this entry because it already exists!');
}
}

Expand Down Expand Up @@ -201,7 +197,7 @@ function sel_related() {
}

if ($_POST['form_save'] && $drug_id) {
$tmpl = $_POST['tmpl'];
$tmpl = $_POST['form_tmpl'];
// If using the simplified drug form, then force the one and only
// selector name to be the same as the product name.
if ($GLOBALS['sell_non_drug_products'] == 2) {
Expand Down Expand Up @@ -307,15 +303,9 @@ function sel_related() {
<tr class='drugsonly'>
<td valign='top' nowrap><b><?php xl('Form','e'); ?>:</b></td>
<td>
<select name='form_form'>
<?php
foreach ($form_array as $key => $value) {
echo " <option value='$key'";
if ($key == $row['form']) echo " selected";
echo ">$value\n";
}
generate_form_field(array('data_type'=>1,'field_id'=>'form','list_id'=>'drug_form','empty_title'=>'SKIP'), $row['form']);
?>
</select>
</td>
</tr>

Expand All @@ -329,30 +319,18 @@ function sel_related() {
<tr class='drugsonly'>
<td valign='top' nowrap><b><?php xl('Units','e'); ?>:</b></td>
<td>
<select name='form_unit'>
<?php
foreach ($unit_array as $key => $value) {
echo " <option value='$key'";
if ($key == $row['unit']) echo " selected";
echo ">$value\n";
}
generate_form_field(array('data_type'=>1,'field_id'=>'unit','list_id'=>'drug_units','empty_title'=>'SKIP'), $row['unit']);
?>
</select>
</td>
</tr>

<tr class='drugsonly'>
<td valign='top' nowrap><b><?php xl('Route','e'); ?>:</b></td>
<td>
<select name='form_route'>
<?php
foreach ($route_array as $key => $value) {
echo " <option value='$key'";
if ($key == $row['route']) echo " selected";
echo ">$value\n";
}
generate_form_field(array('data_type'=>1,'field_id'=>'route','list_id'=>'drug_route','empty_title'=>'SKIP'), $row['route']);
?>
</select>
</td>
</tr>

Expand All @@ -375,7 +353,7 @@ function sel_related() {

<tr>
<td valign='top' nowrap>
<b><?php xl($GLOBALS['sell_non_drug_products'] == 2 ? 'Fees' : 'Templates','e'); ?>:</b>
<b><?php $GLOBALS['sell_non_drug_products'] == 2 ? xl('Fees','e') : xl('Templates','e'); ?>:</b>
</td>
<td>
<table border='0' width='100%'>
Expand All @@ -393,13 +371,17 @@ function sel_related() {
"WHERE list_id = 'pricelevel' ORDER BY seq");
while ($prow = sqlFetchArray($pres)) {
$emptyPrices[$prow['option_id']] = '';
echo " <td><b>" . $prow['title'] . "</b></td>\n";
echo " <td><b>" .
generate_display_field(array('data_type'=>'1','list_id'=>'pricelevel'), $prow['option_id']) .
"</b></td>\n";
}
// Show a heading for each tax rate.
$pres = sqlStatement("SELECT option_id, title FROM list_options " .
"WHERE list_id = 'taxrate' ORDER BY seq");
while ($prow = sqlFetchArray($pres)) {
echo " <td><b>" . $prow['title'] . "</b></td>\n";
echo " <td><b>" .
generate_display_field(array('data_type'=>'1','list_id'=>'taxrate'), $prow['option_id']) .
"</b></td>\n";
}
?>
</tr>
Expand Down
10 changes: 5 additions & 5 deletions interface/drugs/add_edit_lot.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ function QuotedOrNull($fld) {
$lot_id = $_REQUEST['lot'];
$info_msg = "";

if (!acl_check('admin', 'drugs')) die("Not authorized!");
if (!$drug_id) die("Drug ID missing!");
if (!acl_check('admin', 'drugs')) die(xl('Not authorized'));
if (!$drug_id) die(xl('Drug ID missing!'));
?>
<html>
<head>
<?php html_header_show();?>
<title><?php echo $lot_id ? xl("Edit") : xl("Add New"); xl(' Lot', 'e'); ?></title>
<title><?php echo $lot_id ? xl("Edit") : xl("Add New"); xl('Lot','e',' '); ?></title>
<link rel="stylesheet" href='<?php echo $css_header ?>' type='text/css'>

<style>
Expand Down Expand Up @@ -125,10 +125,10 @@ function validate() {
<input type='text' size='10' name='form_expiration' id='form_expiration'
value='<?php echo $row['expiration'] ?>'
onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)'
title='yyyy-mm-dd date of expiration' />
title=<?php xl('yyyy-mm-dd date of expiration','e','\'','\''); ?> />
<img src='../pic/show_calendar.gif' align='absbottom' width='24' height='22'
id='img_expiration' border='0' alt='[?]' style='cursor:pointer'
title='Click here to choose a date'>
title=<?php xl('Click here to choose a date','e','\'','\''); ?>>
</td>
</tr>

Expand Down
10 changes: 5 additions & 5 deletions interface/drugs/destroy_lot.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ function QuotedOrNull($fld) {
$lot_id = $_REQUEST['lot'];
$info_msg = "";

if (!acl_check('admin', 'drugs')) die("Not authorized!");
if (!$drug_id) die("Drug ID missing!");
if (!$lot_id ) die("Lot ID missing!");
if (!acl_check('admin', 'drugs')) die(xl('Not authorized'));
if (!$drug_id) die(xl('Drug ID missing!'));
if (!$lot_id ) die(xl('Lot ID missing!'));
?>
<html>
<head>
Expand Down Expand Up @@ -110,10 +110,10 @@ function QuotedOrNull($fld) {
<input type='text' size='10' name='form_date' id='form_date'
value='<?php echo $row['destroy_date'] ? $row['destroy_date'] : date("Y-m-d"); ?>'
onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)'
title='yyyy-mm-dd date destroyed' />
title=<?php xl('yyyy-mm-dd date destroyed','e','\'','\''); ?> />
<img src='../pic/show_calendar.gif' align='absbottom' width='24' height='22'
id='img_date' border='0' alt='[?]' style='cursor:pointer'
title='Click here to choose a date'>
title=<?php xl('Click here to choose a date','e','\'','\''); ?>>
</td>
</tr>

Expand Down
29 changes: 15 additions & 14 deletions interface/drugs/dispense_drug.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
require_once("../globals.php");
require_once("$srcdir/acl.inc");
require_once("drugs.inc.php");
require_once("$srcdir/options.inc.php");
require_once($GLOBALS['fileroot'] . "/library/classes/class.phpmailer.php");
require_once($GLOBALS['fileroot'] . "/library/classes/class.ezpdf.php");

Expand All @@ -26,7 +27,7 @@ function send_email($subject, $body) {
$mail->Subject = $subject;
$mail->AddAddress($recipient);
if(!$mail->Send()) {
error_log("There has been a mail error sending to " . $recipient .
error_log(xl('There has been a mail error sending to','','',' ') . $recipient .
" " . $mail->ErrorInfo);
}
}
Expand All @@ -38,7 +39,7 @@ function send_email($subject, $body) {
$fee = $_REQUEST['fee'];
$user = $_SESSION['authUser'];

if (!acl_check('admin', 'drugs')) die("Not authorized!");
if (!acl_check('admin', 'drugs')) die(xl('Not authorized'));

if (!$drug_id ) $drug_id = 0;
if (!$prescription_id) $prescription_id = 0;
Expand All @@ -56,7 +57,7 @@ function send_email($subject, $body) {
//
if ($drug_id) {
$sale_id = sellDrug($drug_id, $quantity, $fee, $pid, 0, $prescription_id, $today, $user);
if (!$sale_id) die("Inventory is not available for this order.");
if (!$sale_id) die(xl('Inventory is not available for this order.'));

/******************************************************************
$res = sqlStatement("SELECT * FROM drug_inventory WHERE " .
Expand Down Expand Up @@ -112,7 +113,7 @@ function send_email($subject, $body) {
")");
*******************************************************************/

if (!$sale_id) die("Internal error, no drug ID specified!");
if (!$sale_id) die(xl('Internal error, no drug ID specified!'));

} // end if not $sale_id

Expand Down Expand Up @@ -150,16 +151,16 @@ function send_email($subject, $body) {
$label_text = $row['fname'] . ' ' . $row['lname'] . ' ' . $row['date_modified'] .
' RX#' . sprintf('%06u', $row['prescription_id']) . "\n" .
$row['name'] . ' ' . $row['size'] . ' ' .
$unit_array[$row['unit']] . ' QTY ' .
$row['quantity'] . "\n" .
'Take ' . $row['dosage'] . ' ' . $form_array[$row['form']] .
generate_display_field(array('data_type'=>'1','list_id'=>'drug_units'), $row['unit']) .
xl('QTY','',' ',' ') . $row['quantity'] . "\n" .
xl('Take','','',' ') . $row['dosage'] . ' ' .
generate_display_field(array('data_type'=>'1','list_id'=>'drug_form'), $row['form']) .
($row['dosage'] > 1 ? 's ' : ' ') .
// $interval_array_verbose[$row['interval']] . ' ' .
$interval_array[$row['interval']] . ' ' .
// $route_array_verbose[$row['route']] . "\n" .
$route_array[$row['route']] . "\n" .
'Lot ' . $row['lot_number'] . ' Exp ' . $row['expiration'] . "\n" .
'NDC ' . $row['ndc_number'] . ' ' . $row['manufacturer'];
generate_display_field(array('data_type'=>'1','list_id'=>'drug_interval'), $row['interval']) .
' ' .
generate_display_field(array('data_type'=>'1','list_id'=>'drug_route'), $row['route']) .
"\n" . xl('Lot','','',' ') . $row['lot_number'] . xl('Exp','',' ',' ') . $row['expiration'] . "\n" .
xl('NDC','','',' ') . $row['ndc_number'] . ' ' . $row['manufacturer'];

// if ($row['refills']) {
// // Find out how many times this prescription has been filled/refilled.
Expand Down Expand Up @@ -238,4 +239,4 @@ function send_email($subject, $body) {
</html>
<?php
}
?>
?>
19 changes: 12 additions & 7 deletions interface/drugs/drug_inventory.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
require_once("../globals.php");
require_once("$srcdir/acl.inc");
require_once("drugs.inc.php");
require_once("$srcdir/options.inc.php");

// Check authorization.
$thisauth = acl_check('admin', 'drugs');
if (!$thisauth) die("Not authorized.");
if (!$thisauth) die(xl('Not authorized'));

// get drugs
$res = sqlStatement("SELECT d.*, " .
Expand Down Expand Up @@ -64,14 +65,14 @@ function doiclick(id, lot) {

<table width='100%' cellpadding='1' cellspacing='2'>
<tr class='head'>
<td title='Click to edit'><?php xl('Name','e'); ?></td>
<td title=<?php xl('Click to edit','e','\'','\''); ?>><?php xl('Name','e'); ?></td>
<td><?php xl('Act','e'); ?></td>
<td><?php xl('NDC','e'); ?></td>
<td><?php xl('Form','e'); ?></td>
<td><?php xl('Size','e'); ?></td>
<td><?php xl('Unit','e'); ?></td>
<td title='Click to receive (add) new lot'><?php xl('Add','e'); ?></td>
<td title='Click to edit'><?php xl('Lot','e'); ?></td>
<td title=<?php xl('Click to receive (add) new lot','e','\'','\''); ?>><?php xl('Add','e'); ?></td>
<td title=<?php xl('Click to edit','e','\'','\''); ?>><?php xl('Lot','e'); ?></td>
<td><?php xl('QOH','e'); ?></td>
<td><?php xl('Expires','e'); ?></td>
</tr>
Expand All @@ -89,11 +90,15 @@ function doiclick(id, lot) {
htmlentities($row['name']) . "</a></td>\n";
echo " <td>" . ($row['active'] ? xl('Yes') : xl('No')) . "</td>\n";
echo " <td>" . htmlentities($row['ndc_number']) . "</td>\n";
echo " <td>" . $form_array[$row['form']] . "</td>\n";
echo " <td>" .
generate_display_field(array('data_type'=>'1','list_id'=>'drug_form'), $row['form']) .
"</td>\n";
echo " <td>" . $row['size'] . "</td>\n";
echo " <td>" . $unit_array[$row['unit']] . "</td>\n";
echo " <td>" .
generate_display_field(array('data_type'=>'1','list_id'=>'drug_units'), $row['unit']) .
"</td>\n";
echo " <td onclick='doiclick($lastid,0)'>" .
"<a href='' onclick='return false'>Add</a></td>\n";
"<a href='' onclick='return false'>" . xl('Add') . "</a></td>\n";
} else {
echo " <tr class='detail' bgcolor='$bgcolor'>\n";
echo " <td colspan='7'>&nbsp;</td>\n";
Expand Down
Loading

0 comments on commit 63c3803

Please sign in to comment.