@d4l/collect-lib 1.51.0 → 1.52.0
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/chunk-DDAAVRWG.js +25 -0
- package/dist/chunk-DDAAVRWG.js.map +1 -0
- package/dist/chunk-FJBZBVPE.mjs +25 -0
- package/dist/chunk-FJBZBVPE.mjs.map +1 -0
- package/dist/enable-when-expression-L1gQM0rv.d.mts +76 -0
- package/dist/enable-when-expression-L1gQM0rv.d.ts +76 -0
- package/dist/fhirpath.d.mts +24 -0
- package/dist/fhirpath.d.ts +24 -0
- package/dist/fhirpath.js +16 -0
- package/dist/fhirpath.js.map +1 -0
- package/dist/fhirpath.mjs +16 -0
- package/dist/fhirpath.mjs.map +1 -0
- package/dist/index.d.mts +134 -1
- package/dist/index.d.ts +134 -1
- package/dist/index.js +878 -44
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +887 -53
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -1
package/dist/index.mjs
CHANGED
|
@@ -1,22 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
1
|
+
import {
|
|
2
|
+
__spreadProps,
|
|
3
|
+
__spreadValues
|
|
4
|
+
} from "./chunk-FJBZBVPE.mjs";
|
|
20
5
|
|
|
21
6
|
// src/devices/annotations/internal.ts
|
|
22
7
|
var InternalSensorAnnotationTypes = {
|
|
@@ -231,7 +216,7 @@ var DEVICE_ANNOTATION_ITEM_HRV_RMSSD = {
|
|
|
231
216
|
var DEVICE_ANNOTATION_HRV_RMSSD = [DEVICE_ANNOTATION_ITEM_HRV_RMSSD];
|
|
232
217
|
|
|
233
218
|
// src/devices/annotations/dataSource.ts
|
|
234
|
-
import { Buffer
|
|
219
|
+
import { Buffer } from "buffer/";
|
|
235
220
|
var DATA_SOURCE_BYTE_SIZE = 16;
|
|
236
221
|
var APPLE_HEALTH_DATA_SOURCES = ["apple-watch", "iphone", "unknown"];
|
|
237
222
|
var HEALTH_CONNECT_DATA_SOURCES = [
|
|
@@ -241,7 +226,7 @@ var HEALTH_CONNECT_DATA_SOURCES = [
|
|
|
241
226
|
"unknown"
|
|
242
227
|
];
|
|
243
228
|
function encodeDataSource(value, size = DATA_SOURCE_BYTE_SIZE) {
|
|
244
|
-
const buffer =
|
|
229
|
+
const buffer = Buffer.alloc(size);
|
|
245
230
|
buffer.write(value, 0, size, "ascii");
|
|
246
231
|
return buffer;
|
|
247
232
|
}
|
|
@@ -951,13 +936,13 @@ var GARMIN_ACTIVITY_ANNOTATION = [
|
|
|
951
936
|
];
|
|
952
937
|
var GARMIN_SIGNAL_TYPE_ANNOTATIONS = {
|
|
953
938
|
heartRate: FITBIT_HEART_RATE_ANNOTATION,
|
|
954
|
-
hrv:
|
|
939
|
+
hrv: DEVICE_ANNOTATION_HRV_RMSSD,
|
|
955
940
|
spo2: FITBIT_SPO2_ANNOTATION,
|
|
956
941
|
sleep: FITBIT_SLEEP_ANNOTATION,
|
|
957
942
|
steps: FITBIT_STEPS_ANNOTATION,
|
|
958
943
|
calories: FITBIT_CALORIES_ANNOTATION,
|
|
959
944
|
respiratoryRate: FITBIT_BREATHING_RATE_ANNOTATION,
|
|
960
|
-
skinTemperature:
|
|
945
|
+
skinTemperature: DEVICE_ANNOTATION_SKIN_TEMPERATURE_DEVIATION,
|
|
961
946
|
stress: OURA_STRESS_ANNOTATION,
|
|
962
947
|
menstrualCycle: MENSTRUAL_CYCLE_ANNOTATION,
|
|
963
948
|
// Daily floors climbed: cumulative day total from /dailies (same float32 encoding
|
|
@@ -1356,7 +1341,7 @@ function isFlatAnswer(answer) {
|
|
|
1356
1341
|
}
|
|
1357
1342
|
|
|
1358
1343
|
// src/fhir/consent.ts
|
|
1359
|
-
import { Buffer as
|
|
1344
|
+
import { Buffer as Buffer2 } from "buffer/";
|
|
1360
1345
|
|
|
1361
1346
|
// src/fhir/constants.ts
|
|
1362
1347
|
var SliderMinLabelExtension = "http://fhir.data4life.care/StructureDefinition/slider-label-min";
|
|
@@ -1381,6 +1366,13 @@ var QuestionnaireItemInputExtension = "http://fhir.data4life.care/StructureDefin
|
|
|
1381
1366
|
var TopicInputTopicUrl = "topic";
|
|
1382
1367
|
var TopicInputScopeUrl = "scope";
|
|
1383
1368
|
var TopicSystem = "http://fhir.data4life.care/topic";
|
|
1369
|
+
var QuestionnaireItemVariableExtension = "http://fhir.data4life.care/StructureDefinition/questionnaire-item-variable";
|
|
1370
|
+
var ItemVariableNameUrl = "name";
|
|
1371
|
+
var ItemVariableTopicUrl = "topic";
|
|
1372
|
+
var ItemVariableQuestionUrl = "question";
|
|
1373
|
+
var ItemVariableScopeUrl = "scope";
|
|
1374
|
+
var EnableWhenExpressionExtension = "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-enableWhenExpression";
|
|
1375
|
+
var FhirPathLanguage = "text/fhirpath";
|
|
1384
1376
|
var SignalIDSystem = "http://fhir.data4life.care/r5/NamingSystem/app-signal-ids";
|
|
1385
1377
|
var AppIDNamingSystem = "http://fhir.data4life.care/r5/NamingSystem/app-db-ids";
|
|
1386
1378
|
var SensorTypeSystem = "http://fhir.data4life.care/r5/NamingSystem/sensor-device-type";
|
|
@@ -1455,7 +1447,7 @@ function generateFHIRConsent(id, consent, decision, start, end) {
|
|
|
1455
1447
|
contentType: "text/plain",
|
|
1456
1448
|
language: lng,
|
|
1457
1449
|
title: consent.title[lng],
|
|
1458
|
-
data:
|
|
1450
|
+
data: Buffer2.from(consent.text[lng]).toString("base64")
|
|
1459
1451
|
})),
|
|
1460
1452
|
decision
|
|
1461
1453
|
};
|
|
@@ -1469,6 +1461,827 @@ var isValidTopicCanonical = (canonical) => isValidTopicId(topicIdFromCanonical(c
|
|
|
1469
1461
|
var TOPIC_SCOPE_CODES = ["session", "latest", "all"];
|
|
1470
1462
|
var isValidTopicScope = (code) => TOPIC_SCOPE_CODES.includes(code);
|
|
1471
1463
|
|
|
1464
|
+
// src/fhir/enable-when-expression.ts
|
|
1465
|
+
var SUPPORTED_FHIRPATH_OPERATORS = [
|
|
1466
|
+
"and",
|
|
1467
|
+
"or",
|
|
1468
|
+
"contains",
|
|
1469
|
+
"=",
|
|
1470
|
+
"!=",
|
|
1471
|
+
">",
|
|
1472
|
+
"<",
|
|
1473
|
+
">=",
|
|
1474
|
+
"<=",
|
|
1475
|
+
"|"
|
|
1476
|
+
];
|
|
1477
|
+
var SUPPORTED_FHIRPATH_FUNCTIONS = [
|
|
1478
|
+
"exists",
|
|
1479
|
+
"empty",
|
|
1480
|
+
"not",
|
|
1481
|
+
"first",
|
|
1482
|
+
"today",
|
|
1483
|
+
"now",
|
|
1484
|
+
"toDate",
|
|
1485
|
+
"toInteger",
|
|
1486
|
+
"toDecimal"
|
|
1487
|
+
];
|
|
1488
|
+
var SUPPORTED_FHIRPATH_DATE_UNITS = ["years", "months", "weeks", "days"];
|
|
1489
|
+
var referencedVariables = (expression) => {
|
|
1490
|
+
const names = /* @__PURE__ */ new Set();
|
|
1491
|
+
const re = /%([A-Za-z_][A-Za-z0-9_]*)/g;
|
|
1492
|
+
let match;
|
|
1493
|
+
while ((match = re.exec(expression)) !== null) {
|
|
1494
|
+
names.add(match[1]);
|
|
1495
|
+
}
|
|
1496
|
+
return Array.from(names);
|
|
1497
|
+
};
|
|
1498
|
+
var STRING_LITERAL = /'(?:\\.|[^'\\])*'/g;
|
|
1499
|
+
var DATE_LITERAL = /@\d{4}(?:-\d{2}(?:-\d{2})?)?/g;
|
|
1500
|
+
var NUMBER_LITERAL = /\b\d+(?:\.\d+)?\b/g;
|
|
1501
|
+
var VARIABLE = /%[A-Za-z_][A-Za-z0-9_]*/g;
|
|
1502
|
+
var FUNCTION_CALL = /([A-Za-z_][A-Za-z0-9_]*)\s*\(/g;
|
|
1503
|
+
var BARE_WORD = /[A-Za-z_][A-Za-z0-9_]*/g;
|
|
1504
|
+
var ALLOWED_SYMBOLS = /^[\s().=!<>|+\-]*$/;
|
|
1505
|
+
var RAW_VARIABLE_VS_NUMBER = /%[A-Za-z_][A-Za-z0-9_]*(?:\.first\(\))?\s*(?:=|!=|<=|>=|<|>)\s*\d|\d\s*(?:=|!=|<=|>=|<|>)\s*%[A-Za-z_][A-Za-z0-9_]*(?:\.first\(\))?(?![.\w])/;
|
|
1506
|
+
var RAW_VARIABLE_DATE_ARITHMETIC = /%[A-Za-z_][A-Za-z0-9_]*(?:\.first\(\))?\s*[+-]\s*\d+\s*(?:years|months|weeks|days)\b/;
|
|
1507
|
+
var WORD_OPERATORS = /* @__PURE__ */ new Set(["and", "or", "contains"]);
|
|
1508
|
+
var DATE_UNITS = new Set(SUPPORTED_FHIRPATH_DATE_UNITS);
|
|
1509
|
+
var FUNCTIONS = new Set(SUPPORTED_FHIRPATH_FUNCTIONS);
|
|
1510
|
+
var BOOLEAN_LITERALS = /* @__PURE__ */ new Set(["true", "false"]);
|
|
1511
|
+
var findSubsetViolations = (expression) => {
|
|
1512
|
+
const violations = [];
|
|
1513
|
+
const withoutStrings = expression.replace(STRING_LITERAL, " ");
|
|
1514
|
+
if (RAW_VARIABLE_VS_NUMBER.test(withoutStrings)) {
|
|
1515
|
+
violations.push(
|
|
1516
|
+
"a variable must be converted with toInteger()/toDecimal() before comparing it to a number"
|
|
1517
|
+
);
|
|
1518
|
+
}
|
|
1519
|
+
if (RAW_VARIABLE_DATE_ARITHMETIC.test(withoutStrings)) {
|
|
1520
|
+
violations.push("a variable must be converted with toDate() before date arithmetic");
|
|
1521
|
+
}
|
|
1522
|
+
let rest = withoutStrings.replace(DATE_LITERAL, " ").replace(VARIABLE, " ");
|
|
1523
|
+
rest = rest.replace(FUNCTION_CALL, (call, name) => {
|
|
1524
|
+
if (WORD_OPERATORS.has(name)) {
|
|
1525
|
+
return call;
|
|
1526
|
+
}
|
|
1527
|
+
if (!FUNCTIONS.has(name)) {
|
|
1528
|
+
violations.push(`unsupported function: ${name}()`);
|
|
1529
|
+
}
|
|
1530
|
+
return " (";
|
|
1531
|
+
});
|
|
1532
|
+
rest = rest.replace(BARE_WORD, (word) => {
|
|
1533
|
+
if (!WORD_OPERATORS.has(word) && !DATE_UNITS.has(word) && !BOOLEAN_LITERALS.has(word)) {
|
|
1534
|
+
violations.push(`unsupported token: ${word}`);
|
|
1535
|
+
}
|
|
1536
|
+
return " ";
|
|
1537
|
+
});
|
|
1538
|
+
rest = rest.replace(NUMBER_LITERAL, " ");
|
|
1539
|
+
if (!ALLOWED_SYMBOLS.test(rest)) {
|
|
1540
|
+
const offending = Array.from(new Set(rest.replace(/[\s().=!<>|+\-]/g, "").split("")));
|
|
1541
|
+
violations.push(`unsupported character(s): ${offending.join(" ")}`);
|
|
1542
|
+
}
|
|
1543
|
+
return violations;
|
|
1544
|
+
};
|
|
1545
|
+
var ENABLE_WHEN_CONFORMANCE_CASES = [
|
|
1546
|
+
// existence
|
|
1547
|
+
{
|
|
1548
|
+
description: "exists: topic has a value -> shown",
|
|
1549
|
+
expression: "%gender.exists()",
|
|
1550
|
+
variables: { gender: ["female"] },
|
|
1551
|
+
now: "2026-08-31",
|
|
1552
|
+
expected: true
|
|
1553
|
+
},
|
|
1554
|
+
{
|
|
1555
|
+
description: "exists: topic empty -> hidden",
|
|
1556
|
+
expression: "%gender.exists()",
|
|
1557
|
+
variables: { gender: [] },
|
|
1558
|
+
now: "2026-08-31",
|
|
1559
|
+
expected: false
|
|
1560
|
+
},
|
|
1561
|
+
{
|
|
1562
|
+
description: "is not answered: topic empty -> shown",
|
|
1563
|
+
expression: "%gender.empty()",
|
|
1564
|
+
variables: { gender: [] },
|
|
1565
|
+
now: "2026-08-31",
|
|
1566
|
+
expected: true
|
|
1567
|
+
},
|
|
1568
|
+
{
|
|
1569
|
+
description: "is not answered: topic has a value -> hidden",
|
|
1570
|
+
expression: "%gender.empty()",
|
|
1571
|
+
variables: { gender: ["female"] },
|
|
1572
|
+
now: "2026-08-31",
|
|
1573
|
+
expected: false
|
|
1574
|
+
},
|
|
1575
|
+
// coding equality is membership: any held value matches.
|
|
1576
|
+
{
|
|
1577
|
+
description: "coding equals: single value matches -> shown",
|
|
1578
|
+
expression: "%gender contains 'female'",
|
|
1579
|
+
variables: { gender: ["female"] },
|
|
1580
|
+
now: "2026-08-31",
|
|
1581
|
+
expected: true
|
|
1582
|
+
},
|
|
1583
|
+
{
|
|
1584
|
+
description: "coding equals: multi-value topic (scope all / multi_select) holds the code -> shown",
|
|
1585
|
+
expression: "%gender contains 'male'",
|
|
1586
|
+
variables: { gender: ["female", "male"] },
|
|
1587
|
+
now: "2026-08-31",
|
|
1588
|
+
expected: true
|
|
1589
|
+
},
|
|
1590
|
+
{
|
|
1591
|
+
description: "coding equals: empty -> hidden",
|
|
1592
|
+
expression: "%gender contains 'female'",
|
|
1593
|
+
variables: { gender: [] },
|
|
1594
|
+
now: "2026-08-31",
|
|
1595
|
+
expected: false
|
|
1596
|
+
},
|
|
1597
|
+
{
|
|
1598
|
+
description: "coding not equals: known and not male -> shown",
|
|
1599
|
+
expression: "%gender.exists() and (%gender contains 'male').not()",
|
|
1600
|
+
variables: { gender: ["female"] },
|
|
1601
|
+
now: "2026-08-31",
|
|
1602
|
+
expected: true
|
|
1603
|
+
},
|
|
1604
|
+
{
|
|
1605
|
+
description: "coding not equals: multi-value topic holding male -> hidden",
|
|
1606
|
+
expression: "%gender.exists() and (%gender contains 'male').not()",
|
|
1607
|
+
variables: { gender: ["female", "male"] },
|
|
1608
|
+
now: "2026-08-31",
|
|
1609
|
+
expected: false
|
|
1610
|
+
},
|
|
1611
|
+
{
|
|
1612
|
+
description: "coding not equals: unknown (empty) -> hidden until known",
|
|
1613
|
+
expression: "%gender.exists() and (%gender contains 'male').not()",
|
|
1614
|
+
variables: { gender: [] },
|
|
1615
|
+
now: "2026-08-31",
|
|
1616
|
+
expected: false
|
|
1617
|
+
},
|
|
1618
|
+
{
|
|
1619
|
+
description: "one of: gender is one of {female, diverse} -> shown",
|
|
1620
|
+
expression: "%gender contains 'female' or %gender contains 'diverse'",
|
|
1621
|
+
variables: { gender: ["diverse"] },
|
|
1622
|
+
now: "2026-08-31",
|
|
1623
|
+
expected: true
|
|
1624
|
+
},
|
|
1625
|
+
{
|
|
1626
|
+
description: "one of: gender not in the set -> hidden",
|
|
1627
|
+
expression: "%gender contains 'female' or %gender contains 'diverse'",
|
|
1628
|
+
variables: { gender: ["male"] },
|
|
1629
|
+
now: "2026-08-31",
|
|
1630
|
+
expected: false
|
|
1631
|
+
},
|
|
1632
|
+
// free-text equality on the first value (with escaped quote).
|
|
1633
|
+
{
|
|
1634
|
+
description: "string equals: first value matches (escaped quote) -> shown",
|
|
1635
|
+
expression: "%city.first() = 'L\\'Aquila'",
|
|
1636
|
+
variables: { city: ["L'Aquila"] },
|
|
1637
|
+
now: "2026-08-31",
|
|
1638
|
+
expected: true
|
|
1639
|
+
},
|
|
1640
|
+
{
|
|
1641
|
+
description: "string not equals: unknown -> hidden",
|
|
1642
|
+
expression: "%city.exists() and %city.first() != 'Berlin'",
|
|
1643
|
+
variables: { city: [] },
|
|
1644
|
+
now: "2026-08-31",
|
|
1645
|
+
expected: false
|
|
1646
|
+
},
|
|
1647
|
+
// numeric comparisons need an explicit conversion (values are strings).
|
|
1648
|
+
{
|
|
1649
|
+
description: "integer greater than: 7 > 5 -> shown",
|
|
1650
|
+
expression: "%score.first().toInteger() > 5",
|
|
1651
|
+
variables: { score: ["7"] },
|
|
1652
|
+
now: "2026-08-31",
|
|
1653
|
+
expected: true
|
|
1654
|
+
},
|
|
1655
|
+
{
|
|
1656
|
+
description: "integer at most: 5 <= 5 -> shown",
|
|
1657
|
+
expression: "%score.first().toInteger() <= 5",
|
|
1658
|
+
variables: { score: ["5"] },
|
|
1659
|
+
now: "2026-08-31",
|
|
1660
|
+
expected: true
|
|
1661
|
+
},
|
|
1662
|
+
{
|
|
1663
|
+
description: "integer equals: empty -> hidden",
|
|
1664
|
+
expression: "%score.first().toInteger() = 5",
|
|
1665
|
+
variables: { score: [] },
|
|
1666
|
+
now: "2026-08-31",
|
|
1667
|
+
expected: false
|
|
1668
|
+
},
|
|
1669
|
+
{
|
|
1670
|
+
description: "decimal at least: 7.25 >= 5.5 -> shown",
|
|
1671
|
+
expression: "%weight.first().toDecimal() >= 5.5",
|
|
1672
|
+
variables: { weight: ["7.25"] },
|
|
1673
|
+
now: "2026-08-31",
|
|
1674
|
+
expected: true
|
|
1675
|
+
},
|
|
1676
|
+
{
|
|
1677
|
+
description: "decimal less than: 7.25 < 5.5 -> hidden",
|
|
1678
|
+
expression: "%weight.first().toDecimal() < 5.5",
|
|
1679
|
+
variables: { weight: ["7.25"] },
|
|
1680
|
+
now: "2026-08-31",
|
|
1681
|
+
expected: false
|
|
1682
|
+
},
|
|
1683
|
+
// date compared to a literal date.
|
|
1684
|
+
{
|
|
1685
|
+
description: "date after literal: 2021-05-05 > 2020-01-01 -> shown",
|
|
1686
|
+
expression: "%visit.first().toDate() > @2020-01-01",
|
|
1687
|
+
variables: { visit: ["2021-05-05"] },
|
|
1688
|
+
now: "2026-08-31",
|
|
1689
|
+
expected: true
|
|
1690
|
+
},
|
|
1691
|
+
{
|
|
1692
|
+
description: "year equals literal year -> shown",
|
|
1693
|
+
expression: "%born.first().toDate() = @1990",
|
|
1694
|
+
variables: { born: ["1990"] },
|
|
1695
|
+
now: "2026-08-31",
|
|
1696
|
+
expected: true
|
|
1697
|
+
},
|
|
1698
|
+
// age at least (derived vs today; inclusive: shown on the Nth birthday).
|
|
1699
|
+
{
|
|
1700
|
+
description: "age at least 18: 26 year old -> shown",
|
|
1701
|
+
expression: "%birthDate.exists() and today() >= %birthDate.first().toDate() + 18 years",
|
|
1702
|
+
variables: { birthDate: ["2000-01-01"] },
|
|
1703
|
+
now: "2026-08-31",
|
|
1704
|
+
expected: true
|
|
1705
|
+
},
|
|
1706
|
+
{
|
|
1707
|
+
description: "age at least 18: on the 18th birthday -> shown",
|
|
1708
|
+
expression: "%birthDate.exists() and today() >= %birthDate.first().toDate() + 18 years",
|
|
1709
|
+
variables: { birthDate: ["2008-08-31"] },
|
|
1710
|
+
now: "2026-08-31",
|
|
1711
|
+
expected: true
|
|
1712
|
+
},
|
|
1713
|
+
{
|
|
1714
|
+
description: "age at least 18: the day before the 18th birthday -> hidden",
|
|
1715
|
+
expression: "%birthDate.exists() and today() >= %birthDate.first().toDate() + 18 years",
|
|
1716
|
+
variables: { birthDate: ["2008-09-01"] },
|
|
1717
|
+
now: "2026-08-31",
|
|
1718
|
+
expected: false
|
|
1719
|
+
},
|
|
1720
|
+
{
|
|
1721
|
+
description: "age at least 18: 11 year old -> hidden",
|
|
1722
|
+
expression: "%birthDate.exists() and today() >= %birthDate.first().toDate() + 18 years",
|
|
1723
|
+
variables: { birthDate: ["2015-01-01"] },
|
|
1724
|
+
now: "2026-08-31",
|
|
1725
|
+
expected: false
|
|
1726
|
+
},
|
|
1727
|
+
{
|
|
1728
|
+
description: "age at least 18: unknown birth date -> hidden",
|
|
1729
|
+
expression: "%birthDate.exists() and today() >= %birthDate.first().toDate() + 18 years",
|
|
1730
|
+
variables: { birthDate: [] },
|
|
1731
|
+
now: "2026-08-31",
|
|
1732
|
+
expected: false
|
|
1733
|
+
},
|
|
1734
|
+
// a year-only source is a year-precision date: decidable outside the boundary year, hidden within it.
|
|
1735
|
+
{
|
|
1736
|
+
description: "age at least 18 from a birth year: 2000 -> shown",
|
|
1737
|
+
expression: "%birthYear.exists() and today() >= %birthYear.first().toDate() + 18 years",
|
|
1738
|
+
variables: { birthYear: ["2000"] },
|
|
1739
|
+
now: "2026-08-31",
|
|
1740
|
+
expected: true
|
|
1741
|
+
},
|
|
1742
|
+
{
|
|
1743
|
+
description: "age at least 18 from a birth year: 2008 in 2026 is undecidable -> hidden",
|
|
1744
|
+
expression: "%birthYear.exists() and today() >= %birthYear.first().toDate() + 18 years",
|
|
1745
|
+
variables: { birthYear: ["2008"] },
|
|
1746
|
+
now: "2026-08-31",
|
|
1747
|
+
expected: false
|
|
1748
|
+
},
|
|
1749
|
+
// elapsed less than N (exclusive), the complement of at-least: "age at most 17" = less than 18 years ago.
|
|
1750
|
+
{
|
|
1751
|
+
description: "less than 18 years ago (age at most 17): 11 year old -> shown",
|
|
1752
|
+
expression: "%birthDate.exists() and today() < %birthDate.first().toDate() + 18 years",
|
|
1753
|
+
variables: { birthDate: ["2015-01-01"] },
|
|
1754
|
+
now: "2026-08-31",
|
|
1755
|
+
expected: true
|
|
1756
|
+
},
|
|
1757
|
+
{
|
|
1758
|
+
description: "less than 18 years ago (age at most 17): on the 18th birthday -> hidden",
|
|
1759
|
+
expression: "%birthDate.exists() and today() < %birthDate.first().toDate() + 18 years",
|
|
1760
|
+
variables: { birthDate: ["2008-08-31"] },
|
|
1761
|
+
now: "2026-08-31",
|
|
1762
|
+
expected: false
|
|
1763
|
+
},
|
|
1764
|
+
// age band: min <= age <= max, inclusive (upper bound uses max + 1 years).
|
|
1765
|
+
{
|
|
1766
|
+
description: "age between 18..65: 36 year old -> shown",
|
|
1767
|
+
expression: "%birthDate.exists() and today() >= %birthDate.first().toDate() + 18 years and today() < %birthDate.first().toDate() + 66 years",
|
|
1768
|
+
variables: { birthDate: ["1990-01-01"] },
|
|
1769
|
+
now: "2026-08-31",
|
|
1770
|
+
expected: true
|
|
1771
|
+
},
|
|
1772
|
+
{
|
|
1773
|
+
description: "age between 18..65: 11 year old -> hidden (below min)",
|
|
1774
|
+
expression: "%birthDate.exists() and today() >= %birthDate.first().toDate() + 18 years and today() < %birthDate.first().toDate() + 66 years",
|
|
1775
|
+
variables: { birthDate: ["2015-01-01"] },
|
|
1776
|
+
now: "2026-08-31",
|
|
1777
|
+
expected: false
|
|
1778
|
+
},
|
|
1779
|
+
{
|
|
1780
|
+
description: "age between 18..65: 70 year old -> hidden (above max)",
|
|
1781
|
+
expression: "%birthDate.exists() and today() >= %birthDate.first().toDate() + 18 years and today() < %birthDate.first().toDate() + 66 years",
|
|
1782
|
+
variables: { birthDate: ["1956-01-01"] },
|
|
1783
|
+
now: "2026-08-31",
|
|
1784
|
+
expected: false
|
|
1785
|
+
},
|
|
1786
|
+
// elapsed time since a date.
|
|
1787
|
+
{
|
|
1788
|
+
description: "at least 31 days ago (more than 30): enrolled 7 months ago -> shown",
|
|
1789
|
+
expression: "%enrolledAt.exists() and today() >= %enrolledAt.first().toDate() + 31 days",
|
|
1790
|
+
variables: { enrolledAt: ["2026-01-01"] },
|
|
1791
|
+
now: "2026-08-31",
|
|
1792
|
+
expected: true
|
|
1793
|
+
},
|
|
1794
|
+
{
|
|
1795
|
+
description: "at least 31 days ago (more than 30): enrolled 11 days ago -> hidden",
|
|
1796
|
+
expression: "%enrolledAt.exists() and today() >= %enrolledAt.first().toDate() + 31 days",
|
|
1797
|
+
variables: { enrolledAt: ["2026-08-20"] },
|
|
1798
|
+
now: "2026-08-31",
|
|
1799
|
+
expected: false
|
|
1800
|
+
},
|
|
1801
|
+
{
|
|
1802
|
+
description: "less than 31 days ago (within the last 30): enrolled 11 days ago -> shown",
|
|
1803
|
+
expression: "%enrolledAt.exists() and today() < %enrolledAt.first().toDate() + 31 days",
|
|
1804
|
+
variables: { enrolledAt: ["2026-08-20"] },
|
|
1805
|
+
now: "2026-08-31",
|
|
1806
|
+
expected: true
|
|
1807
|
+
},
|
|
1808
|
+
{
|
|
1809
|
+
description: "less than 31 days ago (within the last 30): enrolled 7 months ago -> hidden",
|
|
1810
|
+
expression: "%enrolledAt.exists() and today() < %enrolledAt.first().toDate() + 31 days",
|
|
1811
|
+
variables: { enrolledAt: ["2026-01-01"] },
|
|
1812
|
+
now: "2026-08-31",
|
|
1813
|
+
expected: false
|
|
1814
|
+
},
|
|
1815
|
+
{
|
|
1816
|
+
description: "months unit: at least 6 months ago -> shown",
|
|
1817
|
+
expression: "%enrolledAt.exists() and today() >= %enrolledAt.first().toDate() + 6 months",
|
|
1818
|
+
variables: { enrolledAt: ["2026-01-01"] },
|
|
1819
|
+
now: "2026-08-31",
|
|
1820
|
+
expected: true
|
|
1821
|
+
},
|
|
1822
|
+
{
|
|
1823
|
+
description: "weeks unit: less than 2 weeks ago -> hidden when 11 weeks ago",
|
|
1824
|
+
expression: "%enrolledAt.exists() and today() < %enrolledAt.first().toDate() + 2 weeks",
|
|
1825
|
+
variables: { enrolledAt: ["2026-06-15"] },
|
|
1826
|
+
now: "2026-08-31",
|
|
1827
|
+
expected: false
|
|
1828
|
+
},
|
|
1829
|
+
{
|
|
1830
|
+
description: "now(): date is in the past -> shown",
|
|
1831
|
+
expression: "now() > %visit.first().toDate()",
|
|
1832
|
+
variables: { visit: ["2020-01-01"] },
|
|
1833
|
+
now: "2026-08-31",
|
|
1834
|
+
expected: true
|
|
1835
|
+
},
|
|
1836
|
+
// combining conditions: each condition parenthesized, one connector.
|
|
1837
|
+
{
|
|
1838
|
+
description: "all of: local smoker yes and topic gender not male -> shown",
|
|
1839
|
+
expression: "(%smoker contains 'yes') and (%gender.exists() and (%gender contains 'male').not())",
|
|
1840
|
+
variables: { smoker: ["yes"], gender: ["female"] },
|
|
1841
|
+
now: "2026-08-31",
|
|
1842
|
+
expected: true
|
|
1843
|
+
},
|
|
1844
|
+
{
|
|
1845
|
+
description: "all of: local smoker no -> hidden",
|
|
1846
|
+
expression: "(%smoker contains 'yes') and (%gender.exists() and (%gender contains 'male').not())",
|
|
1847
|
+
variables: { smoker: ["no"], gender: ["female"] },
|
|
1848
|
+
now: "2026-08-31",
|
|
1849
|
+
expected: false
|
|
1850
|
+
},
|
|
1851
|
+
{
|
|
1852
|
+
description: "any of: adult or consented -> shown via second condition",
|
|
1853
|
+
expression: "(%birthDate.exists() and today() >= %birthDate.first().toDate() + 18 years) or (%consent contains 'yes')",
|
|
1854
|
+
variables: { birthDate: ["2015-01-01"], consent: ["yes"] },
|
|
1855
|
+
now: "2026-08-31",
|
|
1856
|
+
expected: true
|
|
1857
|
+
},
|
|
1858
|
+
// union: any of several sources holds a value.
|
|
1859
|
+
{
|
|
1860
|
+
description: "union: first source empty, second set -> shown",
|
|
1861
|
+
expression: "(%a | %b).exists()",
|
|
1862
|
+
variables: { a: [], b: ["x"] },
|
|
1863
|
+
now: "2026-08-31",
|
|
1864
|
+
expected: true
|
|
1865
|
+
}
|
|
1866
|
+
];
|
|
1867
|
+
var OUT_OF_SUBSET_EXPRESSIONS = [
|
|
1868
|
+
"%gender.where($this = 'male').exists()",
|
|
1869
|
+
// where() not supported
|
|
1870
|
+
"iif(%gender.exists(), true, false)",
|
|
1871
|
+
// iif() not supported
|
|
1872
|
+
"%gender.count() > 0",
|
|
1873
|
+
// count() not supported
|
|
1874
|
+
"%name.substring(0, 2) = 'ab'",
|
|
1875
|
+
// substring() not supported
|
|
1876
|
+
"%code.matches('^[0-9]+$')",
|
|
1877
|
+
// matches() not supported
|
|
1878
|
+
"%gender in ('male' | 'female')",
|
|
1879
|
+
// `in` not supported, use `contains`
|
|
1880
|
+
"%coding.code = 'male'",
|
|
1881
|
+
// member access not supported: variables are scalar strings
|
|
1882
|
+
"%score > 5",
|
|
1883
|
+
// raw string compared to a number is an evaluation error: needs toInteger()/toDecimal()
|
|
1884
|
+
"%d.toDate() + 18 hours < today()",
|
|
1885
|
+
// sub-day units not supported
|
|
1886
|
+
"%score.first().toInteger() * 2 > 5"
|
|
1887
|
+
// arithmetic other than date +/- not supported
|
|
1888
|
+
];
|
|
1889
|
+
|
|
1890
|
+
// src/fhir/enable-when-conditions.ts
|
|
1891
|
+
var TEMPORAL_PREDICATES = ["elapsedAtLeast", "elapsedLessThan", "elapsedBetween"];
|
|
1892
|
+
var ELAPSED_UNITS_BY_VALUE_TYPE = {
|
|
1893
|
+
date: SUPPORTED_FHIRPATH_DATE_UNITS,
|
|
1894
|
+
year: ["years"]
|
|
1895
|
+
};
|
|
1896
|
+
var COMPARISONS = [
|
|
1897
|
+
"exists",
|
|
1898
|
+
"empty",
|
|
1899
|
+
"eq",
|
|
1900
|
+
"neq",
|
|
1901
|
+
"gt",
|
|
1902
|
+
"lt",
|
|
1903
|
+
"gteq",
|
|
1904
|
+
"lteq"
|
|
1905
|
+
];
|
|
1906
|
+
var ENABLE_WHEN_PREDICATES_BY_VALUE_TYPE = {
|
|
1907
|
+
coding: ["exists", "empty", "eq", "neq", "oneOf"],
|
|
1908
|
+
string: ["exists", "empty", "eq", "neq"],
|
|
1909
|
+
integer: COMPARISONS,
|
|
1910
|
+
decimal: COMPARISONS,
|
|
1911
|
+
date: [...COMPARISONS, ...TEMPORAL_PREDICATES],
|
|
1912
|
+
year: [...COMPARISONS, ...TEMPORAL_PREDICATES]
|
|
1913
|
+
};
|
|
1914
|
+
var requiresExpression = (conditions) => conditions.some(
|
|
1915
|
+
(c) => c.source.kind === "topic" || TEMPORAL_PREDICATES.includes(c.predicate.op) || c.predicate.op === "empty" || c.predicate.op === "oneOf"
|
|
1916
|
+
);
|
|
1917
|
+
var EnableWhenCompileError = class extends Error {
|
|
1918
|
+
constructor(message, conditionIndex) {
|
|
1919
|
+
super(message);
|
|
1920
|
+
this.conditionIndex = conditionIndex;
|
|
1921
|
+
this.name = "EnableWhenCompileError";
|
|
1922
|
+
}
|
|
1923
|
+
};
|
|
1924
|
+
var ISO_DATE = /^\d{4}-\d{2}-\d{2}$/;
|
|
1925
|
+
var ISO_YEAR = /^\d{4}$/;
|
|
1926
|
+
var COMPARISON_SYMBOL = {
|
|
1927
|
+
eq: "=",
|
|
1928
|
+
neq: "!=",
|
|
1929
|
+
gt: ">",
|
|
1930
|
+
lt: "<",
|
|
1931
|
+
gteq: ">=",
|
|
1932
|
+
lteq: "<="
|
|
1933
|
+
};
|
|
1934
|
+
var SYMBOL_COMPARISON = Object.fromEntries(
|
|
1935
|
+
Object.entries(COMPARISON_SYMBOL).map(([op, symbol]) => [symbol, op])
|
|
1936
|
+
);
|
|
1937
|
+
var CONVERSION = {
|
|
1938
|
+
integer: "toInteger",
|
|
1939
|
+
decimal: "toDecimal",
|
|
1940
|
+
date: "toDate",
|
|
1941
|
+
year: "toDate"
|
|
1942
|
+
};
|
|
1943
|
+
var escapeString = (value) => `'${value.replace(/\\/g, "\\\\").replace(/'/g, "\\'")}'`;
|
|
1944
|
+
var unescapeString = (literal) => literal.slice(1, -1).replace(/\\(['\\])/g, "$1");
|
|
1945
|
+
var sourceKey = (source) => source.kind === "question" ? `q:${source.linkId}` : `t:${source.topic}:${source.scope}`;
|
|
1946
|
+
var baseVariableName = (source) => {
|
|
1947
|
+
const raw = source.kind === "question" ? source.linkId : source.topic;
|
|
1948
|
+
const cleaned = raw.replace(/[^A-Za-z0-9_]/g, "_");
|
|
1949
|
+
return /^[A-Za-z_]/.test(cleaned) ? cleaned : `_${cleaned}`;
|
|
1950
|
+
};
|
|
1951
|
+
var assertElapsedUnit = (valueType, unit, index) => {
|
|
1952
|
+
var _a;
|
|
1953
|
+
if (!((_a = ELAPSED_UNITS_BY_VALUE_TYPE[valueType]) == null ? void 0 : _a.includes(unit))) {
|
|
1954
|
+
throw new EnableWhenCompileError(
|
|
1955
|
+
`unit ${unit} is not supported for a ${valueType} source`,
|
|
1956
|
+
index
|
|
1957
|
+
);
|
|
1958
|
+
}
|
|
1959
|
+
};
|
|
1960
|
+
var assertNonNegativeInteger = (n, what, index) => {
|
|
1961
|
+
if (!Number.isInteger(n) || n < 0) {
|
|
1962
|
+
throw new EnableWhenCompileError(`${what} must be a non-negative integer, got ${n}`, index);
|
|
1963
|
+
}
|
|
1964
|
+
};
|
|
1965
|
+
var formatLiteral = (valueType, value, index) => {
|
|
1966
|
+
switch (valueType) {
|
|
1967
|
+
case "coding":
|
|
1968
|
+
case "string":
|
|
1969
|
+
if (typeof value !== "string") {
|
|
1970
|
+
throw new EnableWhenCompileError(`a ${valueType} value must be a string`, index);
|
|
1971
|
+
}
|
|
1972
|
+
return escapeString(value);
|
|
1973
|
+
case "integer":
|
|
1974
|
+
if (typeof value !== "number" || !Number.isInteger(value)) {
|
|
1975
|
+
throw new EnableWhenCompileError("an integer value must be a whole number", index);
|
|
1976
|
+
}
|
|
1977
|
+
return String(value);
|
|
1978
|
+
case "decimal":
|
|
1979
|
+
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
1980
|
+
throw new EnableWhenCompileError("a decimal value must be a finite number", index);
|
|
1981
|
+
}
|
|
1982
|
+
return String(value);
|
|
1983
|
+
case "date":
|
|
1984
|
+
if (typeof value !== "string" || !ISO_DATE.test(value)) {
|
|
1985
|
+
throw new EnableWhenCompileError("a date value must be YYYY-MM-DD", index);
|
|
1986
|
+
}
|
|
1987
|
+
return `@${value}`;
|
|
1988
|
+
case "year":
|
|
1989
|
+
if (typeof value !== "string" || !ISO_YEAR.test(value)) {
|
|
1990
|
+
throw new EnableWhenCompileError("a year value must be YYYY", index);
|
|
1991
|
+
}
|
|
1992
|
+
return `@${value}`;
|
|
1993
|
+
}
|
|
1994
|
+
};
|
|
1995
|
+
var compileCondition = (condition, v, index) => {
|
|
1996
|
+
const { valueType, predicate } = condition;
|
|
1997
|
+
if (!ENABLE_WHEN_PREDICATES_BY_VALUE_TYPE[valueType].includes(predicate.op)) {
|
|
1998
|
+
throw new EnableWhenCompileError(
|
|
1999
|
+
`predicate ${predicate.op} is not supported for a ${valueType} source`,
|
|
2000
|
+
index
|
|
2001
|
+
);
|
|
2002
|
+
}
|
|
2003
|
+
const date = `${v}.first().toDate()`;
|
|
2004
|
+
switch (predicate.op) {
|
|
2005
|
+
case "exists":
|
|
2006
|
+
return `${v}.exists()`;
|
|
2007
|
+
case "empty":
|
|
2008
|
+
return `${v}.empty()`;
|
|
2009
|
+
case "oneOf":
|
|
2010
|
+
if (predicate.values.length === 0) {
|
|
2011
|
+
throw new EnableWhenCompileError("oneOf needs at least one value", index);
|
|
2012
|
+
}
|
|
2013
|
+
return predicate.values.map((value) => `${v} contains ${formatLiteral("coding", value, index)}`).join(" or ");
|
|
2014
|
+
case "elapsedAtLeast":
|
|
2015
|
+
assertElapsedUnit(valueType, predicate.unit, index);
|
|
2016
|
+
assertNonNegativeInteger(predicate.amount, "amount", index);
|
|
2017
|
+
return `${v}.exists() and today() >= ${date} + ${predicate.amount} ${predicate.unit}`;
|
|
2018
|
+
case "elapsedLessThan":
|
|
2019
|
+
assertElapsedUnit(valueType, predicate.unit, index);
|
|
2020
|
+
assertNonNegativeInteger(predicate.amount, "amount", index);
|
|
2021
|
+
return `${v}.exists() and today() < ${date} + ${predicate.amount} ${predicate.unit}`;
|
|
2022
|
+
case "elapsedBetween":
|
|
2023
|
+
assertElapsedUnit(valueType, predicate.unit, index);
|
|
2024
|
+
assertNonNegativeInteger(predicate.min, "min", index);
|
|
2025
|
+
assertNonNegativeInteger(predicate.max, "max", index);
|
|
2026
|
+
if (predicate.max <= predicate.min) {
|
|
2027
|
+
throw new EnableWhenCompileError("max must be greater than min (max is exclusive)", index);
|
|
2028
|
+
}
|
|
2029
|
+
return `${v}.exists() and today() >= ${date} + ${predicate.min} ${predicate.unit} and today() < ${date} + ${predicate.max} ${predicate.unit}`;
|
|
2030
|
+
}
|
|
2031
|
+
const literal = formatLiteral(valueType, predicate.value, index);
|
|
2032
|
+
const symbol = COMPARISON_SYMBOL[predicate.op];
|
|
2033
|
+
if (valueType === "coding") {
|
|
2034
|
+
return predicate.op === "eq" ? `${v} contains ${literal}` : `${v}.exists() and (${v} contains ${literal}).not()`;
|
|
2035
|
+
}
|
|
2036
|
+
const converted = valueType === "string" ? `${v}.first()` : `${v}.first().${CONVERSION[valueType]}()`;
|
|
2037
|
+
return predicate.op === "neq" ? `${v}.exists() and ${converted} != ${literal}` : `${converted} ${symbol} ${literal}`;
|
|
2038
|
+
};
|
|
2039
|
+
var compileEnableWhen = (conditions, behavior) => {
|
|
2040
|
+
if (conditions.length === 0) {
|
|
2041
|
+
throw new EnableWhenCompileError("an enableWhen needs at least one condition");
|
|
2042
|
+
}
|
|
2043
|
+
const variablesBySource = /* @__PURE__ */ new Map();
|
|
2044
|
+
const usedNames = /* @__PURE__ */ new Set();
|
|
2045
|
+
const variableFor = (source) => {
|
|
2046
|
+
const key = sourceKey(source);
|
|
2047
|
+
const existing = variablesBySource.get(key);
|
|
2048
|
+
if (existing) {
|
|
2049
|
+
return existing.name;
|
|
2050
|
+
}
|
|
2051
|
+
const base = baseVariableName(source);
|
|
2052
|
+
let name = base;
|
|
2053
|
+
for (let i = 2; usedNames.has(name); i++) {
|
|
2054
|
+
name = `${base}_${i}`;
|
|
2055
|
+
}
|
|
2056
|
+
usedNames.add(name);
|
|
2057
|
+
const variable = source.kind === "question" ? { name, question: source.linkId } : { name, topic: source.topic, scope: source.scope };
|
|
2058
|
+
variablesBySource.set(key, variable);
|
|
2059
|
+
return name;
|
|
2060
|
+
};
|
|
2061
|
+
const compiled = conditions.map(
|
|
2062
|
+
(condition, index) => compileCondition(condition, `%${variableFor(condition.source)}`, index)
|
|
2063
|
+
);
|
|
2064
|
+
const expression = compiled.length === 1 ? compiled[0] : compiled.map((part) => `(${part})`).join(behavior === "all" ? " and " : " or ");
|
|
2065
|
+
return { itemVariables: Array.from(variablesBySource.values()), expression };
|
|
2066
|
+
};
|
|
2067
|
+
var V = "%([A-Za-z_][A-Za-z0-9_]*)";
|
|
2068
|
+
var STR = "('(?:\\\\.|[^'\\\\])*')";
|
|
2069
|
+
var NUM = "(-?\\d+(?:\\.\\d+)?)";
|
|
2070
|
+
var DATE = "(@\\d{4}(?:-\\d{2}-\\d{2})?)";
|
|
2071
|
+
var LIT = `(?:${STR}|${NUM}|${DATE})`;
|
|
2072
|
+
var CMP = "(=|!=|<=|>=|<|>)";
|
|
2073
|
+
var CONV = "(toInteger|toDecimal|toDate)";
|
|
2074
|
+
var INT = "(\\d+)";
|
|
2075
|
+
var rx = (pattern) => new RegExp(`^${pattern}$`);
|
|
2076
|
+
var CONDITION_EXISTS = rx(`${V}\\.exists\\(\\)`);
|
|
2077
|
+
var CONDITION_EMPTY = rx(`${V}\\.empty\\(\\)`);
|
|
2078
|
+
var CONDITION_CONTAINS = rx(`${V} contains ${STR}`);
|
|
2079
|
+
var CONDITION_NOT_CONTAINS = rx(`${V}\\.exists\\(\\) and \\(${V} contains ${STR}\\)\\.not\\(\\)`);
|
|
2080
|
+
var CONDITION_STRING_EQ = rx(`${V}\\.first\\(\\) = ${STR}`);
|
|
2081
|
+
var CONDITION_STRING_NEQ = rx(`${V}\\.exists\\(\\) and ${V}\\.first\\(\\) != ${STR}`);
|
|
2082
|
+
var CONDITION_CONVERTED_CMP = rx(`${V}\\.first\\(\\)\\.${CONV}\\(\\) ${CMP} ${LIT}`);
|
|
2083
|
+
var CONDITION_CONVERTED_NEQ = rx(
|
|
2084
|
+
`${V}\\.exists\\(\\) and ${V}\\.first\\(\\)\\.${CONV}\\(\\) != ${LIT}`
|
|
2085
|
+
);
|
|
2086
|
+
var UNIT = `(${SUPPORTED_FHIRPATH_DATE_UNITS.join("|")})`;
|
|
2087
|
+
var ELAPSED = `${V}\\.first\\(\\)\\.toDate\\(\\) \\+ ${INT} ${UNIT}`;
|
|
2088
|
+
var CONDITION_ELAPSED_AT_LEAST = rx(`${V}\\.exists\\(\\) and today\\(\\) >= ${ELAPSED}`);
|
|
2089
|
+
var CONDITION_ELAPSED_LESS_THAN = rx(`${V}\\.exists\\(\\) and today\\(\\) < ${ELAPSED}`);
|
|
2090
|
+
var CONDITION_ELAPSED_BETWEEN = rx(
|
|
2091
|
+
`${V}\\.exists\\(\\) and today\\(\\) >= ${ELAPSED} and today\\(\\) < ${ELAPSED}`
|
|
2092
|
+
);
|
|
2093
|
+
var literalValue = (str, num, date) => {
|
|
2094
|
+
if (str !== void 0) return { value: unescapeString(str), valueType: "string" };
|
|
2095
|
+
if (num !== void 0) return { value: Number(num) };
|
|
2096
|
+
return {
|
|
2097
|
+
value: date.slice(1),
|
|
2098
|
+
valueType: date.length === 5 ? "year" : "date"
|
|
2099
|
+
};
|
|
2100
|
+
};
|
|
2101
|
+
var convertedValueType = (conv, literalType) => conv === "toInteger" ? "integer" : conv === "toDecimal" ? "decimal" : literalType != null ? literalType : "date";
|
|
2102
|
+
var sameVariable = (...names) => names.every((n) => n === names[0]);
|
|
2103
|
+
var parseCondition = (text) => {
|
|
2104
|
+
let m;
|
|
2105
|
+
if (m = text.match(CONDITION_EXISTS)) return { variable: m[1], predicate: { op: "exists" } };
|
|
2106
|
+
if (m = text.match(CONDITION_EMPTY)) return { variable: m[1], predicate: { op: "empty" } };
|
|
2107
|
+
if ((m = text.match(CONDITION_NOT_CONTAINS)) && sameVariable(m[1], m[2])) {
|
|
2108
|
+
return {
|
|
2109
|
+
variable: m[1],
|
|
2110
|
+
valueType: "coding",
|
|
2111
|
+
predicate: { op: "neq", value: unescapeString(m[3]) }
|
|
2112
|
+
};
|
|
2113
|
+
}
|
|
2114
|
+
if (m = text.match(CONDITION_STRING_EQ)) {
|
|
2115
|
+
return {
|
|
2116
|
+
variable: m[1],
|
|
2117
|
+
valueType: "string",
|
|
2118
|
+
predicate: { op: "eq", value: unescapeString(m[2]) }
|
|
2119
|
+
};
|
|
2120
|
+
}
|
|
2121
|
+
if ((m = text.match(CONDITION_STRING_NEQ)) && sameVariable(m[1], m[2])) {
|
|
2122
|
+
return {
|
|
2123
|
+
variable: m[1],
|
|
2124
|
+
valueType: "string",
|
|
2125
|
+
predicate: { op: "neq", value: unescapeString(m[3]) }
|
|
2126
|
+
};
|
|
2127
|
+
}
|
|
2128
|
+
if (m = text.match(CONDITION_CONVERTED_CMP)) {
|
|
2129
|
+
const lit = literalValue(m[4], m[5], m[6]);
|
|
2130
|
+
if (lit.valueType === "string") return null;
|
|
2131
|
+
return {
|
|
2132
|
+
variable: m[1],
|
|
2133
|
+
valueType: convertedValueType(m[2], lit.valueType),
|
|
2134
|
+
predicate: { op: SYMBOL_COMPARISON[m[3]], value: lit.value }
|
|
2135
|
+
};
|
|
2136
|
+
}
|
|
2137
|
+
if ((m = text.match(CONDITION_CONVERTED_NEQ)) && sameVariable(m[1], m[2])) {
|
|
2138
|
+
const lit = literalValue(m[4], m[5], m[6]);
|
|
2139
|
+
if (lit.valueType === "string") return null;
|
|
2140
|
+
return {
|
|
2141
|
+
variable: m[1],
|
|
2142
|
+
valueType: convertedValueType(m[3], lit.valueType),
|
|
2143
|
+
predicate: { op: "neq", value: lit.value }
|
|
2144
|
+
};
|
|
2145
|
+
}
|
|
2146
|
+
if ((m = text.match(CONDITION_ELAPSED_BETWEEN)) && sameVariable(m[1], m[2], m[5]) && m[4] === m[7]) {
|
|
2147
|
+
return {
|
|
2148
|
+
variable: m[1],
|
|
2149
|
+
valueType: "date",
|
|
2150
|
+
predicate: {
|
|
2151
|
+
op: "elapsedBetween",
|
|
2152
|
+
min: Number(m[3]),
|
|
2153
|
+
max: Number(m[6]),
|
|
2154
|
+
unit: m[4]
|
|
2155
|
+
}
|
|
2156
|
+
};
|
|
2157
|
+
}
|
|
2158
|
+
if ((m = text.match(CONDITION_ELAPSED_AT_LEAST)) && sameVariable(m[1], m[2])) {
|
|
2159
|
+
return {
|
|
2160
|
+
variable: m[1],
|
|
2161
|
+
valueType: "date",
|
|
2162
|
+
predicate: { op: "elapsedAtLeast", amount: Number(m[3]), unit: m[4] }
|
|
2163
|
+
};
|
|
2164
|
+
}
|
|
2165
|
+
if ((m = text.match(CONDITION_ELAPSED_LESS_THAN)) && sameVariable(m[1], m[2])) {
|
|
2166
|
+
return {
|
|
2167
|
+
variable: m[1],
|
|
2168
|
+
valueType: "date",
|
|
2169
|
+
predicate: { op: "elapsedLessThan", amount: Number(m[3]), unit: m[4] }
|
|
2170
|
+
};
|
|
2171
|
+
}
|
|
2172
|
+
const parts = splitTopLevel(text);
|
|
2173
|
+
if (parts && parts.connector === "or") {
|
|
2174
|
+
const matches = parts.segments.map((s) => s.match(CONDITION_CONTAINS));
|
|
2175
|
+
if (matches.every((x) => x !== null) && sameVariable(...matches.map((x) => x[1]))) {
|
|
2176
|
+
return {
|
|
2177
|
+
variable: matches[0][1],
|
|
2178
|
+
valueType: "coding",
|
|
2179
|
+
predicate: { op: "oneOf", values: matches.map((x) => unescapeString(x[2])) }
|
|
2180
|
+
};
|
|
2181
|
+
}
|
|
2182
|
+
}
|
|
2183
|
+
if (m = text.match(CONDITION_CONTAINS)) {
|
|
2184
|
+
return {
|
|
2185
|
+
variable: m[1],
|
|
2186
|
+
valueType: "coding",
|
|
2187
|
+
predicate: { op: "eq", value: unescapeString(m[2]) }
|
|
2188
|
+
};
|
|
2189
|
+
}
|
|
2190
|
+
return null;
|
|
2191
|
+
};
|
|
2192
|
+
var normalize = (expression) => expression.split(/('(?:\\.|[^'\\])*')/).map((part, i) => i % 2 === 1 ? part : part.replace(/\s+/g, " ")).join("").trim();
|
|
2193
|
+
var unwrap = (s) => {
|
|
2194
|
+
if (!s.startsWith("(") || !s.endsWith(")")) return s;
|
|
2195
|
+
let depth = 0;
|
|
2196
|
+
let inString = false;
|
|
2197
|
+
for (let i = 0; i < s.length; i++) {
|
|
2198
|
+
const ch = s[i];
|
|
2199
|
+
if (inString) {
|
|
2200
|
+
if (ch === "\\") i++;
|
|
2201
|
+
else if (ch === "'") inString = false;
|
|
2202
|
+
continue;
|
|
2203
|
+
}
|
|
2204
|
+
if (ch === "'") inString = true;
|
|
2205
|
+
else if (ch === "(") depth++;
|
|
2206
|
+
else if (ch === ")") {
|
|
2207
|
+
depth--;
|
|
2208
|
+
if (depth === 0 && i < s.length - 1) return s;
|
|
2209
|
+
}
|
|
2210
|
+
}
|
|
2211
|
+
return s.slice(1, -1).trim();
|
|
2212
|
+
};
|
|
2213
|
+
var splitTopLevel = (s) => {
|
|
2214
|
+
const segments = [];
|
|
2215
|
+
let connector = null;
|
|
2216
|
+
let depth = 0;
|
|
2217
|
+
let inString = false;
|
|
2218
|
+
let start = 0;
|
|
2219
|
+
for (let i = 0; i < s.length; i++) {
|
|
2220
|
+
const ch = s[i];
|
|
2221
|
+
if (inString) {
|
|
2222
|
+
if (ch === "\\") i++;
|
|
2223
|
+
else if (ch === "'") inString = false;
|
|
2224
|
+
continue;
|
|
2225
|
+
}
|
|
2226
|
+
if (ch === "'") inString = true;
|
|
2227
|
+
else if (ch === "(") depth++;
|
|
2228
|
+
else if (ch === ")") depth--;
|
|
2229
|
+
else if (depth === 0 && ch === " ") {
|
|
2230
|
+
const found = s.startsWith(" and ", i) ? "and" : s.startsWith(" or ", i) ? "or" : null;
|
|
2231
|
+
if (found) {
|
|
2232
|
+
if (connector && connector !== found) return null;
|
|
2233
|
+
connector = found;
|
|
2234
|
+
segments.push(s.slice(start, i).trim());
|
|
2235
|
+
i += found.length + 1;
|
|
2236
|
+
start = i + 1;
|
|
2237
|
+
}
|
|
2238
|
+
}
|
|
2239
|
+
}
|
|
2240
|
+
if (!connector) return null;
|
|
2241
|
+
segments.push(s.slice(start).trim());
|
|
2242
|
+
return { connector, segments };
|
|
2243
|
+
};
|
|
2244
|
+
var decompileEnableWhen = (itemVariables, expression, resolveValueType) => {
|
|
2245
|
+
var _a, _b, _c;
|
|
2246
|
+
const sources = /* @__PURE__ */ new Map();
|
|
2247
|
+
for (const variable of itemVariables) {
|
|
2248
|
+
if (variable.question !== void 0 && variable.topic === void 0) {
|
|
2249
|
+
sources.set(variable.name, { kind: "question", linkId: variable.question });
|
|
2250
|
+
} else if (variable.topic !== void 0 && variable.question === void 0) {
|
|
2251
|
+
sources.set(variable.name, {
|
|
2252
|
+
kind: "topic",
|
|
2253
|
+
topic: variable.topic,
|
|
2254
|
+
scope: (_a = variable.scope) != null ? _a : "latest"
|
|
2255
|
+
});
|
|
2256
|
+
} else {
|
|
2257
|
+
return null;
|
|
2258
|
+
}
|
|
2259
|
+
}
|
|
2260
|
+
const normalized = unwrap(normalize(expression));
|
|
2261
|
+
let behavior = "all";
|
|
2262
|
+
let parsedConditions;
|
|
2263
|
+
const single = parseCondition(normalized);
|
|
2264
|
+
if (single) {
|
|
2265
|
+
parsedConditions = [single];
|
|
2266
|
+
} else {
|
|
2267
|
+
const split = splitTopLevel(normalized);
|
|
2268
|
+
if (!split) return null;
|
|
2269
|
+
behavior = split.connector === "and" ? "all" : "any";
|
|
2270
|
+
const parsed = split.segments.map((segment) => parseCondition(unwrap(segment)));
|
|
2271
|
+
if (!parsed.every((r) => r !== null)) return null;
|
|
2272
|
+
parsedConditions = parsed;
|
|
2273
|
+
}
|
|
2274
|
+
const conditions = [];
|
|
2275
|
+
for (const parsed of parsedConditions) {
|
|
2276
|
+
const source = sources.get(parsed.variable);
|
|
2277
|
+
if (!source) return null;
|
|
2278
|
+
const valueType = (_c = (_b = resolveValueType == null ? void 0 : resolveValueType(source)) != null ? _b : parsed.valueType) != null ? _c : "string";
|
|
2279
|
+
if (!ENABLE_WHEN_PREDICATES_BY_VALUE_TYPE[valueType].includes(parsed.predicate.op)) return null;
|
|
2280
|
+
conditions.push({ source, valueType, predicate: parsed.predicate });
|
|
2281
|
+
}
|
|
2282
|
+
return { conditions, behavior };
|
|
2283
|
+
};
|
|
2284
|
+
|
|
1472
2285
|
// src/fhir/utils.ts
|
|
1473
2286
|
import { v4 as uuid } from "uuid";
|
|
1474
2287
|
function generateUrn() {
|
|
@@ -1752,7 +2565,7 @@ var createArrayAnswer = (responses, mapper) => {
|
|
|
1752
2565
|
};
|
|
1753
2566
|
|
|
1754
2567
|
// src/fhir/recordingSignal.ts
|
|
1755
|
-
import { Buffer as
|
|
2568
|
+
import { Buffer as Buffer3 } from "buffer/";
|
|
1756
2569
|
function toFHIRBundleEntries(signal) {
|
|
1757
2570
|
const urn = generateUrn();
|
|
1758
2571
|
const deviceUrn = generateUrn();
|
|
@@ -1790,7 +2603,7 @@ function toFHIRDocumentReference(signal, deviceUrn) {
|
|
|
1790
2603
|
{
|
|
1791
2604
|
attachment: {
|
|
1792
2605
|
contentType: "application/json",
|
|
1793
|
-
data:
|
|
2606
|
+
data: Buffer3.from(
|
|
1794
2607
|
JSON.stringify({
|
|
1795
2608
|
schemaVersion: version,
|
|
1796
2609
|
entrySize: entrySize + DEVICE_ANNOTATION_TIMESTAMP_SIZE,
|
|
@@ -1803,7 +2616,7 @@ function toFHIRDocumentReference(signal, deviceUrn) {
|
|
|
1803
2616
|
{
|
|
1804
2617
|
attachment: {
|
|
1805
2618
|
contentType: "application/octet-stream",
|
|
1806
|
-
data:
|
|
2619
|
+
data: Buffer3.from(data).toString("base64")
|
|
1807
2620
|
}
|
|
1808
2621
|
}
|
|
1809
2622
|
]
|
|
@@ -2145,7 +2958,7 @@ var getPeriod = (progress) => {
|
|
|
2145
2958
|
};
|
|
2146
2959
|
|
|
2147
2960
|
// src/fhir/seenDisplay.ts
|
|
2148
|
-
import { Buffer as
|
|
2961
|
+
import { Buffer as Buffer4 } from "buffer/";
|
|
2149
2962
|
function generateFHIRSeenDisplay(id, seenDisplay) {
|
|
2150
2963
|
var _a;
|
|
2151
2964
|
const contentCodeableConcept = {
|
|
@@ -2178,7 +2991,7 @@ function generateFHIRSeenDisplay(id, seenDisplay) {
|
|
|
2178
2991
|
"default.title",
|
|
2179
2992
|
seenDisplay.lng
|
|
2180
2993
|
),
|
|
2181
|
-
data:
|
|
2994
|
+
data: Buffer4.from(contentData).toString("base64")
|
|
2182
2995
|
},
|
|
2183
2996
|
contentCodeableConcept
|
|
2184
2997
|
}
|
|
@@ -2195,7 +3008,7 @@ function generateFHIRSeenDisplay(id, seenDisplay) {
|
|
|
2195
3008
|
}
|
|
2196
3009
|
|
|
2197
3010
|
// src/fhir/seenMessage.ts
|
|
2198
|
-
import { Buffer as
|
|
3011
|
+
import { Buffer as Buffer5 } from "buffer/";
|
|
2199
3012
|
function generateFHIRSeenMessage(id, seenMessage) {
|
|
2200
3013
|
const contentCodeableConcept = {
|
|
2201
3014
|
coding: [
|
|
@@ -2213,7 +3026,7 @@ function generateFHIRSeenMessage(id, seenMessage) {
|
|
|
2213
3026
|
contentType: "text/plain",
|
|
2214
3027
|
language: seenMessage.lng,
|
|
2215
3028
|
title: seenMessage.subject[seenMessage.lng],
|
|
2216
|
-
data:
|
|
3029
|
+
data: Buffer5.from(contentData).toString("base64")
|
|
2217
3030
|
},
|
|
2218
3031
|
contentCodeableConcept
|
|
2219
3032
|
}
|
|
@@ -2402,13 +3215,13 @@ var MonthFuncs = class extends TimeFuncs {
|
|
|
2402
3215
|
};
|
|
2403
3216
|
|
|
2404
3217
|
// src/collector/sdk.ts
|
|
2405
|
-
import { Buffer as
|
|
3218
|
+
import { Buffer as Buffer7 } from "buffer/";
|
|
2406
3219
|
|
|
2407
3220
|
// src/donation/keyHandler.ts
|
|
2408
3221
|
import * as secpUtils from "@noble/curves/abstract/utils";
|
|
2409
3222
|
import { secp256k1 } from "@noble/curves/secp256k1";
|
|
2410
3223
|
import * as bip39 from "@scure/bip39";
|
|
2411
|
-
import { Buffer as
|
|
3224
|
+
import { Buffer as Buffer6 } from "buffer/";
|
|
2412
3225
|
import * as forge from "node-forge";
|
|
2413
3226
|
|
|
2414
3227
|
// src/helper/wordlists.ts
|
|
@@ -4525,12 +5338,12 @@ var KeyHandler = class {
|
|
|
4525
5338
|
return "";
|
|
4526
5339
|
};
|
|
4527
5340
|
this.extendPublicKey = (publicKey) => {
|
|
4528
|
-
let key =
|
|
5341
|
+
let key = Buffer6.from(publicKey);
|
|
4529
5342
|
if (key.length !== 65) {
|
|
4530
5343
|
throw new Error("Invalid public key length");
|
|
4531
5344
|
}
|
|
4532
5345
|
key = key.slice(1);
|
|
4533
|
-
const header =
|
|
5346
|
+
const header = Buffer6.from([
|
|
4534
5347
|
48,
|
|
4535
5348
|
86,
|
|
4536
5349
|
48,
|
|
@@ -4556,7 +5369,7 @@ var KeyHandler = class {
|
|
|
4556
5369
|
0,
|
|
4557
5370
|
4
|
|
4558
5371
|
]);
|
|
4559
|
-
return
|
|
5372
|
+
return Buffer6.concat([header, key]).toString("base64");
|
|
4560
5373
|
};
|
|
4561
5374
|
/**
|
|
4562
5375
|
* Hash a message with SHA-256
|
|
@@ -4770,7 +5583,7 @@ var buildSelfSignedAuthToken = async (keyHandler, converter, pub, priv, token, s
|
|
|
4770
5583
|
messageJSON: message,
|
|
4771
5584
|
signature: converter.uint8ArrayToBase64(signature)
|
|
4772
5585
|
});
|
|
4773
|
-
return
|
|
5586
|
+
return Buffer7.from(signedMessage).toString("base64");
|
|
4774
5587
|
};
|
|
4775
5588
|
var CollectorClient = class {
|
|
4776
5589
|
/**
|
|
@@ -5275,11 +6088,11 @@ var sha256 = /* @__PURE__ */ createHasher(() => new SHA256());
|
|
|
5275
6088
|
var sha2562 = sha256;
|
|
5276
6089
|
|
|
5277
6090
|
// src/donation/hybridEncryption.ts
|
|
5278
|
-
import { Buffer as
|
|
6091
|
+
import { Buffer as Buffer9 } from "buffer/";
|
|
5279
6092
|
import * as forge2 from "node-forge";
|
|
5280
6093
|
|
|
5281
6094
|
// src/helper/converter.ts
|
|
5282
|
-
import { Buffer as
|
|
6095
|
+
import { Buffer as Buffer8 } from "buffer/";
|
|
5283
6096
|
var binaryStringToUint8Array = (binaryString) => {
|
|
5284
6097
|
return new Uint8Array(binaryString.split("").map((c) => c.charCodeAt(0)));
|
|
5285
6098
|
};
|
|
@@ -5373,10 +6186,10 @@ var WebConverter = class {
|
|
|
5373
6186
|
this.uint8ArrayToUTF8 = (uint) => {
|
|
5374
6187
|
const decoder = new TextDecoder();
|
|
5375
6188
|
const str = decoder.decode(uint);
|
|
5376
|
-
return
|
|
6189
|
+
return Buffer8.from(str, "base64").toString("utf8");
|
|
5377
6190
|
};
|
|
5378
|
-
this.base64ToHex = (base64String) =>
|
|
5379
|
-
this.hexToBase64 = (hexString) =>
|
|
6191
|
+
this.base64ToHex = (base64String) => Buffer8.from(base64String, "base64").toString("hex");
|
|
6192
|
+
this.hexToBase64 = (hexString) => Buffer8.from(hexString, "hex").toString("base64");
|
|
5380
6193
|
}
|
|
5381
6194
|
};
|
|
5382
6195
|
|
|
@@ -5534,7 +6347,7 @@ var HybridEncrypter = class {
|
|
|
5534
6347
|
donation.encrypted,
|
|
5535
6348
|
donation.iv
|
|
5536
6349
|
);
|
|
5537
|
-
return
|
|
6350
|
+
return Buffer9.from(decryptedDonation).toString("utf8");
|
|
5538
6351
|
};
|
|
5539
6352
|
/**
|
|
5540
6353
|
* Decrypt a v4 hybrid ciphertext addressed to the mobile app. The normal path is the EC
|
|
@@ -5593,7 +6406,7 @@ var HybridEncrypter = class {
|
|
|
5593
6406
|
this.openV4Record = (record, keys) => {
|
|
5594
6407
|
const dataKey = this.unwrapV4DataKey(record.slots, keys);
|
|
5595
6408
|
const plaintext = this.decryptAESGCM(dataKey, record.payloadIv, record.payload);
|
|
5596
|
-
return
|
|
6409
|
+
return Buffer9.from(plaintext).toString("utf8");
|
|
5597
6410
|
};
|
|
5598
6411
|
/**
|
|
5599
6412
|
* Parse a v4 record into its slots and payload. Every length comes from the record
|
|
@@ -5947,7 +6760,7 @@ var HybridEncrypter = class {
|
|
|
5947
6760
|
const tag = cipher2.mode.tag.getBytes();
|
|
5948
6761
|
return {
|
|
5949
6762
|
iv: binaryStringToUint8Array(iv),
|
|
5950
|
-
encrypted:
|
|
6763
|
+
encrypted: Buffer9.concat([
|
|
5951
6764
|
binaryStringToUint8Array(encrypted),
|
|
5952
6765
|
binaryStringToUint8Array(tag)
|
|
5953
6766
|
])
|
|
@@ -5983,7 +6796,7 @@ var setUint8Array = (dataView, offset, values) => {
|
|
|
5983
6796
|
};
|
|
5984
6797
|
|
|
5985
6798
|
// src/donation/sdk.ts
|
|
5986
|
-
import { Buffer as
|
|
6799
|
+
import { Buffer as Buffer10 } from "buffer/";
|
|
5987
6800
|
|
|
5988
6801
|
// src/donation/blurring.ts
|
|
5989
6802
|
import { DateTime as DateTime3 } from "luxon";
|
|
@@ -6166,7 +6979,7 @@ var DonationSDK = class {
|
|
|
6166
6979
|
messageJSON: message,
|
|
6167
6980
|
signature: this.converter.uint8ArrayToBase64(signature)
|
|
6168
6981
|
});
|
|
6169
|
-
return
|
|
6982
|
+
return Buffer10.from(signedMessage).toString("base64");
|
|
6170
6983
|
};
|
|
6171
6984
|
/**
|
|
6172
6985
|
* Validate an authentication token which can be used to authenticated with the Donation API
|
|
@@ -7070,16 +7883,16 @@ function mergeContexts(a, b) {
|
|
|
7070
7883
|
}
|
|
7071
7884
|
|
|
7072
7885
|
// src/helper/ulid/index.ts
|
|
7073
|
-
import { Buffer as
|
|
7886
|
+
import { Buffer as Buffer12 } from "buffer/";
|
|
7074
7887
|
|
|
7075
7888
|
// src/helper/ulid/base32.ts
|
|
7076
|
-
import { Buffer as
|
|
7889
|
+
import { Buffer as Buffer11 } from "buffer/";
|
|
7077
7890
|
var B32_CHARACTERS = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
|
|
7078
7891
|
var crockfordEncode = (input) => {
|
|
7079
7892
|
const output = [];
|
|
7080
7893
|
let bitsRead = 0;
|
|
7081
7894
|
let buffer = 0;
|
|
7082
|
-
const reversedInput =
|
|
7895
|
+
const reversedInput = Buffer11.from(input).reverse();
|
|
7083
7896
|
for (const byte of reversedInput) {
|
|
7084
7897
|
buffer |= byte << bitsRead;
|
|
7085
7898
|
bitsRead += 8;
|
|
@@ -7116,7 +7929,7 @@ var crockfordDecode = (input) => {
|
|
|
7116
7929
|
if (bitsRead >= 5 || buffer > 0) {
|
|
7117
7930
|
output.unshift(buffer & 255);
|
|
7118
7931
|
}
|
|
7119
|
-
return
|
|
7932
|
+
return Buffer11.from(output);
|
|
7120
7933
|
};
|
|
7121
7934
|
|
|
7122
7935
|
// src/helper/ulid/index.ts
|
|
@@ -7130,7 +7943,7 @@ function UUIDtoULID(uuid2, opts) {
|
|
|
7130
7943
|
}
|
|
7131
7944
|
throw new Error("UUID to ULID conversion failed: invalid UUID input");
|
|
7132
7945
|
}
|
|
7133
|
-
const ulid = crockfordEncode(
|
|
7946
|
+
const ulid = crockfordEncode(Buffer12.from(uuid2.replace(/-/g, ""), "hex"));
|
|
7134
7947
|
return ulid;
|
|
7135
7948
|
}
|
|
7136
7949
|
function ULIDtoUUID(ulid, opts) {
|
|
@@ -7354,7 +8167,12 @@ export {
|
|
|
7354
8167
|
DecimalGuard,
|
|
7355
8168
|
Disjunction,
|
|
7356
8169
|
DonationSDK,
|
|
8170
|
+
ELAPSED_UNITS_BY_VALUE_TYPE,
|
|
8171
|
+
ENABLE_WHEN_CONFORMANCE_CASES,
|
|
8172
|
+
ENABLE_WHEN_PREDICATES_BY_VALUE_TYPE,
|
|
7357
8173
|
ERROR_CODES,
|
|
8174
|
+
EnableWhenCompileError,
|
|
8175
|
+
EnableWhenExpressionExtension,
|
|
7358
8176
|
ExistsGuard,
|
|
7359
8177
|
FITBIT_ANNOTATION_ITEM_BREATHING_RATE,
|
|
7360
8178
|
FITBIT_ANNOTATION_ITEM_CALORIES,
|
|
@@ -7375,6 +8193,7 @@ export {
|
|
|
7375
8193
|
FITBIT_SLEEP_LEVEL_MAP,
|
|
7376
8194
|
FITBIT_SPO2_ANNOTATION,
|
|
7377
8195
|
FITBIT_STEPS_ANNOTATION,
|
|
8196
|
+
FhirPathLanguage,
|
|
7378
8197
|
GARMIN_ACTIVITY_ANNOTATION,
|
|
7379
8198
|
GARMIN_ANNOTATION_ITEM_ACTIVITY_ACTIVE_TIME,
|
|
7380
8199
|
GARMIN_ANNOTATION_ITEM_ACTIVITY_LEVEL,
|
|
@@ -7408,6 +8227,10 @@ export {
|
|
|
7408
8227
|
ImageExtension,
|
|
7409
8228
|
InternalSensorAnnotationTypes,
|
|
7410
8229
|
Iso3166CodeSystem,
|
|
8230
|
+
ItemVariableNameUrl,
|
|
8231
|
+
ItemVariableQuestionUrl,
|
|
8232
|
+
ItemVariableScopeUrl,
|
|
8233
|
+
ItemVariableTopicUrl,
|
|
7411
8234
|
KEY_LENGTH,
|
|
7412
8235
|
KeyHandler,
|
|
7413
8236
|
MENSTRUAL_CYCLE_ANNOTATION,
|
|
@@ -7434,6 +8257,7 @@ export {
|
|
|
7434
8257
|
OURA_STRESS_ANNOTATION,
|
|
7435
8258
|
OURA_TAG_ANNOTATION,
|
|
7436
8259
|
OURA_WORKOUT_ANNOTATION,
|
|
8260
|
+
OUT_OF_SUBSET_EXPRESSIONS,
|
|
7437
8261
|
ObservationTypeSystem,
|
|
7438
8262
|
Offset,
|
|
7439
8263
|
PAMSCardioVascularActivityAnnotation,
|
|
@@ -7453,6 +8277,7 @@ export {
|
|
|
7453
8277
|
QItemControlDefinition,
|
|
7454
8278
|
QuestionnaireItemInputExtension,
|
|
7455
8279
|
QuestionnaireItemOutputExtension,
|
|
8280
|
+
QuestionnaireItemVariableExtension,
|
|
7456
8281
|
RECORDING_MODEL_CURRENT_VERSION,
|
|
7457
8282
|
RECORDING_SIGNAL_MODEL_CURRENT_VERSION,
|
|
7458
8283
|
RelativeMaxValueExtension,
|
|
@@ -7461,6 +8286,9 @@ export {
|
|
|
7461
8286
|
RoutineGuard,
|
|
7462
8287
|
RoutineIsPassiveExtension,
|
|
7463
8288
|
SIGNAL_DURATION_CODING,
|
|
8289
|
+
SUPPORTED_FHIRPATH_DATE_UNITS,
|
|
8290
|
+
SUPPORTED_FHIRPATH_FUNCTIONS,
|
|
8291
|
+
SUPPORTED_FHIRPATH_OPERATORS,
|
|
7464
8292
|
SensorIdentifierSystem,
|
|
7465
8293
|
SensorSettingsSystem,
|
|
7466
8294
|
SensorTypeSystem,
|
|
@@ -7473,6 +8301,7 @@ export {
|
|
|
7473
8301
|
StudyNameSystem,
|
|
7474
8302
|
SurveyGuard,
|
|
7475
8303
|
TAG_LENGTH,
|
|
8304
|
+
TEMPORAL_PREDICATES,
|
|
7476
8305
|
TOPIC_ID_PATTERN,
|
|
7477
8306
|
TOPIC_SCOPE_CODES,
|
|
7478
8307
|
TRACKING_RESOURCE_TYPE,
|
|
@@ -7496,9 +8325,12 @@ export {
|
|
|
7496
8325
|
calculateQuestionnaireScoreRange,
|
|
7497
8326
|
calculateScoreRangeForItem,
|
|
7498
8327
|
capitalizeFirstLetter,
|
|
8328
|
+
compileEnableWhen,
|
|
7499
8329
|
dayFormat,
|
|
8330
|
+
decompileEnableWhen,
|
|
7500
8331
|
encodeDataSource,
|
|
7501
8332
|
extractWordsFromRecoveryPhrase,
|
|
8333
|
+
findSubsetViolations,
|
|
7502
8334
|
generateFHIRConsent,
|
|
7503
8335
|
generateFHIRQuestionnaireScore,
|
|
7504
8336
|
generateFHIRRecordingBundle,
|
|
@@ -7532,6 +8364,8 @@ export {
|
|
|
7532
8364
|
isYearString,
|
|
7533
8365
|
newStepDateGuard,
|
|
7534
8366
|
overwriteTime,
|
|
8367
|
+
referencedVariables,
|
|
8368
|
+
requiresExpression,
|
|
7535
8369
|
stringToDate,
|
|
7536
8370
|
stringToYear,
|
|
7537
8371
|
timezonelessDate,
|