@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
@@ -1,12 +1,37 @@
1
- import { ClinicalPathway_ActionInfo_$union, ClinicalPathway_MedsetAction, ClinicalPathway_TreatmentAction, ClinicalPathway_ProblemAction, ClinicalPathway_AlertAction, ClinicalPathway_RecurrencePattern, ClinicalPathway_RecurrenceEnd_$union, ClinicalPathway_TaskAction, ClinicalPathway_DueDate_$union, ClinicalPathway_TaskPriority_$union } from "./FormSpec.js";
2
- import { int32 } from "@fable-org/fable-library-js/Int32.js";
3
1
  import { fromDateTimeOffset, today, addDays, toString } from "@fable-org/fable-library-js/Date.js";
4
- import { orElse, defaultArg, map, Option, value as value_2 } from "@fable-org/fable-library-js/Option.js";
5
- import { FSharpList, choose } from "@fable-org/fable-library-js/List.js";
6
- import { TriggerAction } from "../vye-os-contracts-fs/src/Clinical/TriggerAction.js";
2
+ import { Result_Map, FSharpResult$2_$union, FSharpResult$2_Error, FSharpResult$2_Ok } from "@fable-org/fable-library-js/Result.js";
3
+ import { int32 } from "@fable-org/fable-library-js/Int32.js";
4
+ import { ClinicalPathway_ActionInfo_$union, ClinicalPathway_TaskAction, ClinicalPathway_MedsetAction, ClinicalPathway_TreatmentAction, ClinicalPathway_ProblemAction, ClinicalPathway_AlertAction, ClinicalPathway_StandingSchedule, ClinicalPathway_Cadence_$union, ClinicalPathway_TaskPriority_$union, ClinicalPathway_DueDate_$union } from "./FormSpec.js";
5
+ import { bind, map, defaultArg, Option, value } from "@fable-org/fable-library-js/Option.js";
6
+ import { Union } from "@fable-org/fable-library-js/Types.js";
7
+ import { TriggerAction_$reflection, TriggerAction } from "../vye-os-contracts-fs/src/Clinical/TriggerAction.js";
8
+ import { union_type, string_type, TypeInfo } from "@fable-org/fable-library-js/Reflection.js";
7
9
 
8
10
  /**
9
- * Convert ClinicalPathway.TaskPriority DU → CoreMR int (1=High, 2=Medium, 3=Low)
11
+ * Convert ClinicalPathway.DueDate DU → date-only string (yyyy-MM-dd), or the reason it cannot be dated.
12
+ * Date-only format avoids timezone offset issues — the conduit computes date_end as end-of-day from the date portion.
13
+ * ⛔ `AsStated` is the source's own expression ("+2 months", "+1 hours next monday"); f1 cannot date it exactly, so
14
+ * it is NOT WRITTEN rather than guessed (CTA-033).
15
+ */
16
+ export function convertDueDate(dueDate: ClinicalPathway_DueDate_$union): FSharpResult$2_$union<string, string> {
17
+ switch (dueDate.tag) {
18
+ case /* Tomorrow */ 1:
19
+ return FSharpResult$2_Ok<string, string>(toString(addDays(today(), 1), "yyyy-MM-dd"));
20
+ case /* DaysFromNow */ 2: {
21
+ const days: int32 = dueDate.fields[0] | 0;
22
+ return FSharpResult$2_Ok<string, string>(toString(addDays(today(), days), "yyyy-MM-dd"));
23
+ }
24
+ case /* SpecificDate */ 3:
25
+ return FSharpResult$2_Ok<string, string>(toString(fromDateTimeOffset(dueDate.fields[0], 0), "yyyy-MM-dd"));
26
+ case /* AsStated */ 4:
27
+ return FSharpResult$2_Error<string, string>(`due "${dueDate.fields[0]}" is the source's own expression and cannot be dated by f1`);
28
+ default:
29
+ return FSharpResult$2_Ok<string, string>(toString(today(), "yyyy-MM-dd"));
30
+ }
31
+ }
32
+
33
+ /**
34
+ * Convert ClinicalPathway.TaskPriority DU → CoreMR int (1=High, 2=Medium, 3=Low; a stated band verbatim).
10
35
  */
11
36
  export function convertPriority(priority: ClinicalPathway_TaskPriority_$union): int32 {
12
37
  switch (priority.tag) {
@@ -14,99 +39,247 @@ export function convertPriority(priority: ClinicalPathway_TaskPriority_$union):
14
39
  return 2;
15
40
  case /* Low */ 2:
16
41
  return 3;
42
+ case /* Stated */ 3:
43
+ return priority.fields[0] | 0;
17
44
  default:
18
45
  return 1;
19
46
  }
20
47
  }
21
48
 
22
- /**
23
- * Convert ClinicalPathway.DueDate DU → date-only string (yyyy-MM-dd).
24
- * Date-only format avoids timezone offset issues — the conduit computes
25
- * date_end as end-of-day from the date portion.
26
- */
27
- export function convertDueDate(dueDate: ClinicalPathway_DueDate_$union): string {
28
- switch (dueDate.tag) {
29
- case /* Tomorrow */ 1:
30
- return toString(addDays(today(), 1), "yyyy-MM-dd");
31
- case /* DaysFromNow */ 2: {
32
- const days: int32 = dueDate.fields[0] | 0;
33
- return toString(addDays(today(), days), "yyyy-MM-dd");
34
- }
35
- case /* SpecificDate */ 3:
36
- return toString(fromDateTimeOffset(dueDate.fields[0], 0), "yyyy-MM-dd");
37
- default:
38
- return toString(today(), "yyyy-MM-dd");
49
+ function requireCategoryId(categoryName: string, categoryIdOpt: Option<int32>): FSharpResult$2_$union<int32, string> {
50
+ if (categoryIdOpt == null) {
51
+ return FSharpResult$2_Error<int32, string>(`it states no categoryId (category '${categoryName}'), and CoreMR records every action under one`);
52
+ }
53
+ else if (value(categoryIdOpt) > 0) {
54
+ const id_1: int32 = value(categoryIdOpt) | 0;
55
+ return FSharpResult$2_Ok<int32, string>(id_1);
56
+ }
57
+ else {
58
+ const id_2: int32 = value(categoryIdOpt) | 0;
59
+ return FSharpResult$2_Error<int32, string>(`its categoryId ${id_2} (category '${categoryName}') is not a CoreMR id — it must be > 0`);
39
60
  }
40
61
  }
41
62
 
42
- function requireCategoryId(actionType: string, categoryName: string, categoryIdOpt: Option<int32>): int32 {
43
- if (categoryIdOpt == null) {
44
- throw new Error(`TriggerActionDto.convert: missing categoryId for actionType='${actionType}' category='${categoryName}'. CoreMR submit requires provenance category IDs.`);
63
+ export type ActionWrite_$union =
64
+ | ActionWrite<0>
65
+ | ActionWrite<1>
66
+
67
+ export type ActionWrite_$cases = {
68
+ 0: ["Written", [TriggerAction]],
69
+ 1: ["NotWritten", [string, string]]
70
+ }
71
+
72
+ export function ActionWrite_Written(Item: TriggerAction) {
73
+ return new ActionWrite<0>(0, [Item]);
74
+ }
75
+
76
+ export function ActionWrite_NotWritten(action: string, reason: string) {
77
+ return new ActionWrite<1>(1, [action, reason]);
78
+ }
79
+
80
+ export class ActionWrite<Tag extends keyof ActionWrite_$cases> extends Union<Tag, ActionWrite_$cases[Tag][0]> {
81
+ constructor(readonly tag: Tag, readonly fields: ActionWrite_$cases[Tag][1]) {
82
+ super();
83
+ }
84
+ cases() {
85
+ return ["Written", "NotWritten"];
86
+ }
87
+ }
88
+
89
+ export function ActionWrite_$reflection(): TypeInfo {
90
+ return union_type("F1.Studio.TriggerActions.ActionWrite", [], ActionWrite, () => [[["Item", TriggerAction_$reflection()]], [["action", string_type], ["reason", string_type]]]);
91
+ }
92
+
93
+ const blank: TriggerAction = new TriggerAction("", 0, 0, 0, "", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined);
94
+
95
+ function optionalDate(d: Option<ClinicalPathway_DueDate_$union>): FSharpResult$2_$union<Option<string>, string> {
96
+ if (d != null) {
97
+ return Result_Map<string, Option<string>, string>((Value: string): Option<string> => Value, convertDueDate(value(d)));
98
+ }
99
+ else {
100
+ return FSharpResult$2_Ok<Option<string>, string>(undefined);
45
101
  }
46
- else if (value_2(categoryIdOpt) > 0) {
47
- const id_1: int32 = value_2(categoryIdOpt) | 0;
48
- return id_1 | 0;
102
+ }
103
+
104
+ function scheduleIdOf(s: ClinicalPathway_StandingSchedule): Option<int32> {
105
+ const matchValue: ClinicalPathway_Cadence_$union = s.Cadence;
106
+ if (matchValue.tag === /* Every */ 1) {
107
+ return undefined;
49
108
  }
50
109
  else {
51
- const id_2: int32 = value_2(categoryIdOpt) | 0;
52
- throw new Error(`TriggerActionDto.convert: invalid categoryId=${id_2} for actionType='${actionType}' category='${categoryName}'. categoryId must be > 0.`);
110
+ return matchValue.fields[0];
53
111
  }
54
112
  }
55
113
 
56
114
  /**
57
- * BASE conversion: ClinicalPathway ActionInfo → TriggerActionDto.
58
- * Provider-agnostic — converts only Task, Alert, Problem (generic clinical actions).
59
- *
60
- * DOES NOT produce treatment or medset DTOs (those map to Medication in the pathway,
61
- * which this function skips). DOES NOT enrich with trigger IDs from provenance.
62
- *
63
- * For CoreMR publishing, use CoreMRTriggerEnrichment.convertActionsForCoreMR instead —
64
- * it calls this function internally, then adds treatment/medset DTOs and enriches
65
- * with trigger IDs from provenance.
66
- *
67
- * Direct callers: unit tests (testing base conversion logic in isolation).
68
- * Production callers: NONE (production always goes through convertActionsForCoreMR).
115
+ * BASE conversion: ONE ClinicalPathway ActionInfo → its `ActionWrite`. Vendor-free: it sets no trigger identity —
116
+ * `CoreMRTriggerEnrichment.convertActionsForCoreMR` calls this per action and adds the identity the action's ORIGIN
117
+ * states (or names an `Authored` action NOT WRITTEN).
118
+ * ⛔ NOTHING IS SKIPPED SILENTLY: an action the CoreMR write path has no home for (a group change, a medication, a
119
+ * referral, …) or whose date f1 cannot compute (`AsStated`) is `NotWritten` with its reason.
120
+ * Callers: `convertActionsForCoreMR` (production) and unit tests.
69
121
  */
70
- export function convertActionsToBaseDtos(actions: FSharpList<ClinicalPathway_ActionInfo_$union>): FSharpList<TriggerAction> {
71
- return choose<ClinicalPathway_ActionInfo_$union, TriggerAction>((action: ClinicalPathway_ActionInfo_$union): Option<TriggerAction> => {
72
- switch (action.tag) {
73
- case /* Task */ 8: {
74
- const taskAction: ClinicalPathway_TaskAction = action.fields[0];
75
- const actionType: string = (taskAction.Recurrence != null) ? "recurring_task" : "task";
76
- return new TriggerAction(actionType, 0, 0, requireCategoryId(actionType, taskAction.Category, taskAction.CategoryId), taskAction.Category, convertPriority(taskAction.Priority), taskAction.Description, convertDueDate(taskAction.DueDate), true, map<ClinicalPathway_RecurrencePattern, string>((r: ClinicalPathway_RecurrencePattern): string => {
77
- const matchValue: ClinicalPathway_RecurrenceEnd_$union = r.Until;
78
- switch (matchValue.tag) {
79
- case /* AfterOccurrences */ 1: {
80
- const n: int32 = matchValue.fields[0] | 0;
81
- return toString(addDays(today(), n), "yyyy-MM-dd");
122
+ export function convertActionToBaseDto(action: ClinicalPathway_ActionInfo_$union): ActionWrite_$union {
123
+ const notWritten = ActionWrite_NotWritten;
124
+ switch (action.tag) {
125
+ case /* Alert */ 9: {
126
+ const alertAction: ClinicalPathway_AlertAction = action.fields[0];
127
+ const matchValue_4: FSharpResult$2_$union<int32, string> = requireCategoryId(alertAction.Category, alertAction.CategoryId);
128
+ if (matchValue_4.tag === /* Ok */ 0) {
129
+ return ActionWrite_Written(new TriggerAction("alert", blank.TriggerId, blank.TriggerActionId, matchValue_4.fields[0], alertAction.Category, blank.Priority, blank.Description, blank.DateStart, blank.AllDay, blank.ScheduleEnd, blank.ProblemListId, blank.FormItemId, blank.TreatmentId, blank.ScheduleId, blank.ProviderId, blank.Signature, blank.SourceRelatedId, blank.RelatedType, blank.Chronic, blank.Severity, blank.Inflammation, blank.MedsetId, blank.PharmacyId));
130
+ }
131
+ else {
132
+ return notWritten("alert", matchValue_4.fields[0]);
133
+ }
134
+ }
135
+ case /* Problem */ 10: {
136
+ const problemAction: ClinicalPathway_ProblemAction = action.fields[0];
137
+ const name: string = defaultArg<string>(problemAction.ProblemName, "");
138
+ const matchValue_5: FSharpResult$2_$union<int32, string> = requireCategoryId(name, problemAction.CategoryId);
139
+ if (matchValue_5.tag === /* Ok */ 0) {
140
+ return ActionWrite_Written(new TriggerAction("problem", blank.TriggerId, blank.TriggerActionId, matchValue_5.fields[0], name, blank.Priority, blank.Description, blank.DateStart, blank.AllDay, blank.ScheduleEnd, blank.ProblemListId, blank.FormItemId, blank.TreatmentId, blank.ScheduleId, blank.ProviderId, blank.Signature, blank.SourceRelatedId, blank.RelatedType, problemAction.Chronic, problemAction.Severity, problemAction.Inflammation, blank.MedsetId, blank.PharmacyId));
141
+ }
142
+ else {
143
+ return notWritten("problem", matchValue_5.fields[0]);
144
+ }
145
+ }
146
+ case /* Treatment */ 1: {
147
+ const t: ClinicalPathway_TreatmentAction = action.fields[0];
148
+ const matchValue_6: FSharpResult$2_$union<string, string> = convertDueDate(t.DateStart);
149
+ const matchValue_7: FSharpResult$2_$union<Option<string>, string> = optionalDate(t.Standing.Ends);
150
+ let matchResult: int32, reason_5: string, ends_1: Option<string>, start_1: string;
151
+ const copyOfStruct_2: FSharpResult$2_$union<string, string> = matchValue_6;
152
+ if (copyOfStruct_2.tag === /* Ok */ 0) {
153
+ const copyOfStruct_3: FSharpResult$2_$union<Option<string>, string> = matchValue_7;
154
+ if (copyOfStruct_3.tag === /* Ok */ 0) {
155
+ matchResult = 1;
156
+ ends_1 = copyOfStruct_3.fields[0];
157
+ start_1 = copyOfStruct_2.fields[0];
158
+ }
159
+ else {
160
+ matchResult = 0;
161
+ reason_5 = copyOfStruct_3.fields[0];
162
+ }
163
+ }
164
+ else {
165
+ matchResult = 0;
166
+ reason_5 = copyOfStruct_2.fields[0];
167
+ }
168
+ switch (matchResult) {
169
+ case 0:
170
+ return notWritten("treatment", reason_5!);
171
+ default: {
172
+ const matchValue_9: Option<int32> = t.TreatmentId;
173
+ let matchResult_1: int32, treatmentId: int32;
174
+ if (matchValue_9 != null) {
175
+ if (value(matchValue_9) === 0) {
176
+ matchResult_1 = 0;
177
+ }
178
+ else {
179
+ matchResult_1 = 1;
180
+ treatmentId = value(matchValue_9);
82
181
  }
83
- case /* Never */ 2:
84
- return toString(addDays(today(), 7), "yyyy-MM-dd");
182
+ }
183
+ else {
184
+ matchResult_1 = 0;
185
+ }
186
+ switch (matchResult_1) {
187
+ case 0:
188
+ return notWritten("treatment", "it states no treatment id, and CoreMR orders a treatment by its id");
85
189
  default:
86
- return toString(fromDateTimeOffset(matchValue.fields[0], 0), "yyyy-MM-dd");
190
+ return ActionWrite_Written(new TriggerAction("treatment", blank.TriggerId, blank.TriggerActionId, treatmentId!, defaultArg<string>(t.Name, ""), map<ClinicalPathway_TaskPriority_$union, int32>(convertPriority, t.Priority), t.Description, start_1, blank.AllDay, ends_1, blank.ProblemListId, blank.FormItemId, treatmentId!, scheduleIdOf(t.Standing), t.ProviderId, t.Signature, t.SourceRelatedId, 3, blank.Chronic, blank.Severity, blank.Inflammation, blank.MedsetId, blank.PharmacyId));
87
191
  }
88
- }, taskAction.Recurrence), undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined);
192
+ }
89
193
  }
90
- case /* Alert */ 9: {
91
- const alertAction: ClinicalPathway_AlertAction = action.fields[0];
92
- return new TriggerAction("alert", 0, 0, requireCategoryId("alert", alertAction.Category, alertAction.CategoryId), alertAction.Category, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined);
194
+ }
195
+ case /* Medset */ 2: {
196
+ const m: ClinicalPathway_MedsetAction = action.fields[0];
197
+ const matchValue_10: FSharpResult$2_$union<string, string> = convertDueDate(m.DateStart);
198
+ if (matchValue_10.tag === /* Ok */ 0) {
199
+ const start_2: string = matchValue_10.fields[0];
200
+ const matchValue_11: Option<int32> = m.MedsetId;
201
+ let matchResult_2: int32, medsetId: int32;
202
+ if (matchValue_11 != null) {
203
+ if (value(matchValue_11) === 0) {
204
+ matchResult_2 = 0;
205
+ }
206
+ else {
207
+ matchResult_2 = 1;
208
+ medsetId = value(matchValue_11);
209
+ }
210
+ }
211
+ else {
212
+ matchResult_2 = 0;
213
+ }
214
+ switch (matchResult_2) {
215
+ case 0:
216
+ return notWritten("medset", "it states no medset id, and CoreMR orders a medset by its id");
217
+ default:
218
+ return ActionWrite_Written(new TriggerAction("medset", blank.TriggerId, blank.TriggerActionId, medsetId!, m.Name, blank.Priority, blank.Description, start_2, blank.AllDay, blank.ScheduleEnd, blank.ProblemListId, blank.FormItemId, blank.TreatmentId, blank.ScheduleId, m.ProviderId, blank.Signature, blank.SourceRelatedId, blank.RelatedType, blank.Chronic, blank.Severity, blank.Inflammation, medsetId!, m.PharmacyId));
219
+ }
220
+ }
221
+ else {
222
+ return notWritten("medset", matchValue_10.fields[0]);
93
223
  }
94
- case /* Problem */ 10: {
95
- const problemAction: ClinicalPathway_ProblemAction = action.fields[0];
96
- return new TriggerAction("problem", 0, 0, requireCategoryId("problem", problemAction.ProblemName, problemAction.CategoryId), problemAction.ProblemName, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, problemAction.Chronic, problemAction.Severity, problemAction.Inflammation, undefined, undefined);
224
+ }
225
+ case /* ChangeGroups */ 14:
226
+ return notWritten("groups", "a patient-group change: conduit has no write for patient groups");
227
+ case /* Medication */ 0:
228
+ return notWritten("medication", "the CoreMR write path has no medication action");
229
+ case /* Test */ 3:
230
+ return notWritten("test", "the CoreMR write path has no test action");
231
+ case /* Referral */ 4:
232
+ return notWritten("referral", "the CoreMR write path has no referral action");
233
+ case /* Education */ 5:
234
+ return notWritten("education", "the CoreMR write path has no education action");
235
+ case /* Procedure */ 6:
236
+ return notWritten("procedure", "the CoreMR write path has no procedure action");
237
+ case /* Documentation */ 7:
238
+ return notWritten("documentation", "the CoreMR write path has no documentation action");
239
+ case /* Prescription */ 11:
240
+ return notWritten("prescription", "the CoreMR write path has no prescription action");
241
+ case /* SetFieldValue */ 12:
242
+ return notWritten("setFieldValue", "a form-local field change, not a CoreMR record");
243
+ case /* NavigateToForm */ 13:
244
+ return notWritten("navigateToForm", "a navigation, not a CoreMR record");
245
+ default: {
246
+ const taskAction: ClinicalPathway_TaskAction = action.fields[0];
247
+ const actionType: string = (taskAction.Standing != null) ? "recurring_task" : "task";
248
+ const matchValue: FSharpResult$2_$union<string, string> = convertDueDate(taskAction.DueDate);
249
+ const matchValue_1: FSharpResult$2_$union<Option<string>, string> = optionalDate(bind<ClinicalPathway_StandingSchedule, ClinicalPathway_DueDate_$union>((s: ClinicalPathway_StandingSchedule): Option<ClinicalPathway_DueDate_$union> => s.Ends, taskAction.Standing));
250
+ let matchResult_3: int32, reason_1: string, ends: Option<string>, start: string;
251
+ const copyOfStruct: FSharpResult$2_$union<string, string> = matchValue;
252
+ if (copyOfStruct.tag === /* Ok */ 0) {
253
+ const copyOfStruct_1: FSharpResult$2_$union<Option<string>, string> = matchValue_1;
254
+ if (copyOfStruct_1.tag === /* Ok */ 0) {
255
+ matchResult_3 = 1;
256
+ ends = copyOfStruct_1.fields[0];
257
+ start = copyOfStruct.fields[0];
258
+ }
259
+ else {
260
+ matchResult_3 = 0;
261
+ reason_1 = copyOfStruct_1.fields[0];
262
+ }
97
263
  }
98
- case /* Treatment */ 1: {
99
- const t: ClinicalPathway_TreatmentAction = action.fields[0];
100
- return new TriggerAction("treatment", 0, 0, defaultArg(orElse(t.CategoryId, t.TreatmentId), 0), t.Name, map<ClinicalPathway_TaskPriority_$union, int32>(convertPriority, t.Priority), t.Description, convertDueDate(t.DateStart), undefined, convertDueDate(t.Duration), undefined, undefined, t.TreatmentId, t.ScheduleId, t.ProviderId, t.Signature, t.SourceRelatedId, 3, undefined, undefined, undefined, undefined, undefined);
264
+ else {
265
+ matchResult_3 = 0;
266
+ reason_1 = copyOfStruct.fields[0];
101
267
  }
102
- case /* Medset */ 2: {
103
- const m: ClinicalPathway_MedsetAction = action.fields[0];
104
- return new TriggerAction("medset", 0, 0, defaultArg(orElse(m.CategoryId, m.MedsetId), 0), m.Name, undefined, undefined, convertDueDate(m.DateStart), undefined, undefined, undefined, undefined, undefined, undefined, m.ProviderId, undefined, undefined, undefined, undefined, undefined, undefined, m.MedsetId, m.PharmacyId);
268
+ switch (matchResult_3) {
269
+ case 0:
270
+ return notWritten(actionType, reason_1!);
271
+ default: {
272
+ const matchValue_3: FSharpResult$2_$union<int32, string> = requireCategoryId(taskAction.Category, taskAction.CategoryId);
273
+ if (matchValue_3.tag === /* Ok */ 0) {
274
+ return ActionWrite_Written(new TriggerAction(actionType, blank.TriggerId, blank.TriggerActionId, matchValue_3.fields[0], taskAction.Category, convertPriority(taskAction.Priority), taskAction.Description, start!, true, ends!, blank.ProblemListId, blank.FormItemId, blank.TreatmentId, bind<ClinicalPathway_StandingSchedule, int32>(scheduleIdOf, taskAction.Standing), blank.ProviderId, blank.Signature, blank.SourceRelatedId, blank.RelatedType, blank.Chronic, blank.Severity, blank.Inflammation, blank.MedsetId, blank.PharmacyId));
275
+ }
276
+ else {
277
+ return notWritten(actionType, matchValue_3.fields[0]);
278
+ }
279
+ }
105
280
  }
106
- default:
107
- return undefined;
108
281
  }
109
- }, actions);
282
+ }
110
283
  }
111
284
 
112
285
  //# sourceMappingURL=TriggerActionDto.ts.map
@@ -23,7 +23,7 @@ import { collect, empty as empty_1, map as map_1, singleton, append, delay, toLi
23
23
  import { tryParse, float64, int32 } from "@fable-org/fable-library-js/Int32.js";
24
24
  import { IReactProperty } from "../../../fable_modules/Feliz.2.8.0/Types.fs.js";
25
25
  import { IStandardField$3_$reflection, IStandardField$3, IField$1, StandardRenderFieldConfig$2 } from "../../../fable_modules/Fable.Form.Simple.Bulma.5.0.1/Types.fs.js";
26
- import { Spec_FormField$1, Spec_FieldType_$union, Shared_FieldAnswer, Shared_FieldOption, Shared_FieldValue_$union, Shared_FieldKey, Shared_FieldValue_PluginData, Shared_PluginDataProperty, Shared_PluginPropertyKey, Spec_PluginFieldConfig } from "../../../FormSpec.FS/FormSpec.js";
26
+ import { Spec_FormField$1, Spec_Label_shown, Spec_FieldType_$union, Shared_FieldAnswer, Shared_FieldOption, Shared_FieldValue_$union, Shared_FieldKey, Shared_FieldValue_PluginData, Shared_PluginDataProperty, Shared_PluginPropertyKey, Spec_PluginFieldConfig } from "../../../FormSpec.FS/FormSpec.js";
27
27
  import { IPluginValueConverter } from "../../../FormSpec.FS/PluginInterface.js";
28
28
  import { Helpers_combineClasses } from "../../../fable_modules/Feliz.Bulma.3.0.0/ElementBuilders.fs.js";
29
29
  import { RenderPreviewProps$1 } from "../../../FormSpec.FS/Interfaces.js";
@@ -1315,10 +1315,10 @@ export function Form_markdownRenderer(field: Spec_FormField$1<Spec_FieldType_$un
1315
1315
  let matchValue: Shared_FieldValue_$union;
1316
1316
  const allergies: FSharpList<AllergyFinderField_AllergyEntry> = AllergyFinderField_parseAllergies((matchValue = fieldDetails.FieldValue, (matchValue.tag === /* Single */ 0) ? matchValue.fields[0].Value : ((matchValue.tag === /* PluginData */ 3) ? defaultArg(map_2<Shared_PluginDataProperty, string>((p_1: Shared_PluginDataProperty): string => p_1.Value, tryFind<Shared_PluginDataProperty>((p: Shared_PluginDataProperty): boolean => (p.Name === "allergies_json"), matchValue.fields[0])), "[]") : "[]")));
1317
1317
  if (isEmpty_1(allergies)) {
1318
- return `**${field.Label}:** *[No allergies recorded]*`;
1318
+ return `**${Spec_Label_shown(field.Label)}:** *[No allergies recorded]*`;
1319
1319
  }
1320
1320
  else {
1321
- let rows: FSharpList<string> = ofArray([`**${field.Label}**`, "", "| Allergen | Severity | Category | Reactions | Remedy |", "|----------|----------|----------|-----------|--------|"]);
1321
+ let rows: FSharpList<string> = ofArray([`**${Spec_Label_shown(field.Label)}**`, "", "| Allergen | Severity | Category | Reactions | Remedy |", "|----------|----------|----------|-----------|--------|"]);
1322
1322
  const enumerator: IEnumerator<AllergyFinderField_AllergyEntry> = getEnumerator(allergies);
1323
1323
  try {
1324
1324
  while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
@@ -16,7 +16,7 @@ import { empty, singleton, append, delay, toList } from "@fable-org/fable-librar
16
16
  import { empty as empty_1, tryFind, FSharpList, ofArray } from "@fable-org/fable-library-js/List.js";
17
17
  import { ReactElement } from "../../../fable_modules/Fable.React.Types.18.3.0/Fable.React.fs.js";
18
18
  import { IStandardField$3_$reflection, IStandardField$3, IField$1, StandardRenderFieldConfig$2 } from "../../../fable_modules/Fable.Form.Simple.Bulma.5.0.1/Types.fs.js";
19
- import { Spec_FormField$1, Spec_FieldType_$union, Shared_FieldOption, Shared_FieldValue_$union, Shared_FieldKey, Shared_FieldValue_PluginData, Shared_PluginDataProperty, Shared_PluginPropertyKey, Spec_PluginFieldConfig } from "../../../FormSpec.FS/FormSpec.js";
19
+ import { Spec_FormField$1, Spec_Label_shown, Spec_FieldType_$union, Shared_FieldOption, Shared_FieldValue_$union, Shared_FieldKey, Shared_FieldValue_PluginData, Shared_PluginDataProperty, Shared_PluginPropertyKey, Spec_PluginFieldConfig } from "../../../FormSpec.FS/FormSpec.js";
20
20
  import { FSharpResult$2_$union, FSharpResult$2_Error, FSharpResult$2_Ok } from "@fable-org/fable-library-js/Result.js";
21
21
  import { IPluginValueConverter } from "../../../FormSpec.FS/PluginInterface.js";
22
22
  import { RenderPreviewProps$1 } from "../../../FormSpec.FS/Interfaces.js";
@@ -453,20 +453,27 @@ export function Form_designerPreview(props: RenderPreviewProps$1<Spec_FieldType_
453
453
  }
454
454
 
455
455
  export function Form_markdownRenderer(field: Spec_FormField$1<Spec_FieldType_$union>, fieldDetails: FieldDetails): string {
456
- let matchValue_1: string;
457
456
  let value: string;
458
457
  const matchValue: Shared_FieldValue_$union = fieldDetails.FieldValue;
459
458
  value = ((matchValue.tag === /* Single */ 0) ? matchValue.fields[0].Value : "");
460
459
  if (isNullOrWhiteSpace(value)) {
461
- return `**${field.Label}:** *[No data entered]*`;
460
+ return `**${Spec_Label_shown(field.Label)}:** *[No data entered]*`;
462
461
  }
463
462
  else {
464
463
  try {
465
464
  const bmiData: BMIField_BMIData = BMIField_parseBMIData(value);
466
- return ((((bmiData.Height > 0) && (bmiData.Weight > 0)) && (bmiData.BMI != null)) && (bmiData.Category != null)) ? join("\n", [`**${field.Label}** ${(matchValue_1 = value_90(bmiData.Category), (matchValue_1 === "Underweight") ? "⚖️" : ((matchValue_1 === "Normal weight") ? "✅" : ((matchValue_1 === "Overweight") ? "⚠️" : ((matchValue_1 === "Obese") ? "🚨" : "📊"))))}`, "", "| Metric | Value |", "|--------|-------|", `| **Height** | %P(F1) cm |`, `| **Weight** | %P(F1) kg |`, `| **BMI** | **%P(F1)** |`, `| **Category** | **${value_90(bmiData.Category)}** |`, "", "> 💡 *BMI is calculated as weight (kg) divided by height (m) squared*"]) : (`**${field.Label}:** *[Incomplete data: Height=%P(F1)cm, Weight=%P(F1)kg]*`);
465
+ if ((((bmiData.Height > 0) && (bmiData.Weight > 0)) && (bmiData.BMI != null)) && (bmiData.Category != null)) {
466
+ let emoji: string;
467
+ const matchValue_1: string = value_90(bmiData.Category);
468
+ emoji = ((matchValue_1 === "Underweight") ? "⚖️" : ((matchValue_1 === "Normal weight") ? "✅" : ((matchValue_1 === "Overweight") ? "⚠️" : ((matchValue_1 === "Obese") ? "🚨" : "📊"))));
469
+ return join("\n", [`**${Spec_Label_shown(field.Label)}** ${emoji}`, "", "| Metric | Value |", "|--------|-------|", `| **Height** | %P(F1) cm |`, `| **Weight** | %P(F1) kg |`, `| **BMI** | **%P(F1)** |`, `| **Category** | **${value_90(bmiData.Category)}** |`, "", "> 💡 *BMI is calculated as weight (kg) divided by height (m) squared*"]);
470
+ }
471
+ else {
472
+ return `**${Spec_Label_shown(field.Label)}:** *[Incomplete data: Height=%P(F1)cm, Weight=%P(F1)kg]*`;
473
+ }
467
474
  }
468
475
  catch (ex: any) {
469
- return `**${field.Label}:** *[Error processing data: ${ex.message}]*`;
476
+ return `**${Spec_Label_shown(field.Label)}:** *[Error processing data: ${ex.message}]*`;
470
477
  }
471
478
  }
472
479
  }
@@ -6,7 +6,7 @@ import { mapValues, Field$3, IAttributes } from "../../../fable_modules/Fable.Fo
6
6
  import { Form$3, FieldConfig$4, field as field_1 } from "../../../fable_modules/Fable.Form.3.0.0/Base.fs.js";
7
7
  import { join, split, isNullOrWhiteSpace, isNullOrEmpty } from "@fable-org/fable-library-js/String.js";
8
8
  import { newGuid } from "@fable-org/fable-library-js/Guid.js";
9
- import { Spec_FormField$1, Spec_FieldType_$union, Shared_FieldValue_$union, Shared_FieldKey, Shared_FieldValue_PluginData, Shared_PluginDataProperty, Shared_PluginPropertyKey, Spec_PluginFieldConfig, Shared_FieldOption, Shared_FieldOptionKey } from "../../../FormSpec.FS/FormSpec.js";
9
+ import { Spec_FormField$1, Spec_Label_shown, Spec_FieldType_$union, Shared_FieldValue_$union, Shared_FieldKey, Shared_FieldValue_PluginData, Shared_PluginDataProperty, Shared_PluginPropertyKey, Spec_PluginFieldConfig, Shared_FieldOption, Shared_FieldOptionKey } from "../../../FormSpec.FS/FormSpec.js";
10
10
  import { empty as empty_1, tryFind, FSharpList, ofArray } from "@fable-org/fable-library-js/List.js";
11
11
  import { item } from "@fable-org/fable-library-js/Array.js";
12
12
  import { int32 } from "@fable-org/fable-library-js/Int32.js";
@@ -464,7 +464,7 @@ export function Form_markdownRenderer(field: Spec_FormField$1<Spec_FieldType_$un
464
464
  const matchValue: Shared_FieldValue_$union = fieldDetails.FieldValue;
465
465
  value = ((matchValue.tag === /* Single */ 0) ? matchValue.fields[0].Value : "");
466
466
  if (isNullOrWhiteSpace(value)) {
467
- return `**${field.Label}:** *[No demographics recorded]*`;
467
+ return `**${Spec_Label_shown(field.Label)}:** *[No demographics recorded]*`;
468
468
  }
469
469
  else {
470
470
  try {
@@ -489,12 +489,12 @@ export function Form_markdownRenderer(field: Spec_FormField$1<Spec_FieldType_$un
489
489
  if (data.MRN != null) {
490
490
  void (parts.push(`MRN: ${value_40(data.MRN)}`));
491
491
  }
492
- return (parts.length > 0) ? ((`**${field.Label}**
492
+ return (parts.length > 0) ? ((`**${Spec_Label_shown(field.Label)}**
493
493
 
494
- `) + join("\n", map_1<string, string>((p: string): string => ("- " + p), parts))) : (`**${field.Label}:** *[No demographics recorded]*`);
494
+ `) + join("\n", map_1<string, string>((p: string): string => ("- " + p), parts))) : (`**${Spec_Label_shown(field.Label)}:** *[No demographics recorded]*`);
495
495
  }
496
496
  catch (ex: any) {
497
- return `**${field.Label}:** *[Error: ${ex.message}]*`;
497
+ return `**${Spec_Label_shown(field.Label)}:** *[Error: ${ex.message}]*`;
498
498
  }
499
499
  }
500
500
  }
@@ -14,7 +14,7 @@ import { map as map_2, defaultArg, some, value as value_47, Option } from "@fabl
14
14
  import { reactApi } from "../../../fable_modules/Feliz.2.8.0/Interop.fs.js";
15
15
  import { tryParse, int32 } from "@fable-org/fable-library-js/Int32.js";
16
16
  import { IStandardField$3_$reflection, IStandardField$3, IField$1, StandardRenderFieldConfig$2 } from "../../../fable_modules/Fable.Form.Simple.Bulma.5.0.1/Types.fs.js";
17
- import { Spec_FormField$1, Shared_FieldAnswer, Spec_FieldType_$union, Shared_MatrixAnswer, Shared_FieldOption, Shared_MatrixItemKey, Shared_FieldValue_$union, Shared_FieldKey, Shared_FieldValue_PluginData, Shared_PluginDataProperty, Shared_PluginPropertyKey, Spec_PluginFieldConfig } from "../../../FormSpec.FS/FormSpec.js";
17
+ import { Spec_FormField$1, Spec_Label_shown, Shared_FieldAnswer, Spec_FieldType_$union, Shared_MatrixAnswer, Shared_FieldOption, Shared_MatrixItemKey, Shared_FieldValue_$union, Shared_FieldKey, Shared_FieldValue_PluginData, Shared_PluginDataProperty, Shared_PluginPropertyKey, Spec_PluginFieldConfig } from "../../../FormSpec.FS/FormSpec.js";
18
18
  import { tryParse as tryParse_1 } from "@fable-org/fable-library-js/Guid.js";
19
19
  import { FSharpResult$2_$union, FSharpResult$2_Ok } from "@fable-org/fable-library-js/Result.js";
20
20
  import { IPluginValueConverter } from "../../../FormSpec.FS/PluginInterface.js";
@@ -396,10 +396,10 @@ export function Form_markdownRenderer(field: Spec_FormField$1<Spec_FieldType_$un
396
396
  const pairs: FSharpList<[string, string]> = Form_parseLikertSerialized(answer.Value);
397
397
  if (isEmpty_2(pairs)) {
398
398
  if (isNullOrWhiteSpace(answer.Value)) {
399
- return `**${field.Label}:** *No responses provided*`;
399
+ return `**${Spec_Label_shown(field.Label)}:** *No responses provided*`;
400
400
  }
401
401
  else {
402
- return `**${field.Label}:** ${answer.Value}`;
402
+ return `**${Spec_Label_shown(field.Label)}:** ${answer.Value}`;
403
403
  }
404
404
  }
405
405
  else {
@@ -422,28 +422,32 @@ export function Form_markdownRenderer(field: Spec_FormField$1<Spec_FieldType_$un
422
422
  const optionScoreMap: FSharpMap<string, int32> = ofList<string, int32>(choose_1<Shared_FieldOption, [string, int32]>((o_2: Shared_FieldOption): Option<[string, int32]> => map_2<int32, [string, int32]>((sc: int32): [string, int32] => ([o_2.Value, sc] as [string, int32]), o_2.Score), options), {
423
423
  Compare: comparePrimitives,
424
424
  });
425
- return join("\n", append_1(ofArray([`**${field.Label}** 📊`, "", "| Item | Rating |", "|------|--------|"]), append_1(map_1<[string, string], string>((tupledArg_2: [string, string]): string => {
425
+ const valueRows_1: FSharpList<string> = map_1<[string, string], string>((tupledArg_2: [string, string]): string => {
426
426
  const itemKey_1: string = tupledArg_2[0];
427
427
  const optValue: string = tupledArg_2[1];
428
428
  return `| ${defaultArg(tryFind<string, string>(itemKey_1, itemLabelMap), itemKey_1)} | **${defaultArg(tryFind<string, string>(optValue, optionLabelMap), optValue)}** |`;
429
- }, pairs), ofArray(["", `> **Total Score:** ${sum<int32>(choose_1<[string, string], int32>((tupledArg_3: [string, string]): Option<int32> => tryFind<string, int32>(tupledArg_3[1], optionScoreMap), pairs), {
429
+ }, pairs);
430
+ const totalScore_1: int32 = sum<int32>(choose_1<[string, string], int32>((tupledArg_3: [string, string]): Option<int32> => tryFind<string, int32>(tupledArg_3[1], optionScoreMap), pairs), {
430
431
  GetZero: (): int32 => 0,
431
432
  Add: (x_4: int32, y_4: int32): int32 => (x_4 + y_4),
432
- })} (${length<[string, string]>(pairs)} items rated)`]))));
433
+ }) | 0;
434
+ const itemCount_1: int32 = length<[string, string]>(pairs) | 0;
435
+ return join("\n", append_1(ofArray([`**${Spec_Label_shown(field.Label)}** 📊`, "", "| Item | Rating |", "|------|--------|"]), append_1(valueRows_1, ofArray(["", `> **Total Score:** ${totalScore_1} (${itemCount_1} items rated)`]))));
433
436
  }
434
437
  }
435
438
  case /* Multiple */ 1:
436
- return `**${field.Label}:** *Multiple values (unexpected format)*`;
439
+ return `**${Spec_Label_shown(field.Label)}:** *Multiple values (unexpected format)*`;
437
440
  case /* PluginData */ 3:
438
- return `**${field.Label}:** *Plugin data (use plugin-specific export)*`;
441
+ return `**${Spec_Label_shown(field.Label)}:** *Plugin data (use plugin-specific export)*`;
439
442
  default: {
440
443
  const matrixAnswer: Shared_MatrixAnswer = matchValue.fields[0];
441
444
  const itemCount: int32 = FSharpMap__get_Count(matrixAnswer.Values) | 0;
442
445
  if (itemCount === 0) {
443
- return `**${field.Label}:** *No responses provided*`;
446
+ return `**${Spec_Label_shown(field.Label)}:** *No responses provided*`;
444
447
  }
445
448
  else {
446
- return join("\n", append_1(ofArray([`**${field.Label}** 📊`, "", "| Item | Rating |", "|------|--------|"]), append_1(map_1<[Shared_MatrixItemKey, string], string>((tupledArg: [Shared_MatrixItemKey, string]): string => (`| ${substring(tupledArg[0].fields[0], 0, 8)} | **${tupledArg[1]}** |`), toList_1<Shared_MatrixItemKey, string>(matrixAnswer.Values)), ofArray(["", `> **Total Score:** ${sum<int32>(choose_1<[Shared_MatrixItemKey, string], int32>((tupledArg_1: [Shared_MatrixItemKey, string]): Option<int32> => {
449
+ const valueRows: FSharpList<string> = map_1<[Shared_MatrixItemKey, string], string>((tupledArg: [Shared_MatrixItemKey, string]): string => (`| ${substring(tupledArg[0].fields[0], 0, 8)} | **${tupledArg[1]}** |`), toList_1<Shared_MatrixItemKey, string>(matrixAnswer.Values));
450
+ const totalScore: int32 = sum<int32>(choose_1<[Shared_MatrixItemKey, string], int32>((tupledArg_1: [Shared_MatrixItemKey, string]): Option<int32> => {
447
451
  let matchValue_1: [boolean, int32];
448
452
  let outArg = 0;
449
453
  matchValue_1 = ([tryParse(tupledArg_1[1], 511, false, 32, new FSharpRef<int32>((): int32 => outArg, (v_1: int32): void => {
@@ -458,7 +462,8 @@ export function Form_markdownRenderer(field: Spec_FormField$1<Spec_FieldType_$un
458
462
  }, toList_1<Shared_MatrixItemKey, string>(matrixAnswer.Values)), {
459
463
  GetZero: (): int32 => 0,
460
464
  Add: (x: int32, y: int32): int32 => (x + y),
461
- })} (${itemCount} items rated)`]))));
465
+ }) | 0;
466
+ return join("\n", append_1(ofArray([`**${Spec_Label_shown(field.Label)}** 📊`, "", "| Item | Rating |", "|------|--------|"]), append_1(valueRows, ofArray(["", `> **Total Score:** ${totalScore} (${itemCount} items rated)`]))));
462
467
  }
463
468
  }
464
469
  }
@@ -19,7 +19,7 @@ import { reactApi as reactApi_1 } from "../../../fable_modules/Feliz.2.8.0/Inter
19
19
  import react_signature_pad_wrapper from "react-signature-pad-wrapper";
20
20
  import { IStandardField$3_$reflection, IStandardField$3, IField$1, StandardRenderFieldConfig$2 } from "../../../fable_modules/Fable.Form.Simple.Bulma.5.0.1/Types.fs.js";
21
21
  import { ISignaturePadProperty } from "../../../fable_modules/Glutinum.Feliz.ReactSignaturePadWrapper.1.0.2/Types.fs.js";
22
- import { Spec_FormField$1, Spec_FieldType_$union, Shared_FieldOption, Shared_FieldValue_$union, Shared_FieldKey, Shared_FieldValue_Single, Shared_FieldAnswer, Shared_PluginDataProperty, Shared_PluginPropertyKey, Spec_PluginFieldConfig } from "../../../FormSpec.FS/FormSpec.js";
22
+ import { Spec_FormField$1, Spec_Label_shown, Spec_FieldType_$union, Shared_FieldOption, Shared_FieldValue_$union, Shared_FieldKey, Shared_FieldValue_Single, Shared_FieldAnswer, Shared_PluginDataProperty, Shared_PluginPropertyKey, Spec_PluginFieldConfig } from "../../../FormSpec.FS/FormSpec.js";
23
23
  import { FSharpResult$2_$union, FSharpResult$2_Ok } from "@fable-org/fable-library-js/Result.js";
24
24
  import { IPluginValueConverter } from "../../../FormSpec.FS/PluginInterface.js";
25
25
  import { Helpers_combineClasses } from "../../../fable_modules/Feliz.Bulma.3.0.0/ElementBuilders.fs.js";
@@ -175,10 +175,11 @@ export function Form_markdownRenderer(field: Spec_FormField$1<Spec_FieldType_$un
175
175
  const matchValue: Shared_FieldValue_$union = fieldDetails.FieldValue;
176
176
  value = ((matchValue.tag === /* Single */ 0) ? matchValue.fields[0].Value : "");
177
177
  if (isNullOrWhiteSpace(value)) {
178
- return `**${field.Label}:** ❌ *[No signature provided]*`;
178
+ return `**${Spec_Label_shown(field.Label)}:** ❌ *[No signature provided]*`;
179
179
  }
180
180
  else {
181
- return join("\n", [`**${field.Label}** ✍️`, "", "| Status | Details |", "|--------|---------|", "| **Signature** | ✅ **Captured** |", `| **Timestamp** | ${toString(now(), "yyyy-MM-dd HH:mm")} |`, `| **Data Size** | ${value.length} characters |`, "| **Format** | Digital signature |", "", "> 🔒 *Digital signature has been securely captured and stored*", ">", "> 📋 *This signature serves as electronic consent and acknowledgment*"]);
181
+ const timestamp: string = toString(now(), "yyyy-MM-dd HH:mm");
182
+ return join("\n", [`**${Spec_Label_shown(field.Label)}** ✍️`, "", "| Status | Details |", "|--------|---------|", "| **Signature** | ✅ **Captured** |", `| **Timestamp** | ${timestamp} |`, `| **Data Size** | ${value.length} characters |`, "| **Format** | Digital signature |", "", "> 🔒 *Digital signature has been securely captured and stored*", ">", "> 📋 *This signature serves as electronic consent and acknowledgment*"]);
182
183
  }
183
184
  }
184
185
 
@@ -17,7 +17,7 @@ import { append as append_1, cons, empty as empty_1, tryFind, FSharpList, exists
17
17
  import { IReactProperty } from "../../../fable_modules/Feliz.2.8.0/Types.fs.js";
18
18
  import { withLabelAndError } from "../../../fable_modules/Fable.Form.Simple.Bulma.5.0.1/Html.View.fs.js";
19
19
  import { IStandardField$3_$reflection, IStandardField$3, IField$1, StandardRenderFieldConfig$2 } from "../../../fable_modules/Fable.Form.Simple.Bulma.5.0.1/Types.fs.js";
20
- import { Spec_FormField$1, Spec_FieldType_$union, Shared_FieldOption, Shared_FieldValue_$union, Shared_FieldKey, Shared_FieldValue_PluginData, Shared_PluginDataProperty, Shared_PluginPropertyKey, Spec_PluginFieldConfig } from "../../../FormSpec.FS/FormSpec.js";
20
+ import { Spec_FormField$1, Spec_Label_shown, Spec_FieldType_$union, Shared_FieldOption, Shared_FieldValue_$union, Shared_FieldKey, Shared_FieldValue_PluginData, Shared_PluginDataProperty, Shared_PluginPropertyKey, Spec_PluginFieldConfig } from "../../../FormSpec.FS/FormSpec.js";
21
21
  import { FSharpResult$2_$union, FSharpResult$2_Error, FSharpResult$2_Ok } from "@fable-org/fable-library-js/Result.js";
22
22
  import { IPluginValueConverter } from "../../../FormSpec.FS/PluginInterface.js";
23
23
  import { Helpers_combineClasses } from "../../../fable_modules/Feliz.Bulma.3.0.0/ElementBuilders.fs.js";
@@ -531,7 +531,7 @@ export function Form_markdownRenderer(field: Spec_FormField$1<Spec_FieldType_$un
531
531
  const matchValue: Shared_FieldValue_$union = fieldDetails.FieldValue;
532
532
  value = ((matchValue.tag === /* Single */ 0) ? matchValue.fields[0].Value : "");
533
533
  if (isNullOrWhiteSpace(value)) {
534
- return `**${field.Label}:** *[No vital signs recorded]*`;
534
+ return `**${Spec_Label_shown(field.Label)}:** *[No vital signs recorded]*`;
535
535
  }
536
536
  else {
537
537
  try {
@@ -553,7 +553,7 @@ export function Form_markdownRenderer(field: Spec_FormField$1<Spec_FieldType_$un
553
553
  }
554
554
  };
555
555
  const propStatus = (name: string): Option<VitalPropertyValidation> => tryFind_1<VitalPropertyValidation>((p: VitalPropertyValidation): boolean => (p.PropertyName === name), result.Properties);
556
- let rows: FSharpList<string> = ofArray([("**" + field.Label) + "** 🩺", "", "| Vital Sign | Value | Status |", "|------------|-------|--------|"]);
556
+ let rows: FSharpList<string> = ofArray([("**" + Spec_Label_shown(field.Label)) + "** 🩺", "", "| Vital Sign | Value | Status |", "|------------|-------|--------|"]);
557
557
  if (vitalsData.Temperature != null) {
558
558
  const v_1: Option<VitalPropertyValidation> = propStatus("temperature");
559
559
  rows = append_1(rows, singleton_1(((("| **Temperature** | " + ((arg = value_202(vitalsData.Temperature), toText(printf("%.1f"))(arg)))) + "°F | ") + statusEmoji(defaultArg(map<VitalPropertyValidation, string>((p_1: VitalPropertyValidation): string => p_1.ClinicalStatus, v_1), "empty"))) + " |"));
@@ -601,11 +601,11 @@ export function Form_markdownRenderer(field: Spec_FormField$1<Spec_FieldType_$un
601
601
  return join("\n", rows);
602
602
  }
603
603
  else {
604
- return ("**" + field.Label) + ":** *[No complete vital signs recorded]*";
604
+ return ("**" + Spec_Label_shown(field.Label)) + ":** *[No complete vital signs recorded]*";
605
605
  }
606
606
  }
607
607
  catch (ex: any) {
608
- return ((("**" + field.Label) + ":** *[Error processing vital signs data: ") + ex.message) + "]*";
608
+ return ((("**" + Spec_Label_shown(field.Label)) + ":** *[Error processing vital signs data: ") + ex.message) + "]*";
609
609
  }
610
610
  }
611
611
  }