From 338b7fafb058acab69277d511891a9407219de2f Mon Sep 17 00:00:00 2001 From: Manas Pradhan Date: Sun, 1 Sep 2024 17:26:16 +0530 Subject: [PATCH 1/6] total_bed update --- Government of NCT of Delhi/app.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Government of NCT of Delhi/app.py b/Government of NCT of Delhi/app.py index b294fa0..835a1db 100644 --- a/Government of NCT of Delhi/app.py +++ b/Government of NCT of Delhi/app.py @@ -83,9 +83,9 @@ def login_required(role): def decorator(f): @wraps(f) def decorated_function(*args,**kwargs): - print(f"Session data: {session}") - print(f"Checking if username in session: {'username' in session}") - print(f"Checking if role matches: {session.get('role')} == {role}") + # print(f"Session data: {session}") + # print(f"Checking if username in session: {'username' in session}") + # print(f"Checking if role matches: {session.get('role')} == {role}") if 'username' not in session or session.get('role')!=role: return redirect(f'/{role}_login') return f(*args,**kwargs) @@ -135,7 +135,7 @@ def user_login(): # return response session['username']=username session['role']='user' - print(f'user session details:{session}') + return redirect('/user_app') else: return 'Wrong password' @@ -236,7 +236,7 @@ def add_patient(): session['patient_name']=name hospital_name_patient=session.get('hospital_name') - print(hospital_name_patient) + data = { 'name':name, 'dob':dob, @@ -299,7 +299,7 @@ def admin_login(): hospital_data=admin_collection.find_one({"hospital_mail":admin_email}) hospital_name_doctor=hospital_data.get("hospital_name") session['hospital_name']=hospital_name_doctor - print(f'session details:{session}') + # return response return redirect('/admin') @@ -314,7 +314,7 @@ def admin_login(): @login_required('admin') def admin(): hospital_name=session.get('hospital_name') - print(hospital_name) + total_appointment = appointment_collection.count_documents({"hospital_name":hospital_name}) data = hospital_data_collection.find_one({'hospital_name': hospital_name}) if data: @@ -493,7 +493,7 @@ def superadmin(): # Aggregate the total number of beds, ICU beds, and ventilators total_beds = hospital_data_collection.aggregate([ - {"$group": {"_id": None, "total_beds": {"$sum": "$number_of_beds"}}} + {"$group": {"_id": None, "total_beds": {"$sum": "$number_of_general_beds"}}} ]).next()['total_beds'] total_icu_beds = hospital_data_collection.aggregate([ From 93870a81ef3b0bd094f6119913fa6d43120d1660 Mon Sep 17 00:00:00 2001 From: diptesh224 Date: Sun, 1 Sep 2024 17:36:06 +0530 Subject: [PATCH 2/6] admin dash --- .../templates/admin_dashboard.html | 18 +- .../templates/contact us.html | 294 ------------------ 2 files changed, 15 insertions(+), 297 deletions(-) delete mode 100644 Government of NCT of Delhi/templates/contact us.html diff --git a/Government of NCT of Delhi/templates/admin_dashboard.html b/Government of NCT of Delhi/templates/admin_dashboard.html index 31dd0c7..c8779ce 100644 --- a/Government of NCT of Delhi/templates/admin_dashboard.html +++ b/Government of NCT of Delhi/templates/admin_dashboard.html @@ -174,15 +174,27 @@

Government of NCT of Delhi

Admin Dashboard

-

Total Patients

+

Active Patient

{{count}}

-

Available Beds

+

Doctors

{{beds}}

-

Doctors On Duty

+

Total Patient

+

45

+
+
+

General bed

+

45

+
+
+

ICU Bed

+

45

+
+
+

Ventilator

45

diff --git a/Government of NCT of Delhi/templates/contact us.html b/Government of NCT of Delhi/templates/contact us.html deleted file mode 100644 index f3374fb..0000000 --- a/Government of NCT of Delhi/templates/contact us.html +++ /dev/null @@ -1,294 +0,0 @@ - - - - - - - Contact Us - - - - - - - -
- -
-
-
-

Contact Us

-
-

SmartCare Ninjas

-

Delhi, 110001

-

Board Number: +91-11-12345678 / 12345679

-

