-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcancelProcedure.php
More file actions
151 lines (124 loc) · 5.43 KB
/
cancelProcedure.php
File metadata and controls
151 lines (124 loc) · 5.43 KB
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
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
include("connection.php");
session_start();
$error = null;
if (isset($_POST["submit"])) {
$procedureID = $_POST['procedureID'];
$IDexists = checkIfProcedureExists($procedureID, $con);
if (!$IDexists) {
// Patient does not exist, send an error message
echo '<script>
alert("Procedure can not be found. Reenter valid information.");
window.location.href = "cancelProcedure.php"
</script>';
exit();
}
echo '<script>
const confirmation = confirm("Are you sure that you want to cancel an procedure?");
if (!confirmation) {
alert("Update Cancelled");
} else {
const xhr = new XMLHttpRequest();
xhr.open("POST", "scheduleAppt.php", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
// Add other form data to the request if needed
const formData = new FormData(document.getElementById("updatePatientRecord"));
xhr.send(formData);
// Handle the response from the server-side PHP file
xhr.onreadystatechange = function () {
if (xhr.readyState === 4 && xhr.status === 200) {
alert(xhr.responseText); // Display the response from PHP
}
};
}
</script>';
$query = "DELETE FROM Procedures WHERE ProcedureID = ?";
$stmt = $con->prepare($query);
$stmt->bind_param("i", $procedureID);
$stmt->execute();
$query = "UPDATE patientAppts
SET procedureDate = NULL, procedureID = NULL, procedureType = NULL WHERE procedureID = ?";
$stmt = $con->prepare($query);
$stmt->bind_param("i", $procedureID);
$stmt->execute();
echo '<script>
alert("Procedure deleted successfully!");
window.location.href = "cancelProcedure.php";
</script>';
}
// Function to check if the patient exists
function checkIfProcedureExists($procedureID, $con) {
$query = "SELECT ProcedureID FROM Procedures WHERE ProcedureID = ?";
$stmt = $con->prepare($query);
$stmt->bind_param("i", $procedureID);
$stmt->execute();
$stmt->store_result();
$rowCount = $stmt->num_rows;
$stmt->close();
return $rowCount > 0;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Schedule Patient Appointment</title>
<link rel="stylesheet" href="newStyle.css">
</head>
<body>
<div class = "navbar"></div>
<nav>
<a href="searchReceptionist.php">Search Receptionist</a>
<a href="updateInfo.php">Update Patient Information</a>
<a href="verifyPatient.php">Schedule Patient Appoin`tment</a>
<a href="cancelAppt.php">Cancel Patient Appointment</a>
<a href="scheduleProcedure.php">Schedule Patient Procedure</a>
<a href="cancelProcedure.php">Cancel A Patient Procedure</a>
<a href="createNewPatient.php">Create A New Patient</a>
<a href="databasemain.html">Access Database Main</a>
</nav>
</div>
<form id="cancelProcedure" action="cancelProcedure.php" method="POST" onsubmit="return validateForm()">
<div class="container">
<div class="header">
<h2>Cancel Procedure</h2>
</div>
<div class="UserInput">
<div class="enter1">
<p>Input Procedure ID</p>
<input type="text" name="procedureID" id = 'procedureID' placeholder="Input Procedure ID" style="color: black">
<p><strong>REQUIRED</strong></p>
</div>
<div class="enter2">
<button type="submit" class="btn" name = "submit">Submit</button>
<button type="reset" class="btn">Reset</button>
<button id = "homeButton" class = "btn" onclick = "redirect()">Home Button</button>
</div>
</div>
<div class = "footer">
<br>
</div>
</form>
<script>
function redirect() {
// Redirect to the Doctors Receptionist Database page
window.location.href = "main.html";
exit();
}
function validateForm() {
// Validate date on the client side
const IDInput = document.getElementsByName('procedureID')[0].value;
const IDRegex = /^\d{6}$/
}
// Display error message if validation fails
if (!IDRegex.test(IDInput)) {
alert("Please enter a valid ID in the format of 6 digit integer value");
return false; // Prevent form submission
} else {
return true; // Allow form submission
}
</script>
</body>
</html>