From d729ac1b70487378c1411bb67b34d97d005ab726 Mon Sep 17 00:00:00 2001 From: debaraja-394 Date: Sun, 1 Sep 2024 16:07:04 +0530 Subject: [PATCH 2/2] discharge_details --- Government of NCT of Delhi/app.py | 36 +++++++++++++++++-- .../templates/Patient_discharge.html | 1 - 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/Government of NCT of Delhi/app.py b/Government of NCT of Delhi/app.py index 5b3eb91..6db7311 100644 --- a/Government of NCT of Delhi/app.py +++ b/Government of NCT of Delhi/app.py @@ -3,6 +3,16 @@ from pymongo import MongoClient import jwt from functools import wraps +from reportlab.lib.pagesizes import A4 +from reportlab.lib import colors +from reportlab.lib.units import inch +from reportlab.lib.styles import getSampleStyleSheet +from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Image, Table, TableStyle +from reportlab.graphics.barcode.qr import QrCodeWidget +from reportlab.graphics.shapes import Drawing +from reportlab.graphics import renderPDF +import qrcode +import io #test pull app = Flask(__name__) @@ -479,6 +489,8 @@ def superadmin_login(): # 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' return redirect('/superadmin') else: return redirect('/superadmin_login') @@ -487,7 +499,7 @@ def superadmin_login(): @app.route('/superadmin/addHospital', methods=['GET', 'POST']) - +@login_required('superadmin') def add_hospital(): if request.method == 'POST': hospital_name = request.form['hospitalName'] @@ -522,6 +534,7 @@ def add_hospital(): @app.route('/superadmin/checkHospitalStatus', methods=['GET', 'POST']) +@login_required('superadmin') def check_hospital(): if request.method == 'POST': hospital_name = request.form.get('hname') @@ -554,6 +567,7 @@ 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') data_discharge={ 'patient_id': patient_id, @@ -568,7 +582,21 @@ def submit_discharge(): 'medications': medications, 'contact_info': contact_info } - + # Generate PDF with the provided details + pdf_buffer = io.BytesIO() + doc = SimpleDocTemplate(pdf_buffer, pagesize=A4) + styles = getSampleStyleSheet() + #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"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"Discharge Summary: {discharge_summary}", styles['Normal'])) hospital_discharge_collection.insert_one(data_discharge) return redirect('/admin') return render_template('Patient_discharge.html') @@ -585,6 +613,10 @@ def user_logout(): def admin_logout(): session.clear() return redirect('/') +@app.route('/superadmin_logout') +def sueperadmin_logout(): + session.clear() + return redirect('/') if __name__ == '__main__': diff --git a/Government of NCT of Delhi/templates/Patient_discharge.html b/Government of NCT of Delhi/templates/Patient_discharge.html index 7693840..132de25 100644 --- a/Government of NCT of Delhi/templates/Patient_discharge.html +++ b/Government of NCT of Delhi/templates/Patient_discharge.html @@ -104,7 +104,6 @@

Hospital Discharge Details Form

cols="50" required > -