lookup_hl7_table
Retrieve HL7 table values and descriptions for healthcare data integration, such as administrative sex codes, to support interoperability workflows.
Instructions
Look up HL7 table values. Returns the table name and all defined values with descriptions. Example: Table 0001 = Administrative Sex.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| table_number | Yes | HL7 table number (e.g., '0001', '0004', '76'). Leading zeros optional. |
Implementation Reference
- The implementation of lookup_hl7_table, which takes a table_number, normalizes it, and returns the corresponding HL7 table information.
def lookup_hl7_table(table_number: str) -> str: """Look up HL7 table values. Args: table_number: Table number (e.g., "0001", "0004", "76"). Leading zeros are optional. Returns: Table name and all defined values with descriptions. """ # Normalize table number to 4-digit zero-padded string table_number = table_number.strip().lstrip("0") or "0" table_key = table_number.zfill(4) table_info = HL7_TABLES.get(table_key) if not table_info: # Try without padding for key in HL7_TABLES: if key.lstrip("0") == table_number.lstrip("0"): table_info = HL7_TABLES[key] table_key = key break if not table_info: available = sorted(HL7_TABLES.keys()) return ( f"Table {table_key} not found in dictionary.\n\n" f"Available tables: {', '.join(available)}" ) parts = [ f"## HL7 Table {table_key} — {table_info['name']}", "", f"{'Value':<10} {'Description'}", f"{'-----':<10} {'-----------'}", ]