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

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 (194) hide show
  1. package/FormSpec.FS/BlueprintValidation.d.ts +6 -3
  2. package/FormSpec.FS/BlueprintValidation.d.ts.map +1 -1
  3. package/FormSpec.FS/BlueprintValidation.js +39 -15
  4. package/FormSpec.FS/BlueprintValidation.js.map +1 -1
  5. package/FormSpec.FS/Designer.d.ts.map +1 -1
  6. package/FormSpec.FS/Designer.js +1 -1
  7. package/FormSpec.FS/Designer.js.map +1 -1
  8. package/FormSpec.FS/FormSpec.d.ts +108 -58
  9. package/FormSpec.FS/FormSpec.d.ts.map +1 -1
  10. package/FormSpec.FS/FormSpec.js +319 -129
  11. package/FormSpec.FS/FormSpec.js.map +1 -1
  12. package/FormSpec.FS/FormSpecHelpers.d.ts.map +1 -1
  13. package/FormSpec.FS/FormSpecHelpers.js +1 -1
  14. package/FormSpec.FS/FormSpecHelpers.js.map +1 -1
  15. package/FormSpec.FS/FormSpecValues.d.ts.map +1 -1
  16. package/FormSpec.FS/FormSpecValues.js +5 -2
  17. package/FormSpec.FS/FormSpecValues.js.map +1 -1
  18. package/FormSpec.FS/Helpers.d.ts.map +1 -1
  19. package/FormSpec.FS/Helpers.js +14 -9
  20. package/FormSpec.FS/Helpers.js.map +1 -1
  21. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRFieldTypeMapper.d.ts.map +1 -1
  22. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRFieldTypeMapper.js +1 -1
  23. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRFieldTypeMapper.js.map +1 -1
  24. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRFormSpecValidator.d.ts +1 -1
  25. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRFormSpecValidator.d.ts.map +1 -1
  26. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRFormSpecValidator.js +1 -1
  27. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRFormSpecValidator.js.map +1 -1
  28. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRSectioning.d.ts +3 -3
  29. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRSectioning.d.ts.map +1 -1
  30. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRSectioning.js +7 -5
  31. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRSectioning.js.map +1 -1
  32. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRSemanticReportBuilder.d.ts.map +1 -1
  33. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRSemanticReportBuilder.js +11 -10
  34. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRSemanticReportBuilder.js.map +1 -1
  35. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRStepsBuilder.d.ts.map +1 -1
  36. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRStepsBuilder.js +1 -9
  37. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRStepsBuilder.js.map +1 -1
  38. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateMapper.d.ts +11 -4
  39. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateMapper.d.ts.map +1 -1
  40. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateMapper.js +30 -28
  41. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateMapper.js.map +1 -1
  42. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateToFormSpec.d.ts +3 -9
  43. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateToFormSpec.d.ts.map +1 -1
  44. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateToFormSpec.js +4 -31
  45. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateToFormSpec.js.map +1 -1
  46. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMREncoder.d.ts.map +1 -1
  47. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMREncoder.js +2 -6
  48. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMREncoder.js.map +1 -1
  49. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRImportPipeline.d.ts +45 -0
  50. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRImportPipeline.d.ts.map +1 -0
  51. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRImportPipeline.js +141 -0
  52. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRImportPipeline.js.map +1 -0
  53. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRImporterAnalysis.d.ts +326 -0
  54. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRImporterAnalysis.d.ts.map +1 -0
  55. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRImporterAnalysis.js +1743 -0
  56. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRImporterAnalysis.js.map +1 -0
  57. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRSourceMap.d.ts +8 -8
  58. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRSourceMap.d.ts.map +1 -1
  59. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRSourceMap.js +6 -6
  60. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRSourceMap.js.map +1 -1
  61. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRTriggerEnrichment.d.ts +21 -15
  62. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRTriggerEnrichment.d.ts.map +1 -1
  63. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRTriggerEnrichment.js +83 -80
  64. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRTriggerEnrichment.js.map +1 -1
  65. package/FormSpec.FS/Integrations/CorEMR/CoreMRPathwayMapper.d.ts +51 -0
  66. package/FormSpec.FS/Integrations/CorEMR/CoreMRPathwayMapper.d.ts.map +1 -0
  67. package/FormSpec.FS/Integrations/CorEMR/CoreMRPathwayMapper.js +939 -0
  68. package/FormSpec.FS/Integrations/CorEMR/CoreMRPathwayMapper.js.map +1 -0
  69. package/FormSpec.FS/Integrations/CorEMR/CoreMRTypes.d.ts +2 -17
  70. package/FormSpec.FS/Integrations/CorEMR/CoreMRTypes.d.ts.map +1 -1
  71. package/FormSpec.FS/Integrations/CorEMR/CoreMRTypes.js +1 -66
  72. package/FormSpec.FS/Integrations/CorEMR/{TemplateManifestDecoder.d.ts → FormTemplateDecoder.d.ts} +53 -45
  73. package/FormSpec.FS/Integrations/CorEMR/FormTemplateDecoder.d.ts.map +1 -0
  74. package/FormSpec.FS/Integrations/CorEMR/{TemplateManifestDecoder.js → FormTemplateDecoder.js} +544 -254
  75. package/FormSpec.FS/Integrations/CorEMR/FormTemplateDecoder.js.map +1 -0
  76. package/FormSpec.FS/Integrations/CorEMR/FormTemplateDomainDecoder.d.ts +7 -0
  77. package/FormSpec.FS/Integrations/CorEMR/FormTemplateDomainDecoder.d.ts.map +1 -0
  78. package/FormSpec.FS/Integrations/CorEMR/FormTemplateDomainDecoder.js +280 -0
  79. package/FormSpec.FS/Integrations/CorEMR/FormTemplateDomainDecoder.js.map +1 -0
  80. package/FormSpec.FS/Interop/FormSpec.Api.Helpers.d.ts +16 -4
  81. package/FormSpec.FS/Interop/FormSpec.Api.Helpers.d.ts.map +1 -1
  82. package/FormSpec.FS/Interop/FormSpec.Api.Helpers.js +63 -18
  83. package/FormSpec.FS/Interop/FormSpec.Api.Helpers.js.map +1 -1
  84. package/FormSpec.FS/Interop/FormSpec.Api.Option.d.ts +4 -4
  85. package/FormSpec.FS/Interop/FormSpec.Api.Option.d.ts.map +1 -1
  86. package/FormSpec.FS/Interop/FormSpec.Api.Option.js +2 -2
  87. package/FormSpec.FS/Interop/FormSpec.Api.Option.js.map +1 -1
  88. package/FormSpec.FS/PathwayDataExtractor.d.ts.map +1 -1
  89. package/FormSpec.FS/PathwayDataExtractor.js +39 -18
  90. package/FormSpec.FS/PathwayDataExtractor.js.map +1 -1
  91. package/FormSpec.FS/PathwayExecutor.d.ts +10 -10
  92. package/FormSpec.FS/PathwayExecutor.d.ts.map +1 -1
  93. package/FormSpec.FS/PathwayExecutor.js +14 -14
  94. package/FormSpec.FS/PathwayExecutor.js.map +1 -1
  95. package/FormSpec.FS/PathwayValidator.d.ts.map +1 -1
  96. package/FormSpec.FS/PathwayValidator.js +8 -5
  97. package/FormSpec.FS/PathwayValidator.js.map +1 -1
  98. package/FormSpec.FS/Provenance.d.ts +15 -7
  99. package/FormSpec.FS/Provenance.d.ts.map +1 -1
  100. package/FormSpec.FS/Provenance.js +11 -11
  101. package/FormSpec.FS/Provenance.js.map +1 -1
  102. package/FormSpec.FS/Renderers/FormSpecMarkdownRenderer.d.ts.map +1 -1
  103. package/FormSpec.FS/Renderers/FormSpecMarkdownRenderer.js +16 -7
  104. package/FormSpec.FS/Renderers/FormSpecMarkdownRenderer.js.map +1 -1
  105. package/FormSpec.FS/Renderers/MermaidRenderer.d.ts.map +1 -1
  106. package/FormSpec.FS/Renderers/MermaidRenderer.js +4 -8
  107. package/FormSpec.FS/Renderers/MermaidRenderer.js.map +1 -1
  108. package/FormSpec.FS/Renderers/PathwayRenderers.d.ts.map +1 -1
  109. package/FormSpec.FS/Renderers/PathwayRenderers.js +5 -4
  110. package/FormSpec.FS/Renderers/PathwayRenderers.js.map +1 -1
  111. package/FormSpec.FS/TriggerActionDto.d.ts +32 -21
  112. package/FormSpec.FS/TriggerActionDto.d.ts.map +1 -1
  113. package/FormSpec.FS/TriggerActionDto.js +247 -61
  114. package/FormSpec.FS/TriggerActionDto.js.map +1 -1
  115. package/README.md +7 -7
  116. package/package.json +1 -1
  117. package/plugins/allergyfinder/src/AllergyFinderField.d.ts.map +1 -1
  118. package/plugins/allergyfinder/src/AllergyFinderField.js +2 -2
  119. package/plugins/allergyfinder/src/AllergyFinderField.js.map +1 -1
  120. package/plugins/bmi/src/BMIField.d.ts.map +1 -1
  121. package/plugins/bmi/src/BMIField.js +21 -15
  122. package/plugins/bmi/src/BMIField.js.map +1 -1
  123. package/plugins/demographics/src/DemographicsField.d.ts.map +1 -1
  124. package/plugins/demographics/src/DemographicsField.js +4 -4
  125. package/plugins/demographics/src/DemographicsField.js.map +1 -1
  126. package/plugins/likert/src/LikertField.d.ts.map +1 -1
  127. package/plugins/likert/src/LikertField.js +40 -35
  128. package/plugins/likert/src/LikertField.js.map +1 -1
  129. package/plugins/signature/src/SignatureField.d.ts.map +1 -1
  130. package/plugins/signature/src/SignatureField.js +4 -3
  131. package/plugins/signature/src/SignatureField.js.map +1 -1
  132. package/plugins/vitals/src/VitalsField.d.ts.map +1 -1
  133. package/plugins/vitals/src/VitalsField.js +4 -4
  134. package/plugins/vitals/src/VitalsField.js.map +1 -1
  135. package/src/FormSpec.FS/BlueprintValidation.ts +55 -24
  136. package/src/FormSpec.FS/Designer.ts +2 -2
  137. package/src/FormSpec.FS/FormSpec.ts +223 -100
  138. package/src/FormSpec.FS/FormSpecHelpers.ts +2 -2
  139. package/src/FormSpec.FS/FormSpecValues.ts +6 -3
  140. package/src/FormSpec.FS/Helpers.ts +16 -11
  141. package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRFieldTypeMapper.ts +2 -2
  142. package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRFormSpecValidator.ts +3 -3
  143. package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRSectioning.ts +10 -8
  144. package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRSemanticReportBuilder.ts +6 -5
  145. package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRStepsBuilder.ts +1 -10
  146. package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateMapper.ts +35 -30
  147. package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateToFormSpec.ts +7 -26
  148. package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMREncoder.ts +2 -6
  149. package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRImportPipeline.ts +115 -0
  150. package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRImporterAnalysis.ts +1059 -0
  151. package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRSourceMap.ts +10 -10
  152. package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRTriggerEnrichment.ts +61 -88
  153. package/src/FormSpec.FS/Integrations/CorEMR/CoreMRPathwayMapper.ts +926 -0
  154. package/src/FormSpec.FS/Integrations/CorEMR/CoreMRTypes.ts +3 -37
  155. package/src/FormSpec.FS/Integrations/CorEMR/FormTemplateDecoder.ts +1284 -0
  156. package/src/FormSpec.FS/Integrations/CorEMR/FormTemplateDomainDecoder.ts +287 -0
  157. package/src/FormSpec.FS/Interop/FormSpec.Api.Helpers.ts +76 -25
  158. package/src/FormSpec.FS/Interop/FormSpec.Api.Option.ts +6 -6
  159. package/src/FormSpec.FS/PathwayDataExtractor.ts +40 -20
  160. package/src/FormSpec.FS/PathwayExecutor.ts +26 -26
  161. package/src/FormSpec.FS/PathwayValidator.ts +8 -5
  162. package/src/FormSpec.FS/Provenance.ts +23 -15
  163. package/src/FormSpec.FS/Renderers/FormSpecMarkdownRenderer.ts +18 -8
  164. package/src/FormSpec.FS/Renderers/MermaidRenderer.ts +6 -10
  165. package/src/FormSpec.FS/Renderers/PathwayRenderers.ts +5 -5
  166. package/src/FormSpec.FS/TriggerActionDto.ts +247 -74
  167. package/src/plugins/allergyfinder/src/AllergyFinderField.ts +3 -3
  168. package/src/plugins/bmi/src/BMIField.ts +12 -5
  169. package/src/plugins/demographics/src/DemographicsField.ts +5 -5
  170. package/src/plugins/likert/src/LikertField.ts +16 -11
  171. package/src/plugins/signature/src/SignatureField.ts +4 -3
  172. package/src/plugins/vitals/src/VitalsField.ts +5 -5
  173. package/src/vye-os-contracts-fs/src/Core/Ids.ts +8 -8
  174. package/src/vye-os-contracts-fs/src/CoreMR/FormTemplate.ts +715 -0
  175. package/vye-os-contracts-fs/src/Core/Ids.d.ts +4 -4
  176. package/vye-os-contracts-fs/src/Core/Ids.d.ts.map +1 -1
  177. package/vye-os-contracts-fs/src/Core/Ids.js +18 -18
  178. package/vye-os-contracts-fs/src/CoreMR/FormTemplate.d.ts +310 -0
  179. package/vye-os-contracts-fs/src/CoreMR/FormTemplate.d.ts.map +1 -0
  180. package/vye-os-contracts-fs/src/CoreMR/FormTemplate.js +1242 -0
  181. package/vye-os-contracts-fs/src/CoreMR/FormTemplate.js.map +1 -0
  182. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTriggerConverter.d.ts +0 -69
  183. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTriggerConverter.d.ts.map +0 -1
  184. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTriggerConverter.js +0 -447
  185. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTriggerConverter.js.map +0 -1
  186. package/FormSpec.FS/Integrations/CorEMR/ItemTriggerConverter.d.ts +0 -19
  187. package/FormSpec.FS/Integrations/CorEMR/ItemTriggerConverter.d.ts.map +0 -1
  188. package/FormSpec.FS/Integrations/CorEMR/ItemTriggerConverter.js +0 -643
  189. package/FormSpec.FS/Integrations/CorEMR/ItemTriggerConverter.js.map +0 -1
  190. package/FormSpec.FS/Integrations/CorEMR/TemplateManifestDecoder.d.ts.map +0 -1
  191. package/FormSpec.FS/Integrations/CorEMR/TemplateManifestDecoder.js.map +0 -1
  192. package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTriggerConverter.ts +0 -412
  193. package/src/FormSpec.FS/Integrations/CorEMR/ItemTriggerConverter.ts +0 -588
  194. package/src/FormSpec.FS/Integrations/CorEMR/TemplateManifestDecoder.ts +0 -1054
