-
Notifications
You must be signed in to change notification settings - Fork 0
/
viewprescript.php
97 lines (81 loc) · 2.04 KB
/
viewprescript.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
<?php
/**
* Function to query information based on
* a parameter: in this case, location.
*
*/
if (isset($_POST['submit']))
{
try
{
require "config.php";
require "common.php";
$connection = new PDO($dsn, $username, $password, $options);
$sql = "SELECT *
FROM Prescription as a
INNER JOIN Patient as b ON a.idPatient = b.idPatient
INNER JOIN Physician as c ON a.idPhysician = c.idPhysician
INNER JOIN Drug as d ON a.idDrug = d.idDrug
WHERE b.idPatient = :idPatient";
$idPatient = $_POST['idPatient'];
$statement = $connection->prepare($sql);
$statement->bindParam(':idPatient', $idPatient, PDO::PARAM_STR);
$statement->execute();
$result = $statement->fetchAll();
}
catch(PDOException $error)
{
echo $sql . "<br>" . $error->getMessage();
}
}
?>
<?php
if (isset($_POST['submit']))
{
if ($result && $statement->rowCount() > 0)
{ ?>
<h2>Prescription History</h2>
<table>
<thead>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Patient ID Number</th>
<th>Date Prescribed</th>
<th>Prescribing Physician ID</th>
<th>Dosage</th>
<th>Frequency</th>
</tr>
</thead>
<tbody>
<?php
foreach ($result as $row)
{ ?>
<tr>
<td><?php echo escape($row["first_name"]); ?></td>
<td><?php echo escape($row["last_name"]); ?></td>
<td><?php echo escape($row["idPatient"]); ?></td>
<td><?php echo escape($row["dp"]); ?></td>
<td><?php echo escape($row["idPhysician"]); ?></td>
<td><?php echo escape($row["dosage"]); ?></td>
<td><?php echo escape($row["frequency"]); ?></td>
</tr>
<?php
} ?>
</tbody>
</table>
<?php
}
else
{ ?>
<blockquote>No results found for <?php echo escape($_POST['idPatient']); ?>.</blockquote>
<?php
}
}?>
<h2>View Patient Prescription History</h2>
<form method="post">
<label for="idPatient">idPatient</label>
<input type="text" id="idPatient" name="idPatient".>
<input type="submit" name="submit" value="View Results">
</form>
<a href="Patient.php">Back to Patient Management</a>