@medplum/core 2.0.14 → 2.0.15
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.cjs +1155 -1060
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.min.cjs +1 -1
- package/dist/esm/base64.mjs +33 -0
- package/dist/esm/base64.mjs.map +1 -0
- package/dist/esm/cache.mjs +17 -23
- package/dist/esm/cache.mjs.map +1 -1
- package/dist/esm/client.mjs +464 -395
- package/dist/esm/client.mjs.map +1 -1
- package/dist/esm/eventtarget.mjs +6 -11
- package/dist/esm/eventtarget.mjs.map +1 -1
- package/dist/esm/fhirlexer/parse.mjs +15 -23
- package/dist/esm/fhirlexer/parse.mjs.map +1 -1
- package/dist/esm/fhirlexer/tokenize.mjs +190 -180
- package/dist/esm/fhirlexer/tokenize.mjs.map +1 -1
- package/dist/esm/fhirmapper/parse.mjs +264 -252
- package/dist/esm/fhirmapper/parse.mjs.map +1 -1
- package/dist/esm/fhirmapper/tokenize.mjs +0 -1
- package/dist/esm/fhirmapper/tokenize.mjs.map +1 -1
- package/dist/esm/fhirpath/atoms.mjs +0 -1
- package/dist/esm/fhirpath/atoms.mjs.map +1 -1
- package/dist/esm/fhirpath/parse.mjs +0 -1
- package/dist/esm/fhirpath/parse.mjs.map +1 -1
- package/dist/esm/fhirpath/tokenize.mjs +0 -1
- package/dist/esm/fhirpath/tokenize.mjs.map +1 -1
- package/dist/esm/filter/parse.mjs +0 -2
- package/dist/esm/filter/parse.mjs.map +1 -1
- package/dist/esm/filter/tokenize.mjs +0 -1
- package/dist/esm/filter/tokenize.mjs.map +1 -1
- package/dist/esm/index.min.mjs +1 -1
- package/dist/esm/jwt.mjs +2 -9
- package/dist/esm/jwt.mjs.map +1 -1
- package/dist/esm/readablepromise.mjs +18 -23
- package/dist/esm/readablepromise.mjs.map +1 -1
- package/dist/esm/schema.mjs +146 -123
- package/dist/esm/schema.mjs.map +1 -1
- package/dist/esm/search/match.mjs +0 -2
- package/dist/esm/search/match.mjs.map +1 -1
- package/dist/esm/storage.mjs +13 -19
- package/dist/esm/storage.mjs.map +1 -1
- package/dist/types/base64.d.ts +14 -0
- package/dist/types/cache.d.ts +3 -1
- package/dist/types/client.d.ts +127 -1
- package/dist/types/eventtarget.d.ts +1 -1
- package/dist/types/fhirlexer/parse.d.ts +5 -2
- package/dist/types/fhirlexer/tokenize.d.ts +28 -1
- package/dist/types/readablepromise.d.ts +4 -1
- package/dist/types/schema.d.ts +33 -1
- package/dist/types/storage.d.ts +2 -2
- package/package.json +1 -1
- package/dist/esm/node_modules/tslib/tslib.es6.mjs +0 -30
- package/dist/esm/node_modules/tslib/tslib.es6.mjs.map +0 -1
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
import { __classPrivateFieldGet } from '../node_modules/tslib/tslib.es6.mjs';
|
|
2
1
|
import { SymbolAtom, FunctionAtom, LiteralAtom } from '../fhirpath/atoms.mjs';
|
|
3
2
|
import { initFhirPathParserBuilder } from '../fhirpath/parse.mjs';
|
|
4
|
-
import '../fhirlexer/parse.mjs';
|
|
5
|
-
import '../fhirlexer/tokenize.mjs';
|
|
6
3
|
import '../types.mjs';
|
|
7
4
|
import '../utils.mjs';
|
|
8
5
|
import { tokenize } from './tokenize.mjs';
|
|
9
6
|
|
|
10
|
-
var _StructureMapParser_instances, _StructureMapParser_parseUses, _StructureMapParser_parseImport, _StructureMapParser_parseGroup, _StructureMapParser_parseParameters, _StructureMapParser_parseParameter, _StructureMapParser_parseRules, _StructureMapParser_parseRule, _StructureMapParser_parseRuleSources, _StructureMapParser_parseRuleSource, _StructureMapParser_parseRuleTargets, _StructureMapParser_parseRuleTarget, _StructureMapParser_parseRuleTargetTransform, _StructureMapParser_parseRuleTargetSymbol, _StructureMapParser_parseRuleTargetFunction, _StructureMapParser_parseRuleTargetLiteral, _StructureMapParser_parseRuleContext, _StructureMapParser_parseRuleDependents, _StructureMapParser_parseConceptMap;
|
|
11
7
|
class StructureMapParser {
|
|
12
8
|
constructor(parser) {
|
|
13
|
-
_StructureMapParser_instances.add(this);
|
|
14
9
|
this.parser = parser;
|
|
15
10
|
this.structureMap = { resourceType: 'StructureMap' };
|
|
16
11
|
}
|
|
@@ -25,16 +20,16 @@ class StructureMapParser {
|
|
|
25
20
|
const next = this.parser.peek()?.value;
|
|
26
21
|
switch (next) {
|
|
27
22
|
case 'uses':
|
|
28
|
-
|
|
23
|
+
this.parseUses();
|
|
29
24
|
break;
|
|
30
25
|
case 'imports':
|
|
31
|
-
|
|
26
|
+
this.parseImport();
|
|
32
27
|
break;
|
|
33
28
|
case 'group':
|
|
34
|
-
|
|
29
|
+
this.parseGroup();
|
|
35
30
|
break;
|
|
36
31
|
case 'conceptmap':
|
|
37
|
-
|
|
32
|
+
this.parseConceptMap();
|
|
38
33
|
break;
|
|
39
34
|
default:
|
|
40
35
|
throw new Error(`Unexpected token: ${next}`);
|
|
@@ -42,263 +37,280 @@ class StructureMapParser {
|
|
|
42
37
|
}
|
|
43
38
|
return this.structureMap;
|
|
44
39
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
this.structureMap.structure.push(result);
|
|
62
|
-
}, _StructureMapParser_parseImport = function _StructureMapParser_parseImport() {
|
|
63
|
-
this.parser.consume('Symbol', 'imports');
|
|
64
|
-
if (!this.structureMap.import) {
|
|
65
|
-
this.structureMap.import = [];
|
|
66
|
-
}
|
|
67
|
-
this.structureMap.import.push(this.parser.consume('String').value);
|
|
68
|
-
}, _StructureMapParser_parseGroup = function _StructureMapParser_parseGroup() {
|
|
69
|
-
// 'group' identifier parameters extends? typeMode? rules
|
|
70
|
-
// group tutorial(source src : TLeft, target tgt : TRight) {
|
|
71
|
-
const result = {};
|
|
72
|
-
this.parser.consume('Symbol', 'group');
|
|
73
|
-
result.name = this.parser.consume('Symbol').value;
|
|
74
|
-
result.input = __classPrivateFieldGet(this, _StructureMapParser_instances, "m", _StructureMapParser_parseParameters).call(this);
|
|
75
|
-
if (this.parser.peek()?.value === 'extends') {
|
|
76
|
-
this.parser.consume('Symbol', 'extends');
|
|
77
|
-
result.extends = this.parser.consume('Symbol').value;
|
|
78
|
-
}
|
|
79
|
-
if (this.parser.peek()?.value === '<<') {
|
|
80
|
-
this.parser.consume('<<');
|
|
81
|
-
result.typeMode = this.parser.consume().value;
|
|
82
|
-
if (this.parser.peek()?.value === '+') {
|
|
83
|
-
this.parser.consume('+');
|
|
84
|
-
result.typeMode = 'type-and-types';
|
|
85
|
-
}
|
|
86
|
-
this.parser.consume('>>');
|
|
40
|
+
parseUses() {
|
|
41
|
+
// 'uses' url structureAlias? 'as' modelMode
|
|
42
|
+
// uses "http://hl7.org/fhir/StructureDefinition/tutorial-left" as source
|
|
43
|
+
this.parser.consume('Symbol', 'uses');
|
|
44
|
+
const result = {};
|
|
45
|
+
result.url = this.parser.consume('String').value;
|
|
46
|
+
if (this.parser.peek()?.value === 'alias') {
|
|
47
|
+
this.parser.consume('Symbol', 'alias');
|
|
48
|
+
result.alias = this.parser.consume('Symbol').value;
|
|
49
|
+
}
|
|
50
|
+
this.parser.consume('Symbol', 'as');
|
|
51
|
+
result.mode = this.parser.consume().value;
|
|
52
|
+
if (!this.structureMap.structure) {
|
|
53
|
+
this.structureMap.structure = [];
|
|
54
|
+
}
|
|
55
|
+
this.structureMap.structure.push(result);
|
|
87
56
|
}
|
|
88
|
-
|
|
89
|
-
|
|
57
|
+
parseImport() {
|
|
58
|
+
this.parser.consume('Symbol', 'imports');
|
|
59
|
+
if (!this.structureMap.import) {
|
|
60
|
+
this.structureMap.import = [];
|
|
61
|
+
}
|
|
62
|
+
this.structureMap.import.push(this.parser.consume('String').value);
|
|
63
|
+
}
|
|
64
|
+
parseGroup() {
|
|
65
|
+
// 'group' identifier parameters extends? typeMode? rules
|
|
66
|
+
// group tutorial(source src : TLeft, target tgt : TRight) {
|
|
67
|
+
const result = {};
|
|
68
|
+
this.parser.consume('Symbol', 'group');
|
|
69
|
+
result.name = this.parser.consume('Symbol').value;
|
|
70
|
+
result.input = this.parseParameters();
|
|
71
|
+
if (this.parser.peek()?.value === 'extends') {
|
|
72
|
+
this.parser.consume('Symbol', 'extends');
|
|
73
|
+
result.extends = this.parser.consume('Symbol').value;
|
|
74
|
+
}
|
|
75
|
+
if (this.parser.peek()?.value === '<<') {
|
|
76
|
+
this.parser.consume('<<');
|
|
77
|
+
result.typeMode = this.parser.consume().value;
|
|
78
|
+
if (this.parser.peek()?.value === '+') {
|
|
79
|
+
this.parser.consume('+');
|
|
80
|
+
result.typeMode = 'type-and-types';
|
|
81
|
+
}
|
|
82
|
+
this.parser.consume('>>');
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
result.typeMode = 'none';
|
|
86
|
+
}
|
|
87
|
+
result.rule = this.parseRules();
|
|
88
|
+
if (!this.structureMap.group) {
|
|
89
|
+
this.structureMap.group = [];
|
|
90
|
+
}
|
|
91
|
+
this.structureMap.group.push(result);
|
|
92
|
+
}
|
|
93
|
+
parseParameters() {
|
|
94
|
+
const parameters = [];
|
|
95
|
+
this.parser.consume('(');
|
|
96
|
+
while (this.parser.hasMore() && this.parser.peek()?.value !== ')') {
|
|
97
|
+
parameters.push(this.parseParameter());
|
|
98
|
+
if (this.parser.peek()?.value === ',') {
|
|
99
|
+
this.parser.consume(',');
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
this.parser.consume(')');
|
|
103
|
+
return parameters;
|
|
104
|
+
}
|
|
105
|
+
parseParameter() {
|
|
106
|
+
// inputMode identifier type?
|
|
107
|
+
// ':' identifier
|
|
108
|
+
// source src : TLeft
|
|
109
|
+
const result = {};
|
|
110
|
+
result.mode = this.parser.consume().value;
|
|
111
|
+
result.name = this.parser.consume('Symbol').value;
|
|
112
|
+
if (this.parser.peek()?.value === ':') {
|
|
113
|
+
this.parser.consume(':');
|
|
114
|
+
result.type = this.parser.consume('Symbol').value;
|
|
115
|
+
}
|
|
116
|
+
return result;
|
|
90
117
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
this.
|
|
118
|
+
parseRules() {
|
|
119
|
+
const rules = [];
|
|
120
|
+
this.parser.consume('{');
|
|
121
|
+
while (this.parser.hasMore() && this.parser.peek()?.value !== '}') {
|
|
122
|
+
rules.push(this.parseRule());
|
|
123
|
+
}
|
|
124
|
+
this.parser.consume('}');
|
|
125
|
+
return rules;
|
|
126
|
+
}
|
|
127
|
+
parseRule() {
|
|
128
|
+
const result = {
|
|
129
|
+
source: this.parseRuleSources(),
|
|
130
|
+
};
|
|
131
|
+
if (this.parser.peek()?.value === '->') {
|
|
132
|
+
this.parser.consume('->');
|
|
133
|
+
result.target = this.parseRuleTargets();
|
|
134
|
+
}
|
|
135
|
+
if (this.parser.peek()?.value === 'then') {
|
|
136
|
+
this.parser.consume('Symbol', 'then');
|
|
137
|
+
if (this.parser.peek()?.id === '{') {
|
|
138
|
+
result.rule = this.parseRules();
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
result.dependent = this.parseRuleDependents();
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if (this.parser.peek()?.id === 'String') {
|
|
145
|
+
result.name = this.parser.consume().value;
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
result.name = result.source?.[0]?.element;
|
|
149
|
+
}
|
|
150
|
+
this.parser.consume(';');
|
|
151
|
+
return result;
|
|
94
152
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
this.parser.consume('(');
|
|
99
|
-
while (this.parser.hasMore() && this.parser.peek()?.value !== ')') {
|
|
100
|
-
parameters.push(__classPrivateFieldGet(this, _StructureMapParser_instances, "m", _StructureMapParser_parseParameter).call(this));
|
|
101
|
-
if (this.parser.peek()?.value === ',') {
|
|
153
|
+
parseRuleSources() {
|
|
154
|
+
const sources = [this.parseRuleSource()];
|
|
155
|
+
while (this.parser.hasMore() && this.parser.peek()?.value === ',') {
|
|
102
156
|
this.parser.consume(',');
|
|
157
|
+
sources.push(this.parseRuleSource());
|
|
103
158
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
result.name = this.parser.consume('Symbol').value;
|
|
114
|
-
if (this.parser.peek()?.value === ':') {
|
|
115
|
-
this.parser.consume(':');
|
|
116
|
-
result.type = this.parser.consume('Symbol').value;
|
|
117
|
-
}
|
|
118
|
-
return result;
|
|
119
|
-
}, _StructureMapParser_parseRules = function _StructureMapParser_parseRules() {
|
|
120
|
-
const rules = [];
|
|
121
|
-
this.parser.consume('{');
|
|
122
|
-
while (this.parser.hasMore() && this.parser.peek()?.value !== '}') {
|
|
123
|
-
rules.push(__classPrivateFieldGet(this, _StructureMapParser_instances, "m", _StructureMapParser_parseRule).call(this));
|
|
124
|
-
}
|
|
125
|
-
this.parser.consume('}');
|
|
126
|
-
return rules;
|
|
127
|
-
}, _StructureMapParser_parseRule = function _StructureMapParser_parseRule() {
|
|
128
|
-
const result = {
|
|
129
|
-
source: __classPrivateFieldGet(this, _StructureMapParser_instances, "m", _StructureMapParser_parseRuleSources).call(this),
|
|
130
|
-
};
|
|
131
|
-
if (this.parser.peek()?.value === '->') {
|
|
132
|
-
this.parser.consume('->');
|
|
133
|
-
result.target = __classPrivateFieldGet(this, _StructureMapParser_instances, "m", _StructureMapParser_parseRuleTargets).call(this);
|
|
134
|
-
}
|
|
135
|
-
if (this.parser.peek()?.value === 'then') {
|
|
136
|
-
this.parser.consume('Symbol', 'then');
|
|
137
|
-
if (this.parser.peek()?.id === '{') {
|
|
138
|
-
result.rule = __classPrivateFieldGet(this, _StructureMapParser_instances, "m", _StructureMapParser_parseRules).call(this);
|
|
159
|
+
return sources;
|
|
160
|
+
}
|
|
161
|
+
parseRuleSource() {
|
|
162
|
+
const result = {};
|
|
163
|
+
const context = this.parseRuleContext();
|
|
164
|
+
if (context.includes('.')) {
|
|
165
|
+
const parts = context.split('.');
|
|
166
|
+
result.context = parts[0];
|
|
167
|
+
result.element = parts[1];
|
|
139
168
|
}
|
|
140
169
|
else {
|
|
141
|
-
result.
|
|
170
|
+
result.context = context;
|
|
142
171
|
}
|
|
172
|
+
if (this.parser.hasMore() && this.parser.peek()?.value === ':') {
|
|
173
|
+
this.parser.consume(':');
|
|
174
|
+
result.type = this.parser.consume().value;
|
|
175
|
+
}
|
|
176
|
+
if (this.parser.hasMore() && this.parser.peek()?.value === 'default') {
|
|
177
|
+
this.parser.consume('default');
|
|
178
|
+
this.parser.consumeAndParse();
|
|
179
|
+
}
|
|
180
|
+
if (this.parser.peek()?.value === 'first' ||
|
|
181
|
+
this.parser.peek()?.value === 'not_first' ||
|
|
182
|
+
this.parser.peek()?.value === 'last' ||
|
|
183
|
+
this.parser.peek()?.value === 'not_last' ||
|
|
184
|
+
this.parser.peek()?.value === 'only_one') {
|
|
185
|
+
result.listMode = this.parser.consume().value;
|
|
186
|
+
}
|
|
187
|
+
if (this.parser.peek()?.value === 'as') {
|
|
188
|
+
this.parser.consume('Symbol', 'as');
|
|
189
|
+
result.variable = this.parser.consume().value;
|
|
190
|
+
}
|
|
191
|
+
if (this.parser.peek()?.value === 'where') {
|
|
192
|
+
this.parser.consume('Symbol', 'where');
|
|
193
|
+
const whereFhirPath = this.parser.consumeAndParse(100 /* OperatorPrecedence.Arrow */);
|
|
194
|
+
result.condition = whereFhirPath.toString();
|
|
195
|
+
}
|
|
196
|
+
if (this.parser.peek()?.value === 'check') {
|
|
197
|
+
this.parser.consume('Symbol', 'check');
|
|
198
|
+
const checkFhirPath = this.parser.consumeAndParse(100 /* OperatorPrecedence.Arrow */);
|
|
199
|
+
result.check = checkFhirPath.toString();
|
|
200
|
+
}
|
|
201
|
+
return result;
|
|
143
202
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
this.parser.peek()?.value === 'not_first' ||
|
|
180
|
-
this.parser.peek()?.value === 'last' ||
|
|
181
|
-
this.parser.peek()?.value === 'not_last' ||
|
|
182
|
-
this.parser.peek()?.value === 'only_one') {
|
|
183
|
-
result.listMode = this.parser.consume().value;
|
|
184
|
-
}
|
|
185
|
-
if (this.parser.peek()?.value === 'as') {
|
|
186
|
-
this.parser.consume('Symbol', 'as');
|
|
187
|
-
result.variable = this.parser.consume().value;
|
|
188
|
-
}
|
|
189
|
-
if (this.parser.peek()?.value === 'where') {
|
|
190
|
-
this.parser.consume('Symbol', 'where');
|
|
191
|
-
const whereFhirPath = this.parser.consumeAndParse(100 /* OperatorPrecedence.Arrow */);
|
|
192
|
-
result.condition = whereFhirPath.toString();
|
|
193
|
-
}
|
|
194
|
-
if (this.parser.peek()?.value === 'check') {
|
|
195
|
-
this.parser.consume('Symbol', 'check');
|
|
196
|
-
const checkFhirPath = this.parser.consumeAndParse(100 /* OperatorPrecedence.Arrow */);
|
|
197
|
-
result.check = checkFhirPath.toString();
|
|
198
|
-
}
|
|
199
|
-
return result;
|
|
200
|
-
}, _StructureMapParser_parseRuleTargets = function _StructureMapParser_parseRuleTargets() {
|
|
201
|
-
const targets = [__classPrivateFieldGet(this, _StructureMapParser_instances, "m", _StructureMapParser_parseRuleTarget).call(this)];
|
|
202
|
-
while (this.parser.hasMore() && this.parser.peek()?.value === ',') {
|
|
203
|
-
this.parser.consume(',');
|
|
204
|
-
targets.push(__classPrivateFieldGet(this, _StructureMapParser_instances, "m", _StructureMapParser_parseRuleTarget).call(this));
|
|
205
|
-
}
|
|
206
|
-
return targets;
|
|
207
|
-
}, _StructureMapParser_parseRuleTarget = function _StructureMapParser_parseRuleTarget() {
|
|
208
|
-
const result = {};
|
|
209
|
-
const context = __classPrivateFieldGet(this, _StructureMapParser_instances, "m", _StructureMapParser_parseRuleContext).call(this);
|
|
210
|
-
if (context.includes('.')) {
|
|
211
|
-
const parts = context.split('.');
|
|
212
|
-
result.contextType = 'variable';
|
|
213
|
-
result.context = parts[0];
|
|
214
|
-
result.element = parts[1];
|
|
215
|
-
}
|
|
216
|
-
else {
|
|
217
|
-
result.context = context;
|
|
218
|
-
}
|
|
219
|
-
if (this.parser.peek()?.value === '=') {
|
|
220
|
-
this.parser.consume('=');
|
|
221
|
-
__classPrivateFieldGet(this, _StructureMapParser_instances, "m", _StructureMapParser_parseRuleTargetTransform).call(this, result);
|
|
222
|
-
}
|
|
223
|
-
if (this.parser.peek()?.value === 'as') {
|
|
224
|
-
this.parser.consume('Symbol', 'as');
|
|
225
|
-
result.variable = this.parser.consume().value;
|
|
226
|
-
}
|
|
227
|
-
if (this.parser.peek()?.value === 'first' ||
|
|
228
|
-
this.parser.peek()?.value === 'share' ||
|
|
229
|
-
this.parser.peek()?.value === 'last' ||
|
|
230
|
-
this.parser.peek()?.value === 'collate') {
|
|
231
|
-
result.listMode = [this.parser.consume().value];
|
|
232
|
-
}
|
|
233
|
-
return result;
|
|
234
|
-
}, _StructureMapParser_parseRuleTargetTransform = function _StructureMapParser_parseRuleTargetTransform(result) {
|
|
235
|
-
result.transform = 'copy';
|
|
236
|
-
const transformFhirPath = this.parser.consumeAndParse(6 /* OperatorPrecedence.As */);
|
|
237
|
-
if (transformFhirPath instanceof SymbolAtom) {
|
|
238
|
-
__classPrivateFieldGet(this, _StructureMapParser_instances, "m", _StructureMapParser_parseRuleTargetSymbol).call(this, result, transformFhirPath);
|
|
239
|
-
}
|
|
240
|
-
else if (transformFhirPath instanceof FunctionAtom) {
|
|
241
|
-
__classPrivateFieldGet(this, _StructureMapParser_instances, "m", _StructureMapParser_parseRuleTargetFunction).call(this, result, transformFhirPath);
|
|
242
|
-
}
|
|
243
|
-
else if (transformFhirPath instanceof LiteralAtom) {
|
|
244
|
-
__classPrivateFieldGet(this, _StructureMapParser_instances, "m", _StructureMapParser_parseRuleTargetLiteral).call(this, result, transformFhirPath);
|
|
245
|
-
}
|
|
246
|
-
else {
|
|
247
|
-
throw new Error(`Unexpected FHIRPath: ${transformFhirPath}`);
|
|
203
|
+
parseRuleTargets() {
|
|
204
|
+
const targets = [this.parseRuleTarget()];
|
|
205
|
+
while (this.parser.hasMore() && this.parser.peek()?.value === ',') {
|
|
206
|
+
this.parser.consume(',');
|
|
207
|
+
targets.push(this.parseRuleTarget());
|
|
208
|
+
}
|
|
209
|
+
return targets;
|
|
210
|
+
}
|
|
211
|
+
parseRuleTarget() {
|
|
212
|
+
const result = {};
|
|
213
|
+
const context = this.parseRuleContext();
|
|
214
|
+
if (context.includes('.')) {
|
|
215
|
+
const parts = context.split('.');
|
|
216
|
+
result.contextType = 'variable';
|
|
217
|
+
result.context = parts[0];
|
|
218
|
+
result.element = parts[1];
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
result.context = context;
|
|
222
|
+
}
|
|
223
|
+
if (this.parser.peek()?.value === '=') {
|
|
224
|
+
this.parser.consume('=');
|
|
225
|
+
this.parseRuleTargetTransform(result);
|
|
226
|
+
}
|
|
227
|
+
if (this.parser.peek()?.value === 'as') {
|
|
228
|
+
this.parser.consume('Symbol', 'as');
|
|
229
|
+
result.variable = this.parser.consume().value;
|
|
230
|
+
}
|
|
231
|
+
if (this.parser.peek()?.value === 'first' ||
|
|
232
|
+
this.parser.peek()?.value === 'share' ||
|
|
233
|
+
this.parser.peek()?.value === 'last' ||
|
|
234
|
+
this.parser.peek()?.value === 'collate') {
|
|
235
|
+
result.listMode = [this.parser.consume().value];
|
|
236
|
+
}
|
|
237
|
+
return result;
|
|
248
238
|
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
default:
|
|
265
|
-
throw new Error('Unknown target function: ' + functionName);
|
|
239
|
+
parseRuleTargetTransform(result) {
|
|
240
|
+
result.transform = 'copy';
|
|
241
|
+
const transformFhirPath = this.parser.consumeAndParse(6 /* OperatorPrecedence.As */);
|
|
242
|
+
if (transformFhirPath instanceof SymbolAtom) {
|
|
243
|
+
this.parseRuleTargetSymbol(result, transformFhirPath);
|
|
244
|
+
}
|
|
245
|
+
else if (transformFhirPath instanceof FunctionAtom) {
|
|
246
|
+
this.parseRuleTargetFunction(result, transformFhirPath);
|
|
247
|
+
}
|
|
248
|
+
else if (transformFhirPath instanceof LiteralAtom) {
|
|
249
|
+
this.parseRuleTargetLiteral(result, transformFhirPath);
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
throw new Error(`Unexpected FHIRPath: ${transformFhirPath}`);
|
|
253
|
+
}
|
|
266
254
|
}
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
255
|
+
parseRuleTargetSymbol(result, literalAtom) {
|
|
256
|
+
result.parameter = [{ valueId: literalAtom.name }];
|
|
257
|
+
}
|
|
258
|
+
parseRuleTargetFunction(result, functionAtom) {
|
|
259
|
+
const functionName = functionAtom.name;
|
|
260
|
+
switch (functionName) {
|
|
261
|
+
case 'create':
|
|
262
|
+
result.parameter = [
|
|
263
|
+
{
|
|
264
|
+
valueString: (functionAtom.args?.[0]).value.value,
|
|
265
|
+
},
|
|
266
|
+
];
|
|
267
|
+
break;
|
|
268
|
+
case 'translate':
|
|
269
|
+
result.parameter = [{}];
|
|
270
|
+
break;
|
|
271
|
+
default:
|
|
272
|
+
throw new Error('Unknown target function: ' + functionName);
|
|
273
|
+
}
|
|
280
274
|
}
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
275
|
+
parseRuleTargetLiteral(result, literalAtom) {
|
|
276
|
+
switch (literalAtom.value.type) {
|
|
277
|
+
case 'boolean':
|
|
278
|
+
result.parameter = [{ valueBoolean: literalAtom.value.value }];
|
|
279
|
+
break;
|
|
280
|
+
case 'decimal':
|
|
281
|
+
result.parameter = [{ valueDecimal: literalAtom.value.value }];
|
|
282
|
+
break;
|
|
283
|
+
case 'string':
|
|
284
|
+
result.parameter = [{ valueString: literalAtom.value.value }];
|
|
285
|
+
break;
|
|
286
|
+
default:
|
|
287
|
+
throw new Error('Unknown target literal type: ' + literalAtom.value.type);
|
|
288
|
+
}
|
|
286
289
|
}
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
290
|
+
parseRuleContext() {
|
|
291
|
+
let identifier = this.parser.consume().value;
|
|
292
|
+
while (this.parser.peek()?.value === '.') {
|
|
293
|
+
this.parser.consume('.');
|
|
294
|
+
identifier += '.' + this.parser.consume().value;
|
|
295
|
+
}
|
|
296
|
+
return identifier;
|
|
297
|
+
}
|
|
298
|
+
parseRuleDependents() {
|
|
299
|
+
const atom = this.parser.consumeAndParse(100 /* OperatorPrecedence.Arrow */);
|
|
300
|
+
return [
|
|
301
|
+
{
|
|
302
|
+
name: atom.name,
|
|
303
|
+
variable: atom.args.map((arg) => arg.name),
|
|
304
|
+
},
|
|
305
|
+
];
|
|
306
|
+
}
|
|
307
|
+
parseConceptMap() {
|
|
308
|
+
while (this.parser.peek()?.value !== '}') {
|
|
309
|
+
this.parser.consume();
|
|
310
|
+
}
|
|
311
|
+
this.parser.consume('}');
|
|
299
312
|
}
|
|
300
|
-
|
|
301
|
-
};
|
|
313
|
+
}
|
|
302
314
|
const fhirPathParserBuilder = initFhirPathParserBuilder()
|
|
303
315
|
.registerInfix('->', { precedence: 100 /* OperatorPrecedence.Arrow */ })
|
|
304
316
|
.registerInfix(';', { precedence: 200 /* OperatorPrecedence.Semicolon */ });
|