import sys; sys.path.insert(0,"/app")
from app.database import SessionLocal
from sqlalchemy import text as sa_text
from scripts import fix_lab_formatting as F
db = SessionLocal()
t = db.execute(sa_text("SELECT question_text FROM questions WHERE id=143")).scalar()
t,_ = F.repair_units(t)
for m in F._ITEM.finditer(t):
    a = F._accept(m)
    if "smolal" in m.group("name") or "Albumin" in m.group("name") or a is None and "smolal" in m.group(0):
        print(m.start(), m.end(), repr(m.group("name")), "|", repr(m.group("value")), "|", repr(m.group("paren")), "->", a)
print("--- all accepted spans ---")
for m in F._ITEM.finditer(t):
    a=F._accept(m)
    if a: print(m.start(), m.end(), a[0])
