Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ManaS066 committed Sep 1, 2024
2 parents a09b22f + 9cdb2db commit 4a64da4
Show file tree
Hide file tree
Showing 5 changed files with 245 additions and 209 deletions.
51 changes: 41 additions & 10 deletions Government of NCT of Delhi/app.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from flask import Flask, flash, render_template, request, redirect, url_for,make_response,session
from flask import Flask, flash, render_template, request, redirect, url_for,make_response,session,send_file
import os,secrets
from pymongo import MongoClient
import jwt
Expand Down Expand Up @@ -317,10 +317,11 @@ def admin():
print(hospital_name)
total_appointment = appointment_collection.count_documents({"hospital_name":hospital_name})
data = hospital_data_collection.find_one({'hospital_name': hospital_name})

beds = data['number_of_beds']
return render_template('admin_dashboard.html',count=total_appointment,beds=beds)

if data:
beds = data['number_of_beds']
return render_template('admin_dashboard.html',count=total_appointment,beds=beds)
else:
return redirect('/admin/add_detail')

@app.route("/admin/contact-us")
def admin_contact_us():
Expand Down Expand Up @@ -481,6 +482,7 @@ def doctor_app():
return render_template('doctor_dash.html',appointments=appointments,doctor=doc_detail)

@app.route('/superadmin/', methods=['GET', 'POST'])
@login_required('superadmin')
def superadmin():
# Count the total number of hospitals, doctors, and active patients
no_of_hospital = hospital_data_collection.count_documents({})
Expand Down Expand Up @@ -518,9 +520,10 @@ def superadmin_login():
if request.method == 'POST':
username = request.form['username']
password = request.form['password']

print('hello')
# Check if the username and password match an entry in the admin_collection
if superadmin_collection.find_one({"username": username, "password": password}):
print('hello')
session['username']=username
session['role']='superadmin'
return redirect('/superadmin')
Expand Down Expand Up @@ -599,7 +602,7 @@ def submit_discharge():
medications = request.form.get('medications')
contact_info = request.form.get('contact_info')
gender=request.form.get('gender')

address=request.form.get('address')
data_discharge={
'patient_id': patient_id,
'patient_name': patient_name,
Expand All @@ -613,6 +616,7 @@ def submit_discharge():
'medications': medications,
'contact_info': contact_info
}
hospital_discharge_collection.insert_one(data_discharge)
# Generate PDF with the provided details
pdf_buffer = io.BytesIO()
doc = SimpleDocTemplate(pdf_buffer, pagesize=A4)
Expand All @@ -626,10 +630,33 @@ def submit_discharge():
elements.append(Paragraph(f"Gender: {gender}", styles['Normal']))
elements.append(Paragraph(f"Address: {address}", styles['Normal']))
elements.append(Paragraph(f"Phone Number: {contact_info}", styles['Normal']))
elements.append(Paragraph(f"Email: {email}", styles['Normal']))
elements.append(Paragraph(f"Diagnosis: {diagnosis}", styles['Normal']))
elements.append(Paragraph(f"Discharge Summary: {discharge_summary}", styles['Normal']))
hospital_discharge_collection.insert_one(data_discharge)
return redirect('/admin')

# Generate QR code
qr = qrcode.QRCode(
version=1,
error_correction=qrcode.constants.ERROR_CORRECT_L,
box_size=10,
border=4,
)
qr.add_data(
f"Name: {patient_name}\Admission Date: {admission_date}\nPhone: {contact_info}\nDischarge Summary: {diagnosis}")
qr.make(fit=True)
img = qr.make_image(fill='black', back_color='white')
qr_buffer = io.BytesIO()
img.save(qr_buffer, 'PNG')
qr_buffer.seek(0)

# Add QR code to PDF
elements.append(Spacer(1, 12))
elements.append(Image(qr_buffer, width=100, height=100))

doc.build(elements)

pdf_buffer.seek(0)
return send_file(pdf_buffer, as_attachment=True, download_name='patient_id_card.pdf', mimetype='application/pdf')
# return redirect('/admin')
return render_template('Patient_discharge.html')
#where is the change

Expand All @@ -648,6 +675,10 @@ def admin_logout():
def sueperadmin_logout():
session.clear()
return redirect('/')
@app.route('/doc_logout')
def doc_logout():
session.clear()
return redirect('/')


if __name__ == '__main__':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ <h3 class="mehran">Government of NCT of Delhi</h3>
<div class="container d-flex align-items-center justify-content-center min-vh-100">
<div class="login-container">
<h2>Super Admin Login</h2>
<form method="POST" id="loginForm">
<form method="POST" action="/superadmin_login" id="loginForm">
<div class="form-group">
<label for="username">Username:</label>
<input type="text" class="form-control" id="username" name="username" required>
Expand Down
54 changes: 23 additions & 31 deletions Government of NCT of Delhi/templates/super_add_hospital.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@
.main-content {
margin-left: 250px;
padding: 20px;
display: flex;
justify-content: center;
align-items: center;
min-height: calc(100vh - 70px);
/* Adjusting for navbar height */
}

.card {
Expand All @@ -59,6 +64,10 @@
margin-bottom: 20px;
padding: 20px;
text-align: center;
width: 70%;
/* Set card width to 70% of the available space */
max-width: 1000px;
/* Optional: Set a maximum width for larger screens */
}

.card h3 {
Expand Down Expand Up @@ -91,6 +100,9 @@
padding: 10px 15px;
border-radius: 4px;
cursor: pointer;
margin-top: 10px;
margin-right: 5px;
/* Optional: Add some space between buttons */
}

.card button:hover {
Expand Down Expand Up @@ -134,36 +146,11 @@
</a>
<h3 class="text-light">Government of NCT of Delhi</h3>
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<div class="ml-auto">
<a class="nav-link btn btn-primary text-light" href="#"></a>
</div>
</li>
<li class="nav-item">
<div class="ml-auto">
<a class="nav-link btn btn-primary text-light" href="#"></a>
</div>
</li>
<li class="nav-item">
<div class="ml-auto">
<a class="nav-link btn btn-primary text-light" href="#"></a>
</div>
</li>
<li class="nav-item">
<div class="ml-auto">
<a class="nav-link btn btn-primary text-light" href="#"></a>
</div>
</li>
<li class="nav-item">
<div class="ml-auto">
<a class="nav-link btn btn-primary text-light" href="dashboard.html">Return to Dashboard</a>
</div>
</li>
<!-- Keeping the navbar items if any -->
</ul>
</div>

<div class="main-content">
<h2>Add Hospital</h2>
<div class="card">
<h3>Add New Hospital</h3>
<form method="POST" action="/superadmin/addHospital">
Expand All @@ -173,15 +160,20 @@ <h3>Add New Hospital</h3>
<input type="email" id="hospitalmail" name="hospitalmail" required><br>
<label for="hospitalpass">Password:</label>
<input type="password" id="hospitalpass" name="hospitalpass" required><br>
<button type="submit">Add Hospital</button>
<!-- Button container -->
<div style="text-align: center; margin-top: 10px;">
<button type="submit"
style="background-color: #00637f; color: white; border: none; padding: 10px 15px; border-radius: 4px; cursor: pointer;">Add
Hospital</button>
<button type="button" onclick="window.location.href='dashboard.html';"
style="background-color: #00637f; color: white; border: none; padding: 10px 15px; border-radius: 4px; cursor: pointer; margin-left: 10px;">Return
to Dashboard</button>
</div>

</form>
<p id="hospital-message"></p>
</div>
</div>

<div class="footer">
<p>&copy; 2024 Government of NCT of Delhi</p>
</div>
</body>

</html>
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@
margin-bottom: 20px;
padding: 20px;
text-align: center;
width: 70%;
margin-left: auto;
margin-right: auto;
}

.card h3 {
Expand All @@ -67,7 +70,9 @@
}

.card form {
text-align: left;
display: flex;
flex-direction: column;
align-items: center;
margin-top: 20px;
}

Expand All @@ -84,16 +89,24 @@
border-radius: 4px;
}

.card button {
.button-container {
display: flex;
justify-content: center;
gap: 10px;
margin-top: 20px;
}

.button-container button {
background-color: #00637f;
color: white;
border: none;
padding: 10px 15px;
border-radius: 4px;
cursor: pointer;
margin: 0;
}

.card button:hover {
.button-container button:hover {
background-color: #004d66;
}

Expand Down Expand Up @@ -141,33 +154,21 @@
</a>
<h3 class="text-light">Government of NCT of Delhi</h3>
</div>

<div class="sidebar">
<a href="dashboard.html">Dashboard</a>
<a href="add-hospital.html">Add Hospital</a>
<a href="check-hospital-status.html">Check Hospital Status</a>
<a href="order-medicine.html">Order Medicine</a>
<a href="feedback.html">Feedback</a>
<a href="blood-bank-status.html">Blood Bank Status</a>
<a href="/">Logout</a>
</div>

<div class="main-content">
<h2>Check Hospital Status</h2>
<!-- <h2>Check Hospital Status</h2> -->
<div class="card">
<h3>Hospital Status</h3>
<form method="POST" action="/superadmin/checkHospitalStatus">
<label for="hname">Hospital Name:</label>
<input type="text" name="hname" id="hname">
<button type="submit" id="check-hospital-status">View Status</button>
<div class="button-container">
<button type="submit" id="check-hospital-status">View Status</button>
<button type="button" onclick="location.href='/dashboard';">Return to Dashboard</button>
</div>
<div id="hospital-status" class="status"></div>
</form>
</div>
</div>

<div class="footer">
<p>&copy; 2024 Government of NCT of Delhi</p>
</div>
</body>

</html>
Loading

0 comments on commit 4a64da4

Please sign in to comment.