| Current Path : /var/www/html/mmishra/icure/staff/ |
| Current File : /var/www/html/mmishra/icure/staff/medication.inc.bak |
<h3 align='left'>Medication</h3>
<?php
$tbl = 'medications';
$regno = $_REQUEST["regno"];
$disids = $_REQUEST["disid"];
$medid = $_POST["medid"];
$qty = ($_POST["qty"] ? $_POST["qty"] : 0);
$xqty = ($_POST["xqty"] ? $_POST["xqty"] : 0);
$j = 0;
if ($_POST["submit"] == 'SAVE') {
foreach ($disids as $disid) {
if (mysql_num_rows(mysql_query("select * from $tbl where dis_id=$disid"))) {
mysql_query("update $tbl set reg_no=$regno,med_id=$medid[$j],qty=$qty[$j],dis_datetime=now(),
date_updation=now(),login_id='$user' where dis_id=$disid");
//update medicine inventory
mysql_query("update medicines set qty_inhand=qty_inhand-$qty[$j]+$xqty[$j],qty_used=qty_used+$qty[$j]-$xqty[$j]
where med_id=$medid[$j]");
} else {
mysql_query("insert into $tbl(reg_no,med_id,qty,dis_datetime,date_creation,date_updation,login_id)
values($regno,$medid[$j],$qty[$j],now(),now(),now(),'$user')");
//update medicine inventory
mysql_query("update medicines set qty_inhand=qty_inhand-$qty[$j],qty_used=qty_used+$qty[$j]
where med_id=$medid[$j]");
}
$j++;
}
/*
$rs = mysql_query("select * from registrations where reg_no=$regno");
while ($o = mysql_fetch_object($rs)) {
$txt = patient_detail($o->pat_id);
$txt .= $o->reg_date $o->reg_time;
$txt .= doctor_detail($o->dr_id);
$email = 'mmishra@iiita.ac.in';
}
echo automailer($email, "iCure@IIITA", "Medicine receipt\n $txt");
*/
}
if ($_GET["del"] == 1) {
// mysql_query("delete from $tbl where dis_id=$disid");
//update medicine inventory
// mysql_query("update medicines set qty_inhand=qty_inhand+$xqty,qty_used=qty_used-$xqty
// where med_id=$medid");
}
?>
Registration No. <input type='text' name='regno' value='<?php echo $regno; ?>' size='10'>
<input type='submit' name='submit' value='FIND'>
<br><br>
<?php
if ($regno) {
if (is_registration($regno)) {
echo registration_detail($regno);
//if (is_prescription($regno)) {
// echo prescription_detail($regno);
echo "<font color='red'><b>Stocks of red marked medicines are in critical zone</b></font>
<table border='1' width='60%'>
<tr><th>Sr</th><th>Medicine</th><th>Qty</th><th>Date Time</th></tr>";
if (!$disid) {
echo "<tr><td>+</td>
<td>".medicine_list('','-')."</td>
<td align='center'><input type='text' name='qty' value='0' size='5'></td>
<td align='center'><input type='text' name='disdatetime' value='".date("Y-m-d H:i:s")."' size='20'></td>
</tr>";
} else {
echo "<tr><td colspan='5'><a href='staff/?pg=$pg®no=$regno&disid='>+</a></td></tr>";
}
$rs = mysql_query("select * from $tbl where reg_no=$regno order by med_id");
while ($o = mysql_fetch_object($rs)) {
$i++;
echo "<tr><td>$i</td>";
if ($disid == $o->dis_id) {
echo "<td><input type='hidden' name='disid[]' value='$o->dis_id'>
".medicine_list($o->med_id,'-')."<input type='hidden' name='xqty[]' value='$o->qty'></td>
<td align='center'><input type='text' name='qty[]' value='$o->qty' size='5'></td>
<td align='center'>$o->dis_datetime</td>";
} else {
echo "<td><a href='staff/?pg=$pg®no=$regno&disid=$o->dis_id'>".medicine_detail($o->med_id)."</a></td>
<td align='center'>$o->qty</td>
<td align='center'>$o->dis_datetime</td>";
}
echo "</tr>";
}
echo "</table>";
$dt = new datetime($o->dis_datetime);
$ddt = $dt->format('Y-m-d');
if ($ddt == date("Y-m-d")) echo "<input type='submit' name='submit' value='SAVE'>
<a href='staff/?pg=$pg®no=$regno&disid=$o->dis_id'>x</a>";
//} else
// echo "No prescription";
} else
echo "No registration";
}
?>