Skip to main content
Glama
AttachmentArrayDisplay.tsx1.68 kB
// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors // SPDX-License-Identifier: Apache-2.0 import type { InternalSchemaElement } from '@medplum/core'; import { getPathDisplayName, isPopulated } from '@medplum/core'; import type { Attachment } from '@medplum/fhirtypes'; import type { JSX } from 'react'; import { AttachmentDisplay } from '../AttachmentDisplay/AttachmentDisplay'; import { DescriptionListEntry } from '../DescriptionList/DescriptionList'; export interface AttachmentArrayDisplayProps { readonly path?: string; readonly values?: Attachment[]; readonly maxWidth?: number; readonly includeDescriptionListEntry?: boolean; readonly property?: InternalSchemaElement; } export function AttachmentArrayDisplay(props: AttachmentArrayDisplayProps): JSX.Element { const attachmentElements = props.values?.map((v, index) => ( <div key={'attatchment-' + index}> <AttachmentDisplay value={v} maxWidth={props.maxWidth} /> </div> )); let content: JSX.Element; if (props.includeDescriptionListEntry) { if (props.property === undefined) { throw new Error('props.property is required when includeDescriptionListEntry is true'); } if (!isPopulated(props.path)) { throw new Error('props.path is required when includeDescriptionListEntry is true'); } // Since arrays are responsible for rendering their own DescriptionListEntry, we must find the key const key = props.path.split('.').pop() as string; content = <DescriptionListEntry term={getPathDisplayName(key)}>{attachmentElements}</DescriptionListEntry>; } else { content = <>{attachmentElements}</>; } return content; }

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