Fax: +91-11-12345680 / 12345681

-

Email: support@smartcareninjas@gmail.com -

-
- -
-
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- -
-
-
-
- - - - - - - \ No newline at end of file From f8bd6331129aaae8247760b56ecff0902e52951f Mon Sep 17 00:00:00 2001 From: Manas Pradhan Date: Sun, 1 Sep 2024 17:48:23 +0530 Subject: [PATCH 3/6] minorchanges --- Government of NCT of Delhi/app.py | 4 +- .../templates/admin_dashboard.html | 5 +- .../templates/manage_contactus.html | 67 +++++++++++++++++++ .../templates/super_admin_dash.html | 4 +- 4 files changed, 73 insertions(+), 7 deletions(-) create mode 100644 Government of NCT of Delhi/templates/manage_contactus.html diff --git a/Government of NCT of Delhi/app.py b/Government of NCT of Delhi/app.py index 835a1db..42b91b4 100644 --- a/Government of NCT of Delhi/app.py +++ b/Government of NCT of Delhi/app.py @@ -325,8 +325,8 @@ def admin(): @app.route("/admin/contact-us") def admin_contact_us(): - contacts = contact_collection.find() - return render_template("manage_appointment.html", contacts=contacts) + contacts = contact_collection.find({}) + return render_template("manage_contactus.html", contacts=contacts) @app.route('/admin/add_detail',methods=['GET','POST']) @login_required('admin') diff --git a/Government of NCT of Delhi/templates/admin_dashboard.html b/Government of NCT of Delhi/templates/admin_dashboard.html index 31dd0c7..0db9100 100644 --- a/Government of NCT of Delhi/templates/admin_dashboard.html +++ b/Government of NCT of Delhi/templates/admin_dashboard.html @@ -158,15 +158,14 @@

Government of NCT of Delhi

diff --git a/Government of NCT of Delhi/templates/manage_contactus.html b/Government of NCT of Delhi/templates/manage_contactus.html new file mode 100644 index 0000000..04b5de5 --- /dev/null +++ b/Government of NCT of Delhi/templates/manage_contactus.html @@ -0,0 +1,67 @@ + + + + + + + Admin Contact Us Data + + + + +
+

Admin Feedback Data

+ + + + + + + + {% for contact in contacts %} + + + + + + + {% endfor %} +
NameEmailNumberComment
{{ contact.name }}{{ contact.email }}{{ contact.number }}{{ contact.comment }}
+
+ + + \ No newline at end of file diff --git a/Government of NCT of Delhi/templates/super_admin_dash.html b/Government of NCT of Delhi/templates/super_admin_dash.html index 3287301..4c0af53 100644 --- a/Government of NCT of Delhi/templates/super_admin_dash.html +++ b/Government of NCT of Delhi/templates/super_admin_dash.html @@ -113,10 +113,10 @@

Government of NCT of Delhi

