From: Agnibho Mondal Date: Tue, 5 Sep 2023 16:37:26 +0000 (+0530) Subject: Rearranged directories X-Git-Tag: v0.2~12 X-Git-Url: https://code.agnibho.com/repo?a=commitdiff_plain;h=97534cba897a7f9b529375722f91705ea6dcb9a8;p=medscript.git Rearranged directories --- diff --git a/config.py b/config.py index c9d14fe..91468f7 100644 --- a/config.py +++ b/config.py @@ -7,6 +7,8 @@ import argparse, json, os +default_config_file=os.path.abspath(os.path.join("config", "config.json")) + parser = argparse.ArgumentParser() parser.add_argument("filename", nargs="?") parser.add_argument("-c", "--config") @@ -14,18 +16,20 @@ parser.add_argument("-p", "--prescriber") args = parser.parse_args() if(args.config is None): - config_file=os.path.join("config", "config.json") + config_file=default_config_file else: config_file=args.config default = { - "data_directory": "data", "config_directory": "config", + "data_directory": "data", + "document_directory": "document", + "prescriber_directory": "prescriber", + "prescriber": "prescriber", "template_directory": "template", "template": "default", "preset_directory": "preset", - "preset_newline": "True", - "prescriber": "prescriber.json" + "preset_newline": "True" } with open(config_file) as conf: @@ -33,9 +37,14 @@ with open(config_file) as conf: config = default | read config["filename"]=args.filename +config["data_directory"]=os.path.abspath(config["data_directory"]) +config["document_directory"]=os.path.join(config["data_directory"], config["document_directory"]) +config["template_directory"]=os.path.join(config["data_directory"], config["template_directory"]) config["template"]=os.path.join(config["template_directory"], config["template"]) if(args.prescriber is None): - config["prescriber"]=os.path.join(config["config_directory"], config["prescriber"]) + config["prescriber_directory"]=os.path.join(config["data_directory"], config["prescriber_directory"]) + config["prescriber"]=os.path.join(config["prescriber_directory"], config["prescriber"]) + if (not config["prescriber"].endswith(".json")): config["prescriber"]=config["prescriber"]+".json" else: if(not os.path.isabs(args.prescriber)): args.prescriber=os.path.join(config["config_directory"], args.prescriber) diff --git a/config/config.json b/config/config.json index fcd2378..c18be77 100644 --- a/config/config.json +++ b/config/config.json @@ -1,9 +1,11 @@ { - "data_directory": "data", "config_directory": "config", + "data_directory": "data", + "document_directory": "document", + "prescriber_directory": "prescriber", + "prescriber": "prescriber", "template_directory": "template", "template": "default", "preset_directory": "preset", - "preset_newline": "True", - "prescriber": "prescriber.json" + "preset_newline": "True" } diff --git a/config/prescriber.json b/config/prescriber.json deleted file mode 100644 index 097dca5..0000000 --- a/config/prescriber.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": "Dr. John Doe", - "qualification": "MD", - "registration": "0000", - "address": "", - "contact": "", - "extra": "" -} diff --git a/data/.gitignore b/data/.gitignore deleted file mode 100644 index 94548af..0000000 --- a/data/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -* -*/ -!.gitignore diff --git a/data/document/.gitignore b/data/document/.gitignore new file mode 100644 index 0000000..94548af --- /dev/null +++ b/data/document/.gitignore @@ -0,0 +1,3 @@ +* +*/ +!.gitignore diff --git a/data/prescriber/prescriber.json b/data/prescriber/prescriber.json new file mode 100644 index 0000000..097dca5 --- /dev/null +++ b/data/prescriber/prescriber.json @@ -0,0 +1,8 @@ +{ + "name": "Dr. John Doe", + "qualification": "MD", + "registration": "0000", + "address": "", + "contact": "", + "extra": "" +} diff --git a/data/preset/.gitignore b/data/preset/.gitignore new file mode 100644 index 0000000..94548af --- /dev/null +++ b/data/preset/.gitignore @@ -0,0 +1,3 @@ +* +*/ +!.gitignore diff --git a/data/template/default/index.html b/data/template/default/index.html new file mode 100644 index 0000000..8dafdc4 --- /dev/null +++ b/data/template/default/index.html @@ -0,0 +1,86 @@ + + + + Prescription + + + +
+
+ + + + + +
+

