From: Agnibho Mondal Date: Sun, 3 Sep 2023 18:50:38 +0000 (+0530) Subject: Print both generic and brand if available X-Git-Tag: v0.2~16 X-Git-Url: https://code.agnibho.com/repo?a=commitdiff_plain;h=20a27ea5e161ba8aa90a0e048f51613470c128ac;p=medscript.git Print both generic and brand if available --- diff --git a/renderer.py b/renderer.py index 0c77d0a..6b4aa2e 100644 --- a/renderer.py +++ b/renderer.py @@ -22,7 +22,7 @@ class Renderer: with open(source, "r") as source_file, open(target, "w") as target_file: with open(template) as template_file: template_data = Template(template_file.read()) - data=json.loads(source_file.read()) + data=self.process_medication(json.loads(source_file.read())) try: data["date"]=datetime.datetime.strptime(data["date"], "%Y-%m-%d %H:%M:%S") except Exception as e: @@ -30,3 +30,11 @@ class Renderer: output=template_data.render(data) target_file.write(output) return(target) + + def process_medication(self, data): + medication_list=[] + for line in data["medication"].splitlines(): + if(line): + medication_list.append([m.strip() for m in line.replace(")", "").split("(")]) + data["medication_list"]=medication_list + return data diff --git a/template/default/index.html b/template/default/index.html index f4d5493..6dcfc08 100644 --- a/template/default/index.html +++ b/template/default/index.html @@ -54,10 +54,20 @@

{{note}}

{{report}}

- -

{{medication}}

-

{{investigation}}

-

{{advice}}

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

{{investigation}}

+

{{advice}}

+