Skip to main content
Glama
ResourcePropertyDisplay.utils.ts2.26 kB
// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors // SPDX-License-Identifier: Apache-2.0 import type { InternalSchemaElement, TypedValue } from '@medplum/core'; import { getTypedPropertyValue, getTypedPropertyValueWithSchema } from '@medplum/core'; /** * Returns the value of the property and the property type. * Some property definitions support multiple types. * For example, "Observation.value[x]" can be "valueString", "valueInteger", "valueQuantity", etc. * According to the spec, there can only be one property for a given element definition. * This function returns the value and the type. * @param context - The base context (usually a FHIR resource). * @param path - The property path. * @param profileUrl - The property path. * @returns The value of the property and the property type. */ export function getValueAndType(context: TypedValue, path: string, profileUrl?: string): [any, string] { const typedResult = getTypedPropertyValue(context, path, { profileUrl }); if (!typedResult) { return [undefined, 'undefined']; } if (Array.isArray(typedResult)) { return [typedResult.map((e) => e.value), typedResult[0].type]; } return [typedResult.value, typedResult.type]; } /** * Returns the value of the property and the property type. * Some property definitions support multiple types. * For example, "Observation.value[x]" can be "valueString", "valueInteger", "valueQuantity", etc. * According to the spec, there can only be one property for a given element definition. * This function returns the value and the type. * @param typedValue - The base context (usually a FHIR resource). * @param path - The property path. * @param element - The property element definition. * @returns The value of the property and the property type. */ export function getValueAndTypeFromElement( typedValue: TypedValue, path: string, element: InternalSchemaElement ): [any, string] { const typedResult = getTypedPropertyValueWithSchema(typedValue, path, element); if (!typedResult) { return [undefined, 'undefined']; } if (Array.isArray(typedResult)) { return [typedResult.map((e) => e.value), typedResult[0].type]; } return [typedResult.value, typedResult.type]; }

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