@f1studio/form-spec 5.0.0-alpha.165 → 5.0.0-alpha.167

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.
Files changed (22) hide show
  1. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateMapper.d.ts +13 -13
  2. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateMapper.d.ts.map +1 -1
  3. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateMapper.js +25 -121
  4. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateMapper.js.map +1 -1
  5. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMREncoder.js.map +1 -1
  6. package/FormSpec.FS/Integrations/CorEMR/ItemTriggerConverter.d.ts.map +1 -1
  7. package/FormSpec.FS/Integrations/CorEMR/ItemTriggerConverter.js +13 -4
  8. package/FormSpec.FS/Integrations/CorEMR/ItemTriggerConverter.js.map +1 -1
  9. package/FormSpec.FS/Integrations/CorEMR/TemplateManifestDecoder.d.ts +98 -27
  10. package/FormSpec.FS/Integrations/CorEMR/TemplateManifestDecoder.d.ts.map +1 -1
  11. package/FormSpec.FS/Integrations/CorEMR/TemplateManifestDecoder.js +500 -81
  12. package/FormSpec.FS/Integrations/CorEMR/TemplateManifestDecoder.js.map +1 -1
  13. package/FormSpec.FS/Interop/Facade/FormItemLookup.d.ts +95 -0
  14. package/FormSpec.FS/Interop/Facade/FormItemLookup.d.ts.map +1 -0
  15. package/FormSpec.FS/Interop/Facade/FormItemLookup.js +155 -0
  16. package/FormSpec.FS/Interop/Facade/FormItemLookup.js.map +1 -0
  17. package/README.md +7 -7
  18. package/package.json +5 -1
  19. package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateMapper.ts +44 -105
  20. package/src/FormSpec.FS/Integrations/CorEMR/ItemTriggerConverter.ts +11 -2
  21. package/src/FormSpec.FS/Integrations/CorEMR/TemplateManifestDecoder.ts +469 -82
  22. package/src/FormSpec.FS/Interop/Facade/FormItemLookup.ts +179 -0
@@ -1,17 +1,173 @@
1
- import { Union, Record } from "@fable-org/fable-library-js/Types.js";
1
+ import { Record, Union } from "@fable-org/fable-library-js/Types.js";
2
+ import { ofArray, empty, FSharpList } from "@fable-org/fable-library-js/List.js";
3
+ import { bool_type, class_type, record_type, option_type, int64_type, int32_type, union_type, list_type, string_type, TypeInfo } from "@fable-org/fable-library-js/Reflection.js";
4
+ import { defaultArg, value as value_13, Option } from "@fable-org/fable-library-js/Option.js";
2
5
  import { int32 } from "@fable-org/fable-library-js/Int32.js";
3
- import { toInt32, int64 } from "@fable-org/fable-library-js/BigInt.js";
4
- import { map as map_1, defaultArg, Option } from "@fable-org/fable-library-js/Option.js";
5
- import { int32ToString, uncurry2, comparePrimitives, IComparable, IEquatable } from "@fable-org/fable-library-js/Util.js";
6
- import { union_type, bool_type, class_type, list_type, record_type, option_type, string_type, int64_type, int32_type, TypeInfo } from "@fable-org/fable-library-js/Reflection.js";
7
- import { collect, map as map_2, isEmpty, empty, FSharpList } from "@fable-org/fable-library-js/List.js";
8
- import { tryFind, empty as empty_1, ofList, FSharpMap } from "@fable-org/fable-library-js/Map.js";
6
+ import { join as join_1, printf, toText } from "@fable-org/fable-library-js/String.js";
7
+ import { int64 } from "@fable-org/fable-library-js/BigInt.js";
8
+ import { uncurry3, uncurry2, comparePrimitives, IComparable, IEquatable } from "@fable-org/fable-library-js/Util.js";
9
+ import { empty as empty_1, ofList, FSharpMap } from "@fable-org/fable-library-js/Map.js";
9
10
  import { Auto_generateBoxedDecoder_Z6670B51 } from "../../../Thoth.Json/packages/Thoth.Json/Decode.js";
10
- import { FSharpResult$2_$union } from "@fable-org/fable-library-js/Result.js";
11
+ import { Result_Bind, FSharpResult$2_Error, FSharpResult$2_Ok, FSharpResult$2_$union } from "@fable-org/fable-library-js/Result.js";
11
12
  import { ErrorReason_$union } from "../../../Thoth.Json/packages/Thoth.Json/Types.js";
12
- import { fromString, bool, list as list_3, IOptionalGetter, IGetters, string, int, IRequiredGetter, object, map, keyValuePairs } from "../../../Thoth.Json/packages/Thoth.Json/Decode.js";
13
- import { isNullOrEmpty, printf, toFail } from "@fable-org/fable-library-js/String.js";
14
- import { CoreMRFormData, CoreMRTag, CoreMRTrigger, CoreMRFormMetadata, CoreMRItem, CoreMRChoice } from "./CoreMRTypes.js";
13
+ import { fromString, at, bool, IOptionalGetter, int, IGetters, list, string, IRequiredGetter, object, succeed, fail, andThen, map, keyValuePairs } from "../../../Thoth.Json/packages/Thoth.Json/Decode.js";
14
+ import { empty as empty_2, singleton, append, delay, toList } from "@fable-org/fable-library-js/Seq.js";
15
+
16
+ export type ReleaseAvailability$1_$union<T> =
17
+ | ReleaseAvailability$1<T, 0>
18
+ | ReleaseAvailability$1<T, 1>
19
+ | ReleaseAvailability$1<T, 2>
20
+
21
+ export type ReleaseAvailability$1_$cases<T> = {
22
+ 0: ["Stated", [T]],
23
+ 1: ["NotInRelease", [string]],
24
+ 2: ["NotReadYet", [string, FSharpList<string>]]
25
+ }
26
+
27
+ export function ReleaseAvailability$1_Stated<T>(Item: T) {
28
+ return new ReleaseAvailability$1<T, 0>(0, [Item]);
29
+ }
30
+
31
+ export function ReleaseAvailability$1_NotInRelease<T>(because: string) {
32
+ return new ReleaseAvailability$1<T, 1>(1, [because]);
33
+ }
34
+
35
+ export function ReleaseAvailability$1_NotReadYet<T>(because: string, witness: FSharpList<string>) {
36
+ return new ReleaseAvailability$1<T, 2>(2, [because, witness]);
37
+ }
38
+
39
+ export class ReleaseAvailability$1<T, Tag extends keyof ReleaseAvailability$1_$cases<T>> extends Union<Tag, ReleaseAvailability$1_$cases<T>[Tag][0]> {
40
+ constructor(readonly tag: Tag, readonly fields: ReleaseAvailability$1_$cases<T>[Tag][1]) {
41
+ super();
42
+ }
43
+ cases() {
44
+ return ["Stated", "NotInRelease", "NotReadYet"];
45
+ }
46
+ }
47
+
48
+ export function ReleaseAvailability$1_$reflection(gen0: TypeInfo): TypeInfo {
49
+ return union_type("FormSpec.Integrations.CorEMR.TemplateManifestDecoder.ReleaseAvailability`1", [gen0], ReleaseAvailability$1, () => [[["Item", gen0]], [["because", string_type]], [["because", string_type], ["witness", list_type(string_type)]]]);
50
+ }
51
+
52
+ /**
53
+ * The `kind` tag this crossed the wire under. ⭐ ONE home for the three spellings, so conduit's
54
+ * emission and this build's narrowing cannot drift.
55
+ */
56
+ export function ReleaseAvailability_kind<T>(a: ReleaseAvailability$1_$union<T>): string {
57
+ switch (a.tag) {
58
+ case /* NotInRelease */ 1:
59
+ return "notInRelease";
60
+ case /* NotReadYet */ 2:
61
+ return "notReadYet";
62
+ default:
63
+ return "stated";
64
+ }
65
+ }
66
+
67
+ /**
68
+ * Conduit's own reason, where there is one. `None` means it is stated and read.
69
+ */
70
+ export function ReleaseAvailability_because<T>(a: ReleaseAvailability$1_$union<T>): Option<string> {
71
+ switch (a.tag) {
72
+ case /* NotInRelease */ 1:
73
+ return a.fields[0];
74
+ case /* NotReadYet */ 2:
75
+ return a.fields[0];
76
+ default:
77
+ return undefined;
78
+ }
79
+ }
80
+
81
+ /**
82
+ * The objects that DO state it — only `NotReadYet` names any. ⛔ An empty list here is not evidence
83
+ * of absence; it means this case does not carry witnesses.
84
+ */
85
+ export function ReleaseAvailability_witness<T>(a: ReleaseAvailability$1_$union<T>): FSharpList<string> {
86
+ switch (a.tag) {
87
+ case /* Stated */ 0:
88
+ case /* NotInRelease */ 1:
89
+ return empty<string>();
90
+ default:
91
+ return a.fields[1];
92
+ }
93
+ }
94
+
95
+ /**
96
+ * The same release fact over a differently-shaped value. ⭐ The two absences pass through untouched —
97
+ * ⛔ there is no case here that could turn one into the other.
98
+ */
99
+ export function ReleaseAvailability_map<a, b>(f: ((arg0: a) => b), a: ReleaseAvailability$1_$union<a>): ReleaseAvailability$1_$union<b> {
100
+ switch (a.tag) {
101
+ case /* NotInRelease */ 1:
102
+ return ReleaseAvailability$1_NotInRelease<b>(a.fields[0]);
103
+ case /* NotReadYet */ 2:
104
+ return ReleaseAvailability$1_NotReadYet<b>(a.fields[0], a.fields[1]);
105
+ default:
106
+ return ReleaseAvailability$1_Stated<b>(f(a.fields[0]));
107
+ }
108
+ }
109
+
110
+ /**
111
+ * ⚠️ WHAT THIS BUILD READ, and nothing more. Both absences give `[]`, meaning **"nothing was read"** —
112
+ * ⛔ NEVER "there is none". At 5.5.0+9704 this returns `[]` over 2,606 stated triggers.
113
+ */
114
+ export function ReleaseAvailability_readList<T>(a: ReleaseAvailability$1_$union<FSharpList<T>>): FSharpList<T> {
115
+ switch (a.tag) {
116
+ case /* NotInRelease */ 1:
117
+ case /* NotReadYet */ 2:
118
+ return empty<T>();
119
+ default:
120
+ return a.fields[0];
121
+ }
122
+ }
123
+
124
+ /**
125
+ * ⚠️ `true` ONLY where the release states it AND states `true`. Both absences give `false`, meaning
126
+ * **"not listed"** — ⛔ never "the site denies it". 5.5.0+9704 cannot say either way about `other`.
127
+ */
128
+ export function ReleaseAvailability_statedTrue(a: ReleaseAvailability$1_$union<boolean>): boolean {
129
+ switch (a.tag) {
130
+ case /* NotInRelease */ 1:
131
+ case /* NotReadYet */ 2:
132
+ return false;
133
+ default:
134
+ return a.fields[0];
135
+ }
136
+ }
137
+
138
+ /**
139
+ * ⚠️ A LAYOUT DEPTH ONLY. Both absences render UNINDENTED — a rendering decision, ⛔ never a claim that
140
+ * the item sits at the root of a hierarchy this release states differently.
141
+ */
142
+ export function ReleaseAvailability_renderDepth(a: ReleaseAvailability$1_$union<int32>): int32 {
143
+ switch (a.tag) {
144
+ case /* NotInRelease */ 1:
145
+ case /* NotReadYet */ 2:
146
+ return 0;
147
+ default:
148
+ return a.fields[0] | 0;
149
+ }
150
+ }
151
+
152
+ /**
153
+ * ⭐ ONE SENTENCE A HUMAN CAN READ, for a UI that must show WHY a number is not there. It keeps the
154
+ * two absences apart in words as well as in the type.
155
+ */
156
+ export function ReleaseAvailability_describe<T>(a: ReleaseAvailability$1_$union<T>): string {
157
+ switch (a.tag) {
158
+ case /* NotInRelease */ 1: {
159
+ const b: string = a.fields[0];
160
+ return toText(printf("not in this release: %s"))(b);
161
+ }
162
+ case /* NotReadYet */ 2: {
163
+ const b_1: string = a.fields[0];
164
+ const arg_2: string = join_1(", ", a.fields[1]);
165
+ return toText(printf("stated by this release, NOT READ YET: %s (stated by: %s)"))(b_1)(arg_2);
166
+ }
167
+ default:
168
+ return "stated by this release, and read";
169
+ }
170
+ }
15
171
 
16
172
  export class TemplateChoice extends Record implements IEquatable<TemplateChoice>, IComparable<TemplateChoice> {
17
173
  readonly ChoiceId: int32;
@@ -103,7 +259,7 @@ export class TemplateItem extends Record implements IEquatable<TemplateItem>, IC
103
259
  readonly ItemId: int32;
104
260
  readonly Sequence: int32;
105
261
  readonly Type: int32;
106
- readonly NestingLevel: int32;
262
+ readonly NestingLevel: ReleaseAvailability$1_$union<int32>;
107
263
  readonly IsRequired: boolean;
108
264
  readonly Text: string;
109
265
  readonly SequenceText: Option<string>;
@@ -112,13 +268,13 @@ export class TemplateItem extends Record implements IEquatable<TemplateItem>, IC
112
268
  readonly GenderRequired: Option<string>;
113
269
  readonly Highlight: Option<int32>;
114
270
  readonly Choices: FSharpList<TemplateChoice>;
115
- readonly Triggers: FSharpList<ItemTrigger>;
116
- constructor(ItemId: int32, Sequence: int32, Type: int32, NestingLevel: int32, IsRequired: boolean, Text$: string, SequenceText: Option<string>, Code: Option<string>, Uuid: Option<string>, GenderRequired: Option<string>, Highlight: Option<int32>, Choices: FSharpList<TemplateChoice>, Triggers: FSharpList<ItemTrigger>) {
271
+ readonly Triggers: ReleaseAvailability$1_$union<FSharpList<ItemTrigger>>;
272
+ constructor(ItemId: int32, Sequence: int32, Type: int32, NestingLevel: ReleaseAvailability$1_$union<int32>, IsRequired: boolean, Text$: string, SequenceText: Option<string>, Code: Option<string>, Uuid: Option<string>, GenderRequired: Option<string>, Highlight: Option<int32>, Choices: FSharpList<TemplateChoice>, Triggers: ReleaseAvailability$1_$union<FSharpList<ItemTrigger>>) {
117
273
  super();
118
274
  this.ItemId = (ItemId | 0);
119
275
  this.Sequence = (Sequence | 0);
120
276
  this.Type = (Type | 0);
121
- this.NestingLevel = (NestingLevel | 0);
277
+ this.NestingLevel = NestingLevel;
122
278
  this.IsRequired = IsRequired;
123
279
  this.Text = Text$;
124
280
  this.SequenceText = SequenceText;
@@ -132,15 +288,15 @@ export class TemplateItem extends Record implements IEquatable<TemplateItem>, IC
132
288
  }
133
289
 
134
290
  export function TemplateItem_$reflection(): TypeInfo {
135
- return record_type("FormSpec.Integrations.CorEMR.TemplateManifestDecoder.TemplateItem", [], TemplateItem, () => [["ItemId", int32_type], ["Sequence", int32_type], ["Type", int32_type], ["NestingLevel", 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(TemplateChoice_$reflection())], ["Triggers", list_type(ItemTrigger_$reflection())]]);
291
+ return record_type("FormSpec.Integrations.CorEMR.TemplateManifestDecoder.TemplateItem", [], TemplateItem, () => [["ItemId", int32_type], ["Sequence", int32_type], ["Type", int32_type], ["NestingLevel", ReleaseAvailability$1_$reflection(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(TemplateChoice_$reflection())], ["Triggers", ReleaseAvailability$1_$reflection(list_type(ItemTrigger_$reflection()))]]);
136
292
  }
137
293
 
138
294
  export class EncounterTypes extends Record implements IEquatable<EncounterTypes>, IComparable<EncounterTypes> {
139
295
  readonly Medical: boolean;
140
296
  readonly Mental: boolean;
141
297
  readonly Dental: boolean;
142
- readonly Other: boolean;
143
- constructor(Medical: boolean, Mental: boolean, Dental: boolean, Other: boolean) {
298
+ readonly Other: ReleaseAvailability$1_$union<boolean>;
299
+ constructor(Medical: boolean, Mental: boolean, Dental: boolean, Other: ReleaseAvailability$1_$union<boolean>) {
144
300
  super();
145
301
  this.Medical = Medical;
146
302
  this.Mental = Mental;
@@ -150,7 +306,7 @@ export class EncounterTypes extends Record implements IEquatable<EncounterTypes>
150
306
  }
151
307
 
152
308
  export function EncounterTypes_$reflection(): TypeInfo {
153
- return record_type("FormSpec.Integrations.CorEMR.TemplateManifestDecoder.EncounterTypes", [], EncounterTypes, () => [["Medical", bool_type], ["Mental", bool_type], ["Dental", bool_type], ["Other", bool_type]]);
309
+ return record_type("FormSpec.Integrations.CorEMR.TemplateManifestDecoder.EncounterTypes", [], EncounterTypes, () => [["Medical", bool_type], ["Mental", bool_type], ["Dental", bool_type], ["Other", ReleaseAvailability$1_$reflection(bool_type)]]);
154
310
  }
155
311
 
156
312
  export class ScoringLabel extends Record implements IEquatable<ScoringLabel>, IComparable<ScoringLabel> {
@@ -339,28 +495,24 @@ export class TemplateStats extends Record implements IEquatable<TemplateStats>,
339
495
  readonly TotalForms: int32;
340
496
  readonly WithCodes: int32;
341
497
  readonly WithSyntheticCodes: int32;
342
- readonly WithScoring: int32;
343
498
  readonly WithSignature: int32;
344
499
  readonly ByUsage: FSharpMap<string, int32>;
345
500
  readonly ByElementType: FSharpMap<string, int32>;
346
501
  readonly CodeExtraction: CodeExtractionStats;
347
- readonly TriggerStats: Option<TriggerStats>;
348
- constructor(TotalForms: int32, WithCodes: int32, WithSyntheticCodes: int32, WithScoring: int32, WithSignature: int32, ByUsage: FSharpMap<string, int32>, ByElementType: FSharpMap<string, int32>, CodeExtraction: CodeExtractionStats, TriggerStats: Option<TriggerStats>) {
502
+ constructor(TotalForms: int32, WithCodes: int32, WithSyntheticCodes: int32, WithSignature: int32, ByUsage: FSharpMap<string, int32>, ByElementType: FSharpMap<string, int32>, CodeExtraction: CodeExtractionStats) {
349
503
  super();
350
504
  this.TotalForms = (TotalForms | 0);
351
505
  this.WithCodes = (WithCodes | 0);
352
506
  this.WithSyntheticCodes = (WithSyntheticCodes | 0);
353
- this.WithScoring = (WithScoring | 0);
354
507
  this.WithSignature = (WithSignature | 0);
355
508
  this.ByUsage = ByUsage;
356
509
  this.ByElementType = ByElementType;
357
510
  this.CodeExtraction = CodeExtraction;
358
- this.TriggerStats = TriggerStats;
359
511
  }
360
512
  }
361
513
 
362
514
  export function TemplateStats_$reflection(): TypeInfo {
363
- return record_type("FormSpec.Integrations.CorEMR.TemplateManifestDecoder.TemplateStats", [], TemplateStats, () => [["TotalForms", int32_type], ["WithCodes", int32_type], ["WithSyntheticCodes", int32_type], ["WithScoring", int32_type], ["WithSignature", int32_type], ["ByUsage", class_type("Microsoft.FSharp.Collections.FSharpMap`2", [string_type, int32_type])], ["ByElementType", class_type("Microsoft.FSharp.Collections.FSharpMap`2", [string_type, int32_type])], ["CodeExtraction", CodeExtractionStats_$reflection()], ["TriggerStats", option_type(TriggerStats_$reflection())]]);
515
+ return record_type("FormSpec.Integrations.CorEMR.TemplateManifestDecoder.TemplateStats", [], TemplateStats, () => [["TotalForms", int32_type], ["WithCodes", int32_type], ["WithSyntheticCodes", int32_type], ["WithSignature", int32_type], ["ByUsage", class_type("Microsoft.FSharp.Collections.FSharpMap`2", [string_type, int32_type])], ["ByElementType", class_type("Microsoft.FSharp.Collections.FSharpMap`2", [string_type, int32_type])], ["CodeExtraction", CodeExtractionStats_$reflection()]]);
364
516
  }
365
517
 
366
518
  export class CoreEmrInfo extends Record implements IEquatable<CoreEmrInfo>, IComparable<CoreEmrInfo> {
@@ -399,6 +551,22 @@ export function InstrumentMapStats_$reflection(): TypeInfo {
399
551
  return record_type("FormSpec.Integrations.CorEMR.TemplateManifestDecoder.InstrumentMapStats", [], InstrumentMapStats, () => [["Total", int32_type], ["Current", int32_type], ["Archived", int32_type], ["BySource", class_type("Microsoft.FSharp.Collections.FSharpMap`2", [string_type, int32_type])], ["ByType", class_type("Microsoft.FSharp.Collections.FSharpMap`2", [string_type, int32_type])]]);
400
552
  }
401
553
 
554
+ export class ScoringCatalog extends Record implements IEquatable<ScoringCatalog>, IComparable<ScoringCatalog> {
555
+ readonly InstrumentMap: FSharpMap<string, InstrumentMapEntry>;
556
+ readonly InstrumentMapStats: InstrumentMapStats;
557
+ readonly FormsWithScoring: int32;
558
+ constructor(InstrumentMap: FSharpMap<string, InstrumentMapEntry>, InstrumentMapStats: InstrumentMapStats, FormsWithScoring: int32) {
559
+ super();
560
+ this.InstrumentMap = InstrumentMap;
561
+ this.InstrumentMapStats = InstrumentMapStats;
562
+ this.FormsWithScoring = (FormsWithScoring | 0);
563
+ }
564
+ }
565
+
566
+ export function ScoringCatalog_$reflection(): TypeInfo {
567
+ return record_type("FormSpec.Integrations.CorEMR.TemplateManifestDecoder.ScoringCatalog", [], ScoringCatalog, () => [["InstrumentMap", class_type("Microsoft.FSharp.Collections.FSharpMap`2", [string_type, InstrumentMapEntry_$reflection()])], ["InstrumentMapStats", InstrumentMapStats_$reflection()], ["FormsWithScoring", int32_type]]);
568
+ }
569
+
402
570
  export class TemplateManifest extends Record implements IEquatable<TemplateManifest>, IComparable<TemplateManifest> {
403
571
  readonly Schema: Option<string>;
404
572
  readonly Version: int32;
@@ -409,9 +577,9 @@ export class TemplateManifest extends Record implements IEquatable<TemplateManif
409
577
  readonly ElementTypes: Option<FSharpMap<string, ElementTypeEntry>>;
410
578
  readonly ElementTypesFrom: ElementTypesFrom_$union;
411
579
  readonly Forms: FSharpMap<string, TemplateForm>;
412
- readonly InstrumentMap: FSharpMap<string, InstrumentMapEntry>;
413
- readonly InstrumentMapStats: InstrumentMapStats;
414
- constructor(Schema: Option<string>, Version: int32, GeneratedAt: string, GeneratedFrom: string, CoreEmr: CoreEmrInfo, Stats: TemplateStats, ElementTypes: Option<FSharpMap<string, ElementTypeEntry>>, ElementTypesFrom: ElementTypesFrom_$union, Forms: FSharpMap<string, TemplateForm>, InstrumentMap: FSharpMap<string, InstrumentMapEntry>, InstrumentMapStats: InstrumentMapStats) {
580
+ readonly Scoring: ReleaseAvailability$1_$union<ScoringCatalog>;
581
+ readonly Triggers: ReleaseAvailability$1_$union<TriggerStats>;
582
+ constructor(Schema: Option<string>, Version: int32, GeneratedAt: string, GeneratedFrom: string, CoreEmr: CoreEmrInfo, Stats: TemplateStats, ElementTypes: Option<FSharpMap<string, ElementTypeEntry>>, ElementTypesFrom: ElementTypesFrom_$union, Forms: FSharpMap<string, TemplateForm>, Scoring: ReleaseAvailability$1_$union<ScoringCatalog>, Triggers: ReleaseAvailability$1_$union<TriggerStats>) {
415
583
  super();
416
584
  this.Schema = Schema;
417
585
  this.Version = (Version | 0);
@@ -422,13 +590,13 @@ export class TemplateManifest extends Record implements IEquatable<TemplateManif
422
590
  this.ElementTypes = ElementTypes;
423
591
  this.ElementTypesFrom = ElementTypesFrom;
424
592
  this.Forms = Forms;
425
- this.InstrumentMap = InstrumentMap;
426
- this.InstrumentMapStats = InstrumentMapStats;
593
+ this.Scoring = Scoring;
594
+ this.Triggers = Triggers;
427
595
  }
428
596
  }
429
597
 
430
598
  export function TemplateManifest_$reflection(): TypeInfo {
431
- return record_type("FormSpec.Integrations.CorEMR.TemplateManifestDecoder.TemplateManifest", [], TemplateManifest, () => [["Schema", option_type(string_type)], ["Version", int32_type], ["GeneratedAt", string_type], ["GeneratedFrom", string_type], ["CoreEmr", CoreEmrInfo_$reflection()], ["Stats", TemplateStats_$reflection()], ["ElementTypes", option_type(class_type("Microsoft.FSharp.Collections.FSharpMap`2", [string_type, ElementTypeEntry_$reflection()]))], ["ElementTypesFrom", ElementTypesFrom_$reflection()], ["Forms", class_type("Microsoft.FSharp.Collections.FSharpMap`2", [string_type, TemplateForm_$reflection()])], ["InstrumentMap", class_type("Microsoft.FSharp.Collections.FSharpMap`2", [string_type, InstrumentMapEntry_$reflection()])], ["InstrumentMapStats", InstrumentMapStats_$reflection()]]);
599
+ return record_type("FormSpec.Integrations.CorEMR.TemplateManifestDecoder.TemplateManifest", [], TemplateManifest, () => [["Schema", option_type(string_type)], ["Version", int32_type], ["GeneratedAt", string_type], ["GeneratedFrom", string_type], ["CoreEmr", CoreEmrInfo_$reflection()], ["Stats", TemplateStats_$reflection()], ["ElementTypes", option_type(class_type("Microsoft.FSharp.Collections.FSharpMap`2", [string_type, ElementTypeEntry_$reflection()]))], ["ElementTypesFrom", ElementTypesFrom_$reflection()], ["Forms", class_type("Microsoft.FSharp.Collections.FSharpMap`2", [string_type, TemplateForm_$reflection()])], ["Scoring", ReleaseAvailability$1_$reflection(ScoringCatalog_$reflection())], ["Triggers", ReleaseAvailability$1_$reflection(TriggerStats_$reflection())]]);
432
600
  }
433
601
 
434
602
  const liberatedInt64Decoder: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<int64, [string, ErrorReason_$union]>)) = Auto_generateBoxedDecoder_Z6670B51(int64_type, undefined, undefined);
@@ -442,6 +610,119 @@ function dictDecoder<T>(decoder: ((arg0: string, arg1: any) => FSharpResult$2_$u
442
610
  }), uncurry2(d), path_1, value_1));
443
611
  }
444
612
 
613
+ function orFail<T>(d: ((arg0: string, arg1: any) => FSharpResult$2_$union<FSharpResult$2_$union<T, string>, [string, ErrorReason_$union]>)): ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<T, [string, ErrorReason_$union]>)) {
614
+ const decoder: ((arg0: string, arg1: any) => FSharpResult$2_$union<FSharpResult$2_$union<T, string>, [string, ErrorReason_$union]>) = d;
615
+ return (path_1: string): ((arg0: any) => FSharpResult$2_$union<T, [string, ErrorReason_$union]>) => ((value: any): FSharpResult$2_$union<T, [string, ErrorReason_$union]> => andThen<FSharpResult$2_$union<T, string>, T>(uncurry3((r: FSharpResult$2_$union<T, string>): ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<T, [string, ErrorReason_$union]>)) => {
616
+ if (r.tag === /* Error */ 1) {
617
+ const msg: string = r.fields[0];
618
+ return (path: string): ((arg0: any) => FSharpResult$2_$union<T, [string, ErrorReason_$union]>) => ((arg20$0040_1: any): FSharpResult$2_$union<T, [string, ErrorReason_$union]> => fail<T>(msg, path, arg20$0040_1));
619
+ }
620
+ else {
621
+ const v: T = r.fields[0];
622
+ return (arg10$0040: string): ((arg0: any) => FSharpResult$2_$union<T, [string, ErrorReason_$union]>) => ((arg20$0040: any): FSharpResult$2_$union<T, [string, ErrorReason_$union]> => succeed<T>(v, arg10$0040, arg20$0040));
623
+ }
624
+ }), decoder, path_1, value));
625
+ }
626
+
627
+ function availabilityRowDecoder(field: string): ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<ReleaseAvailability$1_$union<FSharpList<string>>, [string, ErrorReason_$union]>)) {
628
+ return orFail<ReleaseAvailability$1_$union<FSharpList<string>>>((path_7: string, v: any): FSharpResult$2_$union<FSharpResult$2_$union<ReleaseAvailability$1_$union<FSharpList<string>>, string>, [string, ErrorReason_$union]> => object<FSharpResult$2_$union<ReleaseAvailability$1_$union<FSharpList<string>>, string>>((get$: IGetters): FSharpResult$2_$union<ReleaseAvailability$1_$union<FSharpList<string>>, string> => {
629
+ let objectArg_1: IRequiredGetter, objectArg_2: IRequiredGetter, objectArg_3: IRequiredGetter, objectArg_4: IRequiredGetter;
630
+ let matchValue: string;
631
+ const objectArg: IRequiredGetter = get$.Required;
632
+ matchValue = objectArg.Field<string>("kind", string);
633
+ switch (matchValue) {
634
+ case "stated":
635
+ return FSharpResult$2_Ok<ReleaseAvailability$1_$union<FSharpList<string>>, string>(ReleaseAvailability$1_Stated<FSharpList<string>>((objectArg_1 = get$.Required, objectArg_1.Field<FSharpList<string>>("states", (path_2: string, value_2: any): FSharpResult$2_$union<FSharpList<string>, [string, ErrorReason_$union]> => list<string>(string, path_2, value_2)))));
636
+ case "notInRelease":
637
+ return FSharpResult$2_Ok<ReleaseAvailability$1_$union<FSharpList<string>>, string>(ReleaseAvailability$1_NotInRelease<FSharpList<string>>((objectArg_2 = get$.Required, objectArg_2.Field<string>("because", string))));
638
+ case "notReadYet":
639
+ return FSharpResult$2_Ok<ReleaseAvailability$1_$union<FSharpList<string>>, string>(ReleaseAvailability$1_NotReadYet<FSharpList<string>>((objectArg_3 = get$.Required, objectArg_3.Field<string>("because", string)), (objectArg_4 = get$.Required, objectArg_4.Field<FSharpList<string>>("witness", (path_6: string, value_6: any): FSharpResult$2_$union<FSharpList<string>, [string, ErrorReason_$union]> => list<string>(string, path_6, value_6)))));
640
+ default:
641
+ return FSharpResult$2_Error<ReleaseAvailability$1_$union<FSharpList<string>>, string>(toText(printf("`%s.kind` = `%s` is not a kind this build understands (stated | notInRelease | notReadYet). ⛔ It is NOT read as an absence: a word this build does not know might mean the release DOES state it"))(field)(matchValue));
642
+ }
643
+ }, path_7, v));
644
+ }
645
+
646
+ function join<T>(field: string, row: Option<ReleaseAvailability$1_$union<FSharpList<string>>>, datum: Option<T>): FSharpResult$2_$union<ReleaseAvailability$1_$union<T>, string> {
647
+ let matchResult: int32, v: T, because: string, because_1: string, because_2: string, because_3: string, witness: FSharpList<string>;
648
+ if (row != null) {
649
+ switch (value_13(row).tag) {
650
+ case /* NotInRelease */ 1: {
651
+ if (datum == null) {
652
+ matchResult = 5;
653
+ because_2 = (value_13(row) as ReleaseAvailability$1<FSharpList<string>, 1>).fields[0];
654
+ }
655
+ else {
656
+ matchResult = 3;
657
+ because = (value_13(row) as ReleaseAvailability$1<FSharpList<string>, 1>).fields[0];
658
+ }
659
+ break;
660
+ }
661
+ case /* NotReadYet */ 2: {
662
+ if (datum == null) {
663
+ matchResult = 6;
664
+ because_3 = (value_13(row) as ReleaseAvailability$1<FSharpList<string>, 2>).fields[0];
665
+ witness = (value_13(row) as ReleaseAvailability$1<FSharpList<string>, 2>).fields[1];
666
+ }
667
+ else {
668
+ matchResult = 4;
669
+ because_1 = (value_13(row) as ReleaseAvailability$1<FSharpList<string>, 2>).fields[0];
670
+ }
671
+ break;
672
+ }
673
+ default:
674
+ if (datum == null) {
675
+ matchResult = 2;
676
+ }
677
+ else {
678
+ matchResult = 0;
679
+ v = value_13(datum);
680
+ }
681
+ }
682
+ }
683
+ else if (datum == null) {
684
+ matchResult = 1;
685
+ }
686
+ else {
687
+ matchResult = 0;
688
+ v = value_13(datum);
689
+ }
690
+ switch (matchResult) {
691
+ case 0:
692
+ return FSharpResult$2_Ok<ReleaseAvailability$1_$union<T>, string>(ReleaseAvailability$1_Stated<T>(v!));
693
+ case 1:
694
+ return FSharpResult$2_Error<ReleaseAvailability$1_$union<T>, string>(toText(printf("`%s` is absent and NOTHING DECLARES WHY. An undeclared absence cannot be read: it is indistinguishable from a release that does not state it, from one that states it and was not read, and from a payload that lost it in transit"))(field));
695
+ case 2:
696
+ return FSharpResult$2_Error<ReleaseAvailability$1_$union<T>, string>(toText(printf("the manifest declares `%s` STATED by this release, but carries no `%s`"))(field)(field));
697
+ case 3:
698
+ return FSharpResult$2_Error<ReleaseAvailability$1_$union<T>, string>(toText(printf("the manifest declares `%s` NOT IN THIS RELEASE (%s) and carries a value for it anyway"))(field)(because!));
699
+ case 4:
700
+ return FSharpResult$2_Error<ReleaseAvailability$1_$union<T>, string>(toText(printf("the manifest declares `%s` NOT READ YET (%s) and carries a value for it anyway"))(field)(because_1!));
701
+ case 5:
702
+ return FSharpResult$2_Ok<ReleaseAvailability$1_$union<T>, string>(ReleaseAvailability$1_NotInRelease<T>(because_2!));
703
+ default:
704
+ return FSharpResult$2_Ok<ReleaseAvailability$1_$union<T>, string>(ReleaseAvailability$1_NotReadYet<T>(because_3!, witness!));
705
+ }
706
+ }
707
+
708
+ export class FormDeclarations extends Record implements IEquatable<FormDeclarations>, IComparable<FormDeclarations> {
709
+ readonly ItemNesting: Option<ReleaseAvailability$1_$union<FSharpList<string>>>;
710
+ readonly Triggers: Option<ReleaseAvailability$1_$union<FSharpList<string>>>;
711
+ readonly EncounterOther: Option<ReleaseAvailability$1_$union<FSharpList<string>>>;
712
+ constructor(ItemNesting: Option<ReleaseAvailability$1_$union<FSharpList<string>>>, Triggers: Option<ReleaseAvailability$1_$union<FSharpList<string>>>, EncounterOther: Option<ReleaseAvailability$1_$union<FSharpList<string>>>) {
713
+ super();
714
+ this.ItemNesting = ItemNesting;
715
+ this.Triggers = Triggers;
716
+ this.EncounterOther = EncounterOther;
717
+ }
718
+ }
719
+
720
+ export function FormDeclarations_$reflection(): TypeInfo {
721
+ return record_type("FormSpec.Integrations.CorEMR.TemplateManifestDecoder.FormDeclarations", [], FormDeclarations, () => [["ItemNesting", option_type(ReleaseAvailability$1_$reflection(list_type(string_type)))], ["Triggers", option_type(ReleaseAvailability$1_$reflection(list_type(string_type)))], ["EncounterOther", option_type(ReleaseAvailability$1_$reflection(list_type(string_type)))]]);
722
+ }
723
+
724
+ export const declaresNothing: FormDeclarations = new FormDeclarations(undefined, undefined, undefined);
725
+
445
726
  const choiceDecoder = (path_2: string): ((arg0: any) => FSharpResult$2_$union<TemplateChoice, [string, ErrorReason_$union]>) => ((v: any): FSharpResult$2_$union<TemplateChoice, [string, ErrorReason_$union]> => object<TemplateChoice>((get$: IGetters): TemplateChoice => {
446
727
  let objectArg_1: IRequiredGetter, objectArg_2: IRequiredGetter, objectArg_3: IRequiredGetter, objectArg_4: IOptionalGetter, objectArg_5: IOptionalGetter, objectArg_6: IOptionalGetter;
447
728
  let score: int64;
@@ -452,7 +733,7 @@ const choiceDecoder = (path_2: string): ((arg0: any) => FSharpResult$2_$union<Te
452
733
 
453
734
  const triggerConditionDecoder = (path_6: string): ((arg0: any) => FSharpResult$2_$union<TriggerCondition, [string, ErrorReason_$union]>) => ((v: any): FSharpResult$2_$union<TriggerCondition, [string, ErrorReason_$union]> => object<TriggerCondition>((get$: IGetters): TriggerCondition => {
454
735
  let objectArg: IRequiredGetter, objectArg_1: IRequiredGetter, objectArg_2: IRequiredGetter, objectArg_3: IRequiredGetter, objectArg_4: IOptionalGetter, objectArg_5: IOptionalGetter, objectArg_6: IOptionalGetter;
455
- return new TriggerCondition((objectArg = get$.Required, objectArg.Field<int32>("conditionId", uncurry2(int))), (objectArg_1 = get$.Required, objectArg_1.Field<int32>("sourceFieldId", uncurry2(int))), (objectArg_2 = get$.Required, objectArg_2.Field<string>("source", string)), (objectArg_3 = get$.Required, objectArg_3.Field<string>("operator", string)), defaultArg((objectArg_4 = get$.Optional, objectArg_4.Field<FSharpList<string>>("values", (path_3: string, value_3: any): FSharpResult$2_$union<FSharpList<string>, [string, ErrorReason_$union]> => list_3<string>(string, path_3, value_3))), empty<string>()), defaultArg((objectArg_5 = get$.Optional, objectArg_5.Field<FSharpList<int32>>("rawChoiceIds", (path_4: string, value_5: any): FSharpResult$2_$union<FSharpList<int32>, [string, ErrorReason_$union]> => list_3<int32>(uncurry2(int), path_4, value_5))), empty<int32>()), defaultArg((objectArg_6 = get$.Optional, objectArg_6.Field<string>("booleanOperator", string)), "&&"));
736
+ return new TriggerCondition((objectArg = get$.Required, objectArg.Field<int32>("conditionId", uncurry2(int))), (objectArg_1 = get$.Required, objectArg_1.Field<int32>("sourceFieldId", uncurry2(int))), (objectArg_2 = get$.Required, objectArg_2.Field<string>("source", string)), (objectArg_3 = get$.Required, objectArg_3.Field<string>("operator", string)), defaultArg((objectArg_4 = get$.Optional, objectArg_4.Field<FSharpList<string>>("values", (path_3: string, value_3: any): FSharpResult$2_$union<FSharpList<string>, [string, ErrorReason_$union]> => list<string>(string, path_3, value_3))), empty<string>()), defaultArg((objectArg_5 = get$.Optional, objectArg_5.Field<FSharpList<int32>>("rawChoiceIds", (path_4: string, value_5: any): FSharpResult$2_$union<FSharpList<int32>, [string, ErrorReason_$union]> => list<int32>(uncurry2(int), path_4, value_5))), empty<int32>()), defaultArg((objectArg_6 = get$.Optional, objectArg_6.Field<string>("booleanOperator", string)), "&&"));
456
737
  }, path_6, v));
457
738
 
458
739
  const triggerActionDecoder = (path_2: string): ((arg0: any) => FSharpResult$2_$union<TriggerAction, [string, ErrorReason_$union]>) => ((v: any): FSharpResult$2_$union<TriggerAction, [string, ErrorReason_$union]> => object<TriggerAction>((get$: IGetters): TriggerAction => {
@@ -464,18 +745,58 @@ const triggerActionDecoder = (path_2: string): ((arg0: any) => FSharpResult$2_$u
464
745
 
465
746
  const itemTriggerDecoder = (path_5: string): ((arg0: any) => FSharpResult$2_$union<ItemTrigger, [string, ErrorReason_$union]>) => ((v: any): FSharpResult$2_$union<ItemTrigger, [string, ErrorReason_$union]> => object<ItemTrigger>((get$: IGetters): ItemTrigger => {
466
747
  let objectArg: IRequiredGetter, objectArg_1: IRequiredGetter, objectArg_2: IOptionalGetter, objectArg_3: IOptionalGetter, objectArg_4: IOptionalGetter, objectArg_5: IOptionalGetter;
467
- return new ItemTrigger((objectArg = get$.Required, objectArg.Field<int32>("triggerId", uncurry2(int))), (objectArg_1 = get$.Required, objectArg_1.Field<string>("eventName", string)), defaultArg((objectArg_2 = get$.Optional, objectArg_2.Field<boolean>("enabled", bool)), true), (objectArg_3 = get$.Optional, objectArg_3.Field<string>("exclusiveTag", string)), defaultArg((objectArg_4 = get$.Optional, objectArg_4.Field<FSharpList<TriggerCondition>>("conditions", (path_3: string, value_4: any): FSharpResult$2_$union<FSharpList<TriggerCondition>, [string, ErrorReason_$union]> => list_3<TriggerCondition>(uncurry2(triggerConditionDecoder), path_3, value_4))), empty<TriggerCondition>()), defaultArg((objectArg_5 = get$.Optional, objectArg_5.Field<FSharpList<TriggerAction>>("actions", (path_4: string, value_6: any): FSharpResult$2_$union<FSharpList<TriggerAction>, [string, ErrorReason_$union]> => list_3<TriggerAction>(uncurry2(triggerActionDecoder), path_4, value_6))), empty<TriggerAction>()));
748
+ return new ItemTrigger((objectArg = get$.Required, objectArg.Field<int32>("triggerId", uncurry2(int))), (objectArg_1 = get$.Required, objectArg_1.Field<string>("eventName", string)), defaultArg((objectArg_2 = get$.Optional, objectArg_2.Field<boolean>("enabled", bool)), true), (objectArg_3 = get$.Optional, objectArg_3.Field<string>("exclusiveTag", string)), defaultArg((objectArg_4 = get$.Optional, objectArg_4.Field<FSharpList<TriggerCondition>>("conditions", (path_3: string, value_4: any): FSharpResult$2_$union<FSharpList<TriggerCondition>, [string, ErrorReason_$union]> => list<TriggerCondition>(uncurry2(triggerConditionDecoder), path_3, value_4))), empty<TriggerCondition>()), defaultArg((objectArg_5 = get$.Optional, objectArg_5.Field<FSharpList<TriggerAction>>("actions", (path_4: string, value_6: any): FSharpResult$2_$union<FSharpList<TriggerAction>, [string, ErrorReason_$union]> => list<TriggerAction>(uncurry2(triggerActionDecoder), path_4, value_6))), empty<TriggerAction>()));
468
749
  }, path_5, v));
469
750
 
470
- const itemDecoder = (path_8: string): ((arg0: any) => FSharpResult$2_$union<TemplateItem, [string, ErrorReason_$union]>) => ((v: any): FSharpResult$2_$union<TemplateItem, [string, ErrorReason_$union]> => object<TemplateItem>((get$: IGetters): TemplateItem => {
471
- let objectArg: IRequiredGetter, objectArg_1: IRequiredGetter, objectArg_2: IRequiredGetter, objectArg_3: IRequiredGetter, objectArg_4: IRequiredGetter, objectArg_5: IRequiredGetter, objectArg_6: IOptionalGetter, objectArg_7: IOptionalGetter, objectArg_8: IOptionalGetter, objectArg_9: IOptionalGetter, objectArg_10: IOptionalGetter, objectArg_11: IRequiredGetter, objectArg_12: IOptionalGetter;
472
- return new TemplateItem((objectArg = get$.Required, objectArg.Field<int32>("itemId", uncurry2(int))), (objectArg_1 = get$.Required, objectArg_1.Field<int32>("sequence", uncurry2(int))), (objectArg_2 = get$.Required, objectArg_2.Field<int32>("type", uncurry2(int))), (objectArg_3 = get$.Required, objectArg_3.Field<int32>("nestingLevel", uncurry2(int))), (objectArg_4 = get$.Required, objectArg_4.Field<boolean>("isRequired", bool)), (objectArg_5 = get$.Required, objectArg_5.Field<string>("text", string)), (objectArg_6 = get$.Optional, objectArg_6.Field<string>("sequenceText", string)), (objectArg_7 = get$.Optional, objectArg_7.Field<string>("code", string)), (objectArg_8 = get$.Optional, objectArg_8.Field<string>("uuid", string)), (objectArg_9 = get$.Optional, objectArg_9.Field<string>("genderRequired", string)), (objectArg_10 = get$.Optional, objectArg_10.Field<int32>("highlight", uncurry2(int))), (objectArg_11 = get$.Required, objectArg_11.Field<FSharpList<TemplateChoice>>("choices", (path_6: string, value_6: any): FSharpResult$2_$union<FSharpList<TemplateChoice>, [string, ErrorReason_$union]> => list_3<TemplateChoice>(uncurry2(choiceDecoder), path_6, value_6))), defaultArg((objectArg_12 = get$.Optional, objectArg_12.Field<FSharpList<ItemTrigger>>("triggers", (path_7: string, value_7: any): FSharpResult$2_$union<FSharpList<ItemTrigger>, [string, ErrorReason_$union]> => list_3<ItemTrigger>(uncurry2(itemTriggerDecoder), path_7, value_7))), empty<ItemTrigger>()));
473
- }, path_8, v));
751
+ function itemDecoder(declared: FormDeclarations): ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<TemplateItem, [string, ErrorReason_$union]>)) {
752
+ return orFail<TemplateItem>((path_9: string, v: any): FSharpResult$2_$union<FSharpResult$2_$union<TemplateItem, string>, [string, ErrorReason_$union]> => object<FSharpResult$2_$union<TemplateItem, string>>((get$: IGetters): FSharpResult$2_$union<TemplateItem, string> => {
753
+ let objectArg_1: IOptionalGetter, objectArg_2: IOptionalGetter, objectArg_3: IRequiredGetter, objectArg_4: IRequiredGetter, objectArg_5: IRequiredGetter, objectArg_6: IRequiredGetter, objectArg_7: IOptionalGetter, objectArg_8: IOptionalGetter, objectArg_9: IOptionalGetter, objectArg_10: IOptionalGetter, objectArg_11: IOptionalGetter, objectArg_12: IRequiredGetter;
754
+ let itemId: int32;
755
+ const objectArg: IRequiredGetter = get$.Required;
756
+ itemId = objectArg.Field<int32>("itemId", uncurry2(int));
757
+ const path = (f: string): string => toText(printf("forms[].items[itemId=%d].%s"))(itemId)(f);
758
+ const nesting: FSharpResult$2_$union<ReleaseAvailability$1_$union<int32>, string> = join<int32>(path("nestingLevel"), declared.ItemNesting, (objectArg_1 = get$.Optional, objectArg_1.Field<int32>("nestingLevel", uncurry2(int))));
759
+ const triggers: FSharpResult$2_$union<ReleaseAvailability$1_$union<FSharpList<ItemTrigger>>, string> = join<FSharpList<ItemTrigger>>(path("triggers"), declared.Triggers, (objectArg_2 = get$.Optional, objectArg_2.Field<FSharpList<ItemTrigger>>("triggers", (path_1: string, value: any): FSharpResult$2_$union<FSharpList<ItemTrigger>, [string, ErrorReason_$union]> => list<ItemTrigger>(uncurry2(itemTriggerDecoder), path_1, value))));
760
+ let matchResult: int32, itemTriggers: ReleaseAvailability$1_$union<FSharpList<ItemTrigger>>, nestingLevel: ReleaseAvailability$1_$union<int32>, e: string;
761
+ const copyOfStruct: FSharpResult$2_$union<ReleaseAvailability$1_$union<int32>, string> = nesting;
762
+ if (copyOfStruct.tag === /* Error */ 1) {
763
+ matchResult = 1;
764
+ e = copyOfStruct.fields[0];
765
+ }
766
+ else {
767
+ const copyOfStruct_1: FSharpResult$2_$union<ReleaseAvailability$1_$union<FSharpList<ItemTrigger>>, string> = triggers;
768
+ if (copyOfStruct_1.tag === /* Error */ 1) {
769
+ matchResult = 1;
770
+ e = copyOfStruct_1.fields[0];
771
+ }
772
+ else {
773
+ matchResult = 0;
774
+ itemTriggers = copyOfStruct_1.fields[0];
775
+ nestingLevel = copyOfStruct.fields[0];
776
+ }
777
+ }
778
+ switch (matchResult) {
779
+ case 0:
780
+ return FSharpResult$2_Ok<TemplateItem, string>(new TemplateItem(itemId, (objectArg_3 = get$.Required, objectArg_3.Field<int32>("sequence", uncurry2(int))), (objectArg_4 = get$.Required, objectArg_4.Field<int32>("type", uncurry2(int))), nestingLevel!, (objectArg_5 = get$.Required, objectArg_5.Field<boolean>("isRequired", bool)), (objectArg_6 = get$.Required, objectArg_6.Field<string>("text", string)), (objectArg_7 = get$.Optional, objectArg_7.Field<string>("sequenceText", string)), (objectArg_8 = get$.Optional, objectArg_8.Field<string>("code", string)), (objectArg_9 = get$.Optional, objectArg_9.Field<string>("uuid", string)), (objectArg_10 = get$.Optional, objectArg_10.Field<string>("genderRequired", string)), (objectArg_11 = get$.Optional, objectArg_11.Field<int32>("highlight", uncurry2(int))), (objectArg_12 = get$.Required, objectArg_12.Field<FSharpList<TemplateChoice>>("choices", (path_8: string, value_7: any): FSharpResult$2_$union<FSharpList<TemplateChoice>, [string, ErrorReason_$union]> => list<TemplateChoice>(uncurry2(choiceDecoder), path_8, value_7))), itemTriggers!));
781
+ default:
782
+ return FSharpResult$2_Error<TemplateItem, string>(e!);
783
+ }
784
+ }, path_9, v));
785
+ }
474
786
 
475
- const encounterTypesDecoder = (path_4: string): ((arg0: any) => FSharpResult$2_$union<EncounterTypes, [string, ErrorReason_$union]>) => ((v: any): FSharpResult$2_$union<EncounterTypes, [string, ErrorReason_$union]> => object<EncounterTypes>((get$: IGetters): EncounterTypes => {
476
- let objectArg: IRequiredGetter, objectArg_1: IRequiredGetter, objectArg_2: IRequiredGetter, objectArg_3: IRequiredGetter;
477
- return new EncounterTypes((objectArg = get$.Required, objectArg.Field<boolean>("medical", bool)), (objectArg_1 = get$.Required, objectArg_1.Field<boolean>("mental", bool)), (objectArg_2 = get$.Required, objectArg_2.Field<boolean>("dental", bool)), (objectArg_3 = get$.Required, objectArg_3.Field<boolean>("other", bool)));
478
- }, path_4, v));
787
+ function encounterTypesDecoder(declared: FormDeclarations): ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<EncounterTypes, [string, ErrorReason_$union]>)) {
788
+ return orFail<EncounterTypes>((path_4: string, v: any): FSharpResult$2_$union<FSharpResult$2_$union<EncounterTypes, string>, [string, ErrorReason_$union]> => object<FSharpResult$2_$union<EncounterTypes, string>>((get$: IGetters): FSharpResult$2_$union<EncounterTypes, string> => {
789
+ let objectArg: IOptionalGetter, objectArg_1: IRequiredGetter, objectArg_2: IRequiredGetter, objectArg_3: IRequiredGetter;
790
+ const matchValue: FSharpResult$2_$union<ReleaseAvailability$1_$union<boolean>, string> = join<boolean>("forms[].encounterTypes.other", declared.EncounterOther, (objectArg = get$.Optional, objectArg.Field<boolean>("other", bool)));
791
+ if (matchValue.tag === /* Error */ 1) {
792
+ return FSharpResult$2_Error<EncounterTypes, string>(matchValue.fields[0]);
793
+ }
794
+ else {
795
+ const other: ReleaseAvailability$1_$union<boolean> = matchValue.fields[0];
796
+ return FSharpResult$2_Ok<EncounterTypes, string>(new EncounterTypes((objectArg_1 = get$.Required, objectArg_1.Field<boolean>("medical", bool)), (objectArg_2 = get$.Required, objectArg_2.Field<boolean>("mental", bool)), (objectArg_3 = get$.Required, objectArg_3.Field<boolean>("dental", bool)), other));
797
+ }
798
+ }, path_4, v));
799
+ }
479
800
 
480
801
  const scoringLabelDecoder = (path_1: string): ((arg0: any) => FSharpResult$2_$union<ScoringLabel, [string, ErrorReason_$union]>) => ((v: any): FSharpResult$2_$union<ScoringLabel, [string, ErrorReason_$union]> => object<ScoringLabel>((get$: IGetters): ScoringLabel => {
481
802
  let objectArg: IRequiredGetter, objectArg_1: IRequiredGetter;
@@ -484,33 +805,35 @@ const scoringLabelDecoder = (path_1: string): ((arg0: any) => FSharpResult$2_$un
484
805
 
485
806
  const formScoringDecoder = (path_2: string): ((arg0: any) => FSharpResult$2_$union<FormScoring, [string, ErrorReason_$union]>) => ((v: any): FSharpResult$2_$union<FormScoring, [string, ErrorReason_$union]> => object<FormScoring>((get$: IGetters): FormScoring => {
486
807
  let objectArg: IRequiredGetter, objectArg_1: IRequiredGetter, objectArg_2: IRequiredGetter, arg_7: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<FSharpMap<string, int32>, [string, ErrorReason_$union]>)), objectArg_3: IRequiredGetter;
487
- return new FormScoring((objectArg = get$.Required, objectArg.Field<int32>("scoreId", uncurry2(int))), (objectArg_1 = get$.Required, objectArg_1.Field<string>("scoreName", string)), (objectArg_2 = get$.Required, objectArg_2.Field<FSharpList<ScoringLabel>>("labels", (path_1: string, value_1: any): FSharpResult$2_$union<FSharpList<ScoringLabel>, [string, ErrorReason_$union]> => list_3<ScoringLabel>(uncurry2(scoringLabelDecoder), path_1, value_1))), (arg_7 = dictDecoder<int32>(uncurry2(int)), (objectArg_3 = get$.Required, objectArg_3.Field<FSharpMap<string, int32>>("choiceScores", uncurry2(arg_7)))));
808
+ return new FormScoring((objectArg = get$.Required, objectArg.Field<int32>("scoreId", uncurry2(int))), (objectArg_1 = get$.Required, objectArg_1.Field<string>("scoreName", string)), (objectArg_2 = get$.Required, objectArg_2.Field<FSharpList<ScoringLabel>>("labels", (path_1: string, value_1: any): FSharpResult$2_$union<FSharpList<ScoringLabel>, [string, ErrorReason_$union]> => list<ScoringLabel>(uncurry2(scoringLabelDecoder), path_1, value_1))), (arg_7 = dictDecoder<int32>(uncurry2(int)), (objectArg_3 = get$.Required, objectArg_3.Field<FSharpMap<string, int32>>("choiceScores", uncurry2(arg_7)))));
488
809
  }, path_2, v));
489
810
 
490
- const formDecoder = (path_13: string): ((arg0: any) => FSharpResult$2_$union<TemplateForm, [string, ErrorReason_$union]>) => ((v: any): FSharpResult$2_$union<TemplateForm, [string, ErrorReason_$union]> => object<TemplateForm>((get$: IGetters): TemplateForm => {
491
- let objectArg: IRequiredGetter, objectArg_1: IRequiredGetter, objectArg_2: IRequiredGetter, objectArg_3: IRequiredGetter, objectArg_4: IRequiredGetter, objectArg_5: IRequiredGetter, objectArg_6: IRequiredGetter, objectArg_7: IRequiredGetter, objectArg_8: IRequiredGetter, objectArg_9: IRequiredGetter, objectArg_10: IRequiredGetter, objectArg_11: IRequiredGetter, objectArg_12: IRequiredGetter, objectArg_13: IRequiredGetter, objectArg_14: IRequiredGetter, objectArg_15: IRequiredGetter, objectArg_16: IOptionalGetter;
492
- return new TemplateForm((objectArg = get$.Required, objectArg.Field<int32>("formId", uncurry2(int))), (objectArg_1 = get$.Required, objectArg_1.Field<string>("name", string)), (objectArg_2 = get$.Required, objectArg_2.Field<string>("formCode", string)), (objectArg_3 = get$.Required, objectArg_3.Field<string>("formCodeSource", string)), (objectArg_4 = get$.Required, objectArg_4.Field<string>("description", string)), (objectArg_5 = get$.Required, objectArg_5.Field<int64>("currentVersionId", uncurry2(liberatedInt64Decoder))), (objectArg_6 = get$.Required, objectArg_6.Field<boolean>("isIntake", bool)), (objectArg_7 = get$.Required, objectArg_7.Field<string>("usage", string)), (objectArg_8 = get$.Required, objectArg_8.Field<boolean>("requiresSignature", bool)), (objectArg_9 = get$.Required, objectArg_9.Field<EncounterTypes>("encounterTypes", uncurry2(encounterTypesDecoder))), (objectArg_10 = get$.Required, objectArg_10.Field<boolean>("onceAYear", bool)), (objectArg_11 = get$.Required, objectArg_11.Field<string>("structureHash", string)), (objectArg_12 = get$.Required, objectArg_12.Field<string>("clinicalHash", string)), (objectArg_13 = get$.Required, objectArg_13.Field<string>("cosmeticHash", string)), (objectArg_14 = get$.Required, objectArg_14.Field<string>("hash", string)), (objectArg_15 = get$.Required, objectArg_15.Field<FSharpList<TemplateItem>>("items", (path_12: string, value_12: any): FSharpResult$2_$union<FSharpList<TemplateItem>, [string, ErrorReason_$union]> => list_3<TemplateItem>(uncurry2(itemDecoder), path_12, value_12))), (objectArg_16 = get$.Optional, objectArg_16.Field<FormScoring>("scoring", uncurry2(formScoringDecoder))));
493
- }, path_13, v));
811
+ function formDecoder(declared: FormDeclarations): ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<TemplateForm, [string, ErrorReason_$union]>)) {
812
+ return (path_13: string): ((arg0: any) => FSharpResult$2_$union<TemplateForm, [string, ErrorReason_$union]>) => ((v: any): FSharpResult$2_$union<TemplateForm, [string, ErrorReason_$union]> => object<TemplateForm>((get$: IGetters): TemplateForm => {
813
+ let objectArg: IRequiredGetter, objectArg_1: IRequiredGetter, objectArg_2: IRequiredGetter, objectArg_3: IRequiredGetter, objectArg_4: IRequiredGetter, objectArg_5: IRequiredGetter, objectArg_6: IRequiredGetter, objectArg_7: IRequiredGetter, objectArg_8: IRequiredGetter, arg_19: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<EncounterTypes, [string, ErrorReason_$union]>)), objectArg_9: IRequiredGetter, objectArg_10: IRequiredGetter, objectArg_11: IRequiredGetter, objectArg_12: IRequiredGetter, objectArg_13: IRequiredGetter, objectArg_14: IRequiredGetter, arg_31: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<FSharpList<TemplateItem>, [string, ErrorReason_$union]>)), decoder: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<TemplateItem, [string, ErrorReason_$union]>)), objectArg_15: IRequiredGetter, objectArg_16: IOptionalGetter;
814
+ return new TemplateForm((objectArg = get$.Required, objectArg.Field<int32>("formId", uncurry2(int))), (objectArg_1 = get$.Required, objectArg_1.Field<string>("name", string)), (objectArg_2 = get$.Required, objectArg_2.Field<string>("formCode", string)), (objectArg_3 = get$.Required, objectArg_3.Field<string>("formCodeSource", string)), (objectArg_4 = get$.Required, objectArg_4.Field<string>("description", string)), (objectArg_5 = get$.Required, objectArg_5.Field<int64>("currentVersionId", uncurry2(liberatedInt64Decoder))), (objectArg_6 = get$.Required, objectArg_6.Field<boolean>("isIntake", bool)), (objectArg_7 = get$.Required, objectArg_7.Field<string>("usage", string)), (objectArg_8 = get$.Required, objectArg_8.Field<boolean>("requiresSignature", bool)), (arg_19 = encounterTypesDecoder(declared), (objectArg_9 = get$.Required, objectArg_9.Field<EncounterTypes>("encounterTypes", uncurry2(arg_19)))), (objectArg_10 = get$.Required, objectArg_10.Field<boolean>("onceAYear", bool)), (objectArg_11 = get$.Required, objectArg_11.Field<string>("structureHash", string)), (objectArg_12 = get$.Required, objectArg_12.Field<string>("clinicalHash", string)), (objectArg_13 = get$.Required, objectArg_13.Field<string>("cosmeticHash", string)), (objectArg_14 = get$.Required, objectArg_14.Field<string>("hash", string)), (arg_31 = ((decoder = itemDecoder(declared), (path_12: string): ((arg0: any) => FSharpResult$2_$union<FSharpList<TemplateItem>, [string, ErrorReason_$union]>) => ((value_12: any): FSharpResult$2_$union<FSharpList<TemplateItem>, [string, ErrorReason_$union]> => list<TemplateItem>(uncurry2(decoder), path_12, value_12)))), (objectArg_15 = get$.Required, objectArg_15.Field<FSharpList<TemplateItem>>("items", uncurry2(arg_31)))), (objectArg_16 = get$.Optional, objectArg_16.Field<FormScoring>("scoring", uncurry2(formScoringDecoder))));
815
+ }, path_13, v));
816
+ }
494
817
 
495
818
  const elementTypeDecoder = (path_2: string): ((arg0: any) => FSharpResult$2_$union<ElementTypeEntry, [string, ErrorReason_$union]>) => ((v: any): FSharpResult$2_$union<ElementTypeEntry, [string, ErrorReason_$union]> => object<ElementTypeEntry>((get$: IGetters): ElementTypeEntry => {
496
819
  let objectArg: IRequiredGetter, objectArg_1: IRequiredGetter;
497
820
  return new ElementTypeEntry((objectArg = get$.Required, objectArg.Field<string>("label", string)), (objectArg_1 = get$.Required, objectArg_1.Field<string>("control", string)));
498
821
  }, path_2, v));
499
822
 
500
- const elementTypesFromDecoder = (path_6: string): ((arg0: any) => FSharpResult$2_$union<ElementTypesFrom_$union, [string, ErrorReason_$union]>) => ((v: any): FSharpResult$2_$union<ElementTypesFrom_$union, [string, ErrorReason_$union]> => object<ElementTypesFrom_$union>((get$: IGetters): ElementTypesFrom_$union => {
823
+ const elementTypesFromDecoder: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<ElementTypesFrom_$union, [string, ErrorReason_$union]>)) = orFail<ElementTypesFrom_$union>((path_6: string, v: any): FSharpResult$2_$union<FSharpResult$2_$union<ElementTypesFrom_$union, string>, [string, ErrorReason_$union]> => object<FSharpResult$2_$union<ElementTypesFrom_$union, string>>((get$: IGetters): FSharpResult$2_$union<ElementTypesFrom_$union, string> => {
501
824
  let objectArg_1: IRequiredGetter, objectArg_2: IRequiredGetter, objectArg_3: IRequiredGetter, objectArg_4: IRequiredGetter, objectArg_5: IRequiredGetter;
502
825
  let matchValue: string;
503
826
  const objectArg: IRequiredGetter = get$.Required;
504
827
  matchValue = objectArg.Field<string>("statedBy", string);
505
828
  switch (matchValue) {
506
829
  case "site":
507
- return ElementTypesFrom_StatedBy((objectArg_1 = get$.Required, objectArg_1.Field<string>("table", string)), (objectArg_2 = get$.Required, objectArg_2.Field<string>("key", string)), (objectArg_3 = get$.Required, objectArg_3.Field<string>("label", string)));
830
+ return FSharpResult$2_Ok<ElementTypesFrom_$union, string>(ElementTypesFrom_StatedBy((objectArg_1 = get$.Required, objectArg_1.Field<string>("table", string)), (objectArg_2 = get$.Required, objectArg_2.Field<string>("key", string)), (objectArg_3 = get$.Required, objectArg_3.Field<string>("label", string))));
508
831
  case "conduit":
509
- return ElementTypesFrom_DeclaredByConduit((objectArg_4 = get$.Required, objectArg_4.Field<string>("because", string)));
832
+ return FSharpResult$2_Ok<ElementTypesFrom_$union, string>(ElementTypesFrom_DeclaredByConduit((objectArg_4 = get$.Required, objectArg_4.Field<string>("because", string))));
510
833
  case "nobody":
511
- return ElementTypesFrom_NotInRelease((objectArg_5 = get$.Required, objectArg_5.Field<string>("because", string)));
834
+ return FSharpResult$2_Ok<ElementTypesFrom_$union, string>(ElementTypesFrom_NotInRelease((objectArg_5 = get$.Required, objectArg_5.Field<string>("because", string))));
512
835
  default:
513
- return toFail(printf("elementTypesFrom.statedBy = %s is not a provenance this build understands (site | conduit | nobody)"))(matchValue);
836
+ return FSharpResult$2_Error<ElementTypesFrom_$union, string>(toText(printf("`elementTypesFrom.statedBy` = `%s` is not a provenance this build understands (site | conduit | nobody)"))(matchValue));
514
837
  }
515
838
  }, path_6, v));
516
839
 
@@ -532,8 +855,8 @@ const triggerStatsDecoder = (path: string): ((arg0: any) => FSharpResult$2_$unio
532
855
  }, path, v));
533
856
 
534
857
  const statsDecoder = (path: string): ((arg0: any) => FSharpResult$2_$union<TemplateStats, [string, ErrorReason_$union]>) => ((v: any): FSharpResult$2_$union<TemplateStats, [string, ErrorReason_$union]> => object<TemplateStats>((get$: IGetters): TemplateStats => {
535
- let objectArg: IRequiredGetter, objectArg_1: IRequiredGetter, objectArg_2: IRequiredGetter, objectArg_3: IRequiredGetter, objectArg_4: IRequiredGetter, arg_11: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<FSharpMap<string, int32>, [string, ErrorReason_$union]>)), objectArg_5: IRequiredGetter, arg_13: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<FSharpMap<string, int32>, [string, ErrorReason_$union]>)), objectArg_6: IRequiredGetter, objectArg_7: IRequiredGetter, objectArg_8: IOptionalGetter;
536
- return new TemplateStats((objectArg = get$.Required, objectArg.Field<int32>("totalForms", uncurry2(int))), (objectArg_1 = get$.Required, objectArg_1.Field<int32>("withCodes", uncurry2(int))), (objectArg_2 = get$.Required, objectArg_2.Field<int32>("withSyntheticCodes", uncurry2(int))), (objectArg_3 = get$.Required, objectArg_3.Field<int32>("withScoring", uncurry2(int))), (objectArg_4 = get$.Required, objectArg_4.Field<int32>("withSignature", uncurry2(int))), (arg_11 = dictDecoder<int32>(uncurry2(int)), (objectArg_5 = get$.Required, objectArg_5.Field<FSharpMap<string, int32>>("byUsage", uncurry2(arg_11)))), (arg_13 = dictDecoder<int32>(uncurry2(int)), (objectArg_6 = get$.Required, objectArg_6.Field<FSharpMap<string, int32>>("byElementType", uncurry2(arg_13)))), (objectArg_7 = get$.Required, objectArg_7.Field<CodeExtractionStats>("codeExtraction", uncurry2(codeExtractionStatsDecoder))), (objectArg_8 = get$.Optional, objectArg_8.Field<TriggerStats>("triggerStats", uncurry2(triggerStatsDecoder))));
858
+ let objectArg: IRequiredGetter, objectArg_1: IRequiredGetter, objectArg_2: IRequiredGetter, objectArg_3: IRequiredGetter, arg_9: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<FSharpMap<string, int32>, [string, ErrorReason_$union]>)), objectArg_4: IRequiredGetter, arg_11: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<FSharpMap<string, int32>, [string, ErrorReason_$union]>)), objectArg_5: IRequiredGetter, objectArg_6: IRequiredGetter;
859
+ return new TemplateStats((objectArg = get$.Required, objectArg.Field<int32>("totalForms", uncurry2(int))), (objectArg_1 = get$.Required, objectArg_1.Field<int32>("withCodes", uncurry2(int))), (objectArg_2 = get$.Required, objectArg_2.Field<int32>("withSyntheticCodes", uncurry2(int))), (objectArg_3 = get$.Required, objectArg_3.Field<int32>("withSignature", uncurry2(int))), (arg_9 = dictDecoder<int32>(uncurry2(int)), (objectArg_4 = get$.Required, objectArg_4.Field<FSharpMap<string, int32>>("byUsage", uncurry2(arg_9)))), (arg_11 = dictDecoder<int32>(uncurry2(int)), (objectArg_5 = get$.Required, objectArg_5.Field<FSharpMap<string, int32>>("byElementType", uncurry2(arg_11)))), (objectArg_6 = get$.Required, objectArg_6.Field<CodeExtractionStats>("codeExtraction", uncurry2(codeExtractionStatsDecoder))));
537
860
  }, path, v));
