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 2253b62 + c0755b1 commit 5b474c4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
6 changes: 5 additions & 1 deletion Government of NCT of Delhi/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
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,send_file
from flask import Flask, flash, render_template, request, redirect, url_for, make_response, session,send_file,after_this_request
import os
import secrets
from pymongo import MongoClient
Expand Down Expand Up @@ -690,8 +690,12 @@ def submit_discharge():
elements.append(Image(qr_buffer, width=100, height=100))

doc.build(elements)


pdf_buffer.seek(0)
# @after_this_request
# def redirect_to_admin(reponse=302):
# return redirect('/admin')
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')
Expand Down
21 changes: 18 additions & 3 deletions Government of NCT of Delhi/templates/Patient_discharge.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,12 @@
</head>

<body>
<form action="/admin/discharge" method="POST">
<form
action="/admin/discharge"
method="POST"
id="discharge"
onsubmit="submitFormAndRedirect()"
>
<h2>Hospital Discharge Details Form</h2>

<label for="patient_id">Patient ID:</label>
Expand Down Expand Up @@ -105,9 +110,8 @@ <h2>Hospital Discharge Details Form</h2>

<label for="treatment">Treatment Provided:</label>
<div class="form-group">

<textarea id="treatment" name="treatment" rows="4" required></textarea>

<label for="category">Select type of bed:</label>

<select id="bedtype" name="bedtype" required>
Expand Down Expand Up @@ -150,5 +154,16 @@ <h2>Hospital Discharge Details Form</h2>

<input type="submit" value="Submit" />
</form>
<script>
function submitFormAndRedirect() {
var form = document.getElementById("discharge");
form.submit();
console.log("hellof");
// Redirect after a delay to ensure the file download starts
setTimeout(function () {
window.location.href = "/admin";
},2000); // 2-second delay
}
</script>
</body>
</html>

0 comments on commit 5b474c4

Please sign in to comment.