@f1studio/form-spec 5.0.0-alpha.111 → 5.0.0-alpha.112

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 (189) hide show
  1. package/FormSpec.FS/BitmaskHelpers.d.ts +23 -0
  2. package/FormSpec.FS/BitmaskHelpers.d.ts.map +1 -0
  3. package/FormSpec.FS/BlueprintValidation.d.ts +16 -0
  4. package/FormSpec.FS/BlueprintValidation.d.ts.map +1 -0
  5. package/FormSpec.FS/FormSpec.d.ts +19 -5
  6. package/FormSpec.FS/FormSpec.d.ts.map +1 -1
  7. package/FormSpec.FS/FormSpecHelpers.d.ts +4 -0
  8. package/FormSpec.FS/FormSpecHelpers.d.ts.map +1 -1
  9. package/FormSpec.FS/FormSpecValues.d.ts +5 -0
  10. package/FormSpec.FS/FormSpecValues.d.ts.map +1 -1
  11. package/FormSpec.FS/Helpers.d.ts.map +1 -1
  12. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRAdapter.d.ts +13 -0
  13. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRAdapter.d.ts.map +1 -0
  14. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRElementTypeMap.d.ts +22 -0
  15. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRElementTypeMap.d.ts.map +1 -0
  16. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRFieldTypeMapper.d.ts +22 -0
  17. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRFieldTypeMapper.d.ts.map +1 -0
  18. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRFormSpecValidator.d.ts +130 -0
  19. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRFormSpecValidator.d.ts.map +1 -0
  20. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRSectioning.d.ts +37 -0
  21. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRSectioning.d.ts.map +1 -0
  22. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRSemanticReportBuilder.d.ts +231 -0
  23. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRSemanticReportBuilder.d.ts.map +1 -0
  24. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRStepsBuilder.d.ts +10 -0
  25. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRStepsBuilder.d.ts.map +1 -0
  26. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateToFormSpec.d.ts +55 -0
  27. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateToFormSpec.d.ts.map +1 -0
  28. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTriggerConverter.d.ts +69 -0
  29. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTriggerConverter.d.ts.map +1 -0
  30. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMREncoder.d.ts +21 -0
  31. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMREncoder.d.ts.map +1 -0
  32. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRSourceMap.d.ts +133 -0
  33. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRSourceMap.d.ts.map +1 -0
  34. package/FormSpec.FS/Integrations/Adapters/CorEMR/FormSpecToCoreMRInsert.d.ts +52 -0
  35. package/FormSpec.FS/Integrations/Adapters/CorEMR/FormSpecToCoreMRInsert.d.ts.map +1 -0
  36. package/FormSpec.FS/Integrations/Adapters/FormSystemAdapter.d.ts +46 -0
  37. package/FormSpec.FS/Integrations/Adapters/FormSystemAdapter.d.ts.map +1 -0
  38. package/FormSpec.FS/Integrations/Adapters/ReactHookForm/ReactHookFormAdapter.d.ts +4 -0
  39. package/FormSpec.FS/Integrations/Adapters/ReactHookForm/ReactHookFormAdapter.d.ts.map +1 -0
  40. package/FormSpec.FS/Integrations/Adapters/ReactHookForm/ReactHookFormTypes.d.ts +36 -0
  41. package/FormSpec.FS/Integrations/Adapters/ReactHookForm/ReactHookFormTypes.d.ts.map +1 -0
  42. package/FormSpec.FS/Integrations/CorEMR/CorEmrTemplates.d.ts +95 -0
  43. package/FormSpec.FS/Integrations/CorEMR/CorEmrTemplates.d.ts.map +1 -0
  44. package/FormSpec.FS/Integrations/CorEMR/CoreMRTypes.d.ts +449 -0
  45. package/FormSpec.FS/Integrations/CorEMR/CoreMRTypes.d.ts.map +1 -0
  46. package/FormSpec.FS/Interop/FormSpec.Api.Helpers.d.ts.map +1 -1
  47. package/FormSpec.FS/Interop/FormSpec.Api.Option.d.ts +3 -1
  48. package/FormSpec.FS/Interop/FormSpec.Api.Option.d.ts.map +1 -1
  49. package/FormSpec.FS/Provenance.d.ts +10 -0
  50. package/FormSpec.FS/Provenance.d.ts.map +1 -0
  51. package/FormSpec.FS/Renderers/FormSpecMarkdownRenderer.d.ts.map +1 -1
  52. package/FormSpec.TS/FormSpec.FS/BitmaskHelpers.js +56 -0
  53. package/FormSpec.TS/FormSpec.FS/BitmaskHelpers.js.map +1 -0
  54. package/FormSpec.TS/FormSpec.FS/BitmaskHelpers.ts.map +1 -0
  55. package/FormSpec.TS/FormSpec.FS/BlueprintValidation.js +116 -0
  56. package/FormSpec.TS/FormSpec.FS/BlueprintValidation.js.map +1 -0
  57. package/FormSpec.TS/FormSpec.FS/BlueprintValidation.ts.map +1 -0
  58. package/FormSpec.TS/FormSpec.FS/Designer.js +2 -2
  59. package/FormSpec.TS/FormSpec.FS/Designer.js.map +1 -1
  60. package/FormSpec.TS/FormSpec.FS/Designer.ts.map +1 -1
  61. package/FormSpec.TS/FormSpec.FS/FormSpec.js +72 -3
  62. package/FormSpec.TS/FormSpec.FS/FormSpec.js.map +1 -1
  63. package/FormSpec.TS/FormSpec.FS/FormSpec.ts.map +1 -1
  64. package/FormSpec.TS/FormSpec.FS/FormSpecHelpers.js +201 -3
  65. package/FormSpec.TS/FormSpec.FS/FormSpecHelpers.js.map +1 -1
  66. package/FormSpec.TS/FormSpec.FS/FormSpecHelpers.ts.map +1 -1
  67. package/FormSpec.TS/FormSpec.FS/FormSpecValues.js +38 -3
  68. package/FormSpec.TS/FormSpec.FS/FormSpecValues.js.map +1 -1
  69. package/FormSpec.TS/FormSpec.FS/FormSpecValues.ts.map +1 -1
  70. package/FormSpec.TS/FormSpec.FS/Helpers.js +44 -27
  71. package/FormSpec.TS/FormSpec.FS/Helpers.js.map +1 -1
  72. package/FormSpec.TS/FormSpec.FS/Helpers.ts.map +1 -1
  73. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRAdapter.js +45 -0
  74. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRAdapter.js.map +1 -0
  75. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRAdapter.ts.map +1 -0
  76. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRElementTypeMap.js +145 -0
  77. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRElementTypeMap.js.map +1 -0
  78. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRElementTypeMap.ts.map +1 -0
  79. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRFieldTypeMapper.js +139 -0
  80. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRFieldTypeMapper.js.map +1 -0
  81. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRFieldTypeMapper.ts.map +1 -0
  82. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRFormSpecValidator.js +801 -0
  83. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRFormSpecValidator.js.map +1 -0
  84. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRFormSpecValidator.ts.map +1 -0
  85. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRSectioning.js +121 -0
  86. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRSectioning.js.map +1 -0
  87. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRSectioning.ts.map +1 -0
  88. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRSemanticReportBuilder.js +1380 -0
  89. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRSemanticReportBuilder.js.map +1 -0
  90. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRSemanticReportBuilder.ts.map +1 -0
  91. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRStepsBuilder.js +29 -0
  92. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRStepsBuilder.js.map +1 -0
  93. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRStepsBuilder.ts.map +1 -0
  94. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateToFormSpec.js +172 -0
  95. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateToFormSpec.js.map +1 -0
  96. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateToFormSpec.ts.map +1 -0
  97. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTriggerConverter.js +406 -0
  98. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTriggerConverter.js.map +1 -0
  99. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTriggerConverter.ts.map +1 -0
  100. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMREncoder.js +317 -0
  101. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMREncoder.js.map +1 -0
  102. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMREncoder.ts.map +1 -0
  103. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRSourceMap.js +622 -0
  104. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRSourceMap.js.map +1 -0
  105. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRSourceMap.ts.map +1 -0
  106. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/FormSpecToCoreMRInsert.js +448 -0
  107. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/FormSpecToCoreMRInsert.js.map +1 -0
  108. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/FormSpecToCoreMRInsert.ts.map +1 -0
  109. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/FormSystemAdapter.js +198 -0
  110. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/FormSystemAdapter.js.map +1 -0
  111. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/FormSystemAdapter.ts.map +1 -0
  112. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/ReactHookForm/ReactHookFormAdapter.js +57 -0
  113. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/ReactHookForm/ReactHookFormAdapter.js.map +1 -0
  114. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/ReactHookForm/ReactHookFormAdapter.ts.map +1 -0
  115. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/ReactHookForm/ReactHookFormTypes.js +144 -0
  116. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/ReactHookForm/ReactHookFormTypes.js.map +1 -0
  117. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/ReactHookForm/ReactHookFormTypes.ts.map +1 -0
  118. package/FormSpec.TS/FormSpec.FS/Integrations/CorEMR/CorEmrTemplates.js +258 -0
  119. package/FormSpec.TS/FormSpec.FS/Integrations/CorEMR/CorEmrTemplates.js.map +1 -0
  120. package/FormSpec.TS/FormSpec.FS/Integrations/CorEMR/CorEmrTemplates.ts.map +1 -0
  121. package/FormSpec.TS/FormSpec.FS/Integrations/CorEMR/CoreMRTypes.js +1768 -0
  122. package/FormSpec.TS/FormSpec.FS/Integrations/CorEMR/CoreMRTypes.js.map +1 -0
  123. package/FormSpec.TS/FormSpec.FS/Integrations/CorEMR/CoreMRTypes.ts.map +1 -0
  124. package/FormSpec.TS/FormSpec.FS/Interop/FormSpec.Api.Helpers.js +22 -18
  125. package/FormSpec.TS/FormSpec.FS/Interop/FormSpec.Api.Helpers.js.map +1 -1
  126. package/FormSpec.TS/FormSpec.FS/Interop/FormSpec.Api.Helpers.ts.map +1 -1
  127. package/FormSpec.TS/FormSpec.FS/Interop/FormSpec.Api.Option.js +18 -6
  128. package/FormSpec.TS/FormSpec.FS/Interop/FormSpec.Api.Option.js.map +1 -1
  129. package/FormSpec.TS/FormSpec.FS/Interop/FormSpec.Api.Option.ts.map +1 -1
  130. package/FormSpec.TS/FormSpec.FS/PathwayExecutor.js +1 -1
  131. package/FormSpec.TS/FormSpec.FS/Provenance.js +41 -0
  132. package/FormSpec.TS/FormSpec.FS/Provenance.js.map +1 -0
  133. package/FormSpec.TS/FormSpec.FS/Provenance.ts.map +1 -0
  134. package/FormSpec.TS/FormSpec.FS/Renderers/FormSpecMarkdownRenderer.js +36 -13
  135. package/FormSpec.TS/FormSpec.FS/Renderers/FormSpecMarkdownRenderer.js.map +1 -1
  136. package/FormSpec.TS/FormSpec.FS/Renderers/FormSpecMarkdownRenderer.ts.map +1 -1
  137. package/FormSpec.TS/FormSpec.FS/Renderers/PathwayRenderers.js +1 -1
  138. package/FormSpec.TS/PathwayExecutor.withPlugins.js +0 -5
  139. package/FormSpec.TS/PathwayExecutor.withPlugins.js.map +1 -1
  140. package/FormSpec.TS/PluginRegistration.js +2 -0
  141. package/FormSpec.TS/PluginRegistration.js.map +1 -1
  142. package/FormSpec.TS/PluginRegistration.ts.map +1 -1
  143. package/FormSpec.TS/fable_modules/project_cracked.json +1 -1
  144. package/FormSpec.TS/plugins/demographics/src/DemographicsField.js +918 -0
  145. package/FormSpec.TS/plugins/demographics/src/DemographicsField.js.map +1 -0
  146. package/FormSpec.TS/plugins/demographics/src/DemographicsField.ts.map +1 -0
  147. package/FormSpec.TS/plugins/likert/src/LikertField.js +1 -1
  148. package/PathwayExecutor.withPlugins.d.ts +0 -5
  149. package/PathwayExecutor.withPlugins.d.ts.map +1 -1
  150. package/README.md +7 -7
  151. package/fable_modules/Thoth.Json.10.4.1/Extra.fs.d.ts +3 -0
  152. package/fable_modules/Thoth.Json.10.4.1/Extra.fs.d.ts.map +1 -0
  153. package/package.json +4 -4
  154. package/plugins/demographics/src/DemographicsField.d.ts +104 -0
  155. package/plugins/demographics/src/DemographicsField.d.ts.map +1 -0
  156. package/src/FormSpec.FS/BitmaskHelpers.ts +52 -0
  157. package/src/FormSpec.FS/BlueprintValidation.ts +108 -0
  158. package/src/FormSpec.FS/Designer.ts +2 -2
  159. package/src/FormSpec.FS/FormSpec.ts +39 -8
  160. package/src/FormSpec.FS/FormSpecHelpers.ts +190 -12
  161. package/src/FormSpec.FS/FormSpecValues.ts +42 -3
  162. package/src/FormSpec.FS/Helpers.ts +44 -27
  163. package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRAdapter.ts +37 -0
  164. package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRElementTypeMap.ts +103 -0
  165. package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRFieldTypeMapper.ts +129 -0
  166. package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRFormSpecValidator.ts +490 -0
  167. package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRSectioning.ts +87 -0
  168. package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRSemanticReportBuilder.ts +1046 -0
  169. package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRStepsBuilder.ts +26 -0
  170. package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateToFormSpec.ts +161 -0
  171. package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTriggerConverter.ts +386 -0
  172. package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMREncoder.ts +320 -0
  173. package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRSourceMap.ts +371 -0
  174. package/src/FormSpec.FS/Integrations/Adapters/CorEMR/FormSpecToCoreMRInsert.ts +372 -0
  175. package/src/FormSpec.FS/Integrations/Adapters/FormSystemAdapter.ts +92 -0
  176. package/src/FormSpec.FS/Integrations/Adapters/ReactHookForm/ReactHookFormAdapter.ts +51 -0
  177. package/src/FormSpec.FS/Integrations/Adapters/ReactHookForm/ReactHookFormTypes.ts +71 -0
  178. package/src/FormSpec.FS/Integrations/CorEMR/CorEmrTemplates.ts +15 -0
  179. package/src/FormSpec.FS/Integrations/CorEMR/CoreMRTypes.ts +825 -0
  180. package/src/FormSpec.FS/Interop/FormSpec.Api.Helpers.ts +19 -15
  181. package/src/FormSpec.FS/Interop/FormSpec.Api.Option.ts +13 -7
  182. package/src/FormSpec.FS/PathwayExecutor.ts +1 -1
  183. package/src/FormSpec.FS/Provenance.ts +19 -0
  184. package/src/FormSpec.FS/Renderers/FormSpecMarkdownRenderer.ts +32 -12
  185. package/src/FormSpec.FS/Renderers/PathwayRenderers.ts +1 -1
  186. package/src/PathwayExecutor.withPlugins.ts +0 -5
  187. package/src/PluginRegistration.ts +2 -0
  188. package/src/plugins/demographics/src/DemographicsField.ts +502 -0
  189. package/src/plugins/likert/src/LikertField.ts +1 -1
