From: Agnibho Mondal Date: Tue, 5 Mar 2024 20:40:03 +0000 (+0530) Subject: Vaccination log in transaction view X-Git-Url: https://code.agnibho.com/repo?a=commitdiff_plain;h=b8ae1123697c189957155686dd731ed31de477e3;p=librevax.git Vaccination log in transaction view --- diff --git a/librevax.py b/librevax.py index 53c765c..9967b59 100644 --- a/librevax.py +++ b/librevax.py @@ -330,13 +330,13 @@ def transaction_view(action, id=None): usage=0 for used in administered: usage=usage+int(float(used["dosage"])) - balance=usage + balance=0-usage for entry in data: if(entry["action"]=="IN"): balance=balance+int(float(entry["target"])) elif(entry["action"]=="OUT"): balance=balance-int(float(entry["target"])) - return render_template("transaction-view.html", data=data, item=item, usage=usage, balance=balance, action=action) + return render_template("transaction-view.html", data=data, item=item, administered=administered, usage=usage, balance=balance, action=action) else: raise Exception("Invalid parameter") elif(action=="view"): diff --git a/templates/transaction-view.html b/templates/transaction-view.html index 9e79352..1db1733 100644 --- a/templates/transaction-view.html +++ b/templates/transaction-view.html @@ -18,7 +18,7 @@ You should have received a copy of the GNU General Public License along with Lib
-

{{item["vaccine"]}}

+

{{item["vaccine"]}} ({{item["batch"]}})


@@ -30,6 +30,15 @@ You should have received a copy of the GNU General Public License along with Lib Administered{{usage}} Balance{{balance}} +
+

Vaccination Record

+ + + {% for rec in administered %} + + {% endfor %} +
DatePatientDosage
{{rec["date"]|format_date}}{{rec["name"]}}{{rec["dosage"]}}
+ {% endif %} diff --git a/vaccination.py b/vaccination.py index e4ca779..aaf4ceb 100644 --- a/vaccination.py +++ b/vaccination.py @@ -57,7 +57,7 @@ def list_by_patient(cursor, pid): def list_by_inventory(cursor, iid): try: - result=cursor.execute("SELECT * FROM vaccination WHERE iid=?", (iid,)) + result=cursor.execute("SELECT * FROM vaccination LEFT JOIN patients ON vaccination.pid=patients.pid WHERE iid=?", (iid,)) if(cursor.rowcount==0): return (False, "Record not found.") else: