]> Softwares of Agnibho - medscript.git/commitdiff
Patch: medication alt name format
authorAgnibho Mondal <mondal@agnibho.com>
Sun, 3 Sep 2023 19:50:36 +0000 (01:20 +0530)
committerAgnibho Mondal <mondal@agnibho.com>
Sun, 3 Sep 2023 19:50:36 +0000 (01:20 +0530)
renderer.py

index 6b4aa2ed2ae69614dcbb6f7b1364c5fddbc7ba3a..6f18e38d34a3d755443330075e77e06247788ce5 100644 (file)
@@ -5,7 +5,7 @@
 # MedScript is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 # You should have received a copy of the GNU General Public License along with MedScript. If not, see <https://www.gnu.org/licenses/>.
 
-import os, shutil, tempfile, json, datetime
+import os, shutil, tempfile, json, datetime, re
 from jinja2 import Template
 from config import config
 
@@ -33,8 +33,14 @@ class Renderer:
 
     def process_medication(self, data):
         medication_list=[]
+        pattern=re.compile(r".*?\[(.*)\].*")
         for line in data["medication"].splitlines():
             if(line):
-                medication_list.append([m.strip() for m in line.replace(")", "").split("(")])
+                try:
+                    f2=re.search(pattern, line).group(1)
+                    f1=line.replace("["+f2+"]", "")
+                    medication_list.append([f1, f2])
+                except AttributeError:
+                    medication_list.append([line, ""])
         data["medication_list"]=medication_list
         return data