From 573e32846059010a03e2e6bc191ccbf9fcb3b57f Mon Sep 17 00:00:00 2001 From: Agnibho Mondal Date: Mon, 4 Sep 2023 01:20:36 +0530 Subject: [PATCH] Patch: medication alt name format --- renderer.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/renderer.py b/renderer.py index 6b4aa2e..6f18e38 100644 --- a/renderer.py +++ b/renderer.py @@ -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 . -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 -- 2.39.2