@f1studio/form-spec 5.0.0-alpha.101

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 (225) hide show
  1. package/Designer.d.ts +89 -0
  2. package/FormSpec.TS/Components/HelloComponent.js +68 -0
  3. package/FormSpec.TS/Components/HelloComponent.js.map +1 -0
  4. package/FormSpec.TS/Components/HelloComponent.ts.map +1 -0
  5. package/FormSpec.TS/Designer.js +526 -0
  6. package/FormSpec.TS/Designer.js.map +1 -0
  7. package/FormSpec.TS/Designer.ts.map +1 -0
  8. package/FormSpec.TS/FormSpec.js +5400 -0
  9. package/FormSpec.TS/FormSpec.js.map +1 -0
  10. package/FormSpec.TS/FormSpec.ts.map +1 -0
  11. package/FormSpec.TS/FormSpecHelpers.js +382 -0
  12. package/FormSpec.TS/FormSpecHelpers.js.map +1 -0
  13. package/FormSpec.TS/FormSpecHelpers.ts.map +1 -0
  14. package/FormSpec.TS/Helpers.js +732 -0
  15. package/FormSpec.TS/Helpers.js.map +1 -0
  16. package/FormSpec.TS/Helpers.ts.map +1 -0
  17. package/FormSpec.TS/Interfaces.js +257 -0
  18. package/FormSpec.TS/Interfaces.js.map +1 -0
  19. package/FormSpec.TS/Interfaces.ts.map +1 -0
  20. package/FormSpec.TS/Interop/FormSpec.Api.Helpers.js +854 -0
  21. package/FormSpec.TS/Interop/FormSpec.Api.Helpers.js.map +1 -0
  22. package/FormSpec.TS/Interop/FormSpec.Api.Helpers.ts.map +1 -0
  23. package/FormSpec.TS/Interop/FormSpec.Api.Option.js +1961 -0
  24. package/FormSpec.TS/Interop/FormSpec.Api.Option.js.map +1 -0
  25. package/FormSpec.TS/Interop/FormSpec.Api.Option.ts.map +1 -0
  26. package/FormSpec.TS/Interop/FormSpec.Values.Api.Option.js +1367 -0
  27. package/FormSpec.TS/Interop/FormSpec.Values.Api.Option.js.map +1 -0
  28. package/FormSpec.TS/Interop/FormSpec.Values.Api.Option.ts.map +1 -0
  29. package/FormSpec.TS/Logging/LogTypes.js +347 -0
  30. package/FormSpec.TS/Logging/LogTypes.js.map +1 -0
  31. package/FormSpec.TS/Logging/LogTypes.ts.map +1 -0
  32. package/FormSpec.TS/Migrator.js +230 -0
  33. package/FormSpec.TS/Migrator.js.map +1 -0
  34. package/FormSpec.TS/Migrator.ts.map +1 -0
  35. package/FormSpec.TS/PathwayDataExtractor.js +361 -0
  36. package/FormSpec.TS/PathwayDataExtractor.js.map +1 -0
  37. package/FormSpec.TS/PathwayDataExtractor.ts.map +1 -0
  38. package/FormSpec.TS/PathwayExecutor.js +1321 -0
  39. package/FormSpec.TS/PathwayExecutor.js.map +1 -0
  40. package/FormSpec.TS/PathwayExecutor.ts.map +1 -0
  41. package/FormSpec.TS/PathwayValidator.js +346 -0
  42. package/FormSpec.TS/PathwayValidator.js.map +1 -0
  43. package/FormSpec.TS/PathwayValidator.ts.map +1 -0
  44. package/FormSpec.TS/PluginInterface.js +171 -0
  45. package/FormSpec.TS/PluginInterface.js.map +1 -0
  46. package/FormSpec.TS/PluginInterface.ts.map +1 -0
  47. package/FormSpec.TS/Prelude.js +59 -0
  48. package/FormSpec.TS/Prelude.js.map +1 -0
  49. package/FormSpec.TS/Prelude.ts.map +1 -0
  50. package/FormSpec.TS/Renderers/FormSpecMarkdownRenderer.js +958 -0
  51. package/FormSpec.TS/Renderers/FormSpecMarkdownRenderer.js.map +1 -0
  52. package/FormSpec.TS/Renderers/FormSpecMarkdownRenderer.ts.map +1 -0
  53. package/FormSpec.TS/Renderers/MermaidRenderer.js +228 -0
  54. package/FormSpec.TS/Renderers/MermaidRenderer.js.map +1 -0
  55. package/FormSpec.TS/Renderers/MermaidRenderer.ts.map +1 -0
  56. package/FormSpec.TS/Renderers/PathwayRenderers.js +190 -0
  57. package/FormSpec.TS/Renderers/PathwayRenderers.js.map +1 -0
  58. package/FormSpec.TS/Renderers/PathwayRenderers.ts.map +1 -0
  59. package/FormSpec.TS/fable_modules/Fable.Form.3.0.0/Base.fs +511 -0
  60. package/FormSpec.TS/fable_modules/Fable.Form.3.0.0/Base.fs.js +437 -0
  61. package/FormSpec.TS/fable_modules/Fable.Form.3.0.0/Base.fs.js.map +1 -0
  62. package/FormSpec.TS/fable_modules/Fable.Form.3.0.0/Base.fs.ts.map +1 -0
  63. package/FormSpec.TS/fable_modules/Fable.Form.3.0.0/Error.fs +16 -0
  64. package/FormSpec.TS/fable_modules/Fable.Form.3.0.0/Error.fs.js +73 -0
  65. package/FormSpec.TS/fable_modules/Fable.Form.3.0.0/Error.fs.js.map +1 -0
  66. package/FormSpec.TS/fable_modules/Fable.Form.3.0.0/Error.fs.ts.map +1 -0
  67. package/FormSpec.TS/fable_modules/Fable.Form.3.0.0/Extensions.fs +50 -0
  68. package/FormSpec.TS/fable_modules/Fable.Form.3.0.0/Extensions.fs.js +72 -0
  69. package/FormSpec.TS/fable_modules/Fable.Form.3.0.0/Extensions.fs.js.map +1 -0
  70. package/FormSpec.TS/fable_modules/Fable.Form.3.0.0/Extensions.fs.ts.map +1 -0
  71. package/FormSpec.TS/fable_modules/Fable.Form.3.0.0/Fable.Form.fableproj +28 -0
  72. package/FormSpec.TS/fable_modules/Fable.Form.3.0.0/Field.fs +24 -0
  73. package/FormSpec.TS/fable_modules/Fable.Form.3.0.0/Field.fs.js +56 -0
  74. package/FormSpec.TS/fable_modules/Fable.Form.3.0.0/Field.fs.js.map +1 -0
  75. package/FormSpec.TS/fable_modules/Fable.Form.3.0.0/Field.fs.ts.map +1 -0
  76. package/FormSpec.TS/fable_modules/Fable.Form.Simple.5.0.1/Fable.Form.Simple.fableproj +31 -0
  77. package/FormSpec.TS/fable_modules/Fable.Form.Simple.5.0.1/Form.fs +178 -0
  78. package/FormSpec.TS/fable_modules/Fable.Form.Simple.5.0.1/Form.fs.js +464 -0
  79. package/FormSpec.TS/fable_modules/Fable.Form.Simple.5.0.1/Form.fs.js.map +1 -0
  80. package/FormSpec.TS/fable_modules/Fable.Form.Simple.5.0.1/Form.fs.ts.map +1 -0
  81. package/FormSpec.TS/fable_modules/Fable.React.Types.18.3.0/Fable.React.Extensions.fs +17 -0
  82. package/FormSpec.TS/fable_modules/Fable.React.Types.18.3.0/Fable.React.Hooks.fs +152 -0
  83. package/FormSpec.TS/fable_modules/Fable.React.Types.18.3.0/Fable.React.Hooks.fs.js +25 -0
  84. package/FormSpec.TS/fable_modules/Fable.React.Types.18.3.0/Fable.React.Hooks.fs.js.map +1 -0
  85. package/FormSpec.TS/fable_modules/Fable.React.Types.18.3.0/Fable.React.Hooks.fs.ts.map +1 -0
  86. package/FormSpec.TS/fable_modules/Fable.React.Types.18.3.0/Fable.React.Types.fableproj +28 -0
  87. package/FormSpec.TS/fable_modules/Fable.React.Types.18.3.0/Fable.React.fs +218 -0
  88. package/FormSpec.TS/fable_modules/Fable.React.Types.18.3.0/Fable.React.fs.js +37 -0
  89. package/FormSpec.TS/fable_modules/Fable.React.Types.18.3.0/Fable.React.fs.js.map +1 -0
  90. package/FormSpec.TS/fable_modules/Fable.React.Types.18.3.0/Fable.React.fs.ts.map +1 -0
  91. package/FormSpec.TS/fable_modules/Fable.ReactDom.Types.18.2.0/Fable.ReactDom.Types.fableproj +27 -0
  92. package/FormSpec.TS/fable_modules/Fable.ReactDom.Types.18.2.0/Fable.ReactDom.fs +82 -0
  93. package/FormSpec.TS/fable_modules/Fable.ReactDom.Types.18.2.0/Fable.ReactDom.fs.js +7 -0
  94. package/FormSpec.TS/fable_modules/Fable.ReactDom.Types.18.2.0/Fable.ReactDom.fs.js.map +1 -0
  95. package/FormSpec.TS/fable_modules/Fable.ReactDom.Types.18.2.0/Fable.ReactDom.fs.ts.map +1 -0
  96. package/FormSpec.TS/fable_modules/Feliz.2.7.0/BorderStyle.fs +59 -0
  97. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Colors.fs +154 -0
  98. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Colors.fs.js +32 -0
  99. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Colors.fs.js.map +1 -0
  100. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Colors.fs.ts.map +1 -0
  101. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Feliz.fableproj +42 -0
  102. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Fonts.fs +240 -0
  103. package/FormSpec.TS/fable_modules/Feliz.2.7.0/GridTypes.fs +24 -0
  104. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Html.fs +826 -0
  105. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Interop.fs +83 -0
  106. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Interop.fs.js +292 -0
  107. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Interop.fs.js.map +1 -0
  108. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Interop.fs.ts.map +1 -0
  109. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Key.fs +65 -0
  110. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Key.fs.js +229 -0
  111. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Key.fs.js.map +1 -0
  112. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Key.fs.ts.map +1 -0
  113. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Length.fs +91 -0
  114. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Locale.fs +876 -0
  115. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Properties.fs +4080 -0
  116. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Properties.fs.js +133 -0
  117. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Properties.fs.js.map +1 -0
  118. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Properties.fs.ts.map +1 -0
  119. package/FormSpec.TS/fable_modules/Feliz.2.7.0/React.fs +656 -0
  120. package/FormSpec.TS/fable_modules/Feliz.2.7.0/React.fs.js +561 -0
  121. package/FormSpec.TS/fable_modules/Feliz.2.7.0/React.fs.js.map +1 -0
  122. package/FormSpec.TS/fable_modules/Feliz.2.7.0/React.fs.ts.map +1 -0
  123. package/FormSpec.TS/fable_modules/Feliz.2.7.0/ReactDOM.fs +25 -0
  124. package/FormSpec.TS/fable_modules/Feliz.2.7.0/ReactDOM.fs.js +46 -0
  125. package/FormSpec.TS/fable_modules/Feliz.2.7.0/ReactDOM.fs.js.map +1 -0
  126. package/FormSpec.TS/fable_modules/Feliz.2.7.0/ReactDOM.fs.ts.map +1 -0
  127. package/FormSpec.TS/fable_modules/Feliz.2.7.0/ReactInterop.js +63 -0
  128. package/FormSpec.TS/fable_modules/Feliz.2.7.0/ReactInterop.js.map +1 -0
  129. package/FormSpec.TS/fable_modules/Feliz.2.7.0/ReactTypes.fs +41 -0
  130. package/FormSpec.TS/fable_modules/Feliz.2.7.0/ReactTypes.fs.js +7 -0
  131. package/FormSpec.TS/fable_modules/Feliz.2.7.0/ReactTypes.fs.js.map +1 -0
  132. package/FormSpec.TS/fable_modules/Feliz.2.7.0/ReactTypes.fs.ts.map +1 -0
  133. package/FormSpec.TS/fable_modules/Feliz.2.7.0/StyleTypes.fs +53 -0
  134. package/FormSpec.TS/fable_modules/Feliz.2.7.0/StyleTypes.fs.js +7 -0
  135. package/FormSpec.TS/fable_modules/Feliz.2.7.0/StyleTypes.fs.js.map +1 -0
  136. package/FormSpec.TS/fable_modules/Feliz.2.7.0/StyleTypes.fs.ts.map +1 -0
  137. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Styles.fs +5740 -0
  138. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Svg.fs +1455 -0
  139. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Svg.fs.js +39 -0
  140. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Svg.fs.js.map +1 -0
  141. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Svg.fs.ts.map +1 -0
  142. package/FormSpec.TS/fable_modules/Feliz.2.7.0/TextDecorationLine.fs +13 -0
  143. package/FormSpec.TS/fable_modules/Feliz.2.7.0/TextDecorationStyle.fs +33 -0
  144. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Transform.fs +181 -0
  145. package/FormSpec.TS/fable_modules/Feliz.2.7.0/TransformOrigin.fs +17 -0
  146. package/FormSpec.TS/fable_modules/Feliz.2.7.0/TransitionProperty.fs +162 -0
  147. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Types.fs +13 -0
  148. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Types.fs.js +7 -0
  149. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Types.fs.js.map +1 -0
  150. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Types.fs.ts.map +1 -0
  151. package/FormSpec.TS/fable_modules/Thoth.Json.10.4.1/Decode.fs +1768 -0
  152. package/FormSpec.TS/fable_modules/Thoth.Json.10.4.1/Decode.fs.js +2337 -0
  153. package/FormSpec.TS/fable_modules/Thoth.Json.10.4.1/Decode.fs.js.map +1 -0
  154. package/FormSpec.TS/fable_modules/Thoth.Json.10.4.1/Decode.fs.ts.map +1 -0
  155. package/FormSpec.TS/fable_modules/Thoth.Json.10.4.1/Encode.fs +811 -0
  156. package/FormSpec.TS/fable_modules/Thoth.Json.10.4.1/Encode.fs.js +465 -0
  157. package/FormSpec.TS/fable_modules/Thoth.Json.10.4.1/Encode.fs.js.map +1 -0
  158. package/FormSpec.TS/fable_modules/Thoth.Json.10.4.1/Encode.fs.ts.map +1 -0
  159. package/FormSpec.TS/fable_modules/Thoth.Json.10.4.1/Extra.fs +47 -0
  160. package/FormSpec.TS/fable_modules/Thoth.Json.10.4.1/Extra.fs.js +18 -0
  161. package/FormSpec.TS/fable_modules/Thoth.Json.10.4.1/Extra.fs.js.map +1 -0
  162. package/FormSpec.TS/fable_modules/Thoth.Json.10.4.1/Extra.fs.ts.map +1 -0
  163. package/FormSpec.TS/fable_modules/Thoth.Json.10.4.1/Thoth.Json.fableproj +34 -0
  164. package/FormSpec.TS/fable_modules/Thoth.Json.10.4.1/Types.fs +68 -0
  165. package/FormSpec.TS/fable_modules/Thoth.Json.10.4.1/Types.fs.js +355 -0
  166. package/FormSpec.TS/fable_modules/Thoth.Json.10.4.1/Types.fs.js.map +1 -0
  167. package/FormSpec.TS/fable_modules/Thoth.Json.10.4.1/Types.fs.ts.map +1 -0
  168. package/FormSpec.TS/fable_modules/project_cracked.json +1 -0
  169. package/FormSpec.d.ts +1257 -0
  170. package/FormSpecHelpers.d.ts +50 -0
  171. package/Helpers.d.ts +147 -0
  172. package/Interfaces.d.ts +70 -0
  173. package/Interop/FormSpec.Api.Helpers.d.ts +247 -0
  174. package/Interop/FormSpec.Api.Helpers.d.ts.map +1 -0
  175. package/Interop/FormSpec.Api.Option.d.ts +384 -0
  176. package/Interop/FormSpec.Api.Option.d.ts.map +1 -0
  177. package/Interop/FormSpec.Values.Api.Option.d.ts +324 -0
  178. package/Interop/FormSpec.Values.Api.Option.d.ts.map +1 -0
  179. package/Migrator.d.ts +59 -0
  180. package/PathwayDataExtractor.d.ts +19 -0
  181. package/PathwayExecutor.d.ts +210 -0
  182. package/PathwayValidator.d.ts +52 -0
  183. package/PluginInterface.d.ts +36 -0
  184. package/Prelude.d.ts +11 -0
  185. package/README.TS.md +622 -0
  186. package/README.md +85 -0
  187. package/package.json +39 -0
  188. package/src/Components/HelloComponent.ts +48 -0
  189. package/src/Components/HelloComponent.ts.map +1 -0
  190. package/src/Designer.ts +389 -0
  191. package/src/Designer.ts.map +1 -0
  192. package/src/FormSpec.ts +3114 -0
  193. package/src/FormSpec.ts.map +1 -0
  194. package/src/FormSpecHelpers.ts +374 -0
  195. package/src/FormSpecHelpers.ts.map +1 -0
  196. package/src/Helpers.ts +765 -0
  197. package/src/Helpers.ts.map +1 -0
  198. package/src/Interfaces.ts +166 -0
  199. package/src/Interfaces.ts.map +1 -0
  200. package/src/Interop/FormSpec.Api.Helpers.ts +872 -0
  201. package/src/Interop/FormSpec.Api.Helpers.ts.map +1 -0
  202. package/src/Interop/FormSpec.Api.Option.ts +1618 -0
  203. package/src/Interop/FormSpec.Api.Option.ts.map +1 -0
  204. package/src/Interop/FormSpec.Values.Api.Option.ts +1214 -0
  205. package/src/Interop/FormSpec.Values.Api.Option.ts.map +1 -0
  206. package/src/Logging/LogTypes.ts +212 -0
  207. package/src/Logging/LogTypes.ts.map +1 -0
  208. package/src/Migrator.ts +156 -0
  209. package/src/Migrator.ts.map +1 -0
  210. package/src/PathwayDataExtractor.ts +290 -0
  211. package/src/PathwayDataExtractor.ts.map +1 -0
  212. package/src/PathwayExecutor.ts +1102 -0
  213. package/src/PathwayExecutor.ts.map +1 -0
  214. package/src/PathwayValidator.ts +244 -0
  215. package/src/PathwayValidator.ts.map +1 -0
  216. package/src/PluginInterface.ts +79 -0
  217. package/src/PluginInterface.ts.map +1 -0
  218. package/src/Prelude.ts +21 -0
  219. package/src/Prelude.ts.map +1 -0
  220. package/src/Renderers/FormSpecMarkdownRenderer.ts +874 -0
  221. package/src/Renderers/FormSpecMarkdownRenderer.ts.map +1 -0
  222. package/src/Renderers/MermaidRenderer.ts +218 -0
  223. package/src/Renderers/MermaidRenderer.ts.map +1 -0
  224. package/src/Renderers/PathwayRenderers.ts +200 -0
  225. package/src/Renderers/PathwayRenderers.ts.map +1 -0
@@ -0,0 +1,872 @@
1
+ import { map as map_3, some, value as value_11, unwrap, defaultArgWith as defaultArgWith_1, Option, defaultArg as defaultArg_1 } from "@fable-org/fable-library-js/Option.js";
2
+ import { tryPick, singleton, exists, filter, map as map_2, ofArray as ofArray_1, ofSeq, empty, collect, tryFind, FSharpList } from "@fable-org/fable-library-js/List.js";
3
+ import { join, printf, toConsole } from "@fable-org/fable-library-js/String.js";
4
+ import { Auto_generateBoxedEncoder_437914C6, toString } from "../fable_modules/Thoth.Json.10.4.1/Encode.fs.js";
5
+ import { array_type, string_type, union_type, TypeInfo, obj_type } from "@fable-org/fable-library-js/Reflection.js";
6
+ import { Auto_generateBoxedDecoder_Z6670B51, fromString } from "../fable_modules/Thoth.Json.10.4.1/Decode.fs.js";
7
+ import { equals, compare, IDisposable, disposeSafe, IEnumerator, getEnumerator, IMap, isArrayLike, uncurry2 } from "@fable-org/fable-library-js/Util.js";
8
+ import { ClinicalPathway_StateType_$union, ClinicalPathway_TaskPriority_$union, ClinicalPathway_AlertSeverity_$union, ClinicalPathway_ReferralUrgency_$union, ClinicalPathway_ActionInfo_$union, ClinicalPathway_NavigateToFormAction, ClinicalPathway_ProblemAction, ClinicalPathway_AlertAction, ClinicalPathway_EducationAction, ClinicalPathway_ProcedureAction, ClinicalPathway_TestAction, ClinicalPathway_DocumentationAction, ClinicalPathway_FieldValueSource_$union, ClinicalPathway_SetFieldValueAction, ClinicalPathway_PrescriptionAction, ClinicalPathway_MedicationAction, ClinicalPathway_ReferralAction, ClinicalPathway_ClinicalPathwaySpec, ClinicalPathway_PathRequirement, ClinicalPathway_ConstraintDefinition, ClinicalPathway_PathwayExecutionMode_SinglePathway, ClinicalPathway_SinglePathwayConfig, ClinicalPathway_SelectionStrategy_HighestPriority, ClinicalPathway_TransitionDefinition, ClinicalPathway_TransitionCondition_FieldCondition, Shared_ConditionValue_Single, ClinicalPathway_FieldEvaluator_Equals, Shared_TransitionKey, ClinicalPathway_StateType_Terminal, ClinicalPathway_TerminalInfo, ClinicalPathway_StateDefinition, ClinicalPathway_StateType_Action, ClinicalPathway_ActionInfo_Task, ClinicalPathway_TaskAction, ClinicalPathway_DueDate_Today, ClinicalPathway_TaskPriority_Medium, ClinicalPathway_TaskPriority_Low, ClinicalPathway_TaskPriority_High, Shared_StateKey, Spec_FieldType_PluginField, Spec_PluginFieldConfig, Spec_FieldType_Matrix, Spec_MatrixInfo, Spec_FieldType_Text, Spec_TextInfo, Spec_FieldType_CheckboxList, Spec_MultiChoiceInfo, Shared_FieldOptionKey, Spec_FieldType_Checkbox, Spec_BooleanInfo, Shared_FieldKey, Values_StepOrder, Values_FieldDetails$1, Shared_FieldOption, Shared_FieldValue_Single, Shared_FieldValue_PluginData, Shared_PluginDataProperty, Shared_PluginPropertyKey, Shared_FieldValue_Matrix, Shared_MatrixAnswer, Shared_MatrixItemKey, Shared_FieldValue_Multiple, Shared_FieldAnswer, Values_DynamicFormSpecDetails, Values_Signature, Values_FormStatus_Pending, Spec_FormStep$1, Spec_FormField$1, Values_DynamicFormResultData$1, Values_DynamicFormResultData$1_$reflection, Spec_FieldType_$union, Spec_FormSpec$1, Spec_FormSpec$1_$reflection, Spec_FieldType_$reflection } from "../FormSpec.js";
9
+ import { FSharpResult$2_$union } from "@fable-org/fable-library-js/Result.js";
10
+ import { Union } from "@fable-org/fable-library-js/Types.js";
11
+ import { IOptionalGetter, array as array_4, IGetters, dict, string, IRequiredGetter, object, fromString as fromString_1 } from "../fable_modules/Thoth.Json.10.4.1/Decode.fs.js";
12
+ import { ErrorReason_$union } from "../fable_modules/Thoth.Json.10.4.1/Types.fs.js";
13
+ import { toSeq, tryFind as tryFind_1, ofList, ofSeq as ofSeq_1, FSharpMap } from "@fable-org/fable-library-js/Map.js";
14
+ import { addToDict } from "@fable-org/fable-library-js/MapUtil.js";
15
+ import { mapIndexed, map as map_1, choose } from "@fable-org/fable-library-js/Seq.js";
16
+ import { ofArray } from "@fable-org/fable-library-js/Set.js";
17
+ import { map } from "@fable-org/fable-library-js/Array.js";
18
+ import { int32 } from "@fable-org/fable-library-js/Int32.js";
19
+ import { newGuid, parse } from "@fable-org/fable-library-js/Guid.js";
20
+ import { now } from "@fable-org/fable-library-js/DateOffset.js";
21
+ import { initializeExecution } from "../PathwayExecutor.js";
22
+
23
+ /**
24
+ * Get value from Option or return default (SAFE - recommended)
25
+ * TypeScript: <T>(opt: Option<T>, defaultValue: T) => T
26
+ * Usage: Api.defaultArg(formSpec.Code, "unknown")
27
+ */
28
+ export function defaultArg<T>(opt: Option<T>, defaultValue: T): T {
29
+ return defaultArg_1(opt, defaultValue);
30
+ }
31
+
32
+ /**
33
+ * Get value from Option or compute default using function (SAFE - recommended)
34
+ * TypeScript: <T>(opt: Option<T>, defThunk: () => T) => T
35
+ * Usage: Api.defaultArgWith(formSpec.Code, () => "unknown")
36
+ */
37
+ export function defaultArgWith<T>(opt: Option<T>, defThunk: (() => T)): T {
38
+ return defaultArgWith_1<T>(opt, defThunk);
39
+ }
40
+
41
+ /**
42
+ * Check if Option is Some
43
+ * TypeScript: <T>(opt: Option<T>) => boolean
44
+ * Usage: if (Api.isSome(formSpec.Code)) { ... }
45
+ */
46
+ export function isSome<T>(opt: Option<T>): boolean {
47
+ return opt != null;
48
+ }
49
+
50
+ /**
51
+ * Check if Option is None
52
+ * TypeScript: <T>(opt: Option<T>) => boolean
53
+ * Usage: if (Api.isNone(formSpec.Code)) { ... }
54
+ */
55
+ export function isNone<T>(opt: Option<T>): boolean {
56
+ return opt == null;
57
+ }
58
+
59
+ export function listToArray<T>(list: FSharpList<T>): T[] {
60
+ return Array.from(list);
61
+ }
62
+
63
+ export function serializeFormSpec(formSpec: any): string {
64
+ toConsole(printf("[API.Helpers] Serializing FormSpec!!"));
65
+ toConsole(`[API.Helpers] FormSpec: ${formSpec}`);
66
+ return toString(0, Auto_generateBoxedEncoder_437914C6(obj_type, undefined, undefined, undefined)(formSpec));
67
+ }
68
+
69
+ export function deserializeFormSpec(json: string): Option<Spec_FormSpec$1<Spec_FieldType_$union>> {
70
+ toConsole(printf("[API.Helpers] Deserializing FormSpec"));
71
+ const matchValue: FSharpResult$2_$union<Spec_FormSpec$1<Spec_FieldType_$union>, string> = fromString<Spec_FormSpec$1<Spec_FieldType_$union>>(uncurry2(Auto_generateBoxedDecoder_Z6670B51(Spec_FormSpec$1_$reflection(Spec_FieldType_$reflection()), undefined, undefined)), json);
72
+ if (matchValue.tag === /* Error */ 1) {
73
+ throw new Error(`[API.Helpers] Deserialization failed: ${matchValue.fields[0]}`);
74
+ }
75
+ else {
76
+ return matchValue.fields[0];
77
+ }
78
+ }
79
+
80
+ export function serializeDynamicFormResultData(data: Values_DynamicFormResultData$1<Spec_FieldType_$union>): string {
81
+ toConsole(printf("[API.Helpers] Serializing DynamicFormResultData"));
82
+ return toString(0, Auto_generateBoxedEncoder_437914C6(Values_DynamicFormResultData$1_$reflection(Spec_FieldType_$reflection()), undefined, undefined, undefined)(data));
83
+ }
84
+
85
+ export function deserializeDynamicFormResultData(json: string): Option<Values_DynamicFormResultData$1<Spec_FieldType_$union>> {
86
+ const matchValue: FSharpResult$2_$union<Values_DynamicFormResultData$1<Spec_FieldType_$union>, string> = fromString<Values_DynamicFormResultData$1<Spec_FieldType_$union>>(uncurry2(Auto_generateBoxedDecoder_Z6670B51(Values_DynamicFormResultData$1_$reflection(Spec_FieldType_$reflection()), undefined, undefined)), json);
87
+ if (matchValue.tag === /* Error */ 1) {
88
+ return undefined;
89
+ }
90
+ else {
91
+ return matchValue.fields[0];
92
+ }
93
+ }
94
+
95
+ /**
96
+ * Find FormField by its FieldKey string representation
97
+ */
98
+ export function findFieldByKey(spec: Spec_FormSpec$1<Spec_FieldType_$union>, fieldKeyString: string): Option<Spec_FormField$1<Spec_FieldType_$union>> {
99
+ return tryFind<Spec_FormField$1<Spec_FieldType_$union>>((field: Spec_FormField$1<Spec_FieldType_$union>): boolean => (field.FieldKey.fields[0] === fieldKeyString), collect<Spec_FormStep$1<Spec_FieldType_$union>, Spec_FormField$1<Spec_FieldType_$union>>((step: Spec_FormStep$1<Spec_FieldType_$union>): FSharpList<Spec_FormField$1<Spec_FieldType_$union>> => step.Fields, spec.Steps));
100
+ }
101
+
102
+ export type ExpectedFieldValueType_$union =
103
+ | ExpectedFieldValueType<0>
104
+ | ExpectedFieldValueType<1>
105
+ | ExpectedFieldValueType<2>
106
+ | ExpectedFieldValueType<3>
107
+
108
+ export type ExpectedFieldValueType_$cases = {
109
+ 0: ["SingleValue", []],
110
+ 1: ["MultipleValues", []],
111
+ 2: ["MatrixValue", []],
112
+ 3: ["PluginDataValue", []]
113
+ }
114
+
115
+ export function ExpectedFieldValueType_SingleValue() {
116
+ return new ExpectedFieldValueType<0>(0, []);
117
+ }
118
+
119
+ export function ExpectedFieldValueType_MultipleValues() {
120
+ return new ExpectedFieldValueType<1>(1, []);
121
+ }
122
+
123
+ export function ExpectedFieldValueType_MatrixValue() {
124
+ return new ExpectedFieldValueType<2>(2, []);
125
+ }
126
+
127
+ export function ExpectedFieldValueType_PluginDataValue() {
128
+ return new ExpectedFieldValueType<3>(3, []);
129
+ }
130
+
131
+ export class ExpectedFieldValueType<Tag extends keyof ExpectedFieldValueType_$cases> extends Union<Tag, ExpectedFieldValueType_$cases[Tag][0]> {
132
+ constructor(readonly tag: Tag, readonly fields: ExpectedFieldValueType_$cases[Tag][1]) {
133
+ super();
134
+ }
135
+ cases() {
136
+ return ["SingleValue", "MultipleValues", "MatrixValue", "PluginDataValue"];
137
+ }
138
+ }
139
+
140
+ export function ExpectedFieldValueType_$reflection(): TypeInfo {
141
+ return union_type("FormSpec.Interop.Helpers.ExpectedFieldValueType", [], ExpectedFieldValueType, () => [[], [], [], []]);
142
+ }
143
+
144
+ export function getExpectedFieldValueType(fieldType: Spec_FieldType_$union): ExpectedFieldValueType_$union {
145
+ switch (fieldType.tag) {
146
+ case /* TextArea */ 1:
147
+ return ExpectedFieldValueType_SingleValue();
148
+ case /* Email */ 2:
149
+ return ExpectedFieldValueType_SingleValue();
150
+ case /* Password */ 3:
151
+ return ExpectedFieldValueType_SingleValue();
152
+ case /* Search */ 4:
153
+ return ExpectedFieldValueType_SingleValue();
154
+ case /* Color */ 5:
155
+ return ExpectedFieldValueType_SingleValue();
156
+ case /* Number */ 6:
157
+ return ExpectedFieldValueType_SingleValue();
158
+ case /* Tel */ 7:
159
+ return ExpectedFieldValueType_SingleValue();
160
+ case /* Date */ 8:
161
+ return ExpectedFieldValueType_SingleValue();
162
+ case /* DateTimeLocal */ 9:
163
+ return ExpectedFieldValueType_SingleValue();
164
+ case /* Time */ 10:
165
+ return ExpectedFieldValueType_SingleValue();
166
+ case /* Checkbox */ 11:
167
+ return ExpectedFieldValueType_SingleValue();
168
+ case /* Radio */ 12:
169
+ return ExpectedFieldValueType_SingleValue();
170
+ case /* SingleChoice */ 13:
171
+ return ExpectedFieldValueType_SingleValue();
172
+ case /* Dropdown */ 14:
173
+ return ExpectedFieldValueType_SingleValue();
174
+ case /* TextAutoComplete */ 18:
175
+ return ExpectedFieldValueType_SingleValue();
176
+ case /* Signature */ 20:
177
+ return ExpectedFieldValueType_SingleValue();
178
+ case /* Message */ 21:
179
+ return ExpectedFieldValueType_SingleValue();
180
+ case /* CheckboxList */ 16:
181
+ return ExpectedFieldValueType_MultipleValues();
182
+ case /* MultiChoice */ 15:
183
+ return ExpectedFieldValueType_MultipleValues();
184
+ case /* TagList */ 17:
185
+ return ExpectedFieldValueType_MultipleValues();
186
+ case /* Matrix */ 19:
187
+ return ExpectedFieldValueType_MatrixValue();
188
+ case /* PluginField */ 22:
189
+ return ExpectedFieldValueType_PluginDataValue();
190
+ default:
191
+ return ExpectedFieldValueType_SingleValue();
192
+ }
193
+ }
194
+
195
+ export function decodeAsString(fieldKey: string, obj: any): string {
196
+ let matchValue: FSharpResult$2_$union<string, string>;
197
+ const json: string = toString(0, Auto_generateBoxedEncoder_437914C6(obj_type, undefined, undefined, undefined)(obj));
198
+ matchValue = fromString<string>(uncurry2(Auto_generateBoxedDecoder_Z6670B51(string_type, undefined, undefined)), json);
199
+ if (matchValue.tag === /* Error */ 1) {
200
+ if (typeof obj === "string") {
201
+ const str = obj as string;
202
+ return str;
203
+ }
204
+ else {
205
+ throw new Error(`Field ${fieldKey}: Expected string value, got ${"Object"}`);
206
+ }
207
+ }
208
+ else {
209
+ return matchValue.fields[0];
210
+ }
211
+ }
212
+
213
+ export function decodeAsStringArray(fieldKey: string, obj: any): string[] {
214
+ if (isArrayLike(obj)) {
215
+ return obj;
216
+ }
217
+ else if (isArrayLike(obj)) {
218
+ const resizeArray: string[] = obj;
219
+ return resizeArray.slice();
220
+ }
221
+ else if (typeof obj === "string") {
222
+ return [obj];
223
+ }
224
+ else {
225
+ try {
226
+ let matchValue: FSharpResult$2_$union<string[], string>;
227
+ const json: string = toString(0, Auto_generateBoxedEncoder_437914C6(obj_type, undefined, undefined, undefined)(obj));
228
+ matchValue = fromString<string[]>(uncurry2(Auto_generateBoxedDecoder_Z6670B51(array_type(string_type), undefined, undefined)), json);
229
+ if (matchValue.tag === /* Error */ 1) {
230
+ throw new Error(`Field ${fieldKey}: Expected string array, got ${"Object"}`);
231
+ }
232
+ else {
233
+ return matchValue.fields[0];
234
+ }
235
+ }
236
+ catch (ex: any) {
237
+ throw new Error(`Field ${fieldKey}: Expected string array, got ${"Object"}`);
238
+ }
239
+ }
240
+ }
241
+
242
+ export function decodeAsMatrixValue(fieldKey: string, obj: any): { description: string, values: IMap<string, string> } {
243
+ let str: string;
244
+ const objAsString: string = (typeof obj === "string") ? ((str = (obj as string), str)) : toString(0, Auto_generateBoxedEncoder_437914C6(obj_type, undefined, undefined, undefined)(obj));
245
+ try {
246
+ const matchValue: FSharpResult$2_$union<{ description: string, values: IMap<string, string> }, string> = fromString_1<{ description: string, values: IMap<string, string> }>((path_2: string, v: any): FSharpResult$2_$union<{ description: string, values: IMap<string, string> }, [string, ErrorReason_$union]> => object<{ description: string, values: IMap<string, string> }>((get$: IGetters): { description: string, values: IMap<string, string> } => {
247
+ let description: string;
248
+ const objectArg: IRequiredGetter = get$.Required;
249
+ description = objectArg.Field<string>("description", string);
250
+ let valuesMap: FSharpMap<string, string>;
251
+ const arg_3: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<FSharpMap<string, string>, [string, ErrorReason_$union]>)) = dict<string>(string);
252
+ const objectArg_1: IRequiredGetter = get$.Required;
253
+ valuesMap = objectArg_1.Field<FSharpMap<string, string>>("values", uncurry2(arg_3));
254
+ const valuesDict: IMap<string, string> = new Map<string, string>([]);
255
+ const enumerator: IEnumerator<[string, string]> = getEnumerator(valuesMap);
256
+ try {
257
+ while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
258
+ const kvp: [string, string] = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
259
+ addToDict(valuesDict, kvp[0], kvp[1]);
260
+ }
261
+ }
262
+ finally {
263
+ disposeSafe(enumerator as IDisposable);
264
+ }
265
+ return {
266
+ description: description,
267
+ values: valuesDict,
268
+ };
269
+ }, path_2, v), objAsString);
270
+ if (matchValue.tag === /* Error */ 1) {
271
+ throw new Error(`Field ${fieldKey}: Invalid matrix data format - ${matchValue.fields[0]}`);
272
+ }
273
+ else {
274
+ return matchValue.fields[0];
275
+ }
276
+ }
277
+ catch (ex: any) {
278
+ throw new Error(`Field ${fieldKey}: Failed to decode matrix value - ${ex.message}`);
279
+ }
280
+ }
281
+
282
+ export function decodeAsPluginDataArray(fieldKey: string, obj: any): { dataType: string, description?: string, displayName?: string, name: string, propertyKey: string, unit?: string, value: string }[] {
283
+ let str: string;
284
+ const objAsString: string = (typeof obj === "string") ? ((str = (obj as string), str)) : toString(0, Auto_generateBoxedEncoder_437914C6(obj_type, undefined, undefined, undefined)(obj));
285
+ try {
286
+ const matchValue: FSharpResult$2_$union<{ dataType: string, description?: string, displayName?: string, name: string, propertyKey: string, unit?: string, value: string }[], string> = fromString_1<{ dataType: string, description?: string, displayName?: string, name: string, propertyKey: string, unit?: string, value: string }[]>((path_8: string, value_10: any): FSharpResult$2_$union<{ dataType: string, description?: string, displayName?: string, name: string, propertyKey: string, unit?: string, value: string }[], [string, ErrorReason_$union]> => array_4<{ dataType: string, description?: string, displayName?: string, name: string, propertyKey: string, unit?: string, value: string }>((path_7: string, v: any): FSharpResult$2_$union<{ dataType: string, description?: string, displayName?: string, name: string, propertyKey: string, unit?: string, value: string }, [string, ErrorReason_$union]> => object<{ dataType: string, description?: string, displayName?: string, name: string, propertyKey: string, unit?: string, value: string }>((get$: IGetters): { dataType: string, description?: string, displayName?: string, name: string, propertyKey: string, unit?: string, value: string } => {
287
+ let objectArg_6: IOptionalGetter;
288
+ let propertyKey: string;
289
+ const objectArg: IRequiredGetter = get$.Required;
290
+ propertyKey = objectArg.Field<string>("propertyKey", string);
291
+ let name: string;
292
+ const objectArg_1: IRequiredGetter = get$.Required;
293
+ name = objectArg_1.Field<string>("name", string);
294
+ let dataType: string;
295
+ const objectArg_2: IRequiredGetter = get$.Required;
296
+ dataType = objectArg_2.Field<string>("dataType", string);
297
+ let value_6: string;
298
+ const objectArg_3: IRequiredGetter = get$.Required;
299
+ value_6 = objectArg_3.Field<string>("value", string);
300
+ let displayName: Option<string>;
301
+ const objectArg_4: IOptionalGetter = get$.Optional;
302
+ displayName = objectArg_4.Field<string>("displayName", string);
303
+ let unit: Option<string>;
304
+ const objectArg_5: IOptionalGetter = get$.Optional;
305
+ unit = objectArg_5.Field<string>("unit", string);
306
+ return {
307
+ dataType: dataType,
308
+ description: unwrap((objectArg_6 = get$.Optional, objectArg_6.Field<string>("description", string))),
309
+ displayName: unwrap(displayName),
310
+ name: name,
311
+ propertyKey: propertyKey,
312
+ unit: unwrap(unit),
313
+ value: value_6,
314
+ };
315
+ }, path_7, v), path_8, value_10), objAsString);
316
+ if (matchValue.tag === /* Error */ 1) {
317
+ throw new Error(`Field ${fieldKey}: Invalid plugin data format - ${matchValue.fields[0]}`);
318
+ }
319
+ else {
320
+ return matchValue.fields[0];
321
+ }
322
+ }
323
+ catch (ex: any) {
324
+ throw new Error(`Field ${fieldKey}: Failed to decode plugin data - ${ex.message}`);
325
+ }
326
+ }
327
+
328
+ export function createFormFieldData(fieldKey: string, objectValue: any): { fieldKey: string, objectValue: any } {
329
+ return {
330
+ fieldKey: fieldKey,
331
+ objectValue: objectValue,
332
+ };
333
+ }
334
+
335
+ /**
336
+ * Build DynamicFormResultData from FormSpec with comprehensive type validation
337
+ * TypeScript: (formSpec: FormSpec, fieldData: FieldInput[]) => DynamicFormResultData
338
+ * Where FieldInput = SingleValueInput | MultipleValueInput | MatrixValueInput | PluginValueInput
339
+ */
340
+ export function buildDynamicFormResultData(formSpec: Spec_FormSpec$1<Spec_FieldType_$union>, fieldData: { fieldKey: string, objectValue: any }[]): Values_DynamicFormResultData$1<Spec_FieldType_$union> {
341
+ const resultFormSpecDetails: Values_DynamicFormSpecDetails = new Values_DynamicFormSpecDetails(formSpec.Id, formSpec.Code, formSpec.FormSpecVersion, formSpec.FormSpecVersion, formSpec.Score, Values_FormStatus_Pending(), empty<Values_Signature>());
342
+ const allFieldDetails: FSharpList<[Spec_FormField$1<Spec_FieldType_$union>, Values_FieldDetails$1<Spec_FieldType_$union>]> = ofSeq<[Spec_FormField$1<Spec_FieldType_$union>, Values_FieldDetails$1<Spec_FieldType_$union>]>(choose<{ fieldKey: string, objectValue: any }, [Spec_FormField$1<Spec_FieldType_$union>, Values_FieldDetails$1<Spec_FieldType_$union>]>((input: { fieldKey: string, objectValue: any }): Option<[Spec_FormField$1<Spec_FieldType_$union>, Values_FieldDetails$1<Spec_FieldType_$union>]> => {
343
+ let matchValue_1: ExpectedFieldValueType_$union, matrixData: { description: string, values: IMap<string, string> }, matchValue_2: Spec_FieldType_$union;
344
+ const matchValue: Option<Spec_FormField$1<Spec_FieldType_$union>> = findFieldByKey(formSpec, input.fieldKey);
345
+ if (matchValue == null) {
346
+ toConsole(`Warning: Field ${input.fieldKey} not found in FormSpec`);
347
+ return undefined;
348
+ }
349
+ else {
350
+ const field: Spec_FormField$1<Spec_FieldType_$union> = value_11(matchValue);
351
+ try {
352
+ return [field, new Values_FieldDetails$1(field.FieldOrder, field.FieldKey, field.Label, (matchValue_1 = getExpectedFieldValueType(field.FieldType), (matchValue_1.tag === /* MultipleValues */ 1) ? Shared_FieldValue_Multiple(ofArray<Shared_FieldAnswer>(map<string, Shared_FieldAnswer>((value: string): Shared_FieldAnswer => (new Shared_FieldAnswer(field.FieldKey, field.Label, value)), decodeAsStringArray(input.fieldKey, input.objectValue)), {
353
+ Compare: compare,
354
+ })) : ((matchValue_1.tag === /* MatrixValue */ 2) ? ((matrixData = decodeAsMatrixValue(input.fieldKey, input.objectValue), Shared_FieldValue_Matrix(new Shared_MatrixAnswer(field.FieldKey, matrixData.description, ofSeq_1<Shared_MatrixItemKey, string>(map_1<[string, string], [Shared_MatrixItemKey, string]>((kvp: [string, string]): [Shared_MatrixItemKey, string] => ([new Shared_MatrixItemKey(parse(kvp[0])), kvp[1]] as [Shared_MatrixItemKey, string]), matrixData.values), {
355
+ Compare: compare,
356
+ }))))) : ((matchValue_1.tag === /* PluginDataValue */ 3) ? Shared_FieldValue_PluginData(ofArray_1<Shared_PluginDataProperty>(map<{ dataType: string, description?: string, displayName?: string, name: string, propertyKey: string, unit?: string, value: string }, Shared_PluginDataProperty>((prop: { dataType: string, description?: string, displayName?: string, name: string, propertyKey: string, unit?: string, value: string }): Shared_PluginDataProperty => (new Shared_PluginDataProperty(new Shared_PluginPropertyKey(parse(prop.propertyKey)), prop.name, prop.dataType, prop.value, prop.displayName, prop.unit, prop.description)), decodeAsPluginDataArray(input.fieldKey, input.objectValue)))) : Shared_FieldValue_Single(new Shared_FieldAnswer(field.FieldKey, field.Label, decodeAsString(input.fieldKey, input.objectValue)))))), field.FieldType, (matchValue_2 = field.FieldType, (matchValue_2.tag === /* Radio */ 12) ? matchValue_2.fields[0].Options : ((matchValue_2.tag === /* SingleChoice */ 13) ? matchValue_2.fields[0].Options : ((matchValue_2.tag === /* Dropdown */ 14) ? matchValue_2.fields[0].Options : ((matchValue_2.tag === /* MultiChoice */ 15) ? matchValue_2.fields[0].Options : ((matchValue_2.tag === /* CheckboxList */ 16) ? matchValue_2.fields[0].Options : ((matchValue_2.tag === /* TagList */ 17) ? matchValue_2.fields[0].Options : ((matchValue_2.tag === /* TextAutoComplete */ 18) ? matchValue_2.fields[0].Options : ((matchValue_2.tag === /* Matrix */ 19) ? matchValue_2.fields[0].Options : empty<Shared_FieldOption>())))))))))] as [Spec_FormField$1<Spec_FieldType_$union>, Values_FieldDetails$1<Spec_FieldType_$union>];
357
+ }
358
+ catch (ex: any) {
359
+ toConsole(`Error processing field ${input.fieldKey}: ${ex.message}`);
360
+ return undefined;
361
+ }
362
+ }
363
+ }, fieldData));
364
+ return new Values_DynamicFormResultData$1(resultFormSpecDetails, ofList<Values_StepOrder, FSharpMap<Shared_FieldKey, Values_FieldDetails$1<Spec_FieldType_$union>>>(map_2<Spec_FormStep$1<Spec_FieldType_$union>, [Values_StepOrder, FSharpMap<Shared_FieldKey, Values_FieldDetails$1<Spec_FieldType_$union>>]>((step: Spec_FormStep$1<Spec_FieldType_$union>): [Values_StepOrder, FSharpMap<Shared_FieldKey, Values_FieldDetails$1<Spec_FieldType_$union>>] => ([new Values_StepOrder(step.StepOrder), ofList<Shared_FieldKey, Values_FieldDetails$1<Spec_FieldType_$union>>(map_2<[Spec_FormField$1<Spec_FieldType_$union>, Values_FieldDetails$1<Spec_FieldType_$union>], [Shared_FieldKey, Values_FieldDetails$1<Spec_FieldType_$union>]>((tupledArg_1: [Spec_FormField$1<Spec_FieldType_$union>, Values_FieldDetails$1<Spec_FieldType_$union>]): [Shared_FieldKey, Values_FieldDetails$1<Spec_FieldType_$union>] => {
365
+ const fieldDetails_1: Values_FieldDetails$1<Spec_FieldType_$union> = tupledArg_1[1];
366
+ return [fieldDetails_1.Key, fieldDetails_1] as [Shared_FieldKey, Values_FieldDetails$1<Spec_FieldType_$union>];
367
+ }, filter<[Spec_FormField$1<Spec_FieldType_$union>, Values_FieldDetails$1<Spec_FieldType_$union>]>((tupledArg: [Spec_FormField$1<Spec_FieldType_$union>, Values_FieldDetails$1<Spec_FieldType_$union>]): boolean => exists<Spec_FormField$1<Spec_FieldType_$union>>((stepField: Spec_FormField$1<Spec_FieldType_$union>): boolean => equals(stepField.FieldKey, tupledArg[0].FieldKey), step.Fields), allFieldDetails)), {
368
+ Compare: compare,
369
+ })] as [Values_StepOrder, FSharpMap<Shared_FieldKey, Values_FieldDetails$1<Spec_FieldType_$union>>]), formSpec.Steps), {
370
+ Compare: compare,
371
+ }));
372
+ }
373
+
374
+ /**
375
+ * Create a checkbox field with the given parameters
376
+ * TypeScript: createCheckboxField(fieldKey: string, label: string, isOptional: boolean)
377
+ */
378
+ export function createCheckboxField(fieldKeyString: string, label: string, isOptional: boolean): Spec_FormField$1<Spec_FieldType_$union> {
379
+ return new Spec_FormField$1(1, new Shared_FieldKey(parse(fieldKeyString)), label, undefined, undefined, isOptional, false, Spec_FieldType_Checkbox(new Spec_BooleanInfo(undefined, undefined)));
380
+ }
381
+
382
+ /**
383
+ * Create a checkbox list field with options
384
+ * TypeScript: createCheckboxListField(fieldKey: string, label: string, options: {value: string, description: string, optionKey: string}[])
385
+ */
386
+ export function createCheckboxListField(fieldKeyString: string, label: string, options: { description: string, optionKey: string, value: string }[]): Spec_FormField$1<Spec_FieldType_$union> {
387
+ const fieldOptions: FSharpList<Shared_FieldOption> = ofSeq<Shared_FieldOption>(mapIndexed<{ description: string, optionKey: string, value: string }, Shared_FieldOption>((_arg: int32, opt: { description: string, optionKey: string, value: string }): Shared_FieldOption => (new Shared_FieldOption(opt.description, opt.value, new Shared_FieldOptionKey(parse(opt.optionKey)))), options));
388
+ return new Spec_FormField$1(1, new Shared_FieldKey(parse(fieldKeyString)), label, undefined, undefined, false, false, Spec_FieldType_CheckboxList(new Spec_MultiChoiceInfo(fieldOptions)));
389
+ }
390
+
391
+ /**
392
+ * Create a text field
393
+ * TypeScript: createTextField(fieldKey: string, label: string, isOptional: boolean)
394
+ */
395
+ export function createTextField(fieldKeyString: string, label: string, isOptional: boolean): Spec_FormField$1<Spec_FieldType_$union> {
396
+ return new Spec_FormField$1(1, new Shared_FieldKey(parse(fieldKeyString)), label, undefined, undefined, isOptional, false, Spec_FieldType_Text(new Spec_TextInfo(undefined)));
397
+ }
398
+
399
+ /**
400
+ * Create a form step with fields
401
+ * TypeScript: createFormStep(stepOrder: number, stepLabel: string, fields: FormField[])
402
+ */
403
+ export function createFormStep(stepOrder: int32, stepLabel: string, fields: Spec_FormField$1<Spec_FieldType_$union>[]): Spec_FormStep$1<Spec_FieldType_$union> {
404
+ return new Spec_FormStep$1(stepOrder, stepLabel, ofSeq<Spec_FormField$1<Spec_FieldType_$union>>(mapIndexed<Spec_FormField$1<Spec_FieldType_$union>, Spec_FormField$1<Spec_FieldType_$union>>((index: int32, field: Spec_FormField$1<Spec_FieldType_$union>): Spec_FormField$1<Spec_FieldType_$union> => (new Spec_FormField$1(index + 1, field.FieldKey, field.Label, field.Notes, field.DependsOn, field.IsOptional, field.IsDeprecated, field.FieldType)), fields)));
405
+ }
406
+
407
+ /**
408
+ * Create a FormSpec with basic information
409
+ * TypeScript: createFormSpec(id: string, title: string, steps: FormStep[])
410
+ */
411
+ export function createFormSpec(idString: string, title: string, steps: Spec_FormStep$1<Spec_FieldType_$union>[]): Spec_FormSpec$1<Spec_FieldType_$union> {
412
+ return new Spec_FormSpec$1(parse(idString), "DYN", title, "Dynamically created FormSpec", "1.0.0", "2.0.5", ofSeq<Spec_FormStep$1<Spec_FieldType_$union>>(steps), empty<string>(), undefined, empty<string>(), false, false, undefined);
413
+ }
414
+
415
+ /**
416
+ * Create a field option
417
+ * TypeScript: createFieldOption(description: string, value: string, optionKey: string)
418
+ */
419
+ export function createFieldOption(description: string, value: string, optionKeyString: string): Shared_FieldOption {
420
+ return new Shared_FieldOption(description, value, new Shared_FieldOptionKey(parse(optionKeyString)));
421
+ }
422
+
423
+ /**
424
+ * Create a matrix field
425
+ * TypeScript: createMatrixField(fieldKey: string, label: string, items: FieldOption[], options: FieldOption[])
426
+ */
427
+ export function createMatrixField(fieldKeyString: string, label: string, items: Shared_FieldOption[], options: Shared_FieldOption[]): Spec_FormField$1<Spec_FieldType_$union> {
428
+ return new Spec_FormField$1(1, new Shared_FieldKey(parse(fieldKeyString)), label, undefined, undefined, false, false, Spec_FieldType_Matrix(new Spec_MatrixInfo(ofSeq<Shared_FieldOption>(items), ofSeq<Shared_FieldOption>(options))));
429
+ }
430
+
431
+ /**
432
+ * Create a plugin field
433
+ * TypeScript: createPluginField(fieldKey: string, label: string, config: {pluginId: string, fieldName: string})
434
+ */
435
+ export function createPluginField(fieldKeyString: string, label: string, config: { fieldName: string, pluginId: string }): Spec_FormField$1<Spec_FieldType_$union> {
436
+ return new Spec_FormField$1(1, new Shared_FieldKey(parse(fieldKeyString)), label, undefined, undefined, false, false, Spec_FieldType_PluginField(new Spec_PluginFieldConfig(config.pluginId, config.fieldName)));
437
+ }
438
+
439
+ /**
440
+ * Create an action state that executes a task
441
+ * TypeScript: createActionState(stateKey: string, label: string, taskDescription: string, priority?: string)
442
+ */
443
+ export function createActionState(stateKeyString: string, label: string, taskDescription: string, priority: Option<string>): ClinicalPathway_StateDefinition {
444
+ return new ClinicalPathway_StateDefinition(new Shared_StateKey(parse(stateKeyString)), label, 1, ClinicalPathway_StateType_Action(ClinicalPathway_ActionInfo_Task(new ClinicalPathway_TaskAction("Clinical", taskDescription, (priority != null) ? ((value_11(priority) === "High") ? ClinicalPathway_TaskPriority_High() : ((value_11(priority) === "Low") ? ClinicalPathway_TaskPriority_Low() : ClinicalPathway_TaskPriority_Medium())) : ClinicalPathway_TaskPriority_Medium(), ClinicalPathway_DueDate_Today(), "Clinical Staff", undefined))), undefined);
445
+ }
446
+
447
+ /**
448
+ * Create a terminal state that ends the pathway
449
+ * TypeScript: createTerminalState(stateKey: string, outcome: string)
450
+ */
451
+ export function createTerminalState(stateKeyString: string, outcome: string): ClinicalPathway_StateDefinition {
452
+ return new ClinicalPathway_StateDefinition(new Shared_StateKey(parse(stateKeyString)), outcome, 1, ClinicalPathway_StateType_Terminal(new ClinicalPathway_TerminalInfo("Complete", outcome, undefined)), undefined);
453
+ }
454
+
455
+ /**
456
+ * Create a transition between states based on field condition
457
+ * TypeScript: createTransition(transitionKey: string, fromState: string, toState: string, fieldKey: string, expectedValue: string)
458
+ */
459
+ export function createTransition(transitionKeyString: string, fromStateString: string, toStateString: string, fieldKeyString: string, expectedValue: string): ClinicalPathway_TransitionDefinition {
460
+ return new ClinicalPathway_TransitionDefinition(new Shared_TransitionKey(parse(transitionKeyString)), new Shared_StateKey(parse(fromStateString)), new Shared_StateKey(parse(toStateString)), ClinicalPathway_TransitionCondition_FieldCondition(new Shared_FieldKey(parse(fieldKeyString)), ClinicalPathway_FieldEvaluator_Equals(), Shared_ConditionValue_Single(expectedValue)), undefined);
461
+ }
462
+
463
+ /**
464
+ * Create a clinical pathway with states and transitions
465
+ * TypeScript: createClinicalPathway(name: string, states: StateDefinition[], transitions: TransitionDefinition[])
466
+ */
467
+ export function createClinicalPathway(name: string, states: ClinicalPathway_StateDefinition[], transitions: ClinicalPathway_TransitionDefinition[]): ClinicalPathway_ClinicalPathwaySpec {
468
+ let copyOfStruct: string;
469
+ const statesWithOrder: FSharpList<ClinicalPathway_StateDefinition> = ofSeq<ClinicalPathway_StateDefinition>(mapIndexed<ClinicalPathway_StateDefinition, ClinicalPathway_StateDefinition>((index: int32, state: ClinicalPathway_StateDefinition): ClinicalPathway_StateDefinition => (new ClinicalPathway_StateDefinition(state.StateKey, state.StateLabel, index + 1, state.StateType, state.DependsOn)), states));
470
+ return new ClinicalPathway_ClinicalPathwaySpec((copyOfStruct = newGuid(), copyOfStruct), name, "1.0.0", "Dynamic Builder", ClinicalPathway_PathwayExecutionMode_SinglePathway(new ClinicalPathway_SinglePathwayConfig(ClinicalPathway_SelectionStrategy_HighestPriority(), true)), new Shared_StateKey("00000000-0000-0000-0000-000000000001"), statesWithOrder, ofSeq<ClinicalPathway_TransitionDefinition>(transitions), empty<ClinicalPathway_ConstraintDefinition>(), empty<ClinicalPathway_PathRequirement>(), now(), undefined, undefined, undefined);
471
+ }
472
+
473
+ /**
474
+ * Add a clinical pathway to an existing FormSpec
475
+ * TypeScript: addPathwayToFormSpec(formSpec: FormSpec, pathway: ClinicalPathwaySpec)
476
+ */
477
+ export function addPathwayToFormSpec(formSpec: Spec_FormSpec$1<Spec_FieldType_$union>, pathway: ClinicalPathway_ClinicalPathwaySpec): Spec_FormSpec$1<Spec_FieldType_$union> {
478
+ return new Spec_FormSpec$1(formSpec.Id, formSpec.Code, formSpec.Title, formSpec.Abstract, formSpec.Version, formSpec.FormSpecVersion, formSpec.Steps, formSpec.CategoryTags, formSpec.Score, formSpec.AssociatedCodes, formSpec.RequiresReview, formSpec.RequiresReviewAndApproval, pathway);
479
+ }
480
+
481
+ /**
482
+ * Extract form field data from DynamicFormResultData in TypeScript-friendly format
483
+ * TypeScript: getFieldDataFromFormResult(formData: DynamicFormResultData, stepOrder: number, fieldKey: string)
484
+ */
485
+ export function getFieldDataFromFormResult(formData: Values_DynamicFormResultData$1<Spec_FieldType_$union>, stepOrder: int32, fieldKeyString: string): Option<any> {
486
+ const fieldKey: Shared_FieldKey = new Shared_FieldKey(parse(fieldKeyString));
487
+ const matchValue: Option<FSharpMap<Shared_FieldKey, Values_FieldDetails$1<Spec_FieldType_$union>>> = tryFind_1<Values_StepOrder, FSharpMap<Shared_FieldKey, Values_FieldDetails$1<Spec_FieldType_$union>>>(new Values_StepOrder(stepOrder), formData.ResultSteps);
488
+ if (matchValue == null) {
489
+ return undefined;
490
+ }
491
+ else {
492
+ const matchValue_1: Option<Values_FieldDetails$1<Spec_FieldType_$union>> = tryFind_1<Shared_FieldKey, Values_FieldDetails$1<Spec_FieldType_$union>>(fieldKey, value_11(matchValue));
493
+ if (matchValue_1 == null) {
494
+ return undefined;
495
+ }
496
+ else {
497
+ const fieldDetails: Values_FieldDetails$1<Spec_FieldType_$union> = value_11(matchValue_1);
498
+ return some({
499
+ FieldOrder: fieldDetails.FieldOrder,
500
+ FieldType: fieldDetails.FieldType,
501
+ FieldValue: fieldDetails.FieldValue,
502
+ Key: fieldKeyString,
503
+ Label: fieldDetails.Label,
504
+ });
505
+ }
506
+ }
507
+ }
508
+
509
+ /**
510
+ * Get all step orders from DynamicFormResultData
511
+ * TypeScript: getFormResultStepOrders(formData: DynamicFormResultData)
512
+ */
513
+ export function getFormResultStepOrders(formData: Values_DynamicFormResultData$1<Spec_FieldType_$union>): int32[] {
514
+ const collection: Iterable<int32> = map_1<[Values_StepOrder, FSharpMap<Shared_FieldKey, Values_FieldDetails$1<Spec_FieldType_$union>>], int32>((tupledArg: [Values_StepOrder, FSharpMap<Shared_FieldKey, Values_FieldDetails$1<Spec_FieldType_$union>>]): int32 => tupledArg[0].fields[0], toSeq<Values_StepOrder, FSharpMap<Shared_FieldKey, Values_FieldDetails$1<Spec_FieldType_$union>>>(formData.ResultSteps));
515
+ return Array.from(collection);
516
+ }
517
+
518
+ /**
519
+ * Get all field keys for a specific step from DynamicFormResultData
520
+ * TypeScript: getFormResultFieldKeys(formData: DynamicFormResultData, stepOrder: number)
521
+ */
522
+ export function getFormResultFieldKeys(formData: Values_DynamicFormResultData$1<Spec_FieldType_$union>, stepOrder: int32): string[] {
523
+ const matchValue: Option<FSharpMap<Shared_FieldKey, Values_FieldDetails$1<Spec_FieldType_$union>>> = tryFind_1<Values_StepOrder, FSharpMap<Shared_FieldKey, Values_FieldDetails$1<Spec_FieldType_$union>>>(new Values_StepOrder(stepOrder), formData.ResultSteps);
524
+ if (matchValue == null) {
525
+ return [];
526
+ }
527
+ else {
528
+ const collection: Iterable<string> = map_1<Shared_FieldKey, string>((_arg: Shared_FieldKey): string => _arg.fields[0], map_1<[Shared_FieldKey, Values_FieldDetails$1<Spec_FieldType_$union>], Shared_FieldKey>((tuple: [Shared_FieldKey, Values_FieldDetails$1<Spec_FieldType_$union>]): Shared_FieldKey => tuple[0], toSeq<Shared_FieldKey, Values_FieldDetails$1<Spec_FieldType_$union>>(value_11(matchValue))));
529
+ return Array.from(collection);
530
+ }
531
+ }
532
+
533
+ /**
534
+ * Get the ResultSteps as a TypeScript-friendly structure
535
+ * TypeScript: getResultSteps(formResult: DynamicFormResultData)
536
+ */
537
+ export function getResultSteps(formData: Values_DynamicFormResultData$1<Spec_FieldType_$union>): any {
538
+ return formData.ResultSteps;
539
+ }
540
+
541
+ /**
542
+ * Get a specific field value from the result
543
+ * TypeScript: getFieldValue(formResult: DynamicFormResultData, stepOrder: number, fieldKey: string)
544
+ */
545
+ export function getFieldValue(formData: Values_DynamicFormResultData$1<Spec_FieldType_$union>, stepOrder: int32, fieldKeyString: string): Option<any> {
546
+ const fieldKey: Shared_FieldKey = new Shared_FieldKey(parse(fieldKeyString));
547
+ const matchValue: Option<FSharpMap<Shared_FieldKey, Values_FieldDetails$1<Spec_FieldType_$union>>> = tryFind_1<Values_StepOrder, FSharpMap<Shared_FieldKey, Values_FieldDetails$1<Spec_FieldType_$union>>>(new Values_StepOrder(stepOrder), formData.ResultSteps);
548
+ if (matchValue == null) {
549
+ return undefined;
550
+ }
551
+ else {
552
+ const matchValue_1: Option<Values_FieldDetails$1<Spec_FieldType_$union>> = tryFind_1<Shared_FieldKey, Values_FieldDetails$1<Spec_FieldType_$union>>(fieldKey, value_11(matchValue));
553
+ if (matchValue_1 == null) {
554
+ return undefined;
555
+ }
556
+ else {
557
+ return some(value_11(matchValue_1).FieldValue);
558
+ }
559
+ }
560
+ }
561
+
562
+ /**
563
+ * Get complete field details from the result
564
+ * TypeScript: getFieldDetails(formResult: DynamicFormResultData, stepOrder: number, fieldKey: string)
565
+ */
566
+ export function getFieldDetails(formData: Values_DynamicFormResultData$1<Spec_FieldType_$union>, stepOrder: int32, fieldKeyString: string): Option<any> {
567
+ const fieldKey: Shared_FieldKey = new Shared_FieldKey(parse(fieldKeyString));
568
+ const matchValue: Option<FSharpMap<Shared_FieldKey, Values_FieldDetails$1<Spec_FieldType_$union>>> = tryFind_1<Values_StepOrder, FSharpMap<Shared_FieldKey, Values_FieldDetails$1<Spec_FieldType_$union>>>(new Values_StepOrder(stepOrder), formData.ResultSteps);
569
+ if (matchValue == null) {
570
+ return undefined;
571
+ }
572
+ else {
573
+ const matchValue_1: Option<Values_FieldDetails$1<Spec_FieldType_$union>> = tryFind_1<Shared_FieldKey, Values_FieldDetails$1<Spec_FieldType_$union>>(fieldKey, value_11(matchValue));
574
+ if (matchValue_1 == null) {
575
+ return undefined;
576
+ }
577
+ else {
578
+ return some(value_11(matchValue_1));
579
+ }
580
+ }
581
+ }
582
+
583
+ /**
584
+ * Create a complete test FormSpec for buildDynamicFormResultData testing
585
+ * TypeScript: createTestFormSpec()
586
+ */
587
+ export function createTestFormSpec(): Spec_FormSpec$1<Spec_FieldType_$union> {
588
+ const option1: Shared_FieldOption = new Shared_FieldOption("Option 1", "opt1", new Shared_FieldOptionKey(newGuid()));
589
+ const option2: Shared_FieldOption = new Shared_FieldOption("Option 2", "opt2", new Shared_FieldOptionKey(newGuid()));
590
+ const testStep: Spec_FormStep$1<Spec_FieldType_$union> = new Spec_FormStep$1(1, "Test Step", ofArray_1([new Spec_FormField$1(1, new Shared_FieldKey("11111111-1111-1111-1111-111111111111"), "Test Text Field", undefined, undefined, false, false, Spec_FieldType_Text(new Spec_TextInfo(undefined))), new Spec_FormField$1(2, new Shared_FieldKey("22222222-2222-2222-2222-222222222222"), "Test Checkbox List", undefined, undefined, false, false, Spec_FieldType_CheckboxList(new Spec_MultiChoiceInfo(ofArray_1([option1, option2])))), new Spec_FormField$1(3, new Shared_FieldKey("33333333-3333-3333-3333-333333333333"), "Test Matrix", undefined, undefined, false, false, Spec_FieldType_Matrix(new Spec_MatrixInfo(ofArray_1([option1, option2]), ofArray_1([new Shared_FieldOption("Scale 1", "1", new Shared_FieldOptionKey(newGuid())), new Shared_FieldOption("Scale 2", "2", new Shared_FieldOptionKey(newGuid()))])))), new Spec_FormField$1(4, new Shared_FieldKey("44444444-4444-4444-4444-444444444444"), "Test Plugin Field", undefined, undefined, false, false, Spec_FieldType_PluginField(new Spec_PluginFieldConfig("test.plugin", "Test Plugin")))]));
591
+ return new Spec_FormSpec$1(newGuid(), "TEST-001", "Test Form", "Test form for buildDynamicFormResultData", "1.0.0", "5.0.0", singleton(testStep), empty<string>(), undefined, empty<string>(), false, false, undefined);
592
+ }
593
+
594
+ /**
595
+ * Safe pathway execution initialization wrapper
596
+ * TypeScript: initializePathwayExecution(formSpec: FormSpec, pathway: ClinicalPathwaySpec, formData: DynamicFormResultData)
597
+ */
598
+ export function initializePathwayExecution(formSpec: Spec_FormSpec$1<Spec_FieldType_$union>, pathway: ClinicalPathway_ClinicalPathwaySpec, formData: Values_DynamicFormResultData$1<Spec_FieldType_$union>): any {
599
+ try {
600
+ return initializeExecution<Spec_FieldType_$union>(formSpec, formData);
601
+ }
602
+ catch (ex: any) {
603
+ return {
604
+ ErrorMessage: ex.message,
605
+ ErrorType: "Exception",
606
+ IsError: true,
607
+ };
608
+ }
609
+ }
610
+
611
+ /**
612
+ * Get field type information in TypeScript-friendly format
613
+ * TypeScript: getFieldTypeInfo(field: FormField) => {typeName: string, isRequired: boolean}
614
+ */
615
+ export function getFieldTypeInfo(field: Spec_FormField$1<Spec_FieldType_$union>): { isRequired: boolean, typeName: string } {
616
+ let matchValue: Spec_FieldType_$union;
617
+ return {
618
+ isRequired: !field.IsOptional,
619
+ typeName: (matchValue = field.FieldType, (matchValue.tag === /* TextArea */ 1) ? "TextArea" : ((matchValue.tag === /* Email */ 2) ? "Email" : ((matchValue.tag === /* Password */ 3) ? "Password" : ((matchValue.tag === /* Search */ 4) ? "Search" : ((matchValue.tag === /* Color */ 5) ? "Color" : ((matchValue.tag === /* Number */ 6) ? "Number" : ((matchValue.tag === /* Tel */ 7) ? "Tel" : ((matchValue.tag === /* Date */ 8) ? "Date" : ((matchValue.tag === /* DateTimeLocal */ 9) ? "DateTimeLocal" : ((matchValue.tag === /* Time */ 10) ? "Time" : ((matchValue.tag === /* Checkbox */ 11) ? "Checkbox" : ((matchValue.tag === /* Radio */ 12) ? "Radio" : ((matchValue.tag === /* SingleChoice */ 13) ? "SingleChoice" : ((matchValue.tag === /* Dropdown */ 14) ? "Dropdown" : ((matchValue.tag === /* TextAutoComplete */ 18) ? "TextAutoComplete" : ((matchValue.tag === /* MultiChoice */ 15) ? "MultiChoice" : ((matchValue.tag === /* CheckboxList */ 16) ? "CheckboxList" : ((matchValue.tag === /* TagList */ 17) ? "TagList" : ((matchValue.tag === /* Matrix */ 19) ? "Matrix" : ((matchValue.tag === /* Signature */ 20) ? "Signature" : ((matchValue.tag === /* Message */ 21) ? "Message" : ((matchValue.tag === /* PluginField */ 22) ? "PluginField" : "Text")))))))))))))))))))))),
620
+ };
621
+ }
622
+
623
+ /**
624
+ * Extract choice options from fields that support them
625
+ * TypeScript: getFieldChoiceOptions(field: FormField) => {key: string, label: string, value: string}[] | null
626
+ */
627
+ export function getFieldChoiceOptions(field: Spec_FormField$1<Spec_FieldType_$union>): Option<{ key: string, label: string, value: string }[]> {
628
+ let collection: FSharpList<{ key: string, label: string, value: string }>, collection_1: FSharpList<{ key: string, label: string, value: string }>, collection_2: FSharpList<{ key: string, label: string, value: string }>, collection_3: FSharpList<{ key: string, label: string, value: string }>, collection_4: FSharpList<{ key: string, label: string, value: string }>, collection_5: FSharpList<{ key: string, label: string, value: string }>, collection_6: FSharpList<{ key: string, label: string, value: string }>;
629
+ const matchValue: Spec_FieldType_$union = field.FieldType;
630
+ switch (matchValue.tag) {
631
+ case /* Radio */ 12:
632
+ return (collection = map_2<Shared_FieldOption, { key: string, label: string, value: string }>((opt: Shared_FieldOption): { key: string, label: string, value: string } => ({
633
+ key: opt.OptionKey.fields[0],
634
+ label: opt.Description,
635
+ value: opt.Value,
636
+ }), matchValue.fields[0].Options), Array.from(collection));
637
+ case /* SingleChoice */ 13:
638
+ return (collection_1 = map_2<Shared_FieldOption, { key: string, label: string, value: string }>((opt_1: Shared_FieldOption): { key: string, label: string, value: string } => ({
639
+ key: opt_1.OptionKey.fields[0],
640
+ label: opt_1.Description,
641
+ value: opt_1.Value,
642
+ }), matchValue.fields[0].Options), Array.from(collection_1));
643
+ case /* Dropdown */ 14:
644
+ return (collection_2 = map_2<Shared_FieldOption, { key: string, label: string, value: string }>((opt_2: Shared_FieldOption): { key: string, label: string, value: string } => ({
645
+ key: opt_2.OptionKey.fields[0],
646
+ label: opt_2.Description,
647
+ value: opt_2.Value,
648
+ }), matchValue.fields[0].Options), Array.from(collection_2));
649
+ case /* MultiChoice */ 15:
650
+ return (collection_3 = map_2<Shared_FieldOption, { key: string, label: string, value: string }>((opt_3: Shared_FieldOption): { key: string, label: string, value: string } => ({
651
+ key: opt_3.OptionKey.fields[0],
652
+ label: opt_3.Description,
653
+ value: opt_3.Value,
654
+ }), matchValue.fields[0].Options), Array.from(collection_3));
655
+ case /* CheckboxList */ 16:
656
+ return (collection_4 = map_2<Shared_FieldOption, { key: string, label: string, value: string }>((opt_4: Shared_FieldOption): { key: string, label: string, value: string } => ({
657
+ key: opt_4.OptionKey.fields[0],
658
+ label: opt_4.Description,
659
+ value: opt_4.Value,
660
+ }), matchValue.fields[0].Options), Array.from(collection_4));
661
+ case /* TagList */ 17:
662
+ return (collection_5 = map_2<Shared_FieldOption, { key: string, label: string, value: string }>((opt_5: Shared_FieldOption): { key: string, label: string, value: string } => ({
663
+ key: opt_5.OptionKey.fields[0],
664
+ label: opt_5.Description,
665
+ value: opt_5.Value,
666
+ }), matchValue.fields[0].Options), Array.from(collection_5));
667
+ case /* TextAutoComplete */ 18:
668
+ return (collection_6 = map_2<Shared_FieldOption, { key: string, label: string, value: string }>((opt_6: Shared_FieldOption): { key: string, label: string, value: string } => ({
669
+ key: opt_6.OptionKey.fields[0],
670
+ label: opt_6.Description,
671
+ value: opt_6.Value,
672
+ }), matchValue.fields[0].Options), Array.from(collection_6));
673
+ default:
674
+ return undefined;
675
+ }
676
+ }
677
+
678
+ /**
679
+ * Extract matrix field structure (items and options)
680
+ * TypeScript: getFieldMatrixInfo(field: FormField) => {items: {key: string, label: string}[], options: {key: string, description: string, value: string}[]} | null
681
+ */
682
+ export function getFieldMatrixInfo(field: Spec_FormField$1<Spec_FieldType_$union>): Option<{ items: { key: string, label: string }[], options: { description: string, key: string, value: string }[] }> {
683
+ let collection: FSharpList<{ key: string, label: string }>, collection_1: FSharpList<{ description: string, key: string, value: string }>;
684
+ const matchValue: Spec_FieldType_$union = field.FieldType;
685
+ if (matchValue.tag === /* Matrix */ 19) {
686
+ const matrixInfo: Spec_MatrixInfo = matchValue.fields[0];
687
+ return {
688
+ items: (collection = map_2<Shared_FieldOption, { key: string, label: string }>((item: Shared_FieldOption): { key: string, label: string } => ({
689
+ key: item.OptionKey.fields[0],
690
+ label: item.Description,
691
+ }), matrixInfo.Items), Array.from(collection)),
692
+ options: (collection_1 = map_2<Shared_FieldOption, { description: string, key: string, value: string }>((opt: Shared_FieldOption): { description: string, key: string, value: string } => ({
693
+ description: opt.Description,
694
+ key: opt.OptionKey.fields[0],
695
+ value: opt.Value,
696
+ }), matrixInfo.Options), Array.from(collection_1)),
697
+ };
698
+ }
699
+ else {
700
+ return undefined;
701
+ }
702
+ }
703
+
704
+ /**
705
+ * Extract GUID string from FieldKey (single-case DU)
706
+ * TypeScript: getFieldKeyString(fieldKey: FieldKey) => string
707
+ */
708
+ export function getFieldKeyString(fieldKey: Shared_FieldKey): string {
709
+ return fieldKey.fields[0];
710
+ }
711
+
712
+ /**
713
+ * Convert ClinicalPathway ActionInfo to TypeScript-friendly objects
714
+ * TypeScript: convertActionInfo(action: ActionInfo) => {type: string, description: string, ...}
715
+ */
716
+ export function convertActionInfo(action: ClinicalPathway_ActionInfo_$union): any {
717
+ let matchValue_1: ClinicalPathway_ReferralUrgency_$union, matchValue_3: ClinicalPathway_AlertSeverity_$union, matchValue: ClinicalPathway_TaskPriority_$union;
718
+ switch (action.tag) {
719
+ case /* Referral */ 2: {
720
+ const referral: ClinicalPathway_ReferralAction = action.fields[0];
721
+ return {
722
+ description: `Refer to ${referral.Target}`,
723
+ reason: referral.Reason,
724
+ type: "referral",
725
+ urgency: (matchValue_1 = referral.Urgency, (matchValue_1.tag === /* Routine */ 1) ? (`routine-${matchValue_1.fields[0]}`) : ((matchValue_1.tag === /* AsNeeded */ 2) ? "asNeeded" : "immediate")),
726
+ };
727
+ }
728
+ case /* Medication */ 0: {
729
+ const med: ClinicalPathway_MedicationAction = action.fields[0];
730
+ return {
731
+ description: `${med.Name} - ${med.Dose} ${med.Route}`,
732
+ dose: med.Dose,
733
+ duration: med.Duration,
734
+ frequency: med.Frequency,
735
+ medicationName: med.Name,
736
+ route: med.Route,
737
+ type: "medication",
738
+ };
739
+ }
740
+ case /* Prescription */ 9: {
741
+ const presc: ClinicalPathway_PrescriptionAction = action.fields[0];
742
+ return {
743
+ description: `${presc.Medication} - ${presc.Dose} ${presc.Route}`,
744
+ dose: presc.Dose,
745
+ duration: presc.Duration,
746
+ frequency: presc.Frequency,
747
+ medication: presc.Medication,
748
+ quantity: presc.Quantity,
749
+ route: presc.Route,
750
+ type: "prescription",
751
+ };
752
+ }
753
+ case /* SetFieldValue */ 10: {
754
+ const setField: ClinicalPathway_SetFieldValueAction = action.fields[0];
755
+ let valueStr: string;
756
+ const matchValue_2: ClinicalPathway_FieldValueSource_$union = setField.Value;
757
+ valueStr = ((matchValue_2.tag === /* FieldReference */ 1) ? (`Reference to ${matchValue_2.fields[0].fields[0]}`) : ((matchValue_2.tag === /* OptionKey */ 2) ? (`Option ${matchValue_2.fields[0].fields[0]}`) : matchValue_2.fields[0]));
758
+ const fieldGuid: string = setField.TargetField.fields[0];
759
+ return {
760
+ description: `Set field ${fieldGuid} to ${valueStr}`,
761
+ fieldKey: fieldGuid,
762
+ type: "setFieldValue",
763
+ value: valueStr,
764
+ };
765
+ }
766
+ case /* Documentation */ 5: {
767
+ const doc: ClinicalPathway_DocumentationAction = action.fields[0];
768
+ return {
769
+ description: `Document: ${doc.FormName}`,
770
+ formName: doc.FormName,
771
+ purpose: doc.Purpose,
772
+ required: doc.Required,
773
+ type: "documentation",
774
+ };
775
+ }
776
+ case /* Test */ 1: {
777
+ const test: ClinicalPathway_TestAction = action.fields[0];
778
+ return {
779
+ description: `${test.TestName} (${test.TestType})`,
780
+ testName: test.TestName,
781
+ testType: test.TestType,
782
+ type: "test",
783
+ };
784
+ }
785
+ case /* Procedure */ 4: {
786
+ const proc: ClinicalPathway_ProcedureAction = action.fields[0];
787
+ return {
788
+ description: `${proc.Name}: ${proc.Description}`,
789
+ procedureDescription: proc.Description,
790
+ procedureName: proc.Name,
791
+ type: "procedure",
792
+ };
793
+ }
794
+ case /* Education */ 3: {
795
+ const edu: ClinicalPathway_EducationAction = action.fields[0];
796
+ return {
797
+ description: `Education: ${join(", ", edu.Topics)}`,
798
+ topics: edu.Topics,
799
+ type: "education",
800
+ };
801
+ }
802
+ case /* Alert */ 7: {
803
+ const alert: ClinicalPathway_AlertAction = action.fields[0];
804
+ return {
805
+ category: alert.Category,
806
+ description: alert.Message,
807
+ severity: (matchValue_3 = alert.Severity, (matchValue_3.tag === /* High */ 2) ? "high" : ((matchValue_3.tag === /* Medium */ 1) ? "medium" : ((matchValue_3.tag === /* Low */ 0) ? "low" : "critical"))),
808
+ type: "alert",
809
+ };
810
+ }
811
+ case /* Problem */ 8: {
812
+ const prob: ClinicalPathway_ProblemAction = action.fields[0];
813
+ return {
814
+ description: `${prob.ProblemName}${defaultArg_1(map_3<string, string>((code: string): string => (` (ICD: ${code})`), prob.IcdCode), "")}`,
815
+ icdCode: unwrap(prob.IcdCode),
816
+ problemName: prob.ProblemName,
817
+ type: "problem",
818
+ };
819
+ }
820
+ case /* NavigateToForm */ 11: {
821
+ const nav: ClinicalPathway_NavigateToFormAction = action.fields[0];
822
+ const formCode: string = defaultArg_1(nav.FormCode, nav.FormId);
823
+ return {
824
+ description: `Navigate to form: ${formCode}`,
825
+ formCode: formCode,
826
+ type: "navigateToForm",
827
+ };
828
+ }
829
+ default: {
830
+ const task: ClinicalPathway_TaskAction = action.fields[0];
831
+ return {
832
+ category: task.Category,
833
+ description: task.Description,
834
+ priority: (matchValue = task.Priority, (matchValue.tag === /* Medium */ 1) ? "medium" : ((matchValue.tag === /* Low */ 2) ? "low" : "high")),
835
+ type: "task",
836
+ };
837
+ }
838
+ }
839
+ }
840
+
841
+ /**
842
+ * Find the StateKey for a given ActionInfo in a ClinicalPathwaySpec
843
+ * TypeScript: stateKeyForAction(pathway: ClinicalPathwaySpec, action: ActionInfo) => string | null
844
+ */
845
+ export function stateKeyForAction(pathway: ClinicalPathway_ClinicalPathwaySpec, action: ClinicalPathway_ActionInfo_$union): Option<string> {
846
+ toConsole(printf("PathwayId: %A"))(pathway.PathwayId);
847
+ toConsole(printf("Finding state key for action: %A"))(action);
848
+ return tryPick<ClinicalPathway_StateDefinition, string>((state: ClinicalPathway_StateDefinition): Option<string> => {
849
+ const matchValue: ClinicalPathway_StateType_$union = state.StateType;
850
+ let matchResult: int32, actionInfo_1: ClinicalPathway_ActionInfo_$union;
851
+ if (matchValue.tag === /* Action */ 2) {
852
+ if (equals(matchValue.fields[0], action)) {
853
+ matchResult = 0;
854
+ actionInfo_1 = matchValue.fields[0];
855
+ }
856
+ else {
857
+ matchResult = 1;
858
+ }
859
+ }
860
+ else {
861
+ matchResult = 1;
862
+ }
863
+ switch (matchResult) {
864
+ case 0:
865
+ return state.StateKey.fields[0];
866
+ default:
867
+ return undefined;
868
+ }
869
+ }, pathway.States);
870
+ }
871
+
872
+ //# sourceMappingURL=FormSpec.Api.Helpers.ts.map