]> Softwares of Agnibho - medscript.git/commitdiff
Print both generic and brand if available
authorAgnibho Mondal <mondal@agnibho.com>
Sun, 3 Sep 2023 18:50:38 +0000 (00:20 +0530)
committerAgnibho Mondal <mondal@agnibho.com>
Sun, 3 Sep 2023 18:50:38 +0000 (00:20 +0530)
renderer.py
template/default/index.html

index 0c77d0aa5a194fffe7ced38d4e0ed18722ae2530..6b4aa2ed2ae69614dcbb6f7b1364c5fddbc7ba3a 100644 (file)
@@ -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
index f4d5493f0c03d4ba0c38078f7484607792f73bd0..6dcfc0897e43921d3a17a9c9d73fed0b0600aad1 100644 (file)
                       <p>{{note}}</p>
                       <p>{{report}}</p>
                     </td>
-                    <td class="formatted lbordered">
-                      <p>{{medication}}</p>
-                      <p>{{investigation}}</p>
-                      <p>{{advice}}</p>
+                    <td class="lbordered">
+                      <div>
+                        <ol>
+                          {% for med in medication_list %}
+                          <li><strong>{{med[0]}}</strong><br>
+                            <small><em>{{med[1]}}</em></small></li>
+                          <hr>
+                          {% endfor %}
+                        </ol>
+                      </div>
+                      <div class="formatted">
+                        <p>{{investigation}}</p>
+                        <p>{{advice}}</p>
+                      </div>
                     </td>
                   </tr>
                 </table>