--- /dev/null
+# MedScript
+# Copyright (C) 2023 Dr. Agnibho Mondal
+# This file is part of MedScript.
+# MedScript is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+# MedScript is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+# You should have received a copy of the GNU General Public License along with MedScript. If not, see <https://www.gnu.org/licenses/>.
+
+from config import config
+from glob import glob
+from zipfile import ZipFile
+import os
+import json
+import csv
+
+class Tabular():
+
+ def export(filename):
+ files=glob(os.path.join(config["document_directory"], "**", "*.mpaz"), recursive=True)
+ with open(filename, "w", newline="") as ss:
+ writer=csv.writer(ss, delimiter=config["preset_delimiter"], quoting=csv.QUOTE_MINIMAL)
+ writer.writerow(["id", "date", "name", "age", "sex", "address", "contact", "extra", "mode", "daw", "diagnosis", "note", "report", "advice", "investigation", "medication", "additional", "prescriber"])
+ for file in files:
+ with ZipFile(file) as zf:
+ with zf.open("prescription.json") as pf:
+ pres=json.loads(pf.read())
+ writer.writerow([pres["id"], pres["date"], pres["name"], pres["age"], pres["sex"], pres["address"], pres["contact"], pres["extra"], pres["mode"], pres["daw"], pres["diagnosis"], pres["note"], pres["report"], pres["advice"], pres["investigation"], pres["medication"], pres["additional"], pres["prescriber"]["name"]])
from setting import EditConfiguration, EditPrescriber
from viewbox import ViewBox
from preset import Preset
+from tabular import Tabular
try:
from M2Crypto.EVP import EVPError
from M2Crypto.BIO import BIOError
try:
result=self.current_file.verify()
if result is False:
- QMessageBox.critical(self, "Verification failed", "Signature is invalid.")
+ QMessageBox.critical(self, "Verification failed", "Signature is invalid.")
elif result is None:
QMessageBox.warning(self, "No Siganture", "No signature was found.")
else:
print(e)
QMessageBox.warning(self, "Failed", "Failed to verify.")
+ def cmd_tabular(self):
+ try:
+ filename=QFileDialog.getSaveFileName(self, "Export CSV File", os.path.join(config["data_directory"], "data.csv"), "CSV (*.csv);; All Files (*)")[0]
+ Tabular.export(filename)
+ QMessageBox.information(self, "Data Exported", "Data exported to."+filename)
+ except Exception as e:
+ print(e)
+ QMessageBox.critical(self, "Export failed", "Failed to export the data.")
+
+ def cmd_index(self):
+ pass
+
def cmd_configuration(self):
self.edit_configuration.show()
action_prescriber.triggered.connect(self.cmd_prescriber)
action_switch=QAction("Switch", self)
action_switch.triggered.connect(self.cmd_switch)
+ action_tabular=QAction("Tabular", self)
+ action_tabular.triggered.connect(self.cmd_tabular)
+ action_index=QAction("Index", self)
+ action_index.triggered.connect(self.cmd_index)
action_about=QAction("About", self)
action_about.triggered.connect(self.cmd_about)
action_help=QAction("Help", self)
menu_settings.addAction(action_configuration)
menu_settings.addAction(action_prescriber)
menu_settings.addAction(action_switch)
+ menu_data=menubar.addMenu("Data")
+ menu_data.addAction(action_tabular)
+ menu_data.addAction(action_index)
menu_help=menubar.addMenu("Help")
menu_help.addAction(action_about)
menu_help.addAction(action_help)