Skip to main content
Glama
useAvailableTables.ts1.16 kB
// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors // SPDX-License-Identifier: Apache-2.0 import type { MedplumClient } from '@medplum/core'; import { useEffect } from 'react'; import { getAvailableTables } from './utils'; export interface UseResourceTypesProps { readonly medplum: MedplumClient; readonly onChange: (value: string[]) => void; readonly onError?: (error: unknown) => void; } export const useAvailableTables = ({ medplum, onChange, onError }: UseResourceTypesProps): void => { useEffect(() => { async function loadResourceTypes(): Promise<string[]> { const valueSet = await medplum.valueSetExpand({ url: 'https://medplum.com/fhir/ValueSet/resource-types', count: 200, }); return valueSet.expansion?.contains?.map((c) => c.code).filter((c) => c !== undefined) ?? []; } loadResourceTypes() .then((resourceTypes) => { onChange(getAvailableTables(resourceTypes)); }) .catch((err) => { if (onError) { onError(err); } else { console.error(err); } }); }, [medplum, onChange, onError]); };

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/medplum/medplum'

If you have feedback or need assistance with the MCP directory API, please join our Discord server