@f1studio/form-spec 5.0.0-alpha.124 → 5.0.0-alpha.125
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/Integrations/Adapters/CorEMR/CorEMRAdapter.d.ts.map +1 -1
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateMapper.d.ts +8 -51
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateMapper.d.ts.map +1 -1
- package/FormSpec.FS/Integrations/CorEMR/TemplateDecodeTypes.d.ts +73 -0
- package/FormSpec.FS/Integrations/CorEMR/TemplateDecodeTypes.d.ts.map +1 -0
- package/FormSpec.FS/Integrations/CorEMR/TemplateManifestDecoder.d.ts +162 -0
- package/FormSpec.FS/Integrations/CorEMR/TemplateManifestDecoder.d.ts.map +1 -0
- package/FormSpec.FS/Interop/FormSpec.Api.Helpers.d.ts +21 -0
- package/FormSpec.FS/Interop/FormSpec.Api.Helpers.d.ts.map +1 -1
- package/FormSpec.TS/FormSpec.FS/BitmaskHelpers.js +1 -1
- package/FormSpec.TS/FormSpec.FS/BitmaskHelpers.js.map +1 -1
- package/FormSpec.TS/FormSpec.FS/BitmaskHelpers.ts.map +1 -1
- package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRAdapter.js +1 -1
- package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRAdapter.js.map +1 -1
- package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRAdapter.ts.map +1 -1
- package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateMapper.js +16 -220
- package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateMapper.js.map +1 -1
- package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateMapper.ts.map +1 -1
- package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMREncoder.js.map +1 -1
- package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMREncoder.ts.map +1 -1
- package/FormSpec.TS/FormSpec.FS/Integrations/CorEMR/TemplateDecodeTypes.js +387 -0
- package/FormSpec.TS/FormSpec.FS/Integrations/CorEMR/TemplateDecodeTypes.js.map +1 -0
- package/FormSpec.TS/FormSpec.FS/Integrations/CorEMR/TemplateDecodeTypes.ts.map +1 -0
- package/FormSpec.TS/FormSpec.FS/Integrations/CorEMR/TemplateManifestDecoder.js +771 -0
- package/FormSpec.TS/FormSpec.FS/Integrations/CorEMR/TemplateManifestDecoder.js.map +1 -0
- package/FormSpec.TS/FormSpec.FS/Integrations/CorEMR/TemplateManifestDecoder.ts.map +1 -0
- package/FormSpec.TS/FormSpec.FS/Interop/FormSpec.Api.Helpers.js +87 -0
- package/FormSpec.TS/FormSpec.FS/Interop/FormSpec.Api.Helpers.js.map +1 -1
- package/FormSpec.TS/FormSpec.FS/Interop/FormSpec.Api.Helpers.ts.map +1 -1
- package/FormSpec.TS/fable_modules/project_cracked.json +1 -1
- package/README.md +7 -7
- package/package.json +1 -1
- package/src/FormSpec.FS/BitmaskHelpers.ts +1 -1
- package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRAdapter.ts +2 -2
- package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateMapper.ts +32 -127
- package/src/FormSpec.FS/Integrations/CorEMR/TemplateDecodeTypes.ts +246 -0
- package/src/FormSpec.FS/Integrations/CorEMR/TemplateManifestDecoder.ts +431 -0
- package/src/FormSpec.FS/Interop/FormSpec.Api.Helpers.ts +104 -2
- package/FormSpec.FS/Integrations/CorEMR/CorEmrTemplates.d.ts +0 -95
- package/FormSpec.FS/Integrations/CorEMR/CorEmrTemplates.d.ts.map +0 -1
- package/FormSpec.TS/FormSpec.FS/Integrations/CorEMR/CorEmrTemplates.js +0 -258
- package/FormSpec.TS/FormSpec.FS/Integrations/CorEMR/CorEmrTemplates.js.map +0 -1
- package/FormSpec.TS/FormSpec.FS/Integrations/CorEMR/CorEmrTemplates.ts.map +0 -1
- package/src/FormSpec.FS/Integrations/CorEMR/CorEmrTemplates.ts +0 -15
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { 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
|
-
import {
|
|
4
|
-
import { bind, orElse, map as map_1, orElseWith, defaultArg, value as value_13, Option } from "@fable-org/fable-library-js/Option.js";
|
|
5
|
-
import { int32 } from "@fable-org/fable-library-js/Int32.js";
|
|
6
|
-
import { int64 } from "@fable-org/fable-library-js/BigInt.js";
|
|
7
|
-
import { empty, item as item_2, length, mapIndexed, sortBy, collect, isEmpty, map, FSharpList } from "@fable-org/fable-library-js/List.js";
|
|
3
|
+
import { record_type, string_type, TypeInfo } from "@fable-org/fable-library-js/Reflection.js";
|
|
8
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 value_3 } from "@fable-org/fable-library-js/Option.js";
|
|
9
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
|
+
import { isNullOrEmpty } from "@fable-org/fable-library-js/String.js";
|
|
9
|
+
import { int64, toInt32 } from "@fable-org/fable-library-js/BigInt.js";
|
|
10
10
|
import { CoreMRFormDetail, CoreMRTag, CoreMRTrigger, CoreMRChoice, CoreMRItem, CoreMRFormMetadata } from "../../CorEMR/CoreMRTypes.js";
|
|
11
|
+
import { empty, item as item_2, length, mapIndexed, sortBy, collect, FSharpList, isEmpty, map } from "@fable-org/fable-library-js/List.js";
|
|
11
12
|
import { FSharpMap, filter, keys, isEmpty as isEmpty_1, tryFind } from "@fable-org/fable-library-js/Map.js";
|
|
12
13
|
import { ElementTypeInfo, getElementTypeInfo } from "./CorEMRElementTypeMap.js";
|
|
14
|
+
import { TemplateForm, TemplateChoice, TemplateItem } from "../../CorEMR/TemplateManifestDecoder.js";
|
|
13
15
|
import { normalizeChoiceScores } from "../../../BitmaskHelpers.js";
|
|
14
16
|
|
|
15
17
|
export class BridgeElementTypeInfo extends Record implements IEquatable<BridgeElementTypeInfo>, IComparable<BridgeElementTypeInfo> {
|
|
@@ -28,98 +30,6 @@ export function BridgeElementTypeInfo_$reflection(): TypeInfo {
|
|
|
28
30
|
return record_type("FormSpec.Integrations.CorEMR.CorEMRTemplateMapper.BridgeElementTypeInfo", [], BridgeElementTypeInfo, () => [["Code", string_type], ["ValueEncoding", string_type], ["TextFieldRole", string_type]]);
|
|
29
31
|
}
|
|
30
32
|
|
|
31
|
-
export class BridgeTemplateChoice extends Record implements IEquatable<BridgeTemplateChoice>, IComparable<BridgeTemplateChoice> {
|
|
32
|
-
readonly ChoiceId: Option<int32>;
|
|
33
|
-
readonly Sequence: Option<int32>;
|
|
34
|
-
readonly Text: Option<string>;
|
|
35
|
-
readonly Score: Option<int64>;
|
|
36
|
-
readonly BitPosition: Option<int32>;
|
|
37
|
-
readonly Code: Option<string>;
|
|
38
|
-
readonly Highlight: Option<string>;
|
|
39
|
-
constructor(ChoiceId: Option<int32>, Sequence: Option<int32>, Text$: Option<string>, Score: Option<int64>, BitPosition: Option<int32>, Code: Option<string>, Highlight: Option<string>) {
|
|
40
|
-
super();
|
|
41
|
-
this.ChoiceId = ChoiceId;
|
|
42
|
-
this.Sequence = Sequence;
|
|
43
|
-
this.Text = Text$;
|
|
44
|
-
this.Score = Score;
|
|
45
|
-
this.BitPosition = BitPosition;
|
|
46
|
-
this.Code = Code;
|
|
47
|
-
this.Highlight = Highlight;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export function BridgeTemplateChoice_$reflection(): TypeInfo {
|
|
52
|
-
return record_type("FormSpec.Integrations.CorEMR.CorEMRTemplateMapper.BridgeTemplateChoice", [], BridgeTemplateChoice, () => [["ChoiceId", option_type(int32_type)], ["Sequence", option_type(int32_type)], ["Text", option_type(string_type)], ["Score", option_type(int64_type)], ["BitPosition", option_type(int32_type)], ["Code", option_type(string_type)], ["Highlight", option_type(string_type)]]);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export class BridgeTemplateItem extends Record implements IEquatable<BridgeTemplateItem>, IComparable<BridgeTemplateItem> {
|
|
56
|
-
readonly ItemId: int32;
|
|
57
|
-
readonly Sequence: int32;
|
|
58
|
-
readonly Type: int32;
|
|
59
|
-
readonly NestingLevel: Option<int32>;
|
|
60
|
-
readonly IsRequired: boolean;
|
|
61
|
-
readonly Text: string;
|
|
62
|
-
readonly SequenceText: Option<string>;
|
|
63
|
-
readonly Code: Option<string>;
|
|
64
|
-
readonly Uuid: Option<string>;
|
|
65
|
-
readonly GenderRequired: Option<string>;
|
|
66
|
-
readonly Highlight: Option<int32>;
|
|
67
|
-
readonly Choices: FSharpList<BridgeTemplateChoice>;
|
|
68
|
-
constructor(ItemId: int32, Sequence: int32, Type: int32, NestingLevel: Option<int32>, IsRequired: boolean, Text$: string, SequenceText: Option<string>, Code: Option<string>, Uuid: Option<string>, GenderRequired: Option<string>, Highlight: Option<int32>, Choices: FSharpList<BridgeTemplateChoice>) {
|
|
69
|
-
super();
|
|
70
|
-
this.ItemId = (ItemId | 0);
|
|
71
|
-
this.Sequence = (Sequence | 0);
|
|
72
|
-
this.Type = (Type | 0);
|
|
73
|
-
this.NestingLevel = NestingLevel;
|
|
74
|
-
this.IsRequired = IsRequired;
|
|
75
|
-
this.Text = Text$;
|
|
76
|
-
this.SequenceText = SequenceText;
|
|
77
|
-
this.Code = Code;
|
|
78
|
-
this.Uuid = Uuid;
|
|
79
|
-
this.GenderRequired = GenderRequired;
|
|
80
|
-
this.Highlight = Highlight;
|
|
81
|
-
this.Choices = Choices;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export function BridgeTemplateItem_$reflection(): TypeInfo {
|
|
86
|
-
return record_type("FormSpec.Integrations.CorEMR.CorEMRTemplateMapper.BridgeTemplateItem", [], BridgeTemplateItem, () => [["ItemId", int32_type], ["Sequence", int32_type], ["Type", int32_type], ["NestingLevel", option_type(int32_type)], ["IsRequired", bool_type], ["Text", string_type], ["SequenceText", option_type(string_type)], ["Code", option_type(string_type)], ["Uuid", option_type(string_type)], ["GenderRequired", option_type(string_type)], ["Highlight", option_type(int32_type)], ["Choices", list_type(BridgeTemplateChoice_$reflection())]]);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export class BridgeTemplateDetail extends Record implements IEquatable<BridgeTemplateDetail>, IComparable<BridgeTemplateDetail> {
|
|
90
|
-
readonly FormId: int32;
|
|
91
|
-
readonly Name: string;
|
|
92
|
-
readonly FormCode: Option<string>;
|
|
93
|
-
readonly Description: Option<string>;
|
|
94
|
-
readonly CurrentVersionId: Option<int32>;
|
|
95
|
-
readonly IsIntake: Option<boolean>;
|
|
96
|
-
readonly RequiresSignature: Option<boolean>;
|
|
97
|
-
readonly Items: FSharpList<BridgeTemplateItem>;
|
|
98
|
-
readonly FormCategory: Option<string>;
|
|
99
|
-
readonly InstrumentType: Option<string>;
|
|
100
|
-
readonly InstrumentConfidence: Option<string>;
|
|
101
|
-
readonly InstrumentMaxScore: Option<int32>;
|
|
102
|
-
constructor(FormId: int32, Name: string, FormCode: Option<string>, Description: Option<string>, CurrentVersionId: Option<int32>, IsIntake: Option<boolean>, RequiresSignature: Option<boolean>, Items: FSharpList<BridgeTemplateItem>, FormCategory: Option<string>, InstrumentType: Option<string>, InstrumentConfidence: Option<string>, InstrumentMaxScore: Option<int32>) {
|
|
103
|
-
super();
|
|
104
|
-
this.FormId = (FormId | 0);
|
|
105
|
-
this.Name = Name;
|
|
106
|
-
this.FormCode = FormCode;
|
|
107
|
-
this.Description = Description;
|
|
108
|
-
this.CurrentVersionId = CurrentVersionId;
|
|
109
|
-
this.IsIntake = IsIntake;
|
|
110
|
-
this.RequiresSignature = RequiresSignature;
|
|
111
|
-
this.Items = Items;
|
|
112
|
-
this.FormCategory = FormCategory;
|
|
113
|
-
this.InstrumentType = InstrumentType;
|
|
114
|
-
this.InstrumentConfidence = InstrumentConfidence;
|
|
115
|
-
this.InstrumentMaxScore = InstrumentMaxScore;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export function BridgeTemplateDetail_$reflection(): TypeInfo {
|
|
120
|
-
return record_type("FormSpec.Integrations.CorEMR.CorEMRTemplateMapper.BridgeTemplateDetail", [], BridgeTemplateDetail, () => [["FormId", int32_type], ["Name", string_type], ["FormCode", option_type(string_type)], ["Description", option_type(string_type)], ["CurrentVersionId", option_type(int32_type)], ["IsIntake", option_type(bool_type)], ["RequiresSignature", option_type(bool_type)], ["Items", list_type(BridgeTemplateItem_$reflection())], ["FormCategory", option_type(string_type)], ["InstrumentType", option_type(string_type)], ["InstrumentConfidence", option_type(string_type)], ["InstrumentMaxScore", option_type(int32_type)]]);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
33
|
const multiSelectCodes: FSharpSet<string> = ofSeq(["chips_notes", "checkbox", "checkbox_notes", "chips_ros"], {
|
|
124
34
|
Compare: comparePrimitives,
|
|
125
35
|
});
|
|
@@ -129,20 +39,18 @@ function hasTextHasDateFromBridge(textField: string): [boolean, boolean] {
|
|
|
129
39
|
}
|
|
130
40
|
|
|
131
41
|
/**
|
|
132
|
-
* Map
|
|
133
|
-
*
|
|
42
|
+
* Map catalog classification fields to FormClassification DU.
|
|
43
|
+
* formCategory, instrumentType, instrumentConfidence, maxScore come from the catalog FormListItem,
|
|
44
|
+
* not from TemplateForm (which doesn't carry them).
|
|
134
45
|
*/
|
|
135
|
-
export function mapFormClassification(
|
|
136
|
-
let matchValue_3: Option<string>;
|
|
137
|
-
const matchValue: Option<string> = detail.FormCategory;
|
|
138
|
-
const matchValue_1: Option<string> = detail.InstrumentType;
|
|
46
|
+
export function mapFormClassification(formCategory: Option<string>, instrumentType: Option<string>, instrumentConfidence: Option<string>, instrumentMaxScore: Option<int32>): Spec_FormClassification_$union {
|
|
139
47
|
let matchResult: int32, instType: string;
|
|
140
|
-
if (
|
|
141
|
-
switch (
|
|
48
|
+
if (formCategory != null) {
|
|
49
|
+
switch (value_3(formCategory)) {
|
|
142
50
|
case "clinical_instrument": {
|
|
143
|
-
if (
|
|
51
|
+
if (instrumentType != null) {
|
|
144
52
|
matchResult = 0;
|
|
145
|
-
instType =
|
|
53
|
+
instType = value_3(instrumentType);
|
|
146
54
|
}
|
|
147
55
|
else {
|
|
148
56
|
matchResult = 3;
|
|
@@ -166,7 +74,7 @@ export function mapFormClassification(detail: BridgeTemplateDetail): Spec_FormCl
|
|
|
166
74
|
}
|
|
167
75
|
switch (matchResult) {
|
|
168
76
|
case 0:
|
|
169
|
-
return Spec_FormClassification_ClinicalInstrument(new Spec_ClinicalInstrumentInfo(instType!, (
|
|
77
|
+
return Spec_FormClassification_ClinicalInstrument(new Spec_ClinicalInstrumentInfo(instType!, (instrumentConfidence != null) ? ((value_3(instrumentConfidence) === "exact") ? Spec_InstrumentConfidence_Exact() : Spec_InstrumentConfidence_Inferred()) : Spec_InstrumentConfidence_Inferred(), instrumentMaxScore));
|
|
170
78
|
case 1:
|
|
171
79
|
return Spec_FormClassification_Intake();
|
|
172
80
|
case 2:
|
|
@@ -177,13 +85,13 @@ export function mapFormClassification(detail: BridgeTemplateDetail): Spec_FormCl
|
|
|
177
85
|
}
|
|
178
86
|
|
|
179
87
|
/**
|
|
180
|
-
* Map bridge template to CoreMRFormDetail.
|
|
88
|
+
* Map bridge template (TemplateForm — SSOT) to CoreMRFormDetail.
|
|
181
89
|
* When elementTypes is non-empty, use it for ItemTypeName, HasText, HasDate, and bitmask detection.
|
|
182
90
|
* When elementTypes is empty, fallback to CorEMRElementTypeMap.
|
|
183
91
|
*/
|
|
184
|
-
export function mapNewTemplateToCoreMRDetail(elementTypes: FSharpMap<int32, BridgeElementTypeInfo>, template:
|
|
185
|
-
const metadata: CoreMRFormMetadata = new CoreMRFormMetadata(template.FormId, template.Name, template.Description,
|
|
186
|
-
const items: FSharpList<CoreMRItem> = map<
|
|
92
|
+
export function mapNewTemplateToCoreMRDetail(elementTypes: FSharpMap<int32, BridgeElementTypeInfo>, template: TemplateForm): CoreMRFormDetail {
|
|
93
|
+
const metadata: CoreMRFormMetadata = new CoreMRFormMetadata(template.FormId, template.Name, isNullOrEmpty(template.Description) ? undefined : template.Description, ~~toInt32(template.CurrentVersionId), 1, undefined, template.RequiresSignature, template.IsIntake, template.FormCode, "");
|
|
94
|
+
const items: FSharpList<CoreMRItem> = map<TemplateItem, CoreMRItem>((item: TemplateItem): CoreMRItem => {
|
|
187
95
|
let info_1: BridgeElementTypeInfo;
|
|
188
96
|
const itemTypeId: int32 = item.Type | 0;
|
|
189
97
|
const value: BridgeElementTypeInfo = new BridgeElementTypeInfo(`unknown_${itemTypeId}`, "unknown", "unknown");
|
|
@@ -192,30 +100,27 @@ export function mapNewTemplateToCoreMRDetail(elementTypes: FSharpMap<int32, Brid
|
|
|
192
100
|
return new BridgeElementTypeInfo(info.Code, info.ValueEncoding, info.TextFieldRole);
|
|
193
101
|
}), value);
|
|
194
102
|
const patternInput: [boolean, boolean] = hasTextHasDateFromBridge(info_1.TextFieldRole);
|
|
195
|
-
return new CoreMRItem(item.ItemId, item.Sequence,
|
|
103
|
+
return new CoreMRItem(item.ItemId, item.Sequence, item.NestingLevel, item.SequenceText, item.Type, info_1.Code, !isEmpty(item.Choices), patternInput[0], patternInput[1], item.Text, item.IsRequired, item.GenderRequired, map_1<int32, string>(int32ToString, item.Highlight), item.Code, item.Uuid, undefined, undefined, 0, 0, undefined);
|
|
196
104
|
}, template.Items);
|
|
197
105
|
const multiSelectTypes: FSharpSet<int32> = isEmpty_1<int32, BridgeElementTypeInfo>(elementTypes) ? ofSeq([26, 40, 41, 143], {
|
|
198
106
|
Compare: comparePrimitives,
|
|
199
107
|
}) : ofSeq<int32>(keys<int32, BridgeElementTypeInfo>(filter<int32, BridgeElementTypeInfo>((_arg: int32, info_2: BridgeElementTypeInfo): boolean => contains<string>(info_2.Code, multiSelectCodes), elementTypes)), {
|
|
200
108
|
Compare: comparePrimitives,
|
|
201
109
|
});
|
|
202
|
-
return new CoreMRFormDetail(metadata, items, collect<
|
|
203
|
-
const sortedChoices: FSharpList<
|
|
110
|
+
return new CoreMRFormDetail(metadata, items, collect<TemplateItem, CoreMRChoice>((item_1: TemplateItem): FSharpList<CoreMRChoice> => {
|
|
111
|
+
const sortedChoices: FSharpList<TemplateChoice> = sortBy<TemplateChoice, int32>((c: TemplateChoice): int32 => c.Sequence, item_1.Choices, {
|
|
204
112
|
Compare: comparePrimitives,
|
|
205
113
|
});
|
|
206
|
-
const patternInput_1: [FSharpList<int32>, boolean] = normalizeChoiceScores(map<
|
|
114
|
+
const patternInput_1: [FSharpList<int32>, boolean] = normalizeChoiceScores(map<TemplateChoice, int64>((c_1: TemplateChoice): int64 => c_1.Score, sortedChoices));
|
|
207
115
|
const bitPositions: Option<FSharpList<int32>> = (FSharpSet__Contains(multiSelectTypes, item_1.Type) && patternInput_1[1]) ? patternInput_1[0] : undefined;
|
|
208
|
-
return mapIndexed<
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
}, bitPositions));
|
|
217
|
-
return new CoreMRChoice(defaultArg(choice.ChoiceId, ((item_1.ItemId * 1000) + index) + 1), item_1.ItemId, defaultArg(choice.Sequence, index + 1), defaultArg(choice.Text, ""), defaultArg(choice.Score, 0n), bitPosition, choice.Code, choice.Highlight);
|
|
218
|
-
}, sortedChoices);
|
|
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
|
+
if (index < length(positions)) {
|
|
118
|
+
return item_2(index, positions);
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
return undefined;
|
|
122
|
+
}
|
|
123
|
+
}, bitPositions)), choice.Code, map_1<int32, string>(int32ToString, choice.Highlight))), sortedChoices);
|
|
219
124
|
}, template.Items), empty<CoreMRTrigger>(), empty<CoreMRTag>(), undefined);
|
|
220
125
|
}
|
|
221
126
|
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import { Record, Union } from "@fable-org/fable-library-js/Types.js";
|
|
2
|
+
import { list_type, record_type, option_type, string_type, int32_type, union_type, TypeInfo } from "@fable-org/fable-library-js/Reflection.js";
|
|
3
|
+
import { int32 } from "@fable-org/fable-library-js/Int32.js";
|
|
4
|
+
import { value, Option } from "@fable-org/fable-library-js/Option.js";
|
|
5
|
+
import { equals, IComparable, IEquatable } from "@fable-org/fable-library-js/Util.js";
|
|
6
|
+
import { isEmpty, take, iterate, filter, length, FSharpList } from "@fable-org/fable-library-js/List.js";
|
|
7
|
+
import { join, printf, toText } from "@fable-org/fable-library-js/String.js";
|
|
8
|
+
|
|
9
|
+
export type DecodeIssueSeverity_$union =
|
|
10
|
+
| DecodeIssueSeverity<0>
|
|
11
|
+
| DecodeIssueSeverity<1>
|
|
12
|
+
|
|
13
|
+
export type DecodeIssueSeverity_$cases = {
|
|
14
|
+
0: ["Error", []],
|
|
15
|
+
1: ["Warning", []]
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function DecodeIssueSeverity_Error() {
|
|
19
|
+
return new DecodeIssueSeverity<0>(0, []);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function DecodeIssueSeverity_Warning() {
|
|
23
|
+
return new DecodeIssueSeverity<1>(1, []);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export class DecodeIssueSeverity<Tag extends keyof DecodeIssueSeverity_$cases> extends Union<Tag, DecodeIssueSeverity_$cases[Tag][0]> {
|
|
27
|
+
constructor(readonly tag: Tag, readonly fields: DecodeIssueSeverity_$cases[Tag][1]) {
|
|
28
|
+
super();
|
|
29
|
+
}
|
|
30
|
+
cases() {
|
|
31
|
+
return ["Error", "Warning"];
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function DecodeIssueSeverity_$reflection(): TypeInfo {
|
|
36
|
+
return union_type("FormSpec.Integrations.CorEMR.TemplateDecodeTypes.DecodeIssueSeverity", [], DecodeIssueSeverity, () => [[], []]);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export type DecodeIssuePath_$union =
|
|
40
|
+
| DecodeIssuePath<0>
|
|
41
|
+
| DecodeIssuePath<1>
|
|
42
|
+
| DecodeIssuePath<2>
|
|
43
|
+
| DecodeIssuePath<3>
|
|
44
|
+
|
|
45
|
+
export type DecodeIssuePath_$cases = {
|
|
46
|
+
0: ["PayloadLevel", []],
|
|
47
|
+
1: ["FormLevel", [int32, string]],
|
|
48
|
+
2: ["ItemLevel", [int32, string, int32, string]],
|
|
49
|
+
3: ["ChoiceLevel", [int32, string, int32, string, int32, Option<string>]]
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function DecodeIssuePath_PayloadLevel() {
|
|
53
|
+
return new DecodeIssuePath<0>(0, []);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function DecodeIssuePath_FormLevel(formId: int32, formName: string) {
|
|
57
|
+
return new DecodeIssuePath<1>(1, [formId, formName]);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function DecodeIssuePath_ItemLevel(formId: int32, formName: string, itemId: int32, itemText: string) {
|
|
61
|
+
return new DecodeIssuePath<2>(2, [formId, formName, itemId, itemText]);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function DecodeIssuePath_ChoiceLevel(formId: int32, formName: string, itemId: int32, itemText: string, choiceIndex: int32, choiceText: Option<string>) {
|
|
65
|
+
return new DecodeIssuePath<3>(3, [formId, formName, itemId, itemText, choiceIndex, choiceText]);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export class DecodeIssuePath<Tag extends keyof DecodeIssuePath_$cases> extends Union<Tag, DecodeIssuePath_$cases[Tag][0]> {
|
|
69
|
+
constructor(readonly tag: Tag, readonly fields: DecodeIssuePath_$cases[Tag][1]) {
|
|
70
|
+
super();
|
|
71
|
+
}
|
|
72
|
+
cases() {
|
|
73
|
+
return ["PayloadLevel", "FormLevel", "ItemLevel", "ChoiceLevel"];
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function DecodeIssuePath_$reflection(): TypeInfo {
|
|
78
|
+
return union_type("FormSpec.Integrations.CorEMR.TemplateDecodeTypes.DecodeIssuePath", [], DecodeIssuePath, () => [[], [["formId", int32_type], ["formName", string_type]], [["formId", int32_type], ["formName", string_type], ["itemId", int32_type], ["itemText", string_type]], [["formId", int32_type], ["formName", string_type], ["itemId", int32_type], ["itemText", string_type], ["choiceIndex", int32_type], ["choiceText", option_type(string_type)]]]);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export class DecodeIssue extends Record implements IEquatable<DecodeIssue>, IComparable<DecodeIssue> {
|
|
82
|
+
readonly Path: DecodeIssuePath_$union;
|
|
83
|
+
readonly Severity: DecodeIssueSeverity_$union;
|
|
84
|
+
readonly Field: string;
|
|
85
|
+
readonly Expected: string;
|
|
86
|
+
readonly Got: string;
|
|
87
|
+
readonly Message: string;
|
|
88
|
+
constructor(Path: DecodeIssuePath_$union, Severity: DecodeIssueSeverity_$union, Field: string, Expected: string, Got: string, Message: string) {
|
|
89
|
+
super();
|
|
90
|
+
this.Path = Path;
|
|
91
|
+
this.Severity = Severity;
|
|
92
|
+
this.Field = Field;
|
|
93
|
+
this.Expected = Expected;
|
|
94
|
+
this.Got = Got;
|
|
95
|
+
this.Message = Message;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export function DecodeIssue_$reflection(): TypeInfo {
|
|
100
|
+
return record_type("FormSpec.Integrations.CorEMR.TemplateDecodeTypes.DecodeIssue", [], DecodeIssue, () => [["Path", DecodeIssuePath_$reflection()], ["Severity", DecodeIssueSeverity_$reflection()], ["Field", string_type], ["Expected", string_type], ["Got", string_type], ["Message", string_type]]);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export class DecodeBatchResult$1<T> extends Record implements IEquatable<DecodeBatchResult$1<T>>, IComparable<DecodeBatchResult$1<T>> {
|
|
104
|
+
readonly Succeeded: FSharpList<T>;
|
|
105
|
+
readonly Issues: FSharpList<DecodeIssue>;
|
|
106
|
+
readonly SkippedTemplates: int32;
|
|
107
|
+
readonly SkippedItems: int32;
|
|
108
|
+
readonly SkippedChoices: int32;
|
|
109
|
+
readonly TotalTemplates: int32;
|
|
110
|
+
readonly TotalItems: int32;
|
|
111
|
+
readonly TotalChoices: int32;
|
|
112
|
+
constructor(Succeeded: FSharpList<T>, Issues: FSharpList<DecodeIssue>, SkippedTemplates: int32, SkippedItems: int32, SkippedChoices: int32, TotalTemplates: int32, TotalItems: int32, TotalChoices: int32) {
|
|
113
|
+
super();
|
|
114
|
+
this.Succeeded = Succeeded;
|
|
115
|
+
this.Issues = Issues;
|
|
116
|
+
this.SkippedTemplates = (SkippedTemplates | 0);
|
|
117
|
+
this.SkippedItems = (SkippedItems | 0);
|
|
118
|
+
this.SkippedChoices = (SkippedChoices | 0);
|
|
119
|
+
this.TotalTemplates = (TotalTemplates | 0);
|
|
120
|
+
this.TotalItems = (TotalItems | 0);
|
|
121
|
+
this.TotalChoices = (TotalChoices | 0);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export function DecodeBatchResult$1_$reflection(gen0: TypeInfo): TypeInfo {
|
|
126
|
+
return record_type("FormSpec.Integrations.CorEMR.TemplateDecodeTypes.DecodeBatchResult`1", [gen0], DecodeBatchResult$1, () => [["Succeeded", list_type(gen0)], ["Issues", list_type(DecodeIssue_$reflection())], ["SkippedTemplates", int32_type], ["SkippedItems", int32_type], ["SkippedChoices", int32_type], ["TotalTemplates", int32_type], ["TotalItems", int32_type], ["TotalChoices", int32_type]]);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function formatPath(path: DecodeIssuePath_$union): string {
|
|
130
|
+
switch (path.tag) {
|
|
131
|
+
case /* FormLevel */ 1: {
|
|
132
|
+
const formName: string = path.fields[1];
|
|
133
|
+
const formId: int32 = path.fields[0] | 0;
|
|
134
|
+
return toText(printf("Form \'%s\' (FormId: %d)"))(formName)(formId);
|
|
135
|
+
}
|
|
136
|
+
case /* ItemLevel */ 2: {
|
|
137
|
+
const itemText: string = path.fields[3];
|
|
138
|
+
const itemId: int32 = path.fields[2] | 0;
|
|
139
|
+
const formName_1: string = path.fields[1];
|
|
140
|
+
const formId_1: int32 = path.fields[0] | 0;
|
|
141
|
+
return toText(printf("Form \'%s\' (FormId: %d): Item #%d \'%s\'"))(formName_1)(formId_1)(itemId)(itemText);
|
|
142
|
+
}
|
|
143
|
+
case /* ChoiceLevel */ 3: {
|
|
144
|
+
const itemText_1: string = path.fields[3];
|
|
145
|
+
const itemId_1: int32 = path.fields[2] | 0;
|
|
146
|
+
const formName_2: string = path.fields[1];
|
|
147
|
+
const formId_2: int32 = path.fields[0] | 0;
|
|
148
|
+
const choiceText: Option<string> = path.fields[5];
|
|
149
|
+
const choiceIndex: int32 = path.fields[4] | 0;
|
|
150
|
+
let choicePart: string;
|
|
151
|
+
if (choiceText == null) {
|
|
152
|
+
choicePart = toText(printf("Choice #%d"))(choiceIndex);
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
const t: string = value(choiceText);
|
|
156
|
+
choicePart = toText(printf("Choice #%d (text: \'%s\')"))(choiceIndex)(t);
|
|
157
|
+
}
|
|
158
|
+
return toText(printf("Form \'%s\' (FormId: %d): Item #%d \'%s\' — %s"))(formName_2)(formId_2)(itemId_1)(itemText_1)(choicePart);
|
|
159
|
+
}
|
|
160
|
+
default:
|
|
161
|
+
return "payload";
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Format a single DecodeIssue for display.
|
|
167
|
+
*/
|
|
168
|
+
export function formatIssue(issue: DecodeIssue): string {
|
|
169
|
+
const pathStr: string = formatPath(issue.Path);
|
|
170
|
+
return toText(printf("%s — Field \'%s\': expected %s, got %s"))(pathStr)(issue.Field)(issue.Expected)(issue.Got);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Human-readable summary for DecodeBatchResult (partial success).
|
|
175
|
+
*/
|
|
176
|
+
export function formatSummary<T>(result: DecodeBatchResult$1<T>): string {
|
|
177
|
+
let arg_4: int32, arg_7: int32;
|
|
178
|
+
const lines: string[] = [];
|
|
179
|
+
const successCount: int32 = length(result.Succeeded) | 0;
|
|
180
|
+
void (lines.push(toText(printf("Decoded %d/%d templates successfully."))(successCount)(result.TotalTemplates)));
|
|
181
|
+
if (result.SkippedTemplates > 0) {
|
|
182
|
+
const templateIssues: FSharpList<DecodeIssue> = filter<DecodeIssue>((i: DecodeIssue): boolean => {
|
|
183
|
+
const matchValue: DecodeIssuePath_$union = i.Path;
|
|
184
|
+
switch (matchValue.tag) {
|
|
185
|
+
case /* ItemLevel */ 2:
|
|
186
|
+
case /* ChoiceLevel */ 3:
|
|
187
|
+
return false;
|
|
188
|
+
default:
|
|
189
|
+
return true;
|
|
190
|
+
}
|
|
191
|
+
}, result.Issues);
|
|
192
|
+
void (lines.push(""));
|
|
193
|
+
void (lines.push(toText(printf("%d templates skipped:"))(result.SkippedTemplates)));
|
|
194
|
+
iterate<DecodeIssue>((i_1: DecodeIssue): void => {
|
|
195
|
+
let arg_3: string;
|
|
196
|
+
void (lines.push((arg_3 = formatIssue(i_1), toText(printf(" %s"))(arg_3))));
|
|
197
|
+
}, take<DecodeIssue>(10, templateIssues));
|
|
198
|
+
if (length(templateIssues) > 10) {
|
|
199
|
+
void (lines.push((arg_4 = ((length(templateIssues) - 10) | 0), toText(printf(" ... and %d more"))(arg_4))));
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
if (result.SkippedChoices > 0) {
|
|
203
|
+
const choiceIssues: FSharpList<DecodeIssue> = filter<DecodeIssue>((i_2: DecodeIssue): boolean => {
|
|
204
|
+
if (i_2.Path.tag === /* ChoiceLevel */ 3) {
|
|
205
|
+
return equals(i_2.Severity, DecodeIssueSeverity_Warning());
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
return false;
|
|
209
|
+
}
|
|
210
|
+
}, result.Issues);
|
|
211
|
+
void (lines.push(""));
|
|
212
|
+
void (lines.push(toText(printf("%d choices skipped across successful templates (non-fatal warnings):"))(result.SkippedChoices)));
|
|
213
|
+
iterate<DecodeIssue>((i_3: DecodeIssue): void => {
|
|
214
|
+
let arg_6: string;
|
|
215
|
+
void (lines.push((arg_6 = formatIssue(i_3), toText(printf(" %s"))(arg_6))));
|
|
216
|
+
}, take<DecodeIssue>(5, choiceIssues));
|
|
217
|
+
if (length(choiceIssues) > 5) {
|
|
218
|
+
void (lines.push((arg_7 = ((length(choiceIssues) - 5) | 0), toText(printf(" ... and %d more"))(arg_7))));
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
return join("\n", lines);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Human-readable summary for DecodeIssue list (hard failure, no partial success).
|
|
226
|
+
*/
|
|
227
|
+
export function formatDecodeErrors(issues: FSharpList<DecodeIssue>): string {
|
|
228
|
+
let arg: int32, arg_2: int32;
|
|
229
|
+
if (isEmpty(issues)) {
|
|
230
|
+
return "Decode failed (no details)";
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
233
|
+
const lines: string[] = [];
|
|
234
|
+
void (lines.push((arg = (length(issues) | 0), toText(printf("Decode failed: %d issue(s)"))(arg))));
|
|
235
|
+
iterate<DecodeIssue>((i: DecodeIssue): void => {
|
|
236
|
+
let arg_1: string;
|
|
237
|
+
void (lines.push((arg_1 = formatIssue(i), toText(printf(" %s"))(arg_1))));
|
|
238
|
+
}, take<DecodeIssue>(10, issues));
|
|
239
|
+
if (length(issues) > 10) {
|
|
240
|
+
void (lines.push((arg_2 = ((length(issues) - 10) | 0), toText(printf(" ... and %d more"))(arg_2))));
|
|
241
|
+
}
|
|
242
|
+
return join("\n", lines);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
//# sourceMappingURL=TemplateDecodeTypes.ts.map
|