{{prescriber.name}}

+

{{prescriber.qualification}}

+

{{prescriber.registration}}

+
+

{{prescriber.address}}

+

{% if prescriber.contact %}Contact: {{prescriber.contact}}{% endif %}

+

{{prescriber.extra}}

+
+
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + +
{% if id %}ID: {{id}}{% endif %}

Name: {{name}}

Age: {{age}}

Sex: {{sex}}

{% if address %}Address: {{address}}{% endif %} {% if contact %}Contact: {{contact}}{% endif %}
{% if extra %}{{extra}}{% endif %}
+ + + + + + + + + +

Clinical Notes

Advice

+ {% if diagnosis %}

{{diagnosis}}

{% endif %} + {% if note %}

{{note}}

{% endif %} + {% if report %}

{{report}}

{% endif %} +
+ {% if advice %}

{{advice}}

{% endif %} +
    + {% for med in medication_list %} +
  1. {{med[0]}}
    + {{med[1]}}
  2. +
    + {% endfor %} +
+ {% if investigation %}

{{investigation}}

{% endif %} + {% if additional %}

{{additional}}

{% endif %} +
+
+
+ +
+ + diff --git a/data/template/default/style.css b/data/template/default/style.css new file mode 100644 index 0000000..a4bf210 --- /dev/null +++ b/data/template/default/style.css @@ -0,0 +1,136 @@ +table { + width: 100%; + border-collapse: collapse; +} + +td { + vertical-align: top; +} + +.container { + width: 95%; + margin-left: auto; + margin-right: auto; +} + +.header, .footer { + width: 95%; + position: fixed; + left: 50%; + transform: translateX(-50%); + background: white; +} +.header { + top: 0; + border-bottom: 2px solid black; +} + +.footer { + bottom: 0; + border-top: 2px solid black; +} + +.header, .header-space { + height: 200px; +} + +.footer, .footer-space { + height: 100px; +} + +.patient { + border-bottom: 2px solid black; +} + +.sign { + border-top: 2px solid black; +} + +.formatted { + white-space: pre-wrap; + padding: 2px; +} + +.ltxt { + text-align: left; +} + +.rtxt { + text-align: right; +} + +.ctxt { + text-align: center; +} + +.bordered { + border: 2px solid black; +} + +.lbordered { + border-left: 2px dotted black; +} + +.rbordered { + border-right: 2px dotted black; +} + +.tbordered { + border-top: 2px solid black; +} + +.bbordered { + border-bottom: 2px solid black; +} + +.w0 { + width: 0%; +} + +.w10 { + width: 10%; +} + +.w20 { + width: 20%; +} + +.w25 { + width: 25%; +} + +.w30 { + width: 30%; +} + +.w40 { + width: 40%; +} + +.w50 { + width: 50%; +} + +.w60 { + width: 60%; +} + +.w70 { + width: 70%; +} + +.w75 { + width: 75%; +} + +.w80 { + width: 80%; +} + +.w90 { + width: 90%; +} + +.w100 { + width: 100%; +} diff --git a/preset/.gitignore b/preset/.gitignore deleted file mode 100644 index 94548af..0000000 --- a/preset/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -* -*/ -!.gitignore diff --git a/resource/prescriber-0.2.schema b/resource/prescriber-0.2.schema new file mode 100644 index 0000000..3e079a5 --- /dev/null +++ b/resource/prescriber-0.2.schema @@ -0,0 +1,33 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "qualification": { + "type": "string" + }, + "registration": { + "type": "string" + }, + "address": { + "type": "string" + }, + "contact": { + "type": "string" + }, + "extra": { + "type": "string" + } + }, + "required": [ + "name", + "qualification", + "registration", + "address", + "contact", + "extra" + ] +} + diff --git a/resource/prescription-0.2.schema b/resource/prescription-0.2.schema new file mode 100644 index 0000000..6341fa5 --- /dev/null +++ b/resource/prescription-0.2.schema @@ -0,0 +1,106 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "properties": { + "date": { + "type": "string" + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "age": { + "type": "string" + }, + "sex": { + "type": "string" + }, + "address": { + "type": "string" + }, + "contact": { + "type": "string" + }, + "extra": { + "type": "string" + }, + "mode": { + "type": "string" + }, + "daw": { + "type": "boolean" + }, + "diagnosis": { + "type": "string" + }, + "note": { + "type": "string" + }, + "report": { + "type": "string" + }, + "advice": { + "type": "string" + }, + "investigation": { + "type": "string" + }, + "medication": { + "type": "string" + }, + "additional": { + "type": "string" + }, + "prescriber": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "qualification": { + "type": "string" + }, + "registration": { + "type": "string" + }, + "address": { + "type": "string" + }, + "contact": { + "type": "string" + }, + "extra": { + "type": "string" + } + }, + "required": [ + "name", + "qualification", + "registration", + "address", + "contact", + "extra" + ] + } + }, + "required": [ + "date", + "id", + "name", + "age", + "sex", + "address", + "contact", + "extra", + "mode", + "daw", + "note", + "report", + "investigation", + "medication", + "advice", + "prescriber" + ] +} diff --git a/schema/prescriber-0.1.schema b/schema/prescriber-0.1.schema deleted file mode 100644 index 3e079a5..0000000 --- a/schema/prescriber-0.1.schema +++ /dev/null @@ -1,33 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-04/schema#", - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "qualification": { - "type": "string" - }, - "registration": { - "type": "string" - }, - "address": { - "type": "string" - }, - "contact": { - "type": "string" - }, - "extra": { - "type": "string" - } - }, - "required": [ - "name", - "qualification", - "registration", - "address", - "contact", - "extra" - ] -} - diff --git a/schema/prescription-0.1.schema b/schema/prescription-0.1.schema deleted file mode 100644 index 6341fa5..0000000 --- a/schema/prescription-0.1.schema +++ /dev/null @@ -1,106 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-04/schema#", - "type": "object", - "properties": { - "date": { - "type": "string" - }, - "id": { - "type": "string" - }, - "name": { - "type": "string" - }, - "age": { - "type": "string" - }, - "sex": { - "type": "string" - }, - "address": { - "type": "string" - }, - "contact": { - "type": "string" - }, - "extra": { - "type": "string" - }, - "mode": { - "type": "string" - }, - "daw": { - "type": "boolean" - }, - "diagnosis": { - "type": "string" - }, - "note": { - "type": "string" - }, - "report": { - "type": "string" - }, - "advice": { - "type": "string" - }, - "investigation": { - "type": "string" - }, - "medication": { - "type": "string" - }, - "additional": { - "type": "string" - }, - "prescriber": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "qualification": { - "type": "string" - }, - "registration": { - "type": "string" - }, - "address": { - "type": "string" - }, - "contact": { - "type": "string" - }, - "extra": { - "type": "string" - } - }, - "required": [ - "name", - "qualification", - "registration", - "address", - "contact", - "extra" - ] - } - }, - "required": [ - "date", - "id", - "name", - "age", - "sex", - "address", - "contact", - "extra", - "mode", - "daw", - "note", - "report", - "investigation", - "medication", - "advice", - "prescriber" - ] -} diff --git a/template/default/index.html b/template/default/index.html deleted file mode 100644 index 8dafdc4..0000000 --- a/template/default/index.html +++ /dev/null @@ -1,86 +0,0 @@ - - - - Prescription - - - -
-
- - - - - -
-

