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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (194) hide show
  1. package/FormSpec.FS/BlueprintValidation.d.ts +6 -3
  2. package/FormSpec.FS/BlueprintValidation.d.ts.map +1 -1
  3. package/FormSpec.FS/BlueprintValidation.js +39 -15
  4. package/FormSpec.FS/BlueprintValidation.js.map +1 -1
  5. package/FormSpec.FS/Designer.d.ts.map +1 -1
  6. package/FormSpec.FS/Designer.js +1 -1
  7. package/FormSpec.FS/Designer.js.map +1 -1
  8. package/FormSpec.FS/FormSpec.d.ts +108 -58
  9. package/FormSpec.FS/FormSpec.d.ts.map +1 -1
  10. package/FormSpec.FS/FormSpec.js +319 -129
  11. package/FormSpec.FS/FormSpec.js.map +1 -1
  12. package/FormSpec.FS/FormSpecHelpers.d.ts.map +1 -1
  13. package/FormSpec.FS/FormSpecHelpers.js +1 -1
  14. package/FormSpec.FS/FormSpecHelpers.js.map +1 -1
  15. package/FormSpec.FS/FormSpecValues.d.ts.map +1 -1
  16. package/FormSpec.FS/FormSpecValues.js +5 -2
  17. package/FormSpec.FS/FormSpecValues.js.map +1 -1
  18. package/FormSpec.FS/Helpers.d.ts.map +1 -1
  19. package/FormSpec.FS/Helpers.js +14 -9
  20. package/FormSpec.FS/Helpers.js.map +1 -1
  21. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRFieldTypeMapper.d.ts.map +1 -1
  22. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRFieldTypeMapper.js +1 -1
  23. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRFieldTypeMapper.js.map +1 -1
  24. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRFormSpecValidator.d.ts +1 -1
  25. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRFormSpecValidator.d.ts.map +1 -1
  26. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRFormSpecValidator.js +1 -1
  27. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRFormSpecValidator.js.map +1 -1
  28. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRSectioning.d.ts +3 -3
  29. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRSectioning.d.ts.map +1 -1
  30. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRSectioning.js +7 -5
  31. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRSectioning.js.map +1 -1
  32. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRSemanticReportBuilder.d.ts.map +1 -1
  33. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRSemanticReportBuilder.js +11 -10
  34. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRSemanticReportBuilder.js.map +1 -1
  35. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRStepsBuilder.d.ts.map +1 -1
  36. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRStepsBuilder.js +1 -9
  37. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRStepsBuilder.js.map +1 -1
  38. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateMapper.d.ts +11 -4
  39. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateMapper.d.ts.map +1 -1
  40. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateMapper.js +30 -28
  41. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateMapper.js.map +1 -1
  42. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateToFormSpec.d.ts +3 -9
  43. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateToFormSpec.d.ts.map +1 -1
  44. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateToFormSpec.js +4 -31
  45. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateToFormSpec.js.map +1 -1
  46. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMREncoder.d.ts.map +1 -1
  47. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMREncoder.js +2 -6
  48. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMREncoder.js.map +1 -1
  49. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRImportPipeline.d.ts +45 -0
  50. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRImportPipeline.d.ts.map +1 -0
  51. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRImportPipeline.js +141 -0
  52. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRImportPipeline.js.map +1 -0
  53. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRImporterAnalysis.d.ts +326 -0
  54. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRImporterAnalysis.d.ts.map +1 -0
  55. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRImporterAnalysis.js +1743 -0
  56. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRImporterAnalysis.js.map +1 -0
  57. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRSourceMap.d.ts +8 -8
  58. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRSourceMap.d.ts.map +1 -1
  59. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRSourceMap.js +6 -6
  60. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRSourceMap.js.map +1 -1
  61. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRTriggerEnrichment.d.ts +21 -15
  62. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRTriggerEnrichment.d.ts.map +1 -1
  63. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRTriggerEnrichment.js +83 -80
  64. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRTriggerEnrichment.js.map +1 -1
  65. package/FormSpec.FS/Integrations/CorEMR/CoreMRPathwayMapper.d.ts +51 -0
  66. package/FormSpec.FS/Integrations/CorEMR/CoreMRPathwayMapper.d.ts.map +1 -0
  67. package/FormSpec.FS/Integrations/CorEMR/CoreMRPathwayMapper.js +939 -0
  68. package/FormSpec.FS/Integrations/CorEMR/CoreMRPathwayMapper.js.map +1 -0
  69. package/FormSpec.FS/Integrations/CorEMR/CoreMRTypes.d.ts +2 -17
  70. package/FormSpec.FS/Integrations/CorEMR/CoreMRTypes.d.ts.map +1 -1
  71. package/FormSpec.FS/Integrations/CorEMR/CoreMRTypes.js +1 -66
  72. package/FormSpec.FS/Integrations/CorEMR/{TemplateManifestDecoder.d.ts → FormTemplateDecoder.d.ts} +53 -45
  73. package/FormSpec.FS/Integrations/CorEMR/FormTemplateDecoder.d.ts.map +1 -0
  74. package/FormSpec.FS/Integrations/CorEMR/{TemplateManifestDecoder.js → FormTemplateDecoder.js} +544 -254
  75. package/FormSpec.FS/Integrations/CorEMR/FormTemplateDecoder.js.map +1 -0
  76. package/FormSpec.FS/Integrations/CorEMR/FormTemplateDomainDecoder.d.ts +7 -0
  77. package/FormSpec.FS/Integrations/CorEMR/FormTemplateDomainDecoder.d.ts.map +1 -0
  78. package/FormSpec.FS/Integrations/CorEMR/FormTemplateDomainDecoder.js +280 -0
  79. package/FormSpec.FS/Integrations/CorEMR/FormTemplateDomainDecoder.js.map +1 -0
  80. package/FormSpec.FS/Interop/FormSpec.Api.Helpers.d.ts +16 -4
  81. package/FormSpec.FS/Interop/FormSpec.Api.Helpers.d.ts.map +1 -1
  82. package/FormSpec.FS/Interop/FormSpec.Api.Helpers.js +63 -18
  83. package/FormSpec.FS/Interop/FormSpec.Api.Helpers.js.map +1 -1
  84. package/FormSpec.FS/Interop/FormSpec.Api.Option.d.ts +4 -4
  85. package/FormSpec.FS/Interop/FormSpec.Api.Option.d.ts.map +1 -1
  86. package/FormSpec.FS/Interop/FormSpec.Api.Option.js +2 -2
  87. package/FormSpec.FS/Interop/FormSpec.Api.Option.js.map +1 -1
  88. package/FormSpec.FS/PathwayDataExtractor.d.ts.map +1 -1
  89. package/FormSpec.FS/PathwayDataExtractor.js +39 -18
  90. package/FormSpec.FS/PathwayDataExtractor.js.map +1 -1
  91. package/FormSpec.FS/PathwayExecutor.d.ts +10 -10
  92. package/FormSpec.FS/PathwayExecutor.d.ts.map +1 -1
  93. package/FormSpec.FS/PathwayExecutor.js +14 -14
  94. package/FormSpec.FS/PathwayExecutor.js.map +1 -1
  95. package/FormSpec.FS/PathwayValidator.d.ts.map +1 -1
  96. package/FormSpec.FS/PathwayValidator.js +8 -5
  97. package/FormSpec.FS/PathwayValidator.js.map +1 -1
  98. package/FormSpec.FS/Provenance.d.ts +15 -7
  99. package/FormSpec.FS/Provenance.d.ts.map +1 -1
  100. package/FormSpec.FS/Provenance.js +11 -11
  101. package/FormSpec.FS/Provenance.js.map +1 -1
  102. package/FormSpec.FS/Renderers/FormSpecMarkdownRenderer.d.ts.map +1 -1
  103. package/FormSpec.FS/Renderers/FormSpecMarkdownRenderer.js +16 -7
  104. package/FormSpec.FS/Renderers/FormSpecMarkdownRenderer.js.map +1 -1
  105. package/FormSpec.FS/Renderers/MermaidRenderer.d.ts.map +1 -1
  106. package/FormSpec.FS/Renderers/MermaidRenderer.js +4 -8
  107. package/FormSpec.FS/Renderers/MermaidRenderer.js.map +1 -1
  108. package/FormSpec.FS/Renderers/PathwayRenderers.d.ts.map +1 -1
  109. package/FormSpec.FS/Renderers/PathwayRenderers.js +5 -4
  110. package/FormSpec.FS/Renderers/PathwayRenderers.js.map +1 -1
  111. package/FormSpec.FS/TriggerActionDto.d.ts +32 -21
  112. package/FormSpec.FS/TriggerActionDto.d.ts.map +1 -1
  113. package/FormSpec.FS/TriggerActionDto.js +247 -61
  114. package/FormSpec.FS/TriggerActionDto.js.map +1 -1
  115. package/README.md +7 -7
  116. package/package.json +1 -1
  117. package/plugins/allergyfinder/src/AllergyFinderField.d.ts.map +1 -1
  118. package/plugins/allergyfinder/src/AllergyFinderField.js +2 -2
  119. package/plugins/allergyfinder/src/AllergyFinderField.js.map +1 -1
  120. package/plugins/bmi/src/BMIField.d.ts.map +1 -1
  121. package/plugins/bmi/src/BMIField.js +21 -15
  122. package/plugins/bmi/src/BMIField.js.map +1 -1
  123. package/plugins/demographics/src/DemographicsField.d.ts.map +1 -1
  124. package/plugins/demographics/src/DemographicsField.js +4 -4
  125. package/plugins/demographics/src/DemographicsField.js.map +1 -1
  126. package/plugins/likert/src/LikertField.d.ts.map +1 -1
  127. package/plugins/likert/src/LikertField.js +40 -35
  128. package/plugins/likert/src/LikertField.js.map +1 -1
  129. package/plugins/signature/src/SignatureField.d.ts.map +1 -1
  130. package/plugins/signature/src/SignatureField.js +4 -3
  131. package/plugins/signature/src/SignatureField.js.map +1 -1
  132. package/plugins/vitals/src/VitalsField.d.ts.map +1 -1
  133. package/plugins/vitals/src/VitalsField.js +4 -4
  134. package/plugins/vitals/src/VitalsField.js.map +1 -1
  135. package/src/FormSpec.FS/BlueprintValidation.ts +55 -24
  136. package/src/FormSpec.FS/Designer.ts +2 -2
  137. package/src/FormSpec.FS/FormSpec.ts +223 -100
  138. package/src/FormSpec.FS/FormSpecHelpers.ts +2 -2
  139. package/src/FormSpec.FS/FormSpecValues.ts +6 -3
  140. package/src/FormSpec.FS/Helpers.ts +16 -11
  141. package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRFieldTypeMapper.ts +2 -2
  142. package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRFormSpecValidator.ts +3 -3
  143. package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRSectioning.ts +10 -8
  144. package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRSemanticReportBuilder.ts +6 -5
  145. package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRStepsBuilder.ts +1 -10
  146. package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateMapper.ts +35 -30
  147. package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateToFormSpec.ts +7 -26
  148. package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMREncoder.ts +2 -6
  149. package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRImportPipeline.ts +115 -0
  150. package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRImporterAnalysis.ts +1059 -0
  151. package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRSourceMap.ts +10 -10
  152. package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRTriggerEnrichment.ts +61 -88
  153. package/src/FormSpec.FS/Integrations/CorEMR/CoreMRPathwayMapper.ts +926 -0
  154. package/src/FormSpec.FS/Integrations/CorEMR/CoreMRTypes.ts +3 -37
  155. package/src/FormSpec.FS/Integrations/CorEMR/FormTemplateDecoder.ts +1284 -0
  156. package/src/FormSpec.FS/Integrations/CorEMR/FormTemplateDomainDecoder.ts +287 -0
  157. package/src/FormSpec.FS/Interop/FormSpec.Api.Helpers.ts +76 -25
  158. package/src/FormSpec.FS/Interop/FormSpec.Api.Option.ts +6 -6
  159. package/src/FormSpec.FS/PathwayDataExtractor.ts +40 -20
  160. package/src/FormSpec.FS/PathwayExecutor.ts +26 -26
  161. package/src/FormSpec.FS/PathwayValidator.ts +8 -5
  162. package/src/FormSpec.FS/Provenance.ts +23 -15
  163. package/src/FormSpec.FS/Renderers/FormSpecMarkdownRenderer.ts +18 -8
  164. package/src/FormSpec.FS/Renderers/MermaidRenderer.ts +6 -10
  165. package/src/FormSpec.FS/Renderers/PathwayRenderers.ts +5 -5
  166. package/src/FormSpec.FS/TriggerActionDto.ts +247 -74
  167. package/src/plugins/allergyfinder/src/AllergyFinderField.ts +3 -3
  168. package/src/plugins/bmi/src/BMIField.ts +12 -5
  169. package/src/plugins/demographics/src/DemographicsField.ts +5 -5
  170. package/src/plugins/likert/src/LikertField.ts +16 -11
  171. package/src/plugins/signature/src/SignatureField.ts +4 -3
  172. package/src/plugins/vitals/src/VitalsField.ts +5 -5
  173. package/src/vye-os-contracts-fs/src/Core/Ids.ts +8 -8
  174. package/src/vye-os-contracts-fs/src/CoreMR/FormTemplate.ts +715 -0
  175. package/vye-os-contracts-fs/src/Core/Ids.d.ts +4 -4
  176. package/vye-os-contracts-fs/src/Core/Ids.d.ts.map +1 -1
  177. package/vye-os-contracts-fs/src/Core/Ids.js +18 -18
  178. package/vye-os-contracts-fs/src/CoreMR/FormTemplate.d.ts +310 -0
  179. package/vye-os-contracts-fs/src/CoreMR/FormTemplate.d.ts.map +1 -0
  180. package/vye-os-contracts-fs/src/CoreMR/FormTemplate.js +1242 -0
  181. package/vye-os-contracts-fs/src/CoreMR/FormTemplate.js.map +1 -0
  182. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTriggerConverter.d.ts +0 -69
  183. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTriggerConverter.d.ts.map +0 -1
  184. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTriggerConverter.js +0 -447
  185. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTriggerConverter.js.map +0 -1
  186. package/FormSpec.FS/Integrations/CorEMR/ItemTriggerConverter.d.ts +0 -19
  187. package/FormSpec.FS/Integrations/CorEMR/ItemTriggerConverter.d.ts.map +0 -1
  188. package/FormSpec.FS/Integrations/CorEMR/ItemTriggerConverter.js +0 -643
  189. package/FormSpec.FS/Integrations/CorEMR/ItemTriggerConverter.js.map +0 -1
  190. package/FormSpec.FS/Integrations/CorEMR/TemplateManifestDecoder.d.ts.map +0 -1
  191. package/FormSpec.FS/Integrations/CorEMR/TemplateManifestDecoder.js.map +0 -1
  192. package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTriggerConverter.ts +0 -412
  193. package/src/FormSpec.FS/Integrations/CorEMR/ItemTriggerConverter.ts +0 -588
  194. package/src/FormSpec.FS/Integrations/CorEMR/TemplateManifestDecoder.ts +0 -1054
