From: Agnibho Mondal Date: Wed, 8 Nov 2023 12:40:46 +0000 (+0530) Subject: Option to set age as default X-Git-Tag: v0.5~46 X-Git-Url: https://code.agnibho.com/repo?a=commitdiff_plain;h=df3bb136caf37d3b5f0e32f7a0e5c25b023c0d85;p=medscript.git Option to set age as default --- diff --git a/config.py b/config.py index 0f0c84a..ae6b2b7 100644 --- a/config.py +++ b/config.py @@ -34,6 +34,7 @@ default = { "template": "default_prescription", "preset_directory": "preset", "form_directory": "form", + "age_default": True, "enable_form": False, "plugin_directory": "plugin", "enable_plugin": False, diff --git a/setting.py b/setting.py index 9a33bb7..f4aaf3c 100644 --- a/setting.py +++ b/setting.py @@ -42,6 +42,7 @@ class EditConfiguration(QDialog): self.input_prescriber.setText(self.config["prescriber"]) self.input_newline.setChecked(bool(self.config["preset_newline"])) self.input_delimiter.setCurrentText(self.config["preset_delimiter"]) + self.input_agedob.setChecked(bool(self.config["age_default"])) self.input_markdown.setChecked(bool(self.config["markdown"])) self.input_update.setChecked(bool(self.config["check_update"])) self.input_form.setChecked(bool(self.config["enable_form"])) @@ -52,7 +53,7 @@ class EditConfiguration(QDialog): self.input_root.setText(self.config["root_bundle"]) except Exception as e: QMessageBox.critical(self,"Failed to load", "Failed to load the data into the application.") - raise(e) + logging.warning(e) def save(self): if(QMessageBox.StandardButton.Yes==QMessageBox.question(self,"Confirm Save", "This action will overwrite the previous configuration. Continue?")): @@ -61,6 +62,7 @@ class EditConfiguration(QDialog): self.config["prescriber"]=self.input_prescriber.text() self.config["preset_newline"]=self.input_newline.isChecked() self.config["preset_delimiter"]=self.input_delimiter.currentText() + self.config["age_default"]=self.input_agedob.isChecked() self.config["markdown"]=self.input_markdown.isChecked() self.config["check_update"]=self.input_update.isChecked() self.config["enable_form"]=self.input_form.isChecked() @@ -109,6 +111,8 @@ class EditConfiguration(QDialog): self.input_delimiter=QComboBox(self) self.input_delimiter.addItems([",", ";"]) layout.addRow("Preset Delimiter", self.input_delimiter) + self.input_agedob=QCheckBox("Age default in new prescriptions", self) + layout.addRow("Age/DOB", self.input_agedob) self.input_markdown=QCheckBox("Enable markdown formatting", self) layout.addRow("Markdown", self.input_markdown) self.input_update=QCheckBox("Check update on startup", self) diff --git a/window.py b/window.py index ca80b94..30cdf44 100644 --- a/window.py +++ b/window.py @@ -448,6 +448,9 @@ class MainWindow(QMainWindow): self.update_instance() self.plugin.new(self.prescription) self.load_interface_from_instance() + if(config["age_default"]): + self.btnAge.click() + self.update_instance() self.save_state=md5(self.prescription.get_json().encode()).hexdigest() def change_prescriber(self, file):