ezmedicationinput 0.1.36 → 0.1.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/i18n.js +17 -0
- package/dist/schedule.js +78 -0
- package/package.json +1 -1
package/dist/i18n.js
CHANGED
|
@@ -551,8 +551,25 @@ function combineFrequencyAndEventsThai(frequency, events) {
|
|
|
551
551
|
}
|
|
552
552
|
return { frequency, event: joinWithAndThai(events) };
|
|
553
553
|
}
|
|
554
|
+
function isOralRouteThai(internal) {
|
|
555
|
+
var _a;
|
|
556
|
+
if (internal.routeCode === types_1.RouteCode["Oral route"]) {
|
|
557
|
+
return true;
|
|
558
|
+
}
|
|
559
|
+
const text = (_a = internal.routeText) === null || _a === void 0 ? void 0 : _a.trim().toLowerCase();
|
|
560
|
+
if (!text) {
|
|
561
|
+
return false;
|
|
562
|
+
}
|
|
563
|
+
return (text === "po" ||
|
|
564
|
+
text === "oral" ||
|
|
565
|
+
text.includes("mouth") ||
|
|
566
|
+
text.includes("per os"));
|
|
567
|
+
}
|
|
554
568
|
function buildRoutePhraseThai(internal, grammar, hasSite) {
|
|
555
569
|
var _a;
|
|
570
|
+
if (grammar.verb === "รับประทาน" && isOralRouteThai(internal)) {
|
|
571
|
+
return undefined;
|
|
572
|
+
}
|
|
556
573
|
if (typeof grammar.routePhrase === "function") {
|
|
557
574
|
return grammar.routePhrase({ hasSite, internal });
|
|
558
575
|
}
|
package/dist/schedule.js
CHANGED
|
@@ -419,6 +419,69 @@ function expandWhenCodes(whenCodes, config, repeat) {
|
|
|
419
419
|
return a.time.localeCompare(b.time);
|
|
420
420
|
});
|
|
421
421
|
}
|
|
422
|
+
const DEFAULT_WHEN_FALLBACK_CLOCKS = {
|
|
423
|
+
[types_1.EventTiming.Wake]: ["06:00:00"],
|
|
424
|
+
[types_1.EventTiming["Early Morning"]]: ["06:00:00"],
|
|
425
|
+
[types_1.EventTiming.Morning]: ["08:00:00"],
|
|
426
|
+
[types_1.EventTiming["Late Morning"]]: ["10:00:00"],
|
|
427
|
+
[types_1.EventTiming.Breakfast]: ["08:00:00"],
|
|
428
|
+
[types_1.EventTiming["Before Breakfast"]]: ["07:30:00"],
|
|
429
|
+
[types_1.EventTiming["After Breakfast"]]: ["08:30:00"],
|
|
430
|
+
[types_1.EventTiming.Noon]: ["12:00:00"],
|
|
431
|
+
[types_1.EventTiming.Lunch]: ["12:30:00"],
|
|
432
|
+
[types_1.EventTiming["Before Lunch"]]: ["12:00:00"],
|
|
433
|
+
[types_1.EventTiming["After Lunch"]]: ["13:00:00"],
|
|
434
|
+
[types_1.EventTiming["Early Afternoon"]]: ["14:00:00"],
|
|
435
|
+
[types_1.EventTiming.Afternoon]: ["15:00:00"],
|
|
436
|
+
[types_1.EventTiming["Late Afternoon"]]: ["16:00:00"],
|
|
437
|
+
[types_1.EventTiming["Early Evening"]]: ["18:00:00"],
|
|
438
|
+
[types_1.EventTiming.Evening]: ["19:00:00"],
|
|
439
|
+
[types_1.EventTiming["Late Evening"]]: ["20:00:00"],
|
|
440
|
+
[types_1.EventTiming.Dinner]: ["18:30:00"],
|
|
441
|
+
[types_1.EventTiming["Before Dinner"]]: ["18:00:00"],
|
|
442
|
+
[types_1.EventTiming["After Dinner"]]: ["19:00:00"],
|
|
443
|
+
[types_1.EventTiming.Night]: ["21:00:00"],
|
|
444
|
+
[types_1.EventTiming["Before Sleep"]]: ["22:00:00"],
|
|
445
|
+
[types_1.EventTiming["After Sleep"]]: ["06:30:00"],
|
|
446
|
+
[types_1.EventTiming.Meal]: ["08:00:00", "12:30:00", "18:30:00"],
|
|
447
|
+
[types_1.EventTiming["Before Meal"]]: ["07:30:00", "12:00:00", "18:00:00"],
|
|
448
|
+
[types_1.EventTiming["After Meal"]]: ["08:30:00", "13:00:00", "19:00:00"]
|
|
449
|
+
};
|
|
450
|
+
function inferWhenFallbackEntries(whenCodes, repeat) {
|
|
451
|
+
const entries = [];
|
|
452
|
+
const seen = new Set();
|
|
453
|
+
const addClock = (clock) => {
|
|
454
|
+
var _a;
|
|
455
|
+
const normalized = normalizeClock(clock);
|
|
456
|
+
const adjusted = repeat.offset
|
|
457
|
+
? applyOffset(normalized, (_a = repeat.offset) !== null && _a !== void 0 ? _a : 0)
|
|
458
|
+
: { time: normalized, dayShift: 0 };
|
|
459
|
+
const key = `${adjusted.dayShift}|${adjusted.time}`;
|
|
460
|
+
if (seen.has(key)) {
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
463
|
+
seen.add(key);
|
|
464
|
+
entries.push(adjusted);
|
|
465
|
+
};
|
|
466
|
+
for (const code of whenCodes) {
|
|
467
|
+
if (code === types_1.EventTiming.Immediate) {
|
|
468
|
+
continue;
|
|
469
|
+
}
|
|
470
|
+
const fallbackClocks = DEFAULT_WHEN_FALLBACK_CLOCKS[code];
|
|
471
|
+
if (!fallbackClocks) {
|
|
472
|
+
continue;
|
|
473
|
+
}
|
|
474
|
+
for (const clock of fallbackClocks) {
|
|
475
|
+
addClock(clock);
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
return entries.sort((a, b) => {
|
|
479
|
+
if (a.dayShift !== b.dayShift) {
|
|
480
|
+
return a.dayShift - b.dayShift;
|
|
481
|
+
}
|
|
482
|
+
return a.time.localeCompare(b.time);
|
|
483
|
+
});
|
|
484
|
+
}
|
|
422
485
|
function mergeFrequencyDefaults(base, override) {
|
|
423
486
|
var _a, _b, _c, _d;
|
|
424
487
|
if (!base && !override) {
|
|
@@ -571,6 +634,11 @@ function nextDueDoses(dosage, options) {
|
|
|
571
634
|
return a.time.localeCompare(b.time);
|
|
572
635
|
});
|
|
573
636
|
}
|
|
637
|
+
if (expanded.length === 0 &&
|
|
638
|
+
timeOfDayEntries.length === 0 &&
|
|
639
|
+
(!repeat.frequency || !repeat.period || !repeat.periodUnit)) {
|
|
640
|
+
expanded.push(...inferWhenFallbackEntries(whenCodes, repeat));
|
|
641
|
+
}
|
|
574
642
|
const includesImmediate = (0, array_1.arrayIncludes)(whenCodes, types_1.EventTiming.Immediate);
|
|
575
643
|
if (includesImmediate) {
|
|
576
644
|
const immediateSource = orderedAt !== null && orderedAt !== void 0 ? orderedAt : from;
|
|
@@ -731,6 +799,11 @@ function derivePriorCountFromHistory(timing, repeat, config, orderedAt, from, ti
|
|
|
731
799
|
return a.time.localeCompare(b.time);
|
|
732
800
|
});
|
|
733
801
|
}
|
|
802
|
+
if (expanded.length === 0 &&
|
|
803
|
+
timeOfDayEntries.length === 0 &&
|
|
804
|
+
(!repeat.frequency || !repeat.period || !repeat.periodUnit)) {
|
|
805
|
+
expanded.push(...inferWhenFallbackEntries(whenCodes, repeat));
|
|
806
|
+
}
|
|
734
807
|
if ((0, array_1.arrayIncludes)(whenCodes, types_1.EventTiming.Immediate)) {
|
|
735
808
|
if (recordCandidate(orderedAt) && normalizedCount !== undefined && seen.size >= normalizedCount) {
|
|
736
809
|
return count;
|
|
@@ -981,6 +1054,11 @@ function countScheduleEvents(dosage, from, to, config, baseTime, orderedAt, limi
|
|
|
981
1054
|
return a.time.localeCompare(b.time);
|
|
982
1055
|
});
|
|
983
1056
|
}
|
|
1057
|
+
if (expanded.length === 0 &&
|
|
1058
|
+
timeOfDayEntries.length === 0 &&
|
|
1059
|
+
(!repeat.frequency || !repeat.period || !repeat.periodUnit)) {
|
|
1060
|
+
expanded.push(...inferWhenFallbackEntries(whenCodes, repeat));
|
|
1061
|
+
}
|
|
984
1062
|
if ((0, array_1.arrayIncludes)(whenCodes, types_1.EventTiming.Immediate)) {
|
|
985
1063
|
const immediateSource = orderedAt !== null && orderedAt !== void 0 ? orderedAt : from;
|
|
986
1064
|
if (!orderedAt || orderedAt >= from) {
|