@@ -1,7 +1,7 @@
1
1
  import { singleton, head, isEmpty, ofSeq, iterate, forAll, exists, sumBy, collect, tryFind, FSharpList, empty, sortBy, mapIndexed, map } from "@fable-org/fable-library-js/List.js";
2
2
  import { tryParse as tryParse_1, float64, int32 } from "@fable-org/fable-library-js/Int32.js";
3
3
  import { getFieldDetails, FormSpecMetadata, FieldDetails$1 } from "./FormSpecValues.js";
4
- import { Shared_FieldValue_Single, Shared_FieldValue_PluginData, Shared_FieldValue_Matrix, Shared_FieldValue_Multiple, Shared_ConditionValue_Single, Shared_ConditionValue_PluginData, Shared_ConditionValue_Matrix, Shared_ConditionValue_Multiple, ClinicalPathway_ConstraintDefinition, ClinicalPathway_ConstraintType_$union, ClinicalPathway_TransitionDefinition, ClinicalPathway_ClinicalPathwaySpec, ClinicalPathway_TransitionCondition_$union, ClinicalPathway_LogicalOp_$union, Shared_MatrixAnswer, Shared_PluginPropertyKey, Shared_FieldOptionKey, Shared_ConditionValue_$union, ClinicalPathway_FieldEvaluator_$union, Shared_PluginDataProperty_$reflection, Shared_PluginDataProperty, Shared_MatrixItemKey, Shared_FieldAnswer, Shared_FieldValue_$union, Spec_FormSpec$1, Spec_FormClassification_General, Spec_FormLifecycle_Draft, Values_StepOrder, Spec_FormStep$1, Shared_FieldKey, Spec_FormField$1, Spec_FieldType_$union } from "./FormSpec.js";
4
+ import { Shared_FieldValue_Single, Shared_FieldValue_PluginData, Shared_FieldValue_Matrix, Shared_FieldValue_Multiple, Shared_ConditionValue_Single, Shared_ConditionValue_PluginData, Shared_ConditionValue_Matrix, Shared_ConditionValue_Multiple, ClinicalPathway_ConstraintDefinition, ClinicalPathway_ConstraintType_$union, ClinicalPathway_TransitionDefinition, ClinicalPathway_ClinicalPathwaySpec, Spec_Label_shown, ClinicalPathway_TransitionCondition_$union, ClinicalPathway_LogicalOp_$union, Shared_MatrixAnswer, Shared_PluginPropertyKey, Shared_FieldOptionKey, Shared_ConditionValue_$union, ClinicalPathway_FieldEvaluator_$union, Shared_PluginDataProperty_$reflection, Shared_PluginDataProperty, Shared_MatrixItemKey, Shared_FieldAnswer, Shared_FieldValue_$union, Spec_FormSpec$1, Spec_FormClassification_General, Spec_FormLifecycle_Draft, Values_StepOrder, Spec_FormStep$1, Shared_FieldKey, Spec_FormField$1, Spec_FieldType_$union } from "./FormSpec.js";
5
5
  import { FSharpMap, toList } from "@fable-org/fable-library-js/Map.js";
6
6
  import { compare, int32ToString, equals, comparePrimitives } from "@fable-org/fable-library-js/Util.js";
7
7
  import { newGuid } from "@fable-org/fable-library-js/Guid.js";
@@ -424,7 +424,7 @@ export function validateFormSpecFieldKeys(formSpec: Spec_FormSpec$1<Spec_FieldTy
424
424
  iterate<Spec_FormStep$1<Spec_FieldType_$union>>((step: Spec_FormStep$1<Spec_FieldType_$union>): void => {
425
425
  iterate<Spec_FormField$1<Spec_FieldType_$union>>((field: Spec_FormField$1<Spec_FieldType_$union>): void => {
426
426
  if (field.FieldKey.fields[0] === "00000000-0000-0000-0000-000000000000") {
427
- void (errors.push(`Field '${field.Label}' has empty GUID field key`));
427
+ void (errors.push(`Field '${Spec_Label_shown(field.Label)}' has empty GUID field key`));
428
428
  }
429
429
  }, step.Fields);
430
430
  }, formSpec.Steps);
@@ -1,6 +1,6 @@
1
1
  import { Record } from "@fable-org/fable-library-js/Types.js";
2
2
  import { map as map_1, value as value_1, defaultArg, bind, Option } from "@fable-org/fable-library-js/Option.js";
3
- import { Values_StepOrder, Shared_FieldValue_Single, Shared_FieldAnswer, Spec_FormSpec$1, Spec_FormStep$1, Spec_FormField$1, Spec_FieldType_$union, Shared_FieldOption_$reflection, Shared_FieldValue_$reflection, Shared_FieldKey_$reflection, Shared_FieldOption, Shared_FieldValue_$union, Shared_FieldKey, Spec_Score_$reflection, Spec_Score } from "./FormSpec.js";
3
+ import { Values_StepOrder, Shared_FieldValue_Single, Shared_FieldAnswer, Spec_Label_shown, Spec_FormSpec$1, Spec_FormStep$1, Spec_FormField$1, Spec_FieldType_$union, Shared_FieldOption_$reflection, Shared_FieldValue_$reflection, Shared_FieldKey_$reflection, Shared_FieldOption, Shared_FieldValue_$union, Shared_FieldKey, Spec_Score_$reflection, Spec_Score } from "./FormSpec.js";
4
4
  import { compare, equals, IComparable, IEquatable } from "@fable-org/fable-library-js/Util.js";
5
5
  import { list_type, int32_type, record_type, option_type, string_type, class_type, TypeInfo } from "@fable-org/fable-library-js/Reflection.js";
6
6
  import { int32 } from "@fable-org/fable-library-js/Int32.js";
@@ -131,8 +131,11 @@ export function updateField<FieldType>(spec: Spec_FormSpec$1<FieldType>, fieldKe
131
131
  * Uses field.Value or creates empty default based on field type.
132
132
  */
133
133
  export function fieldToDetails(field: Spec_FormField$1<Spec_FieldType_$union>): FieldDetails$1<Spec_FieldType_$union> {
134
- let matchValue: Option<Shared_FieldValue_$union>;
135
- return new FieldDetails$1(field.FieldOrder, field.FieldKey, field.Label, (matchValue = field.Value, (matchValue == null) ? Shared_FieldValue_Single(new Shared_FieldAnswer(field.FieldKey, field.Label, "", undefined)) : value_1(matchValue)), field.FieldType, optionsFromField(field));
134
+ let fieldValue: Shared_FieldValue_$union;
135
+ const matchValue: Option<Shared_FieldValue_$union> = field.Value;
136
+ fieldValue = ((matchValue == null) ? Shared_FieldValue_Single(new Shared_FieldAnswer(field.FieldKey, Spec_Label_shown(field.Label), "", undefined)) : value_1(matchValue));
137
+ const options: FSharpList<Shared_FieldOption> = optionsFromField(field);
138
+ return new FieldDetails$1(field.FieldOrder, field.FieldKey, Spec_Label_shown(field.Label), fieldValue, field.FieldType, options);
136
139
  }
137
140
 
138
141
  /**
@@ -1,4 +1,4 @@
1
- import { Values_StepOrder, Shared_FieldValue_Multiple, Shared_FieldValue_Single, Shared_FieldAnswer, Shared_FieldValue_$union, Shared_FieldOption, Spec_PluginFieldConfig, Spec_FieldType_$union, Spec_FieldType, Spec_FormSpec$1, Spec_FormField$1, Spec_FormStep$1, Shared_FieldKey } from "./FormSpec.js";
1
+ import { Values_StepOrder, Shared_FieldValue_Multiple, Spec_Label_shown, Shared_FieldValue_Single, Shared_FieldAnswer, Shared_FieldValue_$union, Shared_FieldOption, Spec_PluginFieldConfig, Spec_FieldType_$union, Spec_FieldType, Spec_FormSpec$1, Spec_FormField$1, Spec_FormStep$1, Shared_FieldKey } from "./FormSpec.js";
2
2
  import { arrayToGuid, parse } from "@fable-org/fable-library-js/Guid.js";
3
3
  import { toConsole, isNullOrEmpty, trimEnd, trim, isNullOrWhiteSpace } from "@fable-org/fable-library-js/String.js";
4
4
  import { replace } from "@fable-org/fable-library-js/RegExp.js";
@@ -6,9 +6,9 @@ import { uint8, int32, parse as parse_1 } from "@fable-org/fable-library-js/Int3
6
6
  import sha256 from "crypto-js/sha256";
7
7
  import { initialize } from "@fable-org/fable-library-js/Array.js";
8
8
  import { value as value_1, Option, map, defaultArg } from "@fable-org/fable-library-js/Option.js";
9
- import { splitAt, tryFindIndex, forAll, sortBy, find, insertAt, mapIndexed, singleton, append, head, tail, isEmpty, collect, empty, tryFind, FSharpList, filter, map as map_1 } from "@fable-org/fable-library-js/List.js";
10
- import { Result_Map, FSharpResult$2_$union, FSharpResult$2_Error, FSharpResult$2_Ok } from "@fable-org/fable-library-js/Result.js";
9
+ import { splitAt, tryFindIndex, forAll, sortBy, find, insertAt, mapIndexed, singleton, append, choose, head, tail, isEmpty, collect, empty, tryFind, FSharpList, filter, map as map_1 } from "@fable-org/fable-library-js/List.js";
11
10
  import { compare, safeHash, comparePrimitives, stringHash, equals } from "@fable-org/fable-library-js/Util.js";
11
+ import { Result_Map, FSharpResult$2_$union, FSharpResult$2_Error, FSharpResult$2_Ok } from "@fable-org/fable-library-js/Result.js";
12
12
  import { List_distinct } from "@fable-org/fable-library-js/Seq2.js";
13
13
  import { map as map_2, tryFind as tryFind_1 } from "@fable-org/fable-library-js/Seq.js";
14
14
  import { FieldDetails$1 } from "./FormSpecValues.js";
@@ -70,14 +70,14 @@ export function Helpers_generateDeterministicGuid(fieldName: string): string {
70
70
  * Finds a form field by its label string in a specific step.
71
71
  */
72
72
  export function Helpers_FieldFinders_findFormFieldInStepByLabelString<FieldType>(label: string, stepNumber: int32, formSpec: Spec_FormSpec$1<FieldType>): FSharpList<[Spec_FormStep$1<FieldType>, Spec_FormField$1<FieldType>]> {
73
- return defaultArg(map<Spec_FormStep$1<FieldType>, FSharpList<[Spec_FormStep$1<FieldType>, Spec_FormField$1<FieldType>]>>((step_1: Spec_FormStep$1<FieldType>): FSharpList<[Spec_FormStep$1<FieldType>, Spec_FormField$1<FieldType>]> => map_1<Spec_FormField$1<FieldType>, [Spec_FormStep$1<FieldType>, Spec_FormField$1<FieldType>]>((field_1: Spec_FormField$1<FieldType>): [Spec_FormStep$1<FieldType>, Spec_FormField$1<FieldType>] => ([step_1, field_1] as [Spec_FormStep$1<FieldType>, Spec_FormField$1<FieldType>]), filter<Spec_FormField$1<FieldType>>((field: Spec_FormField$1<FieldType>): boolean => (field.Label === label), step_1.Fields)), tryFind<Spec_FormStep$1<FieldType>>((step: Spec_FormStep$1<FieldType>): boolean => (step.StepOrder === stepNumber), formSpec.Steps)), empty<[Spec_FormStep$1<FieldType>, Spec_FormField$1<FieldType>]>());
73
+ return defaultArg(map<Spec_FormStep$1<FieldType>, FSharpList<[Spec_FormStep$1<FieldType>, Spec_FormField$1<FieldType>]>>((step_1: Spec_FormStep$1<FieldType>): FSharpList<[Spec_FormStep$1<FieldType>, Spec_FormField$1<FieldType>]> => map_1<Spec_FormField$1<FieldType>, [Spec_FormStep$1<FieldType>, Spec_FormField$1<FieldType>]>((field_1: Spec_FormField$1<FieldType>): [Spec_FormStep$1<FieldType>, Spec_FormField$1<FieldType>] => ([step_1, field_1] as [Spec_FormStep$1<FieldType>, Spec_FormField$1<FieldType>]), filter<Spec_FormField$1<FieldType>>((field: Spec_FormField$1<FieldType>): boolean => equals(field.Label, label), step_1.Fields)), tryFind<Spec_FormStep$1<FieldType>>((step: Spec_FormStep$1<FieldType>): boolean => (step.StepOrder === stepNumber), formSpec.Steps)), empty<[Spec_FormStep$1<FieldType>, Spec_FormField$1<FieldType>]>());
74
74
  }
75
75
 
76
76
  /**
77
77
  * Finds a form field by its label string across all steps in the form.
78
78
  */
79
79
  export function Helpers_FieldFinders_findFormFieldInFormByLabelString<FieldType>(label: string, formSpec: Spec_FormSpec$1<FieldType>): FSharpList<[Spec_FormStep$1<FieldType>, Spec_FormField$1<FieldType>]> {
80
- return collect<Spec_FormStep$1<FieldType>, [Spec_FormStep$1<FieldType>, Spec_FormField$1<FieldType>]>((step: Spec_FormStep$1<FieldType>): FSharpList<[Spec_FormStep$1<FieldType>, Spec_FormField$1<FieldType>]> => map_1<Spec_FormField$1<FieldType>, [Spec_FormStep$1<FieldType>, Spec_FormField$1<FieldType>]>((field_1: Spec_FormField$1<FieldType>): [Spec_FormStep$1<FieldType>, Spec_FormField$1<FieldType>] => ([step, field_1] as [Spec_FormStep$1<FieldType>, Spec_FormField$1<FieldType>]), filter<Spec_FormField$1<FieldType>>((field: Spec_FormField$1<FieldType>): boolean => (field.Label === label), step.Fields)), formSpec.Steps);
80
+ return collect<Spec_FormStep$1<FieldType>, [Spec_FormStep$1<FieldType>, Spec_FormField$1<FieldType>]>((step: Spec_FormStep$1<FieldType>): FSharpList<[Spec_FormStep$1<FieldType>, Spec_FormField$1<FieldType>]> => map_1<Spec_FormField$1<FieldType>, [Spec_FormStep$1<FieldType>, Spec_FormField$1<FieldType>]>((field_1: Spec_FormField$1<FieldType>): [Spec_FormStep$1<FieldType>, Spec_FormField$1<FieldType>] => ([step, field_1] as [Spec_FormStep$1<FieldType>, Spec_FormField$1<FieldType>]), filter<Spec_FormField$1<FieldType>>((field: Spec_FormField$1<FieldType>): boolean => equals(field.Label, label), step.Fields)), formSpec.Steps);
81
81
  }
82
82
 
83
83
  /**
@@ -155,7 +155,7 @@ export function Helpers_FieldFinders_tryFindFieldInSpec<UserField>(fieldNumber:
155
155
  * Gets all unique field labels from a FormSpec.
156
156
  */
157
157
  export function Helpers_FieldFinders_getAllFieldNames<UserField>(formSpec: Spec_FormSpec$1<UserField>): FSharpList<string> {
158
- return List_distinct<string>(map_1<Spec_FormField$1<UserField>, string>((field: Spec_FormField$1<UserField>): string => field.Label, collect<Spec_FormStep$1<UserField>, Spec_FormField$1<UserField>>((step: Spec_FormStep$1<UserField>): FSharpList<Spec_FormField$1<UserField>> => step.Fields, formSpec.Steps)), {
158
+ return List_distinct<string>(choose<Spec_FormField$1<UserField>, string>((field: Spec_FormField$1<UserField>): Option<string> => field.Label, collect<Spec_FormStep$1<UserField>, Spec_FormField$1<UserField>>((step: Spec_FormStep$1<UserField>): FSharpList<Spec_FormField$1<UserField>> => step.Fields, formSpec.Steps)), {
159
159
  Equals: (x: string, y: string): boolean => (x === y),
160
160
  GetHashCode: stringHash,
161
161
  });
@@ -711,7 +711,9 @@ export function Helpers_readManyValue<FieldType>(fieldKey: Shared_FieldKey, valu
711
711
  export function Helpers_updateSingleFunc(formatter: ((arg0: string) => string), specField: Spec_FormField$1<Spec_FieldType_$union>, newValue: string, values: FSharpMap<Shared_FieldKey, FieldDetails$1<Spec_FieldType_$union>>): FSharpMap<Shared_FieldKey, FieldDetails$1<Spec_FieldType_$union>> {
712
712
  let Value: string, matchValue: Option<Shared_FieldOption>;
713
713
  const fieldOptions: FSharpList<Shared_FieldOption> = Helpers_optionsFromSpecField(specField);
714
- const newFieldDetails: FieldDetails$1<Spec_FieldType_$union> = new FieldDetails$1(specField.FieldOrder, specField.FieldKey, specField.Label, Shared_FieldValue_Single((Value = formatter(newValue), new Shared_FieldAnswer(specField.FieldKey, (matchValue = tryFind<Shared_FieldOption>((o: Shared_FieldOption): boolean => (o.Value === newValue), fieldOptions), (matchValue == null) ? newValue : value_1(matchValue).Description), Value, undefined))), specField.FieldType, Helpers_specFieldOptionsToValueOptions(fieldOptions));
714
+ let newFieldDetails: FieldDetails$1<Spec_FieldType_$union>;
715
+ const FieldValue: Shared_FieldValue_$union = Shared_FieldValue_Single((Value = formatter(newValue), new Shared_FieldAnswer(specField.FieldKey, (matchValue = tryFind<Shared_FieldOption>((o: Shared_FieldOption): boolean => (o.Value === newValue), fieldOptions), (matchValue == null) ? newValue : value_1(matchValue).Description), Value, undefined)));
716
+ newFieldDetails = (new FieldDetails$1(specField.FieldOrder, specField.FieldKey, Spec_Label_shown(specField.Label), FieldValue, specField.FieldType, Helpers_specFieldOptionsToValueOptions(fieldOptions)));
715
717
  const matchValue_1: Option<Shared_FieldKey> = tryFind_1<Shared_FieldKey>((k: Shared_FieldKey): boolean => equals(k, newFieldDetails.Key), map_2<[Shared_FieldKey, FieldDetails$1<Spec_FieldType_$union>], Shared_FieldKey>((tuple: [Shared_FieldKey, FieldDetails$1<Spec_FieldType_$union>]): Shared_FieldKey => tuple[0], toSeq<Shared_FieldKey, FieldDetails$1<Spec_FieldType_$union>>(values)));
716
718
  if (matchValue_1 != null) {
717
719
  const key: Shared_FieldKey = value_1(matchValue_1);
@@ -724,13 +726,15 @@ export function Helpers_updateSingleFunc(formatter: ((arg0: string) => string),
724
726
  }
725
727
 
726
728
  export function Helpers_updateManyFunc(formatter: ((arg0: string) => string), specField: Spec_FormField$1<Spec_FieldType_$union>, newValue: FSharpSet<string>, values: FSharpMap<Shared_FieldKey, FieldDetails$1<Spec_FieldType_$union>>): FSharpMap<Shared_FieldKey, FieldDetails$1<Spec_FieldType_$union>> {
727
- const newFieldDetails: FieldDetails$1<Spec_FieldType_$union> = new FieldDetails$1(specField.FieldOrder, specField.FieldKey, specField.Label, Shared_FieldValue_Multiple(map_3<string, Shared_FieldAnswer>((v: string): Shared_FieldAnswer => {
729
+ let newFieldDetails: FieldDetails$1<Spec_FieldType_$union>;
730
+ const FieldValue: Shared_FieldValue_$union = Shared_FieldValue_Multiple(map_3<string, Shared_FieldAnswer>((v: string): Shared_FieldAnswer => {
728
731
  let matchValue: Option<Shared_FieldOption>;
729
732
  const Value: string = formatter(v);
730
733
  return new Shared_FieldAnswer(specField.FieldKey, (matchValue = tryFind<Shared_FieldOption>((o: Shared_FieldOption): boolean => (o.Value === v), Helpers_optionsFromSpecField(specField)), (matchValue == null) ? v : value_1(matchValue).Description), Value, undefined);
731
734
  }, newValue, {
732
735
  Compare: compare,
733
- })), specField.FieldType, Helpers_specFieldOptionsToValueOptions(Helpers_optionsFromSpecField(specField)));
736
+ }));
737
+ newFieldDetails = (new FieldDetails$1(specField.FieldOrder, specField.FieldKey, Spec_Label_shown(specField.Label), FieldValue, specField.FieldType, Helpers_specFieldOptionsToValueOptions(Helpers_optionsFromSpecField(specField))));
734
738
  const matchValue_1: Option<Shared_FieldKey> = tryFind_1<Shared_FieldKey>((k: Shared_FieldKey): boolean => equals(k, newFieldDetails.Key), map_2<[Shared_FieldKey, FieldDetails$1<Spec_FieldType_$union>], Shared_FieldKey>((tuple: [Shared_FieldKey, FieldDetails$1<Spec_FieldType_$union>]): Shared_FieldKey => tuple[0], toSeq<Shared_FieldKey, FieldDetails$1<Spec_FieldType_$union>>(values)));
735
739
  if (matchValue_1 != null) {
736
740
  const key: Shared_FieldKey = value_1(matchValue_1);
@@ -746,9 +750,10 @@ export function Helpers_updateManyFunc(formatter: ((arg0: string) => string), sp
746
750
  * Returns the updated ResultStepValues
747
751
  */
748
752
  export function Helpers_updateFormFieldValue(field: Spec_FormField$1<Spec_FieldType_$union>, newValue: any, values: FSharpMap<Shared_FieldKey, FieldDetails$1<Spec_FieldType_$union>>): FSharpMap<Shared_FieldKey, FieldDetails$1<Spec_FieldType_$union>> {
749
- const newFieldDetails: FieldDetails$1<Spec_FieldType_$union> = new FieldDetails$1(field.FieldOrder, field.FieldKey, field.Label, (() => {
753
+ const fieldOptions: FSharpList<Shared_FieldOption> = Helpers_optionsFromSpecField(field);
754
+ const newFieldDetails: FieldDetails$1<Spec_FieldType_$union> = new FieldDetails$1(field.FieldOrder, field.FieldKey, Spec_Label_shown(field.Label), (() => {
750
755
  throw new Error("updateFormFieldValue: Field type handling not implemented.");
751
- })(), field.FieldType, Helpers_specFieldOptionsToValueOptions(Helpers_optionsFromSpecField(field)));
756
+ })(), field.FieldType, Helpers_specFieldOptionsToValueOptions(fieldOptions));
752
757
  const matchValue_1: Option<Shared_FieldKey> = tryFind_1<Shared_FieldKey>((k: Shared_FieldKey): boolean => equals(k, newFieldDetails.Key), map_2<[Shared_FieldKey, FieldDetails$1<Spec_FieldType_$union>], Shared_FieldKey>((tuple: [Shared_FieldKey, FieldDetails$1<Spec_FieldType_$union>]): Shared_FieldKey => tuple[0], toSeq<Shared_FieldKey, FieldDetails$1<Spec_FieldType_$union>>(values)));
753
758
  if (matchValue_1 != null) {
754
759
  const key: Shared_FieldKey = value_1(matchValue_1);
@@ -2,7 +2,7 @@ import { isNullOrWhiteSpace } from "@fable-org/fable-library-js/String.js";
2
2
  import { Helpers_generateDeterministicGuidRaw, Helpers_canonicalizeFieldKey } from "../../../Helpers.js";
3
3
  import { int32 } from "@fable-org/fable-library-js/Int32.js";
4
4
  import { CoreMRChoice, CoreMRItem } from "../../CorEMR/CoreMRTypes.js";
5
- import { Spec_FormField$1, Spec_FieldType_$union, Spec_FieldType_UnsupportedField, Spec_UnsupportedFieldInfo, Spec_FieldType_PluginField, Spec_PluginFieldConfig, Spec_FieldType_Message, Spec_MessageInfo, Spec_MessageType_Info, Spec_FieldType_Signature, Spec_SignatureInfo, Spec_FieldType_DateTimeLocal, Spec_FieldType_Date, Spec_FieldType_CheckboxList, Spec_MultiChoiceInfo, Spec_FieldType_Dropdown, Spec_FieldType_Radio, Spec_SingleChoiceInfo, Spec_FieldType_TextArea, Spec_FieldType_Text, Spec_TextInfo, Shared_FieldOption, Shared_FieldOptionKey, Shared_FieldKey } from "../../../FormSpec.js";
5
+ import { Spec_FormField$1, Spec_Label_ofStated, Spec_FieldType_$union, Spec_FieldType_UnsupportedField, Spec_UnsupportedFieldInfo, Spec_FieldType_PluginField, Spec_PluginFieldConfig, Spec_FieldType_Message, Spec_MessageInfo, Spec_MessageType_Info, Spec_FieldType_Signature, Spec_SignatureInfo, Spec_FieldType_DateTimeLocal, Spec_FieldType_Date, Spec_FieldType_CheckboxList, Spec_MultiChoiceInfo, Spec_FieldType_Dropdown, Spec_FieldType_Radio, Spec_SingleChoiceInfo, Spec_FieldType_TextArea, Spec_FieldType_Text, Spec_TextInfo, Shared_FieldOption, Shared_FieldOptionKey, Shared_FieldKey } from "../../../FormSpec.js";
6
6
  import { isEmpty, ofArray, FSharpList, sortBy, map } from "@fable-org/fable-library-js/List.js";
7
7
  import { comparePrimitives } from "@fable-org/fable-library-js/Util.js";
8
8
  import { getElementTypeInfo } from "./CorEMRElementTypeMap.js";
@@ -108,7 +108,7 @@ export function mapToFormField(formCode: string, stepOrder: int32, item: CoreMRI
108
108
  const fieldType: Spec_FieldType_$union = mapFieldType(item, choices);
109
109
  const mainLabel: string = item.Label.trim();
110
110
  const notesField: Option<string> = isPlusNotesType(item) ? "" : undefined;
111
- return new Spec_FormField$1(item.Sequence, generateNamespacedFieldKey(formCode, stepOrder, item), mainLabel, notesField, undefined, !item.IsRequired, false, isNeedsDocumentationType(item), fieldType, undefined);
111
+ return new Spec_FormField$1(item.Sequence, generateNamespacedFieldKey(formCode, stepOrder, item), Spec_Label_ofStated(mainLabel), notesField, undefined, !item.IsRequired, false, isNeedsDocumentationType(item), fieldType, undefined);
112
112
  }
113
113
 
114
114
  //# sourceMappingURL=CorEMRFieldTypeMapper.ts.map
@@ -1,6 +1,6 @@
1
1
  import { toString, Record, Union } from "@fable-org/fable-library-js/Types.js";
2
2
  import { int32 } from "@fable-org/fable-library-js/Int32.js";
3
- import { defaultArg, value as value_3, map as map_1, Option } from "@fable-org/fable-library-js/Option.js";
3
+ import { bind, defaultArg, value as value_3, map as map_1, Option } from "@fable-org/fable-library-js/Option.js";
4
4
  import { record_type, list_type, union_type, option_type, bool_type, string_type, int32_type, TypeInfo } from "@fable-org/fable-library-js/Reflection.js";
5
5
  import { isEmpty, filter, singleton as singleton_1, empty as empty_1, ofSeq, choose, collect, sortBy, map, sumBy, length, FSharpList } from "@fable-org/fable-library-js/List.js";
6
6
  import { IDisposable, disposeSafe, IEnumerator, getEnumerator, compare, int32ToString, comparePrimitives, numberHash, IComparable, IEquatable } from "@fable-org/fable-library-js/Util.js";
@@ -12,7 +12,7 @@ import { List_groupBy } from "@fable-org/fable-library-js/Seq2.js";
12
12
  import { join } from "@fable-org/fable-library-js/String.js";
13
13
  import { empty, singleton, append, delay, toList } from "@fable-org/fable-library-js/Seq.js";
14
14
  import { getElementTypeInfo } from "./CorEMRElementTypeMap.js";
15
- import { FormScoring, ScoringLabel } from "../../CorEMR/TemplateManifestDecoder.js";
15
+ import { FormScoring, ScoringLabel } from "../../CorEMR/FormTemplateDecoder.js";
16
16
  import { FSharpResult$2_$union, FSharpResult$2_Ok, FSharpResult$2_Error } from "@fable-org/fable-library-js/Result.js";
17
17
 
18
18
  export type ValidationError_$union =
@@ -371,7 +371,7 @@ export function FormSpecValidator_validateRequiredFields(coreMR: CoreMRFormData,
371
371
  try {
372
372
  while (enumerator_1["System.Collections.IEnumerator.MoveNext"]()) {
373
373
  const field: Spec_FormField$1<Spec_FieldType_$union> = enumerator_1["System.Collections.Generic.IEnumerator`1.get_Current"]();
374
- const matchValue: Option<CoreMRItem> = tryFind<string, CoreMRItem>(field.Label, itemsByLabel);
374
+ const matchValue: Option<CoreMRItem> = bind<string, CoreMRItem>((label: string): Option<CoreMRItem> => tryFind<string, CoreMRItem>(label, itemsByLabel), field.Label);
375
375
  if (matchValue == null) {
376
376
  }
377
377
  else {
@@ -5,6 +5,7 @@ import { list_type, option_type, record_type, string_type, int32_type, TypeInfo
5
5
  import { Option } from "@fable-org/fable-library-js/Option.js";
6
6
  import { item as item_3, length, mapIndexed, append, head, singleton, isEmpty, map, sortBy, filter, FSharpList } from "@fable-org/fable-library-js/List.js";
7
7
  import { CoreMRItem_$reflection, CoreMRItem } from "../../CorEMR/CoreMRTypes.js";
8
+ import { Spec_Label_ofStated } from "../../../FormSpec.js";
8
9
 
9
10
  export class HeadingItem extends Record implements IEquatable<HeadingItem>, IComparable<HeadingItem> {
10
11
  readonly Sequence: int32;
@@ -25,9 +26,9 @@ export function HeadingItem_$reflection(): TypeInfo {
25
26
  export class Section extends Record implements IEquatable<Section>, IComparable<Section> {
26
27
  readonly Heading: Option<HeadingItem>;
27
28
  readonly HeadingSequence: int32;
28
- readonly HeadingLabel: string;
29
+ readonly HeadingLabel: Option<string>;
29
30
  readonly Items: FSharpList<CoreMRItem>;
30
- constructor(Heading: Option<HeadingItem>, HeadingSequence: int32, HeadingLabel: string, Items: FSharpList<CoreMRItem>) {
31
+ constructor(Heading: Option<HeadingItem>, HeadingSequence: int32, HeadingLabel: Option<string>, Items: FSharpList<CoreMRItem>) {
31
32
  super();
32
33
  this.Heading = Heading;
33
34
  this.HeadingSequence = (HeadingSequence | 0);
@@ -37,7 +38,7 @@ export class Section extends Record implements IEquatable<Section>, IComparable<
37
38
  }
38
39
 
39
40
  export function Section_$reflection(): TypeInfo {
40
- return record_type("FormSpec.Integrations.CorEMR.CorEMRSectioning.Section", [], Section, () => [["Heading", option_type(HeadingItem_$reflection())], ["HeadingSequence", int32_type], ["HeadingLabel", string_type], ["Items", list_type(CoreMRItem_$reflection())]]);
41
+ return record_type("FormSpec.Integrations.CorEMR.CorEMRSectioning.Section", [], Section, () => [["Heading", option_type(HeadingItem_$reflection())], ["HeadingSequence", int32_type], ["HeadingLabel", option_type(string_type)], ["Items", list_type(CoreMRItem_$reflection())]]);
41
42
  }
42
43
 
43
44
  /**
@@ -58,7 +59,7 @@ export function detectHeadings(items: FSharpList<CoreMRItem>): FSharpList<Headin
58
59
 
59
60
  /**
60
61
  * Group items into sections based on heading positions.
61
- * Preamble: items before first heading (HeadingLabel = "Form").
62
+ * Preamble: items before first heading (`HeadingLabel = None` — CoreMR states no heading there).
62
63
  * Sections: one per heading, items between heading N and N+1.
63
64
  */
64
65
  export function groupItemsByHeadings(headings: FSharpList<HeadingItem>, allItems: FSharpList<CoreMRItem>): FSharpList<Section> {
@@ -66,20 +67,21 @@ export function groupItemsByHeadings(headings: FSharpList<HeadingItem>, allItems
66
67
  Compare: comparePrimitives,
67
68
  });
68
69
  if (isEmpty(headings)) {
69
- return singleton(new Section(undefined, 0, "Form", nonHeading));
70
+ return singleton(new Section(undefined, 0, undefined, nonHeading));
70
71
  }
71
72
  else {
72
73
  const firstHeading: HeadingItem = head(headings);
73
- return append(singleton(new Section(undefined, 0, "Form", filter<CoreMRItem>((item_1: CoreMRItem): boolean => (item_1.Sequence < firstHeading.Sequence), nonHeading))), mapIndexed<HeadingItem, Section>((index: int32, heading: HeadingItem): Section => {
74
+ return append(singleton(new Section(undefined, 0, undefined, filter<CoreMRItem>((item_1: CoreMRItem): boolean => (item_1.Sequence < firstHeading.Sequence), nonHeading))), mapIndexed<HeadingItem, Section>((index: int32, heading: HeadingItem): Section => {
74
75
  const nextHeadingSeq: int32 = ((index < (length(headings) - 1)) ? item_3(index + 1, headings).Sequence : 2147483647) | 0;
75
- return new Section(heading, heading.Sequence, heading.Label, filter<CoreMRItem>((item_2: CoreMRItem): boolean => {
76
+ const sectionItems: FSharpList<CoreMRItem> = filter<CoreMRItem>((item_2: CoreMRItem): boolean => {
76
77
  if (item_2.Sequence > heading.Sequence) {
77
78
  return item_2.Sequence < nextHeadingSeq;
78
79
  }
79
80
  else {
80
81
  return false;
81
82
  }
82
- }, nonHeading));
83
+ }, nonHeading);
84
+ return new Section(heading, heading.Sequence, Spec_Label_ofStated(heading.Label), sectionItems);
83
85
  }, headings));
84
86
  }
85
87
  }
@@ -4,7 +4,7 @@ import { float64, int32 } from "@fable-org/fable-library-js/Int32.js";
4
4
  import { value as value_129, map, defaultArg, Option } from "@fable-org/fable-library-js/Option.js";
5
5
  import { stringHash, IDisposable, disposeSafe, IEnumerator, getEnumerator, compareArrays, comparePrimitives, IComparable, IEquatable } from "@fable-org/fable-library-js/Util.js";
6
6
  import { int64 } from "@fable-org/fable-library-js/BigInt.js";
7
- import { reverse, length, sortByDescending, cons, sortBy, choose, map as map_2, collect, exists, empty as empty_1, tryFind, head, isEmpty, ofArray, FSharpList } from "@fable-org/fable-library-js/List.js";
7
+ import { reverse, length, sortByDescending, cons, sortBy, map as map_2, choose, collect, exists, empty as empty_1, tryFind, head, isEmpty, ofArray, FSharpList } from "@fable-org/fable-library-js/List.js";
8
8
  import { FSharpMap__get_IsEmpty, tryFind as tryFind_1, FSharpMap__TryFind, ofList, FSharpMap__ContainsKey, FSharpMap } from "@fable-org/fable-library-js/Map.js";
9
9
  import { CoreMRFormData, CoreMRChoice, CoreMRItem, CoreMRTrigger, CoreMRTriggerEvent } from "../../CorEMR/CoreMRTypes.js";
10
10
  import { toString, utcNow } from "@fable-org/fable-library-js/Date.js";
@@ -499,7 +499,10 @@ export function extractFormReferences(itemId: int32, text: string): FSharpList<F
499
499
  * Build field catalog from CoreMR items and FormSpec
500
500
  */
501
501
  export function buildFieldCatalog<T>(items: FSharpList<CoreMRItem>, formSpec: Spec_FormSpec$1<T>): FSharpList<FieldCatalogEntry> {
502
- const fieldDataMap: FSharpMap<string, [string, Option<string>]> = ofList<string, [string, Option<string>]>(collect<Spec_FormStep$1<T>, [string, [string, Option<string>]]>((step: Spec_FormStep$1<T>): FSharpList<[string, [string, Option<string>]]> => map_2<Spec_FormField$1<T>, [string, [string, Option<string>]]>((field: Spec_FormField$1<T>): [string, [string, Option<string>]] => ([field.Label, [field.FieldKey.fields[0], field.Notes] as [string, Option<string>]] as [string, [string, Option<string>]]), step.Fields), formSpec.Steps), {
502
+ const fieldDataMap: FSharpMap<string, [string, Option<string>]> = ofList<string, [string, Option<string>]>(collect<Spec_FormStep$1<T>, [string, [string, Option<string>]]>((step: Spec_FormStep$1<T>): FSharpList<[string, [string, Option<string>]]> => choose<Spec_FormField$1<T>, [string, [string, Option<string>]]>((field: Spec_FormField$1<T>): Option<[string, [string, Option<string>]]> => {
503
+ const guid: string = field.FieldKey.fields[0];
504
+ return map<string, [string, [string, Option<string>]]>((label: string): [string, [string, Option<string>]] => ([label, [guid, field.Notes] as [string, Option<string>]] as [string, [string, Option<string>]]), field.Label);
505
+ }, step.Fields), formSpec.Steps), {
503
506
  Compare: comparePrimitives,
504
507
  });
505
508
  return choose<CoreMRItem, FieldCatalogEntry>((item: CoreMRItem): Option<FieldCatalogEntry> => {
@@ -548,9 +551,7 @@ export function buildPathwayContext(pathway: Option<ClinicalPathway_ClinicalPath
548
551
  const p: ClinicalPathway_ClinicalPathwaySpec = value_129(pathway);
549
552
  return new PathwayContext(map_2<ClinicalPathway_StateDefinition, PathwayState>((state: ClinicalPathway_StateDefinition): PathwayState => {
550
553
  let matchValue: ClinicalPathway_StateType_$union;
551
- return new PathwayState(state.StateKey.fields[0], (matchValue = state.StateType, (matchValue.tag === /* Evaluation */ 1) ? "Evaluation" : ((matchValue.tag === /* Action */ 2) ? "Action" : ((matchValue.tag === /* Terminal */ 5) ? "Terminal" : ((matchValue.tag === /* CompoundAction */ 3) ? "CompoundAction" : ((matchValue.tag === /* ConditionalAction */ 4) ? "ConditionalAction" : (() => {
552
- throw new Error("Match failure: F1.Studio.ClinicalPathway.StateType");
553
- })()))))), state.StateLabel, state.StateOrder);
554
+ return new PathwayState(state.StateKey.fields[0], (matchValue = state.StateType, (matchValue.tag === /* Action */ 1) ? "Action" : ((matchValue.tag === /* Terminal */ 4) ? "Terminal" : ((matchValue.tag === /* CompoundAction */ 2) ? "CompoundAction" : ((matchValue.tag === /* ConditionalAction */ 3) ? "ConditionalAction" : "Evaluation")))), state.StateLabel, state.StateOrder);
554
555
  }, p.States), map_2<ClinicalPathway_TransitionDefinition, PathwayTransition>((trans: ClinicalPathway_TransitionDefinition): PathwayTransition => {
555
556
  let matchValue_2: ClinicalPathway_TransitionCondition_$union;
556
557
  const transKey: string = trans.TransitionKey.fields[0];
@@ -5,22 +5,13 @@ import { FSharpMap, tryFind } from "@fable-org/fable-library-js/Map.js";
5
5
  import { int32 } from "@fable-org/fable-library-js/Int32.js";
6
6
  import { CoreMRItem, CoreMRChoice } from "../../CorEMR/CoreMRTypes.js";
7
7
  import { Spec_FormStep$1, Spec_FieldType_$union, Spec_FormField$1 } from "../../../FormSpec.js";
8
- import { isNullOrWhiteSpace } from "@fable-org/fable-library-js/String.js";
9
8
  import { detectHeadings, groupItemsByHeadings, Section } from "./CorEMRSectioning.js";
10
9
 
11
10
  /**
12
11
  * Create FormSpec Steps from CoreMR items
13
12
  */
14
13
  export function createSteps(formCode: string, items: FSharpList<CoreMRItem>, choicesByItem: FSharpMap<int32, FSharpList<CoreMRChoice>>): FSharpList<Spec_FormStep$1<Spec_FieldType_$union>> {
15
- return mapIndexed<Section, Spec_FormStep$1<Spec_FieldType_$union>>((index: int32, section: Section): Spec_FormStep$1<Spec_FieldType_$union> => (new Spec_FormStep$1(index + 1, section.HeadingLabel, map<CoreMRItem, Spec_FormField$1<Spec_FieldType_$union>>((item: CoreMRItem): Spec_FormField$1<Spec_FieldType_$union> => {
16
- const field: Spec_FormField$1<Spec_FieldType_$union> = mapToFormField(formCode, index + 1, item, defaultArg(tryFind<int32, FSharpList<CoreMRChoice>>(item.ItemId, choicesByItem), empty<CoreMRChoice>()));
17
- if (isNullOrWhiteSpace(field.Label)) {
18
- return new Spec_FormField$1(field.FieldOrder, field.FieldKey, "_(blank)_", field.Notes, field.DependsOn, field.IsOptional, field.IsDeprecated, field.NeedsDocumentation, field.FieldType, field.Value);
19
- }
20
- else {
21
- return field;
22
- }
23
- }, section.Items))), groupItemsByHeadings(detectHeadings(items), items));
14
+ return mapIndexed<Section, Spec_FormStep$1<Spec_FieldType_$union>>((index: int32, section: Section): Spec_FormStep$1<Spec_FieldType_$union> => (new Spec_FormStep$1(index + 1, section.HeadingLabel, map<CoreMRItem, Spec_FormField$1<Spec_FieldType_$union>>((item: CoreMRItem): Spec_FormField$1<Spec_FieldType_$union> => mapToFormField(formCode, index + 1, item, defaultArg(tryFind<int32, FSharpList<CoreMRChoice>>(item.ItemId, choicesByItem), empty<CoreMRChoice>())), section.Items))), groupItemsByHeadings(detectHeadings(items), items));
24
15
  }
25
16
 
26
17
  //# sourceMappingURL=CorEMRStepsBuilder.ts.map
@@ -1,16 +1,16 @@
1
1
  import { Spec_FormClassification_$union, Spec_FormClassification_General, Spec_FormClassification_Screening, Spec_FormClassification_Intake, Spec_FormClassification_ClinicalInstrument, Spec_ClinicalInstrumentInfo } from "../../../FormSpec.js";
2
2
  import { tryParse, int32 } from "@fable-org/fable-library-js/Int32.js";
3
- import { bind, orElse, map as map_1, defaultArg, Option, value as value_5 } from "@fable-org/fable-library-js/Option.js";
3
+ import { bind, orElse, map as map_1, defaultArg, Option, value as value_3 } from "@fable-org/fable-library-js/Option.js";
4
+ import { item as item_2, length, sortBy, FSharpList, empty, choose, isEmpty, map, mapIndexed, collect } from "@fable-org/fable-library-js/List.js";
5
+ import { FSharpRef } from "@fable-org/fable-library-js/Types.js";
6
+ import { CoreMRFormData, CoreMRFormDetail, CoreMRTag, CoreMRChoice, CoreMRItem, CoreMRFormMetadata, CoreMRTrigger, CoreMRTriggerEvent, CoreMRTriggerCondition } from "../../CorEMR/CoreMRTypes.js";
7
+ import { TemplateChoice, carriesTextOrDate, ElementTypeEntry, TemplateForm, ReleaseAvailability$1_$union, TemplateItem, ItemTrigger, TriggerAction, TriggerCondition } from "../../CorEMR/FormTemplateDecoder.js";
4
8
  import { isNullOrEmpty } from "@fable-org/fable-library-js/String.js";
5
9
  import { int64, toInt32 } from "@fable-org/fable-library-js/BigInt.js";
6
- import { CoreMRFormData, CoreMRFormDetail, CoreMRTag, CoreMRTrigger, CoreMRTriggerEvent, CoreMRTriggerCondition, CoreMRChoice, CoreMRItem, CoreMRFormMetadata } from "../../CorEMR/CoreMRTypes.js";
7
- import { empty, choose, item as item_3, length, mapIndexed, sortBy, collect, FSharpList, isEmpty, map } from "@fable-org/fable-library-js/List.js";
8
- import { TemplateForm, ItemTrigger, TriggerAction, TriggerCondition, TemplateChoice, ReleaseAvailability$1_$union, TemplateItem, carriesTextOrDate, ElementTypeEntry } from "../../CorEMR/TemplateManifestDecoder.js";
9
10
  import { FSharpMap, tryFind } from "@fable-org/fable-library-js/Map.js";
10
11
  import { comparePrimitives, int32ToString } from "@fable-org/fable-library-js/Util.js";
11
12
  import { FSharpSet__Contains, FSharpSet, ofSeq } from "@fable-org/fable-library-js/Set.js";
12
13
  import { normalizeChoiceScores } from "../../../BitmaskHelpers.js";
13
- import { FSharpRef } from "@fable-org/fable-library-js/Types.js";
14
14
 
15
15
  /**
16
16
  * Map catalog classification fields to the FormClassification DU.
@@ -27,11 +27,11 @@ import { FSharpRef } from "@fable-org/fable-library-js/Types.js";
27
27
  export function mapFormClassification(formCategory: Option<string>, instrumentType: Option<string>, instrumentMaxScore: Option<int32>): Spec_FormClassification_$union {
28
28
  let matchResult: int32, instType: string;
29
29
  if (formCategory != null) {
30
- switch (value_5(formCategory)) {
30
+ switch (value_3(formCategory)) {
31
31
  case "clinical_instrument": {
32
32
  if (instrumentType != null) {
33
33
  matchResult = 0;
34
- instType = value_5(instrumentType);
34
+ instType = value_3(instrumentType);
35
35
  }
36
36
  else {
37
37
  matchResult = 3;
@@ -65,10 +65,34 @@ export function mapFormClassification(formCategory: Option<string>, instrumentTy
65
65
  }
66
66
  }
67
67
 
68
+ /**
69
+ * The form's RAW trigger rows, reshaped for the record — PROVENANCE ONLY (see the file's teaching note).
70
+ * One `CoreMRTrigger` per item × trigger attachment, conditions and actions exactly as conduit served them.
71
+ * ⛔ Never a pathway input: `CoreMRPathwayMapper` reads the domain, and a test holds that it reads nothing here.
72
+ */
73
+ export function provenanceTriggersOf(template: TemplateForm): FSharpList<CoreMRTrigger> {
74
+ return collect<TemplateItem, CoreMRTrigger>((item: TemplateItem): FSharpList<CoreMRTrigger> => {
75
+ let matchValue: ReleaseAvailability$1_$union<FSharpList<ItemTrigger>>;
76
+ return mapIndexed<ItemTrigger, CoreMRTrigger>((triggerOrder: int32, trigger: ItemTrigger): CoreMRTrigger => (new CoreMRTrigger(trigger.TriggerId, item.ItemId, trigger.EventName, triggerOrder + 1, trigger.ExclusiveTag, trigger.Enabled, map<TriggerCondition, CoreMRTriggerCondition>((cond: TriggerCondition): CoreMRTriggerCondition => (new CoreMRTriggerCondition(cond.ConditionId, trigger.TriggerId, undefined, cond.Source, cond.Operator, !isEmpty(cond.RawChoiceIds) ? cond.RawChoiceIds : choose<string, int32>((value: string): Option<int32> => {
77
+ let matchValue_1: [boolean, int32];
78
+ let outArg = 0;
79
+ matchValue_1 = ([tryParse(value, 511, false, 32, new FSharpRef<int32>((): int32 => outArg, (v: int32): void => {
80
+ outArg = (v | 0);
81
+ })), outArg] as [boolean, int32]);
82
+ if (matchValue_1[0]) {
83
+ return matchValue_1[1];
84
+ }
85
+ else {
86
+ return undefined;
87
+ }
88
+ }, cond.Values))), trigger.Conditions), map<TriggerAction, CoreMRTriggerEvent>((action: TriggerAction): CoreMRTriggerEvent => (new CoreMRTriggerEvent(action.ActionId, trigger.TriggerId, action.ActionType, action.Params)), trigger.Actions))), (matchValue = item.Triggers, (matchValue.tag === /* NotInRelease */ 1) ? empty<ItemTrigger>() : ((matchValue.tag === /* NotReadYet */ 2) ? empty<ItemTrigger>() : matchValue.fields[0])));
89
+ }, template.Items);
90
+ }
91
+
68
92
  /**
69
93
  * Map bridge template (TemplateForm — SSOT) to CoreMRFormDetail.
70
94
  * When elementTypes is non-empty, use it for ItemTypeName, HasText, HasDate, and bitmask detection.
71
- * When elementTypes is empty, fallback to CorEMRElementTypeMap.
95
+ * A kind `elementTypes` does not carry is NAMED unresolved (`unresolved_<code>`) — never guessed from a constant.
72
96
  */
73
97
  export function mapNewTemplateToCoreMRDetail(elementTypes: FSharpMap<string, ElementTypeEntry>, template: TemplateForm): CoreMRFormDetail {
74
98
  const metadata: CoreMRFormMetadata = new CoreMRFormMetadata(template.FormId, template.Name, isNullOrEmpty(template.Description) ? undefined : template.Description, ~~toInt32(template.CurrentVersionId), 1, undefined, template.RequiresSignature, template.IsIntake, template.FormCode, "");
@@ -92,39 +116,20 @@ export function mapNewTemplateToCoreMRDetail(elementTypes: FSharpMap<string, Ele
92
116
  const bitPositions: Option<FSharpList<int32>> = (FSharpSet__Contains(multiSelectTypes, item_1.Type) && patternInput_1[1]) ? patternInput_1[0] : undefined;
93
117
  return mapIndexed<TemplateChoice, CoreMRChoice>((index: int32, choice: TemplateChoice): CoreMRChoice => (new CoreMRChoice(choice.ChoiceId, item_1.ItemId, choice.Sequence, choice.Text, choice.Score, orElse(choice.BitPosition, bind<FSharpList<int32>, int32>((positions: FSharpList<int32>): Option<int32> => {
94
118
  if (index < length(positions)) {
95
- return item_3(index, positions);
119
+ return item_2(index, positions);
96
120
  }
97
121
  else {
98
122
  return undefined;
99
123
  }
100
124
  }, bitPositions)), choice.Code, map_1<int32, string>(int32ToString, choice.Highlight))), sortedChoices);
101
- }, template.Items), collect<TemplateItem, CoreMRTrigger>((item_2: TemplateItem): FSharpList<CoreMRTrigger> => {
102
- let matchValue_1: ReleaseAvailability$1_$union<FSharpList<ItemTrigger>>;
103
- return mapIndexed<ItemTrigger, CoreMRTrigger>((triggerOrder: int32, trigger: ItemTrigger): CoreMRTrigger => {
104
- const conditions: FSharpList<CoreMRTriggerCondition> = map<TriggerCondition, CoreMRTriggerCondition>((cond: TriggerCondition): CoreMRTriggerCondition => (new CoreMRTriggerCondition(cond.ConditionId, trigger.TriggerId, undefined, cond.Source, cond.Operator, !isEmpty(cond.RawChoiceIds) ? cond.RawChoiceIds : choose<string, int32>((value_3: string): Option<int32> => {
105
- let matchValue_2: [boolean, int32];
106
- let outArg = 0;
107
- matchValue_2 = ([tryParse(value_3, 511, false, 32, new FSharpRef<int32>((): int32 => outArg, (v: int32): void => {
108
- outArg = (v | 0);
109
- })), outArg] as [boolean, int32]);
110
- if (matchValue_2[0]) {
111
- return matchValue_2[1];
112
- }
113
- else {
114
- return undefined;
115
- }
116
- }, cond.Values))), trigger.Conditions);
117
- const events: FSharpList<CoreMRTriggerEvent> = map<TriggerAction, CoreMRTriggerEvent>((action: TriggerAction): CoreMRTriggerEvent => (new CoreMRTriggerEvent(action.ActionId, trigger.TriggerId, action.ActionType, action.Params)), trigger.Actions);
118
- return new CoreMRTrigger(trigger.TriggerId, item_2.ItemId, trigger.EventName, triggerOrder + 1, defaultArg(trigger.ExclusiveTag, ""), trigger.Enabled, conditions, events);
119
- }, (matchValue_1 = item_2.Triggers, (matchValue_1.tag === /* NotInRelease */ 1) ? empty<ItemTrigger>() : ((matchValue_1.tag === /* NotReadYet */ 2) ? empty<ItemTrigger>() : matchValue_1.fields[0])));
120
- }, template.Items), empty<CoreMRTag>(), undefined);
125
+ }, template.Items), provenanceTriggersOf(template), empty<CoreMRTag>(), undefined);
121
126
  }
122
127
 
123
128
  /**
124
129
  * ⭐ THE ONE `TemplateForm -> CoreMRFormData` PATH. A projection of the single builder above, so
125
130
  * Studio and f1-api cannot drift: the same CoreMR form becomes the same record in both.
126
131
  *
127
- * ⚰️ It replaces `TemplateManifestDecoder.toCoreMRFormData`, a SECOND builder that stringified the
132
+ * ⚰️ It replaces `FormTemplateDecoder.toCoreMRFormData`, a SECOND builder that stringified the
128
133
  * item type code, hardcoded `HasText`/`HasDate`, dropped every trigger and tag, and never computed a
129
134
  * choice's `BitPosition`. Studio used that one and f1-api used this one.
130
135
  */
@@ -1,18 +1,15 @@
1
1
  import { Helpers_generateDeterministicGuidRaw, Helpers_canonicalizeFieldKey } from "../../../Helpers.js";
2
- import { tryFind, FSharpMap, ofList } from "@fable-org/fable-library-js/Map.js";
3
- import { empty, collect, isEmpty, sortBy, FSharpList, map } from "@fable-org/fable-library-js/List.js";
2
+ import { defaultArg, Option, bind } from "@fable-org/fable-library-js/Option.js";
3
+ import { empty, isEmpty, FSharpList, map, sortBy } from "@fable-org/fable-library-js/List.js";
4
+ import { Spec_FormSpec$1_$reflection, Spec_FieldType_$reflection, Spec_FormSpec$1, Spec_FormClassification_General, Spec_FormLifecycle_Blueprint, Spec_FieldType_$union, Spec_FormStep$1, Spec_VendorScore, Spec_VendorScoreBand } from "../../../FormSpec.js";
4
5
  import { int32 } from "@fable-org/fable-library-js/Int32.js";
5
- import { CoreMRFormData, CoreMRTag, CoreMRItem, CoreMRChoice } from "../../CorEMR/CoreMRTypes.js";
6
+ import { FormScoring, ScoringLabel } from "../../CorEMR/FormTemplateDecoder.js";
6
7
  import { numberHash, comparePrimitives } from "@fable-org/fable-library-js/Util.js";
7
- import { defaultArg, Option, bind } from "@fable-org/fable-library-js/Option.js";
8
- import { Spec_FormSpec$1_$reflection, Spec_FieldType_$reflection, Spec_FormSpec$1, Spec_FormClassification_General, Spec_FormLifecycle_Blueprint, ClinicalPathway_ClinicalPathwaySpec, Spec_FormField$1, Shared_FieldKey, Spec_FieldType_$union, Spec_FormStep$1, Spec_VendorScore, Spec_VendorScoreBand } from "../../../FormSpec.js";
9
- import { FormScoring, ScoringLabel } from "../../CorEMR/TemplateManifestDecoder.js";
10
8
  import { toConsoleError, printf, toText, substring } from "@fable-org/fable-library-js/String.js";
11
9
  import { createSteps } from "./CorEMRStepsBuilder.js";
10
+ import { ofList } from "@fable-org/fable-library-js/Map.js";
12
11
  import { List_groupBy } from "@fable-org/fable-library-js/Seq2.js";
13
- import { generateNamespacedFieldKey } from "./CorEMRFieldTypeMapper.js";
14
- import { nonHeadingItems } from "./CorEMRSectioning.js";
15
- import { convertTriggersToSinglePathway } from "./CorEMRTriggerConverter.js";
12
+ import { CoreMRFormData, CoreMRTag, CoreMRChoice } from "../../CorEMR/CoreMRTypes.js";
16
13
  import { Auto_generateBoxedEncoder_437914C6, toString } from "../../../../Thoth.Json/packages/Thoth.Json/Encode.js";
17
14
  import { FSharpResult$2_Ok, FSharpResult$2_$union, FSharpResult$2_Error } from "@fable-org/fable-library-js/Result.js";
18
15
  import { FormSpecValidator_validateConversion, ValidationResult } from "./CorEMRFormSpecValidator.js";
@@ -32,15 +29,6 @@ export function generateStableDeterministicGuid(name: string): string {
32
29
  return Helpers_generateDeterministicGuidRaw(`coremr:formspec:${name}`);
33
30
  }
34
31
 
35
- /**
36
- * Create mapping from choice ID to actual text value
37
- */
38
- export function createChoiceIdToTextMap(choices: FSharpList<CoreMRChoice>): FSharpMap<int32, string> {
39
- return ofList<int32, string>(map<CoreMRChoice, [int32, string]>((c: CoreMRChoice): [int32, string] => ([c.ChoiceId, c.Text] as [int32, string]), choices), {
40
- Compare: comparePrimitives,
41
- });
42
- }
43
-
44
32
  /**
45
33
  * ⚰️ `calculateScore` WAS HERE AND IS NOT COMING BACK. It summed every `item_choices.score`
46
34
  * in the form — the BITMASK WEIGHT column, which `CoreMRTypes.CoreMRChoice.Score` documents as
@@ -121,14 +109,7 @@ export function convertToFormSpec(scoring: Option<FormScoring>, formData: CoreMR
121
109
  Compare: comparePrimitives,
122
110
  }));
123
111
  const vendorScore: Option<Spec_VendorScore> = statedScale(scoring);
124
- const fieldKeyBySequence: FSharpMap<int32, Shared_FieldKey> = ofList<int32, Shared_FieldKey>(map<Spec_FormField$1<Spec_FieldType_$union>, [int32, Shared_FieldKey]>((field: Spec_FormField$1<Spec_FieldType_$union>): [int32, Shared_FieldKey] => ([field.FieldOrder, field.FieldKey] as [int32, Shared_FieldKey]), collect<Spec_FormStep$1<Spec_FieldType_$union>, Spec_FormField$1<Spec_FieldType_$union>>((step: Spec_FormStep$1<Spec_FieldType_$union>): FSharpList<Spec_FormField$1<Spec_FieldType_$union>> => step.Fields, steps)), {
125
- Compare: comparePrimitives,
126
- });
127
- const itemIdToFieldKeyMap: FSharpMap<int32, Shared_FieldKey> = ofList<int32, Shared_FieldKey>(map<CoreMRItem, [int32, Shared_FieldKey]>((item: CoreMRItem): [int32, Shared_FieldKey] => ([item.ItemId, defaultArg(tryFind<int32, Shared_FieldKey>(item.Sequence, fieldKeyBySequence), generateNamespacedFieldKey(formCode, 1, item))] as [int32, Shared_FieldKey]), nonHeadingItems(formData.Items)), {
128
- Compare: comparePrimitives,
129
- });
130
- const clinicalPathway: Option<ClinicalPathway_ClinicalPathwaySpec> = isEmpty(formData.Triggers) ? undefined : convertTriggersToSinglePathway(formData.Triggers, (itemId: int32): Shared_FieldKey => defaultArg(tryFind<int32, Shared_FieldKey>(itemId, itemIdToFieldKeyMap), new Shared_FieldKey(generateStableDeterministicGuid(`unknown_item_${itemId}`))), createChoiceIdToTextMap(formData.Choices), formData.Metadata, formData.Items);
131
- return new Spec_FormSpec$1(generateStableDeterministicGuid(`form_${formData.Metadata.FormId}_${formData.Metadata.FormName}`), formCode, formData.Metadata.FormName, defaultArg(formData.Metadata.Description, ""), toText(printf("1.0.0-CoreEMRv%d"))(formData.Metadata.VersionNumber), "5.0.0", steps, map<CoreMRTag, string>((t: CoreMRTag): string => t.TagName, formData.Tags), undefined, vendorScore, empty<string>(), formData.Metadata.RequiresSignature, false, clinicalPathway, Spec_FormLifecycle_Blueprint(), undefined, undefined, undefined, Spec_FormClassification_General());
112
+ return new Spec_FormSpec$1(generateStableDeterministicGuid(`form_${formData.Metadata.FormId}_${formData.Metadata.FormName}`), formCode, formData.Metadata.FormName, defaultArg(formData.Metadata.Description, ""), toText(printf("1.0.0-CoreEMRv%d"))(formData.Metadata.VersionNumber), "5.0.0", steps, map<CoreMRTag, string>((t: CoreMRTag): string => t.TagName, formData.Tags), undefined, vendorScore, empty<string>(), formData.Metadata.RequiresSignature, false, undefined, Spec_FormLifecycle_Blueprint(), undefined, undefined, undefined, Spec_FormClassification_General());
132
113
  }
133
114
 
134
115
  /**
@@ -806,10 +806,9 @@ export function encodeToFormAnswersWithVitals(provenancePayload: string, filledF
806
806
  const matchValue: FSharpResult$2_$union<CoreMRSourceMap, string> = tryDecodeSourceMap(provenancePayload);
807
807
  if (matchValue.tag === /* Ok */ 0) {
808
808
  const sourceMap: CoreMRSourceMap = matchValue.fields[0];
809
- const formName: string = defaultArg(sourceMap.FormName, `CORE-${sourceMap.FormId}`);
810
809
  const fieldMap: FSharpMap<string, Spec_FormField$1<Spec_FieldType_$union>> = buildFieldByKeyMap(filledFormSpec);
811
810
  try {
812
- return FSharpResult$2_Ok<CoreMRFormInsertRequest, string>(new CoreMRFormInsertRequest(sourceMap.FormId, formName, scaffoldMode ? undefined : ((acc = collect<CoreMRFieldAnchor, CoreMRAnswer>((anchor: CoreMRFieldAnchor): FSharpList<CoreMRAnswer> => anchorToAnswers(fieldMap, vitalsIdOpt, anchor), collect<CoreMRStepMap, CoreMRFieldAnchor>((step: CoreMRStepMap): FSharpList<CoreMRFieldAnchor> => step.FieldAnchors, sourceMap.Steps)), isEmpty(acc) ? undefined : acc)), dryRun, undefined));
811
+ return FSharpResult$2_Ok<CoreMRFormInsertRequest, string>(new CoreMRFormInsertRequest(sourceMap.FormId, sourceMap.FormName, scaffoldMode ? undefined : ((acc = collect<CoreMRFieldAnchor, CoreMRAnswer>((anchor: CoreMRFieldAnchor): FSharpList<CoreMRAnswer> => anchorToAnswers(fieldMap, vitalsIdOpt, anchor), collect<CoreMRStepMap, CoreMRFieldAnchor>((step: CoreMRStepMap): FSharpList<CoreMRFieldAnchor> => step.FieldAnchors, sourceMap.Steps)), isEmpty(acc) ? undefined : acc)), dryRun, undefined));
813
812
  }
814
813
  catch (matchValue_1: any) {
815
814
  const activePatternResult: Option<string> = Operators_FailurePattern(matchValue_1);
@@ -852,12 +851,9 @@ export function encodeToFormAnswers(provenancePayload: string, filledFormSpec: S
852
851
  return FSharpResult$2_Error<CoreMRFormInsertRequest, string>(`FormSpecId mismatch: provenance is for form ${sourceMap.FormSpecId} but data is from form ${filledFormSpec.Id}. This could cause patient data mixing!`);
853
852
  }
854
853
  else {
855
- let formName: string;
856
- const value = `CORE-${sourceMap.FormId}`;
857
- formName = defaultArg(orElse(sourceMap.FormName, isNullOrWhiteSpace(filledFormSpec.Title) ? undefined : filledFormSpec.Title), value);
858
854
  const fieldMap: FSharpMap<string, Spec_FormField$1<Spec_FieldType_$union>> = buildFieldByKeyMap(filledFormSpec);
859
855
  try {
860
- return FSharpResult$2_Ok<CoreMRFormInsertRequest, string>(new CoreMRFormInsertRequest(sourceMap.FormId, formName, scaffoldMode ? undefined : ((acc = collect<CoreMRFieldAnchor, CoreMRAnswer>((anchor: CoreMRFieldAnchor): FSharpList<CoreMRAnswer> => anchorToAnswers(fieldMap, undefined, anchor), collect<CoreMRStepMap, CoreMRFieldAnchor>((step: CoreMRStepMap): FSharpList<CoreMRFieldAnchor> => step.FieldAnchors, sourceMap.Steps)), isEmpty(acc) ? undefined : acc)), dryRun, undefined));
856
+ return FSharpResult$2_Ok<CoreMRFormInsertRequest, string>(new CoreMRFormInsertRequest(sourceMap.FormId, sourceMap.FormName, scaffoldMode ? undefined : ((acc = collect<CoreMRFieldAnchor, CoreMRAnswer>((anchor: CoreMRFieldAnchor): FSharpList<CoreMRAnswer> => anchorToAnswers(fieldMap, undefined, anchor), collect<CoreMRStepMap, CoreMRFieldAnchor>((step: CoreMRStepMap): FSharpList<CoreMRFieldAnchor> => step.FieldAnchors, sourceMap.Steps)), isEmpty(acc) ? undefined : acc)), dryRun, undefined));
861
857
  }
862
858
  catch (matchValue_1: any) {
863
859
  const activePatternResult: Option<string> = Operators_FailurePattern(matchValue_1);