Skip to main content
Glama
baseschema.ts1.99 kB
// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors // SPDX-License-Identifier: Apache-2.0 import type { BaseSchema, InternalTypeSchema } from '@medplum/core'; import { compressElement, getAllDataTypes, indexStructureDefinitionBundle, isLowerCase } from '@medplum/core'; import { readJson } from '@medplum/definitions'; import type { Bundle } from '@medplum/fhirtypes'; import { writeFileSync } from 'fs'; import { resolve } from 'path'; export function main(): void { indexStructureDefinitionBundle(readJson('fhir/r4/profiles-types.json') as Bundle); indexStructureDefinitionBundle(readJson('fhir/r4/profiles-resources.json') as Bundle); indexStructureDefinitionBundle(readJson('fhir/r4/profiles-medplum.json') as Bundle); const allTypes = getAllDataTypes(); const outputTypes: BaseSchema = Object.create(null); // For each type schema, only keep "display" and "properties" for (const [typeName, typeSchema] of Object.entries(allTypes).filter(([name, schema]) => isBaseType(name, schema))) { addOutputType(outputTypes, typeName, typeSchema); } writeFileSync( resolve(import.meta.dirname, '../../core/src/base-schema.json'), JSON.stringify(outputTypes, undefined, 2), 'utf8' ); } function isBaseType(name: string, schema: InternalTypeSchema): boolean { return !isLowerCase(name.charAt(0)) && schema.kind !== 'resource' && schema.kind !== 'logical' && !schema.parentType; } function addOutputType(outputTypes: BaseSchema, typeName: string, typeSchema: InternalTypeSchema): void { const output = { elements: Object.create(null) }; for (const [propertyName, propertySchema] of Object.entries(typeSchema.elements)) { output.elements[propertyName] = compressElement(propertySchema); } outputTypes[typeName] = output; if (typeSchema.innerTypes) { for (const innerType of typeSchema.innerTypes) { addOutputType(outputTypes, innerType.name, innerType); } } } if (import.meta.main) { main(); }

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