Skip to main content
Glama
ResourcePage.tsx1.35 kB
// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors // SPDX-License-Identifier: Apache-2.0 import { Title } from '@mantine/core'; import { getDisplayString, getReferenceString } from '@medplum/core'; import type { Resource, ResourceType } from '@medplum/fhirtypes'; import { Document, ResourceTable, useMedplum } from '@medplum/react'; import { useEffect, useState } from 'react'; import type { JSX } from 'react'; import { useParams } from 'react-router'; /** * This is an example of a generic "Resource Display" page. * It uses the Medplum `<ResourceTable>` component to display a resource. * * @returns The generic resource display page */ export function ResourcePage(): JSX.Element | null { const medplum = useMedplum(); const { resourceType, id } = useParams(); const [resource, setResource] = useState<Resource | undefined>(undefined); useEffect(() => { if (resourceType && id) { medplum .readResource(resourceType as ResourceType, id) .then(setResource) .catch(console.error); } }, [medplum, resourceType, id]); if (!resource) { return null; } return ( <Document key={getReferenceString(resource)}> <Title>{getDisplayString(resource)}</Title> <ResourceTable key={`${resourceType}/${id}`} value={resource} /> </Document> ); }

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