{{prescriber.name}}

-

{{prescriber.qualification}}

-

{{prescriber.registration}}

-
-

{{prescriber.address}}

-

{% if prescriber.contact %}Contact: {{prescriber.contact}}{% endif %}

-

{{prescriber.extra}}

-
-
-
- - - - - - - - -
- - - - - - - - - - - - - - - -
{% if id %}ID: {{id}}{% endif %}

Name: {{name}}

Age: {{age}}

Sex: {{sex}}

{% if address %}Address: {{address}}{% endif %} {% if contact %}Contact: {{contact}}{% endif %}
{% if extra %}{{extra}}{% endif %}
- - - - - - - - - -

Clinical Notes

Advice

- {% if diagnosis %}

{{diagnosis}}

{% endif %} - {% if note %}

{{note}}

{% endif %} - {% if report %}

{{report}}

{% endif %} -
- {% if advice %}

{{advice}}

{% endif %} -
    - {% for med in medication_list %} -
  1. {{med[0]}}
    - {{med[1]}}
  2. -
    - {% endfor %} -
- {% if investigation %}

{{investigation}}

{% endif %} - {% if additional %}

{{additional}}

{% endif %} -
-
-
- -
- - diff --git a/template/default/style.css b/template/default/style.css deleted file mode 100644 index a4bf210..0000000 --- a/template/default/style.css +++ /dev/null @@ -1,136 +0,0 @@ -table { - width: 100%; - border-collapse: collapse; -} - -td { - vertical-align: top; -} - -.container { - width: 95%; - margin-left: auto; - margin-right: auto; -} - -.header, .footer { - width: 95%; - position: fixed; - left: 50%; - transform: translateX(-50%); - background: white; -} -.header { - top: 0; - border-bottom: 2px solid black; -} - -.footer { - bottom: 0; - border-top: 2px solid black; -} - -.header, .header-space { - height: 200px; -} - -.footer, .footer-space { - height: 100px; -} - -.patient { - border-bottom: 2px solid black; -} - -.sign { - border-top: 2px solid black; -} - -.formatted { - white-space: pre-wrap; - padding: 2px; -} - -.ltxt { - text-align: left; -} - -.rtxt { - text-align: right; -} - -.ctxt { - text-align: center; -} - -.bordered { - border: 2px solid black; -} - -.lbordered { - border-left: 2px dotted black; -} - -.rbordered { - border-right: 2px dotted black; -} - -.tbordered { - border-top: 2px solid black; -} - -.bbordered { - border-bottom: 2px solid black; -} - -.w0 { - width: 0%; -} - -.w10 { - width: 10%; -} - -.w20 { - width: 20%; -} - -.w25 { - width: 25%; -} - -.w30 { - width: 30%; -} - -.w40 { - width: 40%; -} - -.w50 { - width: 50%; -} - -.w60 { - width: 60%; -} - -.w70 { - width: 70%; -} - -.w75 { - width: 75%; -} - -.w80 { - width: 80%; -} - -.w90 { - width: 90%; -} - -.w100 { - width: 100%; -} diff --git a/window.py b/window.py index 998b17e..eb507b3 100644 --- a/window.py +++ b/window.py @@ -38,7 +38,7 @@ class MainWindow(QMainWindow): def cmd_open(self): try: - self.current_file.set_file(QFileDialog.getOpenFileName(self, "Open File", config["data_directory"], "Prescriptions (*.mpaz);; All Files (*)")[0]) + self.current_file.set_file(QFileDialog.getOpenFileName(self, "Open File", config["document_directory"], "Prescriptions (*.mpaz);; All Files (*)")[0]) self.current_file.open() self.prescription.read_from(os.path.join(self.current_file.directory.name,"prescription.json")) self.load_interface_from_instance() @@ -52,7 +52,7 @@ class MainWindow(QMainWindow): def cmd_save(self, save_as=False): self.update_instance() suggest=self.prescription.id if(self.prescription.id) else self.prescription.name - suggest=os.path.abspath(os.path.join(config["data_directory"], suggest)+".mpaz") + suggest=os.path.abspath(os.path.join(config["document_directory"], suggest)+".mpaz") if(save_as or not self.unchanged_state or QMessageBox.StandardButton.Yes==QMessageBox.question(self,"Confirm change", "Modify the original file?")): try: if not os.path.exists(self.current_file.file): @@ -72,7 +72,7 @@ class MainWindow(QMainWindow): def cmd_save_as(self): suggest=self.prescription.id if(self.prescription.id) else self.prescription.name - suggest=os.path.abspath(os.path.join(config["data_directory"], suggest)+".mpaz") + suggest=os.path.abspath(os.path.join(config["document_directory"], suggest)+".mpaz") self.current_file.set_file(QFileDialog.getSaveFileName(self, "Save File", suggest, "Prescriptions (*.mpaz);; All Files (*)")[0]) Path(self.current_file.file).touch() self.cmd_save(save_as=True) @@ -248,7 +248,7 @@ class MainWindow(QMainWindow): def add_attachment(self): try: - new=QFileDialog.getOpenFileName(self, "Open File", config["data_directory"], "PDF (*.pdf);; Images (*.jpg, *.jpeg, *.png, *.gif);; All Files (*)")[0] + new=QFileDialog.getOpenFileName(self, "Open File", config["document_directory"], "PDF (*.pdf);; Images (*.jpg, *.jpeg, *.png, *.gif);; All Files (*)")[0] if new: self.input_attachment.addItem(new) except Exception as e: