UNPKG

@medplum/definitions

Version:

Medplum Data Definitions

3 lines (2 loc) 1.51 kB
import{readFileSync as u}from"fs";import{existsSync as c}from"node:fs";import{readFile as m}from"node:fs/promises";import{dirname as l,resolve as o}from"node:path";import{fileURLToPath as d}from"node:url";var p=Object.freeze([]);function h(e){let r=o(f(),e);return JSON.parse(u(r,"utf8"))}async function D(e){let r=o(f(),e),t=await m(r,"utf8");return JSON.parse(t)}var a;function f(){if(a)return a;let e=y(),r=["./","../","./cjs/","./esm/"];for(let t of r){let n=o(e,t),s=o(n,"fhir");if(c(s))return a=n,n}throw new Error("No data directory found")}function y(){if(typeof __dirname<"u")return o(__dirname);if(import.meta.url)return o(l(d(import.meta.url)));throw new Error("No data directory found")}var R=["fhir/r4/search-parameters.json","fhir/r4/search-parameters-medplum.json","fhir/r4/search-parameters-uscore.json"],N=["fhir/r4/profiles-types.json","fhir/r4/profiles-resources.json","fhir/r4/profiles-medplum.json","fhir/r4/profiles-others.json"],P=["fhir/r4/v2-tables.json","fhir/r4/v3-codesystems.json","fhir/r4/valuesets.json","fhir/r4/valuesets-medplum.json","fhir/r4/valuesets-medplum-generated.json"];function x(e,r,t){let n=h(e);for(let s of n.entry??p){let i=s.resource;if(i?.resourceType===r&&i.url===t)return i}throw new Error(`Missing definition resource: ${r}?url=${t}`)}export{R as SEARCH_PARAMETER_BUNDLE_FILES,N as STRUCTURE_DEFINITION_BUNDLE_FILES,P as TERMINOLOGY_BUNDLE_FILES,f as getDataDir,x as getDefinitionResource,h as readJson,D as readJsonAsync}; //# sourceMappingURL=index.mjs.map