get_loinc_codes
Find clinically relevant LOINC codes for an observation by name, returning only active codes sorted by popularity to support FHIR data interoperability.
Instructions
Get the most relevant LOINC codes for a given observation name.
The function automatically:
Filters for STATUS="ACTIVE" codes only
Sorts by COMMON_TEST_RANK (lower rank = more commonly used)
Returns codes in popularity order (most common first)
Your job is to:
Analyze returned codes for semantic relevance to the search query
Balance clinical popularity with semantic matching
Select codes that best match the intended observation
Strategy:
Start with default parameters (max_codes=5, max_fetch=50)
Check if result contains "Error" key in first element
If "Authentication failed" or "Authorization" error:
STOP using this tool immediately.
Do not retry with different parameters.
Report the authentication error to the user.
Suggest they check their LOINC API credentials.
Ask the user if they want to use your knowledge to find a LOINC code and wait for the confirmation. Add warning that this may cause wrong results.
If "No active LOINC codes found in current fetch":
Increase max_fetch progressively (50→100→200→RecordsFound).
Keep trying until max_fetch >= RecordsFound or you find active codes.
If "No LOINC codes found": Try alternative search terms or report failure.
If you get codes but they don't semantically match your query:
Increase max_codes to see more options.
Look for better matches in COMPONENT, SHORTNAME, LONG_COMMON_NAME fields.
Rules:
Function returns codes sorted by popularity - YOU decide which are most relevant.
Don't automatically pick the first (most common) codes.
Prioritize semantic relevance: exact matches in COMPONENT > SHORTNAME > partial matches.
Balance popularity with relevance (very rare codes might not be clinically useful).
Keep increasing max_fetch until you exhaust all available records (max_fetch >= RecordsFound).
Increase max_codes only when you need more options to find better semantic matches.
Args: component_name: The name of the observation to get the LOINC code for (i.e. "glucose"). max_codes: The maximum number of LOINC codes to return. max_fetch: The maximum number of LOINC codes to fetch from the API. Returns: LOINC codes sorted by popularity - you must select the most semantically relevant ones.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| max_codes | No | ||
| max_fetch | No | ||
| component_name | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |