@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
package/src/PathwayExecutor.ts
CHANGED
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
import { FSharpRef, Record, Union } from "@fable-org/fable-library-js/Types.js";
|
|
2
|
-
import { fold, tryPick, sortByDescending, truncate, length, sortBy, tryHead, filter, ofArray as ofArray_1, append, empty,
|
|
2
|
+
import { fold, findIndex, tryPick, sortByDescending, truncate, length, sortBy, tryHead, filter as filter_1, ofArray as ofArray_1, append, empty, head, tail, concat, singleton, forAll, exists, collect, map, sumBy, sum, isEmpty, choose, tryFind, FSharpList } from "@fable-org/fable-library-js/List.js";
|
|
3
3
|
import { tuple_type, bool_type, float64_type, lambda_type, class_type, record_type, int32_type, union_type, list_type, string_type, TypeInfo } from "@fable-org/fable-library-js/Reflection.js";
|
|
4
|
-
import { ClinicalPathway_PathwayExecutionMode_$reflection, ClinicalPathway_SetFieldValueAction, ClinicalPathway_FieldValueSource_$union, ClinicalPathway_PathwayExecutionMode_$union, ClinicalPathway_SelectionStrategy_$union, ClinicalPathway_CombinationStrategy_$union, ClinicalPathway_StateType_$union, ClinicalPathway_StateDefinition, Shared_PluginPropertyKey,
|
|
5
|
-
import { uint8, float64, int32 } from "@fable-org/fable-library-js/Int32.js";
|
|
6
|
-
import { equals, compare, comparePrimitives, stringHash, IComparable, IEquatable } from "@fable-org/fable-library-js/Util.js";
|
|
7
|
-
import { difference, union, empty as empty_1, FSharpSet__get_IsEmpty, FSharpSet__get_Count, contains, ofList as ofList_1, isSubset, ofArray, map as
|
|
8
|
-
import { map as map_3,
|
|
4
|
+
import { ClinicalPathway_PathwayExecutionMode_$reflection, ClinicalPathway_SetFieldValueAction, ClinicalPathway_FieldValueSource_$union, ClinicalPathway_PathwayExecutionMode_$union, ClinicalPathway_SelectionStrategy_$union, ClinicalPathway_CombinationStrategy_$union, ClinicalPathway_StateType_$union, ClinicalPathway_StateDefinition, Shared_PluginPropertyKey, Shared_FieldOptionKey, ClinicalPathway_TransitionCondition_$union, ClinicalPathway_LogicalOp_$union, ClinicalPathway_StateEvaluator_$union, Shared_FieldValue_Single, Shared_ConditionValue_$union, Shared_MatrixAnswer, ClinicalPathway_FieldEvaluator_$union, Shared_PluginDataProperty, Shared_PluginDataProperty_$reflection, Spec_Score, Spec_ScoreRange, Spec_FormStep$1, Spec_FormField$1, Shared_FieldValue_$union, Shared_MatrixItemKey, Shared_FieldAnswer, Shared_FieldOption, Spec_FieldType, Shared_TransitionKey_$reflection, Shared_TransitionKey, Shared_FieldKey_$reflection, ClinicalPathway_ActionInfo_$reflection, Spec_FormSpec$1_$reflection, Spec_FieldType_$reflection, ClinicalPathway_ClinicalPathwaySpec_$reflection, Shared_FieldKey, ClinicalPathway_ActionInfo_$union, Spec_FieldType_$union, Spec_FormSpec$1, ClinicalPathway_ClinicalPathwaySpec, Shared_StateKey_$reflection, Shared_StateKey, ClinicalPathway_TransitionDefinition_$reflection, ClinicalPathway_TransitionDefinition } from "./FormSpec.js";
|
|
5
|
+
import { tryParse as tryParse_1, uint8, float64, int32 } from "@fable-org/fable-library-js/Int32.js";
|
|
6
|
+
import { uncurry2, int32ToString, equals, compare, comparePrimitives, stringHash, IComparable, IEquatable } from "@fable-org/fable-library-js/Util.js";
|
|
7
|
+
import { difference, union, empty as empty_1, FSharpSet__get_IsEmpty, FSharpSet__get_Count, contains, ofList as ofList_1, isSubset, ofArray, map as map_1, toList, FSharpSet } from "@fable-org/fable-library-js/Set.js";
|
|
8
|
+
import { toArray, filter, map as map_3, defaultArg, value as value_3, bind, Option } from "@fable-org/fable-library-js/Option.js";
|
|
9
|
+
import { tryFind as tryFind_1, FSharpMap, ofList, toList as toList_1 } from "@fable-org/fable-library-js/Map.js";
|
|
10
|
+
import { updateField, getFieldDetails, FieldDetails$1, fieldToDetails } from "./FormSpecValues.js";
|
|
11
|
+
import { choose as choose_1, sum as sum_1, map as map_2, setItem, iterateIndexed, fill } from "@fable-org/fable-library-js/Array.js";
|
|
9
12
|
import { getBytesInt32 } from "@fable-org/fable-library-js/BitConverter.js";
|
|
10
13
|
import { arrayToGuid } from "@fable-org/fable-library-js/Guid.js";
|
|
11
|
-
import {
|
|
12
|
-
import { defaultArg, toArray, some, map as map_4, bind, value as value_3, Option } from "@fable-org/fable-library-js/Option.js";
|
|
13
|
-
import { map as map_1, collect as collect_1 } from "@fable-org/fable-library-js/Seq.js";
|
|
14
|
-
import { printf, toText, isNullOrWhiteSpace, join } from "@fable-org/fable-library-js/String.js";
|
|
14
|
+
import { printf, toText, isNullOrEmpty, isNullOrWhiteSpace, join } from "@fable-org/fable-library-js/String.js";
|
|
15
15
|
import { Auto_generateBoxedEncoder_437914C6, toString } from "./fable_modules/Thoth.Json.10.4.1/Encode.fs.js";
|
|
16
16
|
import { tryParse } from "@fable-org/fable-library-js/Double.js";
|
|
17
17
|
import { create, isMatch } from "@fable-org/fable-library-js/RegExp.js";
|
|
18
|
+
import { Auto_generateBoxedDecoder_Z6670B51, fromString } from "./fable_modules/Thoth.Json.10.4.1/Decode.fs.js";
|
|
19
|
+
import { FSharpResult$2_$union } from "@fable-org/fable-library-js/Result.js";
|
|
20
|
+
import { PluginValueRegistry_tryGet, IPluginValueConverter } from "./PluginInterface.js";
|
|
18
21
|
import { now } from "@fable-org/fable-library-js/Date.js";
|
|
19
22
|
|
|
20
23
|
export type TransitionStatus_$union =
|
|
@@ -87,19 +90,18 @@ export function ExecutionLogEntry_$reflection(): TypeInfo {
|
|
|
87
90
|
return record_type("F1.Studio.PathwayExecutor.ExecutionLogEntry", [], ExecutionLogEntry, () => [["Timestamp", class_type("System.DateTime")], ["StateKey", Shared_StateKey_$reflection()], ["Action", string_type], ["Details", string_type]]);
|
|
88
91
|
}
|
|
89
92
|
|
|
90
|
-
export class ExecutionContext
|
|
93
|
+
export class ExecutionContext extends Record {
|
|
91
94
|
readonly PathwaySpec: ClinicalPathway_ClinicalPathwaySpec;
|
|
92
|
-
readonly FormSpec: Spec_FormSpec$1<
|
|
95
|
+
readonly FormSpec: Spec_FormSpec$1<Spec_FieldType_$union>;
|
|
93
96
|
readonly CurrentStates: FSharpSet<Shared_StateKey>;
|
|
94
97
|
readonly VisitedStates: FSharpSet<Shared_StateKey>;
|
|
95
98
|
readonly CompletedStates: FSharpSet<Shared_StateKey>;
|
|
96
99
|
readonly ActiveTransitions: FSharpList<MatchedTransition>;
|
|
97
100
|
readonly PendingTransitions: FSharpList<MatchedTransition>;
|
|
98
101
|
readonly ExecutedActions: FSharpList<ClinicalPathway_ActionInfo_$union>;
|
|
99
|
-
readonly FormData: Values_DynamicFormResultData$1<FieldType>;
|
|
100
102
|
readonly FieldResolver: ((arg0: string) => Shared_FieldKey);
|
|
101
103
|
readonly ExecutionLog: FSharpList<ExecutionLogEntry>;
|
|
102
|
-
constructor(PathwaySpec: ClinicalPathway_ClinicalPathwaySpec, FormSpec: Spec_FormSpec$1<
|
|
104
|
+
constructor(PathwaySpec: ClinicalPathway_ClinicalPathwaySpec, FormSpec: Spec_FormSpec$1<Spec_FieldType_$union>, CurrentStates: FSharpSet<Shared_StateKey>, VisitedStates: FSharpSet<Shared_StateKey>, CompletedStates: FSharpSet<Shared_StateKey>, ActiveTransitions: FSharpList<MatchedTransition>, PendingTransitions: FSharpList<MatchedTransition>, ExecutedActions: FSharpList<ClinicalPathway_ActionInfo_$union>, FieldResolver: ((arg0: string) => Shared_FieldKey), ExecutionLog: FSharpList<ExecutionLogEntry>) {
|
|
103
105
|
super();
|
|
104
106
|
this.PathwaySpec = PathwaySpec;
|
|
105
107
|
this.FormSpec = FormSpec;
|
|
@@ -109,14 +111,13 @@ export class ExecutionContext$1<FieldType> extends Record {
|
|
|
109
111
|
this.ActiveTransitions = ActiveTransitions;
|
|
110
112
|
this.PendingTransitions = PendingTransitions;
|
|
111
113
|
this.ExecutedActions = ExecutedActions;
|
|
112
|
-
this.FormData = FormData;
|
|
113
114
|
this.FieldResolver = FieldResolver;
|
|
114
115
|
this.ExecutionLog = ExecutionLog;
|
|
115
116
|
}
|
|
116
117
|
}
|
|
117
118
|
|
|
118
|
-
export function
|
|
119
|
-
return record_type("F1.Studio.PathwayExecutor.ExecutionContext
|
|
119
|
+
export function ExecutionContext_$reflection(): TypeInfo {
|
|
120
|
+
return record_type("F1.Studio.PathwayExecutor.ExecutionContext", [], ExecutionContext, () => [["PathwaySpec", ClinicalPathway_ClinicalPathwaySpec_$reflection()], ["FormSpec", Spec_FormSpec$1_$reflection(Spec_FieldType_$reflection())], ["CurrentStates", class_type("Microsoft.FSharp.Collections.FSharpSet`1", [Shared_StateKey_$reflection()])], ["VisitedStates", class_type("Microsoft.FSharp.Collections.FSharpSet`1", [Shared_StateKey_$reflection()])], ["CompletedStates", class_type("Microsoft.FSharp.Collections.FSharpSet`1", [Shared_StateKey_$reflection()])], ["ActiveTransitions", list_type(MatchedTransition_$reflection())], ["PendingTransitions", list_type(MatchedTransition_$reflection())], ["ExecutedActions", list_type(ClinicalPathway_ActionInfo_$reflection())], ["FieldResolver", lambda_type(string_type, Shared_FieldKey_$reflection())], ["ExecutionLog", list_type(ExecutionLogEntry_$reflection())]]);
|
|
120
121
|
}
|
|
121
122
|
|
|
122
123
|
export class PredictedPathway extends Record implements IEquatable<PredictedPathway>, IComparable<PredictedPathway> {
|
|
@@ -139,14 +140,14 @@ export function PredictedPathway_$reflection(): TypeInfo {
|
|
|
139
140
|
return record_type("F1.Studio.PathwayExecutor.PredictedPathway", [], PredictedPathway, () => [["PathwayId", string_type], ["Probability", float64_type], ["RequiredFields", list_type(string_type)], ["ExpectedActions", list_type(ClinicalPathway_ActionInfo_$reflection())], ["TargetState", string_type]]);
|
|
140
141
|
}
|
|
141
142
|
|
|
142
|
-
export class IncrementalExecutionResult
|
|
143
|
-
readonly Context: ExecutionContext
|
|
143
|
+
export class IncrementalExecutionResult extends Record {
|
|
144
|
+
readonly Context: ExecutionContext;
|
|
144
145
|
readonly NewlyActivatedStates: FSharpList<string>;
|
|
145
146
|
readonly NewlyActiveTransitions: FSharpList<ClinicalPathway_TransitionDefinition>;
|
|
146
147
|
readonly PredictedOutcomes: FSharpList<PredictedPathway>;
|
|
147
148
|
readonly CompletionPercentage: float64;
|
|
148
149
|
readonly IsComplete: boolean;
|
|
149
|
-
constructor(Context: ExecutionContext
|
|
150
|
+
constructor(Context: ExecutionContext, NewlyActivatedStates: FSharpList<string>, NewlyActiveTransitions: FSharpList<ClinicalPathway_TransitionDefinition>, PredictedOutcomes: FSharpList<PredictedPathway>, CompletionPercentage: float64, IsComplete: boolean) {
|
|
150
151
|
super();
|
|
151
152
|
this.Context = Context;
|
|
152
153
|
this.NewlyActivatedStates = NewlyActivatedStates;
|
|
@@ -157,8 +158,8 @@ export class IncrementalExecutionResult$1<FieldType> extends Record {
|
|
|
157
158
|
}
|
|
158
159
|
}
|
|
159
160
|
|
|
160
|
-
export function
|
|
161
|
-
return record_type("F1.Studio.PathwayExecutor.IncrementalExecutionResult
|
|
161
|
+
export function IncrementalExecutionResult_$reflection(): TypeInfo {
|
|
162
|
+
return record_type("F1.Studio.PathwayExecutor.IncrementalExecutionResult", [], IncrementalExecutionResult, () => [["Context", ExecutionContext_$reflection()], ["NewlyActivatedStates", list_type(string_type)], ["NewlyActiveTransitions", list_type(ClinicalPathway_TransitionDefinition_$reflection())], ["PredictedOutcomes", list_type(PredictedPathway_$reflection())], ["CompletionPercentage", float64_type], ["IsComplete", bool_type]]);
|
|
162
163
|
}
|
|
163
164
|
|
|
164
165
|
export class ClinicalPlan extends Record implements IEquatable<ClinicalPlan>, IComparable<ClinicalPlan> {
|
|
@@ -201,6 +202,124 @@ export function VisualizationState_$reflection(): TypeInfo {
|
|
|
201
202
|
return record_type("F1.Studio.PathwayExecutor.VisualizationState", [], VisualizationState, () => [["CurrentStates", class_type("Microsoft.FSharp.Collections.FSharpSet`1", [Shared_StateKey_$reflection()])], ["VisitedStates", class_type("Microsoft.FSharp.Collections.FSharpSet`1", [Shared_StateKey_$reflection()])], ["ActiveTransitions", list_type(Shared_TransitionKey_$reflection())], ["PendingTransitions", list_type(Shared_TransitionKey_$reflection())], ["CompletedTransitions", list_type(string_type)], ["PredictedOutcomes", list_type(PredictedPathway_$reflection())]]);
|
|
202
203
|
}
|
|
203
204
|
|
|
205
|
+
/**
|
|
206
|
+
* Extract options from a field type (single source of truth for scoring)
|
|
207
|
+
* This is THE ONLY place where we extract scoring information from fields
|
|
208
|
+
*/
|
|
209
|
+
export function ScoreCalculator_extractFieldOptions<FieldType>(fieldType: FieldType): Option<FSharpList<Shared_FieldOption>> {
|
|
210
|
+
const matchValue: any = fieldType;
|
|
211
|
+
if (matchValue instanceof Spec_FieldType) {
|
|
212
|
+
const ft = matchValue as Spec_FieldType_$union;
|
|
213
|
+
switch (ft.tag) {
|
|
214
|
+
case /* Radio */ 12:
|
|
215
|
+
return ft.fields[0].Options;
|
|
216
|
+
case /* SingleChoice */ 13:
|
|
217
|
+
return ft.fields[0].Options;
|
|
218
|
+
case /* Dropdown */ 14:
|
|
219
|
+
return ft.fields[0].Options;
|
|
220
|
+
case /* TextAutoComplete */ 18:
|
|
221
|
+
return ft.fields[0].Options;
|
|
222
|
+
case /* MultiChoice */ 15:
|
|
223
|
+
return ft.fields[0].Options;
|
|
224
|
+
case /* CheckboxList */ 16:
|
|
225
|
+
return ft.fields[0].Options;
|
|
226
|
+
case /* TagList */ 17:
|
|
227
|
+
return ft.fields[0].Options;
|
|
228
|
+
case /* Matrix */ 19:
|
|
229
|
+
return ft.fields[0].Options;
|
|
230
|
+
default:
|
|
231
|
+
return undefined;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
return undefined;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Calculate score for a field value given its options
|
|
241
|
+
*/
|
|
242
|
+
export function ScoreCalculator_calculateFieldValueScore(options: FSharpList<Shared_FieldOption>, fieldValue: Shared_FieldValue_$union): Option<int32> {
|
|
243
|
+
switch (fieldValue.tag) {
|
|
244
|
+
case /* Single */ 0: {
|
|
245
|
+
const answer: Shared_FieldAnswer = fieldValue.fields[0];
|
|
246
|
+
return bind<Shared_FieldOption, int32>((opt_1: Shared_FieldOption): Option<int32> => opt_1.Score, tryFind<Shared_FieldOption>((opt: Shared_FieldOption): boolean => (opt.Value === answer.Value), options));
|
|
247
|
+
}
|
|
248
|
+
case /* Multiple */ 1: {
|
|
249
|
+
const _arg: FSharpList<int32> = choose<Shared_FieldAnswer, int32>((answer_1: Shared_FieldAnswer): Option<int32> => bind<Shared_FieldOption, int32>((opt_3: Shared_FieldOption): Option<int32> => opt_3.Score, tryFind<Shared_FieldOption>((opt_2: Shared_FieldOption): boolean => (opt_2.Value === answer_1.Value), options)), toList<Shared_FieldAnswer>(fieldValue.fields[0]));
|
|
250
|
+
if (isEmpty(_arg)) {
|
|
251
|
+
return undefined;
|
|
252
|
+
}
|
|
253
|
+
else {
|
|
254
|
+
return sum<int32>(_arg, {
|
|
255
|
+
GetZero: (): int32 => 0,
|
|
256
|
+
Add: (x: int32, y: int32): int32 => (x + y),
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
case /* Matrix */ 2: {
|
|
261
|
+
const _arg_2: FSharpList<int32> = choose<[Shared_MatrixItemKey, string], int32>((tupledArg: [Shared_MatrixItemKey, string]): Option<int32> => bind<Shared_FieldOption, int32>((opt_5: Shared_FieldOption): Option<int32> => opt_5.Score, tryFind<Shared_FieldOption>((opt_4: Shared_FieldOption): boolean => (opt_4.Value === tupledArg[1]), options)), toList_1<Shared_MatrixItemKey, string>(fieldValue.fields[0].Values));
|
|
262
|
+
if (isEmpty(_arg_2)) {
|
|
263
|
+
return undefined;
|
|
264
|
+
}
|
|
265
|
+
else {
|
|
266
|
+
return sum<int32>(_arg_2, {
|
|
267
|
+
GetZero: (): int32 => 0,
|
|
268
|
+
Add: (x_1: int32, y_1: int32): int32 => (x_1 + y_1),
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
default:
|
|
273
|
+
return undefined;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Calculate score for a single field
|
|
279
|
+
*/
|
|
280
|
+
export function ScoreCalculator_calculateFieldScore<FieldType>(field: Spec_FormField$1<FieldType>, fieldValue: Shared_FieldValue_$union): Option<int32> {
|
|
281
|
+
return bind<FSharpList<Shared_FieldOption>, int32>((options: FSharpList<Shared_FieldOption>): Option<int32> => ScoreCalculator_calculateFieldValueScore(options, fieldValue), ScoreCalculator_extractFieldOptions<FieldType>(field.FieldType));
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Calculate total score for a form step (reads from FormSpec step fields)
|
|
286
|
+
*/
|
|
287
|
+
export function ScoreCalculator_calculateStepScore(formSpec: Spec_FormSpec$1<Spec_FieldType_$union>, step: Spec_FormStep$1<Spec_FieldType_$union>): int32 {
|
|
288
|
+
return sum<int32>(choose<Spec_FormField$1<Spec_FieldType_$union>, int32>((field: Spec_FormField$1<Spec_FieldType_$union>): Option<int32> => ScoreCalculator_calculateFieldScore<Spec_FieldType_$union>(field, fieldToDetails(field).FieldValue), step.Fields), {
|
|
289
|
+
GetZero: (): int32 => 0,
|
|
290
|
+
Add: (x: int32, y: int32): int32 => (x + y),
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Calculate total score for entire form (reads from FormSpec)
|
|
296
|
+
*/
|
|
297
|
+
export function ScoreCalculator_calculateTotalScore(formSpec: Spec_FormSpec$1<Spec_FieldType_$union>): int32 {
|
|
298
|
+
return sumBy<Spec_FormStep$1<Spec_FieldType_$union>, int32>((step: Spec_FormStep$1<Spec_FieldType_$union>): int32 => ScoreCalculator_calculateStepScore(formSpec, step), formSpec.Steps, {
|
|
299
|
+
GetZero: (): int32 => 0,
|
|
300
|
+
Add: (x: int32, y: int32): int32 => (x + y),
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Get score range for a given score value
|
|
306
|
+
*/
|
|
307
|
+
export function ScoreCalculator_getScoreRange(score: Option<Spec_Score>, value: int32): Option<Spec_ScoreRange> {
|
|
308
|
+
if (score != null) {
|
|
309
|
+
return tryFind<Spec_ScoreRange>((range: Spec_ScoreRange): boolean => {
|
|
310
|
+
if (value >= range.Min) {
|
|
311
|
+
return value <= range.Max;
|
|
312
|
+
}
|
|
313
|
+
else {
|
|
314
|
+
return false;
|
|
315
|
+
}
|
|
316
|
+
}, value_3(score).ScoreRanges);
|
|
317
|
+
}
|
|
318
|
+
else {
|
|
319
|
+
return undefined;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
204
323
|
/**
|
|
205
324
|
* Generate deterministic GUID from field label
|
|
206
325
|
*/
|
|
@@ -233,26 +352,26 @@ export function FieldResolver_generateFieldKey(fieldName: string): Shared_FieldK
|
|
|
233
352
|
/**
|
|
234
353
|
* Create resolver that maps pathway field references to FieldKeys
|
|
235
354
|
*/
|
|
236
|
-
export function FieldResolver_createResolver
|
|
237
|
-
const labelToFieldKey: FSharpMap<string, Shared_FieldKey> = ofList<string, Shared_FieldKey>(map<Spec_FormField$1<
|
|
355
|
+
export function FieldResolver_createResolver(formSpec: Spec_FormSpec$1<Spec_FieldType_$union>): ((arg0: string) => Shared_FieldKey) {
|
|
356
|
+
const labelToFieldKey: FSharpMap<string, Shared_FieldKey> = ofList<string, Shared_FieldKey>(map<Spec_FormField$1<Spec_FieldType_$union>, [string, Shared_FieldKey]>((field: Spec_FormField$1<Spec_FieldType_$union>): [string, Shared_FieldKey] => ([field.Label.toLocaleLowerCase().trim(), field.FieldKey] as [string, Shared_FieldKey]), collect<Spec_FormStep$1<Spec_FieldType_$union>, Spec_FormField$1<Spec_FieldType_$union>>((step: Spec_FormStep$1<Spec_FieldType_$union>): FSharpList<Spec_FormField$1<Spec_FieldType_$union>> => step.Fields, formSpec.Steps)), {
|
|
238
357
|
Compare: comparePrimitives,
|
|
239
358
|
});
|
|
240
359
|
return (fieldReference: string): Shared_FieldKey => {
|
|
241
|
-
const matchValue: Option<Shared_FieldKey> =
|
|
360
|
+
const matchValue: Option<Shared_FieldKey> = tryFind_1<string, Shared_FieldKey>(fieldReference.toLocaleLowerCase().trim(), labelToFieldKey);
|
|
242
361
|
return (matchValue == null) ? FieldResolver_generateFieldKey(fieldReference) : value_3(matchValue);
|
|
243
362
|
};
|
|
244
363
|
}
|
|
245
364
|
|
|
246
365
|
/**
|
|
247
|
-
* Extract field values from form
|
|
366
|
+
* Extract field values from form spec (reads from FormSpec)
|
|
248
367
|
*/
|
|
249
|
-
export function FieldResolver_extractFieldValues
|
|
250
|
-
return
|
|
368
|
+
export function FieldResolver_extractFieldValues(resolver: ((arg0: string) => Shared_FieldKey), formSpec: Spec_FormSpec$1<Spec_FieldType_$union>): FSharpMap<Shared_FieldKey, string> {
|
|
369
|
+
return ofList<Shared_FieldKey, string>(collect<Spec_FormStep$1<Spec_FieldType_$union>, [Shared_FieldKey, string]>((step: Spec_FormStep$1<Spec_FieldType_$union>): FSharpList<[Shared_FieldKey, string]> => map<Spec_FormField$1<Spec_FieldType_$union>, [Shared_FieldKey, string]>((field: Spec_FormField$1<Spec_FieldType_$union>): [Shared_FieldKey, string] => {
|
|
251
370
|
let matchValue: Shared_FieldValue_$union, pluginData: FSharpList<Shared_PluginDataProperty>;
|
|
252
|
-
return [
|
|
371
|
+
return [field.FieldKey, (matchValue = fieldToDetails(field).FieldValue, (matchValue.tag === /* Multiple */ 1) ? join(",", toList<string>(map_1<Shared_FieldAnswer, string>((a: Shared_FieldAnswer): string => a.Value, matchValue.fields[0], {
|
|
253
372
|
Compare: comparePrimitives,
|
|
254
|
-
}))) : ((matchValue.tag === /* Matrix */ 2) ? join(",", map<[Shared_MatrixItemKey, string], string>((
|
|
255
|
-
},
|
|
373
|
+
}))) : ((matchValue.tag === /* Matrix */ 2) ? join(",", map<[Shared_MatrixItemKey, string], string>((tupledArg: [Shared_MatrixItemKey, string]): string => tupledArg[1], toList_1<Shared_MatrixItemKey, string>(matchValue.fields[0].Values))) : ((matchValue.tag === /* PluginData */ 3) ? ((pluginData = matchValue.fields[0], toString(0, Auto_generateBoxedEncoder_437914C6(list_type(Shared_PluginDataProperty_$reflection()), undefined, undefined, undefined)(pluginData)))) : matchValue.fields[0].Value)))] as [Shared_FieldKey, string];
|
|
374
|
+
}, step.Fields), formSpec.Steps), {
|
|
256
375
|
Compare: compare,
|
|
257
376
|
});
|
|
258
377
|
}
|
|
@@ -407,7 +526,7 @@ export function evaluateFieldCondition(actualValue: string, evaluator: ClinicalP
|
|
|
407
526
|
const maxVal: int32 = evaluator.fields[1] | 0;
|
|
408
527
|
let matchValue_12: [boolean, float64];
|
|
409
528
|
let outArg_8 = 0;
|
|
410
|
-
matchValue_12 = ([tryParse(actualValue, new FSharpRef<float64>((): float64 => outArg_8, (v_8: float64): void => {
|
|
529
|
+
matchValue_12 = ([tryParse(actualValue.trim(), new FSharpRef<float64>((): float64 => outArg_8, (v_8: float64): void => {
|
|
411
530
|
outArg_8 = v_8;
|
|
412
531
|
})), outArg_8] as [boolean, float64]);
|
|
413
532
|
if (matchValue_12[0]) {
|
|
@@ -429,7 +548,7 @@ export function evaluateFieldCondition(actualValue: string, evaluator: ClinicalP
|
|
|
429
548
|
return !exists<string>((v_10: string): boolean => (v_10.trim().toLocaleLowerCase() === actualValue.trim().toLocaleLowerCase()), evaluator.fields[0]);
|
|
430
549
|
case /* ContainsAll */ 4: {
|
|
431
550
|
const values_2: FSharpList<string> = evaluator.fields[0];
|
|
432
|
-
const actualParts: FSharpSet<string> = ofArray<string>(
|
|
551
|
+
const actualParts: FSharpSet<string> = ofArray<string>(map_2<string, string>((s: string): string => s.trim().toLocaleLowerCase(), actualValue.split(",")), {
|
|
433
552
|
Compare: comparePrimitives,
|
|
434
553
|
});
|
|
435
554
|
return isSubset<string>(ofList_1<string>(map<string, string>((s_1: string): string => s_1.trim().toLocaleLowerCase(), values_2), {
|
|
@@ -441,38 +560,175 @@ export function evaluateFieldCondition(actualValue: string, evaluator: ClinicalP
|
|
|
441
560
|
}
|
|
442
561
|
}
|
|
443
562
|
|
|
563
|
+
/**
|
|
564
|
+
* Evaluate Matrix condition: check specific item(s) in the matrix (e.g. PHQ-9 item 9 = suicidal ideation)
|
|
565
|
+
* ConditionValue.Matrix [[itemKey, expectedVal]] means "item should have this value"
|
|
566
|
+
* For NotEquals: trigger when item value ≠ expected (e.g. item 9 ≠ "0" → suicidal ideation endorsed)
|
|
567
|
+
*/
|
|
568
|
+
export function evaluateMatrixItemCondition(actualMatrix: Shared_MatrixAnswer, evaluator: ClinicalPathway_FieldEvaluator_$union, expectedMatrix: FSharpMap<Shared_MatrixItemKey, string>): boolean {
|
|
569
|
+
const entries: FSharpList<[Shared_MatrixItemKey, string]> = toList_1<Shared_MatrixItemKey, string>(expectedMatrix);
|
|
570
|
+
if (isEmpty(entries)) {
|
|
571
|
+
return false;
|
|
572
|
+
}
|
|
573
|
+
else {
|
|
574
|
+
const allMatch: boolean = forAll<[Shared_MatrixItemKey, string]>((tupledArg: [Shared_MatrixItemKey, string]): boolean => {
|
|
575
|
+
const expectedVal: string = tupledArg[1];
|
|
576
|
+
const actualVal: string = defaultArg(tryFind_1<Shared_MatrixItemKey, string>(tupledArg[0], actualMatrix.Values), "0");
|
|
577
|
+
switch (evaluator.tag) {
|
|
578
|
+
case /* Equals */ 0:
|
|
579
|
+
return actualVal.trim().toLocaleLowerCase() === expectedVal.trim().toLocaleLowerCase();
|
|
580
|
+
case /* NotEquals */ 1:
|
|
581
|
+
return actualVal.trim().toLocaleLowerCase() !== expectedVal.trim().toLocaleLowerCase();
|
|
582
|
+
default:
|
|
583
|
+
return evaluateFieldCondition(actualVal, evaluator, expectedVal);
|
|
584
|
+
}
|
|
585
|
+
}, entries);
|
|
586
|
+
switch (evaluator.tag) {
|
|
587
|
+
case /* Equals */ 0:
|
|
588
|
+
return allMatch;
|
|
589
|
+
case /* NotEquals */ 1:
|
|
590
|
+
return allMatch;
|
|
591
|
+
default:
|
|
592
|
+
return allMatch;
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
|
|
444
597
|
/**
|
|
445
598
|
* Evaluate a field condition with ConditionValue (type-aware comparison)
|
|
446
599
|
*/
|
|
447
600
|
export function evaluateFieldConditionWithConditionValue(actualFieldValue: Shared_FieldValue_$union, evaluator: ClinicalPathway_FieldEvaluator_$union, expectedConditionValue: Shared_ConditionValue_$union): boolean {
|
|
448
601
|
let pluginData: FSharpList<Shared_PluginDataProperty>, pluginData_1: Shared_PluginDataProperty;
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
602
|
+
let matchResult: int32, actualMatrix: Shared_MatrixAnswer, expectedMatrix: FSharpMap<Shared_MatrixItemKey, string>;
|
|
603
|
+
if (actualFieldValue.tag === /* Matrix */ 2) {
|
|
604
|
+
if (expectedConditionValue.tag === /* Matrix */ 2) {
|
|
605
|
+
matchResult = 0;
|
|
606
|
+
actualMatrix = actualFieldValue.fields[0];
|
|
607
|
+
expectedMatrix = expectedConditionValue.fields[0];
|
|
608
|
+
}
|
|
609
|
+
else {
|
|
610
|
+
matchResult = 1;
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
else {
|
|
614
|
+
matchResult = 1;
|
|
615
|
+
}
|
|
616
|
+
switch (matchResult) {
|
|
617
|
+
case 0:
|
|
618
|
+
return evaluateMatrixItemCondition(actualMatrix!, evaluator, expectedMatrix!);
|
|
619
|
+
default:
|
|
620
|
+
return evaluateFieldCondition((actualFieldValue.tag === /* Multiple */ 1) ? join(",", toList<string>(map_1<Shared_FieldAnswer, string>((a: Shared_FieldAnswer): string => a.Value, actualFieldValue.fields[0], {
|
|
621
|
+
Compare: comparePrimitives,
|
|
622
|
+
}))) : ((actualFieldValue.tag === /* Matrix */ 2) ? join(",", map<[Shared_MatrixItemKey, string], string>((tupledArg: [Shared_MatrixItemKey, string]): string => tupledArg[1], toList_1<Shared_MatrixItemKey, string>(actualFieldValue.fields[0].Values))) : ((actualFieldValue.tag === /* PluginData */ 3) ? ((pluginData = actualFieldValue.fields[0], toString(0, Auto_generateBoxedEncoder_437914C6(list_type(Shared_PluginDataProperty_$reflection()), undefined, undefined, undefined)(pluginData)))) : actualFieldValue.fields[0].Value)), evaluator, (expectedConditionValue.tag === /* Multiple */ 1) ? join(",", toList<string>(expectedConditionValue.fields[0])) : ((expectedConditionValue.tag === /* Matrix */ 2) ? join(",", map<[Shared_MatrixItemKey, string], string>((tupledArg_1: [Shared_MatrixItemKey, string]): string => tupledArg_1[1], toList_1<Shared_MatrixItemKey, string>(expectedConditionValue.fields[0]))) : ((expectedConditionValue.tag === /* PluginData */ 3) ? ((pluginData_1 = expectedConditionValue.fields[0], toString(0, Auto_generateBoxedEncoder_437914C6(Shared_PluginDataProperty_$reflection(), undefined, undefined, undefined)(pluginData_1)))) : expectedConditionValue.fields[0])));
|
|
623
|
+
}
|
|
452
624
|
}
|
|
453
625
|
|
|
454
626
|
/**
|
|
455
627
|
* Recursively evaluate a transition condition with partial data support
|
|
456
628
|
*/
|
|
457
|
-
export function evaluateTransitionWithPartialData
|
|
458
|
-
let
|
|
629
|
+
export function evaluateTransitionWithPartialData(resolver: ((arg0: string) => Shared_FieldKey), formSpec: Option<Spec_FormSpec$1<Spec_FieldType_$union>>, fieldValues: FSharpMap<Shared_FieldKey, string>, visitedStates: FSharpSet<Shared_StateKey>, formSpecForScores: Option<Spec_FormSpec$1<Spec_FieldType_$union>>, condition: ClinicalPathway_TransitionCondition_$union): TransitionStatus_$union {
|
|
630
|
+
let score: int32, data_1: Spec_FormSpec$1<Spec_FieldType_$union>, score_2: int32, pluginData: Shared_PluginDataProperty;
|
|
459
631
|
switch (condition.tag) {
|
|
460
632
|
case /* FieldCondition */ 0: {
|
|
461
633
|
const fieldKey: Shared_FieldKey = condition.fields[0];
|
|
462
634
|
const evaluator: ClinicalPathway_FieldEvaluator_$union = condition.fields[1];
|
|
463
635
|
const conditionValue: Shared_ConditionValue_$union = condition.fields[2];
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
636
|
+
if (evaluator.tag === /* InRange */ 13) {
|
|
637
|
+
const minVal: int32 = evaluator.fields[0] | 0;
|
|
638
|
+
const maxVal: int32 = evaluator.fields[1] | 0;
|
|
639
|
+
let matchResult: int32, data: Spec_FormSpec$1<Spec_FieldType_$union>, spec: Spec_FormSpec$1<Spec_FieldType_$union>;
|
|
640
|
+
if (formSpec != null) {
|
|
641
|
+
if (formSpecForScores != null) {
|
|
642
|
+
matchResult = 0;
|
|
643
|
+
data = value_3(formSpecForScores);
|
|
644
|
+
spec = value_3(formSpec);
|
|
645
|
+
}
|
|
646
|
+
else {
|
|
647
|
+
matchResult = 1;
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
else {
|
|
651
|
+
matchResult = 1;
|
|
652
|
+
}
|
|
653
|
+
switch (matchResult) {
|
|
654
|
+
case 0: {
|
|
655
|
+
const fieldScoreOpt: Option<int32> = bind<Spec_FormField$1<Spec_FieldType_$union>, int32>((field_1: Spec_FormField$1<Spec_FieldType_$union>): Option<int32> => bind<FieldDetails$1<Spec_FieldType_$union>, int32>((details: FieldDetails$1<Spec_FieldType_$union>): Option<int32> => ScoreCalculator_calculateFieldScore<Spec_FieldType_$union>(field_1, details.FieldValue), getFieldDetails(data!, fieldKey)), tryFind<Spec_FormField$1<Spec_FieldType_$union>>((field: Spec_FormField$1<Spec_FieldType_$union>): boolean => equals(field.FieldKey, fieldKey), collect<Spec_FormStep$1<Spec_FieldType_$union>, Spec_FormField$1<Spec_FieldType_$union>>((step: Spec_FormStep$1<Spec_FieldType_$union>): FSharpList<Spec_FormField$1<Spec_FieldType_$union>> => step.Fields, spec!.Steps)));
|
|
656
|
+
if (fieldScoreOpt == null) {
|
|
657
|
+
return TransitionStatus_Pending(singleton(fieldKey.fields[0]));
|
|
658
|
+
}
|
|
659
|
+
else if ((score = (value_3(fieldScoreOpt) | 0), (score >= minVal) && (score <= maxVal))) {
|
|
660
|
+
const score_1: int32 = value_3(fieldScoreOpt) | 0;
|
|
661
|
+
return TransitionStatus_Satisfied();
|
|
662
|
+
}
|
|
663
|
+
else {
|
|
664
|
+
return TransitionStatus_Failed();
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
default:
|
|
668
|
+
return TransitionStatus_Pending(singleton(fieldKey.fields[0]));
|
|
669
|
+
}
|
|
467
670
|
}
|
|
468
|
-
else
|
|
469
|
-
|
|
671
|
+
else {
|
|
672
|
+
const actualFieldValueOpt: Option<Shared_FieldValue_$union> = (conditionValue.tag === /* Matrix */ 2) ? ((formSpecForScores != null) ? ((data_1 = value_3(formSpecForScores), map_3<FieldDetails$1<Spec_FieldType_$union>, Shared_FieldValue_$union>((details_1: FieldDetails$1<Spec_FieldType_$union>): Shared_FieldValue_$union => details_1.FieldValue, getFieldDetails(data_1, fieldKey)))) : undefined) : undefined;
|
|
673
|
+
if (actualFieldValueOpt == null) {
|
|
674
|
+
const matchValue_2: Option<string> = tryFind_1<Shared_FieldKey, string>(fieldKey, fieldValues);
|
|
675
|
+
if (matchValue_2 == null) {
|
|
676
|
+
return TransitionStatus_Pending(singleton(fieldKey.fields[0]));
|
|
677
|
+
}
|
|
678
|
+
else if (evaluateFieldConditionWithConditionValue(Shared_FieldValue_Single(new Shared_FieldAnswer(fieldKey, "", value_3(matchValue_2))), evaluator, conditionValue)) {
|
|
679
|
+
return TransitionStatus_Satisfied();
|
|
680
|
+
}
|
|
681
|
+
else {
|
|
682
|
+
return TransitionStatus_Failed();
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
else if (evaluateFieldConditionWithConditionValue(value_3(actualFieldValueOpt), evaluator, conditionValue)) {
|
|
686
|
+
return TransitionStatus_Satisfied();
|
|
687
|
+
}
|
|
688
|
+
else {
|
|
689
|
+
return TransitionStatus_Failed();
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
case /* ScoreInRange */ 3: {
|
|
694
|
+
const minScore: int32 = condition.fields[0] | 0;
|
|
695
|
+
const maxScore: int32 = condition.fields[1] | 0;
|
|
696
|
+
if (formSpecForScores != null) {
|
|
697
|
+
const totalScore: int32 = ScoreCalculator_calculateTotalScore(value_3(formSpecForScores)) | 0;
|
|
698
|
+
if ((totalScore >= minScore) && (totalScore <= maxScore)) {
|
|
699
|
+
return TransitionStatus_Satisfied();
|
|
700
|
+
}
|
|
701
|
+
else {
|
|
702
|
+
return TransitionStatus_Failed();
|
|
703
|
+
}
|
|
470
704
|
}
|
|
471
705
|
else {
|
|
472
|
-
return
|
|
706
|
+
return TransitionStatus_Pending(singleton("form_score"));
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
case /* FieldScoreInRange */ 4: {
|
|
710
|
+
const minScore_1: int32 = condition.fields[1] | 0;
|
|
711
|
+
const maxScore_1: int32 = condition.fields[2] | 0;
|
|
712
|
+
const fieldKey_1: Shared_FieldKey = condition.fields[0];
|
|
713
|
+
if (formSpecForScores != null) {
|
|
714
|
+
const spec_2: Spec_FormSpec$1<Spec_FieldType_$union> = value_3(formSpecForScores);
|
|
715
|
+
const fieldScoreOpt_1: Option<int32> = bind<Spec_FormField$1<Spec_FieldType_$union>, int32>((field_3: Spec_FormField$1<Spec_FieldType_$union>): Option<int32> => bind<FieldDetails$1<Spec_FieldType_$union>, int32>((details_2: FieldDetails$1<Spec_FieldType_$union>): Option<int32> => ScoreCalculator_calculateFieldScore<Spec_FieldType_$union>(field_3, details_2.FieldValue), getFieldDetails(spec_2, fieldKey_1)), tryFind<Spec_FormField$1<Spec_FieldType_$union>>((field_2: Spec_FormField$1<Spec_FieldType_$union>): boolean => equals(field_2.FieldKey, fieldKey_1), collect<Spec_FormStep$1<Spec_FieldType_$union>, Spec_FormField$1<Spec_FieldType_$union>>((step_1: Spec_FormStep$1<Spec_FieldType_$union>): FSharpList<Spec_FormField$1<Spec_FieldType_$union>> => step_1.Fields, spec_2.Steps)));
|
|
716
|
+
if (fieldScoreOpt_1 == null) {
|
|
717
|
+
return TransitionStatus_Pending(singleton(fieldKey_1.fields[0]));
|
|
718
|
+
}
|
|
719
|
+
else if ((score_2 = (value_3(fieldScoreOpt_1) | 0), (score_2 >= minScore_1) && (score_2 <= maxScore_1))) {
|
|
720
|
+
const score_3: int32 = value_3(fieldScoreOpt_1) | 0;
|
|
721
|
+
return TransitionStatus_Satisfied();
|
|
722
|
+
}
|
|
723
|
+
else {
|
|
724
|
+
return TransitionStatus_Failed();
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
else {
|
|
728
|
+
return TransitionStatus_Pending(singleton(fieldKey_1.fields[0]));
|
|
473
729
|
}
|
|
474
730
|
}
|
|
475
|
-
case /* StateCondition */
|
|
731
|
+
case /* StateCondition */ 5: {
|
|
476
732
|
const evaluator_1: ClinicalPathway_StateEvaluator_$union = condition.fields[1];
|
|
477
733
|
const stateVisited: boolean = contains<Shared_StateKey>(condition.fields[0], visitedStates);
|
|
478
734
|
switch (evaluator_1.tag) {
|
|
@@ -501,12 +757,12 @@ export function evaluateTransitionWithPartialData<FieldType>(resolver: ((arg0: s
|
|
|
501
757
|
}
|
|
502
758
|
}
|
|
503
759
|
}
|
|
504
|
-
case /* CompositeCondition */
|
|
760
|
+
case /* CompositeCondition */ 6: {
|
|
505
761
|
const logicalOp: ClinicalPathway_LogicalOp_$union = condition.fields[0];
|
|
506
762
|
const conditions: FSharpList<ClinicalPathway_TransitionCondition_$union> = condition.fields[1];
|
|
507
763
|
switch (logicalOp.tag) {
|
|
508
764
|
case /* Or */ 1: {
|
|
509
|
-
const results_1: FSharpList<TransitionStatus_$union> = map<ClinicalPathway_TransitionCondition_$union, TransitionStatus_$union>((condition_2: ClinicalPathway_TransitionCondition_$union): TransitionStatus_$union => evaluateTransitionWithPartialData
|
|
765
|
+
const results_1: FSharpList<TransitionStatus_$union> = map<ClinicalPathway_TransitionCondition_$union, TransitionStatus_$union>((condition_2: ClinicalPathway_TransitionCondition_$union): TransitionStatus_$union => evaluateTransitionWithPartialData(resolver, formSpec, fieldValues, visitedStates, formSpecForScores, condition_2), conditions);
|
|
510
766
|
if (exists<TransitionStatus_$union>((r_3: TransitionStatus_$union): boolean => equals(r_3, TransitionStatus_Satisfied()), results_1)) {
|
|
511
767
|
return TransitionStatus_Satisfied();
|
|
512
768
|
}
|
|
@@ -525,27 +781,27 @@ export function evaluateTransitionWithPartialData<FieldType>(resolver: ((arg0: s
|
|
|
525
781
|
}
|
|
526
782
|
}
|
|
527
783
|
case /* Not */ 2: {
|
|
528
|
-
let
|
|
784
|
+
let matchResult_1: int32, cond: ClinicalPathway_TransitionCondition_$union;
|
|
529
785
|
if (!isEmpty(conditions)) {
|
|
530
786
|
if (isEmpty(tail(conditions))) {
|
|
531
|
-
|
|
787
|
+
matchResult_1 = 0;
|
|
532
788
|
cond = head(conditions);
|
|
533
789
|
}
|
|
534
790
|
else {
|
|
535
|
-
|
|
791
|
+
matchResult_1 = 1;
|
|
536
792
|
}
|
|
537
793
|
}
|
|
538
794
|
else {
|
|
539
|
-
|
|
795
|
+
matchResult_1 = 1;
|
|
540
796
|
}
|
|
541
|
-
switch (
|
|
797
|
+
switch (matchResult_1) {
|
|
542
798
|
case 0: {
|
|
543
|
-
const
|
|
544
|
-
switch (
|
|
799
|
+
const matchValue_3: TransitionStatus_$union = evaluateTransitionWithPartialData(resolver, formSpec, fieldValues, visitedStates, formSpecForScores, cond!);
|
|
800
|
+
switch (matchValue_3.tag) {
|
|
545
801
|
case /* Failed */ 1:
|
|
546
802
|
return TransitionStatus_Satisfied();
|
|
547
803
|
case /* Pending */ 2:
|
|
548
|
-
return TransitionStatus_Pending(
|
|
804
|
+
return TransitionStatus_Pending(matchValue_3.fields[0]);
|
|
549
805
|
default:
|
|
550
806
|
return TransitionStatus_Failed();
|
|
551
807
|
}
|
|
@@ -555,7 +811,7 @@ export function evaluateTransitionWithPartialData<FieldType>(resolver: ((arg0: s
|
|
|
555
811
|
}
|
|
556
812
|
}
|
|
557
813
|
default: {
|
|
558
|
-
const results: FSharpList<TransitionStatus_$union> = map<ClinicalPathway_TransitionCondition_$union, TransitionStatus_$union>((condition_1: ClinicalPathway_TransitionCondition_$union): TransitionStatus_$union => evaluateTransitionWithPartialData
|
|
814
|
+
const results: FSharpList<TransitionStatus_$union> = map<ClinicalPathway_TransitionCondition_$union, TransitionStatus_$union>((condition_1: ClinicalPathway_TransitionCondition_$union): TransitionStatus_$union => evaluateTransitionWithPartialData(resolver, formSpec, fieldValues, visitedStates, formSpecForScores, condition_1), conditions);
|
|
559
815
|
if (exists<TransitionStatus_$union>((r: TransitionStatus_$union): boolean => equals(r, TransitionStatus_Failed()), results)) {
|
|
560
816
|
return TransitionStatus_Failed();
|
|
561
817
|
}
|
|
@@ -575,33 +831,31 @@ export function evaluateTransitionWithPartialData<FieldType>(resolver: ((arg0: s
|
|
|
575
831
|
}
|
|
576
832
|
}
|
|
577
833
|
}
|
|
578
|
-
case /* TestResultCondition */
|
|
834
|
+
case /* TestResultCondition */ 7: {
|
|
579
835
|
const result: string = condition.fields[1];
|
|
580
836
|
return TransitionStatus_Pending(singleton(condition.fields[0]));
|
|
581
837
|
}
|
|
582
838
|
case /* FieldOptionCondition */ 1: {
|
|
583
839
|
const optionKey: Shared_FieldOptionKey = condition.fields[2];
|
|
584
840
|
const matrixItemKey: Option<Shared_MatrixItemKey> = condition.fields[1];
|
|
585
|
-
const
|
|
841
|
+
const fieldKey_2: Shared_FieldKey = condition.fields[0];
|
|
586
842
|
const evaluator_2: ClinicalPathway_FieldEvaluator_$union = condition.fields[3];
|
|
587
843
|
const conditionValue_1: Shared_ConditionValue_$union = condition.fields[4];
|
|
588
|
-
const optionValueOpt: Option<string> = (formSpec == null) ? undefined : bind<Spec_FormField$1<
|
|
589
|
-
const fieldType =
|
|
590
|
-
return
|
|
591
|
-
},
|
|
592
|
-
const
|
|
844
|
+
const optionValueOpt: Option<string> = (formSpec == null) ? undefined : bind<Spec_FormField$1<Spec_FieldType_$union>, string>((field_5: Spec_FormField$1<Spec_FieldType_$union>): Option<string> => {
|
|
845
|
+
const fieldType = field_5.FieldType as Spec_FieldType_$union;
|
|
846
|
+
return map_3<Shared_FieldOption, string>((opt_1: Shared_FieldOption): string => opt_1.Value, tryFind<Shared_FieldOption>((opt: Shared_FieldOption): boolean => 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 : empty<Shared_FieldOption>()))))));
|
|
847
|
+
}, tryFind<Spec_FormField$1<Spec_FieldType_$union>>((field_4: Spec_FormField$1<Spec_FieldType_$union>): boolean => equals(field_4.FieldKey, fieldKey_2), collect<Spec_FormStep$1<Spec_FieldType_$union>, Spec_FormField$1<Spec_FieldType_$union>>((step_2: Spec_FormStep$1<Spec_FieldType_$union>): FSharpList<Spec_FormField$1<Spec_FieldType_$union>> => step_2.Fields, value_3(formSpec).Steps)));
|
|
848
|
+
const matchValue_4: Option<string> = tryFind_1<Shared_FieldKey, string>(fieldKey_2, fieldValues);
|
|
593
849
|
if (optionValueOpt == null) {
|
|
594
|
-
const guid_1: string = optionKey.fields[0];
|
|
595
|
-
console.error(some("[evaluateTransition] FieldOptionCondition: Could not find option in formSpec for optionKey:"), guid_1);
|
|
596
850
|
return TransitionStatus_Failed();
|
|
597
851
|
}
|
|
598
|
-
else if (
|
|
599
|
-
return TransitionStatus_Pending(singleton(
|
|
852
|
+
else if (matchValue_4 == null) {
|
|
853
|
+
return TransitionStatus_Pending(singleton(fieldKey_2.fields[0]));
|
|
600
854
|
}
|
|
601
855
|
else {
|
|
602
|
-
const actualValueStr_1: string = value_3(
|
|
856
|
+
const actualValueStr_1: string = value_3(matchValue_4);
|
|
603
857
|
const optionValue: string = value_3(optionValueOpt);
|
|
604
|
-
const actualValues: FSharpSet<string> = ofArray<string>(
|
|
858
|
+
const actualValues: FSharpSet<string> = ofArray<string>(map_2<string, string>((s: string): string => s.trim().toLocaleLowerCase(), actualValueStr_1.split(",")), {
|
|
605
859
|
Compare: comparePrimitives,
|
|
606
860
|
});
|
|
607
861
|
const containsOption: boolean = contains<string>(optionValue.trim().toLocaleLowerCase(), actualValues);
|
|
@@ -646,18 +900,56 @@ export function evaluateTransitionWithPartialData<FieldType>(resolver: ((arg0: s
|
|
|
646
900
|
}
|
|
647
901
|
case /* PluginPropertyCondition */ 2: {
|
|
648
902
|
const propertyKey: Shared_PluginPropertyKey = condition.fields[1];
|
|
649
|
-
const
|
|
903
|
+
const fieldKey_3: Shared_FieldKey = condition.fields[0];
|
|
650
904
|
const evaluator_3: ClinicalPathway_FieldEvaluator_$union = condition.fields[2];
|
|
651
905
|
const conditionValue_2: Shared_ConditionValue_$union = condition.fields[3];
|
|
652
|
-
const
|
|
653
|
-
if (
|
|
654
|
-
return TransitionStatus_Pending(singleton(
|
|
906
|
+
const matchValue_6: Option<string> = tryFind_1<Shared_FieldKey, string>(fieldKey_3, fieldValues);
|
|
907
|
+
if (matchValue_6 == null) {
|
|
908
|
+
return TransitionStatus_Pending(singleton(fieldKey_3.fields[0]));
|
|
655
909
|
}
|
|
656
910
|
else {
|
|
657
|
-
const actualValueStr_2: string = value_3(
|
|
911
|
+
const actualValueStr_2: string = value_3(matchValue_6);
|
|
658
912
|
try {
|
|
659
|
-
const
|
|
660
|
-
|
|
913
|
+
const pluginIdOpt: Option<string> = filter<string>((id: string): boolean => !isNullOrEmpty(id), bind<Spec_FormSpec$1<Spec_FieldType_$union>, string>((spec_4: Spec_FormSpec$1<Spec_FieldType_$union>): Option<string> => map_3<Spec_FormField$1<Spec_FieldType_$union>, string>((f_1: Spec_FormField$1<Spec_FieldType_$union>): string => {
|
|
914
|
+
const ft = f_1.FieldType as Spec_FieldType_$union;
|
|
915
|
+
switch (ft.tag) {
|
|
916
|
+
case /* PluginField */ 22:
|
|
917
|
+
return ft.fields[0].PluginId;
|
|
918
|
+
case /* Matrix */ 19:
|
|
919
|
+
return "Fable.Form.Simple.Bulma.Fields.LikertField";
|
|
920
|
+
default:
|
|
921
|
+
return "";
|
|
922
|
+
}
|
|
923
|
+
}, tryFind<Spec_FormField$1<Spec_FieldType_$union>>((f: Spec_FormField$1<Spec_FieldType_$union>): boolean => equals(f.FieldKey, fieldKey_3), collect<Spec_FormStep$1<Spec_FieldType_$union>, Spec_FormField$1<Spec_FieldType_$union>>((s_1: Spec_FormStep$1<Spec_FieldType_$union>): FSharpList<Spec_FormField$1<Spec_FieldType_$union>> => s_1.Fields, spec_4.Steps))), formSpec));
|
|
924
|
+
return evaluateFieldCondition((pluginIdOpt == null) ? actualValueStr_2 : defaultArg(bind<IPluginValueConverter, string>((converter: IPluginValueConverter): Option<string> => map_3<Shared_PluginDataProperty, string>((propMeta: Shared_PluginDataProperty): string => {
|
|
925
|
+
if (propMeta.Name === "TotalScore") {
|
|
926
|
+
return int32ToString(sum_1<int32>(choose_1<string, int32>((s_2: string): Option<int32> => {
|
|
927
|
+
let matchValue_7: [boolean, int32];
|
|
928
|
+
let outArg = 0;
|
|
929
|
+
matchValue_7 = ([tryParse_1(s_2.trim(), 511, false, 32, new FSharpRef<int32>((): int32 => outArg, (v_2: int32): void => {
|
|
930
|
+
outArg = (v_2 | 0);
|
|
931
|
+
})), outArg] as [boolean, int32]);
|
|
932
|
+
if (matchValue_7[0]) {
|
|
933
|
+
return matchValue_7[1];
|
|
934
|
+
}
|
|
935
|
+
else {
|
|
936
|
+
return undefined;
|
|
937
|
+
}
|
|
938
|
+
}, actualValueStr_2.split(",")), {
|
|
939
|
+
GetZero: (): int32 => 0,
|
|
940
|
+
Add: (x_1: int32, y_1: int32): int32 => (x_1 + y_1),
|
|
941
|
+
}));
|
|
942
|
+
}
|
|
943
|
+
else {
|
|
944
|
+
const matchValue_8: FSharpResult$2_$union<FSharpList<Shared_PluginDataProperty>, string> = fromString<FSharpList<Shared_PluginDataProperty>>(uncurry2(Auto_generateBoxedDecoder_Z6670B51(list_type(Shared_PluginDataProperty_$reflection()), undefined, undefined)), actualValueStr_2);
|
|
945
|
+
if (matchValue_8.tag === /* Error */ 1) {
|
|
946
|
+
return actualValueStr_2;
|
|
947
|
+
}
|
|
948
|
+
else {
|
|
949
|
+
return defaultArg(map_3<Shared_PluginDataProperty, string>((p_1: Shared_PluginDataProperty): string => p_1.Value, tryFind<Shared_PluginDataProperty>((p: Shared_PluginDataProperty): boolean => equals(p.PropertyKey, propertyKey), matchValue_8.fields[0])), actualValueStr_2);
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
}, converter.GetPropertyMetadataByKey(propertyKey)), PluginValueRegistry_tryGet(value_3(pluginIdOpt))), actualValueStr_2), evaluator_3, (conditionValue_2.tag === /* Multiple */ 1) ? join(",", toList<string>(conditionValue_2.fields[0])) : ((conditionValue_2.tag === /* Matrix */ 2) ? join(",", map<[Shared_MatrixItemKey, string], string>((tupledArg_1: [Shared_MatrixItemKey, string]): string => tupledArg_1[1], toList_1<Shared_MatrixItemKey, string>(conditionValue_2.fields[0]))) : ((conditionValue_2.tag === /* PluginData */ 3) ? "" : conditionValue_2.fields[0]))) ? TransitionStatus_Satisfied() : TransitionStatus_Failed();
|
|
661
953
|
}
|
|
662
954
|
catch (ex: any) {
|
|
663
955
|
return TransitionStatus_Failed();
|
|
@@ -673,7 +965,7 @@ export function evaluateTransitionWithPartialData<FieldType>(resolver: ((arg0: s
|
|
|
673
965
|
* Find a state by key
|
|
674
966
|
*/
|
|
675
967
|
export function findState(stateKey: Shared_StateKey, states: FSharpList<ClinicalPathway_StateDefinition>): Option<ClinicalPathway_StateDefinition> {
|
|
676
|
-
return
|
|
968
|
+
return tryFind<ClinicalPathway_StateDefinition>((s: ClinicalPathway_StateDefinition): boolean => equals(s.StateKey, stateKey), states);
|
|
677
969
|
}
|
|
678
970
|
|
|
679
971
|
/**
|
|
@@ -710,38 +1002,26 @@ export function isTerminalState(state: ClinicalPathway_StateDefinition): boolean
|
|
|
710
1002
|
/**
|
|
711
1003
|
* Evaluate all transitions from current states
|
|
712
1004
|
*/
|
|
713
|
-
export function evaluateAllTransitions<FieldType>(context: ExecutionContext
|
|
714
|
-
const fieldValues: FSharpMap<Shared_FieldKey, string> = FieldResolver_extractFieldValues
|
|
715
|
-
console.log(some("[evaluateAllTransitions] Extracted field values:"), fieldValues);
|
|
716
|
-
console.log(some("[evaluateAllTransitions] Current states in context:"), context.CurrentStates);
|
|
717
|
-
console.log(some("[evaluateAllTransitions] All transitions in pathway:"), context.PathwaySpec.Transitions);
|
|
718
|
-
const transitionsFromCurrentStates: FSharpList<ClinicalPathway_TransitionDefinition> = filter<ClinicalPathway_TransitionDefinition>((t: ClinicalPathway_TransitionDefinition): boolean => {
|
|
719
|
-
const isFromCurrentState: boolean = contains<Shared_StateKey>(t.FromState, context.CurrentStates);
|
|
720
|
-
console.log(some("[evaluateAllTransitions] Transition from"), t.FromState, "to", t.ToState, "FromCurrentState=", isFromCurrentState);
|
|
721
|
-
return isFromCurrentState;
|
|
722
|
-
}, context.PathwaySpec.Transitions);
|
|
723
|
-
console.log(some("[evaluateAllTransitions] Transitions from current states:"), transitionsFromCurrentStates);
|
|
1005
|
+
export function evaluateAllTransitions<FieldType>(context: ExecutionContext): FSharpList<MatchedTransition> {
|
|
1006
|
+
const fieldValues: FSharpMap<Shared_FieldKey, string> = FieldResolver_extractFieldValues(context.FieldResolver, context.FormSpec);
|
|
724
1007
|
return map<ClinicalPathway_TransitionDefinition, MatchedTransition>((transition: ClinicalPathway_TransitionDefinition): MatchedTransition => {
|
|
725
|
-
|
|
726
|
-
console.log(some("[evaluateAllTransitions] Transition condition:"), transition.Condition);
|
|
727
|
-
const status: TransitionStatus_$union = evaluateTransitionWithPartialData<FieldType>(context.FieldResolver, context.FormSpec, fieldValues, context.VisitedStates, transition.Condition);
|
|
728
|
-
console.log(some("[evaluateAllTransitions] Transition status:"), status);
|
|
1008
|
+
const status: TransitionStatus_$union = evaluateTransitionWithPartialData(context.FieldResolver, context.FormSpec, fieldValues, context.VisitedStates, context.FormSpec, transition.Condition);
|
|
729
1009
|
return new MatchedTransition(transition, defaultArg(transition.Priority, 999), status);
|
|
730
|
-
},
|
|
1010
|
+
}, filter_1<ClinicalPathway_TransitionDefinition>((t: ClinicalPathway_TransitionDefinition): boolean => contains<Shared_StateKey>(t.FromState, context.CurrentStates), context.PathwaySpec.Transitions));
|
|
731
1011
|
}
|
|
732
1012
|
|
|
733
1013
|
/**
|
|
734
1014
|
* Separate matched transitions into active, pending, and failed
|
|
735
1015
|
*/
|
|
736
1016
|
export function categorizeTransitions(transitions: FSharpList<MatchedTransition>): [FSharpList<MatchedTransition>, FSharpList<MatchedTransition>, FSharpList<MatchedTransition>] {
|
|
737
|
-
return [
|
|
1017
|
+
return [filter_1<MatchedTransition>((t: MatchedTransition): boolean => equals(t.Status, TransitionStatus_Satisfied()), transitions), filter_1<MatchedTransition>((t_1: MatchedTransition): boolean => {
|
|
738
1018
|
if (t_1.Status.tag === /* Pending */ 2) {
|
|
739
1019
|
return true;
|
|
740
1020
|
}
|
|
741
1021
|
else {
|
|
742
1022
|
return false;
|
|
743
1023
|
}
|
|
744
|
-
}, transitions),
|
|
1024
|
+
}, transitions), filter_1<MatchedTransition>((t_2: MatchedTransition): boolean => equals(t_2.Status, TransitionStatus_Failed()), transitions)] as [FSharpList<MatchedTransition>, FSharpList<MatchedTransition>, FSharpList<MatchedTransition>];
|
|
745
1025
|
}
|
|
746
1026
|
|
|
747
1027
|
/**
|
|
@@ -799,7 +1079,7 @@ export function calculateProbability(status: TransitionStatus_$union, totalCondi
|
|
|
799
1079
|
/**
|
|
800
1080
|
* Predict possible outcomes based on current form state
|
|
801
1081
|
*/
|
|
802
|
-
export function predictOutcomes
|
|
1082
|
+
export function predictOutcomes(context: ExecutionContext): FSharpList<PredictedPathway> {
|
|
803
1083
|
return truncate<PredictedPathway>(5, sortByDescending<PredictedPathway, float64>((p: PredictedPathway): float64 => p.Probability, choose<MatchedTransition, PredictedPathway>((matched: MatchedTransition): Option<PredictedPathway> => {
|
|
804
1084
|
const matchValue: TransitionStatus_$union = matched.Status;
|
|
805
1085
|
switch (matchValue.tag) {
|
|
@@ -827,7 +1107,7 @@ export function predictOutcomes<FieldType>(context: ExecutionContext$1<FieldType
|
|
|
827
1107
|
}
|
|
828
1108
|
}
|
|
829
1109
|
}
|
|
830
|
-
}, evaluateAllTransitions<
|
|
1110
|
+
}, evaluateAllTransitions<any>(context)), {
|
|
831
1111
|
Compare: comparePrimitives,
|
|
832
1112
|
}));
|
|
833
1113
|
}
|
|
@@ -835,7 +1115,7 @@ export function predictOutcomes<FieldType>(context: ExecutionContext$1<FieldType
|
|
|
835
1115
|
/**
|
|
836
1116
|
* Calculate completion percentage based on states visited and actions executed
|
|
837
1117
|
*/
|
|
838
|
-
export function calculateCompletionPercentage
|
|
1118
|
+
export function calculateCompletionPercentage(context: ExecutionContext): float64 {
|
|
839
1119
|
const totalStates: float64 = length(context.PathwaySpec.States);
|
|
840
1120
|
if (totalStates === 0) {
|
|
841
1121
|
return 0;
|
|
@@ -848,7 +1128,7 @@ export function calculateCompletionPercentage<FieldType>(context: ExecutionConte
|
|
|
848
1128
|
/**
|
|
849
1129
|
* Check if pathway execution is complete
|
|
850
1130
|
*/
|
|
851
|
-
export function isExecutionComplete
|
|
1131
|
+
export function isExecutionComplete(context: ExecutionContext): boolean {
|
|
852
1132
|
if (exists<ClinicalPathway_StateDefinition>(isTerminalState, choose<Shared_StateKey, ClinicalPathway_StateDefinition>((sk: Shared_StateKey): Option<ClinicalPathway_StateDefinition> => findState(sk, context.PathwaySpec.States), toList<Shared_StateKey>(context.CurrentStates)))) {
|
|
853
1133
|
return true;
|
|
854
1134
|
}
|
|
@@ -863,49 +1143,49 @@ export function isExecutionComplete<FieldType>(context: ExecutionContext$1<Field
|
|
|
863
1143
|
/**
|
|
864
1144
|
* Initialize execution context from scratch
|
|
865
1145
|
*/
|
|
866
|
-
export function initializeExecution
|
|
1146
|
+
export function initializeExecution(formSpec: Spec_FormSpec$1<Spec_FieldType_$union>): ExecutionContext {
|
|
867
1147
|
const matchValue: Option<ClinicalPathway_ClinicalPathwaySpec> = formSpec.ClinicalPathway;
|
|
868
1148
|
if (matchValue == null) {
|
|
869
1149
|
throw new Error("No clinical pathway found in form spec");
|
|
870
1150
|
}
|
|
871
1151
|
else {
|
|
872
1152
|
const pathway: ClinicalPathway_ClinicalPathwaySpec = value_3(matchValue);
|
|
873
|
-
const resolver: ((arg0: string) => Shared_FieldKey) = FieldResolver_createResolver
|
|
1153
|
+
const resolver: ((arg0: string) => Shared_FieldKey) = FieldResolver_createResolver(formSpec);
|
|
874
1154
|
let initialStates: FSharpList<Shared_StateKey>;
|
|
875
1155
|
const matchValue_1: Option<Shared_StateKey> = pathway.InitialState;
|
|
876
1156
|
if (matchValue_1 == null) {
|
|
877
1157
|
const statesWithIncoming: FSharpSet<Shared_StateKey> = ofList_1<Shared_StateKey>(map<ClinicalPathway_TransitionDefinition, Shared_StateKey>((t: ClinicalPathway_TransitionDefinition): Shared_StateKey => t.ToState, pathway.Transitions), {
|
|
878
1158
|
Compare: compare,
|
|
879
1159
|
});
|
|
880
|
-
const candidates: FSharpList<Shared_StateKey> = map<ClinicalPathway_StateDefinition, Shared_StateKey>((s_1: ClinicalPathway_StateDefinition): Shared_StateKey => s_1.StateKey,
|
|
881
|
-
initialStates = (isEmpty(candidates) ? defaultArg(
|
|
1160
|
+
const candidates: FSharpList<Shared_StateKey> = map<ClinicalPathway_StateDefinition, Shared_StateKey>((s_1: ClinicalPathway_StateDefinition): Shared_StateKey => s_1.StateKey, filter_1<ClinicalPathway_StateDefinition>((s: ClinicalPathway_StateDefinition): boolean => !contains<Shared_StateKey>(s.StateKey, statesWithIncoming), pathway.States));
|
|
1161
|
+
initialStates = (isEmpty(candidates) ? defaultArg(map_3<ClinicalPathway_StateDefinition, FSharpList<Shared_StateKey>>((s_2: ClinicalPathway_StateDefinition): FSharpList<Shared_StateKey> => singleton(s_2.StateKey), tryHead<ClinicalPathway_StateDefinition>(pathway.States)), empty<Shared_StateKey>()) : candidates);
|
|
882
1162
|
}
|
|
883
1163
|
else {
|
|
884
1164
|
initialStates = singleton(value_3(matchValue_1));
|
|
885
1165
|
}
|
|
886
|
-
return new ExecutionContext
|
|
1166
|
+
return new ExecutionContext(pathway, formSpec, ofList_1<Shared_StateKey>(initialStates, {
|
|
887
1167
|
Compare: compare,
|
|
888
1168
|
}), ofList_1<Shared_StateKey>(initialStates, {
|
|
889
1169
|
Compare: compare,
|
|
890
1170
|
}), empty_1<Shared_StateKey>({
|
|
891
1171
|
Compare: compare,
|
|
892
|
-
}), empty<MatchedTransition>(), empty<MatchedTransition>(), empty<ClinicalPathway_ActionInfo_$union>(),
|
|
1172
|
+
}), empty<MatchedTransition>(), empty<MatchedTransition>(), empty<ClinicalPathway_ActionInfo_$union>(), resolver, map<Shared_StateKey, ExecutionLogEntry>((stateKey: Shared_StateKey): ExecutionLogEntry => (new ExecutionLogEntry(now(), stateKey, "Initialized", "Starting state")), initialStates));
|
|
893
1173
|
}
|
|
894
1174
|
}
|
|
895
1175
|
|
|
896
1176
|
/**
|
|
897
1177
|
* Resolve field value source to actual string value
|
|
898
1178
|
*/
|
|
899
|
-
export function resolveFieldValueSource
|
|
1179
|
+
export function resolveFieldValueSource(valueSource: ClinicalPathway_FieldValueSource_$union, formSpec: Spec_FormSpec$1<Spec_FieldType_$union>): string {
|
|
900
1180
|
switch (valueSource.tag) {
|
|
901
1181
|
case /* FieldReference */ 1:
|
|
902
|
-
return defaultArg(
|
|
1182
|
+
return defaultArg(tryFind_1<Shared_FieldKey, string>(valueSource.fields[0], FieldResolver_extractFieldValues(FieldResolver_createResolver(formSpec), formSpec)), "");
|
|
903
1183
|
case /* OptionKey */ 2: {
|
|
904
1184
|
const optionKey: Shared_FieldOptionKey = valueSource.fields[0];
|
|
905
|
-
return defaultArg(tryPick<Spec_FormField$1<
|
|
1185
|
+
return defaultArg(tryPick<Spec_FormField$1<Spec_FieldType_$union>, string>((field: Spec_FormField$1<Spec_FieldType_$union>): Option<string> => {
|
|
906
1186
|
const fieldType = field.FieldType as Spec_FieldType_$union;
|
|
907
|
-
return
|
|
908
|
-
}, collect<Spec_FormStep$1<
|
|
1187
|
+
return map_3<Shared_FieldOption, string>((opt_1: Shared_FieldOption): string => opt_1.Description, tryFind<Shared_FieldOption>((opt: Shared_FieldOption): boolean => equals(opt.OptionKey, 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 : empty<Shared_FieldOption>()))))));
|
|
1188
|
+
}, collect<Spec_FormStep$1<Spec_FieldType_$union>, Spec_FormField$1<Spec_FieldType_$union>>((step: Spec_FormStep$1<Spec_FieldType_$union>): FSharpList<Spec_FormField$1<Spec_FieldType_$union>> => step.Fields, formSpec.Steps)), "");
|
|
909
1189
|
}
|
|
910
1190
|
default:
|
|
911
1191
|
return valueSource.fields[0];
|
|
@@ -913,87 +1193,84 @@ export function resolveFieldValueSource<FieldType>(valueSource: ClinicalPathway_
|
|
|
913
1193
|
}
|
|
914
1194
|
|
|
915
1195
|
/**
|
|
916
|
-
* Execute SetFieldValue action and update form
|
|
1196
|
+
* Execute SetFieldValue action and update form spec
|
|
917
1197
|
*/
|
|
918
|
-
export function executeSetFieldValueAction
|
|
919
|
-
let matchValue: Option<ClinicalPathway_TransitionCondition_$union>, condition: ClinicalPathway_TransitionCondition_$union, fieldValues: FSharpMap<Shared_FieldKey, string
|
|
920
|
-
if (!((matchValue = action.Condition, (matchValue == null) ? true : ((condition = value_3(matchValue), (fieldValues = FieldResolver_extractFieldValues
|
|
1198
|
+
export function executeSetFieldValueAction(action: ClinicalPathway_SetFieldValueAction, formSpec: Spec_FormSpec$1<Spec_FieldType_$union>): Spec_FormSpec$1<Spec_FieldType_$union> {
|
|
1199
|
+
let matchValue: Option<ClinicalPathway_TransitionCondition_$union>, condition: ClinicalPathway_TransitionCondition_$union, fieldValues: FSharpMap<Shared_FieldKey, string>;
|
|
1200
|
+
if (!((matchValue = action.Condition, (matchValue == null) ? true : ((condition = value_3(matchValue), (fieldValues = FieldResolver_extractFieldValues(FieldResolver_createResolver(formSpec), formSpec), evaluateTransitionWithPartialData(FieldResolver_createResolver(formSpec), formSpec, fieldValues, empty_1<Shared_StateKey>({
|
|
921
1201
|
Compare: compare,
|
|
922
|
-
}), condition).tag === /* Satisfied */ 0)))))) {
|
|
923
|
-
return
|
|
1202
|
+
}), formSpec, condition).tag === /* Satisfied */ 0)))))) {
|
|
1203
|
+
return formSpec;
|
|
924
1204
|
}
|
|
925
1205
|
else {
|
|
926
|
-
const valueToSet: string = resolveFieldValueSource
|
|
927
|
-
const targetFieldOpt: Option<Spec_FormField$1<
|
|
1206
|
+
const valueToSet: string = resolveFieldValueSource(action.Value, formSpec);
|
|
1207
|
+
const targetFieldOpt: Option<Spec_FormField$1<Spec_FieldType_$union>> = tryFind<Spec_FormField$1<Spec_FieldType_$union>>((field: Spec_FormField$1<Spec_FieldType_$union>): boolean => equals(field.FieldKey, action.TargetField), collect<Spec_FormStep$1<Spec_FieldType_$union>, Spec_FormField$1<Spec_FieldType_$union>>((step: Spec_FormStep$1<Spec_FieldType_$union>): FSharpList<Spec_FormField$1<Spec_FieldType_$union>> => step.Fields, formSpec.Steps));
|
|
928
1208
|
if (targetFieldOpt == null) {
|
|
929
|
-
return
|
|
1209
|
+
return formSpec;
|
|
930
1210
|
}
|
|
931
1211
|
else {
|
|
932
|
-
const targetField: Spec_FormField$1<
|
|
933
|
-
const stepOpt: Option<Spec_FormStep$1<
|
|
1212
|
+
const targetField: Spec_FormField$1<Spec_FieldType_$union> = value_3(targetFieldOpt);
|
|
1213
|
+
const stepOpt: Option<Spec_FormStep$1<Spec_FieldType_$union>> = tryFind<Spec_FormStep$1<Spec_FieldType_$union>>((step_1: Spec_FormStep$1<Spec_FieldType_$union>): boolean => exists<Spec_FormField$1<Spec_FieldType_$union>>((f: Spec_FormField$1<Spec_FieldType_$union>): boolean => equals(f.FieldKey, action.TargetField), step_1.Fields), formSpec.Steps);
|
|
934
1214
|
if (stepOpt == null) {
|
|
935
|
-
return
|
|
1215
|
+
return formSpec;
|
|
936
1216
|
}
|
|
937
1217
|
else {
|
|
938
|
-
const
|
|
939
|
-
|
|
940
|
-
return new Values_DynamicFormResultData$1(formData.ResultFormSpecDetails, FSharpMap__Add(formData.ResultSteps, stepOrder, FSharpMap__Add(defaultArg(tryFind<Values_StepOrder, FSharpMap<Shared_FieldKey, Values_FieldDetails$1<FieldType>>>(stepOrder, formData.ResultSteps), empty_2<Shared_FieldKey, Values_FieldDetails$1<FieldType>>({
|
|
941
|
-
Compare: compare,
|
|
942
|
-
})), action.TargetField, (fieldType = (targetField.FieldType as Spec_FieldType_$union), new Values_FieldDetails$1(targetField.FieldOrder, action.TargetField, targetField.Label, Shared_FieldValue_Single(fieldAnswer), targetField.FieldType, map<Shared_FieldOption, Shared_FieldOption>((opt: Shared_FieldOption): Shared_FieldOption => (new 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 : empty<Shared_FieldOption>()))))))))));
|
|
1218
|
+
const step_2: Spec_FormStep$1<Spec_FieldType_$union> = value_3(stepOpt);
|
|
1219
|
+
return updateField<Spec_FieldType_$union>(formSpec, action.TargetField, Shared_FieldValue_Single(new Shared_FieldAnswer(action.TargetField, targetField.Label, valueToSet)), findIndex<Spec_FormStep$1<Spec_FieldType_$union>>((s: Spec_FormStep$1<Spec_FieldType_$union>): boolean => (s.StepOrder === step_2.StepOrder), formSpec.Steps));
|
|
943
1220
|
}
|
|
944
1221
|
}
|
|
945
1222
|
}
|
|
946
1223
|
}
|
|
947
1224
|
|
|
948
1225
|
/**
|
|
949
|
-
* Execute an action and return updated form
|
|
1226
|
+
* Execute an action and return updated form spec
|
|
950
1227
|
*/
|
|
951
|
-
export function executeAction
|
|
1228
|
+
export function executeAction(action: ClinicalPathway_ActionInfo_$union, formSpec: Spec_FormSpec$1<Spec_FieldType_$union>): Spec_FormSpec$1<Spec_FieldType_$union> {
|
|
952
1229
|
if (action.tag === /* SetFieldValue */ 10) {
|
|
953
|
-
return executeSetFieldValueAction
|
|
1230
|
+
return executeSetFieldValueAction(action.fields[0], formSpec);
|
|
954
1231
|
}
|
|
955
1232
|
else {
|
|
956
|
-
return
|
|
1233
|
+
return formSpec;
|
|
957
1234
|
}
|
|
958
1235
|
}
|
|
959
1236
|
|
|
960
1237
|
/**
|
|
961
|
-
* Execute all actions from a list and return updated form
|
|
1238
|
+
* Execute all actions from a list and return updated form spec
|
|
962
1239
|
*/
|
|
963
|
-
export function executeActions
|
|
964
|
-
return fold<ClinicalPathway_ActionInfo_$union,
|
|
1240
|
+
export function executeActions(actions: FSharpList<ClinicalPathway_ActionInfo_$union>, formSpec: Spec_FormSpec$1<Spec_FieldType_$union>): Spec_FormSpec$1<Spec_FieldType_$union> {
|
|
1241
|
+
return fold<ClinicalPathway_ActionInfo_$union, Spec_FormSpec$1<Spec_FieldType_$union>>((currentSpec: Spec_FormSpec$1<Spec_FieldType_$union>, action: ClinicalPathway_ActionInfo_$union): Spec_FormSpec$1<Spec_FieldType_$union> => executeAction(action, currentSpec), formSpec, actions);
|
|
965
1242
|
}
|
|
966
1243
|
|
|
967
1244
|
/**
|
|
968
1245
|
* Execute one step of the pathway (incremental execution)
|
|
969
1246
|
*/
|
|
970
|
-
export function executeStep
|
|
1247
|
+
export function executeStep(context_mut: ExecutionContext, maxIterations_mut: int32): ExecutionContext {
|
|
971
1248
|
executeStep:
|
|
972
1249
|
while (true) {
|
|
973
|
-
const context: ExecutionContext
|
|
1250
|
+
const context: ExecutionContext = context_mut, maxIterations: int32 = maxIterations_mut;
|
|
974
1251
|
if (maxIterations <= 0) {
|
|
975
1252
|
return context;
|
|
976
1253
|
}
|
|
977
1254
|
else {
|
|
978
|
-
const patternInput: [FSharpList<MatchedTransition>, FSharpList<MatchedTransition>, FSharpList<MatchedTransition>] = categorizeTransitions(evaluateAllTransitions<
|
|
1255
|
+
const patternInput: [FSharpList<MatchedTransition>, FSharpList<MatchedTransition>, FSharpList<MatchedTransition>] = categorizeTransitions(evaluateAllTransitions<any>(context));
|
|
979
1256
|
const pending: FSharpList<MatchedTransition> = patternInput[1];
|
|
980
1257
|
const active: FSharpList<MatchedTransition> = patternInput[0];
|
|
981
1258
|
const selectedTransitions: FSharpList<MatchedTransition> = selectTransitionsByMode(context.PathwaySpec.ExecutionMode, active);
|
|
982
1259
|
if (isEmpty(selectedTransitions)) {
|
|
983
|
-
return new ExecutionContext
|
|
1260
|
+
return new ExecutionContext(context.PathwaySpec, context.FormSpec, context.CurrentStates, context.VisitedStates, context.CompletedStates, active, pending, context.ExecutedActions, context.FieldResolver, context.ExecutionLog);
|
|
984
1261
|
}
|
|
985
1262
|
else {
|
|
986
1263
|
const newStates: FSharpSet<Shared_StateKey> = ofList_1<Shared_StateKey>(map<MatchedTransition, Shared_StateKey>((t: MatchedTransition): Shared_StateKey => t.Transition.ToState, selectedTransitions), {
|
|
987
1264
|
Compare: compare,
|
|
988
1265
|
});
|
|
989
1266
|
const newActions: FSharpList<ClinicalPathway_ActionInfo_$union> = collect<ClinicalPathway_StateDefinition, ClinicalPathway_ActionInfo_$union>(extractActionsFromState, choose<Shared_StateKey, ClinicalPathway_StateDefinition>((sk: Shared_StateKey): Option<ClinicalPathway_StateDefinition> => findState(sk, context.PathwaySpec.States), toList<Shared_StateKey>(newStates)));
|
|
990
|
-
const
|
|
1267
|
+
const updatedFormSpec: Spec_FormSpec$1<Spec_FieldType_$union> = executeActions(newActions, context.FormSpec);
|
|
991
1268
|
const newLogEntries: FSharpList<ExecutionLogEntry> = map<MatchedTransition, ExecutionLogEntry>((t_1: MatchedTransition): ExecutionLogEntry => {
|
|
992
1269
|
let arg: string, arg_1: string;
|
|
993
1270
|
return new ExecutionLogEntry(now(), t_1.Transition.ToState, "Transitioned", (arg = t_1.Transition.FromState.fields[0], (arg_1 = t_1.Transition.TransitionKey.fields[0], toText(printf("From %s via %s"))(arg)(arg_1))));
|
|
994
1271
|
}, selectedTransitions);
|
|
995
|
-
const updatedContext: ExecutionContext
|
|
996
|
-
if (isExecutionComplete
|
|
1272
|
+
const updatedContext: ExecutionContext = new ExecutionContext(context.PathwaySpec, updatedFormSpec, newStates, union<Shared_StateKey>(context.VisitedStates, newStates), union<Shared_StateKey>(context.CompletedStates, context.CurrentStates), active, pending, append(context.ExecutedActions, newActions), context.FieldResolver, append(context.ExecutionLog, newLogEntries));
|
|
1273
|
+
if (isExecutionComplete(updatedContext)) {
|
|
997
1274
|
return updatedContext;
|
|
998
1275
|
}
|
|
999
1276
|
else {
|
|
@@ -1010,31 +1287,31 @@ export function executeStep<FieldType>(context_mut: ExecutionContext$1<FieldType
|
|
|
1010
1287
|
/**
|
|
1011
1288
|
* Process incremental updates as form fills
|
|
1012
1289
|
*/
|
|
1013
|
-
export function executeIncremental
|
|
1290
|
+
export function executeIncremental(context: ExecutionContext, formSpec: Spec_FormSpec$1<Spec_FieldType_$union>): IncrementalExecutionResult {
|
|
1014
1291
|
let previousTransitionKeys: FSharpSet<Shared_TransitionKey>, newKeys: FSharpSet<Shared_TransitionKey>;
|
|
1015
1292
|
const startingAtTerminal: boolean = exists<ClinicalPathway_StateDefinition>(isTerminalState, choose<Shared_StateKey, ClinicalPathway_StateDefinition>((sk: Shared_StateKey): Option<ClinicalPathway_StateDefinition> => findState(sk, context.PathwaySpec.States), toList<Shared_StateKey>(context.CurrentStates)));
|
|
1016
|
-
const updatedContext: ExecutionContext
|
|
1017
|
-
const newContext: ExecutionContext
|
|
1018
|
-
return new IncrementalExecutionResult
|
|
1293
|
+
const updatedContext: ExecutionContext = new ExecutionContext(context.PathwaySpec, formSpec, context.CurrentStates, context.VisitedStates, context.CompletedStates, context.ActiveTransitions, context.PendingTransitions, context.ExecutedActions, context.FieldResolver, context.ExecutionLog);
|
|
1294
|
+
const newContext: ExecutionContext = executeStep(updatedContext, 100);
|
|
1295
|
+
return new IncrementalExecutionResult(newContext, map<Shared_StateKey, string>((_arg: Shared_StateKey): string => _arg.fields[0], toList<Shared_StateKey>(difference<Shared_StateKey>(newContext.CurrentStates, updatedContext.CurrentStates))), (previousTransitionKeys = ofList_1<Shared_TransitionKey>(map<MatchedTransition, Shared_TransitionKey>((t: MatchedTransition): Shared_TransitionKey => t.Transition.TransitionKey, updatedContext.ActiveTransitions), {
|
|
1019
1296
|
Compare: compare,
|
|
1020
1297
|
}), (newKeys = difference<Shared_TransitionKey>(ofList_1<Shared_TransitionKey>(map<MatchedTransition, Shared_TransitionKey>((t_1: MatchedTransition): Shared_TransitionKey => t_1.Transition.TransitionKey, newContext.ActiveTransitions), {
|
|
1021
1298
|
Compare: compare,
|
|
1022
|
-
}), previousTransitionKeys), map<MatchedTransition, ClinicalPathway_TransitionDefinition>((t_3: MatchedTransition): ClinicalPathway_TransitionDefinition => t_3.Transition,
|
|
1299
|
+
}), previousTransitionKeys), map<MatchedTransition, ClinicalPathway_TransitionDefinition>((t_3: MatchedTransition): ClinicalPathway_TransitionDefinition => t_3.Transition, filter_1<MatchedTransition>((t_2: MatchedTransition): boolean => contains<Shared_TransitionKey>(t_2.Transition.TransitionKey, newKeys), newContext.ActiveTransitions)))), predictOutcomes(newContext), calculateCompletionPercentage(newContext), isExecutionComplete(newContext));
|
|
1023
1300
|
}
|
|
1024
1301
|
|
|
1025
1302
|
/**
|
|
1026
1303
|
* Get visualization state from execution context
|
|
1027
1304
|
*/
|
|
1028
|
-
export function getVisualizationState
|
|
1305
|
+
export function getVisualizationState(context: ExecutionContext): VisualizationState {
|
|
1029
1306
|
const patternInput: [FSharpList<MatchedTransition>, FSharpList<MatchedTransition>, FSharpList<MatchedTransition>] = categorizeTransitions(context.ActiveTransitions);
|
|
1030
|
-
const completedTransitions: FSharpList<string> = map<ExecutionLogEntry, string>((log_1: ExecutionLogEntry): string => log_1.Details,
|
|
1031
|
-
return new VisualizationState(context.CurrentStates, context.VisitedStates, map<MatchedTransition, Shared_TransitionKey>((t: MatchedTransition): Shared_TransitionKey => t.Transition.TransitionKey, patternInput[0]), map<MatchedTransition, Shared_TransitionKey>((t_1: MatchedTransition): Shared_TransitionKey => t_1.Transition.TransitionKey, patternInput[1]), completedTransitions, predictOutcomes
|
|
1307
|
+
const completedTransitions: FSharpList<string> = map<ExecutionLogEntry, string>((log_1: ExecutionLogEntry): string => log_1.Details, filter_1<ExecutionLogEntry>((log: ExecutionLogEntry): boolean => (log.Action === "Transitioned"), context.ExecutionLog));
|
|
1308
|
+
return new VisualizationState(context.CurrentStates, context.VisitedStates, map<MatchedTransition, Shared_TransitionKey>((t: MatchedTransition): Shared_TransitionKey => t.Transition.TransitionKey, patternInput[0]), map<MatchedTransition, Shared_TransitionKey>((t_1: MatchedTransition): Shared_TransitionKey => t_1.Transition.TransitionKey, patternInput[1]), completedTransitions, predictOutcomes(context));
|
|
1032
1309
|
}
|
|
1033
1310
|
|
|
1034
1311
|
/**
|
|
1035
1312
|
* Extract final clinical plans from execution context
|
|
1036
1313
|
*/
|
|
1037
|
-
export function extractClinicalPlans
|
|
1314
|
+
export function extractClinicalPlans(context: ExecutionContext): FSharpList<ClinicalPlan> {
|
|
1038
1315
|
return sortBy<ClinicalPlan, int32>((plan: ClinicalPlan): int32 => plan.Priority, choose<Shared_StateKey, ClinicalPlan>((stateKey: Shared_StateKey): Option<ClinicalPlan> => {
|
|
1039
1316
|
const matchValue: Option<ClinicalPathway_StateDefinition> = findState(stateKey, context.PathwaySpec.States);
|
|
1040
1317
|
let matchResult: int32, state_1: ClinicalPathway_StateDefinition;
|
|
@@ -1073,11 +1350,11 @@ export class PathwayExecutionResult$1<FieldType> extends Record implements IEqua
|
|
|
1073
1350
|
readonly ExecutedActions: FSharpList<ClinicalPathway_ActionInfo_$union>;
|
|
1074
1351
|
readonly VisitedStates: FSharpList<string>;
|
|
1075
1352
|
readonly TransitionsUsed: FSharpList<string>;
|
|
1076
|
-
readonly
|
|
1353
|
+
readonly FormSpec: Spec_FormSpec$1<FieldType>;
|
|
1077
1354
|
readonly ExecutionTime: Date;
|
|
1078
1355
|
readonly Success: boolean;
|
|
1079
1356
|
readonly Errors: FSharpList<string>;
|
|
1080
|
-
constructor(PathwayId: string, StartState: string, CurrentState: string, ExecutionMode: ClinicalPathway_PathwayExecutionMode_$union, SelectedPaths: FSharpList<string>, RejectedPaths: FSharpList<[string, string]>, ExecutedActions: FSharpList<ClinicalPathway_ActionInfo_$union>, VisitedStates: FSharpList<string>, TransitionsUsed: FSharpList<string>,
|
|
1357
|
+
constructor(PathwayId: string, StartState: string, CurrentState: string, ExecutionMode: ClinicalPathway_PathwayExecutionMode_$union, SelectedPaths: FSharpList<string>, RejectedPaths: FSharpList<[string, string]>, ExecutedActions: FSharpList<ClinicalPathway_ActionInfo_$union>, VisitedStates: FSharpList<string>, TransitionsUsed: FSharpList<string>, FormSpec: Spec_FormSpec$1<FieldType>, ExecutionTime: Date, Success: boolean, Errors: FSharpList<string>) {
|
|
1081
1358
|
super();
|
|
1082
1359
|
this.PathwayId = PathwayId;
|
|
1083
1360
|
this.StartState = StartState;
|
|
@@ -1088,7 +1365,7 @@ export class PathwayExecutionResult$1<FieldType> extends Record implements IEqua
|
|
|
1088
1365
|
this.ExecutedActions = ExecutedActions;
|
|
1089
1366
|
this.VisitedStates = VisitedStates;
|
|
1090
1367
|
this.TransitionsUsed = TransitionsUsed;
|
|
1091
|
-
this.
|
|
1368
|
+
this.FormSpec = FormSpec;
|
|
1092
1369
|
this.ExecutionTime = ExecutionTime;
|
|
1093
1370
|
this.Success = Success;
|
|
1094
1371
|
this.Errors = Errors;
|
|
@@ -1096,7 +1373,7 @@ export class PathwayExecutionResult$1<FieldType> extends Record implements IEqua
|
|
|
1096
1373
|
}
|
|
1097
1374
|
|
|
1098
1375
|
export function PathwayExecutionResult$1_$reflection(gen0: TypeInfo): TypeInfo {
|
|
1099
|
-
return record_type("F1.Studio.PathwayExecutor.PathwayExecutionResult`1", [gen0], PathwayExecutionResult$1, () => [["PathwayId", string_type], ["StartState", string_type], ["CurrentState", string_type], ["ExecutionMode", ClinicalPathway_PathwayExecutionMode_$reflection()], ["SelectedPaths", list_type(string_type)], ["RejectedPaths", list_type(tuple_type(string_type, string_type))], ["ExecutedActions", list_type(ClinicalPathway_ActionInfo_$reflection())], ["VisitedStates", list_type(string_type)], ["TransitionsUsed", list_type(string_type)], ["
|
|
1376
|
+
return record_type("F1.Studio.PathwayExecutor.PathwayExecutionResult`1", [gen0], PathwayExecutionResult$1, () => [["PathwayId", string_type], ["StartState", string_type], ["CurrentState", string_type], ["ExecutionMode", ClinicalPathway_PathwayExecutionMode_$reflection()], ["SelectedPaths", list_type(string_type)], ["RejectedPaths", list_type(tuple_type(string_type, string_type))], ["ExecutedActions", list_type(ClinicalPathway_ActionInfo_$reflection())], ["VisitedStates", list_type(string_type)], ["TransitionsUsed", list_type(string_type)], ["FormSpec", Spec_FormSpec$1_$reflection(gen0)], ["ExecutionTime", class_type("System.DateTime")], ["Success", bool_type], ["Errors", list_type(string_type)]]);
|
|
1100
1377
|
}
|
|
1101
1378
|
|
|
1102
1379
|
//# sourceMappingURL=PathwayExecutor.ts.map
|