538
861
 
539
862
  const coreEmrDecoder = (path_2: string): ((arg0: any) => FSharpResult$2_$union<CoreEmrInfo, [string, ErrorReason_$union]>) => ((v: any): FSharpResult$2_$union<CoreEmrInfo, [string, ErrorReason_$union]> => object<CoreEmrInfo>((get$: IGetters): CoreEmrInfo => {
@@ -546,16 +869,84 @@ const instrumentMapStatsDecoder = (path: string): ((arg0: any) => FSharpResult$2
546
869
  return new InstrumentMapStats((objectArg = get$.Required, objectArg.Field<int32>("total", uncurry2(int))), (objectArg_1 = get$.Required, objectArg_1.Field<int32>("current", uncurry2(int))), (objectArg_2 = get$.Required, objectArg_2.Field<int32>("archived", uncurry2(int))), (arg_7 = dictDecoder<int32>(uncurry2(int)), (objectArg_3 = get$.Required, objectArg_3.Field<FSharpMap<string, int32>>("bySource", uncurry2(arg_7)))), (arg_9 = dictDecoder<int32>(uncurry2(int)), (objectArg_4 = get$.Required, objectArg_4.Field<FSharpMap<string, int32>>("byType", uncurry2(arg_9)))));
547
870
  }, path, v));
548
871
 
549
- const manifestDecoder = (path_3: string): ((arg0: any) => FSharpResult$2_$union<TemplateManifest, [string, ErrorReason_$union]>) => ((v: any): FSharpResult$2_$union<TemplateManifest, [string, ErrorReason_$union]> => object<TemplateManifest>((get$: IGetters): TemplateManifest => {
550
- let objectArg: IOptionalGetter, objectArg_1: IRequiredGetter, objectArg_2: IRequiredGetter, objectArg_3: IRequiredGetter, objectArg_4: IRequiredGetter, objectArg_5: IRequiredGetter, arg_13: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<FSharpMap<string, ElementTypeEntry>, [string, ErrorReason_$union]>)), objectArg_6: IOptionalGetter, objectArg_7: IOptionalGetter, arg_17: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<FSharpMap<string, TemplateForm>, [string, ErrorReason_$union]>)), objectArg_8: IRequiredGetter, arg_19: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<FSharpMap<string, InstrumentMapEntry>, [string, ErrorReason_$union]>)), objectArg_9: IRequiredGetter, objectArg_10: IRequiredGetter;
551
- return new TemplateManifest((objectArg = get$.Optional, objectArg.Field<string>("$schema", string)), (objectArg_1 = get$.Required, objectArg_1.Field<int32>("version", uncurry2(int))), (objectArg_2 = get$.Required, objectArg_2.Field<string>("generatedAt", string)), (objectArg_3 = get$.Required, objectArg_3.Field<string>("generatedFrom", string)), (objectArg_4 = get$.Required, objectArg_4.Field<CoreEmrInfo>("coreEmr", uncurry2(coreEmrDecoder))), (objectArg_5 = get$.Required, objectArg_5.Field<TemplateStats>("stats", uncurry2(statsDecoder))), (arg_13 = dictDecoder<ElementTypeEntry>(uncurry2(elementTypeDecoder)), (objectArg_6 = get$.Optional, objectArg_6.Field<FSharpMap<string, ElementTypeEntry>>("elementTypes", uncurry2(arg_13)))), defaultArg((objectArg_7 = get$.Optional, objectArg_7.Field<ElementTypesFrom_$union>("elementTypesFrom", uncurry2(elementTypesFromDecoder))), ElementTypesFrom_NotInRelease("the manifest carried no `elementTypesFrom`, so no provenance for the item-type vocabulary was stated")), (arg_17 = dictDecoder<TemplateForm>(uncurry2(formDecoder)), (objectArg_8 = get$.Required, objectArg_8.Field<FSharpMap<string, TemplateForm>>("forms", uncurry2(arg_17)))), (arg_19 = dictDecoder<InstrumentMapEntry>(uncurry2(instrumentMapEntryDecoder)), (objectArg_9 = get$.Required, objectArg_9.Field<FSharpMap<string, InstrumentMapEntry>>("instrumentMap", uncurry2(arg_19)))), (objectArg_10 = get$.Required, objectArg_10.Field<InstrumentMapStats>("instrumentMapStats", uncurry2(instrumentMapStatsDecoder))));
552
- }, path_3, v));
553
-
554
- function toCoreMRChoice(itemId: int32, c: TemplateChoice): CoreMRChoice {
555
- return new CoreMRChoice(c.ChoiceId, itemId, c.Sequence, c.Text, c.Score, c.BitPosition, c.Code, map_1<int32, string>(int32ToString, c.Highlight));
872
+ function scoringCatalogOf(instrumentMap: Option<FSharpMap<string, InstrumentMapEntry>>, instrumentMapStats: Option<InstrumentMapStats>, withScoring: Option<int32>): FSharpResult$2_$union<Option<ScoringCatalog>, string> {
873
+ let arg: string;
874
+ let matchResult: int32, m: FSharpMap<string, InstrumentMapEntry>, s: InstrumentMapStats, w: int32;
875
+ if (instrumentMap == null) {
876
+ if (instrumentMapStats == null) {
877
+ if (withScoring == null) {
878
+ matchResult = 1;
879
+ }
880
+ else {
881
+ matchResult = 2;
882
+ }
883
+ }
884
+ else {
885
+ matchResult = 2;
886
+ }
887
+ }
888
+ else if (instrumentMapStats != null) {
889
+ if (withScoring != null) {
890
+ matchResult = 0;
891
+ m = value_13(instrumentMap);
892
+ s = value_13(instrumentMapStats);
893
+ w = value_13(withScoring);
894
+ }
895
+ else {
896
+ matchResult = 2;
897
+ }
898
+ }
899
+ else {
900
+ matchResult = 2;
901
+ }
902
+ switch (matchResult) {
903
+ case 0:
904
+ return FSharpResult$2_Ok<Option<ScoringCatalog>, string>(new ScoringCatalog(m!, s!, w!));
905
+ case 1:
906
+ return FSharpResult$2_Ok<Option<ScoringCatalog>, string>(undefined);
907
+ default:
908
+ return FSharpResult$2_Error<Option<ScoringCatalog>, string>((arg = join_1("`, `", toList<string>(delay<string>((): Iterable<string> => append<string>((instrumentMap != null) ? singleton<string>("instrumentMap") : empty_2<string>(), delay<string>((): Iterable<string> => append<string>((instrumentMapStats != null) ? singleton<string>("instrumentMapStats") : empty_2<string>(), delay<string>((): Iterable<string> => ((withScoring != null) ? singleton<string>("stats.withScoring") : empty_2<string>())))))))), toText(printf("the scoring catalog is PARTIAL — `%s` present, the rest absent. One release fact governs all three; half of it cannot be read"))(arg)));
909
+ }
556
910
  }
557
911
 
912
+ const manifestDecoder: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<TemplateManifest, [string, ErrorReason_$union]>)) = orFail<TemplateManifest>((path_3: string, v: any): FSharpResult$2_$union<FSharpResult$2_$union<TemplateManifest, string>, [string, ErrorReason_$union]> => object<FSharpResult$2_$union<TemplateManifest, string>>((get$: IGetters): FSharpResult$2_$union<TemplateManifest, string> => {
913
+ let arg_1: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<ReleaseAvailability$1_$union<FSharpList<string>>, [string, ErrorReason_$union]>)), objectArg: IOptionalGetter, arg_3: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<ReleaseAvailability$1_$union<FSharpList<string>>, [string, ErrorReason_$union]>)), objectArg_1: IOptionalGetter, arg_5: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<ReleaseAvailability$1_$union<FSharpList<string>>, [string, ErrorReason_$union]>)), objectArg_2: IOptionalGetter, arg_9: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<FSharpMap<string, InstrumentMapEntry>, [string, ErrorReason_$union]>)), objectArg_4: IOptionalGetter, objectArg_5: IOptionalGetter, objectArg_6: IOptionalGetter, objectArg_7: IRequiredGetter, objectArg_8: IRequiredGetter, objectArg_9: IRequiredGetter, objectArg_10: IRequiredGetter, objectArg_11: IRequiredGetter, arg_25: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<FSharpMap<string, ElementTypeEntry>, [string, ErrorReason_$union]>)), objectArg_12: IOptionalGetter, objectArg_13: IOptionalGetter, arg_29: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<FSharpMap<string, TemplateForm>, [string, ErrorReason_$union]>)), objectArg_14: IRequiredGetter;
914
+ const declared: FormDeclarations = new FormDeclarations((arg_1 = availabilityRowDecoder("itemNestingFrom"), (objectArg = get$.Optional, objectArg.Field<ReleaseAvailability$1_$union<FSharpList<string>>>("itemNestingFrom", uncurry2(arg_1)))), (arg_3 = availabilityRowDecoder("triggersFrom"), (objectArg_1 = get$.Optional, objectArg_1.Field<ReleaseAvailability$1_$union<FSharpList<string>>>("triggersFrom", uncurry2(arg_3)))), (arg_5 = availabilityRowDecoder("encounterOtherFrom"), (objectArg_2 = get$.Optional, objectArg_2.Field<ReleaseAvailability$1_$union<FSharpList<string>>>("encounterOtherFrom", uncurry2(arg_5)))));
915
+ let scoringRow: Option<ReleaseAvailability$1_$union<FSharpList<string>>>;
916
+ const arg_7: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<ReleaseAvailability$1_$union<FSharpList<string>>, [string, ErrorReason_$union]>)) = availabilityRowDecoder("scoringFrom");
917
+ const objectArg_3: IOptionalGetter = get$.Optional;
918
+ scoringRow = objectArg_3.Field<ReleaseAvailability$1_$union<FSharpList<string>>>("scoringFrom", uncurry2(arg_7));
919
+ const scoring: FSharpResult$2_$union<ReleaseAvailability$1_$union<ScoringCatalog>, string> = Result_Bind<Option<ScoringCatalog>, ReleaseAvailability$1_$union<ScoringCatalog>, string>((datum: Option<ScoringCatalog>): FSharpResult$2_$union<ReleaseAvailability$1_$union<ScoringCatalog>, string> => join<ScoringCatalog>("scoringFrom (instrumentMap + instrumentMapStats + stats.withScoring)", scoringRow, datum), scoringCatalogOf((arg_9 = dictDecoder<InstrumentMapEntry>(uncurry2(instrumentMapEntryDecoder)), (objectArg_4 = get$.Optional, objectArg_4.Field<FSharpMap<string, InstrumentMapEntry>>("instrumentMap", uncurry2(arg_9)))), (objectArg_5 = get$.Optional, objectArg_5.Field<InstrumentMapStats>("instrumentMapStats", uncurry2(instrumentMapStatsDecoder))), get$.Optional.Raw<int32>((firstPath: string, firstValue: any): FSharpResult$2_$union<int32, [string, ErrorReason_$union]> => at<int32>(ofArray(["stats", "withScoring"]), uncurry2(int), firstPath, firstValue))));
920
+ const triggers: FSharpResult$2_$union<ReleaseAvailability$1_$union<TriggerStats>, string> = join<TriggerStats>("triggersFrom (stats.triggerStats)", declared.Triggers, get$.Optional.Raw<TriggerStats>((firstPath_1: string, firstValue_1: any): FSharpResult$2_$union<TriggerStats, [string, ErrorReason_$union]> => at<TriggerStats>(ofArray(["stats", "triggerStats"]), uncurry2(triggerStatsDecoder), firstPath_1, firstValue_1)));
921
+ let matchResult: int32, scoringAvailability: ReleaseAvailability$1_$union<ScoringCatalog>, triggerAvailability: ReleaseAvailability$1_$union<TriggerStats>, e: string;
922
+ const copyOfStruct: FSharpResult$2_$union<ReleaseAvailability$1_$union<ScoringCatalog>, string> = scoring;
923
+ if (copyOfStruct.tag === /* Error */ 1) {
924
+ matchResult = 1;
925
+ e = copyOfStruct.fields[0];
926
+ }
927
+ else {
928
+ const copyOfStruct_1: FSharpResult$2_$union<ReleaseAvailability$1_$union<TriggerStats>, string> = triggers;
929
+ if (copyOfStruct_1.tag === /* Error */ 1) {
930
+ matchResult = 1;
931
+ e = copyOfStruct_1.fields[0];
932
+ }
933
+ else {
934
+ matchResult = 0;
935
+ scoringAvailability = copyOfStruct.fields[0];
936
+ triggerAvailability = copyOfStruct_1.fields[0];
937
+ }
938
+ }
939
+ switch (matchResult) {
940
+ case 0:
941
+ return FSharpResult$2_Ok<TemplateManifest, string>(new TemplateManifest((objectArg_6 = get$.Optional, objectArg_6.Field<string>("$schema", string)), (objectArg_7 = get$.Required, objectArg_7.Field<int32>("version", uncurry2(int))), (objectArg_8 = get$.Required, objectArg_8.Field<string>("generatedAt", string)), (objectArg_9 = get$.Required, objectArg_9.Field<string>("generatedFrom", string)), (objectArg_10 = get$.Required, objectArg_10.Field<CoreEmrInfo>("coreEmr", uncurry2(coreEmrDecoder))), (objectArg_11 = get$.Required, objectArg_11.Field<TemplateStats>("stats", uncurry2(statsDecoder))), (arg_25 = dictDecoder<ElementTypeEntry>(uncurry2(elementTypeDecoder)), (objectArg_12 = get$.Optional, objectArg_12.Field<FSharpMap<string, ElementTypeEntry>>("elementTypes", uncurry2(arg_25)))), defaultArg((objectArg_13 = get$.Optional, objectArg_13.Field<ElementTypesFrom_$union>("elementTypesFrom", uncurry2(elementTypesFromDecoder))), ElementTypesFrom_NotInRelease("the manifest carried no `elementTypesFrom`, so no provenance for the item-type vocabulary was stated")), (arg_29 = dictDecoder<TemplateForm>(uncurry2(formDecoder(declared))), (objectArg_14 = get$.Required, objectArg_14.Field<FSharpMap<string, TemplateForm>>("forms", uncurry2(arg_29)))), scoringAvailability!, triggerAvailability!));
942
+ default:
943
+ return FSharpResult$2_Error<TemplateManifest, string>(e!);
944
+ }
945
+ }, path_3, v));
946
+
558
947
  /**
948
+ * Convert a TemplateChoice to CoreMRChoice (FormSpec type).
949
+ * Score stays int64 — raw scores can reach 2^31 for bitmask forms.
559
950
  * Does this control carry free text, and does it carry a date?
560
951
  *
561
952
  * ⭐ THE ONE IMPLEMENTATION. It lives here because this file compiles before every adapter that needs
@@ -628,40 +1019,36 @@ export function carriesTextOrDate(control: string): [boolean, boolean] {
628
1019
  }
629
1020
  }
630
1021
 
631
- function toCoreMRItem(kinds: FSharpMap<string, ElementTypeEntry>, item: TemplateItem): CoreMRItem {
632
- let control: string;
633
- const value = `unresolved_${item.Type}`;
634
- control = defaultArg(map_1<ElementTypeEntry, string>((k: ElementTypeEntry): string => k.Control, tryFind<string, ElementTypeEntry>(int32ToString(item.Type), kinds)), value);
635
- const patternInput: [boolean, boolean] = carriesTextOrDate(control);
636
- return new CoreMRItem(item.ItemId, item.Sequence, item.NestingLevel, item.SequenceText, item.Type, control, !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);
1022
+ /**
1023
+ * Decode templates.json manifest. Strict (all-or-nothing).
1024
+ */
1025
+ export function decodeManifest(json: string): FSharpResult$2_$union<TemplateManifest, string> {
1026
+ return fromString<TemplateManifest>(uncurry2(manifestDecoder), json);
637
1027
  }
