Work with OMOP medical concepts in the OMOPHub Node.js SDK - retrieve, search, and inspect concept details, synonyms, and relationships from TypeScript.
The SDK validates conceptIds.length is between 1 and 100 and returns a validation_error synthetically (no network call) if outside that range.
Autocomplete Suggestions
Get concept suggestions for autocomplete UI:
const { data, error, meta } = await client.concepts.suggest('diab', { pageSize: 10,});if (error) throw new Error(error.message);// Suggestions are an array - pagination on outer `meta`for (const concept of Array.isArray(data) ? data : data?.data ?? []) { console.log(concept.concept_name);}console.log(meta?.pagination?.total_items);console.log(meta?.pagination?.has_next);
client.concepts.suggest() returns data as either ConceptSuggestion[] (bare array) or { data: ConceptSuggestion[] } (envelope), depending on the API version answering the request. Both shapes are valid per the SDK type (ConceptSuggestion[] | PaginatedData<ConceptSuggestion>); the Array.isArray(data) ? data : data?.data ?? [] pattern above handles both. Pagination always lives on the outer meta.pagination, never on the inner shape.
Get relationships for a concept. Both client.concepts.relationships(...) and client.relationships.get(...) hit the same wire endpoint - pick whichever reads more naturally at the call site:
const { data, error, meta } = await client.relationships.get(201826);if (error) throw new Error(error.message);for (const rel of data.relationships) { console.log(`${rel.relationship_id}: ${rel.target_concept_name}`);}console.log(`Page ${meta?.pagination?.page} of ${meta?.pagination?.total_pages}`);
Filter by relationship type, vocabulary, and direction: