npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@precisa-saude/fhir-ocr-utils

v0.5.1

Published

Utilitários de ancoragem OCR para extração de biomarcadores de PDFs de resultados laboratoriais

Readme

@precisa-saude/fhir-ocr-utils

Utilitários de ancoragem OCR para extração de biomarcadores de PDFs de resultados laboratoriais.

Instalação

npm install @precisa-saude/fhir-ocr-utils

Nota: Requer @precisa-saude/fhir como peer dependency.

Uso rápido

Encontrar biomarcadores em texto OCR

import { findBiomarkersInText, getMatchedCodes } from '@precisa-saude/fhir-ocr-utils';

const ocrText = `
  HEMOGRAMA COMPLETO
  Hemoglobina: 14.2 g/dL
  Glicose Jejum: 95 mg/dL
  Colesterol Total: 195 mg/dL
  HDL: 55 mg/dL
  Triglicerídeos: 120 mg/dL
`;

const result = findBiomarkersInText(ocrText);

console.log(result.matches);
// [
//   { code: 'Hgb', loinc: '718-7', matchedName: 'Hemoglobina', ... },
//   { code: 'Glucose', loinc: '2345-7', matchedName: 'Glicose', ... },
//   { code: 'Cholesterol', loinc: '2093-3', matchedName: 'Colesterol Total', ... },
//   ...
// ]

const codes = getMatchedCodes(result);
// ['Hgb', 'Glucose', 'Cholesterol', 'HDL', 'Triglycerides']

console.log(result.filteredReference);
// Referência LLM filtrada apenas com os biomarcadores encontrados

Padrão anti-alucinação

Este pacote implementa um padrão de ancoragem antes do LLM para prevenir alucinações na extração de dados laboratoriais:

  1. Ancoragem (este pacote): Escaneia o texto OCR bruto procurando nomes de biomarcadores conhecidos usando correspondência exata de strings contra as 200+ definições de @precisa-saude/fhir.

  2. Filtragem: Gera uma referência LLM filtrada (filteredReference) contendo apenas os biomarcadores que foram realmente encontrados no texto. O LLM só pode extrair valores para biomarcadores presentes nesta lista.

  3. Extração (LLM): O modelo de linguagem recebe o texto OCR junto com a referência filtrada, restringindo sua saída apenas aos biomarcadores ancorados.

Este fluxo em dois estágios garante que o LLM não invente biomarcadores que não estão presentes no documento original.

PDF → OCR → findBiomarkersInText() → filteredReference → LLM → valores extraídos
                    |                                                      |
                    +── restringe quais biomarcadores ─────────────────────+
                        o LLM pode extrair

API

findBiomarkersInText(ocrText: string): AnchorResult

Escaneia texto OCR e retorna todos os biomarcadores encontrados.

  • result.matches — Lista de biomarcadores encontrados com código, LOINC, nome e posição
  • result.filteredReference — Referência formatada para enviar ao LLM
  • result.stats — Estatísticas de execução (total de padrões, encontrados, tempo)

getMatchedCodes(result: AnchorResult): string[]

Extrai a lista de códigos de biomarcadores de um resultado de ancoragem.

Aviso médico

Este pacote fornece utilitários de processamento de texto para extração de dados laboratoriais. Não substitui orientação médica profissional. Consulte o DISCLAIMER.md na raiz do repositório para detalhes completos.

Licença

Apache-2.0