638
1028
 
639
1029
  /**
640
- * Convert a TemplateForm to CoreMRFormData — the universal pipeline input.
641
- * ⭐ `kinds` IS REQUIRED — the manifest's item vocabulary, stated by the site or declared by conduit.
642
- * ⛔ It is not optional and it does not default: the whole point of FLIP-9 is that a form's fields are
643
- * typed by what the SITE says an item kind is, and a caller that has no kinds is a caller whose items
644
- * cannot be resolved. Passing `Map.empty` is a legitimate statement ("nothing states them"), and every
645
- * field then arrives NAMED as unresolved rather than silently guessed.
1030
+ * Decode a single TemplateForm from JSON (bridge API single-form response).
1031
+ * ⭐ It takes the envelope rows explicitly: a form carries governed fields, and whoever hands one over must
1032
+ * also hand over what the release says about them. `declaresNothing` is the honest answer for a payload
1033
+ * that states nothing — and it then REQUIRES every governed field to be present.
646
1034
  */
647
- export function toCoreMRFormData(kinds: FSharpMap<string, ElementTypeEntry>, form: TemplateForm): CoreMRFormData {
648
- return new CoreMRFormData(new CoreMRFormMetadata(form.FormId, form.Name, isNullOrEmpty(form.Description) ? undefined : form.Description, ~~toInt32(form.CurrentVersionId), 1, undefined, form.RequiresSignature, form.IsIntake, "", ""), map_2<TemplateItem, CoreMRItem>((item: TemplateItem): CoreMRItem => toCoreMRItem(kinds, item), form.Items), collect<TemplateItem, CoreMRChoice>((item_1: TemplateItem): FSharpList<CoreMRChoice> => map_2<TemplateChoice, CoreMRChoice>((c: TemplateChoice): CoreMRChoice => toCoreMRChoice(item_1.ItemId, c), item_1.Choices), form.Items), empty<CoreMRTrigger>(), empty<CoreMRTag>());
1035
+ export function decodeTemplateForm(declared: FormDeclarations, json: string): FSharpResult$2_$union<TemplateForm, string> {
1036
+ return fromString<TemplateForm>(uncurry2(formDecoder(declared)), json);
649
1037
  }
650
1038
 
651
1039
  /**
652
- * Decode templates.json manifest. Strict (all-or-nothing).
1040
+ * Public decoder for TemplateForm — use with Decode.list for batch API responses.
653
1041
  */
654
- export function decodeManifest(json: string): FSharpResult$2_$union<TemplateManifest, string> {
655
- return fromString<TemplateManifest>(uncurry2(manifestDecoder), json);
1042
+ export function templateFormDecoder(declared: FormDeclarations): ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<TemplateForm, [string, ErrorReason_$union]>)) {
1043
+ return formDecoder(declared);
656
1044
  }
657
1045
 
658
1046
  /**
659
- * Decode a single TemplateForm from JSON (bridge API single-form response).
1047
+ * Decode one envelope row (`{ kind, states, because, witness }`) on its own — for a response that carries a
1048
+ * declaration beside its data, such as the single-form endpoint's `triggersFrom`.
660
1049
  */
661
- export function decodeTemplateForm(json: string): FSharpResult$2_$union<TemplateForm, string> {
662
- return fromString<TemplateForm>(uncurry2(formDecoder), json);
1050
+ export function releaseAvailabilityDecoder(field: string): ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<ReleaseAvailability$1_$union<FSharpList<string>>, [string, ErrorReason_$union]>)) {
1051
+ return availabilityRowDecoder(field);
663
1052
  }
664
1053
 
665
- export const templateFormDecoder: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<TemplateForm, [string, ErrorReason_$union]>)) = formDecoder;
666
-
667
1054
  //# sourceMappingURL=TemplateManifestDecoder.ts.map