loinc_details
Retrieve full details for a given LOINC code, including name, component, property, timing, system, scale type, and method.
Instructions
Get detailed information about a specific LOINC code.
Use this tool to:
Get the full name and description of a LOINC code
Find the component, property, timing, and system
Check the scale type and method
Provide a LOINC number in format "XXXXX-X" (e.g., "2339-0" for Glucose).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| loinc_num | Yes | LOINC number (e.g., "2339-0") |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| loinc_num | Yes | ||
| long_common_name | Yes | ||
| short_name | Yes | ||
| component | Yes | ||
| property | Yes | ||
| time_aspect | Yes | ||
| system | Yes | ||
| scale_type | Yes | ||
| method_type | Yes | ||
| class | Yes | ||
| status | Yes |
Implementation Reference
- src/tools/loinc.ts:271-296 (handler)handleLOINCDetails - The main handler function that executes the loinc_details tool logic. Parses the input via LOINCByCodeParamsSchema, calls client.getLOINCDetails(), converts the result via loincItemToOutput() and formatLOINCDetails(), and returns a CallToolResult with both text and structured content.
async function handleLOINCDetails(args: Record<string, unknown>): Promise<CallToolResult> { try { const params = LOINCByCodeParamsSchema.parse(args); const client = getNLMClient(); const item = await client.getLOINCDetails(params.loinc_num); if (!item) { return { content: [{ type: 'text', text: `LOINC code "${params.loinc_num}" not found. Please verify the code is correct.`, }], isError: true, }; } const structured: LOINCDetailsOutput = loincItemToOutput(item); return { content: [{ type: 'text', text: formatLOINCDetails(item) }], structuredContent: structured, }; } catch (error) { return handleToolError(error); } } - src/tools/loinc.ts:357-358 (registration)Registration of loincDetailsTool with handleLOINCDetails handler via toolRegistry.register(). This is where the loinc_details tool name becomes available in the server.
toolRegistry.register(loincSearchTool, handleLOINCSearch); toolRegistry.register(loincDetailsTool, handleLOINCDetails); - src/tools/loinc.ts:70-83 (schema)loincDetailsTool definition - Tool object with name 'loinc_details', description, inputSchema (built from LOINCByCodeParamsSchema), outputSchema (built from LOINCDetailsOutputSchema), and read-only annotations.
const loincDetailsTool: Tool = { name: 'loinc_details', description: `Get detailed information about a specific LOINC code. Use this tool to: - Get the full name and description of a LOINC code - Find the component, property, timing, and system - Check the scale type and method Provide a LOINC number in format "XXXXX-X" (e.g., "2339-0" for Glucose).`, inputSchema: buildInputSchema(LOINCByCodeParamsSchema), outputSchema: buildOutputSchema(LOINCDetailsOutputSchema), annotations: READ_ONLY_TOOL_ANNOTATIONS, }; - src/tools/loinc.ts:35-49 (helper)loincItemToOutput - Helper function that transforms a LOINCItem from the NLM API into the structured LOINCDetailsOutput format.
function loincItemToOutput(item: LOINCItem): LOINCDetailsOutput { return { loinc_num: item.LOINC_NUM, long_common_name: item.LONG_COMMON_NAME, short_name: item.SHORTNAME ?? '', component: item.COMPONENT ?? '', property: item.PROPERTY ?? '', time_aspect: item.TIME_ASPCT ?? '', system: item.SYSTEM ?? '', scale_type: item.SCALE_TYP ?? '', method_type: item.METHOD_TYP ?? '', class: item.CLASS ?? '', status: item.STATUS ?? '', }; } - src/tools/loinc.ts:144-169 (helper)formatLOINCDetails - Helper function that formats a LOINCItem into a human-readable Markdown table string for the text content response.
function formatLOINCDetails(item: LOINCItem): string { const lines: string[] = []; lines.push(`# ${item.LOINC_NUM} - ${item.LONG_COMMON_NAME}`); lines.push(''); if (item.SHORTNAME) { lines.push(`**Short Name:** ${item.SHORTNAME}`); } lines.push(''); lines.push('## Attributes'); lines.push(''); lines.push(`| Attribute | Value |`); lines.push(`|-----------|-------|`); lines.push(`| Component | ${item.COMPONENT || 'N/A'} |`); lines.push(`| Property | ${item.PROPERTY || 'N/A'} |`); lines.push(`| Timing | ${item.TIME_ASPCT || 'N/A'} |`); lines.push(`| System | ${item.SYSTEM || 'N/A'} |`); lines.push(`| Scale Type | ${item.SCALE_TYP || 'N/A'} |`); lines.push(`| Method | ${item.METHOD_TYP || 'N/A'} |`); lines.push(`| Class | ${item.CLASS || 'N/A'} |`); lines.push(`| Status | ${item.STATUS || 'Active'} |`); return lines.join('\n'); }