Zira
11/13/2025, 5:13 PMisResourceType(resourceType) from the core package seems to be broken.
Its documentation gives this as an example: isResourceType('Patient'). However, running that in my Foo Medical-based app returns undefined.
Digging into it, it appears to depend on the core/src/base-schema.json file, which doesn't seem to include a "Patient" entry.
Am I using this function wrong?Ian Plunkett
11/18/2025, 6:32 PMIan Plunkett
11/18/2025, 6:32 PM{
"resourceType": "Patient",
"name": [
{
"family": "Test",
"given": [
"Patient"
]
}
],
"id": "d462f407-48c4-4f33-876a-b549b683fc21",
"meta": {
"versionId": "e6456ff9-7808-4498-8b73-3dd44542f152",
"lastUpdated": "2025-11-18T18:26:07.563Z",
"author": {
"reference": "Practitioner/0194702a-c167-740d-8e95-f7c9338de5c5",
"display": "Ian Plunkett"
},
"project": "0194702a-c12f-77bb-9109-7510aff58757",
"compartment": [
{
"reference": "Project/0194702a-c12f-77bb-9109-7510aff58757"
},
{
"reference": "Patient/d462f407-48c4-4f33-876a-b549b683fc21"
}
]
}
}Zira
11/18/2025, 9:13 PMisResource() method which accepts an unknown value.
The isResourceType() function I'm talking about is in packages/core/src/typeschema/types.ts. It accepts a string called "resourceType"Ian Plunkett
11/19/2025, 12:07 AMisResourceType function requires the FHIR schema to be loaded first, but it's not automatically initialized when you import @medplum/core.Ian Plunkett
11/19/2025, 12:07 AMconst medplumCore = require('@medplum/core');
const fhirDefinitions = require('@medplum/definitions');
// Load the FHIR structure definitions
const structureDefs = fhirDefinitions.readJson('fhir/r4/profiles-resources.json');
// Index the schema
medplumCore.indexStructureDefinitionBundle(structureDefs);
// Now you can use isResourceType
const { isResourceType } = medplumCore;
console.log(isResourceType('Patient')); // true
console.log(isResourceType('Invalid')); // falseIan Plunkett
11/19/2025, 12:08 AM