@f1studio/form-spec 5.0.0-alpha.154 → 5.0.0-alpha.155
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.FS/BitmaskHelpers.d.ts.map +1 -1
- package/FormSpec.FS/FormSpec.d.ts +6 -3
- package/FormSpec.FS/FormSpec.d.ts.map +1 -1
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateMapper.d.ts.map +1 -1
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTriggerConverter.d.ts.map +1 -1
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMREncoder.d.ts +1 -1
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMREncoder.d.ts.map +1 -1
- package/FormSpec.FS/Integrations/Adapters/CorEMR/FormSpecToCoreMRInsert.d.ts +3 -1
- package/FormSpec.FS/Integrations/Adapters/CorEMR/FormSpecToCoreMRInsert.d.ts.map +1 -1
- package/FormSpec.FS/Integrations/CorEMR/ItemTriggerConverter.d.ts.map +1 -1
- package/FormSpec.FS/TriggerActionDto.d.ts +44 -0
- package/FormSpec.FS/TriggerActionDto.d.ts.map +1 -0
- package/FormSpec.TS/FormSpec.FS/BitmaskHelpers.js +1 -1
- package/FormSpec.TS/FormSpec.FS/BitmaskHelpers.js.map +1 -1
- package/FormSpec.TS/FormSpec.FS/FormSpec.js +18 -3
- package/FormSpec.TS/FormSpec.FS/FormSpec.js.map +1 -1
- package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateMapper.js +20 -1
- package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateMapper.js.map +1 -1
- package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTriggerConverter.js +44 -6
- package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTriggerConverter.js.map +1 -1
- package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMREncoder.js +4 -8
- package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMREncoder.js.map +1 -1
- package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/FormSpecToCoreMRInsert.js +8 -2
- package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/FormSpecToCoreMRInsert.js.map +1 -1
- package/FormSpec.TS/FormSpec.FS/Integrations/CorEMR/ItemTriggerConverter.js +53 -7
- package/FormSpec.TS/FormSpec.FS/Integrations/CorEMR/ItemTriggerConverter.js.map +1 -1
- package/FormSpec.TS/FormSpec.FS/Interop/FormSpec.Api.Helpers.js +1 -1
- package/FormSpec.TS/FormSpec.FS/Interop/FormSpec.Api.Helpers.js.map +1 -1
- package/FormSpec.TS/FormSpec.FS/TriggerActionDto.js +176 -0
- package/FormSpec.TS/FormSpec.FS/TriggerActionDto.js.map +1 -0
- package/FormSpec.TS/Thoth.Json/packages/Thoth.Json/Encode.js.map +1 -1
- package/README.md +7 -7
- package/package.json +1 -1
- package/src/FormSpec.FS/BitmaskHelpers.ts +3 -3
- package/src/FormSpec.FS/FormSpec.ts +12 -6
- package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateMapper.ts +27 -11
- package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTriggerConverter.ts +34 -8
- package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMREncoder.ts +6 -12
- package/src/FormSpec.FS/Integrations/Adapters/CorEMR/FormSpecToCoreMRInsert.ts +6 -3
- package/src/FormSpec.FS/Integrations/CorEMR/ItemTriggerConverter.ts +40 -8
- package/src/FormSpec.FS/Interop/FormSpec.Api.Helpers.ts +1 -1
- package/src/FormSpec.FS/TriggerActionDto.ts +135 -0
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { Record } from "@fable-org/fable-library-js/Types.js";
|
|
1
|
+
import { FSharpRef, Record } from "@fable-org/fable-library-js/Types.js";
|
|
2
2
|
import { int32ToString, comparePrimitives, IComparable, IEquatable } from "@fable-org/fable-library-js/Util.js";
|
|
3
3
|
import { record_type, string_type, TypeInfo } from "@fable-org/fable-library-js/Reflection.js";
|
|
4
4
|
import { FSharpSet__Contains, contains, FSharpSet, ofSeq } from "@fable-org/fable-library-js/Set.js";
|
|
5
|
-
import { int32 } from "@fable-org/fable-library-js/Int32.js";
|
|
6
|
-
import { bind, orElse, map as map_1, orElseWith, defaultArg, Option, value as
|
|
5
|
+
import { tryParse, int32 } from "@fable-org/fable-library-js/Int32.js";
|
|
6
|
+
import { bind, orElse, map as map_1, orElseWith, defaultArg, Option, value as value_5 } from "@fable-org/fable-library-js/Option.js";
|
|
7
7
|
import { Spec_FormClassification_$union, Spec_FormClassification_General, Spec_FormClassification_Screening, Spec_FormClassification_Intake, Spec_FormClassification_ClinicalInstrument, Spec_ClinicalInstrumentInfo, Spec_InstrumentConfidence_Inferred, Spec_InstrumentConfidence_Exact } from "../../../FormSpec.js";
|
|
8
8
|
import { isNullOrEmpty } from "@fable-org/fable-library-js/String.js";
|
|
9
9
|
import { int64, toInt32 } from "@fable-org/fable-library-js/BigInt.js";
|
|
10
|
-
import { CoreMRFormDetail, CoreMRTag, CoreMRTrigger, CoreMRChoice, CoreMRItem, CoreMRFormMetadata } from "../../CorEMR/CoreMRTypes.js";
|
|
11
|
-
import { empty, item as
|
|
10
|
+
import { CoreMRFormDetail, CoreMRTag, CoreMRTrigger, CoreMRTriggerEvent, CoreMRTriggerCondition, CoreMRChoice, CoreMRItem, CoreMRFormMetadata } from "../../CorEMR/CoreMRTypes.js";
|
|
11
|
+
import { empty, choose, item as item_3, length, mapIndexed, sortBy, collect, FSharpList, isEmpty, map } from "@fable-org/fable-library-js/List.js";
|
|
12
12
|
import { FSharpMap, filter, keys, isEmpty as isEmpty_1, tryFind } from "@fable-org/fable-library-js/Map.js";
|
|
13
13
|
import { ElementTypeInfo, getElementTypeInfo } from "./CorEMRElementTypeMap.js";
|
|
14
|
-
import { TemplateForm, TemplateChoice, TemplateItem } from "../../CorEMR/TemplateManifestDecoder.js";
|
|
14
|
+
import { TemplateForm, ItemTrigger, TriggerAction, TriggerCondition, TemplateChoice, TemplateItem } from "../../CorEMR/TemplateManifestDecoder.js";
|
|
15
15
|
import { normalizeChoiceScores } from "../../../BitmaskHelpers.js";
|
|
16
16
|
|
|
17
17
|
export class BridgeElementTypeInfo extends Record implements IEquatable<BridgeElementTypeInfo>, IComparable<BridgeElementTypeInfo> {
|
|
@@ -46,11 +46,11 @@ function hasTextHasDateFromBridge(textField: string): [boolean, boolean] {
|
|
|
46
46
|
export function mapFormClassification(formCategory: Option<string>, instrumentType: Option<string>, instrumentConfidence: Option<string>, instrumentMaxScore: Option<int32>): Spec_FormClassification_$union {
|
|
47
47
|
let matchResult: int32, instType: string;
|
|
48
48
|
if (formCategory != null) {
|
|
49
|
-
switch (
|
|
49
|
+
switch (value_5(formCategory)) {
|
|
50
50
|
case "clinical_instrument": {
|
|
51
51
|
if (instrumentType != null) {
|
|
52
52
|
matchResult = 0;
|
|
53
|
-
instType =
|
|
53
|
+
instType = value_5(instrumentType);
|
|
54
54
|
}
|
|
55
55
|
else {
|
|
56
56
|
matchResult = 3;
|
|
@@ -74,7 +74,7 @@ export function mapFormClassification(formCategory: Option<string>, instrumentTy
|
|
|
74
74
|
}
|
|
75
75
|
switch (matchResult) {
|
|
76
76
|
case 0:
|
|
77
|
-
return Spec_FormClassification_ClinicalInstrument(new Spec_ClinicalInstrumentInfo(instType!, (instrumentConfidence != null) ? ((
|
|
77
|
+
return Spec_FormClassification_ClinicalInstrument(new Spec_ClinicalInstrumentInfo(instType!, (instrumentConfidence != null) ? ((value_5(instrumentConfidence) === "exact") ? Spec_InstrumentConfidence_Exact() : Spec_InstrumentConfidence_Inferred()) : Spec_InstrumentConfidence_Inferred(), instrumentMaxScore));
|
|
78
78
|
case 1:
|
|
79
79
|
return Spec_FormClassification_Intake();
|
|
80
80
|
case 2:
|
|
@@ -115,13 +115,29 @@ export function mapNewTemplateToCoreMRDetail(elementTypes: FSharpMap<int32, Brid
|
|
|
115
115
|
const bitPositions: Option<FSharpList<int32>> = (FSharpSet__Contains(multiSelectTypes, item_1.Type) && patternInput_1[1]) ? patternInput_1[0] : undefined;
|
|
116
116
|
return mapIndexed<TemplateChoice, CoreMRChoice>((index: int32, choice: TemplateChoice): CoreMRChoice => (new CoreMRChoice(choice.ChoiceId, item_1.ItemId, choice.Sequence, choice.Text, choice.Score, orElse(choice.BitPosition, bind<FSharpList<int32>, int32>((positions: FSharpList<int32>): Option<int32> => {
|
|
117
117
|
if (index < length(positions)) {
|
|
118
|
-
return
|
|
118
|
+
return item_3(index, positions);
|
|
119
119
|
}
|
|
120
120
|
else {
|
|
121
121
|
return undefined;
|
|
122
122
|
}
|
|
123
123
|
}, bitPositions)), choice.Code, map_1<int32, string>(int32ToString, choice.Highlight))), sortedChoices);
|
|
124
|
-
}, template.Items),
|
|
124
|
+
}, template.Items), collect<TemplateItem, CoreMRTrigger>((item_2: TemplateItem): FSharpList<CoreMRTrigger> => mapIndexed<ItemTrigger, CoreMRTrigger>((triggerOrder: int32, trigger: ItemTrigger): CoreMRTrigger => {
|
|
125
|
+
const conditions: FSharpList<CoreMRTriggerCondition> = map<TriggerCondition, CoreMRTriggerCondition>((cond: TriggerCondition): CoreMRTriggerCondition => (new CoreMRTriggerCondition(cond.ConditionId, trigger.TriggerId, undefined, cond.Source, cond.Operator, !isEmpty(cond.RawChoiceIds) ? cond.RawChoiceIds : choose<string, int32>((value_3: string): Option<int32> => {
|
|
126
|
+
let matchValue: [boolean, int32];
|
|
127
|
+
let outArg = 0;
|
|
128
|
+
matchValue = ([tryParse(value_3, 511, false, 32, new FSharpRef<int32>((): int32 => outArg, (v: int32): void => {
|
|
129
|
+
outArg = (v | 0);
|
|
130
|
+
})), outArg] as [boolean, int32]);
|
|
131
|
+
if (matchValue[0]) {
|
|
132
|
+
return matchValue[1];
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
return undefined;
|
|
136
|
+
}
|
|
137
|
+
}, cond.Values))), trigger.Conditions);
|
|
138
|
+
const events: FSharpList<CoreMRTriggerEvent> = map<TriggerAction, CoreMRTriggerEvent>((action: TriggerAction): CoreMRTriggerEvent => (new CoreMRTriggerEvent(action.ActionId, trigger.TriggerId, action.ActionType, action.Params)), trigger.Actions);
|
|
139
|
+
return new CoreMRTrigger(trigger.TriggerId, item_2.ItemId, trigger.EventName, triggerOrder + 1, defaultArg(trigger.ExclusiveTag, ""), trigger.Enabled, conditions, events);
|
|
140
|
+
}, item_2.Triggers), template.Items), empty<CoreMRTag>(), undefined);
|
|
125
141
|
}
|
|
126
142
|
|
|
127
143
|
//# sourceMappingURL=CorEMRTemplateMapper.ts.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Helpers_generateDeterministicGuidRaw } from "../../../Helpers.js";
|
|
2
2
|
import { ClinicalPathway_PathwayExecutionMode_MultiPathway, ClinicalPathway_MultiPathwayConfig, ClinicalPathway_ConflictResolution_CombineActions, ClinicalPathway_CombinationStrategy_AllMatching, ClinicalPathway_PathwayExecutionMode_$union, ClinicalPathway_ClinicalPathwaySpec, ClinicalPathway_PathRequirement, ClinicalPathway_ConstraintDefinition, ClinicalPathway_PathwayExecutionMode_TriggerBased, ClinicalPathway_TriggerBasedConfig, ClinicalPathway_TransitionDefinition, ClinicalPathway_StateType_Terminal, ClinicalPathway_TerminalInfo, ClinicalPathway_StateType_CompoundAction, ClinicalPathway_StateType_Action, ClinicalPathway_StateDefinition, ClinicalPathway_StateType_Evaluation, ClinicalPathway_EvaluationInfo, Shared_TransitionKey, Shared_StateKey, ClinicalPathway_TransitionCondition_Always, ClinicalPathway_TransitionCondition_CompositeCondition, ClinicalPathway_LogicalOp_And, ClinicalPathway_TransitionCondition_$union, ClinicalPathway_TransitionCondition_FieldCondition, Shared_ConditionValue_Single, Shared_ConditionValue_Multiple, Shared_FieldKey, ClinicalPathway_ActionInfo_$union, ClinicalPathway_ActionInfo_Prescription, ClinicalPathway_PrescriptionAction, ClinicalPathway_ActionInfo_Medication, ClinicalPathway_MedicationAction, ClinicalPathway_ActionInfo_Problem, ClinicalPathway_ProblemAction, ClinicalPathway_ProblemStatus_Active, ClinicalPathway_ActionInfo_Task, ClinicalPathway_TaskAction, ClinicalPathway_ActionInfo_Alert, ClinicalPathway_AlertAction, ClinicalPathway_AlertSeverity_High, ClinicalPathway_RecurrencePattern, ClinicalPathway_RecurrenceEnd_OnDate, ClinicalPathway_RecurrenceEnd_Never, ClinicalPathway_DueDate_$union, ClinicalPathway_DueDate_DaysFromNow, ClinicalPathway_DueDate_Tomorrow, ClinicalPathway_DueDate_Today, ClinicalPathway_TaskPriority_$union, ClinicalPathway_TaskPriority_Low, ClinicalPathway_TaskPriority_Medium, ClinicalPathway_TaskPriority_High, ClinicalPathway_TriggerTiming_$union, ClinicalPathway_TriggerTiming_OnFormLoad, ClinicalPathway_TriggerTiming_OnFormSubmit, ClinicalPathway_TriggerTiming_OnFormSave, ClinicalPathway_FieldEvaluator_$union, ClinicalPathway_FieldEvaluator_NotInSet, ClinicalPathway_FieldEvaluator_ContainsAll, ClinicalPathway_FieldEvaluator_LessOrEqual, ClinicalPathway_FieldEvaluator_LessThan, ClinicalPathway_FieldEvaluator_GreaterOrEqual, ClinicalPathway_FieldEvaluator_GreaterThan, ClinicalPathway_FieldEvaluator_NotEquals, ClinicalPathway_FieldEvaluator_Equals, ClinicalPathway_FieldEvaluator_InSet } from "../../../FormSpec.js";
|
|
3
3
|
import { join, trimStart, trim, split, replace, toConsoleError, printf, toFail } from "@fable-org/fable-library-js/String.js";
|
|
4
|
-
import { singleton, tryHead, append, cons, collect, mapIndexed, filter, empty,
|
|
4
|
+
import { singleton, tryHead, append, cons, collect, mapIndexed, filter, empty, map as map_1, item as item_3, length, tryFind as tryFind_1, head, tail, isEmpty, choose, ofArray, tryPick, FSharpList } from "@fable-org/fable-library-js/List.js";
|
|
5
5
|
import { tryParse, int32 } from "@fable-org/fable-library-js/Int32.js";
|
|
6
6
|
import { FSharpRef } from "@fable-org/fable-library-js/Types.js";
|
|
7
7
|
import { item as item_2 } from "@fable-org/fable-library-js/Array.js";
|
|
8
8
|
import { fromDays, fromHours } from "@fable-org/fable-library-js/TimeSpan.js";
|
|
9
|
-
import { map, defaultArg, Option, value as value_7 } from "@fable-org/fable-library-js/Option.js";
|
|
9
|
+
import { map, defaultArg, bind, Option, value as value_7 } from "@fable-org/fable-library-js/Option.js";
|
|
10
10
|
import { addDays, now, add } from "@fable-org/fable-library-js/DateOffset.js";
|
|
11
11
|
import { FSharpMap, tryFind } from "@fable-org/fable-library-js/Map.js";
|
|
12
12
|
import { CoreMRFormMetadata, CoreMRTrigger, CoreMRItem, CoreMRTriggerCondition, CoreMRTriggerEvent } from "../../CorEMR/CoreMRTypes.js";
|
|
@@ -186,11 +186,36 @@ export function parseRecurrence(recurEvery: Option<string>, recurEnd: Option<str
|
|
|
186
186
|
* Convert CoreMR event to FormSpec ActionInfo
|
|
187
187
|
*/
|
|
188
188
|
export function convertEvent(event: CoreMRTriggerEvent): ClinicalPathway_ActionInfo_$union {
|
|
189
|
-
const
|
|
190
|
-
|
|
189
|
+
const tryEventParamInt = (keys: FSharpList<string>): Option<int32> => tryPick<string, int32>((key: string): Option<int32> => bind<string, int32>((raw: string): Option<int32> => {
|
|
190
|
+
let matchValue: [boolean, int32];
|
|
191
|
+
let outArg = 0;
|
|
192
|
+
matchValue = ([tryParse(raw, 511, false, 32, new FSharpRef<int32>((): int32 => outArg, (v: int32): void => {
|
|
193
|
+
outArg = (v | 0);
|
|
194
|
+
})), outArg] as [boolean, int32]);
|
|
195
|
+
let matchResult: int32;
|
|
196
|
+
if (matchValue[0]) {
|
|
197
|
+
if (matchValue[1] > 0) {
|
|
198
|
+
matchResult = 0;
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
matchResult = 1;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
matchResult = 1;
|
|
206
|
+
}
|
|
207
|
+
switch (matchResult) {
|
|
208
|
+
case 0:
|
|
209
|
+
return matchValue[1];
|
|
210
|
+
default:
|
|
211
|
+
return undefined;
|
|
212
|
+
}
|
|
213
|
+
}, tryFind<string, string>(key, event.EventParams)), keys);
|
|
214
|
+
const matchValue_1: string = event.EventType.toLocaleLowerCase();
|
|
215
|
+
switch (matchValue_1) {
|
|
191
216
|
case "alert": {
|
|
192
217
|
const category: string = defaultArg(tryFind<string, string>("category_desc", event.EventParams), "Alert");
|
|
193
|
-
return ClinicalPathway_ActionInfo_Alert(new ClinicalPathway_AlertAction(category, `Alert: ${category}`, ClinicalPathway_AlertSeverity_High(), undefined));
|
|
218
|
+
return ClinicalPathway_ActionInfo_Alert(new ClinicalPathway_AlertAction(tryEventParamInt(ofArray(["category_id", "id"])), category, `Alert: ${category}`, ClinicalPathway_AlertSeverity_High(), undefined));
|
|
194
219
|
}
|
|
195
220
|
case "task": {
|
|
196
221
|
const category_1: string = defaultArg(tryFind<string, string>("cat_desc", event.EventParams), "Task");
|
|
@@ -199,19 +224,20 @@ export function convertEvent(event: CoreMRTriggerEvent): ClinicalPathway_ActionI
|
|
|
199
224
|
const dateStr: string = defaultArg(tryFind<string, string>("date", event.EventParams), "Today");
|
|
200
225
|
const recurEvery: Option<string> = tryFind<string, string>("recur_every", event.EventParams);
|
|
201
226
|
const recurEnd: Option<string> = tryFind<string, string>("recur_end", event.EventParams);
|
|
227
|
+
const categoryId_1: Option<int32> = tryEventParamInt(ofArray(["cat_id", "category_id", "id"]));
|
|
202
228
|
let assignee: string;
|
|
203
229
|
const parts: string[] = split(category_1, ["-"], 2);
|
|
204
230
|
assignee = ((parts.length > 0) ? item_2(0, parts).trim() : "Staff");
|
|
205
|
-
return ClinicalPathway_ActionInfo_Task(new ClinicalPathway_TaskAction(category_1, description, convertPriority(priorityStr), parseDueDate(dateStr), assignee, parseRecurrence(recurEvery, recurEnd)));
|
|
231
|
+
return ClinicalPathway_ActionInfo_Task(new ClinicalPathway_TaskAction(categoryId_1, category_1, description, convertPriority(priorityStr), parseDueDate(dateStr), assignee, parseRecurrence(recurEvery, recurEnd)));
|
|
206
232
|
}
|
|
207
233
|
case "problem":
|
|
208
|
-
return ClinicalPathway_ActionInfo_Problem(new ClinicalPathway_ProblemAction("Problem", undefined, now(), ClinicalPathway_ProblemStatus_Active(), undefined));
|
|
234
|
+
return ClinicalPathway_ActionInfo_Problem(new ClinicalPathway_ProblemAction(tryEventParamInt(ofArray(["problem_list_id", "category_id", "id"])), "Problem", undefined, now(), ClinicalPathway_ProblemStatus_Active(), undefined));
|
|
209
235
|
case "medset":
|
|
210
236
|
return ClinicalPathway_ActionInfo_Medication(new ClinicalPathway_MedicationAction("Medication Set", "", "", "", "", false));
|
|
211
237
|
case "prescription":
|
|
212
238
|
return ClinicalPathway_ActionInfo_Prescription(new ClinicalPathway_PrescriptionAction("", "", "PO", "", "", 30, 0, true, undefined));
|
|
213
239
|
default:
|
|
214
|
-
return toFail(printf("Unknown CoreMR event type: %s"))(
|
|
240
|
+
return toFail(printf("Unknown CoreMR event type: %s"))(matchValue_1);
|
|
215
241
|
}
|
|
216
242
|
}
|
|
217
243
|
|
|
@@ -3,7 +3,7 @@ import { orElse, defaultArg, map, value as value_3, bind, unwrap, Option } from
|
|
|
3
3
|
import { int32, float64 } from "@fable-org/fable-library-js/Int32.js";
|
|
4
4
|
import { comparePrimitives, stringHash, uncurry2, IComparable, IEquatable } from "@fable-org/fable-library-js/Util.js";
|
|
5
5
|
import { record_type, option_type, float64_type, TypeInfo } from "@fable-org/fable-library-js/Reflection.js";
|
|
6
|
-
import { exists, fold, contains, tail, mapIndexed, tryHead, choose, map as map_1,
|
|
6
|
+
import { exists, fold, contains, tail, mapIndexed, singleton, tryHead, choose, map as map_1, empty, tryFind, head, isEmpty, FSharpList, collect, filter } from "@fable-org/fable-library-js/List.js";
|
|
7
7
|
import { Shared_MatrixItemKey, Shared_MatrixAnswer, Spec_MultiChoiceInfo, Spec_SingleChoiceInfo, Shared_FieldOption, Shared_FieldOptionKey, Shared_FieldKey, Spec_FormSpec$1, Shared_FieldValue, Shared_FieldAnswer, Shared_PluginDataProperty, Shared_FieldValue_$union, Spec_FormStep$1, Spec_FormField$1, Spec_PluginFieldConfig, Spec_FieldType_$union } from "../../../FormSpec.js";
|
|
8
8
|
import { split, isNullOrWhiteSpace } from "@fable-org/fable-library-js/String.js";
|
|
9
9
|
import { tryParse } from "@fable-org/fable-library-js/Double.js";
|
|
@@ -280,12 +280,9 @@ function getOptionsFromFieldType(ft: Spec_FieldType_$union): FSharpList<Shared_F
|
|
|
280
280
|
}
|
|
281
281
|
|
|
282
282
|
function fieldToAnswers(field: Spec_FormField$1<Spec_FieldType_$union>, vitalsIdOpt: Option<int64>, anchor: CoreMRFieldAnchor): FSharpList<CoreMRAnswer> {
|
|
283
|
-
if (anchor.Encoding.IsSkip) {
|
|
283
|
+
if (anchor.Encoding.IsSkip ? true : anchor.Encoding.IsScaffold) {
|
|
284
284
|
return empty<CoreMRAnswer>();
|
|
285
285
|
}
|
|
286
|
-
else if (anchor.Encoding.IsScaffold) {
|
|
287
|
-
return singleton(new CoreMRAnswer(anchor.Sequence, 2n, undefined));
|
|
288
|
-
}
|
|
289
286
|
else {
|
|
290
287
|
const matchValue: Option<Shared_FieldValue_$union> = field.Value;
|
|
291
288
|
if (matchValue != null) {
|
|
@@ -506,10 +503,7 @@ function buildFieldByKeyMap(spec: Spec_FormSpec$1<Spec_FieldType_$union>): FShar
|
|
|
506
503
|
|
|
507
504
|
function anchorToAnswers(fieldMap: FSharpMap<string, Spec_FormField$1<Spec_FieldType_$union>>, vitalsIdOpt: Option<int64>, anchor: CoreMRFieldAnchor): FSharpList<CoreMRAnswer> {
|
|
508
505
|
const field: Option<Spec_FormField$1<Spec_FieldType_$union>> = tryFind_1<string, Spec_FormField$1<Spec_FieldType_$union>>(getFieldKeyGuid(anchor.FieldKey), fieldMap);
|
|
509
|
-
if (anchor.Encoding.IsSkip) {
|
|
510
|
-
return empty<CoreMRAnswer>();
|
|
511
|
-
}
|
|
512
|
-
else if (anchor.Encoding.IsScaffold) {
|
|
506
|
+
if (anchor.Encoding.IsSkip ? true : anchor.Encoding.IsScaffold) {
|
|
513
507
|
return empty<CoreMRAnswer>();
|
|
514
508
|
}
|
|
515
509
|
else if (field != null) {
|
|
@@ -548,7 +542,7 @@ export function encodeToFormAnswersWithVitals(provenancePayload: string, filledF
|
|
|
548
542
|
const formName: string = defaultArg(sourceMap.FormName, `CORE-${sourceMap.FormId}`);
|
|
549
543
|
const fieldMap: FSharpMap<string, Spec_FormField$1<Spec_FieldType_$union>> = buildFieldByKeyMap(filledFormSpec);
|
|
550
544
|
try {
|
|
551
|
-
return FSharpResult$2_Ok<CoreMRFormInsertRequest, string>(new CoreMRFormInsertRequest(sourceMap.FormId, formName, scaffoldMode ? undefined : ((acc = collect<CoreMRFieldAnchor, CoreMRAnswer>((anchor: CoreMRFieldAnchor): FSharpList<CoreMRAnswer> => anchorToAnswers(fieldMap, vitalsIdOpt, anchor), collect<CoreMRStepMap, CoreMRFieldAnchor>((step: CoreMRStepMap): FSharpList<CoreMRFieldAnchor> => step.FieldAnchors, sourceMap.Steps)), isEmpty(acc) ? undefined : acc)), dryRun));
|
|
545
|
+
return FSharpResult$2_Ok<CoreMRFormInsertRequest, string>(new CoreMRFormInsertRequest(sourceMap.FormId, formName, scaffoldMode ? undefined : ((acc = collect<CoreMRFieldAnchor, CoreMRAnswer>((anchor: CoreMRFieldAnchor): FSharpList<CoreMRAnswer> => anchorToAnswers(fieldMap, vitalsIdOpt, anchor), collect<CoreMRStepMap, CoreMRFieldAnchor>((step: CoreMRStepMap): FSharpList<CoreMRFieldAnchor> => step.FieldAnchors, sourceMap.Steps)), isEmpty(acc) ? undefined : acc)), dryRun, undefined));
|
|
552
546
|
}
|
|
553
547
|
catch (matchValue_1: any) {
|
|
554
548
|
const activePatternResult: Option<string> = Operators_FailurePattern(matchValue_1);
|
|
@@ -578,7 +572,7 @@ export function extractVitalsAndFormData(provenancePayload: string, filledFormSp
|
|
|
578
572
|
|
|
579
573
|
/**
|
|
580
574
|
* Encode filled FormSpec to CoreMR form-insert payload.
|
|
581
|
-
* scaffoldMode: when true, omit answers
|
|
575
|
+
* scaffoldMode: when true, omit answers.
|
|
582
576
|
* Iterates over provenance anchors (source of truth) so we never omit required items.
|
|
583
577
|
* LEGACY: Use extractVitalsAndFormData for new smart coordination.
|
|
584
578
|
*/
|
|
@@ -596,7 +590,7 @@ export function encodeToFormAnswers(provenancePayload: string, filledFormSpec: S
|
|
|
596
590
|
formName = defaultArg(orElse(sourceMap.FormName, isNullOrWhiteSpace(filledFormSpec.Title) ? undefined : filledFormSpec.Title), value);
|
|
597
591
|
const fieldMap: FSharpMap<string, Spec_FormField$1<Spec_FieldType_$union>> = buildFieldByKeyMap(filledFormSpec);
|
|
598
592
|
try {
|
|
599
|
-
return FSharpResult$2_Ok<CoreMRFormInsertRequest, string>(new CoreMRFormInsertRequest(sourceMap.FormId, formName, scaffoldMode ? undefined : ((acc = collect<CoreMRFieldAnchor, CoreMRAnswer>((anchor: CoreMRFieldAnchor): FSharpList<CoreMRAnswer> => anchorToAnswers(fieldMap, undefined, anchor), collect<CoreMRStepMap, CoreMRFieldAnchor>((step: CoreMRStepMap): FSharpList<CoreMRFieldAnchor> => step.FieldAnchors, sourceMap.Steps)), isEmpty(acc) ? undefined : acc)), dryRun));
|
|
593
|
+
return FSharpResult$2_Ok<CoreMRFormInsertRequest, string>(new CoreMRFormInsertRequest(sourceMap.FormId, formName, scaffoldMode ? undefined : ((acc = collect<CoreMRFieldAnchor, CoreMRAnswer>((anchor: CoreMRFieldAnchor): FSharpList<CoreMRAnswer> => anchorToAnswers(fieldMap, undefined, anchor), collect<CoreMRStepMap, CoreMRFieldAnchor>((step: CoreMRStepMap): FSharpList<CoreMRFieldAnchor> => step.FieldAnchors, sourceMap.Steps)), isEmpty(acc) ? undefined : acc)), dryRun, undefined));
|
|
600
594
|
}
|
|
601
595
|
catch (matchValue_1: any) {
|
|
602
596
|
const activePatternResult: Option<string> = Operators_FailurePattern(matchValue_1);
|
|
@@ -7,6 +7,7 @@ import { bool_type, list_type, option_type, int64_type, record_type, class_type,
|
|
|
7
7
|
import { fromInt32, toInt64, int64 } from "@fable-org/fable-library-js/BigInt.js";
|
|
8
8
|
import { defaultArg, toArray, value as value_6, map, bind, Option } from "@fable-org/fable-library-js/Option.js";
|
|
9
9
|
import { map as map_1, choose, mapIndexed, collect, head, tail, isEmpty, ofArray, empty, tryFind, FSharpList } from "@fable-org/fable-library-js/List.js";
|
|
10
|
+
import { TriggerActionDto_$reflection, TriggerActionDto } from "../../../TriggerActionDto.js";
|
|
10
11
|
import { Helpers_canonicalizeFieldKey } from "../../../Helpers.js";
|
|
11
12
|
import { isNullOrWhiteSpace } from "@fable-org/fable-library-js/String.js";
|
|
12
13
|
import { object, toString } from "../../../../Thoth.Json/packages/Thoth.Json/Encode.js";
|
|
@@ -53,17 +54,19 @@ export class CoreMRFormInsertRequest extends Record implements IEquatable<CoreMR
|
|
|
53
54
|
readonly FormName: string;
|
|
54
55
|
readonly Answers: Option<FSharpList<CoreMRAnswer>>;
|
|
55
56
|
readonly DryRun: Option<boolean>;
|
|
56
|
-
|
|
57
|
+
readonly TriggerActions: Option<FSharpList<TriggerActionDto>>;
|
|
58
|
+
constructor(FormId: int32, FormName: string, Answers: Option<FSharpList<CoreMRAnswer>>, DryRun: Option<boolean>, TriggerActions: Option<FSharpList<TriggerActionDto>>) {
|
|
57
59
|
super();
|
|
58
60
|
this.FormId = (FormId | 0);
|
|
59
61
|
this.FormName = FormName;
|
|
60
62
|
this.Answers = Answers;
|
|
61
63
|
this.DryRun = DryRun;
|
|
64
|
+
this.TriggerActions = TriggerActions;
|
|
62
65
|
}
|
|
63
66
|
}
|
|
64
67
|
|
|
65
68
|
export function CoreMRFormInsertRequest_$reflection(): TypeInfo {
|
|
66
|
-
return record_type("FormSpec.Integrations.CorEMR.CoreMRFormInsertRequest", [], CoreMRFormInsertRequest, () => [["FormId", int32_type], ["FormName", string_type], ["Answers", option_type(list_type(CoreMRAnswer_$reflection()))], ["DryRun", option_type(bool_type)]]);
|
|
69
|
+
return record_type("FormSpec.Integrations.CorEMR.CoreMRFormInsertRequest", [], CoreMRFormInsertRequest, () => [["FormId", int32_type], ["FormName", string_type], ["Answers", option_type(list_type(CoreMRAnswer_$reflection()))], ["DryRun", option_type(bool_type)], ["TriggerActions", option_type(list_type(TriggerActionDto_$reflection()))]]);
|
|
67
70
|
}
|
|
68
71
|
|
|
69
72
|
function FormSpecToCoreMRInsert_getScoreFromOption(options: FSharpList<Shared_FieldOption>, selectedValue: string): Option<int32> {
|
|
@@ -252,7 +255,7 @@ function FormSpecToCoreMRInsert_fieldToValueAndText(field: Spec_FormField$1<Spec
|
|
|
252
255
|
*/
|
|
253
256
|
export function FormSpecToCoreMRInsert_convertToCoreMRInsertPayload(filledFormSpec: Spec_FormSpec$1<Spec_FieldType_$union>, metadata: CoreMRPublishMetadata, scaffoldMode: boolean, dryRun: boolean): CoreMRFormInsertRequest {
|
|
254
257
|
let allFields: FSharpList<Spec_FormField$1<Spec_FieldType_$union>>, acc: FSharpList<CoreMRAnswer>;
|
|
255
|
-
return new CoreMRFormInsertRequest(metadata.FormId, metadata.FormName, scaffoldMode ? undefined : ((allFields = 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, filledFormSpec.Steps), (acc = (isEmpty_1<Shared_FieldKey, int32>(metadata.FieldKeyToSequence) ? mapIndexed<[int32, Option<string>], CoreMRAnswer>((i: int32, tupledArg: [int32, Option<string>]): CoreMRAnswer => (new CoreMRAnswer((2 * i) + 1, toInt64(fromInt32(tupledArg[0])), tupledArg[1])), choose<Spec_FormField$1<Spec_FieldType_$union>, [int32, Option<string>]>(FormSpecToCoreMRInsert_fieldToValueAndText, allFields)) : collect<Spec_FormField$1<Spec_FieldType_$union>, CoreMRAnswer>((f: Spec_FormField$1<Spec_FieldType_$union>): FSharpList<CoreMRAnswer> => FormSpecToCoreMRInsert_fieldToAnswers(f, metadata.FieldKeyToSequence), allFields)), isEmpty(acc) ? undefined : acc))), dryRun);
|
|
258
|
+
return new CoreMRFormInsertRequest(metadata.FormId, metadata.FormName, scaffoldMode ? undefined : ((allFields = 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, filledFormSpec.Steps), (acc = (isEmpty_1<Shared_FieldKey, int32>(metadata.FieldKeyToSequence) ? mapIndexed<[int32, Option<string>], CoreMRAnswer>((i: int32, tupledArg: [int32, Option<string>]): CoreMRAnswer => (new CoreMRAnswer((2 * i) + 1, toInt64(fromInt32(tupledArg[0])), tupledArg[1])), choose<Spec_FormField$1<Spec_FieldType_$union>, [int32, Option<string>]>(FormSpecToCoreMRInsert_fieldToValueAndText, allFields)) : collect<Spec_FormField$1<Spec_FieldType_$union>, CoreMRAnswer>((f: Spec_FormField$1<Spec_FieldType_$union>): FSharpList<CoreMRAnswer> => FormSpecToCoreMRInsert_fieldToAnswers(f, metadata.FieldKeyToSequence), allFields)), isEmpty(acc) ? undefined : acc))), dryRun, undefined);
|
|
256
259
|
}
|
|
257
260
|
|
|
258
261
|
const CoreMRPublishMetadataCustomData_key = "coremr_publish";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Helpers_generateDeterministicGuidRaw } from "../../Helpers.js";
|
|
2
2
|
import { ClinicalPathway_PathwayExecutionMode_MultiPathway, ClinicalPathway_MultiPathwayConfig, ClinicalPathway_ConflictResolution_CombineActions, ClinicalPathway_CombinationStrategy_AllMatching, ClinicalPathway_ClinicalPathwaySpec, ClinicalPathway_PathRequirement, ClinicalPathway_ConstraintDefinition, ClinicalPathway_PathwayExecutionMode_TriggerBased, ClinicalPathway_TriggerBasedConfig, ClinicalPathway_TransitionDefinition, Shared_TransitionKey, ClinicalPathway_StateType_Terminal, ClinicalPathway_TerminalInfo, ClinicalPathway_StateType_Action, ClinicalPathway_StateType_CompoundAction, ClinicalPathway_StateDefinition, ClinicalPathway_StateType_Evaluation, ClinicalPathway_EvaluationInfo, Shared_StateKey, ClinicalPathway_ActionInfo_$union, ClinicalPathway_ActionInfo_Documentation, ClinicalPathway_DocumentationAction, ClinicalPathway_ActionInfo_Problem, ClinicalPathway_ProblemAction, ClinicalPathway_ProblemStatus_Active, ClinicalPathway_ActionInfo_Medication, ClinicalPathway_MedicationAction, ClinicalPathway_ActionInfo_Task, ClinicalPathway_TaskAction, ClinicalPathway_ActionInfo_Alert, ClinicalPathway_AlertAction, ClinicalPathway_AlertSeverity_High, ClinicalPathway_TransitionCondition_Always, ClinicalPathway_TransitionCondition_CompositeCondition, ClinicalPathway_LogicalOp_And, ClinicalPathway_LogicalOp_Or, ClinicalPathway_TransitionCondition_$union, ClinicalPathway_TransitionCondition_FieldCondition, ClinicalPathway_TransitionCondition_PluginPropertyCondition, Shared_PluginPropertyKey, Shared_ConditionValue_Single, Shared_ConditionValue_Multiple, Shared_ConditionValue_$union, Shared_FieldKey, ClinicalPathway_RecurrencePattern, ClinicalPathway_RecurrenceEnd_AfterOccurrences, ClinicalPathway_RecurrenceEnd_OnDate, ClinicalPathway_RecurrenceEnd_$union, ClinicalPathway_DueDate_$union, ClinicalPathway_DueDate_DaysFromNow, ClinicalPathway_DueDate_Tomorrow, ClinicalPathway_DueDate_Today, ClinicalPathway_TaskPriority_$union, ClinicalPathway_TaskPriority_Medium, ClinicalPathway_TaskPriority_Low, ClinicalPathway_TaskPriority_High, ClinicalPathway_TriggerTiming_$union, ClinicalPathway_TriggerTiming_OnFormLoad, ClinicalPathway_TriggerTiming_OnFormSubmit, ClinicalPathway_TriggerTiming_OnFormSave, ClinicalPathway_FieldEvaluator_$union, ClinicalPathway_FieldEvaluator_MatchesPattern, ClinicalPathway_FieldEvaluator_NotInSet, ClinicalPathway_FieldEvaluator_ContainsAll, ClinicalPathway_FieldEvaluator_LessOrEqual, ClinicalPathway_FieldEvaluator_LessThan, ClinicalPathway_FieldEvaluator_GreaterOrEqual, ClinicalPathway_FieldEvaluator_GreaterThan, ClinicalPathway_FieldEvaluator_NotEquals, ClinicalPathway_FieldEvaluator_Equals, ClinicalPathway_FieldEvaluator_InSet } from "../../FormSpec.js";
|
|
3
3
|
import { bind, map as map_1, defaultArgWith, Option, value as value_1, defaultArg } from "@fable-org/fable-library-js/Option.js";
|
|
4
|
-
import { sortByDescending, append, indexed, singleton, collect, filter, empty,
|
|
4
|
+
import { sortByDescending, append, indexed, singleton, collect, filter, empty, length, tryFind as tryFind_1, ofArray, tryPick, map, tail, head, isEmpty, FSharpList, tryHead } from "@fable-org/fable-library-js/List.js";
|
|
5
5
|
import { tryParse, int32 } from "@fable-org/fable-library-js/Int32.js";
|
|
6
6
|
import { substring, join, isNullOrEmpty, split, replace } from "@fable-org/fable-library-js/String.js";
|
|
7
7
|
import { FSharpRef } from "@fable-org/fable-library-js/Types.js";
|
|
@@ -206,42 +206,74 @@ function param(key: string, action: TriggerAction): string {
|
|
|
206
206
|
return defaultArg(tryFind<string, string>(key, action.Params), "");
|
|
207
207
|
}
|
|
208
208
|
|
|
209
|
+
function tryParsePositiveInt(value: string): Option<int32> {
|
|
210
|
+
let matchValue: [boolean, int32];
|
|
211
|
+
let outArg = 0;
|
|
212
|
+
matchValue = ([tryParse(value, 511, false, 32, new FSharpRef<int32>((): int32 => outArg, (v: int32): void => {
|
|
213
|
+
outArg = (v | 0);
|
|
214
|
+
})), outArg] as [boolean, int32]);
|
|
215
|
+
let matchResult: int32;
|
|
216
|
+
if (matchValue[0]) {
|
|
217
|
+
if (matchValue[1] > 0) {
|
|
218
|
+
matchResult = 0;
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
matchResult = 1;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
matchResult = 1;
|
|
226
|
+
}
|
|
227
|
+
switch (matchResult) {
|
|
228
|
+
case 0:
|
|
229
|
+
return matchValue[1];
|
|
230
|
+
default:
|
|
231
|
+
return undefined;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function paramInt(keys: FSharpList<string>, action: TriggerAction): Option<int32> {
|
|
236
|
+
return tryPick<string, int32>((key: string): Option<int32> => bind<string, int32>(tryParsePositiveInt, tryFind<string, string>(key, action.Params)), keys);
|
|
237
|
+
}
|
|
238
|
+
|
|
209
239
|
export function convertAction(action: TriggerAction): ClinicalPathway_ActionInfo_$union {
|
|
210
240
|
let s: string, s_1: string;
|
|
211
241
|
const matchValue: string = action.ActionType.toLowerCase();
|
|
212
242
|
switch (matchValue) {
|
|
213
243
|
case "alert": {
|
|
214
244
|
const categoryName: string = param("category_name", action);
|
|
215
|
-
return ClinicalPathway_ActionInfo_Alert(new ClinicalPathway_AlertAction(categoryName, `Alert: ${categoryName}`, ClinicalPathway_AlertSeverity_High(), undefined));
|
|
245
|
+
return ClinicalPathway_ActionInfo_Alert(new ClinicalPathway_AlertAction(paramInt(ofArray(["category_id", "id"]), action), categoryName, `Alert: ${categoryName}`, ClinicalPathway_AlertSeverity_High(), undefined));
|
|
216
246
|
}
|
|
217
247
|
case "task": {
|
|
218
248
|
const category: string = param("category_name", action);
|
|
249
|
+
const categoryId_1: Option<int32> = paramInt(ofArray(["id", "category_id", "cat_id"]), action);
|
|
219
250
|
let assignee: string;
|
|
220
251
|
const parts: string[] = split(category, ["-"], undefined, 0);
|
|
221
252
|
assignee = ((parts.length > 0) ? item_1(0, parts).trim() : "Staff");
|
|
222
|
-
return ClinicalPathway_ActionInfo_Task(new ClinicalPathway_TaskAction(category, param("description", action), convertPriority(param("priority", action)), parseDueDate(param("start", action)), assignee, undefined));
|
|
253
|
+
return ClinicalPathway_ActionInfo_Task(new ClinicalPathway_TaskAction(categoryId_1, category, param("description", action), convertPriority(param("priority", action)), parseDueDate(param("start", action)), assignee, undefined));
|
|
223
254
|
}
|
|
224
255
|
case "recurring_task": {
|
|
225
256
|
const category_1: string = param("category_name", action);
|
|
257
|
+
const categoryId_2: Option<int32> = paramInt(ofArray(["id", "category_id", "cat_id"]), action);
|
|
226
258
|
let assignee_1: string;
|
|
227
259
|
const parts_1: string[] = split(category_1, ["-"], undefined, 0);
|
|
228
260
|
assignee_1 = ((parts_1.length > 0) ? item_1(0, parts_1).trim() : "Staff");
|
|
229
|
-
return ClinicalPathway_ActionInfo_Task(new ClinicalPathway_TaskAction(category_1, param("description", action), convertPriority(param("priority", action)), parseDueDate(param("start", action)), assignee_1, parseRecurrence(tryFind<string, string>("end", action.Params))));
|
|
261
|
+
return ClinicalPathway_ActionInfo_Task(new ClinicalPathway_TaskAction(categoryId_2, category_1, param("description", action), convertPriority(param("priority", action)), parseDueDate(param("start", action)), assignee_1, parseRecurrence(tryFind<string, string>("end", action.Params))));
|
|
230
262
|
}
|
|
231
263
|
case "medset":
|
|
232
264
|
return ClinicalPathway_ActionInfo_Medication(new ClinicalPathway_MedicationAction(param("medset_name", action), "", "", "", "", false));
|
|
233
265
|
case "problem":
|
|
234
|
-
return ClinicalPathway_ActionInfo_Problem(new ClinicalPathway_ProblemAction((s = param("category_name", action), isNullOrEmpty(s) ? "Problem" : s), undefined, utcNow(), ClinicalPathway_ProblemStatus_Active(), undefined));
|
|
266
|
+
return ClinicalPathway_ActionInfo_Problem(new ClinicalPathway_ProblemAction(paramInt(ofArray(["problem_list_id", "category_id", "id"]), action), (s = param("category_name", action), isNullOrEmpty(s) ? "Problem" : s), undefined, utcNow(), ClinicalPathway_ProblemStatus_Active(), undefined));
|
|
235
267
|
case "treatment":
|
|
236
268
|
return ClinicalPathway_ActionInfo_Medication(new ClinicalPathway_MedicationAction((s_1 = param("category_name", action), isNullOrEmpty(s_1) ? "Treatment" : s_1), "", "", "", "", false));
|
|
237
269
|
case "taskcomplete":
|
|
238
|
-
return ClinicalPathway_ActionInfo_Task(new ClinicalPathway_TaskAction(`Complete: ${param("category_name", action)}`, "Mark task as complete", ClinicalPathway_TaskPriority_Medium(), ClinicalPathway_DueDate_Today(), "Staff", undefined));
|
|
270
|
+
return ClinicalPathway_ActionInfo_Task(new ClinicalPathway_TaskAction(undefined, `Complete: ${param("category_name", action)}`, "Mark task as complete", ClinicalPathway_TaskPriority_Medium(), ClinicalPathway_DueDate_Today(), "Staff", undefined));
|
|
239
271
|
case "approval":
|
|
240
|
-
return ClinicalPathway_ActionInfo_Task(new ClinicalPathway_TaskAction("Approval Required", param("description", action), ClinicalPathway_TaskPriority_High(), ClinicalPathway_DueDate_Today(), "Supervisor", undefined));
|
|
272
|
+
return ClinicalPathway_ActionInfo_Task(new ClinicalPathway_TaskAction(undefined, "Approval Required", param("description", action), ClinicalPathway_TaskPriority_High(), ClinicalPathway_DueDate_Today(), "Supervisor", undefined));
|
|
241
273
|
case "groups":
|
|
242
274
|
return ClinicalPathway_ActionInfo_Documentation(new ClinicalPathway_DocumentationAction("Group Assignment", param("category_name", action), false));
|
|
243
275
|
default:
|
|
244
|
-
return ClinicalPathway_ActionInfo_Task(new ClinicalPathway_TaskAction(`Unknown action: ${matchValue}`, join("; ", map<[string, string], string>((tupledArg: [string, string]): string => (`${tupledArg[0]}=${tupledArg[1]}`), toList<string, string>(action.Params))), ClinicalPathway_TaskPriority_Medium(), ClinicalPathway_DueDate_Today(), "Staff", undefined));
|
|
276
|
+
return ClinicalPathway_ActionInfo_Task(new ClinicalPathway_TaskAction(undefined, `Unknown action: ${matchValue}`, join("; ", map<[string, string], string>((tupledArg: [string, string]): string => (`${tupledArg[0]}=${tupledArg[1]}`), toList<string, string>(action.Params))), ClinicalPathway_TaskPriority_Medium(), ClinicalPathway_DueDate_Today(), "Staff", undefined));
|
|
245
277
|
}
|
|
246
278
|
}
|
|
247
279
|
|
|
@@ -732,7 +732,7 @@ export function createPluginField(fieldKeyString: string, label: string, config:
|
|
|
732
732
|
* TypeScript: createActionState(stateKey: string, label: string, taskDescription: string, priority?: string)
|
|
733
733
|
*/
|
|
734
734
|
export function createActionState(stateKeyString: string, label: string, taskDescription: string, priority: Option<string>): ClinicalPathway_StateDefinition {
|
|
735
|
-
return new ClinicalPathway_StateDefinition(new Shared_StateKey(parse(stateKeyString)), label, 1, ClinicalPathway_StateType_Action(ClinicalPathway_ActionInfo_Task(new ClinicalPathway_TaskAction("Clinical", taskDescription, (priority != null) ? ((value_19(priority) === "High") ? ClinicalPathway_TaskPriority_High() : ((value_19(priority) === "Low") ? ClinicalPathway_TaskPriority_Low() : ClinicalPathway_TaskPriority_Medium())) : ClinicalPathway_TaskPriority_Medium(), ClinicalPathway_DueDate_Today(), "Clinical Staff", undefined))), undefined);
|
|
735
|
+
return new ClinicalPathway_StateDefinition(new Shared_StateKey(parse(stateKeyString)), label, 1, ClinicalPathway_StateType_Action(ClinicalPathway_ActionInfo_Task(new ClinicalPathway_TaskAction(undefined, "Clinical", taskDescription, (priority != null) ? ((value_19(priority) === "High") ? ClinicalPathway_TaskPriority_High() : ((value_19(priority) === "Low") ? ClinicalPathway_TaskPriority_Low() : ClinicalPathway_TaskPriority_Medium())) : ClinicalPathway_TaskPriority_Medium(), ClinicalPathway_DueDate_Today(), "Clinical Staff", undefined))), undefined);
|
|
736
736
|
}
|
|
737
737
|
|
|
738
738
|
/**
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { Record } from "@fable-org/fable-library-js/Types.js";
|
|
2
|
+
import { int32 } from "@fable-org/fable-library-js/Int32.js";
|
|
3
|
+
import { map, value, Option } from "@fable-org/fable-library-js/Option.js";
|
|
4
|
+
import { IComparable, IEquatable } from "@fable-org/fable-library-js/Util.js";
|
|
5
|
+
import { record_type, bool_type, option_type, int32_type, string_type, TypeInfo } from "@fable-org/fable-library-js/Reflection.js";
|
|
6
|
+
import { ClinicalPathway_ActionInfo_$union, ClinicalPathway_ProblemAction, ClinicalPathway_AlertAction, ClinicalPathway_RecurrencePattern, ClinicalPathway_RecurrenceEnd_$union, ClinicalPathway_TaskAction, ClinicalPathway_DueDate_$union, ClinicalPathway_TaskPriority_$union } from "./FormSpec.js";
|
|
7
|
+
import { fromDateTimeOffset, today, addDays, toString } from "@fable-org/fable-library-js/Date.js";
|
|
8
|
+
import { FSharpList, choose } from "@fable-org/fable-library-js/List.js";
|
|
9
|
+
|
|
10
|
+
export class TriggerActionDto extends Record implements IEquatable<TriggerActionDto>, IComparable<TriggerActionDto> {
|
|
11
|
+
readonly ActionType: string;
|
|
12
|
+
readonly TriggerId: int32;
|
|
13
|
+
readonly TriggerActionId: int32;
|
|
14
|
+
readonly CategoryId: int32;
|
|
15
|
+
readonly CategoryName: string;
|
|
16
|
+
readonly Priority: Option<int32>;
|
|
17
|
+
readonly Description: Option<string>;
|
|
18
|
+
readonly DateStart: Option<string>;
|
|
19
|
+
readonly AllDay: Option<boolean>;
|
|
20
|
+
readonly ScheduleEnd: Option<string>;
|
|
21
|
+
readonly ProblemListId: Option<int32>;
|
|
22
|
+
readonly FormItemId: Option<int32>;
|
|
23
|
+
constructor(ActionType: string, TriggerId: int32, TriggerActionId: int32, CategoryId: int32, CategoryName: string, Priority: Option<int32>, Description: Option<string>, DateStart: Option<string>, AllDay: Option<boolean>, ScheduleEnd: Option<string>, ProblemListId: Option<int32>, FormItemId: Option<int32>) {
|
|
24
|
+
super();
|
|
25
|
+
this.ActionType = ActionType;
|
|
26
|
+
this.TriggerId = (TriggerId | 0);
|
|
27
|
+
this.TriggerActionId = (TriggerActionId | 0);
|
|
28
|
+
this.CategoryId = (CategoryId | 0);
|
|
29
|
+
this.CategoryName = CategoryName;
|
|
30
|
+
this.Priority = Priority;
|
|
31
|
+
this.Description = Description;
|
|
32
|
+
this.DateStart = DateStart;
|
|
33
|
+
this.AllDay = AllDay;
|
|
34
|
+
this.ScheduleEnd = ScheduleEnd;
|
|
35
|
+
this.ProblemListId = ProblemListId;
|
|
36
|
+
this.FormItemId = FormItemId;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function TriggerActionDto_$reflection(): TypeInfo {
|
|
41
|
+
return record_type("F1.Studio.TriggerActions.TriggerActionDto", [], TriggerActionDto, () => [["ActionType", string_type], ["TriggerId", int32_type], ["TriggerActionId", int32_type], ["CategoryId", int32_type], ["CategoryName", string_type], ["Priority", option_type(int32_type)], ["Description", option_type(string_type)], ["DateStart", option_type(string_type)], ["AllDay", option_type(bool_type)], ["ScheduleEnd", option_type(string_type)], ["ProblemListId", option_type(int32_type)], ["FormItemId", option_type(int32_type)]]);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Convert ClinicalPathway.TaskPriority DU → CoreMR int (1=High, 2=Medium, 3=Low)
|
|
46
|
+
*/
|
|
47
|
+
export function convertPriority(priority: ClinicalPathway_TaskPriority_$union): int32 {
|
|
48
|
+
switch (priority.tag) {
|
|
49
|
+
case /* Medium */ 1:
|
|
50
|
+
return 2;
|
|
51
|
+
case /* Low */ 2:
|
|
52
|
+
return 3;
|
|
53
|
+
default:
|
|
54
|
+
return 1;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Convert ClinicalPathway.DueDate DU → ISO 8601 date string
|
|
60
|
+
*/
|
|
61
|
+
export function convertDueDate(dueDate: ClinicalPathway_DueDate_$union): string {
|
|
62
|
+
switch (dueDate.tag) {
|
|
63
|
+
case /* Tomorrow */ 1:
|
|
64
|
+
return toString(addDays(today(), 1), "o");
|
|
65
|
+
case /* DaysFromNow */ 2: {
|
|
66
|
+
const days: int32 = dueDate.fields[0] | 0;
|
|
67
|
+
return toString(addDays(today(), days), "o");
|
|
68
|
+
}
|
|
69
|
+
case /* SpecificDate */ 3:
|
|
70
|
+
return toString(fromDateTimeOffset(dueDate.fields[0], 0), "o");
|
|
71
|
+
default:
|
|
72
|
+
return toString(today(), "o");
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function requireCategoryId(actionType: string, categoryName: string, categoryIdOpt: Option<int32>): int32 {
|
|
77
|
+
if (categoryIdOpt == null) {
|
|
78
|
+
throw new Error(`TriggerActionDto.convert: missing categoryId for actionType='${actionType}' category='${categoryName}'. CoreMR submit requires provenance category IDs.`);
|
|
79
|
+
}
|
|
80
|
+
else if (value(categoryIdOpt) > 0) {
|
|
81
|
+
const id_1: int32 = value(categoryIdOpt) | 0;
|
|
82
|
+
return id_1 | 0;
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
const id_2: int32 = value(categoryIdOpt) | 0;
|
|
86
|
+
throw new Error(`TriggerActionDto.convert: invalid categoryId=${id_2} for actionType='${actionType}' category='${categoryName}'. categoryId must be > 0.`);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Convert a list of ClinicalPathway ActionInfo (from PathwayExecutor.ExecutedActions)
|
|
92
|
+
* into a list of TriggerActionDto ready for JSON serialization and bridge POST.
|
|
93
|
+
*
|
|
94
|
+
* Only converts CoreMR-actionable types: Task, Alert, Problem.
|
|
95
|
+
* Skips: Medication, Education, Referral, Procedure, Documentation, Prescription,
|
|
96
|
+
* SetFieldValue, NavigateToForm (these are either Phase 2 or F1-internal).
|
|
97
|
+
*
|
|
98
|
+
* Task with Recurrence.IsSome → ActionType = "recurring_task"
|
|
99
|
+
* Task with Recurrence.IsNone → ActionType = "task"
|
|
100
|
+
*/
|
|
101
|
+
export function convert(actions: FSharpList<ClinicalPathway_ActionInfo_$union>): FSharpList<TriggerActionDto> {
|
|
102
|
+
return choose<ClinicalPathway_ActionInfo_$union, TriggerActionDto>((action: ClinicalPathway_ActionInfo_$union): Option<TriggerActionDto> => {
|
|
103
|
+
switch (action.tag) {
|
|
104
|
+
case /* Task */ 6: {
|
|
105
|
+
const taskAction: ClinicalPathway_TaskAction = action.fields[0];
|
|
106
|
+
const actionType: string = (taskAction.Recurrence != null) ? "recurring_task" : "task";
|
|
107
|
+
return new TriggerActionDto(actionType, 0, 0, requireCategoryId(actionType, taskAction.Category, taskAction.CategoryId), taskAction.Category, convertPriority(taskAction.Priority), taskAction.Description, convertDueDate(taskAction.DueDate), true, map<ClinicalPathway_RecurrencePattern, string>((r: ClinicalPathway_RecurrencePattern): string => {
|
|
108
|
+
const matchValue: ClinicalPathway_RecurrenceEnd_$union = r.Until;
|
|
109
|
+
switch (matchValue.tag) {
|
|
110
|
+
case /* AfterOccurrences */ 1: {
|
|
111
|
+
const n: int32 = matchValue.fields[0] | 0;
|
|
112
|
+
return toString(addDays(today(), n), "o");
|
|
113
|
+
}
|
|
114
|
+
case /* Never */ 2:
|
|
115
|
+
return toString(addDays(today(), 7), "o");
|
|
116
|
+
default:
|
|
117
|
+
return toString(fromDateTimeOffset(matchValue.fields[0], 0), "o");
|
|
118
|
+
}
|
|
119
|
+
}, taskAction.Recurrence), undefined, undefined);
|
|
120
|
+
}
|
|
121
|
+
case /* Alert */ 7: {
|
|
122
|
+
const alertAction: ClinicalPathway_AlertAction = action.fields[0];
|
|
123
|
+
return new TriggerActionDto("alert", 0, 0, requireCategoryId("alert", alertAction.Category, alertAction.CategoryId), alertAction.Category, undefined, undefined, undefined, undefined, undefined, undefined, undefined);
|
|
124
|
+
}
|
|
125
|
+
case /* Problem */ 8: {
|
|
126
|
+
const problemAction: ClinicalPathway_ProblemAction = action.fields[0];
|
|
127
|
+
return new TriggerActionDto("problem", 0, 0, requireCategoryId("problem", problemAction.ProblemName, problemAction.CategoryId), problemAction.ProblemName, undefined, undefined, undefined, undefined, undefined, undefined, undefined);
|
|
128
|
+
}
|
|
129
|
+
default:
|
|
130
|
+
return undefined;
|
|
131
|
+
}
|
|
132
|
+
}, actions);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
//# sourceMappingURL=TriggerActionDto.ts.map
|