From 7641ea66ee3b4555438240ac059b5661143ed5bc Mon Sep 17 00:00:00 2001 From: ABHISEK PANDA <117925314+abhisek2004@users.noreply.github.com> Date: Sun, 1 Sep 2024 18:13:21 +0530 Subject: [PATCH 4/6] comit --- Government of NCT of Delhi/app.py | 428 +++++++++++++++--------------- 1 file changed, 221 insertions(+), 207 deletions(-) diff --git a/Government of NCT of Delhi/app.py b/Government of NCT of Delhi/app.py index c5743e9..facf132 100644 --- a/Government of NCT of Delhi/app.py +++ b/Government of NCT of Delhi/app.py @@ -1,5 +1,11 @@ -from flask import Flask, flash, render_template, request, redirect, url_for,make_response,session -import os,secrets +from flask_bcrypt import Bcrypt +from datetime import datetime, timedelta +from pymongo.server_api import ServerApi +from pymongo.mongo_client import MongoClient +import smtplib +from flask import Flask, flash, render_template, request, redirect, url_for, make_response, session +import os +import secrets from pymongo import MongoClient import jwt from functools import wraps @@ -14,20 +20,15 @@ import qrcode import io -#test pull +# test pull app = Flask(__name__) -#test push +# test push # app.config['SECRET_KEY']=secrets.token_hex()\ -app.secret_key=secrets.token_hex() +app.secret_key = secrets.token_hex() -import smtplib -from datetime import datetime,timedelta my_email = "nicdelhi2024@gmail.com" code = "zuff vkvx pamt kdor" -from flask_bcrypt import Bcrypt -from pymongo.mongo_client import MongoClient -from pymongo.server_api import ServerApi -bcrypt = Bcrypt(app) +bcrypt = Bcrypt(app) uri = "mongodb+srv://manasranjanpradhan2004:root@hms.m7j9t.mongodb.net/?retryWrites=true&w=majority&appName=HMS" # Create a new client and connect to the server client = MongoClient(uri, server_api=ServerApi('1')) @@ -45,10 +46,9 @@ admin_collection = db['admin'] appointment_collection = db['appointment'] contact_collection = db['contact'] -superadmin_collection=db['Superadmin'] -hospital_data_collection=db['hospital_data'] -hospital_discharge_collection=db['discharged'] - +superadmin_collection = db['Superadmin'] +hospital_data_collection = db['hospital_data'] +hospital_discharge_collection = db['discharged'] # def token_required(expected_role): @@ -72,32 +72,31 @@ # return redirect(f'/{expected_role}_login') # except jwt.ExpiredSignatureError: # return 'Token has expired',401 - + # except jwt.InvalidTokenError: # return redirect(f'/{expected_role}_login') - + # return f(current_user,*args,**kwargs) # return decorated # return decorator def login_required(role): def decorator(f): @wraps(f) - def decorated_function(*args,**kwargs): + def decorated_function(*args, **kwargs): print(f"Session data: {session}") print(f"Checking if username in session: {'username' in session}") print(f"Checking if role matches: {session.get('role')} == {role}") - if 'username' not in session or session.get('role')!=role: + if 'username' not in session or session.get('role') != role: return redirect(f'/{role}_login') - return f(*args,**kwargs) + return f(*args, **kwargs) return decorated_function return decorator - -@app.route('/',methods=['GET', 'POST']) +@app.route('/', methods=['GET', 'POST']) def landing(): - if request.method=='POST': - name= request.form['name'] + if request.method == 'POST': + name = request.form['name'] email = request.form['email'] number = request.form['number'] comment = request.form['comment'] @@ -131,44 +130,48 @@ def user_login(): # response=make_response(redirect('/appointment')) # response.set_cookie('access_token_user',token,httponly=True) # response.set_cookie('user_username',username,httponly=True) - + # return response - session['username']=username - session['role']='user' + session['username'] = username + session['role'] = 'user' print(f'user session details:{session}') return redirect('/user_app') else: return 'Wrong password' - + return 'User not found' return render_template('user_login.html') -@app.route('/user_app',methods=['GET','POST']) + +@app.route('/user_app', methods=['GET', 'POST']) @login_required('user') def user_app(): - user_info = users_collection.find_one({'username':session.get('username')}) - appointment = appointment_collection.find({'username':session.get('username')}) - return render_template('user_app.html',user = user_info,appointments =appointment) + user_info = users_collection.find_one( + {'username': session.get('username')}) + appointment = appointment_collection.find( + {'username': session.get('username')}) + return render_template('user_app.html', user=user_info, appointments=appointment) -@app.route('/user_register',methods=['GET','POST']) + +@app.route('/user_register', methods=['GET', 'POST']) def user_register(): - if request.method=='POST': - name=request.form['name'] - number=request.form['phone'] - email= request.form['email'] + if request.method == 'POST': + name = request.form['name'] + number = request.form['phone'] + email = request.form['email'] user_name = request.form['username'] # existing_user = users_collection.find_one({'$or': [{'username': user_name}, {'email': email}]}) # if existing_user: # return 'Username or email already exists' pa = request.form['password'] - password=bcrypt.generate_password_hash(pa).decode('utf-8') - user_data={ - 'name':name, - 'username':user_name, - 'email':email, - 'number':number, - 'password':password + password = bcrypt.generate_password_hash(pa).decode('utf-8') + user_data = { + 'name': name, + 'username': user_name, + 'email': email, + 'number': number, + 'password': password } users_collection.insert_one(user_data) return redirect('/user_login') @@ -186,7 +189,7 @@ def appointment(): if request.method == 'POST': # Extract form data name = request.form['name'] - user_name=session.get('username') + user_name = session.get('username') number = request.form['number'] email = request.form['email'] address = request.form['Address'] @@ -199,7 +202,7 @@ def appointment(): # print(total_no_of_appointments) appointment_data = { 'name': name, - 'username':user_name, + 'username': user_name, 'number': number, 'email': email, 'address': address, @@ -207,10 +210,10 @@ def appointment(): 'time_slot': time_slot, 'speciality': speciality, 'disease_description': disease_description, - 'hospital_name':hospital_name + 'hospital_name': hospital_name } appointment_collection.insert_one(appointment_data) - + # After saving or processing, redirect or render a success page return redirect('/admin/confirmation') # If GET request, just render the appointment form @@ -219,65 +222,64 @@ def appointment(): return render_template('appointment.html', hospitals=hospital_names) -@app.route('/admin/add_patient',methods=['GET','POST']) + +@app.route('/admin/add_patient', methods=['GET', 'POST']) # @token_required('admin') @login_required('admin') def add_patient(): - if request.method=='POST': + if request.method == 'POST': name = request.form['Name'] - dob =request.form['dob'] + dob = request.form['dob'] gender = request.form['gender'] address = request.form['address'] - phone= request.form['phone'] - email=request.form['email'] - aadhaar= request.form['aadhaar'] + phone = request.form['phone'] + email = request.form['email'] + aadhaar = request.form['aadhaar'] bed_type = request.form['bedtype'] bed_no = request.form['bedno'] - session['patient_name']=name - hospital_name_patient=session.get('hospital_name') + session['patient_name'] = name + hospital_name_patient = session.get('hospital_name') print(hospital_name_patient) data = { - 'name':name, - 'dob':dob, - 'gender':gender, - 'address':address, - 'phone':phone, - 'email':email, - "aadhaar":aadhaar, - "bed_type":bed_type, - "bed no":bed_no, - "hospital_name":hospital_name_patient + 'name': name, + 'dob': dob, + 'gender': gender, + 'address': address, + 'phone': phone, + 'email': email, + "aadhaar": aadhaar, + "bed_type": bed_type, + "bed no": bed_no, + "hospital_name": hospital_name_patient } patients_collection.insert_one(data) return redirect(url_for('confirmation')) return render_template('add patient.html') + @app.route('/admin/confirmation') def confirmation(): return render_template('conformation.html', message="Patient successfully added!") -@app.route('/admin/manage_appointment',methods=['GET','POST']) +@app.route('/admin/manage_appointment', methods=['GET', 'POST']) @login_required('admin') def manage(): - hospital_name=session.get('hospital_name') - appointments= appointment_collection.find({"hospital_name":hospital_name}) - return render_template('manage_appointment.html',appointments = appointments) - - - + hospital_name = session.get('hospital_name') + appointments = appointment_collection.find( + {"hospital_name": hospital_name}) + return render_template('manage_appointment.html', appointments=appointments) - -@app.route('/admin_login',methods=["GET","POST"]) +@app.route('/admin_login', methods=["GET", "POST"]) def admin_login(): if request.method == 'POST': - username= request.form['username'] + username = request.form['username'] pa = request.form['password'] - password=bcrypt.generate_password_hash(pa).decode('utf-8') + password = bcrypt.generate_password_hash(pa).decode('utf-8') # print('this is executed') - + admin = admin_collection.find_one({'hospital_mail': username}) if admin: # Compare the entered password with the stored hashed password @@ -289,37 +291,39 @@ def admin_login(): # 'exp':datetime.utcnow()+timedelta(hours=1) # },app.config['SECRET_KEY'],algorithm="HS256") - # response=make_response(redirect('/admin')) # response.set_cookie('access_token',token,httponly=True) # response.set_cookie('user_username',username,httponly=True) - session['username']=username - session['role']='admin' - admin_email=session['username'] - hospital_data=admin_collection.find_one({"hospital_mail":admin_email}) - hospital_name_doctor=hospital_data.get("hospital_name") - session['hospital_name']=hospital_name_doctor + session['username'] = username + session['role'] = 'admin' + admin_email = session['username'] + hospital_data = admin_collection.find_one( + {"hospital_mail": admin_email}) + hospital_name_doctor = hospital_data.get("hospital_name") + session['hospital_name'] = hospital_name_doctor print(f'session details:{session}') # return response return redirect('/admin') - + else: return 'Wrong password' - + return 'User not found' return render_template("login_admin.html") -@app.route('/admin/',methods=['GET','POST']) + +@app.route('/admin/', methods=['GET', 'POST']) # @token_required('admin') @login_required('admin') def admin(): - hospital_name=session.get('hospital_name') + hospital_name = session.get('hospital_name') print(hospital_name) - total_appointment = appointment_collection.count_documents({"hospital_name":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) + return render_template('admin_dashboard.html', count=total_appointment, beds=beds) @app.route("/admin/contact-us") @@ -327,26 +331,27 @@ def admin_contact_us(): contacts = contact_collection.find() return render_template("manage_appointment.html", contacts=contacts) -@app.route('/admin/add_detail',methods=['GET','POST']) + +@app.route('/admin/add_detail', methods=['GET', 'POST']) @login_required('admin') def add_details(): - if request.method=='POST': - name= request.form['hospitalName'] - ID =request.form['hospitalID'] - address1=request.form['addressLine1'] + if request.method == 'POST': + name = request.form['hospitalName'] + ID = request.form['hospitalID'] + address1 = request.form['addressLine1'] city = request.form['city'] state = request.form['stateProvince'] postal_code = request.form['postalCode'] - contact_number= request.form['contactNumber'] - emergency=request.form['emergencyContactNumber'] + contact_number = request.form['contactNumber'] + emergency = request.form['emergencyContactNumber'] email = request.form['emailAddress'] website = request.form['websiteURL'] no_beds = int(request.form['numberOfBeds']) - occupied_beds=int(request.form['Beds_occupied']) + occupied_beds = int(request.form['Beds_occupied']) no_icu = int(request.form['numberOfICUBeds']) occupied_icu = int(request.form['icu_occupied']) no_ventilator = int(request.form['numberOfVentilators']) - occupied_ventilator=int(request.form['ventilator_occupied']) + occupied_ventilator = int(request.form['ventilator_occupied']) emergency_dept = request.form['emergencyDepartment'] spetialisation = request.form['specialization'] operating_hour = request.form['hospitalOperatingHours'] @@ -358,103 +363,104 @@ def add_details(): bload_bank = request.form['bloodBank'] diagonis_services = request.form['diagnosticServices'] - data = { - "hospital_name": name, - "hospital_id": ID, - "address_line1": address1, - "city": city, - "state": state, - "postal_code": postal_code, - "contact_number": contact_number, - "emergency_contact_number": emergency, - "email_address": email, - "website_url": website, - "number_of_general_beds": no_beds, - "occupied_general":occupied_beds, - "number_of_icu_beds": no_icu, - "occupied_icu":occupied_icu, - "number_of_ventilators": no_ventilator, - "occupied_ventilator":occupied_ventilator, - "emergency_department": emergency_dept, - "specialization": spetialisation, - "hospital_operating_hours": operating_hour, - "visiting_hours": visiting_hour, - "pharmacy_on_site": pharmacy_onsite, - "total_number_of_nurses": no_nurse, - "administrative_staff_count": no_admin_staff, - "ambulance_services": ambulance, - "blood_bank": bload_bank, - "diagnostic_services": diagonis_services} - + data = { + "hospital_name": name, + "hospital_id": ID, + "address_line1": address1, + "city": city, + "state": state, + "postal_code": postal_code, + "contact_number": contact_number, + "emergency_contact_number": emergency, + "email_address": email, + "website_url": website, + "number_of_general_beds": no_beds, + "occupied_general": occupied_beds, + "number_of_icu_beds": no_icu, + "occupied_icu": occupied_icu, + "number_of_ventilators": no_ventilator, + "occupied_ventilator": occupied_ventilator, + "emergency_department": emergency_dept, + "specialization": spetialisation, + "hospital_operating_hours": operating_hour, + "visiting_hours": visiting_hour, + "pharmacy_on_site": pharmacy_onsite, + "total_number_of_nurses": no_nurse, + "administrative_staff_count": no_admin_staff, + "ambulance_services": ambulance, + "blood_bank": bload_bank, + "diagnostic_services": diagonis_services} + # Insert the data into the hospital collection hospital_data_collection.insert_one(data) return render_template('hospital_details.html',) - - -@app.route('/add_doc',methods=['POST','GET']) +@app.route('/add_doc', methods=['POST', 'GET']) # @token_required('admin') @login_required('admin') def doctor_register(): - if request.method=='POST': - name=request.form['doctor_name'] - specialization=request.form['specialization'] - qualification=request.form['qualification'] - email=request.form['email'] - username=request.form['username'] - password=request.form['password'] - hash_password=bcrypt.generate_password_hash(password).decode('utf-8') - phone=request.form['phone'] - aadhar=request.form['aadhaar'] - #Doctor and hospital relation - session['doctor_name']=name - admin_email=session['username'] - hospital_data=admin_collection.find_one({"hospital_mail":admin_email}) - hospital_name_doctor=hospital_data.get("hospital_name") - session['hospital_name']=hospital_name_doctor + if request.method == 'POST': + name = request.form['doctor_name'] + specialization = request.form['specialization'] + qualification = request.form['qualification'] + email = request.form['email'] + username = request.form['username'] + password = request.form['password'] + hash_password = bcrypt.generate_password_hash(password).decode('utf-8') + phone = request.form['phone'] + aadhar = request.form['aadhaar'] + # Doctor and hospital relation + session['doctor_name'] = name + admin_email = session['username'] + hospital_data = admin_collection.find_one( + {"hospital_mail": admin_email}) + hospital_name_doctor = hospital_data.get("hospital_name") + session['hospital_name'] = hospital_name_doctor # print(hospital_name_patient) - doctor_data={ - 'name':name, - 'specialization':specialization, - 'qualification':qualification, - 'email':email, - 'username':username, - 'password':hash_password, - 'phone':phone, - 'aadhar':aadhar, - "hospital_name":hospital_name_doctor + doctor_data = { + 'name': name, + 'specialization': specialization, + 'qualification': qualification, + 'email': email, + 'username': username, + 'password': hash_password, + 'phone': phone, + 'aadhar': aadhar, + "hospital_name": hospital_name_doctor } - if doctors_collection.find_one({'username':username}): + if doctors_collection.find_one({'username': username}): return redirect('/add_doc') else: doctors_collection.insert_one(doctor_data) return render_template('add doc.html') return render_template('add doc.html') + @app.route('/doctor_login', methods=['POST', 'GET']) def doc_login(): if request.method == "POST": username = request.form['username'] password = request.form['password'] - + # Fetch the doctor's details from the database by username doctor = doctors_collection.find_one({'username': username}) # print(username,password) if doctor: # stored_hash = doctor['password'] # The stored hashed password - + # Check if the provided password matches the hashed passwor - if bcrypt.check_password_hash(doctor['password'],password): + if bcrypt.check_password_hash(doctor['password'], password): # Password matches, grant access # Store doctor ID in session - doctor_data=doctors_collection.find_one({'username':username}) + doctor_data = doctors_collection.find_one( + {'username': username}) - session['username']=username - session['hospital_name']=doctor_data.get('hospital_name') - session['specialization']=doctor_data.get('specialization') - session['role']='doc' - return redirect('/doctor_app') # Redirect to the doctor app + session['username'] = username + session['hospital_name'] = doctor_data.get('hospital_name') + session['specialization'] = doctor_data.get('specialization') + session['role'] = 'doc' + return redirect('/doctor_app') # Redirect to the doctor app else: # Password does not match @@ -466,26 +472,26 @@ def doc_login(): return "Wrong id" # Render the login page if GET request - return render_template('doctor login.html') # Replace with your login template - + # Replace with your login template + return render_template('doctor login.html') - - - -@app.route('/doctor_app',methods=["POST","GET"]) +@app.route('/doctor_app', methods=["POST", "GET"]) @login_required('doc') def doctor_app(): - appointments=appointment_collection.find({'hospital_name':session.get('hospital_name'),'speciality':session.get('specialization')}) - doc_detail = doctors_collection.find_one({'username':session.get('username')}) - return render_template('doctor_dash.html',appointments=appointments,doctor=doc_detail) + appointments = appointment_collection.find({'hospital_name': session.get( + 'hospital_name'), 'speciality': session.get('specialization')}) + doc_detail = doctors_collection.find_one( + {'username': session.get('username')}) + return render_template('doctor_dash.html', appointments=appointments, doctor=doc_detail) + @app.route('/superadmin/', methods=['GET', 'POST']) def superadmin(): no_of_hospital = hospital_data_collection.count_documents() total_doctor = doctors_collection.count_documents() - active_patient = patients_collection.count_documents() - + active_patient = patients_collection.count_documents() + return render_template('super_admin_dash.html') @@ -494,15 +500,15 @@ def superadmin_login(): if request.method == 'POST': username = request.form['username'] password = request.form['password'] - + # Check if the username and password match an entry in the admin_collection if superadmin_collection.find_one({"username": username, "password": password}): - session['username']=username - session['role']='superadmin' + session['username'] = username + session['role'] = 'superadmin' return redirect('/superadmin') else: return redirect('/superadmin_login') - + return render_template("Super_Admin_login.html") @@ -513,7 +519,7 @@ def add_hospital(): hospital_name = request.form['hospitalName'] hospital_mail = request.form['hospitalmail'] pa = request.form['hospitalpass'] - password=bcrypt.generate_password_hash(pa).decode('utf-8') + password = bcrypt.generate_password_hash(pa).decode('utf-8') # Store the hospital data in the hospital collection hospitalData = { "hospital_name": hospital_name, @@ -522,14 +528,13 @@ def add_hospital(): } admin_collection.insert_one(hospitalData) - with smtplib.SMTP("smtp.gmail.com", 587) as connection: connection.starttls() time = datetime.now() connection.login(user=my_email, password=code) connection.sendmail(from_addr=my_email, - to_addrs=hospital_mail, - msg=f""" + to_addrs=hospital_mail, + msg=f""" Dear, Your Hospital Account (Email ID {hospital_mail}) Password is:{pa}. @@ -538,31 +543,33 @@ def add_hospital(): ******************************** This is an auto-generated email. Do not reply to this email.""") return render_template('super_add_hospital.html') - - + + @app.route('/superadmin/checkHospitalStatus', methods=['GET', 'POST']) @login_required('superadmin') def check_hospital(): if request.method == 'POST': hospital_name = request.form.get('hname') - + if not hospital_name: return "Hospital name is missing", 400 # Bad Request - - data = hospital_data_collection.find_one({'hospital_name': hospital_name}) - + + data = hospital_data_collection.find_one( + {'hospital_name': hospital_name}) + if data: return render_template('superadmin_hospital_status.html', data=data) else: return "No hospital found" - + return render_template('superadmin_hospital_status.html') -@app.route('/admin/discharge',methods=['POST','GET']) + +@app.route('/admin/discharge', methods=['POST', 'GET']) @login_required('admin') def submit_discharge(): - if request.method=='POST': - # Extracting form data + if request.method == 'POST': + # Extracting form data patient_id = request.form.get('patient_id') patient_name = request.form.get('patient_name') admission_date = request.form.get('admission_date') @@ -574,9 +581,9 @@ def submit_discharge(): follow_up_instructions = request.form.get('follow_up_instructions') medications = request.form.get('medications') contact_info = request.form.get('contact_info') - gender=request.form.get('gender') + gender = request.form.get('gender') - data_discharge={ + data_discharge = { 'patient_id': patient_id, 'patient_name': patient_name, 'admission_date': admission_date, @@ -593,33 +600,40 @@ def submit_discharge(): pdf_buffer = io.BytesIO() doc = SimpleDocTemplate(pdf_buffer, pagesize=A4) styles = getSampleStyleSheet() - #Patient details inside the pdf + # Patient details inside the pdf elements = [] elements.append(Paragraph("Patient ID Card", styles['Title'])) elements.append(Spacer(1, 12)) - elements.append(Paragraph(f"Full Name: {patient_name}", styles['Normal'])) - elements.append(Paragraph(f"Admission Date: {admission_date}", styles['Normal'])) + elements.append( + Paragraph(f"Full Name: {patient_name}", styles['Normal'])) + elements.append(Paragraph(f"Admission Date: { + admission_date}", styles['Normal'])) 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"Phone Number: { + contact_info}", styles['Normal'])) elements.append(Paragraph(f"Email: {email}", styles['Normal'])) - elements.append(Paragraph(f"Discharge Summary: {discharge_summary}", styles['Normal'])) + elements.append(Paragraph(f"Discharge Summary: { + discharge_summary}", styles['Normal'])) hospital_discharge_collection.insert_one(data_discharge) - return redirect('/admin') + return redirect('/admin') return render_template('Patient_discharge.html') -#where is the change +# where is the change -#show +# show @app.route('/user_logout') def user_logout(): session.clear() return redirect('/') + @app.route('/admin_logout') def admin_logout(): session.clear() return redirect('/') + + @app.route('/superadmin_logout') def sueperadmin_logout(): session.clear() @@ -627,4 +641,4 @@ def sueperadmin_logout(): if __name__ == '__main__': - app.run( port=8000,debug=True) \ No newline at end of file + app.run(port=8000, debug=True) From 7049364a3755eac010bb5d834f628d8ebd22fb25 Mon Sep 17 00:00:00 2001 From: ABHISEK PANDA <117925314+abhisek2004@users.noreply.github.com> Date: Sun, 1 Sep 2024 18:13:41 +0530 Subject: [PATCH 5/6] comit all --- .../templates/add patient.html | 257 +++++++++--------- 1 file changed, 129 insertions(+), 128 deletions(-) diff --git a/Government of NCT of Delhi/templates/add patient.html b/Government of NCT of Delhi/templates/add patient.html index cec692c..e6a88a7 100644 --- a/Government of NCT of Delhi/templates/add patient.html +++ b/Government of NCT of Delhi/templates/add patient.html @@ -1,128 +1,129 @@ - - - - Add Patient - - - - -
-

Add Patient

-
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
- -
- - -
-
- - -
- - - -
- - -
-
- +
+ + +
+ + - - - - -
- + + + + + + \ No newline at end of file From 504f9c1277f343c34b6c07576a0bfe9d071e20f9 Mon Sep 17 00:00:00 2001 From: Manas Pradhan Date: Sun, 1 Sep 2024 18:20:37 +0530 Subject: [PATCH 6/6] admin coomit --- Government of NCT of Delhi/app.py | 8 ++++++-- .../templates/admin_dashboard.html | 14 +++++++------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/Government of NCT of Delhi/app.py b/Government of NCT of Delhi/app.py index 42b91b4..38b18af 100644 --- a/Government of NCT of Delhi/app.py +++ b/Government of NCT of Delhi/app.py @@ -318,8 +318,12 @@ def admin(): total_appointment = appointment_collection.count_documents({"hospital_name":hospital_name}) data = hospital_data_collection.find_one({'hospital_name': hospital_name}) if data: - beds = data['number_of_general_beds'] - return render_template('admin_dashboard.html',count=total_appointment,beds=beds) + g_beds = data['number_of_general_beds'] + icu_beds= data['number_of_icu_beds'] + v_beds = data['number_of_ventilators'] + total_patient = patients_collection.count_documents({'hospital_name': hospital_name}) + total_doc= doctors_collection.count_documents({"hospital_name":hospital_name}) + return render_template('admin_dashboard.html',count=total_appointment,general_total=g_beds,icu_total= icu_beds,vantilator_total =v_beds,patient = total_patient,doc=total_doc) else: return redirect('/admin/add_detail') diff --git a/Government of NCT of Delhi/templates/admin_dashboard.html b/Government of NCT of Delhi/templates/admin_dashboard.html index c55ae0f..10ebda4 100644 --- a/Government of NCT of Delhi/templates/admin_dashboard.html +++ b/Government of NCT of Delhi/templates/admin_dashboard.html @@ -173,28 +173,28 @@

Government of NCT of Delhi

Admin Dashboard

-

Active Patient

+

Total appointment

{{count}}

Doctors

-

{{beds}}

+

{{doc}}

-

Total Patient

-

45

+

Total patient

+

{{patient}}

General bed

-

45

+

{{general_total}}

ICU Bed

-

45

+

{{icu_total}}

Ventilator

-

45

+

{{vantilator_total}}