From: Agnibho Mondal Date: Thu, 9 Nov 2023 19:23:12 +0000 (+0530) Subject: Option to replace when original/current prescribers differ X-Git-Tag: v0.5~30 X-Git-Url: https://code.agnibho.com/repo?a=commitdiff_plain;h=1dfbb63f4f726a26bc7ae7ee8511ea1f6f3c8314;p=medscript.git Option to replace when original/current prescribers differ --- diff --git a/prescription.py b/prescription.py index 893a303..e730690 100644 --- a/prescription.py +++ b/prescription.py @@ -24,6 +24,9 @@ class Prescriber: self.extra = extra self.properties = properties + def get_json(self): + return(json.dumps(self, default=lambda o: o.__dict__, indent=4)) + def set_data_from_json(self, data): try: self.name = data["name"] diff --git a/window.py b/window.py index c281b5e..56e8b49 100644 --- a/window.py +++ b/window.py @@ -5,7 +5,7 @@ # 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 . -import logging, os, sys, datetime, dateutil.parser, shutil, json, threading +import logging, os, sys, datetime, dateutil.parser, shutil, json, copy, threading from PyQt6.QtCore import Qt, QDateTime, QDate, QSize, pyqtSignal from PyQt6.QtWidgets import QWidget, QMainWindow, QMessageBox, QLabel, QPushButton, QLineEdit, QTextEdit, QDateTimeEdit, QDateEdit, QCalendarWidget, QListWidget, QComboBox, QCheckBox, QRadioButton, QButtonGroup, QVBoxLayout, QHBoxLayout, QFormLayout, QToolBar, QTabWidget, QStatusBar, QFileDialog, QInputDialog, QCompleter, QSizePolicy from PyQt6.QtGui import QAction, QIcon @@ -97,6 +97,9 @@ class MainWindow(QMainWindow): self.current_file.set_file(filename) for i in range(self.input_attachment.count()): self.current_file.copy(self.input_attachment.item(i).text()) + if(self.prescription.prescriber.get_json()!=self.prescriber.get_json()): + if(QMessageBox.StandardButton.Yes==QMessageBox.question(self,"Change Prescriber", "Original Prescriber: "+self.prescription.prescriber.name+"\nCurrent Prescriber: "+self.prescriber.name+"\nReplace original with current?")): + self.prescription.prescriber=copy.deepcopy(self.prescriber) self.prescription.write_to(os.path.join(self.current_file.directory.name, "prescription.json")) if change_template: config["template"]=os.path.join(config["template_directory"], template)