@f1studio/form-spec 5.0.0-alpha.102 → 5.0.0-alpha.104
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/FormSpec.TS/Designer.js +2 -2
- package/FormSpec.TS/Designer.js.map +1 -1
- package/FormSpec.TS/Designer.ts.map +1 -1
- package/FormSpec.TS/FormSpec.js +235 -178
- package/FormSpec.TS/FormSpec.js.map +1 -1
- package/FormSpec.TS/FormSpec.ts.map +1 -1
- package/FormSpec.TS/FormSpecHelpers.js +62 -40
- package/FormSpec.TS/FormSpecHelpers.js.map +1 -1
- package/FormSpec.TS/FormSpecHelpers.ts.map +1 -1
- package/FormSpec.TS/FormSpecValues.js +207 -0
- package/FormSpec.TS/FormSpecValues.js.map +1 -0
- package/FormSpec.TS/FormSpecValues.ts.map +1 -0
- package/FormSpec.TS/Helpers.js +26 -25
- package/FormSpec.TS/Helpers.js.map +1 -1
- package/FormSpec.TS/Helpers.ts.map +1 -1
- package/FormSpec.TS/Interop/FormSpec.Api.Helpers.js +85 -125
- package/FormSpec.TS/Interop/FormSpec.Api.Helpers.js.map +1 -1
- package/FormSpec.TS/Interop/FormSpec.Api.Helpers.ts.map +1 -1
- package/FormSpec.TS/Interop/FormSpec.Api.Option.js +40 -19
- package/FormSpec.TS/Interop/FormSpec.Api.Option.js.map +1 -1
- package/FormSpec.TS/Interop/FormSpec.Api.Option.ts.map +1 -1
- package/FormSpec.TS/Interop/FormSpec.Values.Api.Option.js +103 -80
- package/FormSpec.TS/Interop/FormSpec.Values.Api.Option.js.map +1 -1
- package/FormSpec.TS/Interop/FormSpec.Values.Api.Option.ts.map +1 -1
- package/FormSpec.TS/PathwayDataExtractor.js +4 -19
- package/FormSpec.TS/PathwayDataExtractor.js.map +1 -1
- package/FormSpec.TS/PathwayDataExtractor.ts.map +1 -1
- package/FormSpec.TS/PathwayExecutor.js +371 -125
- package/FormSpec.TS/PathwayExecutor.js.map +1 -1
- package/FormSpec.TS/PathwayExecutor.ts.map +1 -1
- package/FormSpec.TS/PathwayValidator.js +14 -26
- package/FormSpec.TS/PathwayValidator.js.map +1 -1
- package/FormSpec.TS/PathwayValidator.ts.map +1 -1
- package/FormSpec.TS/Renderers/FormSpecMarkdownRenderer.ts.map +1 -1
- package/FormSpec.TS/Renderers/MermaidRenderer.js +8 -5
- package/FormSpec.TS/Renderers/MermaidRenderer.js.map +1 -1
- package/FormSpec.TS/Renderers/MermaidRenderer.ts.map +1 -1
- package/FormSpec.TS/Renderers/PathwayRenderers.js +35 -26
- package/FormSpec.TS/Renderers/PathwayRenderers.js.map +1 -1
- package/FormSpec.TS/Renderers/PathwayRenderers.ts.map +1 -1
- package/FormSpec.TS/fable_modules/Thoth.Json.10.4.1/Encode.fs.js.map +1 -1
- package/FormSpec.TS/fable_modules/Thoth.Json.10.4.1/Encode.fs.ts.map +1 -1
- package/FormSpec.TS/fable_modules/project_cracked.json +1 -1
- package/FormSpec.d.ts +67 -56
- package/FormSpec.d.ts.map +1 -1
- package/FormSpecHelpers.d.ts +18 -12
- package/FormSpecHelpers.d.ts.map +1 -1
- package/FormSpecValues.d.ts +62 -0
- package/FormSpecValues.d.ts.map +1 -0
- package/Helpers.d.ts +11 -10
- package/Helpers.d.ts.map +1 -1
- package/Interop/FormSpec.Api.Helpers.d.ts +26 -30
- package/Interop/FormSpec.Api.Helpers.d.ts.map +1 -1
- package/Interop/FormSpec.Api.Option.d.ts +11 -8
- package/Interop/FormSpec.Api.Option.d.ts.map +1 -1
- package/Interop/FormSpec.Values.Api.Option.d.ts +35 -22
- package/Interop/FormSpec.Values.Api.Option.d.ts.map +1 -1
- package/PathwayDataExtractor.d.ts +1 -2
- package/PathwayDataExtractor.d.ts.map +1 -1
- package/PathwayExecutor.d.ts +63 -33
- package/PathwayExecutor.d.ts.map +1 -1
- package/PathwayValidator.d.ts.map +1 -1
- package/README.md +18 -7
- package/Renderers/FormSpecMarkdownRenderer.d.ts +3 -2
- package/Renderers/FormSpecMarkdownRenderer.d.ts.map +1 -1
- package/Renderers/MermaidRenderer.d.ts.map +1 -1
- package/Renderers/PathwayRenderers.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/Designer.ts +2 -2
- package/src/FormSpec.ts +145 -109
- package/src/FormSpecHelpers.ts +71 -48
- package/src/FormSpecValues.ts +158 -0
- package/src/Helpers.ts +52 -51
- package/src/Interop/FormSpec.Api.Helpers.ts +113 -150
- package/src/Interop/FormSpec.Api.Option.ts +37 -23
- package/src/Interop/FormSpec.Values.Api.Option.ts +156 -129
- package/src/PathwayDataExtractor.ts +6 -17
- package/src/PathwayExecutor.ts +431 -154
- package/src/PathwayValidator.ts +17 -23
- package/src/Renderers/FormSpecMarkdownRenderer.ts +6 -5
- package/src/Renderers/MermaidRenderer.ts +19 -16
- package/src/Renderers/PathwayRenderers.ts +37 -29
|
@@ -15,11 +15,11 @@ _export(exports, {
|
|
|
15
15
|
get ClinicalPlan_$reflection () {
|
|
16
16
|
return ClinicalPlan_$reflection;
|
|
17
17
|
},
|
|
18
|
-
get ExecutionContext
|
|
19
|
-
return ExecutionContext
|
|
18
|
+
get ExecutionContext () {
|
|
19
|
+
return ExecutionContext;
|
|
20
20
|
},
|
|
21
|
-
get
|
|
22
|
-
return
|
|
21
|
+
get ExecutionContext_$reflection () {
|
|
22
|
+
return ExecutionContext_$reflection;
|
|
23
23
|
},
|
|
24
24
|
get ExecutionLogEntry () {
|
|
25
25
|
return ExecutionLogEntry;
|
|
@@ -36,11 +36,11 @@ _export(exports, {
|
|
|
36
36
|
get FieldResolver_generateFieldKey () {
|
|
37
37
|
return FieldResolver_generateFieldKey;
|
|
38
38
|
},
|
|
39
|
-
get IncrementalExecutionResult
|
|
40
|
-
return IncrementalExecutionResult
|
|
39
|
+
get IncrementalExecutionResult () {
|
|
40
|
+
return IncrementalExecutionResult;
|
|
41
41
|
},
|
|
42
|
-
get
|
|
43
|
-
return
|
|
42
|
+
get IncrementalExecutionResult_$reflection () {
|
|
43
|
+
return IncrementalExecutionResult_$reflection;
|
|
44
44
|
},
|
|
45
45
|
get MatchedTransition () {
|
|
46
46
|
return MatchedTransition;
|
|
@@ -60,6 +60,24 @@ _export(exports, {
|
|
|
60
60
|
get PredictedPathway_$reflection () {
|
|
61
61
|
return PredictedPathway_$reflection;
|
|
62
62
|
},
|
|
63
|
+
get ScoreCalculator_calculateFieldScore () {
|
|
64
|
+
return ScoreCalculator_calculateFieldScore;
|
|
65
|
+
},
|
|
66
|
+
get ScoreCalculator_calculateFieldValueScore () {
|
|
67
|
+
return ScoreCalculator_calculateFieldValueScore;
|
|
68
|
+
},
|
|
69
|
+
get ScoreCalculator_calculateStepScore () {
|
|
70
|
+
return ScoreCalculator_calculateStepScore;
|
|
71
|
+
},
|
|
72
|
+
get ScoreCalculator_calculateTotalScore () {
|
|
73
|
+
return ScoreCalculator_calculateTotalScore;
|
|
74
|
+
},
|
|
75
|
+
get ScoreCalculator_extractFieldOptions () {
|
|
76
|
+
return ScoreCalculator_extractFieldOptions;
|
|
77
|
+
},
|
|
78
|
+
get ScoreCalculator_getScoreRange () {
|
|
79
|
+
return ScoreCalculator_getScoreRange;
|
|
80
|
+
},
|
|
63
81
|
get TransitionStatus () {
|
|
64
82
|
return TransitionStatus;
|
|
65
83
|
},
|
|
@@ -99,6 +117,9 @@ _export(exports, {
|
|
|
99
117
|
get evaluateFieldConditionWithConditionValue () {
|
|
100
118
|
return evaluateFieldConditionWithConditionValue;
|
|
101
119
|
},
|
|
120
|
+
get evaluateMatrixItemCondition () {
|
|
121
|
+
return evaluateMatrixItemCondition;
|
|
122
|
+
},
|
|
102
123
|
get evaluateTransitionWithPartialData () {
|
|
103
124
|
return evaluateTransitionWithPartialData;
|
|
104
125
|
},
|
|
@@ -152,18 +173,21 @@ const _Types = require("@fable-org/fable-library-js/Types.js");
|
|
|
152
173
|
const _List = require("@fable-org/fable-library-js/List.js");
|
|
153
174
|
const _Reflection = require("@fable-org/fable-library-js/Reflection.js");
|
|
154
175
|
const _FormSpec = require("./FormSpec.js");
|
|
176
|
+
const _Int32 = require("@fable-org/fable-library-js/Int32.js");
|
|
155
177
|
const _Util = require("@fable-org/fable-library-js/Util.js");
|
|
156
178
|
const _Set = require("@fable-org/fable-library-js/Set.js");
|
|
179
|
+
const _Option = require("@fable-org/fable-library-js/Option.js");
|
|
180
|
+
const _Map = require("@fable-org/fable-library-js/Map.js");
|
|
181
|
+
const _FormSpecValues = require("./FormSpecValues.js");
|
|
157
182
|
const _Array = require("@fable-org/fable-library-js/Array.js");
|
|
158
183
|
const _BitConverter = require("@fable-org/fable-library-js/BitConverter.js");
|
|
159
184
|
const _Guid = require("@fable-org/fable-library-js/Guid.js");
|
|
160
|
-
const _Map = require("@fable-org/fable-library-js/Map.js");
|
|
161
|
-
const _Option = require("@fable-org/fable-library-js/Option.js");
|
|
162
|
-
const _Seq = require("@fable-org/fable-library-js/Seq.js");
|
|
163
185
|
const _String = require("@fable-org/fable-library-js/String.js");
|
|
164
186
|
const _Encodefs = require("./fable_modules/Thoth.Json.10.4.1/Encode.fs.js");
|
|
165
187
|
const _Double = require("@fable-org/fable-library-js/Double.js");
|
|
166
188
|
const _RegExp = require("@fable-org/fable-library-js/RegExp.js");
|
|
189
|
+
const _Decodefs = require("./fable_modules/Thoth.Json.10.4.1/Decode.fs.js");
|
|
190
|
+
const _PluginInterface = require("./PluginInterface.js");
|
|
167
191
|
const _Date = require("@fable-org/fable-library-js/Date.js");
|
|
168
192
|
function TransitionStatus_Satisfied() {
|
|
169
193
|
return new TransitionStatus(0, []);
|
|
@@ -253,8 +277,8 @@ function ExecutionLogEntry_$reflection() {
|
|
|
253
277
|
]
|
|
254
278
|
]);
|
|
255
279
|
}
|
|
256
|
-
class ExecutionContext
|
|
257
|
-
constructor(PathwaySpec, FormSpec, CurrentStates, VisitedStates, CompletedStates, ActiveTransitions, PendingTransitions, ExecutedActions,
|
|
280
|
+
class ExecutionContext extends _Types.Record {
|
|
281
|
+
constructor(PathwaySpec, FormSpec, CurrentStates, VisitedStates, CompletedStates, ActiveTransitions, PendingTransitions, ExecutedActions, FieldResolver, ExecutionLog){
|
|
258
282
|
super();
|
|
259
283
|
this.PathwaySpec = PathwaySpec;
|
|
260
284
|
this.FormSpec = FormSpec;
|
|
@@ -264,22 +288,19 @@ class ExecutionContext$1 extends _Types.Record {
|
|
|
264
288
|
this.ActiveTransitions = ActiveTransitions;
|
|
265
289
|
this.PendingTransitions = PendingTransitions;
|
|
266
290
|
this.ExecutedActions = ExecutedActions;
|
|
267
|
-
this.FormData = FormData;
|
|
268
291
|
this.FieldResolver = FieldResolver;
|
|
269
292
|
this.ExecutionLog = ExecutionLog;
|
|
270
293
|
}
|
|
271
294
|
}
|
|
272
|
-
function
|
|
273
|
-
return (0, _Reflection.record_type)("F1.Studio.PathwayExecutor.ExecutionContext
|
|
274
|
-
gen0
|
|
275
|
-
], ExecutionContext$1, ()=>[
|
|
295
|
+
function ExecutionContext_$reflection() {
|
|
296
|
+
return (0, _Reflection.record_type)("F1.Studio.PathwayExecutor.ExecutionContext", [], ExecutionContext, ()=>[
|
|
276
297
|
[
|
|
277
298
|
"PathwaySpec",
|
|
278
299
|
(0, _FormSpec.ClinicalPathway_ClinicalPathwaySpec_$reflection)()
|
|
279
300
|
],
|
|
280
301
|
[
|
|
281
302
|
"FormSpec",
|
|
282
|
-
(0, _FormSpec.Spec_FormSpec$1_$reflection)(
|
|
303
|
+
(0, _FormSpec.Spec_FormSpec$1_$reflection)((0, _FormSpec.Spec_FieldType_$reflection)())
|
|
283
304
|
],
|
|
284
305
|
[
|
|
285
306
|
"CurrentStates",
|
|
@@ -311,10 +332,6 @@ function ExecutionContext$1_$reflection(gen0) {
|
|
|
311
332
|
"ExecutedActions",
|
|
312
333
|
(0, _Reflection.list_type)((0, _FormSpec.ClinicalPathway_ActionInfo_$reflection)())
|
|
313
334
|
],
|
|
314
|
-
[
|
|
315
|
-
"FormData",
|
|
316
|
-
(0, _FormSpec.Values_DynamicFormResultData$1_$reflection)(gen0)
|
|
317
|
-
],
|
|
318
335
|
[
|
|
319
336
|
"FieldResolver",
|
|
320
337
|
(0, _Reflection.lambda_type)(_Reflection.string_type, (0, _FormSpec.Shared_FieldKey_$reflection)())
|
|
@@ -359,7 +376,7 @@ function PredictedPathway_$reflection() {
|
|
|
359
376
|
]
|
|
360
377
|
]);
|
|
361
378
|
}
|
|
362
|
-
class IncrementalExecutionResult
|
|
379
|
+
class IncrementalExecutionResult extends _Types.Record {
|
|
363
380
|
constructor(Context, NewlyActivatedStates, NewlyActiveTransitions, PredictedOutcomes, CompletionPercentage, IsComplete){
|
|
364
381
|
super();
|
|
365
382
|
this.Context = Context;
|
|
@@ -370,13 +387,11 @@ class IncrementalExecutionResult$1 extends _Types.Record {
|
|
|
370
387
|
this.IsComplete = IsComplete;
|
|
371
388
|
}
|
|
372
389
|
}
|
|
373
|
-
function
|
|
374
|
-
return (0, _Reflection.record_type)("F1.Studio.PathwayExecutor.IncrementalExecutionResult
|
|
375
|
-
gen0
|
|
376
|
-
], IncrementalExecutionResult$1, ()=>[
|
|
390
|
+
function IncrementalExecutionResult_$reflection() {
|
|
391
|
+
return (0, _Reflection.record_type)("F1.Studio.PathwayExecutor.IncrementalExecutionResult", [], IncrementalExecutionResult, ()=>[
|
|
377
392
|
[
|
|
378
393
|
"Context",
|
|
379
|
-
|
|
394
|
+
ExecutionContext_$reflection()
|
|
380
395
|
],
|
|
381
396
|
[
|
|
382
397
|
"NewlyActivatedStates",
|
|
@@ -472,6 +487,97 @@ function VisualizationState_$reflection() {
|
|
|
472
487
|
]
|
|
473
488
|
]);
|
|
474
489
|
}
|
|
490
|
+
function ScoreCalculator_extractFieldOptions(fieldType) {
|
|
491
|
+
const matchValue = fieldType;
|
|
492
|
+
if (matchValue instanceof _FormSpec.Spec_FieldType) {
|
|
493
|
+
const ft = matchValue;
|
|
494
|
+
switch(ft.tag){
|
|
495
|
+
case /* Radio */ 12:
|
|
496
|
+
return ft.fields[0].Options;
|
|
497
|
+
case /* SingleChoice */ 13:
|
|
498
|
+
return ft.fields[0].Options;
|
|
499
|
+
case /* Dropdown */ 14:
|
|
500
|
+
return ft.fields[0].Options;
|
|
501
|
+
case /* TextAutoComplete */ 18:
|
|
502
|
+
return ft.fields[0].Options;
|
|
503
|
+
case /* MultiChoice */ 15:
|
|
504
|
+
return ft.fields[0].Options;
|
|
505
|
+
case /* CheckboxList */ 16:
|
|
506
|
+
return ft.fields[0].Options;
|
|
507
|
+
case /* TagList */ 17:
|
|
508
|
+
return ft.fields[0].Options;
|
|
509
|
+
case /* Matrix */ 19:
|
|
510
|
+
return ft.fields[0].Options;
|
|
511
|
+
default:
|
|
512
|
+
return undefined;
|
|
513
|
+
}
|
|
514
|
+
} else {
|
|
515
|
+
return undefined;
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
function ScoreCalculator_calculateFieldValueScore(options, fieldValue) {
|
|
519
|
+
switch(fieldValue.tag){
|
|
520
|
+
case /* Single */ 0:
|
|
521
|
+
{
|
|
522
|
+
const answer = fieldValue.fields[0];
|
|
523
|
+
return (0, _Option.bind)((opt_1)=>opt_1.Score, (0, _List.tryFind)((opt)=>opt.Value === answer.Value, options));
|
|
524
|
+
}
|
|
525
|
+
case /* Multiple */ 1:
|
|
526
|
+
{
|
|
527
|
+
const _arg = (0, _List.choose)((answer_1)=>(0, _Option.bind)((opt_3)=>opt_3.Score, (0, _List.tryFind)((opt_2)=>opt_2.Value === answer_1.Value, options)), (0, _Set.toList)(fieldValue.fields[0]));
|
|
528
|
+
if ((0, _List.isEmpty)(_arg)) {
|
|
529
|
+
return undefined;
|
|
530
|
+
} else {
|
|
531
|
+
return (0, _List.sum)(_arg, {
|
|
532
|
+
GetZero: ()=>0,
|
|
533
|
+
Add: (x, y)=>x + y
|
|
534
|
+
});
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
case /* Matrix */ 2:
|
|
538
|
+
{
|
|
539
|
+
const _arg_2 = (0, _List.choose)((tupledArg)=>(0, _Option.bind)((opt_5)=>opt_5.Score, (0, _List.tryFind)((opt_4)=>opt_4.Value === tupledArg[1], options)), (0, _Map.toList)(fieldValue.fields[0].Values));
|
|
540
|
+
if ((0, _List.isEmpty)(_arg_2)) {
|
|
541
|
+
return undefined;
|
|
542
|
+
} else {
|
|
543
|
+
return (0, _List.sum)(_arg_2, {
|
|
544
|
+
GetZero: ()=>0,
|
|
545
|
+
Add: (x_1, y_1)=>x_1 + y_1
|
|
546
|
+
});
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
default:
|
|
550
|
+
return undefined;
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
function ScoreCalculator_calculateFieldScore(field, fieldValue) {
|
|
554
|
+
return (0, _Option.bind)((options)=>ScoreCalculator_calculateFieldValueScore(options, fieldValue), ScoreCalculator_extractFieldOptions(field.FieldType));
|
|
555
|
+
}
|
|
556
|
+
function ScoreCalculator_calculateStepScore(formSpec, step) {
|
|
557
|
+
return (0, _List.sum)((0, _List.choose)((field)=>ScoreCalculator_calculateFieldScore(field, (0, _FormSpecValues.fieldToDetails)(field).FieldValue), step.Fields), {
|
|
558
|
+
GetZero: ()=>0,
|
|
559
|
+
Add: (x, y)=>x + y
|
|
560
|
+
});
|
|
561
|
+
}
|
|
562
|
+
function ScoreCalculator_calculateTotalScore(formSpec) {
|
|
563
|
+
return (0, _List.sumBy)((step)=>ScoreCalculator_calculateStepScore(formSpec, step), formSpec.Steps, {
|
|
564
|
+
GetZero: ()=>0,
|
|
565
|
+
Add: (x, y)=>x + y
|
|
566
|
+
});
|
|
567
|
+
}
|
|
568
|
+
function ScoreCalculator_getScoreRange(score, value) {
|
|
569
|
+
if (score != null) {
|
|
570
|
+
return (0, _List.tryFind)((range)=>{
|
|
571
|
+
if (value >= range.Min) {
|
|
572
|
+
return value <= range.Max;
|
|
573
|
+
} else {
|
|
574
|
+
return false;
|
|
575
|
+
}
|
|
576
|
+
}, (0, _Option.value)(score).ScoreRanges);
|
|
577
|
+
} else {
|
|
578
|
+
return undefined;
|
|
579
|
+
}
|
|
580
|
+
}
|
|
475
581
|
function FieldResolver_generateFieldKey(fieldName) {
|
|
476
582
|
const hash = (0, _Util.stringHash)(fieldName) | 0;
|
|
477
583
|
const bytes = (0, _Array.fill)(new Array(16), 0, 16, 0);
|
|
@@ -509,16 +615,16 @@ function FieldResolver_createResolver(formSpec) {
|
|
|
509
615
|
return matchValue == null ? FieldResolver_generateFieldKey(fieldReference) : (0, _Option.value)(matchValue);
|
|
510
616
|
};
|
|
511
617
|
}
|
|
512
|
-
function FieldResolver_extractFieldValues(resolver,
|
|
513
|
-
return (0, _Map.
|
|
618
|
+
function FieldResolver_extractFieldValues(resolver, formSpec) {
|
|
619
|
+
return (0, _Map.ofList)((0, _List.collect)((step)=>(0, _List.map)((field)=>{
|
|
514
620
|
let matchValue, pluginData;
|
|
515
621
|
return [
|
|
516
|
-
|
|
517
|
-
(matchValue =
|
|
622
|
+
field.FieldKey,
|
|
623
|
+
(matchValue = (0, _FormSpecValues.fieldToDetails)(field).FieldValue, matchValue.tag === /* Multiple */ 1 ? (0, _String.join)(",", (0, _Set.toList)((0, _Set.map)((a)=>a.Value, matchValue.fields[0], {
|
|
518
624
|
Compare: _Util.comparePrimitives
|
|
519
|
-
}))) : matchValue.tag === /* Matrix */ 2 ? (0, _String.join)(",", (0, _List.map)((
|
|
625
|
+
}))) : matchValue.tag === /* Matrix */ 2 ? (0, _String.join)(",", (0, _List.map)((tupledArg)=>tupledArg[1], (0, _Map.toList)(matchValue.fields[0].Values))) : matchValue.tag === /* PluginData */ 3 ? (pluginData = matchValue.fields[0], (0, _Encodefs.toString)(0, (0, _Encodefs.Auto_generateBoxedEncoder_437914C6)((0, _Reflection.list_type)((0, _FormSpec.Shared_PluginDataProperty_$reflection)()), undefined, undefined, undefined)(pluginData))) : matchValue.fields[0].Value)
|
|
520
626
|
];
|
|
521
|
-
},
|
|
627
|
+
}, step.Fields), formSpec.Steps), {
|
|
522
628
|
Compare: _Util.compare
|
|
523
629
|
});
|
|
524
630
|
}
|
|
@@ -689,7 +795,7 @@ function evaluateFieldCondition(actualValue, evaluator, expectedValue) {
|
|
|
689
795
|
let matchValue_12;
|
|
690
796
|
let outArg_8 = 0;
|
|
691
797
|
matchValue_12 = [
|
|
692
|
-
(0, _Double.tryParse)(actualValue, new _Types.FSharpRef(()=>outArg_8, (v_8)=>{
|
|
798
|
+
(0, _Double.tryParse)(actualValue.trim(), new _Types.FSharpRef(()=>outArg_8, (v_8)=>{
|
|
693
799
|
outArg_8 = v_8;
|
|
694
800
|
})),
|
|
695
801
|
outArg_8
|
|
@@ -723,30 +829,149 @@ function evaluateFieldCondition(actualValue, evaluator, expectedValue) {
|
|
|
723
829
|
return actualValue.trim().toLocaleLowerCase() === expectedValue.trim().toLocaleLowerCase();
|
|
724
830
|
}
|
|
725
831
|
}
|
|
832
|
+
function evaluateMatrixItemCondition(actualMatrix, evaluator, expectedMatrix) {
|
|
833
|
+
const entries = (0, _Map.toList)(expectedMatrix);
|
|
834
|
+
if ((0, _List.isEmpty)(entries)) {
|
|
835
|
+
return false;
|
|
836
|
+
} else {
|
|
837
|
+
const allMatch = (0, _List.forAll)((tupledArg)=>{
|
|
838
|
+
const expectedVal = tupledArg[1];
|
|
839
|
+
const actualVal = (0, _Option.defaultArg)((0, _Map.tryFind)(tupledArg[0], actualMatrix.Values), "0");
|
|
840
|
+
switch(evaluator.tag){
|
|
841
|
+
case /* Equals */ 0:
|
|
842
|
+
return actualVal.trim().toLocaleLowerCase() === expectedVal.trim().toLocaleLowerCase();
|
|
843
|
+
case /* NotEquals */ 1:
|
|
844
|
+
return actualVal.trim().toLocaleLowerCase() !== expectedVal.trim().toLocaleLowerCase();
|
|
845
|
+
default:
|
|
846
|
+
return evaluateFieldCondition(actualVal, evaluator, expectedVal);
|
|
847
|
+
}
|
|
848
|
+
}, entries);
|
|
849
|
+
switch(evaluator.tag){
|
|
850
|
+
case /* Equals */ 0:
|
|
851
|
+
return allMatch;
|
|
852
|
+
case /* NotEquals */ 1:
|
|
853
|
+
return allMatch;
|
|
854
|
+
default:
|
|
855
|
+
return allMatch;
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
}
|
|
726
859
|
function evaluateFieldConditionWithConditionValue(actualFieldValue, evaluator, expectedConditionValue) {
|
|
727
860
|
let pluginData, pluginData_1;
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
861
|
+
let matchResult, actualMatrix, expectedMatrix;
|
|
862
|
+
if (actualFieldValue.tag === /* Matrix */ 2) {
|
|
863
|
+
if (expectedConditionValue.tag === /* Matrix */ 2) {
|
|
864
|
+
matchResult = 0;
|
|
865
|
+
actualMatrix = actualFieldValue.fields[0];
|
|
866
|
+
expectedMatrix = expectedConditionValue.fields[0];
|
|
867
|
+
} else {
|
|
868
|
+
matchResult = 1;
|
|
869
|
+
}
|
|
870
|
+
} else {
|
|
871
|
+
matchResult = 1;
|
|
872
|
+
}
|
|
873
|
+
switch(matchResult){
|
|
874
|
+
case 0:
|
|
875
|
+
return evaluateMatrixItemCondition(actualMatrix, evaluator, expectedMatrix);
|
|
876
|
+
default:
|
|
877
|
+
return evaluateFieldCondition(actualFieldValue.tag === /* Multiple */ 1 ? (0, _String.join)(",", (0, _Set.toList)((0, _Set.map)((a)=>a.Value, actualFieldValue.fields[0], {
|
|
878
|
+
Compare: _Util.comparePrimitives
|
|
879
|
+
}))) : actualFieldValue.tag === /* Matrix */ 2 ? (0, _String.join)(",", (0, _List.map)((tupledArg)=>tupledArg[1], (0, _Map.toList)(actualFieldValue.fields[0].Values))) : actualFieldValue.tag === /* PluginData */ 3 ? (pluginData = actualFieldValue.fields[0], (0, _Encodefs.toString)(0, (0, _Encodefs.Auto_generateBoxedEncoder_437914C6)((0, _Reflection.list_type)((0, _FormSpec.Shared_PluginDataProperty_$reflection)()), undefined, undefined, undefined)(pluginData))) : actualFieldValue.fields[0].Value, evaluator, expectedConditionValue.tag === /* Multiple */ 1 ? (0, _String.join)(",", (0, _Set.toList)(expectedConditionValue.fields[0])) : expectedConditionValue.tag === /* Matrix */ 2 ? (0, _String.join)(",", (0, _List.map)((tupledArg_1)=>tupledArg_1[1], (0, _Map.toList)(expectedConditionValue.fields[0]))) : expectedConditionValue.tag === /* PluginData */ 3 ? (pluginData_1 = expectedConditionValue.fields[0], (0, _Encodefs.toString)(0, (0, _Encodefs.Auto_generateBoxedEncoder_437914C6)((0, _FormSpec.Shared_PluginDataProperty_$reflection)(), undefined, undefined, undefined)(pluginData_1))) : expectedConditionValue.fields[0]);
|
|
880
|
+
}
|
|
731
881
|
}
|
|
732
|
-
function evaluateTransitionWithPartialData(resolver, formSpec, fieldValues, visitedStates, condition) {
|
|
733
|
-
let
|
|
882
|
+
function evaluateTransitionWithPartialData(resolver, formSpec, fieldValues, visitedStates, formSpecForScores, condition) {
|
|
883
|
+
let score, data_1, score_2, pluginData;
|
|
734
884
|
switch(condition.tag){
|
|
735
885
|
case /* FieldCondition */ 0:
|
|
736
886
|
{
|
|
737
887
|
const fieldKey = condition.fields[0];
|
|
738
888
|
const evaluator = condition.fields[1];
|
|
739
889
|
const conditionValue = condition.fields[2];
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
890
|
+
if (evaluator.tag === /* InRange */ 13) {
|
|
891
|
+
const minVal = evaluator.fields[0] | 0;
|
|
892
|
+
const maxVal = evaluator.fields[1] | 0;
|
|
893
|
+
let matchResult, data, spec;
|
|
894
|
+
if (formSpec != null) {
|
|
895
|
+
if (formSpecForScores != null) {
|
|
896
|
+
matchResult = 0;
|
|
897
|
+
data = (0, _Option.value)(formSpecForScores);
|
|
898
|
+
spec = (0, _Option.value)(formSpec);
|
|
899
|
+
} else {
|
|
900
|
+
matchResult = 1;
|
|
901
|
+
}
|
|
902
|
+
} else {
|
|
903
|
+
matchResult = 1;
|
|
904
|
+
}
|
|
905
|
+
switch(matchResult){
|
|
906
|
+
case 0:
|
|
907
|
+
{
|
|
908
|
+
const fieldScoreOpt = (0, _Option.bind)((field_1)=>(0, _Option.bind)((details)=>ScoreCalculator_calculateFieldScore(field_1, details.FieldValue), (0, _FormSpecValues.getFieldDetails)(data, fieldKey)), (0, _List.tryFind)((field)=>(0, _Util.equals)(field.FieldKey, fieldKey), (0, _List.collect)((step)=>step.Fields, spec.Steps)));
|
|
909
|
+
if (fieldScoreOpt == null) {
|
|
910
|
+
return TransitionStatus_Pending((0, _List.singleton)(fieldKey.fields[0]));
|
|
911
|
+
} else if (score = (0, _Option.value)(fieldScoreOpt) | 0, score >= minVal && score <= maxVal) {
|
|
912
|
+
const score_1 = (0, _Option.value)(fieldScoreOpt) | 0;
|
|
913
|
+
return TransitionStatus_Satisfied();
|
|
914
|
+
} else {
|
|
915
|
+
return TransitionStatus_Failed();
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
default:
|
|
919
|
+
return TransitionStatus_Pending((0, _List.singleton)(fieldKey.fields[0]));
|
|
920
|
+
}
|
|
745
921
|
} else {
|
|
746
|
-
|
|
922
|
+
const actualFieldValueOpt = conditionValue.tag === /* Matrix */ 2 ? formSpecForScores != null ? (data_1 = (0, _Option.value)(formSpecForScores), (0, _Option.map)((details_1)=>details_1.FieldValue, (0, _FormSpecValues.getFieldDetails)(data_1, fieldKey))) : undefined : undefined;
|
|
923
|
+
if (actualFieldValueOpt == null) {
|
|
924
|
+
const matchValue_2 = (0, _Map.tryFind)(fieldKey, fieldValues);
|
|
925
|
+
if (matchValue_2 == null) {
|
|
926
|
+
return TransitionStatus_Pending((0, _List.singleton)(fieldKey.fields[0]));
|
|
927
|
+
} else if (evaluateFieldConditionWithConditionValue((0, _FormSpec.Shared_FieldValue_Single)(new _FormSpec.Shared_FieldAnswer(fieldKey, "", (0, _Option.value)(matchValue_2))), evaluator, conditionValue)) {
|
|
928
|
+
return TransitionStatus_Satisfied();
|
|
929
|
+
} else {
|
|
930
|
+
return TransitionStatus_Failed();
|
|
931
|
+
}
|
|
932
|
+
} else if (evaluateFieldConditionWithConditionValue((0, _Option.value)(actualFieldValueOpt), evaluator, conditionValue)) {
|
|
933
|
+
return TransitionStatus_Satisfied();
|
|
934
|
+
} else {
|
|
935
|
+
return TransitionStatus_Failed();
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
case /* ScoreInRange */ 3:
|
|
940
|
+
{
|
|
941
|
+
const minScore = condition.fields[0] | 0;
|
|
942
|
+
const maxScore = condition.fields[1] | 0;
|
|
943
|
+
if (formSpecForScores != null) {
|
|
944
|
+
const totalScore = ScoreCalculator_calculateTotalScore((0, _Option.value)(formSpecForScores)) | 0;
|
|
945
|
+
if (totalScore >= minScore && totalScore <= maxScore) {
|
|
946
|
+
return TransitionStatus_Satisfied();
|
|
947
|
+
} else {
|
|
948
|
+
return TransitionStatus_Failed();
|
|
949
|
+
}
|
|
950
|
+
} else {
|
|
951
|
+
return TransitionStatus_Pending((0, _List.singleton)("form_score"));
|
|
747
952
|
}
|
|
748
953
|
}
|
|
749
|
-
case /*
|
|
954
|
+
case /* FieldScoreInRange */ 4:
|
|
955
|
+
{
|
|
956
|
+
const minScore_1 = condition.fields[1] | 0;
|
|
957
|
+
const maxScore_1 = condition.fields[2] | 0;
|
|
958
|
+
const fieldKey_1 = condition.fields[0];
|
|
959
|
+
if (formSpecForScores != null) {
|
|
960
|
+
const spec_2 = (0, _Option.value)(formSpecForScores);
|
|
961
|
+
const fieldScoreOpt_1 = (0, _Option.bind)((field_3)=>(0, _Option.bind)((details_2)=>ScoreCalculator_calculateFieldScore(field_3, details_2.FieldValue), (0, _FormSpecValues.getFieldDetails)(spec_2, fieldKey_1)), (0, _List.tryFind)((field_2)=>(0, _Util.equals)(field_2.FieldKey, fieldKey_1), (0, _List.collect)((step_1)=>step_1.Fields, spec_2.Steps)));
|
|
962
|
+
if (fieldScoreOpt_1 == null) {
|
|
963
|
+
return TransitionStatus_Pending((0, _List.singleton)(fieldKey_1.fields[0]));
|
|
964
|
+
} else if (score_2 = (0, _Option.value)(fieldScoreOpt_1) | 0, score_2 >= minScore_1 && score_2 <= maxScore_1) {
|
|
965
|
+
const score_3 = (0, _Option.value)(fieldScoreOpt_1) | 0;
|
|
966
|
+
return TransitionStatus_Satisfied();
|
|
967
|
+
} else {
|
|
968
|
+
return TransitionStatus_Failed();
|
|
969
|
+
}
|
|
970
|
+
} else {
|
|
971
|
+
return TransitionStatus_Pending((0, _List.singleton)(fieldKey_1.fields[0]));
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
case /* StateCondition */ 5:
|
|
750
975
|
{
|
|
751
976
|
const evaluator_1 = condition.fields[1];
|
|
752
977
|
const stateVisited = (0, _Set.contains)(condition.fields[0], visitedStates);
|
|
@@ -773,14 +998,14 @@ function evaluateTransitionWithPartialData(resolver, formSpec, fieldValues, visi
|
|
|
773
998
|
}
|
|
774
999
|
}
|
|
775
1000
|
}
|
|
776
|
-
case /* CompositeCondition */
|
|
1001
|
+
case /* CompositeCondition */ 6:
|
|
777
1002
|
{
|
|
778
1003
|
const logicalOp = condition.fields[0];
|
|
779
1004
|
const conditions = condition.fields[1];
|
|
780
1005
|
switch(logicalOp.tag){
|
|
781
1006
|
case /* Or */ 1:
|
|
782
1007
|
{
|
|
783
|
-
const results_1 = (0, _List.map)((condition_2)=>evaluateTransitionWithPartialData(resolver, formSpec, fieldValues, visitedStates, condition_2), conditions);
|
|
1008
|
+
const results_1 = (0, _List.map)((condition_2)=>evaluateTransitionWithPartialData(resolver, formSpec, fieldValues, visitedStates, formSpecForScores, condition_2), conditions);
|
|
784
1009
|
if ((0, _List.exists)((r_3)=>(0, _Util.equals)(r_3, TransitionStatus_Satisfied()), results_1)) {
|
|
785
1010
|
return TransitionStatus_Satisfied();
|
|
786
1011
|
} else if ((0, _List.forAll)((r_4)=>(0, _Util.equals)(r_4, TransitionStatus_Failed()), results_1)) {
|
|
@@ -797,26 +1022,26 @@ function evaluateTransitionWithPartialData(resolver, formSpec, fieldValues, visi
|
|
|
797
1022
|
}
|
|
798
1023
|
case /* Not */ 2:
|
|
799
1024
|
{
|
|
800
|
-
let
|
|
1025
|
+
let matchResult_1, cond;
|
|
801
1026
|
if (!(0, _List.isEmpty)(conditions)) {
|
|
802
1027
|
if ((0, _List.isEmpty)((0, _List.tail)(conditions))) {
|
|
803
|
-
|
|
1028
|
+
matchResult_1 = 0;
|
|
804
1029
|
cond = (0, _List.head)(conditions);
|
|
805
1030
|
} else {
|
|
806
|
-
|
|
1031
|
+
matchResult_1 = 1;
|
|
807
1032
|
}
|
|
808
1033
|
} else {
|
|
809
|
-
|
|
1034
|
+
matchResult_1 = 1;
|
|
810
1035
|
}
|
|
811
|
-
switch(
|
|
1036
|
+
switch(matchResult_1){
|
|
812
1037
|
case 0:
|
|
813
1038
|
{
|
|
814
|
-
const
|
|
815
|
-
switch(
|
|
1039
|
+
const matchValue_3 = evaluateTransitionWithPartialData(resolver, formSpec, fieldValues, visitedStates, formSpecForScores, cond);
|
|
1040
|
+
switch(matchValue_3.tag){
|
|
816
1041
|
case /* Failed */ 1:
|
|
817
1042
|
return TransitionStatus_Satisfied();
|
|
818
1043
|
case /* Pending */ 2:
|
|
819
|
-
return TransitionStatus_Pending(
|
|
1044
|
+
return TransitionStatus_Pending(matchValue_3.fields[0]);
|
|
820
1045
|
default:
|
|
821
1046
|
return TransitionStatus_Failed();
|
|
822
1047
|
}
|
|
@@ -827,7 +1052,7 @@ function evaluateTransitionWithPartialData(resolver, formSpec, fieldValues, visi
|
|
|
827
1052
|
}
|
|
828
1053
|
default:
|
|
829
1054
|
{
|
|
830
|
-
const results = (0, _List.map)((condition_1)=>evaluateTransitionWithPartialData(resolver, formSpec, fieldValues, visitedStates, condition_1), conditions);
|
|
1055
|
+
const results = (0, _List.map)((condition_1)=>evaluateTransitionWithPartialData(resolver, formSpec, fieldValues, visitedStates, formSpecForScores, condition_1), conditions);
|
|
831
1056
|
if ((0, _List.exists)((r)=>(0, _Util.equals)(r, TransitionStatus_Failed()), results)) {
|
|
832
1057
|
return TransitionStatus_Failed();
|
|
833
1058
|
} else if ((0, _List.forAll)((r_1)=>(0, _Util.equals)(r_1, TransitionStatus_Satisfied()), results)) {
|
|
@@ -844,7 +1069,7 @@ function evaluateTransitionWithPartialData(resolver, formSpec, fieldValues, visi
|
|
|
844
1069
|
}
|
|
845
1070
|
}
|
|
846
1071
|
}
|
|
847
|
-
case /* TestResultCondition */
|
|
1072
|
+
case /* TestResultCondition */ 7:
|
|
848
1073
|
{
|
|
849
1074
|
const result = condition.fields[1];
|
|
850
1075
|
return TransitionStatus_Pending((0, _List.singleton)(condition.fields[0]));
|
|
@@ -853,22 +1078,20 @@ function evaluateTransitionWithPartialData(resolver, formSpec, fieldValues, visi
|
|
|
853
1078
|
{
|
|
854
1079
|
const optionKey = condition.fields[2];
|
|
855
1080
|
const matrixItemKey = condition.fields[1];
|
|
856
|
-
const
|
|
1081
|
+
const fieldKey_2 = condition.fields[0];
|
|
857
1082
|
const evaluator_2 = condition.fields[3];
|
|
858
1083
|
const conditionValue_1 = condition.fields[4];
|
|
859
|
-
const optionValueOpt = formSpec == null ? undefined : (0, _Option.bind)((
|
|
860
|
-
const fieldType =
|
|
1084
|
+
const optionValueOpt = formSpec == null ? undefined : (0, _Option.bind)((field_5)=>{
|
|
1085
|
+
const fieldType = field_5.FieldType;
|
|
861
1086
|
return (0, _Option.map)((opt_1)=>opt_1.Value, (0, _List.tryFind)((opt)=>(0, _Util.equals)(opt.OptionKey, optionKey), fieldType.tag === /* SingleChoice */ 13 ? fieldType.fields[0].Options : fieldType.tag === /* Radio */ 12 ? fieldType.fields[0].Options : fieldType.tag === /* Dropdown */ 14 ? fieldType.fields[0].Options : fieldType.tag === /* MultiChoice */ 15 ? fieldType.fields[0].Options : fieldType.tag === /* CheckboxList */ 16 ? fieldType.fields[0].Options : (0, _List.empty)()));
|
|
862
|
-
}, (0, _List.tryFind)((
|
|
863
|
-
const
|
|
1087
|
+
}, (0, _List.tryFind)((field_4)=>(0, _Util.equals)(field_4.FieldKey, fieldKey_2), (0, _List.collect)((step_2)=>step_2.Fields, (0, _Option.value)(formSpec).Steps)));
|
|
1088
|
+
const matchValue_4 = (0, _Map.tryFind)(fieldKey_2, fieldValues);
|
|
864
1089
|
if (optionValueOpt == null) {
|
|
865
|
-
const guid_1 = optionKey.fields[0];
|
|
866
|
-
console.error((0, _Option.some)("[evaluateTransition] FieldOptionCondition: Could not find option in formSpec for optionKey:"), guid_1);
|
|
867
1090
|
return TransitionStatus_Failed();
|
|
868
|
-
} else if (
|
|
869
|
-
return TransitionStatus_Pending((0, _List.singleton)(
|
|
1091
|
+
} else if (matchValue_4 == null) {
|
|
1092
|
+
return TransitionStatus_Pending((0, _List.singleton)(fieldKey_2.fields[0]));
|
|
870
1093
|
} else {
|
|
871
|
-
const actualValueStr_1 = (0, _Option.value)(
|
|
1094
|
+
const actualValueStr_1 = (0, _Option.value)(matchValue_4);
|
|
872
1095
|
const optionValue = (0, _Option.value)(optionValueOpt);
|
|
873
1096
|
const actualValues = (0, _Set.ofArray)((0, _Array.map)((s)=>s.trim().toLocaleLowerCase(), actualValueStr_1.split(",")), {
|
|
874
1097
|
Compare: _Util.comparePrimitives
|
|
@@ -911,17 +1134,55 @@ function evaluateTransitionWithPartialData(resolver, formSpec, fieldValues, visi
|
|
|
911
1134
|
case /* PluginPropertyCondition */ 2:
|
|
912
1135
|
{
|
|
913
1136
|
const propertyKey = condition.fields[1];
|
|
914
|
-
const
|
|
1137
|
+
const fieldKey_3 = condition.fields[0];
|
|
915
1138
|
const evaluator_3 = condition.fields[2];
|
|
916
1139
|
const conditionValue_2 = condition.fields[3];
|
|
917
|
-
const
|
|
918
|
-
if (
|
|
919
|
-
return TransitionStatus_Pending((0, _List.singleton)(
|
|
1140
|
+
const matchValue_6 = (0, _Map.tryFind)(fieldKey_3, fieldValues);
|
|
1141
|
+
if (matchValue_6 == null) {
|
|
1142
|
+
return TransitionStatus_Pending((0, _List.singleton)(fieldKey_3.fields[0]));
|
|
920
1143
|
} else {
|
|
921
|
-
const actualValueStr_2 = (0, _Option.value)(
|
|
1144
|
+
const actualValueStr_2 = (0, _Option.value)(matchValue_6);
|
|
922
1145
|
try {
|
|
923
|
-
const
|
|
924
|
-
|
|
1146
|
+
const pluginIdOpt = (0, _Option.filter)((id)=>!(0, _String.isNullOrEmpty)(id), (0, _Option.bind)((spec_4)=>(0, _Option.map)((f_1)=>{
|
|
1147
|
+
const ft = f_1.FieldType;
|
|
1148
|
+
switch(ft.tag){
|
|
1149
|
+
case /* PluginField */ 22:
|
|
1150
|
+
return ft.fields[0].PluginId;
|
|
1151
|
+
case /* Matrix */ 19:
|
|
1152
|
+
return "Fable.Form.Simple.Bulma.Fields.LikertField";
|
|
1153
|
+
default:
|
|
1154
|
+
return "";
|
|
1155
|
+
}
|
|
1156
|
+
}, (0, _List.tryFind)((f)=>(0, _Util.equals)(f.FieldKey, fieldKey_3), (0, _List.collect)((s_1)=>s_1.Fields, spec_4.Steps))), formSpec));
|
|
1157
|
+
return evaluateFieldCondition(pluginIdOpt == null ? actualValueStr_2 : (0, _Option.defaultArg)((0, _Option.bind)((converter)=>(0, _Option.map)((propMeta)=>{
|
|
1158
|
+
if (propMeta.Name === "TotalScore") {
|
|
1159
|
+
return (0, _Util.int32ToString)((0, _Array.sum)((0, _Array.choose)((s_2)=>{
|
|
1160
|
+
let matchValue_7;
|
|
1161
|
+
let outArg = 0;
|
|
1162
|
+
matchValue_7 = [
|
|
1163
|
+
(0, _Int32.tryParse)(s_2.trim(), 511, false, 32, new _Types.FSharpRef(()=>outArg, (v_2)=>{
|
|
1164
|
+
outArg = v_2 | 0;
|
|
1165
|
+
})),
|
|
1166
|
+
outArg
|
|
1167
|
+
];
|
|
1168
|
+
if (matchValue_7[0]) {
|
|
1169
|
+
return matchValue_7[1];
|
|
1170
|
+
} else {
|
|
1171
|
+
return undefined;
|
|
1172
|
+
}
|
|
1173
|
+
}, actualValueStr_2.split(",")), {
|
|
1174
|
+
GetZero: ()=>0,
|
|
1175
|
+
Add: (x_1, y_1)=>x_1 + y_1
|
|
1176
|
+
}));
|
|
1177
|
+
} else {
|
|
1178
|
+
const matchValue_8 = (0, _Decodefs.fromString)((0, _Util.uncurry2)((0, _Decodefs.Auto_generateBoxedDecoder_Z6670B51)((0, _Reflection.list_type)((0, _FormSpec.Shared_PluginDataProperty_$reflection)()), undefined, undefined)), actualValueStr_2);
|
|
1179
|
+
if (matchValue_8.tag === /* Error */ 1) {
|
|
1180
|
+
return actualValueStr_2;
|
|
1181
|
+
} else {
|
|
1182
|
+
return (0, _Option.defaultArg)((0, _Option.map)((p_1)=>p_1.Value, (0, _List.tryFind)((p)=>(0, _Util.equals)(p.PropertyKey, propertyKey), matchValue_8.fields[0])), actualValueStr_2);
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
}, converter.GetPropertyMetadataByKey(propertyKey)), (0, _PluginInterface.PluginValueRegistry_tryGet)((0, _Option.value)(pluginIdOpt))), actualValueStr_2), evaluator_3, conditionValue_2.tag === /* Multiple */ 1 ? (0, _String.join)(",", (0, _Set.toList)(conditionValue_2.fields[0])) : conditionValue_2.tag === /* Matrix */ 2 ? (0, _String.join)(",", (0, _List.map)((tupledArg_1)=>tupledArg_1[1], (0, _Map.toList)(conditionValue_2.fields[0]))) : conditionValue_2.tag === /* PluginData */ 3 ? "" : conditionValue_2.fields[0]) ? TransitionStatus_Satisfied() : TransitionStatus_Failed();
|
|
925
1186
|
} catch (ex) {
|
|
926
1187
|
return TransitionStatus_Failed();
|
|
927
1188
|
}
|
|
@@ -958,23 +1219,11 @@ function isTerminalState(state) {
|
|
|
958
1219
|
}
|
|
959
1220
|
}
|
|
960
1221
|
function evaluateAllTransitions(context) {
|
|
961
|
-
const fieldValues = FieldResolver_extractFieldValues(context.FieldResolver, context.
|
|
962
|
-
console.log((0, _Option.some)("[evaluateAllTransitions] Extracted field values:"), fieldValues);
|
|
963
|
-
console.log((0, _Option.some)("[evaluateAllTransitions] Current states in context:"), context.CurrentStates);
|
|
964
|
-
console.log((0, _Option.some)("[evaluateAllTransitions] All transitions in pathway:"), context.PathwaySpec.Transitions);
|
|
965
|
-
const transitionsFromCurrentStates = (0, _List.filter)((t)=>{
|
|
966
|
-
const isFromCurrentState = (0, _Set.contains)(t.FromState, context.CurrentStates);
|
|
967
|
-
console.log((0, _Option.some)("[evaluateAllTransitions] Transition from"), t.FromState, "to", t.ToState, "FromCurrentState=", isFromCurrentState);
|
|
968
|
-
return isFromCurrentState;
|
|
969
|
-
}, context.PathwaySpec.Transitions);
|
|
970
|
-
console.log((0, _Option.some)("[evaluateAllTransitions] Transitions from current states:"), transitionsFromCurrentStates);
|
|
1222
|
+
const fieldValues = FieldResolver_extractFieldValues(context.FieldResolver, context.FormSpec);
|
|
971
1223
|
return (0, _List.map)((transition)=>{
|
|
972
|
-
|
|
973
|
-
console.log((0, _Option.some)("[evaluateAllTransitions] Transition condition:"), transition.Condition);
|
|
974
|
-
const status = evaluateTransitionWithPartialData(context.FieldResolver, context.FormSpec, fieldValues, context.VisitedStates, transition.Condition);
|
|
975
|
-
console.log((0, _Option.some)("[evaluateAllTransitions] Transition status:"), status);
|
|
1224
|
+
const status = evaluateTransitionWithPartialData(context.FieldResolver, context.FormSpec, fieldValues, context.VisitedStates, context.FormSpec, transition.Condition);
|
|
976
1225
|
return new MatchedTransition(transition, (0, _Option.defaultArg)(transition.Priority, 999), status);
|
|
977
|
-
},
|
|
1226
|
+
}, (0, _List.filter)((t)=>(0, _Set.contains)(t.FromState, context.CurrentStates), context.PathwaySpec.Transitions));
|
|
978
1227
|
}
|
|
979
1228
|
function categorizeTransitions(transitions) {
|
|
980
1229
|
return [
|
|
@@ -1084,7 +1333,7 @@ function isExecutionComplete(context) {
|
|
|
1084
1333
|
return false;
|
|
1085
1334
|
}
|
|
1086
1335
|
}
|
|
1087
|
-
function initializeExecution(formSpec
|
|
1336
|
+
function initializeExecution(formSpec) {
|
|
1088
1337
|
const matchValue = formSpec.ClinicalPathway;
|
|
1089
1338
|
if (matchValue == null) {
|
|
1090
1339
|
throw new Error("No clinical pathway found in form spec");
|
|
@@ -1102,19 +1351,19 @@ function initializeExecution(formSpec, formData) {
|
|
|
1102
1351
|
} else {
|
|
1103
1352
|
initialStates = (0, _List.singleton)((0, _Option.value)(matchValue_1));
|
|
1104
1353
|
}
|
|
1105
|
-
return new ExecutionContext
|
|
1354
|
+
return new ExecutionContext(pathway, formSpec, (0, _Set.ofList)(initialStates, {
|
|
1106
1355
|
Compare: _Util.compare
|
|
1107
1356
|
}), (0, _Set.ofList)(initialStates, {
|
|
1108
1357
|
Compare: _Util.compare
|
|
1109
1358
|
}), (0, _Set.empty)({
|
|
1110
1359
|
Compare: _Util.compare
|
|
1111
|
-
}), (0, _List.empty)(), (0, _List.empty)(), (0, _List.empty)(),
|
|
1360
|
+
}), (0, _List.empty)(), (0, _List.empty)(), (0, _List.empty)(), resolver, (0, _List.map)((stateKey)=>new ExecutionLogEntry((0, _Date.now)(), stateKey, "Initialized", "Starting state"), initialStates));
|
|
1112
1361
|
}
|
|
1113
1362
|
}
|
|
1114
|
-
function resolveFieldValueSource(valueSource, formSpec
|
|
1363
|
+
function resolveFieldValueSource(valueSource, formSpec) {
|
|
1115
1364
|
switch(valueSource.tag){
|
|
1116
1365
|
case /* FieldReference */ 1:
|
|
1117
|
-
return (0, _Option.defaultArg)((0, _Map.tryFind)(valueSource.fields[0], FieldResolver_extractFieldValues(FieldResolver_createResolver(formSpec),
|
|
1366
|
+
return (0, _Option.defaultArg)((0, _Map.tryFind)(valueSource.fields[0], FieldResolver_extractFieldValues(FieldResolver_createResolver(formSpec), formSpec)), "");
|
|
1118
1367
|
case /* OptionKey */ 2:
|
|
1119
1368
|
{
|
|
1120
1369
|
const optionKey = valueSource.fields[0];
|
|
@@ -1127,41 +1376,38 @@ function resolveFieldValueSource(valueSource, formSpec, formData) {
|
|
|
1127
1376
|
return valueSource.fields[0];
|
|
1128
1377
|
}
|
|
1129
1378
|
}
|
|
1130
|
-
function executeSetFieldValueAction(action, formSpec
|
|
1131
|
-
let matchValue, condition, fieldValues
|
|
1132
|
-
if (!(matchValue = action.Condition, matchValue == null ? true : (condition = (0, _Option.value)(matchValue), fieldValues = FieldResolver_extractFieldValues(FieldResolver_createResolver(formSpec),
|
|
1379
|
+
function executeSetFieldValueAction(action, formSpec) {
|
|
1380
|
+
let matchValue, condition, fieldValues;
|
|
1381
|
+
if (!(matchValue = action.Condition, matchValue == null ? true : (condition = (0, _Option.value)(matchValue), fieldValues = FieldResolver_extractFieldValues(FieldResolver_createResolver(formSpec), formSpec), evaluateTransitionWithPartialData(FieldResolver_createResolver(formSpec), formSpec, fieldValues, (0, _Set.empty)({
|
|
1133
1382
|
Compare: _Util.compare
|
|
1134
|
-
}), condition).tag === /* Satisfied */ 0))) {
|
|
1135
|
-
return
|
|
1383
|
+
}), formSpec, condition).tag === /* Satisfied */ 0))) {
|
|
1384
|
+
return formSpec;
|
|
1136
1385
|
} else {
|
|
1137
|
-
const valueToSet = resolveFieldValueSource(action.Value, formSpec
|
|
1386
|
+
const valueToSet = resolveFieldValueSource(action.Value, formSpec);
|
|
1138
1387
|
const targetFieldOpt = (0, _List.tryFind)((field)=>(0, _Util.equals)(field.FieldKey, action.TargetField), (0, _List.collect)((step)=>step.Fields, formSpec.Steps));
|
|
1139
1388
|
if (targetFieldOpt == null) {
|
|
1140
|
-
return
|
|
1389
|
+
return formSpec;
|
|
1141
1390
|
} else {
|
|
1142
1391
|
const targetField = (0, _Option.value)(targetFieldOpt);
|
|
1143
1392
|
const stepOpt = (0, _List.tryFind)((step_1)=>(0, _List.exists)((f)=>(0, _Util.equals)(f.FieldKey, action.TargetField), step_1.Fields), formSpec.Steps);
|
|
1144
1393
|
if (stepOpt == null) {
|
|
1145
|
-
return
|
|
1394
|
+
return formSpec;
|
|
1146
1395
|
} else {
|
|
1147
|
-
const
|
|
1148
|
-
|
|
1149
|
-
return new _FormSpec.Values_DynamicFormResultData$1(formData.ResultFormSpecDetails, (0, _Map.FSharpMap__Add)(formData.ResultSteps, stepOrder, (0, _Map.FSharpMap__Add)((0, _Option.defaultArg)((0, _Map.tryFind)(stepOrder, formData.ResultSteps), (0, _Map.empty)({
|
|
1150
|
-
Compare: _Util.compare
|
|
1151
|
-
})), action.TargetField, (fieldType = targetField.FieldType, new _FormSpec.Values_FieldDetails$1(targetField.FieldOrder, action.TargetField, targetField.Label, (0, _FormSpec.Shared_FieldValue_Single)(fieldAnswer), targetField.FieldType, (0, _List.map)((opt)=>new _FormSpec.Shared_FieldOption(opt.Description, opt.Value, opt.OptionKey), fieldType.tag === /* SingleChoice */ 13 ? fieldType.fields[0].Options : fieldType.tag === /* MultiChoice */ 15 ? fieldType.fields[0].Options : fieldType.tag === /* CheckboxList */ 16 ? fieldType.fields[0].Options : fieldType.tag === /* Dropdown */ 14 ? fieldType.fields[0].Options : fieldType.tag === /* Radio */ 12 ? fieldType.fields[0].Options : (0, _List.empty)()))))));
|
|
1396
|
+
const step_2 = (0, _Option.value)(stepOpt);
|
|
1397
|
+
return (0, _FormSpecValues.updateField)(formSpec, action.TargetField, (0, _FormSpec.Shared_FieldValue_Single)(new _FormSpec.Shared_FieldAnswer(action.TargetField, targetField.Label, valueToSet)), (0, _List.findIndex)((s)=>s.StepOrder === step_2.StepOrder, formSpec.Steps));
|
|
1152
1398
|
}
|
|
1153
1399
|
}
|
|
1154
1400
|
}
|
|
1155
1401
|
}
|
|
1156
|
-
function executeAction(action, formSpec
|
|
1402
|
+
function executeAction(action, formSpec) {
|
|
1157
1403
|
if (action.tag === /* SetFieldValue */ 10) {
|
|
1158
|
-
return executeSetFieldValueAction(action.fields[0], formSpec
|
|
1404
|
+
return executeSetFieldValueAction(action.fields[0], formSpec);
|
|
1159
1405
|
} else {
|
|
1160
|
-
return
|
|
1406
|
+
return formSpec;
|
|
1161
1407
|
}
|
|
1162
1408
|
}
|
|
1163
|
-
function executeActions(actions, formSpec
|
|
1164
|
-
return (0, _List.fold)((
|
|
1409
|
+
function executeActions(actions, formSpec) {
|
|
1410
|
+
return (0, _List.fold)((currentSpec, action)=>executeAction(action, currentSpec), formSpec, actions);
|
|
1165
1411
|
}
|
|
1166
1412
|
function executeStep(context_mut, maxIterations_mut) {
|
|
1167
1413
|
executeStep: while(true){
|
|
@@ -1174,18 +1420,18 @@ function executeStep(context_mut, maxIterations_mut) {
|
|
|
1174
1420
|
const active = patternInput[0];
|
|
1175
1421
|
const selectedTransitions = selectTransitionsByMode(context.PathwaySpec.ExecutionMode, active);
|
|
1176
1422
|
if ((0, _List.isEmpty)(selectedTransitions)) {
|
|
1177
|
-
return new ExecutionContext
|
|
1423
|
+
return new ExecutionContext(context.PathwaySpec, context.FormSpec, context.CurrentStates, context.VisitedStates, context.CompletedStates, active, pending, context.ExecutedActions, context.FieldResolver, context.ExecutionLog);
|
|
1178
1424
|
} else {
|
|
1179
1425
|
const newStates = (0, _Set.ofList)((0, _List.map)((t)=>t.Transition.ToState, selectedTransitions), {
|
|
1180
1426
|
Compare: _Util.compare
|
|
1181
1427
|
});
|
|
1182
1428
|
const newActions = (0, _List.collect)(extractActionsFromState, (0, _List.choose)((sk)=>findState(sk, context.PathwaySpec.States), (0, _Set.toList)(newStates)));
|
|
1183
|
-
const
|
|
1429
|
+
const updatedFormSpec = executeActions(newActions, context.FormSpec);
|
|
1184
1430
|
const newLogEntries = (0, _List.map)((t_1)=>{
|
|
1185
1431
|
let arg, arg_1;
|
|
1186
1432
|
return new ExecutionLogEntry((0, _Date.now)(), t_1.Transition.ToState, "Transitioned", (arg = t_1.Transition.FromState.fields[0], arg_1 = t_1.Transition.TransitionKey.fields[0], (0, _String.toText)((0, _String.printf)("From %s via %s"))(arg)(arg_1)));
|
|
1187
1433
|
}, selectedTransitions);
|
|
1188
|
-
const updatedContext = new ExecutionContext
|
|
1434
|
+
const updatedContext = new ExecutionContext(context.PathwaySpec, updatedFormSpec, newStates, (0, _Set.union)(context.VisitedStates, newStates), (0, _Set.union)(context.CompletedStates, context.CurrentStates), active, pending, (0, _List.append)(context.ExecutedActions, newActions), context.FieldResolver, (0, _List.append)(context.ExecutionLog, newLogEntries));
|
|
1189
1435
|
if (isExecutionComplete(updatedContext)) {
|
|
1190
1436
|
return updatedContext;
|
|
1191
1437
|
} else {
|
|
@@ -1198,12 +1444,12 @@ function executeStep(context_mut, maxIterations_mut) {
|
|
|
1198
1444
|
break;
|
|
1199
1445
|
}
|
|
1200
1446
|
}
|
|
1201
|
-
function executeIncremental(context,
|
|
1447
|
+
function executeIncremental(context, formSpec) {
|
|
1202
1448
|
let previousTransitionKeys, newKeys;
|
|
1203
1449
|
const startingAtTerminal = (0, _List.exists)(isTerminalState, (0, _List.choose)((sk)=>findState(sk, context.PathwaySpec.States), (0, _Set.toList)(context.CurrentStates)));
|
|
1204
|
-
const updatedContext = new ExecutionContext
|
|
1450
|
+
const updatedContext = new ExecutionContext(context.PathwaySpec, formSpec, context.CurrentStates, context.VisitedStates, context.CompletedStates, context.ActiveTransitions, context.PendingTransitions, context.ExecutedActions, context.FieldResolver, context.ExecutionLog);
|
|
1205
1451
|
const newContext = executeStep(updatedContext, 100);
|
|
1206
|
-
return new IncrementalExecutionResult
|
|
1452
|
+
return new IncrementalExecutionResult(newContext, (0, _List.map)((_arg)=>_arg.fields[0], (0, _Set.toList)((0, _Set.difference)(newContext.CurrentStates, updatedContext.CurrentStates))), (previousTransitionKeys = (0, _Set.ofList)((0, _List.map)((t)=>t.Transition.TransitionKey, updatedContext.ActiveTransitions), {
|
|
1207
1453
|
Compare: _Util.compare
|
|
1208
1454
|
}), newKeys = (0, _Set.difference)((0, _Set.ofList)((0, _List.map)((t_1)=>t_1.Transition.TransitionKey, newContext.ActiveTransitions), {
|
|
1209
1455
|
Compare: _Util.compare
|
|
@@ -1242,7 +1488,7 @@ function extractClinicalPlans(context) {
|
|
|
1242
1488
|
});
|
|
1243
1489
|
}
|
|
1244
1490
|
class PathwayExecutionResult$1 extends _Types.Record {
|
|
1245
|
-
constructor(PathwayId, StartState, CurrentState, ExecutionMode, SelectedPaths, RejectedPaths, ExecutedActions, VisitedStates, TransitionsUsed,
|
|
1491
|
+
constructor(PathwayId, StartState, CurrentState, ExecutionMode, SelectedPaths, RejectedPaths, ExecutedActions, VisitedStates, TransitionsUsed, FormSpec, ExecutionTime, Success, Errors){
|
|
1246
1492
|
super();
|
|
1247
1493
|
this.PathwayId = PathwayId;
|
|
1248
1494
|
this.StartState = StartState;
|
|
@@ -1253,7 +1499,7 @@ class PathwayExecutionResult$1 extends _Types.Record {
|
|
|
1253
1499
|
this.ExecutedActions = ExecutedActions;
|
|
1254
1500
|
this.VisitedStates = VisitedStates;
|
|
1255
1501
|
this.TransitionsUsed = TransitionsUsed;
|
|
1256
|
-
this.
|
|
1502
|
+
this.FormSpec = FormSpec;
|
|
1257
1503
|
this.ExecutionTime = ExecutionTime;
|
|
1258
1504
|
this.Success = Success;
|
|
1259
1505
|
this.Errors = Errors;
|
|
@@ -1300,8 +1546,8 @@ function PathwayExecutionResult$1_$reflection(gen0) {
|
|
|
1300
1546
|
(0, _Reflection.list_type)(_Reflection.string_type)
|
|
1301
1547
|
],
|
|
1302
1548
|
[
|
|
1303
|
-
"
|
|
1304
|
-
(0, _FormSpec.
|
|
1549
|
+
"FormSpec",
|
|
1550
|
+
(0, _FormSpec.Spec_FormSpec$1_$reflection)(gen0)
|
|
1305
1551
|
],
|
|
1306
1552
|
[
|
|
1307
1553
|
"ExecutionTime",
|