ezmedicationinput 0.1.42 → 0.1.44
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/README.md +31 -1
- package/dist/advice-rules.json +772 -0
- package/dist/advice-terminology.json +104 -0
- package/dist/advice.d.ts +16 -0
- package/dist/advice.js +1375 -0
- package/dist/event-trigger.d.ts +14 -0
- package/dist/event-trigger.js +501 -0
- package/dist/fhir-translations.d.ts +5 -0
- package/dist/fhir-translations.js +117 -0
- package/dist/fhir.d.ts +6 -4
- package/dist/fhir.js +566 -134
- package/dist/format.d.ts +5 -2
- package/dist/format.js +581 -219
- package/dist/i18n.d.ts +4 -2
- package/dist/i18n.js +725 -197
- package/dist/index.d.ts +0 -1
- package/dist/index.js +221 -169
- package/dist/internal-types.d.ts +5 -5
- package/dist/ir.d.ts +4 -0
- package/dist/ir.js +178 -0
- package/dist/lexer/lex.d.ts +2 -0
- package/dist/lexer/lex.js +401 -0
- package/dist/lexer/meaning.d.ts +71 -0
- package/dist/lexer/meaning.js +619 -0
- package/dist/lexer/surface.d.ts +2 -0
- package/dist/lexer/surface.js +62 -0
- package/dist/lexer/token-types.d.ts +36 -0
- package/dist/lexer/token-types.js +19 -0
- package/dist/maps.d.ts +6 -12
- package/dist/maps.js +793 -247
- package/dist/parser-state.d.ts +101 -0
- package/dist/parser-state.js +441 -0
- package/dist/parser.d.ts +7 -7
- package/dist/parser.js +3598 -1974
- package/dist/prn.d.ts +4 -0
- package/dist/prn.js +59 -0
- package/dist/schedule.js +230 -32
- package/dist/site-phrases.d.ts +35 -0
- package/dist/site-phrases.js +344 -0
- package/dist/timing-summary.d.ts +25 -0
- package/dist/timing-summary.js +138 -0
- package/dist/types.d.ts +248 -32
- package/dist/types.js +49 -1
- package/dist/utils/text.d.ts +3 -0
- package/dist/utils/text.js +48 -0
- package/package.json +1 -1
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { AnnotatedLexToken } from "./lexer/meaning";
|
|
2
|
+
import { CanonicalAdditionalInstructionExpr, CanonicalDoseRange, CanonicalPrnReasonExpr, CanonicalSigClause, EventTiming, FhirCoding, FhirDayOfWeek, FhirPrimitiveElement, FhirPeriodUnit, PrnReasonLookupRequest, PrnReasonSuggestion, RouteCode, SiteCodeLookupRequest, SiteCodeSuggestion } from "./types";
|
|
3
|
+
export interface SiteLookupDetail {
|
|
4
|
+
request: SiteCodeLookupRequest;
|
|
5
|
+
suggestions: SiteCodeSuggestion[];
|
|
6
|
+
}
|
|
7
|
+
export interface PrnReasonLookupDetail {
|
|
8
|
+
request: PrnReasonLookupRequest;
|
|
9
|
+
suggestions: PrnReasonSuggestion[];
|
|
10
|
+
}
|
|
11
|
+
export interface Token extends AnnotatedLexToken {
|
|
12
|
+
}
|
|
13
|
+
type LocalizedCoding = FhirCoding & {
|
|
14
|
+
i18n?: Record<string, string>;
|
|
15
|
+
};
|
|
16
|
+
export declare class ParserState {
|
|
17
|
+
input: string;
|
|
18
|
+
tokens: Token[];
|
|
19
|
+
consumed: Set<number>;
|
|
20
|
+
warnings: string[];
|
|
21
|
+
siteTokenIndices: Set<number>;
|
|
22
|
+
siteLookupRequest?: SiteCodeLookupRequest;
|
|
23
|
+
siteLookups: SiteLookupDetail[];
|
|
24
|
+
customSiteHints?: Set<string>;
|
|
25
|
+
prnReasonLookupRequest?: PrnReasonLookupRequest;
|
|
26
|
+
prnReasonLookups: PrnReasonLookupDetail[];
|
|
27
|
+
methodVerb?: string;
|
|
28
|
+
productFormKey?: string;
|
|
29
|
+
clauses: CanonicalSigClause[];
|
|
30
|
+
private clause;
|
|
31
|
+
constructor(input: string, tokens: Token[], customSiteHints?: Set<string>);
|
|
32
|
+
get primaryClause(): CanonicalSigClause;
|
|
33
|
+
get dose(): number | undefined;
|
|
34
|
+
set dose(value: number | undefined);
|
|
35
|
+
get doseRange(): CanonicalDoseRange | undefined;
|
|
36
|
+
set doseRange(value: CanonicalDoseRange | undefined);
|
|
37
|
+
get unit(): string | undefined;
|
|
38
|
+
set unit(value: string | undefined);
|
|
39
|
+
get routeCode(): RouteCode | undefined;
|
|
40
|
+
set routeCode(value: RouteCode | undefined);
|
|
41
|
+
get routeText(): string | undefined;
|
|
42
|
+
set routeText(value: string | undefined);
|
|
43
|
+
get methodText(): string | undefined;
|
|
44
|
+
set methodText(value: string | undefined);
|
|
45
|
+
get methodTextElement(): FhirPrimitiveElement | undefined;
|
|
46
|
+
set methodTextElement(value: FhirPrimitiveElement | undefined);
|
|
47
|
+
get methodCoding(): LocalizedCoding | undefined;
|
|
48
|
+
set methodCoding(value: LocalizedCoding | undefined);
|
|
49
|
+
get count(): number | undefined;
|
|
50
|
+
set count(value: number | undefined);
|
|
51
|
+
get duration(): number | undefined;
|
|
52
|
+
set duration(value: number | undefined);
|
|
53
|
+
get durationMax(): number | undefined;
|
|
54
|
+
set durationMax(value: number | undefined);
|
|
55
|
+
get durationUnit(): FhirPeriodUnit | undefined;
|
|
56
|
+
set durationUnit(value: FhirPeriodUnit | undefined);
|
|
57
|
+
get frequency(): number | undefined;
|
|
58
|
+
set frequency(value: number | undefined);
|
|
59
|
+
get frequencyMax(): number | undefined;
|
|
60
|
+
set frequencyMax(value: number | undefined);
|
|
61
|
+
get period(): number | undefined;
|
|
62
|
+
set period(value: number | undefined);
|
|
63
|
+
get periodMax(): number | undefined;
|
|
64
|
+
set periodMax(value: number | undefined);
|
|
65
|
+
get periodUnit(): FhirPeriodUnit | undefined;
|
|
66
|
+
set periodUnit(value: FhirPeriodUnit | undefined);
|
|
67
|
+
get dayOfWeek(): FhirDayOfWeek[];
|
|
68
|
+
get when(): EventTiming[];
|
|
69
|
+
get timeOfDay(): string[] | undefined;
|
|
70
|
+
set timeOfDay(value: string[] | undefined);
|
|
71
|
+
get timingCode(): string | undefined;
|
|
72
|
+
set timingCode(value: string | undefined);
|
|
73
|
+
get asNeeded(): boolean | undefined;
|
|
74
|
+
set asNeeded(value: boolean | undefined);
|
|
75
|
+
get asNeededReason(): string | undefined;
|
|
76
|
+
set asNeededReason(value: string | undefined);
|
|
77
|
+
get asNeededReasons(): CanonicalPrnReasonExpr[] | undefined;
|
|
78
|
+
set asNeededReasons(value: CanonicalPrnReasonExpr[] | undefined);
|
|
79
|
+
get asNeededReasonCoding(): LocalizedCoding | undefined;
|
|
80
|
+
set asNeededReasonCoding(value: LocalizedCoding | undefined);
|
|
81
|
+
get siteText(): string | undefined;
|
|
82
|
+
set siteText(value: string | undefined);
|
|
83
|
+
get siteSource(): "abbreviation" | "text" | "selection" | "resolver" | undefined;
|
|
84
|
+
set siteSource(value: "abbreviation" | "text" | "selection" | "resolver" | undefined);
|
|
85
|
+
get siteCoding(): LocalizedCoding | undefined;
|
|
86
|
+
set siteCoding(value: LocalizedCoding | undefined);
|
|
87
|
+
get additionalInstructions(): CanonicalAdditionalInstructionExpr[];
|
|
88
|
+
set additionalInstructions(value: CanonicalAdditionalInstructionExpr[]);
|
|
89
|
+
get patientInstruction(): string | undefined;
|
|
90
|
+
set patientInstruction(value: string | undefined);
|
|
91
|
+
private ensureDose;
|
|
92
|
+
private ensureRoute;
|
|
93
|
+
private ensureSite;
|
|
94
|
+
private ensureMethod;
|
|
95
|
+
private ensureSchedule;
|
|
96
|
+
private ensurePrn;
|
|
97
|
+
private cleanupPrn;
|
|
98
|
+
private cleanupSite;
|
|
99
|
+
private cleanupMethod;
|
|
100
|
+
}
|
|
101
|
+
export {};
|
|
@@ -0,0 +1,441 @@
|
|
|
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;
|
package/dist/parser.d.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ParserState, Token } from "./parser-state";
|
|
2
2
|
import { ParseOptions, TextRange } from "./types";
|
|
3
3
|
export declare function tokenize(input: string): Token[];
|
|
4
|
-
export declare function findUnparsedTokenGroups(internal:
|
|
4
|
+
export declare function findUnparsedTokenGroups(internal: ParserState): Array<{
|
|
5
5
|
tokens: Token[];
|
|
6
6
|
range?: TextRange;
|
|
7
7
|
}>;
|
|
8
|
-
export declare function
|
|
8
|
+
export declare function parseClauseState(input: string, options?: ParseOptions): ParserState;
|
|
9
9
|
/**
|
|
10
10
|
* Resolves parsed site text against SNOMED dictionaries and synchronous
|
|
11
11
|
* callbacks, applying the best match to the in-progress parse result.
|
|
12
12
|
*/
|
|
13
|
-
export declare function applyPrnReasonCoding(internal:
|
|
14
|
-
export declare function applyPrnReasonCodingAsync(internal:
|
|
15
|
-
export declare function applySiteCoding(internal:
|
|
13
|
+
export declare function applyPrnReasonCoding(internal: ParserState, options?: ParseOptions): void;
|
|
14
|
+
export declare function applyPrnReasonCodingAsync(internal: ParserState, options?: ParseOptions): Promise<void>;
|
|
15
|
+
export declare function applySiteCoding(internal: ParserState, options?: ParseOptions): void;
|
|
16
16
|
/**
|
|
17
17
|
* Asynchronous counterpart to {@link applySiteCoding} that awaits resolver and
|
|
18
18
|
* suggestion callbacks so remote terminology services can be used.
|
|
19
19
|
*/
|
|
20
|
-
export declare function applySiteCodingAsync(internal:
|
|
20
|
+
export declare function applySiteCodingAsync(internal: ParserState, options?: ParseOptions): Promise<void>;
|