@icure/form 2.0.11 → 3.0.2
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/.yarn/cache/@babel-runtime-npm-7.26.9-8369ff039f-838492d8a9.zip +0 -0
- package/.yarn/cache/@icure-motss-app-datepicker-npm-6.0.0-rc.36-66219db2d1-5f34375d97.zip +0 -0
- package/.yarn/cache/@lit-labs-ssr-dom-shim-npm-1.3.0-6bfa115c08-c2003e8bb6.zip +0 -0
- package/.yarn/cache/@lit-reactive-element-npm-1.6.3-4828441e51-79b58631c3.zip +0 -0
- package/.yarn/cache/@lit-reactive-element-npm-2.0.4-4836436301-368d788d9e.zip +0 -0
- package/.yarn/cache/@material-animation-npm-14.0.0-canary.53b3cad2f.0-06a813cdea-9b5190654c.zip +0 -0
- package/.yarn/cache/@material-base-npm-14.0.0-canary.53b3cad2f.0-d195c1fdc4-9f4928d115.zip +0 -0
- package/.yarn/cache/@material-button-npm-14.0.0-canary.53b3cad2f.0-d4b070f508-873295c56a.zip +0 -0
- package/.yarn/cache/@material-density-npm-14.0.0-canary.53b3cad2f.0-48c1f65059-a23f00edfe.zip +0 -0
- package/.yarn/cache/@material-dialog-npm-14.0.0-canary.53b3cad2f.0-96168fa294-c1a498b81a.zip +0 -0
- package/.yarn/cache/@material-dom-npm-14.0.0-canary.53b3cad2f.0-ac009dc871-f5817f76dd.zip +0 -0
- package/.yarn/cache/@material-elevation-npm-14.0.0-canary.53b3cad2f.0-3312f06793-2f8945c7b6.zip +0 -0
- package/.yarn/cache/@material-feature-targeting-npm-14.0.0-canary.53b3cad2f.0-a919042d50-e7a1ed68f9.zip +0 -0
- package/.yarn/cache/@material-floating-label-npm-14.0.0-canary.53b3cad2f.0-eb8f330f2f-5295dc481d.zip +0 -0
- package/.yarn/cache/@material-focus-ring-npm-14.0.0-canary.53b3cad2f.0-b22f851a2e-92273b1247.zip +0 -0
- package/.yarn/cache/@material-icon-button-npm-14.0.0-canary.53b3cad2f.0-e158d26048-19b51665f2.zip +0 -0
- package/.yarn/cache/@material-line-ripple-npm-14.0.0-canary.53b3cad2f.0-d089468db9-6518961487.zip +0 -0
- package/.yarn/cache/@material-list-npm-14.0.0-canary.53b3cad2f.0-df9ce05084-6c977f518d.zip +0 -0
- package/.yarn/cache/@material-menu-npm-14.0.0-canary.53b3cad2f.0-9489b592c8-71b6a1f4dd.zip +0 -0
- package/.yarn/cache/@material-menu-surface-npm-14.0.0-canary.53b3cad2f.0-52212f38f4-ad48e168ca.zip +0 -0
- package/.yarn/cache/@material-mwc-base-npm-0.27.0-79caf3ef2b-07af17edfc.zip +0 -0
- package/.yarn/cache/@material-mwc-button-npm-0.27.0-4b85f2b26f-2ef5cc0951.zip +0 -0
- package/.yarn/cache/@material-mwc-checkbox-npm-0.27.0-e837031d8e-ba53a6ea8c.zip +0 -0
- package/.yarn/cache/@material-mwc-dialog-npm-0.27.0-77c6071543-ffab528e8e.zip +0 -0
- package/.yarn/cache/@material-mwc-floating-label-npm-0.27.0-80e62b22c0-fbbf4f2e42.zip +0 -0
- package/.yarn/cache/@material-mwc-icon-button-npm-0.27.0-41f82f135b-7315c0735b.zip +0 -0
- package/.yarn/cache/@material-mwc-icon-npm-0.27.0-98c9e8509f-6dfa5115d5.zip +0 -0
- package/.yarn/cache/@material-mwc-line-ripple-npm-0.27.0-e6704221e0-6862ede0f4.zip +0 -0
- package/.yarn/cache/@material-mwc-list-npm-0.27.0-5344fc9de4-6c2ae4f1c6.zip +0 -0
- package/.yarn/cache/@material-mwc-menu-npm-0.27.0-7c2bb47797-126f733659.zip +0 -0
- package/.yarn/cache/@material-mwc-notched-outline-npm-0.27.0-0e0d1c4d5f-2739032f76.zip +0 -0
- package/.yarn/cache/@material-mwc-radio-npm-0.27.0-aa2098a280-0b0a0a6b99.zip +0 -0
- package/.yarn/cache/@material-mwc-ripple-npm-0.27.0-ed37672f08-9cd73fdfe4.zip +0 -0
- package/.yarn/cache/@material-mwc-textfield-npm-0.27.0-dabd704f55-978c893aca.zip +0 -0
- package/.yarn/cache/@material-notched-outline-npm-14.0.0-canary.53b3cad2f.0-ecacde98db-1a9f8db4d8.zip +0 -0
- package/.yarn/cache/@material-radio-npm-14.0.0-canary.53b3cad2f.0-c50de64d41-898554f2b3.zip +0 -0
- package/.yarn/cache/@material-ripple-npm-14.0.0-canary.53b3cad2f.0-49060bfe7e-08b71917e2.zip +0 -0
- package/.yarn/cache/@material-rtl-npm-14.0.0-canary.53b3cad2f.0-daca794b76-3c1b8b48c6.zip +0 -0
- package/.yarn/cache/@material-shape-npm-14.0.0-canary.53b3cad2f.0-5bcff722a6-6ad9b020c0.zip +0 -0
- package/.yarn/cache/@material-textfield-npm-14.0.0-canary.53b3cad2f.0-4414808dda-7072e3c9df.zip +0 -0
- package/.yarn/cache/@material-theme-npm-14.0.0-canary.53b3cad2f.0-9a24e7b046-fd44e92917.zip +0 -0
- package/.yarn/cache/@material-tokens-npm-14.0.0-canary.53b3cad2f.0-f1c87523da-efa909f861.zip +0 -0
- package/.yarn/cache/@material-touch-target-npm-14.0.0-canary.53b3cad2f.0-fa6a2d0875-dbc13cbe7a.zip +0 -0
- package/.yarn/cache/@material-typography-npm-14.0.0-canary.53b3cad2f.0-f4a58946f1-fa2671df40.zip +0 -0
- package/.yarn/cache/@types-trusted-types-npm-2.0.7-a07fc44f59-8e4202766a.zip +0 -0
- package/.yarn/cache/@webcomponents-webcomponentsjs-npm-2.8.0-36c07db4d2-186373c030.zip +0 -0
- package/.yarn/cache/argparse-npm-2.0.1-faff7999e6-83644b5649.zip +0 -0
- package/.yarn/cache/blocking-elements-npm-0.1.1-423f51c76e-9a34084405.zip +0 -0
- package/.yarn/cache/date-fns-npm-2.30.0-895c790e0f-f7be015232.zip +0 -0
- package/.yarn/cache/entities-npm-4.5.0-7cdb83b832-853f8ebd5b.zip +0 -0
- package/.yarn/cache/fast-deep-equal-npm-3.1.3-790edcfcf5-e21a9d8d84.zip +0 -0
- package/.yarn/cache/linkify-it-npm-5.0.0-adb5f9c96f-b0b86cadaf.zip +0 -0
- package/.yarn/cache/lit-element-npm-3.3.3-2f9f9e38c0-29a596fa55.zip +0 -0
- package/.yarn/cache/lit-element-npm-4.1.1-bb20932b82-74d0f2d6fb.zip +0 -0
- package/.yarn/cache/lit-html-npm-2.8.0-82f88d6ebf-2d70df0724.zip +0 -0
- package/.yarn/cache/lit-html-npm-3.2.1-1662fc597d-1bacd9f8b2.zip +0 -0
- package/.yarn/cache/lit-npm-2.8.0-92bb1333a4-2480e733f7.zip +0 -0
- package/.yarn/cache/lit-npm-3.2.1-27cb5b7782-ee22bbc53d.zip +0 -0
- package/.yarn/cache/markdown-it-npm-14.1.0-e337d75bfe-07296b45eb.zip +0 -0
- package/.yarn/cache/mdurl-npm-2.0.0-3259713daf-880bc289ef.zip +0 -0
- package/.yarn/cache/orderedmap-npm-2.1.1-64b8a0684f-082cf970b0.zip +0 -0
- package/.yarn/cache/prosemirror-commands-npm-1.5.2-27f8f3fee9-ff65063a8c.zip +0 -0
- package/.yarn/cache/prosemirror-history-npm-1.3.2-cc128c8ee6-b85fe6378a.zip +0 -0
- package/.yarn/cache/prosemirror-keymap-npm-1.2.2-efb8276b00-85fe4fc303.zip +0 -0
- package/.yarn/cache/prosemirror-markdown-npm-1.12.0-28e990f443-d7607ee1a6.zip +0 -0
- package/.yarn/cache/prosemirror-model-npm-1.19.4-4fd32211c8-12c277ed30.zip +0 -0
- package/.yarn/cache/prosemirror-model-npm-1.24.1-6467e55b40-386076e2ff.zip +0 -0
- package/.yarn/cache/prosemirror-schema-basic-npm-1.2.2-def7bf2ec7-1f93f8678c.zip +0 -0
- package/.yarn/cache/prosemirror-schema-list-npm-1.3.0-23c1830a7e-03654e37c8.zip +0 -0
- package/.yarn/cache/prosemirror-state-npm-1.4.3-d6540e44ad-28857d935c.zip +0 -0
- package/.yarn/cache/prosemirror-transform-npm-1.10.2-1c2da9123e-93b0c03aff.zip +0 -0
- package/.yarn/cache/prosemirror-transform-npm-1.8.0-ea3ca0411f-6d16ca4f95.zip +0 -0
- package/.yarn/cache/prosemirror-view-npm-1.32.7-63c3e4b182-40c9038a52.zip +0 -0
- package/.yarn/cache/prosemirror-view-npm-1.38.0-9061dc9cf4-0d0f17c1b2.zip +0 -0
- package/.yarn/cache/punycode.js-npm-2.3.1-9084ecbbf5-13466d7ed5.zip +0 -0
- package/.yarn/cache/regenerator-runtime-npm-0.14.1-a6c97c609a-9f57c93277.zip +0 -0
- package/.yarn/cache/rope-sequence-npm-1.3.4-3b09587e5f-95cca2f99a.zip +0 -0
- package/.yarn/cache/tslib-npm-2.8.1-66590b21b8-e4aba30e63.zip +0 -0
- package/.yarn/cache/uc.micro-npm-2.1.0-c45282c865-3719735824.zip +0 -0
- package/.yarn/cache/uuid-npm-9.0.1-39a8442bc6-39931f6da7.zip +0 -0
- package/.yarn/cache/w3c-keyname-npm-2.2.8-66d7d5317a-95bafa4c04.zip +0 -0
- package/.yarn/cache/wicg-inert-npm-3.1.3-38590e83f2-45b3cfec63.zip +0 -0
- package/.yarn/install-state.gz +0 -0
- package/components/common/field-with-options.js +9 -5
- package/components/common/field-with-options.js.map +1 -1
- package/components/common/field.js +25 -21
- package/components/common/field.js.map +1 -1
- package/components/common/index.js +17 -1
- package/components/common/index.js.map +1 -1
- package/components/common/metadata-buttons-bar.d.ts +1 -1
- package/components/common/metadata-buttons-bar.js +58 -65
- package/components/common/metadata-buttons-bar.js.map +1 -1
- package/components/common/styles/paths.js +13 -10
- package/components/common/styles/paths.js.map +1 -1
- package/components/common/utils.js +21 -11
- package/components/common/utils.js.map +1 -1
- package/components/icure-button/index.js +19 -15
- package/components/icure-button/index.js.map +1 -1
- package/components/icure-button-group/index.js +26 -22
- package/components/icure-button-group/index.js.map +1 -1
- package/components/icure-date-picker/index.d.ts +2 -2
- package/components/icure-date-picker/index.js +31 -27
- package/components/icure-date-picker/index.js.map +1 -1
- package/components/icure-dropdown-field/index.js +25 -21
- package/components/icure-dropdown-field/index.js.map +1 -1
- package/components/icure-form/fields/button/button.js +17 -13
- package/components/icure-form/fields/button/button.js.map +1 -1
- package/components/icure-form/fields/button/index.js +17 -1
- package/components/icure-form/fields/button/index.js.map +1 -1
- package/components/icure-form/fields/button-group/checkbox.js +14 -10
- package/components/icure-form/fields/button-group/checkbox.js.map +1 -1
- package/components/icure-form/fields/button-group/index.js +18 -2
- package/components/icure-form/fields/button-group/index.js.map +1 -1
- package/components/icure-form/fields/button-group/radio-button.js +14 -10
- package/components/icure-form/fields/button-group/radio-button.js.map +1 -1
- package/components/icure-form/fields/date-picker/date-picker.js +12 -8
- package/components/icure-form/fields/date-picker/date-picker.js.map +1 -1
- package/components/icure-form/fields/date-picker/date-time-picker.js +12 -8
- package/components/icure-form/fields/date-picker/date-time-picker.js.map +1 -1
- package/components/icure-form/fields/date-picker/index.js +19 -3
- package/components/icure-form/fields/date-picker/index.js.map +1 -1
- package/components/icure-form/fields/date-picker/time-picker.js +12 -8
- package/components/icure-form/fields/date-picker/time-picker.js.map +1 -1
- package/components/icure-form/fields/dropdown/dropdown-field.js +14 -10
- package/components/icure-form/fields/dropdown/dropdown-field.js.map +1 -1
- package/components/icure-form/fields/dropdown/index.js +17 -1
- package/components/icure-form/fields/dropdown/index.js.map +1 -1
- package/components/icure-form/fields/index.js +26 -10
- package/components/icure-form/fields/index.js.map +1 -1
- package/components/icure-form/fields/items-list-field/index.js +17 -1
- package/components/icure-form/fields/items-list-field/index.js.map +1 -1
- package/components/icure-form/fields/items-list-field/items-list-field.js +11 -7
- package/components/icure-form/fields/items-list-field/items-list-field.js.map +1 -1
- package/components/icure-form/fields/label/index.js +17 -1
- package/components/icure-form/fields/label/index.js.map +1 -1
- package/components/icure-form/fields/label/label.js +15 -11
- package/components/icure-form/fields/label/label.js.map +1 -1
- package/components/icure-form/fields/measure-field/index.js +17 -1
- package/components/icure-form/fields/measure-field/index.js.map +1 -1
- package/components/icure-form/fields/measure-field/measure-field.js +12 -8
- package/components/icure-form/fields/measure-field/measure-field.js.map +1 -1
- package/components/icure-form/fields/number-field/index.js +17 -1
- package/components/icure-form/fields/number-field/index.js.map +1 -1
- package/components/icure-form/fields/number-field/number-field.js +12 -8
- package/components/icure-form/fields/number-field/number-field.js.map +1 -1
- package/components/icure-form/fields/text-field/index.js +17 -1
- package/components/icure-form/fields/text-field/index.js.map +1 -1
- package/components/icure-form/fields/text-field/text-field.js +24 -20
- package/components/icure-form/fields/text-field/text-field.js.map +1 -1
- package/components/icure-form/fields/token-field/index.js +17 -1
- package/components/icure-form/fields/token-field/index.js.map +1 -1
- package/components/icure-form/fields/token-field/token-field.js +12 -8
- package/components/icure-form/fields/token-field/token-field.js.map +1 -1
- package/components/icure-form/fields/utils/index.js +13 -5
- package/components/icure-form/fields/utils/index.js.map +1 -1
- package/components/icure-form/index.js +32 -28
- package/components/icure-form/index.js.map +1 -1
- package/components/icure-form/renderer/form/form-selection-button.js +19 -15
- package/components/icure-form/renderer/form/form-selection-button.js.map +1 -1
- package/components/icure-form/renderer/form/form.js +127 -123
- package/components/icure-form/renderer/form/form.js.map +1 -1
- package/components/icure-form/renderer/index.js +2 -1
- package/components/icure-label/index.js +17 -13
- package/components/icure-label/index.js.map +1 -1
- package/components/icure-text-field/index.js +106 -98
- package/components/icure-text-field/index.js.map +1 -1
- package/components/icure-text-field/plugin/caret-fix-plugin.js +7 -3
- package/components/icure-text-field/plugin/caret-fix-plugin.js.map +1 -1
- package/components/icure-text-field/plugin/has-content-class-plugin.js +7 -3
- package/components/icure-text-field/plugin/has-content-class-plugin.js.map +1 -1
- package/components/icure-text-field/plugin/mask-plugin.js +11 -7
- package/components/icure-text-field/plugin/mask-plugin.js.map +1 -1
- package/components/icure-text-field/plugin/regexp-plugin.js +9 -5
- package/components/icure-text-field/plugin/regexp-plugin.js.map +1 -1
- package/components/icure-text-field/prosemirror-commands.js +15 -10
- package/components/icure-text-field/prosemirror-commands.js.map +1 -1
- package/components/icure-text-field/prosemirror-utils.js +5 -1
- package/components/icure-text-field/prosemirror-utils.js.map +1 -1
- package/components/icure-text-field/schema/common-marks.js +7 -3
- package/components/icure-text-field/schema/common-marks.js.map +1 -1
- package/components/icure-text-field/schema/date-time-schema.js +9 -3
- package/components/icure-text-field/schema/date-time-schema.js.map +1 -1
- package/components/icure-text-field/schema/decimal-schema.js +5 -1
- package/components/icure-text-field/schema/decimal-schema.js.map +1 -1
- package/components/icure-text-field/schema/index.js +21 -17
- package/components/icure-text-field/schema/index.js.map +1 -1
- package/components/icure-text-field/schema/items-list-schema.js +7 -3
- package/components/icure-text-field/schema/items-list-schema.js.map +1 -1
- package/components/icure-text-field/schema/markdown-schema.js +9 -5
- package/components/icure-text-field/schema/markdown-schema.js.map +1 -1
- package/components/icure-text-field/schema/measure-schema.js +12 -6
- package/components/icure-text-field/schema/measure-schema.js.map +1 -1
- package/components/icure-text-field/schema/token-schema.js +9 -5
- package/components/icure-text-field/schema/token-schema.js.map +1 -1
- package/components/icure-text-field/schema/utils.js +7 -2
- package/components/icure-text-field/schema/utils.js.map +1 -1
- package/components/icure-text-field/selection-companion.js +5 -1
- package/components/icure-text-field/selection-companion.js.map +1 -1
- package/components/icure-text-field/suggestion-palette.js +10 -3
- package/components/icure-text-field/suggestion-palette.js.map +1 -1
- package/components/index.js +21 -5
- package/components/index.js.map +1 -1
- package/components/model/index.js +46 -22
- package/components/model/index.js.map +1 -1
- package/components/themes/default/index.js +32 -30
- package/components/themes/default/index.js.map +1 -1
- package/components/themes/icure-blue/index.js +47 -45
- package/components/themes/icure-blue/index.js.map +1 -1
- package/components/themes/kendo/index.js +47 -45
- package/components/themes/kendo/index.js.map +1 -1
- package/conversion/ckmeans-grouping.js +10 -3
- package/conversion/ckmeans-grouping.js.map +1 -1
- package/conversion/ckmeans.js +3 -1
- package/conversion/ckmeans.js.map +1 -1
- package/generic/index.js +17 -1
- package/generic/index.js.map +1 -1
- package/generic/model.js +2 -1
- package/icure/form-values-container.d.ts +14 -14
- package/icure/form-values-container.js +45 -37
- package/icure/form-values-container.js.map +1 -1
- package/icure/icure-utils.d.ts +7 -7
- package/icure/icure-utils.js +28 -16
- package/icure/icure-utils.js.map +1 -1
- package/icure/index.js +18 -2
- package/icure/index.js.map +1 -1
- package/icure/model.d.ts +1 -1
- package/icure/model.js +2 -1
- package/icure/model.js.map +1 -1
- package/index.js +17 -1
- package/index.js.map +1 -1
- package/package.json +3 -2
- package/utils/code-utils.d.ts +10 -1
- package/utils/code-utils.js +59 -11
- package/utils/code-utils.js.map +1 -1
- package/utils/dates.js +21 -9
- package/utils/dates.js.map +1 -1
- package/utils/fields-values-provider.js +17 -8
- package/utils/fields-values-provider.js.map +1 -1
- package/utils/form-value-container.js +7 -3
- package/utils/form-value-container.js.map +1 -1
- package/utils/interpreter.js +5 -1
- package/utils/interpreter.js.map +1 -1
- package/utils/languages.js +8 -3
- package/utils/languages.js.map +1 -1
- package/utils/markdown.js +11 -6
- package/utils/markdown.js.map +1 -1
- package/utils/no-lodash.js +9 -3
- package/utils/no-lodash.js.map +1 -1
- package/utils/primitive.js +12 -7
- package/utils/primitive.js.map +1 -1
- package/conversion/icure-convert.d.ts +0 -3
- package/conversion/icure-convert.js +0 -161
- package/conversion/icure-convert.js.map +0 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -7,13 +8,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
9
|
});
|
|
9
10
|
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ContactFormValuesContainer = exports.BridgedFormValuesContainer = void 0;
|
|
13
|
+
const cardinal_sdk_1 = require("@icure/cardinal-sdk");
|
|
14
|
+
const no_lodash_1 = require("../utils/no-lodash");
|
|
15
|
+
const icure_utils_1 = require("./icure-utils");
|
|
16
|
+
const primitive_1 = require("../utils/primitive");
|
|
17
|
+
const dates_1 = require("../utils/dates");
|
|
18
|
+
const uuid_1 = require("uuid");
|
|
19
|
+
const code_utils_1 = require("../utils/code-utils");
|
|
17
20
|
function notify(l, fvc) {
|
|
18
21
|
//console.log('Notifying', l, fvc.toString())
|
|
19
22
|
l(fvc);
|
|
@@ -37,7 +40,7 @@ function notify(l, fvc) {
|
|
|
37
40
|
*
|
|
38
41
|
* This class is fairly generic and can be used as an inspiration or subclassed for other bridges
|
|
39
42
|
*/
|
|
40
|
-
|
|
43
|
+
class BridgedFormValuesContainer {
|
|
41
44
|
toString() {
|
|
42
45
|
return `Bridged(${this.contactFormValuesContainer.rootForm.formTemplateId}[${this.contactFormValuesContainer.rootForm.id}]) - ${this._id}`;
|
|
43
46
|
}
|
|
@@ -61,7 +64,7 @@ export class BridgedFormValuesContainer {
|
|
|
61
64
|
this.validatorsProvider = validatorsProvider;
|
|
62
65
|
this.language = language;
|
|
63
66
|
this.changeListeners = changeListeners;
|
|
64
|
-
this._id =
|
|
67
|
+
this._id = (0, uuid_1.v4)();
|
|
65
68
|
console.log(`Creating bridge FVC (${contactFormValuesContainer.rootForm.formTemplateId}) with ${contactFormValuesContainer.children.length} children [${this._id}]`);
|
|
66
69
|
//Before start to broadcast changes, we need to fill in the contactFormValuesContainer with the dependent values
|
|
67
70
|
this.contactFormValuesContainer = contactFormValuesContainer;
|
|
@@ -104,7 +107,7 @@ export class BridgedFormValuesContainer {
|
|
|
104
107
|
value: {
|
|
105
108
|
label: sm.label,
|
|
106
109
|
owner: sm.responsible,
|
|
107
|
-
tags: (_a = sm.tags) === null || _a === void 0 ? void 0 : _a.map(codeStubToCode),
|
|
110
|
+
tags: (_a = sm.tags) === null || _a === void 0 ? void 0 : _a.map(icure_utils_1.codeStubToCode),
|
|
108
111
|
valueDate: sm.valueDate,
|
|
109
112
|
},
|
|
110
113
|
});
|
|
@@ -116,10 +119,10 @@ export class BridgedFormValuesContainer {
|
|
|
116
119
|
modified,
|
|
117
120
|
value: {
|
|
118
121
|
content: Object.entries((_a = s.content) !== null && _a !== void 0 ? _a : {}).reduce((acc, [lng, cnt]) => {
|
|
119
|
-
const converted = contentToPrimitiveType(lng, cnt);
|
|
122
|
+
const converted = (0, icure_utils_1.contentToPrimitiveType)(lng, cnt);
|
|
120
123
|
return converted ? Object.assign(Object.assign({}, acc), { [lng]: converted }) : acc;
|
|
121
124
|
}, {}),
|
|
122
|
-
codes: (_b = s.codes) === null || _b === void 0 ? void 0 : _b.map(codeStubToCode),
|
|
125
|
+
codes: (_b = s.codes) === null || _b === void 0 ? void 0 : _b.map(icure_utils_1.codeStubToCode),
|
|
123
126
|
},
|
|
124
127
|
});
|
|
125
128
|
}) });
|
|
@@ -136,7 +139,7 @@ export class BridgedFormValuesContainer {
|
|
|
136
139
|
tags: s.tags,
|
|
137
140
|
discordantMetadata: () => {
|
|
138
141
|
var _a, _b;
|
|
139
|
-
return (Object.assign(Object.assign({}, (s.responsible !== this.responsible ? { owner: this.responsible } : {})), (Math.abs(+((_a = anyDateToDate(s.valueDate)) !== null && _a !== void 0 ? _a : 0) - +((_b = anyDateToDate(this.contact.created)) !== null && _b !== void 0 ? _b : 0)) > 24 * 3600000 ? { valueDate: s.valueDate } : {})));
|
|
142
|
+
return (Object.assign(Object.assign({}, (s.responsible !== this.responsible ? { owner: this.responsible } : {})), (Math.abs(+((_a = (0, dates_1.anyDateToDate)(s.valueDate)) !== null && _a !== void 0 ? _a : 0) - +((_b = (0, dates_1.anyDateToDate)(this.contact.created)) !== null && _b !== void 0 ? _b : 0)) > 24 * 3600000 ? { valueDate: s.valueDate } : {})));
|
|
140
143
|
},
|
|
141
144
|
},
|
|
142
145
|
})) })), {});
|
|
@@ -210,11 +213,12 @@ export class BridgedFormValuesContainer {
|
|
|
210
213
|
setValueOnContactFormValuesContainer(this.contactFormValuesContainer, label, language, fv, id, metadata);
|
|
211
214
|
}
|
|
212
215
|
setMetadata(meta, id) {
|
|
216
|
+
var _a;
|
|
213
217
|
this.contactFormValuesContainer.setMetadata({
|
|
214
218
|
label: meta.label,
|
|
215
219
|
responsible: meta.owner,
|
|
216
220
|
valueDate: meta.valueDate,
|
|
217
|
-
tags: meta.tags,
|
|
221
|
+
tags: (_a = meta.tags) === null || _a === void 0 ? void 0 : _a.map((x) => new cardinal_sdk_1.CodeStub(x)),
|
|
218
222
|
}, id);
|
|
219
223
|
}
|
|
220
224
|
delete(serviceId) {
|
|
@@ -232,7 +236,7 @@ export class BridgedFormValuesContainer {
|
|
|
232
236
|
return undefined;
|
|
233
237
|
}
|
|
234
238
|
const primitive = (_b = (_a = content[this.language]) !== null && _a !== void 0 ? _a : content['*']) !== null && _b !== void 0 ? _b : content[Object.keys(content)[0]];
|
|
235
|
-
return primitive && parsePrimitive(primitive);
|
|
239
|
+
return primitive && (0, primitive_1.parsePrimitive)(primitive);
|
|
236
240
|
};
|
|
237
241
|
const log = console.log;
|
|
238
242
|
const native = {
|
|
@@ -310,6 +314,7 @@ export class BridgedFormValuesContainer {
|
|
|
310
314
|
return this;
|
|
311
315
|
}
|
|
312
316
|
}
|
|
317
|
+
exports.BridgedFormValuesContainer = BridgedFormValuesContainer;
|
|
313
318
|
/**
|
|
314
319
|
* This class is a form values container that uses a hierarchy of forms as a data source. The actual values are extracted from the services of the contacts.
|
|
315
320
|
* The `currentContact` is the contact that has been selected by the user, any later contact should be ignored.
|
|
@@ -318,7 +323,7 @@ export class BridgedFormValuesContainer {
|
|
|
318
323
|
* Each ContactFormValuesContainer has a reference to its `rootForm`.
|
|
319
324
|
* The `serviceFactory` and `formFactory` are used to create new services and add sub-forms.
|
|
320
325
|
*/
|
|
321
|
-
|
|
326
|
+
class ContactFormValuesContainer {
|
|
322
327
|
toString() {
|
|
323
328
|
return `Contact(${this.rootForm.formTemplateId}[${this.rootForm.id}]) - ${this._id}`;
|
|
324
329
|
}
|
|
@@ -332,9 +337,11 @@ export class ContactFormValuesContainer {
|
|
|
332
337
|
var _a, _b, _c;
|
|
333
338
|
const childrenContacts = this.children.map((c) => c.coordinatedContact());
|
|
334
339
|
const thisKeptServiceIds = ((_a = this.currentContact.subContacts) !== null && _a !== void 0 ? _a : []).filter((sc) => sc.formId === this.rootForm.id).flatMap((sc) => { var _a; return ((_a = sc.services) !== null && _a !== void 0 ? _a : []).map((s) => s.serviceId); });
|
|
335
|
-
return Object.assign(Object.assign({}, this.currentContact), { services: childrenContacts
|
|
340
|
+
return new cardinal_sdk_1.DecryptedContact(Object.assign(Object.assign({}, this.currentContact), { services: childrenContacts
|
|
341
|
+
.reduce((acc, c) => { var _a; return acc.concat((_a = c.services) !== null && _a !== void 0 ? _a : []); }, [])
|
|
342
|
+
.concat(((_b = this.currentContact.services) !== null && _b !== void 0 ? _b : []).filter((s) => thisKeptServiceIds.includes(s.id))), subContacts: childrenContacts
|
|
336
343
|
.reduce((acc, c) => { var _a; return acc.concat((_a = c.subContacts) !== null && _a !== void 0 ? _a : []); }, [])
|
|
337
|
-
.concat(((_c = this.currentContact.subContacts) !== null && _c !== void 0 ? _c : []).filter((s) => s.formId === this.rootForm.id)) });
|
|
344
|
+
.concat(((_c = this.currentContact.subContacts) !== null && _c !== void 0 ? _c : []).filter((s) => s.formId === this.rootForm.id)) }));
|
|
338
345
|
}
|
|
339
346
|
/**
|
|
340
347
|
* Returns a contact that combines the content of the contact in this form with the content of all contents stored in the children
|
|
@@ -343,7 +350,7 @@ export class ContactFormValuesContainer {
|
|
|
343
350
|
return [this.rootForm].concat(this.children.flatMap((c) => c.allForms()));
|
|
344
351
|
}
|
|
345
352
|
constructor(rootForm, currentContact, contactsHistory, serviceFactory, children, formFactory, formRecycler, changeListeners = [], initialised = true) {
|
|
346
|
-
this._id =
|
|
353
|
+
this._id = (0, uuid_1.v4)();
|
|
347
354
|
this._initialised = false;
|
|
348
355
|
console.log(`Creating contact FVC (${rootForm.formTemplateId}) with ${children.length} children [${this._id}]`);
|
|
349
356
|
if (contactsHistory.includes(currentContact)) {
|
|
@@ -351,7 +358,7 @@ export class ContactFormValuesContainer {
|
|
|
351
358
|
}
|
|
352
359
|
this.rootForm = rootForm;
|
|
353
360
|
this.currentContact = currentContact;
|
|
354
|
-
this.contactsHistory = sortedBy(contactsHistory, 'created', 'desc');
|
|
361
|
+
this.contactsHistory = (0, no_lodash_1.sortedBy)(contactsHistory, 'created', 'desc');
|
|
355
362
|
this.children = children;
|
|
356
363
|
this.serviceFactory = serviceFactory;
|
|
357
364
|
this.formFactory = formFactory;
|
|
@@ -447,11 +454,11 @@ export class ContactFormValuesContainer {
|
|
|
447
454
|
(meta.valueDate && service.valueDate !== meta.valueDate) ||
|
|
448
455
|
(meta.codes && service.codes !== meta.codes) ||
|
|
449
456
|
(meta.tags && service.tags !== meta.tags)) {
|
|
450
|
-
const newService = new
|
|
457
|
+
const newService = new cardinal_sdk_1.DecryptedService(Object.assign(Object.assign({}, service), { modified: Date.now() }));
|
|
451
458
|
meta.responsible && (newService.responsible = meta.responsible);
|
|
452
459
|
meta.valueDate && (newService.valueDate = meta.valueDate);
|
|
453
|
-
meta.codes && (newService.codes = normalizeCodes(meta.codes));
|
|
454
|
-
meta.tags && (newService.tags = normalizeCodes(meta.tags));
|
|
460
|
+
meta.codes && (newService.codes = (0, code_utils_1.normalizeCodes)(meta.codes));
|
|
461
|
+
meta.tags && (newService.tags = (0, code_utils_1.normalizeCodes)(meta.tags));
|
|
455
462
|
const newFormValuesContainer = new ContactFormValuesContainer(this.rootForm, Object.assign(Object.assign({}, this.currentContact), { services: (_a = this.currentContact.services) === null || _a === void 0 ? void 0 : _a.map((s) => (s.id === service.id ? newService : s)) }), this.contactsHistory, this.serviceFactory, this.children, this.formFactory, this.formRecycler, this.changeListeners);
|
|
456
463
|
this.changeListeners.forEach((l) => notify(l, newFormValuesContainer));
|
|
457
464
|
}
|
|
@@ -464,9 +471,9 @@ export class ContactFormValuesContainer {
|
|
|
464
471
|
}
|
|
465
472
|
console.log('Setting value of service', service.id, 'with', value, 'and metadata', metadata);
|
|
466
473
|
const newContent = (_c = value === null || value === void 0 ? void 0 : value.content) === null || _c === void 0 ? void 0 : _c[language];
|
|
467
|
-
const newCodes = (value === null || value === void 0 ? void 0 : value.codes) ? normalizeCodes(value.codes) : [];
|
|
468
|
-
if (!isContentEqual((_d = service.content) === null || _d === void 0 ? void 0 : _d[language], newContent) || (newCodes && !areCodesEqual(newCodes, (_e = service.codes) !== null && _e !== void 0 ? _e : []))) {
|
|
469
|
-
const newService = new
|
|
474
|
+
const newCodes = (value === null || value === void 0 ? void 0 : value.codes) ? (0, code_utils_1.normalizeCodes)(value.codes) : [];
|
|
475
|
+
if (!(0, icure_utils_1.isContentEqual)((_d = service.content) === null || _d === void 0 ? void 0 : _d[language], newContent) || (newCodes && !(0, icure_utils_1.areCodesEqual)(newCodes, (_e = service.codes) !== null && _e !== void 0 ? _e : []))) {
|
|
476
|
+
const newService = new cardinal_sdk_1.DecryptedService(Object.assign(Object.assign({}, service), { modified: Date.now() }));
|
|
470
477
|
const newContents = newContent
|
|
471
478
|
? Object.assign(Object.assign({}, (service.content || {})), { [language]: newContent }) : Object.assign({}, (service.content || {}));
|
|
472
479
|
if (!newContent) {
|
|
@@ -484,7 +491,7 @@ export class ContactFormValuesContainer {
|
|
|
484
491
|
return sc;
|
|
485
492
|
}
|
|
486
493
|
})
|
|
487
|
-
: ((_h = this.currentContact.subContacts) !== null && _h !== void 0 ? _h : []).concat({ formId: this.rootForm.id, services: [{ serviceId: service.id }] }), services: ((_j = this.currentContact.services) !== null && _j !== void 0 ? _j : []).some((s) => s.id === service.id)
|
|
494
|
+
: ((_h = this.currentContact.subContacts) !== null && _h !== void 0 ? _h : []).concat(new cardinal_sdk_1.DecryptedSubContact({ formId: this.rootForm.id, services: [{ serviceId: service.id }] })), services: ((_j = this.currentContact.services) !== null && _j !== void 0 ? _j : []).some((s) => s.id === service.id)
|
|
488
495
|
? ((_k = this.currentContact.services) !== null && _k !== void 0 ? _k : []).filter((s) => s.id !== service.id)
|
|
489
496
|
: [...((_l = this.currentContact.services) !== null && _l !== void 0 ? _l : [])] });
|
|
490
497
|
}
|
|
@@ -494,7 +501,7 @@ export class ContactFormValuesContainer {
|
|
|
494
501
|
if (metadata) {
|
|
495
502
|
newService.responsible = (_m = metadata.responsible) !== null && _m !== void 0 ? _m : newService.responsible;
|
|
496
503
|
newService.valueDate = (_o = metadata.valueDate) !== null && _o !== void 0 ? _o : newService.valueDate;
|
|
497
|
-
newService.tags = metadata.tags ? normalizeCodes(metadata.tags) : newService.tags;
|
|
504
|
+
newService.tags = metadata.tags ? (0, code_utils_1.normalizeCodes)(metadata.tags) : newService.tags;
|
|
498
505
|
newService.label = (_p = metadata.label) !== null && _p !== void 0 ? _p : newService.label;
|
|
499
506
|
}
|
|
500
507
|
newCurrentContact = Object.assign(Object.assign({}, this.currentContact), { subContacts: ((_q = this.currentContact.subContacts) !== null && _q !== void 0 ? _q : []).some((sc) => sc.formId === this.rootForm.id)
|
|
@@ -507,7 +514,7 @@ export class ContactFormValuesContainer {
|
|
|
507
514
|
return sc;
|
|
508
515
|
}
|
|
509
516
|
})
|
|
510
|
-
: ((_s = this.currentContact.subContacts) !== null && _s !== void 0 ? _s : []).concat({ formId: this.rootForm.id, services: [{ serviceId: service.id }] }), services: ((_t = this.currentContact.services) !== null && _t !== void 0 ? _t : []).some((s) => s.id === service.id)
|
|
517
|
+
: ((_s = this.currentContact.subContacts) !== null && _s !== void 0 ? _s : []).concat(new cardinal_sdk_1.DecryptedSubContact({ formId: this.rootForm.id, services: [{ serviceId: service.id }] })), services: ((_t = this.currentContact.services) !== null && _t !== void 0 ? _t : []).some((s) => s.id === service.id)
|
|
511
518
|
? ((_u = this.currentContact.services) !== null && _u !== void 0 ? _u : []).map((s) => (s.id === service.id ? newService : s))
|
|
512
519
|
: [...((_v = this.currentContact.services) !== null && _v !== void 0 ? _v : []), newService] });
|
|
513
520
|
}
|
|
@@ -520,7 +527,7 @@ export class ContactFormValuesContainer {
|
|
|
520
527
|
const service = this.getServiceInCurrentContact(serviceId);
|
|
521
528
|
if (service) {
|
|
522
529
|
const newFormValuesContainer = new ContactFormValuesContainer(this.rootForm, Object.assign(Object.assign({}, this.currentContact), { services: (_a = this.currentContact.services) === null || _a === void 0 ? void 0 : _a.map((s) => s.id === serviceId
|
|
523
|
-
? new
|
|
530
|
+
? new cardinal_sdk_1.DecryptedService(Object.assign(Object.assign({}, service), { endOfLife: Date.now() }))
|
|
524
531
|
: s) }), this.contactsHistory, this.serviceFactory, this.children, this.formFactory, this.formRecycler, this.changeListeners);
|
|
525
532
|
this.changeListeners.forEach((l) => notify(l, newFormValuesContainer));
|
|
526
533
|
}
|
|
@@ -591,23 +598,24 @@ export class ContactFormValuesContainer {
|
|
|
591
598
|
});
|
|
592
599
|
}
|
|
593
600
|
}
|
|
601
|
+
exports.ContactFormValuesContainer = ContactFormValuesContainer;
|
|
594
602
|
const setValueOnContactFormValuesContainer = (cfvc, label, language, fv, id, metadata, changeListenersOverrider) => {
|
|
595
|
-
var _a, _b;
|
|
603
|
+
var _a, _b, _c, _d;
|
|
596
604
|
const value = fv === null || fv === void 0 ? void 0 : fv.content[language];
|
|
597
|
-
cfvc.setValue(label, language, {
|
|
605
|
+
cfvc.setValue(label, language, new cardinal_sdk_1.DecryptedService({
|
|
598
606
|
id: id,
|
|
599
|
-
codes: (_a = fv === null || fv === void 0 ? void 0 : fv.codes) !== null &&
|
|
607
|
+
codes: (_b = (_a = fv === null || fv === void 0 ? void 0 : fv.codes) === null || _a === void 0 ? void 0 : _a.map((x) => new cardinal_sdk_1.CodeStub(x))) !== null && _b !== void 0 ? _b : [],
|
|
600
608
|
content: value
|
|
601
609
|
? {
|
|
602
|
-
[language]: primitiveTypeToContent(language, value),
|
|
610
|
+
[language]: (0, icure_utils_1.primitiveTypeToContent)(language, value),
|
|
603
611
|
}
|
|
604
612
|
: undefined,
|
|
605
|
-
}, id, metadata
|
|
613
|
+
}), id, metadata
|
|
606
614
|
? {
|
|
607
|
-
label: (
|
|
615
|
+
label: (_c = metadata === null || metadata === void 0 ? void 0 : metadata.label) !== null && _c !== void 0 ? _c : label,
|
|
608
616
|
responsible: metadata === null || metadata === void 0 ? void 0 : metadata.owner,
|
|
609
617
|
valueDate: metadata === null || metadata === void 0 ? void 0 : metadata.valueDate,
|
|
610
|
-
tags: metadata === null || metadata === void 0 ? void 0 : metadata.tags,
|
|
618
|
+
tags: (_d = metadata === null || metadata === void 0 ? void 0 : metadata.tags) === null || _d === void 0 ? void 0 : _d.map((x) => new cardinal_sdk_1.CodeStub(x)),
|
|
611
619
|
}
|
|
612
620
|
: undefined, changeListenersOverrider);
|
|
613
621
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form-values-container.js","sourceRoot":"","sources":["../../tmp/icure/form-values-container.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAoC,OAAO,EAAE,MAAM,YAAY,CAAA;AACtE,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAI7C,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,sBAAsB,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAA;AAC7H,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAA;AACnC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAEpD,SAAS,MAAM,CAAkB,CAAsD,EAAE,GAAyC;IACjI,6CAA6C;IAC7C,CAAC,CAAC,GAAG,CAAC,CAAA;AACP,CAAC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,OAA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EAAE,EAAE,EAAE;QACN,KAAK,EAAE,MAAA,EAAE,aAAF,EAAE,uBAAF,EAAE,CAAE,KAAK,mCAAI,EAAE;QACtB,OAAO,EAAE,KAAK;YACb,CAAC,CAAC;gBACA,CAAC,QAAQ,CAAC,EAAE,sBAAsB,CAAC,QAAQ,EAAE,KAAK,CAAC;aAClD;YACH,CAAC,CAAC,SAAS;KACZ,EACD,EAAE,EACF,QAAQ;QACP,CAAC,CAAC;YACA,KAAK,EAAE,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,KAAK,mCAAI,KAAK;YAC/B,WAAW,EAAE,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,KAAK;YAC5B,SAAS,EAAE,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,SAAS;YAC9B,IAAI,EAAE,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI;SACnB;QACH,CAAC,CAAC,SAAS,EACZ,wBAAwB,CACxB,CAAA;AACF,CAAC,CAAA","sourcesContent":["import { Contact, Form, Form as ICureForm, Service } from '@icure/api'\nimport { sortedBy } from '../utils/no-lodash'\nimport { FormValuesContainer, Version, VersionedData } from '../generic'\nimport { ServiceMetadata } from './model'\nimport { FieldMetadata, FieldValue, PrimitiveType, Validator } from '../components/model'\nimport { areCodesEqual, codeStubToCode, contentToPrimitiveType, isContentEqual, primitiveTypeToContent } from './icure-utils'\nimport { parsePrimitive } from '../utils/primitive'\nimport { anyDateToDate } from '../utils/dates'\nimport { v4 as uuidv4 } from 'uuid'\nimport { normalizeCodes } from '../utils/code-utils'\n\nfunction notify<Value, Metadata>(l: (fvc: FormValuesContainer<Value, Metadata>) => void, fvc: FormValuesContainer<Value, Metadata>) {\n\t//console.log('Notifying', l, fvc.toString())\n\tl(fvc)\n}\n\n/** This class is a bridge between the ICure API and the generic FormValuesContainer interface.\n * It wraps around a ContactFormValuesContainer and provides a series of services:\n * - It computes dependent values when the form is created\n * - It broadcasts changes from the wrapped ContactFormValuesContainer to its listeners\n * - It provides a way to compute formulas in a sandboxed environment\n * - It bridges the setValues and setMetadata methods with the wrapped ContactFormValuesContainer by\n * \t\t- converting the FieldValue to a Service\n * \t\t- converting the FieldMetadata to a ServiceMetadata\n * - It bridges the getValues and getMetadata methods with the wrapped ContactFormValuesContainer by\n * \t\t- converting the Service to a FieldValue\n * \t\t- converting the ServiceMetadata to a FieldMetadata\n * - It lazily creates bridges the children by\n * - lazily creating BridgedFormValuesContainer when the children of the wrapped ContactFormValuesContainer are accessed\n * - creating a new ContactFormValuesContainer and wrapping it in a BridgedFormValuesContainer when a child is added\n *\n * The icure-form typically accepts a BridgedFormValuesContainer as a prop and uses it to interact with the form.\n *\n * This class is fairly generic and can be used as an inspiration or subclassed for other bridges\n */\nexport class BridgedFormValuesContainer implements FormValuesContainer<FieldValue, FieldMetadata> {\n\tprivate contact: Contact\n\tprivate contactFormValuesContainer: ContactFormValuesContainer\n\tprivate _id: string = uuidv4()\n\tprivate mutateAndNotify: (newContactFormValuesContainer: ContactFormValuesContainer) => BridgedFormValuesContainer\n\n\ttoString(): string {\n\t\treturn `Bridged(${this.contactFormValuesContainer.rootForm.formTemplateId}[${this.contactFormValuesContainer.rootForm.id}]) - ${this._id}`\n\t}\n\n\t/**\n\t * Creates an instance of BridgedFormValuesContainer.\n\t * @param responsible The id of the data owner responsible for the creation of the values\n\t * @param contact The displayed contact (may be in the past). === to currentContact if the contact is the contact of the day\n\t * @param contactFormValuesContainer The wrapped ContactFormValuesContainer\n\t * @param interpreter A function that can interpret formulas\n\t * @param dependentValuesProvider A function that provides the dependent values (computed on the basis of other values) for a given anchorId and templateId\n\t * @param validatorsProvider A function that provides the validators for a given anchorId and templateId\n\t * @param language The language in which the values are displayed\n\t * @param changeListeners The listeners that will be notified when the values change\n\t * @param initialValuesProvider A lambda that provides the initial values of the form\n\t */\n\tconstructor(\n\t\tprivate responsible: string,\n\t\tcontactFormValuesContainer: ContactFormValuesContainer,\n\t\tprivate interpreter?: <\n\t\t\tT,\n\t\t\tS extends {\n\t\t\t\t[key: string | symbol]: unknown\n\t\t\t},\n\t\t>(\n\t\t\tformula: string,\n\t\t\tsandbox: S,\n\t\t) => T | undefined,\n\t\tcontact?: Contact,\n\t\tprivate initialValuesProvider: (\n\t\t\tanchorId?: string,\n\t\t\ttemplateId?: string,\n\t\t) => {\n\t\t\tmetadata: FieldMetadata\n\t\t\trevisionsFilter: (id: string, history: Version<FieldMetadata>[]) => (string | null)[]\n\t\t\tformula: string\n\t\t}[] = () => [],\n\t\tprivate dependentValuesProvider: (\n\t\t\tanchorId: string | undefined,\n\t\t\ttemplateId: string | undefined,\n\t\t) => {\n\t\t\tmetadata: FieldMetadata\n\t\t\trevisionsFilter: (id: string, history: Version<FieldMetadata>[]) => (string | null)[]\n\t\t\tformula: string\n\t\t}[] = () => [],\n\t\tprivate validatorsProvider: (\n\t\t\tanchorId: string | undefined,\n\t\t\ttemplateId: string,\n\t\t) => {\n\t\t\tmetadata: FieldMetadata\n\t\t\tvalidators: Validator[]\n\t\t}[] = () => [],\n\t\tprivate language = 'en',\n\t\tprivate changeListeners: ((newValue: BridgedFormValuesContainer) => void)[] = [],\n\t) {\n\t\tconsole.log(`Creating bridge FVC (${contactFormValuesContainer.rootForm.formTemplateId}) with ${contactFormValuesContainer.children.length} children [${this._id}]`)\n\t\t//Before start to broadcast changes, we need to fill in the contactFormValuesContainer with the dependent values\n\t\tthis.contactFormValuesContainer = contactFormValuesContainer\n\t\tthis.mutateAndNotify = (newContactFormValuesContainer: ContactFormValuesContainer) => {\n\t\t\tnewContactFormValuesContainer.unregisterChangeListener(this.mutateAndNotify)\n\t\t\tconst newBridgedFormValueContainer = new BridgedFormValuesContainer(\n\t\t\t\tthis.responsible,\n\t\t\t\tnewContactFormValuesContainer,\n\t\t\t\tthis.interpreter,\n\t\t\t\tthis.contact === this.contactFormValuesContainer.currentContact ? newContactFormValuesContainer.currentContact : this.contact,\n\t\t\t\tthis.initialValuesProvider,\n\t\t\t\tthis.dependentValuesProvider,\n\t\t\t\tthis.validatorsProvider,\n\t\t\t\tthis.language,\n\t\t\t\tthis.changeListeners,\n\t\t\t)\n\t\t\tthis.changeListeners.forEach((l) => notify(l, newBridgedFormValueContainer))\n\t\t\treturn newBridgedFormValueContainer\n\t\t}\n\t\tthis.contactFormValuesContainer.registerChangeListener(this.mutateAndNotify)\n\t\tthis.contact = contact ?? contactFormValuesContainer.currentContact\n\t\tif (this.contactFormValuesContainer.mustBeInitialised()) {\n\t\t\tthis.computeInitialValues()\n\t\t}\n\t\tthis.computeDependentValues()\n\t}\n\n\tgetLabel(): string {\n\t\treturn this.contactFormValuesContainer.getLabel()\n\t}\n\n\tgetFormId(): string | undefined {\n\t\treturn this.contactFormValuesContainer.getFormId()\n\t}\n\n\tgetContactFormValuesContainer() {\n\t\treturn this.contactFormValuesContainer\n\t}\n\n\tregisterChangeListener(listener: (newValue: BridgedFormValuesContainer) => void): void {\n\t\tthis.changeListeners.push(listener)\n\t}\n\n\tunregisterChangeListener(listener: (newValue: BridgedFormValuesContainer) => void): void {\n\t\tthis.changeListeners = this.changeListeners.filter((l) => l !== listener)\n\t}\n\n\tgetValues(revisionsFilter: (id: string, history: Version<FieldMetadata>[]) => (string | null)[]): VersionedData<FieldValue> {\n\t\treturn Object.entries(\n\t\t\tthis.contactFormValuesContainer.getValues((id, history) =>\n\t\t\t\trevisionsFilter(\n\t\t\t\t\tid,\n\t\t\t\t\thistory\n\t\t\t\t\t\t.filter(({ modified }) => !this.contact.created || !modified || modified <= this.contact.created)\n\t\t\t\t\t\t.map(({ revision, modified, value: sm }) => ({\n\t\t\t\t\t\t\trevision,\n\t\t\t\t\t\t\tmodified,\n\t\t\t\t\t\t\tvalue: {\n\t\t\t\t\t\t\t\tlabel: sm.label,\n\t\t\t\t\t\t\t\towner: sm.responsible,\n\t\t\t\t\t\t\t\ttags: sm.tags?.map(codeStubToCode),\n\t\t\t\t\t\t\t\tvalueDate: sm.valueDate,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t})),\n\t\t\t\t),\n\t\t\t),\n\t\t).reduce((acc, [id, history]) => {\n\t\t\treturn {\n\t\t\t\t...acc,\n\t\t\t\t[id]: history.map(({ revision, modified, value: s }) => ({\n\t\t\t\t\trevision,\n\t\t\t\t\tmodified,\n\t\t\t\t\tvalue: {\n\t\t\t\t\t\tcontent: Object.entries(s.content ?? {}).reduce((acc, [lng, cnt]) => {\n\t\t\t\t\t\t\tconst converted = contentToPrimitiveType(lng, cnt)\n\t\t\t\t\t\t\treturn converted ? { ...acc, [lng]: converted } : acc\n\t\t\t\t\t\t}, {}),\n\t\t\t\t\t\tcodes: s.codes?.map(codeStubToCode),\n\t\t\t\t\t},\n\t\t\t\t})),\n\t\t\t}\n\t\t}, {} as VersionedData<FieldValue>)\n\t}\n\n\tgetMetadata(id: string, revisions: (string | null)[]): VersionedData<FieldMetadata> {\n\t\treturn Object.entries(this.contactFormValuesContainer.getMetadata(id, revisions)).reduce(\n\t\t\t(acc, [id, history]) => ({\n\t\t\t\t...acc,\n\t\t\t\t[id]: history.map(({ revision, modified, value: s }) => ({\n\t\t\t\t\trevision,\n\t\t\t\t\tmodified,\n\t\t\t\t\tvalue: {\n\t\t\t\t\t\tlabel: s.label,\n\t\t\t\t\t\towner: s.responsible,\n\t\t\t\t\t\tvalueDate: s.valueDate,\n\t\t\t\t\t\ttags: s.tags,\n\t\t\t\t\t\tdiscordantMetadata: () => ({\n\t\t\t\t\t\t\t...(s.responsible !== this.responsible ? { owner: this.responsible } : {}),\n\t\t\t\t\t\t\t...(Math.abs(+(anyDateToDate(s.valueDate) ?? 0) - +(anyDateToDate(this.contact.created) ?? 0)) > 24 * 3600000 ? { valueDate: s.valueDate } : {}),\n\t\t\t\t\t\t}),\n\t\t\t\t\t},\n\t\t\t\t})),\n\t\t\t}),\n\t\t\t{},\n\t\t)\n\t}\n\n\t//This method mutates the BridgedFormValuesContainer but can only be called from the constructor\n\tprivate computeInitialValues() {\n\t\tif (this.contactFormValuesContainer.rootForm.formTemplateId) {\n\t\t\tthis.initialValuesProvider(this.contactFormValuesContainer.rootForm.descr, this.contactFormValuesContainer.rootForm.formTemplateId).forEach(({ metadata, revisionsFilter, formula }) => {\n\t\t\t\ttry {\n\t\t\t\t\tconst currentValue = this.getValues(revisionsFilter)\n\t\t\t\t\tif (!currentValue || !Object.keys(currentValue).length) {\n\t\t\t\t\t\tconst newValue = this.compute(formula) as FieldValue | undefined\n\t\t\t\t\t\tif (newValue !== undefined) {\n\t\t\t\t\t\t\tconst lng = this.language ?? 'en'\n\t\t\t\t\t\t\tif (newValue && !newValue.content[lng] && newValue.content['*']) {\n\t\t\t\t\t\t\t\tnewValue.content[lng] = newValue.content['*']\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (newValue) {\n\t\t\t\t\t\t\t\tdelete newValue.content['*']\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tsetValueOnContactFormValuesContainer(this.contactFormValuesContainer, metadata.label, lng, newValue, undefined, metadata, (fvc: ContactFormValuesContainer) => {\n\t\t\t\t\t\t\t\tconst currentContact = this.contactFormValuesContainer.currentContact\n\t\t\t\t\t\t\t\tthis.contactFormValuesContainer = fvc\n\t\t\t\t\t\t\t\tif (this.contact === currentContact) {\n\t\t\t\t\t\t\t\t\tthis.contact = fvc.currentContact\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} catch (e) {\n\t\t\t\t\tconsole.log(`Error while computing formula : ${formula}`, e)\n\t\t\t\t}\n\t\t\t})\n\t\t}\n\t}\n\n\t//This method mutates the BridgedFormValuesContainer but can only be called from the constructor\n\tprivate computeDependentValues() {\n\t\tif (this.contactFormValuesContainer.rootForm.formTemplateId) {\n\t\t\tthis.dependentValuesProvider(this.contactFormValuesContainer.rootForm.descr, this.contactFormValuesContainer.rootForm.formTemplateId).forEach(({ metadata, revisionsFilter, formula }) => {\n\t\t\t\ttry {\n\t\t\t\t\tconst currentValue = this.getValues(revisionsFilter)\n\t\t\t\t\tconst newValue = this.compute(formula) as FieldValue | undefined\n\t\t\t\t\tif (newValue !== undefined || currentValue != undefined) {\n\t\t\t\t\t\tconst lng = this.language ?? 'en'\n\t\t\t\t\t\tif (newValue && !newValue.content[lng] && newValue.content['*']) {\n\t\t\t\t\t\t\tnewValue.content[lng] = newValue.content['*']\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (newValue) {\n\t\t\t\t\t\t\tdelete newValue.content['*']\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst interceptor = (fvc: ContactFormValuesContainer) => {\n\t\t\t\t\t\t\tconst currentContact = this.contactFormValuesContainer.currentContact\n\t\t\t\t\t\t\tthis.contactFormValuesContainer = fvc\n\t\t\t\t\t\t\tif (this.contact === currentContact) {\n\t\t\t\t\t\t\t\tthis.contact = fvc.currentContact\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsetValueOnContactFormValuesContainer(this.contactFormValuesContainer, metadata.label, lng, newValue, Object.keys(currentValue ?? {})[0], metadata, interceptor)\n\t\t\t\t\t}\n\t\t\t\t} catch (e) {\n\t\t\t\t\tconsole.log(`Error while computing formula : ${formula}`, e)\n\t\t\t\t}\n\t\t\t})\n\t\t}\n\t}\n\n\tsetValue(label: string, language: string, fv?: FieldValue, id?: string, metadata?: FieldMetadata): void {\n\t\tsetValueOnContactFormValuesContainer(this.contactFormValuesContainer, label, language, fv, id, metadata)\n\t}\n\n\tsetMetadata(meta: FieldMetadata, id?: string | undefined): void {\n\t\tthis.contactFormValuesContainer.setMetadata(\n\t\t\t{\n\t\t\t\tlabel: meta.label,\n\t\t\t\tresponsible: meta.owner,\n\t\t\t\tvalueDate: meta.valueDate,\n\t\t\t\ttags: meta.tags,\n\t\t\t},\n\t\t\tid,\n\t\t)\n\t}\n\n\tdelete(serviceId: string): void {\n\t\tthis.contactFormValuesContainer.delete(serviceId)\n\t}\n\n\tprivate getVersionedValuesForKey(key: string | symbol) {\n\t\treturn this.getValues((id, history) => (history?.[0]?.value?.label && key === history[0].value.label ? [history?.[0]?.revision] : []))\n\t}\n\n\tcompute<T, S extends { [key: string | symbol]: unknown }>(formula: string, sandbox?: S): T | undefined {\n\t\t// noinspection JSUnusedGlobalSymbols\n\t\tconst parseContent = (content?: { [key: string]: PrimitiveType }) => {\n\t\t\tif (!content) {\n\t\t\t\treturn undefined\n\t\t\t}\n\t\t\tconst primitive = content[this.language] ?? content['*'] ?? content[Object.keys(content)[0]]\n\t\t\treturn primitive && parsePrimitive(primitive)\n\t\t}\n\t\tconst log = console.log\n\t\tconst native = {\n\t\t\tparseInt: parseInt,\n\t\t\tparseFloat: parseFloat,\n\t\t\tDate: Date,\n\t\t\tMath: Math,\n\t\t\tNumber: Number,\n\t\t\tString: String,\n\t\t\tBoolean: Boolean,\n\t\t\tArray: Array,\n\t\t\tObject: Object,\n\t\t\tparseContent,\n\t\t\tvalidate: {\n\t\t\t\tnotBlank: (self: any, label: string) => {\n\t\t\t\t\tconst value = parseContent((self[label as any] as any)?.[0]?.content)\n\t\t\t\t\treturn !!(value as any)?.trim()?.length\n\t\t\t\t},\n\t\t\t},\n\t\t\tlog,\n\t\t} as { [key: string]: any }\n\t\tconst proxy: S = new Proxy({} as S, {\n\t\t\thas: (target: S, key: string | symbol) => !!native[key as string] || key === 'self' || Object.keys(this.getVersionedValuesForKey(key) ?? {}).length > 0,\n\t\t\tget: (target: S, key: string | symbol) => {\n\t\t\t\tif (key === 'undefined') {\n\t\t\t\t\treturn undefined\n\t\t\t\t}\n\t\t\t\tconst nativeValue = native[key as string]\n\t\t\t\tif (!!nativeValue) {\n\t\t\t\t\treturn nativeValue\n\t\t\t\t}\n\t\t\t\treturn key === 'self' ? proxy : Object.values(this.getVersionedValuesForKey(key)).map((v) => v[0]?.value)\n\t\t\t},\n\t\t})\n\t\treturn this.interpreter?.(formula, sandbox ?? proxy)\n\t}\n\n\tgetChildren(): FormValuesContainer<FieldValue, FieldMetadata>[] {\n\t\tconst children = this.contactFormValuesContainer\n\t\t\t.getChildren()\n\t\t\t.map(\n\t\t\t\t(fvc) =>\n\t\t\t\t\tnew BridgedFormValuesContainer(this.responsible, fvc, this.interpreter, this.contact, this.initialValuesProvider, this.dependentValuesProvider, this.validatorsProvider, this.language, []),\n\t\t\t)\n\t\tconsole.log(`${children.length} children found in ${this.contactFormValuesContainer.rootForm.formTemplateId} initialised with `, this.initialValuesProvider)\n\t\treturn children\n\t}\n\n\tgetValidationErrors(): [FieldMetadata, string][] {\n\t\tif (this.contactFormValuesContainer.rootForm.formTemplateId) {\n\t\t\treturn this.validatorsProvider(this.contactFormValuesContainer.rootForm.descr, this.contactFormValuesContainer.rootForm.formTemplateId).flatMap(\n\t\t\t\t({ metadata, validators }) =>\n\t\t\t\t\tvalidators\n\t\t\t\t\t\t.map(({ validation, message }) => {\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\treturn this.compute(validation) ? undefined : [metadata, message]\n\t\t\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\t\t\tconsole.log(`Error while computing validation : ${validation}`, e)\n\t\t\t\t\t\t\t\treturn undefined\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.filter((x) => !!x) as [FieldMetadata, string][],\n\t\t\t)\n\t\t} else {\n\t\t\treturn []\n\t\t}\n\t}\n\n\tasync addChild(anchorId: string, templateId: string, label: string): Promise<void> {\n\t\tawait this.contactFormValuesContainer.addChild(anchorId, templateId, label)\n\t}\n\n\tasync removeChild(container: BridgedFormValuesContainer): Promise<void> {\n\t\tawait this.contactFormValuesContainer.removeChild(container.contactFormValuesContainer)\n\t}\n\n\tsynchronise() {\n\t\tthis.contactFormValuesContainer.synchronise()\n\t\treturn this\n\t}\n}\n\n/**\n * This class is a form values container that uses a hierarchy of forms as a data source. The actual values are extracted from the services of the contacts.\n * The `currentContact` is the contact that has been selected by the user, any later contact should be ignored.\n * The `contactsHistory` is used to provide the full history of the services.\n * The hierarchy of ContactFormValuesContainer has to be maintained by the manager of the instances of this class (typically the BridgedFormValuesContainer).\n * Each ContactFormValuesContainer has a reference to its `rootForm`.\n * The `serviceFactory` and `formFactory` are used to create new services and add sub-forms.\n */\nexport class ContactFormValuesContainer implements FormValuesContainer<Service, ServiceMetadata> {\n\trootForm: ICureForm\n\tcurrentContact: Contact //The contact of the moment, used to record new modifications\n\tcontactsHistory: Contact[] //Must be sorted (most recent first), contains all the contacts linked to this form\n\tchildren: ContactFormValuesContainer[] //Direct children of the ContactFormValuesContainer\n\tserviceFactory: (label: string, serviceId?: string) => Service\n\tformFactory: (parentId: string, anchorId: string, formTemplateId: string, label: string) => Promise<ICureForm>\n\tformRecycler: (formId: string) => Promise<void>\n\n\tchangeListeners: ((newValue: ContactFormValuesContainer) => void)[]\n\tprivate _id: string = uuidv4()\n\tprivate _initialised = false\n\n\ttoString(): string {\n\t\treturn `Contact(${this.rootForm.formTemplateId}[${this.rootForm.id}]) - ${this._id}`\n\t}\n\n\tmustBeInitialised() {\n\t\treturn !this._initialised\n\t}\n\n\t/**\n\t * Returns a contact that combines the content of the contact in this form with the content of all contents stored in the children\n\t */\n\tcoordinatedContact(): Contact {\n\t\tconst childrenContacts = this.children.map((c) => c.coordinatedContact())\n\t\tconst thisKeptServiceIds = (this.currentContact.subContacts ?? []).filter((sc) => sc.formId === this.rootForm.id).flatMap((sc) => (sc.services ?? []).map((s) => s.serviceId))\n\t\treturn {\n\t\t\t...this.currentContact,\n\t\t\tservices: childrenContacts.reduce((acc: Service[], c: Contact) => acc.concat(c.services ?? []), []).concat((this.currentContact.services ?? []).filter((s) => thisKeptServiceIds.includes(s.id))),\n\t\t\tsubContacts: childrenContacts\n\t\t\t\t.reduce((acc: Service[], c: Contact) => acc.concat(c.subContacts ?? []), [])\n\t\t\t\t.concat((this.currentContact.subContacts ?? []).filter((s) => s.formId === this.rootForm.id)),\n\t\t}\n\t}\n\n\t/**\n\t * Returns a contact that combines the content of the contact in this form with the content of all contents stored in the children\n\t */\n\tallForms(): Form[] {\n\t\treturn [this.rootForm].concat(this.children.flatMap((c) => c.allForms()))\n\t}\n\n\tconstructor(\n\t\trootForm: ICureForm,\n\t\tcurrentContact: Contact,\n\t\tcontactsHistory: Contact[],\n\t\tserviceFactory: (label: string, serviceId?: string) => Service,\n\t\tchildren: ContactFormValuesContainer[],\n\t\tformFactory: (parentId: string, anchorId: string, formTemplateId: string, label: string) => Promise<ICureForm>,\n\t\tformRecycler: (formId: string) => Promise<void>,\n\t\tchangeListeners: ((newValue: ContactFormValuesContainer) => void)[] = [],\n\t\tinitialised = true,\n\t) {\n\t\tconsole.log(`Creating contact FVC (${rootForm.formTemplateId}) with ${children.length} children [${this._id}]`)\n\n\t\tif (contactsHistory.includes(currentContact)) {\n\t\t\tthrow new Error('Illegal argument, the history must not contain the currentContact')\n\t\t}\n\t\tthis.rootForm = rootForm\n\t\tthis.currentContact = currentContact\n\t\tthis.contactsHistory = sortedBy(contactsHistory, 'created', 'desc')\n\t\tthis.children = children\n\t\tthis.serviceFactory = serviceFactory\n\t\tthis.formFactory = formFactory\n\t\tthis.formRecycler = formRecycler\n\t\tthis.changeListeners = changeListeners\n\t\tthis._initialised = initialised\n\n\t\tthis.synchronise()\n\t}\n\n\tsynchronise() {\n\t\tthis.children.forEach((childFVC) => {\n\t\t\tthis.registerChildFormValuesContainer(childFVC.synchronise())\n\t\t})\n\t\treturn this\n\t}\n\n\t//Make sure that when a child is changed, a new version of this is created with the updated child\n\tregisterChildFormValuesContainer(childFormValueContainer: ContactFormValuesContainer) {\n\t\tchildFormValueContainer.changeListeners = [\n\t\t\t(newValue) => {\n\t\t\t\tconsole.log(`Child ${newValue._id} ${childFormValueContainer.rootForm.formTemplateId} changed, updating parent ${this._id} ${this.rootForm.formTemplateId}`)\n\t\t\t\tconst newContactFormValuesContainer = new ContactFormValuesContainer(\n\t\t\t\t\tthis.rootForm,\n\t\t\t\t\tthis.currentContact,\n\t\t\t\t\tthis.contactsHistory,\n\t\t\t\t\tthis.serviceFactory,\n\t\t\t\t\tthis.children.map((c) => {\n\t\t\t\t\t\treturn c.rootForm.id === childFormValueContainer.rootForm.id ? newValue : c\n\t\t\t\t\t}),\n\t\t\t\t\tthis.formFactory,\n\t\t\t\t\tthis.formRecycler,\n\t\t\t\t)\n\t\t\t\tthis.changeListeners.forEach((l) => notify(l, newContactFormValuesContainer))\n\t\t\t},\n\t\t]\n\t}\n\n\tstatic async fromFormsHierarchy(\n\t\trootForm: ICureForm,\n\t\tcurrentContact: Contact,\n\t\tcontactsHistory: Contact[],\n\t\tserviceFactory: (label: string, serviceId?: string) => Service,\n\t\tformChildrenProvider: (parentId: string | undefined) => Promise<ICureForm[]>,\n\t\tformFactory: (parentId: string, anchorId: string, formTemplateId: string, label: string) => Promise<ICureForm>,\n\t\tformRecycler: (formId: string) => Promise<void>,\n\t\tchangeListeners: ((newValue: ContactFormValuesContainer) => void)[] = [],\n\t): Promise<ContactFormValuesContainer> {\n\t\tconst contactFormValuesContainer = new ContactFormValuesContainer(\n\t\t\trootForm,\n\t\t\tcurrentContact,\n\t\t\tcontactsHistory,\n\t\t\tserviceFactory,\n\t\t\trootForm.id\n\t\t\t\t? await Promise.all(\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\tawait formChildrenProvider(rootForm.id)\n\t\t\t\t\t\t).map(\n\t\t\t\t\t\t\tasync (f) =>\n\t\t\t\t\t\t\t\t// eslint-disable-next-line max-len\n\t\t\t\t\t\t\t\tawait ContactFormValuesContainer.fromFormsHierarchy(f, currentContact, contactsHistory, serviceFactory, formChildrenProvider, formFactory, formRecycler),\n\t\t\t\t\t\t),\n\t\t\t\t )\n\t\t\t\t: [],\n\t\t\tformFactory,\n\t\t\tformRecycler,\n\t\t\tchangeListeners,\n\t\t\tfalse,\n\t\t)\n\t\tcontactFormValuesContainer.children.forEach((childFVC) => contactFormValuesContainer.registerChildFormValuesContainer(childFVC))\n\n\t\treturn contactFormValuesContainer\n\t}\n\n\tgetLabel(): string {\n\t\treturn this.rootForm.descr ?? ''\n\t}\n\n\tgetFormId(): string | undefined {\n\t\treturn this.rootForm?.formTemplateId\n\t}\n\n\tregisterChangeListener(listener: (newValue: ContactFormValuesContainer) => void): void {\n\t\tthis.changeListeners.push(listener)\n\t}\n\n\tunregisterChangeListener(listener: (newValue: ContactFormValuesContainer) => void): void {\n\t\tthis.changeListeners = this.changeListeners.filter((l) => l !== listener)\n\t}\n\n\tgetChildren(): ContactFormValuesContainer[] {\n\t\treturn this.children\n\t}\n\n\tgetValidationErrors(): [FieldMetadata, string][] {\n\t\tthrow new Error('Validation not supported at contact level')\n\t}\n\n\tgetValues(revisionsFilter: (id: string, history: Version<ServiceMetadata>[]) => (string | null)[]): VersionedData<Service> {\n\t\treturn Object.entries(this.getServicesInHistory(revisionsFilter)).reduce(\n\t\t\t(acc, [id, history]) =>\n\t\t\t\thistory.length\n\t\t\t\t\t? {\n\t\t\t\t\t\t\t...acc,\n\t\t\t\t\t\t\t[id]: [...history].sort((a, b) => (b?.modified || +new Date()) - (a?.modified || +new Date())),\n\t\t\t\t\t }\n\t\t\t\t\t: acc,\n\t\t\t{},\n\t\t)\n\t}\n\n\tgetMetadata(id: string, revisions: (string | null)[]): VersionedData<ServiceMetadata> {\n\t\treturn [this.currentContact]\n\t\t\t.concat(this.contactsHistory)\n\t\t\t.filter((ctc) => ctc.rev !== undefined && revisions.includes(ctc.rev))\n\t\t\t.reduce(\n\t\t\t\t(acc, ctc) =>\n\t\t\t\t\t(ctc.services ?? [])\n\t\t\t\t\t\t.filter((s) => s.id === id)\n\t\t\t\t\t\t.reduce(\n\t\t\t\t\t\t\t(acc, s) =>\n\t\t\t\t\t\t\t\ts.id\n\t\t\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t\t\t...acc,\n\t\t\t\t\t\t\t\t\t\t\t[s.id]: (acc[s.id] ?? (acc[s.id] = [])).concat({\n\t\t\t\t\t\t\t\t\t\t\t\trevision: ctc.rev ?? null,\n\t\t\t\t\t\t\t\t\t\t\t\tmodified: s.modified,\n\t\t\t\t\t\t\t\t\t\t\t\tvalue: {\n\t\t\t\t\t\t\t\t\t\t\t\t\tlabel: s.label ?? s.id,\n\t\t\t\t\t\t\t\t\t\t\t\t\tresponsible: s.responsible,\n\t\t\t\t\t\t\t\t\t\t\t\t\tvalueDate: s.valueDate,\n\t\t\t\t\t\t\t\t\t\t\t\t\ttags: s.tags,\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t\t\t: acc,\n\t\t\t\t\t\t\tacc,\n\t\t\t\t\t\t) ?? acc,\n\t\t\t\t{} as { [id: string]: Version<ServiceMetadata>[] },\n\t\t\t) //index services in history by id\n\t}\n\n\tsetMetadata(meta: ServiceMetadata, id?: string): void {\n\t\tconst service = (id && this.getServiceInCurrentContact(id)) || this.serviceFactory(meta.label, id)\n\t\tif (!service.id) {\n\t\t\tthrow new Error('Service id must be defined')\n\t\t}\n\t\tif (\n\t\t\t(meta.responsible && service.responsible !== meta.responsible) ||\n\t\t\t(meta.valueDate && service.valueDate !== meta.valueDate) ||\n\t\t\t(meta.codes && service.codes !== meta.codes) ||\n\t\t\t(meta.tags && service.tags !== meta.tags)\n\t\t) {\n\t\t\tconst newService = new Service({ ...service, modified: Date.now() })\n\t\t\tmeta.responsible && (newService.responsible = meta.responsible)\n\t\t\tmeta.valueDate && (newService.valueDate = meta.valueDate)\n\t\t\tmeta.codes && (newService.codes = normalizeCodes(meta.codes))\n\t\t\tmeta.tags && (newService.tags = normalizeCodes(meta.tags))\n\n\t\t\tconst newFormValuesContainer = new ContactFormValuesContainer(\n\t\t\t\tthis.rootForm,\n\t\t\t\t{\n\t\t\t\t\t...this.currentContact,\n\t\t\t\t\tservices: this.currentContact.services?.map((s) => (s.id === service.id ? newService : s)),\n\t\t\t\t},\n\t\t\t\tthis.contactsHistory,\n\t\t\t\tthis.serviceFactory,\n\t\t\t\tthis.children,\n\t\t\t\tthis.formFactory,\n\t\t\t\tthis.formRecycler,\n\t\t\t\tthis.changeListeners,\n\t\t\t)\n\n\t\t\tthis.changeListeners.forEach((l) => notify(l, newFormValuesContainer))\n\t\t}\n\t}\n\n\tsetValue(label: string, language: string, value?: Service, id?: string, metadata?: ServiceMetadata, changeListenersOverrider?: (fvc: ContactFormValuesContainer) => void): void {\n\t\tconst service = (id && this.getServicesInHistory((sid: string, history) => (sid === id ? history.map((x) => x.revision) : []))[id]?.[0]?.value) || this.serviceFactory(label, id)\n\t\tif (!service.id) {\n\t\t\tthrow new Error('Service id must be defined')\n\t\t}\n\t\tconsole.log('Setting value of service', service.id, 'with', value, 'and metadata', metadata)\n\t\tconst newContent = value?.content?.[language]\n\t\tconst newCodes = value?.codes ? normalizeCodes(value.codes) : []\n\t\tif (!isContentEqual(service.content?.[language], newContent) || (newCodes && !areCodesEqual(newCodes, service.codes ?? []))) {\n\t\t\tconst newService = new Service({ ...service, modified: Date.now() })\n\t\t\tconst newContents = newContent\n\t\t\t\t? {\n\t\t\t\t\t\t...(service.content || {}),\n\t\t\t\t\t\t[language]: newContent,\n\t\t\t\t }\n\t\t\t\t: { ...(service.content || {}) }\n\t\t\tif (!newContent) {\n\t\t\t\tdelete newContents[language]\n\t\t\t}\n\n\t\t\tlet newCurrentContact: Contact\n\t\t\tif (!Object.entries(newContents).filter(([, cnt]) => cnt !== undefined).length) {\n\t\t\t\tnewCurrentContact = {\n\t\t\t\t\t...this.currentContact,\n\t\t\t\t\tsubContacts: (this.currentContact.subContacts ?? []).some((sc) => sc.formId === this.rootForm.id)\n\t\t\t\t\t\t? (this.currentContact.subContacts ?? []).map((sc) => {\n\t\t\t\t\t\t\t\tif (sc.formId === this.rootForm.id) {\n\t\t\t\t\t\t\t\t\treturn { ...sc, services: (sc.services ?? []).filter((s) => s.serviceId !== service.id).concat([{ serviceId: service.id }]) }\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\treturn sc\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t })\n\t\t\t\t\t\t: (this.currentContact.subContacts ?? []).concat({ formId: this.rootForm.id, services: [{ serviceId: service.id }] }),\n\t\t\t\t\tservices: (this.currentContact.services ?? []).some((s) => s.id === service.id)\n\t\t\t\t\t\t? (this.currentContact.services ?? []).filter((s) => s.id !== service.id)\n\t\t\t\t\t\t: [...(this.currentContact.services ?? [])],\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tnewService.content = newContents\n\t\t\t\tnewService.codes = newCodes\n\n\t\t\t\tif (metadata) {\n\t\t\t\t\tnewService.responsible = metadata.responsible ?? newService.responsible\n\t\t\t\t\tnewService.valueDate = metadata.valueDate ?? newService.valueDate\n\t\t\t\t\tnewService.tags = metadata.tags ? normalizeCodes(metadata.tags) : newService.tags\n\t\t\t\t\tnewService.label = metadata.label ?? newService.label\n\t\t\t\t}\n\n\t\t\t\tnewCurrentContact = {\n\t\t\t\t\t...this.currentContact,\n\t\t\t\t\tsubContacts: (this.currentContact.subContacts ?? []).some((sc) => sc.formId === this.rootForm.id)\n\t\t\t\t\t\t? (this.currentContact.subContacts ?? []).map((sc) => {\n\t\t\t\t\t\t\t\tif (sc.formId === this.rootForm.id) {\n\t\t\t\t\t\t\t\t\treturn { ...sc, services: (sc.services ?? []).filter((s) => s.serviceId !== service.id).concat([{ serviceId: service.id }]) }\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\treturn sc\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t })\n\t\t\t\t\t\t: (this.currentContact.subContacts ?? []).concat({ formId: this.rootForm.id, services: [{ serviceId: service.id }] }),\n\t\t\t\t\tservices: (this.currentContact.services ?? []).some((s) => s.id === service.id)\n\t\t\t\t\t\t? (this.currentContact.services ?? []).map((s) => (s.id === service.id ? newService : s))\n\t\t\t\t\t\t: [...(this.currentContact.services ?? []), newService],\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst newFormValuesContainer = new ContactFormValuesContainer(\n\t\t\t\tthis.rootForm,\n\t\t\t\tnewCurrentContact,\n\t\t\t\tthis.contactsHistory.map((c) => (c === this.currentContact ? newCurrentContact : c)),\n\t\t\t\tthis.serviceFactory,\n\t\t\t\tthis.children,\n\t\t\t\tthis.formFactory,\n\t\t\t\tthis.formRecycler,\n\t\t\t\tthis.changeListeners,\n\t\t\t)\n\n\t\t\tchangeListenersOverrider ? changeListenersOverrider(newFormValuesContainer) : this.changeListeners.forEach((l) => notify(l, newFormValuesContainer))\n\t\t}\n\t}\n\n\tdelete(serviceId: string): void {\n\t\tconst service = this.getServiceInCurrentContact(serviceId)\n\t\tif (service) {\n\t\t\tconst newFormValuesContainer = new ContactFormValuesContainer(\n\t\t\t\tthis.rootForm,\n\t\t\t\t{\n\t\t\t\t\t...this.currentContact,\n\t\t\t\t\tservices: this.currentContact.services?.map((s) =>\n\t\t\t\t\t\ts.id === serviceId\n\t\t\t\t\t\t\t? new Service({\n\t\t\t\t\t\t\t\t\t...service,\n\t\t\t\t\t\t\t\t\tendOfLife: Date.now(),\n\t\t\t\t\t\t\t })\n\t\t\t\t\t\t\t: s,\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t\tthis.contactsHistory,\n\t\t\t\tthis.serviceFactory,\n\t\t\t\tthis.children,\n\t\t\t\tthis.formFactory,\n\t\t\t\tthis.formRecycler,\n\t\t\t\tthis.changeListeners,\n\t\t\t)\n\n\t\t\tthis.changeListeners.forEach((l) => notify(l, newFormValuesContainer))\n\t\t}\n\t}\n\n\tcompute<T>(): T | undefined {\n\t\tthrow new Error('Compute not supported at contact level')\n\t}\n\n\t/** returns all services in history that match a selector\n\t *\n\t * @private\n\t * @param revisionsFilter\n\t */\n\tprivate getServicesInHistory(revisionsFilter: (id: string, history: Version<ServiceMetadata>[]) => (string | null)[]): VersionedData<Service> {\n\t\tconst indexedServices = [this.currentContact].concat(this.contactsHistory).reduce((acc, ctc) => {\n\t\t\tconst services =\n\t\t\t\tctc.services\n\t\t\t\t\t?.filter((s) => ctc.subContacts?.some((sc) => sc.formId === this.rootForm.id && sc.services?.some((sss) => sss.serviceId === s.id)))\n\t\t\t\t\t?.reduce(\n\t\t\t\t\t\t(acc, s) =>\n\t\t\t\t\t\t\ts.id\n\t\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t\t...acc,\n\t\t\t\t\t\t\t\t\t\t[s.id]: (acc[s.id] ?? (acc[s.id] = [])).concat({\n\t\t\t\t\t\t\t\t\t\t\trevision: ctc.rev ?? null,\n\t\t\t\t\t\t\t\t\t\t\tmodified: ctc.created,\n\t\t\t\t\t\t\t\t\t\t\tvalue: s,\n\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t\t: acc,\n\t\t\t\t\t\tacc,\n\t\t\t\t\t) ?? acc\n\t\t\treturn services\n\t\t}, {} as VersionedData<Service>) //index services in history by id\n\t\treturn Object.entries(indexedServices)\n\t\t\t.map(([id, history]) => {\n\t\t\t\tconst keptRevisions = revisionsFilter(\n\t\t\t\t\tid,\n\t\t\t\t\thistory.map(({ revision, modified, value: s }) => ({\n\t\t\t\t\t\trevision,\n\t\t\t\t\t\tmodified,\n\t\t\t\t\t\tvalue: {\n\t\t\t\t\t\t\tlabel: s.label ?? s.id ?? '',\n\t\t\t\t\t\t\towner: s.responsible,\n\t\t\t\t\t\t\tvalueDate: s.valueDate,\n\t\t\t\t\t\t\tcodes: s.codes,\n\t\t\t\t\t\t\ttags: s.tags,\n\t\t\t\t\t\t},\n\t\t\t\t\t})),\n\t\t\t\t)\n\t\t\t\treturn [id, history.filter(({ revision }) => keptRevisions.includes(revision))] as [string, Version<Service>[]]\n\t\t\t})\n\t\t\t.reduce((acc, [id, history]) => ({ ...acc, [id]: history }), {})\n\t}\n\n\tasync addChild(anchorId: string, templateId: string, label: string): Promise<void> {\n\t\tconst parentId = this.rootForm.id\n\t\tif (!parentId) return\n\n\t\tconst newForm = await this.formFactory(parentId, anchorId, templateId, label)\n\t\tconst childFVC = new ContactFormValuesContainer(newForm, this.currentContact, this.contactsHistory, this.serviceFactory, [], this.formFactory, this.formRecycler, [], false)\n\n\t\tconst newContactFormValuesContainer = new ContactFormValuesContainer(\n\t\t\tthis.rootForm,\n\t\t\tthis.currentContact,\n\t\t\tthis.contactsHistory,\n\t\t\tthis.serviceFactory,\n\t\t\t[...this.children, childFVC],\n\t\t\tthis.formFactory,\n\t\t\tthis.formRecycler,\n\t\t\tthis.changeListeners,\n\t\t)\n\t\tnewContactFormValuesContainer.registerChildFormValuesContainer(childFVC)\n\t\tthis.changeListeners.forEach((l) => notify(l, newContactFormValuesContainer))\n\t}\n\n\tprivate getServiceInCurrentContact(id: string): Service | undefined {\n\t\tconst service = (this.currentContact.services || [])?.find((s) => s.id === id)\n\t\treturn service ?? undefined\n\t}\n\n\tasync removeChild(container: ContactFormValuesContainer): Promise<void> {\n\t\tconst newContactFormValuesContainer = new ContactFormValuesContainer(\n\t\t\tthis.rootForm,\n\t\t\tthis.currentContact,\n\t\t\tthis.contactsHistory,\n\t\t\tthis.serviceFactory,\n\t\t\tthis.children.filter((c) => c.rootForm.id !== container.rootForm.id),\n\t\t\tthis.formFactory,\n\t\t\tthis.formRecycler,\n\t\t\tthis.changeListeners,\n\t\t)\n\t\tthis.changeListeners.forEach((l) => notify(l, newContactFormValuesContainer))\n\t}\n}\n\nconst setValueOnContactFormValuesContainer = (\n\tcfvc: ContactFormValuesContainer,\n\tlabel: string,\n\tlanguage: string,\n\tfv?: FieldValue,\n\tid?: string,\n\tmetadata?: FieldMetadata,\n\tchangeListenersOverrider?: (fvc: ContactFormValuesContainer) => void,\n) => {\n\tconst value = fv?.content[language]\n\tcfvc.setValue(\n\t\tlabel,\n\t\tlanguage,\n\t\t{\n\t\t\tid: id,\n\t\t\tcodes: fv?.codes ?? [],\n\t\t\tcontent: value\n\t\t\t\t? {\n\t\t\t\t\t\t[language]: primitiveTypeToContent(language, value),\n\t\t\t\t }\n\t\t\t\t: undefined,\n\t\t},\n\t\tid,\n\t\tmetadata\n\t\t\t? {\n\t\t\t\t\tlabel: metadata?.label ?? label,\n\t\t\t\t\tresponsible: metadata?.owner,\n\t\t\t\t\tvalueDate: metadata?.valueDate,\n\t\t\t\t\ttags: metadata?.tags,\n\t\t\t }\n\t\t\t: undefined,\n\t\tchangeListenersOverrider,\n\t)\n}\n"]}
|
|
1
|
+
{"version":3,"file":"form-values-container.js","sourceRoot":"","sources":["../../tmp/icure/form-values-container.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,sDAAsI;AACtI,kDAA6C;AAI7C,+CAA6H;AAC7H,kDAAmD;AACnD,0CAA8C;AAC9C,+BAAmC;AACnC,oDAAoD;AAEpD,SAAS,MAAM,CAAkB,CAAsD,EAAE,GAAyC;IACjI,6CAA6C;IAC7C,CAAC,CAAC,GAAG,CAAC,CAAA;AACP,CAAC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAa,0BAA0B;IAMtC,QAAQ;QACP,OAAO,WAAW,IAAI,CAAC,0BAA0B,CAAC,QAAQ,CAAC,cAAc,IAAI,IAAI,CAAC,0BAA0B,CAAC,QAAQ,CAAC,EAAE,QAAQ,IAAI,CAAC,GAAG,EAAE,CAAA;IAC3I,CAAC;IAED;;;;;;;;;;;OAWG;IACH,YACS,WAAmB,EAC3B,0BAAsD,EAC9C,WAQU,EAClB,OAA0B,EAClB,wBAOF,GAAG,EAAE,CAAC,EAAE,EACN,0BAOF,GAAG,EAAE,CAAC,EAAE,EACN,qBAMF,GAAG,EAAE,CAAC,EAAE,EACN,WAAW,IAAI,EACf,kBAAsE,EAAE;QApCxE,gBAAW,GAAX,WAAW,CAAQ;QAEnB,gBAAW,GAAX,WAAW,CAQD;QAEV,0BAAqB,GAArB,qBAAqB,CAOf;QACN,4BAAuB,GAAvB,uBAAuB,CAOjB;QACN,uBAAkB,GAAlB,kBAAkB,CAMZ;QACN,aAAQ,GAAR,QAAQ,CAAO;QACf,oBAAe,GA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,CAAC;aAClD;YACH,CAAC,CAAC,SAAS;KACZ,CAAC,EACF,EAAE,EACF,QAAQ;QACP,CAAC,CAAC;YACA,KAAK,EAAE,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,KAAK,mCAAI,KAAK;YAC/B,WAAW,EAAE,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,KAAK;YAC5B,SAAS,EAAE,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,SAAS;YAC9B,IAAI,EAAE,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,0CAAE,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,uBAAQ,CAAC,CAAC,CAAC,CAAC;SAChD;QACH,CAAC,CAAC,SAAS,EACZ,wBAAwB,CACxB,CAAA;AACF,CAAC,CAAA","sourcesContent":["import { CodeStub, DecryptedContact, DecryptedForm as CardinalForm, DecryptedService, DecryptedSubContact } from '@icure/cardinal-sdk'\nimport { sortedBy } from '../utils/no-lodash'\nimport { FormValuesContainer, Version, VersionedData } from '../generic'\nimport { ServiceMetadata } from './model'\nimport { FieldMetadata, FieldValue, PrimitiveType, Validator } from '../components/model'\nimport { areCodesEqual, codeStubToCode, contentToPrimitiveType, isContentEqual, primitiveTypeToContent } from './icure-utils'\nimport { parsePrimitive } from '../utils/primitive'\nimport { anyDateToDate } from '../utils/dates'\nimport { v4 as uuidv4 } from 'uuid'\nimport { normalizeCodes } from '../utils/code-utils'\n\nfunction notify<Value, Metadata>(l: (fvc: FormValuesContainer<Value, Metadata>) => void, fvc: FormValuesContainer<Value, Metadata>) {\n\t//console.log('Notifying', l, fvc.toString())\n\tl(fvc)\n}\n\n/** This class is a bridge between the ICure API and the generic FormValuesContainer interface.\n * It wraps around a ContactFormValuesContainer and provides a series of services:\n * - It computes dependent values when the form is created\n * - It broadcasts changes from the wrapped ContactFormValuesContainer to its listeners\n * - It provides a way to compute formulas in a sandboxed environment\n * - It bridges the setValues and setMetadata methods with the wrapped ContactFormValuesContainer by\n * \t\t- converting the FieldValue to a Service\n * \t\t- converting the FieldMetadata to a ServiceMetadata\n * - It bridges the getValues and getMetadata methods with the wrapped ContactFormValuesContainer by\n * \t\t- converting the Service to a FieldValue\n * \t\t- converting the ServiceMetadata to a FieldMetadata\n * - It lazily creates bridges the children by\n * - lazily creating BridgedFormValuesContainer when the children of the wrapped ContactFormValuesContainer are accessed\n * - creating a new ContactFormValuesContainer and wrapping it in a BridgedFormValuesContainer when a child is added\n *\n * The icure-form typically accepts a BridgedFormValuesContainer as a prop and uses it to interact with the form.\n *\n * This class is fairly generic and can be used as an inspiration or subclassed for other bridges\n */\nexport class BridgedFormValuesContainer implements FormValuesContainer<FieldValue, FieldMetadata> {\n\tprivate contact: DecryptedContact\n\tprivate contactFormValuesContainer: ContactFormValuesContainer\n\tprivate _id: string = uuidv4()\n\tprivate mutateAndNotify: (newContactFormValuesContainer: ContactFormValuesContainer) => BridgedFormValuesContainer\n\n\ttoString(): string {\n\t\treturn `Bridged(${this.contactFormValuesContainer.rootForm.formTemplateId}[${this.contactFormValuesContainer.rootForm.id}]) - ${this._id}`\n\t}\n\n\t/**\n\t * Creates an instance of BridgedFormValuesContainer.\n\t * @param responsible The id of the data owner responsible for the creation of the values\n\t * @param contact The displayed contact (may be in the past). === to currentContact if the contact is the contact of the day\n\t * @param contactFormValuesContainer The wrapped ContactFormValuesContainer\n\t * @param interpreter A function that can interpret formulas\n\t * @param dependentValuesProvider A function that provides the dependent values (computed on the basis of other values) for a given anchorId and templateId\n\t * @param validatorsProvider A function that provides the validators for a given anchorId and templateId\n\t * @param language The language in which the values are displayed\n\t * @param changeListeners The listeners that will be notified when the values change\n\t * @param initialValuesProvider A lambda that provides the initial values of the form\n\t */\n\tconstructor(\n\t\tprivate responsible: string,\n\t\tcontactFormValuesContainer: ContactFormValuesContainer,\n\t\tprivate interpreter?: <\n\t\t\tT,\n\t\t\tS extends {\n\t\t\t\t[key: string | symbol]: unknown\n\t\t\t},\n\t\t>(\n\t\t\tformula: string,\n\t\t\tsandbox: S,\n\t\t) => T | undefined,\n\t\tcontact?: DecryptedContact,\n\t\tprivate initialValuesProvider: (\n\t\t\tanchorId?: string,\n\t\t\ttemplateId?: string,\n\t\t) => {\n\t\t\tmetadata: FieldMetadata\n\t\t\trevisionsFilter: (id: string, history: Version<FieldMetadata>[]) => (string | null)[]\n\t\t\tformula: string\n\t\t}[] = () => [],\n\t\tprivate dependentValuesProvider: (\n\t\t\tanchorId: string | undefined,\n\t\t\ttemplateId: string | undefined,\n\t\t) => {\n\t\t\tmetadata: FieldMetadata\n\t\t\trevisionsFilter: (id: string, history: Version<FieldMetadata>[]) => (string | null)[]\n\t\t\tformula: string\n\t\t}[] = () => [],\n\t\tprivate validatorsProvider: (\n\t\t\tanchorId: string | undefined,\n\t\t\ttemplateId: string,\n\t\t) => {\n\t\t\tmetadata: FieldMetadata\n\t\t\tvalidators: Validator[]\n\t\t}[] = () => [],\n\t\tprivate language = 'en',\n\t\tprivate changeListeners: ((newValue: BridgedFormValuesContainer) => void)[] = [],\n\t) {\n\t\tconsole.log(`Creating bridge FVC (${contactFormValuesContainer.rootForm.formTemplateId}) with ${contactFormValuesContainer.children.length} children [${this._id}]`)\n\t\t//Before start to broadcast changes, we need to fill in the contactFormValuesContainer with the dependent values\n\t\tthis.contactFormValuesContainer = contactFormValuesContainer\n\t\tthis.mutateAndNotify = (newContactFormValuesContainer: ContactFormValuesContainer) => {\n\t\t\tnewContactFormValuesContainer.unregisterChangeListener(this.mutateAndNotify)\n\t\t\tconst newBridgedFormValueContainer = new BridgedFormValuesContainer(\n\t\t\t\tthis.responsible,\n\t\t\t\tnewContactFormValuesContainer,\n\t\t\t\tthis.interpreter,\n\t\t\t\tthis.contact === this.contactFormValuesContainer.currentContact ? newContactFormValuesContainer.currentContact : this.contact,\n\t\t\t\tthis.initialValuesProvider,\n\t\t\t\tthis.dependentValuesProvider,\n\t\t\t\tthis.validatorsProvider,\n\t\t\t\tthis.language,\n\t\t\t\tthis.changeListeners,\n\t\t\t)\n\t\t\tthis.changeListeners.forEach((l) => notify(l, newBridgedFormValueContainer))\n\t\t\treturn newBridgedFormValueContainer\n\t\t}\n\t\tthis.contactFormValuesContainer.registerChangeListener(this.mutateAndNotify)\n\t\tthis.contact = contact ?? contactFormValuesContainer.currentContact\n\t\tif (this.contactFormValuesContainer.mustBeInitialised()) {\n\t\t\tthis.computeInitialValues()\n\t\t}\n\t\tthis.computeDependentValues()\n\t}\n\n\tgetLabel(): string {\n\t\treturn this.contactFormValuesContainer.getLabel()\n\t}\n\n\tgetFormId(): string | undefined {\n\t\treturn this.contactFormValuesContainer.getFormId()\n\t}\n\n\tgetContactFormValuesContainer() {\n\t\treturn this.contactFormValuesContainer\n\t}\n\n\tregisterChangeListener(listener: (newValue: BridgedFormValuesContainer) => void): void {\n\t\tthis.changeListeners.push(listener)\n\t}\n\n\tunregisterChangeListener(listener: (newValue: BridgedFormValuesContainer) => void): void {\n\t\tthis.changeListeners = this.changeListeners.filter((l) => l !== listener)\n\t}\n\n\tgetValues(revisionsFilter: (id: string, history: Version<FieldMetadata>[]) => (string | null)[]): VersionedData<FieldValue> {\n\t\treturn Object.entries(\n\t\t\tthis.contactFormValuesContainer.getValues((id, history) =>\n\t\t\t\trevisionsFilter(\n\t\t\t\t\tid,\n\t\t\t\t\thistory\n\t\t\t\t\t\t.filter(({ modified }) => !this.contact.created || !modified || modified <= this.contact.created)\n\t\t\t\t\t\t.map(({ revision, modified, value: sm }) => ({\n\t\t\t\t\t\t\trevision,\n\t\t\t\t\t\t\tmodified,\n\t\t\t\t\t\t\tvalue: {\n\t\t\t\t\t\t\t\tlabel: sm.label,\n\t\t\t\t\t\t\t\towner: sm.responsible,\n\t\t\t\t\t\t\t\ttags: sm.tags?.map(codeStubToCode),\n\t\t\t\t\t\t\t\tvalueDate: sm.valueDate,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t})),\n\t\t\t\t),\n\t\t\t),\n\t\t).reduce((acc, [id, history]) => {\n\t\t\treturn {\n\t\t\t\t...acc,\n\t\t\t\t[id]: history.map(({ revision, modified, value: s }) => ({\n\t\t\t\t\trevision,\n\t\t\t\t\tmodified,\n\t\t\t\t\tvalue: {\n\t\t\t\t\t\tcontent: Object.entries(s.content ?? {}).reduce((acc, [lng, cnt]) => {\n\t\t\t\t\t\t\tconst converted = contentToPrimitiveType(lng, cnt)\n\t\t\t\t\t\t\treturn converted ? { ...acc, [lng]: converted } : acc\n\t\t\t\t\t\t}, {}),\n\t\t\t\t\t\tcodes: s.codes?.map(codeStubToCode),\n\t\t\t\t\t},\n\t\t\t\t})),\n\t\t\t}\n\t\t}, {} as VersionedData<FieldValue>)\n\t}\n\n\tgetMetadata(id: string, revisions: (string | null)[]): VersionedData<FieldMetadata> {\n\t\treturn Object.entries(this.contactFormValuesContainer.getMetadata(id, revisions)).reduce(\n\t\t\t(acc, [id, history]) => ({\n\t\t\t\t...acc,\n\t\t\t\t[id]: history.map(({ revision, modified, value: s }) => ({\n\t\t\t\t\trevision,\n\t\t\t\t\tmodified,\n\t\t\t\t\tvalue: {\n\t\t\t\t\t\tlabel: s.label,\n\t\t\t\t\t\towner: s.responsible,\n\t\t\t\t\t\tvalueDate: s.valueDate,\n\t\t\t\t\t\ttags: s.tags,\n\t\t\t\t\t\tdiscordantMetadata: () => ({\n\t\t\t\t\t\t\t...(s.responsible !== this.responsible ? { owner: this.responsible } : {}),\n\t\t\t\t\t\t\t...(Math.abs(+(anyDateToDate(s.valueDate) ?? 0) - +(anyDateToDate(this.contact.created) ?? 0)) > 24 * 3600000 ? { valueDate: s.valueDate } : {}),\n\t\t\t\t\t\t}),\n\t\t\t\t\t},\n\t\t\t\t})),\n\t\t\t}),\n\t\t\t{},\n\t\t)\n\t}\n\n\t//This method mutates the BridgedFormValuesContainer but can only be called from the constructor\n\tprivate computeInitialValues() {\n\t\tif (this.contactFormValuesContainer.rootForm.formTemplateId) {\n\t\t\tthis.initialValuesProvider(this.contactFormValuesContainer.rootForm.descr, this.contactFormValuesContainer.rootForm.formTemplateId).forEach(({ metadata, revisionsFilter, formula }) => {\n\t\t\t\ttry {\n\t\t\t\t\tconst currentValue = this.getValues(revisionsFilter)\n\t\t\t\t\tif (!currentValue || !Object.keys(currentValue).length) {\n\t\t\t\t\t\tconst newValue = this.compute(formula) as FieldValue | undefined\n\t\t\t\t\t\tif (newValue !== undefined) {\n\t\t\t\t\t\t\tconst lng = this.language ?? 'en'\n\t\t\t\t\t\t\tif (newValue && !newValue.content[lng] && newValue.content['*']) {\n\t\t\t\t\t\t\t\tnewValue.content[lng] = newValue.content['*']\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (newValue) {\n\t\t\t\t\t\t\t\tdelete newValue.content['*']\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tsetValueOnContactFormValuesContainer(this.contactFormValuesContainer, metadata.label, lng, newValue, undefined, metadata, (fvc: ContactFormValuesContainer) => {\n\t\t\t\t\t\t\t\tconst currentContact = this.contactFormValuesContainer.currentContact\n\t\t\t\t\t\t\t\tthis.contactFormValuesContainer = fvc\n\t\t\t\t\t\t\t\tif (this.contact === currentContact) {\n\t\t\t\t\t\t\t\t\tthis.contact = fvc.currentContact\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} catch (e) {\n\t\t\t\t\tconsole.log(`Error while computing formula : ${formula}`, e)\n\t\t\t\t}\n\t\t\t})\n\t\t}\n\t}\n\n\t//This method mutates the BridgedFormValuesContainer but can only be called from the constructor\n\tprivate computeDependentValues() {\n\t\tif (this.contactFormValuesContainer.rootForm.formTemplateId) {\n\t\t\tthis.dependentValuesProvider(this.contactFormValuesContainer.rootForm.descr, this.contactFormValuesContainer.rootForm.formTemplateId).forEach(({ metadata, revisionsFilter, formula }) => {\n\t\t\t\ttry {\n\t\t\t\t\tconst currentValue = this.getValues(revisionsFilter)\n\t\t\t\t\tconst newValue = this.compute(formula) as FieldValue | undefined\n\t\t\t\t\tif (newValue !== undefined || currentValue != undefined) {\n\t\t\t\t\t\tconst lng = this.language ?? 'en'\n\t\t\t\t\t\tif (newValue && !newValue.content[lng] && newValue.content['*']) {\n\t\t\t\t\t\t\tnewValue.content[lng] = newValue.content['*']\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (newValue) {\n\t\t\t\t\t\t\tdelete newValue.content['*']\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst interceptor = (fvc: ContactFormValuesContainer) => {\n\t\t\t\t\t\t\tconst currentContact = this.contactFormValuesContainer.currentContact\n\t\t\t\t\t\t\tthis.contactFormValuesContainer = fvc\n\t\t\t\t\t\t\tif (this.contact === currentContact) {\n\t\t\t\t\t\t\t\tthis.contact = fvc.currentContact\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsetValueOnContactFormValuesContainer(this.contactFormValuesContainer, metadata.label, lng, newValue, Object.keys(currentValue ?? {})[0], metadata, interceptor)\n\t\t\t\t\t}\n\t\t\t\t} catch (e) {\n\t\t\t\t\tconsole.log(`Error while computing formula : ${formula}`, e)\n\t\t\t\t}\n\t\t\t})\n\t\t}\n\t}\n\n\tsetValue(label: string, language: string, fv?: FieldValue, id?: string, metadata?: FieldMetadata): void {\n\t\tsetValueOnContactFormValuesContainer(this.contactFormValuesContainer, label, language, fv, id, metadata)\n\t}\n\n\tsetMetadata(meta: FieldMetadata, id?: string | undefined): void {\n\t\tthis.contactFormValuesContainer.setMetadata(\n\t\t\t{\n\t\t\t\tlabel: meta.label,\n\t\t\t\tresponsible: meta.owner,\n\t\t\t\tvalueDate: meta.valueDate,\n\t\t\t\ttags: meta.tags?.map((x) => new CodeStub(x)),\n\t\t\t},\n\t\t\tid,\n\t\t)\n\t}\n\n\tdelete(serviceId: string): void {\n\t\tthis.contactFormValuesContainer.delete(serviceId)\n\t}\n\n\tprivate getVersionedValuesForKey(key: string | symbol) {\n\t\treturn this.getValues((id, history) => (history?.[0]?.value?.label && key === history[0].value.label ? [history?.[0]?.revision] : []))\n\t}\n\n\tcompute<T, S extends { [key: string | symbol]: unknown }>(formula: string, sandbox?: S): T | undefined {\n\t\t// noinspection JSUnusedGlobalSymbols\n\t\tconst parseContent = (content?: { [key: string]: PrimitiveType }) => {\n\t\t\tif (!content) {\n\t\t\t\treturn undefined\n\t\t\t}\n\t\t\tconst primitive = content[this.language] ?? content['*'] ?? content[Object.keys(content)[0]]\n\t\t\treturn primitive && parsePrimitive(primitive)\n\t\t}\n\t\tconst log = console.log\n\t\tconst native = {\n\t\t\tparseInt: parseInt,\n\t\t\tparseFloat: parseFloat,\n\t\t\tDate: Date,\n\t\t\tMath: Math,\n\t\t\tNumber: Number,\n\t\t\tString: String,\n\t\t\tBoolean: Boolean,\n\t\t\tArray: Array,\n\t\t\tObject: Object,\n\t\t\tparseContent,\n\t\t\tvalidate: {\n\t\t\t\tnotBlank: (self: any, label: string) => {\n\t\t\t\t\tconst value = parseContent((self[label as any] as any)?.[0]?.content)\n\t\t\t\t\treturn !!(value as any)?.trim()?.length\n\t\t\t\t},\n\t\t\t},\n\t\t\tlog,\n\t\t} as { [key: string]: any }\n\t\tconst proxy: S = new Proxy({} as S, {\n\t\t\thas: (target: S, key: string | symbol) => !!native[key as string] || key === 'self' || Object.keys(this.getVersionedValuesForKey(key) ?? {}).length > 0,\n\t\t\tget: (target: S, key: string | symbol) => {\n\t\t\t\tif (key === 'undefined') {\n\t\t\t\t\treturn undefined\n\t\t\t\t}\n\t\t\t\tconst nativeValue = native[key as string]\n\t\t\t\tif (!!nativeValue) {\n\t\t\t\t\treturn nativeValue\n\t\t\t\t}\n\t\t\t\treturn key === 'self' ? proxy : Object.values(this.getVersionedValuesForKey(key)).map((v) => v[0]?.value)\n\t\t\t},\n\t\t})\n\t\treturn this.interpreter?.(formula, sandbox ?? proxy)\n\t}\n\n\tgetChildren(): FormValuesContainer<FieldValue, FieldMetadata>[] {\n\t\tconst children = this.contactFormValuesContainer\n\t\t\t.getChildren()\n\t\t\t.map(\n\t\t\t\t(fvc) =>\n\t\t\t\t\tnew BridgedFormValuesContainer(this.responsible, fvc, this.interpreter, this.contact, this.initialValuesProvider, this.dependentValuesProvider, this.validatorsProvider, this.language, []),\n\t\t\t)\n\t\tconsole.log(`${children.length} children found in ${this.contactFormValuesContainer.rootForm.formTemplateId} initialised with `, this.initialValuesProvider)\n\t\treturn children\n\t}\n\n\tgetValidationErrors(): [FieldMetadata, string][] {\n\t\tif (this.contactFormValuesContainer.rootForm.formTemplateId) {\n\t\t\treturn this.validatorsProvider(this.contactFormValuesContainer.rootForm.descr, this.contactFormValuesContainer.rootForm.formTemplateId).flatMap(\n\t\t\t\t({ metadata, validators }) =>\n\t\t\t\t\tvalidators\n\t\t\t\t\t\t.map(({ validation, message }) => {\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\treturn this.compute(validation) ? undefined : [metadata, message]\n\t\t\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\t\t\tconsole.log(`Error while computing validation : ${validation}`, e)\n\t\t\t\t\t\t\t\treturn undefined\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.filter((x) => !!x) as [FieldMetadata, string][],\n\t\t\t)\n\t\t} else {\n\t\t\treturn []\n\t\t}\n\t}\n\n\tasync addChild(anchorId: string, templateId: string, label: string): Promise<void> {\n\t\tawait this.contactFormValuesContainer.addChild(anchorId, templateId, label)\n\t}\n\n\tasync removeChild(container: BridgedFormValuesContainer): Promise<void> {\n\t\tawait this.contactFormValuesContainer.removeChild(container.contactFormValuesContainer)\n\t}\n\n\tsynchronise() {\n\t\tthis.contactFormValuesContainer.synchronise()\n\t\treturn this\n\t}\n}\n\n/**\n * This class is a form values container that uses a hierarchy of forms as a data source. The actual values are extracted from the services of the contacts.\n * The `currentContact` is the contact that has been selected by the user, any later contact should be ignored.\n * The `contactsHistory` is used to provide the full history of the services.\n * The hierarchy of ContactFormValuesContainer has to be maintained by the manager of the instances of this class (typically the BridgedFormValuesContainer).\n * Each ContactFormValuesContainer has a reference to its `rootForm`.\n * The `serviceFactory` and `formFactory` are used to create new services and add sub-forms.\n */\nexport class ContactFormValuesContainer implements FormValuesContainer<DecryptedService, ServiceMetadata> {\n\trootForm: CardinalForm\n\tcurrentContact: DecryptedContact //The contact of the moment, used to record new modifications\n\tcontactsHistory: DecryptedContact[] //Must be sorted (most recent first), contains all the contacts linked to this form\n\tchildren: ContactFormValuesContainer[] //Direct children of the ContactFormValuesContainer\n\tserviceFactory: (label: string, serviceId?: string) => DecryptedService\n\tformFactory: (parentId: string, anchorId: string, formTemplateId: string, label: string) => Promise<CardinalForm>\n\tformRecycler: (formId: string) => Promise<void>\n\n\tchangeListeners: ((newValue: ContactFormValuesContainer) => void)[]\n\tprivate _id: string = uuidv4()\n\tprivate _initialised = false\n\n\ttoString(): string {\n\t\treturn `Contact(${this.rootForm.formTemplateId}[${this.rootForm.id}]) - ${this._id}`\n\t}\n\n\tmustBeInitialised() {\n\t\treturn !this._initialised\n\t}\n\n\t/**\n\t * Returns a contact that combines the content of the contact in this form with the content of all contents stored in the children\n\t */\n\tcoordinatedContact(): DecryptedContact {\n\t\tconst childrenContacts = this.children.map((c) => c.coordinatedContact())\n\t\tconst thisKeptServiceIds = (this.currentContact.subContacts ?? []).filter((sc) => sc.formId === this.rootForm.id).flatMap((sc) => (sc.services ?? []).map((s) => s.serviceId))\n\t\treturn new DecryptedContact({\n\t\t\t...this.currentContact,\n\t\t\tservices: childrenContacts\n\t\t\t\t.reduce((acc: DecryptedService[], c: DecryptedContact) => acc.concat(c.services ?? []), [])\n\t\t\t\t.concat((this.currentContact.services ?? []).filter((s) => thisKeptServiceIds.includes(s.id))),\n\t\t\tsubContacts: childrenContacts\n\t\t\t\t.reduce((acc: DecryptedSubContact[], c: DecryptedContact) => acc.concat(c.subContacts ?? []), [])\n\t\t\t\t.concat((this.currentContact.subContacts ?? []).filter((s) => s.formId === this.rootForm.id)),\n\t\t})\n\t}\n\n\t/**\n\t * Returns a contact that combines the content of the contact in this form with the content of all contents stored in the children\n\t */\n\tallForms(): CardinalForm[] {\n\t\treturn [this.rootForm].concat(this.children.flatMap((c) => c.allForms()))\n\t}\n\n\tconstructor(\n\t\trootForm: CardinalForm,\n\t\tcurrentContact: DecryptedContact,\n\t\tcontactsHistory: DecryptedContact[],\n\t\tserviceFactory: (label: string, serviceId?: string) => DecryptedService,\n\t\tchildren: ContactFormValuesContainer[],\n\t\tformFactory: (parentId: string, anchorId: string, formTemplateId: string, label: string) => Promise<CardinalForm>,\n\t\tformRecycler: (formId: string) => Promise<void>,\n\t\tchangeListeners: ((newValue: ContactFormValuesContainer) => void)[] = [],\n\t\tinitialised = true,\n\t) {\n\t\tconsole.log(`Creating contact FVC (${rootForm.formTemplateId}) with ${children.length} children [${this._id}]`)\n\n\t\tif (contactsHistory.includes(currentContact)) {\n\t\t\tthrow new Error('Illegal argument, the history must not contain the currentContact')\n\t\t}\n\t\tthis.rootForm = rootForm\n\t\tthis.currentContact = currentContact\n\t\tthis.contactsHistory = sortedBy(contactsHistory, 'created', 'desc')\n\t\tthis.children = children\n\t\tthis.serviceFactory = serviceFactory\n\t\tthis.formFactory = formFactory\n\t\tthis.formRecycler = formRecycler\n\t\tthis.changeListeners = changeListeners\n\t\tthis._initialised = initialised\n\n\t\tthis.synchronise()\n\t}\n\n\tsynchronise() {\n\t\tthis.children.forEach((childFVC) => {\n\t\t\tthis.registerChildFormValuesContainer(childFVC.synchronise())\n\t\t})\n\t\treturn this\n\t}\n\n\t//Make sure that when a child is changed, a new version of this is created with the updated child\n\tregisterChildFormValuesContainer(childFormValueContainer: ContactFormValuesContainer) {\n\t\tchildFormValueContainer.changeListeners = [\n\t\t\t(newValue) => {\n\t\t\t\tconsole.log(`Child ${newValue._id} ${childFormValueContainer.rootForm.formTemplateId} changed, updating parent ${this._id} ${this.rootForm.formTemplateId}`)\n\t\t\t\tconst newContactFormValuesContainer = new ContactFormValuesContainer(\n\t\t\t\t\tthis.rootForm,\n\t\t\t\t\tthis.currentContact,\n\t\t\t\t\tthis.contactsHistory,\n\t\t\t\t\tthis.serviceFactory,\n\t\t\t\t\tthis.children.map((c) => {\n\t\t\t\t\t\treturn c.rootForm.id === childFormValueContainer.rootForm.id ? newValue : c\n\t\t\t\t\t}),\n\t\t\t\t\tthis.formFactory,\n\t\t\t\t\tthis.formRecycler,\n\t\t\t\t)\n\t\t\t\tthis.changeListeners.forEach((l) => notify(l, newContactFormValuesContainer))\n\t\t\t},\n\t\t]\n\t}\n\n\tstatic async fromFormsHierarchy(\n\t\trootForm: CardinalForm,\n\t\tcurrentContact: DecryptedContact,\n\t\tcontactsHistory: DecryptedContact[],\n\t\tserviceFactory: (label: string, serviceId?: string) => DecryptedService,\n\t\tformChildrenProvider: (parentId: string | undefined) => Promise<CardinalForm[]>,\n\t\tformFactory: (parentId: string, anchorId: string, formTemplateId: string, label: string) => Promise<CardinalForm>,\n\t\tformRecycler: (formId: string) => Promise<void>,\n\t\tchangeListeners: ((newValue: ContactFormValuesContainer) => void)[] = [],\n\t): Promise<ContactFormValuesContainer> {\n\t\tconst contactFormValuesContainer = new ContactFormValuesContainer(\n\t\t\trootForm,\n\t\t\tcurrentContact,\n\t\t\tcontactsHistory,\n\t\t\tserviceFactory,\n\t\t\trootForm.id\n\t\t\t\t? await Promise.all(\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\tawait formChildrenProvider(rootForm.id)\n\t\t\t\t\t\t).map(\n\t\t\t\t\t\t\tasync (f) =>\n\t\t\t\t\t\t\t\t// eslint-disable-next-line max-len\n\t\t\t\t\t\t\t\tawait ContactFormValuesContainer.fromFormsHierarchy(f, currentContact, contactsHistory, serviceFactory, formChildrenProvider, formFactory, formRecycler),\n\t\t\t\t\t\t),\n\t\t\t\t )\n\t\t\t\t: [],\n\t\t\tformFactory,\n\t\t\tformRecycler,\n\t\t\tchangeListeners,\n\t\t\tfalse,\n\t\t)\n\t\tcontactFormValuesContainer.children.forEach((childFVC) => contactFormValuesContainer.registerChildFormValuesContainer(childFVC))\n\n\t\treturn contactFormValuesContainer\n\t}\n\n\tgetLabel(): string {\n\t\treturn this.rootForm.descr ?? ''\n\t}\n\n\tgetFormId(): string | undefined {\n\t\treturn this.rootForm?.formTemplateId\n\t}\n\n\tregisterChangeListener(listener: (newValue: ContactFormValuesContainer) => void): void {\n\t\tthis.changeListeners.push(listener)\n\t}\n\n\tunregisterChangeListener(listener: (newValue: ContactFormValuesContainer) => void): void {\n\t\tthis.changeListeners = this.changeListeners.filter((l) => l !== listener)\n\t}\n\n\tgetChildren(): ContactFormValuesContainer[] {\n\t\treturn this.children\n\t}\n\n\tgetValidationErrors(): [FieldMetadata, string][] {\n\t\tthrow new Error('Validation not supported at contact level')\n\t}\n\n\tgetValues(revisionsFilter: (id: string, history: Version<ServiceMetadata>[]) => (string | null)[]): VersionedData<DecryptedService> {\n\t\treturn Object.entries(this.getServicesInHistory(revisionsFilter)).reduce(\n\t\t\t(acc, [id, history]) =>\n\t\t\t\thistory.length\n\t\t\t\t\t? {\n\t\t\t\t\t\t\t...acc,\n\t\t\t\t\t\t\t[id]: [...history].sort((a, b) => (b?.modified || +new Date()) - (a?.modified || +new Date())),\n\t\t\t\t\t }\n\t\t\t\t\t: acc,\n\t\t\t{},\n\t\t)\n\t}\n\n\tgetMetadata(id: string, revisions: (string | null)[]): VersionedData<ServiceMetadata> {\n\t\treturn [this.currentContact]\n\t\t\t.concat(this.contactsHistory)\n\t\t\t.filter((ctc) => ctc.rev !== undefined && revisions.includes(ctc.rev))\n\t\t\t.reduce(\n\t\t\t\t(acc, ctc) =>\n\t\t\t\t\t(ctc.services ?? [])\n\t\t\t\t\t\t.filter((s) => s.id === id)\n\t\t\t\t\t\t.reduce(\n\t\t\t\t\t\t\t(acc, s) =>\n\t\t\t\t\t\t\t\ts.id\n\t\t\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t\t\t...acc,\n\t\t\t\t\t\t\t\t\t\t\t[s.id]: (acc[s.id] ?? (acc[s.id] = [])).concat({\n\t\t\t\t\t\t\t\t\t\t\t\trevision: ctc.rev ?? null,\n\t\t\t\t\t\t\t\t\t\t\t\tmodified: s.modified,\n\t\t\t\t\t\t\t\t\t\t\t\tvalue: {\n\t\t\t\t\t\t\t\t\t\t\t\t\tlabel: s.label ?? s.id,\n\t\t\t\t\t\t\t\t\t\t\t\t\tresponsible: s.responsible,\n\t\t\t\t\t\t\t\t\t\t\t\t\tvalueDate: s.valueDate,\n\t\t\t\t\t\t\t\t\t\t\t\t\ttags: s.tags,\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t\t\t: acc,\n\t\t\t\t\t\t\tacc,\n\t\t\t\t\t\t) ?? acc,\n\t\t\t\t{} as { [id: string]: Version<ServiceMetadata>[] },\n\t\t\t) //index services in history by id\n\t}\n\n\tsetMetadata(meta: ServiceMetadata, id?: string): void {\n\t\tconst service = (id && this.getServiceInCurrentContact(id)) || this.serviceFactory(meta.label, id)\n\t\tif (!service.id) {\n\t\t\tthrow new Error('Service id must be defined')\n\t\t}\n\t\tif (\n\t\t\t(meta.responsible && service.responsible !== meta.responsible) ||\n\t\t\t(meta.valueDate && service.valueDate !== meta.valueDate) ||\n\t\t\t(meta.codes && service.codes !== meta.codes) ||\n\t\t\t(meta.tags && service.tags !== meta.tags)\n\t\t) {\n\t\t\tconst newService = new DecryptedService({ ...service, modified: Date.now() })\n\t\t\tmeta.responsible && (newService.responsible = meta.responsible)\n\t\t\tmeta.valueDate && (newService.valueDate = meta.valueDate)\n\t\t\tmeta.codes && (newService.codes = normalizeCodes(meta.codes))\n\t\t\tmeta.tags && (newService.tags = normalizeCodes(meta.tags))\n\n\t\t\tconst newFormValuesContainer = new ContactFormValuesContainer(\n\t\t\t\tthis.rootForm,\n\t\t\t\t{\n\t\t\t\t\t...this.currentContact,\n\t\t\t\t\tservices: this.currentContact.services?.map((s) => (s.id === service.id ? newService : s)),\n\t\t\t\t},\n\t\t\t\tthis.contactsHistory,\n\t\t\t\tthis.serviceFactory,\n\t\t\t\tthis.children,\n\t\t\t\tthis.formFactory,\n\t\t\t\tthis.formRecycler,\n\t\t\t\tthis.changeListeners,\n\t\t\t)\n\n\t\t\tthis.changeListeners.forEach((l) => notify(l, newFormValuesContainer))\n\t\t}\n\t}\n\n\tsetValue(label: string, language: string, value?: DecryptedService, id?: string, metadata?: ServiceMetadata, changeListenersOverrider?: (fvc: ContactFormValuesContainer) => void): void {\n\t\tconst service = (id && this.getServicesInHistory((sid: string, history) => (sid === id ? history.map((x) => x.revision) : []))[id]?.[0]?.value) || this.serviceFactory(label, id)\n\t\tif (!service.id) {\n\t\t\tthrow new Error('Service id must be defined')\n\t\t}\n\t\tconsole.log('Setting value of service', service.id, 'with', value, 'and metadata', metadata)\n\t\tconst newContent = value?.content?.[language]\n\t\tconst newCodes = value?.codes ? normalizeCodes(value.codes) : []\n\t\tif (!isContentEqual(service.content?.[language], newContent) || (newCodes && !areCodesEqual(newCodes, service.codes ?? []))) {\n\t\t\tconst newService = new DecryptedService({ ...service, modified: Date.now() })\n\t\t\tconst newContents = newContent\n\t\t\t\t? {\n\t\t\t\t\t\t...(service.content || {}),\n\t\t\t\t\t\t[language]: newContent,\n\t\t\t\t }\n\t\t\t\t: { ...(service.content || {}) }\n\t\t\tif (!newContent) {\n\t\t\t\tdelete newContents[language]\n\t\t\t}\n\n\t\t\tlet newCurrentContact: DecryptedContact\n\t\t\tif (!Object.entries(newContents).filter(([, cnt]) => cnt !== undefined).length) {\n\t\t\t\tnewCurrentContact = {\n\t\t\t\t\t...this.currentContact,\n\t\t\t\t\tsubContacts: (this.currentContact.subContacts ?? []).some((sc) => sc.formId === this.rootForm.id)\n\t\t\t\t\t\t? (this.currentContact.subContacts ?? []).map((sc) => {\n\t\t\t\t\t\t\t\tif (sc.formId === this.rootForm.id) {\n\t\t\t\t\t\t\t\t\treturn { ...sc, services: (sc.services ?? []).filter((s) => s.serviceId !== service.id).concat([{ serviceId: service.id }]) }\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\treturn sc\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t })\n\t\t\t\t\t\t: (this.currentContact.subContacts ?? []).concat(new DecryptedSubContact({ formId: this.rootForm.id, services: [{ serviceId: service.id }] })),\n\t\t\t\t\tservices: (this.currentContact.services ?? []).some((s) => s.id === service.id)\n\t\t\t\t\t\t? (this.currentContact.services ?? []).filter((s) => s.id !== service.id)\n\t\t\t\t\t\t: [...(this.currentContact.services ?? [])],\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tnewService.content = newContents\n\t\t\t\tnewService.codes = newCodes\n\n\t\t\t\tif (metadata) {\n\t\t\t\t\tnewService.responsible = metadata.responsible ?? newService.responsible\n\t\t\t\t\tnewService.valueDate = metadata.valueDate ?? newService.valueDate\n\t\t\t\t\tnewService.tags = metadata.tags ? normalizeCodes(metadata.tags) : newService.tags\n\t\t\t\t\tnewService.label = metadata.label ?? newService.label\n\t\t\t\t}\n\n\t\t\t\tnewCurrentContact = {\n\t\t\t\t\t...this.currentContact,\n\t\t\t\t\tsubContacts: (this.currentContact.subContacts ?? []).some((sc) => sc.formId === this.rootForm.id)\n\t\t\t\t\t\t? (this.currentContact.subContacts ?? []).map((sc) => {\n\t\t\t\t\t\t\t\tif (sc.formId === this.rootForm.id) {\n\t\t\t\t\t\t\t\t\treturn { ...sc, services: (sc.services ?? []).filter((s) => s.serviceId !== service.id).concat([{ serviceId: service.id }]) }\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\treturn sc\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t })\n\t\t\t\t\t\t: (this.currentContact.subContacts ?? []).concat(new DecryptedSubContact({ formId: this.rootForm.id, services: [{ serviceId: service.id }] })),\n\t\t\t\t\tservices: (this.currentContact.services ?? []).some((s) => s.id === service.id)\n\t\t\t\t\t\t? (this.currentContact.services ?? []).map((s) => (s.id === service.id ? newService : s))\n\t\t\t\t\t\t: [...(this.currentContact.services ?? []), newService],\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst newFormValuesContainer = new ContactFormValuesContainer(\n\t\t\t\tthis.rootForm,\n\t\t\t\tnewCurrentContact,\n\t\t\t\tthis.contactsHistory.map((c) => (c === this.currentContact ? newCurrentContact : c)),\n\t\t\t\tthis.serviceFactory,\n\t\t\t\tthis.children,\n\t\t\t\tthis.formFactory,\n\t\t\t\tthis.formRecycler,\n\t\t\t\tthis.changeListeners,\n\t\t\t)\n\n\t\t\tchangeListenersOverrider ? changeListenersOverrider(newFormValuesContainer) : this.changeListeners.forEach((l) => notify(l, newFormValuesContainer))\n\t\t}\n\t}\n\n\tdelete(serviceId: string): void {\n\t\tconst service = this.getServiceInCurrentContact(serviceId)\n\t\tif (service) {\n\t\t\tconst newFormValuesContainer = new ContactFormValuesContainer(\n\t\t\t\tthis.rootForm,\n\t\t\t\t{\n\t\t\t\t\t...this.currentContact,\n\t\t\t\t\tservices: this.currentContact.services?.map((s) =>\n\t\t\t\t\t\ts.id === serviceId\n\t\t\t\t\t\t\t? new DecryptedService({\n\t\t\t\t\t\t\t\t\t...service,\n\t\t\t\t\t\t\t\t\tendOfLife: Date.now(),\n\t\t\t\t\t\t\t })\n\t\t\t\t\t\t\t: s,\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t\tthis.contactsHistory,\n\t\t\t\tthis.serviceFactory,\n\t\t\t\tthis.children,\n\t\t\t\tthis.formFactory,\n\t\t\t\tthis.formRecycler,\n\t\t\t\tthis.changeListeners,\n\t\t\t)\n\n\t\t\tthis.changeListeners.forEach((l) => notify(l, newFormValuesContainer))\n\t\t}\n\t}\n\n\tcompute<T>(): T | undefined {\n\t\tthrow new Error('Compute not supported at contact level')\n\t}\n\n\t/** returns all services in history that match a selector\n\t *\n\t * @private\n\t * @param revisionsFilter\n\t */\n\tprivate getServicesInHistory(revisionsFilter: (id: string, history: Version<ServiceMetadata>[]) => (string | null)[]): VersionedData<DecryptedService> {\n\t\tconst indexedServices = [this.currentContact].concat(this.contactsHistory).reduce((acc, ctc) => {\n\t\t\tconst services =\n\t\t\t\tctc.services\n\t\t\t\t\t?.filter((s) => ctc.subContacts?.some((sc) => sc.formId === this.rootForm.id && sc.services?.some((sss) => sss.serviceId === s.id)))\n\t\t\t\t\t?.reduce(\n\t\t\t\t\t\t(acc, s) =>\n\t\t\t\t\t\t\ts.id\n\t\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t\t...acc,\n\t\t\t\t\t\t\t\t\t\t[s.id]: (acc[s.id] ?? (acc[s.id] = [])).concat({\n\t\t\t\t\t\t\t\t\t\t\trevision: ctc.rev ?? null,\n\t\t\t\t\t\t\t\t\t\t\tmodified: ctc.created,\n\t\t\t\t\t\t\t\t\t\t\tvalue: s,\n\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t\t: acc,\n\t\t\t\t\t\tacc,\n\t\t\t\t\t) ?? acc\n\t\t\treturn services\n\t\t}, {} as VersionedData<DecryptedService>) //index services in history by id\n\t\treturn Object.entries(indexedServices)\n\t\t\t.map(([id, history]) => {\n\t\t\t\tconst keptRevisions = revisionsFilter(\n\t\t\t\t\tid,\n\t\t\t\t\thistory.map(({ revision, modified, value: s }) => ({\n\t\t\t\t\t\trevision,\n\t\t\t\t\t\tmodified,\n\t\t\t\t\t\tvalue: {\n\t\t\t\t\t\t\tlabel: s.label ?? s.id ?? '',\n\t\t\t\t\t\t\towner: s.responsible,\n\t\t\t\t\t\t\tvalueDate: s.valueDate,\n\t\t\t\t\t\t\tcodes: s.codes,\n\t\t\t\t\t\t\ttags: s.tags,\n\t\t\t\t\t\t},\n\t\t\t\t\t})),\n\t\t\t\t)\n\t\t\t\treturn [id, history.filter(({ revision }) => keptRevisions.includes(revision))] as [string, Version<DecryptedService>[]]\n\t\t\t})\n\t\t\t.reduce((acc, [id, history]) => ({ ...acc, [id]: history }), {})\n\t}\n\n\tasync addChild(anchorId: string, templateId: string, label: string): Promise<void> {\n\t\tconst parentId = this.rootForm.id\n\t\tif (!parentId) return\n\n\t\tconst newForm = await this.formFactory(parentId, anchorId, templateId, label)\n\t\tconst childFVC = new ContactFormValuesContainer(newForm, this.currentContact, this.contactsHistory, this.serviceFactory, [], this.formFactory, this.formRecycler, [], false)\n\n\t\tconst newContactFormValuesContainer = new ContactFormValuesContainer(\n\t\t\tthis.rootForm,\n\t\t\tthis.currentContact,\n\t\t\tthis.contactsHistory,\n\t\t\tthis.serviceFactory,\n\t\t\t[...this.children, childFVC],\n\t\t\tthis.formFactory,\n\t\t\tthis.formRecycler,\n\t\t\tthis.changeListeners,\n\t\t)\n\t\tnewContactFormValuesContainer.registerChildFormValuesContainer(childFVC)\n\t\tthis.changeListeners.forEach((l) => notify(l, newContactFormValuesContainer))\n\t}\n\n\tprivate getServiceInCurrentContact(id: string): DecryptedService | undefined {\n\t\tconst service = (this.currentContact.services || [])?.find((s) => s.id === id)\n\t\treturn service ?? undefined\n\t}\n\n\tasync removeChild(container: ContactFormValuesContainer): Promise<void> {\n\t\tconst newContactFormValuesContainer = new ContactFormValuesContainer(\n\t\t\tthis.rootForm,\n\t\t\tthis.currentContact,\n\t\t\tthis.contactsHistory,\n\t\t\tthis.serviceFactory,\n\t\t\tthis.children.filter((c) => c.rootForm.id !== container.rootForm.id),\n\t\t\tthis.formFactory,\n\t\t\tthis.formRecycler,\n\t\t\tthis.changeListeners,\n\t\t)\n\t\tthis.changeListeners.forEach((l) => notify(l, newContactFormValuesContainer))\n\t}\n}\n\nconst setValueOnContactFormValuesContainer = (\n\tcfvc: ContactFormValuesContainer,\n\tlabel: string,\n\tlanguage: string,\n\tfv?: FieldValue,\n\tid?: string,\n\tmetadata?: FieldMetadata,\n\tchangeListenersOverrider?: (fvc: ContactFormValuesContainer) => void,\n) => {\n\tconst value = fv?.content[language]\n\tcfvc.setValue(\n\t\tlabel,\n\t\tlanguage,\n\t\tnew DecryptedService({\n\t\t\tid: id,\n\t\t\tcodes: fv?.codes?.map((x) => new CodeStub(x)) ?? [],\n\t\t\tcontent: value\n\t\t\t\t? {\n\t\t\t\t\t\t[language]: primitiveTypeToContent(language, value),\n\t\t\t\t }\n\t\t\t\t: undefined,\n\t\t}),\n\t\tid,\n\t\tmetadata\n\t\t\t? {\n\t\t\t\t\tlabel: metadata?.label ?? label,\n\t\t\t\t\tresponsible: metadata?.owner,\n\t\t\t\t\tvalueDate: metadata?.valueDate,\n\t\t\t\t\ttags: metadata?.tags?.map((x) => new CodeStub(x)),\n\t\t\t }\n\t\t\t: undefined,\n\t\tchangeListenersOverrider,\n\t)\n}\n"]}
|
package/icure/icure-utils.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { CodeStub,
|
|
1
|
+
import { CodeStub, DecryptedContent, DecryptedService } from '@icure/cardinal-sdk';
|
|
2
2
|
import { PrimitiveType } from '../components/model';
|
|
3
3
|
export declare function isCodeEqual(c1: CodeStub, c2: CodeStub): boolean;
|
|
4
4
|
export declare function areCodesEqual(c1s: CodeStub[], c2s: CodeStub[]): boolean;
|
|
5
|
-
export declare function isServiceEqual(svc1:
|
|
6
|
-
export declare function isContentEqual(content1:
|
|
5
|
+
export declare function isServiceEqual(svc1: DecryptedService, svc2: DecryptedService): boolean;
|
|
6
|
+
export declare function isContentEqual(content1: DecryptedContent | undefined, content2: DecryptedContent | undefined): boolean;
|
|
7
7
|
export declare function isServiceContentEqual(content1: {
|
|
8
|
-
[language: string]:
|
|
8
|
+
[language: string]: DecryptedContent;
|
|
9
9
|
}, content2: {
|
|
10
|
-
[language: string]:
|
|
10
|
+
[language: string]: DecryptedContent;
|
|
11
11
|
}): boolean;
|
|
12
|
-
export declare const primitiveTypeToContent: (language: string, value: PrimitiveType) =>
|
|
13
|
-
export declare const contentToPrimitiveType: (language: string, content:
|
|
12
|
+
export declare const primitiveTypeToContent: (language: string, value: PrimitiveType) => DecryptedContent;
|
|
13
|
+
export declare const contentToPrimitiveType: (language: string, content: DecryptedContent | undefined) => PrimitiveType | undefined;
|
|
14
14
|
export declare const codeStubToCode: (c: CodeStub) => {
|
|
15
15
|
id: string;
|
|
16
16
|
label: {
|