@medplum/core 0.9.34 → 0.9.35
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/client.d.ts +1 -1
- package/dist/cjs/index.js +89 -39
- 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/cjs/searchparams.d.ts +1 -3
- package/dist/cjs/types.d.ts +14 -3
- package/dist/esm/client.d.ts +1 -1
- package/dist/esm/client.js +4 -3
- package/dist/esm/client.js.map +1 -1
- package/dist/esm/fhirpath/utils.js +16 -17
- package/dist/esm/fhirpath/utils.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.min.js +1 -1
- package/dist/esm/index.min.js.map +1 -1
- package/dist/esm/outcomes.js +3 -3
- package/dist/esm/outcomes.js.map +1 -1
- package/dist/esm/searchparams.d.ts +1 -3
- package/dist/esm/searchparams.js +23 -6
- package/dist/esm/searchparams.js.map +1 -1
- package/dist/esm/types.d.ts +14 -3
- package/dist/esm/types.js +45 -13
- package/dist/esm/types.js.map +1 -1
- package/package.json +3 -3
package/dist/cjs/client.d.ts
CHANGED
package/dist/cjs/index.js
CHANGED
|
@@ -6087,17 +6087,16 @@
|
|
|
6087
6087
|
for (const entry of bundle.entry) {
|
|
6088
6088
|
const resource = entry.resource;
|
|
6089
6089
|
if (resource.resourceType === 'StructureDefinition') {
|
|
6090
|
-
indexStructureDefinition(
|
|
6090
|
+
indexStructureDefinition(resource);
|
|
6091
6091
|
}
|
|
6092
6092
|
}
|
|
6093
6093
|
}
|
|
6094
6094
|
/**
|
|
6095
6095
|
* Indexes a StructureDefinition for fast lookup.
|
|
6096
6096
|
* See comments on IndexedStructureDefinition for more details.
|
|
6097
|
-
* @param schema The output IndexedStructureDefinition.
|
|
6098
6097
|
* @param structureDefinition The original StructureDefinition.
|
|
6099
6098
|
*/
|
|
6100
|
-
function indexStructureDefinition(
|
|
6099
|
+
function indexStructureDefinition(structureDefinition) {
|
|
6101
6100
|
var _a;
|
|
6102
6101
|
const typeName = structureDefinition.name;
|
|
6103
6102
|
if (!typeName) {
|
|
@@ -6106,9 +6105,9 @@
|
|
|
6106
6105
|
const elements = (_a = structureDefinition.snapshot) === null || _a === void 0 ? void 0 : _a.element;
|
|
6107
6106
|
if (elements) {
|
|
6108
6107
|
// First pass, build types
|
|
6109
|
-
elements.forEach((element) => indexType(
|
|
6108
|
+
elements.forEach((element) => indexType(structureDefinition, element));
|
|
6110
6109
|
// Second pass, build properties
|
|
6111
|
-
elements.forEach((element) => indexProperty(
|
|
6110
|
+
elements.forEach((element) => indexProperty(element));
|
|
6112
6111
|
}
|
|
6113
6112
|
}
|
|
6114
6113
|
/**
|
|
@@ -6118,7 +6117,7 @@
|
|
|
6118
6117
|
* @param schema The output IndexedStructureDefinition.
|
|
6119
6118
|
* @param element The input ElementDefinition.
|
|
6120
6119
|
*/
|
|
6121
|
-
function indexType(
|
|
6120
|
+
function indexType(structureDefinition, elementDefinition) {
|
|
6122
6121
|
var _a, _b;
|
|
6123
6122
|
const path = elementDefinition.path;
|
|
6124
6123
|
const typeCode = (_b = (_a = elementDefinition.type) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.code;
|
|
@@ -6127,22 +6126,22 @@
|
|
|
6127
6126
|
}
|
|
6128
6127
|
const parts = path.split('.');
|
|
6129
6128
|
const typeName = buildTypeName(parts);
|
|
6130
|
-
|
|
6131
|
-
|
|
6129
|
+
globalSchema.types[typeName] = createTypeSchema(typeName, structureDefinition, elementDefinition);
|
|
6130
|
+
globalSchema.types[typeName].parentType = buildTypeName(parts.slice(0, parts.length - 1));
|
|
6132
6131
|
}
|
|
6133
6132
|
/**
|
|
6134
6133
|
* Indexes PropertySchema from an ElementDefinition.
|
|
6135
6134
|
* @param schema The output IndexedStructureDefinition.
|
|
6136
6135
|
* @param element The input ElementDefinition.
|
|
6137
6136
|
*/
|
|
6138
|
-
function indexProperty(
|
|
6137
|
+
function indexProperty(element) {
|
|
6139
6138
|
const path = element.path;
|
|
6140
6139
|
const parts = path.split('.');
|
|
6141
6140
|
if (parts.length === 1) {
|
|
6142
6141
|
return;
|
|
6143
6142
|
}
|
|
6144
6143
|
const typeName = buildTypeName(parts.slice(0, parts.length - 1));
|
|
6145
|
-
const typeSchema =
|
|
6144
|
+
const typeSchema = globalSchema.types[typeName];
|
|
6146
6145
|
if (!typeSchema) {
|
|
6147
6146
|
return;
|
|
6148
6147
|
}
|
|
@@ -6155,17 +6154,23 @@
|
|
|
6155
6154
|
* @param schema The output IndexedStructureDefinition.
|
|
6156
6155
|
* @param searchParam The SearchParameter resource.
|
|
6157
6156
|
*/
|
|
6158
|
-
function indexSearchParameter(
|
|
6157
|
+
function indexSearchParameter(searchParam) {
|
|
6159
6158
|
if (!searchParam.base) {
|
|
6160
6159
|
return;
|
|
6161
6160
|
}
|
|
6162
6161
|
for (const resourceType of searchParam.base) {
|
|
6163
|
-
const typeSchema =
|
|
6162
|
+
const typeSchema = globalSchema.types[resourceType];
|
|
6164
6163
|
if (!typeSchema) {
|
|
6165
6164
|
continue;
|
|
6166
6165
|
}
|
|
6167
6166
|
if (!typeSchema.searchParams) {
|
|
6168
6167
|
typeSchema.searchParams = {
|
|
6168
|
+
_id: {
|
|
6169
|
+
base: [resourceType],
|
|
6170
|
+
code: '_id',
|
|
6171
|
+
type: 'token',
|
|
6172
|
+
expression: resourceType + '.id',
|
|
6173
|
+
},
|
|
6169
6174
|
_lastUpdated: {
|
|
6170
6175
|
base: [resourceType],
|
|
6171
6176
|
code: '_lastUpdated',
|
|
@@ -6205,6 +6210,33 @@
|
|
|
6205
6210
|
.replace('_', ' ')
|
|
6206
6211
|
.replace(/\s+/g, ' ');
|
|
6207
6212
|
}
|
|
6213
|
+
/**
|
|
6214
|
+
* Returns an element definition by type and property name.
|
|
6215
|
+
* Handles content references.
|
|
6216
|
+
* @param typeName The type name.
|
|
6217
|
+
* @param propertyName The property name.
|
|
6218
|
+
* @returns The element definition if found.
|
|
6219
|
+
*/
|
|
6220
|
+
function getElementDefinition(typeName, propertyName) {
|
|
6221
|
+
var _a;
|
|
6222
|
+
const typeSchema = globalSchema.types[typeName];
|
|
6223
|
+
if (!typeSchema) {
|
|
6224
|
+
return undefined;
|
|
6225
|
+
}
|
|
6226
|
+
const property = (_a = typeSchema.properties[propertyName]) !== null && _a !== void 0 ? _a : typeSchema.properties[propertyName + '[x]'];
|
|
6227
|
+
if (!property) {
|
|
6228
|
+
return undefined;
|
|
6229
|
+
}
|
|
6230
|
+
if (property.contentReference) {
|
|
6231
|
+
// Content references start with a "#"
|
|
6232
|
+
// Remove the "#" character
|
|
6233
|
+
const contentReference = property.contentReference.substring(1).split('.');
|
|
6234
|
+
const referencePropertyName = contentReference.pop();
|
|
6235
|
+
const referenceTypeName = buildTypeName(contentReference);
|
|
6236
|
+
return getElementDefinition(referenceTypeName, referencePropertyName);
|
|
6237
|
+
}
|
|
6238
|
+
return property;
|
|
6239
|
+
}
|
|
6208
6240
|
/**
|
|
6209
6241
|
* Global schema singleton.
|
|
6210
6242
|
*/
|
|
@@ -6617,7 +6649,7 @@
|
|
|
6617
6649
|
* ```json
|
|
6618
6650
|
* {
|
|
6619
6651
|
* "resourceType": "Bundle",
|
|
6620
|
-
* "type": "
|
|
6652
|
+
* "type": "searchset",
|
|
6621
6653
|
* "total": 1,
|
|
6622
6654
|
* "entry": [
|
|
6623
6655
|
* {
|
|
@@ -6860,10 +6892,10 @@
|
|
|
6860
6892
|
}`.replace(/\s+/g, ' ');
|
|
6861
6893
|
const response = (yield this.graphql(query));
|
|
6862
6894
|
for (const structureDefinition of response.data.StructureDefinitionList) {
|
|
6863
|
-
indexStructureDefinition(
|
|
6895
|
+
indexStructureDefinition(structureDefinition);
|
|
6864
6896
|
}
|
|
6865
6897
|
for (const searchParameter of response.data.SearchParameterList) {
|
|
6866
|
-
indexSearchParameter(
|
|
6898
|
+
indexSearchParameter(searchParameter);
|
|
6867
6899
|
}
|
|
6868
6900
|
return globalSchema;
|
|
6869
6901
|
});
|
|
@@ -7531,6 +7563,7 @@
|
|
|
7531
7563
|
options.headers = {};
|
|
7532
7564
|
}
|
|
7533
7565
|
const headers = options.headers;
|
|
7566
|
+
headers['X-Medplum'] = 'extended';
|
|
7534
7567
|
if (!headers['Content-Type']) {
|
|
7535
7568
|
headers['Content-Type'] = FHIR_CONTENT_TYPE;
|
|
7536
7569
|
}
|
|
@@ -7761,9 +7794,9 @@
|
|
|
7761
7794
|
if (!(input === null || input === void 0 ? void 0 : input.value)) {
|
|
7762
7795
|
return undefined;
|
|
7763
7796
|
}
|
|
7764
|
-
const
|
|
7765
|
-
if (
|
|
7766
|
-
const typedResult = getTypedPropertyValueWithSchema(input, path,
|
|
7797
|
+
const elementDefinition = getElementDefinition(input.type, path);
|
|
7798
|
+
if (elementDefinition) {
|
|
7799
|
+
const typedResult = getTypedPropertyValueWithSchema(input, path, elementDefinition);
|
|
7767
7800
|
if (typedResult) {
|
|
7768
7801
|
return typedResult;
|
|
7769
7802
|
}
|
|
@@ -7774,24 +7807,18 @@
|
|
|
7774
7807
|
* Returns the value of the property and the property type using a type schema.
|
|
7775
7808
|
* @param input The base context (FHIR resource or backbone element).
|
|
7776
7809
|
* @param path The property path.
|
|
7777
|
-
* @param
|
|
7810
|
+
* @param property The property element definition.
|
|
7778
7811
|
* @returns The value of the property and the property type.
|
|
7779
7812
|
*/
|
|
7780
|
-
function getTypedPropertyValueWithSchema(input, path,
|
|
7813
|
+
function getTypedPropertyValueWithSchema(input, path, property) {
|
|
7781
7814
|
var _a;
|
|
7782
|
-
const property = (_a = typeSchema.properties[path]) !== null && _a !== void 0 ? _a : typeSchema.properties[path + '[x]'];
|
|
7783
|
-
if (!property) {
|
|
7784
|
-
return undefined;
|
|
7785
|
-
}
|
|
7786
7815
|
const types = property.type;
|
|
7787
7816
|
if (!types || types.length === 0) {
|
|
7788
7817
|
return undefined;
|
|
7789
7818
|
}
|
|
7790
|
-
let propertyName = undefined;
|
|
7791
7819
|
let resultValue = undefined;
|
|
7792
7820
|
let resultType = 'undefined';
|
|
7793
7821
|
if (types.length === 1) {
|
|
7794
|
-
propertyName = path;
|
|
7795
7822
|
resultValue = input.value[path];
|
|
7796
7823
|
resultType = types[0].code;
|
|
7797
7824
|
}
|
|
@@ -7799,7 +7826,6 @@
|
|
|
7799
7826
|
for (const type of types) {
|
|
7800
7827
|
const path2 = path.replace('[x]', '') + capitalize(type.code);
|
|
7801
7828
|
if (path2 in input.value) {
|
|
7802
|
-
propertyName = path2;
|
|
7803
7829
|
resultValue = input.value[path2];
|
|
7804
7830
|
resultType = type.code;
|
|
7805
7831
|
break;
|
|
@@ -7809,16 +7835,22 @@
|
|
|
7809
7835
|
if (isEmpty(resultValue)) {
|
|
7810
7836
|
return undefined;
|
|
7811
7837
|
}
|
|
7812
|
-
if (resultType === 'BackboneElement') {
|
|
7813
|
-
resultType = buildTypeName(
|
|
7838
|
+
if (resultType === 'Element' || resultType === 'BackboneElement') {
|
|
7839
|
+
resultType = buildTypeName((_a = property.path) === null || _a === void 0 ? void 0 : _a.split('.'));
|
|
7814
7840
|
}
|
|
7815
7841
|
if (Array.isArray(resultValue)) {
|
|
7816
|
-
return resultValue.map((element) => (
|
|
7842
|
+
return resultValue.map((element) => toTypedValueWithType(element, resultType));
|
|
7817
7843
|
}
|
|
7818
7844
|
else {
|
|
7819
|
-
return
|
|
7845
|
+
return toTypedValueWithType(resultValue, resultType);
|
|
7820
7846
|
}
|
|
7821
7847
|
}
|
|
7848
|
+
function toTypedValueWithType(value, type) {
|
|
7849
|
+
if (type === 'Resource' && typeof value === 'object' && 'resourceType' in value) {
|
|
7850
|
+
type = value.resourceType;
|
|
7851
|
+
}
|
|
7852
|
+
return { type, value };
|
|
7853
|
+
}
|
|
7822
7854
|
/**
|
|
7823
7855
|
* Returns the value of the property and the property type using a type schema.
|
|
7824
7856
|
* Note that because the type schema is not available, this function may be inaccurate.
|
|
@@ -10443,7 +10475,7 @@
|
|
|
10443
10475
|
issue: [
|
|
10444
10476
|
{
|
|
10445
10477
|
severity: 'information',
|
|
10446
|
-
code: '
|
|
10478
|
+
code: 'informational',
|
|
10447
10479
|
details: {
|
|
10448
10480
|
text: 'All OK',
|
|
10449
10481
|
},
|
|
@@ -10456,7 +10488,7 @@
|
|
|
10456
10488
|
issue: [
|
|
10457
10489
|
{
|
|
10458
10490
|
severity: 'information',
|
|
10459
|
-
code: '
|
|
10491
|
+
code: 'informational',
|
|
10460
10492
|
details: {
|
|
10461
10493
|
text: 'Created',
|
|
10462
10494
|
},
|
|
@@ -10469,7 +10501,7 @@
|
|
|
10469
10501
|
issue: [
|
|
10470
10502
|
{
|
|
10471
10503
|
severity: 'information',
|
|
10472
|
-
code: '
|
|
10504
|
+
code: 'informational',
|
|
10473
10505
|
details: {
|
|
10474
10506
|
text: 'Not Modified',
|
|
10475
10507
|
},
|
|
@@ -10860,17 +10892,32 @@
|
|
|
10860
10892
|
* 2) The "token" type includes enums and booleans.
|
|
10861
10893
|
* 3) Arrays/multiple values are not reflected at all.
|
|
10862
10894
|
*
|
|
10863
|
-
* @param structureDefinitions Collection of StructureDefinition resources indexed by name.
|
|
10864
10895
|
* @param resourceType The root resource type.
|
|
10865
10896
|
* @param searchParam The search parameter.
|
|
10866
10897
|
* @returns The search parameter type details.
|
|
10867
10898
|
*/
|
|
10868
|
-
function getSearchParameterDetails(
|
|
10899
|
+
function getSearchParameterDetails(resourceType, searchParam) {
|
|
10900
|
+
var _a, _b;
|
|
10901
|
+
let result = (_b = (_a = globalSchema.types[resourceType]) === null || _a === void 0 ? void 0 : _a.searchParamsDetails) === null || _b === void 0 ? void 0 : _b[searchParam.code];
|
|
10902
|
+
if (!result) {
|
|
10903
|
+
result = buildSearchParamterDetails(resourceType, searchParam);
|
|
10904
|
+
}
|
|
10905
|
+
return result;
|
|
10906
|
+
}
|
|
10907
|
+
function setSearchParamterDetails(resourceType, code, details) {
|
|
10908
|
+
const typeSchema = globalSchema.types[resourceType];
|
|
10909
|
+
if (!typeSchema.searchParamsDetails) {
|
|
10910
|
+
typeSchema.searchParamsDetails = {};
|
|
10911
|
+
}
|
|
10912
|
+
typeSchema.searchParamsDetails[code] = details;
|
|
10913
|
+
}
|
|
10914
|
+
function buildSearchParamterDetails(resourceType, searchParam) {
|
|
10869
10915
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
10870
10916
|
if (searchParam.code === '_lastUpdated') {
|
|
10871
10917
|
return { columnName: 'lastUpdated', type: exports.SearchParameterType.DATETIME };
|
|
10872
10918
|
}
|
|
10873
|
-
const
|
|
10919
|
+
const code = searchParam.code;
|
|
10920
|
+
const columnName = convertCodeToColumnName(code);
|
|
10874
10921
|
const expression = (_a = getExpressionForResourceType(resourceType, searchParam.expression)) === null || _a === void 0 ? void 0 : _a.split('.');
|
|
10875
10922
|
if (!expression) {
|
|
10876
10923
|
// This happens on compound types
|
|
@@ -10885,7 +10932,7 @@
|
|
|
10885
10932
|
for (let i = 1; i < expression.length; i++) {
|
|
10886
10933
|
const propertyName = expression[i];
|
|
10887
10934
|
elementDefinition =
|
|
10888
|
-
(_d = (_c = (_b =
|
|
10935
|
+
(_d = (_c = (_b = globalSchema.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 = globalSchema.types[baseType]) === null || _e === void 0 ? void 0 : _e.properties) === null || _f === void 0 ? void 0 : _f[propertyName + '[x]'];
|
|
10889
10936
|
if (!elementDefinition) {
|
|
10890
10937
|
throw new Error(`Element definition not found for ${resourceType} ${searchParam.code}`);
|
|
10891
10938
|
}
|
|
@@ -10908,7 +10955,9 @@
|
|
|
10908
10955
|
}
|
|
10909
10956
|
}
|
|
10910
10957
|
const type = getSearchParameterType(searchParam, propertyType);
|
|
10911
|
-
|
|
10958
|
+
const result = { columnName, type, elementDefinition, array };
|
|
10959
|
+
setSearchParamterDetails(resourceType, code, result);
|
|
10960
|
+
return result;
|
|
10912
10961
|
}
|
|
10913
10962
|
/**
|
|
10914
10963
|
* Converts a hyphen-delimited code to camelCase string.
|
|
@@ -11051,6 +11100,7 @@
|
|
|
11051
11100
|
exports.getCodeBySystem = getCodeBySystem;
|
|
11052
11101
|
exports.getDateProperty = getDateProperty;
|
|
11053
11102
|
exports.getDisplayString = getDisplayString;
|
|
11103
|
+
exports.getElementDefinition = getElementDefinition;
|
|
11054
11104
|
exports.getExpressionForResourceType = getExpressionForResourceType;
|
|
11055
11105
|
exports.getExtensionValue = getExtensionValue;
|
|
11056
11106
|
exports.getIdentifier = getIdentifier;
|