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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (186) hide show
  1. package/FormSpec.FS/BlueprintValidation.d.ts +6 -3
  2. package/FormSpec.FS/BlueprintValidation.d.ts.map +1 -1
  3. package/FormSpec.FS/BlueprintValidation.js +39 -15
  4. package/FormSpec.FS/BlueprintValidation.js.map +1 -1
  5. package/FormSpec.FS/Designer.d.ts.map +1 -1
  6. package/FormSpec.FS/Designer.js +1 -1
  7. package/FormSpec.FS/Designer.js.map +1 -1
  8. package/FormSpec.FS/FormSpec.d.ts +108 -58
  9. package/FormSpec.FS/FormSpec.d.ts.map +1 -1
  10. package/FormSpec.FS/FormSpec.js +319 -129
  11. package/FormSpec.FS/FormSpec.js.map +1 -1
  12. package/FormSpec.FS/FormSpecHelpers.d.ts.map +1 -1
  13. package/FormSpec.FS/FormSpecHelpers.js +1 -1
  14. package/FormSpec.FS/FormSpecHelpers.js.map +1 -1
  15. package/FormSpec.FS/FormSpecValues.d.ts.map +1 -1
  16. package/FormSpec.FS/FormSpecValues.js +5 -2
  17. package/FormSpec.FS/FormSpecValues.js.map +1 -1
  18. package/FormSpec.FS/Helpers.d.ts.map +1 -1
  19. package/FormSpec.FS/Helpers.js +14 -9
  20. package/FormSpec.FS/Helpers.js.map +1 -1
  21. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRFieldTypeMapper.d.ts.map +1 -1
  22. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRFieldTypeMapper.js +1 -1
  23. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRFieldTypeMapper.js.map +1 -1
  24. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRFormSpecValidator.d.ts +1 -1
  25. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRFormSpecValidator.d.ts.map +1 -1
  26. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRFormSpecValidator.js +1 -1
  27. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRFormSpecValidator.js.map +1 -1
  28. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRSectioning.d.ts +3 -3
  29. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRSectioning.d.ts.map +1 -1
  30. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRSectioning.js +7 -5
  31. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRSectioning.js.map +1 -1
  32. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRSemanticReportBuilder.d.ts.map +1 -1
  33. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRSemanticReportBuilder.js +11 -10
  34. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRSemanticReportBuilder.js.map +1 -1
  35. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRStepsBuilder.d.ts.map +1 -1
  36. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRStepsBuilder.js +1 -9
  37. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRStepsBuilder.js.map +1 -1
  38. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateMapper.d.ts +11 -4
  39. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateMapper.d.ts.map +1 -1
  40. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateMapper.js +30 -28
  41. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateMapper.js.map +1 -1
  42. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateToFormSpec.d.ts +3 -9
  43. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateToFormSpec.d.ts.map +1 -1
  44. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateToFormSpec.js +4 -31
  45. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateToFormSpec.js.map +1 -1
  46. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMREncoder.d.ts.map +1 -1
  47. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMREncoder.js +2 -6
  48. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMREncoder.js.map +1 -1
  49. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRImportPipeline.d.ts +45 -0
  50. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRImportPipeline.d.ts.map +1 -0
  51. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRImportPipeline.js +141 -0
  52. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRImportPipeline.js.map +1 -0
  53. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRImporterAnalysis.d.ts +326 -0
  54. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRImporterAnalysis.d.ts.map +1 -0
  55. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRImporterAnalysis.js +1743 -0
  56. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRImporterAnalysis.js.map +1 -0
  57. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRSourceMap.d.ts +8 -8
  58. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRSourceMap.d.ts.map +1 -1
  59. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRSourceMap.js +6 -6
  60. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRSourceMap.js.map +1 -1
  61. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRTriggerEnrichment.d.ts +21 -15
  62. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRTriggerEnrichment.d.ts.map +1 -1
  63. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRTriggerEnrichment.js +83 -80
  64. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRTriggerEnrichment.js.map +1 -1
  65. package/FormSpec.FS/Integrations/CorEMR/CoreMRPathwayMapper.d.ts +51 -0
  66. package/FormSpec.FS/Integrations/CorEMR/CoreMRPathwayMapper.d.ts.map +1 -0
  67. package/FormSpec.FS/Integrations/CorEMR/CoreMRPathwayMapper.js +939 -0
  68. package/FormSpec.FS/Integrations/CorEMR/CoreMRPathwayMapper.js.map +1 -0
  69. package/FormSpec.FS/Integrations/CorEMR/CoreMRTypes.d.ts +2 -17
  70. package/FormSpec.FS/Integrations/CorEMR/CoreMRTypes.d.ts.map +1 -1
  71. package/FormSpec.FS/Integrations/CorEMR/CoreMRTypes.js +1 -66
  72. package/FormSpec.FS/Integrations/CorEMR/{TemplateManifestDecoder.d.ts → FormTemplateDecoder.d.ts} +53 -45
  73. package/FormSpec.FS/Integrations/CorEMR/FormTemplateDecoder.d.ts.map +1 -0
  74. package/FormSpec.FS/Integrations/CorEMR/{TemplateManifestDecoder.js → FormTemplateDecoder.js} +544 -254
  75. package/FormSpec.FS/Integrations/CorEMR/FormTemplateDecoder.js.map +1 -0
  76. package/FormSpec.FS/Integrations/CorEMR/FormTemplateDomainDecoder.d.ts +7 -0
  77. package/FormSpec.FS/Integrations/CorEMR/FormTemplateDomainDecoder.d.ts.map +1 -0
  78. package/FormSpec.FS/Integrations/CorEMR/FormTemplateDomainDecoder.js +280 -0
  79. package/FormSpec.FS/Integrations/CorEMR/FormTemplateDomainDecoder.js.map +1 -0
  80. package/FormSpec.FS/Interop/FormSpec.Api.Helpers.d.ts +16 -4
  81. package/FormSpec.FS/Interop/FormSpec.Api.Helpers.d.ts.map +1 -1
  82. package/FormSpec.FS/Interop/FormSpec.Api.Helpers.js +63 -18
  83. package/FormSpec.FS/Interop/FormSpec.Api.Helpers.js.map +1 -1
  84. package/FormSpec.FS/Interop/FormSpec.Api.Option.d.ts +4 -4
  85. package/FormSpec.FS/Interop/FormSpec.Api.Option.d.ts.map +1 -1
  86. package/FormSpec.FS/Interop/FormSpec.Api.Option.js +2 -2
  87. package/FormSpec.FS/Interop/FormSpec.Api.Option.js.map +1 -1
  88. package/FormSpec.FS/PathwayDataExtractor.d.ts.map +1 -1
  89. package/FormSpec.FS/PathwayDataExtractor.js +39 -18
  90. package/FormSpec.FS/PathwayDataExtractor.js.map +1 -1
  91. package/FormSpec.FS/PathwayExecutor.d.ts +10 -10
  92. package/FormSpec.FS/PathwayExecutor.d.ts.map +1 -1
  93. package/FormSpec.FS/PathwayExecutor.js +14 -14
  94. package/FormSpec.FS/PathwayExecutor.js.map +1 -1
  95. package/FormSpec.FS/PathwayValidator.d.ts.map +1 -1
  96. package/FormSpec.FS/PathwayValidator.js +8 -5
  97. package/FormSpec.FS/PathwayValidator.js.map +1 -1
  98. package/FormSpec.FS/Renderers/FormSpecMarkdownRenderer.d.ts.map +1 -1
  99. package/FormSpec.FS/Renderers/FormSpecMarkdownRenderer.js +16 -7
  100. package/FormSpec.FS/Renderers/FormSpecMarkdownRenderer.js.map +1 -1
  101. package/FormSpec.FS/Renderers/MermaidRenderer.d.ts.map +1 -1
  102. package/FormSpec.FS/Renderers/MermaidRenderer.js +4 -8
  103. package/FormSpec.FS/Renderers/MermaidRenderer.js.map +1 -1
  104. package/FormSpec.FS/Renderers/PathwayRenderers.d.ts.map +1 -1
  105. package/FormSpec.FS/Renderers/PathwayRenderers.js +5 -4
  106. package/FormSpec.FS/Renderers/PathwayRenderers.js.map +1 -1
  107. package/FormSpec.FS/TriggerActionDto.d.ts +32 -21
  108. package/FormSpec.FS/TriggerActionDto.d.ts.map +1 -1
  109. package/FormSpec.FS/TriggerActionDto.js +247 -61
  110. package/FormSpec.FS/TriggerActionDto.js.map +1 -1
  111. package/README.md +7 -7
  112. package/Thoth.Json/packages/Thoth.Json/Encode.js.map +1 -1
  113. package/package.json +1 -1
  114. package/plugins/allergyfinder/src/AllergyFinderField.d.ts.map +1 -1
  115. package/plugins/allergyfinder/src/AllergyFinderField.js +2 -2
  116. package/plugins/allergyfinder/src/AllergyFinderField.js.map +1 -1
  117. package/plugins/bmi/src/BMIField.d.ts.map +1 -1
  118. package/plugins/bmi/src/BMIField.js +21 -15
  119. package/plugins/bmi/src/BMIField.js.map +1 -1
  120. package/plugins/demographics/src/DemographicsField.d.ts.map +1 -1
  121. package/plugins/demographics/src/DemographicsField.js +4 -4
  122. package/plugins/demographics/src/DemographicsField.js.map +1 -1
  123. package/plugins/likert/src/LikertField.d.ts.map +1 -1
  124. package/plugins/likert/src/LikertField.js +40 -35
  125. package/plugins/likert/src/LikertField.js.map +1 -1
  126. package/plugins/signature/src/SignatureField.d.ts.map +1 -1
  127. package/plugins/signature/src/SignatureField.js +4 -3
  128. package/plugins/signature/src/SignatureField.js.map +1 -1
  129. package/plugins/vitals/src/VitalsField.d.ts.map +1 -1
  130. package/plugins/vitals/src/VitalsField.js +4 -4
  131. package/plugins/vitals/src/VitalsField.js.map +1 -1
  132. package/src/FormSpec.FS/BlueprintValidation.ts +55 -24
  133. package/src/FormSpec.FS/Designer.ts +2 -2
  134. package/src/FormSpec.FS/FormSpec.ts +223 -100
  135. package/src/FormSpec.FS/FormSpecHelpers.ts +2 -2
  136. package/src/FormSpec.FS/FormSpecValues.ts +6 -3
  137. package/src/FormSpec.FS/Helpers.ts +16 -11
  138. package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRFieldTypeMapper.ts +2 -2
  139. package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRFormSpecValidator.ts +3 -3
  140. package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRSectioning.ts +10 -8
  141. package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRSemanticReportBuilder.ts +6 -5
  142. package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRStepsBuilder.ts +1 -10
  143. package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateMapper.ts +35 -30
  144. package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateToFormSpec.ts +7 -26
  145. package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMREncoder.ts +2 -6
  146. package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRImportPipeline.ts +115 -0
  147. package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRImporterAnalysis.ts +1059 -0
  148. package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRSourceMap.ts +10 -10
  149. package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRTriggerEnrichment.ts +61 -88
  150. package/src/FormSpec.FS/Integrations/CorEMR/CoreMRPathwayMapper.ts +926 -0
  151. package/src/FormSpec.FS/Integrations/CorEMR/CoreMRTypes.ts +3 -37
  152. package/src/FormSpec.FS/Integrations/CorEMR/FormTemplateDecoder.ts +1284 -0
  153. package/src/FormSpec.FS/Integrations/CorEMR/FormTemplateDomainDecoder.ts +287 -0
  154. package/src/FormSpec.FS/Interop/FormSpec.Api.Helpers.ts +76 -25
  155. package/src/FormSpec.FS/Interop/FormSpec.Api.Option.ts +6 -6
  156. package/src/FormSpec.FS/PathwayDataExtractor.ts +40 -20
  157. package/src/FormSpec.FS/PathwayExecutor.ts +26 -26
  158. package/src/FormSpec.FS/PathwayValidator.ts +8 -5
  159. package/src/FormSpec.FS/Renderers/FormSpecMarkdownRenderer.ts +18 -8
  160. package/src/FormSpec.FS/Renderers/MermaidRenderer.ts +6 -10
  161. package/src/FormSpec.FS/Renderers/PathwayRenderers.ts +5 -5
  162. package/src/FormSpec.FS/TriggerActionDto.ts +247 -74
  163. package/src/plugins/allergyfinder/src/AllergyFinderField.ts +3 -3
  164. package/src/plugins/bmi/src/BMIField.ts +12 -5
  165. package/src/plugins/demographics/src/DemographicsField.ts +5 -5
  166. package/src/plugins/likert/src/LikertField.ts +16 -11
  167. package/src/plugins/signature/src/SignatureField.ts +4 -3
  168. package/src/plugins/vitals/src/VitalsField.ts +5 -5
  169. package/src/vye-os-contracts-fs/src/CoreMR/FormTemplate.ts +715 -0
  170. package/vye-os-contracts-fs/src/CoreMR/FormTemplate.d.ts +310 -0
  171. package/vye-os-contracts-fs/src/CoreMR/FormTemplate.d.ts.map +1 -0
  172. package/vye-os-contracts-fs/src/CoreMR/FormTemplate.js +1242 -0
  173. package/vye-os-contracts-fs/src/CoreMR/FormTemplate.js.map +1 -0
  174. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTriggerConverter.d.ts +0 -69
  175. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTriggerConverter.d.ts.map +0 -1
  176. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTriggerConverter.js +0 -447
  177. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTriggerConverter.js.map +0 -1
  178. package/FormSpec.FS/Integrations/CorEMR/ItemTriggerConverter.d.ts +0 -19
  179. package/FormSpec.FS/Integrations/CorEMR/ItemTriggerConverter.d.ts.map +0 -1
  180. package/FormSpec.FS/Integrations/CorEMR/ItemTriggerConverter.js +0 -643
  181. package/FormSpec.FS/Integrations/CorEMR/ItemTriggerConverter.js.map +0 -1
  182. package/FormSpec.FS/Integrations/CorEMR/TemplateManifestDecoder.d.ts.map +0 -1
  183. package/FormSpec.FS/Integrations/CorEMR/TemplateManifestDecoder.js.map +0 -1
  184. package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTriggerConverter.ts +0 -412
  185. package/src/FormSpec.FS/Integrations/CorEMR/ItemTriggerConverter.ts +0 -588
  186. package/src/FormSpec.FS/Integrations/CorEMR/TemplateManifestDecoder.ts +0 -1054
@@ -0,0 +1,287 @@
1
+ import { Result_Map, FSharpResult$2_Ok, FSharpResult$2_Error, FSharpResult$2_$union } from "@fable-org/fable-library-js/Result.js";
2
+ import { ErrorReason_$union } from "../../../Thoth.Json/packages/Thoth.Json/Types.js";
3
+ import { bool, decimal, list as list_1, map, IRequiredGetter, IGetters, string, option, int, object, succeed, fail, andThen } from "../../../Thoth.Json/packages/Thoth.Json/Decode.js";
4
+ import { uncurry2, uncurry3 } from "@fable-org/fable-library-js/Util.js";
5
+ import { printf, toText } from "@fable-org/fable-library-js/String.js";
6
+ import { int32 } from "@fable-org/fable-library-js/Int32.js";
7
+ import { value as value_8, Option } from "@fable-org/fable-library-js/Option.js";
8
+ import { Trigger, StatedAction, StatedCondition, Availability$1_NotReadYet, Availability$1_NotInRelease, Availability$1_$union, Availability$1_Stated, Firing_OnceOnly, Firing_$union, Firing_EveryTime, Timing_UnrecognisedTiming, Timing_OnFirstOpen, Timing_OnLock, Timing_$union, Timing_OnSave, ActionRead_Unmodelled, ActionRead_$union, ActionRead_Modelled, Action_ChangeGroups, Action_Medset, MedsetOrder, Action_Problem, ProblemOrder, Action_Alert, Action_StandingOrder, Action_$union, Action_OneOffTask, GroupChange_RemoveFrom, GroupChange_$union, GroupChange_AddTo, NonEmpty$1, NonEmpty_ofList, Standing_Treatment, Standing_$union, Standing_RecurringTask, TreatmentOrder, Cadence_Every, Cadence_$union, Cadence_OnSchedule, TaskOrder, Priority, Join_UnrecognisedJoin, Join_Or, Join_$union, Join_And, Condition_UnmodelledCondition, Condition_TextCompares, Condition_BooleanIs, Condition_VitalIs, Condition_NoneChosen, Condition_AllChosen, Condition_$union, Condition_AnyChosen, ChoiceId, VitalSign_Weight, VitalSign_SpO2, VitalSign_Temperature, VitalSign_Respiration, VitalSign_HeartRate, VitalSign_DiastolicBP, VitalSign_$union, VitalSign_SystolicBP, Comparison_Greater, Comparison_GreaterOrEqual, Comparison_NotEqual, Comparison_Equal, Comparison_LessOrEqual, Comparison_$union, Comparison_Less, Ref } from "../../../vye-os-contracts-fs/src/CoreMR/FormTemplate.js";
9
+ import { FSharpList, map as map_1 } from "@fable-org/fable-library-js/List.js";
10
+ import { decimal as decimal_1 } from "@fable-org/fable-library-js/Decimal.js";
11
+
12
+ function orFail<T>(d: ((arg0: string, arg1: any) => FSharpResult$2_$union<FSharpResult$2_$union<T, string>, [string, ErrorReason_$union]>)): ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<T, [string, ErrorReason_$union]>)) {
13
+ const decoder: ((arg0: string, arg1: any) => FSharpResult$2_$union<FSharpResult$2_$union<T, string>, [string, ErrorReason_$union]>) = d;
14
+ return (path_1: string): ((arg0: any) => FSharpResult$2_$union<T, [string, ErrorReason_$union]>) => ((value: any): FSharpResult$2_$union<T, [string, ErrorReason_$union]> => andThen<FSharpResult$2_$union<T, string>, T>(uncurry3((_arg: FSharpResult$2_$union<T, string>): ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<T, [string, ErrorReason_$union]>)) => {
15
+ if (_arg.tag === /* Error */ 1) {
16
+ const msg: string = _arg.fields[0];
17
+ return (path: string): ((arg0: any) => FSharpResult$2_$union<T, [string, ErrorReason_$union]>) => ((arg20$0040_1: any): FSharpResult$2_$union<T, [string, ErrorReason_$union]> => fail<T>(msg, path, arg20$0040_1));
18
+ }
19
+ else {
20
+ const v: T = _arg.fields[0];
21
+ return (arg10$0040: string): ((arg0: any) => FSharpResult$2_$union<T, [string, ErrorReason_$union]>) => ((arg20$0040: any): FSharpResult$2_$union<T, [string, ErrorReason_$union]> => succeed<T>(v, arg10$0040, arg20$0040));
22
+ }
23
+ }), decoder, path_1, value));
24
+ }
25
+
26
+ function unknown<T>(what: string, tag: string): FSharpResult$2_$union<T, string> {
27
+ return FSharpResult$2_Error<T, string>(toText(printf("`%s.kind` = `%s` is not a case this build understands — it is NOT read as any other"))(what)(tag));
28
+ }
29
+
30
+ const reference = (path_2: string): ((arg0: any) => FSharpResult$2_$union<Ref, [string, ErrorReason_$union]>) => ((v: any): FSharpResult$2_$union<Ref, [string, ErrorReason_$union]> => object<Ref>((get$: IGetters): Ref => {
31
+ let objectArg: IRequiredGetter, objectArg_1: IRequiredGetter;
32
+ return new Ref((objectArg = get$.Required, objectArg.Field<int32>("id", uncurry2(int))), (objectArg_1 = get$.Required, objectArg_1.Field<Option<string>>("name", (path_1: string, value_1: any): FSharpResult$2_$union<Option<string>, [string, ErrorReason_$union]> => option<string>(string, path_1, value_1))));
33
+ }, path_2, v));
34
+
35
+ const comparison: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<Comparison_$union, [string, ErrorReason_$union]>)) = orFail<Comparison_$union>((path_1: string, value_1: any): FSharpResult$2_$union<FSharpResult$2_$union<Comparison_$union, string>, [string, ErrorReason_$union]> => map<string, FSharpResult$2_$union<Comparison_$union, string>>((_arg: string): FSharpResult$2_$union<Comparison_$union, string> => {
36
+ switch (_arg) {
37
+ case "less":
38
+ return FSharpResult$2_Ok<Comparison_$union, string>(Comparison_Less());
39
+ case "lessOrEqual":
40
+ return FSharpResult$2_Ok<Comparison_$union, string>(Comparison_LessOrEqual());
41
+ case "equal":
42
+ return FSharpResult$2_Ok<Comparison_$union, string>(Comparison_Equal());
43
+ case "notEqual":
44
+ return FSharpResult$2_Ok<Comparison_$union, string>(Comparison_NotEqual());
45
+ case "greaterOrEqual":
46
+ return FSharpResult$2_Ok<Comparison_$union, string>(Comparison_GreaterOrEqual());
47
+ case "greater":
48
+ return FSharpResult$2_Ok<Comparison_$union, string>(Comparison_Greater());
49
+ default:
50
+ return FSharpResult$2_Error<Comparison_$union, string>(toText(printf("`comparison` = `%s` is not a comparison this build understands"))(_arg));
51
+ }
52
+ }, string, path_1, value_1));
53
+
54
+ const vital: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<VitalSign_$union, [string, ErrorReason_$union]>)) = orFail<VitalSign_$union>((path_1: string, value_1: any): FSharpResult$2_$union<FSharpResult$2_$union<VitalSign_$union, string>, [string, ErrorReason_$union]> => map<string, FSharpResult$2_$union<VitalSign_$union, string>>((_arg: string): FSharpResult$2_$union<VitalSign_$union, string> => {
55
+ switch (_arg) {
56
+ case "systolicBP":
57
+ return FSharpResult$2_Ok<VitalSign_$union, string>(VitalSign_SystolicBP());
58
+ case "diastolicBP":
59
+ return FSharpResult$2_Ok<VitalSign_$union, string>(VitalSign_DiastolicBP());
60
+ case "heartRate":
61
+ return FSharpResult$2_Ok<VitalSign_$union, string>(VitalSign_HeartRate());
62
+ case "respiration":
63
+ return FSharpResult$2_Ok<VitalSign_$union, string>(VitalSign_Respiration());
64
+ case "temperature":
65
+ return FSharpResult$2_Ok<VitalSign_$union, string>(VitalSign_Temperature());
66
+ case "spO2":
67
+ return FSharpResult$2_Ok<VitalSign_$union, string>(VitalSign_SpO2());
68
+ case "weight":
69
+ return FSharpResult$2_Ok<VitalSign_$union, string>(VitalSign_Weight());
70
+ default:
71
+ return FSharpResult$2_Error<VitalSign_$union, string>(toText(printf("`vital` = `%s` is not a vital sign this build understands"))(_arg));
72
+ }
73
+ }, string, path_1, value_1));
74
+
75
+ function choices(get$: IGetters): FSharpList<ChoiceId> {
76
+ let objectArg: IRequiredGetter;
77
+ return map_1<int32, ChoiceId>((Item: int32): ChoiceId => (new ChoiceId(Item)), (objectArg = get$.Required, objectArg.Field<FSharpList<int32>>("choices", (path: string, value: any): FSharpResult$2_$union<FSharpList<int32>, [string, ErrorReason_$union]> => list_1<int32>(uncurry2(int), path, value))));
78
+ }
79
+
80
+ const test: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<Condition_$union, [string, ErrorReason_$union]>)) = orFail<Condition_$union>((path_7: string, v: any): FSharpResult$2_$union<FSharpResult$2_$union<Condition_$union, string>, [string, ErrorReason_$union]> => object<FSharpResult$2_$union<Condition_$union, string>>((get$: IGetters): FSharpResult$2_$union<Condition_$union, string> => {
81
+ let objectArg_1: IRequiredGetter, objectArg_2: IRequiredGetter, objectArg_3: IRequiredGetter, objectArg_4: IRequiredGetter, objectArg_5: IRequiredGetter, objectArg_6: IRequiredGetter, objectArg_7: IRequiredGetter, objectArg_8: IRequiredGetter, objectArg_9: IRequiredGetter;
82
+ let matchValue: string;
83
+ const objectArg: IRequiredGetter = get$.Required;
84
+ matchValue = objectArg.Field<string>("kind", string);
85
+ switch (matchValue) {
86
+ case "anyChosen":
87
+ return FSharpResult$2_Ok<Condition_$union, string>(Condition_AnyChosen(choices(get$)));
88
+ case "allChosen":
89
+ return FSharpResult$2_Ok<Condition_$union, string>(Condition_AllChosen(choices(get$)));
90
+ case "noneChosen":
91
+ return FSharpResult$2_Ok<Condition_$union, string>(Condition_NoneChosen(choices(get$)));
92
+ case "vitalIs":
93
+ return FSharpResult$2_Ok<Condition_$union, string>(Condition_VitalIs((objectArg_1 = get$.Required, objectArg_1.Field<VitalSign_$union>("vital", uncurry2(vital))), (objectArg_2 = get$.Required, objectArg_2.Field<Comparison_$union>("comparison", uncurry2(comparison))), (objectArg_3 = get$.Required, objectArg_3.Field<decimal_1>("threshold", decimal))));
94
+ case "booleanIs":
95
+ return FSharpResult$2_Ok<Condition_$union, string>(Condition_BooleanIs((objectArg_4 = get$.Required, objectArg_4.Field<boolean>("equals", bool))));
96
+ case "textCompares":
97
+ return FSharpResult$2_Ok<Condition_$union, string>(Condition_TextCompares((objectArg_5 = get$.Required, objectArg_5.Field<Comparison_$union>("comparison", uncurry2(comparison))), (objectArg_6 = get$.Required, objectArg_6.Field<string>("text", string))));
98
+ case "unmodelledCondition":
99
+ return FSharpResult$2_Ok<Condition_$union, string>(Condition_UnmodelledCondition((objectArg_7 = get$.Required, objectArg_7.Field<string>("source", string)), (objectArg_8 = get$.Required, objectArg_8.Field<string>("operator", string)), (objectArg_9 = get$.Required, objectArg_9.Field<string>("because", string))));
100
+ default:
101
+ return unknown<Condition_$union>("test", matchValue);
102
+ }
103
+ }, path_7, v));
104
+
105
+ const join: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<Join_$union, [string, ErrorReason_$union]>)) = orFail<Join_$union>((path_2: string, v: any): FSharpResult$2_$union<FSharpResult$2_$union<Join_$union, string>, [string, ErrorReason_$union]> => object<FSharpResult$2_$union<Join_$union, string>>((get$: IGetters): FSharpResult$2_$union<Join_$union, string> => {
106
+ let objectArg_1: IRequiredGetter;
107
+ let matchValue: string;
108
+ const objectArg: IRequiredGetter = get$.Required;
109
+ matchValue = objectArg.Field<string>("kind", string);
110
+ switch (matchValue) {
111
+ case "and":
112
+ return FSharpResult$2_Ok<Join_$union, string>(Join_And());
113
+ case "or":
114
+ return FSharpResult$2_Ok<Join_$union, string>(Join_Or());
115
+ case "unrecognisedJoin":
116
+ return FSharpResult$2_Ok<Join_$union, string>(Join_UnrecognisedJoin((objectArg_1 = get$.Required, objectArg_1.Field<string>("stated", string))));
117
+ default:
118
+ return unknown<Join_$union>("join", matchValue);
119
+ }
120
+ }, path_2, v));
121
+
122
+ const taskOrder = (path_4: string): ((arg0: any) => FSharpResult$2_$union<TaskOrder, [string, ErrorReason_$union]>) => ((v: any): FSharpResult$2_$union<TaskOrder, [string, ErrorReason_$union]> => object<TaskOrder>((get$: IGetters): TaskOrder => {
123
+ let objectArg: IRequiredGetter, objectArg_1: IRequiredGetter, objectArg_2: IRequiredGetter, objectArg_3: IRequiredGetter;
124
+ return new TaskOrder((objectArg = get$.Required, objectArg.Field<Ref>("category", uncurry2(reference))), (objectArg_1 = get$.Required, objectArg_1.Field<Option<string>>("description", (path_1: string, value_1: any): FSharpResult$2_$union<Option<string>, [string, ErrorReason_$union]> => option<string>(string, path_1, value_1))), new Priority((objectArg_2 = get$.Required, objectArg_2.Field<int32>("priority", uncurry2(int)))), (objectArg_3 = get$.Required, objectArg_3.Field<Option<string>>("due", (path_3: string, value_3: any): FSharpResult$2_$union<Option<string>, [string, ErrorReason_$union]> => option<string>(string, path_3, value_3))));
125
+ }, path_4, v));
126
+
127
+ const cadence: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<Cadence_$union, [string, ErrorReason_$union]>)) = orFail<Cadence_$union>((path_5: string, v: any): FSharpResult$2_$union<FSharpResult$2_$union<Cadence_$union, string>, [string, ErrorReason_$union]> => object<FSharpResult$2_$union<Cadence_$union, string>>((get$: IGetters): FSharpResult$2_$union<Cadence_$union, string> => {
128
+ let objectArg_1: IRequiredGetter, objectArg_2: IRequiredGetter, objectArg_3: IRequiredGetter, objectArg_4: IRequiredGetter;
129
+ let matchValue: string;
130
+ const objectArg: IRequiredGetter = get$.Required;
131
+ matchValue = objectArg.Field<string>("kind", string);
132
+ switch (matchValue) {
133
+ case "onSchedule":
134
+ return FSharpResult$2_Ok<Cadence_$union, string>(Cadence_OnSchedule((objectArg_1 = get$.Required, objectArg_1.Field<Ref>("schedule", uncurry2(reference))), (objectArg_2 = get$.Required, objectArg_2.Field<Option<string>>("ends", (path_2: string, value_2: any): FSharpResult$2_$union<Option<string>, [string, ErrorReason_$union]> => option<string>(string, path_2, value_2)))));
135
+ case "every":
136
+ return FSharpResult$2_Ok<Cadence_$union, string>(Cadence_Every((objectArg_3 = get$.Required, objectArg_3.Field<string>("interval", string)), (objectArg_4 = get$.Required, objectArg_4.Field<string>("until", string))));
137
+ default:
138
+ return unknown<Cadence_$union>("cadence", matchValue);
139
+ }
140
+ }, path_5, v));
141
+
142
+ const treatmentOrder = (path_6: string): ((arg0: any) => FSharpResult$2_$union<TreatmentOrder, [string, ErrorReason_$union]>) => ((v: any): FSharpResult$2_$union<TreatmentOrder, [string, ErrorReason_$union]> => object<TreatmentOrder>((get$: IGetters): TreatmentOrder => {
143
+ let objectArg: IRequiredGetter, objectArg_1: IRequiredGetter, objectArg_2: IRequiredGetter, objectArg_3: IRequiredGetter, objectArg_4: IRequiredGetter;
144
+ return new TreatmentOrder((objectArg = get$.Required, objectArg.Field<Ref>("treatment", uncurry2(reference))), (objectArg_1 = get$.Required, objectArg_1.Field<Option<Ref>>("provider", (path: string, value: any): FSharpResult$2_$union<Option<Ref>, [string, ErrorReason_$union]> => option<Ref>(uncurry2(reference), path, value))), (objectArg_2 = get$.Required, objectArg_2.Field<string>("start", string)), (objectArg_3 = get$.Required, objectArg_3.Field<Option<string>>("instructions", (path_3: string, value_3: any): FSharpResult$2_$union<Option<string>, [string, ErrorReason_$union]> => option<string>(string, path_3, value_3))), (objectArg_4 = get$.Required, objectArg_4.Field<Option<boolean>>("canTreatImmediately", (path_5: string, value_5: any): FSharpResult$2_$union<Option<boolean>, [string, ErrorReason_$union]> => option<boolean>(bool, path_5, value_5))));
145
+ }, path_6, v));
146
+
147
+ const standing: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<Standing_$union, [string, ErrorReason_$union]>)) = orFail<Standing_$union>((path_1: string, v: any): FSharpResult$2_$union<FSharpResult$2_$union<Standing_$union, string>, [string, ErrorReason_$union]> => object<FSharpResult$2_$union<Standing_$union, string>>((get$: IGetters): FSharpResult$2_$union<Standing_$union, string> => {
148
+ let objectArg_1: IRequiredGetter, objectArg_2: IRequiredGetter;
149
+ let matchValue: string;
150
+ const objectArg: IRequiredGetter = get$.Required;
151
+ matchValue = objectArg.Field<string>("kind", string);
152
+ switch (matchValue) {
153
+ case "recurringTask":
154
+ return FSharpResult$2_Ok<Standing_$union, string>(Standing_RecurringTask((objectArg_1 = get$.Required, objectArg_1.Field<TaskOrder>("task", uncurry2(taskOrder)))));
155
+ case "treatment":
156
+ return FSharpResult$2_Ok<Standing_$union, string>(Standing_Treatment((objectArg_2 = get$.Required, objectArg_2.Field<TreatmentOrder>("treatment", uncurry2(treatmentOrder)))));
157
+ default:
158
+ return unknown<Standing_$union>("standing", matchValue);
159
+ }
160
+ }, path_1, v));
161
+
162
+ const groupChange: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<GroupChange_$union, [string, ErrorReason_$union]>)) = orFail<GroupChange_$union>((path_2: string, v: any): FSharpResult$2_$union<FSharpResult$2_$union<GroupChange_$union, string>, [string, ErrorReason_$union]> => object<FSharpResult$2_$union<GroupChange_$union, string>>((get$: IGetters): FSharpResult$2_$union<GroupChange_$union, string> => {
163
+ const groups = (): FSharpResult$2_$union<NonEmpty$1<Ref>, string> => {
164
+ let objectArg: IRequiredGetter;
165
+ const matchValue: Option<NonEmpty$1<Ref>> = NonEmpty_ofList<Ref>((objectArg = get$.Required, objectArg.Field<FSharpList<Ref>>("groups", (path: string, value: any): FSharpResult$2_$union<FSharpList<Ref>, [string, ErrorReason_$union]> => list_1<Ref>(uncurry2(reference), path, value))));
166
+ if (matchValue == null) {
167
+ return FSharpResult$2_Error<NonEmpty$1<Ref>, string>("a group change names NO group — `groups` is empty");
168
+ }
169
+ else {
170
+ return FSharpResult$2_Ok<NonEmpty$1<Ref>, string>(value_8(matchValue));
171
+ }
172
+ };
173
+ let matchValue_1: string;
174
+ const objectArg_1: IRequiredGetter = get$.Required;
175
+ matchValue_1 = objectArg_1.Field<string>("kind", string);
176
+ switch (matchValue_1) {
177
+ case "addTo":
178
+ return Result_Map<NonEmpty$1<Ref>, GroupChange_$union, string>(GroupChange_AddTo, groups());
179
+ case "removeFrom":
180
+ return Result_Map<NonEmpty$1<Ref>, GroupChange_$union, string>(GroupChange_RemoveFrom, groups());
181
+ default:
182
+ return unknown<GroupChange_$union>("change", matchValue_1);
183
+ }
184
+ }, path_2, v));
185
+
186
+ const action: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<Action_$union, [string, ErrorReason_$union]>)) = orFail<Action_$union>((path_8: string, v: any): FSharpResult$2_$union<FSharpResult$2_$union<Action_$union, string>, [string, ErrorReason_$union]> => object<FSharpResult$2_$union<Action_$union, string>>((get$: IGetters): FSharpResult$2_$union<Action_$union, string> => {
187
+ let objectArg_1: IRequiredGetter, objectArg_2: IRequiredGetter, objectArg_3: IRequiredGetter, objectArg_4: IRequiredGetter, objectArg_5: IRequiredGetter, objectArg_6: IRequiredGetter, objectArg_7: IRequiredGetter, objectArg_8: IRequiredGetter, objectArg_9: IRequiredGetter, objectArg_10: IRequiredGetter, objectArg_11: IRequiredGetter, objectArg_12: IRequiredGetter, objectArg_13: IRequiredGetter;
188
+ let matchValue: string;
189
+ const objectArg: IRequiredGetter = get$.Required;
190
+ matchValue = objectArg.Field<string>("kind", string);
191
+ switch (matchValue) {
192
+ case "oneOffTask":
193
+ return FSharpResult$2_Ok<Action_$union, string>(Action_OneOffTask((objectArg_1 = get$.Required, objectArg_1.Field<TaskOrder>("task", uncurry2(taskOrder)))));
194
+ case "standingOrder":
195
+ return FSharpResult$2_Ok<Action_$union, string>(Action_StandingOrder((objectArg_2 = get$.Required, objectArg_2.Field<Cadence_$union>("cadence", uncurry2(cadence))), (objectArg_3 = get$.Required, objectArg_3.Field<Standing_$union>("standing", uncurry2(standing)))));
196
+ case "alert":
197
+ return FSharpResult$2_Ok<Action_$union, string>(Action_Alert((objectArg_4 = get$.Required, objectArg_4.Field<Ref>("category", uncurry2(reference)))));
198
+ case "problem":
199
+ return FSharpResult$2_Ok<Action_$union, string>(Action_Problem(new ProblemOrder((objectArg_5 = get$.Required, objectArg_5.Field<Ref>("problem", uncurry2(reference))), (objectArg_6 = get$.Required, objectArg_6.Field<Option<int32>>("chronic", (path_1: string, value_1: any): FSharpResult$2_$union<Option<int32>, [string, ErrorReason_$union]> => option<int32>(uncurry2(int), path_1, value_1))), (objectArg_7 = get$.Required, objectArg_7.Field<Option<int32>>("severity", (path_2: string, value_2: any): FSharpResult$2_$union<Option<int32>, [string, ErrorReason_$union]> => option<int32>(uncurry2(int), path_2, value_2))), (objectArg_8 = get$.Required, objectArg_8.Field<Option<int32>>("inflammation", (path_3: string, value_3: any): FSharpResult$2_$union<Option<int32>, [string, ErrorReason_$union]> => option<int32>(uncurry2(int), path_3, value_3))))));
200
+ case "medset":
201
+ return FSharpResult$2_Ok<Action_$union, string>(Action_Medset(new MedsetOrder((objectArg_9 = get$.Required, objectArg_9.Field<Ref>("medset", uncurry2(reference))), (objectArg_10 = get$.Required, objectArg_10.Field<Option<Ref>>("prescriber", (path_4: string, value_4: any): FSharpResult$2_$union<Option<Ref>, [string, ErrorReason_$union]> => option<Ref>(uncurry2(reference), path_4, value_4))), (objectArg_11 = get$.Required, objectArg_11.Field<Option<Ref>>("pharmacy", (path_5: string, value_5: any): FSharpResult$2_$union<Option<Ref>, [string, ErrorReason_$union]> => option<Ref>(uncurry2(reference), path_5, value_5))), (objectArg_12 = get$.Required, objectArg_12.Field<Option<string>>("start", (path_7: string, value_7: any): FSharpResult$2_$union<Option<string>, [string, ErrorReason_$union]> => option<string>(string, path_7, value_7))))));
202
+ case "changeGroups":
203
+ return FSharpResult$2_Ok<Action_$union, string>(Action_ChangeGroups((objectArg_13 = get$.Required, objectArg_13.Field<GroupChange_$union>("change", uncurry2(groupChange)))));
204
+ default:
205
+ return unknown<Action_$union>("action", matchValue);
206
+ }
207
+ }, path_8, v));
208
+
209
+ const read: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<ActionRead_$union, [string, ErrorReason_$union]>)) = orFail<ActionRead_$union>((path_3: string, v: any): FSharpResult$2_$union<FSharpResult$2_$union<ActionRead_$union, string>, [string, ErrorReason_$union]> => object<FSharpResult$2_$union<ActionRead_$union, string>>((get$: IGetters): FSharpResult$2_$union<ActionRead_$union, string> => {
210
+ let objectArg_1: IRequiredGetter, objectArg_2: IRequiredGetter, objectArg_3: IRequiredGetter;
211
+ let matchValue: string;
212
+ const objectArg: IRequiredGetter = get$.Required;
213
+ matchValue = objectArg.Field<string>("kind", string);
214
+ switch (matchValue) {
215
+ case "modelled":
216
+ return FSharpResult$2_Ok<ActionRead_$union, string>(ActionRead_Modelled((objectArg_1 = get$.Required, objectArg_1.Field<Action_$union>("action", uncurry2(action)))));
217
+ case "unmodelled":
218
+ return FSharpResult$2_Ok<ActionRead_$union, string>(ActionRead_Unmodelled((objectArg_2 = get$.Required, objectArg_2.Field<string>("actionKind", string)), (objectArg_3 = get$.Required, objectArg_3.Field<string>("because", string))));
219
+ default:
220
+ return unknown<ActionRead_$union>("read", matchValue);
221
+ }
222
+ }, path_3, v));
223
+
224
+ const timing: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<Timing_$union, [string, ErrorReason_$union]>)) = orFail<Timing_$union>((path_2: string, v: any): FSharpResult$2_$union<FSharpResult$2_$union<Timing_$union, string>, [string, ErrorReason_$union]> => object<FSharpResult$2_$union<Timing_$union, string>>((get$: IGetters): FSharpResult$2_$union<Timing_$union, string> => {
225
+ let objectArg_1: IRequiredGetter;
226
+ let matchValue: string;
227
+ const objectArg: IRequiredGetter = get$.Required;
228
+ matchValue = objectArg.Field<string>("kind", string);
229
+ switch (matchValue) {
230
+ case "onSave":
231
+ return FSharpResult$2_Ok<Timing_$union, string>(Timing_OnSave());
232
+ case "onLock":
233
+ return FSharpResult$2_Ok<Timing_$union, string>(Timing_OnLock());
234
+ case "onFirstOpen":
235
+ return FSharpResult$2_Ok<Timing_$union, string>(Timing_OnFirstOpen());
236
+ case "unrecognisedTiming":
237
+ return FSharpResult$2_Ok<Timing_$union, string>(Timing_UnrecognisedTiming((objectArg_1 = get$.Required, objectArg_1.Field<string>("eventName", string))));
238
+ default:
239
+ return unknown<Timing_$union>("timing", matchValue);
240
+ }
241
+ }, path_2, v));
242
+
243
+ const firingValue: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<Firing_$union, [string, ErrorReason_$union]>)) = orFail<Firing_$union>((path_1: string, v: any): FSharpResult$2_$union<FSharpResult$2_$union<Firing_$union, string>, [string, ErrorReason_$union]> => object<FSharpResult$2_$union<Firing_$union, string>>((get$: IGetters): FSharpResult$2_$union<Firing_$union, string> => {
244
+ let matchValue: string;
245
+ const objectArg: IRequiredGetter = get$.Required;
246
+ matchValue = objectArg.Field<string>("kind", string);
247
+ switch (matchValue) {
248
+ case "everyTime":
249
+ return FSharpResult$2_Ok<Firing_$union, string>(Firing_EveryTime());
250
+ case "onceOnly":
251
+ return FSharpResult$2_Ok<Firing_$union, string>(Firing_OnceOnly());
252
+ default:
253
+ return unknown<Firing_$union>("firing.value", matchValue);
254
+ }
255
+ }, path_1, v));
256
+
257
+ const firing: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<Availability$1_$union<Firing_$union>, [string, ErrorReason_$union]>)) = orFail<Availability$1_$union<Firing_$union>>((path_5: string, v: any): FSharpResult$2_$union<FSharpResult$2_$union<Availability$1_$union<Firing_$union>, string>, [string, ErrorReason_$union]> => object<FSharpResult$2_$union<Availability$1_$union<Firing_$union>, string>>((get$: IGetters): FSharpResult$2_$union<Availability$1_$union<Firing_$union>, string> => {
258
+ let objectArg_1: IRequiredGetter, objectArg_2: IRequiredGetter, objectArg_3: IRequiredGetter, objectArg_4: IRequiredGetter;
259
+ let matchValue: string;
260
+ const objectArg: IRequiredGetter = get$.Required;
261
+ matchValue = objectArg.Field<string>("kind", string);
262
+ switch (matchValue) {
263
+ case "stated":
264
+ return FSharpResult$2_Ok<Availability$1_$union<Firing_$union>, string>(Availability$1_Stated<Firing_$union>((objectArg_1 = get$.Required, objectArg_1.Field<Firing_$union>("value", uncurry2(firingValue)))));
265
+ case "notInRelease":
266
+ return FSharpResult$2_Ok<Availability$1_$union<Firing_$union>, string>(Availability$1_NotInRelease<Firing_$union>((objectArg_2 = get$.Required, objectArg_2.Field<string>("because", string))));
267
+ case "notReadYet":
268
+ return FSharpResult$2_Ok<Availability$1_$union<Firing_$union>, string>(Availability$1_NotReadYet<Firing_$union>((objectArg_3 = get$.Required, objectArg_3.Field<string>("because", string)), (objectArg_4 = get$.Required, objectArg_4.Field<FSharpList<string>>("witness", (path_4: string, value_4: any): FSharpResult$2_$union<FSharpList<string>, [string, ErrorReason_$union]> => list_1<string>(string, path_4, value_4)))));
269
+ default:
270
+ return unknown<Availability$1_$union<Firing_$union>>("firing", matchValue);
271
+ }
272
+ }, path_5, v));
273
+
274
+ export const trigger = (path_7: string): ((arg0: any) => FSharpResult$2_$union<Trigger, [string, ErrorReason_$union]>) => ((v_2: any): FSharpResult$2_$union<Trigger, [string, ErrorReason_$union]> => object<Trigger>((get$: IGetters): Trigger => {
275
+ let objectArg: IRequiredGetter, objectArg_1: IRequiredGetter, objectArg_2: IRequiredGetter, objectArg_3: IRequiredGetter, objectArg_4: IRequiredGetter, objectArg_8: IRequiredGetter;
276
+ return new Trigger((objectArg = get$.Required, objectArg.Field<int32>("triggerId", uncurry2(int))), (objectArg_1 = get$.Required, objectArg_1.Field<Timing_$union>("timing", uncurry2(timing))), (objectArg_2 = get$.Required, objectArg_2.Field<Availability$1_$union<Firing_$union>>("firing", uncurry2(firing))), (objectArg_3 = get$.Required, objectArg_3.Field<boolean>("enabled", bool)), (objectArg_4 = get$.Required, objectArg_4.Field<FSharpList<StatedCondition>>("conditions", (path_4: string, value_3: any): FSharpResult$2_$union<FSharpList<StatedCondition>, [string, ErrorReason_$union]> => list_1<StatedCondition>((path_3: string, v: any): FSharpResult$2_$union<StatedCondition, [string, ErrorReason_$union]> => object<StatedCondition>((c: IGetters): StatedCondition => {
277
+ let objectArg_5: IRequiredGetter, objectArg_6: IRequiredGetter, objectArg_7: IRequiredGetter;
278
+ return new StatedCondition((objectArg_5 = c.Required, objectArg_5.Field<Option<int32>>("sourceItem", (path_1: string, value_1: any): FSharpResult$2_$union<Option<int32>, [string, ErrorReason_$union]> => option<int32>(uncurry2(int), path_1, value_1))), (objectArg_6 = c.Required, objectArg_6.Field<Option<Join_$union>>("join", (path_2: string, value_2: any): FSharpResult$2_$union<Option<Join_$union>, [string, ErrorReason_$union]> => option<Join_$union>(uncurry2(join), path_2, value_2))), (objectArg_7 = c.Required, objectArg_7.Field<Condition_$union>("test", uncurry2(test))));
279
+ }, path_3, v), path_4, value_3))), (objectArg_8 = get$.Required, objectArg_8.Field<FSharpList<StatedAction>>("actions", (path_6: string, value_4: any): FSharpResult$2_$union<FSharpList<StatedAction>, [string, ErrorReason_$union]> => list_1<StatedAction>((path_5: string, v_1: any): FSharpResult$2_$union<StatedAction, [string, ErrorReason_$union]> => object<StatedAction>((a: IGetters): StatedAction => {
280
+ let objectArg_9: IRequiredGetter, objectArg_10: IRequiredGetter;
281
+ return new StatedAction((objectArg_9 = a.Required, objectArg_9.Field<int32>("actionId", uncurry2(int))), (objectArg_10 = a.Required, objectArg_10.Field<ActionRead_$union>("read", uncurry2(read))));
282
+ }, path_5, v_1), path_6, value_4))));
283
+ }, path_7, v_2));
284
+
285
+ export const triggers = (path: string): ((arg0: any) => FSharpResult$2_$union<FSharpList<Trigger>, [string, ErrorReason_$union]>) => ((value: any): FSharpResult$2_$union<FSharpList<Trigger>, [string, ErrorReason_$union]> => list_1<Trigger>(uncurry2(trigger), path, value));
286
+
287
+ //# sourceMappingURL=FormTemplateDomainDecoder.ts.map
@@ -1,12 +1,12 @@
1
- import { map as map_2, bind, unwrap, orElse, value as value_19, orElseWith, defaultArgWith as defaultArgWith_1, Option, defaultArg as defaultArg_1 } from "@fable-org/fable-library-js/Option.js";
2
- import { exists, sortBy, toArray, length as length_1, tryPick, filter as filter_1, mapIndexed as mapIndexed_2, isEmpty, map as map_3, empty, fold, ofSeq as ofSeq_1, ofArray as ofArray_2, singleton as singleton_1, collect as collect_1, tryFind, FSharpList } from "@fable-org/fable-library-js/List.js";
3
- import { int32ToString, int64ToString, stringHash, compare, comparePrimitives, IDisposable, disposeSafe, IEnumerator, getEnumerator, IMap, isArrayLike, uncurry2, createObj, equals, defaultOf } from "@fable-org/fable-library-js/Util.js";
1
+ import { toNullable, map as map_2, bind, unwrap, orElse, value as value_19, orElseWith, defaultArgWith as defaultArgWith_1, Option, defaultArg as defaultArg_1 } from "@fable-org/fable-library-js/Option.js";
2
+ import { exists, sortBy, length as length_1, tryPick, toArray, filter as filter_1, mapIndexed as mapIndexed_2, isEmpty, map as map_3, empty, fold, ofSeq as ofSeq_1, ofArray as ofArray_2, singleton as singleton_1, collect as collect_1, tryFind, FSharpList } from "@fable-org/fable-library-js/List.js";
3
+ import { int64ToString, int32ToString, stringHash, compare, comparePrimitives, IDisposable, disposeSafe, IEnumerator, getEnumerator, IMap, isArrayLike, uncurry2, createObj, equals, defaultOf } from "@fable-org/fable-library-js/Util.js";
4
4
  import { toText, join, isNullOrWhiteSpace, printf, toConsole, isNullOrEmpty } from "@fable-org/fable-library-js/String.js";
5
5
  import { int32, float64 } from "@fable-org/fable-library-js/Int32.js";
6
6
  import { append, mapIndexed, tryFind as tryFind_1, map, item as item_2 } from "@fable-org/fable-library-js/Array.js";
7
7
  import { length, mapIndexed as mapIndexed_1, filter, choose, map as map_1, singleton, collect, delay, toList } from "@fable-org/fable-library-js/Seq.js";
8
8
  import { Auto_generateBoxedEncoder_437914C6, toString } from "../../Thoth.Json/packages/Thoth.Json/Encode.js";
9
- import { Spec_SingleChoiceInfo, Spec_FormClassification_$union, ClinicalPathway_StateType_$union, ClinicalPathway_TaskPriority_$union, ClinicalPathway_AlertSeverity_$union, ClinicalPathway_ReferralUrgency_$union, ClinicalPathway_ActionInfo_$union, ClinicalPathway_NavigateToFormAction, ClinicalPathway_MedsetAction, ClinicalPathway_TreatmentAction, ClinicalPathway_ProblemAction, ClinicalPathway_AlertAction, ClinicalPathway_EducationAction, ClinicalPathway_ProcedureAction, ClinicalPathway_TestAction, ClinicalPathway_DocumentationAction, ClinicalPathway_FieldValueSource_$union, ClinicalPathway_SetFieldValueAction, ClinicalPathway_PrescriptionAction, ClinicalPathway_MedicationAction, ClinicalPathway_ReferralAction, Shared_FieldValue, 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_FormClassification_General, Spec_FormLifecycle_Blueprint, Spec_FieldType_Text, Spec_TextInfo, Spec_FieldType_CheckboxList, Spec_MultiChoiceInfo, Shared_FieldOptionKey, Spec_FieldType_Checkbox, Spec_BooleanInfo, Shared_FieldKey, Shared_FieldOption, Shared_FieldValue_Single, Shared_FieldValue_PluginData, Shared_PluginDataProperty, Shared_PluginPropertyKey, Shared_FieldValue_Matrix, Shared_MatrixAnswer, Shared_MatrixItemKey, Shared_FieldValue_Multiple, Shared_FieldAnswer, Shared_FieldValue_$union, Spec_FormStep$1, Spec_FormField$1, Spec_FieldType_$union, Spec_FormSpec$1, Spec_FormSpec$1_$reflection, Spec_FieldType_$reflection } from "../FormSpec.js";
9
+ import { Spec_SingleChoiceInfo, Spec_FormClassification_$union, ClinicalPathway_StateType_$union, ClinicalPathway_ReferralUrgency_$union, ClinicalPathway_ActionInfo_$union, ClinicalPathway_TaskPriority_$union, ClinicalPathway_GroupRef, ClinicalPathway_GroupChangeAction, ClinicalPathway_NavigateToFormAction, ClinicalPathway_MedsetAction, ClinicalPathway_TreatmentAction, ClinicalPathway_ProblemAction, ClinicalPathway_AlertSeverity_$union, ClinicalPathway_AlertAction, ClinicalPathway_EducationAction, ClinicalPathway_ProcedureAction, ClinicalPathway_TestAction, ClinicalPathway_DocumentationAction, ClinicalPathway_FieldValueSource_$union, ClinicalPathway_SetFieldValueAction, ClinicalPathway_PrescriptionAction, ClinicalPathway_MedicationAction, ClinicalPathway_ReferralAction, Shared_FieldValue, 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_PathwayAction, ClinicalPathway_ActionOrigin_Authored, 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_FormClassification_General, Spec_FormLifecycle_Blueprint, Spec_FieldType_Text, Spec_TextInfo, Spec_FieldType_CheckboxList, Spec_MultiChoiceInfo, Shared_FieldOptionKey, Spec_FieldType_Checkbox, Spec_BooleanInfo, Shared_FieldKey, Shared_FieldOption, Shared_FieldValue_Single, Shared_FieldValue_PluginData, Shared_PluginDataProperty, Shared_PluginPropertyKey, Shared_FieldValue_Matrix, Shared_MatrixAnswer, Shared_MatrixItemKey, Shared_FieldValue_Multiple, Shared_FieldAnswer, Spec_Label_shown, Shared_FieldValue_$union, Spec_FormStep$1, Spec_FormField$1, Spec_FieldType_$union, Spec_FormSpec$1, Spec_FormSpec$1_$reflection, Spec_FieldType_$reflection } from "../FormSpec.js";
10
10
  import { Auto_generateBoxedDecoder_Z6670B51, fromString } from "../../Thoth.Json/packages/Thoth.Json/Decode.js";
11
11
  import { FSharpResult$2_Ok, FSharpResult$2_Error, FSharpResult$2_$union } from "@fable-org/fable-library-js/Result.js";
12
12
  import { newGuid, parse, tryParse } from "@fable-org/fable-library-js/Guid.js";
@@ -538,7 +538,7 @@ export function decodeAsPluginDataArray(fieldKey: string, obj: any): { dataType:
538
538
  * TypeScript: convertFlatValuesToCanonical(formSpec: FormSpec, flatValues: Record<string, unknown>) => BlueprintFilledFormFieldValueAnswersMap
539
539
  */
540
540
  export function convertFlatValuesToCanonical(formSpec: Spec_FormSpec$1<Spec_FieldType_$union>, flatValues: any): any {
541
- let matchValue_2: ExpectedFieldValueType_$union, matrixData: { description: string, values: IMap<string, string> };
541
+ let matchValue_2: ExpectedFieldValueType_$union, matrixData: { description: string, values: IMap<string, string> }, stringValue: string;
542
542
  if (flatValues == null) {
543
543
  return {};
544
544
  }
@@ -572,11 +572,11 @@ export function convertFlatValuesToCanonical(formSpec: Spec_FormSpec$1<Spec_Fiel
572
572
  const matchValue_1: Option<Shared_FieldValue_$union> = tryDecodeFieldValueFromObject(rawValue);
573
573
  if (matchValue_1 == null) {
574
574
  const docOpt: Option<string> = orElseWith<string>(decodeAsOptionalDocumentation(rawValue), (): Option<string> => tryFind_2<string, string>(fieldKey, docMap));
575
- const canonical_1: any = Convert_fieldValueToTs((matchValue_2 = getExpectedFieldValueType(field.FieldType), (matchValue_2.tag === /* MultipleValues */ 1) ? Shared_FieldValue_Multiple(ofArray_1<Shared_FieldAnswer>(mapIndexed<string, Shared_FieldAnswer>((i: int32, value_1: string): Shared_FieldAnswer => (new Shared_FieldAnswer(field.FieldKey, field.Label, value_1, (i === 0) ? docOpt : undefined)), decodeAsStringArray(fieldKey, rawValue)), {
575
+ const canonical_1: any = Convert_fieldValueToTs((matchValue_2 = getExpectedFieldValueType(field.FieldType), (matchValue_2.tag === /* MultipleValues */ 1) ? Shared_FieldValue_Multiple(ofArray_1<Shared_FieldAnswer>(mapIndexed<string, Shared_FieldAnswer>((i: int32, value_1: string): Shared_FieldAnswer => (new Shared_FieldAnswer(field.FieldKey, Spec_Label_shown(field.Label), value_1, (i === 0) ? docOpt : undefined)), decodeAsStringArray(fieldKey, rawValue)), {
576
576
  Compare: compare,
577
577
  })) : ((matchValue_2.tag === /* MatrixValue */ 2) ? ((matrixData = decodeAsMatrixValue(fieldKey, rawValue), Shared_FieldValue_Matrix(new Shared_MatrixAnswer(field.FieldKey, matrixData.description, ofSeq<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), {
578
578
  Compare: compare,
579
- }), docOpt)))) : ((matchValue_2.tag === /* PluginDataValue */ 3) ? Shared_FieldValue_PluginData(ofArray_2<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(fieldKey, rawValue)))) : Shared_FieldValue_Single(new Shared_FieldAnswer(field.FieldKey, field.Label, decodeAsString(fieldKey, rawValue), docOpt))))));
579
+ }), docOpt)))) : ((matchValue_2.tag === /* PluginDataValue */ 3) ? Shared_FieldValue_PluginData(ofArray_2<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(fieldKey, rawValue)))) : ((stringValue = decodeAsString(fieldKey, rawValue), Shared_FieldValue_Single(new Shared_FieldAnswer(field.FieldKey, Spec_Label_shown(field.Label), stringValue, docOpt))))))));
580
580
  void (resultPairs.push([fieldKey, canonical_1] as [string, any]));
