ezmedicationinput 0.1.46 → 0.1.48
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 +29 -0
- package/dist/advice.d.ts +9 -0
- package/dist/hpsg/lexical-classes.d.ts +8 -0
- package/dist/hpsg/method-lexicon.d.ts +2 -0
- package/dist/index.cjs +1483 -624
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1479 -624
- package/dist/types.d.ts +62 -2
- package/dist/unit-lexicon.d.ts +5 -1
- package/package.json +7 -7
package/dist/index.cjs
CHANGED
|
@@ -103,11 +103,15 @@ __export(index_exports, {
|
|
|
103
103
|
getBodySiteCodeAsync: () => getBodySiteCodeAsync,
|
|
104
104
|
getBodySiteText: () => getBodySiteText,
|
|
105
105
|
getBodySiteTextAsync: () => getBodySiteTextAsync,
|
|
106
|
+
getDoseUnitApproximation: () => getDoseUnitApproximation,
|
|
107
|
+
getDoseUnitKind: () => getDoseUnitKind,
|
|
108
|
+
getDoseUnitSemantics: () => getDoseUnitSemantics,
|
|
106
109
|
getRegisteredSigLocalizations: () => getRegisteredSigLocalizations,
|
|
107
110
|
hasSnomedBodySiteLateralityPostcoordination: () => hasSnomedBodySiteLateralityPostcoordination,
|
|
108
111
|
hasSnomedFindingSitePostcoordination: () => hasSnomedFindingSitePostcoordination,
|
|
109
112
|
hasSnomedTopographicalModifierPostcoordination: () => hasSnomedTopographicalModifierPostcoordination,
|
|
110
113
|
lintSig: () => lintSig,
|
|
114
|
+
listDoseUnitTerminology: () => listDoseUnitTerminology,
|
|
111
115
|
listSupportedBodySiteGrammar: () => listSupportedBodySiteGrammar,
|
|
112
116
|
listSupportedBodySiteText: () => listSupportedBodySiteText,
|
|
113
117
|
lookupBodySite: () => lookupBodySite,
|
|
@@ -132,17 +136,17 @@ module.exports = __toCommonJS(index_exports);
|
|
|
132
136
|
|
|
133
137
|
// src/prn.ts
|
|
134
138
|
function getCanonicalPrnReasonText(reason) {
|
|
135
|
-
var
|
|
136
|
-
return (_b = reason == null ? void 0 : reason.text) != null ? _b : (
|
|
139
|
+
var _a2, _b;
|
|
140
|
+
return (_b = reason == null ? void 0 : reason.text) != null ? _b : (_a2 = reason == null ? void 0 : reason.coding) == null ? void 0 : _a2.display;
|
|
137
141
|
}
|
|
138
142
|
function joinCanonicalPrnReasonTexts(reasons, conjunction = "or") {
|
|
139
|
-
var
|
|
143
|
+
var _a2;
|
|
140
144
|
if (!(reasons == null ? void 0 : reasons.length)) {
|
|
141
145
|
return void 0;
|
|
142
146
|
}
|
|
143
147
|
const texts = [];
|
|
144
148
|
for (const reason of reasons) {
|
|
145
|
-
const text = (
|
|
149
|
+
const text = (_a2 = getCanonicalPrnReasonText(reason)) == null ? void 0 : _a2.trim();
|
|
146
150
|
if (!text) {
|
|
147
151
|
continue;
|
|
148
152
|
}
|
|
@@ -173,8 +177,8 @@ function joinCanonicalPrnReasonTexts(reasons, conjunction = "or") {
|
|
|
173
177
|
}
|
|
174
178
|
}
|
|
175
179
|
function getPreferredCanonicalPrnReasonText(reason, reasons, conjunction = "or") {
|
|
176
|
-
var
|
|
177
|
-
const direct = (
|
|
180
|
+
var _a2;
|
|
181
|
+
const direct = (_a2 = getCanonicalPrnReasonText(reason)) == null ? void 0 : _a2.trim();
|
|
178
182
|
if (!(reasons == null ? void 0 : reasons.length)) {
|
|
179
183
|
return direct;
|
|
180
184
|
}
|
|
@@ -478,10 +482,10 @@ function cloneI18nRecord(i18n) {
|
|
|
478
482
|
return i18n ? __spreadValues({}, i18n) : void 0;
|
|
479
483
|
}
|
|
480
484
|
function cloneExtension(extension) {
|
|
481
|
-
var
|
|
485
|
+
var _a2, _b, _c, _d;
|
|
482
486
|
return {
|
|
483
487
|
url: extension.url,
|
|
484
|
-
extension: (
|
|
488
|
+
extension: (_a2 = extension.extension) == null ? void 0 : _a2.map(cloneExtension),
|
|
485
489
|
valueCode: extension.valueCode,
|
|
486
490
|
valueString: extension.valueString,
|
|
487
491
|
valueCoding: extension.valueCoding ? {
|
|
@@ -496,14 +500,14 @@ function cloneExtension(extension) {
|
|
|
496
500
|
text: extension.valueCodeableConcept.text,
|
|
497
501
|
_text: clonePrimitiveElement(extension.valueCodeableConcept._text),
|
|
498
502
|
coding: (_c = extension.valueCodeableConcept.coding) == null ? void 0 : _c.map((coding) => {
|
|
499
|
-
var
|
|
503
|
+
var _a3;
|
|
500
504
|
return {
|
|
501
505
|
system: coding.system,
|
|
502
506
|
code: coding.code,
|
|
503
507
|
display: coding.display,
|
|
504
508
|
_display: clonePrimitiveElement(coding._display),
|
|
505
509
|
i18n: cloneI18nRecord(coding.i18n),
|
|
506
|
-
extension: (
|
|
510
|
+
extension: (_a3 = coding.extension) == null ? void 0 : _a3.map(cloneExtension)
|
|
507
511
|
};
|
|
508
512
|
}),
|
|
509
513
|
extension: (_d = extension.valueCodeableConcept.extension) == null ? void 0 : _d.map(cloneExtension)
|
|
@@ -514,8 +518,8 @@ function cloneExtensions(extensions) {
|
|
|
514
518
|
return (extensions == null ? void 0 : extensions.length) ? extensions.map(cloneExtension) : void 0;
|
|
515
519
|
}
|
|
516
520
|
function clonePrimitiveElement(element) {
|
|
517
|
-
var
|
|
518
|
-
if (!((
|
|
521
|
+
var _a2;
|
|
522
|
+
if (!((_a2 = element == null ? void 0 : element.extension) == null ? void 0 : _a2.length)) {
|
|
519
523
|
return void 0;
|
|
520
524
|
}
|
|
521
525
|
return {
|
|
@@ -538,9 +542,9 @@ function buildTranslationExtension(locale, content) {
|
|
|
538
542
|
};
|
|
539
543
|
}
|
|
540
544
|
function buildTranslationPrimitiveElement(translations, base) {
|
|
541
|
-
var
|
|
545
|
+
var _a2, _b;
|
|
542
546
|
const nextExtensions = [];
|
|
543
|
-
const baseExtensions = (
|
|
547
|
+
const baseExtensions = (_a2 = base == null ? void 0 : base.extension) != null ? _a2 : [];
|
|
544
548
|
for (const extension of baseExtensions) {
|
|
545
549
|
if (extension.url !== FHIR_TRANSLATION_EXTENSION_URL) {
|
|
546
550
|
nextExtensions.push(cloneExtension(extension));
|
|
@@ -564,8 +568,8 @@ function buildTranslationPrimitiveElement(translations, base) {
|
|
|
564
568
|
};
|
|
565
569
|
}
|
|
566
570
|
function getTranslationParts(extension) {
|
|
567
|
-
var
|
|
568
|
-
const parts = (
|
|
571
|
+
var _a2, _b;
|
|
572
|
+
const parts = (_a2 = extension.extension) != null ? _a2 : [];
|
|
569
573
|
let locale;
|
|
570
574
|
let content;
|
|
571
575
|
for (const part of parts) {
|
|
@@ -583,9 +587,9 @@ function getTranslationParts(extension) {
|
|
|
583
587
|
return { locale, content };
|
|
584
588
|
}
|
|
585
589
|
function getPrimitiveTranslation(element, locale) {
|
|
586
|
-
var
|
|
590
|
+
var _a2;
|
|
587
591
|
const targetLocale = normalizeLocaleKey(locale);
|
|
588
|
-
if (!targetLocale || !((
|
|
592
|
+
if (!targetLocale || !((_a2 = element == null ? void 0 : element.extension) == null ? void 0 : _a2.length)) {
|
|
589
593
|
return void 0;
|
|
590
594
|
}
|
|
591
595
|
let languagePrefixMatch;
|
|
@@ -640,19 +644,19 @@ function cloneBodySiteCoding(coding) {
|
|
|
640
644
|
};
|
|
641
645
|
}
|
|
642
646
|
function bodySiteCodingToFhir(coding) {
|
|
643
|
-
var
|
|
647
|
+
var _a2;
|
|
644
648
|
if (!(coding == null ? void 0 : coding.code)) {
|
|
645
649
|
return void 0;
|
|
646
650
|
}
|
|
647
651
|
return {
|
|
648
|
-
system: (
|
|
652
|
+
system: (_a2 = coding.system) != null ? _a2 : SNOMED_SYSTEM2,
|
|
649
653
|
code: coding.code,
|
|
650
654
|
display: coding.display
|
|
651
655
|
};
|
|
652
656
|
}
|
|
653
657
|
function firstCodingWithCode(concept) {
|
|
654
|
-
var
|
|
655
|
-
return (
|
|
658
|
+
var _a2;
|
|
659
|
+
return (_a2 = concept == null ? void 0 : concept.coding) == null ? void 0 : _a2.find((coding) => Boolean(coding.code));
|
|
656
660
|
}
|
|
657
661
|
function cloneBodySiteSpatialRelation(relation) {
|
|
658
662
|
if (!relation) {
|
|
@@ -705,8 +709,8 @@ function buildBodySiteSpatialRelationExtensions(relation) {
|
|
|
705
709
|
return extension ? [extension] : void 0;
|
|
706
710
|
}
|
|
707
711
|
function parseBodySiteSpatialRelationExtension(concept) {
|
|
708
|
-
var
|
|
709
|
-
const extension = (
|
|
712
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
713
|
+
const extension = (_a2 = concept == null ? void 0 : concept.extension) == null ? void 0 : _a2.find(
|
|
710
714
|
(candidate) => candidate.url === BODY_SITE_SPATIAL_RELATION_EXTENSION_URL
|
|
711
715
|
);
|
|
712
716
|
if (!((_b = extension == null ? void 0 : extension.extension) == null ? void 0 : _b.length)) {
|
|
@@ -759,8 +763,8 @@ function buildSnomedBodySiteLateralityPostcoordinationCode(siteCode, lateralityC
|
|
|
759
763
|
return `${siteCode}${SNOMED_LATERALITY_MARKER}${lateralityCode}`;
|
|
760
764
|
}
|
|
761
765
|
function parseSnomedBodySiteTopographicalModifierPostcoordinationCode(code) {
|
|
762
|
-
var
|
|
763
|
-
const markerIndex = (
|
|
766
|
+
var _a2;
|
|
767
|
+
const markerIndex = (_a2 = code == null ? void 0 : code.indexOf(SNOMED_TOPOGRAPHICAL_MODIFIER_MARKER)) != null ? _a2 : -1;
|
|
764
768
|
if (!code || markerIndex < 0) {
|
|
765
769
|
return void 0;
|
|
766
770
|
}
|
|
@@ -772,8 +776,8 @@ function parseSnomedBodySiteTopographicalModifierPostcoordinationCode(code) {
|
|
|
772
776
|
return { siteCode, modifierCode };
|
|
773
777
|
}
|
|
774
778
|
function parseSnomedBodySiteLateralityPostcoordinationCode(code) {
|
|
775
|
-
var
|
|
776
|
-
const markerIndex = (
|
|
779
|
+
var _a2;
|
|
780
|
+
const markerIndex = (_a2 = code == null ? void 0 : code.indexOf(SNOMED_LATERALITY_MARKER)) != null ? _a2 : -1;
|
|
777
781
|
if (!code || markerIndex < 0) {
|
|
778
782
|
return void 0;
|
|
779
783
|
}
|
|
@@ -785,8 +789,8 @@ function parseSnomedBodySiteLateralityPostcoordinationCode(code) {
|
|
|
785
789
|
return { siteCode, lateralityCode };
|
|
786
790
|
}
|
|
787
791
|
function parseSnomedFindingSitePostcoordinationCode(code) {
|
|
788
|
-
var
|
|
789
|
-
const markerIndex = (
|
|
792
|
+
var _a2;
|
|
793
|
+
const markerIndex = (_a2 = code == null ? void 0 : code.indexOf(SNOMED_FINDING_SITE_ATTRIBUTE_MARKER)) != null ? _a2 : -1;
|
|
790
794
|
if (!code || markerIndex < 0) {
|
|
791
795
|
return void 0;
|
|
792
796
|
}
|
|
@@ -798,8 +802,8 @@ function parseSnomedFindingSitePostcoordinationCode(code) {
|
|
|
798
802
|
return { focusCode, siteCode };
|
|
799
803
|
}
|
|
800
804
|
function buildSnomedFindingSiteCoding(params) {
|
|
801
|
-
var
|
|
802
|
-
const focusCode = (
|
|
805
|
+
var _a2, _b, _c, _d, _e, _f;
|
|
806
|
+
const focusCode = (_a2 = params.focusCoding) == null ? void 0 : _a2.code;
|
|
803
807
|
const siteCode = (_b = params.siteCoding) == null ? void 0 : _b.code;
|
|
804
808
|
if (!focusCode || !siteCode || hasSnomedFindingSitePostcoordination(focusCode)) {
|
|
805
809
|
return void 0;
|
|
@@ -905,10 +909,10 @@ var ROUTE_SNOMED = objectFromEntries(
|
|
|
905
909
|
);
|
|
906
910
|
var ROUTE_TEXT = objectFromEntries(
|
|
907
911
|
ROUTE_SNOMED_ENTRIES.map(([routeCode, meta]) => {
|
|
908
|
-
var
|
|
912
|
+
var _a2;
|
|
909
913
|
return [
|
|
910
914
|
routeCode,
|
|
911
|
-
(
|
|
915
|
+
(_a2 = ROUTE_TEXT_OVERRIDES[routeCode]) != null ? _a2 : defaultRouteText(meta.display)
|
|
912
916
|
];
|
|
913
917
|
})
|
|
914
918
|
);
|
|
@@ -1136,7 +1140,7 @@ var LATERALIZABLE_DIGIT_BODY_SITES = [
|
|
|
1136
1140
|
}
|
|
1137
1141
|
];
|
|
1138
1142
|
function buildLateralizedDigitBodySiteEntries() {
|
|
1139
|
-
var
|
|
1143
|
+
var _a2;
|
|
1140
1144
|
const entries = [];
|
|
1141
1145
|
for (const site of LATERALIZABLE_DIGIT_BODY_SITES) {
|
|
1142
1146
|
for (const laterality of BODY_SITE_LATERALITIES) {
|
|
@@ -1161,7 +1165,7 @@ function buildLateralizedDigitBodySiteEntries() {
|
|
|
1161
1165
|
display: text
|
|
1162
1166
|
},
|
|
1163
1167
|
text,
|
|
1164
|
-
routeHint: (
|
|
1168
|
+
routeHint: (_a2 = site.routeHint) != null ? _a2 : RouteCode["Topical route"]
|
|
1165
1169
|
}
|
|
1166
1170
|
});
|
|
1167
1171
|
}
|
|
@@ -2207,6 +2211,18 @@ var STATIC_UNIT_SYNONYMS = {
|
|
|
2207
2211
|
capfuls: "capful",
|
|
2208
2212
|
scoop: "scoop",
|
|
2209
2213
|
scoops: "scoop",
|
|
2214
|
+
tube: "tube",
|
|
2215
|
+
tubes: "tube",
|
|
2216
|
+
bottle: "bottle",
|
|
2217
|
+
bottles: "bottle",
|
|
2218
|
+
container: "container",
|
|
2219
|
+
containers: "container",
|
|
2220
|
+
jar: "jar",
|
|
2221
|
+
jars: "jar",
|
|
2222
|
+
packet: "packet",
|
|
2223
|
+
packets: "packet",
|
|
2224
|
+
sachet: "sachet",
|
|
2225
|
+
sachets: "sachet",
|
|
2210
2226
|
application: "application",
|
|
2211
2227
|
applications: "application",
|
|
2212
2228
|
ribbon: "ribbon",
|
|
@@ -3804,8 +3820,8 @@ var DEFAULT_PRN_REASON_SOURCE = [
|
|
|
3804
3820
|
}
|
|
3805
3821
|
];
|
|
3806
3822
|
var DEFAULT_PRN_REASON_ENTRIES = DEFAULT_PRN_REASON_SOURCE.map((source) => {
|
|
3807
|
-
var
|
|
3808
|
-
const canonicalTerm = (_c = (_b = source.definition.text) != null ? _b : (
|
|
3823
|
+
var _a2, _b, _c;
|
|
3824
|
+
const canonicalTerm = (_c = (_b = source.definition.text) != null ? _b : (_a2 = source.definition.coding) == null ? void 0 : _a2.display) != null ? _c : source.names[0];
|
|
3809
3825
|
const terms = [];
|
|
3810
3826
|
const seen = /* @__PURE__ */ new Set();
|
|
3811
3827
|
const pushTerm = (value) => {
|
|
@@ -3852,13 +3868,13 @@ var DEFAULT_PRN_REASON_DEFINITIONS = objectFromEntries(
|
|
|
3852
3868
|
}, [])
|
|
3853
3869
|
);
|
|
3854
3870
|
function findPrnReasonDefinitionByCoding(system, code) {
|
|
3855
|
-
var
|
|
3856
|
-
return (
|
|
3871
|
+
var _a2;
|
|
3872
|
+
return (_a2 = DEFAULT_PRN_REASON_SOURCE.find(
|
|
3857
3873
|
(source) => {
|
|
3858
|
-
var
|
|
3859
|
-
return ((
|
|
3874
|
+
var _a3, _b;
|
|
3875
|
+
return ((_a3 = source.definition.coding) == null ? void 0 : _a3.system) === system && ((_b = source.definition.coding) == null ? void 0 : _b.code) === code;
|
|
3860
3876
|
}
|
|
3861
|
-
)) == null ? void 0 :
|
|
3877
|
+
)) == null ? void 0 : _a2.definition;
|
|
3862
3878
|
}
|
|
3863
3879
|
|
|
3864
3880
|
// src/hpsg/lexical-classes.json
|
|
@@ -3956,8 +3972,122 @@ var lexical_classes_default = {
|
|
|
3956
3972
|
},
|
|
3957
3973
|
compoundDoseUnits: [
|
|
3958
3974
|
{ head: "cm", tails: ["ribbon", "ribbons"], unit: "cm ribbon" },
|
|
3959
|
-
{ head: "
|
|
3975
|
+
{ head: "cm", tails: ["strip", "strips"], unit: "cm strip" },
|
|
3976
|
+
{ head: "cm", tails: ["line", "lines"], unit: "cm line" },
|
|
3977
|
+
{ head: "inch", tails: ["ribbon", "ribbons", "strip", "strips"], unit: "inch ribbon" },
|
|
3978
|
+
{ head: "inch", tails: ["line", "lines"], unit: "inch line" },
|
|
3979
|
+
{ head: "fingertip", tails: ["unit", "units"], unit: "FTU" },
|
|
3980
|
+
{ head: "eye", tails: ["drop", "drops"], unit: "drop" },
|
|
3981
|
+
{ head: "pea-sized", tails: ["amount"], unit: "pea-sized amount" },
|
|
3982
|
+
{ head: "\u0E40\u0E21\u0E47\u0E14\u0E16\u0E31\u0E48\u0E27", tails: [], unit: "pea-sized amount" },
|
|
3983
|
+
{ head: "\u0E40\u0E21\u0E47\u0E14\u0E16\u0E31\u0E48\u0E27\u0E40\u0E02\u0E35\u0E22\u0E27", tails: [], unit: "pea-sized amount" },
|
|
3984
|
+
{ head: "\u0E40\u0E21\u0E25\u0E47\u0E14\u0E16\u0E31\u0E48\u0E27", tails: [], unit: "pea-sized amount" },
|
|
3985
|
+
{ head: "\u0E02\u0E19\u0E32\u0E14\u0E40\u0E21\u0E47\u0E14\u0E16\u0E31\u0E48\u0E27", tails: [], unit: "pea-sized amount" },
|
|
3986
|
+
{ head: "\u0E02\u0E19\u0E32\u0E14\u0E40\u0E21\u0E47\u0E14\u0E16\u0E31\u0E48\u0E27\u0E40\u0E02\u0E35\u0E22\u0E27", tails: [], unit: "pea-sized amount" },
|
|
3987
|
+
{ head: "\u0E02\u0E19\u0E32\u0E14\u0E40\u0E21\u0E25\u0E47\u0E14\u0E16\u0E31\u0E48\u0E27", tails: [], unit: "pea-sized amount" },
|
|
3988
|
+
{
|
|
3989
|
+
head: "pea",
|
|
3990
|
+
tails: [],
|
|
3991
|
+
tailSequences: [["sized", "amount"], ["size", "amount"]],
|
|
3992
|
+
unit: "pea-sized amount"
|
|
3993
|
+
},
|
|
3994
|
+
{ head: "hand", tails: ["print", "prints"], unit: "handprint" },
|
|
3995
|
+
{ head: "percent", tails: ["bsa", "tbsa"], unit: "% BSA" },
|
|
3996
|
+
{ head: "shot", tails: ["glass", "glasses"], unit: "shot glass" },
|
|
3997
|
+
{ head: "finger", tails: ["length", "lengths"], unit: "finger length" },
|
|
3998
|
+
{ head: "two-finger", tails: ["rule", "method"], unit: "finger length" },
|
|
3999
|
+
{
|
|
4000
|
+
head: "two",
|
|
4001
|
+
tails: [],
|
|
4002
|
+
tailSequences: [["finger", "rule"], ["finger", "method"]],
|
|
4003
|
+
unit: "finger length"
|
|
4004
|
+
},
|
|
4005
|
+
{ head: "full", tails: ["applicator", "applicators"], unit: "applicatorful" },
|
|
4006
|
+
{
|
|
4007
|
+
head: "cap",
|
|
4008
|
+
tails: [],
|
|
4009
|
+
tailSequences: [["to", "line"], ["filled", "to", "line"]],
|
|
4010
|
+
unit: "capful"
|
|
4011
|
+
},
|
|
4012
|
+
{ head: "stick", tails: ["pack", "packs"], unit: "stick-pack" },
|
|
4013
|
+
{ head: "unit-dose", tails: ["vial", "vials"], unit: "vial" },
|
|
4014
|
+
{
|
|
4015
|
+
head: "unit",
|
|
4016
|
+
tails: [],
|
|
4017
|
+
tailSequences: [["dose", "vial"], ["dose", "vials"]],
|
|
4018
|
+
unit: "vial"
|
|
4019
|
+
},
|
|
4020
|
+
{ head: "insulin", tails: ["unit", "units"], unit: "U" },
|
|
4021
|
+
{ head: "usp", tails: ["unit", "units"], unit: "U" },
|
|
4022
|
+
{ head: "pen", tails: ["click", "clicks"], unit: "click" },
|
|
4023
|
+
{ head: "dial", tails: ["click", "clicks"], unit: "click" },
|
|
4024
|
+
{ head: "transdermal", tails: ["system", "systems"], unit: "patch" }
|
|
3960
4025
|
],
|
|
4026
|
+
implicitSingleDoseUnits: ["pea-sized amount", "finger length"],
|
|
4027
|
+
percentBodyAreaUnits: {
|
|
4028
|
+
bsa: "% BSA",
|
|
4029
|
+
tbsa: "% BSA"
|
|
4030
|
+
},
|
|
4031
|
+
doseFractionWords: {
|
|
4032
|
+
half: 0.5,
|
|
4033
|
+
quarter: 0.25,
|
|
4034
|
+
fourth: 0.25,
|
|
4035
|
+
third: 0.3333333333333333,
|
|
4036
|
+
fifth: 0.2,
|
|
4037
|
+
sixth: 0.16666666666666666,
|
|
4038
|
+
seventh: 0.14285714285714285,
|
|
4039
|
+
eighth: 0.125,
|
|
4040
|
+
ninth: 0.1111111111111111,
|
|
4041
|
+
tenth: 0.1,
|
|
4042
|
+
eleventh: 0.09090909090909091,
|
|
4043
|
+
twelfth: 0.08333333333333333,
|
|
4044
|
+
whole: 1,
|
|
4045
|
+
entire: 1,
|
|
4046
|
+
full: 1
|
|
4047
|
+
},
|
|
4048
|
+
doseFractionDenominatorWords: {
|
|
4049
|
+
half: 0.5,
|
|
4050
|
+
halves: 0.5,
|
|
4051
|
+
quarter: 0.25,
|
|
4052
|
+
quarters: 0.25,
|
|
4053
|
+
fourth: 0.25,
|
|
4054
|
+
fourths: 0.25,
|
|
4055
|
+
third: 0.3333333333333333,
|
|
4056
|
+
thirds: 0.3333333333333333,
|
|
4057
|
+
fifth: 0.2,
|
|
4058
|
+
fifths: 0.2,
|
|
4059
|
+
sixth: 0.16666666666666666,
|
|
4060
|
+
sixths: 0.16666666666666666,
|
|
4061
|
+
seventh: 0.14285714285714285,
|
|
4062
|
+
sevenths: 0.14285714285714285,
|
|
4063
|
+
eighth: 0.125,
|
|
4064
|
+
eighths: 0.125,
|
|
4065
|
+
ninth: 0.1111111111111111,
|
|
4066
|
+
ninths: 0.1111111111111111,
|
|
4067
|
+
tenth: 0.1,
|
|
4068
|
+
tenths: 0.1,
|
|
4069
|
+
eleventh: 0.09090909090909091,
|
|
4070
|
+
elevenths: 0.09090909090909091,
|
|
4071
|
+
twelfth: 0.08333333333333333,
|
|
4072
|
+
twelfths: 0.08333333333333333
|
|
4073
|
+
},
|
|
4074
|
+
doseNumberWords: {
|
|
4075
|
+
a: 1,
|
|
4076
|
+
an: 1,
|
|
4077
|
+
one: 1,
|
|
4078
|
+
two: 2,
|
|
4079
|
+
three: 3,
|
|
4080
|
+
four: 4,
|
|
4081
|
+
five: 5,
|
|
4082
|
+
six: 6,
|
|
4083
|
+
seven: 7,
|
|
4084
|
+
eight: 8,
|
|
4085
|
+
nine: 9,
|
|
4086
|
+
ten: 10,
|
|
4087
|
+
eleven: 11,
|
|
4088
|
+
twelve: 12
|
|
4089
|
+
},
|
|
4090
|
+
doseUnitConnectors: ["of", "a", "an", "the"],
|
|
3961
4091
|
millionDoseMultiplierTokens: ["m"],
|
|
3962
4092
|
scheduleUnitSeparatorTokens: ["/"],
|
|
3963
4093
|
compactListSeparators: ["/"],
|
|
@@ -4081,6 +4211,7 @@ var lexical_classes_default = {
|
|
|
4081
4211
|
"dont",
|
|
4082
4212
|
"drink",
|
|
4083
4213
|
"empty",
|
|
4214
|
+
"gently",
|
|
4084
4215
|
"liberally",
|
|
4085
4216
|
"may",
|
|
4086
4217
|
"might",
|
|
@@ -4093,10 +4224,24 @@ var lexical_classes_default = {
|
|
|
4093
4224
|
"should",
|
|
4094
4225
|
"slowly",
|
|
4095
4226
|
"sparingly",
|
|
4227
|
+
"thickly",
|
|
4228
|
+
"thick",
|
|
4229
|
+
"thinly",
|
|
4230
|
+
"thin",
|
|
4096
4231
|
"use",
|
|
4097
4232
|
"with",
|
|
4098
4233
|
"without"
|
|
4099
4234
|
],
|
|
4235
|
+
siteTrailingInstructionWords: [
|
|
4236
|
+
"gently",
|
|
4237
|
+
"liberally",
|
|
4238
|
+
"slowly",
|
|
4239
|
+
"sparingly",
|
|
4240
|
+
"thick",
|
|
4241
|
+
"thickly",
|
|
4242
|
+
"thin",
|
|
4243
|
+
"thinly"
|
|
4244
|
+
],
|
|
4100
4245
|
workflowContinuationLicenses: ["with each", "after each", "the *event", "sun exposure"],
|
|
4101
4246
|
asNeededLeadPhrases: ["as needed"],
|
|
4102
4247
|
prnBreakingCoordinators: [",", "/"],
|
|
@@ -4144,9 +4289,9 @@ function routeCodeSet(labels) {
|
|
|
4144
4289
|
);
|
|
4145
4290
|
}
|
|
4146
4291
|
function eventTimingMap(record) {
|
|
4147
|
-
var
|
|
4292
|
+
var _a2, _b;
|
|
4148
4293
|
const map = /* @__PURE__ */ new Map();
|
|
4149
|
-
const nodeEnv = (_b = (
|
|
4294
|
+
const nodeEnv = (_b = (_a2 = globalThis.process) == null ? void 0 : _a2.env) == null ? void 0 : _b.NODE_ENV;
|
|
4150
4295
|
const shouldWarn = nodeEnv !== "production";
|
|
4151
4296
|
for (const key in record) {
|
|
4152
4297
|
if (Object.prototype.hasOwnProperty.call(record, key)) {
|
|
@@ -4197,6 +4342,15 @@ function stringEntries(record) {
|
|
|
4197
4342
|
function numberRecord(record) {
|
|
4198
4343
|
return __spreadValues({}, record);
|
|
4199
4344
|
}
|
|
4345
|
+
function numberEntries(record) {
|
|
4346
|
+
const entries = [];
|
|
4347
|
+
for (const key in record) {
|
|
4348
|
+
if (Object.prototype.hasOwnProperty.call(record, key)) {
|
|
4349
|
+
entries.push([key, record[key]]);
|
|
4350
|
+
}
|
|
4351
|
+
}
|
|
4352
|
+
return entries;
|
|
4353
|
+
}
|
|
4200
4354
|
function periodUnitRecord(record) {
|
|
4201
4355
|
const result = /* @__PURE__ */ new Map();
|
|
4202
4356
|
for (const [token, label] of stringEntries(record)) {
|
|
@@ -4269,6 +4423,20 @@ var SITE_ROUTE_HINTS_ALLOWED_IN_GRAMMAR = routeCodeSet(lexical_classes_default.s
|
|
|
4269
4423
|
var PRODUCT_METHOD_TEXT = lexical_classes_default.productMethodText;
|
|
4270
4424
|
var PRODUCT_METHOD_THAI = lexical_classes_default.productMethodThai;
|
|
4271
4425
|
var COMPOUND_DOSE_UNITS = lexical_classes_default.compoundDoseUnits;
|
|
4426
|
+
var IMPLICIT_SINGLE_DOSE_UNITS = setOf(lexical_classes_default.implicitSingleDoseUnits);
|
|
4427
|
+
var PERCENT_BODY_AREA_UNITS = new Map(
|
|
4428
|
+
stringEntries(lexical_classes_default.percentBodyAreaUnits)
|
|
4429
|
+
);
|
|
4430
|
+
var DOSE_FRACTION_WORDS = new Map(
|
|
4431
|
+
numberEntries(lexical_classes_default.doseFractionWords)
|
|
4432
|
+
);
|
|
4433
|
+
var DOSE_FRACTION_DENOMINATOR_WORDS = new Map(
|
|
4434
|
+
numberEntries(lexical_classes_default.doseFractionDenominatorWords)
|
|
4435
|
+
);
|
|
4436
|
+
var DOSE_NUMBER_WORDS = new Map(
|
|
4437
|
+
numberEntries(lexical_classes_default.doseNumberWords)
|
|
4438
|
+
);
|
|
4439
|
+
var DOSE_UNIT_CONNECTORS = setOf(lexical_classes_default.doseUnitConnectors);
|
|
4272
4440
|
var MILLION_DOSE_MULTIPLIER_TOKENS = setOf(lexical_classes_default.millionDoseMultiplierTokens);
|
|
4273
4441
|
var SCHEDULE_UNIT_SEPARATOR_TOKENS = setOf(lexical_classes_default.scheduleUnitSeparatorTokens);
|
|
4274
4442
|
var COMPACT_LIST_SEPARATORS = setOf(lexical_classes_default.compactListSeparators);
|
|
@@ -4304,6 +4472,7 @@ var RANGE_CONNECTORS = setOf(lexical_classes_default.rangeConnectors);
|
|
|
4304
4472
|
var DURATION_LEAD_TOKENS = setOf(lexical_classes_default.durationLeadTokens);
|
|
4305
4473
|
var INSTRUCTION_LEADING_SEPARATORS = setOf(lexical_classes_default.instructionLeadingSeparators);
|
|
4306
4474
|
var INSTRUCTION_START_WORDS = setOf(lexical_classes_default.instructionStartWords);
|
|
4475
|
+
var SITE_TRAILING_INSTRUCTION_WORDS = setOf(lexical_classes_default.siteTrailingInstructionWords);
|
|
4307
4476
|
var WORKFLOW_CONTINUATION_LICENSES = setOf(lexical_classes_default.workflowContinuationLicenses);
|
|
4308
4477
|
var AS_NEEDED_LEAD_PHRASES = setOf(lexical_classes_default.asNeededLeadPhrases);
|
|
4309
4478
|
var PRN_BREAKING_COORDINATORS = setOf(lexical_classes_default.prnBreakingCoordinators);
|
|
@@ -4342,7 +4511,7 @@ var HAND_CONTEXT_KEYS = /* @__PURE__ */ new Set(["hand", "hands", "finger", "fin
|
|
|
4342
4511
|
var FOOT_CONTEXT_KEYS = /* @__PURE__ */ new Set(["foot", "feet", "toe", "toes", "\u0E19\u0E34\u0E49\u0E27\u0E40\u0E17\u0E49\u0E32", "\u0E40\u0E17\u0E49\u0E32"]);
|
|
4343
4512
|
var BODY_SITE_ALIAS_INDEXES = /* @__PURE__ */ new WeakMap();
|
|
4344
4513
|
function buildOrGetBodySiteAliasIndex(map) {
|
|
4345
|
-
var
|
|
4514
|
+
var _a2;
|
|
4346
4515
|
const existing = BODY_SITE_ALIAS_INDEXES.get(map);
|
|
4347
4516
|
if (existing) {
|
|
4348
4517
|
return existing;
|
|
@@ -4353,7 +4522,7 @@ function buildOrGetBodySiteAliasIndex(map) {
|
|
|
4353
4522
|
if (normalizedKey) {
|
|
4354
4523
|
index.set(normalizedKey, definition);
|
|
4355
4524
|
}
|
|
4356
|
-
for (const alias of (
|
|
4525
|
+
for (const alias of (_a2 = definition.aliases) != null ? _a2 : []) {
|
|
4357
4526
|
const normalizedAlias = normalizeBodySiteKey(alias);
|
|
4358
4527
|
if (normalizedAlias) {
|
|
4359
4528
|
index.set(normalizedAlias, definition);
|
|
@@ -4414,7 +4583,7 @@ function resolveContextualBodySiteAlias(lookupCanonical, context) {
|
|
|
4414
4583
|
return void 0;
|
|
4415
4584
|
}
|
|
4416
4585
|
function buildBodySiteCoding(definition) {
|
|
4417
|
-
var
|
|
4586
|
+
var _a2;
|
|
4418
4587
|
const coding = definition == null ? void 0 : definition.coding;
|
|
4419
4588
|
if (!(coding == null ? void 0 : coding.code)) {
|
|
4420
4589
|
return void 0;
|
|
@@ -4422,24 +4591,24 @@ function buildBodySiteCoding(definition) {
|
|
|
4422
4591
|
return {
|
|
4423
4592
|
code: coding.code,
|
|
4424
4593
|
display: coding.display,
|
|
4425
|
-
system: (
|
|
4594
|
+
system: (_a2 = coding.system) != null ? _a2 : SNOMED_SYSTEM3
|
|
4426
4595
|
};
|
|
4427
4596
|
}
|
|
4428
4597
|
function cloneBodySiteCode(coding) {
|
|
4429
|
-
var
|
|
4598
|
+
var _a2;
|
|
4430
4599
|
if (!(coding == null ? void 0 : coding.code)) {
|
|
4431
4600
|
return void 0;
|
|
4432
4601
|
}
|
|
4433
4602
|
return {
|
|
4434
4603
|
code: coding.code,
|
|
4435
4604
|
display: coding.display,
|
|
4436
|
-
system: (
|
|
4605
|
+
system: (_a2 = coding.system) != null ? _a2 : SNOMED_SYSTEM3,
|
|
4437
4606
|
i18n: coding.i18n
|
|
4438
4607
|
};
|
|
4439
4608
|
}
|
|
4440
4609
|
function lookupDefinitionForCanonical(canonical, customSiteMap) {
|
|
4441
|
-
var
|
|
4442
|
-
return (
|
|
4610
|
+
var _a2;
|
|
4611
|
+
return (_a2 = lookupBodySiteDefinition(customSiteMap, canonical)) != null ? _a2 : DEFAULT_BODY_SITE_SNOMED[canonical];
|
|
4443
4612
|
}
|
|
4444
4613
|
function isAdjectivalSitePhrase(phrase) {
|
|
4445
4614
|
const normalized = phrase.trim().toLowerCase();
|
|
@@ -4526,7 +4695,7 @@ function pickPreferredBodySitePhrase(canonical, definition, customSiteMap) {
|
|
|
4526
4695
|
return normalizeBodySiteKey(best) === canonical ? void 0 : best;
|
|
4527
4696
|
}
|
|
4528
4697
|
function normalizeSiteDisplayText(text, customSiteMap) {
|
|
4529
|
-
var
|
|
4698
|
+
var _a2, _b;
|
|
4530
4699
|
const trimmed = text.trim();
|
|
4531
4700
|
if (!trimmed) {
|
|
4532
4701
|
return trimmed;
|
|
@@ -4535,13 +4704,13 @@ function normalizeSiteDisplayText(text, customSiteMap) {
|
|
|
4535
4704
|
if (!canonicalInput) {
|
|
4536
4705
|
return trimmed;
|
|
4537
4706
|
}
|
|
4538
|
-
const directDefinition = (
|
|
4707
|
+
const directDefinition = (_a2 = lookupBodySiteDefinition(customSiteMap, canonicalInput)) != null ? _a2 : DEFAULT_BODY_SITE_SNOMED[canonicalInput];
|
|
4539
4708
|
if (directDefinition) {
|
|
4540
4709
|
return (_b = directDefinition.text) != null ? _b : canonicalInput;
|
|
4541
4710
|
}
|
|
4542
4711
|
const resolvePreferred = (canonical) => {
|
|
4543
|
-
var
|
|
4544
|
-
const definition = (
|
|
4712
|
+
var _a3, _b2, _c;
|
|
4713
|
+
const definition = (_a3 = lookupBodySiteDefinition(customSiteMap, canonical)) != null ? _a3 : DEFAULT_BODY_SITE_SNOMED[canonical];
|
|
4545
4714
|
if (!definition) {
|
|
4546
4715
|
return void 0;
|
|
4547
4716
|
}
|
|
@@ -4650,10 +4819,10 @@ function renderNominalObject(features) {
|
|
|
4650
4819
|
return features.article === "bare" ? features.text : `the ${features.text}`;
|
|
4651
4820
|
}
|
|
4652
4821
|
function renderBodySiteObject(features) {
|
|
4653
|
-
var
|
|
4822
|
+
var _a2;
|
|
4654
4823
|
switch (features.kind) {
|
|
4655
4824
|
case "locative":
|
|
4656
|
-
return `${(
|
|
4825
|
+
return `${(_a2 = BODY_SITE_LOCATIVE_RENDER_PREPOSITIONS.get(features.relation)) != null ? _a2 : features.relation} ${renderBodySiteObject(features.target)}`;
|
|
4657
4826
|
case "partitive":
|
|
4658
4827
|
return `${features.part.startsWith("both") || features.part.startsWith("bilateral") ? features.part : `the ${features.part}`} of ${renderNominalObject(features.whole)}`;
|
|
4659
4828
|
case "nominal":
|
|
@@ -4689,7 +4858,7 @@ function resolveFeatureCoding(features, customSiteMap) {
|
|
|
4689
4858
|
}
|
|
4690
4859
|
}
|
|
4691
4860
|
function buildSpatialRelation(features, sourceText, customSiteMap) {
|
|
4692
|
-
var
|
|
4861
|
+
var _a2;
|
|
4693
4862
|
switch (features.kind) {
|
|
4694
4863
|
case "locative": {
|
|
4695
4864
|
const relationCoding = BODY_SITE_SPATIAL_RELATION_CODINGS.get(features.relation);
|
|
@@ -4702,7 +4871,7 @@ function buildSpatialRelation(features, sourceText, customSiteMap) {
|
|
|
4702
4871
|
};
|
|
4703
4872
|
}
|
|
4704
4873
|
case "partitive": {
|
|
4705
|
-
const relationCoding = BODY_SITE_SPATIAL_RELATION_CODINGS.get((
|
|
4874
|
+
const relationCoding = BODY_SITE_SPATIAL_RELATION_CODINGS.get((_a2 = features.relationKey) != null ? _a2 : features.part);
|
|
4706
4875
|
if (!relationCoding) {
|
|
4707
4876
|
return void 0;
|
|
4708
4877
|
}
|
|
@@ -4741,7 +4910,7 @@ function inferPreferredPreposition(canonical, features, definition) {
|
|
|
4741
4910
|
return void 0;
|
|
4742
4911
|
}
|
|
4743
4912
|
function resolveBodySitePhrase(text, customSiteMap, context) {
|
|
4744
|
-
var
|
|
4913
|
+
var _a2, _b, _c, _d, _e, _f, _g;
|
|
4745
4914
|
const trimmed = text.trim().replace(/\s+/g, " ");
|
|
4746
4915
|
if (!trimmed) {
|
|
4747
4916
|
return void 0;
|
|
@@ -4751,7 +4920,7 @@ function resolveBodySitePhrase(text, customSiteMap, context) {
|
|
|
4751
4920
|
const displaySourceText = contextualCanonical != null ? contextualCanonical : trimmed;
|
|
4752
4921
|
const displayText = normalizeSiteDisplayText(displaySourceText, customSiteMap);
|
|
4753
4922
|
const canonical = normalizeBodySiteKey(displayText);
|
|
4754
|
-
const definition = (_e = (_d = (_c = (_b = (
|
|
4923
|
+
const definition = (_e = (_d = (_c = (_b = (_a2 = lookupBodySiteDefinition(customSiteMap, lookupCanonical)) != null ? _a2 : contextualCanonical ? lookupBodySiteDefinition(customSiteMap, contextualCanonical) : void 0) != null ? _b : contextualCanonical ? DEFAULT_BODY_SITE_SNOMED[contextualCanonical] : void 0) != null ? _c : DEFAULT_BODY_SITE_SNOMED[lookupCanonical]) != null ? _d : lookupBodySiteDefinition(customSiteMap, canonical)) != null ? _e : DEFAULT_BODY_SITE_SNOMED[canonical];
|
|
4755
4924
|
const coding = buildBodySiteCoding(definition);
|
|
4756
4925
|
const finalDisplayText = (_f = definition == null ? void 0 : definition.text) != null ? _f : displayText;
|
|
4757
4926
|
const features = parseBodySiteFeatures(finalDisplayText, coding, customSiteMap);
|
|
@@ -4881,7 +5050,7 @@ function getMealTimingGroup(when, options) {
|
|
|
4881
5050
|
};
|
|
4882
5051
|
}
|
|
4883
5052
|
function inferDailyOccurrenceCount(input, options) {
|
|
4884
|
-
var
|
|
5053
|
+
var _a2, _b, _c, _d;
|
|
4885
5054
|
if (!(options == null ? void 0 : options.includeTimesPerDaySummary)) {
|
|
4886
5055
|
return void 0;
|
|
4887
5056
|
}
|
|
@@ -4891,7 +5060,7 @@ function inferDailyOccurrenceCount(input, options) {
|
|
|
4891
5060
|
if (input.period !== void 0 || input.periodMax !== void 0 || input.periodUnit !== void 0) {
|
|
4892
5061
|
return void 0;
|
|
4893
5062
|
}
|
|
4894
|
-
if (((_b = (
|
|
5063
|
+
if (((_b = (_a2 = input.dayOfWeek) == null ? void 0 : _a2.length) != null ? _b : 0) > 0) {
|
|
4895
5064
|
return void 0;
|
|
4896
5065
|
}
|
|
4897
5066
|
const uniqueWhen2 = uniqueValues((_c = input.when) != null ? _c : []);
|
|
@@ -5036,8 +5205,8 @@ var ROUTE_GRAMMAR = {
|
|
|
5036
5205
|
}
|
|
5037
5206
|
};
|
|
5038
5207
|
function scheduleOf(clause) {
|
|
5039
|
-
var
|
|
5040
|
-
return (
|
|
5208
|
+
var _a2;
|
|
5209
|
+
return (_a2 = clause.schedule) != null ? _a2 : {};
|
|
5041
5210
|
}
|
|
5042
5211
|
function grammarFromRouteText(text) {
|
|
5043
5212
|
if (!text) {
|
|
@@ -5089,16 +5258,16 @@ function grammarFromRouteText(text) {
|
|
|
5089
5258
|
return void 0;
|
|
5090
5259
|
}
|
|
5091
5260
|
function resolveRouteGrammar(clause) {
|
|
5092
|
-
var
|
|
5093
|
-
const routeCode = (
|
|
5261
|
+
var _a2, _b, _c, _d;
|
|
5262
|
+
const routeCode = (_a2 = clause.route) == null ? void 0 : _a2.code;
|
|
5094
5263
|
if (routeCode && ROUTE_GRAMMAR[routeCode]) {
|
|
5095
5264
|
return (_b = ROUTE_GRAMMAR[routeCode]) != null ? _b : DEFAULT_ROUTE_GRAMMAR;
|
|
5096
5265
|
}
|
|
5097
5266
|
return (_d = grammarFromRouteText((_c = clause.route) == null ? void 0 : _c.text)) != null ? _d : DEFAULT_ROUTE_GRAMMAR;
|
|
5098
5267
|
}
|
|
5099
5268
|
function resolveMethodVerb(clause, grammar) {
|
|
5100
|
-
var
|
|
5101
|
-
const methodText = (_b = (
|
|
5269
|
+
var _a2, _b;
|
|
5270
|
+
const methodText = (_b = (_a2 = clause.method) == null ? void 0 : _a2.text) == null ? void 0 : _b.trim();
|
|
5102
5271
|
if (methodText) {
|
|
5103
5272
|
return methodText;
|
|
5104
5273
|
}
|
|
@@ -5111,6 +5280,8 @@ function pluralize(unit, value) {
|
|
|
5111
5280
|
return "tablet";
|
|
5112
5281
|
case "cap":
|
|
5113
5282
|
return "capsule";
|
|
5283
|
+
case "FTU":
|
|
5284
|
+
return "FTU";
|
|
5114
5285
|
default:
|
|
5115
5286
|
return unit;
|
|
5116
5287
|
}
|
|
@@ -5118,6 +5289,9 @@ function pluralize(unit, value) {
|
|
|
5118
5289
|
if (unit.endsWith(" ribbon")) {
|
|
5119
5290
|
return unit;
|
|
5120
5291
|
}
|
|
5292
|
+
if (unit.endsWith(" line")) {
|
|
5293
|
+
return unit;
|
|
5294
|
+
}
|
|
5121
5295
|
switch (unit) {
|
|
5122
5296
|
case "tab":
|
|
5123
5297
|
case "tablet":
|
|
@@ -5132,6 +5306,8 @@ function pluralize(unit, value) {
|
|
|
5132
5306
|
return "puffs";
|
|
5133
5307
|
case "patch":
|
|
5134
5308
|
return "patches";
|
|
5309
|
+
case "ring":
|
|
5310
|
+
return "rings";
|
|
5135
5311
|
case "drop":
|
|
5136
5312
|
return "drops";
|
|
5137
5313
|
case "suppository":
|
|
@@ -5146,8 +5322,28 @@ function pluralize(unit, value) {
|
|
|
5146
5322
|
return "capfuls";
|
|
5147
5323
|
case "scoop":
|
|
5148
5324
|
return "scoops";
|
|
5325
|
+
case "palm":
|
|
5326
|
+
return "palms";
|
|
5327
|
+
case "handprint":
|
|
5328
|
+
return "handprints";
|
|
5329
|
+
case "shot glass":
|
|
5330
|
+
return "shot glasses";
|
|
5331
|
+
case "click":
|
|
5332
|
+
return "clicks";
|
|
5333
|
+
case "vial":
|
|
5334
|
+
return "vials";
|
|
5335
|
+
case "ampule":
|
|
5336
|
+
return "ampules";
|
|
5337
|
+
case "packet":
|
|
5338
|
+
return "packets";
|
|
5339
|
+
case "sachet":
|
|
5340
|
+
return "sachets";
|
|
5341
|
+
case "stick-pack":
|
|
5342
|
+
return "stick-packs";
|
|
5149
5343
|
case "application":
|
|
5150
5344
|
return "applications";
|
|
5345
|
+
case "FTU":
|
|
5346
|
+
return "FTU";
|
|
5151
5347
|
case "fingertip unit":
|
|
5152
5348
|
return "fingertip units";
|
|
5153
5349
|
case "finger length":
|
|
@@ -5276,12 +5472,12 @@ function describeFrequencyCount(count) {
|
|
|
5276
5472
|
return `${stripTrailingZero(count)} times daily`;
|
|
5277
5473
|
}
|
|
5278
5474
|
function describeStandaloneOccurrenceCount(schedule) {
|
|
5279
|
-
var
|
|
5475
|
+
var _a2, _b, _c;
|
|
5280
5476
|
const count = schedule == null ? void 0 : schedule.count;
|
|
5281
5477
|
if (!count || count <= 0) {
|
|
5282
5478
|
return void 0;
|
|
5283
5479
|
}
|
|
5284
|
-
if ((schedule == null ? void 0 : schedule.frequency) !== void 0 || (schedule == null ? void 0 : schedule.frequencyMax) !== void 0 || (schedule == null ? void 0 : schedule.period) !== void 0 || (schedule == null ? void 0 : schedule.periodMax) !== void 0 || (schedule == null ? void 0 : schedule.periodUnit) !== void 0 || ((
|
|
5480
|
+
if ((schedule == null ? void 0 : schedule.frequency) !== void 0 || (schedule == null ? void 0 : schedule.frequencyMax) !== void 0 || (schedule == null ? void 0 : schedule.period) !== void 0 || (schedule == null ? void 0 : schedule.periodMax) !== void 0 || (schedule == null ? void 0 : schedule.periodUnit) !== void 0 || ((_a2 = schedule == null ? void 0 : schedule.dayOfWeek) == null ? void 0 : _a2.length) || ((_b = schedule == null ? void 0 : schedule.when) == null ? void 0 : _b.length) || ((_c = schedule == null ? void 0 : schedule.timeOfDay) == null ? void 0 : _c.length) || (schedule == null ? void 0 : schedule.duration) !== void 0 || (schedule == null ? void 0 : schedule.durationMax) !== void 0 || (schedule == null ? void 0 : schedule.durationUnit) !== void 0 || (schedule == null ? void 0 : schedule.timingCode)) {
|
|
5285
5481
|
return void 0;
|
|
5286
5482
|
}
|
|
5287
5483
|
switch (count) {
|
|
@@ -5373,8 +5569,8 @@ function summarizeMealTimingGroup(group) {
|
|
|
5373
5569
|
return `${relationText} ${joinWithAnd(group.meals)}`;
|
|
5374
5570
|
}
|
|
5375
5571
|
function collectWhenPhrases(schedule, options) {
|
|
5376
|
-
var
|
|
5377
|
-
const when = (
|
|
5572
|
+
var _a2, _b, _c;
|
|
5573
|
+
const when = (_a2 = schedule == null ? void 0 : schedule.when) != null ? _a2 : [];
|
|
5378
5574
|
if (!when.length) {
|
|
5379
5575
|
return [];
|
|
5380
5576
|
}
|
|
@@ -5471,14 +5667,14 @@ function combineFrequencyAndEvents(frequency, events) {
|
|
|
5471
5667
|
return { frequency, event: joinWithAnd(events) };
|
|
5472
5668
|
}
|
|
5473
5669
|
function buildRoutePhrase(clause, grammar, hasSite) {
|
|
5474
|
-
var
|
|
5670
|
+
var _a2, _b;
|
|
5475
5671
|
if (typeof grammar.routePhrase === "function") {
|
|
5476
5672
|
return grammar.routePhrase({ hasSite, clause });
|
|
5477
5673
|
}
|
|
5478
5674
|
if (typeof grammar.routePhrase === "string") {
|
|
5479
5675
|
return grammar.routePhrase;
|
|
5480
5676
|
}
|
|
5481
|
-
const text = (_b = (
|
|
5677
|
+
const text = (_b = (_a2 = clause.route) == null ? void 0 : _a2.text) == null ? void 0 : _b.trim();
|
|
5482
5678
|
if (!text) {
|
|
5483
5679
|
return void 0;
|
|
5484
5680
|
}
|
|
@@ -5525,11 +5721,11 @@ var ENGLISH_SPATIAL_PREPOSITIONS = {
|
|
|
5525
5721
|
under: "under"
|
|
5526
5722
|
};
|
|
5527
5723
|
function renderSpatialSiteEnglish(relation, grammar) {
|
|
5528
|
-
var
|
|
5724
|
+
var _a2, _b, _c, _d;
|
|
5529
5725
|
if (!(relation == null ? void 0 : relation.relationText)) {
|
|
5530
5726
|
return void 0;
|
|
5531
5727
|
}
|
|
5532
|
-
const rawTarget = (_b = relation.targetText) != null ? _b : (
|
|
5728
|
+
const rawTarget = (_b = relation.targetText) != null ? _b : (_a2 = relation.targetCoding) == null ? void 0 : _a2.display;
|
|
5533
5729
|
if (!rawTarget) {
|
|
5534
5730
|
return void 0;
|
|
5535
5731
|
}
|
|
@@ -5557,8 +5753,8 @@ function renderSpatialSiteEnglish(relation, grammar) {
|
|
|
5557
5753
|
}
|
|
5558
5754
|
}
|
|
5559
5755
|
function formatSite(clause, grammar) {
|
|
5560
|
-
var
|
|
5561
|
-
let text = (_b = (
|
|
5756
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
|
|
5757
|
+
let text = (_b = (_a2 = clause.site) == null ? void 0 : _a2.text) == null ? void 0 : _b.trim();
|
|
5562
5758
|
if (!text) {
|
|
5563
5759
|
const spatialSite = renderSpatialSiteEnglish((_c = clause.site) == null ? void 0 : _c.spatialRelation, grammar);
|
|
5564
5760
|
if (spatialSite) {
|
|
@@ -5603,8 +5799,8 @@ function formatSite(clause, grammar) {
|
|
|
5603
5799
|
return `${preposition} ${noun}`.trim();
|
|
5604
5800
|
}
|
|
5605
5801
|
function describeDayOfWeek(schedule) {
|
|
5606
|
-
var
|
|
5607
|
-
const dayOfWeek = (
|
|
5802
|
+
var _a2, _b;
|
|
5803
|
+
const dayOfWeek = (_a2 = schedule == null ? void 0 : schedule.dayOfWeek) != null ? _a2 : [];
|
|
5608
5804
|
if (!dayOfWeek.length) {
|
|
5609
5805
|
return void 0;
|
|
5610
5806
|
}
|
|
@@ -5651,8 +5847,8 @@ function describeDuration(schedule) {
|
|
|
5651
5847
|
return `for ${stripTrailingZero(schedule.duration)} ${label(schedule.duration)}`;
|
|
5652
5848
|
}
|
|
5653
5849
|
function shouldUseGenericMedicationObject(clause) {
|
|
5654
|
-
var
|
|
5655
|
-
const methodText = (_b = (
|
|
5850
|
+
var _a2, _b;
|
|
5851
|
+
const methodText = (_b = (_a2 = clause.method) == null ? void 0 : _a2.text) == null ? void 0 : _b.trim();
|
|
5656
5852
|
switch (methodText) {
|
|
5657
5853
|
case "Apply sunscreen":
|
|
5658
5854
|
case "Reapply sunscreen":
|
|
@@ -5663,8 +5859,8 @@ function shouldUseGenericMedicationObject(clause) {
|
|
|
5663
5859
|
}
|
|
5664
5860
|
}
|
|
5665
5861
|
function shouldSuppressRoutePhrase(clause, grammar, verb) {
|
|
5666
|
-
var
|
|
5667
|
-
if (((
|
|
5862
|
+
var _a2;
|
|
5863
|
+
if (((_a2 = clause.route) == null ? void 0 : _a2.code) !== RouteCode["Oral route"]) {
|
|
5668
5864
|
return false;
|
|
5669
5865
|
}
|
|
5670
5866
|
if (grammar.routePhrase !== "orally") {
|
|
@@ -5679,14 +5875,14 @@ function shouldSuppressRoutePhrase(clause, grammar, verb) {
|
|
|
5679
5875
|
}
|
|
5680
5876
|
}
|
|
5681
5877
|
function formatShort(clause) {
|
|
5682
|
-
var
|
|
5878
|
+
var _a2, _b, _c, _d, _e, _f;
|
|
5683
5879
|
const schedule = scheduleOf(clause);
|
|
5684
5880
|
const parts = [];
|
|
5685
5881
|
const dosePart = formatDoseShort(clause.dose);
|
|
5686
5882
|
if (dosePart) {
|
|
5687
5883
|
parts.push(dosePart);
|
|
5688
5884
|
}
|
|
5689
|
-
const routeCode = (
|
|
5885
|
+
const routeCode = (_a2 = clause.route) == null ? void 0 : _a2.code;
|
|
5690
5886
|
const routeText = (_b = clause.route) == null ? void 0 : _b.text;
|
|
5691
5887
|
if (routeCode) {
|
|
5692
5888
|
const short = ROUTE_SHORT[routeCode];
|
|
@@ -5744,7 +5940,7 @@ function formatShort(clause) {
|
|
|
5744
5940
|
return parts.filter(Boolean).join(" ");
|
|
5745
5941
|
}
|
|
5746
5942
|
function formatLong(clause, options) {
|
|
5747
|
-
var
|
|
5943
|
+
var _a2, _b, _c, _d, _e, _f;
|
|
5748
5944
|
const schedule = scheduleOf(clause);
|
|
5749
5945
|
const grammar = resolveRouteGrammar(clause);
|
|
5750
5946
|
const verb = resolveMethodVerb(clause, grammar);
|
|
@@ -5753,7 +5949,7 @@ function formatLong(clause, options) {
|
|
|
5753
5949
|
const sitePart = formatSite(clause, grammar);
|
|
5754
5950
|
const routePart = shouldSuppressRoutePhrase(clause, grammar, verb) ? void 0 : buildRoutePhrase(clause, grammar, Boolean(sitePart));
|
|
5755
5951
|
const standaloneOccurrenceCount = describeStandaloneOccurrenceCount(schedule);
|
|
5756
|
-
const frequencyPart = (_b = (
|
|
5952
|
+
const frequencyPart = (_b = (_a2 = describeFrequency(schedule)) != null ? _a2 : standaloneOccurrenceCount) != null ? _b : describeFrequencyCount(inferDailyOccurrenceCount(schedule, options));
|
|
5757
5953
|
const eventParts = collectWhenPhrases(schedule, options);
|
|
5758
5954
|
if ((_c = schedule.timeOfDay) == null ? void 0 : _c.length) {
|
|
5759
5955
|
const timeStrings = [];
|
|
@@ -5830,8 +6026,8 @@ function formatLong(clause, options) {
|
|
|
5830
6026
|
return trailingInstructionText ? `${baseSentence} ${trailingInstructionText}` : baseSentence;
|
|
5831
6027
|
}
|
|
5832
6028
|
function formatAdditionalInstructions(clause) {
|
|
5833
|
-
var
|
|
5834
|
-
const instructions = (
|
|
6029
|
+
var _a2, _b, _c, _d, _e, _f;
|
|
6030
|
+
const instructions = (_a2 = clause.additionalInstructions) != null ? _a2 : [];
|
|
5835
6031
|
if (!instructions.length) {
|
|
5836
6032
|
return void 0;
|
|
5837
6033
|
}
|
|
@@ -5966,6 +6162,12 @@ var advice_terminology_default = {
|
|
|
5966
6162
|
{ surface: "whole", lemma: "whole", partOfSpeech: "modifier", semanticClass: "amount_style" },
|
|
5967
6163
|
{ surface: "thin layer", lemma: "thin layer", partOfSpeech: "noun", semanticClass: "amount_style" },
|
|
5968
6164
|
{ surface: "thin film", lemma: "thin film", partOfSpeech: "noun", semanticClass: "amount_style" },
|
|
6165
|
+
{ surface: "thin coat", lemma: "thin layer", partOfSpeech: "noun", semanticClass: "amount_style" },
|
|
6166
|
+
{ surface: "thinly", lemma: "thin layer", partOfSpeech: "modifier", semanticClass: "amount_style" },
|
|
6167
|
+
{ surface: "thick layer", lemma: "thick layer", partOfSpeech: "noun", semanticClass: "amount_style" },
|
|
6168
|
+
{ surface: "thick coat", lemma: "thick layer", partOfSpeech: "noun", semanticClass: "amount_style" },
|
|
6169
|
+
{ surface: "thickly", lemma: "thick layer", partOfSpeech: "modifier", semanticClass: "amount_style" },
|
|
6170
|
+
{ surface: "gently", lemma: "gently", partOfSpeech: "modifier", semanticClass: "manner_style" },
|
|
5969
6171
|
{ surface: "sparingly", lemma: "sparingly", partOfSpeech: "modifier", semanticClass: "amount_style" },
|
|
5970
6172
|
{ surface: "liberally", lemma: "liberally", partOfSpeech: "modifier", semanticClass: "amount_style" },
|
|
5971
6173
|
{ surface: "slowly", lemma: "slowly", partOfSpeech: "modifier", semanticClass: "manner_style" },
|
|
@@ -6020,6 +6222,14 @@ var advice_terminology_default = {
|
|
|
6020
6222
|
{ surface: "dressing", lemma: "dressing", semanticClass: "material", conceptId: "dressing" },
|
|
6021
6223
|
{ surface: "affected area", lemma: "affected area", semanticClass: "site", conceptId: "affected_area" },
|
|
6022
6224
|
{ surface: "affected areas", lemma: "affected area", semanticClass: "site", conceptId: "affected_area" },
|
|
6225
|
+
{ surface: "thinly", lemma: "thin layer", semanticClass: "amount_style", conceptId: "thin_layer" },
|
|
6226
|
+
{ surface: "thin layer", lemma: "thin layer", semanticClass: "amount_style", conceptId: "thin_layer" },
|
|
6227
|
+
{ surface: "thin film", lemma: "thin layer", semanticClass: "amount_style", conceptId: "thin_layer" },
|
|
6228
|
+
{ surface: "thin coat", lemma: "thin layer", semanticClass: "amount_style", conceptId: "thin_layer" },
|
|
6229
|
+
{ surface: "thickly", lemma: "thick layer", semanticClass: "amount_style", conceptId: "thick_layer" },
|
|
6230
|
+
{ surface: "thick layer", lemma: "thick layer", semanticClass: "amount_style", conceptId: "thick_layer" },
|
|
6231
|
+
{ surface: "thick coat", lemma: "thick layer", semanticClass: "amount_style", conceptId: "thick_layer" },
|
|
6232
|
+
{ surface: "gently", lemma: "gently", semanticClass: "manner_style", conceptId: "gently" },
|
|
6023
6233
|
{ surface: "slowly", lemma: "slowly", semanticClass: "manner_style", conceptId: "slowly" }
|
|
6024
6234
|
]
|
|
6025
6235
|
};
|
|
@@ -6641,7 +6851,124 @@ var advice_rules_default = {
|
|
|
6641
6851
|
normalizedTexts: [
|
|
6642
6852
|
"liberally",
|
|
6643
6853
|
"apply liberally",
|
|
6644
|
-
"use liberally"
|
|
6854
|
+
"use liberally",
|
|
6855
|
+
"liberal amount",
|
|
6856
|
+
"a liberal amount",
|
|
6857
|
+
"apply liberal amount",
|
|
6858
|
+
"apply a liberal amount",
|
|
6859
|
+
"use liberal amount",
|
|
6860
|
+
"use a liberal amount",
|
|
6861
|
+
"generous amount",
|
|
6862
|
+
"a generous amount",
|
|
6863
|
+
"apply generous amount",
|
|
6864
|
+
"apply a generous amount",
|
|
6865
|
+
"use generous amount",
|
|
6866
|
+
"use a generous amount"
|
|
6867
|
+
]
|
|
6868
|
+
}
|
|
6869
|
+
},
|
|
6870
|
+
{
|
|
6871
|
+
id: "thin-layer",
|
|
6872
|
+
definition: {
|
|
6873
|
+
code: "420162004",
|
|
6874
|
+
display: "To be spread thinly",
|
|
6875
|
+
text: "Apply thinly",
|
|
6876
|
+
thai: "\u0E17\u0E32\u0E1A\u0E32\u0E07\u0E46"
|
|
6877
|
+
},
|
|
6878
|
+
frames: [
|
|
6879
|
+
{
|
|
6880
|
+
force: "instruction",
|
|
6881
|
+
predicate: { lemma: "apply", semanticClass: "administration" },
|
|
6882
|
+
args: [{ role: "amount", text: "thin layer", conceptId: "thin_layer" }]
|
|
6883
|
+
}
|
|
6884
|
+
],
|
|
6885
|
+
matcher: {
|
|
6886
|
+
normalizedTexts: [
|
|
6887
|
+
"thinly",
|
|
6888
|
+
"apply thinly",
|
|
6889
|
+
"use thinly",
|
|
6890
|
+
"thin layer",
|
|
6891
|
+
"a thin layer",
|
|
6892
|
+
"apply thin layer",
|
|
6893
|
+
"apply a thin layer",
|
|
6894
|
+
"use thin layer",
|
|
6895
|
+
"use a thin layer",
|
|
6896
|
+
"thin film",
|
|
6897
|
+
"a thin film",
|
|
6898
|
+
"apply thin film",
|
|
6899
|
+
"apply a thin film",
|
|
6900
|
+
"thin coat",
|
|
6901
|
+
"a thin coat",
|
|
6902
|
+
"apply thin coat",
|
|
6903
|
+
"apply a thin coat",
|
|
6904
|
+
"\u0E17\u0E32\u0E1A\u0E32\u0E07\u0E46",
|
|
6905
|
+
"\u0E17\u0E32\u0E1A\u0E32\u0E07 \u0E46",
|
|
6906
|
+
"\u0E1A\u0E32\u0E07\u0E46",
|
|
6907
|
+
"\u0E1A\u0E32\u0E07 \u0E46"
|
|
6908
|
+
]
|
|
6909
|
+
}
|
|
6910
|
+
},
|
|
6911
|
+
{
|
|
6912
|
+
id: "gently",
|
|
6913
|
+
definition: {
|
|
6914
|
+
code: "418449005",
|
|
6915
|
+
display: "Gently",
|
|
6916
|
+
text: "Apply gently",
|
|
6917
|
+
thai: "\u0E17\u0E32\u0E40\u0E1A\u0E32\u0E46"
|
|
6918
|
+
},
|
|
6919
|
+
frames: [
|
|
6920
|
+
{
|
|
6921
|
+
force: "instruction",
|
|
6922
|
+
predicate: { lemma: "apply", semanticClass: "administration" },
|
|
6923
|
+
args: [{ role: "free", text: "gently", conceptId: "gently" }]
|
|
6924
|
+
}
|
|
6925
|
+
],
|
|
6926
|
+
matcher: {
|
|
6927
|
+
normalizedTexts: [
|
|
6928
|
+
"gently",
|
|
6929
|
+
"apply gently",
|
|
6930
|
+
"use gently",
|
|
6931
|
+
"\u0E40\u0E1A\u0E32\u0E46",
|
|
6932
|
+
"\u0E40\u0E1A\u0E32 \u0E46",
|
|
6933
|
+
"\u0E17\u0E32\u0E40\u0E1A\u0E32\u0E46",
|
|
6934
|
+
"\u0E17\u0E32\u0E40\u0E1A\u0E32 \u0E46"
|
|
6935
|
+
]
|
|
6936
|
+
}
|
|
6937
|
+
},
|
|
6938
|
+
{
|
|
6939
|
+
id: "thick-layer",
|
|
6940
|
+
definition: {
|
|
6941
|
+
code: "246703001",
|
|
6942
|
+
display: "Thick",
|
|
6943
|
+
text: "Apply thickly",
|
|
6944
|
+
thai: "\u0E17\u0E32\u0E2B\u0E19\u0E32\u0E46"
|
|
6945
|
+
},
|
|
6946
|
+
frames: [
|
|
6947
|
+
{
|
|
6948
|
+
force: "instruction",
|
|
6949
|
+
predicate: { lemma: "apply", semanticClass: "administration" },
|
|
6950
|
+
args: [{ role: "amount", text: "thick layer", conceptId: "thick_layer" }]
|
|
6951
|
+
}
|
|
6952
|
+
],
|
|
6953
|
+
matcher: {
|
|
6954
|
+
normalizedTexts: [
|
|
6955
|
+
"thickly",
|
|
6956
|
+
"apply thickly",
|
|
6957
|
+
"use thickly",
|
|
6958
|
+
"thick layer",
|
|
6959
|
+
"a thick layer",
|
|
6960
|
+
"apply thick layer",
|
|
6961
|
+
"apply a thick layer",
|
|
6962
|
+
"use thick layer",
|
|
6963
|
+
"use a thick layer",
|
|
6964
|
+
"thick coat",
|
|
6965
|
+
"a thick coat",
|
|
6966
|
+
"apply thick coat",
|
|
6967
|
+
"apply a thick coat",
|
|
6968
|
+
"\u0E17\u0E32\u0E2B\u0E19\u0E32\u0E46",
|
|
6969
|
+
"\u0E17\u0E32\u0E2B\u0E19\u0E32 \u0E46",
|
|
6970
|
+
"\u0E2B\u0E19\u0E32\u0E46",
|
|
6971
|
+
"\u0E2B\u0E19\u0E32 \u0E46"
|
|
6645
6972
|
]
|
|
6646
6973
|
}
|
|
6647
6974
|
},
|
|
@@ -6879,7 +7206,8 @@ var PER_SLASH_UNITS = /* @__PURE__ */ new Set([
|
|
|
6879
7206
|
"minute",
|
|
6880
7207
|
"minutes"
|
|
6881
7208
|
]);
|
|
6882
|
-
var COMPACT_DISCRETE_UNITS_PATTERN = /^(tab|tabs|tablet|tablets|cap|caps|capsule|capsules|mg|mcg|ml|g|drops|drop|puff|puffs|spray|sprays|patch|patches)$/i;
|
|
7209
|
+
var COMPACT_DISCRETE_UNITS_PATTERN = /^(tab|tabs|tablet|tablets|cap|caps|capsule|capsules|mg|mcg|ml|g|drops|drop|gtt|gtts|eyedrop|eyedrops|puff|puffs|spray|sprays|pump|pumps|ftu|ftus|patch|patches|ring|rings|tube|tubes|bottle|bottles|container|containers|palm|palms|handprint|handprints|click|clicks|vial|vials|ampule|ampules|packet|packets|sachet|sachets|stick-pack|stick-packs|pea-sized)$/i;
|
|
7210
|
+
var COMPACT_DISCRETE_UNIT_SUFFIX_PATTERN = /^[A-Za-z-]+$/;
|
|
6883
7211
|
function classifyLexKind(value) {
|
|
6884
7212
|
const lower = value.toLowerCase();
|
|
6885
7213
|
if (/^[0-9]+(?:\.[0-9]+)?$/.test(lower)) {
|
|
@@ -7015,7 +7343,7 @@ function splitCompactToken(token) {
|
|
|
7015
7343
|
if (/^[0-9]+(?:\.[0-9]+)?$/.test(token)) {
|
|
7016
7344
|
return [token];
|
|
7017
7345
|
}
|
|
7018
|
-
const compactTimesWord = token.match(/^([0-9]+(?:\.[0-9]+)?[x*])([A-Za-z]+)$/i);
|
|
7346
|
+
const compactTimesWord = token.match(/^([0-9]+(?:\.[0-9]+)?[x*])([A-Za-z-]+)$/i);
|
|
7019
7347
|
if (compactTimesWord) {
|
|
7020
7348
|
return [compactTimesWord[1], compactTimesWord[2]];
|
|
7021
7349
|
}
|
|
@@ -7026,11 +7354,11 @@ function splitCompactToken(token) {
|
|
|
7026
7354
|
if (/^[A-Za-z]+$/.test(token)) {
|
|
7027
7355
|
return [token];
|
|
7028
7356
|
}
|
|
7029
|
-
const qRange = token.match(/^q([0-9]+(?:\.[0-9]+)?)-([0-9]+(?:\.[0-9]+)?)([A-Za-z]+)$/i);
|
|
7357
|
+
const qRange = token.match(/^q([0-9]+(?:\.[0-9]+)?)-([0-9]+(?:\.[0-9]+)?)([A-Za-z-]+)$/i);
|
|
7030
7358
|
if (qRange) {
|
|
7031
7359
|
return [token.charAt(0), `${qRange[1]}-${qRange[2]}`, qRange[3]];
|
|
7032
7360
|
}
|
|
7033
|
-
const match = token.match(/^([0-9]+(?:\.[0-9]+)?)([A-Za-z]+)$/);
|
|
7361
|
+
const match = token.match(/^([0-9]+(?:\.[0-9]+)?)([A-Za-z-]+)$/);
|
|
7034
7362
|
if (match) {
|
|
7035
7363
|
const [, numberPart, suffix] = match;
|
|
7036
7364
|
if (/^(st|nd|rd|th)$/i.test(suffix)) {
|
|
@@ -7207,9 +7535,9 @@ function pushTextToken(output, surface, input) {
|
|
|
7207
7535
|
}
|
|
7208
7536
|
}
|
|
7209
7537
|
const compactDiscrete = surface.original.match(
|
|
7210
|
-
/^([0-9]+(?:\.[0-9]+)?)([A-Za-z]+)$/
|
|
7538
|
+
/^([0-9]+(?:\.[0-9]+)?)([A-Za-z-]+)$/
|
|
7211
7539
|
);
|
|
7212
|
-
if (compactDiscrete && COMPACT_DISCRETE_UNITS_PATTERN.test(compactDiscrete[2])) {
|
|
7540
|
+
if (compactDiscrete && COMPACT_DISCRETE_UNIT_SUFFIX_PATTERN.test(compactDiscrete[2]) && COMPACT_DISCRETE_UNITS_PATTERN.test(compactDiscrete[2])) {
|
|
7213
7541
|
pushSplitParts(output, surface, [compactDiscrete[1], compactDiscrete[2]], input);
|
|
7214
7542
|
return;
|
|
7215
7543
|
}
|
|
@@ -7428,9 +7756,11 @@ function cleanFreeText(value) {
|
|
|
7428
7756
|
return collapseWhitespace(value.slice(start, end));
|
|
7429
7757
|
}
|
|
7430
7758
|
function createDefinitionFromSource(source) {
|
|
7759
|
+
var _a2;
|
|
7760
|
+
const system = ((_a2 = source.system) == null ? void 0 : _a2.trim()) || SNOMED_SYSTEM4;
|
|
7431
7761
|
return {
|
|
7432
7762
|
coding: {
|
|
7433
|
-
system
|
|
7763
|
+
system,
|
|
7434
7764
|
code: source.code,
|
|
7435
7765
|
display: source.display
|
|
7436
7766
|
},
|
|
@@ -7734,9 +8064,9 @@ function matchesAdviceMatcher(frames, normalizedText, matcher) {
|
|
|
7734
8064
|
return false;
|
|
7735
8065
|
}
|
|
7736
8066
|
function findRuleByCoding(system, code) {
|
|
7737
|
-
var
|
|
8067
|
+
var _a2, _b;
|
|
7738
8068
|
for (const rule of ADDITIONAL_INSTRUCTION_RULES) {
|
|
7739
|
-
if (((
|
|
8069
|
+
if (((_a2 = rule.definition.coding) == null ? void 0 : _a2.system) !== system) {
|
|
7740
8070
|
continue;
|
|
7741
8071
|
}
|
|
7742
8072
|
if (((_b = rule.definition.coding) == null ? void 0 : _b.code) !== code) {
|
|
@@ -7849,8 +8179,8 @@ function findVerbLexeme(word) {
|
|
|
7849
8179
|
return findNormalizedLexeme(word, "verb");
|
|
7850
8180
|
}
|
|
7851
8181
|
function findVerbLemma(word) {
|
|
7852
|
-
var
|
|
7853
|
-
return (
|
|
8182
|
+
var _a2;
|
|
8183
|
+
return (_a2 = findVerbLexeme(word)) == null ? void 0 : _a2.lemma;
|
|
7854
8184
|
}
|
|
7855
8185
|
function findModalLexeme(word) {
|
|
7856
8186
|
const entry = findNormalizedLexeme(word, "modifier");
|
|
@@ -7962,7 +8292,7 @@ function parseLeadingClauseFeatures(words) {
|
|
|
7962
8292
|
};
|
|
7963
8293
|
}
|
|
7964
8294
|
function deriveClauseForce(sequenceCount, context, predicateLemma, predicateSemanticClass, polarity, modality) {
|
|
7965
|
-
var
|
|
8295
|
+
var _a2;
|
|
7966
8296
|
if (sequenceCount > 1) {
|
|
7967
8297
|
return "sequence" /* Sequence */;
|
|
7968
8298
|
}
|
|
@@ -7995,7 +8325,7 @@ function deriveClauseForce(sequenceCount, context, predicateLemma, predicateSema
|
|
|
7995
8325
|
default:
|
|
7996
8326
|
break;
|
|
7997
8327
|
}
|
|
7998
|
-
return (
|
|
8328
|
+
return (_a2 = context.defaultForce) != null ? _a2 : "instruction" /* Instruction */;
|
|
7999
8329
|
}
|
|
8000
8330
|
function containsNegatedVerb(words, lemma) {
|
|
8001
8331
|
for (let index = 0; index < words.length; index += 1) {
|
|
@@ -8264,11 +8594,11 @@ function skipLeadingNoise(words) {
|
|
|
8264
8594
|
return cursor;
|
|
8265
8595
|
}
|
|
8266
8596
|
function createDefaultForce(sequenceCount, sequenceIndex, context) {
|
|
8267
|
-
var
|
|
8597
|
+
var _a2;
|
|
8268
8598
|
if (sequenceCount > 1 || sequenceIndex > 0) {
|
|
8269
8599
|
return "sequence" /* Sequence */;
|
|
8270
8600
|
}
|
|
8271
|
-
return (
|
|
8601
|
+
return (_a2 = context.defaultForce) != null ? _a2 : "instruction" /* Instruction */;
|
|
8272
8602
|
}
|
|
8273
8603
|
function tryParseRelationInstruction(sourceText, span, context, sequenceIndex, sequenceCount) {
|
|
8274
8604
|
const words = normalizeWords(sourceText);
|
|
@@ -8633,7 +8963,7 @@ function tryParseClauseInstruction(sourceText, span, context, sequenceIndex, seq
|
|
|
8633
8963
|
return frames;
|
|
8634
8964
|
}
|
|
8635
8965
|
function parseSequenceFrames(sourceText, span, context) {
|
|
8636
|
-
var
|
|
8966
|
+
var _a2, _b, _c, _d, _e;
|
|
8637
8967
|
const sequenceSegments = splitSequenceSegments(sourceText, span);
|
|
8638
8968
|
if (!sequenceSegments.length) {
|
|
8639
8969
|
return [];
|
|
@@ -8641,7 +8971,7 @@ function parseSequenceFrames(sourceText, span, context) {
|
|
|
8641
8971
|
const frames = [];
|
|
8642
8972
|
for (let index = 0; index < sequenceSegments.length; index++) {
|
|
8643
8973
|
const segment = sequenceSegments[index];
|
|
8644
|
-
const parsed = (_e = (_d = (_c = (_b = (
|
|
8974
|
+
const parsed = (_e = (_d = (_c = (_b = (_a2 = tryParseRelationInstruction(segment.text, segment.range, context, index, sequenceSegments.length)) != null ? _a2 : tryParseImplicitConceptInstruction(segment.text, segment.range, context, index, sequenceSegments.length)) != null ? _b : tryParseStyleInstruction(segment.text, segment.range, context, index, sequenceSegments.length)) != null ? _c : tryParseNoObjectInstruction(segment.text, segment.range, index, sequenceSegments.length)) != null ? _d : tryParseEllipticalEffectInstruction(
|
|
8645
8975
|
segment.text,
|
|
8646
8976
|
segment.range,
|
|
8647
8977
|
context,
|
|
@@ -8767,9 +9097,9 @@ function realizeAdviceFramesText(frames) {
|
|
|
8767
9097
|
return realized ? capitalizeSentence(realized) : void 0;
|
|
8768
9098
|
}
|
|
8769
9099
|
function parseAdditionalInstructions(sourceText, span, context) {
|
|
8770
|
-
var
|
|
9100
|
+
var _a2, _b, _c, _d, _e;
|
|
8771
9101
|
const effectiveContext = {
|
|
8772
|
-
defaultPredicate: (
|
|
9102
|
+
defaultPredicate: (_a2 = context == null ? void 0 : context.defaultPredicate) != null ? _a2 : DEFAULT_INSTRUCTION_CONTEXT.defaultPredicate,
|
|
8773
9103
|
defaultForce: (_b = context == null ? void 0 : context.defaultForce) != null ? _b : DEFAULT_INSTRUCTION_CONTEXT.defaultForce,
|
|
8774
9104
|
allowFreeTextFallback: (_c = context == null ? void 0 : context.allowFreeTextFallback) != null ? _c : DEFAULT_INSTRUCTION_CONTEXT.allowFreeTextFallback
|
|
8775
9105
|
};
|
|
@@ -8803,16 +9133,16 @@ function parseAdditionalInstructions(sourceText, span, context) {
|
|
|
8803
9133
|
return instructions;
|
|
8804
9134
|
}
|
|
8805
9135
|
function findAdditionalInstructionDefinitionByCoding(system, code) {
|
|
8806
|
-
var
|
|
8807
|
-
return (
|
|
9136
|
+
var _a2;
|
|
9137
|
+
return (_a2 = findRuleByCoding(system, code)) == null ? void 0 : _a2.definition;
|
|
8808
9138
|
}
|
|
8809
9139
|
function buildAdditionalInstructionFramesFromCoding(system, code, sourceText, span) {
|
|
8810
|
-
var
|
|
9140
|
+
var _a2, _b, _c;
|
|
8811
9141
|
const rule = findRuleByCoding(system, code);
|
|
8812
9142
|
if (!rule) {
|
|
8813
9143
|
return void 0;
|
|
8814
9144
|
}
|
|
8815
|
-
const resolvedText = (_c = (_b = sourceText != null ? sourceText : rule.definition.text) != null ? _b : (
|
|
9145
|
+
const resolvedText = (_c = (_b = sourceText != null ? sourceText : rule.definition.text) != null ? _b : (_a2 = rule.definition.coding) == null ? void 0 : _a2.display) != null ? _c : "";
|
|
8816
9146
|
const resolvedSpan = span != null ? span : { start: 0, end: resolvedText.length };
|
|
8817
9147
|
return instantiateTemplateFrames(rule.frames, resolvedText, resolvedSpan);
|
|
8818
9148
|
}
|
|
@@ -8876,12 +9206,12 @@ function pluralizeBodySiteText(text) {
|
|
|
8876
9206
|
return `${normalized}s`;
|
|
8877
9207
|
}
|
|
8878
9208
|
function toBodySiteCode(coding) {
|
|
8879
|
-
var
|
|
9209
|
+
var _a2;
|
|
8880
9210
|
if (!(coding == null ? void 0 : coding.code)) {
|
|
8881
9211
|
return void 0;
|
|
8882
9212
|
}
|
|
8883
9213
|
return {
|
|
8884
|
-
system: (
|
|
9214
|
+
system: (_a2 = coding.system) != null ? _a2 : SNOMED_SYSTEM,
|
|
8885
9215
|
code: coding.code,
|
|
8886
9216
|
display: coding.display,
|
|
8887
9217
|
i18n: "i18n" in coding ? coding.i18n : void 0
|
|
@@ -8901,11 +9231,11 @@ function resultFromResolved(resolved, matchedText, score) {
|
|
|
8901
9231
|
};
|
|
8902
9232
|
}
|
|
8903
9233
|
function bodySiteLookupRequest(input, resolved, options) {
|
|
8904
|
-
var
|
|
9234
|
+
var _a2, _b;
|
|
8905
9235
|
const normalized = normalizeBodySiteKey(input);
|
|
8906
9236
|
return {
|
|
8907
9237
|
originalText: input,
|
|
8908
|
-
text: (
|
|
9238
|
+
text: (_a2 = resolved == null ? void 0 : resolved.displayText) != null ? _a2 : input.trim(),
|
|
8909
9239
|
normalized,
|
|
8910
9240
|
canonical: (_b = resolved == null ? void 0 : resolved.canonical) != null ? _b : normalized,
|
|
8911
9241
|
bodySiteContext: options == null ? void 0 : options.bodySiteContext,
|
|
@@ -8913,18 +9243,18 @@ function bodySiteLookupRequest(input, resolved, options) {
|
|
|
8913
9243
|
};
|
|
8914
9244
|
}
|
|
8915
9245
|
function applyResolverDefinition(result, definition) {
|
|
8916
|
-
var
|
|
9246
|
+
var _a2, _b;
|
|
8917
9247
|
return __spreadProps(__spreadValues({}, result), {
|
|
8918
|
-
text: (
|
|
9248
|
+
text: (_a2 = definition.text) != null ? _a2 : result.text,
|
|
8919
9249
|
coding: toBodySiteCode(definition.coding),
|
|
8920
9250
|
spatialRelation: (_b = definition.spatialRelation) != null ? _b : result.spatialRelation,
|
|
8921
9251
|
definition
|
|
8922
9252
|
});
|
|
8923
9253
|
}
|
|
8924
9254
|
function resultFromResolverDefinition(input, definition) {
|
|
8925
|
-
var
|
|
9255
|
+
var _a2;
|
|
8926
9256
|
const normalized = normalizeBodySiteKey(input);
|
|
8927
|
-
const text = (
|
|
9257
|
+
const text = (_a2 = definition.text) != null ? _a2 : normalized;
|
|
8928
9258
|
return {
|
|
8929
9259
|
text,
|
|
8930
9260
|
canonical: normalizeBodySiteKey(text),
|
|
@@ -8980,12 +9310,12 @@ function addCandidate(candidates, phrase, definition) {
|
|
|
8980
9310
|
candidates.push({ phrase: normalized, definition });
|
|
8981
9311
|
}
|
|
8982
9312
|
function addDefinitionCandidates(candidates, definition) {
|
|
8983
|
-
var
|
|
9313
|
+
var _a2;
|
|
8984
9314
|
if (!definition) {
|
|
8985
9315
|
return;
|
|
8986
9316
|
}
|
|
8987
9317
|
addCandidate(candidates, definition.text, definition);
|
|
8988
|
-
for (const alias of (
|
|
9318
|
+
for (const alias of (_a2 = definition.aliases) != null ? _a2 : []) {
|
|
8989
9319
|
addCandidate(candidates, alias, definition);
|
|
8990
9320
|
}
|
|
8991
9321
|
}
|
|
@@ -9006,21 +9336,21 @@ function collectBodySiteCandidates(siteCodeMap) {
|
|
|
9006
9336
|
return candidates;
|
|
9007
9337
|
}
|
|
9008
9338
|
function codeFromInput(input, options) {
|
|
9009
|
-
var
|
|
9339
|
+
var _a2;
|
|
9010
9340
|
if (typeof input === "string") {
|
|
9011
9341
|
const normalized = input.trim();
|
|
9012
|
-
return normalized ? { code: normalized, system: (
|
|
9342
|
+
return normalized ? { code: normalized, system: (_a2 = options == null ? void 0 : options.system) != null ? _a2 : SNOMED_SYSTEM } : void 0;
|
|
9013
9343
|
}
|
|
9014
9344
|
return toBodySiteCode(input);
|
|
9015
9345
|
}
|
|
9016
9346
|
function bodySiteCodeFromInput(input, options) {
|
|
9017
|
-
var
|
|
9347
|
+
var _a2, _b;
|
|
9018
9348
|
const coding = codeFromInput(input, options);
|
|
9019
9349
|
const shouldParsePostcoordination = (options == null ? void 0 : options.postcoordination) !== false && (options == null ? void 0 : options.parsePostcoordination) !== false;
|
|
9020
9350
|
const parsedTopographicalModifier = shouldParsePostcoordination ? parseSnomedBodySiteTopographicalModifierPostcoordinationCode(coding == null ? void 0 : coding.code) : void 0;
|
|
9021
9351
|
if (parsedTopographicalModifier) {
|
|
9022
9352
|
return {
|
|
9023
|
-
system: (
|
|
9353
|
+
system: (_a2 = coding == null ? void 0 : coding.system) != null ? _a2 : SNOMED_SYSTEM,
|
|
9024
9354
|
code: parsedTopographicalModifier.siteCode
|
|
9025
9355
|
};
|
|
9026
9356
|
}
|
|
@@ -9048,24 +9378,24 @@ function parsedPostcoordinationForInput(input, options) {
|
|
|
9048
9378
|
};
|
|
9049
9379
|
}
|
|
9050
9380
|
function findBodySiteTextByCode(coding, siteCodeMap) {
|
|
9051
|
-
var
|
|
9381
|
+
var _a2;
|
|
9052
9382
|
for (const candidate of collectBodySiteCandidates(siteCodeMap)) {
|
|
9053
|
-
if (codeMatches(coding, (
|
|
9383
|
+
if (codeMatches(coding, (_a2 = candidate.definition) == null ? void 0 : _a2.coding)) {
|
|
9054
9384
|
return definitionText(candidate.phrase, candidate.definition);
|
|
9055
9385
|
}
|
|
9056
9386
|
}
|
|
9057
9387
|
return void 0;
|
|
9058
9388
|
}
|
|
9059
9389
|
function definitionText(phrase, definition) {
|
|
9060
|
-
var
|
|
9061
|
-
return (
|
|
9390
|
+
var _a2;
|
|
9391
|
+
return (_a2 = definition == null ? void 0 : definition.text) != null ? _a2 : normalizeBodySiteKey(phrase);
|
|
9062
9392
|
}
|
|
9063
9393
|
function codeMatches(left, right) {
|
|
9064
|
-
var
|
|
9394
|
+
var _a2, _b;
|
|
9065
9395
|
if (!(right == null ? void 0 : right.code)) {
|
|
9066
9396
|
return false;
|
|
9067
9397
|
}
|
|
9068
|
-
const leftSystem = (
|
|
9398
|
+
const leftSystem = (_a2 = left.system) != null ? _a2 : SNOMED_SYSTEM;
|
|
9069
9399
|
const rightSystem = (_b = right.system) != null ? _b : SNOMED_SYSTEM;
|
|
9070
9400
|
return left.code === right.code && leftSystem === rightSystem;
|
|
9071
9401
|
}
|
|
@@ -9147,11 +9477,11 @@ function scoreCandidate(query, candidate) {
|
|
|
9147
9477
|
return 0;
|
|
9148
9478
|
}
|
|
9149
9479
|
function spatialRelationKey(relation) {
|
|
9150
|
-
var
|
|
9480
|
+
var _a2, _b, _c, _d, _e;
|
|
9151
9481
|
if (!relation) {
|
|
9152
9482
|
return "";
|
|
9153
9483
|
}
|
|
9154
|
-
const relationCode = (_b = (
|
|
9484
|
+
const relationCode = (_b = (_a2 = relation.relationCoding) == null ? void 0 : _a2.code) != null ? _b : "";
|
|
9155
9485
|
const targetCode = (_d = (_c = relation.targetCoding) == null ? void 0 : _c.code) != null ? _d : "";
|
|
9156
9486
|
return [
|
|
9157
9487
|
relation.relationText,
|
|
@@ -9161,9 +9491,9 @@ function spatialRelationKey(relation) {
|
|
|
9161
9491
|
].join("|");
|
|
9162
9492
|
}
|
|
9163
9493
|
function resultKey(result) {
|
|
9164
|
-
var
|
|
9494
|
+
var _a2, _b;
|
|
9165
9495
|
const relation = spatialRelationKey(result.spatialRelation);
|
|
9166
|
-
if ((
|
|
9496
|
+
if ((_a2 = result.coding) == null ? void 0 : _a2.code) {
|
|
9167
9497
|
return `${(_b = result.coding.system) != null ? _b : SNOMED_SYSTEM}|${result.coding.code}|${relation}`;
|
|
9168
9498
|
}
|
|
9169
9499
|
return `${result.canonical}|${relation}`;
|
|
@@ -9194,16 +9524,16 @@ function sortedSetValues(values) {
|
|
|
9194
9524
|
return Array.from(values).sort((left, right) => left.localeCompare(right));
|
|
9195
9525
|
}
|
|
9196
9526
|
function canBuildTopographicalModifierPostcoordination(relation) {
|
|
9197
|
-
var
|
|
9198
|
-
if (!((
|
|
9527
|
+
var _a2, _b;
|
|
9528
|
+
if (!((_a2 = relation == null ? void 0 : relation.relationCoding) == null ? void 0 : _a2.code) || !((_b = relation.targetCoding) == null ? void 0 : _b.code)) {
|
|
9199
9529
|
return false;
|
|
9200
9530
|
}
|
|
9201
9531
|
return POSTCOORDINATABLE_RELATION_TEXTS.has(normalizeBodySiteKey(relation.relationText)) || POSTCOORDINATABLE_RELATION_CODES.has(relation.relationCoding.code);
|
|
9202
9532
|
}
|
|
9203
9533
|
function buildSpatialRelationDisplayText(relation) {
|
|
9204
|
-
var
|
|
9534
|
+
var _a2;
|
|
9205
9535
|
const relationText = normalizeBodySiteKey(relation.relationText);
|
|
9206
|
-
const targetText = normalizeBodySiteKey((
|
|
9536
|
+
const targetText = normalizeBodySiteKey((_a2 = relation.targetText) != null ? _a2 : "");
|
|
9207
9537
|
if (!relationText || !targetText) {
|
|
9208
9538
|
return void 0;
|
|
9209
9539
|
}
|
|
@@ -9224,14 +9554,14 @@ function buildSpatialRelationDisplayText(relation) {
|
|
|
9224
9554
|
}
|
|
9225
9555
|
}
|
|
9226
9556
|
function buildBodySiteTopographicalModifierCoding(relation, display, options) {
|
|
9227
|
-
var
|
|
9557
|
+
var _a2, _b;
|
|
9228
9558
|
if ((options == null ? void 0 : options.postcoordination) === false) {
|
|
9229
9559
|
return void 0;
|
|
9230
9560
|
}
|
|
9231
9561
|
if (!canBuildTopographicalModifierPostcoordination(relation)) {
|
|
9232
9562
|
return void 0;
|
|
9233
9563
|
}
|
|
9234
|
-
const targetSystem = (
|
|
9564
|
+
const targetSystem = (_a2 = relation.targetCoding.system) != null ? _a2 : SNOMED_SYSTEM;
|
|
9235
9565
|
const relationSystem = (_b = relation.relationCoding.system) != null ? _b : SNOMED_SYSTEM;
|
|
9236
9566
|
if (targetSystem !== SNOMED_SYSTEM || relationSystem !== SNOMED_SYSTEM) {
|
|
9237
9567
|
return void 0;
|
|
@@ -9264,12 +9594,12 @@ function lookupBodySiteAsync(input, options) {
|
|
|
9264
9594
|
});
|
|
9265
9595
|
}
|
|
9266
9596
|
function getBodySiteCode(input, options) {
|
|
9267
|
-
var
|
|
9597
|
+
var _a2;
|
|
9268
9598
|
const resolved = lookupBodySite(input, options);
|
|
9269
9599
|
if (!resolved) {
|
|
9270
9600
|
return void 0;
|
|
9271
9601
|
}
|
|
9272
|
-
return (
|
|
9602
|
+
return (_a2 = resolved.coding) != null ? _a2 : buildBodySiteTopographicalModifierCoding(
|
|
9273
9603
|
resolved.spatialRelation,
|
|
9274
9604
|
resolved.text,
|
|
9275
9605
|
options
|
|
@@ -9277,12 +9607,12 @@ function getBodySiteCode(input, options) {
|
|
|
9277
9607
|
}
|
|
9278
9608
|
function getBodySiteCodeAsync(input, options) {
|
|
9279
9609
|
return __async(this, null, function* () {
|
|
9280
|
-
var
|
|
9610
|
+
var _a2;
|
|
9281
9611
|
const resolved = yield lookupBodySiteAsync(input, options);
|
|
9282
9612
|
if (!resolved) {
|
|
9283
9613
|
return void 0;
|
|
9284
9614
|
}
|
|
9285
|
-
return (
|
|
9615
|
+
return (_a2 = resolved.coding) != null ? _a2 : buildBodySiteTopographicalModifierCoding(
|
|
9286
9616
|
resolved.spatialRelation,
|
|
9287
9617
|
resolved.text,
|
|
9288
9618
|
options
|
|
@@ -9290,7 +9620,7 @@ function getBodySiteCodeAsync(input, options) {
|
|
|
9290
9620
|
});
|
|
9291
9621
|
}
|
|
9292
9622
|
function getBodySiteText(input, options) {
|
|
9293
|
-
var
|
|
9623
|
+
var _a2;
|
|
9294
9624
|
const originalCoding = codeFromInput(input, options);
|
|
9295
9625
|
const coding = bodySiteCodeFromInput(input, options);
|
|
9296
9626
|
if (!coding) {
|
|
@@ -9316,7 +9646,7 @@ function getBodySiteText(input, options) {
|
|
|
9316
9646
|
if (!text && parsed.laterality) {
|
|
9317
9647
|
const baseText = findBodySiteTextByCode(
|
|
9318
9648
|
{
|
|
9319
|
-
system: (
|
|
9649
|
+
system: (_a2 = originalCoding == null ? void 0 : originalCoding.system) != null ? _a2 : SNOMED_SYSTEM,
|
|
9320
9650
|
code: parsed.laterality.siteCode
|
|
9321
9651
|
},
|
|
9322
9652
|
options == null ? void 0 : options.siteCodeMap
|
|
@@ -9363,12 +9693,12 @@ function getBodySiteTextAsync(input, options) {
|
|
|
9363
9693
|
});
|
|
9364
9694
|
}
|
|
9365
9695
|
function suggestBodySites(input, options) {
|
|
9366
|
-
var
|
|
9696
|
+
var _a2;
|
|
9367
9697
|
const query = normalizeBodySiteKey(input);
|
|
9368
9698
|
if (!query) {
|
|
9369
9699
|
return [];
|
|
9370
9700
|
}
|
|
9371
|
-
const limit = (
|
|
9701
|
+
const limit = (_a2 = options == null ? void 0 : options.limit) != null ? _a2 : 10;
|
|
9372
9702
|
if (limit <= 0) {
|
|
9373
9703
|
return [];
|
|
9374
9704
|
}
|
|
@@ -9397,8 +9727,8 @@ function suggestBodySiteText(input, options) {
|
|
|
9397
9727
|
return uniqueText(suggestBodySites(input, options));
|
|
9398
9728
|
}
|
|
9399
9729
|
function listSupportedBodySiteText(options) {
|
|
9400
|
-
var
|
|
9401
|
-
const limit = (
|
|
9730
|
+
var _a2;
|
|
9731
|
+
const limit = (_a2 = options == null ? void 0 : options.limit) != null ? _a2 : Number.POSITIVE_INFINITY;
|
|
9402
9732
|
if (limit <= 0) {
|
|
9403
9733
|
return [];
|
|
9404
9734
|
}
|
|
@@ -9469,43 +9799,43 @@ var ParserState = class {
|
|
|
9469
9799
|
return this.clause;
|
|
9470
9800
|
}
|
|
9471
9801
|
get dose() {
|
|
9472
|
-
var
|
|
9473
|
-
return (
|
|
9802
|
+
var _a2;
|
|
9803
|
+
return (_a2 = this.clause.dose) == null ? void 0 : _a2.value;
|
|
9474
9804
|
}
|
|
9475
9805
|
set dose(value) {
|
|
9476
9806
|
this.ensureDose().value = value;
|
|
9477
9807
|
}
|
|
9478
9808
|
get doseRange() {
|
|
9479
|
-
var
|
|
9480
|
-
return (
|
|
9809
|
+
var _a2;
|
|
9810
|
+
return (_a2 = this.clause.dose) == null ? void 0 : _a2.range;
|
|
9481
9811
|
}
|
|
9482
9812
|
set doseRange(value) {
|
|
9483
9813
|
this.ensureDose().range = value;
|
|
9484
9814
|
}
|
|
9485
9815
|
get unit() {
|
|
9486
|
-
var
|
|
9487
|
-
return (
|
|
9816
|
+
var _a2;
|
|
9817
|
+
return (_a2 = this.clause.dose) == null ? void 0 : _a2.unit;
|
|
9488
9818
|
}
|
|
9489
9819
|
set unit(value) {
|
|
9490
9820
|
this.ensureDose().unit = value;
|
|
9491
9821
|
}
|
|
9492
9822
|
get routeCode() {
|
|
9493
|
-
var
|
|
9494
|
-
return (
|
|
9823
|
+
var _a2;
|
|
9824
|
+
return (_a2 = this.clause.route) == null ? void 0 : _a2.code;
|
|
9495
9825
|
}
|
|
9496
9826
|
set routeCode(value) {
|
|
9497
9827
|
this.ensureRoute().code = value;
|
|
9498
9828
|
}
|
|
9499
9829
|
get routeText() {
|
|
9500
|
-
var
|
|
9501
|
-
return (
|
|
9830
|
+
var _a2;
|
|
9831
|
+
return (_a2 = this.clause.route) == null ? void 0 : _a2.text;
|
|
9502
9832
|
}
|
|
9503
9833
|
set routeText(value) {
|
|
9504
9834
|
this.ensureRoute().text = value;
|
|
9505
9835
|
}
|
|
9506
9836
|
get methodText() {
|
|
9507
|
-
var
|
|
9508
|
-
return (
|
|
9837
|
+
var _a2;
|
|
9838
|
+
return (_a2 = this.clause.method) == null ? void 0 : _a2.text;
|
|
9509
9839
|
}
|
|
9510
9840
|
set methodText(value) {
|
|
9511
9841
|
if (value === void 0) {
|
|
@@ -9518,8 +9848,8 @@ var ParserState = class {
|
|
|
9518
9848
|
this.ensureMethod().text = value;
|
|
9519
9849
|
}
|
|
9520
9850
|
get methodTextElement() {
|
|
9521
|
-
var
|
|
9522
|
-
return (
|
|
9851
|
+
var _a2;
|
|
9852
|
+
return (_a2 = this.clause.method) == null ? void 0 : _a2._text;
|
|
9523
9853
|
}
|
|
9524
9854
|
set methodTextElement(value) {
|
|
9525
9855
|
if (value === void 0) {
|
|
@@ -9532,8 +9862,8 @@ var ParserState = class {
|
|
|
9532
9862
|
this.ensureMethod()._text = clonePrimitiveElement(value);
|
|
9533
9863
|
}
|
|
9534
9864
|
get methodCoding() {
|
|
9535
|
-
var
|
|
9536
|
-
return (
|
|
9865
|
+
var _a2;
|
|
9866
|
+
return (_a2 = this.clause.method) == null ? void 0 : _a2.coding;
|
|
9537
9867
|
}
|
|
9538
9868
|
set methodCoding(value) {
|
|
9539
9869
|
if (value === void 0) {
|
|
@@ -9552,64 +9882,64 @@ var ParserState = class {
|
|
|
9552
9882
|
} : void 0;
|
|
9553
9883
|
}
|
|
9554
9884
|
get count() {
|
|
9555
|
-
var
|
|
9556
|
-
return (
|
|
9885
|
+
var _a2;
|
|
9886
|
+
return (_a2 = this.clause.schedule) == null ? void 0 : _a2.count;
|
|
9557
9887
|
}
|
|
9558
9888
|
set count(value) {
|
|
9559
9889
|
this.ensureSchedule().count = value;
|
|
9560
9890
|
}
|
|
9561
9891
|
get duration() {
|
|
9562
|
-
var
|
|
9563
|
-
return (
|
|
9892
|
+
var _a2;
|
|
9893
|
+
return (_a2 = this.clause.schedule) == null ? void 0 : _a2.duration;
|
|
9564
9894
|
}
|
|
9565
9895
|
set duration(value) {
|
|
9566
9896
|
this.ensureSchedule().duration = value;
|
|
9567
9897
|
}
|
|
9568
9898
|
get durationMax() {
|
|
9569
|
-
var
|
|
9570
|
-
return (
|
|
9899
|
+
var _a2;
|
|
9900
|
+
return (_a2 = this.clause.schedule) == null ? void 0 : _a2.durationMax;
|
|
9571
9901
|
}
|
|
9572
9902
|
set durationMax(value) {
|
|
9573
9903
|
this.ensureSchedule().durationMax = value;
|
|
9574
9904
|
}
|
|
9575
9905
|
get durationUnit() {
|
|
9576
|
-
var
|
|
9577
|
-
return (
|
|
9906
|
+
var _a2;
|
|
9907
|
+
return (_a2 = this.clause.schedule) == null ? void 0 : _a2.durationUnit;
|
|
9578
9908
|
}
|
|
9579
9909
|
set durationUnit(value) {
|
|
9580
9910
|
this.ensureSchedule().durationUnit = value;
|
|
9581
9911
|
}
|
|
9582
9912
|
get frequency() {
|
|
9583
|
-
var
|
|
9584
|
-
return (
|
|
9913
|
+
var _a2;
|
|
9914
|
+
return (_a2 = this.clause.schedule) == null ? void 0 : _a2.frequency;
|
|
9585
9915
|
}
|
|
9586
9916
|
set frequency(value) {
|
|
9587
9917
|
this.ensureSchedule().frequency = value;
|
|
9588
9918
|
}
|
|
9589
9919
|
get frequencyMax() {
|
|
9590
|
-
var
|
|
9591
|
-
return (
|
|
9920
|
+
var _a2;
|
|
9921
|
+
return (_a2 = this.clause.schedule) == null ? void 0 : _a2.frequencyMax;
|
|
9592
9922
|
}
|
|
9593
9923
|
set frequencyMax(value) {
|
|
9594
9924
|
this.ensureSchedule().frequencyMax = value;
|
|
9595
9925
|
}
|
|
9596
9926
|
get period() {
|
|
9597
|
-
var
|
|
9598
|
-
return (
|
|
9927
|
+
var _a2;
|
|
9928
|
+
return (_a2 = this.clause.schedule) == null ? void 0 : _a2.period;
|
|
9599
9929
|
}
|
|
9600
9930
|
set period(value) {
|
|
9601
9931
|
this.ensureSchedule().period = value;
|
|
9602
9932
|
}
|
|
9603
9933
|
get periodMax() {
|
|
9604
|
-
var
|
|
9605
|
-
return (
|
|
9934
|
+
var _a2;
|
|
9935
|
+
return (_a2 = this.clause.schedule) == null ? void 0 : _a2.periodMax;
|
|
9606
9936
|
}
|
|
9607
9937
|
set periodMax(value) {
|
|
9608
9938
|
this.ensureSchedule().periodMax = value;
|
|
9609
9939
|
}
|
|
9610
9940
|
get periodUnit() {
|
|
9611
|
-
var
|
|
9612
|
-
return (
|
|
9941
|
+
var _a2;
|
|
9942
|
+
return (_a2 = this.clause.schedule) == null ? void 0 : _a2.periodUnit;
|
|
9613
9943
|
}
|
|
9614
9944
|
set periodUnit(value) {
|
|
9615
9945
|
this.ensureSchedule().periodUnit = value;
|
|
@@ -9629,22 +9959,22 @@ var ParserState = class {
|
|
|
9629
9959
|
return schedule.when;
|
|
9630
9960
|
}
|
|
9631
9961
|
get timeOfDay() {
|
|
9632
|
-
var
|
|
9633
|
-
return (
|
|
9962
|
+
var _a2;
|
|
9963
|
+
return (_a2 = this.clause.schedule) == null ? void 0 : _a2.timeOfDay;
|
|
9634
9964
|
}
|
|
9635
9965
|
set timeOfDay(value) {
|
|
9636
9966
|
this.ensureSchedule().timeOfDay = value;
|
|
9637
9967
|
}
|
|
9638
9968
|
get timingCode() {
|
|
9639
|
-
var
|
|
9640
|
-
return (
|
|
9969
|
+
var _a2;
|
|
9970
|
+
return (_a2 = this.clause.schedule) == null ? void 0 : _a2.timingCode;
|
|
9641
9971
|
}
|
|
9642
9972
|
set timingCode(value) {
|
|
9643
9973
|
this.ensureSchedule().timingCode = value;
|
|
9644
9974
|
}
|
|
9645
9975
|
get asNeeded() {
|
|
9646
|
-
var
|
|
9647
|
-
return (
|
|
9976
|
+
var _a2;
|
|
9977
|
+
return (_a2 = this.clause.prn) == null ? void 0 : _a2.enabled;
|
|
9648
9978
|
}
|
|
9649
9979
|
set asNeeded(value) {
|
|
9650
9980
|
if (value === void 0) {
|
|
@@ -9654,13 +9984,13 @@ var ParserState = class {
|
|
|
9654
9984
|
this.ensurePrn().enabled = value;
|
|
9655
9985
|
}
|
|
9656
9986
|
get asNeededReason() {
|
|
9657
|
-
var
|
|
9658
|
-
return (_b = (
|
|
9987
|
+
var _a2, _b;
|
|
9988
|
+
return (_b = (_a2 = this.clause.prn) == null ? void 0 : _a2.reason) == null ? void 0 : _b.text;
|
|
9659
9989
|
}
|
|
9660
9990
|
set asNeededReason(value) {
|
|
9661
|
-
var
|
|
9991
|
+
var _a2, _b;
|
|
9662
9992
|
if (value === void 0) {
|
|
9663
|
-
if ((
|
|
9993
|
+
if ((_a2 = this.clause.prn) == null ? void 0 : _a2.reason) {
|
|
9664
9994
|
delete this.clause.prn.reason.text;
|
|
9665
9995
|
this.cleanupPrn();
|
|
9666
9996
|
}
|
|
@@ -9676,13 +10006,13 @@ var ParserState = class {
|
|
|
9676
10006
|
prn.reason.text = value;
|
|
9677
10007
|
}
|
|
9678
10008
|
get asNeededReasons() {
|
|
9679
|
-
var
|
|
9680
|
-
return (
|
|
10009
|
+
var _a2;
|
|
10010
|
+
return (_a2 = this.clause.prn) == null ? void 0 : _a2.reasons;
|
|
9681
10011
|
}
|
|
9682
10012
|
set asNeededReasons(value) {
|
|
9683
|
-
var
|
|
10013
|
+
var _a2, _b;
|
|
9684
10014
|
if (!value || !value.length) {
|
|
9685
|
-
if ((
|
|
10015
|
+
if ((_a2 = this.clause.prn) == null ? void 0 : _a2.reasons) {
|
|
9686
10016
|
delete this.clause.prn.reasons;
|
|
9687
10017
|
this.cleanupPrn();
|
|
9688
10018
|
}
|
|
@@ -9710,13 +10040,13 @@ var ParserState = class {
|
|
|
9710
10040
|
prn.reasons = reasons;
|
|
9711
10041
|
}
|
|
9712
10042
|
get asNeededReasonCoding() {
|
|
9713
|
-
var
|
|
9714
|
-
return (_b = (
|
|
10043
|
+
var _a2, _b;
|
|
10044
|
+
return (_b = (_a2 = this.clause.prn) == null ? void 0 : _a2.reason) == null ? void 0 : _b.coding;
|
|
9715
10045
|
}
|
|
9716
10046
|
set asNeededReasonCoding(value) {
|
|
9717
|
-
var
|
|
10047
|
+
var _a2, _b;
|
|
9718
10048
|
if (value === void 0) {
|
|
9719
|
-
if ((
|
|
10049
|
+
if ((_a2 = this.clause.prn) == null ? void 0 : _a2.reason) {
|
|
9720
10050
|
delete this.clause.prn.reason.coding;
|
|
9721
10051
|
this.cleanupPrn();
|
|
9722
10052
|
}
|
|
@@ -9739,22 +10069,22 @@ var ParserState = class {
|
|
|
9739
10069
|
} : void 0;
|
|
9740
10070
|
}
|
|
9741
10071
|
get siteText() {
|
|
9742
|
-
var
|
|
9743
|
-
return (
|
|
10072
|
+
var _a2;
|
|
10073
|
+
return (_a2 = this.clause.site) == null ? void 0 : _a2.text;
|
|
9744
10074
|
}
|
|
9745
10075
|
set siteText(value) {
|
|
9746
10076
|
this.ensureSite().text = value;
|
|
9747
10077
|
}
|
|
9748
10078
|
get siteSource() {
|
|
9749
|
-
var
|
|
9750
|
-
return (
|
|
10079
|
+
var _a2;
|
|
10080
|
+
return (_a2 = this.clause.site) == null ? void 0 : _a2.source;
|
|
9751
10081
|
}
|
|
9752
10082
|
set siteSource(value) {
|
|
9753
10083
|
this.ensureSite().source = value;
|
|
9754
10084
|
}
|
|
9755
10085
|
get siteCoding() {
|
|
9756
|
-
var
|
|
9757
|
-
return (
|
|
10086
|
+
var _a2;
|
|
10087
|
+
return (_a2 = this.clause.site) == null ? void 0 : _a2.coding;
|
|
9758
10088
|
}
|
|
9759
10089
|
set siteCoding(value) {
|
|
9760
10090
|
if (value === void 0) {
|
|
@@ -9772,8 +10102,8 @@ var ParserState = class {
|
|
|
9772
10102
|
} : void 0;
|
|
9773
10103
|
}
|
|
9774
10104
|
get siteSpatialRelation() {
|
|
9775
|
-
var
|
|
9776
|
-
return (
|
|
10105
|
+
var _a2;
|
|
10106
|
+
return (_a2 = this.clause.site) == null ? void 0 : _a2.spatialRelation;
|
|
9777
10107
|
}
|
|
9778
10108
|
set siteSpatialRelation(value) {
|
|
9779
10109
|
if (value === void 0) {
|
|
@@ -9855,7 +10185,7 @@ var ParserState = class {
|
|
|
9855
10185
|
return this.clause.prn;
|
|
9856
10186
|
}
|
|
9857
10187
|
cleanupPrn() {
|
|
9858
|
-
var
|
|
10188
|
+
var _a2;
|
|
9859
10189
|
const prn = this.clause.prn;
|
|
9860
10190
|
if (!prn) {
|
|
9861
10191
|
return;
|
|
@@ -9863,7 +10193,7 @@ var ParserState = class {
|
|
|
9863
10193
|
if (prn.reason && prn.reason.text === void 0 && prn.reason.coding === void 0) {
|
|
9864
10194
|
delete prn.reason;
|
|
9865
10195
|
}
|
|
9866
|
-
if (((
|
|
10196
|
+
if (((_a2 = prn.reasons) == null ? void 0 : _a2.length) === 0) {
|
|
9867
10197
|
delete prn.reasons;
|
|
9868
10198
|
}
|
|
9869
10199
|
if (prn.enabled === void 0 && prn.reason === void 0 && prn.reasons === void 0) {
|
|
@@ -9918,8 +10248,8 @@ function createEmptyCanonicalClause(rawText) {
|
|
|
9918
10248
|
};
|
|
9919
10249
|
}
|
|
9920
10250
|
function selectFirstCodingWithCode(concept) {
|
|
9921
|
-
var
|
|
9922
|
-
if (!((
|
|
10251
|
+
var _a2;
|
|
10252
|
+
if (!((_a2 = concept == null ? void 0 : concept.coding) == null ? void 0 : _a2.length)) {
|
|
9923
10253
|
return void 0;
|
|
9924
10254
|
}
|
|
9925
10255
|
for (const coding of concept.coding) {
|
|
@@ -9930,8 +10260,8 @@ function selectFirstCodingWithCode(concept) {
|
|
|
9930
10260
|
return void 0;
|
|
9931
10261
|
}
|
|
9932
10262
|
function selectPreferredSiteCoding(site) {
|
|
9933
|
-
var
|
|
9934
|
-
if (!((
|
|
10263
|
+
var _a2;
|
|
10264
|
+
if (!((_a2 = site == null ? void 0 : site.coding) == null ? void 0 : _a2.length)) {
|
|
9935
10265
|
return void 0;
|
|
9936
10266
|
}
|
|
9937
10267
|
for (const coding of site.coding) {
|
|
@@ -9942,7 +10272,7 @@ function selectPreferredSiteCoding(site) {
|
|
|
9942
10272
|
return selectFirstCodingWithCode(site);
|
|
9943
10273
|
}
|
|
9944
10274
|
function selectCanonicalSiteCoding(site, options) {
|
|
9945
|
-
var
|
|
10275
|
+
var _a2;
|
|
9946
10276
|
if ((options == null ? void 0 : options.bodySitePostcoordination) === false) {
|
|
9947
10277
|
return site == null ? void 0 : site.coding;
|
|
9948
10278
|
}
|
|
@@ -9951,16 +10281,16 @@ function selectCanonicalSiteCoding(site, options) {
|
|
|
9951
10281
|
site == null ? void 0 : site.text,
|
|
9952
10282
|
{ postcoordination: true }
|
|
9953
10283
|
);
|
|
9954
|
-
return (options == null ? void 0 : options.bodySitePostcoordination) === true ? postcoordinated != null ? postcoordinated : site == null ? void 0 : site.coding : (
|
|
10284
|
+
return (options == null ? void 0 : options.bodySitePostcoordination) === true ? postcoordinated != null ? postcoordinated : site == null ? void 0 : site.coding : (_a2 = site == null ? void 0 : site.coding) != null ? _a2 : postcoordinated;
|
|
9955
10285
|
}
|
|
9956
10286
|
function buildSiteCodingArray(siteCoding) {
|
|
9957
|
-
var
|
|
10287
|
+
var _a2;
|
|
9958
10288
|
if (!(siteCoding == null ? void 0 : siteCoding.code)) {
|
|
9959
10289
|
return void 0;
|
|
9960
10290
|
}
|
|
9961
10291
|
return [
|
|
9962
10292
|
{
|
|
9963
|
-
system: (
|
|
10293
|
+
system: (_a2 = siteCoding.system) != null ? _a2 : SNOMED_SYSTEM5,
|
|
9964
10294
|
code: siteCoding.code,
|
|
9965
10295
|
display: siteCoding.display
|
|
9966
10296
|
}
|
|
@@ -9982,12 +10312,12 @@ function lowerFirst(value) {
|
|
|
9982
10312
|
return trimmed ? trimmed.charAt(0).toLowerCase() + trimmed.slice(1) : void 0;
|
|
9983
10313
|
}
|
|
9984
10314
|
function getSpatialPrnReasonSiteText(spatialRelation) {
|
|
9985
|
-
var
|
|
10315
|
+
var _a2;
|
|
9986
10316
|
const sourceText = lowerFirst(spatialRelation == null ? void 0 : spatialRelation.sourceText);
|
|
9987
10317
|
if (sourceText) {
|
|
9988
10318
|
return sourceText;
|
|
9989
10319
|
}
|
|
9990
|
-
const targetText = (
|
|
10320
|
+
const targetText = (_a2 = lowerFirst(spatialRelation == null ? void 0 : spatialRelation.targetText)) != null ? _a2 : (spatialRelation == null ? void 0 : spatialRelation.targetCoding) ? getBodySiteText(spatialRelation.targetCoding) : void 0;
|
|
9991
10321
|
if (!targetText) {
|
|
9992
10322
|
return void 0;
|
|
9993
10323
|
}
|
|
@@ -10024,7 +10354,7 @@ function getSpatialPrnReasonSiteText(spatialRelation) {
|
|
|
10024
10354
|
}
|
|
10025
10355
|
}
|
|
10026
10356
|
function getFallbackPrnReasonText(concept) {
|
|
10027
|
-
var
|
|
10357
|
+
var _a2, _b, _c, _d, _e;
|
|
10028
10358
|
if (concept == null ? void 0 : concept.text) {
|
|
10029
10359
|
return concept.text;
|
|
10030
10360
|
}
|
|
@@ -10036,7 +10366,7 @@ function getFallbackPrnReasonText(concept) {
|
|
|
10036
10366
|
return display;
|
|
10037
10367
|
}
|
|
10038
10368
|
const parsed = parseSnomedFindingSitePostcoordinationCode(coding == null ? void 0 : coding.code);
|
|
10039
|
-
const focus = parsed && ((
|
|
10369
|
+
const focus = parsed && ((_a2 = coding == null ? void 0 : coding.system) != null ? _a2 : SNOMED_SYSTEM5) === SNOMED_SYSTEM5 ? findPrnReasonDefinitionByCoding(SNOMED_SYSTEM5, parsed.focusCode) : void 0;
|
|
10040
10370
|
const focusText = (_d = lowerFirst((_c = focus == null ? void 0 : focus.text) != null ? _c : (_b = focus == null ? void 0 : focus.coding) == null ? void 0 : _b.display)) != null ? _d : display;
|
|
10041
10371
|
if (focusText && spatialSiteText) {
|
|
10042
10372
|
return spatialSiteText.toLowerCase().startsWith(`${focusText.toLowerCase()} `) ? spatialSiteText : `${focusText} ${spatialSiteText}`;
|
|
@@ -10108,8 +10438,8 @@ function buildFhirBoundsRange(low, high, unit) {
|
|
|
10108
10438
|
};
|
|
10109
10439
|
}
|
|
10110
10440
|
function parseFhirDurationUnit(quantity) {
|
|
10111
|
-
var
|
|
10112
|
-
const candidate = (_c = (
|
|
10441
|
+
var _a2, _b, _c;
|
|
10442
|
+
const candidate = (_c = (_a2 = quantity == null ? void 0 : quantity.code) == null ? void 0 : _a2.trim().toLowerCase()) != null ? _c : (_b = quantity == null ? void 0 : quantity.unit) == null ? void 0 : _b.trim().toLowerCase();
|
|
10113
10443
|
switch (candidate) {
|
|
10114
10444
|
case "s":
|
|
10115
10445
|
case "sec":
|
|
@@ -10151,11 +10481,11 @@ function parseFhirDurationUnit(quantity) {
|
|
|
10151
10481
|
}
|
|
10152
10482
|
}
|
|
10153
10483
|
function extractCanonicalTimingBounds(repeat) {
|
|
10154
|
-
var
|
|
10484
|
+
var _a2;
|
|
10155
10485
|
if (!repeat) {
|
|
10156
10486
|
return {};
|
|
10157
10487
|
}
|
|
10158
|
-
if (((
|
|
10488
|
+
if (((_a2 = repeat.boundsDuration) == null ? void 0 : _a2.value) !== void 0) {
|
|
10159
10489
|
const durationUnit2 = parseFhirDurationUnit(repeat.boundsDuration);
|
|
10160
10490
|
if (!durationUnit2) {
|
|
10161
10491
|
return {};
|
|
@@ -10188,9 +10518,9 @@ function extractCanonicalTimingBounds(repeat) {
|
|
|
10188
10518
|
};
|
|
10189
10519
|
}
|
|
10190
10520
|
function extractCanonicalDoseRange(range) {
|
|
10191
|
-
var
|
|
10521
|
+
var _a2, _b, _c, _d;
|
|
10192
10522
|
const canonicalRange = {};
|
|
10193
|
-
const lowUnit = (
|
|
10523
|
+
const lowUnit = (_a2 = range.low) == null ? void 0 : _a2.unit;
|
|
10194
10524
|
const highUnit = (_b = range.high) == null ? void 0 : _b.unit;
|
|
10195
10525
|
if (((_c = range.low) == null ? void 0 : _c.value) !== void 0) {
|
|
10196
10526
|
canonicalRange.low = range.low.value;
|
|
@@ -10223,7 +10553,7 @@ function appendWarning(warnings, warning) {
|
|
|
10223
10553
|
return warnings;
|
|
10224
10554
|
}
|
|
10225
10555
|
function canonicalToFhir(clause, textOverride, options) {
|
|
10226
|
-
var
|
|
10556
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G;
|
|
10227
10557
|
const dosage = {};
|
|
10228
10558
|
const repeat = {};
|
|
10229
10559
|
let hasRepeat = false;
|
|
@@ -10261,7 +10591,7 @@ function canonicalToFhir(clause, textOverride, options) {
|
|
|
10261
10591
|
repeat.periodMax = schedule.periodMax;
|
|
10262
10592
|
hasRepeat = true;
|
|
10263
10593
|
}
|
|
10264
|
-
if ((
|
|
10594
|
+
if ((_a2 = schedule == null ? void 0 : schedule.dayOfWeek) == null ? void 0 : _a2.length) {
|
|
10265
10595
|
repeat.dayOfWeek = [...schedule.dayOfWeek];
|
|
10266
10596
|
hasRepeat = true;
|
|
10267
10597
|
}
|
|
@@ -10393,8 +10723,8 @@ function canonicalToFhir(clause, textOverride, options) {
|
|
|
10393
10723
|
return dosage;
|
|
10394
10724
|
}
|
|
10395
10725
|
function canonicalFromFhir(dosage) {
|
|
10396
|
-
var
|
|
10397
|
-
const rawText = (
|
|
10726
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F;
|
|
10727
|
+
const rawText = (_a2 = dosage.text) != null ? _a2 : "";
|
|
10398
10728
|
const clause = createEmptyCanonicalClause(rawText);
|
|
10399
10729
|
let routeCode;
|
|
10400
10730
|
const routeCoding = (_c = (_b = dosage.route) == null ? void 0 : _b.coding) == null ? void 0 : _c.find((code) => code.system === SNOMED_SYSTEM5);
|
|
@@ -10472,8 +10802,8 @@ function canonicalFromFhir(dosage) {
|
|
|
10472
10802
|
};
|
|
10473
10803
|
}
|
|
10474
10804
|
const prnReasons = ((_y = dosage.asNeededFor) == null ? void 0 : _y.length) ? dosage.asNeededFor.map((concept) => {
|
|
10475
|
-
var
|
|
10476
|
-
const coding = (
|
|
10805
|
+
var _a3;
|
|
10806
|
+
const coding = (_a3 = concept.coding) == null ? void 0 : _a3.find((code) => Boolean(code.code));
|
|
10477
10807
|
return {
|
|
10478
10808
|
text: getFallbackPrnReasonText(concept),
|
|
10479
10809
|
spatialRelation: parseBodySiteSpatialRelationExtension(concept),
|
|
@@ -10521,7 +10851,7 @@ function canonicalFromFhir(dosage) {
|
|
|
10521
10851
|
|
|
10522
10852
|
// src/ir.ts
|
|
10523
10853
|
function shiftCanonicalSigClauses(clauses, offset) {
|
|
10524
|
-
var
|
|
10854
|
+
var _a2, _b, _c, _d, _e;
|
|
10525
10855
|
for (const clause of clauses) {
|
|
10526
10856
|
if (clause.span) {
|
|
10527
10857
|
clause.span = {
|
|
@@ -10549,7 +10879,7 @@ function shiftCanonicalSigClauses(clauses, offset) {
|
|
|
10549
10879
|
}
|
|
10550
10880
|
};
|
|
10551
10881
|
shiftEvidenceSpans(clause.evidence);
|
|
10552
|
-
shiftEvidenceSpans((
|
|
10882
|
+
shiftEvidenceSpans((_a2 = clause.dose) == null ? void 0 : _a2.evidence);
|
|
10553
10883
|
shiftEvidenceSpans((_b = clause.route) == null ? void 0 : _b.evidence);
|
|
10554
10884
|
shiftEvidenceSpans((_c = clause.site) == null ? void 0 : _c.evidence);
|
|
10555
10885
|
shiftEvidenceSpans((_d = clause.schedule) == null ? void 0 : _d.evidence);
|
|
@@ -10571,8 +10901,8 @@ function getRegisteredSigLocalizations() {
|
|
|
10571
10901
|
return Array.from(REGISTERED_LOCALIZATIONS.values());
|
|
10572
10902
|
}
|
|
10573
10903
|
function resolveSigLocalization(locale, config) {
|
|
10574
|
-
var
|
|
10575
|
-
const normalizedLocale = (
|
|
10904
|
+
var _a2, _b, _c, _d, _e, _f, _g;
|
|
10905
|
+
const normalizedLocale = (_a2 = config == null ? void 0 : config.locale) != null ? _a2 : locale;
|
|
10576
10906
|
const targetKey = normalizedLocale == null ? void 0 : normalizedLocale.toLowerCase();
|
|
10577
10907
|
const base = targetKey ? REGISTERED_LOCALIZATIONS.get(targetKey) : void 0;
|
|
10578
10908
|
const inherited = (config == null ? void 0 : config.inherit) ? REGISTERED_LOCALIZATIONS.get(config.inherit.toLowerCase()) : void 0;
|
|
@@ -10930,10 +11260,10 @@ var THAI_SITE_TRANSLATIONS = {
|
|
|
10930
11260
|
hair: "\u0E40\u0E2A\u0E49\u0E19\u0E1C\u0E21"
|
|
10931
11261
|
};
|
|
10932
11262
|
var THAI_SITE_CODE_TRANSLATIONS = (() => {
|
|
10933
|
-
var
|
|
11263
|
+
var _a2;
|
|
10934
11264
|
const translations = {};
|
|
10935
11265
|
for (const { names, definition } of DEFAULT_BODY_SITE_SNOMED_SOURCE) {
|
|
10936
|
-
const code = (
|
|
11266
|
+
const code = (_a2 = definition.coding) == null ? void 0 : _a2.code;
|
|
10937
11267
|
if (!code || translations[code]) {
|
|
10938
11268
|
continue;
|
|
10939
11269
|
}
|
|
@@ -11070,8 +11400,8 @@ var THAI_SITE_FIRST_VERBS = /* @__PURE__ */ new Set([
|
|
|
11070
11400
|
"\u0E1E\u0E48\u0E19"
|
|
11071
11401
|
]);
|
|
11072
11402
|
function resolveThaiMethodVerb(clause, grammar) {
|
|
11073
|
-
var
|
|
11074
|
-
const translatedText = getPrimitiveTranslation((
|
|
11403
|
+
var _a2, _b, _c, _d, _e;
|
|
11404
|
+
const translatedText = getPrimitiveTranslation((_a2 = clause.method) == null ? void 0 : _a2._text, "th");
|
|
11075
11405
|
if (translatedText) {
|
|
11076
11406
|
return translatedText;
|
|
11077
11407
|
}
|
|
@@ -11115,14 +11445,14 @@ function joinThaiVerbAndBody(verb, body) {
|
|
|
11115
11445
|
return `${verb} ${trimmedBody}`;
|
|
11116
11446
|
}
|
|
11117
11447
|
function shouldUseGenericMedicationObjectThai(clause, verb, explicitDosePart) {
|
|
11118
|
-
var
|
|
11448
|
+
var _a2;
|
|
11119
11449
|
if (explicitDosePart) {
|
|
11120
11450
|
return false;
|
|
11121
11451
|
}
|
|
11122
11452
|
if (THAI_IMPLIED_OBJECT_VERBS.has(verb)) {
|
|
11123
11453
|
return false;
|
|
11124
11454
|
}
|
|
11125
|
-
switch ((
|
|
11455
|
+
switch ((_a2 = clause.route) == null ? void 0 : _a2.code) {
|
|
11126
11456
|
case RouteCode["Topical route"]:
|
|
11127
11457
|
case RouteCode["Transdermal route"]:
|
|
11128
11458
|
case RouteCode["Nasal route"]:
|
|
@@ -11136,14 +11466,14 @@ function shouldUseGenericMedicationObjectThai(clause, verb, explicitDosePart) {
|
|
|
11136
11466
|
}
|
|
11137
11467
|
}
|
|
11138
11468
|
function shouldSuppressRoutePhraseThai(clause, verb, hasSite, explicitDosePart) {
|
|
11139
|
-
var
|
|
11469
|
+
var _a2;
|
|
11140
11470
|
if (hasSite || explicitDosePart) {
|
|
11141
11471
|
return false;
|
|
11142
11472
|
}
|
|
11143
11473
|
if (!THAI_SUPPRESSIBLE_ROUTE_VERBS.has(verb)) {
|
|
11144
11474
|
return false;
|
|
11145
11475
|
}
|
|
11146
|
-
switch ((
|
|
11476
|
+
switch ((_a2 = clause.route) == null ? void 0 : _a2.code) {
|
|
11147
11477
|
case RouteCode["Topical route"]:
|
|
11148
11478
|
case RouteCode["Transdermal route"]:
|
|
11149
11479
|
return true;
|
|
@@ -11152,12 +11482,12 @@ function shouldSuppressRoutePhraseThai(clause, verb, hasSite, explicitDosePart)
|
|
|
11152
11482
|
}
|
|
11153
11483
|
}
|
|
11154
11484
|
function scheduleOf2(clause) {
|
|
11155
|
-
var
|
|
11156
|
-
return (
|
|
11485
|
+
var _a2;
|
|
11486
|
+
return (_a2 = clause.schedule) != null ? _a2 : {};
|
|
11157
11487
|
}
|
|
11158
11488
|
function resolveRouteGrammarThai(clause) {
|
|
11159
|
-
var
|
|
11160
|
-
const routeCode = (
|
|
11489
|
+
var _a2, _b, _c, _d, _e, _f;
|
|
11490
|
+
const routeCode = (_a2 = clause.route) == null ? void 0 : _a2.code;
|
|
11161
11491
|
if (routeCode && THAI_ROUTE_GRAMMAR[routeCode]) {
|
|
11162
11492
|
return (_b = THAI_ROUTE_GRAMMAR[routeCode]) != null ? _b : DEFAULT_THAI_ROUTE_GRAMMAR;
|
|
11163
11493
|
}
|
|
@@ -11314,8 +11644,27 @@ function formatUnitThai(unit, _value, style) {
|
|
|
11314
11644
|
sprays: { short: "\u0E1E\u0E48\u0E19", long: "\u0E1E\u0E48\u0E19" },
|
|
11315
11645
|
drop: { short: "\u0E2B\u0E22\u0E14", long: "\u0E2B\u0E22\u0E14" },
|
|
11316
11646
|
drops: { short: "\u0E2B\u0E22\u0E14", long: "\u0E2B\u0E22\u0E14" },
|
|
11647
|
+
pump: { short: "\u0E1B\u0E31\u0E4A\u0E21", long: "\u0E1B\u0E31\u0E4A\u0E21" },
|
|
11648
|
+
pumps: { short: "\u0E1B\u0E31\u0E4A\u0E21", long: "\u0E1B\u0E31\u0E4A\u0E21" },
|
|
11649
|
+
actuation: { short: "\u0E04\u0E23\u0E31\u0E49\u0E07", long: "\u0E04\u0E23\u0E31\u0E49\u0E07" },
|
|
11650
|
+
ftu: { short: "FTU", long: "FTU" },
|
|
11317
11651
|
patch: { short: "\u0E41\u0E1C\u0E48\u0E19", long: "\u0E41\u0E1C\u0E48\u0E19\u0E41\u0E1B\u0E30" },
|
|
11318
11652
|
patches: { short: "\u0E41\u0E1C\u0E48\u0E19", long: "\u0E41\u0E1C\u0E48\u0E19\u0E41\u0E1B\u0E30" },
|
|
11653
|
+
ring: { short: "\u0E27\u0E07", long: "\u0E27\u0E07" },
|
|
11654
|
+
applicatorful: { short: "\u0E41\u0E2D\u0E1B\u0E1E\u0E25\u0E34\u0E40\u0E04\u0E40\u0E15\u0E2D\u0E23\u0E4C", long: "\u0E41\u0E2D\u0E1B\u0E1E\u0E25\u0E34\u0E40\u0E04\u0E40\u0E15\u0E2D\u0E23\u0E4C" },
|
|
11655
|
+
capful: { short: "\u0E1D\u0E32", long: "\u0E1D\u0E32" },
|
|
11656
|
+
scoop: { short: "\u0E0A\u0E49\u0E2D\u0E19\u0E15\u0E27\u0E07", long: "\u0E0A\u0E49\u0E2D\u0E19\u0E15\u0E27\u0E07" },
|
|
11657
|
+
"pea-sized amount": { short: "\u0E02\u0E19\u0E32\u0E14\u0E40\u0E17\u0E48\u0E32\u0E40\u0E21\u0E47\u0E14\u0E16\u0E31\u0E48\u0E27", long: "\u0E02\u0E19\u0E32\u0E14\u0E40\u0E17\u0E48\u0E32\u0E40\u0E21\u0E47\u0E14\u0E16\u0E31\u0E48\u0E27" },
|
|
11658
|
+
palm: { short: "\u0E1D\u0E48\u0E32\u0E21\u0E37\u0E2D", long: "\u0E1D\u0E48\u0E32\u0E21\u0E37\u0E2D" },
|
|
11659
|
+
handprint: { short: "\u0E2B\u0E19\u0E36\u0E48\u0E07\u0E1D\u0E48\u0E32\u0E21\u0E37\u0E2D", long: "\u0E2B\u0E19\u0E36\u0E48\u0E07\u0E1D\u0E48\u0E32\u0E21\u0E37\u0E2D" },
|
|
11660
|
+
"shot glass": { short: "\u0E41\u0E01\u0E49\u0E27\u0E0A\u0E47\u0E2D\u0E15", long: "\u0E41\u0E01\u0E49\u0E27\u0E0A\u0E47\u0E2D\u0E15" },
|
|
11661
|
+
"finger length": { short: "\u0E04\u0E27\u0E32\u0E21\u0E22\u0E32\u0E27\u0E19\u0E34\u0E49\u0E27", long: "\u0E04\u0E27\u0E32\u0E21\u0E22\u0E32\u0E27\u0E19\u0E34\u0E49\u0E27" },
|
|
11662
|
+
click: { short: "\u0E04\u0E25\u0E34\u0E01", long: "\u0E04\u0E25\u0E34\u0E01" },
|
|
11663
|
+
vial: { short: "\u0E02\u0E27\u0E14", long: "\u0E02\u0E27\u0E14" },
|
|
11664
|
+
ampule: { short: "\u0E41\u0E2D\u0E21\u0E1E\u0E39\u0E25", long: "\u0E41\u0E2D\u0E21\u0E1E\u0E39\u0E25" },
|
|
11665
|
+
packet: { short: "\u0E0B\u0E2D\u0E07", long: "\u0E0B\u0E2D\u0E07" },
|
|
11666
|
+
sachet: { short: "\u0E0B\u0E2D\u0E07", long: "\u0E0B\u0E2D\u0E07" },
|
|
11667
|
+
"stick-pack": { short: "\u0E0B\u0E2D\u0E07\u0E41\u0E17\u0E48\u0E07", long: "\u0E0B\u0E2D\u0E07\u0E41\u0E17\u0E48\u0E07" },
|
|
11319
11668
|
suppository: { short: "\u0E22\u0E32\u0E40\u0E2B\u0E19\u0E47\u0E1A", long: "\u0E22\u0E32\u0E40\u0E2B\u0E19\u0E47\u0E1A" },
|
|
11320
11669
|
suppositories: { short: "\u0E22\u0E32\u0E40\u0E2B\u0E19\u0E47\u0E1A", long: "\u0E22\u0E32\u0E40\u0E2B\u0E19\u0E47\u0E1A" }
|
|
11321
11670
|
};
|
|
@@ -11323,7 +11672,7 @@ function formatUnitThai(unit, _value, style) {
|
|
|
11323
11672
|
return entry ? entry[style] : unit;
|
|
11324
11673
|
}
|
|
11325
11674
|
function describeFrequencyThai(schedule) {
|
|
11326
|
-
var
|
|
11675
|
+
var _a2, _b;
|
|
11327
11676
|
const frequency = schedule == null ? void 0 : schedule.frequency;
|
|
11328
11677
|
const frequencyMax = schedule == null ? void 0 : schedule.frequencyMax;
|
|
11329
11678
|
const period = schedule == null ? void 0 : schedule.period;
|
|
@@ -11340,7 +11689,7 @@ function describeFrequencyThai(schedule) {
|
|
|
11340
11689
|
return `\u0E27\u0E31\u0E19\u0E25\u0E30 ${stripTrailingZero2(frequency)} \u0E16\u0E36\u0E07 ${stripTrailingZero2(frequencyMax)} \u0E04\u0E23\u0E31\u0E49\u0E07`;
|
|
11341
11690
|
}
|
|
11342
11691
|
if (frequency && periodUnit === "d" /* Day */ && (!period || period === 1)) {
|
|
11343
|
-
return (
|
|
11692
|
+
return (_a2 = TH_TIMES_PER_DAY[frequency]) != null ? _a2 : `\u0E27\u0E31\u0E19\u0E25\u0E30 ${stripTrailingZero2(frequency)} \u0E04\u0E23\u0E31\u0E49\u0E07`;
|
|
11344
11693
|
}
|
|
11345
11694
|
if (periodUnit === "min" /* Minute */ && period) {
|
|
11346
11695
|
if (periodMax && periodMax !== period) {
|
|
@@ -11419,19 +11768,19 @@ function describeFrequencyThai(schedule) {
|
|
|
11419
11768
|
return void 0;
|
|
11420
11769
|
}
|
|
11421
11770
|
function describeFrequencyCountThai(count) {
|
|
11422
|
-
var
|
|
11771
|
+
var _a2;
|
|
11423
11772
|
if (!count || count <= 0) {
|
|
11424
11773
|
return void 0;
|
|
11425
11774
|
}
|
|
11426
|
-
return (
|
|
11775
|
+
return (_a2 = TH_TIMES_PER_DAY[count]) != null ? _a2 : `\u0E27\u0E31\u0E19\u0E25\u0E30 ${stripTrailingZero2(count)} \u0E04\u0E23\u0E31\u0E49\u0E07`;
|
|
11427
11776
|
}
|
|
11428
11777
|
function describeStandaloneOccurrenceCountThai(schedule) {
|
|
11429
|
-
var
|
|
11778
|
+
var _a2, _b, _c;
|
|
11430
11779
|
const count = schedule == null ? void 0 : schedule.count;
|
|
11431
11780
|
if (!count || count <= 0) {
|
|
11432
11781
|
return void 0;
|
|
11433
11782
|
}
|
|
11434
|
-
if ((schedule == null ? void 0 : schedule.frequency) !== void 0 || (schedule == null ? void 0 : schedule.frequencyMax) !== void 0 || (schedule == null ? void 0 : schedule.period) !== void 0 || (schedule == null ? void 0 : schedule.periodMax) !== void 0 || (schedule == null ? void 0 : schedule.periodUnit) !== void 0 || ((
|
|
11783
|
+
if ((schedule == null ? void 0 : schedule.frequency) !== void 0 || (schedule == null ? void 0 : schedule.frequencyMax) !== void 0 || (schedule == null ? void 0 : schedule.period) !== void 0 || (schedule == null ? void 0 : schedule.periodMax) !== void 0 || (schedule == null ? void 0 : schedule.periodUnit) !== void 0 || ((_a2 = schedule == null ? void 0 : schedule.dayOfWeek) == null ? void 0 : _a2.length) || ((_b = schedule == null ? void 0 : schedule.when) == null ? void 0 : _b.length) || ((_c = schedule == null ? void 0 : schedule.timeOfDay) == null ? void 0 : _c.length) || (schedule == null ? void 0 : schedule.duration) !== void 0 || (schedule == null ? void 0 : schedule.durationMax) !== void 0 || (schedule == null ? void 0 : schedule.durationUnit) !== void 0 || (schedule == null ? void 0 : schedule.timingCode)) {
|
|
11435
11784
|
return void 0;
|
|
11436
11785
|
}
|
|
11437
11786
|
return `${stripTrailingZero2(count)} \u0E04\u0E23\u0E31\u0E49\u0E07`;
|
|
@@ -11470,8 +11819,8 @@ function summarizeMealTimingGroupThai(group) {
|
|
|
11470
11819
|
return `${relationText[group.relation]}${joinMealNamesThai(meals)}`;
|
|
11471
11820
|
}
|
|
11472
11821
|
function collectWhenPhrasesThai(schedule, options) {
|
|
11473
|
-
var
|
|
11474
|
-
const when = (
|
|
11822
|
+
var _a2;
|
|
11823
|
+
const when = (_a2 = schedule == null ? void 0 : schedule.when) != null ? _a2 : [];
|
|
11475
11824
|
if (!when.length) {
|
|
11476
11825
|
return [];
|
|
11477
11826
|
}
|
|
@@ -11565,8 +11914,8 @@ function combineFrequencyAndEventsThai(frequency, events) {
|
|
|
11565
11914
|
return { frequency, event: joinWithAndThai(events) };
|
|
11566
11915
|
}
|
|
11567
11916
|
function isOralRouteThai(clause) {
|
|
11568
|
-
var
|
|
11569
|
-
if (((
|
|
11917
|
+
var _a2, _b, _c;
|
|
11918
|
+
if (((_a2 = clause.route) == null ? void 0 : _a2.code) === RouteCode["Oral route"]) {
|
|
11570
11919
|
return true;
|
|
11571
11920
|
}
|
|
11572
11921
|
const text = (_c = (_b = clause.route) == null ? void 0 : _b.text) == null ? void 0 : _c.trim().toLowerCase();
|
|
@@ -11576,7 +11925,7 @@ function isOralRouteThai(clause) {
|
|
|
11576
11925
|
return text === "po" || text === "oral" || text.includes("mouth") || text.includes("per os");
|
|
11577
11926
|
}
|
|
11578
11927
|
function buildRoutePhraseThai(clause, grammar, hasSite) {
|
|
11579
|
-
var
|
|
11928
|
+
var _a2, _b;
|
|
11580
11929
|
if (grammar.verb === "\u0E23\u0E31\u0E1A\u0E1B\u0E23\u0E30\u0E17\u0E32\u0E19" && isOralRouteThai(clause)) {
|
|
11581
11930
|
return void 0;
|
|
11582
11931
|
}
|
|
@@ -11586,7 +11935,7 @@ function buildRoutePhraseThai(clause, grammar, hasSite) {
|
|
|
11586
11935
|
if (typeof grammar.routePhrase === "string") {
|
|
11587
11936
|
return grammar.routePhrase;
|
|
11588
11937
|
}
|
|
11589
|
-
const text = (_b = (
|
|
11938
|
+
const text = (_b = (_a2 = clause.route) == null ? void 0 : _a2.text) == null ? void 0 : _b.trim();
|
|
11590
11939
|
if (!text) {
|
|
11591
11940
|
return void 0;
|
|
11592
11941
|
}
|
|
@@ -11621,8 +11970,8 @@ function buildRoutePhraseThai(clause, grammar, hasSite) {
|
|
|
11621
11970
|
return text;
|
|
11622
11971
|
}
|
|
11623
11972
|
function formatSiteThai(clause, grammar) {
|
|
11624
|
-
var
|
|
11625
|
-
const text = ((_b = (
|
|
11973
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
|
|
11974
|
+
const text = ((_b = (_a2 = clause.site) == null ? void 0 : _a2.text) == null ? void 0 : _b.trim()) || ((_e = (_d = (_c = clause.site) == null ? void 0 : _c.coding) == null ? void 0 : _d.display) == null ? void 0 : _e.trim());
|
|
11626
11975
|
const lower = text == null ? void 0 : text.toLowerCase();
|
|
11627
11976
|
const codingCode = (_g = (_f = clause.site) == null ? void 0 : _f.coding) == null ? void 0 : _g.code;
|
|
11628
11977
|
const routeText = (_i = (_h = clause.route) == null ? void 0 : _h.text) == null ? void 0 : _i.trim().toLowerCase();
|
|
@@ -11679,8 +12028,8 @@ var THAI_SPATIAL_TARGET_TRANSLATION_OVERRIDES = {
|
|
|
11679
12028
|
belly: "\u0E17\u0E49\u0E2D\u0E07"
|
|
11680
12029
|
};
|
|
11681
12030
|
function translateSpatialTargetThai(relation) {
|
|
11682
|
-
var
|
|
11683
|
-
const normalizedTarget = normalizeBodySiteKey((
|
|
12031
|
+
var _a2, _b;
|
|
12032
|
+
const normalizedTarget = normalizeBodySiteKey((_a2 = relation.targetText) != null ? _a2 : "");
|
|
11684
12033
|
const override = THAI_SPATIAL_TARGET_TRANSLATION_OVERRIDES[normalizedTarget];
|
|
11685
12034
|
return override != null ? override : translateSiteThai(
|
|
11686
12035
|
relation.targetText,
|
|
@@ -11688,8 +12037,8 @@ function translateSpatialTargetThai(relation) {
|
|
|
11688
12037
|
);
|
|
11689
12038
|
}
|
|
11690
12039
|
function translateSpatialSiteThai(site, relation) {
|
|
11691
|
-
var
|
|
11692
|
-
const spatialRelation = relation != null ? relation : site ? (
|
|
12040
|
+
var _a2;
|
|
12041
|
+
const spatialRelation = relation != null ? relation : site ? (_a2 = resolveBodySitePhrase(site)) == null ? void 0 : _a2.spatialRelation : void 0;
|
|
11693
12042
|
if (!(spatialRelation == null ? void 0 : spatialRelation.relationText)) {
|
|
11694
12043
|
return void 0;
|
|
11695
12044
|
}
|
|
@@ -11742,8 +12091,8 @@ function translateSiteThai(site, code, spatialRelation) {
|
|
|
11742
12091
|
return site;
|
|
11743
12092
|
}
|
|
11744
12093
|
function describeDayOfWeekThai(schedule) {
|
|
11745
|
-
var
|
|
11746
|
-
const dayOfWeek = (
|
|
12094
|
+
var _a2;
|
|
12095
|
+
const dayOfWeek = (_a2 = schedule == null ? void 0 : schedule.dayOfWeek) != null ? _a2 : [];
|
|
11747
12096
|
if (!dayOfWeek.length) {
|
|
11748
12097
|
return void 0;
|
|
11749
12098
|
}
|
|
@@ -11793,7 +12142,7 @@ function describeDurationThai(schedule) {
|
|
|
11793
12142
|
return `\u0E40\u0E1B\u0E47\u0E19\u0E40\u0E27\u0E25\u0E32 ${stripTrailingZero2(schedule.duration)} ${label()}`;
|
|
11794
12143
|
}
|
|
11795
12144
|
function findPrnReasonDefinitionByPossiblyPostcoordinatedCoding(system, code) {
|
|
11796
|
-
var
|
|
12145
|
+
var _a2;
|
|
11797
12146
|
const direct = findPrnReasonDefinitionByCoding(system, code);
|
|
11798
12147
|
if (direct) {
|
|
11799
12148
|
return direct;
|
|
@@ -11802,11 +12151,11 @@ function findPrnReasonDefinitionByPossiblyPostcoordinatedCoding(system, code) {
|
|
|
11802
12151
|
if (!normalizedSystem.includes("snomed.info/sct")) {
|
|
11803
12152
|
return void 0;
|
|
11804
12153
|
}
|
|
11805
|
-
return findPrnReasonDefinitionByCoding(system, (
|
|
12154
|
+
return findPrnReasonDefinitionByCoding(system, (_a2 = code.split(":")[0]) != null ? _a2 : code);
|
|
11806
12155
|
}
|
|
11807
12156
|
function translatePrnReasonThai(reason) {
|
|
11808
|
-
var
|
|
11809
|
-
let text = (_b = reason.text) != null ? _b : (
|
|
12157
|
+
var _a2, _b, _c, _d, _e;
|
|
12158
|
+
let text = (_b = reason.text) != null ? _b : (_a2 = reason.coding) == null ? void 0 : _a2.display;
|
|
11810
12159
|
const coding = reason.coding;
|
|
11811
12160
|
if (coding == null ? void 0 : coding.code) {
|
|
11812
12161
|
const definition = findPrnReasonDefinitionByPossiblyPostcoordinatedCoding(
|
|
@@ -11822,8 +12171,8 @@ function translatePrnReasonThai(reason) {
|
|
|
11822
12171
|
return text;
|
|
11823
12172
|
}
|
|
11824
12173
|
function formatAsNeededThai(clause) {
|
|
11825
|
-
var
|
|
11826
|
-
if (!((
|
|
12174
|
+
var _a2, _b, _c, _d, _e, _f;
|
|
12175
|
+
if (!((_a2 = clause.prn) == null ? void 0 : _a2.enabled)) {
|
|
11827
12176
|
return void 0;
|
|
11828
12177
|
}
|
|
11829
12178
|
if ((_b = clause.prn.reasons) == null ? void 0 : _b.length) {
|
|
@@ -11845,14 +12194,14 @@ function formatAsNeededThai(clause) {
|
|
|
11845
12194
|
return "\u0E43\u0E0A\u0E49\u0E40\u0E21\u0E37\u0E48\u0E2D\u0E08\u0E33\u0E40\u0E1B\u0E47\u0E19";
|
|
11846
12195
|
}
|
|
11847
12196
|
function formatShortThai(clause) {
|
|
11848
|
-
var
|
|
12197
|
+
var _a2, _b, _c, _d, _e, _f;
|
|
11849
12198
|
const schedule = scheduleOf2(clause);
|
|
11850
12199
|
const parts = [];
|
|
11851
12200
|
const dose = formatDoseThaiShort(clause.dose);
|
|
11852
12201
|
if (dose) {
|
|
11853
12202
|
parts.push(dose);
|
|
11854
12203
|
}
|
|
11855
|
-
if ((
|
|
12204
|
+
if ((_a2 = clause.route) == null ? void 0 : _a2.code) {
|
|
11856
12205
|
const short = ROUTE_SHORT2[clause.route.code];
|
|
11857
12206
|
if (short) {
|
|
11858
12207
|
parts.push(short);
|
|
@@ -11904,7 +12253,7 @@ function formatShortThai(clause) {
|
|
|
11904
12253
|
return parts.filter(Boolean).join(" ");
|
|
11905
12254
|
}
|
|
11906
12255
|
function formatLongThai(clause, options) {
|
|
11907
|
-
var
|
|
12256
|
+
var _a2, _b, _c;
|
|
11908
12257
|
const schedule = scheduleOf2(clause);
|
|
11909
12258
|
const grammar = resolveRouteGrammarThai(clause);
|
|
11910
12259
|
const verb = resolveThaiMethodVerb(clause, grammar);
|
|
@@ -11922,7 +12271,7 @@ function formatLongThai(clause, options) {
|
|
|
11922
12271
|
explicitDosePart
|
|
11923
12272
|
) ? void 0 : buildRoutePhraseThai(clause, grammar, Boolean(sitePart));
|
|
11924
12273
|
const standaloneOccurrenceCount = describeStandaloneOccurrenceCountThai(schedule);
|
|
11925
|
-
const frequencyPart = (_b = (
|
|
12274
|
+
const frequencyPart = (_b = (_a2 = describeFrequencyThai(schedule)) != null ? _a2 : standaloneOccurrenceCount) != null ? _b : describeFrequencyCountThai(inferDailyOccurrenceCount(schedule, options));
|
|
11926
12275
|
const eventParts = collectWhenPhrasesThai(schedule, options);
|
|
11927
12276
|
if ((_c = schedule.timeOfDay) == null ? void 0 : _c.length) {
|
|
11928
12277
|
const timeStrings = [];
|
|
@@ -11998,8 +12347,8 @@ function formatLongThai(clause, options) {
|
|
|
11998
12347
|
return trailingInstructionText ? `${baseSentence} ${trailingInstructionText}` : baseSentence;
|
|
11999
12348
|
}
|
|
12000
12349
|
function formatAdditionalInstructionsThai(clause) {
|
|
12001
|
-
var
|
|
12002
|
-
const instructions = (
|
|
12350
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
12351
|
+
const instructions = (_a2 = clause.additionalInstructions) != null ? _a2 : [];
|
|
12003
12352
|
if (!instructions.length) {
|
|
12004
12353
|
return void 0;
|
|
12005
12354
|
}
|
|
@@ -12062,7 +12411,7 @@ function tokenSpanLength(sign) {
|
|
|
12062
12411
|
return Math.max(0, sign.span.end - sign.span.start);
|
|
12063
12412
|
}
|
|
12064
12413
|
function countSynsemFeatures(sign) {
|
|
12065
|
-
var
|
|
12414
|
+
var _a2;
|
|
12066
12415
|
let count = 0;
|
|
12067
12416
|
const { head, valence, cont } = sign.synsem;
|
|
12068
12417
|
if (head.method) count += 1;
|
|
@@ -12071,7 +12420,7 @@ function countSynsemFeatures(sign) {
|
|
|
12071
12420
|
if (head.schedule) count += 1;
|
|
12072
12421
|
if (valence.site) count += 1;
|
|
12073
12422
|
if (valence.prn) count += 1;
|
|
12074
|
-
if ((
|
|
12423
|
+
if ((_a2 = valence.instructions) == null ? void 0 : _a2.length) count += 1;
|
|
12075
12424
|
if (valence.patientInstruction) count += 1;
|
|
12076
12425
|
if (cont.clauseKind) count += 1;
|
|
12077
12426
|
return count;
|
|
@@ -12138,8 +12487,8 @@ function pushUnique(signs, seen, sign) {
|
|
|
12138
12487
|
return true;
|
|
12139
12488
|
}
|
|
12140
12489
|
function parseHpsgChart(context, grammar, options = {}) {
|
|
12141
|
-
var
|
|
12142
|
-
const limit = (
|
|
12490
|
+
var _a2, _b;
|
|
12491
|
+
const limit = (_a2 = options.limit) != null ? _a2 : context.tokens.length;
|
|
12143
12492
|
const maxIterations = (_b = options.maxIterations) != null ? _b : Math.max(16, limit * limit * 2);
|
|
12144
12493
|
const signs = [];
|
|
12145
12494
|
const seen = /* @__PURE__ */ new Map();
|
|
@@ -12186,7 +12535,7 @@ function parseHpsgChart(context, grammar, options = {}) {
|
|
|
12186
12535
|
|
|
12187
12536
|
// src/hpsg/projection.ts
|
|
12188
12537
|
function applySchedule(state, schedule, deps) {
|
|
12189
|
-
var
|
|
12538
|
+
var _a2;
|
|
12190
12539
|
if (schedule.timingCode !== void 0) {
|
|
12191
12540
|
state.timingCode = schedule.timingCode;
|
|
12192
12541
|
}
|
|
@@ -12225,7 +12574,7 @@ function applySchedule(state, schedule, deps) {
|
|
|
12225
12574
|
if (schedule.dayOfWeek) {
|
|
12226
12575
|
deps.addDayOfWeekList(state, schedule.dayOfWeek);
|
|
12227
12576
|
}
|
|
12228
|
-
if ((
|
|
12577
|
+
if ((_a2 = schedule.timeOfDay) == null ? void 0 : _a2.length) {
|
|
12229
12578
|
const existing = state.timeOfDay ? state.timeOfDay.slice() : [];
|
|
12230
12579
|
for (const time of schedule.timeOfDay) {
|
|
12231
12580
|
if (existing.indexOf(time) === -1) {
|
|
@@ -12243,7 +12592,7 @@ function findTokenByIndex(tokens, tokenIndex) {
|
|
|
12243
12592
|
return tokens.find((candidate) => candidate.index === tokenIndex);
|
|
12244
12593
|
}
|
|
12245
12594
|
function projectHpsgSignToState(sign, state, tokens, deps) {
|
|
12246
|
-
var
|
|
12595
|
+
var _a2, _b, _c, _d;
|
|
12247
12596
|
const method = sign.synsem.head.method;
|
|
12248
12597
|
if (method) {
|
|
12249
12598
|
state.methodVerb = method.verb;
|
|
@@ -12287,7 +12636,7 @@ function projectHpsgSignToState(sign, state, tokens, deps) {
|
|
|
12287
12636
|
if (prn.reasonText !== void 0) {
|
|
12288
12637
|
state.asNeededReason = prn.reasonText;
|
|
12289
12638
|
}
|
|
12290
|
-
if ((
|
|
12639
|
+
if ((_a2 = prn.reasons) == null ? void 0 : _a2.length) {
|
|
12291
12640
|
state.asNeededReasons = prn.reasons.map((reason) => ({
|
|
12292
12641
|
text: reason.text
|
|
12293
12642
|
}));
|
|
@@ -12305,8 +12654,8 @@ function projectHpsgSignToState(sign, state, tokens, deps) {
|
|
|
12305
12654
|
for (const instruction of instructions) {
|
|
12306
12655
|
if (!existing.some(
|
|
12307
12656
|
(candidate) => {
|
|
12308
|
-
var
|
|
12309
|
-
return candidate.text === instruction.text && ((
|
|
12657
|
+
var _a3, _b2;
|
|
12658
|
+
return candidate.text === instruction.text && ((_a3 = candidate.coding) == null ? void 0 : _a3.code) === ((_b2 = instruction.coding) == null ? void 0 : _b2.code);
|
|
12310
12659
|
}
|
|
12311
12660
|
)) {
|
|
12312
12661
|
existing.push({
|
|
@@ -12374,13 +12723,13 @@ function mergeOptionalScalar(left, right) {
|
|
|
12374
12723
|
return left !== void 0 ? left : right;
|
|
12375
12724
|
}
|
|
12376
12725
|
function sameCoding(left, right) {
|
|
12377
|
-
var
|
|
12726
|
+
var _a2, _b;
|
|
12378
12727
|
if (!(left == null ? void 0 : left.code) || !(right == null ? void 0 : right.code)) {
|
|
12379
12728
|
return (left == null ? void 0 : left.code) === (right == null ? void 0 : right.code);
|
|
12380
12729
|
}
|
|
12381
12730
|
const leftVersion = left.version;
|
|
12382
12731
|
const rightVersion = right.version;
|
|
12383
|
-
return left.code === right.code && ((
|
|
12732
|
+
return left.code === right.code && ((_a2 = left.system) != null ? _a2 : "http://snomed.info/sct") === ((_b = right.system) != null ? _b : "http://snomed.info/sct") && leftVersion === rightVersion;
|
|
12384
12733
|
}
|
|
12385
12734
|
function sameOptionalText(left, right) {
|
|
12386
12735
|
return (left != null ? left : "") === (right != null ? right : "");
|
|
@@ -12476,11 +12825,11 @@ function mergePrnReasons(left, right) {
|
|
|
12476
12825
|
return result.length ? result : void 0;
|
|
12477
12826
|
}
|
|
12478
12827
|
function samePrnLookupRequest(left, right) {
|
|
12479
|
-
var
|
|
12828
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
12480
12829
|
if (!left || !right) {
|
|
12481
12830
|
return left === right;
|
|
12482
12831
|
}
|
|
12483
|
-
return left.originalText === right.originalText && left.text === right.text && left.normalized === right.normalized && left.canonical === right.canonical && sameOptionalText(left.headCanonical, right.headCanonical) && sameOptionalText(left.locativeSiteCanonical, right.locativeSiteCanonical) && sameCoding(left.locativeSiteCoding, right.locativeSiteCoding) && sameSpatialRelation(left.locativeSiteSpatialRelation, right.locativeSiteSpatialRelation) && left.isProbe === right.isProbe && left.inputText === right.inputText && sameOptionalText(left.sourceText, right.sourceText) && ((_b = (
|
|
12832
|
+
return left.originalText === right.originalText && left.text === right.text && left.normalized === right.normalized && left.canonical === right.canonical && sameOptionalText(left.headCanonical, right.headCanonical) && sameOptionalText(left.locativeSiteCanonical, right.locativeSiteCanonical) && sameCoding(left.locativeSiteCoding, right.locativeSiteCoding) && sameSpatialRelation(left.locativeSiteSpatialRelation, right.locativeSiteSpatialRelation) && left.isProbe === right.isProbe && left.inputText === right.inputText && sameOptionalText(left.sourceText, right.sourceText) && ((_b = (_a2 = left.range) == null ? void 0 : _a2.start) != null ? _b : -1) === ((_d = (_c = right.range) == null ? void 0 : _c.start) != null ? _d : -1) && ((_f = (_e = left.range) == null ? void 0 : _e.end) != null ? _f : -1) === ((_h = (_g = right.range) == null ? void 0 : _g.end) != null ? _h : -1);
|
|
12484
12833
|
}
|
|
12485
12834
|
function mergePrnLookupRequests(left, right) {
|
|
12486
12835
|
const result = [];
|
|
@@ -12563,7 +12912,7 @@ function mergeSchedule(left, right) {
|
|
|
12563
12912
|
};
|
|
12564
12913
|
}
|
|
12565
12914
|
function unifySynsem(left, right, context) {
|
|
12566
|
-
var
|
|
12915
|
+
var _a2;
|
|
12567
12916
|
const method = mergeMethod(left.head.method, right.head.method);
|
|
12568
12917
|
if (method === void 0 && left.head.method && right.head.method) {
|
|
12569
12918
|
return void 0;
|
|
@@ -12605,7 +12954,7 @@ function unifySynsem(left, right, context) {
|
|
|
12605
12954
|
)
|
|
12606
12955
|
},
|
|
12607
12956
|
cont: {
|
|
12608
|
-
clauseKind: (
|
|
12957
|
+
clauseKind: (_a2 = left.cont.clauseKind) != null ? _a2 : right.cont.clauseKind
|
|
12609
12958
|
}
|
|
12610
12959
|
};
|
|
12611
12960
|
}
|
|
@@ -12740,8 +13089,10 @@ var ADMINISTRATION_METHOD_WORDS = /* @__PURE__ */ new Set([
|
|
|
12740
13089
|
"spray",
|
|
12741
13090
|
"take",
|
|
12742
13091
|
"drink",
|
|
13092
|
+
"inhale",
|
|
12743
13093
|
"swallow",
|
|
12744
13094
|
"use",
|
|
13095
|
+
"inject",
|
|
12745
13096
|
"insert",
|
|
12746
13097
|
"instill",
|
|
12747
13098
|
"reapply",
|
|
@@ -13102,12 +13453,12 @@ function annotateLexTokens(tokens) {
|
|
|
13102
13453
|
return tokens.map((token) => annotateLexToken(token));
|
|
13103
13454
|
}
|
|
13104
13455
|
function hasTokenWordClass(token, wordClass) {
|
|
13105
|
-
var
|
|
13106
|
-
return Boolean(((
|
|
13456
|
+
var _a2;
|
|
13457
|
+
return Boolean(((_a2 = token == null ? void 0 : token.annotations) == null ? void 0 : _a2.wordClasses) && arrayIncludes(token.annotations.wordClasses, wordClass));
|
|
13107
13458
|
}
|
|
13108
13459
|
function getDayOfWeekMeaning(token) {
|
|
13109
|
-
var
|
|
13110
|
-
if ((
|
|
13460
|
+
var _a2;
|
|
13461
|
+
if ((_a2 = token == null ? void 0 : token.annotations) == null ? void 0 : _a2.dayOfWeek) {
|
|
13111
13462
|
return token.annotations.dayOfWeek.slice();
|
|
13112
13463
|
}
|
|
13113
13464
|
if (!token) {
|
|
@@ -13116,8 +13467,8 @@ function getDayOfWeekMeaning(token) {
|
|
|
13116
13467
|
return resolveDayMeaning(token.lower);
|
|
13117
13468
|
}
|
|
13118
13469
|
function getRouteMeaning(token) {
|
|
13119
|
-
var
|
|
13120
|
-
if ((_b = (
|
|
13470
|
+
var _a2, _b;
|
|
13471
|
+
if ((_b = (_a2 = token == null ? void 0 : token.annotations) == null ? void 0 : _a2.routeCandidates) == null ? void 0 : _b.length) {
|
|
13121
13472
|
return token.annotations.routeCandidates[0];
|
|
13122
13473
|
}
|
|
13123
13474
|
if (!token) {
|
|
@@ -13129,8 +13480,8 @@ function getRouteMeaning(token) {
|
|
|
13129
13480
|
}) : void 0;
|
|
13130
13481
|
}
|
|
13131
13482
|
function getSiteMeaningCandidates(token) {
|
|
13132
|
-
var
|
|
13133
|
-
if ((_b = (
|
|
13483
|
+
var _a2, _b;
|
|
13484
|
+
if ((_b = (_a2 = token == null ? void 0 : token.annotations) == null ? void 0 : _a2.siteCandidates) == null ? void 0 : _b.length) {
|
|
13134
13485
|
return token.annotations.siteCandidates.slice();
|
|
13135
13486
|
}
|
|
13136
13487
|
if (!token) {
|
|
@@ -13281,6 +13632,7 @@ function pad2(value) {
|
|
|
13281
13632
|
return value < 10 ? `0${value}` : String(value);
|
|
13282
13633
|
}
|
|
13283
13634
|
function parseClockToken(token, meridiemToken) {
|
|
13635
|
+
var _a2;
|
|
13284
13636
|
if (!token) {
|
|
13285
13637
|
return void 0;
|
|
13286
13638
|
}
|
|
@@ -13288,6 +13640,9 @@ function parseClockToken(token, meridiemToken) {
|
|
|
13288
13640
|
if (lower.startsWith("@")) {
|
|
13289
13641
|
lower = lower.slice(1);
|
|
13290
13642
|
}
|
|
13643
|
+
if (token.derived && ((_a2 = token.sourceText) == null ? void 0 : _a2.includes("/")) && /^[0-9]+(?:\.[0-9]+)?$/.test(lower)) {
|
|
13644
|
+
return void 0;
|
|
13645
|
+
}
|
|
13291
13646
|
const meridiem = meridiemToken ? normalizeTokenLower(meridiemToken) : void 0;
|
|
13292
13647
|
let hour;
|
|
13293
13648
|
let minute = 0;
|
|
@@ -13396,7 +13751,7 @@ function emptySynsem() {
|
|
|
13396
13751
|
};
|
|
13397
13752
|
}
|
|
13398
13753
|
function lexicalSign(args) {
|
|
13399
|
-
var
|
|
13754
|
+
var _a2, _b;
|
|
13400
13755
|
const tokenIndices = args.tokens.map((token) => token.index).filter((index) => Number.isFinite(index));
|
|
13401
13756
|
if (!tokenIndices.length) {
|
|
13402
13757
|
throw new Error(`Cannot build lexical sign for ${args.rule} without token indices.`);
|
|
@@ -13408,7 +13763,7 @@ function lexicalSign(args) {
|
|
|
13408
13763
|
span: { start, end },
|
|
13409
13764
|
tokens: args.tokens,
|
|
13410
13765
|
synsem: args.synsem,
|
|
13411
|
-
consumedTokenIndices: (
|
|
13766
|
+
consumedTokenIndices: (_a2 = args.consumedTokenIndices) != null ? _a2 : tokenIndices,
|
|
13412
13767
|
siteTokenIndices: args.siteTokenIndices,
|
|
13413
13768
|
warnings: args.warnings,
|
|
13414
13769
|
evidence: [
|
|
@@ -13438,8 +13793,8 @@ function timingCodeForDailyFrequency(value) {
|
|
|
13438
13793
|
}
|
|
13439
13794
|
function multiplicativeDoseFrequencyRule() {
|
|
13440
13795
|
return lexicalRule("hpsg.lex.doseFrequency.multiplicative", (context, start) => {
|
|
13441
|
-
var
|
|
13442
|
-
const first = (
|
|
13796
|
+
var _a2;
|
|
13797
|
+
const first = (_a2 = tokensAvailable(context, start, 1)) == null ? void 0 : _a2[0];
|
|
13443
13798
|
if (!first) {
|
|
13444
13799
|
return [];
|
|
13445
13800
|
}
|
|
@@ -13569,8 +13924,8 @@ function compactIntervalRule() {
|
|
|
13569
13924
|
}
|
|
13570
13925
|
function separatedIntervalRule() {
|
|
13571
13926
|
return lexicalRule("hpsg.lex.schedule.separatedInterval", (context, start) => {
|
|
13572
|
-
var
|
|
13573
|
-
const lead = (
|
|
13927
|
+
var _a2;
|
|
13928
|
+
const lead = (_a2 = tokensAvailable(context, start, 1)) == null ? void 0 : _a2[0];
|
|
13574
13929
|
if (!lead || !EVERY_INTERVAL_TOKENS.has(normalizeTokenLower(lead))) {
|
|
13575
13930
|
return [];
|
|
13576
13931
|
}
|
|
@@ -13671,8 +14026,8 @@ function separatedIntervalRule() {
|
|
|
13671
14026
|
}
|
|
13672
14027
|
function countFrequencyRule() {
|
|
13673
14028
|
return lexicalRule("hpsg.lex.schedule.frequency", (context, start) => {
|
|
13674
|
-
var
|
|
13675
|
-
const token = (
|
|
14029
|
+
var _a2, _b, _c, _d;
|
|
14030
|
+
const token = (_a2 = tokensAvailable(context, start, 1)) == null ? void 0 : _a2[0];
|
|
13676
14031
|
if (!token) {
|
|
13677
14032
|
return [];
|
|
13678
14033
|
}
|
|
@@ -13801,8 +14156,8 @@ function countFrequencyRule() {
|
|
|
13801
14156
|
}
|
|
13802
14157
|
function timingLexicalRule() {
|
|
13803
14158
|
return lexicalRule("hpsg.lex.schedule.timing", (context, start) => {
|
|
13804
|
-
var
|
|
13805
|
-
const token = (
|
|
14159
|
+
var _a2;
|
|
14160
|
+
const token = (_a2 = tokensAvailable(context, start, 1)) == null ? void 0 : _a2[0];
|
|
13806
14161
|
if (!token) {
|
|
13807
14162
|
return [];
|
|
13808
14163
|
}
|
|
@@ -13893,16 +14248,16 @@ function timingLexicalRule() {
|
|
|
13893
14248
|
});
|
|
13894
14249
|
}
|
|
13895
14250
|
function mealTimingForRelation(relation, meal) {
|
|
13896
|
-
var
|
|
13897
|
-
return (
|
|
14251
|
+
var _a2;
|
|
14252
|
+
return (_a2 = MEAL_TIMING_BY_RELATION.get(relation)) == null ? void 0 : _a2.get(meal);
|
|
13898
14253
|
}
|
|
13899
14254
|
function mealRelationFromToken(lower) {
|
|
13900
14255
|
return MEAL_RELATION_BY_TOKEN.get(lower);
|
|
13901
14256
|
}
|
|
13902
14257
|
function eventTimingPhraseRule() {
|
|
13903
14258
|
return lexicalRule("hpsg.lex.schedule.eventPhrase", (context, start) => {
|
|
13904
|
-
var
|
|
13905
|
-
const first = (
|
|
14259
|
+
var _a2;
|
|
14260
|
+
const first = (_a2 = tokensAvailable(context, start, 1)) == null ? void 0 : _a2[0];
|
|
13906
14261
|
if (!first) {
|
|
13907
14262
|
return [];
|
|
13908
14263
|
}
|
|
@@ -14051,8 +14406,8 @@ function expandDayRange(startDay, endDay) {
|
|
|
14051
14406
|
}
|
|
14052
14407
|
function dayRangeLexicalRule() {
|
|
14053
14408
|
return lexicalRule("hpsg.lex.schedule.dayRange", (context, start) => {
|
|
14054
|
-
var
|
|
14055
|
-
const first = (
|
|
14409
|
+
var _a2;
|
|
14410
|
+
const first = (_a2 = tokensAvailable(context, start, 1)) == null ? void 0 : _a2[0];
|
|
14056
14411
|
if (!first) {
|
|
14057
14412
|
return [];
|
|
14058
14413
|
}
|
|
@@ -14121,8 +14476,8 @@ function dayRangeLexicalRule() {
|
|
|
14121
14476
|
}
|
|
14122
14477
|
function countAndDurationRule() {
|
|
14123
14478
|
return lexicalRule("hpsg.lex.schedule.limit", (context, start) => {
|
|
14124
|
-
var
|
|
14125
|
-
const token = (
|
|
14479
|
+
var _a2, _b;
|
|
14480
|
+
const token = (_a2 = tokensAvailable(context, start, 1)) == null ? void 0 : _a2[0];
|
|
14126
14481
|
if (!token) {
|
|
14127
14482
|
return [];
|
|
14128
14483
|
}
|
|
@@ -14330,57 +14685,180 @@ function isScheduleLead(context, index) {
|
|
|
14330
14685
|
return false;
|
|
14331
14686
|
}
|
|
14332
14687
|
|
|
14688
|
+
// src/unit-terminology.json
|
|
14689
|
+
var unit_terminology_default = {
|
|
14690
|
+
terms: [
|
|
14691
|
+
{ unit: "mg", kind: "metric" },
|
|
14692
|
+
{ unit: "g", kind: "metric" },
|
|
14693
|
+
{ unit: "kg", kind: "metric" },
|
|
14694
|
+
{ unit: "mcg", kind: "metric" },
|
|
14695
|
+
{ unit: "ug", kind: "metric" },
|
|
14696
|
+
{ unit: "microg", kind: "metric" },
|
|
14697
|
+
{ unit: "ng", kind: "metric" },
|
|
14698
|
+
{ unit: "mL", kind: "metric" },
|
|
14699
|
+
{ unit: "L", kind: "metric" },
|
|
14700
|
+
{ unit: "dL", kind: "metric" },
|
|
14701
|
+
{ unit: "mcL", kind: "metric" },
|
|
14702
|
+
{ unit: "uL", kind: "metric" },
|
|
14703
|
+
{ unit: "nL", kind: "metric" },
|
|
14704
|
+
{ unit: "cm3", kind: "metric" },
|
|
14705
|
+
{ unit: "tsp", kind: "metric", aliases: ["teaspoon"] },
|
|
14706
|
+
{ unit: "tbsp", kind: "metric", aliases: ["tablespoon"] },
|
|
14707
|
+
{ unit: "U", kind: "biologic_unit", aliases: ["unit", "units"] },
|
|
14708
|
+
{ unit: "IU", kind: "biologic_unit", aliases: ["iu", "ius"] },
|
|
14709
|
+
{ unit: "puff", kind: "device_actuation", aliases: ["puffs", "inhalation", "inhalations"] },
|
|
14710
|
+
{ unit: "spray", kind: "device_actuation", aliases: ["sprays"] },
|
|
14711
|
+
{ unit: "pump", kind: "device_actuation", aliases: ["pumps"] },
|
|
14712
|
+
{ unit: "actuation", kind: "device_actuation", aliases: ["actuations"] },
|
|
14713
|
+
{
|
|
14714
|
+
unit: "drop",
|
|
14715
|
+
kind: "product_specific_amount",
|
|
14716
|
+
aliases: ["drops", "gtt", "gtts", "eyedrop", "eyedrops"],
|
|
14717
|
+
approximateQuantity: {
|
|
14718
|
+
value: 0.05,
|
|
14719
|
+
unit: "mL",
|
|
14720
|
+
confidence: "approximate",
|
|
14721
|
+
basis: "Generic ophthalmic drop default; product/dropper-specific values should override this",
|
|
14722
|
+
source: "https://pmc.ncbi.nlm.nih.gov/articles/PMC3217709/"
|
|
14723
|
+
}
|
|
14724
|
+
},
|
|
14725
|
+
{ unit: "dropperful", kind: "product_specific_amount", aliases: ["dropperfuls"] },
|
|
14726
|
+
{
|
|
14727
|
+
unit: "drop/min",
|
|
14728
|
+
kind: "infusion_rate",
|
|
14729
|
+
aliases: ["drops/min", "gtt/min", "gtts/min", "drop per minute", "drops per minute"],
|
|
14730
|
+
parseAsDose: false
|
|
14731
|
+
},
|
|
14732
|
+
{ unit: "applicatorful", kind: "product_specific_amount", aliases: ["applicatorfuls", "applicator", "applicators", "full applicator", "full applicators"] },
|
|
14733
|
+
{ unit: "capful", kind: "product_specific_amount", aliases: ["capfuls", "cap to line", "cap filled to line"] },
|
|
14734
|
+
{ unit: "scoop", kind: "product_specific_amount", aliases: ["scoops"] },
|
|
14735
|
+
{
|
|
14736
|
+
unit: "pea-sized amount",
|
|
14737
|
+
kind: "product_specific_amount",
|
|
14738
|
+
aliases: [
|
|
14739
|
+
"pea sized amount",
|
|
14740
|
+
"pea-sized",
|
|
14741
|
+
"pea sized",
|
|
14742
|
+
"pea size amount",
|
|
14743
|
+
"pea-size amount",
|
|
14744
|
+
"\u0E40\u0E21\u0E47\u0E14\u0E16\u0E31\u0E48\u0E27",
|
|
14745
|
+
"\u0E40\u0E21\u0E47\u0E14\u0E16\u0E31\u0E48\u0E27\u0E40\u0E02\u0E35\u0E22\u0E27",
|
|
14746
|
+
"\u0E40\u0E21\u0E25\u0E47\u0E14\u0E16\u0E31\u0E48\u0E27",
|
|
14747
|
+
"\u0E02\u0E19\u0E32\u0E14\u0E40\u0E21\u0E47\u0E14\u0E16\u0E31\u0E48\u0E27",
|
|
14748
|
+
"\u0E02\u0E19\u0E32\u0E14\u0E40\u0E21\u0E47\u0E14\u0E16\u0E31\u0E48\u0E27\u0E40\u0E02\u0E35\u0E22\u0E27",
|
|
14749
|
+
"\u0E02\u0E19\u0E32\u0E14\u0E40\u0E21\u0E25\u0E47\u0E14\u0E16\u0E31\u0E48\u0E27"
|
|
14750
|
+
],
|
|
14751
|
+
approximateQuantity: {
|
|
14752
|
+
value: 0.25,
|
|
14753
|
+
unit: "mL",
|
|
14754
|
+
confidence: "approximate",
|
|
14755
|
+
basis: "Generic pea-sized volume proxy; product labels may define mass and should override when known",
|
|
14756
|
+
source: "https://www.accessdata.fda.gov/drugsatfda_docs/nda/2000/21-108_Renova_Medr_P1.pdf"
|
|
14757
|
+
}
|
|
14758
|
+
},
|
|
14759
|
+
{
|
|
14760
|
+
unit: "shot glass",
|
|
14761
|
+
kind: "product_specific_amount",
|
|
14762
|
+
aliases: ["shotglass", "shot glasses"],
|
|
14763
|
+
approximateQuantity: {
|
|
14764
|
+
value: 29.5735,
|
|
14765
|
+
unit: "mL",
|
|
14766
|
+
confidence: "approximate",
|
|
14767
|
+
basis: "AAD sunscreen full-body adult amount: about 1 ounce, roughly a shot glass",
|
|
14768
|
+
source: "https://www.aad.org/media/stats-sunscreen"
|
|
14769
|
+
}
|
|
14770
|
+
},
|
|
14771
|
+
{ unit: "finger length", kind: "product_specific_amount", aliases: ["finger lengths", "two-finger rule", "two finger rule", "two-finger method", "two finger method"] },
|
|
14772
|
+
{
|
|
14773
|
+
unit: "FTU",
|
|
14774
|
+
kind: "product_specific_amount",
|
|
14775
|
+
aliases: ["ftu", "ftus", "f.t.u", "f.t.u.", "fingertip unit", "fingertip units"],
|
|
14776
|
+
approximateQuantity: {
|
|
14777
|
+
value: 0.5,
|
|
14778
|
+
unit: "g",
|
|
14779
|
+
confidence: "approximate",
|
|
14780
|
+
basis: "DermNet adult male fingertip unit default",
|
|
14781
|
+
source: "https://dermnetnz.org/topics/fingertip-unit"
|
|
14782
|
+
}
|
|
14783
|
+
},
|
|
14784
|
+
{ unit: "cm ribbon", kind: "length_of_product" },
|
|
14785
|
+
{ unit: "inch ribbon", kind: "length_of_product", aliases: ["inch strip"] },
|
|
14786
|
+
{ unit: "cm strip", kind: "length_of_product" },
|
|
14787
|
+
{ unit: "cm line", kind: "length_of_product" },
|
|
14788
|
+
{ unit: "inch line", kind: "length_of_product" },
|
|
14789
|
+
{ unit: "palm", kind: "body_area_proxy", aliases: ["palms"] },
|
|
14790
|
+
{ unit: "handprint", kind: "body_area_proxy", aliases: ["handprints", "hand print", "hand prints"] },
|
|
14791
|
+
{ unit: "% BSA", kind: "body_area_proxy", aliases: ["%BSA", "% TBSA", "%TBSA", "percent BSA", "percent TBSA"] },
|
|
14792
|
+
{ unit: "tab", kind: "counted_presentation", aliases: ["tablet"] },
|
|
14793
|
+
{ unit: "cap", kind: "counted_presentation", aliases: ["capsule"] },
|
|
14794
|
+
{ unit: "patch", kind: "counted_presentation", aliases: ["patches", "system", "systems", "transdermal system", "transdermal systems"] },
|
|
14795
|
+
{ unit: "ring", kind: "counted_presentation", aliases: ["rings"] },
|
|
14796
|
+
{ unit: "suppository", kind: "counted_presentation", aliases: ["suppositories"] },
|
|
14797
|
+
{ unit: "pessary", kind: "counted_presentation", aliases: ["pessaries"] },
|
|
14798
|
+
{ unit: "insert", kind: "counted_presentation", aliases: ["inserts"] },
|
|
14799
|
+
{ unit: "ovule", kind: "counted_presentation", aliases: ["ovules"] },
|
|
14800
|
+
{ unit: "enema", kind: "counted_presentation", aliases: ["enemas"] },
|
|
14801
|
+
{ unit: "swab", kind: "counted_presentation", aliases: ["swabs"] },
|
|
14802
|
+
{ unit: "pad", kind: "counted_presentation", aliases: ["pads"] },
|
|
14803
|
+
{ unit: "wipe", kind: "counted_presentation", aliases: ["wipes"] },
|
|
14804
|
+
{ unit: "stick", kind: "counted_presentation", aliases: ["sticks"] },
|
|
14805
|
+
{ unit: "stick-pack", kind: "counted_presentation", aliases: ["stick pack", "stick packs", "stick-packs"] },
|
|
14806
|
+
{ unit: "implant", kind: "counted_presentation", aliases: ["implants"] },
|
|
14807
|
+
{ unit: "pellet", kind: "counted_presentation", aliases: ["pellets"] },
|
|
14808
|
+
{ unit: "lozenge", kind: "counted_presentation", aliases: ["lozenges"] },
|
|
14809
|
+
{ unit: "troche", kind: "counted_presentation", aliases: ["troches"] },
|
|
14810
|
+
{ unit: "wafer", kind: "counted_presentation", aliases: ["wafers"] },
|
|
14811
|
+
{ unit: "film", kind: "counted_presentation", aliases: ["films"] },
|
|
14812
|
+
{ unit: "strip", kind: "counted_presentation", aliases: ["strips"] },
|
|
14813
|
+
{ unit: "softgel", kind: "counted_presentation", aliases: ["softgels"] },
|
|
14814
|
+
{ unit: "tube", kind: "counted_presentation", aliases: ["tubes"] },
|
|
14815
|
+
{ unit: "bottle", kind: "counted_presentation", aliases: ["bottles"] },
|
|
14816
|
+
{ unit: "container", kind: "counted_presentation", aliases: ["containers"] },
|
|
14817
|
+
{ unit: "jar", kind: "counted_presentation", aliases: ["jars"] },
|
|
14818
|
+
{ unit: "packet", kind: "counted_presentation", aliases: ["packets"] },
|
|
14819
|
+
{ unit: "sachet", kind: "counted_presentation", aliases: ["sachets"] },
|
|
14820
|
+
{ unit: "vial", kind: "counted_presentation", aliases: ["vials", "unit-dose vial", "unit-dose vials", "unit dose vial", "unit dose vials"] },
|
|
14821
|
+
{ unit: "ampule", kind: "counted_presentation", aliases: ["amp", "amps", "ampules", "ampoule", "ampoules"] },
|
|
14822
|
+
{ unit: "nebule", kind: "counted_presentation", aliases: ["nebules"] },
|
|
14823
|
+
{ unit: "respule", kind: "counted_presentation", aliases: ["respules"] },
|
|
14824
|
+
{ unit: "syringe", kind: "counted_presentation", aliases: ["syringes"] },
|
|
14825
|
+
{ unit: "pen", kind: "counted_presentation", aliases: ["pens"] },
|
|
14826
|
+
{ unit: "cartridge", kind: "counted_presentation", aliases: ["cartridges"] },
|
|
14827
|
+
{ unit: "canister", kind: "counted_presentation", aliases: ["canisters"] },
|
|
14828
|
+
{ unit: "blister", kind: "counted_presentation", aliases: ["blisters"] },
|
|
14829
|
+
{ unit: "bag", kind: "counted_presentation", aliases: ["bags"] },
|
|
14830
|
+
{ unit: "pod", kind: "counted_presentation", aliases: ["pods"] },
|
|
14831
|
+
{ unit: "click", kind: "device_actuation", aliases: ["clicks", "pen click", "pen clicks", "dial click", "dial clicks"] }
|
|
14832
|
+
]
|
|
14833
|
+
};
|
|
14834
|
+
|
|
14333
14835
|
// src/unit-lexicon.ts
|
|
14334
14836
|
var HOUSEHOLD_VOLUME_UNIT_SET = new Set(
|
|
14335
14837
|
HOUSEHOLD_VOLUME_UNITS.map((unit) => unit.toLowerCase())
|
|
14336
14838
|
);
|
|
14337
|
-
var
|
|
14338
|
-
|
|
14339
|
-
|
|
14340
|
-
"
|
|
14341
|
-
"
|
|
14342
|
-
"
|
|
14343
|
-
"
|
|
14344
|
-
"
|
|
14345
|
-
"capsules",
|
|
14346
|
-
"puff",
|
|
14347
|
-
"puffs",
|
|
14348
|
-
"spray",
|
|
14349
|
-
"sprays",
|
|
14350
|
-
"drop",
|
|
14351
|
-
"drops",
|
|
14352
|
-
"patch",
|
|
14353
|
-
"patches",
|
|
14354
|
-
"suppository",
|
|
14355
|
-
"suppositories",
|
|
14356
|
-
"implant",
|
|
14357
|
-
"implants",
|
|
14358
|
-
"piece",
|
|
14359
|
-
"pieces",
|
|
14360
|
-
"stick",
|
|
14361
|
-
"sticks",
|
|
14362
|
-
"pump",
|
|
14363
|
-
"pumps",
|
|
14364
|
-
"squeeze",
|
|
14365
|
-
"squeezes",
|
|
14366
|
-
"applicatorful",
|
|
14367
|
-
"applicatorfuls",
|
|
14368
|
-
"capful",
|
|
14369
|
-
"capfuls",
|
|
14370
|
-
"scoop",
|
|
14371
|
-
"scoops",
|
|
14372
|
-
"application",
|
|
14373
|
-
"applications",
|
|
14374
|
-
"ribbon",
|
|
14375
|
-
"pessary",
|
|
14376
|
-
"pessaries",
|
|
14377
|
-
"lozenge",
|
|
14378
|
-
"lozenges"
|
|
14839
|
+
var DOSE_UNIT_TERMINOLOGY = unit_terminology_default.terms;
|
|
14840
|
+
var DOSE_UNIT_TERMINOLOGY_BY_KEY = /* @__PURE__ */ new Map();
|
|
14841
|
+
var DISCRETE_UNIT_KINDS = /* @__PURE__ */ new Set([
|
|
14842
|
+
"biologic_unit",
|
|
14843
|
+
"counted_presentation",
|
|
14844
|
+
"device_actuation",
|
|
14845
|
+
"product_specific_amount",
|
|
14846
|
+
"length_of_product"
|
|
14379
14847
|
]);
|
|
14848
|
+
var _a;
|
|
14849
|
+
for (const entry of DOSE_UNIT_TERMINOLOGY) {
|
|
14850
|
+
const keys = [entry.unit, ...(_a = entry.aliases) != null ? _a : []];
|
|
14851
|
+
for (const key of keys) {
|
|
14852
|
+
const normalized = normalizeUnitKey(key);
|
|
14853
|
+
if (normalized) {
|
|
14854
|
+
DOSE_UNIT_TERMINOLOGY_BY_KEY.set(normalized, entry);
|
|
14855
|
+
}
|
|
14856
|
+
}
|
|
14857
|
+
}
|
|
14380
14858
|
function normalizeUnit(token, options) {
|
|
14381
|
-
var
|
|
14859
|
+
var _a2;
|
|
14382
14860
|
const key = token.trim().toLowerCase();
|
|
14383
|
-
const override = enforceHouseholdUnitPolicy((
|
|
14861
|
+
const override = enforceHouseholdUnitPolicy((_a2 = options == null ? void 0 : options.unitMap) == null ? void 0 : _a2[key], options);
|
|
14384
14862
|
if (override) {
|
|
14385
14863
|
return override;
|
|
14386
14864
|
}
|
|
@@ -14391,8 +14869,80 @@ function normalizeUnit(token, options) {
|
|
|
14391
14869
|
if (defaultUnit) {
|
|
14392
14870
|
return defaultUnit;
|
|
14393
14871
|
}
|
|
14872
|
+
const terminologyEntry = getDoseUnitTerminologyEntry(token);
|
|
14873
|
+
const terminologyUnit = (terminologyEntry == null ? void 0 : terminologyEntry.parseAsDose) === false ? void 0 : terminologyEntry == null ? void 0 : terminologyEntry.unit;
|
|
14874
|
+
const policyCheckedTerminologyUnit = enforceHouseholdUnitPolicy(terminologyUnit, options);
|
|
14875
|
+
if (policyCheckedTerminologyUnit) {
|
|
14876
|
+
return policyCheckedTerminologyUnit;
|
|
14877
|
+
}
|
|
14394
14878
|
return void 0;
|
|
14395
14879
|
}
|
|
14880
|
+
function normalizeUnitKey(unit) {
|
|
14881
|
+
const normalized = unit == null ? void 0 : unit.trim();
|
|
14882
|
+
return normalized ? normalized.toLowerCase() : void 0;
|
|
14883
|
+
}
|
|
14884
|
+
function unitApproximationOverride(unit, context) {
|
|
14885
|
+
const entries = context == null ? void 0 : context.unitApproximationMap;
|
|
14886
|
+
if (!entries) {
|
|
14887
|
+
return void 0;
|
|
14888
|
+
}
|
|
14889
|
+
const unitKey = normalizeUnitKey(unit);
|
|
14890
|
+
for (const candidateUnit in entries) {
|
|
14891
|
+
if (!Object.prototype.hasOwnProperty.call(entries, candidateUnit)) {
|
|
14892
|
+
continue;
|
|
14893
|
+
}
|
|
14894
|
+
const approximation = entries[candidateUnit];
|
|
14895
|
+
if (normalizeUnitKey(candidateUnit) === unitKey) {
|
|
14896
|
+
return approximation;
|
|
14897
|
+
}
|
|
14898
|
+
}
|
|
14899
|
+
return void 0;
|
|
14900
|
+
}
|
|
14901
|
+
function getDoseUnitTerminologyEntry(unit) {
|
|
14902
|
+
var _a2;
|
|
14903
|
+
if (!unit) {
|
|
14904
|
+
return void 0;
|
|
14905
|
+
}
|
|
14906
|
+
return DOSE_UNIT_TERMINOLOGY_BY_KEY.get((_a2 = normalizeUnitKey(unit)) != null ? _a2 : "");
|
|
14907
|
+
}
|
|
14908
|
+
function getDoseUnitKind(unit) {
|
|
14909
|
+
var _a2;
|
|
14910
|
+
return (_a2 = getDoseUnitTerminologyEntry(unit)) == null ? void 0 : _a2.kind;
|
|
14911
|
+
}
|
|
14912
|
+
function getDoseUnitApproximation(unit, context) {
|
|
14913
|
+
var _a2, _b;
|
|
14914
|
+
if (!unit) {
|
|
14915
|
+
return void 0;
|
|
14916
|
+
}
|
|
14917
|
+
const terminologyEntry = getDoseUnitTerminologyEntry(unit);
|
|
14918
|
+
const override = (_b = unitApproximationOverride(unit, context)) != null ? _b : unitApproximationOverride((_a2 = terminologyEntry == null ? void 0 : terminologyEntry.unit) != null ? _a2 : "", context);
|
|
14919
|
+
if (override) {
|
|
14920
|
+
return override;
|
|
14921
|
+
}
|
|
14922
|
+
return terminologyEntry == null ? void 0 : terminologyEntry.approximateQuantity;
|
|
14923
|
+
}
|
|
14924
|
+
function getDoseUnitSemantics(unit, context) {
|
|
14925
|
+
if (!unit) {
|
|
14926
|
+
return void 0;
|
|
14927
|
+
}
|
|
14928
|
+
const terminologyEntry = getDoseUnitTerminologyEntry(unit);
|
|
14929
|
+
if (!terminologyEntry) {
|
|
14930
|
+
return void 0;
|
|
14931
|
+
}
|
|
14932
|
+
return {
|
|
14933
|
+
unit: terminologyEntry.unit,
|
|
14934
|
+
kind: terminologyEntry.kind,
|
|
14935
|
+
parseAsDose: terminologyEntry.parseAsDose,
|
|
14936
|
+
approximateQuantity: getDoseUnitApproximation(unit, context)
|
|
14937
|
+
};
|
|
14938
|
+
}
|
|
14939
|
+
function listDoseUnitTerminology() {
|
|
14940
|
+
return DOSE_UNIT_TERMINOLOGY.map((entry) => __spreadProps(__spreadValues({}, entry), {
|
|
14941
|
+
aliases: entry.aliases ? [...entry.aliases] : void 0,
|
|
14942
|
+
parseAsDose: entry.parseAsDose,
|
|
14943
|
+
approximateQuantity: entry.approximateQuantity ? __spreadValues({}, entry.approximateQuantity) : void 0
|
|
14944
|
+
}));
|
|
14945
|
+
}
|
|
14396
14946
|
function enforceHouseholdUnitPolicy(unit, options) {
|
|
14397
14947
|
if (unit && (options == null ? void 0 : options.allowHouseholdVolumeUnits) === false && HOUSEHOLD_VOLUME_UNIT_SET.has(unit.toLowerCase())) {
|
|
14398
14948
|
return void 0;
|
|
@@ -14403,7 +14953,8 @@ function isDiscreteUnit(unit) {
|
|
|
14403
14953
|
if (!unit) {
|
|
14404
14954
|
return false;
|
|
14405
14955
|
}
|
|
14406
|
-
|
|
14956
|
+
const semantics = getDoseUnitSemantics(unit);
|
|
14957
|
+
return Boolean(semantics && DISCRETE_UNIT_KINDS.has(semantics.kind));
|
|
14407
14958
|
}
|
|
14408
14959
|
|
|
14409
14960
|
// src/hpsg/method-lexicon.ts
|
|
@@ -14412,6 +14963,8 @@ var METHOD_ACTION_BY_VERB = {
|
|
|
14412
14963
|
apply: "apply" /* Apply */,
|
|
14413
14964
|
dab: "apply" /* Apply */,
|
|
14414
14965
|
drink: "swallow" /* Swallow */,
|
|
14966
|
+
inhale: "inhale" /* Inhale */,
|
|
14967
|
+
inject: "inject" /* Inject */,
|
|
14415
14968
|
insert: "insert" /* Insert */,
|
|
14416
14969
|
instill: "instill" /* Instill */,
|
|
14417
14970
|
lather: "wash" /* Wash */,
|
|
@@ -14438,6 +14991,18 @@ var METHOD_CODING_BY_ACTION = {
|
|
|
14438
14991
|
display: "Apply",
|
|
14439
14992
|
_display: buildTranslationPrimitiveElement({ th: "\u0E17\u0E32" })
|
|
14440
14993
|
},
|
|
14994
|
+
["inhale" /* Inhale */]: {
|
|
14995
|
+
system: SNOMED_SYSTEM6,
|
|
14996
|
+
code: "740666001",
|
|
14997
|
+
display: "Inhale",
|
|
14998
|
+
_display: buildTranslationPrimitiveElement({ th: "\u0E2A\u0E39\u0E14" })
|
|
14999
|
+
},
|
|
15000
|
+
["inject" /* Inject */]: {
|
|
15001
|
+
system: SNOMED_SYSTEM6,
|
|
15002
|
+
code: "740685003",
|
|
15003
|
+
display: "Inject",
|
|
15004
|
+
_display: buildTranslationPrimitiveElement({ th: "\u0E09\u0E35\u0E14" })
|
|
15005
|
+
},
|
|
14441
15006
|
["insert" /* Insert */]: {
|
|
14442
15007
|
system: SNOMED_SYSTEM6,
|
|
14443
15008
|
code: "738993004",
|
|
@@ -14483,12 +15048,12 @@ function cloneMethodCoding(coding) {
|
|
|
14483
15048
|
|
|
14484
15049
|
// src/hpsg/rules/product-route.ts
|
|
14485
15050
|
function productRouteHint(phrase) {
|
|
14486
|
-
var
|
|
15051
|
+
var _a2;
|
|
14487
15052
|
const key = (phrase != null ? phrase : "").trim().replace(/\s+/g, " ").toLowerCase();
|
|
14488
15053
|
if (!key) {
|
|
14489
15054
|
return void 0;
|
|
14490
15055
|
}
|
|
14491
|
-
const direct = (
|
|
15056
|
+
const direct = (_a2 = PRODUCT_FORM_HINTS[key]) == null ? void 0 : _a2.routeHint;
|
|
14492
15057
|
if (direct) {
|
|
14493
15058
|
return direct;
|
|
14494
15059
|
}
|
|
@@ -14507,23 +15072,23 @@ function isKnownPrnReasonText(text) {
|
|
|
14507
15072
|
return Boolean(canonical && DEFAULT_PRN_REASON_DEFINITIONS[canonical]);
|
|
14508
15073
|
}
|
|
14509
15074
|
function normalizeLocatedReasonHead(text) {
|
|
14510
|
-
var
|
|
15075
|
+
var _a2;
|
|
14511
15076
|
const canonical = normalizePrnReasonKey(text);
|
|
14512
15077
|
if (!canonical) {
|
|
14513
15078
|
return void 0;
|
|
14514
15079
|
}
|
|
14515
|
-
return (
|
|
15080
|
+
return (_a2 = PRN_GENERIC_LOCATED_HEADS.get(canonical)) != null ? _a2 : canonical;
|
|
14516
15081
|
}
|
|
14517
15082
|
function isLocatedReasonHead(text) {
|
|
14518
15083
|
const canonical = normalizeLocatedReasonHead(text);
|
|
14519
15084
|
return Boolean(canonical && (DEFAULT_PRN_REASON_DEFINITIONS[canonical] || PRN_GENERIC_LOCATED_HEADS.has(canonical)));
|
|
14520
15085
|
}
|
|
14521
15086
|
function normalizePredicativeReasonText(text) {
|
|
14522
|
-
var
|
|
14523
|
-
return (_b = PRN_PREDICATE_REASON_NORMALIZATIONS.get((
|
|
15087
|
+
var _a2, _b;
|
|
15088
|
+
return (_b = PRN_PREDICATE_REASON_NORMALIZATIONS.get((_a2 = normalizePrnReasonKey(text)) != null ? _a2 : "")) != null ? _b : text;
|
|
14524
15089
|
}
|
|
14525
15090
|
function canStartPrnReasonAtom(context, start) {
|
|
14526
|
-
var
|
|
15091
|
+
var _a2, _b, _c;
|
|
14527
15092
|
const first = context.tokens[start];
|
|
14528
15093
|
if (!first || context.state.consumed.has(first.index)) {
|
|
14529
15094
|
return false;
|
|
@@ -14547,7 +15112,7 @@ function canStartPrnReasonAtom(context, start) {
|
|
|
14547
15112
|
return true;
|
|
14548
15113
|
}
|
|
14549
15114
|
}
|
|
14550
|
-
const resolvedSite = resolveBodySitePhrase(first.original, (
|
|
15115
|
+
const resolvedSite = resolveBodySitePhrase(first.original, (_a2 = context.options) == null ? void 0 : _a2.siteCodeMap, {
|
|
14551
15116
|
bodySiteContext: (_c = (_b = context.options) == null ? void 0 : _b.context) == null ? void 0 : _c.bodySiteContext
|
|
14552
15117
|
});
|
|
14553
15118
|
return Boolean((resolvedSite == null ? void 0 : resolvedSite.coding) || (resolvedSite == null ? void 0 : resolvedSite.definition));
|
|
@@ -14570,7 +15135,7 @@ function canContinuePrnReasonAfterSeparator(context, index) {
|
|
|
14570
15135
|
return false;
|
|
14571
15136
|
}
|
|
14572
15137
|
function startsDosageSiteComplement(context, start) {
|
|
14573
|
-
var
|
|
15138
|
+
var _a2, _b, _c;
|
|
14574
15139
|
const anchor = context.tokens[start];
|
|
14575
15140
|
if (!anchor || !PRN_CONDITIONAL_SITE_BOUNDARY_ANCHORS.has(normalizeTokenLower(anchor))) {
|
|
14576
15141
|
return false;
|
|
@@ -14589,7 +15154,7 @@ function startsDosageSiteComplement(context, start) {
|
|
|
14589
15154
|
displayTokens.push(token);
|
|
14590
15155
|
}
|
|
14591
15156
|
const sourceText = joinTokenText(displayTokens).replace(/[{}]/g, "").trim();
|
|
14592
|
-
if (sourceText && resolveBodySitePhrase(sourceText, (
|
|
15157
|
+
if (sourceText && resolveBodySitePhrase(sourceText, (_a2 = context.options) == null ? void 0 : _a2.siteCodeMap, {
|
|
14593
15158
|
bodySiteContext: (_c = (_b = context.options) == null ? void 0 : _b.context) == null ? void 0 : _c.bodySiteContext
|
|
14594
15159
|
})) {
|
|
14595
15160
|
return true;
|
|
@@ -14618,7 +15183,7 @@ function splitPrnReasonParts(tokens) {
|
|
|
14618
15183
|
return parts;
|
|
14619
15184
|
}
|
|
14620
15185
|
function createPrnReasonRequest(context, text, tokens, headText, siteText) {
|
|
14621
|
-
var
|
|
15186
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
14622
15187
|
const range = rangeFromTokens(tokens);
|
|
14623
15188
|
const rawText = joinTokenText(tokens);
|
|
14624
15189
|
const isProbe = rawText.includes("{") || rawText.includes("}");
|
|
@@ -14626,7 +15191,7 @@ function createPrnReasonRequest(context, text, tokens, headText, siteText) {
|
|
|
14626
15191
|
if (isProbe && range) {
|
|
14627
15192
|
let start = range.start;
|
|
14628
15193
|
let end = range.end;
|
|
14629
|
-
while (start < end && /[\s{]/.test((
|
|
15194
|
+
while (start < end && /[\s{]/.test((_a2 = context.state.input[start]) != null ? _a2 : "")) {
|
|
14630
15195
|
start += 1;
|
|
14631
15196
|
}
|
|
14632
15197
|
while (end > start && /[\s}]/.test((_b = context.state.input[end - 1]) != null ? _b : "")) {
|
|
@@ -14668,7 +15233,7 @@ function createPrnReasonRequest(context, text, tokens, headText, siteText) {
|
|
|
14668
15233
|
};
|
|
14669
15234
|
}
|
|
14670
15235
|
function parseLocatedPrnAtom(context, tokens, previousLocatedHead, options) {
|
|
14671
|
-
var
|
|
15236
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
14672
15237
|
const directText = joinTokenText(tokens);
|
|
14673
15238
|
const cleanDirectText = directText.replace(/[{}]/g, "").replace(/\s+/g, " ").trim();
|
|
14674
15239
|
if (!cleanDirectText) {
|
|
@@ -14693,7 +15258,7 @@ function parseLocatedPrnAtom(context, tokens, previousLocatedHead, options) {
|
|
|
14693
15258
|
const headText = joinTokenText(tokens.slice(0, index));
|
|
14694
15259
|
const normalizedHead = normalizePredicativeReasonText(headText);
|
|
14695
15260
|
const siteText = joinTokenText(tokens.slice(index));
|
|
14696
|
-
if (isLocatedReasonHead(normalizedHead) && resolveBodySitePhrase(siteText, (
|
|
15261
|
+
if (isLocatedReasonHead(normalizedHead) && resolveBodySitePhrase(siteText, (_a2 = context.options) == null ? void 0 : _a2.siteCodeMap, {
|
|
14697
15262
|
bodySiteContext: (_c = (_b = context.options) == null ? void 0 : _b.context) == null ? void 0 : _c.bodySiteContext
|
|
14698
15263
|
})) {
|
|
14699
15264
|
return createPrnReasonRequest(context, cleanDirectText, tokens, normalizedHead, siteText);
|
|
@@ -14745,8 +15310,8 @@ function parsePrnReasonAtoms(context, reasonTokens, options) {
|
|
|
14745
15310
|
}
|
|
14746
15311
|
function prnLexicalRule() {
|
|
14747
15312
|
return lexicalRule("hpsg.lex.prn", (context, start) => {
|
|
14748
|
-
var
|
|
14749
|
-
const lead = (
|
|
15313
|
+
var _a2, _b;
|
|
15314
|
+
const lead = (_a2 = tokensAvailable(context, start, 1)) == null ? void 0 : _a2[0];
|
|
14750
15315
|
if (!lead) {
|
|
14751
15316
|
return [];
|
|
14752
15317
|
}
|
|
@@ -14860,7 +15425,7 @@ function prnLexicalRule() {
|
|
|
14860
15425
|
var INSTRUCTION_PREDICATES = ["take", "apply", "use"];
|
|
14861
15426
|
function workflowLexicalRule() {
|
|
14862
15427
|
return lexicalRule("hpsg.lex.patientInstruction.workflow", (context, start) => {
|
|
14863
|
-
var
|
|
15428
|
+
var _a2, _b;
|
|
14864
15429
|
let cursor = start;
|
|
14865
15430
|
const consumed = [];
|
|
14866
15431
|
while (cursor < context.limit) {
|
|
@@ -14900,7 +15465,7 @@ function workflowLexicalRule() {
|
|
|
14900
15465
|
if (bodyTokens.length && isInstructionSeparator(token)) {
|
|
14901
15466
|
break;
|
|
14902
15467
|
}
|
|
14903
|
-
if (bodyTokens.length && isScheduleLead(context, cursor) && !(((
|
|
15468
|
+
if (bodyTokens.length && isScheduleLead(context, cursor) && !(((_a2 = bodyTokens[bodyTokens.length - 1]) == null ? void 0 : _a2.kind) === "NUMBER" /* Number */ && mapIntervalUnit(lower)) && !WORKFLOW_CONTINUATION_LICENSES.has(`${previousLower} ${lower}`) && !(previousLower && WORKFLOW_CONTINUATION_LICENSES.has(`${previousLower} *event`) && EVENT_TIMING_TOKENS[lower]) && !WORKFLOW_CONTINUATION_LICENSES.has(`${lower} ${nextLower}`)) {
|
|
14904
15469
|
break;
|
|
14905
15470
|
}
|
|
14906
15471
|
if (LIST_SEPARATORS.has(lower) && bodyTokens.length && !WORKFLOW_NOUNS.has(normalizeTokenLower((_b = context.tokens[cursor + 1]) != null ? _b : token))) {
|
|
@@ -14961,8 +15526,8 @@ function parseInstructionCandidates(text, range) {
|
|
|
14961
15526
|
}));
|
|
14962
15527
|
const score = instructions.reduce(
|
|
14963
15528
|
(sum, instruction) => {
|
|
14964
|
-
var
|
|
14965
|
-
return sum + (((
|
|
15529
|
+
var _a2, _b;
|
|
15530
|
+
return sum + (((_a2 = instruction.coding) == null ? void 0 : _a2.code) ? 4 : 0) + (((_b = instruction.frames) == null ? void 0 : _b.length) ? 2 : 0) + (instruction.text ? 1 : 0);
|
|
14966
15531
|
},
|
|
14967
15532
|
0
|
|
14968
15533
|
);
|
|
@@ -14973,6 +15538,23 @@ function parseInstructionCandidates(text, range) {
|
|
|
14973
15538
|
}
|
|
14974
15539
|
return best;
|
|
14975
15540
|
}
|
|
15541
|
+
function bodyParsesAsStyleInstruction(context, bodyTokens) {
|
|
15542
|
+
const range = rangeFromTokens(bodyTokens);
|
|
15543
|
+
const text = range ? context.state.input.slice(range.start, range.end).replace(/\s+/g, " ").trim() : joinTokenText(bodyTokens);
|
|
15544
|
+
if (!range || !text) {
|
|
15545
|
+
return false;
|
|
15546
|
+
}
|
|
15547
|
+
return parseInstructionCandidates(text, range).some(
|
|
15548
|
+
(instruction) => {
|
|
15549
|
+
var _a2;
|
|
15550
|
+
return (_a2 = instruction.frames) == null ? void 0 : _a2.some(
|
|
15551
|
+
(frame) => !frame.relation && frame.predicate.semanticClass === "administration" && frame.args.length > 0 && frame.args.every(
|
|
15552
|
+
(arg) => arg.role === "amount" /* Amount */ || arg.role === "free" /* Free */
|
|
15553
|
+
)
|
|
15554
|
+
);
|
|
15555
|
+
}
|
|
15556
|
+
);
|
|
15557
|
+
}
|
|
14976
15558
|
function instructionLexicalRule() {
|
|
14977
15559
|
return lexicalRule("hpsg.lex.instruction", (context, start) => {
|
|
14978
15560
|
const first = context.tokens[start];
|
|
@@ -15007,6 +15589,9 @@ function instructionLexicalRule() {
|
|
|
15007
15589
|
if (bodyTokens.length && isScheduleLead(context, cursor)) {
|
|
15008
15590
|
break;
|
|
15009
15591
|
}
|
|
15592
|
+
if (bodyTokens.length && SITE_ANCHORS.has(normalizeTokenLower(token)) && bodyParsesAsStyleInstruction(context, bodyTokens)) {
|
|
15593
|
+
break;
|
|
15594
|
+
}
|
|
15010
15595
|
bodyTokens.push(token);
|
|
15011
15596
|
}
|
|
15012
15597
|
if (!bodyTokens.length) {
|
|
@@ -15023,8 +15608,8 @@ function instructionLexicalRule() {
|
|
|
15023
15608
|
}
|
|
15024
15609
|
const hasStructuredInstruction = instructions.some(
|
|
15025
15610
|
(instruction) => {
|
|
15026
|
-
var
|
|
15027
|
-
return ((
|
|
15611
|
+
var _a2, _b;
|
|
15612
|
+
return ((_a2 = instruction.coding) == null ? void 0 : _a2.code) || ((_b = instruction.frames) == null ? void 0 : _b.length);
|
|
15028
15613
|
}
|
|
15029
15614
|
);
|
|
15030
15615
|
if (!hasStructuredInstruction && !consumed.length) {
|
|
@@ -15048,12 +15633,12 @@ function instructionLexicalRule() {
|
|
|
15048
15633
|
|
|
15049
15634
|
// src/context.ts
|
|
15050
15635
|
function normalizeDosageForm(form) {
|
|
15051
|
-
var
|
|
15636
|
+
var _a2;
|
|
15052
15637
|
if (!form) {
|
|
15053
15638
|
return void 0;
|
|
15054
15639
|
}
|
|
15055
15640
|
const key = form.trim().toLowerCase();
|
|
15056
|
-
return (
|
|
15641
|
+
return (_a2 = KNOWN_DOSAGE_FORMS_TO_DOSE[key]) != null ? _a2 : key;
|
|
15057
15642
|
}
|
|
15058
15643
|
function inferUnitFromContext(ctx) {
|
|
15059
15644
|
if (!ctx) {
|
|
@@ -15077,7 +15662,7 @@ function inferUnitFromContext(ctx) {
|
|
|
15077
15662
|
return void 0;
|
|
15078
15663
|
}
|
|
15079
15664
|
function inferRouteFromContext(ctx) {
|
|
15080
|
-
var
|
|
15665
|
+
var _a2;
|
|
15081
15666
|
if (!(ctx == null ? void 0 : ctx.dosageForm)) {
|
|
15082
15667
|
return void 0;
|
|
15083
15668
|
}
|
|
@@ -15087,29 +15672,29 @@ function inferRouteFromContext(ctx) {
|
|
|
15087
15672
|
}
|
|
15088
15673
|
const snomed = KNOWN_TMT_DOSAGE_FORM_TO_SNOMED_ROUTE[normalized];
|
|
15089
15674
|
if (!snomed) {
|
|
15090
|
-
return (
|
|
15675
|
+
return (_a2 = DEFAULT_ROUTE_SYNONYMS[normalized]) == null ? void 0 : _a2.code;
|
|
15091
15676
|
}
|
|
15092
15677
|
return ROUTE_BY_SNOMED[snomed];
|
|
15093
15678
|
}
|
|
15094
15679
|
|
|
15095
15680
|
// src/hpsg/rules/site-rules.ts
|
|
15096
15681
|
function siteBoundary(lower, context) {
|
|
15097
|
-
var
|
|
15098
|
-
const siteLike = Boolean(resolveBodySitePhrase(lower, (
|
|
15682
|
+
var _a2, _b, _c;
|
|
15683
|
+
const siteLike = Boolean(resolveBodySitePhrase(lower, (_a2 = context.options) == null ? void 0 : _a2.siteCodeMap, {
|
|
15099
15684
|
bodySiteContext: (_c = (_b = context.options) == null ? void 0 : _b.context) == null ? void 0 : _c.bodySiteContext
|
|
15100
15685
|
}));
|
|
15101
|
-
return isPunctuation(lower) || PRN_LEADS.has(lower) || PRN_STANDALONE_REASON_LEADS.has(lower) || DURATION_LEAD_TOKENS.has(lower) || Boolean(
|
|
15102
|
-
METHOD_ACTION_BY_VERB[lower] || DEFAULT_ROUTE_SYNONYMS[lower] && !siteLike || productRouteHint(lower) || normalizeUnit(lower, context.options) || TIMING_ABBREVIATIONS[lower] || WORD_FREQUENCIES[lower] || FREQUENCY_SIMPLE_WORDS[lower] !== void 0 || FREQUENCY_NUMBER_WORDS[lower] !== void 0 || FREQUENCY_TIMES_WORDS.has(lower) || EVENT_TIMING_TOKENS[lower] || isClockLikeLower(lower) || isAmPmLower(lower) || EVERY_INTERVAL_TOKENS.has(lower) || mapFrequencyAdverb(lower) || mapIntervalUnit(lower)
|
|
15686
|
+
return isPunctuation(lower) || PRN_LEADS.has(lower) || PRN_STANDALONE_REASON_LEADS.has(lower) || DURATION_LEAD_TOKENS.has(lower) || SITE_TRAILING_INSTRUCTION_WORDS.has(lower) || Boolean(
|
|
15687
|
+
METHOD_ACTION_BY_VERB[lower] || DEFAULT_ROUTE_SYNONYMS[lower] && !siteLike || productRouteHint(lower) || normalizeUnit(lower, context.options) && !siteLike || TIMING_ABBREVIATIONS[lower] || WORD_FREQUENCIES[lower] || FREQUENCY_SIMPLE_WORDS[lower] !== void 0 || FREQUENCY_NUMBER_WORDS[lower] !== void 0 || FREQUENCY_TIMES_WORDS.has(lower) || EVENT_TIMING_TOKENS[lower] || isClockLikeLower(lower) || isAmPmLower(lower) || EVERY_INTERVAL_TOKENS.has(lower) || mapFrequencyAdverb(lower) || mapIntervalUnit(lower)
|
|
15103
15688
|
);
|
|
15104
15689
|
}
|
|
15105
15690
|
function trimBraceRange(input, range) {
|
|
15106
|
-
var
|
|
15691
|
+
var _a2, _b;
|
|
15107
15692
|
if (!range) {
|
|
15108
15693
|
return void 0;
|
|
15109
15694
|
}
|
|
15110
15695
|
let start = range.start;
|
|
15111
15696
|
let end = range.end;
|
|
15112
|
-
while (start < end && /[\s{}]/.test((
|
|
15697
|
+
while (start < end && /[\s{}]/.test((_a2 = input[start]) != null ? _a2 : "")) {
|
|
15113
15698
|
start += 1;
|
|
15114
15699
|
}
|
|
15115
15700
|
while (end > start && /[\s{}]/.test((_b = input[end - 1]) != null ? _b : "")) {
|
|
@@ -15146,8 +15731,8 @@ function hasSystemicCueBeforeSiteAbbreviation(context, start) {
|
|
|
15146
15731
|
return sawNonOcularDose;
|
|
15147
15732
|
}
|
|
15148
15733
|
function contextSuggestsNonOcularSite(context) {
|
|
15149
|
-
var
|
|
15150
|
-
const dosageForm = (_c = (_b = (
|
|
15734
|
+
var _a2, _b, _c, _d, _e, _f;
|
|
15735
|
+
const dosageForm = (_c = (_b = (_a2 = context.options) == null ? void 0 : _a2.context) == null ? void 0 : _b.dosageForm) == null ? void 0 : _c.trim().toLowerCase().replace(/\s+/g, " ");
|
|
15151
15736
|
const route = (_f = inferRouteFromContext((_e = (_d = context.options) == null ? void 0 : _d.context) != null ? _e : void 0)) != null ? _f : dosageForm ? productRouteHint(dosageForm) : void 0;
|
|
15152
15737
|
return Boolean(route && !OCULAR_ROUTE_CODES.has(route));
|
|
15153
15738
|
}
|
|
@@ -15156,8 +15741,8 @@ function shouldSuppressEyeSiteAbbreviation(context, start, lower) {
|
|
|
15156
15741
|
}
|
|
15157
15742
|
function siteLexicalRule() {
|
|
15158
15743
|
return lexicalRule("hpsg.lex.site", (context, start) => {
|
|
15159
|
-
var
|
|
15160
|
-
const token = (
|
|
15744
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
15745
|
+
const token = (_a2 = tokensAvailable(context, start, 1)) == null ? void 0 : _a2[0];
|
|
15161
15746
|
if (!token) {
|
|
15162
15747
|
return [];
|
|
15163
15748
|
}
|
|
@@ -15295,9 +15880,9 @@ function siteLexicalRule() {
|
|
|
15295
15880
|
}
|
|
15296
15881
|
function bareSiteLexicalRule() {
|
|
15297
15882
|
return lexicalRule("hpsg.lex.site.bare", (context, start) => {
|
|
15298
|
-
var
|
|
15883
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
15299
15884
|
const signs = [];
|
|
15300
|
-
const first = (
|
|
15885
|
+
const first = (_a2 = tokensAvailable(context, start, 1)) == null ? void 0 : _a2[0];
|
|
15301
15886
|
if (!first) {
|
|
15302
15887
|
return [];
|
|
15303
15888
|
}
|
|
@@ -15372,7 +15957,7 @@ function bareSiteLexicalRule() {
|
|
|
15372
15957
|
// src/hpsg/rules/core-rules.ts
|
|
15373
15958
|
function methodLexicalRule() {
|
|
15374
15959
|
return lexicalRule("hpsg.lex.method", (context, start) => {
|
|
15375
|
-
var
|
|
15960
|
+
var _a2;
|
|
15376
15961
|
const tokens = tokensAvailable(context, start, 1);
|
|
15377
15962
|
const token = tokens == null ? void 0 : tokens[0];
|
|
15378
15963
|
if (!tokens || !token) {
|
|
@@ -15383,7 +15968,7 @@ function methodLexicalRule() {
|
|
|
15383
15968
|
return [];
|
|
15384
15969
|
}
|
|
15385
15970
|
const action = METHOD_ACTION_BY_VERB[verb];
|
|
15386
|
-
const route = (
|
|
15971
|
+
const route = (_a2 = getRouteMeaning(token)) != null ? _a2 : action === "apply" /* Apply */ ? { code: RouteCode["Topical route"], text: ROUTE_TEXT[RouteCode["Topical route"]] } : void 0;
|
|
15387
15972
|
return [
|
|
15388
15973
|
lexicalSign({
|
|
15389
15974
|
type: "method-sign",
|
|
@@ -15407,7 +15992,7 @@ function methodLexicalRule() {
|
|
|
15407
15992
|
}
|
|
15408
15993
|
function routeLexicalRule() {
|
|
15409
15994
|
return lexicalRule("hpsg.lex.route", (context, start) => {
|
|
15410
|
-
var
|
|
15995
|
+
var _a2;
|
|
15411
15996
|
const signs = [];
|
|
15412
15997
|
const maxSpan = Math.min(24, context.limit - start);
|
|
15413
15998
|
for (let span = maxSpan; span >= 1; span -= 1) {
|
|
@@ -15424,13 +16009,13 @@ function routeLexicalRule() {
|
|
|
15424
16009
|
}
|
|
15425
16010
|
const routeCandidates = routePhraseCandidates(phrase);
|
|
15426
16011
|
const customCode = routeCandidates.map((candidate) => {
|
|
15427
|
-
var
|
|
15428
|
-
return (_b = (
|
|
16012
|
+
var _a3, _b;
|
|
16013
|
+
return (_b = (_a3 = context.options) == null ? void 0 : _a3.routeMap) == null ? void 0 : _b[candidate];
|
|
15429
16014
|
}).find((code) => Boolean(code));
|
|
15430
16015
|
const tokenRoute = span === 1 ? getRouteMeaning(tokens[0]) : void 0;
|
|
15431
16016
|
const routeFromSitePreposition = routeFromSitePrepositionPhrase(tokens, context);
|
|
15432
16017
|
const synonym = routeCandidates.map((candidate) => DEFAULT_ROUTE_SYNONYMS[candidate]).find(Boolean);
|
|
15433
|
-
const route = customCode ? { code: customCode, text: ROUTE_TEXT[customCode] } : (
|
|
16018
|
+
const route = customCode ? { code: customCode, text: ROUTE_TEXT[customCode] } : (_a2 = tokenRoute != null ? tokenRoute : synonym) != null ? _a2 : routeFromSitePreposition;
|
|
15434
16019
|
if (!route) {
|
|
15435
16020
|
continue;
|
|
15436
16021
|
}
|
|
@@ -15457,7 +16042,7 @@ function routeLexicalRule() {
|
|
|
15457
16042
|
});
|
|
15458
16043
|
}
|
|
15459
16044
|
function routeTokenIsPartitiveSiteHead(context, start, span) {
|
|
15460
|
-
var
|
|
16045
|
+
var _a2, _b, _c;
|
|
15461
16046
|
if (span !== 1) {
|
|
15462
16047
|
return false;
|
|
15463
16048
|
}
|
|
@@ -15477,7 +16062,7 @@ function routeTokenIsPartitiveSiteHead(context, start, span) {
|
|
|
15477
16062
|
if (tokens.some((token) => context.state.consumed.has(token.index))) {
|
|
15478
16063
|
return false;
|
|
15479
16064
|
}
|
|
15480
|
-
const resolved = resolveBodySitePhrase(joinTokenText(tokens), (
|
|
16065
|
+
const resolved = resolveBodySitePhrase(joinTokenText(tokens), (_a2 = context.options) == null ? void 0 : _a2.siteCodeMap, {
|
|
15481
16066
|
bodySiteContext: (_c = (_b = context.options) == null ? void 0 : _b.context) == null ? void 0 : _c.bodySiteContext
|
|
15482
16067
|
});
|
|
15483
16068
|
if ((resolved == null ? void 0 : resolved.features.kind) === "partitive") {
|
|
@@ -15487,12 +16072,12 @@ function routeTokenIsPartitiveSiteHead(context, start, span) {
|
|
|
15487
16072
|
return false;
|
|
15488
16073
|
}
|
|
15489
16074
|
function routeFromSitePrepositionPhrase(tokens, context) {
|
|
15490
|
-
var
|
|
16075
|
+
var _a2, _b, _c, _d, _e, _f, _g;
|
|
15491
16076
|
if (tokens.length < 2 || !ROUTE_SITE_PREPOSITIONS.has(normalizeTokenLower(tokens[0]))) {
|
|
15492
16077
|
return void 0;
|
|
15493
16078
|
}
|
|
15494
16079
|
const siteText = tokens.slice(1).map((token) => token.original).join(" ");
|
|
15495
|
-
const resolved = resolveBodySitePhrase(siteText, (
|
|
16080
|
+
const resolved = resolveBodySitePhrase(siteText, (_a2 = context.options) == null ? void 0 : _a2.siteCodeMap, {
|
|
15496
16081
|
bodySiteContext: (_c = (_b = context.options) == null ? void 0 : _b.context) == null ? void 0 : _c.bodySiteContext
|
|
15497
16082
|
});
|
|
15498
16083
|
const routeHint = (_g = (_d = resolved == null ? void 0 : resolved.definition) == null ? void 0 : _d.routeHint) != null ? _g : (_f = DEFAULT_BODY_SITE_SNOMED[(_e = resolved == null ? void 0 : resolved.canonical) != null ? _e : ""]) == null ? void 0 : _f.routeHint;
|
|
@@ -15513,8 +16098,8 @@ function routePhraseCandidates(phrase) {
|
|
|
15513
16098
|
}
|
|
15514
16099
|
function fillerLexicalRule() {
|
|
15515
16100
|
return lexicalRule("hpsg.lex.filler.medicationObject", (context, start) => {
|
|
15516
|
-
var
|
|
15517
|
-
const token = (
|
|
16101
|
+
var _a2;
|
|
16102
|
+
const token = (_a2 = tokensAvailable(context, start, 1)) == null ? void 0 : _a2[0];
|
|
15518
16103
|
if (!token || !MEDICATION_OBJECT_FILLERS.has(normalizeTokenLower(token))) {
|
|
15519
16104
|
return [];
|
|
15520
16105
|
}
|
|
@@ -15531,7 +16116,7 @@ function fillerLexicalRule() {
|
|
|
15531
16116
|
}
|
|
15532
16117
|
function productLexicalRule() {
|
|
15533
16118
|
return lexicalRule("hpsg.lex.product", (context, start) => {
|
|
15534
|
-
var
|
|
16119
|
+
var _a2;
|
|
15535
16120
|
const signs = [];
|
|
15536
16121
|
const maxSpan = Math.min(4, context.limit - start);
|
|
15537
16122
|
for (let span = maxSpan; span >= 1; span -= 1) {
|
|
@@ -15549,7 +16134,7 @@ function productLexicalRule() {
|
|
|
15549
16134
|
}
|
|
15550
16135
|
const previous = context.tokens[start - 1];
|
|
15551
16136
|
const previousVerb = previous && METHOD_ACTION_BY_VERB[normalizeTokenLower(previous)] ? normalizeTokenLower(previous) : void 0;
|
|
15552
|
-
const methodText = previousVerb ? (
|
|
16137
|
+
const methodText = previousVerb ? (_a2 = PRODUCT_METHOD_TEXT[previousVerb]) == null ? void 0 : _a2[phrase] : void 0;
|
|
15553
16138
|
signs.push(
|
|
15554
16139
|
lexicalSign({
|
|
15555
16140
|
type: "phrase-sign",
|
|
@@ -15574,21 +16159,53 @@ function productLexicalRule() {
|
|
|
15574
16159
|
return signs;
|
|
15575
16160
|
});
|
|
15576
16161
|
}
|
|
16162
|
+
function matchCompoundDoseUnit(context, start, lower) {
|
|
16163
|
+
var _a2;
|
|
16164
|
+
for (const compound of COMPOUND_DOSE_UNITS) {
|
|
16165
|
+
if (compound.head !== lower) {
|
|
16166
|
+
continue;
|
|
16167
|
+
}
|
|
16168
|
+
const sequences = (_a2 = compound.tailSequences) != null ? _a2 : [];
|
|
16169
|
+
for (const sequence of sequences) {
|
|
16170
|
+
const matchedTokens = [];
|
|
16171
|
+
let matched = true;
|
|
16172
|
+
for (let offset = 0; offset < sequence.length; offset += 1) {
|
|
16173
|
+
const candidate = context.tokens[start + 1 + offset];
|
|
16174
|
+
if (!candidate || context.state.consumed.has(candidate.index) || normalizeTokenLower(candidate) !== sequence[offset]) {
|
|
16175
|
+
matched = false;
|
|
16176
|
+
break;
|
|
16177
|
+
}
|
|
16178
|
+
matchedTokens.push(candidate);
|
|
16179
|
+
}
|
|
16180
|
+
if (matched) {
|
|
16181
|
+
const head = context.tokens[start];
|
|
16182
|
+
return head ? { unit: compound.unit, tokens: [head, ...matchedTokens] } : void 0;
|
|
16183
|
+
}
|
|
16184
|
+
}
|
|
16185
|
+
const next = context.tokens[start + 1];
|
|
16186
|
+
if (next && !context.state.consumed.has(next.index)) {
|
|
16187
|
+
const nextLower = normalizeTokenLower(next);
|
|
16188
|
+
if (compound.tails.indexOf(nextLower) !== -1) {
|
|
16189
|
+
const head = context.tokens[start];
|
|
16190
|
+
return head ? { unit: compound.unit, tokens: [head, next] } : void 0;
|
|
16191
|
+
}
|
|
16192
|
+
}
|
|
16193
|
+
}
|
|
16194
|
+
return void 0;
|
|
16195
|
+
}
|
|
15577
16196
|
function unitAfter(context, start) {
|
|
15578
16197
|
const token = context.tokens[start];
|
|
15579
16198
|
if (!token || context.state.consumed.has(token.index)) {
|
|
15580
16199
|
return void 0;
|
|
15581
16200
|
}
|
|
15582
16201
|
const lower = normalizeTokenLower(token);
|
|
15583
|
-
|
|
16202
|
+
if (DOSE_UNIT_CONNECTORS.has(lower)) {
|
|
16203
|
+
const nested = unitAfter(context, start + 1);
|
|
16204
|
+
return nested ? { unit: nested.unit, tokens: [token, ...nested.tokens] } : void 0;
|
|
16205
|
+
}
|
|
16206
|
+
const compound = matchCompoundDoseUnit(context, start, lower);
|
|
15584
16207
|
if (compound) {
|
|
15585
|
-
|
|
15586
|
-
if (next && !context.state.consumed.has(next.index)) {
|
|
15587
|
-
const nextLower = normalizeTokenLower(next);
|
|
15588
|
-
if (compound.tails.indexOf(nextLower) !== -1) {
|
|
15589
|
-
return { unit: compound.unit, tokens: [token, next] };
|
|
15590
|
-
}
|
|
15591
|
-
}
|
|
16208
|
+
return compound;
|
|
15592
16209
|
}
|
|
15593
16210
|
const direct = normalizeUnit(lower, context.options);
|
|
15594
16211
|
if (direct) {
|
|
@@ -15596,6 +16213,48 @@ function unitAfter(context, start) {
|
|
|
15596
16213
|
}
|
|
15597
16214
|
return void 0;
|
|
15598
16215
|
}
|
|
16216
|
+
function doseNumeratorValue(token, lower) {
|
|
16217
|
+
if (token.kind === "NUMBER" /* Number */ && token.value !== void 0) {
|
|
16218
|
+
return token.value;
|
|
16219
|
+
}
|
|
16220
|
+
return DOSE_NUMBER_WORDS.get(lower);
|
|
16221
|
+
}
|
|
16222
|
+
function percentBodyAreaDoseAfter(context, start, lower) {
|
|
16223
|
+
const percentMatch = lower.match(/^([0-9]+(?:\.[0-9]+)?)%$/);
|
|
16224
|
+
if (!percentMatch) {
|
|
16225
|
+
return void 0;
|
|
16226
|
+
}
|
|
16227
|
+
const unitToken = context.tokens[start + 1];
|
|
16228
|
+
if (!unitToken || context.state.consumed.has(unitToken.index)) {
|
|
16229
|
+
return void 0;
|
|
16230
|
+
}
|
|
16231
|
+
const unit = PERCENT_BODY_AREA_UNITS.get(normalizeTokenLower(unitToken));
|
|
16232
|
+
if (!unit) {
|
|
16233
|
+
return void 0;
|
|
16234
|
+
}
|
|
16235
|
+
const token = context.tokens[start];
|
|
16236
|
+
if (!token) {
|
|
16237
|
+
return void 0;
|
|
16238
|
+
}
|
|
16239
|
+
return [
|
|
16240
|
+
lexicalSign({
|
|
16241
|
+
type: "dose-sign",
|
|
16242
|
+
rule: "hpsg.lex.dose.percentBodyArea",
|
|
16243
|
+
tokens: [token, unitToken],
|
|
16244
|
+
synsem: {
|
|
16245
|
+
head: {
|
|
16246
|
+
dose: {
|
|
16247
|
+
value: parseFloat(percentMatch[1]),
|
|
16248
|
+
unit
|
|
16249
|
+
}
|
|
16250
|
+
},
|
|
16251
|
+
valence: {},
|
|
16252
|
+
cont: { clauseKind: "administration" }
|
|
16253
|
+
},
|
|
16254
|
+
score: 10
|
|
16255
|
+
})
|
|
16256
|
+
];
|
|
16257
|
+
}
|
|
15599
16258
|
function doseLexicalRule() {
|
|
15600
16259
|
return lexicalRule("hpsg.lex.dose", (context, start) => {
|
|
15601
16260
|
const tokens = tokensAvailable(context, start, 1);
|
|
@@ -15607,6 +16266,35 @@ function doseLexicalRule() {
|
|
|
15607
16266
|
if (isClockDoseContext(context, start, lower)) {
|
|
15608
16267
|
return [];
|
|
15609
16268
|
}
|
|
16269
|
+
const percentBodyAreaDose = percentBodyAreaDoseAfter(context, start, lower);
|
|
16270
|
+
if (percentBodyAreaDose) {
|
|
16271
|
+
return percentBodyAreaDose;
|
|
16272
|
+
}
|
|
16273
|
+
const numerator = doseNumeratorValue(token, lower);
|
|
16274
|
+
const denominatorToken = context.tokens[start + 1];
|
|
16275
|
+
const denominatorLower = denominatorToken && !context.state.consumed.has(denominatorToken.index) ? normalizeTokenLower(denominatorToken) : void 0;
|
|
16276
|
+
const denominator = denominatorLower ? DOSE_FRACTION_DENOMINATOR_WORDS.get(denominatorLower) : void 0;
|
|
16277
|
+
if (numerator !== void 0 && denominatorToken && denominator !== void 0) {
|
|
16278
|
+
const unit2 = unitAfter(context, start + 2);
|
|
16279
|
+
return [
|
|
16280
|
+
lexicalSign({
|
|
16281
|
+
type: "dose-sign",
|
|
16282
|
+
rule: "hpsg.lex.dose.wordFractionNumerator",
|
|
16283
|
+
tokens: unit2 ? [token, denominatorToken, ...unit2.tokens] : [token, denominatorToken],
|
|
16284
|
+
synsem: {
|
|
16285
|
+
head: {
|
|
16286
|
+
dose: {
|
|
16287
|
+
value: numerator * denominator,
|
|
16288
|
+
unit: unit2 == null ? void 0 : unit2.unit
|
|
16289
|
+
}
|
|
16290
|
+
},
|
|
16291
|
+
valence: {},
|
|
16292
|
+
cont: { clauseKind: "administration" }
|
|
16293
|
+
},
|
|
16294
|
+
score: unit2 ? 10 : 5
|
|
16295
|
+
})
|
|
16296
|
+
];
|
|
16297
|
+
}
|
|
15610
16298
|
const range = parseNumericRange(lower);
|
|
15611
16299
|
if (range) {
|
|
15612
16300
|
const unit2 = unitAfter(context, start + 1);
|
|
@@ -15651,6 +16339,49 @@ function doseLexicalRule() {
|
|
|
15651
16339
|
})
|
|
15652
16340
|
];
|
|
15653
16341
|
}
|
|
16342
|
+
const wordFraction = DOSE_FRACTION_WORDS.get(lower);
|
|
16343
|
+
if (wordFraction !== void 0) {
|
|
16344
|
+
const unit2 = unitAfter(context, start + 1);
|
|
16345
|
+
return [
|
|
16346
|
+
lexicalSign({
|
|
16347
|
+
type: "dose-sign",
|
|
16348
|
+
rule: "hpsg.lex.dose.wordFraction",
|
|
16349
|
+
tokens: unit2 ? [...tokens, ...unit2.tokens] : tokens,
|
|
16350
|
+
synsem: {
|
|
16351
|
+
head: {
|
|
16352
|
+
dose: {
|
|
16353
|
+
value: wordFraction,
|
|
16354
|
+
unit: unit2 == null ? void 0 : unit2.unit
|
|
16355
|
+
}
|
|
16356
|
+
},
|
|
16357
|
+
valence: {},
|
|
16358
|
+
cont: { clauseKind: "administration" }
|
|
16359
|
+
},
|
|
16360
|
+
score: unit2 ? 9 : 4
|
|
16361
|
+
})
|
|
16362
|
+
];
|
|
16363
|
+
}
|
|
16364
|
+
const implicitUnit = unitAfter(context, start);
|
|
16365
|
+
if (implicitUnit && IMPLICIT_SINGLE_DOSE_UNITS.has(implicitUnit.unit)) {
|
|
16366
|
+
return [
|
|
16367
|
+
lexicalSign({
|
|
16368
|
+
type: "dose-sign",
|
|
16369
|
+
rule: "hpsg.lex.dose.implicitSingleUnit",
|
|
16370
|
+
tokens: implicitUnit.tokens,
|
|
16371
|
+
synsem: {
|
|
16372
|
+
head: {
|
|
16373
|
+
dose: {
|
|
16374
|
+
value: 1,
|
|
16375
|
+
unit: implicitUnit.unit
|
|
16376
|
+
}
|
|
16377
|
+
},
|
|
16378
|
+
valence: {},
|
|
16379
|
+
cont: { clauseKind: "administration" }
|
|
16380
|
+
},
|
|
16381
|
+
score: 9
|
|
16382
|
+
})
|
|
16383
|
+
];
|
|
16384
|
+
}
|
|
15654
16385
|
if (token.kind !== "NUMBER" /* Number */ || token.value === void 0) {
|
|
15655
16386
|
const timesMatch = lower.match(/^([0-9]+(?:\.[0-9]+)?)[x*]$/);
|
|
15656
16387
|
if (!timesMatch) {
|
|
@@ -15731,8 +16462,8 @@ function isClockDoseContext(context, start, lower) {
|
|
|
15731
16462
|
}
|
|
15732
16463
|
function connectorLexicalRule() {
|
|
15733
16464
|
return lexicalRule("hpsg.lex.connector", (context, start) => {
|
|
15734
|
-
var
|
|
15735
|
-
const token = (
|
|
16465
|
+
var _a2;
|
|
16466
|
+
const token = (_a2 = tokensAvailable(context, start, 1)) == null ? void 0 : _a2[0];
|
|
15736
16467
|
if (!token) {
|
|
15737
16468
|
return [];
|
|
15738
16469
|
}
|
|
@@ -15785,13 +16516,13 @@ function buildGrammar(context) {
|
|
|
15785
16516
|
};
|
|
15786
16517
|
}
|
|
15787
16518
|
function hasUsefulAnalysis(sign) {
|
|
15788
|
-
var
|
|
16519
|
+
var _a2;
|
|
15789
16520
|
if (!sign) {
|
|
15790
16521
|
return false;
|
|
15791
16522
|
}
|
|
15792
16523
|
const { head, valence } = sign.synsem;
|
|
15793
16524
|
return Boolean(
|
|
15794
|
-
head.method || head.route || head.dose || head.schedule || valence.site || valence.prn || ((
|
|
16525
|
+
head.method || head.route || head.dose || head.schedule || valence.site || valence.prn || ((_a2 = valence.instructions) == null ? void 0 : _a2.length) || valence.patientInstruction
|
|
15795
16526
|
);
|
|
15796
16527
|
}
|
|
15797
16528
|
function parseHpsgClause(context) {
|
|
@@ -15837,7 +16568,7 @@ function applyRouteDefault(state, context, deps) {
|
|
|
15837
16568
|
}
|
|
15838
16569
|
}
|
|
15839
16570
|
function applyUnitDefault(state, tokens, context, options) {
|
|
15840
|
-
var
|
|
16571
|
+
var _a2;
|
|
15841
16572
|
if (state.unit !== void 0 || state.dose === void 0 && state.doseRange === void 0) {
|
|
15842
16573
|
return;
|
|
15843
16574
|
}
|
|
@@ -15852,12 +16583,12 @@ function applyUnitDefault(state, tokens, context, options) {
|
|
|
15852
16583
|
return;
|
|
15853
16584
|
}
|
|
15854
16585
|
}
|
|
15855
|
-
state.unit = (
|
|
16586
|
+
state.unit = (_a2 = enforceHouseholdUnitPolicy(inferUnitFromContext(context), options)) != null ? _a2 : enforceHouseholdUnitPolicy(inferUnitFromRoute(state), options);
|
|
15856
16587
|
}
|
|
15857
16588
|
function applySingleDoseDefault(state, options) {
|
|
15858
|
-
var
|
|
16589
|
+
var _a2, _b;
|
|
15859
16590
|
if ((options == null ? void 0 : options.assumeSingleDiscreteDose) && state.unit === void 0) {
|
|
15860
|
-
state.unit = (_b = enforceHouseholdUnitPolicy(inferUnitFromContext((
|
|
16591
|
+
state.unit = (_b = enforceHouseholdUnitPolicy(inferUnitFromContext((_a2 = options.context) != null ? _a2 : void 0), options)) != null ? _b : enforceHouseholdUnitPolicy(inferUnitFromRoute(state), options);
|
|
15861
16592
|
}
|
|
15862
16593
|
if ((options == null ? void 0 : options.assumeSingleDiscreteDose) && state.dose === void 0 && state.doseRange === void 0 && state.unit !== void 0 && isDiscreteUnit(state.unit)) {
|
|
15863
16594
|
state.dose = 1;
|
|
@@ -15871,14 +16602,14 @@ var ROUTE_REDUNDANT_SITE_CODES = {
|
|
|
15871
16602
|
[RouteCode["Oral route"]]: /* @__PURE__ */ new Set(["123851003"])
|
|
15872
16603
|
};
|
|
15873
16604
|
function applyRouteSiteDefault(state) {
|
|
15874
|
-
var
|
|
16605
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
15875
16606
|
if (!state.routeCode) {
|
|
15876
16607
|
return;
|
|
15877
16608
|
}
|
|
15878
16609
|
const redundantCodes = ROUTE_REDUNDANT_SITE_CODES[state.routeCode];
|
|
15879
16610
|
if (state.siteText && redundantCodes) {
|
|
15880
16611
|
const currentDefinition = DEFAULT_BODY_SITE_SNOMED[state.siteText.trim().toLowerCase()];
|
|
15881
|
-
const currentCode = (_c = (
|
|
16612
|
+
const currentCode = (_c = (_a2 = state.siteCoding) == null ? void 0 : _a2.code) != null ? _c : (_b = currentDefinition == null ? void 0 : currentDefinition.coding) == null ? void 0 : _b.code;
|
|
15882
16613
|
if (currentCode && redundantCodes.has(currentCode)) {
|
|
15883
16614
|
state.siteText = void 0;
|
|
15884
16615
|
state.siteCoding = void 0;
|
|
@@ -15913,9 +16644,9 @@ function applyRouteSiteDefault(state) {
|
|
|
15913
16644
|
}
|
|
15914
16645
|
}
|
|
15915
16646
|
function hasStructuredTiming(state) {
|
|
15916
|
-
var
|
|
16647
|
+
var _a2;
|
|
15917
16648
|
return Boolean(
|
|
15918
|
-
state.count !== void 0 || state.duration !== void 0 || state.durationMax !== void 0 || state.durationUnit !== void 0 || state.frequency !== void 0 || state.frequencyMax !== void 0 || state.period !== void 0 || state.periodMax !== void 0 || state.periodUnit !== void 0 || state.timingCode !== void 0 || state.dayOfWeek.length || state.when.length || ((
|
|
16649
|
+
state.count !== void 0 || state.duration !== void 0 || state.durationMax !== void 0 || state.durationUnit !== void 0 || state.frequency !== void 0 || state.frequencyMax !== void 0 || state.period !== void 0 || state.periodMax !== void 0 || state.periodUnit !== void 0 || state.timingCode !== void 0 || state.dayOfWeek.length || state.when.length || ((_a2 = state.timeOfDay) == null ? void 0 : _a2.length)
|
|
15919
16650
|
);
|
|
15920
16651
|
}
|
|
15921
16652
|
function addWarning(state, warning) {
|
|
@@ -16009,10 +16740,10 @@ function normalizedFormSet(values) {
|
|
|
16009
16740
|
return result;
|
|
16010
16741
|
}
|
|
16011
16742
|
function smartMealExpansionAllowed(state, options) {
|
|
16012
|
-
var
|
|
16743
|
+
var _a2, _b, _c;
|
|
16013
16744
|
const scope = options.smartMealExpansionScope;
|
|
16014
16745
|
const route = state.routeCode;
|
|
16015
|
-
const dosageForm = normalizeDosageForm((
|
|
16746
|
+
const dosageForm = normalizeDosageForm((_a2 = options.context) == null ? void 0 : _a2.dosageForm);
|
|
16016
16747
|
const excludedRoutes = new Set((_b = scope == null ? void 0 : scope.excludeRoutes) != null ? _b : []);
|
|
16017
16748
|
const includedRoutes = new Set((_c = scope == null ? void 0 : scope.includeRoutes) != null ? _c : []);
|
|
16018
16749
|
const excludedForms = normalizedFormSet(scope == null ? void 0 : scope.excludeDosageForms);
|
|
@@ -16038,8 +16769,8 @@ function mealPair(options) {
|
|
|
16038
16769
|
return options.twoPerDayPair === "breakfast+lunch" ? ["CM" /* Breakfast */, "CD" /* Lunch */] : ["CM" /* Breakfast */, "CV" /* Dinner */];
|
|
16039
16770
|
}
|
|
16040
16771
|
function relationForContext(options) {
|
|
16041
|
-
var
|
|
16042
|
-
const relation = (
|
|
16772
|
+
var _a2;
|
|
16773
|
+
const relation = (_a2 = options.context) == null ? void 0 : _a2.mealRelation;
|
|
16043
16774
|
return relation === "AC" /* Before Meal */ || relation === "PC" /* After Meal */ || relation === "C" /* Meal */ ? relation : "C" /* Meal */;
|
|
16044
16775
|
}
|
|
16045
16776
|
function expandRelationByFrequency(relation, frequency, options) {
|
|
@@ -16049,13 +16780,13 @@ function expandRelationByFrequency(relation, frequency, options) {
|
|
|
16049
16780
|
const baseMeals = frequency === 1 ? ["CM" /* Breakfast */] : frequency === 2 ? [...mealPair(options)] : frequency === 3 ? [...WITH_MEALS] : [...WITH_MEALS, "HS" /* Before Sleep */];
|
|
16050
16781
|
const related = MEAL_RELATION_CODES[relation];
|
|
16051
16782
|
return baseMeals.map((meal) => {
|
|
16052
|
-
var
|
|
16783
|
+
var _a2;
|
|
16053
16784
|
const index = SPECIFIC_MEAL_INDEX[meal];
|
|
16054
|
-
return index === void 0 ? meal : (
|
|
16785
|
+
return index === void 0 ? meal : (_a2 = related[index]) != null ? _a2 : meal;
|
|
16055
16786
|
});
|
|
16056
16787
|
}
|
|
16057
16788
|
function normalizeMealRelations(when, options) {
|
|
16058
|
-
var
|
|
16789
|
+
var _a2;
|
|
16059
16790
|
let relation;
|
|
16060
16791
|
for (const code of when) {
|
|
16061
16792
|
if (code === "AC" /* Before Meal */ || code === "PC" /* After Meal */ || code === "C" /* Meal */) {
|
|
@@ -16082,7 +16813,7 @@ function normalizeMealRelations(when, options) {
|
|
|
16082
16813
|
continue;
|
|
16083
16814
|
}
|
|
16084
16815
|
const index = SPECIFIC_MEAL_INDEX[code];
|
|
16085
|
-
normalized.push(index === void 0 ? code : (
|
|
16816
|
+
normalized.push(index === void 0 ? code : (_a2 = related[index]) != null ? _a2 : code);
|
|
16086
16817
|
}
|
|
16087
16818
|
return normalized.length ? normalized : when;
|
|
16088
16819
|
}
|
|
@@ -16094,8 +16825,8 @@ function clockMinutes(clock) {
|
|
|
16094
16825
|
return parseInt(match[1], 10) * 60 + parseInt(match[2], 10);
|
|
16095
16826
|
}
|
|
16096
16827
|
function sortWhenCodes(when, options) {
|
|
16097
|
-
var
|
|
16098
|
-
const clock = __spreadValues(__spreadValues({}, DEFAULT_EVENT_CLOCK), (
|
|
16828
|
+
var _a2;
|
|
16829
|
+
const clock = __spreadValues(__spreadValues({}, DEFAULT_EVENT_CLOCK), (_a2 = options == null ? void 0 : options.eventClock) != null ? _a2 : {});
|
|
16099
16830
|
return when.map((code, index) => ({ code, index })).sort((left, right) => {
|
|
16100
16831
|
const diff = clockMinutes(clock[left.code]) - clockMinutes(clock[right.code]);
|
|
16101
16832
|
return diff || left.index - right.index;
|
|
@@ -16151,15 +16882,15 @@ function applySmartMealExpansion(state, options) {
|
|
|
16151
16882
|
replaceWhen(state, sortWhenCodes(uniqueWhen(normalizeMealRelations(when, options)), options));
|
|
16152
16883
|
}
|
|
16153
16884
|
function applyWeeklyDefaultForDayFilters(state) {
|
|
16154
|
-
var
|
|
16155
|
-
if (state.dayOfWeek.length && state.frequency === void 0 && state.frequencyMax === void 0 && state.period === void 0 && state.periodMax === void 0 && state.periodUnit === void 0 && !state.when.length && !((
|
|
16885
|
+
var _a2;
|
|
16886
|
+
if (state.dayOfWeek.length && state.frequency === void 0 && state.frequencyMax === void 0 && state.period === void 0 && state.periodMax === void 0 && state.periodUnit === void 0 && !state.when.length && !((_a2 = state.timeOfDay) == null ? void 0 : _a2.length)) {
|
|
16156
16887
|
state.period = 1;
|
|
16157
16888
|
state.periodUnit = "wk" /* Week */;
|
|
16158
16889
|
}
|
|
16159
16890
|
}
|
|
16160
16891
|
function applyHpsgDefaultConstraints(state, tokens, options, deps) {
|
|
16161
|
-
var
|
|
16162
|
-
const context = (
|
|
16892
|
+
var _a2;
|
|
16893
|
+
const context = (_a2 = options == null ? void 0 : options.context) != null ? _a2 : void 0;
|
|
16163
16894
|
applyRouteDefault(state, context, deps);
|
|
16164
16895
|
applyUnitDefault(state, tokens, context, options);
|
|
16165
16896
|
applySingleDoseDefault(state, options);
|
|
@@ -16179,15 +16910,15 @@ function pushUniqueCanonical(canonicals, value) {
|
|
|
16179
16910
|
canonicals.push(normalized);
|
|
16180
16911
|
}
|
|
16181
16912
|
function pushUniqueCoding(codings, coding) {
|
|
16182
|
-
var
|
|
16913
|
+
var _a2;
|
|
16183
16914
|
if (!(coding == null ? void 0 : coding.code)) {
|
|
16184
16915
|
return;
|
|
16185
16916
|
}
|
|
16186
|
-
const system = (
|
|
16917
|
+
const system = (_a2 = coding.system) != null ? _a2 : SNOMED_SYSTEM7;
|
|
16187
16918
|
if (codings.some(
|
|
16188
16919
|
(candidate) => {
|
|
16189
|
-
var
|
|
16190
|
-
return candidate.code === coding.code && ((
|
|
16920
|
+
var _a3;
|
|
16921
|
+
return candidate.code === coding.code && ((_a3 = candidate.system) != null ? _a3 : SNOMED_SYSTEM7) === system;
|
|
16191
16922
|
}
|
|
16192
16923
|
)) {
|
|
16193
16924
|
return;
|
|
@@ -16224,10 +16955,10 @@ function pushResolvedSite(canonicals, codings, value) {
|
|
|
16224
16955
|
pushSpatialRelationTarget(canonicals, codings, resolvedSite.spatialRelation);
|
|
16225
16956
|
}
|
|
16226
16957
|
function collectParsedBodySiteCandidates(internal) {
|
|
16227
|
-
var
|
|
16958
|
+
var _a2, _b, _c, _d;
|
|
16228
16959
|
const canonicals = [];
|
|
16229
16960
|
const codings = [];
|
|
16230
|
-
const normalizedSiteText = normalizeBodySiteKey((
|
|
16961
|
+
const normalizedSiteText = normalizeBodySiteKey((_a2 = internal.siteText) != null ? _a2 : "");
|
|
16231
16962
|
const siteCodingDisplay = (_b = internal.siteCoding) == null ? void 0 : _b.display;
|
|
16232
16963
|
const normalizedSiteCodingDisplay = siteCodingDisplay ? normalizeBodySiteKey(siteCodingDisplay) : "";
|
|
16233
16964
|
pushResolvedSite(
|
|
@@ -16300,8 +17031,8 @@ function collectPrnReasonLookupCanonicals(request) {
|
|
|
16300
17031
|
return canonicals;
|
|
16301
17032
|
}
|
|
16302
17033
|
function buildPostcoordinatedPrnReasonDefinition(request, definition, hasExactCombinedDefinition) {
|
|
16303
|
-
var
|
|
16304
|
-
if (hasExactCombinedDefinition || !((
|
|
17034
|
+
var _a2, _b;
|
|
17035
|
+
if (hasExactCombinedDefinition || !((_a2 = definition == null ? void 0 : definition.coding) == null ? void 0 : _a2.code) || hasSnomedFindingSitePostcoordination(definition.coding.code) || !request.headCanonical || !((_b = request.locativeSiteCoding) == null ? void 0 : _b.code)) {
|
|
16305
17036
|
return definition;
|
|
16306
17037
|
}
|
|
16307
17038
|
const coding = buildSnomedFindingSiteCoding({
|
|
@@ -16431,12 +17162,12 @@ function pickPrnReasonSelection(selections, request) {
|
|
|
16431
17162
|
return void 0;
|
|
16432
17163
|
}
|
|
16433
17164
|
function applyPrnReasonDefinition(internal, definition) {
|
|
16434
|
-
var
|
|
17165
|
+
var _a2;
|
|
16435
17166
|
const coding = definition.coding;
|
|
16436
17167
|
internal.asNeededReasonCoding = (coding == null ? void 0 : coding.code) ? {
|
|
16437
17168
|
code: coding.code,
|
|
16438
17169
|
display: coding.display,
|
|
16439
|
-
system: (
|
|
17170
|
+
system: (_a2 = coding.system) != null ? _a2 : SNOMED_SYSTEM8,
|
|
16440
17171
|
extension: cloneExtensions(coding.extension),
|
|
16441
17172
|
i18n: definition == null ? void 0 : definition.i18n
|
|
16442
17173
|
} : void 0;
|
|
@@ -16563,7 +17294,7 @@ function splitCoordinatedPrnReasonText(text) {
|
|
|
16563
17294
|
return void 0;
|
|
16564
17295
|
}
|
|
16565
17296
|
function maybeApplyCoordinatedPrnReasonsSync(internal, options) {
|
|
16566
|
-
var
|
|
17297
|
+
var _a2, _b;
|
|
16567
17298
|
const text = internal.asNeededReason;
|
|
16568
17299
|
if (!text || internal.asNeededReasonCoding) {
|
|
16569
17300
|
return;
|
|
@@ -16578,7 +17309,7 @@ function maybeApplyCoordinatedPrnReasonsSync(internal, options) {
|
|
|
16578
17309
|
const definition = resolvePrnReasonDefinitionSyncForRequest(internal, request, options);
|
|
16579
17310
|
reasons.push({
|
|
16580
17311
|
text: part,
|
|
16581
|
-
coding: ((
|
|
17312
|
+
coding: ((_a2 = definition == null ? void 0 : definition.coding) == null ? void 0 : _a2.code) ? {
|
|
16582
17313
|
code: definition.coding.code,
|
|
16583
17314
|
display: definition.coding.display,
|
|
16584
17315
|
system: (_b = definition.coding.system) != null ? _b : SNOMED_SYSTEM8,
|
|
@@ -16591,7 +17322,7 @@ function maybeApplyCoordinatedPrnReasonsSync(internal, options) {
|
|
|
16591
17322
|
}
|
|
16592
17323
|
function maybeApplyCoordinatedPrnReasonsAsync(internal, options) {
|
|
16593
17324
|
return __async(this, null, function* () {
|
|
16594
|
-
var
|
|
17325
|
+
var _a2, _b;
|
|
16595
17326
|
const text = internal.asNeededReason;
|
|
16596
17327
|
if (!text || internal.asNeededReasonCoding) {
|
|
16597
17328
|
return;
|
|
@@ -16606,7 +17337,7 @@ function maybeApplyCoordinatedPrnReasonsAsync(internal, options) {
|
|
|
16606
17337
|
const definition = yield resolvePrnReasonDefinitionAsyncForRequest(internal, request, options);
|
|
16607
17338
|
reasons.push({
|
|
16608
17339
|
text: part,
|
|
16609
|
-
coding: ((
|
|
17340
|
+
coding: ((_a2 = definition == null ? void 0 : definition.coding) == null ? void 0 : _a2.code) ? {
|
|
16610
17341
|
code: definition.coding.code,
|
|
16611
17342
|
display: definition.coding.display,
|
|
16612
17343
|
system: (_b = definition.coding.system) != null ? _b : SNOMED_SYSTEM8,
|
|
@@ -16619,11 +17350,11 @@ function maybeApplyCoordinatedPrnReasonsAsync(internal, options) {
|
|
|
16619
17350
|
});
|
|
16620
17351
|
}
|
|
16621
17352
|
function uniquePrnReasonRequests(requests) {
|
|
16622
|
-
var
|
|
17353
|
+
var _a2, _b, _c, _d;
|
|
16623
17354
|
const result = [];
|
|
16624
17355
|
const seen = /* @__PURE__ */ new Set();
|
|
16625
17356
|
for (const request of requests != null ? requests : []) {
|
|
16626
|
-
const key = `${(_b = (
|
|
17357
|
+
const key = `${(_b = (_a2 = request.range) == null ? void 0 : _a2.start) != null ? _b : ""}:${(_d = (_c = request.range) == null ? void 0 : _c.end) != null ? _d : ""}:${request.text}`;
|
|
16627
17358
|
if (seen.has(key)) {
|
|
16628
17359
|
continue;
|
|
16629
17360
|
}
|
|
@@ -16633,20 +17364,20 @@ function uniquePrnReasonRequests(requests) {
|
|
|
16633
17364
|
return result;
|
|
16634
17365
|
}
|
|
16635
17366
|
function codingFromPrnDefinition(definition) {
|
|
16636
|
-
var
|
|
17367
|
+
var _a2;
|
|
16637
17368
|
const coding = definition == null ? void 0 : definition.coding;
|
|
16638
17369
|
return (coding == null ? void 0 : coding.code) ? {
|
|
16639
17370
|
code: coding.code,
|
|
16640
17371
|
display: coding.display,
|
|
16641
|
-
system: (
|
|
17372
|
+
system: (_a2 = coding.system) != null ? _a2 : SNOMED_SYSTEM8,
|
|
16642
17373
|
extension: cloneExtensions(coding.extension),
|
|
16643
17374
|
i18n: definition == null ? void 0 : definition.i18n
|
|
16644
17375
|
} : void 0;
|
|
16645
17376
|
}
|
|
16646
17377
|
function joinPrnReasonTexts(reasons) {
|
|
16647
17378
|
const texts = reasons.map((reason) => {
|
|
16648
|
-
var
|
|
16649
|
-
return (
|
|
17379
|
+
var _a2;
|
|
17380
|
+
return (_a2 = reason.text) == null ? void 0 : _a2.trim();
|
|
16650
17381
|
}).filter((text) => Boolean(text));
|
|
16651
17382
|
switch (texts.length) {
|
|
16652
17383
|
case 0:
|
|
@@ -16707,7 +17438,7 @@ function collectSuggestionsForRequestAsync(internal, request, resolution, option
|
|
|
16707
17438
|
});
|
|
16708
17439
|
}
|
|
16709
17440
|
function runMultiplePrnReasonResolutionSync(internal, requests, options) {
|
|
16710
|
-
var
|
|
17441
|
+
var _a2;
|
|
16711
17442
|
internal.prnReasonLookups = [];
|
|
16712
17443
|
internal.asNeeded = true;
|
|
16713
17444
|
const reasons = [];
|
|
@@ -16723,14 +17454,14 @@ function runMultiplePrnReasonResolutionSync(internal, requests, options) {
|
|
|
16723
17454
|
internal.asNeededReasons = reasons;
|
|
16724
17455
|
internal.asNeededReason = joinPrnReasonTexts(reasons);
|
|
16725
17456
|
if (reasons.length === 1) {
|
|
16726
|
-
internal.asNeededReasonCoding = (
|
|
17457
|
+
internal.asNeededReasonCoding = (_a2 = reasons[0]) == null ? void 0 : _a2.coding;
|
|
16727
17458
|
} else {
|
|
16728
17459
|
internal.asNeededReasonCoding = void 0;
|
|
16729
17460
|
}
|
|
16730
17461
|
}
|
|
16731
17462
|
function runMultiplePrnReasonResolutionAsync(internal, requests, options) {
|
|
16732
17463
|
return __async(this, null, function* () {
|
|
16733
|
-
var
|
|
17464
|
+
var _a2;
|
|
16734
17465
|
internal.prnReasonLookups = [];
|
|
16735
17466
|
internal.asNeeded = true;
|
|
16736
17467
|
const reasons = [];
|
|
@@ -16746,16 +17477,16 @@ function runMultiplePrnReasonResolutionAsync(internal, requests, options) {
|
|
|
16746
17477
|
internal.asNeededReasons = reasons;
|
|
16747
17478
|
internal.asNeededReason = joinPrnReasonTexts(reasons);
|
|
16748
17479
|
if (reasons.length === 1) {
|
|
16749
|
-
internal.asNeededReasonCoding = (
|
|
17480
|
+
internal.asNeededReasonCoding = (_a2 = reasons[0]) == null ? void 0 : _a2.coding;
|
|
16750
17481
|
} else {
|
|
16751
17482
|
internal.asNeededReasonCoding = void 0;
|
|
16752
17483
|
}
|
|
16753
17484
|
});
|
|
16754
17485
|
}
|
|
16755
17486
|
function definitionToPrnSuggestion(definition) {
|
|
16756
|
-
var
|
|
17487
|
+
var _a2, _b, _c, _d;
|
|
16757
17488
|
return {
|
|
16758
|
-
coding: ((
|
|
17489
|
+
coding: ((_a2 = definition.coding) == null ? void 0 : _a2.code) ? {
|
|
16759
17490
|
code: definition.coding.code,
|
|
16760
17491
|
display: definition.coding.display,
|
|
16761
17492
|
system: (_b = definition.coding.system) != null ? _b : SNOMED_SYSTEM8,
|
|
@@ -16765,12 +17496,12 @@ function definitionToPrnSuggestion(definition) {
|
|
|
16765
17496
|
};
|
|
16766
17497
|
}
|
|
16767
17498
|
function addReasonSuggestionToMap(map, suggestion) {
|
|
16768
|
-
var
|
|
17499
|
+
var _a2;
|
|
16769
17500
|
if (!suggestion) {
|
|
16770
17501
|
return;
|
|
16771
17502
|
}
|
|
16772
17503
|
const coding = suggestion.coding;
|
|
16773
|
-
const key = (coding == null ? void 0 : coding.code) ? `${(
|
|
17504
|
+
const key = (coding == null ? void 0 : coding.code) ? `${(_a2 = coding.system) != null ? _a2 : SNOMED_SYSTEM8}|${coding.code}` : suggestion.text ? `text:${suggestion.text.toLowerCase()}` : void 0;
|
|
16774
17505
|
if (!key || map.has(key)) {
|
|
16775
17506
|
return;
|
|
16776
17507
|
}
|
|
@@ -16822,7 +17553,7 @@ function collectDefaultPrnReasonDefinitions(request) {
|
|
|
16822
17553
|
return Array.from(seen);
|
|
16823
17554
|
}
|
|
16824
17555
|
function runPrnReasonResolutionSync(internal, options) {
|
|
16825
|
-
var
|
|
17556
|
+
var _a2, _b, _c;
|
|
16826
17557
|
const requests = uniquePrnReasonRequests(internal.prnReasonLookupRequests);
|
|
16827
17558
|
if (requests.length) {
|
|
16828
17559
|
runMultiplePrnReasonResolutionSync(internal, requests, options);
|
|
@@ -16836,7 +17567,7 @@ function runPrnReasonResolutionSync(internal, options) {
|
|
|
16836
17567
|
const canonicals = collectPrnReasonLookupCanonicals(request);
|
|
16837
17568
|
const combinedCanonical = buildCombinedPrnReasonCanonical(request);
|
|
16838
17569
|
const selection = pickPrnReasonSelection(options == null ? void 0 : options.prnReasonSelections, request);
|
|
16839
|
-
const exactCustomDefinition = (
|
|
17570
|
+
const exactCustomDefinition = (_a2 = lookupPrnReasonDefinition(options == null ? void 0 : options.prnReasonMap, request.canonical)) != null ? _a2 : lookupPrnReasonDefinition(options == null ? void 0 : options.prnReasonMap, combinedCanonical != null ? combinedCanonical : "");
|
|
16840
17571
|
const customDefinition = lookupPrnReasonDefinition(options == null ? void 0 : options.prnReasonMap, canonicals);
|
|
16841
17572
|
const inferredDefinition = inferSiteSpecificPrnReasonDefinition(internal, request);
|
|
16842
17573
|
let resolution = selection != null ? selection : customDefinition;
|
|
@@ -16917,7 +17648,7 @@ function runPrnReasonResolutionSync(internal, options) {
|
|
|
16917
17648
|
}
|
|
16918
17649
|
function runPrnReasonResolutionAsync(internal, options) {
|
|
16919
17650
|
return __async(this, null, function* () {
|
|
16920
|
-
var
|
|
17651
|
+
var _a2, _b, _c;
|
|
16921
17652
|
const requests = uniquePrnReasonRequests(internal.prnReasonLookupRequests);
|
|
16922
17653
|
if (requests.length) {
|
|
16923
17654
|
yield runMultiplePrnReasonResolutionAsync(internal, requests, options);
|
|
@@ -16931,7 +17662,7 @@ function runPrnReasonResolutionAsync(internal, options) {
|
|
|
16931
17662
|
const canonicals = collectPrnReasonLookupCanonicals(request);
|
|
16932
17663
|
const combinedCanonical = buildCombinedPrnReasonCanonical(request);
|
|
16933
17664
|
const selection = pickPrnReasonSelection(options == null ? void 0 : options.prnReasonSelections, request);
|
|
16934
|
-
const exactCustomDefinition = (
|
|
17665
|
+
const exactCustomDefinition = (_a2 = lookupPrnReasonDefinition(options == null ? void 0 : options.prnReasonMap, request.canonical)) != null ? _a2 : lookupPrnReasonDefinition(options == null ? void 0 : options.prnReasonMap, combinedCanonical != null ? combinedCanonical : "");
|
|
16935
17666
|
const customDefinition = lookupPrnReasonDefinition(options == null ? void 0 : options.prnReasonMap, canonicals);
|
|
16936
17667
|
const inferredDefinition = inferSiteSpecificPrnReasonDefinition(internal, request);
|
|
16937
17668
|
let resolution = selection != null ? selection : customDefinition;
|
|
@@ -17215,12 +17946,12 @@ function pickSiteSelection(selections, request) {
|
|
|
17215
17946
|
return void 0;
|
|
17216
17947
|
}
|
|
17217
17948
|
function applySiteDefinition(internal, definition) {
|
|
17218
|
-
var
|
|
17949
|
+
var _a2, _b, _c;
|
|
17219
17950
|
const coding = definition.coding;
|
|
17220
17951
|
internal.siteCoding = (coding == null ? void 0 : coding.code) ? {
|
|
17221
17952
|
code: coding.code,
|
|
17222
17953
|
display: coding.display,
|
|
17223
|
-
system: (
|
|
17954
|
+
system: (_a2 = coding.system) != null ? _a2 : SNOMED_SYSTEM9
|
|
17224
17955
|
} : void 0;
|
|
17225
17956
|
if (definition.text) {
|
|
17226
17957
|
internal.siteText = definition.text;
|
|
@@ -17234,12 +17965,12 @@ function applySiteDefinition(internal, definition) {
|
|
|
17234
17965
|
}
|
|
17235
17966
|
}
|
|
17236
17967
|
function definitionToSuggestion(definition, omitRedundantText = false) {
|
|
17237
|
-
var
|
|
17968
|
+
var _a2, _b;
|
|
17238
17969
|
const coding = definition.coding;
|
|
17239
17970
|
if (!(coding == null ? void 0 : coding.code)) {
|
|
17240
17971
|
return void 0;
|
|
17241
17972
|
}
|
|
17242
|
-
const text = omitRedundantText && definition.text && definition.text.trim().toLowerCase() !== ((
|
|
17973
|
+
const text = omitRedundantText && definition.text && definition.text.trim().toLowerCase() !== ((_a2 = coding.display) == null ? void 0 : _a2.trim().toLowerCase()) ? definition.text : omitRedundantText ? void 0 : definition.text;
|
|
17243
17974
|
return {
|
|
17244
17975
|
coding: {
|
|
17245
17976
|
code: coding.code,
|
|
@@ -17250,7 +17981,7 @@ function definitionToSuggestion(definition, omitRedundantText = false) {
|
|
|
17250
17981
|
};
|
|
17251
17982
|
}
|
|
17252
17983
|
function addSuggestionToMap(map, suggestion) {
|
|
17253
|
-
var
|
|
17984
|
+
var _a2, _b;
|
|
17254
17985
|
if (!suggestion) {
|
|
17255
17986
|
return;
|
|
17256
17987
|
}
|
|
@@ -17258,7 +17989,7 @@ function addSuggestionToMap(map, suggestion) {
|
|
|
17258
17989
|
if (!(coding == null ? void 0 : coding.code)) {
|
|
17259
17990
|
return;
|
|
17260
17991
|
}
|
|
17261
|
-
const key = `${(
|
|
17992
|
+
const key = `${(_a2 = coding.system) != null ? _a2 : SNOMED_SYSTEM9}|${coding.code}`;
|
|
17262
17993
|
if (!map.has(key)) {
|
|
17263
17994
|
map.set(key, {
|
|
17264
17995
|
coding: {
|
|
@@ -17336,6 +18067,8 @@ var METHOD_TEXT_BY_VERB = {
|
|
|
17336
18067
|
var METHOD_THAI_BY_VERB = {
|
|
17337
18068
|
apply: "\u0E17\u0E32",
|
|
17338
18069
|
drink: "\u0E23\u0E31\u0E1A\u0E1B\u0E23\u0E30\u0E17\u0E32\u0E19",
|
|
18070
|
+
inhale: "\u0E2A\u0E39\u0E14",
|
|
18071
|
+
inject: "\u0E09\u0E35\u0E14",
|
|
17339
18072
|
insert: "\u0E2A\u0E2D\u0E14",
|
|
17340
18073
|
instill: "\u0E2B\u0E22\u0E2D\u0E14",
|
|
17341
18074
|
spray: "\u0E1E\u0E48\u0E19",
|
|
@@ -17347,7 +18080,7 @@ function tokenize(input) {
|
|
|
17347
18080
|
return annotateLexTokens(lexInput(input));
|
|
17348
18081
|
}
|
|
17349
18082
|
function buildCustomSiteHints(map) {
|
|
17350
|
-
var
|
|
18083
|
+
var _a2, _b;
|
|
17351
18084
|
if (!map) {
|
|
17352
18085
|
return void 0;
|
|
17353
18086
|
}
|
|
@@ -17369,7 +18102,7 @@ function buildCustomSiteHints(map) {
|
|
|
17369
18102
|
continue;
|
|
17370
18103
|
}
|
|
17371
18104
|
push(key);
|
|
17372
|
-
(
|
|
18105
|
+
(_a2 = definition.aliases) == null ? void 0 : _a2.forEach(push);
|
|
17373
18106
|
push(definition.text);
|
|
17374
18107
|
push((_b = definition.coding) == null ? void 0 : _b.display);
|
|
17375
18108
|
}
|
|
@@ -17391,11 +18124,11 @@ function addDayOfWeekList(state, days) {
|
|
|
17391
18124
|
}
|
|
17392
18125
|
}
|
|
17393
18126
|
function isCompatibleRouteRefinement(current, next) {
|
|
17394
|
-
var
|
|
18127
|
+
var _a2;
|
|
17395
18128
|
if (current === void 0 || current === next) {
|
|
17396
18129
|
return true;
|
|
17397
18130
|
}
|
|
17398
|
-
return Boolean((
|
|
18131
|
+
return Boolean((_a2 = ROUTE_REFINEMENTS.get(current)) == null ? void 0 : _a2.has(next));
|
|
17399
18132
|
}
|
|
17400
18133
|
function setRoute(state, code, text) {
|
|
17401
18134
|
if (!isCompatibleRouteRefinement(state.routeCode, code)) {
|
|
@@ -17405,12 +18138,12 @@ function setRoute(state, code, text) {
|
|
|
17405
18138
|
state.routeText = text != null ? text : ROUTE_TEXT[code];
|
|
17406
18139
|
}
|
|
17407
18140
|
function refreshMethodSurface(state) {
|
|
17408
|
-
var
|
|
18141
|
+
var _a2;
|
|
17409
18142
|
const verb = state.methodVerb;
|
|
17410
18143
|
if (!verb) {
|
|
17411
18144
|
return;
|
|
17412
18145
|
}
|
|
17413
|
-
state.methodText = (
|
|
18146
|
+
state.methodText = (_a2 = METHOD_TEXT_BY_VERB[verb]) != null ? _a2 : verb.charAt(0).toUpperCase() + verb.slice(1);
|
|
17414
18147
|
const thai = METHOD_THAI_BY_VERB[verb];
|
|
17415
18148
|
state.methodTextElement = thai ? buildTranslationPrimitiveElement({ th: thai }) : void 0;
|
|
17416
18149
|
}
|
|
@@ -17433,13 +18166,13 @@ function recordEvidence(state, rule, startIndex, endIndex) {
|
|
|
17433
18166
|
});
|
|
17434
18167
|
}
|
|
17435
18168
|
function computeTrimmedInputRange(input) {
|
|
17436
|
-
var
|
|
18169
|
+
var _a2;
|
|
17437
18170
|
const start = input.search(/\S/);
|
|
17438
18171
|
if (start === -1) {
|
|
17439
18172
|
return void 0;
|
|
17440
18173
|
}
|
|
17441
18174
|
let end = input.length;
|
|
17442
|
-
while (end > start && /\s/.test((
|
|
18175
|
+
while (end > start && /\s/.test((_a2 = input[end - 1]) != null ? _a2 : "")) {
|
|
17443
18176
|
end -= 1;
|
|
17444
18177
|
}
|
|
17445
18178
|
return { start, end };
|
|
@@ -17490,11 +18223,11 @@ function collectLeftovers(state) {
|
|
|
17490
18223
|
return leftovers;
|
|
17491
18224
|
}
|
|
17492
18225
|
function cleanupClause(state) {
|
|
17493
|
-
var
|
|
18226
|
+
var _a2, _b, _c;
|
|
17494
18227
|
const clause = state.primaryClause;
|
|
17495
18228
|
const schedule = clause.schedule;
|
|
17496
18229
|
if (schedule) {
|
|
17497
|
-
if (!((
|
|
18230
|
+
if (!((_a2 = schedule.dayOfWeek) == null ? void 0 : _a2.length)) delete schedule.dayOfWeek;
|
|
17498
18231
|
if (!((_b = schedule.when) == null ? void 0 : _b.length)) delete schedule.when;
|
|
17499
18232
|
if (!((_c = schedule.timeOfDay) == null ? void 0 : _c.length)) delete schedule.timeOfDay;
|
|
17500
18233
|
if (schedule.count === void 0 && schedule.duration === void 0 && schedule.durationMax === void 0 && schedule.durationUnit === void 0 && schedule.frequency === void 0 && schedule.frequencyMax === void 0 && schedule.period === void 0 && schedule.periodMax === void 0 && schedule.periodUnit === void 0 && schedule.timingCode === void 0 && !schedule.dayOfWeek && !schedule.when && !schedule.timeOfDay) {
|
|
@@ -17563,12 +18296,12 @@ function seedKnownRouteFromSurface(state) {
|
|
|
17563
18296
|
}
|
|
17564
18297
|
}
|
|
17565
18298
|
function seedKnownSiteCoding(state) {
|
|
17566
|
-
var
|
|
18299
|
+
var _a2, _b;
|
|
17567
18300
|
if (!state.siteText || state.siteCoding) {
|
|
17568
18301
|
return;
|
|
17569
18302
|
}
|
|
17570
18303
|
const definition = DEFAULT_BODY_SITE_SNOMED[normalizeBodySiteKey(state.siteText)];
|
|
17571
|
-
if (!((
|
|
18304
|
+
if (!((_a2 = definition == null ? void 0 : definition.coding) == null ? void 0 : _a2.code)) {
|
|
17572
18305
|
return;
|
|
17573
18306
|
}
|
|
17574
18307
|
state.siteCoding = {
|
|
@@ -17634,12 +18367,12 @@ function parsesAsInstructionContinuation(input, tokens, index) {
|
|
|
17634
18367
|
allowFreeTextFallback: false
|
|
17635
18368
|
});
|
|
17636
18369
|
return instructions.some((instruction) => {
|
|
17637
|
-
var
|
|
17638
|
-
return ((
|
|
18370
|
+
var _a2;
|
|
18371
|
+
return ((_a2 = instruction.coding) == null ? void 0 : _a2.code) || instruction.frames.length;
|
|
17639
18372
|
});
|
|
17640
18373
|
}
|
|
17641
18374
|
function isCommaClauseBoundary(input, tokens, index) {
|
|
17642
|
-
var
|
|
18375
|
+
var _a2;
|
|
17643
18376
|
const token = tokens[index];
|
|
17644
18377
|
if (!token || token.original !== ",") {
|
|
17645
18378
|
return false;
|
|
@@ -17650,7 +18383,7 @@ function isCommaClauseBoundary(input, tokens, index) {
|
|
|
17650
18383
|
}
|
|
17651
18384
|
const lower = next.lower.replace(/[.,;:]/g, "");
|
|
17652
18385
|
const rawLower = next.lower.replace(/^\.+|\.+$/g, "");
|
|
17653
|
-
const following = (
|
|
18386
|
+
const following = (_a2 = tokens[index + 2]) == null ? void 0 : _a2.lower.replace(/^\.+|\.+$/g, "");
|
|
17654
18387
|
if (/^[0-9]{1,2}[:.][0-9]{2}$/.test(rawLower) || /^[0-9]{1,2}$/.test(rawLower) && Boolean(following && MERIDIEM_TOKENS.has(following))) {
|
|
17655
18388
|
return false;
|
|
17656
18389
|
}
|
|
@@ -17669,7 +18402,7 @@ function isCommaClauseBoundary(input, tokens, index) {
|
|
|
17669
18402
|
return true;
|
|
17670
18403
|
}
|
|
17671
18404
|
function isSlashClauseBoundary(tokens, index) {
|
|
17672
|
-
var
|
|
18405
|
+
var _a2;
|
|
17673
18406
|
const token = tokens[index];
|
|
17674
18407
|
if (!token || token.original !== "/") {
|
|
17675
18408
|
return false;
|
|
@@ -17679,7 +18412,7 @@ function isSlashClauseBoundary(tokens, index) {
|
|
|
17679
18412
|
return false;
|
|
17680
18413
|
}
|
|
17681
18414
|
const previous = tokens[index - 1];
|
|
17682
|
-
const previousLower = (
|
|
18415
|
+
const previousLower = (_a2 = previous == null ? void 0 : previous.lower.replace(/[.,;:]/g, "")) != null ? _a2 : "";
|
|
17683
18416
|
const lower = next.lower.replace(/[.,;:]/g, "");
|
|
17684
18417
|
if (/^\d+(?:\.\d+)?$/.test(previousLower) && /^\d+(?:\.\d+)?$/.test(lower)) {
|
|
17685
18418
|
return false;
|
|
@@ -17687,10 +18420,10 @@ function isSlashClauseBoundary(tokens, index) {
|
|
|
17687
18420
|
return /^\d/.test(lower) || CLAUSE_LEAD_WORDS.has(lower);
|
|
17688
18421
|
}
|
|
17689
18422
|
function pushSegment(segments, input, start, end) {
|
|
17690
|
-
var
|
|
18423
|
+
var _a2, _b;
|
|
17691
18424
|
let trimmedStart = start;
|
|
17692
18425
|
let trimmedEnd = end;
|
|
17693
|
-
while (trimmedStart < trimmedEnd && /\s/.test((
|
|
18426
|
+
while (trimmedStart < trimmedEnd && /\s/.test((_a2 = input[trimmedStart]) != null ? _a2 : "")) {
|
|
17694
18427
|
trimmedStart += 1;
|
|
17695
18428
|
}
|
|
17696
18429
|
while (trimmedEnd > trimmedStart && /\s/.test((_b = input[trimmedEnd - 1]) != null ? _b : "")) {
|
|
@@ -17794,7 +18527,7 @@ var DEFAULT_UNIT_ROUTE_ORDER = [
|
|
|
17794
18527
|
{ unit: "patch", routeCode: RouteCode["Transdermal route"] }
|
|
17795
18528
|
];
|
|
17796
18529
|
var ROUTE_TOKEN_BY_UNIT = (() => {
|
|
17797
|
-
var
|
|
18530
|
+
var _a2, _b, _c;
|
|
17798
18531
|
const map = /* @__PURE__ */ new Map();
|
|
17799
18532
|
const assign = (unit, token) => {
|
|
17800
18533
|
if (!unit || !token) {
|
|
@@ -17815,7 +18548,7 @@ var ROUTE_TOKEN_BY_UNIT = (() => {
|
|
|
17815
18548
|
if (!unit) {
|
|
17816
18549
|
continue;
|
|
17817
18550
|
}
|
|
17818
|
-
const token = (
|
|
18551
|
+
const token = (_a2 = ROUTE_TOKEN_BY_CODE[routeCode]) != null ? _a2 : ROUTE_TEXT[routeCode];
|
|
17819
18552
|
assign(unit, token);
|
|
17820
18553
|
}
|
|
17821
18554
|
for (const preference of DEFAULT_UNIT_ROUTE_ORDER) {
|
|
@@ -17949,7 +18682,7 @@ var UNIT_LOOKUP = (() => {
|
|
|
17949
18682
|
return { canonicalByKey, variantsByCanonical };
|
|
17950
18683
|
})();
|
|
17951
18684
|
function resolveCanonicalUnit(unit) {
|
|
17952
|
-
var
|
|
18685
|
+
var _a2;
|
|
17953
18686
|
if (!unit) {
|
|
17954
18687
|
return void 0;
|
|
17955
18688
|
}
|
|
@@ -17957,7 +18690,7 @@ function resolveCanonicalUnit(unit) {
|
|
|
17957
18690
|
if (!normalized) {
|
|
17958
18691
|
return void 0;
|
|
17959
18692
|
}
|
|
17960
|
-
return (
|
|
18693
|
+
return (_a2 = UNIT_LOOKUP.canonicalByKey.get(normalized)) != null ? _a2 : normalizeSpacing(unit);
|
|
17961
18694
|
}
|
|
17962
18695
|
function normalizeKey(value) {
|
|
17963
18696
|
return value.trim().toLowerCase();
|
|
@@ -17996,8 +18729,8 @@ function removeDashes(value) {
|
|
|
17996
18729
|
}
|
|
17997
18730
|
var UNIT_VARIANT_CACHE = /* @__PURE__ */ new Map();
|
|
17998
18731
|
function getUnitVariants(unit) {
|
|
17999
|
-
var
|
|
18000
|
-
const canonical = (
|
|
18732
|
+
var _a2;
|
|
18733
|
+
const canonical = (_a2 = resolveCanonicalUnit(unit)) != null ? _a2 : normalizeSpacing(unit);
|
|
18001
18734
|
const normalizedCanonical = normalizeKey(canonical);
|
|
18002
18735
|
const cached = UNIT_VARIANT_CACHE.get(normalizedCanonical);
|
|
18003
18736
|
if (cached) {
|
|
@@ -18147,11 +18880,11 @@ function tokensMatch(prefixTokens, candidateTokens) {
|
|
|
18147
18880
|
return prefixIndex >= prefixTokens.length;
|
|
18148
18881
|
}
|
|
18149
18882
|
function buildUnitRoutePairs(contextUnit, options) {
|
|
18150
|
-
var
|
|
18883
|
+
var _a2, _b;
|
|
18151
18884
|
const pairs = [];
|
|
18152
18885
|
const seen = /* @__PURE__ */ new Set();
|
|
18153
18886
|
const addPair = (unit, routeOverride) => {
|
|
18154
|
-
var
|
|
18887
|
+
var _a3;
|
|
18155
18888
|
const canonicalUnit = resolveCanonicalUnit(unit);
|
|
18156
18889
|
if (!canonicalUnit) {
|
|
18157
18890
|
return;
|
|
@@ -18160,7 +18893,7 @@ function buildUnitRoutePairs(contextUnit, options) {
|
|
|
18160
18893
|
if ((options == null ? void 0 : options.allowHouseholdVolumeUnits) === false && HOUSEHOLD_VOLUME_UNIT_SET2.has(normalizedUnit)) {
|
|
18161
18894
|
return;
|
|
18162
18895
|
}
|
|
18163
|
-
const resolvedRoute = (
|
|
18896
|
+
const resolvedRoute = (_a3 = routeOverride != null ? routeOverride : ROUTE_TOKEN_BY_UNIT.get(normalizedUnit)) != null ? _a3 : "po";
|
|
18164
18897
|
const cleanRoute = normalizeSpacing(resolvedRoute);
|
|
18165
18898
|
if (!cleanRoute) {
|
|
18166
18899
|
return;
|
|
@@ -18175,7 +18908,7 @@ function buildUnitRoutePairs(contextUnit, options) {
|
|
|
18175
18908
|
};
|
|
18176
18909
|
addPair(contextUnit);
|
|
18177
18910
|
for (const preference of DEFAULT_UNIT_ROUTE_ORDER) {
|
|
18178
|
-
const routeToken = (_b = (
|
|
18911
|
+
const routeToken = (_b = (_a2 = preference.routeToken) != null ? _a2 : ROUTE_TOKEN_BY_CODE[preference.routeCode]) != null ? _b : ROUTE_TEXT[preference.routeCode];
|
|
18179
18912
|
addPair(preference.unit, routeToken);
|
|
18180
18913
|
}
|
|
18181
18914
|
return pairs;
|
|
@@ -18401,7 +19134,7 @@ function generateCandidateDirections(pairs, doseValues, prnReasons, intervalToke
|
|
|
18401
19134
|
return suggestions;
|
|
18402
19135
|
}
|
|
18403
19136
|
function matchesPrefix(_candidate, candidateLower, context) {
|
|
18404
|
-
var
|
|
19137
|
+
var _a2, _b, _c, _d, _e, _f;
|
|
18405
19138
|
if (!context.raw) {
|
|
18406
19139
|
return true;
|
|
18407
19140
|
}
|
|
@@ -18413,7 +19146,7 @@ function matchesPrefix(_candidate, candidateLower, context) {
|
|
|
18413
19146
|
}
|
|
18414
19147
|
const fingerprint = getCandidateFingerprint(candidateLower);
|
|
18415
19148
|
if (context.requiresCompact) {
|
|
18416
|
-
const compactCandidate = (
|
|
19149
|
+
const compactCandidate = (_a2 = fingerprint.compact) != null ? _a2 : fingerprint.compact = removeWhitespaceCharacters(candidateLower);
|
|
18417
19150
|
if (compactCandidate.startsWith(context.compact)) {
|
|
18418
19151
|
return true;
|
|
18419
19152
|
}
|
|
@@ -18488,7 +19221,7 @@ function collectMatchedCandidates(candidates, limit, matcher) {
|
|
|
18488
19221
|
return suggestions;
|
|
18489
19222
|
}
|
|
18490
19223
|
function buildMealDashCoreVariants(prefixCore) {
|
|
18491
|
-
var
|
|
19224
|
+
var _a2;
|
|
18492
19225
|
if (!prefixCore.includes("-") || prefixCore.includes("--")) {
|
|
18493
19226
|
return [];
|
|
18494
19227
|
}
|
|
@@ -18496,7 +19229,7 @@ function buildMealDashCoreVariants(prefixCore) {
|
|
|
18496
19229
|
if (slots.length < 2 || slots.length > 4) {
|
|
18497
19230
|
return [];
|
|
18498
19231
|
}
|
|
18499
|
-
if (!/^[0-9]+(?:\.[0-9]+)?$/.test((
|
|
19232
|
+
if (!/^[0-9]+(?:\.[0-9]+)?$/.test((_a2 = slots[0]) != null ? _a2 : "")) {
|
|
18500
19233
|
return [];
|
|
18501
19234
|
}
|
|
18502
19235
|
for (let i = 1; i < slots.length; i += 1) {
|
|
@@ -18569,7 +19302,7 @@ function suggestMealDashSyntax(prefix, limit, matcher) {
|
|
|
18569
19302
|
return collectMatchedCandidates(candidates, limit, matcher);
|
|
18570
19303
|
}
|
|
18571
19304
|
function suggestCompactOralMealTiming(prefix, limit, matcher) {
|
|
18572
|
-
var
|
|
19305
|
+
var _a2, _b;
|
|
18573
19306
|
const match = prefix.match(
|
|
18574
19307
|
/^(\d+(?:\.\d+)?)\s*(?:po\s*(c|ac|pc)|po(c|ac|pc))$/
|
|
18575
19308
|
);
|
|
@@ -18577,14 +19310,14 @@ function suggestCompactOralMealTiming(prefix, limit, matcher) {
|
|
|
18577
19310
|
return void 0;
|
|
18578
19311
|
}
|
|
18579
19312
|
const dose = normalizeSpacing(match[1]);
|
|
18580
|
-
const timing = ((_b = (
|
|
19313
|
+
const timing = ((_b = (_a2 = match[2]) != null ? _a2 : match[3]) != null ? _b : "").toLowerCase();
|
|
18581
19314
|
const orderedTimings = timing === "c" ? ["c", "ac", "pc"] : timing === "ac" ? ["ac", "c", "pc"] : timing === "pc" ? ["pc", "c", "ac"] : ["c", "ac", "pc"];
|
|
18582
19315
|
const candidates = orderedTimings.map((token) => `${dose} po ${token}`);
|
|
18583
19316
|
return collectMatchedCandidates(candidates, limit, matcher);
|
|
18584
19317
|
}
|
|
18585
19318
|
function suggestSig(input, options) {
|
|
18586
|
-
var
|
|
18587
|
-
const limit = (
|
|
19319
|
+
var _a2, _b;
|
|
19320
|
+
const limit = (_a2 = options == null ? void 0 : options.limit) != null ? _a2 : DEFAULT_LIMIT;
|
|
18588
19321
|
if (limit <= 0) {
|
|
18589
19322
|
return [];
|
|
18590
19323
|
}
|
|
@@ -18673,10 +19406,10 @@ function getUnitCategory(unit) {
|
|
|
18673
19406
|
return "other";
|
|
18674
19407
|
}
|
|
18675
19408
|
function getBaseUnitFactor(unit) {
|
|
18676
|
-
var
|
|
19409
|
+
var _a2, _b;
|
|
18677
19410
|
if (!unit) return 1;
|
|
18678
19411
|
const u = unit.toLowerCase();
|
|
18679
|
-
return (_b = (
|
|
19412
|
+
return (_b = (_a2 = MASS_UNITS[u]) != null ? _a2 : VOLUME_UNITS[u]) != null ? _b : 1;
|
|
18680
19413
|
}
|
|
18681
19414
|
function convertValue(value, fromUnit, toUnit, strength) {
|
|
18682
19415
|
const f = fromUnit.toLowerCase();
|
|
@@ -18714,16 +19447,16 @@ function convertValue(value, fromUnit, toUnit, strength) {
|
|
|
18714
19447
|
|
|
18715
19448
|
// src/utils/strength.ts
|
|
18716
19449
|
function parseStrength(strength, context) {
|
|
18717
|
-
var
|
|
19450
|
+
var _a2, _b, _c;
|
|
18718
19451
|
const ratio = parseStrengthIntoRatio(strength, context);
|
|
18719
19452
|
if (!ratio) return {};
|
|
18720
|
-
if (((
|
|
19453
|
+
if (((_a2 = ratio.denominator) == null ? void 0 : _a2.value) === 1 && (((_b = ratio.denominator) == null ? void 0 : _b.unit) === "unit" || !((_c = ratio.denominator) == null ? void 0 : _c.unit))) {
|
|
18721
19454
|
return { strengthQuantity: ratio.numerator };
|
|
18722
19455
|
}
|
|
18723
19456
|
return { strengthRatio: ratio };
|
|
18724
19457
|
}
|
|
18725
19458
|
function parseStrengthIntoRatio(strength, context) {
|
|
18726
|
-
var
|
|
19459
|
+
var _a2, _b, _c, _d, _e;
|
|
18727
19460
|
const parts = strength.split("+").map((p) => p.trim());
|
|
18728
19461
|
let totalMgPerMlOrG = 0;
|
|
18729
19462
|
let hasVolume = false;
|
|
@@ -18733,7 +19466,7 @@ function parseStrengthIntoRatio(strength, context) {
|
|
|
18733
19466
|
let targetDenValue;
|
|
18734
19467
|
for (const part of parts) {
|
|
18735
19468
|
const ratio = parseSingleStrengthPart(part, context);
|
|
18736
|
-
if (!ratio || !((
|
|
19469
|
+
if (!ratio || !((_a2 = ratio.numerator) == null ? void 0 : _a2.value) || ratio.numerator.value === 0) continue;
|
|
18737
19470
|
const nUnit = ratio.numerator.unit;
|
|
18738
19471
|
const dUnit = ((_b = ratio.denominator) == null ? void 0 : _b.unit) || "unit";
|
|
18739
19472
|
const dCat = getUnitCategory(dUnit);
|
|
@@ -18808,7 +19541,7 @@ function isSolidDosageForm(form) {
|
|
|
18808
19541
|
return false;
|
|
18809
19542
|
}
|
|
18810
19543
|
function parseSingleStrengthPart(part, context) {
|
|
18811
|
-
var
|
|
19544
|
+
var _a2, _b;
|
|
18812
19545
|
const p = part.trim();
|
|
18813
19546
|
const percentMatch = p.match(/^(\d+(?:\.\d+)?)\s*%$/);
|
|
18814
19547
|
if (percentMatch) {
|
|
@@ -18823,7 +19556,7 @@ function parseSingleStrengthPart(part, context) {
|
|
|
18823
19556
|
return {
|
|
18824
19557
|
numerator: {
|
|
18825
19558
|
value: parseFloat(ratioMatch[1]),
|
|
18826
|
-
unit: ((
|
|
19559
|
+
unit: ((_a2 = ratioMatch[2]) == null ? void 0 : _a2.trim()) || "mg"
|
|
18827
19560
|
},
|
|
18828
19561
|
denominator: {
|
|
18829
19562
|
value: ratioMatch[3] ? parseFloat(ratioMatch[3]) : 1,
|
|
@@ -18861,6 +19594,7 @@ var DEFAULT_FREQUENCY_DEFAULTS = {
|
|
|
18861
19594
|
};
|
|
18862
19595
|
var SECONDS_PER_MINUTE = 60;
|
|
18863
19596
|
var MINUTES_PER_DAY = 24 * 60;
|
|
19597
|
+
var TOTAL_UNITS_PRECISION = 1e12;
|
|
18864
19598
|
var dateTimeFormatCache = /* @__PURE__ */ new Map();
|
|
18865
19599
|
var weekdayFormatCache = /* @__PURE__ */ new Map();
|
|
18866
19600
|
function pad(value, length = 2) {
|
|
@@ -18887,7 +19621,7 @@ function formatToParts(formatter, date) {
|
|
|
18887
19621
|
];
|
|
18888
19622
|
}
|
|
18889
19623
|
function normalizeClock(clock) {
|
|
18890
|
-
var
|
|
19624
|
+
var _a2;
|
|
18891
19625
|
const parts = clock.split(":");
|
|
18892
19626
|
if (parts.length < 2 || parts.length > 3) {
|
|
18893
19627
|
throw new Error(`Invalid clock value: ${clock}`);
|
|
@@ -18895,7 +19629,7 @@ function normalizeClock(clock) {
|
|
|
18895
19629
|
const [hourPart, minutePart, secondPart] = [
|
|
18896
19630
|
parts[0],
|
|
18897
19631
|
parts[1],
|
|
18898
|
-
(
|
|
19632
|
+
(_a2 = parts[2]) != null ? _a2 : "00"
|
|
18899
19633
|
];
|
|
18900
19634
|
const hour = Number(hourPart);
|
|
18901
19635
|
const minute = Number(minutePart);
|
|
@@ -18937,7 +19671,7 @@ function getWeekdayFormat(timeZone) {
|
|
|
18937
19671
|
return formatter;
|
|
18938
19672
|
}
|
|
18939
19673
|
function getTimeParts(date, timeZone) {
|
|
18940
|
-
var
|
|
19674
|
+
var _a2, _b;
|
|
18941
19675
|
const formatter = getDateTimeFormat(timeZone);
|
|
18942
19676
|
const parts = {};
|
|
18943
19677
|
const rawParts = formatToParts(formatter, date);
|
|
@@ -18975,7 +19709,7 @@ function getTimeParts(date, timeZone) {
|
|
|
18975
19709
|
}
|
|
18976
19710
|
}
|
|
18977
19711
|
parts.hour = 0;
|
|
18978
|
-
parts.minute = (
|
|
19712
|
+
parts.minute = (_a2 = parts.minute) != null ? _a2 : 0;
|
|
18979
19713
|
parts.second = (_b = parts.second) != null ? _b : 0;
|
|
18980
19714
|
}
|
|
18981
19715
|
if (parts.year === void 0 || parts.month === void 0 || parts.day === void 0 || parts.hour === void 0 || parts.minute === void 0 || parts.second === void 0) {
|
|
@@ -19013,10 +19747,10 @@ function makeZonedDate(timeZone, year, month, day, hour, minute, second) {
|
|
|
19013
19747
|
return candidate;
|
|
19014
19748
|
}
|
|
19015
19749
|
function makeZonedDateFromDay(base, timeZone, clock) {
|
|
19016
|
-
var
|
|
19750
|
+
var _a2, _b, _c;
|
|
19017
19751
|
const { year, month, day } = getTimeParts(base, timeZone);
|
|
19018
19752
|
const parts = clock.split(":").map((value) => Number(value));
|
|
19019
|
-
const hour = (
|
|
19753
|
+
const hour = (_a2 = parts[0]) != null ? _a2 : 0;
|
|
19020
19754
|
const minute = (_b = parts[1]) != null ? _b : 0;
|
|
19021
19755
|
const second = (_c = parts[2]) != null ? _c : 0;
|
|
19022
19756
|
return makeZonedDate(timeZone, year, month, day, hour, minute, second);
|
|
@@ -19112,6 +19846,49 @@ function coerceDate(value, label) {
|
|
|
19112
19846
|
}
|
|
19113
19847
|
return date;
|
|
19114
19848
|
}
|
|
19849
|
+
function roundCalculatedUnits(value) {
|
|
19850
|
+
if (!Number.isFinite(value)) {
|
|
19851
|
+
return value;
|
|
19852
|
+
}
|
|
19853
|
+
return Math.round((value + Number.EPSILON) * TOTAL_UNITS_PRECISION) / TOTAL_UNITS_PRECISION;
|
|
19854
|
+
}
|
|
19855
|
+
function resolveContextStrengthRatio(context) {
|
|
19856
|
+
var _a2, _b;
|
|
19857
|
+
if (!context) {
|
|
19858
|
+
return void 0;
|
|
19859
|
+
}
|
|
19860
|
+
return (_b = context.strengthRatio) != null ? _b : context.strength ? (_a2 = parseStrengthIntoRatio(context.strength, context)) != null ? _a2 : void 0 : void 0;
|
|
19861
|
+
}
|
|
19862
|
+
function estimateIngredientQuantity(quantity, context) {
|
|
19863
|
+
if (quantity.value === void 0 || !quantity.unit) {
|
|
19864
|
+
return void 0;
|
|
19865
|
+
}
|
|
19866
|
+
const strength = resolveContextStrengthRatio(context);
|
|
19867
|
+
const numerator = strength == null ? void 0 : strength.numerator;
|
|
19868
|
+
const denominator = strength == null ? void 0 : strength.denominator;
|
|
19869
|
+
if (!(numerator == null ? void 0 : numerator.unit) || numerator.value === void 0 || !(denominator == null ? void 0 : denominator.unit) || denominator.value === void 0) {
|
|
19870
|
+
return void 0;
|
|
19871
|
+
}
|
|
19872
|
+
const converted = convertValue(
|
|
19873
|
+
quantity.value,
|
|
19874
|
+
quantity.unit,
|
|
19875
|
+
numerator.unit,
|
|
19876
|
+
{
|
|
19877
|
+
numerator: { value: numerator.value, unit: numerator.unit },
|
|
19878
|
+
denominator: { value: denominator.value, unit: denominator.unit }
|
|
19879
|
+
}
|
|
19880
|
+
);
|
|
19881
|
+
if (converted === null) {
|
|
19882
|
+
return void 0;
|
|
19883
|
+
}
|
|
19884
|
+
return {
|
|
19885
|
+
value: roundCalculatedUnits(converted),
|
|
19886
|
+
unit: numerator.unit,
|
|
19887
|
+
confidence: quantity.confidence,
|
|
19888
|
+
basis: quantity.basis,
|
|
19889
|
+
source: quantity.source
|
|
19890
|
+
};
|
|
19891
|
+
}
|
|
19115
19892
|
function applyOffset(clock, offsetMinutes) {
|
|
19116
19893
|
const [hour, minute, second] = clock.split(":").map((part) => Number(part));
|
|
19117
19894
|
let totalMinutes = hour * SECONDS_PER_MINUTE + minute + offsetMinutes;
|
|
@@ -19132,8 +19909,8 @@ function applyOffset(clock, offsetMinutes) {
|
|
|
19132
19909
|
};
|
|
19133
19910
|
}
|
|
19134
19911
|
function parseBoundsDurationUnit(quantity) {
|
|
19135
|
-
var
|
|
19136
|
-
const candidate = (_c = (
|
|
19912
|
+
var _a2, _b, _c;
|
|
19913
|
+
const candidate = (_c = (_a2 = quantity == null ? void 0 : quantity.code) == null ? void 0 : _a2.trim().toLowerCase()) != null ? _c : (_b = quantity == null ? void 0 : quantity.unit) == null ? void 0 : _b.trim().toLowerCase();
|
|
19137
19914
|
switch (candidate) {
|
|
19138
19915
|
case "s":
|
|
19139
19916
|
case "sec":
|
|
@@ -19175,11 +19952,11 @@ function parseBoundsDurationUnit(quantity) {
|
|
|
19175
19952
|
}
|
|
19176
19953
|
}
|
|
19177
19954
|
function resolveRepeatBoundsDuration(repeat) {
|
|
19178
|
-
var
|
|
19955
|
+
var _a2, _b, _c, _d;
|
|
19179
19956
|
if (!repeat) {
|
|
19180
19957
|
return {};
|
|
19181
19958
|
}
|
|
19182
|
-
if (((
|
|
19959
|
+
if (((_a2 = repeat.boundsDuration) == null ? void 0 : _a2.value) !== void 0) {
|
|
19183
19960
|
return {
|
|
19184
19961
|
value: repeat.boundsDuration.value,
|
|
19185
19962
|
unit: parseBoundsDurationUnit(repeat.boundsDuration)
|
|
@@ -19195,9 +19972,9 @@ function resolveRepeatBoundsDuration(repeat) {
|
|
|
19195
19972
|
};
|
|
19196
19973
|
}
|
|
19197
19974
|
function resolveRepeatDurationCapEnd(repeat, anchor, timeZone) {
|
|
19198
|
-
var
|
|
19975
|
+
var _a2, _b;
|
|
19199
19976
|
const bounds = resolveRepeatBoundsDuration(repeat);
|
|
19200
|
-
const durationValue = (
|
|
19977
|
+
const durationValue = (_a2 = bounds.max) != null ? _a2 : bounds.value;
|
|
19201
19978
|
const durationUnit = bounds.unit;
|
|
19202
19979
|
if (durationValue === void 0 || !Number.isFinite(durationValue) || durationValue <= 0 || !durationUnit) {
|
|
19203
19980
|
return null;
|
|
@@ -19212,14 +19989,14 @@ function resolveRepeatDurationCapEnd(repeat, anchor, timeZone) {
|
|
|
19212
19989
|
return (_b = stepper(anchor)) != null ? _b : null;
|
|
19213
19990
|
}
|
|
19214
19991
|
function resolveDayFilteredSeriesRepeat(repeat, enforceDayFilter) {
|
|
19215
|
-
var
|
|
19992
|
+
var _a2, _b, _c, _d;
|
|
19216
19993
|
if (!enforceDayFilter) {
|
|
19217
19994
|
return void 0;
|
|
19218
19995
|
}
|
|
19219
19996
|
if (repeat.frequency) {
|
|
19220
19997
|
return void 0;
|
|
19221
19998
|
}
|
|
19222
|
-
if (((_b = (
|
|
19999
|
+
if (((_b = (_a2 = repeat.when) == null ? void 0 : _a2.length) != null ? _b : 0) > 0 || ((_d = (_c = repeat.timeOfDay) == null ? void 0 : _c.length) != null ? _d : 0) > 0) {
|
|
19223
20000
|
return void 0;
|
|
19224
20001
|
}
|
|
19225
20002
|
switch (repeat.periodUnit) {
|
|
@@ -19234,19 +20011,19 @@ function resolveDayFilteredSeriesRepeat(repeat, enforceDayFilter) {
|
|
|
19234
20011
|
}
|
|
19235
20012
|
}
|
|
19236
20013
|
function isSingleAdministrationRepeat(repeat) {
|
|
19237
|
-
var
|
|
19238
|
-
return repeat.count === 1 && repeat.frequency === void 0 && repeat.frequencyMax === void 0 && repeat.period === void 0 && repeat.periodMax === void 0 && repeat.periodUnit === void 0 && ((_b = (
|
|
20014
|
+
var _a2, _b, _c, _d, _e, _f;
|
|
20015
|
+
return repeat.count === 1 && repeat.frequency === void 0 && repeat.frequencyMax === void 0 && repeat.period === void 0 && repeat.periodMax === void 0 && repeat.periodUnit === void 0 && ((_b = (_a2 = repeat.dayOfWeek) == null ? void 0 : _a2.length) != null ? _b : 0) === 0 && ((_d = (_c = repeat.when) == null ? void 0 : _c.length) != null ? _d : 0) === 0 && ((_f = (_e = repeat.timeOfDay) == null ? void 0 : _e.length) != null ? _f : 0) === 0;
|
|
19239
20016
|
}
|
|
19240
20017
|
function hasUnresolvedRelationalInstruction(dosage) {
|
|
19241
|
-
var
|
|
20018
|
+
var _a2, _b, _c, _d, _e, _f;
|
|
19242
20019
|
const texts = [];
|
|
19243
|
-
if ((
|
|
20020
|
+
if ((_a2 = dosage.patientInstruction) == null ? void 0 : _a2.trim()) {
|
|
19244
20021
|
texts.push(dosage.patientInstruction.trim());
|
|
19245
20022
|
}
|
|
19246
20023
|
for (const instruction of (_b = dosage.additionalInstruction) != null ? _b : []) {
|
|
19247
20024
|
const text = ((_c = instruction.text) == null ? void 0 : _c.trim()) || ((_f = (_e = (_d = instruction.coding) == null ? void 0 : _d.find((coding) => {
|
|
19248
|
-
var
|
|
19249
|
-
return (
|
|
20025
|
+
var _a3;
|
|
20026
|
+
return (_a3 = coding.display) == null ? void 0 : _a3.trim();
|
|
19250
20027
|
})) == null ? void 0 : _e.display) == null ? void 0 : _f.trim());
|
|
19251
20028
|
if (text) {
|
|
19252
20029
|
texts.push(text);
|
|
@@ -19288,8 +20065,8 @@ var SPECIFIC_AFTER_MEALS = {
|
|
|
19288
20065
|
["PCV" /* After Dinner */]: "CV" /* Dinner */
|
|
19289
20066
|
};
|
|
19290
20067
|
function expandTiming(code, config, repeat) {
|
|
19291
|
-
var
|
|
19292
|
-
const mealOffsets = (
|
|
20068
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
20069
|
+
const mealOffsets = (_a2 = config.mealOffsets) != null ? _a2 : {};
|
|
19293
20070
|
const eventClock = (_b = config.eventClock) != null ? _b : {};
|
|
19294
20071
|
const normalized = [];
|
|
19295
20072
|
const clockValue = eventClock[code];
|
|
@@ -19338,8 +20115,8 @@ function expandTiming(code, config, repeat) {
|
|
|
19338
20115
|
}
|
|
19339
20116
|
if (repeat.offset && normalized.length) {
|
|
19340
20117
|
return normalized.map((entry) => {
|
|
19341
|
-
var
|
|
19342
|
-
const adjusted = applyOffset(entry.time, (
|
|
20118
|
+
var _a3;
|
|
20119
|
+
const adjusted = applyOffset(entry.time, (_a3 = repeat.offset) != null ? _a3 : 0);
|
|
19343
20120
|
return {
|
|
19344
20121
|
time: adjusted.time,
|
|
19345
20122
|
dayShift: entry.dayShift + adjusted.dayShift
|
|
@@ -19404,9 +20181,9 @@ function inferWhenFallbackEntries(whenCodes, repeat) {
|
|
|
19404
20181
|
const entries = [];
|
|
19405
20182
|
const seen = /* @__PURE__ */ new Set();
|
|
19406
20183
|
const addClock = (clock) => {
|
|
19407
|
-
var
|
|
20184
|
+
var _a2;
|
|
19408
20185
|
const normalized = normalizeClock(clock);
|
|
19409
|
-
const adjusted = repeat.offset ? applyOffset(normalized, (
|
|
20186
|
+
const adjusted = repeat.offset ? applyOffset(normalized, (_a2 = repeat.offset) != null ? _a2 : 0) : { time: normalized, dayShift: 0 };
|
|
19410
20187
|
const key = `${adjusted.dayShift}|${adjusted.time}`;
|
|
19411
20188
|
if (seen.has(key)) {
|
|
19412
20189
|
return;
|
|
@@ -19434,13 +20211,13 @@ function inferWhenFallbackEntries(whenCodes, repeat) {
|
|
|
19434
20211
|
});
|
|
19435
20212
|
}
|
|
19436
20213
|
function mergeFrequencyDefaults(base, override) {
|
|
19437
|
-
var
|
|
20214
|
+
var _a2, _b, _c, _d;
|
|
19438
20215
|
if (!base && !override) {
|
|
19439
20216
|
return void 0;
|
|
19440
20217
|
}
|
|
19441
20218
|
const merged = {};
|
|
19442
20219
|
if ((base == null ? void 0 : base.byCode) || (override == null ? void 0 : override.byCode)) {
|
|
19443
|
-
merged.byCode = __spreadValues(__spreadValues({}, (
|
|
20220
|
+
merged.byCode = __spreadValues(__spreadValues({}, (_a2 = base == null ? void 0 : base.byCode) != null ? _a2 : {}), (_b = override == null ? void 0 : override.byCode) != null ? _b : {});
|
|
19444
20221
|
}
|
|
19445
20222
|
if ((base == null ? void 0 : base.byFrequency) || (override == null ? void 0 : override.byFrequency)) {
|
|
19446
20223
|
merged.byFrequency = __spreadValues(__spreadValues({}, (_c = base == null ? void 0 : base.byFrequency) != null ? _c : {}), (_d = override == null ? void 0 : override.byFrequency) != null ? _d : {});
|
|
@@ -19467,9 +20244,9 @@ function inferDailyFrequencyClocks(frequency) {
|
|
|
19467
20244
|
return Array.from(clocks).sort();
|
|
19468
20245
|
}
|
|
19469
20246
|
function resolveFrequencyClocks(timing, config) {
|
|
19470
|
-
var
|
|
20247
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
19471
20248
|
const defaults = {
|
|
19472
|
-
byCode: __spreadValues(__spreadValues({}, DEFAULT_FREQUENCY_DEFAULTS.byCode), (_b = (
|
|
20249
|
+
byCode: __spreadValues(__spreadValues({}, DEFAULT_FREQUENCY_DEFAULTS.byCode), (_b = (_a2 = config.frequencyDefaults) == null ? void 0 : _a2.byCode) != null ? _b : {}),
|
|
19473
20250
|
byFrequency: __spreadValues(__spreadValues({}, DEFAULT_FREQUENCY_DEFAULTS.byFrequency), (_d = (_c = config.frequencyDefaults) == null ? void 0 : _c.byFrequency) != null ? _d : {})
|
|
19474
20251
|
};
|
|
19475
20252
|
const collected = /* @__PURE__ */ new Set();
|
|
@@ -19503,14 +20280,14 @@ function resolveFrequencyClocks(timing, config) {
|
|
|
19503
20280
|
return Array.from(collected).sort();
|
|
19504
20281
|
}
|
|
19505
20282
|
function nextDueDoses(dosage, options) {
|
|
19506
|
-
var
|
|
20283
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
19507
20284
|
if (!options || typeof options !== "object") {
|
|
19508
20285
|
throw new Error("Options argument is required for nextDueDoses");
|
|
19509
20286
|
}
|
|
19510
20287
|
if (options.from === void 0) {
|
|
19511
20288
|
throw new Error("The 'from' option is required for nextDueDoses");
|
|
19512
20289
|
}
|
|
19513
|
-
const limit = (
|
|
20290
|
+
const limit = (_a2 = options.limit) != null ? _a2 : 10;
|
|
19514
20291
|
if (!Number.isFinite(limit) || limit <= 0) {
|
|
19515
20292
|
return [];
|
|
19516
20293
|
}
|
|
@@ -19739,7 +20516,7 @@ function nextDueDoses(dosage, options) {
|
|
|
19739
20516
|
return [];
|
|
19740
20517
|
}
|
|
19741
20518
|
function derivePriorCountFromHistory(timing, repeat, config, orderedAt, from, timeZone) {
|
|
19742
|
-
var
|
|
20519
|
+
var _a2, _b, _c;
|
|
19743
20520
|
if (from <= orderedAt) {
|
|
19744
20521
|
return 0;
|
|
19745
20522
|
}
|
|
@@ -19747,7 +20524,7 @@ function derivePriorCountFromHistory(timing, repeat, config, orderedAt, from, ti
|
|
|
19747
20524
|
if (normalizedCount === 0) {
|
|
19748
20525
|
return 0;
|
|
19749
20526
|
}
|
|
19750
|
-
const dayFilter = new Set(((
|
|
20527
|
+
const dayFilter = new Set(((_a2 = repeat.dayOfWeek) != null ? _a2 : []).map((day) => day.toLowerCase()));
|
|
19751
20528
|
const enforceDayFilter = dayFilter.size > 0;
|
|
19752
20529
|
const dayFilteredSeriesRepeat = resolveDayFilteredSeriesRepeat(repeat, enforceDayFilter);
|
|
19753
20530
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -20091,7 +20868,7 @@ function toLocalClock(date, timeZone) {
|
|
|
20091
20868
|
return `${h}:${m}:${s}`;
|
|
20092
20869
|
}
|
|
20093
20870
|
function countScheduleEvents(dosage, from, to, config, baseTime, orderedAt, limit) {
|
|
20094
|
-
var
|
|
20871
|
+
var _a2, _b, _c;
|
|
20095
20872
|
const timing = dosage.timing;
|
|
20096
20873
|
const repeat = timing == null ? void 0 : timing.repeat;
|
|
20097
20874
|
if (!timing || !repeat) return 0;
|
|
@@ -20099,7 +20876,7 @@ function countScheduleEvents(dosage, from, to, config, baseTime, orderedAt, limi
|
|
|
20099
20876
|
if (normalizedCount === 0) {
|
|
20100
20877
|
return 0;
|
|
20101
20878
|
}
|
|
20102
|
-
const dayFilter = new Set(((
|
|
20879
|
+
const dayFilter = new Set(((_a2 = repeat.dayOfWeek) != null ? _a2 : []).map((day) => day.toLowerCase()));
|
|
20103
20880
|
const enforceDayFilter = dayFilter.size > 0;
|
|
20104
20881
|
const dayFilteredSeriesRepeat = resolveDayFilteredSeriesRepeat(repeat, enforceDayFilter);
|
|
20105
20882
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -20238,12 +21015,12 @@ function countScheduleEvents(dosage, from, to, config, baseTime, orderedAt, limi
|
|
|
20238
21015
|
return count;
|
|
20239
21016
|
}
|
|
20240
21017
|
function calculateTotalUnitsSingle(options) {
|
|
20241
|
-
var
|
|
21018
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
20242
21019
|
const { dosage, durationValue, durationUnit, roundToMultiple, context } = options;
|
|
20243
21020
|
const from = coerceDate(options.from, "from");
|
|
20244
21021
|
const orderedAtDate = options.orderedAt === void 0 ? null : coerceDate(options.orderedAt, "orderedAt");
|
|
20245
21022
|
const providedConfig = options.config;
|
|
20246
|
-
const timeZone = (
|
|
21023
|
+
const timeZone = (_a2 = options.timeZone) != null ? _a2 : providedConfig == null ? void 0 : providedConfig.timeZone;
|
|
20247
21024
|
if (!timeZone) {
|
|
20248
21025
|
throw new Error("timeZone is required for calculateTotalUnits");
|
|
20249
21026
|
}
|
|
@@ -20281,31 +21058,61 @@ function calculateTotalUnitsSingle(options) {
|
|
|
20281
21058
|
2e3
|
|
20282
21059
|
);
|
|
20283
21060
|
const doseQuantity = (_j = (_i = (_h = (_g = dosage.doseAndRate) == null ? void 0 : _g[0]) == null ? void 0 : _h.doseQuantity) == null ? void 0 : _i.value) != null ? _j : 0;
|
|
20284
|
-
let totalUnits = count * doseQuantity;
|
|
21061
|
+
let totalUnits = roundCalculatedUnits(count * doseQuantity);
|
|
20285
21062
|
if (roundToMultiple && roundToMultiple > 0) {
|
|
20286
|
-
totalUnits = Math.ceil(totalUnits / roundToMultiple) * roundToMultiple;
|
|
21063
|
+
totalUnits = roundCalculatedUnits(Math.ceil(totalUnits / roundToMultiple) * roundToMultiple);
|
|
20287
21064
|
}
|
|
20288
21065
|
const result = { totalUnits };
|
|
20289
21066
|
const containerValue = context == null ? void 0 : context.containerValue;
|
|
20290
21067
|
const containerUnit = context == null ? void 0 : context.containerUnit;
|
|
21068
|
+
const packageUnit = context == null ? void 0 : context.packageUnit;
|
|
20291
21069
|
const doseUnit = (_m = (_l = (_k = dosage.doseAndRate) == null ? void 0 : _k[0]) == null ? void 0 : _l.doseQuantity) == null ? void 0 : _m.unit;
|
|
21070
|
+
const unitSemantics = getDoseUnitSemantics(doseUnit, context);
|
|
21071
|
+
if (unitSemantics == null ? void 0 : unitSemantics.approximateQuantity) {
|
|
21072
|
+
const approximation = unitSemantics.approximateQuantity;
|
|
21073
|
+
result.totalApproximateQuantity = {
|
|
21074
|
+
value: roundCalculatedUnits(totalUnits * approximation.value),
|
|
21075
|
+
unit: approximation.unit,
|
|
21076
|
+
confidence: approximation.confidence,
|
|
21077
|
+
basis: approximation.basis,
|
|
21078
|
+
source: approximation.source
|
|
21079
|
+
};
|
|
21080
|
+
result.totalApproximateIngredientQuantity = estimateIngredientQuantity(
|
|
21081
|
+
result.totalApproximateQuantity,
|
|
21082
|
+
context
|
|
21083
|
+
);
|
|
21084
|
+
}
|
|
20292
21085
|
if (containerValue && containerValue > 0) {
|
|
20293
21086
|
let effectiveUnits = totalUnits;
|
|
20294
|
-
|
|
20295
|
-
|
|
20296
|
-
|
|
20297
|
-
|
|
21087
|
+
let effectiveContainerValue = containerValue;
|
|
21088
|
+
if (containerUnit && ((_n = result.totalApproximateQuantity) == null ? void 0 : _n.unit) && result.totalApproximateQuantity.value !== void 0 && result.totalApproximateQuantity.unit.trim().toLowerCase() === containerUnit.trim().toLowerCase()) {
|
|
21089
|
+
effectiveUnits = result.totalApproximateQuantity.value;
|
|
21090
|
+
result.totalContainerQuantity = {
|
|
21091
|
+
value: result.totalApproximateQuantity.value,
|
|
21092
|
+
unit: containerUnit
|
|
21093
|
+
};
|
|
21094
|
+
} else if (packageUnit && doseUnit && doseUnit.trim().toLowerCase() === packageUnit.trim().toLowerCase()) {
|
|
21095
|
+
effectiveUnits = totalUnits;
|
|
21096
|
+
effectiveContainerValue = 1;
|
|
21097
|
+
if (containerUnit) {
|
|
21098
|
+
result.totalContainerQuantity = {
|
|
21099
|
+
value: roundCalculatedUnits(totalUnits * containerValue),
|
|
21100
|
+
unit: containerUnit
|
|
21101
|
+
};
|
|
20298
21102
|
}
|
|
21103
|
+
} else if (containerUnit && doseUnit && containerUnit !== doseUnit) {
|
|
21104
|
+
const strength = resolveContextStrengthRatio(context);
|
|
20299
21105
|
const converted = convertValue(totalUnits, doseUnit, containerUnit, strength);
|
|
20300
21106
|
if (converted !== null) {
|
|
20301
21107
|
effectiveUnits = converted;
|
|
20302
21108
|
}
|
|
20303
21109
|
}
|
|
20304
|
-
result.totalContainers = Math.ceil(effectiveUnits /
|
|
21110
|
+
result.totalContainers = Math.ceil(effectiveUnits / effectiveContainerValue);
|
|
20305
21111
|
}
|
|
20306
21112
|
return result;
|
|
20307
21113
|
}
|
|
20308
21114
|
function calculateTotalUnits(options) {
|
|
21115
|
+
var _a2, _b, _c, _d, _e, _f;
|
|
20309
21116
|
if (Array.isArray(options.dosage)) {
|
|
20310
21117
|
const hasAnyDosage = options.dosage.length > 0;
|
|
20311
21118
|
if (!hasAnyDosage) {
|
|
@@ -20313,18 +21120,62 @@ function calculateTotalUnits(options) {
|
|
|
20313
21120
|
}
|
|
20314
21121
|
let totalUnits = 0;
|
|
20315
21122
|
let totalContainers = 0;
|
|
21123
|
+
let totalContainerQuantity;
|
|
21124
|
+
let totalApproximateQuantity;
|
|
21125
|
+
let totalApproximateIngredientQuantity;
|
|
21126
|
+
let mixedTotalContainerQuantities = false;
|
|
21127
|
+
let mixedApproximateQuantities = false;
|
|
21128
|
+
let mixedApproximateIngredientQuantities = false;
|
|
20316
21129
|
let sawContainers = false;
|
|
20317
21130
|
for (const dosage of options.dosage) {
|
|
20318
21131
|
const result = calculateTotalUnitsSingle(__spreadProps(__spreadValues({}, options), {
|
|
20319
21132
|
dosage
|
|
20320
21133
|
}));
|
|
20321
|
-
totalUnits
|
|
21134
|
+
totalUnits = roundCalculatedUnits(totalUnits + result.totalUnits);
|
|
21135
|
+
if (result.totalApproximateQuantity && !mixedApproximateQuantities) {
|
|
21136
|
+
if (totalApproximateQuantity && totalApproximateQuantity.unit === result.totalApproximateQuantity.unit && totalApproximateQuantity.confidence === result.totalApproximateQuantity.confidence && totalApproximateQuantity.basis === result.totalApproximateQuantity.basis && totalApproximateQuantity.source === result.totalApproximateQuantity.source) {
|
|
21137
|
+
totalApproximateQuantity.value = roundCalculatedUnits(
|
|
21138
|
+
((_a2 = totalApproximateQuantity.value) != null ? _a2 : 0) + ((_b = result.totalApproximateQuantity.value) != null ? _b : 0)
|
|
21139
|
+
);
|
|
21140
|
+
} else if (!totalApproximateQuantity) {
|
|
21141
|
+
totalApproximateQuantity = __spreadValues({}, result.totalApproximateQuantity);
|
|
21142
|
+
} else {
|
|
21143
|
+
totalApproximateQuantity = void 0;
|
|
21144
|
+
mixedApproximateQuantities = true;
|
|
21145
|
+
}
|
|
21146
|
+
}
|
|
21147
|
+
if (result.totalApproximateIngredientQuantity && !mixedApproximateIngredientQuantities) {
|
|
21148
|
+
if (totalApproximateIngredientQuantity && totalApproximateIngredientQuantity.unit === result.totalApproximateIngredientQuantity.unit && totalApproximateIngredientQuantity.confidence === result.totalApproximateIngredientQuantity.confidence && totalApproximateIngredientQuantity.basis === result.totalApproximateIngredientQuantity.basis && totalApproximateIngredientQuantity.source === result.totalApproximateIngredientQuantity.source) {
|
|
21149
|
+
totalApproximateIngredientQuantity.value = roundCalculatedUnits(
|
|
21150
|
+
((_c = totalApproximateIngredientQuantity.value) != null ? _c : 0) + ((_d = result.totalApproximateIngredientQuantity.value) != null ? _d : 0)
|
|
21151
|
+
);
|
|
21152
|
+
} else if (!totalApproximateIngredientQuantity) {
|
|
21153
|
+
totalApproximateIngredientQuantity = __spreadValues({}, result.totalApproximateIngredientQuantity);
|
|
21154
|
+
} else {
|
|
21155
|
+
totalApproximateIngredientQuantity = void 0;
|
|
21156
|
+
mixedApproximateIngredientQuantities = true;
|
|
21157
|
+
}
|
|
21158
|
+
}
|
|
20322
21159
|
if (result.totalContainers !== void 0) {
|
|
20323
21160
|
totalContainers += result.totalContainers;
|
|
20324
21161
|
sawContainers = true;
|
|
20325
21162
|
}
|
|
21163
|
+
if (result.totalContainerQuantity && !mixedTotalContainerQuantities) {
|
|
21164
|
+
if (totalContainerQuantity && totalContainerQuantity.unit === result.totalContainerQuantity.unit && totalContainerQuantity.system === result.totalContainerQuantity.system && totalContainerQuantity.code === result.totalContainerQuantity.code) {
|
|
21165
|
+
totalContainerQuantity.value = roundCalculatedUnits(
|
|
21166
|
+
((_e = totalContainerQuantity.value) != null ? _e : 0) + ((_f = result.totalContainerQuantity.value) != null ? _f : 0)
|
|
21167
|
+
);
|
|
21168
|
+
} else if (!totalContainerQuantity) {
|
|
21169
|
+
totalContainerQuantity = __spreadValues({}, result.totalContainerQuantity);
|
|
21170
|
+
} else {
|
|
21171
|
+
totalContainerQuantity = void 0;
|
|
21172
|
+
mixedTotalContainerQuantities = true;
|
|
21173
|
+
}
|
|
21174
|
+
}
|
|
20326
21175
|
}
|
|
20327
|
-
return
|
|
21176
|
+
return __spreadValues(__spreadValues(__spreadValues(__spreadValues({
|
|
21177
|
+
totalUnits
|
|
21178
|
+
}, sawContainers ? { totalContainers } : {}), !mixedTotalContainerQuantities && totalContainerQuantity ? { totalContainerQuantity } : {}), !mixedApproximateQuantities && totalApproximateQuantity ? { totalApproximateQuantity } : {}), !mixedApproximateIngredientQuantities && totalApproximateIngredientQuantity ? { totalApproximateIngredientQuantity } : {});
|
|
20328
21179
|
}
|
|
20329
21180
|
return calculateTotalUnitsSingle(options);
|
|
20330
21181
|
}
|
|
@@ -20525,8 +21376,8 @@ function uniqueStrings(values) {
|
|
|
20525
21376
|
return output;
|
|
20526
21377
|
}
|
|
20527
21378
|
function mergeParseResults(base, next, options) {
|
|
20528
|
-
var
|
|
20529
|
-
const baseRepeat = (_b = (
|
|
21379
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
21380
|
+
const baseRepeat = (_b = (_a2 = base.fhir.timing) == null ? void 0 : _a2.repeat) != null ? _b : {};
|
|
20530
21381
|
const nextRepeat = (_d = (_c = next.fhir.timing) == null ? void 0 : _c.repeat) != null ? _d : {};
|
|
20531
21382
|
const mergedWhen = uniqueStrings([...(_e = baseRepeat.when) != null ? _e : [], ...(_f = nextRepeat.when) != null ? _f : []]);
|
|
20532
21383
|
const mergedTimeOfDay = uniqueStrings([...(_g = baseRepeat.timeOfDay) != null ? _g : [], ...(_h = nextRepeat.timeOfDay) != null ? _h : []]).sort();
|
|
@@ -20685,8 +21536,8 @@ function formatSig(dosage, style = "short", options) {
|
|
|
20685
21536
|
return formatCanonicalClause(clause, style, localization, options);
|
|
20686
21537
|
}
|
|
20687
21538
|
function formatSigBatch(dosages, style = "short", options) {
|
|
20688
|
-
var
|
|
20689
|
-
const separator = (
|
|
21539
|
+
var _a2;
|
|
21540
|
+
const separator = (_a2 = options == null ? void 0 : options.separator) != null ? _a2 : ", ";
|
|
20690
21541
|
const formatted = [];
|
|
20691
21542
|
for (const dosage of dosages) {
|
|
20692
21543
|
const text = formatSig(dosage, style, options);
|
|
@@ -20701,7 +21552,7 @@ function formatParseBatch(batch, style = "short", separator = ", ") {
|
|
|
20701
21552
|
return texts.join(separator);
|
|
20702
21553
|
}
|
|
20703
21554
|
function fromFhirDosage(dosage, options) {
|
|
20704
|
-
var
|
|
21555
|
+
var _a2;
|
|
20705
21556
|
const clause = canonicalFromFhir(dosage);
|
|
20706
21557
|
const localization = resolveSigLocalization(options == null ? void 0 : options.locale, options == null ? void 0 : options.i18n);
|
|
20707
21558
|
const shortText = formatCanonicalClause(clause, "short", localization, options);
|
|
@@ -20712,10 +21563,10 @@ function fromFhirDosage(dosage, options) {
|
|
|
20712
21563
|
fhir: dosage,
|
|
20713
21564
|
shortText,
|
|
20714
21565
|
longText,
|
|
20715
|
-
warnings: (
|
|
21566
|
+
warnings: (_a2 = clause.warnings) != null ? _a2 : [],
|
|
20716
21567
|
meta: {
|
|
20717
21568
|
consumedTokens: [],
|
|
20718
|
-
normalized: buildNormalizedMetaFromClause(clause, dosage),
|
|
21569
|
+
normalized: buildNormalizedMetaFromClause(clause, dosage, options),
|
|
20719
21570
|
canonical: {
|
|
20720
21571
|
clauses: [clause]
|
|
20721
21572
|
}
|
|
@@ -20737,8 +21588,8 @@ function createEmptyCanonicalClause2(rawText) {
|
|
|
20737
21588
|
};
|
|
20738
21589
|
}
|
|
20739
21590
|
function getPrimaryClause(clauses, rawText) {
|
|
20740
|
-
var
|
|
20741
|
-
return (
|
|
21591
|
+
var _a2;
|
|
21592
|
+
return (_a2 = clauses[0]) != null ? _a2 : createEmptyCanonicalClause2(rawText);
|
|
20742
21593
|
}
|
|
20743
21594
|
function cloneCoding2(coding) {
|
|
20744
21595
|
if (!(coding == null ? void 0 : coding.code) && !(coding == null ? void 0 : coding.display) && !(coding == null ? void 0 : coding.system)) {
|
|
@@ -20761,32 +21612,36 @@ function cloneBodySiteCoding2(coding) {
|
|
|
20761
21612
|
system: coding.system
|
|
20762
21613
|
};
|
|
20763
21614
|
}
|
|
20764
|
-
function buildNormalizedMetaFromClause(clause, fhir) {
|
|
20765
|
-
var
|
|
20766
|
-
const additionalInstructions = ((
|
|
21615
|
+
function buildNormalizedMetaFromClause(clause, fhir, options) {
|
|
21616
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F;
|
|
21617
|
+
const additionalInstructions = ((_a2 = clause.additionalInstructions) == null ? void 0 : _a2.length) ? clause.additionalInstructions.map((instruction) => ({
|
|
20767
21618
|
text: instruction.text,
|
|
20768
21619
|
coding: cloneCoding2(instruction.coding)
|
|
20769
21620
|
})) : void 0;
|
|
20770
21621
|
const siteCoding = (_e = cloneBodySiteCoding2((_b = clause.site) == null ? void 0 : _b.coding)) != null ? _e : cloneBodySiteCoding2((_d = (_c = fhir == null ? void 0 : fhir.site) == null ? void 0 : _c.coding) == null ? void 0 : _d[0]);
|
|
21622
|
+
const parseContext = options && "context" in options ? options.context : void 0;
|
|
21623
|
+
const unitSemantics = getDoseUnitSemantics((_f = clause.dose) == null ? void 0 : _f.unit, parseContext);
|
|
20771
21624
|
return {
|
|
20772
|
-
route: (
|
|
20773
|
-
unit: (
|
|
20774
|
-
|
|
20775
|
-
|
|
21625
|
+
route: (_g = clause.route) == null ? void 0 : _g.code,
|
|
21626
|
+
unit: (_h = clause.dose) == null ? void 0 : _h.unit,
|
|
21627
|
+
unitKind: unitSemantics == null ? void 0 : unitSemantics.kind,
|
|
21628
|
+
unitSemantics,
|
|
21629
|
+
site: ((_i = clause.site) == null ? void 0 : _i.text) || ((_k = (_j = clause.site) == null ? void 0 : _j.coding) == null ? void 0 : _k.code) || ((_l = clause.site) == null ? void 0 : _l.spatialRelation) ? {
|
|
21630
|
+
text: (_m = clause.site) == null ? void 0 : _m.text,
|
|
20776
21631
|
coding: siteCoding,
|
|
20777
|
-
spatialRelation: cloneBodySiteSpatialRelation((
|
|
21632
|
+
spatialRelation: cloneBodySiteSpatialRelation((_n = clause.site) == null ? void 0 : _n.spatialRelation)
|
|
20778
21633
|
} : void 0,
|
|
20779
|
-
method: ((
|
|
20780
|
-
text: (
|
|
20781
|
-
coding: cloneCoding2((
|
|
21634
|
+
method: ((_o = clause.method) == null ? void 0 : _o.text) || ((_q = (_p = clause.method) == null ? void 0 : _p.coding) == null ? void 0 : _q.code) ? {
|
|
21635
|
+
text: (_r = clause.method) == null ? void 0 : _r.text,
|
|
21636
|
+
coding: cloneCoding2((_s = clause.method) == null ? void 0 : _s.coding)
|
|
20782
21637
|
} : void 0,
|
|
20783
21638
|
patientInstruction: clause.patientInstruction,
|
|
20784
|
-
prnReason: ((
|
|
20785
|
-
text: (
|
|
20786
|
-
coding: cloneCoding2((
|
|
20787
|
-
spatialRelation: cloneBodySiteSpatialRelation((
|
|
21639
|
+
prnReason: ((_u = (_t = clause.prn) == null ? void 0 : _t.reason) == null ? void 0 : _u.text) || ((_x = (_w = (_v = clause.prn) == null ? void 0 : _v.reason) == null ? void 0 : _w.coding) == null ? void 0 : _x.code) ? {
|
|
21640
|
+
text: (_z = (_y = clause.prn) == null ? void 0 : _y.reason) == null ? void 0 : _z.text,
|
|
21641
|
+
coding: cloneCoding2((_B = (_A = clause.prn) == null ? void 0 : _A.reason) == null ? void 0 : _B.coding),
|
|
21642
|
+
spatialRelation: cloneBodySiteSpatialRelation((_D = (_C = clause.prn) == null ? void 0 : _C.reason) == null ? void 0 : _D.spatialRelation)
|
|
20788
21643
|
} : void 0,
|
|
20789
|
-
prnReasons: ((
|
|
21644
|
+
prnReasons: ((_F = (_E = clause.prn) == null ? void 0 : _E.reasons) == null ? void 0 : _F.length) ? clause.prn.reasons.map((reason) => ({
|
|
20790
21645
|
text: reason.text,
|
|
20791
21646
|
coding: cloneCoding2(reason.coding),
|
|
20792
21647
|
spatialRelation: cloneBodySiteSpatialRelation(reason.spatialRelation)
|
|
@@ -20856,7 +21711,7 @@ function buildParseResult(state, options) {
|
|
|
20856
21711
|
meta: {
|
|
20857
21712
|
consumedTokens,
|
|
20858
21713
|
leftoverText: leftoverParts.length ? leftoverParts.join(" ") : void 0,
|
|
20859
|
-
normalized: buildNormalizedMetaFromClause(clause, fhir),
|
|
21714
|
+
normalized: buildNormalizedMetaFromClause(clause, fhir, options),
|
|
20860
21715
|
canonical: {
|
|
20861
21716
|
clauses: canonicalClauses
|
|
20862
21717
|
},
|
|
@@ -20936,10 +21791,10 @@ function resolvePrimaryParseResult(results, input, options) {
|
|
|
20936
21791
|
return buildParseResult(state, options);
|
|
20937
21792
|
}
|
|
20938
21793
|
function buildSemanticLintIssues(result, input, fallbackRange) {
|
|
20939
|
-
var
|
|
21794
|
+
var _a2;
|
|
20940
21795
|
const issues = [];
|
|
20941
21796
|
const clause = result.meta.canonical.clauses[0];
|
|
20942
|
-
const range = (
|
|
21797
|
+
const range = (_a2 = clause == null ? void 0 : clause.span) != null ? _a2 : fallbackRange;
|
|
20943
21798
|
const text = range ? input.slice(range.start, range.end) : input;
|
|
20944
21799
|
const trimmedText = text.trim() || text;
|
|
20945
21800
|
const tokens = trimmedText ? trimmedText.split(/\s+/).filter((part) => part.length > 0) : [];
|
|
@@ -21025,11 +21880,15 @@ function resolvePrimaryLintResult(results, input, options) {
|
|
|
21025
21880
|
getBodySiteCodeAsync,
|
|
21026
21881
|
getBodySiteText,
|
|
21027
21882
|
getBodySiteTextAsync,
|
|
21883
|
+
getDoseUnitApproximation,
|
|
21884
|
+
getDoseUnitKind,
|
|
21885
|
+
getDoseUnitSemantics,
|
|
21028
21886
|
getRegisteredSigLocalizations,
|
|
21029
21887
|
hasSnomedBodySiteLateralityPostcoordination,
|
|
21030
21888
|
hasSnomedFindingSitePostcoordination,
|
|
21031
21889
|
hasSnomedTopographicalModifierPostcoordination,
|
|
21032
21890
|
lintSig,
|
|
21891
|
+
listDoseUnitTerminology,
|
|
21033
21892
|
listSupportedBodySiteGrammar,
|
|
21034
21893
|
listSupportedBodySiteText,
|
|
21035
21894
|
lookupBodySite,
|