@f1studio/form-spec 5.0.0-alpha.166 → 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.
@@ -1,16 +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";
6
+ import { join as join_1, printf, toText } from "@fable-org/fable-library-js/String.js";
3
7
  import { int64 } from "@fable-org/fable-library-js/BigInt.js";
4
- import { defaultArg, Option } from "@fable-org/fable-library-js/Option.js";
5
- import { 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 { empty, FSharpList } from "@fable-org/fable-library-js/List.js";
8
+ import { uncurry3, uncurry2, comparePrimitives, IComparable, IEquatable } from "@fable-org/fable-library-js/Util.js";
8
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, IOptionalGetter, IGetters, string, int, IRequiredGetter, object, map, keyValuePairs } from "../../../Thoth.Json/packages/Thoth.Json/Decode.js";
13
- import { printf, toFail } from "@fable-org/fable-library-js/String.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
+ }
14
171
 
15
172
  export class TemplateChoice extends Record implements IEquatable<TemplateChoice>, IComparable<TemplateChoice> {
16
173
  readonly ChoiceId: int32;
@@ -102,7 +259,7 @@ export class TemplateItem extends Record implements IEquatable<TemplateItem>, IC
102
259
  readonly ItemId: int32;
103
260
  readonly Sequence: int32;
104
261
  readonly Type: int32;
105
- readonly NestingLevel: int32;
262
+ readonly NestingLevel: ReleaseAvailability$1_$union<int32>;
106
263
  readonly IsRequired: boolean;
107
264
  readonly Text: string;
108
265
  readonly SequenceText: Option<string>;
@@ -111,13 +268,13 @@ export class TemplateItem extends Record implements IEquatable<TemplateItem>, IC
111
268
  readonly GenderRequired: Option<string>;
112
269
  readonly Highlight: Option<int32>;
113
270
  readonly Choices: FSharpList<TemplateChoice>;
114
- readonly Triggers: FSharpList<ItemTrigger>;
115
- 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>>) {
116
273
  super();
117
274
  this.ItemId = (ItemId | 0);
118
275
  this.Sequence = (Sequence | 0);
119
276
  this.Type = (Type | 0);
120
- this.NestingLevel = (NestingLevel | 0);
277
+ this.NestingLevel = NestingLevel;
121
278
  this.IsRequired = IsRequired;
122
279
  this.Text = Text$;
123
280
  this.SequenceText = SequenceText;
@@ -131,15 +288,15 @@ export class TemplateItem extends Record implements IEquatable<TemplateItem>, IC
131
288
  }
132
289
 
133
290
  export function TemplateItem_$reflection(): TypeInfo {
134
- 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()))]]);
135
292
  }
136
293
 
137
294
  export class EncounterTypes extends Record implements IEquatable<EncounterTypes>, IComparable<EncounterTypes> {
138
295
  readonly Medical: boolean;
139
296
  readonly Mental: boolean;
140
297
  readonly Dental: boolean;
141
- readonly Other: boolean;
142
- 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>) {
143
300
  super();
144
301
  this.Medical = Medical;
145
302
  this.Mental = Mental;
@@ -149,7 +306,7 @@ export class EncounterTypes extends Record implements IEquatable<EncounterTypes>
149
306
  }
150
307
 
151
308
  export function EncounterTypes_$reflection(): TypeInfo {
152
- 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)]]);
153
310
  }
154
311
 
155
312
  export class ScoringLabel extends Record implements IEquatable<ScoringLabel>, IComparable<ScoringLabel> {
@@ -338,28 +495,24 @@ export class TemplateStats extends Record implements IEquatable<TemplateStats>,
338
495
  readonly TotalForms: int32;
339
496
  readonly WithCodes: int32;
340
497
  readonly WithSyntheticCodes: int32;
341
- readonly WithScoring: int32;
342
498
  readonly WithSignature: int32;
343
499
  readonly ByUsage: FSharpMap<string, int32>;
344
500
  readonly ByElementType: FSharpMap<string, int32>;
345
501
  readonly CodeExtraction: CodeExtractionStats;
346
- readonly TriggerStats: Option<TriggerStats>;
347
- 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) {
348
503
  super();
349
504
  this.TotalForms = (TotalForms | 0);
350
505
  this.WithCodes = (WithCodes | 0);
351
506
  this.WithSyntheticCodes = (WithSyntheticCodes | 0);
352
- this.WithScoring = (WithScoring | 0);
353
507
  this.WithSignature = (WithSignature | 0);
354
508
  this.ByUsage = ByUsage;
355
509
  this.ByElementType = ByElementType;
356
510
  this.CodeExtraction = CodeExtraction;
357
- this.TriggerStats = TriggerStats;
358
511
  }
359
512
  }
360
513
 
361
514
  export function TemplateStats_$reflection(): TypeInfo {
362
- 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()]]);
363
516
  }
364
517
 
365
518
  export class CoreEmrInfo extends Record implements IEquatable<CoreEmrInfo>, IComparable<CoreEmrInfo> {
@@ -398,6 +551,22 @@ export function InstrumentMapStats_$reflection(): TypeInfo {
398
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])]]);
399
552
  }
400
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
+
401
570
  export class TemplateManifest extends Record implements IEquatable<TemplateManifest>, IComparable<TemplateManifest> {
402
571
  readonly Schema: Option<string>;
403
572
  readonly Version: int32;
@@ -408,9 +577,9 @@ export class TemplateManifest extends Record implements IEquatable<TemplateManif
408
577
  readonly ElementTypes: Option<FSharpMap<string, ElementTypeEntry>>;
409
578
  readonly ElementTypesFrom: ElementTypesFrom_$union;
410
579
  readonly Forms: FSharpMap<string, TemplateForm>;
411
- readonly InstrumentMap: FSharpMap<string, InstrumentMapEntry>;
412
- readonly InstrumentMapStats: InstrumentMapStats;
413
- 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>) {
414
583
  super();
415
584
  this.Schema = Schema;
416
585
  this.Version = (Version | 0);
@@ -421,13 +590,13 @@ export class TemplateManifest extends Record implements IEquatable<TemplateManif
421
590
  this.ElementTypes = ElementTypes;
422
591
  this.ElementTypesFrom = ElementTypesFrom;
423
592
  this.Forms = Forms;
424
- this.InstrumentMap = InstrumentMap;
425
- this.InstrumentMapStats = InstrumentMapStats;
593
+ this.Scoring = Scoring;
594
+ this.Triggers = Triggers;
426
595
  }
427
596
  }
428
597
 
429
598
  export function TemplateManifest_$reflection(): TypeInfo {
430
- 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())]]);
431
600
  }
432
601
 
433
602
  const liberatedInt64Decoder: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<int64, [string, ErrorReason_$union]>)) = Auto_generateBoxedDecoder_Z6670B51(int64_type, undefined, undefined);
@@ -441,6 +610,119 @@ function dictDecoder<T>(decoder: ((arg0: string, arg1: any) => FSharpResult$2_$u
441
610
  }), uncurry2(d), path_1, value_1));
442
611
  }
443
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
+
444
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 => {
445
727
  let objectArg_1: IRequiredGetter, objectArg_2: IRequiredGetter, objectArg_3: IRequiredGetter, objectArg_4: IOptionalGetter, objectArg_5: IOptionalGetter, objectArg_6: IOptionalGetter;
446
728
  let score: int64;
@@ -466,15 +748,55 @@ const itemTriggerDecoder = (path_5: string): ((arg0: any) => FSharpResult$2_$uni
466
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>()));
467
749
  }, path_5, v));
468
750
 
469
- 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 => {
470
- 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;
471
- 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<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<ItemTrigger>(uncurry2(itemTriggerDecoder), path_7, value_7))), empty<ItemTrigger>()));
472
- }, 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
+ }
473
786
 
474
- 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 => {
475
- let objectArg: IRequiredGetter, objectArg_1: IRequiredGetter, objectArg_2: IRequiredGetter, objectArg_3: IRequiredGetter;
476
- 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)));
477
- }, 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
+ }
478
800
 
479
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 => {
480
802
  let objectArg: IRequiredGetter, objectArg_1: IRequiredGetter;
@@ -486,30 +808,32 @@ const formScoringDecoder = (path_2: string): ((arg0: any) => FSharpResult$2_$uni
486
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)))));
487
809
  }, path_2, v));
488
810
 
489
- 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 => {
490
- 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;
491
- 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<TemplateItem>(uncurry2(itemDecoder), path_12, value_12))), (objectArg_16 = get$.Optional, objectArg_16.Field<FormScoring>("scoring", uncurry2(formScoringDecoder))));
492
- }, 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
+ }
493
817
 
494
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 => {
495
819
  let objectArg: IRequiredGetter, objectArg_1: IRequiredGetter;
496
820
  return new ElementTypeEntry((objectArg = get$.Required, objectArg.Field<string>("label", string)), (objectArg_1 = get$.Required, objectArg_1.Field<string>("control", string)));
497
821
  }, path_2, v));
498
822
 
499
- 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> => {
500
824
  let objectArg_1: IRequiredGetter, objectArg_2: IRequiredGetter, objectArg_3: IRequiredGetter, objectArg_4: IRequiredGetter, objectArg_5: IRequiredGetter;
501
825
  let matchValue: string;
502
826
  const objectArg: IRequiredGetter = get$.Required;
503
827
  matchValue = objectArg.Field<string>("statedBy", string);
504
828
  switch (matchValue) {
505
829
  case "site":
506
- 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))));
507
831
  case "conduit":
508
- 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))));
509
833
  case "nobody":
510
- 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))));
511
835
  default:
512
- 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));
513
837
  }
514
838
  }, path_6, v));
515
839
 
@@ -531,8 +855,8 @@ const triggerStatsDecoder = (path: string): ((arg0: any) => FSharpResult$2_$unio
531
855
  }, path, v));
532
856
 
533
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 => {
534
- 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;
535
- 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))));
536
860
  }, path, v));
537
861
 
538
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 => {
@@ -545,9 +869,79 @@ const instrumentMapStatsDecoder = (path: string): ((arg0: any) => FSharpResult$2
545
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)))));
546
870
  }, path, v));
547
871
 
548
- 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 => {
549
- 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;
550
- 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))));
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
+ }
910
+ }
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
+ }
551
945
  }, path_3, v));
552
946
 
553
947
  /**
@@ -634,11 +1028,27 @@ export function decodeManifest(json: string): FSharpResult$2_$union<TemplateMani
634
1028
 
635
1029
  /**
636
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.
1034
+ */
1035
+ export function decodeTemplateForm(declared: FormDeclarations, json: string): FSharpResult$2_$union<TemplateForm, string> {
1036
+ return fromString<TemplateForm>(uncurry2(formDecoder(declared)), json);
1037
+ }
1038
+
1039
+ /**
1040
+ * Public decoder for TemplateForm — use with Decode.list for batch API responses.
637
1041
  */
638
- export function decodeTemplateForm(json: string): FSharpResult$2_$union<TemplateForm, string> {
639
- return fromString<TemplateForm>(uncurry2(formDecoder), json);
1042
+ export function templateFormDecoder(declared: FormDeclarations): ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<TemplateForm, [string, ErrorReason_$union]>)) {
1043
+ return formDecoder(declared);
640
1044
  }
641
1045
 
642
- export const templateFormDecoder: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<TemplateForm, [string, ErrorReason_$union]>)) = formDecoder;
1046
+ /**
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`.
1049
+ */
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);
1052
+ }
643
1053
 
644
1054
  //# sourceMappingURL=TemplateManifestDecoder.ts.map