searchOrganizations
Search for healthcare organizations by name or address using structured criteria. Designed for Medplum MCP Server to manage FHIR data efficiently through targeted queries.
Instructions
Searches for organizations based on criteria like name or address. Provide at least one criterion.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| address | No | Part of the organization's address to search for. Optional. | |
| name | No | The name of the organization to search for. Optional. |
Implementation Reference
- src/tools/organizationUtils.ts:184-223 (handler)The handler function that builds FHIR search query parameters from input arguments and executes the search using Medplum client.export async function searchOrganizations(searchArgs: OrganizationSearchArgs): Promise<Organization[]> { await ensureAuthenticated(); const searchCriteria: string[] = []; if (searchArgs.name) { searchCriteria.push(`name=${encodeURIComponent(searchArgs.name)}`); } if (searchArgs.identifier) { searchCriteria.push(`identifier=${encodeURIComponent(searchArgs.identifier)}`); } if (searchArgs.type) { searchCriteria.push(`type=${encodeURIComponent(searchArgs.type)}`); } if (searchArgs.active !== undefined) { searchCriteria.push(`active=${searchArgs.active}`); } if (searchArgs.address) { searchCriteria.push(`address=${encodeURIComponent(searchArgs.address)}`); } if (searchArgs.city) { searchCriteria.push(`address-city=${encodeURIComponent(searchArgs.city)}`); } if (searchArgs.state) { searchCriteria.push(`address-state=${encodeURIComponent(searchArgs.state)}`); } if (searchArgs.postalCode) { searchCriteria.push(`address-postalcode=${encodeURIComponent(searchArgs.postalCode)}`); } if (searchArgs.country) { searchCriteria.push(`address-country=${encodeURIComponent(searchArgs.country)}`); } if (searchCriteria.length === 0) { return []; } const queryString = searchCriteria.join('&'); return medplum.searchResources("Organization", queryString); }
- src/index.ts:351-368 (schema)MCP tool schema defining the input parameters for the searchOrganizations tool.{ name: "searchOrganizations", description: "Searches for organizations based on criteria like name or address. Provide at least one criterion.", inputSchema: { type: "object", properties: { name: { type: "string", description: "The name of the organization to search for. Optional.", }, address: { type: "string", description: "Part of the organization's address to search for. Optional.", }, }, required: [], }, },
- src/index.ts:963-963 (registration)Registration of the searchOrganizations handler function in the toolMapping object used by the MCP server.searchOrganizations,
- src/index.ts:21-25 (registration)Import of the searchOrganizations function into the main server file.createOrganization, getOrganizationById, updateOrganization, searchOrganizations, } from './tools/organizationUtils.js';
- src/tools/toolSchemas.ts:159-169 (schema)TypeScript schema definition for searchOrganizations tool (potentially legacy or supplementary).{ name: 'searchOrganizations', description: "Searches for organizations based on criteria like name or address. Provide at least one criterion.", input_schema: { type: 'object', properties: { name: { type: 'string', description: "The name of the organization to search for. Optional." }, address: { type: 'string', description: "Part of the organization\'s address to search for. Optional." }, }, required: [], // Function logic ensures at least one is present },