GABRIELSZK commited on
Commit
d354e3f
·
verified ·
1 Parent(s): 8f07449

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -12,12 +12,12 @@ faixas = {
12
  "HB": (12, 17), "HT": (36, 50), "LEUCO": (4, 11), "PLT": (150, 450),
13
  "K+": (3.5, 5.5), "NA+": (135, 145), "UREIA": (10, 50), "CR": (0.6, 1.3),
14
  "TGO": (0, 40), "TGP": (0, 40), "ALB": (3.5, 5.0), "INR": (0.8, 1.2),
15
- "TAP": (10, 14), "TTP": (25, 35), "LAC": (0.5, 2.2)
16
  }
17
 
18
  def classificar(nome, valor):
19
  """
20
- Recebe o nome do exame e valor em string; retorna valor com ou ↑ se fora da faixa.
21
  """
22
  try:
23
  raw = valor.replace("K", "").replace(">", "").replace("<", "").strip()
@@ -95,6 +95,7 @@ exames = {
95
  "TAP": r"tempo de protrombina.*?\bresultado\b\s*([\d]+,[\d]+)",
96
  "INR": r"I\s*N\s*R\s+([\d]+,[\d]+)",
97
  "TTP": r"ttpa.*?([\d.,]+)\s?seg",
 
98
  "LAC": r"lactato.*?([\d.,]+)\s?mmol/l",
99
  "CKMB": r"ck[- ]?mb.*?([\d.,]+)\s?u/l",
100
  "CPK": r"cpk.*?\bresultado\b\s*([\d.,]+)",
@@ -108,7 +109,8 @@ ordem = [
108
  "CAI","CA TOTAL","CL-","CR","UREIA",
109
  "FAL","FÓS","GGT","GLI","LIP","MG++",
110
  "PCR","K+","NA+","PTN","ALB","GLOB","RELAÇÃO",
111
- "TGO","TGP","TAP","INR","TTP","LAC","CKMB","CPK","TROPO"
 
112
  ]
113
 
114
  # Função principal de extração e formatação
@@ -135,10 +137,10 @@ def extrair_exames_formatado(pdf_file):
135
 
136
  # Interface Gradio
137
  with gr.Blocks() as demo:
138
- gr.Markdown("## 🧪 Extrator Avançado com OCR - Versão Corrigida")
139
  pdf_file = gr.File(label="📄 PDF de exames", file_types=[".pdf"])
140
  btn = gr.Button("🔍 Extrair Exames")
141
- out_txt = gr.Textbox(label="📋 Exames Classificados", lines=10)
142
  dl = gr.File(label="📥 CSV")
143
  btn.click(extrair_exames_formatado, inputs=pdf_file, outputs=[out_txt, dl])
144
 
 
12
  "HB": (12, 17), "HT": (36, 50), "LEUCO": (4, 11), "PLT": (150, 450),
13
  "K+": (3.5, 5.5), "NA+": (135, 145), "UREIA": (10, 50), "CR": (0.6, 1.3),
14
  "TGO": (0, 40), "TGP": (0, 40), "ALB": (3.5, 5.0), "INR": (0.8, 1.2),
15
+ "TAP": (10, 14), "TTP": (25, 35)
16
  }
17
 
18
  def classificar(nome, valor):
19
  """
20
+ Retorna valor com setas se fora da faixa.
21
  """
22
  try:
23
  raw = valor.replace("K", "").replace(">", "").replace("<", "").strip()
 
95
  "TAP": r"tempo de protrombina.*?\bresultado\b\s*([\d]+,[\d]+)",
96
  "INR": r"I\s*N\s*R\s+([\d]+,[\d]+)",
97
  "TTP": r"ttpa.*?([\d.,]+)\s?seg",
98
+ "DIMERO D":r"d[ií]mero d.*?resultado\s*([\d.,]+)\s?ng/ml",
99
  "LAC": r"lactato.*?([\d.,]+)\s?mmol/l",
100
  "CKMB": r"ck[- ]?mb.*?([\d.,]+)\s?u/l",
101
  "CPK": r"cpk.*?\bresultado\b\s*([\d.,]+)",
 
109
  "CAI","CA TOTAL","CL-","CR","UREIA",
110
  "FAL","FÓS","GGT","GLI","LIP","MG++",
111
  "PCR","K+","NA+","PTN","ALB","GLOB","RELAÇÃO",
112
+ "TGO","TGP","TAP","INR","TTP","DIMERO D","LAC",
113
+ "CKMB","CPK","TROPO"
114
  ]
115
 
116
  # Função principal de extração e formatação
 
137
 
138
  # Interface Gradio
139
  with gr.Blocks() as demo:
140
+ gr.Markdown("## 🧪 Extrator Avançado com OCR - Versão Corrigida com D-Dímero")
141
  pdf_file = gr.File(label="📄 PDF de exames", file_types=[".pdf"])
142
  btn = gr.Button("🔍 Extrair Exames")
143
+ out_txt = gr.Textbox(label="📋 Exames Classificados", lines=12)
144
  dl = gr.File(label="📥 CSV")
145
  btn.click(extrair_exames_formatado, inputs=pdf_file, outputs=[out_txt, dl])
146