The healthcare industry faces an efficiency crisis: physicians spend 49% of their time on
administrative documentation, records are fragmented and inaccessible at the point of care,
and waitlists keep growing as demand outpaces capacity.
LLMs are changing this. They don't replace the physician — they remove the administrative
burden so the physician can focus on the patient.
Problem: An internist reviews 20-30 patients/day. Each chart can
run 50-200 pages. That takes 10-20 minutes per patient.
Solution: A RAG pipeline that indexes the chart and generates an executive
summary with: active diagnoses, current medications, allergies, latest labs, and alerts.
Result: Reduced from 15 minutes to 3 minutes per patient.
The physician has more relevant clinical context, not less.
Privacy: The system must run on-premise (Llama 3.1) or in a private cloud.
Patient data must never be sent to third-party APIs without confidentiality agreements.
Problem: Physicians spend 2-3 hours a day documenting visits. This
burden causes burnout and reduces time with patients.
Solution: The physician records the visit (with consent). The system:
A chatbot on WhatsApp or the hospital's app lets patients:
# RAG for medical chart summarization
from langchain_community.document_loaders import PyPDFLoader
from langchain.text_splitter import RecursiveCharacterTextSplitter
from langchain_community.vectorstores import PGVector
from langchain_anthropic import ChatAnthropic
from langchain_core.prompts import ChatPromptTemplate
SYSTEM = '''You are a medical assistant. Analyze charts and generate summaries.
ONLY use information from the chart. Do NOT make new diagnoses.
Flag anything that requires urgent attention.'''
def summarize_chart(pdf_path: str) -> str:
# Load the chart
docs = PyPDFLoader(pdf_path).load()
chunks = RecursiveCharacterTextSplitter(
chunk_size=800, chunk_overlap=100
).split_documents(docs)
# Index (local model for privacy)
vectorstore = PGVector.from_documents(
chunks,
embedding=LocalEmbeddings(),
connection_string="postgresql://localhost/hospital_db"
)
# Retrieve relevant context
retriever = vectorstore.as_retriever(search_kwargs={"k": 8})
context = "\n\n".join(
[doc.page_content for doc in retriever.invoke("diagnosis medications allergies labs")]
)
# Generate summary
llm = ChatAnthropic(model="claude-sonnet-4-6")
prompt = ChatPromptTemplate.from_messages([
("system", SYSTEM),
("human", "Chart:\n{context}\n\nGenerate: 1) Active diagnoses 2) Medications 3) Allergies 4) Latest labs 5) Alerts")
])
return llm.invoke(prompt.format_messages(context=context)).contentCarlos Montiel is an enterprise AI solutions architect with experience in LLMs, Agents, RAG, and orchestration in Guatemala and Latin America.
Contact Carlos Montiel