ezmedicationinput 0.1.44 → 0.1.45
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/index.cjs +18842 -0
- package/dist/index.js +18689 -675
- package/package.json +17 -6
- package/dist/advice-rules.json +0 -772
- package/dist/advice-terminology.json +0 -104
- package/dist/advice.js +0 -1375
- package/dist/context.js +0 -50
- package/dist/event-trigger.d.ts +0 -14
- package/dist/event-trigger.js +0 -501
- package/dist/fhir-translations.js +0 -117
- package/dist/fhir.js +0 -693
- package/dist/format.js +0 -1034
- package/dist/i18n.js +0 -1341
- package/dist/internal-types.d.ts +0 -60
- package/dist/internal-types.js +0 -2
- package/dist/ir.js +0 -178
- package/dist/lexer/lex.js +0 -401
- package/dist/lexer/meaning.js +0 -619
- package/dist/lexer/surface.js +0 -62
- package/dist/lexer/token-types.js +0 -19
- package/dist/maps.js +0 -2226
- package/dist/package.json +0 -3
- package/dist/parser-state.js +0 -441
- package/dist/parser.js +0 -5631
- package/dist/prn.js +0 -59
- package/dist/safety.js +0 -15
- package/dist/schedule.js +0 -1636
- package/dist/segment.js +0 -203
- package/dist/site-phrases.js +0 -344
- package/dist/suggest.js +0 -907
- package/dist/timing-summary.js +0 -138
- package/dist/types.js +0 -276
- package/dist/utils/array.js +0 -11
- package/dist/utils/enum.d.ts +0 -2
- package/dist/utils/enum.js +0 -7
- package/dist/utils/object.js +0 -34
- package/dist/utils/strength.js +0 -149
- package/dist/utils/text.js +0 -48
- package/dist/utils/units.js +0 -82
package/dist/package.json
DELETED
package/dist/parser-state.js
DELETED
|
@@ -1,441 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ParserState = void 0;
|
|
4
|
-
const fhir_translations_1 = require("./fhir-translations");
|
|
5
|
-
class ParserState {
|
|
6
|
-
constructor(input, tokens, customSiteHints) {
|
|
7
|
-
const dayOfWeek = [];
|
|
8
|
-
const when = [];
|
|
9
|
-
this.clause = {
|
|
10
|
-
kind: "administration",
|
|
11
|
-
rawText: input,
|
|
12
|
-
raw: {
|
|
13
|
-
start: 0,
|
|
14
|
-
end: input.length,
|
|
15
|
-
text: input
|
|
16
|
-
},
|
|
17
|
-
schedule: {
|
|
18
|
-
dayOfWeek,
|
|
19
|
-
when
|
|
20
|
-
},
|
|
21
|
-
leftovers: [],
|
|
22
|
-
evidence: [],
|
|
23
|
-
confidence: 1
|
|
24
|
-
};
|
|
25
|
-
this.input = input;
|
|
26
|
-
this.tokens = tokens;
|
|
27
|
-
this.consumed = new Set();
|
|
28
|
-
this.warnings = [];
|
|
29
|
-
this.siteTokenIndices = new Set();
|
|
30
|
-
this.siteLookups = [];
|
|
31
|
-
this.customSiteHints = customSiteHints;
|
|
32
|
-
this.prnReasonLookups = [];
|
|
33
|
-
this.clauses = [this.clause];
|
|
34
|
-
}
|
|
35
|
-
get primaryClause() {
|
|
36
|
-
return this.clause;
|
|
37
|
-
}
|
|
38
|
-
get dose() {
|
|
39
|
-
var _a;
|
|
40
|
-
return (_a = this.clause.dose) === null || _a === void 0 ? void 0 : _a.value;
|
|
41
|
-
}
|
|
42
|
-
set dose(value) {
|
|
43
|
-
this.ensureDose().value = value;
|
|
44
|
-
}
|
|
45
|
-
get doseRange() {
|
|
46
|
-
var _a;
|
|
47
|
-
return (_a = this.clause.dose) === null || _a === void 0 ? void 0 : _a.range;
|
|
48
|
-
}
|
|
49
|
-
set doseRange(value) {
|
|
50
|
-
this.ensureDose().range = value;
|
|
51
|
-
}
|
|
52
|
-
get unit() {
|
|
53
|
-
var _a;
|
|
54
|
-
return (_a = this.clause.dose) === null || _a === void 0 ? void 0 : _a.unit;
|
|
55
|
-
}
|
|
56
|
-
set unit(value) {
|
|
57
|
-
this.ensureDose().unit = value;
|
|
58
|
-
}
|
|
59
|
-
get routeCode() {
|
|
60
|
-
var _a;
|
|
61
|
-
return (_a = this.clause.route) === null || _a === void 0 ? void 0 : _a.code;
|
|
62
|
-
}
|
|
63
|
-
set routeCode(value) {
|
|
64
|
-
this.ensureRoute().code = value;
|
|
65
|
-
}
|
|
66
|
-
get routeText() {
|
|
67
|
-
var _a;
|
|
68
|
-
return (_a = this.clause.route) === null || _a === void 0 ? void 0 : _a.text;
|
|
69
|
-
}
|
|
70
|
-
set routeText(value) {
|
|
71
|
-
this.ensureRoute().text = value;
|
|
72
|
-
}
|
|
73
|
-
get methodText() {
|
|
74
|
-
var _a;
|
|
75
|
-
return (_a = this.clause.method) === null || _a === void 0 ? void 0 : _a.text;
|
|
76
|
-
}
|
|
77
|
-
set methodText(value) {
|
|
78
|
-
if (value === undefined) {
|
|
79
|
-
if (this.clause.method) {
|
|
80
|
-
delete this.clause.method.text;
|
|
81
|
-
this.cleanupMethod();
|
|
82
|
-
}
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
this.ensureMethod().text = value;
|
|
86
|
-
}
|
|
87
|
-
get methodTextElement() {
|
|
88
|
-
var _a;
|
|
89
|
-
return (_a = this.clause.method) === null || _a === void 0 ? void 0 : _a._text;
|
|
90
|
-
}
|
|
91
|
-
set methodTextElement(value) {
|
|
92
|
-
if (value === undefined) {
|
|
93
|
-
if (this.clause.method) {
|
|
94
|
-
delete this.clause.method._text;
|
|
95
|
-
this.cleanupMethod();
|
|
96
|
-
}
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
this.ensureMethod()._text = (0, fhir_translations_1.clonePrimitiveElement)(value);
|
|
100
|
-
}
|
|
101
|
-
get methodCoding() {
|
|
102
|
-
var _a;
|
|
103
|
-
return (_a = this.clause.method) === null || _a === void 0 ? void 0 : _a.coding;
|
|
104
|
-
}
|
|
105
|
-
set methodCoding(value) {
|
|
106
|
-
if (value === undefined) {
|
|
107
|
-
if (this.clause.method) {
|
|
108
|
-
delete this.clause.method.coding;
|
|
109
|
-
this.cleanupMethod();
|
|
110
|
-
}
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
this.ensureMethod().coding = (value === null || value === void 0 ? void 0 : value.code)
|
|
114
|
-
? {
|
|
115
|
-
code: value.code,
|
|
116
|
-
display: value.display,
|
|
117
|
-
system: value.system,
|
|
118
|
-
_display: (0, fhir_translations_1.clonePrimitiveElement)(value._display),
|
|
119
|
-
i18n: value.i18n
|
|
120
|
-
}
|
|
121
|
-
: undefined;
|
|
122
|
-
}
|
|
123
|
-
get count() {
|
|
124
|
-
var _a;
|
|
125
|
-
return (_a = this.clause.schedule) === null || _a === void 0 ? void 0 : _a.count;
|
|
126
|
-
}
|
|
127
|
-
set count(value) {
|
|
128
|
-
this.ensureSchedule().count = value;
|
|
129
|
-
}
|
|
130
|
-
get duration() {
|
|
131
|
-
var _a;
|
|
132
|
-
return (_a = this.clause.schedule) === null || _a === void 0 ? void 0 : _a.duration;
|
|
133
|
-
}
|
|
134
|
-
set duration(value) {
|
|
135
|
-
this.ensureSchedule().duration = value;
|
|
136
|
-
}
|
|
137
|
-
get durationMax() {
|
|
138
|
-
var _a;
|
|
139
|
-
return (_a = this.clause.schedule) === null || _a === void 0 ? void 0 : _a.durationMax;
|
|
140
|
-
}
|
|
141
|
-
set durationMax(value) {
|
|
142
|
-
this.ensureSchedule().durationMax = value;
|
|
143
|
-
}
|
|
144
|
-
get durationUnit() {
|
|
145
|
-
var _a;
|
|
146
|
-
return (_a = this.clause.schedule) === null || _a === void 0 ? void 0 : _a.durationUnit;
|
|
147
|
-
}
|
|
148
|
-
set durationUnit(value) {
|
|
149
|
-
this.ensureSchedule().durationUnit = value;
|
|
150
|
-
}
|
|
151
|
-
get frequency() {
|
|
152
|
-
var _a;
|
|
153
|
-
return (_a = this.clause.schedule) === null || _a === void 0 ? void 0 : _a.frequency;
|
|
154
|
-
}
|
|
155
|
-
set frequency(value) {
|
|
156
|
-
this.ensureSchedule().frequency = value;
|
|
157
|
-
}
|
|
158
|
-
get frequencyMax() {
|
|
159
|
-
var _a;
|
|
160
|
-
return (_a = this.clause.schedule) === null || _a === void 0 ? void 0 : _a.frequencyMax;
|
|
161
|
-
}
|
|
162
|
-
set frequencyMax(value) {
|
|
163
|
-
this.ensureSchedule().frequencyMax = value;
|
|
164
|
-
}
|
|
165
|
-
get period() {
|
|
166
|
-
var _a;
|
|
167
|
-
return (_a = this.clause.schedule) === null || _a === void 0 ? void 0 : _a.period;
|
|
168
|
-
}
|
|
169
|
-
set period(value) {
|
|
170
|
-
this.ensureSchedule().period = value;
|
|
171
|
-
}
|
|
172
|
-
get periodMax() {
|
|
173
|
-
var _a;
|
|
174
|
-
return (_a = this.clause.schedule) === null || _a === void 0 ? void 0 : _a.periodMax;
|
|
175
|
-
}
|
|
176
|
-
set periodMax(value) {
|
|
177
|
-
this.ensureSchedule().periodMax = value;
|
|
178
|
-
}
|
|
179
|
-
get periodUnit() {
|
|
180
|
-
var _a;
|
|
181
|
-
return (_a = this.clause.schedule) === null || _a === void 0 ? void 0 : _a.periodUnit;
|
|
182
|
-
}
|
|
183
|
-
set periodUnit(value) {
|
|
184
|
-
this.ensureSchedule().periodUnit = value;
|
|
185
|
-
}
|
|
186
|
-
get dayOfWeek() {
|
|
187
|
-
const schedule = this.ensureSchedule();
|
|
188
|
-
if (!schedule.dayOfWeek) {
|
|
189
|
-
schedule.dayOfWeek = [];
|
|
190
|
-
}
|
|
191
|
-
return schedule.dayOfWeek;
|
|
192
|
-
}
|
|
193
|
-
get when() {
|
|
194
|
-
const schedule = this.ensureSchedule();
|
|
195
|
-
if (!schedule.when) {
|
|
196
|
-
schedule.when = [];
|
|
197
|
-
}
|
|
198
|
-
return schedule.when;
|
|
199
|
-
}
|
|
200
|
-
get timeOfDay() {
|
|
201
|
-
var _a;
|
|
202
|
-
return (_a = this.clause.schedule) === null || _a === void 0 ? void 0 : _a.timeOfDay;
|
|
203
|
-
}
|
|
204
|
-
set timeOfDay(value) {
|
|
205
|
-
this.ensureSchedule().timeOfDay = value;
|
|
206
|
-
}
|
|
207
|
-
get timingCode() {
|
|
208
|
-
var _a;
|
|
209
|
-
return (_a = this.clause.schedule) === null || _a === void 0 ? void 0 : _a.timingCode;
|
|
210
|
-
}
|
|
211
|
-
set timingCode(value) {
|
|
212
|
-
this.ensureSchedule().timingCode = value;
|
|
213
|
-
}
|
|
214
|
-
get asNeeded() {
|
|
215
|
-
var _a;
|
|
216
|
-
return (_a = this.clause.prn) === null || _a === void 0 ? void 0 : _a.enabled;
|
|
217
|
-
}
|
|
218
|
-
set asNeeded(value) {
|
|
219
|
-
if (value === undefined) {
|
|
220
|
-
delete this.clause.prn;
|
|
221
|
-
return;
|
|
222
|
-
}
|
|
223
|
-
this.ensurePrn().enabled = value;
|
|
224
|
-
}
|
|
225
|
-
get asNeededReason() {
|
|
226
|
-
var _a, _b;
|
|
227
|
-
return (_b = (_a = this.clause.prn) === null || _a === void 0 ? void 0 : _a.reason) === null || _b === void 0 ? void 0 : _b.text;
|
|
228
|
-
}
|
|
229
|
-
set asNeededReason(value) {
|
|
230
|
-
var _a, _b;
|
|
231
|
-
if (value === undefined) {
|
|
232
|
-
if ((_a = this.clause.prn) === null || _a === void 0 ? void 0 : _a.reason) {
|
|
233
|
-
delete this.clause.prn.reason.text;
|
|
234
|
-
this.cleanupPrn();
|
|
235
|
-
}
|
|
236
|
-
return;
|
|
237
|
-
}
|
|
238
|
-
const prn = (_b = this.clause.prn) !== null && _b !== void 0 ? _b : (this.clause.prn = { enabled: true });
|
|
239
|
-
if (prn.enabled === undefined) {
|
|
240
|
-
prn.enabled = true;
|
|
241
|
-
}
|
|
242
|
-
if (!prn.reason) {
|
|
243
|
-
prn.reason = {};
|
|
244
|
-
}
|
|
245
|
-
prn.reason.text = value;
|
|
246
|
-
}
|
|
247
|
-
get asNeededReasons() {
|
|
248
|
-
var _a;
|
|
249
|
-
return (_a = this.clause.prn) === null || _a === void 0 ? void 0 : _a.reasons;
|
|
250
|
-
}
|
|
251
|
-
set asNeededReasons(value) {
|
|
252
|
-
var _a, _b;
|
|
253
|
-
if (!value || !value.length) {
|
|
254
|
-
if ((_a = this.clause.prn) === null || _a === void 0 ? void 0 : _a.reasons) {
|
|
255
|
-
delete this.clause.prn.reasons;
|
|
256
|
-
this.cleanupPrn();
|
|
257
|
-
}
|
|
258
|
-
return;
|
|
259
|
-
}
|
|
260
|
-
const prn = (_b = this.clause.prn) !== null && _b !== void 0 ? _b : (this.clause.prn = { enabled: true });
|
|
261
|
-
if (prn.enabled === undefined) {
|
|
262
|
-
prn.enabled = true;
|
|
263
|
-
}
|
|
264
|
-
const reasons = [];
|
|
265
|
-
for (const reason of value) {
|
|
266
|
-
reasons.push({
|
|
267
|
-
text: reason.text,
|
|
268
|
-
coding: reason.coding
|
|
269
|
-
? {
|
|
270
|
-
code: reason.coding.code,
|
|
271
|
-
display: reason.coding.display,
|
|
272
|
-
system: reason.coding.system,
|
|
273
|
-
_display: (0, fhir_translations_1.clonePrimitiveElement)(reason.coding._display),
|
|
274
|
-
i18n: reason.coding.i18n
|
|
275
|
-
}
|
|
276
|
-
: undefined
|
|
277
|
-
});
|
|
278
|
-
}
|
|
279
|
-
prn.reasons = reasons;
|
|
280
|
-
}
|
|
281
|
-
get asNeededReasonCoding() {
|
|
282
|
-
var _a, _b;
|
|
283
|
-
return (_b = (_a = this.clause.prn) === null || _a === void 0 ? void 0 : _a.reason) === null || _b === void 0 ? void 0 : _b.coding;
|
|
284
|
-
}
|
|
285
|
-
set asNeededReasonCoding(value) {
|
|
286
|
-
var _a, _b;
|
|
287
|
-
if (value === undefined) {
|
|
288
|
-
if ((_a = this.clause.prn) === null || _a === void 0 ? void 0 : _a.reason) {
|
|
289
|
-
delete this.clause.prn.reason.coding;
|
|
290
|
-
this.cleanupPrn();
|
|
291
|
-
}
|
|
292
|
-
return;
|
|
293
|
-
}
|
|
294
|
-
const prn = (_b = this.clause.prn) !== null && _b !== void 0 ? _b : (this.clause.prn = { enabled: true });
|
|
295
|
-
if (prn.enabled === undefined) {
|
|
296
|
-
prn.enabled = true;
|
|
297
|
-
}
|
|
298
|
-
if (!prn.reason) {
|
|
299
|
-
prn.reason = {};
|
|
300
|
-
}
|
|
301
|
-
prn.reason.coding = (value === null || value === void 0 ? void 0 : value.code)
|
|
302
|
-
? {
|
|
303
|
-
code: value.code,
|
|
304
|
-
display: value.display,
|
|
305
|
-
system: value.system,
|
|
306
|
-
_display: (0, fhir_translations_1.clonePrimitiveElement)(value._display),
|
|
307
|
-
i18n: value.i18n
|
|
308
|
-
}
|
|
309
|
-
: undefined;
|
|
310
|
-
}
|
|
311
|
-
get siteText() {
|
|
312
|
-
var _a;
|
|
313
|
-
return (_a = this.clause.site) === null || _a === void 0 ? void 0 : _a.text;
|
|
314
|
-
}
|
|
315
|
-
set siteText(value) {
|
|
316
|
-
this.ensureSite().text = value;
|
|
317
|
-
}
|
|
318
|
-
get siteSource() {
|
|
319
|
-
var _a;
|
|
320
|
-
return (_a = this.clause.site) === null || _a === void 0 ? void 0 : _a.source;
|
|
321
|
-
}
|
|
322
|
-
set siteSource(value) {
|
|
323
|
-
this.ensureSite().source = value;
|
|
324
|
-
}
|
|
325
|
-
get siteCoding() {
|
|
326
|
-
var _a;
|
|
327
|
-
return (_a = this.clause.site) === null || _a === void 0 ? void 0 : _a.coding;
|
|
328
|
-
}
|
|
329
|
-
set siteCoding(value) {
|
|
330
|
-
if (value === undefined) {
|
|
331
|
-
if (this.clause.site) {
|
|
332
|
-
delete this.clause.site.coding;
|
|
333
|
-
this.cleanupSite();
|
|
334
|
-
}
|
|
335
|
-
return;
|
|
336
|
-
}
|
|
337
|
-
this.ensureSite().coding = (value === null || value === void 0 ? void 0 : value.code)
|
|
338
|
-
? {
|
|
339
|
-
code: value.code,
|
|
340
|
-
display: value.display,
|
|
341
|
-
system: value.system,
|
|
342
|
-
i18n: value.i18n
|
|
343
|
-
}
|
|
344
|
-
: undefined;
|
|
345
|
-
}
|
|
346
|
-
get additionalInstructions() {
|
|
347
|
-
if (!this.clause.additionalInstructions) {
|
|
348
|
-
this.clause.additionalInstructions = [];
|
|
349
|
-
}
|
|
350
|
-
return this.clause.additionalInstructions;
|
|
351
|
-
}
|
|
352
|
-
set additionalInstructions(value) {
|
|
353
|
-
this.clause.additionalInstructions = value;
|
|
354
|
-
}
|
|
355
|
-
get patientInstruction() {
|
|
356
|
-
return this.clause.patientInstruction;
|
|
357
|
-
}
|
|
358
|
-
set patientInstruction(value) {
|
|
359
|
-
this.clause.patientInstruction = value;
|
|
360
|
-
}
|
|
361
|
-
ensureDose() {
|
|
362
|
-
if (!this.clause.dose) {
|
|
363
|
-
this.clause.dose = {};
|
|
364
|
-
}
|
|
365
|
-
return this.clause.dose;
|
|
366
|
-
}
|
|
367
|
-
ensureRoute() {
|
|
368
|
-
if (!this.clause.route) {
|
|
369
|
-
this.clause.route = {};
|
|
370
|
-
}
|
|
371
|
-
return this.clause.route;
|
|
372
|
-
}
|
|
373
|
-
ensureSite() {
|
|
374
|
-
if (!this.clause.site) {
|
|
375
|
-
this.clause.site = {};
|
|
376
|
-
}
|
|
377
|
-
return this.clause.site;
|
|
378
|
-
}
|
|
379
|
-
ensureMethod() {
|
|
380
|
-
if (!this.clause.method) {
|
|
381
|
-
this.clause.method = {};
|
|
382
|
-
}
|
|
383
|
-
return this.clause.method;
|
|
384
|
-
}
|
|
385
|
-
ensureSchedule() {
|
|
386
|
-
if (!this.clause.schedule) {
|
|
387
|
-
this.clause.schedule = {};
|
|
388
|
-
}
|
|
389
|
-
return this.clause.schedule;
|
|
390
|
-
}
|
|
391
|
-
ensurePrn() {
|
|
392
|
-
if (!this.clause.prn) {
|
|
393
|
-
this.clause.prn = { enabled: false };
|
|
394
|
-
}
|
|
395
|
-
return this.clause.prn;
|
|
396
|
-
}
|
|
397
|
-
cleanupPrn() {
|
|
398
|
-
var _a;
|
|
399
|
-
const prn = this.clause.prn;
|
|
400
|
-
if (!prn) {
|
|
401
|
-
return;
|
|
402
|
-
}
|
|
403
|
-
if (prn.reason &&
|
|
404
|
-
prn.reason.text === undefined &&
|
|
405
|
-
prn.reason.coding === undefined) {
|
|
406
|
-
delete prn.reason;
|
|
407
|
-
}
|
|
408
|
-
if (((_a = prn.reasons) === null || _a === void 0 ? void 0 : _a.length) === 0) {
|
|
409
|
-
delete prn.reasons;
|
|
410
|
-
}
|
|
411
|
-
if (prn.enabled === undefined && prn.reason === undefined && prn.reasons === undefined) {
|
|
412
|
-
delete this.clause.prn;
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
cleanupSite() {
|
|
416
|
-
const site = this.clause.site;
|
|
417
|
-
if (!site) {
|
|
418
|
-
return;
|
|
419
|
-
}
|
|
420
|
-
if (site.text === undefined &&
|
|
421
|
-
site.coding === undefined &&
|
|
422
|
-
site.source === undefined &&
|
|
423
|
-
site.inferred === undefined &&
|
|
424
|
-
site.evidence === undefined) {
|
|
425
|
-
delete this.clause.site;
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
cleanupMethod() {
|
|
429
|
-
const method = this.clause.method;
|
|
430
|
-
if (!method) {
|
|
431
|
-
return;
|
|
432
|
-
}
|
|
433
|
-
if (method.text === undefined &&
|
|
434
|
-
method._text === undefined &&
|
|
435
|
-
method.coding === undefined &&
|
|
436
|
-
method.evidence === undefined) {
|
|
437
|
-
delete this.clause.method;
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
exports.ParserState = ParserState;
|