the respective files. These files are in the .csv format and can be edited
with any spreadsheet editing software.
+There is a preset editor included with this software as well. This editor can
+be accessed by going to the setting menu and selecting the preset option.
+
+The preset editor contains a drop down input at the top which can be used to
+select the respective file to edit. There is also a save button at the top
+which can be used to save the changes to the selected file.
+
+The data is presented in an editable table which can be used to edit the data
+in the selected file. While editing, the KEY/VALUE format is to be used as
+shown in the top row. The add row button at the bottom can be used to add a
+new row for entry of new data.
+
The preset files are kept in the preset directory. The files associated with
medical certificate, clinical note, report, advice, investigation, medication
and additional are certify.csv, note.csv, report.csv, advice.csv,
investigation.csv, medication.csv and additional.csv. Each file contains a top
row indicating the variables in the columns. The data is entered in two
columns with each row containing a KEY and a TEXT. The TEXT can be entered in
-to the edit area by selecting the KEY from the preset input. Blank files with
+the edit area by selecting the KEY from the preset input. Blank files with
only the top row are included with the program.
Configuration
--- /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 PyQt6.QtWidgets import QWidget, QMainWindow, QVBoxLayout, QHBoxLayout, QPushButton, QComboBox, QTextEdit, QTableView, QMessageBox
+from PyQt6.QtGui import QIcon, QStandardItemModel, QStandardItem
+from config import config
+import os, csv
+
+class EditPreset(QMainWindow):
+
+ editors=[]
+ model=QStandardItemModel()
+
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+
+ self.setWindowTitle("MedScript")
+ self.setGeometry(200, 200, 600, 400)
+
+ widget=QWidget(self)
+ layout=QVBoxLayout(widget)
+ self.table=QTableView()
+ layout2=QHBoxLayout()
+ self.input_file=QComboBox()
+ self.input_file.addItems(["note", "report", "advice", "investigation", "medication", "additional", "certify"])
+ self.input_file.currentIndexChanged.connect(self.cmd_load)
+ button_save=QPushButton("Save")
+ button_save.clicked.connect(self.cmd_save)
+ button_row=QPushButton("Add Row")
+ button_row.clicked.connect(self.cmd_row)
+ layout2.addWidget(self.input_file)
+ layout2.addWidget(button_save)
+ layout.addLayout(layout2)
+ layout.addWidget(self.table)
+ layout.addWidget(button_row)
+
+ self.setCentralWidget(widget)
+ self.setWindowIcon(QIcon(os.path.join("resource", "icon_medscript.ico")))
+
+ self.load()
+
+ def cmd_load(self):
+ if self.confirm():
+ self.load()
+
+ def cmd_save(self):
+ try:
+ item=self.input_file.currentText()
+ file=os.path.join(config["preset_directory"], item+".csv")
+ with open(file, "w") as f:
+ writer=csv.writer(f, delimiter=config["preset_delimiter"])
+ writer.writerow(["KEY", "VALUE"])
+ for i in self.editors:
+ row=[i[0].toPlainText(), i[1].toPlainText()]
+ if row[0].strip()!="" or row[1].strip()!="":
+ writer.writerow(row)
+ self.load(file)
+ QMessageBox.information(self,"File saved", "Changes saved. Please restart the program.")
+ except Exception as e:
+ print(e)
+
+ def cmd_row(self):
+ tablerow=[]
+ tablerow.append(QStandardItem(""))
+ tablerow.append(QStandardItem(""))
+ self.model.appendRow(tablerow)
+ self.editors.append([QTextEdit(), QTextEdit()])
+ self.table.setIndexWidget(self.model.index(self.model.rowCount()-1,0), self.editors[-1][0])
+ self.table.setIndexWidget(self.model.index(self.model.rowCount()-1,1), self.editors[-1][1])
+ self.table.resizeRowsToContents()
+
+ def load(self, file=None):
+ try:
+ if file is None:
+ item=self.input_file.currentText()
+ file=os.path.join(config["preset_directory"], item+".csv")
+ self.editors=[]
+ self.model=QStandardItemModel()
+ self.model.setHorizontalHeaderLabels(["KEY", "VALUE"])
+ self.table.setModel(self.model)
+ with open(file) as f:
+ reader=csv.reader(f, delimiter=config["preset_delimiter"])
+ next(reader)
+ for idx,row in enumerate(reader):
+ tablerow=[]
+ tablerow.append(QStandardItem(row[0]))
+ tablerow.append(QStandardItem(row[1]))
+ self.model.appendRow(tablerow)
+ self.editors.append([QTextEdit(), QTextEdit()])
+ self.editors[idx][0].setPlainText(row[0])
+ self.editors[idx][1].setPlainText(row[1])
+ self.table.setIndexWidget(self.model.index(idx,0), self.editors[idx][0])
+ self.table.setIndexWidget(self.model.index(idx,1), self.editors[idx][1])
+ self.table.horizontalHeader().setStretchLastSection(True)
+ self.table.resizeRowsToContents()
+ textedit=QTextEdit()
+ except Exception as e:
+ print(e)
+
+ def confirm(self):
+ return QMessageBox.StandardButton.Yes==QMessageBox.question(self,"Confirm action", "Unsaved changes may be lost. Continue?")
+
+ def closeEvent(self, event):
+ if self.confirm():
+ event.accept()
+ else:
+ event.ignore()
from filehandler import FileHandler
from renderbox import RenderBox
from setting import EditConfiguration, EditPrescriber
+from editpreset import EditPreset
from viewbox import ViewBox
from preset import Preset
from tabular import Tabular
except FileNotFoundError as e:
print(e)
+ def cmd_preset(self):
+ self.edit_preset.show()
+
def cmd_about(self):
year=datetime.datetime.now().year
if(year>2023):
action_prescriber.triggered.connect(self.cmd_prescriber)
action_switch=QAction("Switch", self)
action_switch.triggered.connect(self.cmd_switch)
+ action_preset=QAction("Preset", self)
+ action_preset.triggered.connect(self.cmd_preset)
action_tabular=QAction("Tabular", self)
action_tabular.triggered.connect(self.cmd_tabular)
action_index=QAction("Index", self)
menu_settings.addAction(action_configuration)
menu_settings.addAction(action_prescriber)
menu_settings.addAction(action_switch)
+ menu_settings.addAction(action_preset)
menu_data=menubar.addMenu("Data")
menu_data.addAction(action_index)
menu_data.addAction(action_tabular)
self.edit_prescriber.signal_save.connect(self.cmd_prescriber_reload)
self.viewbox=ViewBox()
self.index=Index()
+ self.edit_preset=EditPreset()
self.index.signal_open.connect(self.cmd_open)
self.index.signal_copy.connect(self.cmd_copy)
self.signal_update.connect(self.show_update)