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")
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:
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)
{
- "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"
}
+++ /dev/null
-{
- "name": "Dr. John Doe",
- "qualification": "MD",
- "registration": "0000",
- "address": "",
- "contact": "",
- "extra": ""
-}
+++ /dev/null
-*
-*/
-!.gitignore
--- /dev/null
+*
+*/
+!.gitignore
--- /dev/null
+{
+ "name": "Dr. John Doe",
+ "qualification": "MD",
+ "registration": "0000",
+ "address": "",
+ "contact": "",
+ "extra": ""
+}
--- /dev/null
+*
+*/
+!.gitignore
--- /dev/null
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Prescription</title>
+ <link rel="stylesheet" href="style.css">
+ </head>
+ <body>
+ <div class="container">
+ <div class="header" style="position:fixed;top:0">
+ <table class="w100">
+ <tr>
+ <td class="w60">
+ <h1>{{prescriber.name}}</h1>
+ <h2>{{prescriber.qualification}}</h2>
+ <h3>{{prescriber.registration}}</h3>
+ </td>
+ <td class="w40">
+ <p class="formatted">{{prescriber.address}}</p>
+ <p>{% if prescriber.contact %}Contact: {{prescriber.contact}}{% endif %}</p>
+ <p class="formatted">{{prescriber.extra}}</p>
+ </td>
+ </tr>
+ </table>
+ </div>
+ <div class="content">
+ <table>
+ <thead><tr><td><div class="header-space"></div></td></tr></thead>
+ <tbody>
+ <tr>
+ <td>
+ <table class="patient">
+ <tr>
+ <td class="rtxt" colspan="3"><small>{% if id %}ID: {{id}}{% endif %}</small></td>
+ </tr>
+ <tr>
+ <td><p><strong>Name:</strong> {{name}}</p></td>
+ <td><p><strong>Age:</strong> {{age}}</p></td>
+ <td><p><strong>Sex:</strong> {{sex}}</p></td>
+ </tr>
+ <tr>
+ <td colspan="3"><small>{% if address %}Address: {{address}}{% endif %} {% if contact %}Contact: {{contact}}{% endif %}</small></td>
+ </tr>
+ <tr>
+ <td colspan="3"><small>{% if extra %}{{extra}}{% endif %}</small></td>
+ </tr>
+ </table>
+ <table>
+ <tr>
+ <td class="w40 bbordered ctxt"><p><strong>Clinical Notes</strong></p></td>
+ <td class="w60 bbordered ctxt"><p><strong>Advice</strong></p></td>
+ </tr>
+ <tr>
+ <td class="rbordered">
+ {% if diagnosis %}<p class="formatted"><strong>{{diagnosis}}</strong></p>{% endif %}
+ {% if note %}<p class="formatted">{{note}}</p>{% endif %}
+ {% if report %}<p class="formatted">{{report}}</p>{% endif %}
+ </td>
+ <td class="lbordered">
+ {% if advice %}<p class="formatted">{{advice}}</p>{% endif %}
+ <ol>
+ {% for med in medication_list %}
+ <li><strong>{{med[0]}}</strong><br>
+ <small><em>{{med[1]}}</em></small></li>
+ <hr>
+ {% endfor %}
+ </ol>
+ {% if investigation %}<p class="formatted">{{investigation}}</p>{% endif %}
+ {% if additional %}<p class="formatted">{{additional}}</p>{% endif %}
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </tbody>
+ <tfoot><tr><td><div class="footer-space"></div></td></tr></tfoot>
+ </table>
+ </div>
+ <div class="footer">
+ <table class="w100">
+ <tr><td class="w75">{% if mode %}Consultation: {{mode}}{% endif %}<br>{% if daw %}Dispense as written{% endif %}</td><td class="w25"><br><br></td></tr>
+ <tr><td><p>{{date.strftime("%B %d, %Y %I:%M %p")}}</p></td><td class="sign"><p>Signature</p></td></tr>
+ </table>
+ </div>
+ </div>
+ </body>
+</html>
--- /dev/null
+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%;
+}
+++ /dev/null
-*
-*/
-!.gitignore
--- /dev/null
+{
+ "$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"
+ ]
+}
+
--- /dev/null
+{
+ "$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"
+ ]
+}
+++ /dev/null
-{
- "$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"
- ]
-}
-
+++ /dev/null
-{
- "$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"
- ]
-}
+++ /dev/null
-<!DOCTYPE html>
-<html>
- <head>
- <title>Prescription</title>
- <link rel="stylesheet" href="style.css">
- </head>
- <body>
- <div class="container">
- <div class="header" style="position:fixed;top:0">
- <table class="w100">
- <tr>
- <td class="w60">
- <h1>{{prescriber.name}}</h1>
- <h2>{{prescriber.qualification}}</h2>
- <h3>{{prescriber.registration}}</h3>
- </td>
- <td class="w40">
- <p class="formatted">{{prescriber.address}}</p>
- <p>{% if prescriber.contact %}Contact: {{prescriber.contact}}{% endif %}</p>
- <p class="formatted">{{prescriber.extra}}</p>
- </td>
- </tr>
- </table>
- </div>
- <div class="content">
- <table>
- <thead><tr><td><div class="header-space"></div></td></tr></thead>
- <tbody>
- <tr>
- <td>
- <table class="patient">
- <tr>
- <td class="rtxt" colspan="3"><small>{% if id %}ID: {{id}}{% endif %}</small></td>
- </tr>
- <tr>
- <td><p><strong>Name:</strong> {{name}}</p></td>
- <td><p><strong>Age:</strong> {{age}}</p></td>
- <td><p><strong>Sex:</strong> {{sex}}</p></td>
- </tr>
- <tr>
- <td colspan="3"><small>{% if address %}Address: {{address}}{% endif %} {% if contact %}Contact: {{contact}}{% endif %}</small></td>
- </tr>
- <tr>
- <td colspan="3"><small>{% if extra %}{{extra}}{% endif %}</small></td>
- </tr>
- </table>
- <table>
- <tr>
- <td class="w40 bbordered ctxt"><p><strong>Clinical Notes</strong></p></td>
- <td class="w60 bbordered ctxt"><p><strong>Advice</strong></p></td>
- </tr>
- <tr>
- <td class="rbordered">
- {% if diagnosis %}<p class="formatted"><strong>{{diagnosis}}</strong></p>{% endif %}
- {% if note %}<p class="formatted">{{note}}</p>{% endif %}
- {% if report %}<p class="formatted">{{report}}</p>{% endif %}
- </td>
- <td class="lbordered">
- {% if advice %}<p class="formatted">{{advice}}</p>{% endif %}
- <ol>
- {% for med in medication_list %}
- <li><strong>{{med[0]}}</strong><br>
- <small><em>{{med[1]}}</em></small></li>
- <hr>
- {% endfor %}
- </ol>
- {% if investigation %}<p class="formatted">{{investigation}}</p>{% endif %}
- {% if additional %}<p class="formatted">{{additional}}</p>{% endif %}
- </td>
- </tr>
- </table>
- </td>
- </tr>
- </tbody>
- <tfoot><tr><td><div class="footer-space"></div></td></tr></tfoot>
- </table>
- </div>
- <div class="footer">
- <table class="w100">
- <tr><td class="w75">{% if mode %}Consultation: {{mode}}{% endif %}<br>{% if daw %}Dispense as written{% endif %}</td><td class="w25"><br><br></td></tr>
- <tr><td><p>{{date.strftime("%B %d, %Y %I:%M %p")}}</p></td><td class="sign"><p>Signature</p></td></tr>
- </table>
- </div>
- </div>
- </body>
-</html>
+++ /dev/null
-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%;
-}
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()
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):
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)
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: