Objective
A clinical decision-support answer is only safe if it is grounded in a citable source. This recipe does the retrieval half: given a clinical question, find the most relevant guideline or chart passage by meaning, so the answer (and its citation) trace to a real record rather than to the model's priors. Everything runs self-hosted — the embeddings compute where the PHI already lives.
Step 1: A small guideline corpus with embeddings
DROP TABLE IF EXISTS clinical_kb;
CREATE TABLE clinical_kb (
doc_id TEXT PRIMARY KEY,
source TEXT,
passage TEXT,
emb VECTOR(384)
);
INSERT INTO clinical_kb VALUES
('G-114','Sepsis bundle',
'For suspected sepsis, obtain blood cultures before antibiotics and start broad-spectrum antibiotics within one hour of recognition.',
EMBED('For suspected sepsis, obtain blood cultures before antibiotics and start broad-spectrum antibiotics within one hour of recognition.')),
('G-233','VTE prophylaxis',
'Assess VTE risk on admission; offer pharmacologic prophylaxis to high-risk medical inpatients without contraindication.',
EMBED('Assess VTE risk on admission; offer pharmacologic prophylaxis to high-risk medical inpatients without contraindication.'));