Skip to main content
Glama
IdentifierInput.tsx2.18 kB
// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors // SPDX-License-Identifier: Apache-2.0 import { Group, TextInput } from '@mantine/core'; import type { Identifier } from '@medplum/fhirtypes'; import type { JSX } from 'react'; import { useContext, useMemo, useState } from 'react'; import { ElementsContext } from '../ElementsInput/ElementsInput.utils'; import type { ComplexTypeInputProps } from '../ResourcePropertyInput/ResourcePropertyInput.utils'; import { getErrorsForInput } from '../utils/outcomes'; export type IdentifierInputProps = ComplexTypeInputProps<Identifier>; export function IdentifierInput(props: IdentifierInputProps): JSX.Element { const [value, setValue] = useState(props.defaultValue); const { elementsByPath, getExtendedProps } = useContext(ElementsContext); const [systemElement, valueElement] = useMemo( () => ['system', 'value'].map((field) => elementsByPath[props.path + '.' + field]), [elementsByPath, props.path] ); const [systemProps, valueProps] = useMemo( () => ['system', 'value'].map((field) => getExtendedProps(props.path + '.' + field)), [getExtendedProps, props.path] ); function setValueWrapper(newValue: Identifier): void { setValue(newValue); if (props.onChange) { props.onChange(newValue); } } const errorPath: string = props.valuePath ?? props.path; return ( <Group gap="xs" grow wrap="nowrap" align="flex-start"> <TextInput disabled={props.disabled || systemProps?.readonly} placeholder="System" required={(systemElement?.min ?? 0) > 0} defaultValue={value?.system} onChange={(e) => setValueWrapper({ ...value, system: e.currentTarget.value })} error={getErrorsForInput(props.outcome, errorPath + '.system')} /> <TextInput disabled={props.disabled || valueProps?.readonly} placeholder="Value" required={(valueElement?.min ?? 0) > 0} defaultValue={value?.value} onChange={(e) => setValueWrapper({ ...value, value: e.currentTarget.value })} error={getErrorsForInput(props.outcome, errorPath + '.value')} /> </Group> ); }

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