@@ -0,0 +1,1284 @@
1
+ import { Record, Union } from "@fable-org/fable-library-js/Types.js";
2
+ import { collect, tryPick, map as map_1, isEmpty, choose, 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 { value as value_15, Option } from "@fable-org/fable-library-js/Option.js";
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";
7
+ import { int64 } from "@fable-org/fable-library-js/BigInt.js";
8
+ import { equals, uncurry3, uncurry2, comparePrimitives, IComparable, IEquatable } from "@fable-org/fable-library-js/Util.js";
9
+ import { FSharpMap__TryFind, toList, ofList, FSharpMap } from "@fable-org/fable-library-js/Map.js";
10
+ import { Auto_generateBoxedDecoder_Z6670B51 } from "../../../Thoth.Json/packages/Thoth.Json/Decode.js";
11
+ import { Result_Bind, FSharpResult$2_Error, FSharpResult$2_Ok, FSharpResult$2_$union } from "@fable-org/fable-library-js/Result.js";
12
+ import { ErrorReason_$union } from "../../../Thoth.Json/packages/Thoth.Json/Types.js";
13
+ import { at, fromString, bool, map3, field as field_1, oneOf, IOptionalGetter, option, int, IGetters, list as list_7, string, IRequiredGetter, object, succeed, fail, andThen, map, keyValuePairs } from "../../../Thoth.Json/packages/Thoth.Json/Decode.js";
14
+ import { empty as empty_1, singleton, append, delay, toList as toList_1 } from "@fable-org/fable-library-js/Seq.js";
15
+ import { StatedCondition, StatedAction, Trigger_$reflection, Trigger } from "../../../vye-os-contracts-fs/src/CoreMR/FormTemplate.js";
16
+ import { triggers as triggers_1 } from "./FormTemplateDomainDecoder.js";
17
+ import { toList as toList_2, FSharpSet, ofList as ofList_1 } from "@fable-org/fable-library-js/Set.js";
18
+
19
+ export type ReleaseAvailability$1_$union<T> =
20
+ | ReleaseAvailability$1<T, 0>
21
+ | ReleaseAvailability$1<T, 1>
22
+ | ReleaseAvailability$1<T, 2>
23
+
24
+ export type ReleaseAvailability$1_$cases<T> = {
25
+ 0: ["Stated", [T]],
26
+ 1: ["NotInRelease", [string]],
27
+ 2: ["NotReadYet", [string, FSharpList<string>]]
28
+ }
29
+
30
+ export function ReleaseAvailability$1_Stated<T>(Item: T) {
31
+ return new ReleaseAvailability$1<T, 0>(0, [Item]);
32
+ }
33
+
34
+ export function ReleaseAvailability$1_NotInRelease<T>(because: string) {
35
+ return new ReleaseAvailability$1<T, 1>(1, [because]);
36
+ }
37
+
38
+ export function ReleaseAvailability$1_NotReadYet<T>(because: string, witness: FSharpList<string>) {
39
+ return new ReleaseAvailability$1<T, 2>(2, [because, witness]);
40
+ }
41
+
42
+ export class ReleaseAvailability$1<T, Tag extends keyof ReleaseAvailability$1_$cases<T>> extends Union<Tag, ReleaseAvailability$1_$cases<T>[Tag][0]> {
43
+ constructor(readonly tag: Tag, readonly fields: ReleaseAvailability$1_$cases<T>[Tag][1]) {
44
+ super();
45
+ }
46
+ cases() {
47
+ return ["Stated", "NotInRelease", "NotReadYet"];
48
+ }
49
+ }
50
+
51
+ export function ReleaseAvailability$1_$reflection(gen0: TypeInfo): TypeInfo {
52
+ return union_type("FormSpec.Integrations.CorEMR.FormTemplateDecoder.ReleaseAvailability`1", [gen0], ReleaseAvailability$1, () => [[["Item", gen0]], [["because", string_type]], [["because", string_type], ["witness", list_type(string_type)]]]);
53
+ }
54
+
55
+ /**
56
+ * The `kind` tag this crossed the wire under. ⭐ ONE home for the three spellings, so conduit's
57
+ * emission and this build's narrowing cannot drift.
58
+ */
59
+ export function ReleaseAvailability_kind<T>(a: ReleaseAvailability$1_$union<T>): string {
60
+ switch (a.tag) {
61
+ case /* NotInRelease */ 1:
62
+ return "notInRelease";
63
+ case /* NotReadYet */ 2:
64
+ return "notReadYet";
65
+ default:
66
+ return "stated";
67
+ }
68
+ }
69
+
70
+ /**
71
+ * Conduit's own reason, where there is one. `None` means it is stated and read.
72
+ */
73
+ export function ReleaseAvailability_because<T>(a: ReleaseAvailability$1_$union<T>): Option<string> {
74
+ switch (a.tag) {
75
+ case /* NotInRelease */ 1:
76
+ return a.fields[0];
77
+ case /* NotReadYet */ 2:
78
+ return a.fields[0];
79
+ default:
80
+ return undefined;
81
+ }
82
+ }
83
+
84
+ /**
85
+ * The objects that DO state it — only `NotReadYet` names any. ⛔ An empty list here is not evidence
86
+ * of absence; it means this case does not carry witnesses.
87
+ */
88
+ export function ReleaseAvailability_witness<T>(a: ReleaseAvailability$1_$union<T>): FSharpList<string> {
89
+ switch (a.tag) {
90
+ case /* Stated */ 0:
91
+ case /* NotInRelease */ 1:
92
+ return empty<string>();
93
+ default:
94
+ return a.fields[1];
95
+ }
96
+ }
97
+
98
+ /**
99
+ * The same release fact over a differently-shaped value. ⭐ The two absences pass through untouched —
100
+ * ⛔ there is no case here that could turn one into the other.
101
+ */
102
+ export function ReleaseAvailability_map<a, b>(f: ((arg0: a) => b), a: ReleaseAvailability$1_$union<a>): ReleaseAvailability$1_$union<b> {
103
+ switch (a.tag) {
104
+ case /* NotInRelease */ 1:
105
+ return ReleaseAvailability$1_NotInRelease<b>(a.fields[0]);
106
+ case /* NotReadYet */ 2:
107
+ return ReleaseAvailability$1_NotReadYet<b>(a.fields[0], a.fields[1]);
108
+ default:
109
+ return ReleaseAvailability$1_Stated<b>(f(a.fields[0]));
110
+ }
111
+ }
112
+
113
+ /**
114
+ * ⚠️ WHAT THIS BUILD READ, and nothing more. Both absences give `[]`, meaning **"nothing was read"** —
115
+ * ⛔ NEVER "there is none". At 5.5.0+9704 this returns `[]` over 2,606 stated triggers.
116
+ */
117
+ export function ReleaseAvailability_readList<T>(a: ReleaseAvailability$1_$union<FSharpList<T>>): FSharpList<T> {
118
+ switch (a.tag) {
119
+ case /* NotInRelease */ 1:
120
+ case /* NotReadYet */ 2:
121
+ return empty<T>();
122
+ default:
123
+ return a.fields[0];
124
+ }
125
+ }
126
+
127
+ /**
128
+ * ⚠️ `true` ONLY where the release states it AND states `true`. Both absences give `false`, meaning
129
+ * **"not listed"** — ⛔ never "the site denies it". 5.5.0+9704 cannot say either way about `other`.
130
+ */
131
+ export function ReleaseAvailability_statedTrue(a: ReleaseAvailability$1_$union<boolean>): boolean {
132
+ switch (a.tag) {
133
+ case /* NotInRelease */ 1:
134
+ case /* NotReadYet */ 2:
135
+ return false;
136
+ default:
137
+ return a.fields[0];
138
+ }
139
+ }
140
+
141
+ /**
142
+ * ⚠️ A LAYOUT DEPTH ONLY. Both absences render UNINDENTED — a rendering decision, ⛔ never a claim that
143
+ * the item sits at the root of a hierarchy this release states differently.
144
+ */
145
+ export function ReleaseAvailability_renderDepth(a: ReleaseAvailability$1_$union<int32>): int32 {
146
+ switch (a.tag) {
147
+ case /* NotInRelease */ 1:
148
+ case /* NotReadYet */ 2:
149
+ return 0;
150
+ default:
151
+ return a.fields[0] | 0;
152
+ }
153
+ }
154
+
155
+ /**
156
+ * ⭐ ONE SENTENCE A HUMAN CAN READ, for a UI that must show WHY a number is not there. It keeps the
157
+ * two absences apart in words as well as in the type.
158
+ */
159
+ export function ReleaseAvailability_describe<T>(a: ReleaseAvailability$1_$union<T>): string {
160
+ switch (a.tag) {
161
+ case /* NotInRelease */ 1: {
162
+ const b: string = a.fields[0];
163
+ return toText(printf("not in this release: %s"))(b);
164
+ }
165
+ case /* NotReadYet */ 2: {
166
+ const b_1: string = a.fields[0];
167
+ const arg_2: string = join_1(", ", a.fields[1]);
168
+ return toText(printf("stated by this release, NOT READ YET: %s (stated by: %s)"))(b_1)(arg_2);
169
+ }
170
+ default:
171
+ return "stated by this release, and read";
172
+ }
173
+ }
174
+
175
+ export class TemplateChoice extends Record implements IEquatable<TemplateChoice>, IComparable<TemplateChoice> {
176
+ readonly ChoiceId: int32;
177
+ readonly Sequence: int32;
178
+ readonly Score: int64;
179
+ readonly Text: string;
180
+ readonly BitPosition: Option<int32>;
181
+ readonly Code: Option<string>;
182
+ readonly Highlight: Option<int32>;
183
+ constructor(ChoiceId: int32, Sequence: int32, Score: int64, Text$: string, BitPosition: Option<int32>, Code: Option<string>, Highlight: Option<int32>) {
184
+ super();
185
+ this.ChoiceId = (ChoiceId | 0);
186
+ this.Sequence = (Sequence | 0);
187
+ this.Score = Score;
188
+ this.Text = Text$;
189
+ this.BitPosition = BitPosition;
190
+ this.Code = Code;
191
+ this.Highlight = Highlight;
192
+ }
193
+ }
194
+
195
+ export function TemplateChoice_$reflection(): TypeInfo {
196
+ return record_type("FormSpec.Integrations.CorEMR.FormTemplateDecoder.TemplateChoice", [], TemplateChoice, () => [["ChoiceId", int32_type], ["Sequence", int32_type], ["Score", int64_type], ["Text", string_type], ["BitPosition", option_type(int32_type)], ["Code", option_type(string_type)], ["Highlight", option_type(int32_type)]]);
197
+ }
198
+
199
+ export class TriggerCondition extends Record implements IEquatable<TriggerCondition>, IComparable<TriggerCondition> {
200
+ readonly ConditionId: int32;
201
+ readonly SourceFieldId: Option<int32>;
202
+ readonly Source: string;
203
+ readonly Operator: string;
204
+ readonly Values: FSharpList<string>;
205
+ readonly RawChoiceIds: FSharpList<int32>;
206
+ readonly BooleanOperator: Option<string>;
207
+ constructor(ConditionId: int32, SourceFieldId: Option<int32>, Source: string, Operator: string, Values: FSharpList<string>, RawChoiceIds: FSharpList<int32>, BooleanOperator: Option<string>) {
208
+ super();
209
+ this.ConditionId = (ConditionId | 0);
210
+ this.SourceFieldId = SourceFieldId;
211
+ this.Source = Source;
212
+ this.Operator = Operator;
213
+ this.Values = Values;
214
+ this.RawChoiceIds = RawChoiceIds;
215
+ this.BooleanOperator = BooleanOperator;
216
+ }
217
+ }
218
+
219
+ export function TriggerCondition_$reflection(): TypeInfo {
220
+ return record_type("FormSpec.Integrations.CorEMR.FormTemplateDecoder.TriggerCondition", [], TriggerCondition, () => [["ConditionId", int32_type], ["SourceFieldId", option_type(int32_type)], ["Source", string_type], ["Operator", string_type], ["Values", list_type(string_type)], ["RawChoiceIds", list_type(int32_type)], ["BooleanOperator", option_type(string_type)]]);
221
+ }
222
+
223
+ export class TriggerAction extends Record implements IEquatable<TriggerAction>, IComparable<TriggerAction> {
224
+ readonly ActionId: int32;
225
+ readonly ActionType: string;
226
+ readonly Params: FSharpMap<string, string>;
227
+ readonly ListParams: Option<FSharpMap<string, FSharpList<string>>>;
228
+ constructor(ActionId: int32, ActionType: string, Params: FSharpMap<string, string>, ListParams: Option<FSharpMap<string, FSharpList<string>>>) {
229
+ super();
230
+ this.ActionId = (ActionId | 0);
231
+ this.ActionType = ActionType;
232
+ this.Params = Params;
233
+ this.ListParams = ListParams;
234
+ }
235
+ }
236
+
237
+ export function TriggerAction_$reflection(): TypeInfo {
238
+ return record_type("FormSpec.Integrations.CorEMR.FormTemplateDecoder.TriggerAction", [], TriggerAction, () => [["ActionId", int32_type], ["ActionType", string_type], ["Params", class_type("Microsoft.FSharp.Collections.FSharpMap`2", [string_type, string_type])], ["ListParams", option_type(class_type("Microsoft.FSharp.Collections.FSharpMap`2", [string_type, list_type(string_type)]))]]);
239
+ }
240
+
241
+ export class ItemTrigger extends Record implements IEquatable<ItemTrigger>, IComparable<ItemTrigger> {
242
+ readonly TriggerId: int32;
243
+ readonly EventName: string;
244
+ readonly Enabled: boolean;
245
+ readonly ExclusiveTag: Option<string>;
246
+ readonly Conditions: FSharpList<TriggerCondition>;
247
+ readonly Actions: FSharpList<TriggerAction>;
248
+ constructor(TriggerId: int32, EventName: string, Enabled: boolean, ExclusiveTag: Option<string>, Conditions: FSharpList<TriggerCondition>, Actions: FSharpList<TriggerAction>) {
249
+ super();
250
+ this.TriggerId = (TriggerId | 0);
251
+ this.EventName = EventName;
252
+ this.Enabled = Enabled;
253
+ this.ExclusiveTag = ExclusiveTag;
254
+ this.Conditions = Conditions;
255
+ this.Actions = Actions;
256
+ }
257
+ }
258
+
259
+ export function ItemTrigger_$reflection(): TypeInfo {
260
+ return record_type("FormSpec.Integrations.CorEMR.FormTemplateDecoder.ItemTrigger", [], ItemTrigger, () => [["TriggerId", int32_type], ["EventName", string_type], ["Enabled", bool_type], ["ExclusiveTag", option_type(string_type)], ["Conditions", list_type(TriggerCondition_$reflection())], ["Actions", list_type(TriggerAction_$reflection())]]);
261
+ }
262
+
263
+ export class TemplateItem extends Record implements IEquatable<TemplateItem>, IComparable<TemplateItem> {
264
+ readonly ItemId: int32;
265
+ readonly Sequence: int32;
266
+ readonly Type: int32;
267
+ readonly NestingLevel: ReleaseAvailability$1_$union<int32>;
268
+ readonly IsRequired: boolean;
269
+ readonly Text: string;
270
+ readonly SequenceText: Option<string>;
271
+ readonly Code: Option<string>;
272
+ readonly Uuid: Option<string>;
273
+ readonly GenderRequired: Option<string>;
274
+ readonly Highlight: Option<int32>;
275
+ readonly Choices: FSharpList<TemplateChoice>;
276
+ readonly Triggers: ReleaseAvailability$1_$union<FSharpList<ItemTrigger>>;
277
+ 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>>) {
278
+ super();
279
+ this.ItemId = (ItemId | 0);
280
+ this.Sequence = (Sequence | 0);
281
+ this.Type = (Type | 0);
282
+ this.NestingLevel = NestingLevel;
283
+ this.IsRequired = IsRequired;
284
+ this.Text = Text$;
285
+ this.SequenceText = SequenceText;
286
+ this.Code = Code;
287
+ this.Uuid = Uuid;
288
+ this.GenderRequired = GenderRequired;
289
+ this.Highlight = Highlight;
290
+ this.Choices = Choices;
291
+ this.Triggers = Triggers;
292
+ }
293
+ }
294
+
295
+ export function TemplateItem_$reflection(): TypeInfo {
296
+ return record_type("FormSpec.Integrations.CorEMR.FormTemplateDecoder.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()))]]);
297
+ }
298
+
299
+ export class EncounterTypes extends Record implements IEquatable<EncounterTypes>, IComparable<EncounterTypes> {
300
+ readonly Medical: boolean;
301
+ readonly Mental: boolean;
302
+ readonly Dental: boolean;
303
+ readonly Other: ReleaseAvailability$1_$union<boolean>;
304
+ constructor(Medical: boolean, Mental: boolean, Dental: boolean, Other: ReleaseAvailability$1_$union<boolean>) {
305
+ super();
306
+ this.Medical = Medical;
307
+ this.Mental = Mental;
308
+ this.Dental = Dental;
309
+ this.Other = Other;
310
+ }
311
+ }
312
+
313
+ export function EncounterTypes_$reflection(): TypeInfo {
314
+ return record_type("FormSpec.Integrations.CorEMR.FormTemplateDecoder.EncounterTypes", [], EncounterTypes, () => [["Medical", bool_type], ["Mental", bool_type], ["Dental", bool_type], ["Other", ReleaseAvailability$1_$reflection(bool_type)]]);
315
+ }
316
+
317
+ export class ScoringLabel extends Record implements IEquatable<ScoringLabel>, IComparable<ScoringLabel> {
318
+ readonly Name: string;
319
+ readonly Min: int32;
320
+ constructor(Name: string, Min: int32) {
321
+ super();
322
+ this.Name = Name;
323
+ this.Min = (Min | 0);
324
+ }
325
+ }
326
+
327
+ export function ScoringLabel_$reflection(): TypeInfo {
328
+ return record_type("FormSpec.Integrations.CorEMR.FormTemplateDecoder.ScoringLabel", [], ScoringLabel, () => [["Name", string_type], ["Min", int32_type]]);
329
+ }
330
+
331
+ export class FormScoring extends Record implements IEquatable<FormScoring>, IComparable<FormScoring> {
332
+ readonly ScoreId: int32;
333
+ readonly ScoreName: string;
334
+ readonly Labels: FSharpList<ScoringLabel>;
335
+ readonly ChoiceScores: FSharpMap<string, int32>;
336
+ constructor(ScoreId: int32, ScoreName: string, Labels: FSharpList<ScoringLabel>, ChoiceScores: FSharpMap<string, int32>) {
337
+ super();
338
+ this.ScoreId = (ScoreId | 0);
339
+ this.ScoreName = ScoreName;
340
+ this.Labels = Labels;
341
+ this.ChoiceScores = ChoiceScores;
342
+ }
343
+ }
344
+
345
+ export function FormScoring_$reflection(): TypeInfo {
346
+ return record_type("FormSpec.Integrations.CorEMR.FormTemplateDecoder.FormScoring", [], FormScoring, () => [["ScoreId", int32_type], ["ScoreName", string_type], ["Labels", list_type(ScoringLabel_$reflection())], ["ChoiceScores", class_type("Microsoft.FSharp.Collections.FSharpMap`2", [string_type, int32_type])]]);
347
+ }
348
+
349
+ export class TemplateForm extends Record implements IEquatable<TemplateForm>, IComparable<TemplateForm> {
350
+ readonly FormId: int32;
351
+ readonly Name: string;
352
+ readonly FormCode: string;
353
+ readonly FormCodeSource: string;
354
+ readonly Description: string;
355
+ readonly CurrentVersionId: int64;
356
+ readonly IsIntake: boolean;
357
+ readonly Usage: Option<string>;
358
+ readonly RequiresSignature: boolean;
359
+ readonly EncounterTypes: EncounterTypes;
360
+ readonly OnceAYear: boolean;
361
+ readonly StructureHash: string;
362
+ readonly ClinicalHash: string;
363
+ readonly CosmeticHash: string;
364
+ readonly Hash: string;
365
+ readonly Items: FSharpList<TemplateItem>;
366
+ readonly Scoring: Option<FormScoring>;
367
+ constructor(FormId: int32, Name: string, FormCode: string, FormCodeSource: string, Description: string, CurrentVersionId: int64, IsIntake: boolean, Usage: Option<string>, RequiresSignature: boolean, EncounterTypes: EncounterTypes, OnceAYear: boolean, StructureHash: string, ClinicalHash: string, CosmeticHash: string, Hash: string, Items: FSharpList<TemplateItem>, Scoring: Option<FormScoring>) {
368
+ super();
369
+ this.FormId = (FormId | 0);
370
+ this.Name = Name;
371
+ this.FormCode = FormCode;
372
+ this.FormCodeSource = FormCodeSource;
373
+ this.Description = Description;
374
+ this.CurrentVersionId = CurrentVersionId;
375
+ this.IsIntake = IsIntake;
376
+ this.Usage = Usage;
377
+ this.RequiresSignature = RequiresSignature;
378
+ this.EncounterTypes = EncounterTypes;
379
+ this.OnceAYear = OnceAYear;
380
+ this.StructureHash = StructureHash;
381
+ this.ClinicalHash = ClinicalHash;
382
+ this.CosmeticHash = CosmeticHash;
383
+ this.Hash = Hash;
384
+ this.Items = Items;
385
+ this.Scoring = Scoring;
386
+ }
387
+ }
388
+
389
+ export function TemplateForm_$reflection(): TypeInfo {
390
+ return record_type("FormSpec.Integrations.CorEMR.FormTemplateDecoder.TemplateForm", [], TemplateForm, () => [["FormId", int32_type], ["Name", string_type], ["FormCode", string_type], ["FormCodeSource", string_type], ["Description", string_type], ["CurrentVersionId", int64_type], ["IsIntake", bool_type], ["Usage", option_type(string_type)], ["RequiresSignature", bool_type], ["EncounterTypes", EncounterTypes_$reflection()], ["OnceAYear", bool_type], ["StructureHash", string_type], ["ClinicalHash", string_type], ["CosmeticHash", string_type], ["Hash", string_type], ["Items", list_type(TemplateItem_$reflection())], ["Scoring", option_type(FormScoring_$reflection())]]);
391
+ }
392
+
393
+ export class ElementTypeEntry extends Record implements IEquatable<ElementTypeEntry>, IComparable<ElementTypeEntry> {
394
+ readonly Label: string;
395
+ readonly Control: string;
396
+ constructor(Label: string, Control: string) {
397
+ super();
398
+ this.Label = Label;
399
+ this.Control = Control;
400
+ }
401
+ }
402
+
403
+ export function ElementTypeEntry_$reflection(): TypeInfo {
404
+ return record_type("FormSpec.Integrations.CorEMR.FormTemplateDecoder.ElementTypeEntry", [], ElementTypeEntry, () => [["Label", string_type], ["Control", string_type]]);
405
+ }
406
+
407
+ export type ElementTypesFrom_$union =
408
+ | ElementTypesFrom<0>
409
+ | ElementTypesFrom<1>
410
+ | ElementTypesFrom<2>
411
+
412
+ export type ElementTypesFrom_$cases = {
413
+ 0: ["StatedBy", [string, string, string]],
414
+ 1: ["DeclaredByConduit", [string]],
415
+ 2: ["NotInRelease", [string]]
416
+ }
417
+
418
+ export function ElementTypesFrom_StatedBy(table: string, key: string, label: string) {
419
+ return new ElementTypesFrom<0>(0, [table, key, label]);
420
+ }
421
+
422
+ export function ElementTypesFrom_DeclaredByConduit(because: string) {
423
+ return new ElementTypesFrom<1>(1, [because]);
424
+ }
425
+
426
+ export function ElementTypesFrom_NotInRelease(because: string) {
427
+ return new ElementTypesFrom<2>(2, [because]);
428
+ }
429
+
430
+ export class ElementTypesFrom<Tag extends keyof ElementTypesFrom_$cases> extends Union<Tag, ElementTypesFrom_$cases[Tag][0]> {
431
+ constructor(readonly tag: Tag, readonly fields: ElementTypesFrom_$cases[Tag][1]) {
432
+ super();
433
+ }
434
+ cases() {
435
+ return ["StatedBy", "DeclaredByConduit", "NotInRelease"];
436
+ }
437
+ }
438
+
439
+ export function ElementTypesFrom_$reflection(): TypeInfo {
440
+ return union_type("FormSpec.Integrations.CorEMR.FormTemplateDecoder.ElementTypesFrom", [], ElementTypesFrom, () => [[["table", string_type], ["key", string_type], ["label", string_type]], [["because", string_type]], [["because", string_type]]]);
441
+ }
442
+
443
+ export class InstrumentMapEntry extends Record implements IEquatable<InstrumentMapEntry>, IComparable<InstrumentMapEntry> {
444
+ readonly InstrumentType: string;
445
+ readonly FormCode: string;
446
+ readonly MaxScore: Option<int32>;
447
+ readonly Source: string;
448
+ readonly Archived: boolean;
449
+ readonly FormName: string;
450
+ constructor(InstrumentType: string, FormCode: string, MaxScore: Option<int32>, Source: string, Archived: boolean, FormName: string) {
451
+ super();
452
+ this.InstrumentType = InstrumentType;
453
+ this.FormCode = FormCode;
454
+ this.MaxScore = MaxScore;
455
+ this.Source = Source;
456
+ this.Archived = Archived;
457
+ this.FormName = FormName;
458
+ }
459
+ }
460
+
461
+ export function InstrumentMapEntry_$reflection(): TypeInfo {
462
+ return record_type("FormSpec.Integrations.CorEMR.FormTemplateDecoder.InstrumentMapEntry", [], InstrumentMapEntry, () => [["InstrumentType", string_type], ["FormCode", string_type], ["MaxScore", option_type(int32_type)], ["Source", string_type], ["Archived", bool_type], ["FormName", string_type]]);
463
+ }
464
+
465
+ export class CodeExtractionStats extends Record implements IEquatable<CodeExtractionStats>, IComparable<CodeExtractionStats> {
466
+ readonly Extracted: int32;
467
+ readonly Generated: int32;
468
+ readonly BySource: FSharpMap<string, int32>;
469
+ readonly Regex: string;
470
+ constructor(Extracted: int32, Generated: int32, BySource: FSharpMap<string, int32>, Regex: string) {
471
+ super();
472
+ this.Extracted = (Extracted | 0);
473
+ this.Generated = (Generated | 0);
474
+ this.BySource = BySource;
475
+ this.Regex = Regex;
476
+ }
477
+ }
478
+
479
+ export function CodeExtractionStats_$reflection(): TypeInfo {
480
+ return record_type("FormSpec.Integrations.CorEMR.FormTemplateDecoder.CodeExtractionStats", [], CodeExtractionStats, () => [["Extracted", int32_type], ["Generated", int32_type], ["BySource", class_type("Microsoft.FSharp.Collections.FSharpMap`2", [string_type, int32_type])], ["Regex", string_type]]);
481
+ }
482
+
483
+ export class TriggerStats extends Record implements IEquatable<TriggerStats>, IComparable<TriggerStats> {
484
+ readonly FormsWithTriggers: int32;
485
+ readonly TotalTriggers: int32;
486
+ readonly ByActionType: FSharpMap<string, int32>;
487
+ constructor(FormsWithTriggers: int32, TotalTriggers: int32, ByActionType: FSharpMap<string, int32>) {
488
+ super();
489
+ this.FormsWithTriggers = (FormsWithTriggers | 0);
490
+ this.TotalTriggers = (TotalTriggers | 0);
491
+ this.ByActionType = ByActionType;
492
+ }
493
+ }
494
+
495
+ export function TriggerStats_$reflection(): TypeInfo {
496
+ return record_type("FormSpec.Integrations.CorEMR.FormTemplateDecoder.TriggerStats", [], TriggerStats, () => [["FormsWithTriggers", int32_type], ["TotalTriggers", int32_type], ["ByActionType", class_type("Microsoft.FSharp.Collections.FSharpMap`2", [string_type, int32_type])]]);
497
+ }
498
+
499
+ export class TemplateStats extends Record implements IEquatable<TemplateStats>, IComparable<TemplateStats> {
500
+ readonly TotalForms: int32;
501
+ readonly WithCodes: int32;
502
+ readonly WithSyntheticCodes: int32;
503
+ readonly WithSignature: int32;
504
+ readonly ByUsage: FSharpMap<string, int32>;
505
+ readonly ByElementType: FSharpMap<string, int32>;
506
+ readonly CodeExtraction: CodeExtractionStats;
507
+ constructor(TotalForms: int32, WithCodes: int32, WithSyntheticCodes: int32, WithSignature: int32, ByUsage: FSharpMap<string, int32>, ByElementType: FSharpMap<string, int32>, CodeExtraction: CodeExtractionStats) {
508
+ super();
509
+ this.TotalForms = (TotalForms | 0);
510
+ this.WithCodes = (WithCodes | 0);
511
+ this.WithSyntheticCodes = (WithSyntheticCodes | 0);
512
+ this.WithSignature = (WithSignature | 0);
513
+ this.ByUsage = ByUsage;
514
+ this.ByElementType = ByElementType;
515
+ this.CodeExtraction = CodeExtraction;
516
+ }
517
+ }
518
+
519
+ export function TemplateStats_$reflection(): TypeInfo {
520
+ return record_type("FormSpec.Integrations.CorEMR.FormTemplateDecoder.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()]]);
521
+ }
522
+
523
+ export class CoreEmrInfo extends Record implements IEquatable<CoreEmrInfo>, IComparable<CoreEmrInfo> {
524
+ readonly AppVersion: string;
525
+ readonly SchemaVersion: string;
526
+ readonly SchemaRevision: int32;
527
+ constructor(AppVersion: string, SchemaVersion: string, SchemaRevision: int32) {
528
+ super();
529
+ this.AppVersion = AppVersion;
530
+ this.SchemaVersion = SchemaVersion;
531
+ this.SchemaRevision = (SchemaRevision | 0);
532
+ }
533
+ }
534
+
535
+ export function CoreEmrInfo_$reflection(): TypeInfo {
536
+ return record_type("FormSpec.Integrations.CorEMR.FormTemplateDecoder.CoreEmrInfo", [], CoreEmrInfo, () => [["AppVersion", string_type], ["SchemaVersion", string_type], ["SchemaRevision", int32_type]]);
537
+ }
538
+
539
+ export class InstrumentMapStats extends Record implements IEquatable<InstrumentMapStats>, IComparable<InstrumentMapStats> {
540
+ readonly Total: int32;
541
+ readonly Current: int32;
542
+ readonly Archived: int32;
543
+ readonly BySource: FSharpMap<string, int32>;
544
+ readonly ByType: FSharpMap<string, int32>;
545
+ constructor(Total: int32, Current: int32, Archived: int32, BySource: FSharpMap<string, int32>, ByType: FSharpMap<string, int32>) {
546
+ super();
547
+ this.Total = (Total | 0);
548
+ this.Current = (Current | 0);
549
+ this.Archived = (Archived | 0);
550
+ this.BySource = BySource;
551
+ this.ByType = ByType;
552
+ }
553
+ }
554
+
555
+ export function InstrumentMapStats_$reflection(): TypeInfo {
556
+ return record_type("FormSpec.Integrations.CorEMR.FormTemplateDecoder.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])]]);
557
+ }
558
+
559
+ export class ScoringCatalog extends Record implements IEquatable<ScoringCatalog>, IComparable<ScoringCatalog> {
560
+ readonly InstrumentMap: FSharpMap<string, InstrumentMapEntry>;
561
+ readonly InstrumentMapStats: InstrumentMapStats;
562
+ readonly FormsWithScoring: int32;
563
+ constructor(InstrumentMap: FSharpMap<string, InstrumentMapEntry>, InstrumentMapStats: InstrumentMapStats, FormsWithScoring: int32) {
564
+ super();
565
+ this.InstrumentMap = InstrumentMap;
566
+ this.InstrumentMapStats = InstrumentMapStats;
567
+ this.FormsWithScoring = (FormsWithScoring | 0);
568
+ }
569
+ }
570
+
571
+ export function ScoringCatalog_$reflection(): TypeInfo {
572
+ return record_type("FormSpec.Integrations.CorEMR.FormTemplateDecoder.ScoringCatalog", [], ScoringCatalog, () => [["InstrumentMap", class_type("Microsoft.FSharp.Collections.FSharpMap`2", [string_type, InstrumentMapEntry_$reflection()])], ["InstrumentMapStats", InstrumentMapStats_$reflection()], ["FormsWithScoring", int32_type]]);
573
+ }
574
+
575
+ const liberatedInt64Decoder: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<int64, [string, ErrorReason_$union]>)) = Auto_generateBoxedDecoder_Z6670B51(int64_type, undefined, undefined);
576
+
577
+ function dictDecoder<T>(decoder: ((arg0: string, arg1: any) => FSharpResult$2_$union<T, [string, ErrorReason_$union]>)): ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<FSharpMap<string, T>, [string, ErrorReason_$union]>)) {
578
+ let d: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<FSharpList<[string, T]>, [string, ErrorReason_$union]>));
579
+ const decoder_1: ((arg0: string, arg1: any) => FSharpResult$2_$union<T, [string, ErrorReason_$union]>) = decoder;
580
+ d = ((path: string): ((arg0: any) => FSharpResult$2_$union<FSharpList<[string, T]>, [string, ErrorReason_$union]>) => ((value: any): FSharpResult$2_$union<FSharpList<[string, T]>, [string, ErrorReason_$union]> => keyValuePairs<T>(decoder_1, path, value)));
581
+ return (path_1: string): ((arg0: any) => FSharpResult$2_$union<FSharpMap<string, T>, [string, ErrorReason_$union]>) => ((value_1: any): FSharpResult$2_$union<FSharpMap<string, T>, [string, ErrorReason_$union]> => map<FSharpList<[string, T]>, FSharpMap<string, T>>((elements: FSharpList<[string, T]>): FSharpMap<string, T> => ofList<string, T>(elements, {
582
+ Compare: comparePrimitives,
583
+ }), uncurry2(d), path_1, value_1));
584
+ }
585
+
586
+ 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]>)) {
587
+ const decoder: ((arg0: string, arg1: any) => FSharpResult$2_$union<FSharpResult$2_$union<T, string>, [string, ErrorReason_$union]>) = d;
588
+ 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]>)) => {
589
+ if (r.tag === /* Error */ 1) {
590
+ const msg: string = r.fields[0];
591
+ 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));
592
+ }
593
+ else {
594
+ const v: T = r.fields[0];
595
+ 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));
596
+ }
597
+ }), decoder, path_1, value));
598
+ }
599
+
600
+ function availabilityRowDecoder(field: string): ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<ReleaseAvailability$1_$union<FSharpList<string>>, [string, ErrorReason_$union]>)) {
601
+ 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> => {
602
+ let objectArg_1: IRequiredGetter, objectArg_2: IRequiredGetter, objectArg_3: IRequiredGetter, objectArg_4: IRequiredGetter;
603
+ let matchValue: string;
604
+ const objectArg: IRequiredGetter = get$.Required;
605
+ matchValue = objectArg.Field<string>("kind", string);
606
+ switch (matchValue) {
607
+ case "stated":
608
+ 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_7<string>(string, path_2, value_2)))));
609
+ case "notInRelease":
610
+ 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))));
611
+ case "notReadYet":
612
+ 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_7<string>(string, path_6, value_6)))));
613
+ default:
614
+ 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));
615
+ }
616
+ }, path_7, v));
617
+ }
618
+
619
+ function join<T>(field: string, row: ReleaseAvailability$1_$union<FSharpList<string>>, datum: Option<T>): FSharpResult$2_$union<ReleaseAvailability$1_$union<T>, string> {
620
+ switch (row.tag) {
621
+ case /* NotInRelease */ 1:
622
+ if (datum == null) {
623
+ const because_2: string = row.fields[0];
624
+ return FSharpResult$2_Ok<ReleaseAvailability$1_$union<T>, string>(ReleaseAvailability$1_NotInRelease<T>(because_2));
625
+ }
626
+ else {
627
+ const because: string = row.fields[0];
628
+ return FSharpResult$2_Error<ReleaseAvailability$1_$union<T>, string>(toText(printf("the answer declares `%s` NOT IN THIS RELEASE (%s) and carries a value for it anyway"))(field)(because));
629
+ }
630
+ case /* NotReadYet */ 2:
631
+ if (datum == null) {
632
+ const because_3: string = row.fields[0];
633
+ const witness: FSharpList<string> = row.fields[1];
634
+ return FSharpResult$2_Ok<ReleaseAvailability$1_$union<T>, string>(ReleaseAvailability$1_NotReadYet<T>(because_3, witness));
635
+ }
636
+ else {
637
+ const because_1: string = row.fields[0];
638
+ return FSharpResult$2_Error<ReleaseAvailability$1_$union<T>, string>(toText(printf("the answer declares `%s` NOT READ YET (%s) and carries a value for it anyway"))(field)(because_1));
639
+ }
640
+ default:
641
+ if (datum == null) {
642
+ return FSharpResult$2_Error<ReleaseAvailability$1_$union<T>, string>(toText(printf("the answer declares `%s` STATED by this release, but carries no `%s`"))(field)(field));
643
+ }
644
+ else {
645
+ const v: T = value_15(datum);
646
+ return FSharpResult$2_Ok<ReleaseAvailability$1_$union<T>, string>(ReleaseAvailability$1_Stated<T>(v));
647
+ }
648
+ }
649
+ }
650
+
651
+ class FormDeclarations extends Record implements IEquatable<FormDeclarations>, IComparable<FormDeclarations> {
652
+ readonly ItemNesting: ReleaseAvailability$1_$union<FSharpList<string>>;
653
+ readonly Triggers: ReleaseAvailability$1_$union<FSharpList<string>>;
654
+ readonly EncounterOther: ReleaseAvailability$1_$union<FSharpList<string>>;
655
+ readonly Scoring: ReleaseAvailability$1_$union<FSharpList<string>>;
656
+ constructor(ItemNesting: ReleaseAvailability$1_$union<FSharpList<string>>, Triggers: ReleaseAvailability$1_$union<FSharpList<string>>, EncounterOther: ReleaseAvailability$1_$union<FSharpList<string>>, Scoring: ReleaseAvailability$1_$union<FSharpList<string>>) {
657
+ super();
658
+ this.ItemNesting = ItemNesting;
659
+ this.Triggers = Triggers;
660
+ this.EncounterOther = EncounterOther;
661
+ this.Scoring = Scoring;
662
+ }
663
+ }
664
+
665
+ function FormDeclarations_$reflection(): TypeInfo {
666
+ return record_type("FormSpec.Integrations.CorEMR.FormTemplateDecoder.FormDeclarations", [], FormDeclarations, () => [["ItemNesting", ReleaseAvailability$1_$reflection(list_type(string_type))], ["Triggers", ReleaseAvailability$1_$reflection(list_type(string_type))], ["EncounterOther", ReleaseAvailability$1_$reflection(list_type(string_type))], ["Scoring", ReleaseAvailability$1_$reflection(list_type(string_type))]]);
667
+ }
668
+
669
+ const choiceDecoder = (path_4: string): ((arg0: any) => FSharpResult$2_$union<TemplateChoice, [string, ErrorReason_$union]>) => ((v: any): FSharpResult$2_$union<TemplateChoice, [string, ErrorReason_$union]> => object<TemplateChoice>((get$: IGetters): TemplateChoice => {
670
+ let objectArg_1: IRequiredGetter, objectArg_2: IRequiredGetter, objectArg_3: IRequiredGetter, objectArg_4: IRequiredGetter, objectArg_5: IRequiredGetter, objectArg_6: IOptionalGetter;
671
+ let score: int64;
672
+ const objectArg: IRequiredGetter = get$.Required;
673
+ score = objectArg.Field<int64>("score", uncurry2(liberatedInt64Decoder));
674
+ return new TemplateChoice((objectArg_1 = get$.Required, objectArg_1.Field<int32>("choiceId", uncurry2(int))), (objectArg_2 = get$.Required, objectArg_2.Field<int32>("sequence", uncurry2(int))), score, (objectArg_3 = get$.Required, objectArg_3.Field<string>("text", string)), (objectArg_4 = get$.Required, objectArg_4.Field<Option<int32>>("bitPosition", (path_1: string, value_1: any): FSharpResult$2_$union<Option<int32>, [string, ErrorReason_$union]> => option<int32>(uncurry2(int), path_1, value_1))), (objectArg_5 = get$.Required, objectArg_5.Field<Option<string>>("code", (path_3: string, value_3: any): FSharpResult$2_$union<Option<string>, [string, ErrorReason_$union]> => option<string>(string, path_3, value_3))), (objectArg_6 = get$.Optional, objectArg_6.Field<int32>("highlight", uncurry2(int))));
675
+ }, path_4, v));
676
+
677
+ const triggerConditionDecoder = (path_8: string): ((arg0: any) => FSharpResult$2_$union<TriggerCondition, [string, ErrorReason_$union]>) => ((v: any): FSharpResult$2_$union<TriggerCondition, [string, ErrorReason_$union]> => object<TriggerCondition>((get$: IGetters): TriggerCondition => {
678
+ let objectArg: IRequiredGetter, objectArg_1: IRequiredGetter, objectArg_2: IRequiredGetter, objectArg_3: IRequiredGetter, objectArg_4: IRequiredGetter, objectArg_5: IRequiredGetter, objectArg_6: IRequiredGetter;
679
+ return new TriggerCondition((objectArg = get$.Required, objectArg.Field<int32>("conditionId", uncurry2(int))), (objectArg_1 = get$.Required, objectArg_1.Field<Option<int32>>("sourceFieldId", (path: string, value: any): FSharpResult$2_$union<Option<int32>, [string, ErrorReason_$union]> => option<int32>(uncurry2(int), path, value))), (objectArg_2 = get$.Required, objectArg_2.Field<string>("source", string)), (objectArg_3 = get$.Required, objectArg_3.Field<string>("operator", string)), (objectArg_4 = get$.Required, objectArg_4.Field<FSharpList<string>>("values", (path_4: string, value_4: any): FSharpResult$2_$union<FSharpList<string>, [string, ErrorReason_$union]> => list_7<string>(string, path_4, value_4))), (objectArg_5 = get$.Required, objectArg_5.Field<FSharpList<int32>>("rawChoiceIds", (path_5: string, value_5: any): FSharpResult$2_$union<FSharpList<int32>, [string, ErrorReason_$union]> => list_7<int32>(uncurry2(int), path_5, value_5))), (objectArg_6 = get$.Required, objectArg_6.Field<Option<string>>("booleanOperator", (path_7: string, value_7: any): FSharpResult$2_$union<Option<string>, [string, ErrorReason_$union]> => option<string>(string, path_7, value_7))));
680
+ }, path_8, v));
681
+
682
+ type ParamValue_$union =
683
+ | ParamValue<0>
684
+ | ParamValue<1>
685
+
686
+ type ParamValue_$cases = {
687
+ 0: ["ScalarParam", [string]],
688
+ 1: ["ListParam", [FSharpList<string>]]
689
+ }
690
+
691
+ function ParamValue_ScalarParam(Item: string) {
692
+ return new ParamValue<0>(0, [Item]);
693
+ }
694
+
695
+ function ParamValue_ListParam(Item: FSharpList<string>) {
696
+ return new ParamValue<1>(1, [Item]);
697
+ }
698
+
699
+ class ParamValue<Tag extends keyof ParamValue_$cases> extends Union<Tag, ParamValue_$cases[Tag][0]> {
700
+ constructor(readonly tag: Tag, readonly fields: ParamValue_$cases[Tag][1]) {
701
+ super();
702
+ }
703
+ cases() {
704
+ return ["ScalarParam", "ListParam"];
705
+ }
706
+ }
707
+
708
+ function ParamValue_$reflection(): TypeInfo {
709
+ return union_type("FormSpec.Integrations.CorEMR.FormTemplateDecoder.ParamValue", [], ParamValue, () => [[["Item", string_type]], [["Item", list_type(string_type)]]]);
710
+ }
711
+
712
+ const paramValueDecoder = (path_5: string): ((arg0: any) => FSharpResult$2_$union<ParamValue_$union, [string, ErrorReason_$union]>) => ((value_5: any): FSharpResult$2_$union<ParamValue_$union, [string, ErrorReason_$union]> => oneOf<ParamValue_$union>(ofArray([(path_1: string): ((arg0: any) => FSharpResult$2_$union<ParamValue_$union, [string, ErrorReason_$union]>) => ((value_1: any): FSharpResult$2_$union<ParamValue_$union, [string, ErrorReason_$union]> => map<string, ParamValue_$union>(ParamValue_ScalarParam, string, path_1, value_1)), (path_4: string): ((arg0: any) => FSharpResult$2_$union<ParamValue_$union, [string, ErrorReason_$union]>) => ((value_4: any): FSharpResult$2_$union<ParamValue_$union, [string, ErrorReason_$union]> => map<FSharpList<string>, ParamValue_$union>(ParamValue_ListParam, (path_3: string, value_3: any): FSharpResult$2_$union<FSharpList<string>, [string, ErrorReason_$union]> => list_7<string>(string, path_3, value_3), path_4, value_4))]), path_5, value_5));
713
+
714
+ const triggerActionDecoder: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<TriggerAction, [string, ErrorReason_$union]>)) = (() => {
715
+ let d_2: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<FSharpMap<string, ParamValue_$union>, [string, ErrorReason_$union]>));
716
+ const decoder_2: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<FSharpMap<string, ParamValue_$union>, [string, ErrorReason_$union]>)) = dictDecoder<ParamValue_$union>(uncurry2(paramValueDecoder));
717
+ d_2 = ((path_3: string): ((arg0: any) => FSharpResult$2_$union<FSharpMap<string, ParamValue_$union>, [string, ErrorReason_$union]>) => ((value_3: any): FSharpResult$2_$union<FSharpMap<string, ParamValue_$union>, [string, ErrorReason_$union]> => field_1<FSharpMap<string, ParamValue_$union>>("params", uncurry2(decoder_2), path_3, value_3)));
718
+ return (path_4: string): ((arg0: any) => FSharpResult$2_$union<TriggerAction, [string, ErrorReason_$union]>) => ((value_4: any): FSharpResult$2_$union<TriggerAction, [string, ErrorReason_$union]> => map3<int32, string, FSharpMap<string, ParamValue_$union>, TriggerAction>((actionId: int32, actionType: string, raw: FSharpMap<string, ParamValue_$union>): TriggerAction => {
719
+ let matchValue: FSharpList<[string, FSharpList<string>]>;
720
+ return new TriggerAction(actionId, actionType, ofList<string, string>(choose<[string, ParamValue_$union], [string, string]>((_arg: [string, ParamValue_$union]): Option<[string, string]> => {
721
+ if (_arg[1].tag === /* ListParam */ 1) {
722
+ return undefined;
723
+ }
724
+ else {
725
+ return [_arg[0], (_arg[1] as ParamValue<0>).fields[0]] as [string, string];
726
+ }
727
+ }, toList<string, ParamValue_$union>(raw)), {
728
+ Compare: comparePrimitives,
729
+ }), (matchValue = choose<[string, ParamValue_$union], [string, FSharpList<string>]>((_arg_1: [string, ParamValue_$union]): Option<[string, FSharpList<string>]> => {
730
+ if (_arg_1[1].tag === /* ScalarParam */ 0) {
731
+ return undefined;
732
+ }
733
+ else {
734
+ return [_arg_1[0], (_arg_1[1] as ParamValue<1>).fields[0]] as [string, FSharpList<string>];
735
+ }
736
+ }, toList<string, ParamValue_$union>(raw)), isEmpty(matchValue) ? undefined : ofList<string, FSharpList<string>>(matchValue, {
737
+ Compare: comparePrimitives,
738
+ })));
739
+ }, (path: string, value: any): FSharpResult$2_$union<int32, [string, ErrorReason_$union]> => field_1<int32>("actionId", uncurry2(int), path, value), (path_2: string, value_2: any): FSharpResult$2_$union<string, [string, ErrorReason_$union]> => field_1<string>("actionType", string, path_2, value_2), uncurry2(d_2), path_4, value_4));
740
+ })();
741
+
742
+ const itemTriggerDecoder = (path_6: string): ((arg0: any) => FSharpResult$2_$union<ItemTrigger, [string, ErrorReason_$union]>) => ((v: any): FSharpResult$2_$union<ItemTrigger, [string, ErrorReason_$union]> => object<ItemTrigger>((get$: IGetters): ItemTrigger => {
743
+ let objectArg: IRequiredGetter, objectArg_1: IRequiredGetter, objectArg_2: IRequiredGetter, objectArg_3: IRequiredGetter, objectArg_4: IRequiredGetter, objectArg_5: IRequiredGetter;
744
+ return new ItemTrigger((objectArg = get$.Required, objectArg.Field<int32>("triggerId", uncurry2(int))), (objectArg_1 = get$.Required, objectArg_1.Field<string>("eventName", string)), (objectArg_2 = get$.Required, objectArg_2.Field<boolean>("enabled", bool)), (objectArg_3 = get$.Required, objectArg_3.Field<Option<string>>("exclusiveTag", (path_3: string, value_3: any): FSharpResult$2_$union<Option<string>, [string, ErrorReason_$union]> => option<string>(string, path_3, value_3))), (objectArg_4 = get$.Required, objectArg_4.Field<FSharpList<TriggerCondition>>("conditions", (path_4: string, value_4: any): FSharpResult$2_$union<FSharpList<TriggerCondition>, [string, ErrorReason_$union]> => list_7<TriggerCondition>(uncurry2(triggerConditionDecoder), path_4, value_4))), (objectArg_5 = get$.Required, objectArg_5.Field<FSharpList<TriggerAction>>("actions", (path_5: string, value_5: any): FSharpResult$2_$union<FSharpList<TriggerAction>, [string, ErrorReason_$union]> => list_7<TriggerAction>(uncurry2(triggerActionDecoder), path_5, value_5))));
745
+ }, path_6, v));
746
+
747
+ function itemDecoder(declared: FormDeclarations): ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<TemplateItem, [string, ErrorReason_$union]>)) {
748
+ return orFail<TemplateItem>((path_13: 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> => {
749
+ let objectArg_1: IOptionalGetter, objectArg_2: IOptionalGetter, 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: IOptionalGetter, objectArg_12: IRequiredGetter;
750
+ let itemId: int32;
751
+ const objectArg: IRequiredGetter = get$.Required;
752
+ itemId = objectArg.Field<int32>("itemId", uncurry2(int));
753
+ const path = (f: string): string => toText(printf("forms[].items[itemId=%d].%s"))(itemId)(f);
754
+ 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))));
755
+ 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_7<ItemTrigger>(uncurry2(itemTriggerDecoder), path_1, value))));
756
+ let matchResult: int32, itemTriggers: ReleaseAvailability$1_$union<FSharpList<ItemTrigger>>, nestingLevel: ReleaseAvailability$1_$union<int32>, e: string;
757
+ const copyOfStruct: FSharpResult$2_$union<ReleaseAvailability$1_$union<int32>, string> = nesting;
758
+ if (copyOfStruct.tag === /* Error */ 1) {
759
+ matchResult = 1;
760
+ e = copyOfStruct.fields[0];
761
+ }
762
+ else {
763
+ const copyOfStruct_1: FSharpResult$2_$union<ReleaseAvailability$1_$union<FSharpList<ItemTrigger>>, string> = triggers;
764
+ if (copyOfStruct_1.tag === /* Error */ 1) {
765
+ matchResult = 1;
766
+ e = copyOfStruct_1.fields[0];
767
+ }
768
+ else {
769
+ matchResult = 0;
770
+ itemTriggers = copyOfStruct_1.fields[0];
771
+ nestingLevel = copyOfStruct.fields[0];
772
+ }
773
+ }
774
+ switch (matchResult) {
775
+ case 0:
776
+ 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$.Required, objectArg_7.Field<Option<string>>("sequenceText", (path_5: string, value_4: any): FSharpResult$2_$union<Option<string>, [string, ErrorReason_$union]> => option<string>(string, path_5, value_4))), (objectArg_8 = get$.Required, objectArg_8.Field<Option<string>>("code", (path_7: string, value_6: any): FSharpResult$2_$union<Option<string>, [string, ErrorReason_$union]> => option<string>(string, path_7, value_6))), (objectArg_9 = get$.Required, objectArg_9.Field<Option<string>>("uuid", (path_9: string, value_8: any): FSharpResult$2_$union<Option<string>, [string, ErrorReason_$union]> => option<string>(string, path_9, value_8))), (objectArg_10 = get$.Required, objectArg_10.Field<Option<string>>("genderRequired", (path_11: string, value_10: any): FSharpResult$2_$union<Option<string>, [string, ErrorReason_$union]> => option<string>(string, path_11, value_10))), (objectArg_11 = get$.Optional, objectArg_11.Field<int32>("highlight", uncurry2(int))), (objectArg_12 = get$.Required, objectArg_12.Field<FSharpList<TemplateChoice>>("choices", (path_12: string, value_11: any): FSharpResult$2_$union<FSharpList<TemplateChoice>, [string, ErrorReason_$union]> => list_7<TemplateChoice>(uncurry2(choiceDecoder), path_12, value_11))), itemTriggers!));
777
+ default:
778
+ return FSharpResult$2_Error<TemplateItem, string>(e!);
779
+ }
780
+ }, path_13, v));
781
+ }
782
+
783
+ function encounterTypesDecoder(declared: FormDeclarations): ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<EncounterTypes, [string, ErrorReason_$union]>)) {
784
+ 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> => {
785
+ let objectArg: IOptionalGetter, objectArg_1: IRequiredGetter, objectArg_2: IRequiredGetter, objectArg_3: IRequiredGetter;
786
+ 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)));
787
+ if (matchValue.tag === /* Error */ 1) {
788
+ return FSharpResult$2_Error<EncounterTypes, string>(matchValue.fields[0]);
789
+ }
790
+ else {
791
+ const other: ReleaseAvailability$1_$union<boolean> = matchValue.fields[0];
792
+ 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));
793
+ }
794
+ }, path_4, v));
795
+ }
796
+
797
+ 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 => {
798
+ let objectArg: IRequiredGetter, objectArg_1: IRequiredGetter;
799
+ return new ScoringLabel((objectArg = get$.Required, objectArg.Field<string>("name", string)), (objectArg_1 = get$.Required, objectArg_1.Field<int32>("min", uncurry2(int))));
800
+ }, path_1, v));
801
+
802
+ 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 => {
803
+ 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;
804
+ 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_7<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)))));
805
+ }, path_2, v));
806
+
807
+ function formDecoder(declared: FormDeclarations): ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<TemplateForm, [string, ErrorReason_$union]>)) {
808
+ return orFail<TemplateForm>((path_15: string, v: any): FSharpResult$2_$union<FSharpResult$2_$union<TemplateForm, string>, [string, ErrorReason_$union]> => object<FSharpResult$2_$union<TemplateForm, string>>((get$: IGetters): FSharpResult$2_$union<TemplateForm, string> => {
809
+ let objectArg: 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, arg_24: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<EncounterTypes, [string, ErrorReason_$union]>)), objectArg_11: IRequiredGetter, objectArg_12: IRequiredGetter, objectArg_13: IRequiredGetter, objectArg_14: IRequiredGetter, objectArg_15: IRequiredGetter, objectArg_16: IRequiredGetter, arg_36: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<FSharpList<TemplateItem>, [string, ErrorReason_$union]>)), decoder_2: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<TemplateItem, [string, ErrorReason_$union]>)), objectArg_17: IRequiredGetter;
810
+ let scoring: FSharpResult$2_$union<Option<FormScoring>, string>;
811
+ const matchValue: ReleaseAvailability$1_$union<FSharpList<string>> = declared.Scoring;
812
+ let matchResult: int32, because: string;
813
+ switch (matchValue.tag) {
814
+ case /* NotInRelease */ 1: {
815
+ matchResult = 1;
816
+ because = matchValue.fields[0];
817
+ break;
818
+ }
819
+ case /* NotReadYet */ 2: {
820
+ matchResult = 1;
821
+ because = matchValue.fields[0];
822
+ break;
823
+ }
824
+ default:
825
+ matchResult = 0;
826
+ }
827
+ switch (matchResult) {
828
+ case 0: {
829
+ scoring = FSharpResult$2_Ok<Option<FormScoring>, string>((objectArg = get$.Required, objectArg.Field<Option<FormScoring>>("scoring", (path: string, value: any): FSharpResult$2_$union<Option<FormScoring>, [string, ErrorReason_$union]> => option<FormScoring>(uncurry2(formScoringDecoder), path, value))));
830
+ break;
831
+ }
832
+ default: {
833
+ let matchValue_1: Option<FormScoring>;
834
+ const objectArg_1: IOptionalGetter = get$.Optional;
835
+ matchValue_1 = objectArg_1.Field<FormScoring>("scoring", uncurry2(formScoringDecoder));
836
+ scoring = ((matchValue_1 != null) ? FSharpResult$2_Error<Option<FormScoring>, string>(toText(printf("the answer declares scoring NOT stated by this release (%s) and the form carries a `scoring` anyway"))(because!)) : FSharpResult$2_Ok<Option<FormScoring>, string>(undefined));
837
+ }
838
+ }
839
+ if (scoring.tag === /* Ok */ 0) {
840
+ const formScoring: Option<FormScoring> = scoring.fields[0];
841
+ return FSharpResult$2_Ok<TemplateForm, string>(new TemplateForm((objectArg_2 = get$.Required, objectArg_2.Field<int32>("formId", uncurry2(int))), (objectArg_3 = get$.Required, objectArg_3.Field<string>("name", string)), (objectArg_4 = get$.Required, objectArg_4.Field<string>("formCode", string)), (objectArg_5 = get$.Required, objectArg_5.Field<string>("formCodeSource", string)), (objectArg_6 = get$.Required, objectArg_6.Field<string>("description", string)), (objectArg_7 = get$.Required, objectArg_7.Field<int64>("currentVersionId", uncurry2(liberatedInt64Decoder))), (objectArg_8 = get$.Required, objectArg_8.Field<boolean>("isIntake", bool)), (objectArg_9 = get$.Required, objectArg_9.Field<Option<string>>("usage", (path_7: string, value_7: any): FSharpResult$2_$union<Option<string>, [string, ErrorReason_$union]> => option<string>(string, path_7, value_7))), (objectArg_10 = get$.Required, objectArg_10.Field<boolean>("requiresSignature", bool)), (arg_24 = encounterTypesDecoder(declared), (objectArg_11 = get$.Required, objectArg_11.Field<EncounterTypes>("encounterTypes", uncurry2(arg_24)))), (objectArg_12 = get$.Required, objectArg_12.Field<boolean>("onceAYear", bool)), (objectArg_13 = get$.Required, objectArg_13.Field<string>("structureHash", string)), (objectArg_14 = get$.Required, objectArg_14.Field<string>("clinicalHash", string)), (objectArg_15 = get$.Required, objectArg_15.Field<string>("cosmeticHash", string)), (objectArg_16 = get$.Required, objectArg_16.Field<string>("hash", string)), (arg_36 = ((decoder_2 = itemDecoder(declared), (path_14: string): ((arg0: any) => FSharpResult$2_$union<FSharpList<TemplateItem>, [string, ErrorReason_$union]>) => ((value_14: any): FSharpResult$2_$union<FSharpList<TemplateItem>, [string, ErrorReason_$union]> => list_7<TemplateItem>(uncurry2(decoder_2), path_14, value_14)))), (objectArg_17 = get$.Required, objectArg_17.Field<FSharpList<TemplateItem>>("items", uncurry2(arg_36)))), formScoring));
842
+ }
843
+ else {
844
+ return FSharpResult$2_Error<TemplateForm, string>(scoring.fields[0]);
845
+ }
846
+ }, path_15, v));
847
+ }
848
+
849
+ 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 => {
850
+ let objectArg: IRequiredGetter, objectArg_1: IRequiredGetter;
851
+ return new ElementTypeEntry((objectArg = get$.Required, objectArg.Field<string>("label", string)), (objectArg_1 = get$.Required, objectArg_1.Field<string>("control", string)));
852
+ }, path_2, v));
853
+
854
+ 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> => {
855
+ let objectArg_1: IRequiredGetter, objectArg_2: IRequiredGetter, objectArg_3: IRequiredGetter, objectArg_4: IRequiredGetter, objectArg_5: IRequiredGetter;
856
+ let matchValue: string;
857
+ const objectArg: IRequiredGetter = get$.Required;
858
+ matchValue = objectArg.Field<string>("statedBy", string);
859
+ switch (matchValue) {
860
+ case "site":
861
+ 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))));
862
+ case "conduit":
863
+ return FSharpResult$2_Ok<ElementTypesFrom_$union, string>(ElementTypesFrom_DeclaredByConduit((objectArg_4 = get$.Required, objectArg_4.Field<string>("because", string))));
864
+ case "nobody":
865
+ return FSharpResult$2_Ok<ElementTypesFrom_$union, string>(ElementTypesFrom_NotInRelease((objectArg_5 = get$.Required, objectArg_5.Field<string>("because", string))));
866
+ default:
867
+ return FSharpResult$2_Error<ElementTypesFrom_$union, string>(toText(printf("`elementTypesFrom.statedBy` = `%s` is not a provenance this build understands (site | conduit | nobody)"))(matchValue));
868
+ }
869
+ }, path_6, v));
870
+
871
+ const instrumentMapEntryDecoder = (path_6: string): ((arg0: any) => FSharpResult$2_$union<InstrumentMapEntry, [string, ErrorReason_$union]>) => ((v: any): FSharpResult$2_$union<InstrumentMapEntry, [string, ErrorReason_$union]> => object<InstrumentMapEntry>((get$: IGetters): InstrumentMapEntry => {
872
+ let objectArg: IRequiredGetter, objectArg_1: IRequiredGetter, objectArg_2: IRequiredGetter, objectArg_3: IRequiredGetter, objectArg_4: IRequiredGetter, objectArg_5: IRequiredGetter;
873
+ return new InstrumentMapEntry((objectArg = get$.Required, objectArg.Field<string>("instrumentType", string)), (objectArg_1 = get$.Required, objectArg_1.Field<string>("formCode", string)), (objectArg_2 = get$.Required, objectArg_2.Field<Option<int32>>("maxScore", (path_2: string, value_2: any): FSharpResult$2_$union<Option<int32>, [string, ErrorReason_$union]> => option<int32>(uncurry2(int), path_2, value_2))), (objectArg_3 = get$.Required, objectArg_3.Field<string>("source", string)), (objectArg_4 = get$.Required, objectArg_4.Field<boolean>("archived", bool)), (objectArg_5 = get$.Required, objectArg_5.Field<string>("formName", string)));
874
+ }, path_6, v));
875
+
876
+ const codeExtractionStatsDecoder = (path_1: string): ((arg0: any) => FSharpResult$2_$union<CodeExtractionStats, [string, ErrorReason_$union]>) => ((v: any): FSharpResult$2_$union<CodeExtractionStats, [string, ErrorReason_$union]> => object<CodeExtractionStats>((get$: IGetters): CodeExtractionStats => {
877
+ let objectArg: IRequiredGetter, objectArg_1: IRequiredGetter, arg_5: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<FSharpMap<string, int32>, [string, ErrorReason_$union]>)), objectArg_2: IRequiredGetter, objectArg_3: IRequiredGetter;
878
+ return new CodeExtractionStats((objectArg = get$.Required, objectArg.Field<int32>("extracted", uncurry2(int))), (objectArg_1 = get$.Required, objectArg_1.Field<int32>("generated", uncurry2(int))), (arg_5 = dictDecoder<int32>(uncurry2(int)), (objectArg_2 = get$.Required, objectArg_2.Field<FSharpMap<string, int32>>("bySource", uncurry2(arg_5)))), (objectArg_3 = get$.Required, objectArg_3.Field<string>("regex", string)));
879
+ }, path_1, v));
880
+
881
+ const triggerStatsDecoder = (path: string): ((arg0: any) => FSharpResult$2_$union<TriggerStats, [string, ErrorReason_$union]>) => ((v: any): FSharpResult$2_$union<TriggerStats, [string, ErrorReason_$union]> => object<TriggerStats>((get$: IGetters): TriggerStats => {
882
+ let objectArg: IRequiredGetter, objectArg_1: IRequiredGetter, arg_5: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<FSharpMap<string, int32>, [string, ErrorReason_$union]>)), objectArg_2: IRequiredGetter;
883
+ return new TriggerStats((objectArg = get$.Required, objectArg.Field<int32>("formsWithTriggers", uncurry2(int))), (objectArg_1 = get$.Required, objectArg_1.Field<int32>("totalTriggers", uncurry2(int))), (arg_5 = dictDecoder<int32>(uncurry2(int)), (objectArg_2 = get$.Required, objectArg_2.Field<FSharpMap<string, int32>>("byActionType", uncurry2(arg_5)))));
884
+ }, path, v));
885
+
886
+ 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 => {
887
+ 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;
888
+ 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))));
889
+ }, path, v));
890
+
891
+ 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 => {
892
+ let objectArg: IRequiredGetter, objectArg_1: IRequiredGetter, objectArg_2: IRequiredGetter;
893
+ return new CoreEmrInfo((objectArg = get$.Required, objectArg.Field<string>("appVersion", string)), (objectArg_1 = get$.Required, objectArg_1.Field<string>("schemaVersion", string)), (objectArg_2 = get$.Required, objectArg_2.Field<int32>("schemaRevision", uncurry2(int))));
894
+ }, path_2, v));
895
+
896
+ const instrumentMapStatsDecoder = (path: string): ((arg0: any) => FSharpResult$2_$union<InstrumentMapStats, [string, ErrorReason_$union]>) => ((v: any): FSharpResult$2_$union<InstrumentMapStats, [string, ErrorReason_$union]> => object<InstrumentMapStats>((get$: IGetters): InstrumentMapStats => {
897
+ 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, arg_9: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<FSharpMap<string, int32>, [string, ErrorReason_$union]>)), objectArg_4: IRequiredGetter;
898
+ 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)))));
899
+ }, path, v));
900
+
901
+ function scoringCatalogOf(instrumentMap: Option<FSharpMap<string, InstrumentMapEntry>>, instrumentMapStats: Option<InstrumentMapStats>, withScoring: Option<int32>): FSharpResult$2_$union<Option<ScoringCatalog>, string> {
902
+ let arg: string;
903
+ let matchResult: int32, m: FSharpMap<string, InstrumentMapEntry>, s: InstrumentMapStats, w: int32;
904
+ if (instrumentMap == null) {
905
+ if (instrumentMapStats == null) {
906
+ if (withScoring == null) {
907
+ matchResult = 1;
908
+ }
909
+ else {
910
+ matchResult = 2;
911
+ }
912
+ }
913
+ else {
914
+ matchResult = 2;
915
+ }
916
+ }
917
+ else if (instrumentMapStats != null) {
918
+ if (withScoring != null) {
919
+ matchResult = 0;
920
+ m = value_15(instrumentMap);
921
+ s = value_15(instrumentMapStats);
922
+ w = value_15(withScoring);
923
+ }
924
+ else {
925
+ matchResult = 2;
926
+ }
927
+ }
928
+ else {
929
+ matchResult = 2;
930
+ }
931
+ switch (matchResult) {
932
+ case 0:
933
+ return FSharpResult$2_Ok<Option<ScoringCatalog>, string>(new ScoringCatalog(m!, s!, w!));
934
+ case 1:
935
+ return FSharpResult$2_Ok<Option<ScoringCatalog>, string>(undefined);
936
+ default:
937
+ return FSharpResult$2_Error<Option<ScoringCatalog>, string>((arg = join_1("`, `", toList_1<string>(delay<string>((): Iterable<string> => append<string>((instrumentMap != null) ? singleton<string>("instrumentMap") : empty_1<string>(), delay<string>((): Iterable<string> => append<string>((instrumentMapStats != null) ? singleton<string>("instrumentMapStats") : empty_1<string>(), delay<string>((): Iterable<string> => ((withScoring != null) ? singleton<string>("stats.withScoring") : empty_1<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)));
938
+ }
939
+ }
940
+
941
+ /**
942
+ * Convert a TemplateChoice to CoreMRChoice (FormSpec type).
943
+ * Score stays int64 — raw scores can reach 2^31 for bitmask forms.
944
+ * Does this control carry free text, and does it carry a date?
945
+ *
946
+ * ⭐ THE ONE IMPLEMENTATION. It lives here because this file compiles before every adapter that needs
947
+ * it, so nothing downstream has an excuse to write a second one. ⛔ It follows from the CONTROL, which
948
+ * the site states (5.5.0+9704) or conduit declares (5.5.0+10245) — never from the invented `textField`
949
+ * word, which nothing publishes any more.
950
+ * ⚠️ It says what the UI OFFERS, not what a given item's answers contain: type 130 is a vitals widget
951
+ * and 35,427 of its answers carry text anyway.
952
+ */
953
+ export function carriesTextOrDate(control: string): [boolean, boolean] {
954
+ let matchResult: int32, c_3: string;
955
+ switch (control) {
956
+ case "DateField":
957
+ case "DateFieldWithTime": {
958
+ matchResult = 0;
959
+ break;
960
+ }
961
+ case "SignatureAndDate":
962
+ case "SignatureAndDateWithTime": {
963
+ matchResult = 1;
964
+ break;
965
+ }
966
+ case "ShortAnswer":
967
+ case "NoteEssay": {
968
+ matchResult = 2;
969
+ break;
970
+ }
971
+ case "PatientVitals": {
972
+ if (control.endsWith("PlusNotes")) {
973
+ matchResult = 3;
974
+ c_3 = control;
975
+ }
976
+ else {
977
+ matchResult = 4;
978
+ }
979
+ break;
980
+ }
981
+ case "AllergyFinder": {
982
+ if (control.endsWith("PlusNotes")) {
983
+ matchResult = 3;
984
+ c_3 = control;
985
+ }
986
+ else {
987
+ matchResult = 4;
988
+ }
989
+ break;
990
+ }
991
+ default:
992
+ if (control.endsWith("PlusNotes")) {
993
+ matchResult = 3;
994
+ c_3 = control;
995
+ }
996
+ else {
997
+ matchResult = 5;
998
+ }
999
+ }
1000
+ switch (matchResult) {
1001
+ case 0:
1002
+ return [true, true] as [boolean, boolean];
1003
+ case 1:
1004
+ return [true, true] as [boolean, boolean];
1005
+ case 2:
1006
+ return [true, false] as [boolean, boolean];
1007
+ case 3:
1008
+ return [true, false] as [boolean, boolean];
1009
+ case 4:
1010
+ return [true, false] as [boolean, boolean];
1011
+ default:
1012
+ return [false, false] as [boolean, boolean];
1013
+ }
1014
+ }
1015
+
1016
+ export class FormTemplateServed extends Record implements IEquatable<FormTemplateServed>, IComparable<FormTemplateServed> {
1017
+ readonly Form: TemplateForm;
1018
+ readonly ElementTypes: Option<FSharpMap<string, ElementTypeEntry>>;
1019
+ readonly ElementTypesFrom: ElementTypesFrom_$union;
1020
+ readonly Instrument: ReleaseAvailability$1_$union<Option<InstrumentMapEntry>>;
1021
+ readonly GeneratedFrom: string;
1022
+ readonly TriggersFrom: ReleaseAvailability$1_$union<FSharpList<string>>;
1023
+ readonly ActiveAt: FSharpList<int32>;
1024
+ readonly TriggerReads: ReleaseAvailability$1_$union<FSharpList<Trigger>>;
1025
+ constructor(Form: TemplateForm, ElementTypes: Option<FSharpMap<string, ElementTypeEntry>>, ElementTypesFrom: ElementTypesFrom_$union, Instrument: ReleaseAvailability$1_$union<Option<InstrumentMapEntry>>, GeneratedFrom: string, TriggersFrom: ReleaseAvailability$1_$union<FSharpList<string>>, ActiveAt: FSharpList<int32>, TriggerReads: ReleaseAvailability$1_$union<FSharpList<Trigger>>) {
1026
+ super();
1027
+ this.Form = Form;
1028
+ this.ElementTypes = ElementTypes;
1029
+ this.ElementTypesFrom = ElementTypesFrom;
1030
+ this.Instrument = Instrument;
1031
+ this.GeneratedFrom = GeneratedFrom;
1032
+ this.TriggersFrom = TriggersFrom;
1033
+ this.ActiveAt = ActiveAt;
1034
+ this.TriggerReads = TriggerReads;
1035
+ }
1036
+ }
1037
+
1038
+ export function FormTemplateServed_$reflection(): TypeInfo {
1039
+ return record_type("FormSpec.Integrations.CorEMR.FormTemplateDecoder.FormTemplateServed", [], FormTemplateServed, () => [["Form", TemplateForm_$reflection()], ["ElementTypes", option_type(class_type("Microsoft.FSharp.Collections.FSharpMap`2", [string_type, ElementTypeEntry_$reflection()]))], ["ElementTypesFrom", ElementTypesFrom_$reflection()], ["Instrument", ReleaseAvailability$1_$reflection(option_type(InstrumentMapEntry_$reflection()))], ["GeneratedFrom", string_type], ["TriggersFrom", ReleaseAvailability$1_$reflection(list_type(string_type))], ["ActiveAt", list_type(int32_type)], ["TriggerReads", ReleaseAvailability$1_$reflection(list_type(Trigger_$reflection()))]]);
1040
+ }
1041
+
1042
+ export type FormTemplateAnswer_$union =
1043
+ | FormTemplateAnswer<0>
1044
+ | FormTemplateAnswer<1>
1045
+
1046
+ export type FormTemplateAnswer_$cases = {
1047
+ 0: ["Served", [FormTemplateServed]],
1048
+ 1: ["NotInCatalog", [int32, string]]
1049
+ }
1050
+
1051
+ export function FormTemplateAnswer_Served(Item: FormTemplateServed) {
1052
+ return new FormTemplateAnswer<0>(0, [Item]);
1053
+ }
1054
+
1055
+ export function FormTemplateAnswer_NotInCatalog(formId: int32, because: string) {
1056
+ return new FormTemplateAnswer<1>(1, [formId, because]);
1057
+ }
1058
+
1059
+ export class FormTemplateAnswer<Tag extends keyof FormTemplateAnswer_$cases> extends Union<Tag, FormTemplateAnswer_$cases[Tag][0]> {
1060
+ constructor(readonly tag: Tag, readonly fields: FormTemplateAnswer_$cases[Tag][1]) {
1061
+ super();
1062
+ }
1063
+ cases() {
1064
+ return ["Served", "NotInCatalog"];
1065
+ }
1066
+ }
1067
+
1068
+ export function FormTemplateAnswer_$reflection(): TypeInfo {
1069
+ return union_type("FormSpec.Integrations.CorEMR.FormTemplateDecoder.FormTemplateAnswer", [], FormTemplateAnswer, () => [[["Item", FormTemplateServed_$reflection()]], [["formId", int32_type], ["because", string_type]]]);
1070
+ }
1071
+
1072
+ const formTemplateAnswerDecoder: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<FormTemplateAnswer_$union, [string, ErrorReason_$union]>)) = orFail<FormTemplateAnswer_$union>((path_6: string, v: any): FSharpResult$2_$union<FSharpResult$2_$union<FormTemplateAnswer_$union, string>, [string, ErrorReason_$union]> => object<FSharpResult$2_$union<FormTemplateAnswer_$union, string>>((get$: IGetters): FSharpResult$2_$union<FormTemplateAnswer_$union, string> => {
1073
+ let objectArg_1: IRequiredGetter, objectArg_2: IRequiredGetter, arg_11: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<ReleaseAvailability$1_$union<FSharpList<string>>, [string, ErrorReason_$union]>)), objectArg_5: IRequiredGetter, arg_13: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<ReleaseAvailability$1_$union<FSharpList<string>>, [string, ErrorReason_$union]>)), objectArg_6: IRequiredGetter, objectArg_7: IRequiredGetter, objectArg_10: IOptionalGetter, arg_24: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<TemplateForm, [string, ErrorReason_$union]>)), objectArg_11: IRequiredGetter, arg_26: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<Option<FSharpMap<string, ElementTypeEntry>>, [string, ErrorReason_$union]>)), decoder_1: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<FSharpMap<string, ElementTypeEntry>, [string, ErrorReason_$union]>)), objectArg_12: IRequiredGetter, objectArg_13: IRequiredGetter, objectArg_14: IRequiredGetter, objectArg_15: IRequiredGetter;
1074
+ let matchValue: string;
1075
+ const objectArg: IRequiredGetter = get$.Required;
1076
+ matchValue = objectArg.Field<string>("kind", string);
1077
+ switch (matchValue) {
1078
+ case "notInCatalog":
1079
+ return FSharpResult$2_Ok<FormTemplateAnswer_$union, string>(FormTemplateAnswer_NotInCatalog((objectArg_1 = get$.Required, objectArg_1.Field<int32>("formId", uncurry2(int))), (objectArg_2 = get$.Required, objectArg_2.Field<string>("because", string))));
1080
+ case "served": {
1081
+ let triggersRow: ReleaseAvailability$1_$union<FSharpList<string>>;
1082
+ const arg_7: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<ReleaseAvailability$1_$union<FSharpList<string>>, [string, ErrorReason_$union]>)) = availabilityRowDecoder("triggersFrom");
1083
+ const objectArg_3: IRequiredGetter = get$.Required;
1084
+ triggersRow = objectArg_3.Field<ReleaseAvailability$1_$union<FSharpList<string>>>("triggersFrom", uncurry2(arg_7));
1085
+ let scoringRow: ReleaseAvailability$1_$union<FSharpList<string>>;
1086
+ const arg_9: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<ReleaseAvailability$1_$union<FSharpList<string>>, [string, ErrorReason_$union]>)) = availabilityRowDecoder("scoringFrom");
1087
+ const objectArg_4: IRequiredGetter = get$.Required;
1088
+ scoringRow = objectArg_4.Field<ReleaseAvailability$1_$union<FSharpList<string>>>("scoringFrom", uncurry2(arg_9));
1089
+ const declared: FormDeclarations = new FormDeclarations((arg_11 = availabilityRowDecoder("itemNestingFrom"), (objectArg_5 = get$.Required, objectArg_5.Field<ReleaseAvailability$1_$union<FSharpList<string>>>("itemNestingFrom", uncurry2(arg_11)))), triggersRow, (arg_13 = availabilityRowDecoder("encounterOtherFrom"), (objectArg_6 = get$.Required, objectArg_6.Field<ReleaseAvailability$1_$union<FSharpList<string>>>("encounterOtherFrom", uncurry2(arg_13)))), scoringRow);
1090
+ let instrument: FSharpResult$2_$union<ReleaseAvailability$1_$union<Option<InstrumentMapEntry>>, string>;
1091
+ const carriedAnyway = <$a>(because: string): FSharpResult$2_$union<$a, string> => FSharpResult$2_Error<$a, string>(toText(printf("the form template declares scoring NOT stated by this release (%s) and carries an `instrument` anyway"))(because));
1092
+ switch (scoringRow.tag) {
1093
+ case /* NotInRelease */ 1: {
1094
+ const because_1: string = scoringRow.fields[0];
1095
+ let matchValue_1: Option<InstrumentMapEntry>;
1096
+ const objectArg_8: IOptionalGetter = get$.Optional;
1097
+ matchValue_1 = objectArg_8.Field<InstrumentMapEntry>("instrument", uncurry2(instrumentMapEntryDecoder));
1098
+ instrument = ((matchValue_1 != null) ? carriedAnyway(because_1) : FSharpResult$2_Ok<ReleaseAvailability$1_$union<Option<InstrumentMapEntry>>, string>(ReleaseAvailability$1_NotInRelease<Option<InstrumentMapEntry>>(because_1)));
1099
+ break;
1100
+ }
1101
+ case /* NotReadYet */ 2: {
1102
+ const witness: FSharpList<string> = scoringRow.fields[1];
1103
+ const because_2: string = scoringRow.fields[0];
1104
+ let matchValue_2: Option<InstrumentMapEntry>;
1105
+ const objectArg_9: IOptionalGetter = get$.Optional;
1106
+ matchValue_2 = objectArg_9.Field<InstrumentMapEntry>("instrument", uncurry2(instrumentMapEntryDecoder));
1107
+ instrument = ((matchValue_2 != null) ? carriedAnyway(because_2) : FSharpResult$2_Ok<ReleaseAvailability$1_$union<Option<InstrumentMapEntry>>, string>(ReleaseAvailability$1_NotReadYet<Option<InstrumentMapEntry>>(because_2, witness)));
1108
+ break;
1109
+ }
1110
+ default:
1111
+ instrument = FSharpResult$2_Ok<ReleaseAvailability$1_$union<Option<InstrumentMapEntry>>, string>(ReleaseAvailability$1_Stated<Option<InstrumentMapEntry>>((objectArg_7 = get$.Required, objectArg_7.Field<Option<InstrumentMapEntry>>("instrument", (path_2: string, value_2: any): FSharpResult$2_$union<Option<InstrumentMapEntry>, [string, ErrorReason_$union]> => option<InstrumentMapEntry>(uncurry2(instrumentMapEntryDecoder), path_2, value_2)))));
1112
+ }
1113
+ const triggerReads: FSharpResult$2_$union<ReleaseAvailability$1_$union<FSharpList<Trigger>>, string> = join<FSharpList<Trigger>>("triggerReads", triggersRow, (objectArg_10 = get$.Optional, objectArg_10.Field<FSharpList<Trigger>>("triggerReads", uncurry2(triggers_1))));
1114
+ let matchResult: int32, e: string, instrument_1: ReleaseAvailability$1_$union<Option<InstrumentMapEntry>>, triggerReads_1: ReleaseAvailability$1_$union<FSharpList<Trigger>>;
1115
+ const copyOfStruct: FSharpResult$2_$union<ReleaseAvailability$1_$union<Option<InstrumentMapEntry>>, string> = instrument;
1116
+ if (copyOfStruct.tag === /* Ok */ 0) {
1117
+ const copyOfStruct_1: FSharpResult$2_$union<ReleaseAvailability$1_$union<FSharpList<Trigger>>, string> = triggerReads;
1118
+ if (copyOfStruct_1.tag === /* Ok */ 0) {
1119
+ matchResult = 1;
1120
+ instrument_1 = copyOfStruct.fields[0];
1121
+ triggerReads_1 = copyOfStruct_1.fields[0];
1122
+ }
1123
+ else {
1124
+ matchResult = 0;
1125
+ e = copyOfStruct_1.fields[0];
1126
+ }
1127
+ }
1128
+ else {
1129
+ matchResult = 0;
1130
+ e = copyOfStruct.fields[0];
1131
+ }
1132
+ switch (matchResult) {
1133
+ case 0:
1134
+ return FSharpResult$2_Error<FormTemplateAnswer_$union, string>(e!);
1135
+ default:
1136
+ return FSharpResult$2_Ok<FormTemplateAnswer_$union, string>(FormTemplateAnswer_Served(new FormTemplateServed((arg_24 = formDecoder(declared), (objectArg_11 = get$.Required, objectArg_11.Field<TemplateForm>("form", uncurry2(arg_24)))), (arg_26 = ((decoder_1 = dictDecoder<ElementTypeEntry>(uncurry2(elementTypeDecoder)), (path_3: string): ((arg0: any) => FSharpResult$2_$union<Option<FSharpMap<string, ElementTypeEntry>>, [string, ErrorReason_$union]>) => ((value_3: any): FSharpResult$2_$union<Option<FSharpMap<string, ElementTypeEntry>>, [string, ErrorReason_$union]> => option<FSharpMap<string, ElementTypeEntry>>(uncurry2(decoder_1), path_3, value_3)))), (objectArg_12 = get$.Required, objectArg_12.Field<Option<FSharpMap<string, ElementTypeEntry>>>("elementTypes", uncurry2(arg_26)))), (objectArg_13 = get$.Required, objectArg_13.Field<ElementTypesFrom_$union>("elementTypesFrom", uncurry2(elementTypesFromDecoder))), instrument_1!, (objectArg_14 = get$.Required, objectArg_14.Field<string>("generatedFrom", string)), triggersRow, (objectArg_15 = get$.Required, objectArg_15.Field<FSharpList<int32>>("activeAt", (path_5: string, value_5: any): FSharpResult$2_$union<FSharpList<int32>, [string, ErrorReason_$union]> => list_7<int32>(uncurry2(int), path_5, value_5))), triggerReads_1!)));
1137
+ }
1138
+ }
1139
+ default:
1140
+ return FSharpResult$2_Error<FormTemplateAnswer_$union, string>(toText(printf("`kind` = `%s` is not a form-template answer this build understands (served | notInCatalog) — it is NOT read as either"))(matchValue));
1141
+ }
1142
+ }, path_6, v));
1143
+
1144
+ function readsJoinRaw(answer: FormTemplateAnswer_$union): FSharpResult$2_$union<FormTemplateAnswer_$union, string> {
1145
+ if (answer.tag === /* Served */ 0) {
1146
+ const served: FormTemplateServed = answer.fields[0];
1147
+ const matchValue: ReleaseAvailability$1_$union<FSharpList<Trigger>> = served.TriggerReads;
1148
+ switch (matchValue.tag) {
1149
+ case /* Stated */ 0: {
1150
+ const form: TemplateForm = served.Form;
1151
+ const byId: FSharpMap<int32, Trigger> = ofList<int32, Trigger>(map_1<Trigger, [int32, Trigger]>((t: Trigger): [int32, Trigger] => ([t.TriggerId, t] as [int32, Trigger]), matchValue.fields[0]), {
1152
+ Compare: comparePrimitives,
1153
+ });
1154
+ const _arg: Option<string> = tryPick<ItemTrigger, string>((raw: ItemTrigger): Option<string> => {
1155
+ let arg_8: FSharpList<int32>, arg_9: FSharpList<int32>;
1156
+ const matchValue_1: Option<Trigger> = FSharpMap__TryFind(byId, raw.TriggerId);
1157
+ if (matchValue_1 != null) {
1158
+ const read: Trigger = value_15(matchValue_1);
1159
+ const rawIds: FSharpSet<int32> = ofList_1<int32>(map_1<TriggerAction, int32>((a: TriggerAction): int32 => a.ActionId, raw.Actions), {
1160
+ Compare: comparePrimitives,
1161
+ });
1162
+ const readIds: FSharpSet<int32> = ofList_1<int32>(map_1<StatedAction, int32>((a_1: StatedAction): int32 => a_1.ActionId, read.Actions), {
1163
+ Compare: comparePrimitives,
1164
+ });
1165
+ const rawSources: FSharpList<Option<int32>> = map_1<TriggerCondition, Option<int32>>((c: TriggerCondition): Option<int32> => c.SourceFieldId, raw.Conditions);
1166
+ const readSources: FSharpList<Option<int32>> = map_1<StatedCondition, Option<int32>>((c_1: StatedCondition): Option<int32> => c_1.SourceItem, read.Conditions);
1167
+ if (!equals(rawSources, readSources)) {
1168
+ return toText(printf("form %d: trigger %d states conditions on items %A but its read carries %A"))(form.FormId)(raw.TriggerId)(rawSources)(readSources);
1169
+ }
1170
+ else if (!rawIds.Equals(readIds)) {
1171
+ return (arg_8 = toList_2<int32>(rawIds), (arg_9 = toList_2<int32>(readIds), toText(printf("form %d: trigger %d states actions %A but its read carries %A"))(form.FormId)(raw.TriggerId)(arg_8)(arg_9)));
1172
+ }
1173
+ else {
1174
+ return undefined;
1175
+ }
1176
+ }
1177
+ else {
1178
+ return toText(printf("form %d: trigger %d is served with no `triggerReads` entry"))(form.FormId)(raw.TriggerId);
1179
+ }
1180
+ }, collect<TemplateItem, ItemTrigger>((i: TemplateItem): FSharpList<ItemTrigger> => ReleaseAvailability_readList<ItemTrigger>(i.Triggers), form.Items));
1181
+ if (_arg == null) {
1182
+ return FSharpResult$2_Ok<FormTemplateAnswer_$union, string>(answer);
1183
+ }
1184
+ else {
1185
+ return FSharpResult$2_Error<FormTemplateAnswer_$union, string>(value_15(_arg));
1186
+ }
1187
+ }
1188
+ default:
1189
+ return FSharpResult$2_Ok<FormTemplateAnswer_$union, string>(answer);
1190
+ }
1191
+ }
1192
+ else {
1193
+ return FSharpResult$2_Ok<FormTemplateAnswer_$union, string>(answer);
1194
+ }
1195
+ }
1196
+
1197
+ const formTemplateAnswerJoined: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<FormTemplateAnswer_$union, [string, ErrorReason_$union]>)) = orFail<FormTemplateAnswer_$union>((path: string, value: any): FSharpResult$2_$union<FSharpResult$2_$union<FormTemplateAnswer_$union, string>, [string, ErrorReason_$union]> => map<FormTemplateAnswer_$union, FSharpResult$2_$union<FormTemplateAnswer_$union, string>>(readsJoinRaw, uncurry2(formTemplateAnswerDecoder), path, value));
1198
+
1199
+ /**
1200
+ * Decode `GET /api/coremr/form-templates/{formId}` (200 `served` or 404 `notInCatalog` — the same wire).
1201
+ */
1202
+ export function decodeFormTemplateAnswer(json: string): FSharpResult$2_$union<FormTemplateAnswer_$union, string> {
1203
+ return fromString<FormTemplateAnswer_$union>(uncurry2(formTemplateAnswerJoined), json);
1204
+ }
1205
+
1206
+ /**
1207
+ * Decode `POST /api/coremr/form-templates/batch` — one answer per requested id, in request order.
1208
+ */
1209
+ export function decodeFormTemplateBatch(json: string): FSharpResult$2_$union<FSharpList<FormTemplateAnswer_$union>, string> {
1210
+ return fromString<FSharpList<FormTemplateAnswer_$union>>((path_1: string, value_1: any): FSharpResult$2_$union<FSharpList<FormTemplateAnswer_$union>, [string, ErrorReason_$union]> => field_1<FSharpList<FormTemplateAnswer_$union>>("answers", (path: string, value: any): FSharpResult$2_$union<FSharpList<FormTemplateAnswer_$union>, [string, ErrorReason_$union]> => list_7<FormTemplateAnswer_$union>(uncurry2(formTemplateAnswerJoined), path, value), path_1, value_1), json);
1211
+ }
1212
+
1213
+ export class SiteCatalog extends Record implements IEquatable<SiteCatalog>, IComparable<SiteCatalog> {
1214
+ readonly Version: int32;
1215
+ readonly GeneratedAt: string;
1216
+ readonly GeneratedFrom: string;
1217
+ readonly CoreEmr: CoreEmrInfo;
1218
+ readonly Stats: TemplateStats;
1219
+ readonly Scoring: ReleaseAvailability$1_$union<ScoringCatalog>;
1220
+ readonly Triggers: ReleaseAvailability$1_$union<TriggerStats>;
1221
+ readonly FormIds: FSharpList<int32>;
1222
+ constructor(Version: int32, GeneratedAt: string, GeneratedFrom: string, CoreEmr: CoreEmrInfo, Stats: TemplateStats, Scoring: ReleaseAvailability$1_$union<ScoringCatalog>, Triggers: ReleaseAvailability$1_$union<TriggerStats>, FormIds: FSharpList<int32>) {
1223
+ super();
1224
+ this.Version = (Version | 0);
1225
+ this.GeneratedAt = GeneratedAt;
1226
+ this.GeneratedFrom = GeneratedFrom;
1227
+ this.CoreEmr = CoreEmr;
1228
+ this.Stats = Stats;
1229
+ this.Scoring = Scoring;
1230
+ this.Triggers = Triggers;
1231
+ this.FormIds = FormIds;
1232
+ }
1233
+ }
1234
+
1235
+ export function SiteCatalog_$reflection(): TypeInfo {
1236
+ return record_type("FormSpec.Integrations.CorEMR.FormTemplateDecoder.SiteCatalog", [], SiteCatalog, () => [["Version", int32_type], ["GeneratedAt", string_type], ["GeneratedFrom", string_type], ["CoreEmr", CoreEmrInfo_$reflection()], ["Stats", TemplateStats_$reflection()], ["Scoring", ReleaseAvailability$1_$reflection(ScoringCatalog_$reflection())], ["Triggers", ReleaseAvailability$1_$reflection(TriggerStats_$reflection())], ["FormIds", list_type(int32_type)]]);
1237
+ }
1238
+
1239
+ const siteCatalogDecoder: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<SiteCatalog, [string, ErrorReason_$union]>)) = orFail<SiteCatalog>((path_4: string, v: any): FSharpResult$2_$union<FSharpResult$2_$union<SiteCatalog, string>, [string, ErrorReason_$union]> => object<FSharpResult$2_$union<SiteCatalog, string>>((get$: IGetters): FSharpResult$2_$union<SiteCatalog, string> => {
1240
+ let arg_5: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<FSharpMap<string, InstrumentMapEntry>, [string, ErrorReason_$union]>)), objectArg_2: IOptionalGetter, objectArg_3: IOptionalGetter, objectArg_4: IRequiredGetter, objectArg_5: IRequiredGetter, objectArg_6: IRequiredGetter, objectArg_7: IRequiredGetter, objectArg_8: IRequiredGetter, objectArg_9: IRequiredGetter;
1241
+ let triggersRow: ReleaseAvailability$1_$union<FSharpList<string>>;
1242
+ const arg_1: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<ReleaseAvailability$1_$union<FSharpList<string>>, [string, ErrorReason_$union]>)) = availabilityRowDecoder("triggersFrom");
1243
+ const objectArg: IRequiredGetter = get$.Required;
1244
+ triggersRow = objectArg.Field<ReleaseAvailability$1_$union<FSharpList<string>>>("triggersFrom", uncurry2(arg_1));
1245
+ let scoringRow: ReleaseAvailability$1_$union<FSharpList<string>>;
1246
+ const arg_3: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<ReleaseAvailability$1_$union<FSharpList<string>>, [string, ErrorReason_$union]>)) = availabilityRowDecoder("scoringFrom");
1247
+ const objectArg_1: IRequiredGetter = get$.Required;
1248
+ scoringRow = objectArg_1.Field<ReleaseAvailability$1_$union<FSharpList<string>>>("scoringFrom", uncurry2(arg_3));
1249
+ 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_5 = dictDecoder<InstrumentMapEntry>(uncurry2(instrumentMapEntryDecoder)), (objectArg_2 = get$.Optional, objectArg_2.Field<FSharpMap<string, InstrumentMapEntry>>("instrumentMap", uncurry2(arg_5)))), (objectArg_3 = get$.Optional, objectArg_3.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))));
1250
+ const triggers: FSharpResult$2_$union<ReleaseAvailability$1_$union<TriggerStats>, string> = join<TriggerStats>("triggersFrom (stats.triggerStats)", triggersRow, 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)));
1251
+ let matchResult: int32, scoringAvailability: ReleaseAvailability$1_$union<ScoringCatalog>, triggerAvailability: ReleaseAvailability$1_$union<TriggerStats>, e: string;
1252
+ const copyOfStruct: FSharpResult$2_$union<ReleaseAvailability$1_$union<ScoringCatalog>, string> = scoring;
1253
+ if (copyOfStruct.tag === /* Error */ 1) {
1254
+ matchResult = 1;
1255
+ e = copyOfStruct.fields[0];
1256
+ }
1257
+ else {
1258
+ const copyOfStruct_1: FSharpResult$2_$union<ReleaseAvailability$1_$union<TriggerStats>, string> = triggers;
1259
+ if (copyOfStruct_1.tag === /* Error */ 1) {
1260
+ matchResult = 1;
1261
+ e = copyOfStruct_1.fields[0];
1262
+ }
1263
+ else {
1264
+ matchResult = 0;
1265
+ scoringAvailability = copyOfStruct.fields[0];
1266
+ triggerAvailability = copyOfStruct_1.fields[0];
1267
+ }
1268
+ }
1269
+ switch (matchResult) {
1270
+ case 0:
1271
+ return FSharpResult$2_Ok<SiteCatalog, string>(new SiteCatalog((objectArg_4 = get$.Required, objectArg_4.Field<int32>("version", uncurry2(int))), (objectArg_5 = get$.Required, objectArg_5.Field<string>("generatedAt", string)), (objectArg_6 = get$.Required, objectArg_6.Field<string>("generatedFrom", string)), (objectArg_7 = get$.Required, objectArg_7.Field<CoreEmrInfo>("coreEmr", uncurry2(coreEmrDecoder))), (objectArg_8 = get$.Required, objectArg_8.Field<TemplateStats>("stats", uncurry2(statsDecoder))), scoringAvailability!, triggerAvailability!, (objectArg_9 = get$.Required, objectArg_9.Field<FSharpList<int32>>("forms", (path_3: string, value_3: any): FSharpResult$2_$union<FSharpList<int32>, [string, ErrorReason_$union]> => list_7<int32>((path_2: string, value_2: any): FSharpResult$2_$union<int32, [string, ErrorReason_$union]> => field_1<int32>("formId", uncurry2(int), path_2, value_2), path_3, value_3)))));
1272
+ default:
1273
+ return FSharpResult$2_Error<SiteCatalog, string>(e!);
1274
+ }
1275
+ }, path_4, v));
1276
+
1277
+ /**
1278
+ * Decode conduit's site catalog. Strict: every governed datum joined with its declaration.
1279
+ */
1280
+ export function decodeSiteCatalog(json: string): FSharpResult$2_$union<SiteCatalog, string> {
1281
+ return fromString<SiteCatalog>(uncurry2(siteCatalogDecoder), json);
1282
+ }
1283
+
1284
+ //# sourceMappingURL=FormTemplateDecoder.ts.map