@medplum/core 0.9.23 → 0.9.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +12 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/index.min.js +1 -1
- package/dist/cjs/index.min.js.map +1 -1
- package/dist/esm/base-schema.json.js +4872 -0
- package/dist/esm/base-schema.json.js.map +1 -0
- package/dist/{types → esm}/cache.d.ts +0 -0
- package/dist/esm/cache.js +70 -0
- package/dist/esm/cache.js.map +1 -0
- package/dist/{types → esm}/client.d.ts +0 -0
- package/dist/esm/client.js +1450 -0
- package/dist/esm/client.js.map +1 -0
- package/dist/{types → esm}/crypto.d.ts +0 -0
- package/dist/esm/crypto.js +23 -0
- package/dist/esm/crypto.js.map +1 -0
- package/dist/{types → esm}/eventtarget.d.ts +0 -0
- package/dist/esm/eventtarget.js +41 -0
- package/dist/esm/eventtarget.js.map +1 -0
- package/dist/{types → esm}/fhirpath/atoms.d.ts +0 -0
- package/dist/esm/fhirpath/atoms.js +329 -0
- package/dist/esm/fhirpath/atoms.js.map +1 -0
- package/dist/{types → esm}/fhirpath/date.d.ts +0 -0
- package/dist/esm/fhirpath/date.js +24 -0
- package/dist/esm/fhirpath/date.js.map +1 -0
- package/dist/{types → esm}/fhirpath/functions.d.ts +0 -0
- package/dist/esm/fhirpath/functions.js +1503 -0
- package/dist/esm/fhirpath/functions.js.map +1 -0
- package/dist/{types → esm}/fhirpath/index.d.ts +0 -0
- package/dist/{types → esm}/fhirpath/parse.d.ts +0 -0
- package/dist/esm/fhirpath/parse.js +258 -0
- package/dist/esm/fhirpath/parse.js.map +1 -0
- package/dist/{types → esm}/fhirpath/tokenize.d.ts +0 -0
- package/dist/esm/fhirpath/tokenize.js +185 -0
- package/dist/esm/fhirpath/tokenize.js.map +1 -0
- package/dist/{types → esm}/fhirpath/utils.d.ts +0 -0
- package/dist/esm/fhirpath/utils.js +372 -0
- package/dist/esm/fhirpath/utils.js.map +1 -0
- package/dist/{types → esm}/format.d.ts +0 -0
- package/dist/esm/format.js +51 -0
- package/dist/esm/format.js.map +1 -0
- package/dist/{types → esm}/hl7.d.ts +0 -0
- package/dist/esm/hl7.js +111 -0
- package/dist/esm/hl7.js.map +1 -0
- package/dist/{types → esm}/index.d.ts +0 -0
- package/dist/esm/index.js +15 -10752
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.min.js +1 -1
- package/dist/esm/index.min.js.map +1 -1
- package/dist/{types → esm}/jwt.d.ts +0 -0
- package/dist/esm/jwt.js +35 -0
- package/dist/esm/jwt.js.map +1 -0
- package/dist/esm/node_modules/tslib/tslib.es6.js +40 -0
- package/dist/esm/node_modules/tslib/tslib.es6.js.map +1 -0
- package/dist/{types → esm}/outcomes.d.ts +0 -0
- package/dist/esm/outcomes.js +151 -0
- package/dist/esm/outcomes.js.map +1 -0
- package/dist/{types → esm}/readablepromise.d.ts +0 -0
- package/dist/esm/readablepromise.js +87 -0
- package/dist/esm/readablepromise.js.map +1 -0
- package/dist/{types → esm}/search.d.ts +0 -0
- package/dist/esm/search.js +207 -0
- package/dist/esm/search.js.map +1 -0
- package/dist/{types → esm}/searchparams.d.ts +0 -0
- package/dist/esm/searchparams.js +145 -0
- package/dist/esm/searchparams.js.map +1 -0
- package/dist/{types → esm}/storage.d.ts +0 -0
- package/dist/esm/storage.js +94 -0
- package/dist/esm/storage.js.map +1 -0
- package/dist/{types → esm}/types.d.ts +0 -0
- package/dist/esm/types.js +223 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/{types → esm}/utils.d.ts +8 -0
- package/dist/esm/utils.js +590 -0
- package/dist/esm/utils.js.map +1 -0
- package/package.json +5 -5
- package/stats.html +4034 -0
- package/tsconfig.cjs.json +7 -0
- package/tsconfig.esm.json +7 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { PropertyType } from './types.js';
|
|
2
|
+
import { capitalize } from './utils.js';
|
|
3
|
+
|
|
4
|
+
var SearchParameterType;
|
|
5
|
+
(function (SearchParameterType) {
|
|
6
|
+
SearchParameterType["BOOLEAN"] = "BOOLEAN";
|
|
7
|
+
SearchParameterType["NUMBER"] = "NUMBER";
|
|
8
|
+
SearchParameterType["QUANTITY"] = "QUANTITY";
|
|
9
|
+
SearchParameterType["TEXT"] = "TEXT";
|
|
10
|
+
SearchParameterType["REFERENCE"] = "REFERENCE";
|
|
11
|
+
SearchParameterType["DATE"] = "DATE";
|
|
12
|
+
SearchParameterType["DATETIME"] = "DATETIME";
|
|
13
|
+
SearchParameterType["PERIOD"] = "PERIOD";
|
|
14
|
+
})(SearchParameterType || (SearchParameterType = {}));
|
|
15
|
+
/**
|
|
16
|
+
* Returns the type details of a SearchParameter.
|
|
17
|
+
*
|
|
18
|
+
* The SearchParameter resource has a "type" parameter, but that is missing some critical information.
|
|
19
|
+
*
|
|
20
|
+
* For example:
|
|
21
|
+
* 1) The "date" type includes "date", "datetime", and "period".
|
|
22
|
+
* 2) The "token" type includes enums and booleans.
|
|
23
|
+
* 3) Arrays/multiple values are not reflected at all.
|
|
24
|
+
*
|
|
25
|
+
* @param structureDefinitions Collection of StructureDefinition resources indexed by name.
|
|
26
|
+
* @param resourceType The root resource type.
|
|
27
|
+
* @param searchParam The search parameter.
|
|
28
|
+
* @returns The search parameter type details.
|
|
29
|
+
*/
|
|
30
|
+
function getSearchParameterDetails(structureDefinitions, resourceType, searchParam) {
|
|
31
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
32
|
+
if (searchParam.code === '_lastUpdated') {
|
|
33
|
+
return { columnName: 'lastUpdated', type: SearchParameterType.DATETIME };
|
|
34
|
+
}
|
|
35
|
+
const columnName = convertCodeToColumnName(searchParam.code);
|
|
36
|
+
const expression = (_a = getExpressionForResourceType(resourceType, searchParam.expression)) === null || _a === void 0 ? void 0 : _a.split('.');
|
|
37
|
+
if (!expression) {
|
|
38
|
+
// This happens on compound types
|
|
39
|
+
// In the future, explore returning multiple column definitions
|
|
40
|
+
return { columnName, type: SearchParameterType.TEXT };
|
|
41
|
+
}
|
|
42
|
+
const defaultType = getSearchParameterType(searchParam);
|
|
43
|
+
let baseType = resourceType;
|
|
44
|
+
let elementDefinition = undefined;
|
|
45
|
+
let propertyType = undefined;
|
|
46
|
+
let array = false;
|
|
47
|
+
for (let i = 1; i < expression.length; i++) {
|
|
48
|
+
const propertyName = expression[i];
|
|
49
|
+
elementDefinition =
|
|
50
|
+
(_d = (_c = (_b = structureDefinitions.types[baseType]) === null || _b === void 0 ? void 0 : _b.properties) === null || _c === void 0 ? void 0 : _c[propertyName]) !== null && _d !== void 0 ? _d : (_f = (_e = structureDefinitions.types[baseType]) === null || _e === void 0 ? void 0 : _e.properties) === null || _f === void 0 ? void 0 : _f[propertyName + '[x]'];
|
|
51
|
+
if (!elementDefinition) {
|
|
52
|
+
throw new Error(`Element definition not found for ${resourceType} ${searchParam.code}`);
|
|
53
|
+
}
|
|
54
|
+
if (elementDefinition.max === '*') {
|
|
55
|
+
array = true;
|
|
56
|
+
}
|
|
57
|
+
propertyType = (_g = elementDefinition.type) === null || _g === void 0 ? void 0 : _g[0].code;
|
|
58
|
+
if (!propertyType) {
|
|
59
|
+
// This happens when one of parent properties uses contentReference
|
|
60
|
+
// In the future, explore following the reference
|
|
61
|
+
return { columnName, type: defaultType, array };
|
|
62
|
+
}
|
|
63
|
+
if (i < expression.length - 1) {
|
|
64
|
+
if (propertyType === 'Element' || propertyType === 'BackboneElement') {
|
|
65
|
+
baseType = baseType + capitalize(propertyName);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
baseType = propertyType;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
const type = getSearchParameterType(searchParam, propertyType);
|
|
73
|
+
return { columnName, type, elementDefinition, array };
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Converts a hyphen-delimited code to camelCase string.
|
|
77
|
+
* @param code The search parameter code.
|
|
78
|
+
* @returns The SQL column name.
|
|
79
|
+
*/
|
|
80
|
+
function convertCodeToColumnName(code) {
|
|
81
|
+
return code.split('-').reduce((result, word, index) => result + (index ? capitalize(word) : word), '');
|
|
82
|
+
}
|
|
83
|
+
function getSearchParameterType(searchParam, propertyType) {
|
|
84
|
+
let type = SearchParameterType.TEXT;
|
|
85
|
+
switch (searchParam.type) {
|
|
86
|
+
case 'date':
|
|
87
|
+
if (propertyType === PropertyType.dateTime || propertyType === PropertyType.instant) {
|
|
88
|
+
type = SearchParameterType.DATETIME;
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
type = SearchParameterType.DATE;
|
|
92
|
+
}
|
|
93
|
+
break;
|
|
94
|
+
case 'number':
|
|
95
|
+
type = SearchParameterType.NUMBER;
|
|
96
|
+
break;
|
|
97
|
+
case 'quantity':
|
|
98
|
+
type = SearchParameterType.QUANTITY;
|
|
99
|
+
break;
|
|
100
|
+
case 'reference':
|
|
101
|
+
type = SearchParameterType.REFERENCE;
|
|
102
|
+
break;
|
|
103
|
+
case 'token':
|
|
104
|
+
if (propertyType === 'boolean') {
|
|
105
|
+
type = SearchParameterType.BOOLEAN;
|
|
106
|
+
}
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
return type;
|
|
110
|
+
}
|
|
111
|
+
function getExpressionForResourceType(resourceType, expression) {
|
|
112
|
+
const expressions = expression.split(' | ');
|
|
113
|
+
for (const e of expressions) {
|
|
114
|
+
if (isIgnoredExpression(e)) {
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
const simplified = simplifyExpression(e);
|
|
118
|
+
if (simplified.startsWith(resourceType + '.')) {
|
|
119
|
+
return simplified;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return undefined;
|
|
123
|
+
}
|
|
124
|
+
function isIgnoredExpression(input) {
|
|
125
|
+
return input.includes(' as Period') || input.includes(' as SampledDate');
|
|
126
|
+
}
|
|
127
|
+
function simplifyExpression(input) {
|
|
128
|
+
let result = input.trim();
|
|
129
|
+
if (result.startsWith('(') && result.endsWith(')')) {
|
|
130
|
+
result = result.substring(1, result.length - 1);
|
|
131
|
+
}
|
|
132
|
+
if (result.includes('[0]')) {
|
|
133
|
+
result = result.replaceAll('[0]', '');
|
|
134
|
+
}
|
|
135
|
+
const stopStrings = [' != ', ' as ', '.as(', '.exists(', '.where('];
|
|
136
|
+
for (const stopString of stopStrings) {
|
|
137
|
+
if (result.includes(stopString)) {
|
|
138
|
+
result = result.substring(0, result.indexOf(stopString));
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return result;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export { SearchParameterType, getExpressionForResourceType, getSearchParameterDetails };
|
|
145
|
+
//# sourceMappingURL=searchparams.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"searchparams.js","sources":["../../src/searchparams.ts"],"sourcesContent":["import { ElementDefinition, SearchParameter } from '@medplum/fhirtypes';\nimport { IndexedStructureDefinition, PropertyType } from './types';\nimport { capitalize } from './utils';\n\nexport enum SearchParameterType {\n BOOLEAN = 'BOOLEAN',\n NUMBER = 'NUMBER',\n QUANTITY = 'QUANTITY',\n TEXT = 'TEXT',\n REFERENCE = 'REFERENCE',\n DATE = 'DATE',\n DATETIME = 'DATETIME',\n PERIOD = 'PERIOD',\n}\n\nexport interface SearchParameterDetails {\n readonly columnName: string;\n readonly type: SearchParameterType;\n readonly elementDefinition?: ElementDefinition;\n readonly array?: boolean;\n}\n\n/**\n * Returns the type details of a SearchParameter.\n *\n * The SearchParameter resource has a \"type\" parameter, but that is missing some critical information.\n *\n * For example:\n * 1) The \"date\" type includes \"date\", \"datetime\", and \"period\".\n * 2) The \"token\" type includes enums and booleans.\n * 3) Arrays/multiple values are not reflected at all.\n *\n * @param structureDefinitions Collection of StructureDefinition resources indexed by name.\n * @param resourceType The root resource type.\n * @param searchParam The search parameter.\n * @returns The search parameter type details.\n */\nexport function getSearchParameterDetails(\n structureDefinitions: IndexedStructureDefinition,\n resourceType: string,\n searchParam: SearchParameter\n): SearchParameterDetails {\n if (searchParam.code === '_lastUpdated') {\n return { columnName: 'lastUpdated', type: SearchParameterType.DATETIME };\n }\n\n const columnName = convertCodeToColumnName(searchParam.code as string);\n const expression = getExpressionForResourceType(resourceType, searchParam.expression as string)?.split('.');\n if (!expression) {\n // This happens on compound types\n // In the future, explore returning multiple column definitions\n return { columnName, type: SearchParameterType.TEXT };\n }\n\n const defaultType = getSearchParameterType(searchParam);\n let baseType = resourceType;\n let elementDefinition = undefined;\n let propertyType = undefined;\n let array = false;\n\n for (let i = 1; i < expression.length; i++) {\n const propertyName = expression[i];\n elementDefinition =\n structureDefinitions.types[baseType]?.properties?.[propertyName] ??\n structureDefinitions.types[baseType]?.properties?.[propertyName + '[x]'];\n if (!elementDefinition) {\n throw new Error(`Element definition not found for ${resourceType} ${searchParam.code}`);\n }\n\n if (elementDefinition.max === '*') {\n array = true;\n }\n\n propertyType = elementDefinition.type?.[0].code;\n if (!propertyType) {\n // This happens when one of parent properties uses contentReference\n // In the future, explore following the reference\n return { columnName, type: defaultType, array };\n }\n\n if (i < expression.length - 1) {\n if (propertyType === 'Element' || propertyType === 'BackboneElement') {\n baseType = baseType + capitalize(propertyName);\n } else {\n baseType = propertyType;\n }\n }\n }\n\n const type = getSearchParameterType(searchParam, propertyType as PropertyType);\n return { columnName, type, elementDefinition, array };\n}\n\n/**\n * Converts a hyphen-delimited code to camelCase string.\n * @param code The search parameter code.\n * @returns The SQL column name.\n */\nfunction convertCodeToColumnName(code: string): string {\n return code.split('-').reduce((result, word, index) => result + (index ? capitalize(word) : word), '');\n}\n\nfunction getSearchParameterType(searchParam: SearchParameter, propertyType?: PropertyType): SearchParameterType {\n let type = SearchParameterType.TEXT;\n switch (searchParam.type) {\n case 'date':\n if (propertyType === PropertyType.dateTime || propertyType === PropertyType.instant) {\n type = SearchParameterType.DATETIME;\n } else {\n type = SearchParameterType.DATE;\n }\n break;\n case 'number':\n type = SearchParameterType.NUMBER;\n break;\n case 'quantity':\n type = SearchParameterType.QUANTITY;\n break;\n case 'reference':\n type = SearchParameterType.REFERENCE;\n break;\n case 'token':\n if (propertyType === 'boolean') {\n type = SearchParameterType.BOOLEAN;\n }\n break;\n }\n return type;\n}\n\nexport function getExpressionForResourceType(resourceType: string, expression: string): string | undefined {\n const expressions = expression.split(' | ');\n for (const e of expressions) {\n if (isIgnoredExpression(e)) {\n continue;\n }\n const simplified = simplifyExpression(e);\n if (simplified.startsWith(resourceType + '.')) {\n return simplified;\n }\n }\n return undefined;\n}\n\nfunction isIgnoredExpression(input: string): boolean {\n return input.includes(' as Period') || input.includes(' as SampledDate');\n}\n\nfunction simplifyExpression(input: string): string {\n let result = input.trim();\n\n if (result.startsWith('(') && result.endsWith(')')) {\n result = result.substring(1, result.length - 1);\n }\n\n if (result.includes('[0]')) {\n result = result.replaceAll('[0]', '');\n }\n\n const stopStrings = [' != ', ' as ', '.as(', '.exists(', '.where('];\n for (const stopString of stopStrings) {\n if (result.includes(stopString)) {\n result = result.substring(0, result.indexOf(stopString));\n }\n }\n\n return result;\n}\n"],"names":[],"mappings":";;;IAIY,oBASX;AATD,CAAA,UAAY,mBAAmB,EAAA;AAC7B,IAAA,mBAAA,CAAA,SAAA,CAAA,GAAA,SAAmB,CAAA;AACnB,IAAA,mBAAA,CAAA,QAAA,CAAA,GAAA,QAAiB,CAAA;AACjB,IAAA,mBAAA,CAAA,UAAA,CAAA,GAAA,UAAqB,CAAA;AACrB,IAAA,mBAAA,CAAA,MAAA,CAAA,GAAA,MAAa,CAAA;AACb,IAAA,mBAAA,CAAA,WAAA,CAAA,GAAA,WAAuB,CAAA;AACvB,IAAA,mBAAA,CAAA,MAAA,CAAA,GAAA,MAAa,CAAA;AACb,IAAA,mBAAA,CAAA,UAAA,CAAA,GAAA,UAAqB,CAAA;AACrB,IAAA,mBAAA,CAAA,QAAA,CAAA,GAAA,QAAiB,CAAA;AACnB,CAAC,EATW,mBAAmB,KAAnB,mBAAmB,GAS9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AAC,CAAC;AACpE,IAAA,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE;AACpC,QAAA,IAAI,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE;AAC/B,YAAA,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC;AAC1D,SAAA;AACF,KAAA;AAED,IAAA,OAAO,MAAM,CAAC;AAChB;;;;"}
|
|
File without changes
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { __classPrivateFieldSet, __classPrivateFieldGet } from './node_modules/tslib/tslib.es6.js';
|
|
2
|
+
import { stringify } from './utils.js';
|
|
3
|
+
|
|
4
|
+
var _ClientStorage_storage, _MemoryStorage_data;
|
|
5
|
+
/**
|
|
6
|
+
* The ClientStorage class is a utility class for storing strings and objects.
|
|
7
|
+
*
|
|
8
|
+
* When using MedplumClient in the browser, it will be backed by browser localStorage.
|
|
9
|
+
*
|
|
10
|
+
* When Using MedplumClient in the server, it will be backed by the MemoryStorage class.
|
|
11
|
+
*/
|
|
12
|
+
class ClientStorage {
|
|
13
|
+
constructor() {
|
|
14
|
+
_ClientStorage_storage.set(this, void 0);
|
|
15
|
+
__classPrivateFieldSet(this, _ClientStorage_storage, typeof localStorage !== 'undefined' ? localStorage : new MemoryStorage(), "f");
|
|
16
|
+
}
|
|
17
|
+
clear() {
|
|
18
|
+
__classPrivateFieldGet(this, _ClientStorage_storage, "f").clear();
|
|
19
|
+
}
|
|
20
|
+
getString(key) {
|
|
21
|
+
return __classPrivateFieldGet(this, _ClientStorage_storage, "f").getItem(key) || undefined;
|
|
22
|
+
}
|
|
23
|
+
setString(key, value) {
|
|
24
|
+
if (value) {
|
|
25
|
+
__classPrivateFieldGet(this, _ClientStorage_storage, "f").setItem(key, value);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
__classPrivateFieldGet(this, _ClientStorage_storage, "f").removeItem(key);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
getObject(key) {
|
|
32
|
+
const str = this.getString(key);
|
|
33
|
+
return str ? JSON.parse(str) : undefined;
|
|
34
|
+
}
|
|
35
|
+
setObject(key, value) {
|
|
36
|
+
this.setString(key, value ? stringify(value) : undefined);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
_ClientStorage_storage = new WeakMap();
|
|
40
|
+
/**
|
|
41
|
+
* The MemoryStorage class is a minimal in-memory implementation of the Storage interface.
|
|
42
|
+
*/
|
|
43
|
+
class MemoryStorage {
|
|
44
|
+
constructor() {
|
|
45
|
+
_MemoryStorage_data.set(this, void 0);
|
|
46
|
+
__classPrivateFieldSet(this, _MemoryStorage_data, new Map(), "f");
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Returns the number of key/value pairs.
|
|
50
|
+
*/
|
|
51
|
+
get length() {
|
|
52
|
+
return __classPrivateFieldGet(this, _MemoryStorage_data, "f").size;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Removes all key/value pairs, if there are any.
|
|
56
|
+
*/
|
|
57
|
+
clear() {
|
|
58
|
+
__classPrivateFieldGet(this, _MemoryStorage_data, "f").clear();
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Returns the current value associated with the given key, or null if the given key does not exist.
|
|
62
|
+
*/
|
|
63
|
+
getItem(key) {
|
|
64
|
+
var _a;
|
|
65
|
+
return (_a = __classPrivateFieldGet(this, _MemoryStorage_data, "f").get(key)) !== null && _a !== void 0 ? _a : null;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Sets the value of the pair identified by key to value, creating a new key/value pair if none existed for key previously.
|
|
69
|
+
*/
|
|
70
|
+
setItem(key, value) {
|
|
71
|
+
if (value) {
|
|
72
|
+
__classPrivateFieldGet(this, _MemoryStorage_data, "f").set(key, value);
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
__classPrivateFieldGet(this, _MemoryStorage_data, "f").delete(key);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Removes the key/value pair with the given key, if a key/value pair with the given key exists.
|
|
80
|
+
*/
|
|
81
|
+
removeItem(key) {
|
|
82
|
+
__classPrivateFieldGet(this, _MemoryStorage_data, "f").delete(key);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Returns the name of the nth key, or null if n is greater than or equal to the number of key/value pairs.
|
|
86
|
+
*/
|
|
87
|
+
key(index) {
|
|
88
|
+
return Array.from(__classPrivateFieldGet(this, _MemoryStorage_data, "f").keys())[index];
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
_MemoryStorage_data = new WeakMap();
|
|
92
|
+
|
|
93
|
+
export { ClientStorage, MemoryStorage };
|
|
94
|
+
//# sourceMappingURL=storage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.js","sources":["../../src/storage.ts"],"sourcesContent":["import { stringify } from './utils';\n\n/**\n * The ClientStorage class is a utility class for storing strings and objects.\n *\n * When using MedplumClient in the browser, it will be backed by browser localStorage.\n *\n * When Using MedplumClient in the server, it will be backed by the MemoryStorage class.\n */\nexport class ClientStorage {\n readonly #storage: Storage;\n\n constructor() {\n this.#storage = typeof localStorage !== 'undefined' ? localStorage : new MemoryStorage();\n }\n\n clear(): void {\n this.#storage.clear();\n }\n\n getString(key: string): string | undefined {\n return this.#storage.getItem(key) || undefined;\n }\n\n setString(key: string, value: string | undefined): void {\n if (value) {\n this.#storage.setItem(key, value);\n } else {\n this.#storage.removeItem(key);\n }\n }\n\n getObject<T>(key: string): T | undefined {\n const str = this.getString(key);\n return str ? (JSON.parse(str) as T) : undefined;\n }\n\n setObject<T>(key: string, value: T): void {\n this.setString(key, value ? stringify(value) : undefined);\n }\n}\n\n/**\n * The MemoryStorage class is a minimal in-memory implementation of the Storage interface.\n */\nexport class MemoryStorage implements Storage {\n #data: Map<string, string>;\n\n constructor() {\n this.#data = new Map<string, string>();\n }\n\n /**\n * Returns the number of key/value pairs.\n */\n get length(): number {\n return this.#data.size;\n }\n\n /**\n * Removes all key/value pairs, if there are any.\n */\n clear(): void {\n this.#data.clear();\n }\n\n /**\n * Returns the current value associated with the given key, or null if the given key does not exist.\n */\n getItem(key: string): string | null {\n return this.#data.get(key) ?? null;\n }\n\n /**\n * Sets the value of the pair identified by key to value, creating a new key/value pair if none existed for key previously.\n */\n setItem(key: string, value: string | null): void {\n if (value) {\n this.#data.set(key, value);\n } else {\n this.#data.delete(key);\n }\n }\n\n /**\n * Removes the key/value pair with the given key, if a key/value pair with the given key exists.\n */\n removeItem(key: string): void {\n this.#data.delete(key);\n }\n\n /**\n * Returns the name of the nth key, or null if n is greater than or equal to the number of key/value pairs.\n */\n key(index: number): string | null {\n return Array.from(this.#data.keys())[index];\n }\n}\n"],"names":[],"mappings":";;;;AAEA;;;;;;AAMG;MACU,aAAa,CAAA;AAGxB,IAAA,WAAA,GAAA;QAFA,sBAA2B,CAAA,GAAA,CAAA,IAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAGzB,QAAA,sBAAA,CAAA,IAAI,EAAY,sBAAA,EAAA,OAAO,YAAY,KAAK,WAAW,GAAG,YAAY,GAAG,IAAI,aAAa,EAAE,MAAA,CAAC;KAC1F;IAED,KAAK,GAAA;AACH,QAAA,sBAAA,CAAA,IAAI,EAAA,sBAAA,EAAA,GAAA,CAAS,CAAC,KAAK,EAAE,CAAC;KACvB;AAED,IAAA,SAAS,CAAC,GAAW,EAAA;QACnB,OAAO,sBAAA,CAAA,IAAI,EAAA,sBAAA,EAAA,GAAA,CAAS,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,SAAS,CAAC;KAChD;IAED,SAAS,CAAC,GAAW,EAAE,KAAyB,EAAA;AAC9C,QAAA,IAAI,KAAK,EAAE;YACT,sBAAA,CAAA,IAAI,8BAAS,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;AACnC,SAAA;AAAM,aAAA;A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ACvC,QAAA,IAAI,KAAK,EAAE;YACT,sBAAA,CAAA,IAAI,2BAAM,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;AAC5B,SAAA;AAAM,aAAA;AACL,YAAA,sBAAA,CAAA,IAAI,EAAM,mBAAA,EAAA,GAAA,CAAA,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AACxB,SAAA;KACF;AAED;;AAEG;AACH,IAAA,UAAU,CAAC,GAAW,EAAA;AACpB,QAAA,sBAAA,CAAA,IAAI,EAAM,mBAAA,EAAA,GAAA,CAAA,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;KACxB;AAED;;AAEG;AACH,IAAA,GAAG,CAAC,KAAa,EAAA;AACf,QAAA,OAAO,KAAK,CAAC,IAAI,CAAC,uBAAA,IAAI,EAAA,mBAAA,EAAA,GAAA,CAAM,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;KAC7C;AACF,CAAA;;;;;"}
|
|
File without changes
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import baseSchema from './base-schema.json.js';
|
|
2
|
+
import { capitalize } from './utils.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* List of property types.
|
|
6
|
+
* http://www.hl7.org/fhir/valueset-defined-types.html
|
|
7
|
+
* The list here includes additions found from StructureDefinition resources.
|
|
8
|
+
*/
|
|
9
|
+
var PropertyType;
|
|
10
|
+
(function (PropertyType) {
|
|
11
|
+
PropertyType["Address"] = "Address";
|
|
12
|
+
PropertyType["Age"] = "Age";
|
|
13
|
+
PropertyType["Annotation"] = "Annotation";
|
|
14
|
+
PropertyType["Attachment"] = "Attachment";
|
|
15
|
+
PropertyType["BackboneElement"] = "BackboneElement";
|
|
16
|
+
PropertyType["CodeableConcept"] = "CodeableConcept";
|
|
17
|
+
PropertyType["Coding"] = "Coding";
|
|
18
|
+
PropertyType["ContactDetail"] = "ContactDetail";
|
|
19
|
+
PropertyType["ContactPoint"] = "ContactPoint";
|
|
20
|
+
PropertyType["Contributor"] = "Contributor";
|
|
21
|
+
PropertyType["Count"] = "Count";
|
|
22
|
+
PropertyType["DataRequirement"] = "DataRequirement";
|
|
23
|
+
PropertyType["Distance"] = "Distance";
|
|
24
|
+
PropertyType["Dosage"] = "Dosage";
|
|
25
|
+
PropertyType["Duration"] = "Duration";
|
|
26
|
+
PropertyType["Expression"] = "Expression";
|
|
27
|
+
PropertyType["Extension"] = "Extension";
|
|
28
|
+
PropertyType["HumanName"] = "HumanName";
|
|
29
|
+
PropertyType["Identifier"] = "Identifier";
|
|
30
|
+
PropertyType["MarketingStatus"] = "MarketingStatus";
|
|
31
|
+
PropertyType["Meta"] = "Meta";
|
|
32
|
+
PropertyType["Money"] = "Money";
|
|
33
|
+
PropertyType["Narrative"] = "Narrative";
|
|
34
|
+
PropertyType["ParameterDefinition"] = "ParameterDefinition";
|
|
35
|
+
PropertyType["Period"] = "Period";
|
|
36
|
+
PropertyType["Population"] = "Population";
|
|
37
|
+
PropertyType["ProdCharacteristic"] = "ProdCharacteristic";
|
|
38
|
+
PropertyType["ProductShelfLife"] = "ProductShelfLife";
|
|
39
|
+
PropertyType["Quantity"] = "Quantity";
|
|
40
|
+
PropertyType["Range"] = "Range";
|
|
41
|
+
PropertyType["Ratio"] = "Ratio";
|
|
42
|
+
PropertyType["Reference"] = "Reference";
|
|
43
|
+
PropertyType["RelatedArtifact"] = "RelatedArtifact";
|
|
44
|
+
PropertyType["SampledData"] = "SampledData";
|
|
45
|
+
PropertyType["Signature"] = "Signature";
|
|
46
|
+
PropertyType["SubstanceAmount"] = "SubstanceAmount";
|
|
47
|
+
PropertyType["SystemString"] = "http://hl7.org/fhirpath/System.String";
|
|
48
|
+
PropertyType["Timing"] = "Timing";
|
|
49
|
+
PropertyType["TriggerDefinition"] = "TriggerDefinition";
|
|
50
|
+
PropertyType["UsageContext"] = "UsageContext";
|
|
51
|
+
PropertyType["base64Binary"] = "base64Binary";
|
|
52
|
+
PropertyType["boolean"] = "boolean";
|
|
53
|
+
PropertyType["canonical"] = "canonical";
|
|
54
|
+
PropertyType["code"] = "code";
|
|
55
|
+
PropertyType["date"] = "date";
|
|
56
|
+
PropertyType["dateTime"] = "dateTime";
|
|
57
|
+
PropertyType["decimal"] = "decimal";
|
|
58
|
+
PropertyType["id"] = "id";
|
|
59
|
+
PropertyType["instant"] = "instant";
|
|
60
|
+
PropertyType["integer"] = "integer";
|
|
61
|
+
PropertyType["markdown"] = "markdown";
|
|
62
|
+
PropertyType["oid"] = "oid";
|
|
63
|
+
PropertyType["positiveInt"] = "positiveInt";
|
|
64
|
+
PropertyType["string"] = "string";
|
|
65
|
+
PropertyType["time"] = "time";
|
|
66
|
+
PropertyType["unsignedInt"] = "unsignedInt";
|
|
67
|
+
PropertyType["uri"] = "uri";
|
|
68
|
+
PropertyType["url"] = "url";
|
|
69
|
+
PropertyType["uuid"] = "uuid";
|
|
70
|
+
})(PropertyType || (PropertyType = {}));
|
|
71
|
+
/**
|
|
72
|
+
* Creates a new empty IndexedStructureDefinition.
|
|
73
|
+
* @returns The empty IndexedStructureDefinition.
|
|
74
|
+
* @deprecated Use globalSchema
|
|
75
|
+
*/
|
|
76
|
+
function createSchema() {
|
|
77
|
+
return { types: {} };
|
|
78
|
+
}
|
|
79
|
+
function createTypeSchema(typeName, description) {
|
|
80
|
+
return {
|
|
81
|
+
display: typeName,
|
|
82
|
+
description,
|
|
83
|
+
properties: {},
|
|
84
|
+
searchParams: {
|
|
85
|
+
_lastUpdated: {
|
|
86
|
+
base: [typeName],
|
|
87
|
+
code: '_lastUpdated',
|
|
88
|
+
type: 'date',
|
|
89
|
+
expression: typeName + '.meta.lastUpdated',
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Indexes a bundle of StructureDefinitions for faster lookup.
|
|
96
|
+
* @param bundle A FHIR bundle StructureDefinition resources.
|
|
97
|
+
*/
|
|
98
|
+
function indexStructureDefinitionBundle(bundle) {
|
|
99
|
+
for (const entry of bundle.entry) {
|
|
100
|
+
const resource = entry.resource;
|
|
101
|
+
if (resource.resourceType === 'StructureDefinition') {
|
|
102
|
+
indexStructureDefinition(globalSchema, resource);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Indexes a StructureDefinition for fast lookup.
|
|
108
|
+
* See comments on IndexedStructureDefinition for more details.
|
|
109
|
+
* @param schema The output IndexedStructureDefinition.
|
|
110
|
+
* @param structureDefinition The original StructureDefinition.
|
|
111
|
+
*/
|
|
112
|
+
function indexStructureDefinition(schema, structureDefinition) {
|
|
113
|
+
var _a;
|
|
114
|
+
const typeName = structureDefinition.name;
|
|
115
|
+
if (!typeName) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
if (!(typeName in schema.types)) {
|
|
119
|
+
schema.types[typeName] = createTypeSchema(typeName, structureDefinition.description);
|
|
120
|
+
}
|
|
121
|
+
const elements = (_a = structureDefinition.snapshot) === null || _a === void 0 ? void 0 : _a.element;
|
|
122
|
+
if (elements) {
|
|
123
|
+
// Filter out any elements missing path or type
|
|
124
|
+
const filtered = elements.filter((e) => e.path !== typeName && e.path);
|
|
125
|
+
// First pass, build types
|
|
126
|
+
filtered.forEach((element) => indexType(schema, element));
|
|
127
|
+
// Second pass, build properties
|
|
128
|
+
filtered.forEach((element) => indexProperty(schema, element));
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Indexes TypeSchema from an ElementDefinition.
|
|
133
|
+
* In the common case, there will be many ElementDefinition instances per TypeSchema.
|
|
134
|
+
* Only the first occurrence is saved.
|
|
135
|
+
* @param schema The output IndexedStructureDefinition.
|
|
136
|
+
* @param element The input ElementDefinition.
|
|
137
|
+
*/
|
|
138
|
+
function indexType(schema, element) {
|
|
139
|
+
var _a, _b;
|
|
140
|
+
const path = element.path;
|
|
141
|
+
const typeCode = (_b = (_a = element.type) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.code;
|
|
142
|
+
if (typeCode !== 'Element' && typeCode !== 'BackboneElement') {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
const parts = path.split('.');
|
|
146
|
+
const typeName = buildTypeName(parts);
|
|
147
|
+
if (!(typeName in schema.types)) {
|
|
148
|
+
schema.types[typeName] = createTypeSchema(typeName, element.definition);
|
|
149
|
+
schema.types[typeName].parentType = buildTypeName(parts.slice(0, parts.length - 1));
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Indexes PropertySchema from an ElementDefinition.
|
|
154
|
+
* @param schema The output IndexedStructureDefinition.
|
|
155
|
+
* @param element The input ElementDefinition.
|
|
156
|
+
*/
|
|
157
|
+
function indexProperty(schema, element) {
|
|
158
|
+
const path = element.path;
|
|
159
|
+
const parts = path.split('.');
|
|
160
|
+
if (parts.length === 1) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
const typeName = buildTypeName(parts.slice(0, parts.length - 1));
|
|
164
|
+
const typeSchema = schema.types[typeName];
|
|
165
|
+
if (!typeSchema) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
const key = parts[parts.length - 1];
|
|
169
|
+
typeSchema.properties[key] = element;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Indexes a SearchParameter resource for fast lookup.
|
|
173
|
+
* Indexes by SearchParameter.code, which is the query string parameter name.
|
|
174
|
+
* @param schema The output IndexedStructureDefinition.
|
|
175
|
+
* @param searchParam The SearchParameter resource.
|
|
176
|
+
*/
|
|
177
|
+
function indexSearchParameter(schema, searchParam) {
|
|
178
|
+
if (!searchParam.base) {
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
for (const resourceType of searchParam.base) {
|
|
182
|
+
const typeSchema = schema.types[resourceType];
|
|
183
|
+
if (!typeSchema) {
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
if (!typeSchema.searchParams) {
|
|
187
|
+
typeSchema.searchParams = {};
|
|
188
|
+
}
|
|
189
|
+
typeSchema.searchParams[searchParam.code] = searchParam;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
function buildTypeName(components) {
|
|
193
|
+
return components.map(capitalize).join('');
|
|
194
|
+
}
|
|
195
|
+
function getPropertyDisplayName(path) {
|
|
196
|
+
// Get the property name, which is the remainder after the last period
|
|
197
|
+
// For example, for path "Patient.birthDate"
|
|
198
|
+
// the property name is "birthDate"
|
|
199
|
+
const propertyName = path.replaceAll('[x]', '').split('.').pop();
|
|
200
|
+
// Special case for ID
|
|
201
|
+
if (propertyName === 'id') {
|
|
202
|
+
return 'ID';
|
|
203
|
+
}
|
|
204
|
+
// Split by capital letters
|
|
205
|
+
// Capitalize the first letter of each word
|
|
206
|
+
// Join together with spaces in between
|
|
207
|
+
// Then normalize whitespace to single space character
|
|
208
|
+
// For example, for property name "birthDate",
|
|
209
|
+
// the display name is "Birth Date".
|
|
210
|
+
return propertyName
|
|
211
|
+
.split(/(?=[A-Z])/)
|
|
212
|
+
.map(capitalize)
|
|
213
|
+
.join(' ')
|
|
214
|
+
.replace('_', ' ')
|
|
215
|
+
.replace(/\s+/g, ' ');
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Global schema singleton.
|
|
219
|
+
*/
|
|
220
|
+
const globalSchema = baseSchema;
|
|
221
|
+
|
|
222
|
+
export { PropertyType, buildTypeName, createSchema, createTypeSchema, getPropertyDisplayName, globalSchema, indexSearchParameter, indexStructureDefinition, indexStructureDefinitionBundle };
|
|
223
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sources":["../../src/types.ts"],"sourcesContent":["import {\n Bundle,\n BundleEntry,\n ElementDefinition,\n Resource,\n SearchParameter,\n StructureDefinition,\n} from '@medplum/fhirtypes';\nimport baseSchema from './base-schema.json';\nimport { capitalize } from './utils';\n\n/**\n * List of property types.\n * http://www.hl7.org/fhir/valueset-defined-types.html\n * The list here includes additions found from StructureDefinition resources.\n */\nexport enum PropertyType {\n Address = 'Address',\n Age = 'Age',\n Annotation = 'Annotation',\n Attachment = 'Attachment',\n BackboneElement = 'BackboneElement',\n CodeableConcept = 'CodeableConcept',\n Coding = 'Coding',\n ContactDetail = 'ContactDetail',\n ContactPoint = 'ContactPoint',\n Contributor = 'Contributor',\n Count = 'Count',\n DataRequirement = 'DataRequirement',\n Distance = 'Distance',\n Dosage = 'Dosage',\n Duration = 'Duration',\n Expression = 'Expression',\n Extension = 'Extension',\n HumanName = 'HumanName',\n Identifier = 'Identifier',\n MarketingStatus = 'MarketingStatus',\n Meta = 'Meta',\n Money = 'Money',\n Narrative = 'Narrative',\n ParameterDefinition = 'ParameterDefinition',\n Period = 'Period',\n Population = 'Population',\n ProdCharacteristic = 'ProdCharacteristic',\n ProductShelfLife = 'ProductShelfLife',\n Quantity = 'Quantity',\n Range = 'Range',\n Ratio = 'Ratio',\n Reference = 'Reference',\n RelatedArtifact = 'RelatedArtifact',\n SampledData = 'SampledData',\n Signature = 'Signature',\n SubstanceAmount = 'SubstanceAmount',\n SystemString = 'http://hl7.org/fhirpath/System.String',\n Timing = 'Timing',\n TriggerDefinition = 'TriggerDefinition',\n UsageContext = 'UsageContext',\n base64Binary = 'base64Binary',\n boolean = 'boolean',\n canonical = 'canonical',\n code = 'code',\n date = 'date',\n dateTime = 'dateTime',\n decimal = 'decimal',\n id = 'id',\n instant = 'instant',\n integer = 'integer',\n markdown = 'markdown',\n oid = 'oid',\n positiveInt = 'positiveInt',\n string = 'string',\n time = 'time',\n unsignedInt = 'unsignedInt',\n uri = 'uri',\n url = 'url',\n uuid = 'uuid',\n}\n\n/**\n * An IndexedStructureDefinition is a lookup-optimized version of a StructureDefinition.\n *\n * StructureDefinition resources contain schema information for other resource types.\n * These schemas can be used to automatically generate user interface elements for\n * resources.\n *\n * However, a StructureDefinition resource is not optimized for realtime lookups. All\n * resource types, sub types, and property definitions are stored in a flat array of\n * ElementDefinition objects. Therefore, to lookup the schema for a property (i.e., \"Patient.name\")\n * requires a linear scan of all ElementDefinition objects\n *\n * A StructureDefinition resource contains information about one or more types.\n * For example, the \"Patient\" StructureDefinition includes \"Patient\", \"Patient_Contact\",\n * \"Patient_Communication\", and \"Patient_Link\". This is inefficient.\n *\n * Instead, we create an indexed version of the StructureDefinition, called IndexedStructureDefinition.\n * In an IndexedStructureDefinition, retrieving a property definition is a hashtable lookup.\n *\n * The hierarchy is:\n * IndexedStructureDefinition - top level for one resource type\n * TypeSchema - one per resource type and all contained BackboneElements\n * PropertySchema - one per property/field\n */\nexport interface IndexedStructureDefinition {\n types: { [resourceType: string]: TypeSchema };\n}\n\n/**\n * An indexed TypeSchema.\n *\n * Example: The IndexedStructureDefinition for \"Patient\" would include the following TypeSchemas:\n * 1) Patient\n * 2) Patient_Contact\n * 3) Patient_Communication\n * 4) Patient_Link\n */\nexport interface TypeSchema {\n display: string;\n properties: { [name: string]: ElementDefinition };\n searchParams?: { [code: string]: SearchParameter };\n description?: string;\n parentType?: string;\n}\n\n/**\n * Creates a new empty IndexedStructureDefinition.\n * @returns The empty IndexedStructureDefinition.\n * @deprecated Use globalSchema\n */\nexport function createSchema(): IndexedStructureDefinition {\n return { types: {} };\n}\n\nexport function createTypeSchema(typeName: string, description: string | undefined): TypeSchema {\n return {\n display: typeName,\n description,\n properties: {},\n searchParams: {\n _lastUpdated: {\n base: [typeName],\n code: '_lastUpdated',\n type: 'date',\n expression: typeName + '.meta.lastUpdated',\n } as SearchParameter,\n },\n };\n}\n\n/**\n * Indexes a bundle of StructureDefinitions for faster lookup.\n * @param bundle A FHIR bundle StructureDefinition resources.\n */\nexport function indexStructureDefinitionBundle(bundle: Bundle): void {\n for (const entry of bundle.entry as BundleEntry[]) {\n const resource = entry.resource as Resource;\n if (resource.resourceType === 'StructureDefinition') {\n indexStructureDefinition(globalSchema, resource);\n }\n }\n}\n\n/**\n * Indexes a StructureDefinition for fast lookup.\n * See comments on IndexedStructureDefinition for more details.\n * @param schema The output IndexedStructureDefinition.\n * @param structureDefinition The original StructureDefinition.\n */\nexport function indexStructureDefinition(\n schema: IndexedStructureDefinition,\n structureDefinition: StructureDefinition\n): void {\n const typeName = structureDefinition.name;\n if (!typeName) {\n return;\n }\n\n if (!(typeName in schema.types)) {\n schema.types[typeName] = createTypeSchema(typeName, structureDefinition.description);\n }\n\n const elements = structureDefinition.snapshot?.element;\n if (elements) {\n // Filter out any elements missing path or type\n const filtered = elements.filter((e) => e.path !== typeName && e.path);\n\n // First pass, build types\n filtered.forEach((element) => indexType(schema, element));\n\n // Second pass, build properties\n filtered.forEach((element) => indexProperty(schema, element));\n }\n}\n\n/**\n * Indexes TypeSchema from an ElementDefinition.\n * In the common case, there will be many ElementDefinition instances per TypeSchema.\n * Only the first occurrence is saved.\n * @param schema The output IndexedStructureDefinition.\n * @param element The input ElementDefinition.\n */\nfunction indexType(schema: IndexedStructureDefinition, element: ElementDefinition): void {\n const path = element.path as string;\n const typeCode = element.type?.[0]?.code;\n if (typeCode !== 'Element' && typeCode !== 'BackboneElement') {\n return;\n }\n const parts = path.split('.');\n const typeName = buildTypeName(parts);\n if (!(typeName in schema.types)) {\n schema.types[typeName] = createTypeSchema(typeName, element.definition);\n schema.types[typeName].parentType = buildTypeName(parts.slice(0, parts.length - 1));\n }\n}\n\n/**\n * Indexes PropertySchema from an ElementDefinition.\n * @param schema The output IndexedStructureDefinition.\n * @param element The input ElementDefinition.\n */\nfunction indexProperty(schema: IndexedStructureDefinition, element: ElementDefinition): void {\n const path = element.path as string;\n const parts = path.split('.');\n if (parts.length === 1) {\n return;\n }\n const typeName = buildTypeName(parts.slice(0, parts.length - 1));\n const typeSchema = schema.types[typeName];\n if (!typeSchema) {\n return;\n }\n const key = parts[parts.length - 1];\n typeSchema.properties[key] = element;\n}\n\n/**\n * Indexes a SearchParameter resource for fast lookup.\n * Indexes by SearchParameter.code, which is the query string parameter name.\n * @param schema The output IndexedStructureDefinition.\n * @param searchParam The SearchParameter resource.\n */\nexport function indexSearchParameter(schema: IndexedStructureDefinition, searchParam: SearchParameter): void {\n if (!searchParam.base) {\n return;\n }\n\n for (const resourceType of searchParam.base) {\n const typeSchema = schema.types[resourceType];\n if (!typeSchema) {\n continue;\n }\n\n if (!typeSchema.searchParams) {\n typeSchema.searchParams = {};\n }\n\n typeSchema.searchParams[searchParam.code as string] = searchParam;\n }\n}\n\nexport function buildTypeName(components: string[]): string {\n return components.map(capitalize).join('');\n}\n\nexport function getPropertyDisplayName(path: string): string {\n // Get the property name, which is the remainder after the last period\n // For example, for path \"Patient.birthDate\"\n // the property name is \"birthDate\"\n const propertyName = path.replaceAll('[x]', '').split('.').pop() as string;\n\n // Special case for ID\n if (propertyName === 'id') {\n return 'ID';\n }\n\n // Split by capital letters\n // Capitalize the first letter of each word\n // Join together with spaces in between\n // Then normalize whitespace to single space character\n // For example, for property name \"birthDate\",\n // the display name is \"Birth Date\".\n return propertyName\n .split(/(?=[A-Z])/)\n .map(capitalize)\n .join(' ')\n .replace('_', ' ')\n .replace(/\\s+/g, ' ');\n}\n\n/**\n * Global schema singleton.\n */\nexport const globalSchema = baseSchema as IndexedStructureDefinition;\n"],"names":[],"mappings":";;;AAWA;;;;AAIG;IACS,aA4DX;AA5DD,CAAA,UAAY,YAAY,EAAA;AACtB,IAAA,YAAA,CAAA,SAAA,CAAA,GAAA,SAAmB,CAAA;AACnB,IAAA,YAAA,CAAA,KAAA,CAAA,GAAA,KAAW,CAAA;AACX,IAAA,YAAA,CAAA,YAAA,CAAA,GAAA,YAAyB,CAAA;AACzB,IAAA,YAAA,CAAA,YAAA,CAAA,GAAA,YAAyB,CAAA;AACzB,IAAA,YAAA,CAAA,iBAAA,CAAA,GAAA,iBAAmC,CAAA;AACnC,IAAA,YAAA,CAAA,iBAAA,CAAA,GAAA,iBAAmC,CAAA;AACnC,IAAA,YAAA,CAAA,QAAA,CAAA,GAAA,QAAiB,CAAA;A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OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAC1B,CAAC;AAED;;AAEG;AACI,MAAM,YAAY,GAAG;;;;"}
|
|
@@ -166,6 +166,14 @@ export declare function setCodeBySystem(concept: CodeableConcept, system: string
|
|
|
166
166
|
* @returns The observation interval if found; otherwise undefined.
|
|
167
167
|
*/
|
|
168
168
|
export declare function findObservationInterval(definition: ObservationDefinition, patient: Patient, value: number, category?: 'reference' | 'critical' | 'absolute'): ObservationDefinitionQualifiedInterval | undefined;
|
|
169
|
+
/**
|
|
170
|
+
* Tries to find an observation reference range for the given patient and condition names.
|
|
171
|
+
* @param definition The observation definition.
|
|
172
|
+
* @param patient The patient.
|
|
173
|
+
* @param names The condition names.
|
|
174
|
+
* @returns The observation interval if found; otherwise undefined.
|
|
175
|
+
*/
|
|
176
|
+
export declare function findObservationReferenceRange(definition: ObservationDefinition, patient: Patient, names: string[]): ObservationDefinitionQualifiedInterval | undefined;
|
|
169
177
|
/**
|
|
170
178
|
* Returns true if the value is in the range accounting for precision.
|
|
171
179
|
* @param value The numeric value.
|