cid10_lookup
Retrieve Portuguese description and restriction flags for any CID-10 code. Accepts both dotted and undotted formats.
Instructions
Look up a specific CID-10 code and return its Portuguese name.
Use this tool to:
Resolve a code to its Brazilian description ("I21" → "Infarto agudo do miocárdio")
Confirm a 3-char category or 4-char subcategory exists in CID-10
Retrieve gender / cause-of-death restriction flags when applicable
Accepts both dotted ("A00.1") and undotted ("A001") forms; returns the canonical display.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | CID-10 code (e.g., "A00", "A00.1", "A001", "I21"). Dotted and undotted forms both accepted. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | ||
| found | Yes | ||
| hit | Yes |
Implementation Reference
- src/tools/cid10.ts:166-215 (handler)Main handler function for the cid10_lookup tool. Accepts a code (e.g., 'A00', 'A00.1', 'A001'), parses it with Zod, delegates to the CID10Client.lookup() method, formats the result as human-readable text and structured content, and returns it as a CallToolResult.
async function handleCID10Lookup(args: Record<string, unknown>): Promise<CallToolResult> { try { const params = CID10LookupParamsSchema.parse(args); const client = getCID10Client(); const hit = client.lookup(params.code); const structured: CID10LookupOutput = { code: params.code, found: hit !== null, hit, }; if (!hit) { return { content: [ { type: 'text', text: `# CID-10 ${params.code}\n\nCódigo não encontrado em CID-10 V2008.`, }, ], structuredContent: structured, }; } const lines: string[] = []; lines.push(`# CID-10 ${hit.display} — ${hit.title}`); lines.push(''); lines.push(`**Nível:** ${hit.level === 'category' ? 'categoria (3 caracteres)' : 'subcategoria (4 caracteres)'}`); if (hit.chapter_num !== null) lines.push(`**Capítulo:** ${hit.chapter_num}`); if (hit.group_range) lines.push(`**Grupo:** ${hit.group_range}`); if (hit.classif) lines.push(`**Classificação:** ${hit.classif}`); if (hit.restr_sexo) lines.push(`**Restrição de sexo:** ${hit.restr_sexo}`); if (hit.causa_obito) lines.push(`**Causa de óbito:** ${hit.causa_obito}`); if (hit.refer) { lines.push(''); lines.push(`**Referências:** ${hit.refer}`); } if (hit.excluidos) { lines.push(''); lines.push(`**Exclusões:** ${hit.excluidos}`); } return { content: [{ type: 'text', text: lines.join('\n') }], structuredContent: structured, }; } catch (error) { return handleToolError(error); } } - src/types/index.ts:739-743 (schema)Input parameter schema for cid10_lookup. Defines a single required parameter 'code' validated by CID10CodeSchema (regex: /^[A-Z]\d{2}(\.?\d)?$/i, accepting formats like A00, A001, or A00.1).
export const CID10LookupParamsSchema = z.object({ code: CID10CodeSchema.describe( 'CID-10 code (e.g., "A00", "A00.1", "A001", "I21"). Dotted and undotted forms both accepted.', ), }); - src/types/index.ts:795-800 (schema)Output schema for cid10_lookup. Contains 'code' (the input code), 'found' (boolean), and 'hit' (nullable CID10HitSchema with level, display, title, chapter info, gender/restriction flags, etc.)
export const CID10LookupOutputSchema = z.object({ code: z.string(), found: z.boolean(), // Populated when found=true; null otherwise. hit: CID10HitSchema.nullable(), }); - src/tools/cid10.ts:299-302 (registration)Registration of the cid10_lookup tool via toolRegistry.register(), binding the cid10LookupTool definition and handleCID10Lookup handler.
toolRegistry.register(cid10SearchTool, handleCID10Search); toolRegistry.register(cid10LookupTool, handleCID10Lookup); toolRegistry.register(cid10ChaptersTool, handleCID10Chapters); toolRegistry.register(cid10ChapterTool, handleCID10Chapter); - src/clients/cid10-client.ts:271-287 (helper)CID10Client.lookup() method: the core data access logic. Normalizes the input code (removes dots), searches subcategories first (4-char) then categories (3-char), converts matches to CID10SearchHit format, or returns null if not found.
lookup(input: string): CID10SearchHit | null { const normalized = normalizeCode(input); if (normalized.length === 4) { const sub = subcategories().find((s) => s.code === normalized); if (sub) return subcategoryToHit(sub); return null; } if (normalized.length === 3) { const cat = categories().find((c) => c.code === normalized); if (cat) return categoryToHit(cat); return null; } return null; }