@@ -0,0 +1,490 @@
1
+ import { toString, Record, Union } from "@fable-org/fable-library-js/Types.js";
2
+ import { int32 } from "@fable-org/fable-library-js/Int32.js";
3
+ import { defaultArg, value as value_3, map as map_1, Option } from "@fable-org/fable-library-js/Option.js";
4
+ import { record_type, list_type, union_type, option_type, bool_type, string_type, int32_type, TypeInfo } from "@fable-org/fable-library-js/Reflection.js";
5
+ import { isEmpty, filter, empty as empty_1, singleton as singleton_1, ofSeq, choose, collect, map, sumBy, length, FSharpList } from "@fable-org/fable-library-js/List.js";
6
+ import { IDisposable, disposeSafe, IEnumerator, getEnumerator, compare, int32ToString, comparePrimitives, numberHash, IComparable, IEquatable } from "@fable-org/fable-library-js/Util.js";
7
+ import { HeadingItem, detectHeadings } from "./CorEMRSectioning.js";
8
+ import { CoreMRTrigger, CoreMRFormData, CoreMRFormMetadata, CoreMRChoice, CoreMRItem } from "../../CorEMR/CoreMRTypes.js";
9
+ import { ClinicalPathway_ClinicalPathwaySpec, Spec_Score, Spec_SingleChoiceInfo, Spec_MultiChoiceInfo, Spec_FormField$1, Shared_FieldKey, Spec_FormSpec$1, Spec_FieldType_$union, Spec_FormStep$1 } from "../../../FormSpec.js";
10
+ import { tryFind, FSharpMap, ofList } from "@fable-org/fable-library-js/Map.js";
11
+ import { List_groupBy } from "@fable-org/fable-library-js/Seq2.js";
12
+ import { empty, singleton, append, delay, toList } from "@fable-org/fable-library-js/Seq.js";
13
+ import { getElementTypeInfo } from "./CorEMRElementTypeMap.js";
14
+ import { FSharpResult$2_$union, FSharpResult$2_Ok, FSharpResult$2_Error } from "@fable-org/fable-library-js/Result.js";
15
+
16
+ export type ValidationError_$union =
17
+ | ValidationError<0>
18
+ | ValidationError<1>
19
+ | ValidationError<2>
20
+ | ValidationError<3>
21
+ | ValidationError<4>
22
+ | ValidationError<5>
23
+ | ValidationError<6>
24
+ | ValidationError<7>
25
+ | ValidationError<8>
26
+ | ValidationError<9>
27
+ | ValidationError<10>
28
+ | ValidationError<11>
29
+ | ValidationError<12>
30
+ | ValidationError<13>
31
+ | ValidationError<14>
32
+ | ValidationError<15>
33
+ | ValidationError<16>
34
+
35
+ export type ValidationError_$cases = {
36
+ 0: ["ItemCountMismatch", [int32, int32]],
37
+ 1: ["StepCountMismatch", [int32, int32]],
38
+ 2: ["FieldCountMismatch", [string, int32, int32]],
39
+ 3: ["MetadataMismatch", [string, string, string]],
40
+ 4: ["MissingChoices", [int32, string]],
41
+ 5: ["InvalidFieldType", [int32, string, string]],
42
+ 6: ["HeadingNotConverted", [int32, string]],
43
+ 7: ["MissingStep", [string]],
44
+ 8: ["ChoiceCountMismatch", [int32, string, int32, int32]],
45
+ 9: ["RequiredFieldMismatch", [int32, string, boolean, boolean]],
46
+ 10: ["ScoreMismatch", [int32, Option<int32>]],
47
+ 11: ["TagCountMismatch", [int32, int32]],
48
+ 12: ["PathwayMissing", [int32]],
49
+ 13: ["PathwayStateCountInvalid", [string, int32, int32]],
50
+ 14: ["PathwayTransitionCountInvalid", [string, int32, int32]],
51
+ 15: ["TriggerConditionCountMismatch", [int32, int32, int32]],
52
+ 16: ["TriggerEventCountMismatch", [int32, int32, int32]]
53
+ }
54
+
55
+ export function ValidationError_ItemCountMismatch(expected: int32, actual: int32) {
56
+ return new ValidationError<0>(0, [expected, actual]);
57
+ }
58
+
59
+ export function ValidationError_StepCountMismatch(expected: int32, actual: int32) {
60
+ return new ValidationError<1>(1, [expected, actual]);
61
+ }
62
+
63
+ export function ValidationError_FieldCountMismatch(step: string, expected: int32, actual: int32) {
64
+ return new ValidationError<2>(2, [step, expected, actual]);
65
+ }
66
+
67
+ export function ValidationError_MetadataMismatch(field: string, expected: string, actual: string) {
68
+ return new ValidationError<3>(3, [field, expected, actual]);
69
+ }
70
+
71
+ export function ValidationError_MissingChoices(itemId: int32, itemLabel: string) {
72
+ return new ValidationError<4>(4, [itemId, itemLabel]);
73
+ }
74
+
75
+ export function ValidationError_InvalidFieldType(itemId: int32, itemType: string, reason: string) {
76
+ return new ValidationError<5>(5, [itemId, itemType, reason]);
77
+ }
78
+
79
+ export function ValidationError_HeadingNotConverted(itemId: int32, heading: string) {
80
+ return new ValidationError<6>(6, [itemId, heading]);
81
+ }
82
+
83
+ export function ValidationError_MissingStep(heading: string) {
84
+ return new ValidationError<7>(7, [heading]);
85
+ }
86
+
87
+ export function ValidationError_ChoiceCountMismatch(itemId: int32, itemLabel: string, expected: int32, actual: int32) {
88
+ return new ValidationError<8>(8, [itemId, itemLabel, expected, actual]);
89
+ }
90
+
91
+ export function ValidationError_RequiredFieldMismatch(itemId: int32, itemLabel: string, expected: boolean, actual: boolean) {
92
+ return new ValidationError<9>(9, [itemId, itemLabel, expected, actual]);
93
+ }
94
+
95
+ export function ValidationError_ScoreMismatch(expected: int32, actual: Option<int32>) {
96
+ return new ValidationError<10>(10, [expected, actual]);
97
+ }
98
+
99
+ export function ValidationError_TagCountMismatch(expected: int32, actual: int32) {
100
+ return new ValidationError<11>(11, [expected, actual]);
101
+ }
102
+
103
+ export function ValidationError_PathwayMissing(triggerCount: int32) {
104
+ return new ValidationError<12>(12, [triggerCount]);
105
+ }
106
+
107
+ export function ValidationError_PathwayStateCountInvalid(pathwayId: string, expected: int32, actual: int32) {
108
+ return new ValidationError<13>(13, [pathwayId, expected, actual]);
109
+ }
110
+
111
+ export function ValidationError_PathwayTransitionCountInvalid(pathwayId: string, expected: int32, actual: int32) {
112
+ return new ValidationError<14>(14, [pathwayId, expected, actual]);
113
+ }
114
+
115
+ export function ValidationError_TriggerConditionCountMismatch(triggerId: int32, expected: int32, actual: int32) {
116
+ return new ValidationError<15>(15, [triggerId, expected, actual]);
117
+ }
118
+
119
+ export function ValidationError_TriggerEventCountMismatch(triggerId: int32, expected: int32, actual: int32) {
120
+ return new ValidationError<16>(16, [triggerId, expected, actual]);
121
+ }
122
+
123
+ export class ValidationError<Tag extends keyof ValidationError_$cases> extends Union<Tag, ValidationError_$cases[Tag][0]> {
124
+ constructor(readonly tag: Tag, readonly fields: ValidationError_$cases[Tag][1]) {
125
+ super();
126
+ }
127
+ cases() {
128
+ return ["ItemCountMismatch", "StepCountMismatch", "FieldCountMismatch", "MetadataMismatch", "MissingChoices", "InvalidFieldType", "HeadingNotConverted", "MissingStep", "ChoiceCountMismatch", "RequiredFieldMismatch", "ScoreMismatch", "TagCountMismatch", "PathwayMissing", "PathwayStateCountInvalid", "PathwayTransitionCountInvalid", "TriggerConditionCountMismatch", "TriggerEventCountMismatch"];
129
+ }
130
+ }
131
+
132
+ export function ValidationError_$reflection(): TypeInfo {
133
+ return union_type("FormSpec.Integrations.CorEMR.CorEMRFormSpecValidator.ValidationError", [], ValidationError, () => [[["expected", int32_type], ["actual", int32_type]], [["expected", int32_type], ["actual", int32_type]], [["step", string_type], ["expected", int32_type], ["actual", int32_type]], [["field", string_type], ["expected", string_type], ["actual", string_type]], [["itemId", int32_type], ["itemLabel", string_type]], [["itemId", int32_type], ["itemType", string_type], ["reason", string_type]], [["itemId", int32_type], ["heading", string_type]], [["heading", string_type]], [["itemId", int32_type], ["itemLabel", string_type], ["expected", int32_type], ["actual", int32_type]], [["itemId", int32_type], ["itemLabel", string_type], ["expected", bool_type], ["actual", bool_type]], [["expected", int32_type], ["actual", option_type(int32_type)]], [["expected", int32_type], ["actual", int32_type]], [["triggerCount", int32_type]], [["pathwayId", string_type], ["expected", int32_type], ["actual", int32_type]], [["pathwayId", string_type], ["expected", int32_type], ["actual", int32_type]], [["triggerId", int32_type], ["expected", int32_type], ["actual", int32_type]], [["triggerId", int32_type], ["expected", int32_type], ["actual", int32_type]]]);
134
+ }
135
+
136
+ export class ValidationResult extends Record implements IEquatable<ValidationResult>, IComparable<ValidationResult> {
137
+ readonly IsValid: boolean;
138
+ readonly Errors: FSharpList<ValidationError_$union>;
139
+ readonly Warnings: FSharpList<ValidationError_$union>;
140
+ readonly Summary: ValidationSummary;
141
+ constructor(IsValid: boolean, Errors: FSharpList<ValidationError_$union>, Warnings: FSharpList<ValidationError_$union>, Summary: ValidationSummary) {
142
+ super();
143
+ this.IsValid = IsValid;
144
+ this.Errors = Errors;
145
+ this.Warnings = Warnings;
146
+ this.Summary = Summary;
147
+ }
148
+ }
149
+
150
+ export function ValidationResult_$reflection(): TypeInfo {
151
+ return record_type("FormSpec.Integrations.CorEMR.CorEMRFormSpecValidator.ValidationResult", [], ValidationResult, () => [["IsValid", bool_type], ["Errors", list_type(ValidationError_$reflection())], ["Warnings", list_type(ValidationError_$reflection())], ["Summary", ValidationSummary_$reflection()]]);
152
+ }
153
+
154
+ export class ValidationSummary extends Record implements IEquatable<ValidationSummary>, IComparable<ValidationSummary> {
155
+ readonly TotalItems: int32;
156
+ readonly ConvertedFields: int32;
157
+ readonly HeadingsDetected: int32;
158
+ readonly StepsCreated: int32;
159
+ readonly ChoicesProcessed: int32;
160
+ readonly TriggersFound: int32;
161
+ readonly TagsMapped: int32;
162
+ constructor(TotalItems: int32, ConvertedFields: int32, HeadingsDetected: int32, StepsCreated: int32, ChoicesProcessed: int32, TriggersFound: int32, TagsMapped: int32) {
163
+ super();
164
+ this.TotalItems = (TotalItems | 0);
165
+ this.ConvertedFields = (ConvertedFields | 0);
166
+ this.HeadingsDetected = (HeadingsDetected | 0);
167
+ this.StepsCreated = (StepsCreated | 0);
168
+ this.ChoicesProcessed = (ChoicesProcessed | 0);
169
+ this.TriggersFound = (TriggersFound | 0);
170
+ this.TagsMapped = (TagsMapped | 0);
171
+ }
172
+ }
173
+
174
+ export function ValidationSummary_$reflection(): TypeInfo {
175
+ return record_type("FormSpec.Integrations.CorEMR.CorEMRFormSpecValidator.ValidationSummary", [], ValidationSummary, () => [["TotalItems", int32_type], ["ConvertedFields", int32_type], ["HeadingsDetected", int32_type], ["StepsCreated", int32_type], ["ChoicesProcessed", int32_type], ["TriggersFound", int32_type], ["TagsMapped", int32_type]]);
176
+ }
177
+
178
+ /**
179
+ * Count non-heading items in CoreMR
180
+ */
181
+ export function FormSpecValidator_countNonHeadingItems(items: FSharpList<CoreMRItem>): int32 {
182
+ const headings: FSharpList<HeadingItem> = detectHeadings(items);
183
+ return (length(items) - length(headings)) | 0;
184
+ }
185
+
186
+ /**
187
+ * Count headings in CoreMR (should become steps)
188
+ */
189
+ export function FormSpecValidator_countHeadings(items: FSharpList<CoreMRItem>): int32 {
190
+ return length(detectHeadings(items));
191
+ }
192
+
193
+ /**
194
+ * Count total fields in FormSpec
195
+ */
196
+ export function FormSpecValidator_countTotalFields(steps: FSharpList<Spec_FormStep$1<Spec_FieldType_$union>>): int32 {
197
+ return sumBy<Spec_FormStep$1<Spec_FieldType_$union>, int32>((s: Spec_FormStep$1<Spec_FieldType_$union>): int32 => length(s.Fields), steps, {
198
+ GetZero: (): int32 => 0,
199
+ Add: (x: int32, y: int32): int32 => (x + y),
200
+ });
201
+ }
202
+
203
+ /**
204
+ * Get choices count per item
205
+ */
206
+ export function FormSpecValidator_getChoicesPerItem(choices: FSharpList<CoreMRChoice>): FSharpMap<int32, int32> {
207
+ return ofList<int32, int32>(map<[int32, FSharpList<CoreMRChoice>], [int32, int32]>((tupledArg: [int32, FSharpList<CoreMRChoice>]): [int32, int32] => ([tupledArg[0], length(tupledArg[1])] as [int32, int32]), List_groupBy<CoreMRChoice, int32>((c: CoreMRChoice): int32 => c.ItemId, choices, {
208
+ Equals: (x: int32, y: int32): boolean => (x === y),
209
+ GetHashCode: numberHash,
210
+ })), {
211
+ Compare: comparePrimitives,
212
+ });
213
+ }
214
+
215
+ /**
216
+ * Calculate expected max score from CoreMR
217
+ */
218
+ export function FormSpecValidator_calculateExpectedMaxScore(choices: FSharpList<CoreMRChoice>): int32 {
219
+ return sumBy<CoreMRChoice, int32>((c: CoreMRChoice): int32 => c.Score, choices, {
220
+ GetZero: (): int32 => 0,
221
+ Add: (x: int32, y: int32): int32 => (x + y),
222
+ });
223
+ }
224
+
225
+ /**
226
+ * Validate metadata mapping
227
+ */
228
+ export function FormSpecValidator_validateMetadata(coreMR: CoreMRFormMetadata, formSpec: Spec_FormSpec$1<Spec_FieldType_$union>): FSharpList<ValidationError_$union> {
229
+ return toList<ValidationError_$union>(delay<ValidationError_$union>((): Iterable<ValidationError_$union> => append<ValidationError_$union>((formSpec.Title !== coreMR.FormName) ? singleton<ValidationError_$union>(ValidationError_MetadataMismatch("title", coreMR.FormName, formSpec.Title)) : empty<ValidationError_$union>(), delay<ValidationError_$union>((): Iterable<ValidationError_$union> => append<ValidationError_$union>((formSpec.Version !== int32ToString(coreMR.VersionNumber)) ? singleton<ValidationError_$union>(ValidationError_MetadataMismatch("version", int32ToString(coreMR.VersionNumber), formSpec.Version)) : empty<ValidationError_$union>(), delay<ValidationError_$union>((): Iterable<ValidationError_$union> => ((formSpec.RequiresReview !== coreMR.RequiresSignature) ? singleton<ValidationError_$union>(ValidationError_MetadataMismatch("requiresReview", toString(coreMR.RequiresSignature), toString(formSpec.RequiresReview))) : empty<ValidationError_$union>())))))));
230
+ }
231
+
232
+ /**
233
+ * Validate item/field counts
234
+ */
235
+ export function FormSpecValidator_validateCounts(coreMR: CoreMRFormData, formSpec: Spec_FormSpec$1<Spec_FieldType_$union>): FSharpList<ValidationError_$union> {
236
+ const expectedFields: int32 = FormSpecValidator_countNonHeadingItems(coreMR.Items) | 0;
237
+ const actualFields: int32 = FormSpecValidator_countTotalFields(formSpec.Steps) | 0;
238
+ const expectedSteps: int32 = FormSpecValidator_countHeadings(coreMR.Items) | 0;
239
+ const actualSteps: int32 = length(formSpec.Steps) | 0;
240
+ return toList<ValidationError_$union>(delay<ValidationError_$union>((): Iterable<ValidationError_$union> => append<ValidationError_$union>((expectedFields !== actualFields) ? singleton<ValidationError_$union>(ValidationError_ItemCountMismatch(expectedFields, actualFields)) : empty<ValidationError_$union>(), delay<ValidationError_$union>((): Iterable<ValidationError_$union> => (((expectedSteps > 0) && (expectedSteps !== actualSteps)) ? singleton<ValidationError_$union>(ValidationError_StepCountMismatch(expectedSteps, actualSteps)) : empty<ValidationError_$union>())))));
241
+ }
242
+
243
+ /**
244
+ * Validate choices were mapped correctly
245
+ */
246
+ export function FormSpecValidator_validateChoices(coreMR: CoreMRFormData, formSpec: Spec_FormSpec$1<Spec_FieldType_$union>): FSharpList<ValidationError_$union> {
247
+ const choicesPerItem: FSharpMap<int32, int32> = FormSpecValidator_getChoicesPerItem(coreMR.Choices);
248
+ const errors: ValidationError_$union[] = [];
249
+ const sequenceToFieldKey: FSharpMap<int32, Shared_FieldKey> = ofList<int32, Shared_FieldKey>(map<Spec_FormField$1<Spec_FieldType_$union>, [int32, Shared_FieldKey]>((f: Spec_FormField$1<Spec_FieldType_$union>): [int32, Shared_FieldKey] => ([f.FieldOrder, f.FieldKey] as [int32, Shared_FieldKey]), collect<Spec_FormStep$1<Spec_FieldType_$union>, Spec_FormField$1<Spec_FieldType_$union>>((s: Spec_FormStep$1<Spec_FieldType_$union>): FSharpList<Spec_FormField$1<Spec_FieldType_$union>> => s.Fields, formSpec.Steps)), {
250
+ Compare: comparePrimitives,
251
+ });
252
+ const fieldKeyToItemId: FSharpMap<Shared_FieldKey, int32> = ofList<Shared_FieldKey, int32>(choose<CoreMRItem, [Shared_FieldKey, int32]>((item: CoreMRItem): Option<[Shared_FieldKey, int32]> => map_1<Shared_FieldKey, [Shared_FieldKey, int32]>((fieldKey: Shared_FieldKey): [Shared_FieldKey, int32] => ([fieldKey, item.ItemId] as [Shared_FieldKey, int32]), tryFind<int32, Shared_FieldKey>(item.Sequence, sequenceToFieldKey)), coreMR.Items), {
253
+ Compare: compare,
254
+ });
255
+ const itemsById: FSharpMap<int32, CoreMRItem> = ofList<int32, CoreMRItem>(map<CoreMRItem, [int32, CoreMRItem]>((i: CoreMRItem): [int32, CoreMRItem] => ([i.ItemId, i] as [int32, CoreMRItem]), coreMR.Items), {
256
+ Compare: comparePrimitives,
257
+ });
258
+ const enumerator: IEnumerator<Spec_FormStep$1<Spec_FieldType_$union>> = getEnumerator(formSpec.Steps);
259
+ try {
260
+ while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
261
+ const enumerator_1: IEnumerator<Spec_FormField$1<Spec_FieldType_$union>> = getEnumerator(enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]().Fields);
262
+ try {
263
+ while (enumerator_1["System.Collections.IEnumerator.MoveNext"]()) {
264
+ const field: Spec_FormField$1<Spec_FieldType_$union> = enumerator_1["System.Collections.Generic.IEnumerator`1.get_Current"]();
265
+ const matchValue: Spec_FieldType_$union = field.FieldType;
266
+ switch (matchValue.tag) {
267
+ case /* MultiChoice */ 15: {
268
+ const info: Spec_MultiChoiceInfo = matchValue.fields[0];
269
+ const matchValue_1: Option<int32> = tryFind<Shared_FieldKey, int32>(field.FieldKey, fieldKeyToItemId);
270
+ if (matchValue_1 == null) {
271
+ }
272
+ else {
273
+ const itemId: int32 = value_3(matchValue_1) | 0;
274
+ const matchValue_2: Option<CoreMRItem> = tryFind<int32, CoreMRItem>(itemId, itemsById);
275
+ if (matchValue_2 == null) {
276
+ }
277
+ else {
278
+ const item_1: CoreMRItem = value_3(matchValue_2);
279
+ const expectedCount: int32 = defaultArg(tryFind<int32, int32>(itemId, choicesPerItem), 0) | 0;
280
+ const actualCount: int32 = length(info.Options) | 0;
281
+ if (!getElementTypeInfo(item_1.ItemTypeId).IsScaffold) {
282
+ if ((expectedCount > 0) && (expectedCount !== actualCount)) {
283
+ void (errors.push(ValidationError_ChoiceCountMismatch(itemId, item_1.Label, expectedCount, actualCount)));
284
+ }
285
+ else if (expectedCount === 0) {
286
+ void (errors.push(ValidationError_MissingChoices(itemId, item_1.Label)));
287
+ }
288
+ }
289
+ }
290
+ }
291
+ break;
292
+ }
293
+ case /* Dropdown */ 14: {
294
+ const info_1: Spec_SingleChoiceInfo = matchValue.fields[0];
295
+ const matchValue_3: Option<int32> = tryFind<Shared_FieldKey, int32>(field.FieldKey, fieldKeyToItemId);
296
+ if (matchValue_3 == null) {
297
+ }
298
+ else {
299
+ const itemId_1: int32 = value_3(matchValue_3) | 0;
300
+ const matchValue_4: Option<CoreMRItem> = tryFind<int32, CoreMRItem>(itemId_1, itemsById);
301
+ if (matchValue_4 == null) {
302
+ }
303
+ else {
304
+ const item_2: CoreMRItem = value_3(matchValue_4);
305
+ const expectedCount_1: int32 = defaultArg(tryFind<int32, int32>(itemId_1, choicesPerItem), 0) | 0;
306
+ const actualCount_1: int32 = length(info_1.Options) | 0;
307
+ if (!getElementTypeInfo(item_2.ItemTypeId).IsScaffold) {
308
+ if ((expectedCount_1 > 0) && (expectedCount_1 !== actualCount_1)) {
309
+ void (errors.push(ValidationError_ChoiceCountMismatch(itemId_1, item_2.Label, expectedCount_1, actualCount_1)));
310
+ }
311
+ else if (expectedCount_1 === 0) {
312
+ void (errors.push(ValidationError_MissingChoices(itemId_1, item_2.Label)));
313
+ }
314
+ }
315
+ }
316
+ }
317
+ break;
318
+ }
319
+ case /* CheckboxList */ 16: {
320
+ const info_2: Spec_MultiChoiceInfo = matchValue.fields[0];
321
+ const matchValue_5: Option<int32> = tryFind<Shared_FieldKey, int32>(field.FieldKey, fieldKeyToItemId);
322
+ if (matchValue_5 == null) {
323
+ }
324
+ else {
325
+ const itemId_2: int32 = value_3(matchValue_5) | 0;
326
+ const matchValue_6: Option<CoreMRItem> = tryFind<int32, CoreMRItem>(itemId_2, itemsById);
327
+ if (matchValue_6 == null) {
328
+ }
329
+ else {
330
+ const item_3: CoreMRItem = value_3(matchValue_6);
331
+ const expectedCount_2: int32 = defaultArg(tryFind<int32, int32>(itemId_2, choicesPerItem), 0) | 0;
332
+ const actualCount_2: int32 = length(info_2.Options) | 0;
333
+ if (!getElementTypeInfo(item_3.ItemTypeId).IsScaffold) {
334
+ if ((expectedCount_2 > 0) && (expectedCount_2 !== actualCount_2)) {
335
+ void (errors.push(ValidationError_ChoiceCountMismatch(itemId_2, item_3.Label, expectedCount_2, actualCount_2)));
336
+ }
337
+ else if (expectedCount_2 === 0) {
338
+ void (errors.push(ValidationError_MissingChoices(itemId_2, item_3.Label)));
339
+ }
340
+ }
341
+ }
342
+ }
343
+ break;
344
+ }
345
+ default:
346
+ undefined;
347
+ }
348
+ }
349
+ }
350
+ finally {
351
+ disposeSafe(enumerator_1 as IDisposable);
352
+ }
353
+ }
354
+ }
355
+ finally {
356
+ disposeSafe(enumerator as IDisposable);
357
+ }
358
+ return ofSeq<ValidationError_$union>(errors);
359
+ }
360
+
361
+ /**
362
+ * Validate required fields mapping
363
+ */
364
+ export function FormSpecValidator_validateRequiredFields(coreMR: CoreMRFormData, formSpec: Spec_FormSpec$1<Spec_FieldType_$union>): FSharpList<ValidationError_$union> {
365
+ const errors: ValidationError_$union[] = [];
366
+ const itemsByLabel: FSharpMap<string, CoreMRItem> = ofList<string, CoreMRItem>(map<CoreMRItem, [string, CoreMRItem]>((i: CoreMRItem): [string, CoreMRItem] => ([i.Label, i] as [string, CoreMRItem]), coreMR.Items), {
367
+ Compare: comparePrimitives,
368
+ });
369
+ const enumerator: IEnumerator<Spec_FormStep$1<Spec_FieldType_$union>> = getEnumerator(formSpec.Steps);
370
+ try {
371
+ while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
372
+ const enumerator_1: IEnumerator<Spec_FormField$1<Spec_FieldType_$union>> = getEnumerator(enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]().Fields);
373
+ try {
374
+ while (enumerator_1["System.Collections.IEnumerator.MoveNext"]()) {
375
+ const field: Spec_FormField$1<Spec_FieldType_$union> = enumerator_1["System.Collections.Generic.IEnumerator`1.get_Current"]();
376
+ const matchValue: Option<CoreMRItem> = tryFind<string, CoreMRItem>(field.Label, itemsByLabel);
377
+ if (matchValue == null) {
378
+ }
379
+ else {
380
+ const item: CoreMRItem = value_3(matchValue);
381
+ const expectedOptional: boolean = !item.IsRequired;
382
+ if (field.IsOptional !== expectedOptional) {
383
+ void (errors.push(ValidationError_RequiredFieldMismatch(item.ItemId, item.Label, expectedOptional, field.IsOptional)));
384
+ }
385
+ }
386
+ }
387
+ }
388
+ finally {
389
+ disposeSafe(enumerator_1 as IDisposable);
390
+ }
391
+ }
392
+ }
393
+ finally {
394
+ disposeSafe(enumerator as IDisposable);
395
+ }
396
+ return ofSeq<ValidationError_$union>(errors);
397
+ }
398
+
399
+ /**
400
+ * Validate scoring calculation
401
+ */
402
+ export function FormSpecValidator_validateScoring(coreMR: CoreMRFormData, formSpec: Spec_FormSpec$1<Spec_FieldType_$union>): FSharpList<ValidationError_$union> {
403
+ const expectedScore: int32 = FormSpecValidator_calculateExpectedMaxScore(coreMR.Choices) | 0;
404
+ if (expectedScore > 0) {
405
+ const matchValue: Option<Spec_Score> = formSpec.Score;
406
+ if (matchValue == null) {
407
+ return singleton_1(ValidationError_ScoreMismatch(expectedScore, undefined));
408
+ }
409
+ else {
410
+ const score: Spec_Score = value_3(matchValue);
411
+ if (score.MaxScore !== expectedScore) {
412
+ return singleton_1(ValidationError_ScoreMismatch(expectedScore, score.MaxScore));
413
+ }
414
+ else {
415
+ return empty_1<ValidationError_$union>();
416
+ }
417
+ }
418
+ }
419
+ else {
420
+ return empty_1<ValidationError_$union>();
421
+ }
422
+ }
423
+
424
+ /**
425
+ * Validate tags mapping
426
+ */
427
+ export function FormSpecValidator_validateTags(coreMR: CoreMRFormData, formSpec: Spec_FormSpec$1<Spec_FieldType_$union>): FSharpList<ValidationError_$union> {
428
+ const expectedCount: int32 = length(coreMR.Tags) | 0;
429
+ const actualCount: int32 = length(formSpec.CategoryTags) | 0;
430
+ if (expectedCount !== actualCount) {
431
+ return singleton_1(ValidationError_TagCountMismatch(expectedCount, actualCount));
432
+ }
433
+ else {
434
+ return empty_1<ValidationError_$union>();
435
+ }
436
+ }
437
+
438
+ /**
439
+ * Create validation summary
440
+ */
441
+ export function FormSpecValidator_createSummary(coreMR: CoreMRFormData, formSpec: Spec_FormSpec$1<Spec_FieldType_$union>): ValidationSummary {
442
+ return new ValidationSummary(length(coreMR.Items), FormSpecValidator_countTotalFields(formSpec.Steps), FormSpecValidator_countHeadings(coreMR.Items), length(formSpec.Steps), length(coreMR.Choices), length(coreMR.Triggers), length(formSpec.CategoryTags));
443
+ }
444
+
445
+ /**
446
+ * Validate pathway conversion from triggers (STUB - simplified for compilation)
447
+ */
448
+ export function FormSpecValidator_validatePathways(triggers: FSharpList<CoreMRTrigger>, pathway: Option<ClinicalPathway_ClinicalPathwaySpec>): FSharpList<ValidationError_$union> {
449
+ const activeTriggers: FSharpList<CoreMRTrigger> = filter<CoreMRTrigger>((t: CoreMRTrigger): boolean => {
450
+ if (t.Active) {
451
+ return !isEmpty(t.Events);
452
+ }
453
+ else {
454
+ return false;
455
+ }
456
+ }, triggers);
457
+ let matchResult: int32;
458
+ if (pathway == null) {
459
+ if (length(activeTriggers) > 0) {
460
+ matchResult = 0;
461
+ }
462
+ else {
463
+ matchResult = 1;
464
+ }
465
+ }
466
+ else {
467
+ matchResult = 1;
468
+ }
469
+ switch (matchResult) {
470
+ case 0:
471
+ return singleton_1(ValidationError_PathwayMissing(length(activeTriggers)));
472
+ default:
473
+ return empty_1<ValidationError_$union>();
474
+ }
475
+ }
476
+
477
+ /**
478
+ * Main validation function
479
+ */
480
+ export function FormSpecValidator_validateConversion(coreMR: CoreMRFormData, formSpec: Spec_FormSpec$1<Spec_FieldType_$union>): FSharpResult$2_$union<ValidationResult, string> {
481
+ try {
482
+ const allErrors: FSharpList<ValidationError_$union> = toList<ValidationError_$union>(delay<ValidationError_$union>((): Iterable<ValidationError_$union> => append<ValidationError_$union>(FormSpecValidator_validateMetadata(coreMR.Metadata, formSpec), delay<ValidationError_$union>((): Iterable<ValidationError_$union> => append<ValidationError_$union>(FormSpecValidator_validateCounts(coreMR, formSpec), delay<ValidationError_$union>((): Iterable<ValidationError_$union> => append<ValidationError_$union>(FormSpecValidator_validateChoices(coreMR, formSpec), delay<ValidationError_$union>((): Iterable<ValidationError_$union> => append<ValidationError_$union>(FormSpecValidator_validateRequiredFields(coreMR, formSpec), delay<ValidationError_$union>((): Iterable<ValidationError_$union> => append<ValidationError_$union>(FormSpecValidator_validateScoring(coreMR, formSpec), delay<ValidationError_$union>((): Iterable<ValidationError_$union> => append<ValidationError_$union>(FormSpecValidator_validateTags(coreMR, formSpec), delay<ValidationError_$union>((): Iterable<ValidationError_$union> => FormSpecValidator_validatePathways(coreMR.Triggers, formSpec.ClinicalPathway)))))))))))))));
483
+ return FSharpResult$2_Ok<ValidationResult, string>(new ValidationResult(isEmpty(allErrors), allErrors, empty_1<ValidationError_$union>(), FormSpecValidator_createSummary(coreMR, formSpec)));
484
+ }
485
+ catch (ex: any) {
486
+ return FSharpResult$2_Error<ValidationResult, string>(`Validation failed: ${ex.message}`);
487
+ }
488
+ }
489
+
490
+ //# sourceMappingURL=CorEMRFormSpecValidator.ts.map
@@ -0,0 +1,87 @@
1
+ import { Record } from "@fable-org/fable-library-js/Types.js";
2
+ import { int32 } from "@fable-org/fable-library-js/Int32.js";
3
+ import { comparePrimitives, IComparable, IEquatable } from "@fable-org/fable-library-js/Util.js";
4
+ import { list_type, option_type, record_type, string_type, int32_type, TypeInfo } from "@fable-org/fable-library-js/Reflection.js";
5
+ import { Option } from "@fable-org/fable-library-js/Option.js";
6
+ import { item as item_3, length, mapIndexed, append, head, singleton, isEmpty, map, sortBy, filter, FSharpList } from "@fable-org/fable-library-js/List.js";
7
+ import { CoreMRItem_$reflection, CoreMRItem } from "../../CorEMR/CoreMRTypes.js";
8
+
9
+ export class HeadingItem extends Record implements IEquatable<HeadingItem>, IComparable<HeadingItem> {
10
+ readonly Sequence: int32;
11
+ readonly Label: string;
12
+ readonly ItemId: int32;
13
+ constructor(Sequence: int32, Label: string, ItemId: int32) {
14
+ super();
15
+ this.Sequence = (Sequence | 0);
16
+ this.Label = Label;
17
+ this.ItemId = (ItemId | 0);
18
+ }
19
+ }
20
+
21
+ export function HeadingItem_$reflection(): TypeInfo {
22
+ return record_type("FormSpec.Integrations.CorEMR.CorEMRSectioning.HeadingItem", [], HeadingItem, () => [["Sequence", int32_type], ["Label", string_type], ["ItemId", int32_type]]);
23
+ }
24
+
25
+ export class Section extends Record implements IEquatable<Section>, IComparable<Section> {
26
+ readonly Heading: Option<HeadingItem>;
27
+ readonly HeadingSequence: int32;
28
+ readonly HeadingLabel: string;
29
+ readonly Items: FSharpList<CoreMRItem>;
30
+ constructor(Heading: Option<HeadingItem>, HeadingSequence: int32, HeadingLabel: string, Items: FSharpList<CoreMRItem>) {
31
+ super();
32
+ this.Heading = Heading;
33
+ this.HeadingSequence = (HeadingSequence | 0);
34
+ this.HeadingLabel = HeadingLabel;
35
+ this.Items = Items;
36
+ }
37
+ }
38
+
39
+ export function Section_$reflection(): TypeInfo {
40
+ return record_type("FormSpec.Integrations.CorEMR.CorEMRSectioning.Section", [], Section, () => [["Heading", option_type(HeadingItem_$reflection())], ["HeadingSequence", int32_type], ["HeadingLabel", string_type], ["Items", list_type(CoreMRItem_$reflection())]]);
41
+ }
42
+
43
+ /**
44
+ * Items that are not headings (type 110). Use this instead of inline ItemTypeId <> 110.
45
+ */
46
+ export function nonHeadingItems(items: FSharpList<CoreMRItem>): FSharpList<CoreMRItem> {
47
+ return filter<CoreMRItem>((item: CoreMRItem): boolean => (item.ItemTypeId !== 110), items);
48
+ }
49
+
50
+ /**
51
+ * Detect heading items (type 110) in item list
52
+ */
53
+ export function detectHeadings(items: FSharpList<CoreMRItem>): FSharpList<HeadingItem> {
54
+ return sortBy<HeadingItem, int32>((h: HeadingItem): int32 => h.Sequence, map<CoreMRItem, HeadingItem>((item_1: CoreMRItem): HeadingItem => (new HeadingItem(item_1.Sequence, item_1.Label, item_1.ItemId)), filter<CoreMRItem>((item: CoreMRItem): boolean => (item.ItemTypeId === 110), items)), {
55
+ Compare: comparePrimitives,
56
+ });
57
+ }
58
+
59
+ /**
60
+ * Group items into sections based on heading positions.
61
+ * Preamble: items before first heading (HeadingLabel = "Form").
62
+ * Sections: one per heading, items between heading N and N+1.
63
+ */
64
+ export function groupItemsByHeadings(headings: FSharpList<HeadingItem>, allItems: FSharpList<CoreMRItem>): FSharpList<Section> {
65
+ const nonHeading: FSharpList<CoreMRItem> = sortBy<CoreMRItem, int32>((item: CoreMRItem): int32 => item.Sequence, nonHeadingItems(allItems), {
66
+ Compare: comparePrimitives,
67
+ });
68
+ if (isEmpty(headings)) {
69
+ return singleton(new Section(undefined, 0, "Form", nonHeading));
70
+ }
71
+ else {
72
+ const firstHeading: HeadingItem = head(headings);
73
+ return append(singleton(new Section(undefined, 0, "Form", filter<CoreMRItem>((item_1: CoreMRItem): boolean => (item_1.Sequence < firstHeading.Sequence), nonHeading))), mapIndexed<HeadingItem, Section>((index: int32, heading: HeadingItem): Section => {
74
+ const nextHeadingSeq: int32 = ((index < (length(headings) - 1)) ? item_3(index + 1, headings).Sequence : 2147483647) | 0;
75
+ return new Section(heading, heading.Sequence, heading.Label, filter<CoreMRItem>((item_2: CoreMRItem): boolean => {
76
+ if (item_2.Sequence > heading.Sequence) {
77
+ return item_2.Sequence < nextHeadingSeq;
78
+ }
79
+ else {
80
+ return false;
81
+ }
82
+ }, nonHeading));
83
+ }, headings));
84
+ }
85
+ }
86
+
87
+ //# sourceMappingURL=CorEMRSectioning.ts.map