581
581
  }
582
582
  else {
@@ -611,7 +611,6 @@ export function buildFormSpecWithValues(formSpec: Spec_FormSpec$1<Spec_FieldType
611
611
  const field_1: Spec_FormField$1<Spec_FieldType_$union> = tupledArg[0];
612
612
  return defaultArg_1(map_2<int32, Spec_FormSpec$1<Spec_FieldType_$union>>((stepIdx: int32): Spec_FormSpec$1<Spec_FieldType_$union> => updateField<Spec_FieldType_$union>(spec, field_1.FieldKey, tupledArg[1].FieldValue, stepIdx), findStepIndexForField<Spec_FieldType_$union>(spec, field_1.FieldKey)), spec);
613
613
  }, formSpec, ofSeq_1<[Spec_FormField$1<Spec_FieldType_$union>, FieldDetails$1<Spec_FieldType_$union>]>(choose<{ fieldKey: string, objectValue: any }, [Spec_FormField$1<Spec_FieldType_$union>, FieldDetails$1<Spec_FieldType_$union>]>((input_1: { fieldKey: string, objectValue: any }): Option<[Spec_FormField$1<Spec_FieldType_$union>, FieldDetails$1<Spec_FieldType_$union>]> => {
614
- let matchValue_1: Option<Shared_FieldValue_$union>, matchValue_2: Spec_FieldType_$union;
615
614
  const matchValue: Option<Spec_FormField$1<Spec_FieldType_$union>> = findFieldByKey(formSpec, input_1.fieldKey);
616
615
  if (matchValue == null) {
617
616
  toConsole(`Warning: Field ${input_1.fieldKey} not found in FormSpec`);
@@ -620,9 +619,18 @@ export function buildFormSpecWithValues(formSpec: Spec_FormSpec$1<Spec_FieldType
620
619
  else {
621
620
  const field: Spec_FormField$1<Spec_FieldType_$union> = value_19(matchValue);
622
621
  try {
623
- return [field, new FieldDetails$1(field.FieldOrder, field.FieldKey, field.Label, (matchValue_1 = tryDecodeFieldValueFromObject(input_1.objectValue), (matchValue_1 == null) ? (() => {
622
+ let fieldValue: Shared_FieldValue_$union;
623
+ const matchValue_1: Option<Shared_FieldValue_$union> = tryDecodeFieldValueFromObject(input_1.objectValue);
624
+ if (matchValue_1 == null) {
624
625
  throw new Error(`Field ${input_1.fieldKey}: Expected canonical discriminated format (with 'kind' tag). Got flat value. Use convertFlatValuesToCanonical() at the boundary to convert flat values before calling buildFormSpecWithValues.`);
625
- })() : value_19(matchValue_1)), 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>, FieldDetails$1<Spec_FieldType_$union>];
626
+ }
627
+ else {
628
+ fieldValue = value_19(matchValue_1);
629
+ }
630
+ let fieldOptions: FSharpList<Shared_FieldOption>;
631
+ const matchValue_2: Spec_FieldType_$union = field.FieldType;
632
+ fieldOptions = ((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>()))))))));
633
+ return [field, new FieldDetails$1(field.FieldOrder, field.FieldKey, Spec_Label_shown(field.Label), fieldValue, field.FieldType, fieldOptions)] as [Spec_FormField$1<Spec_FieldType_$union>, FieldDetails$1<Spec_FieldType_$union>];
626
634
  }
627
635
  catch (ex: any) {
628
636
  toConsole(`Error processing field ${input_1.fieldKey}: ${ex.message}`);
@@ -732,7 +740,7 @@ export function createPluginField(fieldKeyString: string, label: string, config:
732
740
  * TypeScript: createActionState(stateKey: string, label: string, taskDescription: string, priority?: string)
733
741
  */
734
742
  export function createActionState(stateKeyString: string, label: string, taskDescription: string, priority: Option<string>): ClinicalPathway_StateDefinition {
735
- return new ClinicalPathway_StateDefinition(new Shared_StateKey(parse(stateKeyString)), label, 1, ClinicalPathway_StateType_Action(ClinicalPathway_ActionInfo_Task(new ClinicalPathway_TaskAction(undefined, "Clinical", taskDescription, (priority != null) ? ((value_19(priority) === "High") ? ClinicalPathway_TaskPriority_High() : ((value_19(priority) === "Low") ? ClinicalPathway_TaskPriority_Low() : ClinicalPathway_TaskPriority_Medium())) : ClinicalPathway_TaskPriority_Medium(), ClinicalPathway_DueDate_Today(), "Clinical Staff", undefined))), undefined);
743
+ return new ClinicalPathway_StateDefinition(new Shared_StateKey(parse(stateKeyString)), label, 1, ClinicalPathway_StateType_Action(new ClinicalPathway_PathwayAction(ClinicalPathway_ActionInfo_Task(new ClinicalPathway_TaskAction(undefined, "Clinical", taskDescription, (priority != null) ? ((value_19(priority) === "High") ? ClinicalPathway_TaskPriority_High() : ((value_19(priority) === "Low") ? ClinicalPathway_TaskPriority_Low() : ClinicalPathway_TaskPriority_Medium())) : ClinicalPathway_TaskPriority_Medium(), ClinicalPathway_DueDate_Today(), "Clinical Staff", undefined)), ClinicalPathway_ActionOrigin_Authored())), undefined);
736
744
  }
737
745
 
738
746
  /**
@@ -1174,7 +1182,7 @@ export function extractFormValuesFromFormSpec(spec: Spec_FormSpec$1<Spec_FieldTy
1174
1182
  * TypeScript: convertActionInfo(action: ActionInfo) => {type: string, description: string, ...}
1175
1183
  */
1176
1184
  export function convertActionInfo(action: ClinicalPathway_ActionInfo_$union): any {
1177
- let matchValue_1: ClinicalPathway_ReferralUrgency_$union, matchValue_3: ClinicalPathway_AlertSeverity_$union, matchValue: ClinicalPathway_TaskPriority_$union;
1185
+ let matchValue_1: ClinicalPathway_ReferralUrgency_$union;
1178
1186
  switch (action.tag) {
1179
1187
  case /* Referral */ 4: {
1180
1188
  const referral: ClinicalPathway_ReferralAction = action.fields[0];
@@ -1264,26 +1272,38 @@ export function convertActionInfo(action: ClinicalPathway_ActionInfo_$union): an
1264
1272
  return {
1265
1273
  category: alert.Category,
1266
1274
  description: alert.Message,
1267
- severity: (matchValue_3 = alert.Severity, (matchValue_3.tag === /* High */ 2) ? "high" : ((matchValue_3.tag === /* Medium */ 1) ? "medium" : ((matchValue_3.tag === /* Low */ 0) ? "low" : "critical"))),
1275
+ severity: toNullable<string>(map_2<ClinicalPathway_AlertSeverity_$union, string>((_arg: ClinicalPathway_AlertSeverity_$union): string => {
1276
+ switch (_arg.tag) {
1277
+ case /* High */ 2:
1278
+ return "high";
1279
+ case /* Medium */ 1:
1280
+ return "medium";
1281
+ case /* Low */ 0:
1282
+ return "low";
1283
+ default:
1284
+ return "critical";
1285
+ }
1286
+ }, alert.Severity)),
1268
1287
  type: "alert",
1269
1288
  };
1270
1289
  }
1271
1290
  case /* Problem */ 10: {
1272
1291
  const prob: ClinicalPathway_ProblemAction = action.fields[0];
1292
+ const icdStr: string = defaultArg_1(map_2<string, string>((code: string): string => (` (ICD: ${code})`), prob.IcdCode), "");
1273
1293
  return {
1274
- description: `${prob.ProblemName}${defaultArg_1(map_2<string, string>((code: string): string => (` (ICD: ${code})`), prob.IcdCode), "")}`,
1294
+ description: `${defaultArg<string>(prob.ProblemName, "")}${icdStr}`,
1275
1295
  icdCode: unwrap(prob.IcdCode),
1276
- problemName: prob.ProblemName,
1296
+ problemName: toNullable<string>(prob.ProblemName),
1277
1297
  type: "problem",
1278
1298
  };
1279
1299
  }
1280
1300
  case /* Treatment */ 1: {
1281
1301
  const t: ClinicalPathway_TreatmentAction = action.fields[0];
1282
1302
  return {
1283
- description: `Treatment: ${t.Name}`,
1303
+ description: `Treatment: ${defaultArg<string>(t.Name, "")}`,
1284
1304
  signature: unwrap(t.Signature),
1285
1305
  treatmentId: unwrap(t.TreatmentId),
1286
- treatmentName: t.Name,
1306
+ treatmentName: toNullable<string>(t.Name),
1287
1307
  type: "treatment",
1288
1308
  };
1289
1309
  }
@@ -1305,12 +1325,25 @@ export function convertActionInfo(action: ClinicalPathway_ActionInfo_$union): an
1305
1325
  type: "navigateToForm",
1306
1326
  };
1307
1327
  }
1328
+ case /* ChangeGroups */ 14: {
1329
+ const g: ClinicalPathway_GroupChangeAction = action.fields[0];
1330
+ const verb: string = (g.Change.tag === /* RemoveFromGroups */ 1) ? "remove" : "add";
1331
+ return {
1332
+ change: verb,
1333
+ description: `${verb} groups: ${join(", ", map_3<ClinicalPathway_GroupRef, string>((r: ClinicalPathway_GroupRef): string => int32ToString(r.GroupId), g.Groups))}`,
1334
+ groupIds: toArray<int32>(map_3<ClinicalPathway_GroupRef, int32>((r_1: ClinicalPathway_GroupRef): int32 => r_1.GroupId, g.Groups)),
1335
+ type: "groups",
1336
+ };
1337
+ }
1308
1338
  default: {
1309
1339
  const task: ClinicalPathway_TaskAction = action.fields[0];
1340
+ let priorityStr: string;
1341
+ const matchValue: ClinicalPathway_TaskPriority_$union = task.Priority;
1342
+ priorityStr = ((matchValue.tag === /* Medium */ 1) ? "medium" : ((matchValue.tag === /* Low */ 2) ? "low" : ((matchValue.tag === /* Stated */ 3) ? int32ToString(matchValue.fields[0]) : "high")));
1310
1343
  return {
1311
1344
  category: task.Category,
1312
- description: task.Description,
1313
- priority: (matchValue = task.Priority, (matchValue.tag === /* Medium */ 1) ? "medium" : ((matchValue.tag === /* Low */ 2) ? "low" : "high")),
1345
+ description: toNullable<string>(task.Description),
1346
+ priority: priorityStr,
1314
1347
  type: "task",
1315
1348
  };
1316
1349
  }
@@ -1318,16 +1351,34 @@ export function convertActionInfo(action: ClinicalPathway_ActionInfo_$union): an
1318
1351
  }
1319
1352
 
1320
1353
  /**
1321
- * Find the StateKey for a given ActionInfo in a ClinicalPathwaySpec
1322
- * TypeScript: stateKeyForAction(pathway: ClinicalPathwaySpec, action: ActionInfo) => string | null
1354
+ * What a view SHOWS for a step or field label: the stated text, or the "(no text)" marker (wave 8, ruling B).
1355
+ * ⭐ The ONE marker for TypeScript too — a TS view never invents its own placeholder.
1356
+ * TypeScript: shownLabel(label: Option<string>) => string
1357
+ */
1358
+ export function shownLabel(label: Option<string>): string {
1359
+ return Spec_Label_shown(label);
1360
+ }
1361
+
1362
+ /**
1363
+ * A step or field label AS STATED, for a POJO: the text, or `null` where the source states none — an explicit
1364
+ * absence, never "" and never a placeholder (wave 8, ruling B).
1365
+ * TypeScript: statedLabel(label: Option<string>) => string | null
1366
+ */
1367
+ export function statedLabel(label: Option<string>): string {
1368
+ return toNullable<string>(label);
1369
+ }
1370
+
1371
+ /**
1372
+ * Find the StateKey of the single-action state holding a given executed PathwayAction (intent AND origin)
1373
+ * TypeScript: stateKeyForAction(pathway: ClinicalPathwaySpec, action: PathwayAction) => string | null
1323
1374
  */
1324
- export function stateKeyForAction(pathway: ClinicalPathway_ClinicalPathwaySpec, action: ClinicalPathway_ActionInfo_$union): Option<string> {
1375
+ export function stateKeyForAction(pathway: ClinicalPathway_ClinicalPathwaySpec, action: ClinicalPathway_PathwayAction): Option<string> {
1325
1376
  toConsole(printf("PathwayId: %A"))(pathway.PathwayId);
1326
1377
  toConsole(printf("Finding state key for action: %A"))(action);
1327
1378
  return tryPick<ClinicalPathway_StateDefinition, string>((state: ClinicalPathway_StateDefinition): Option<string> => {
1328
1379
  const matchValue: ClinicalPathway_StateType_$union = state.StateType;
1329
- let matchResult: int32, actionInfo_1: ClinicalPathway_ActionInfo_$union;
1330
- if (matchValue.tag === /* Action */ 2) {
1380
+ let matchResult: int32, actionInfo_1: ClinicalPathway_PathwayAction;
1381
+ if (matchValue.tag === /* Action */ 1) {
1331
1382
  if (equals(matchValue.fields[0], action)) {
1332
1383
  matchResult = 0;
1333
1384
  actionInfo_1 = matchValue.fields[0];
@@ -1651,7 +1702,7 @@ export function getFullValidationTelemetry(formSpec: Spec_FormSpec$1<Spec_FieldT
1651
1702
  const fieldTelemetry: { actionHint: string, actualChoices: string[], actualValue: string, dataIssues: string[], dataValid: boolean, expectedChoices: string[], expectedValue: string, fieldKey: string, fieldLabel: string, fieldType: string, severity: string, structureIssues: any[], structureValid: boolean }[] = toArray<{ actionHint: string, actualChoices: string[], actualValue: string, dataIssues: string[], dataValid: boolean, expectedChoices: string[], expectedValue: string, fieldKey: string, fieldLabel: string, fieldType: string, severity: string, structureIssues: any[], structureValid: boolean }>(map_3<Spec_FormField$1<Spec_FieldType_$union>, { actionHint: string, actualChoices: string[], actualValue: string, dataIssues: string[], dataValid: boolean, expectedChoices: string[], expectedValue: string, fieldKey: string, fieldLabel: string, fieldType: string, severity: string, structureIssues: any[], structureValid: boolean }>((field: Spec_FormField$1<Spec_FieldType_$union>): { actionHint: string, actualChoices: string[], actualValue: string, dataIssues: string[], dataValid: boolean, expectedChoices: string[], expectedValue: string, fieldKey: string, fieldLabel: string, fieldType: string, severity: string, structureIssues: any[], structureValid: boolean } => {
1652
1703
  let matchValue_2: Spec_FieldType_$union;
1653
1704
  const fieldKey: string = getFieldKeyString(field.FieldKey);
1654
- const fieldLabel: string = isNullOrEmpty(field.Label) ? fieldKey : field.Label;
1705
+ const fieldLabel: string = Spec_Label_shown(field.Label);
1655
1706
  const fieldTypeInfo: { isRequired: boolean, typeName: string } = getFieldTypeInfo(field);
1656
1707
  const fieldValue: Option<any> = tryFind_2<string, any>(fieldKey, valuesDict);
1657
1708
  let patternInput: [boolean, any[], string[], string[]];
@@ -271,7 +271,7 @@ export function Types_DependsOnTS_$reflection(): TypeInfo {
271
271
  export class Types_FormFieldTS extends Record implements IEquatable<Types_FormFieldTS> {
272
272
  readonly FieldOrder: int32;
273
273
  readonly FieldKey: Types_FieldKeyTS;
274
- readonly Label: string;
274
+ readonly Label: Option<string>;
275
275
  readonly Notes: Option<string>;
276
276
  readonly DependsOn: Option<Types_DependsOnTS>;
277
277
  readonly IsOptional: boolean;
@@ -279,7 +279,7 @@ export class Types_FormFieldTS extends Record implements IEquatable<Types_FormFi
279
279
  readonly NeedsDocumentation: boolean;
280
280
  readonly FieldType: Types_FieldTypeTS;
281
281
  readonly Value: Option<any>;
282
- constructor(FieldOrder: int32, FieldKey: Types_FieldKeyTS, Label: string, Notes: Option<string>, DependsOn: Option<Types_DependsOnTS>, IsOptional: boolean, IsDeprecated: boolean, NeedsDocumentation: boolean, FieldType: Types_FieldTypeTS, Value: Option<any>) {
282
+ constructor(FieldOrder: int32, FieldKey: Types_FieldKeyTS, Label: Option<string>, Notes: Option<string>, DependsOn: Option<Types_DependsOnTS>, IsOptional: boolean, IsDeprecated: boolean, NeedsDocumentation: boolean, FieldType: Types_FieldTypeTS, Value: Option<any>) {
283
283
  super();
284
284
  this.FieldOrder = (FieldOrder | 0);
285
285
  this.FieldKey = FieldKey;
@@ -295,14 +295,14 @@ export class Types_FormFieldTS extends Record implements IEquatable<Types_FormFi
295
295
  }
296
296
 
297
297
  export function Types_FormFieldTS_$reflection(): TypeInfo {
298
- return record_type("F1.Studio.FormSpec.Interop.OptionBased.Types.FormFieldTS", [], Types_FormFieldTS, () => [["FieldOrder", int32_type], ["FieldKey", Types_FieldKeyTS_$reflection()], ["Label", string_type], ["Notes", option_type(string_type)], ["DependsOn", option_type(Types_DependsOnTS_$reflection())], ["IsOptional", bool_type], ["IsDeprecated", bool_type], ["NeedsDocumentation", bool_type], ["FieldType", Types_FieldTypeTS_$reflection()], ["Value", option_type(obj_type)]]);
298
+ return record_type("F1.Studio.FormSpec.Interop.OptionBased.Types.FormFieldTS", [], Types_FormFieldTS, () => [["FieldOrder", int32_type], ["FieldKey", Types_FieldKeyTS_$reflection()], ["Label", option_type(string_type)], ["Notes", option_type(string_type)], ["DependsOn", option_type(Types_DependsOnTS_$reflection())], ["IsOptional", bool_type], ["IsDeprecated", bool_type], ["NeedsDocumentation", bool_type], ["FieldType", Types_FieldTypeTS_$reflection()], ["Value", option_type(obj_type)]]);
299
299
  }
300
300
 
301
301
  export class Types_FormStepTS extends Record implements IEquatable<Types_FormStepTS> {
302
302
  readonly StepOrder: int32;
303
- readonly StepLabel: string;
303
+ readonly StepLabel: Option<string>;
304
304
  readonly Fields: Types_FormFieldTS[];
305
- constructor(StepOrder: int32, StepLabel: string, Fields: Types_FormFieldTS[]) {
305
+ constructor(StepOrder: int32, StepLabel: Option<string>, Fields: Types_FormFieldTS[]) {
306
306
  super();
307
307
  this.StepOrder = (StepOrder | 0);
308
308
  this.StepLabel = StepLabel;
@@ -311,7 +311,7 @@ export class Types_FormStepTS extends Record implements IEquatable<Types_FormSte
311
311
  }
312
312
 
313
313
  export function Types_FormStepTS_$reflection(): TypeInfo {
314
- return record_type("F1.Studio.FormSpec.Interop.OptionBased.Types.FormStepTS", [], Types_FormStepTS, () => [["StepOrder", int32_type], ["StepLabel", string_type], ["Fields", array_type(Types_FormFieldTS_$reflection())]]);
314
+ return record_type("F1.Studio.FormSpec.Interop.OptionBased.Types.FormStepTS", [], Types_FormStepTS, () => [["StepOrder", int32_type], ["StepLabel", option_type(string_type)], ["Fields", array_type(Types_FormFieldTS_$reflection())]]);
315
315
  }
316
316
 
317
317
  export class Types_ScoreRangeTS extends Record implements IEquatable<Types_ScoreRangeTS>, IComparable<Types_ScoreRangeTS> {