-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprescriptionorder.php
157 lines (150 loc) · 4.32 KB
/
prescriptionorder.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<?php
include("adheader.php");
include("dbconnection.php");
if(isset($_POST['submit']))
{
if(isset($_GET['editid']))
{
$sql ="UPDATE prescription SET treatment_records_id='$_POST[treatmentid]',doctorid='$_POST[select2]',patientid='$_POST[patientid]',prescriptiondate='$_POST[date]',status='$_POST[select]' WHERE prescription_id='$_GET[editid]'";
if($qsql = mysqli_query($con,$sql))
{
echo "<script>alert('prescription record updated successfully...');</script>";
}
else
{
echo mysqli_error($con);
}
}
else
{
$sql ="INSERT INTO prescription(treatment_records_id,doctorid,patientid,prescriptiondate,status) values('$_POST[treatmentid]','$_POST[doctorid]','$_POST[patientid]','$_POST[date]','Active')";
if($qsql = mysqli_query($con,$sql))
{
$insid= mysqli_insert_id($con);
$prescriptionid= $insid;
$prescriptiondate= $_POST['date'];
$billtype="Prescription charge";
$billamt=0;
$sql ="UPDATE orders SET deliverydate='$_POST[date]', status ='Active',prescriptionid='$prescriptionid' WHERE orderid='$_GET[orderid]'";
$qsql = mysqli_query($con,$sql);
echo "<script>alert('prescription record inserted successfully...');</script>";
echo "<script>window.location='prescriptionorderdetail.php?prescriptionid=" . $insid . "&patientid=$_GET[patientid]';</script>";
}
else
{
echo mysqli_error($con);
}
}
}
if(isset($_GET['editid']))
{
$sql="SELECT * FROM prescription WHERE prescriptionid='$_GET[editid]' ";
$qsql = mysqli_query($con,$sql);
$rsedit = mysqli_fetch_array($qsql);
}
if(isset($_GET['orderid']))
{
$sqlorders ="SELECT * FROM orders where orderid='$_GET[orderid]' ";
$qsqlorders = mysqli_query($con,$sqlorders);
$rsorder = mysqli_fetch_array($qsqlorders);
}
?>
<div class="wrapper col2">
<div id="breadcrumb">
<ul>
<li class="first">Add New Prescription</li></ul>
</div>
</div>
<div class="wrapper col4">
<div id="container">
<h1>Add new prescription record</h1>
<form method="post" action="" name="frmpres" onSubmit="return validateform()">
<input type="hidden" name="patientid" value="<?php echo $rsorder['patientid']; ?>" />
<input type="hidden" name="doctorid" value="<?php echo $rsorder['doctorid']; ?>" />
<input type="hidden" name="treatmentid" value="0" />
<table width="200" border="3">
<tbody>
<tr>
<td>Patient</td>
<td>
<?php
$sqlpatient= "SELECT * FROM patient WHERE status='Active' AND patientid='$rsorder[patientid]'";
$qsqlpatient = mysqli_query($con,$sqlpatient);
while($rspatient=mysqli_fetch_array($qsqlpatient))
{
echo "$rspatient[patientid]- $rspatient[patientname]";
}
?></td>
</tr>
<tr>
<td width="34%">Doctor</td>
<td width="66%">
<?php
$sqldoctor= "SELECT * FROM doctor WHERE status='Active'";
$qsqldoctor = mysqli_query($con,$sqldoctor);
while($rsdoctor = mysqli_fetch_array($qsqldoctor))
{
if($rsdoctor['doctorid'] == $rsorder['doctorid'])
{
echo "<option value='$rsdoctor[doctorid]' selected>$rsdoctor[doctorid]-$rsdoctor[doctorname]</option>";
}
}
?></td>
</tr>
<?php
if(isset($_SESSION['adminid']))
{
?>
<tr>
<td>Expected Delivery Date</td>
<td><input type="date" name="date" id="date" value="<?php echo date("Y-m-d"); ?>" /></td>
</tr>
<?php
}
?>
<tr>
<td colspan="2" align="center"><input type="submit" name="submit" id="submit" value="Submit" /></td>
</tr>
</tbody>
</table>
<p> </p>
</div>
<div class="clear"></div>
</div>
</div>
<?php
include("adfooter.php");
?>
<script type="application/javascript">
function validateform()
{
if(document.frmpres.select2.value == "")
{
alert("Doctor name should not be empty..");
document.frmpres.select2.focus();
return false;
}
else if(document.frmpres.select3.value == "")
{
alert("Patient name should not be empty..");
document.frmpres.select3.focus();
return false;
}
else if(document.frmpres.date.value == "")
{
alert("Prescription date should not be empty..");
document.frmpres.date.focus();
return false;
}
else if(document.frmpres.select.value == "" )
{
alert("Kindly select the status..");
document.frmpres.select.focus();
return false;
}
else
{
return true;
}
}
</script>