@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,643 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: Object.getOwnPropertyDescriptor(all, name).get
9
- });
10
- }
11
- _export(exports, {
12
- get combineConditions () {
13
- return combineConditions;
14
- },
15
- get convertAction () {
16
- return convertAction;
17
- },
18
- get convertCondition () {
19
- return convertCondition;
20
- },
21
- get convertFormTriggersToPathway () {
22
- return convertFormTriggersToPathway;
23
- },
24
- get convertOperator () {
25
- return convertOperator;
26
- },
27
- get convertTiming () {
28
- return convertTiming;
29
- },
30
- get convertTriggerToPathway () {
31
- return convertTriggerToPathway;
32
- },
33
- get generateActionLabel () {
34
- return generateActionLabel;
35
- },
36
- get generateEvaluationLabel () {
37
- return generateEvaluationLabel;
38
- }
39
- });
40
- const _Helpers = require("../../Helpers.js");
41
- const _List = require("@fable-org/fable-library-js/List.js");
42
- const _FormSpec = require("../../FormSpec.js");
43
- const _Option = require("@fable-org/fable-library-js/Option.js");
44
- const _Int32 = require("@fable-org/fable-library-js/Int32.js");
45
- const _String = require("@fable-org/fable-library-js/String.js");
46
- const _Types = require("@fable-org/fable-library-js/Types.js");
47
- const _DateOffset = require("@fable-org/fable-library-js/DateOffset.js");
48
- const _TimeSpan = require("@fable-org/fable-library-js/TimeSpan.js");
49
- const _Map = require("@fable-org/fable-library-js/Map.js");
50
- const _Set = require("@fable-org/fable-library-js/Set.js");
51
- const _Util = require("@fable-org/fable-library-js/Util.js");
52
- const _Array = require("@fable-org/fable-library-js/Array.js");
53
- const _Seq2 = require("@fable-org/fable-library-js/Seq2.js");
54
- function stableGuid(name) {
55
- return (0, _Helpers.Helpers_generateDeterministicGuidRaw)(`coremr:item_trigger:${name}`);
56
- }
57
- function convertOperator(operator, values) {
58
- const canonValues = (0, _List.map)(_Helpers.Helpers_canonicalizeFieldKey, values);
59
- const matchValue = operator.toLowerCase();
60
- switch(matchValue){
61
- case "any":
62
- return (0, _FormSpec.ClinicalPathway_FieldEvaluator_InSet)(canonValues);
63
- case "equals":
64
- return (0, _FormSpec.ClinicalPathway_FieldEvaluator_Equals)();
65
- case "not_equals":
66
- return (0, _FormSpec.ClinicalPathway_FieldEvaluator_NotEquals)();
67
- case "greater":
68
- return (0, _FormSpec.ClinicalPathway_FieldEvaluator_GreaterThan)();
69
- case "greater_equals":
70
- return (0, _FormSpec.ClinicalPathway_FieldEvaluator_GreaterOrEqual)();
71
- case "less":
72
- return (0, _FormSpec.ClinicalPathway_FieldEvaluator_LessThan)();
73
- case "less_equals":
74
- return (0, _FormSpec.ClinicalPathway_FieldEvaluator_LessOrEqual)();
75
- case "all":
76
- return (0, _FormSpec.ClinicalPathway_FieldEvaluator_ContainsAll)(canonValues);
77
- case "none":
78
- return (0, _FormSpec.ClinicalPathway_FieldEvaluator_NotInSet)(canonValues);
79
- case "regex":
80
- return (0, _FormSpec.ClinicalPathway_FieldEvaluator_MatchesPattern)((0, _Option.defaultArg)((0, _List.tryHead)(values), ".*"));
81
- default:
82
- throw new Error(`ItemTriggerConverter: unknown operator '${matchValue}'`);
83
- }
84
- }
85
- function convertTiming(eventName) {
86
- const matchValue = eventName.toLowerCase();
87
- switch(matchValue){
88
- case "save":
89
- return (0, _FormSpec.ClinicalPathway_TriggerTiming_OnFormSave)();
90
- case "lock":
91
- return (0, _FormSpec.ClinicalPathway_TriggerTiming_OnFormSubmit)();
92
- case "open_first_time":
93
- return (0, _FormSpec.ClinicalPathway_TriggerTiming_OnFormLoad)();
94
- default:
95
- return (0, _FormSpec.ClinicalPathway_TriggerTiming_OnFormSave)();
96
- }
97
- }
98
- function convertPriority(priorityStr) {
99
- switch(priorityStr){
100
- case "1":
101
- return (0, _FormSpec.ClinicalPathway_TaskPriority_High)();
102
- case "3":
103
- return (0, _FormSpec.ClinicalPathway_TaskPriority_Low)();
104
- default:
105
- return (0, _FormSpec.ClinicalPathway_TaskPriority_Medium)();
106
- }
107
- }
108
- function parseDueDate(dateStr) {
109
- const matchValue = dateStr.trim().toLowerCase();
110
- let matchResult;
111
- switch(matchValue){
112
- case "today":
113
- case "":
114
- {
115
- matchResult = 0;
116
- break;
117
- }
118
- case "tomorrow":
119
- {
120
- matchResult = 1;
121
- break;
122
- }
123
- default:
124
- if (matchValue.startsWith("+")) {
125
- matchResult = 2;
126
- } else {
127
- matchResult = 3;
128
- }
129
- }
130
- switch(matchResult){
131
- case 0:
132
- return (0, _FormSpec.ClinicalPathway_DueDate_Today)();
133
- case 1:
134
- return (0, _FormSpec.ClinicalPathway_DueDate_Tomorrow)();
135
- case 2:
136
- {
137
- let matchValue_1;
138
- let outArg = 0;
139
- matchValue_1 = [
140
- (0, _Int32.tryParse)((0, _String.replace)((0, _String.replace)((0, _String.replace)(matchValue, "+", ""), "days", ""), "day", "").trim(), 511, false, 32, new _Types.FSharpRef(()=>outArg, (v)=>{
141
- outArg = v | 0;
142
- })),
143
- outArg
144
- ];
145
- if (matchValue_1[0]) {
146
- return (0, _FormSpec.ClinicalPathway_DueDate_DaysFromNow)(matchValue_1[1]);
147
- } else {
148
- return (0, _FormSpec.ClinicalPathway_DueDate_Today)();
149
- }
150
- }
151
- default:
152
- return (0, _FormSpec.ClinicalPathway_DueDate_Today)();
153
- }
154
- }
155
- function parseRecurrence(endStr) {
156
- let matchResult, s;
157
- if (endStr != null) {
158
- if ((0, _Option.value)(endStr) === "") {
159
- matchResult = 0;
160
- } else {
161
- matchResult = 1;
162
- s = (0, _Option.value)(endStr);
163
- }
164
- } else {
165
- matchResult = 0;
166
- }
167
- switch(matchResult){
168
- case 0:
169
- return undefined;
170
- default:
171
- {
172
- const dueDate = parseDueDate(s);
173
- let until;
174
- if (dueDate.tag === /* DaysFromNow */ 2) {
175
- const days = dueDate.fields[0] | 0;
176
- until = (0, _FormSpec.ClinicalPathway_RecurrenceEnd_OnDate)((0, _DateOffset.addDays)((0, _DateOffset.utcNow)(), days));
177
- } else {
178
- until = (0, _FormSpec.ClinicalPathway_RecurrenceEnd_AfterOccurrences)(7);
179
- }
180
- return new _FormSpec.ClinicalPathway_RecurrencePattern((0, _TimeSpan.fromDays)(1), until);
181
- }
182
- }
183
- }
184
- function convertCondition(cond, itemFieldKeyMap) {
185
- const fieldKey = (0, _Option.defaultArgWith)((0, _Map.tryFind)(cond.SourceFieldId, itemFieldKeyMap), ()=>new _FormSpec.Shared_FieldKey(stableGuid(`field_${cond.SourceFieldId}`)));
186
- const evaluator = convertOperator(cond.Operator, cond.Values);
187
- const canonicalize = _Helpers.Helpers_canonicalizeFieldKey;
188
- let condValue;
189
- const matchValue = cond.Operator.toLowerCase();
190
- switch(matchValue){
191
- case "any":
192
- case "all":
193
- case "none":
194
- {
195
- condValue = (0, _FormSpec.Shared_ConditionValue_Multiple)((0, _Set.ofList)((0, _List.map)(canonicalize, cond.Values), {
196
- Compare: _Util.comparePrimitives
197
- }));
198
- break;
199
- }
200
- default:
201
- {
202
- const matchValue_1 = cond.Values;
203
- if ((0, _List.isEmpty)(matchValue_1)) {
204
- const matchValue_2 = cond.RawChoiceIds;
205
- condValue = (0, _List.isEmpty)(matchValue_2) ? (0, _FormSpec.Shared_ConditionValue_Single)("") : (0, _FormSpec.Shared_ConditionValue_Single)((0, _Util.int32ToString)((0, _List.head)(matchValue_2)));
206
- } else {
207
- condValue = (0, _FormSpec.Shared_ConditionValue_Single)(canonicalize((0, _List.head)(matchValue_1)));
208
- }
209
- }
210
- }
211
- const matchValue_3 = cond.Source.toLowerCase();
212
- switch(matchValue_3){
213
- case "flow_bp_sys":
214
- return (0, _FormSpec.ClinicalPathway_TransitionCondition_PluginPropertyCondition)(fieldKey, new _FormSpec.Shared_PluginPropertyKey(stableGuid("bp_systolic")), evaluator, condValue);
215
- case "flow_bp_dia":
216
- return (0, _FormSpec.ClinicalPathway_TransitionCondition_PluginPropertyCondition)(fieldKey, new _FormSpec.Shared_PluginPropertyKey(stableGuid("bp_diastolic")), evaluator, condValue);
217
- default:
218
- return (0, _FormSpec.ClinicalPathway_TransitionCondition_FieldCondition)(fieldKey, evaluator, condValue);
219
- }
220
- }
221
- function combineConditions(conditions, itemFieldKeyMap) {
222
- let matchValue;
223
- if (!(0, _List.isEmpty)(conditions)) {
224
- if ((0, _List.isEmpty)((0, _List.tail)(conditions))) {
225
- return convertCondition((0, _List.head)(conditions), itemFieldKeyMap);
226
- } else {
227
- const converted = (0, _List.map)((c)=>convertCondition(c, itemFieldKeyMap), conditions);
228
- return (0, _FormSpec.ClinicalPathway_TransitionCondition_CompositeCondition)((matchValue = (0, _Option.map)((c_1)=>c_1.BooleanOperator, (0, _List.tryHead)(conditions)), matchValue != null ? (0, _Option.value)(matchValue) === "||" ? (0, _FormSpec.ClinicalPathway_LogicalOp_Or)() : (0, _FormSpec.ClinicalPathway_LogicalOp_And)() : (0, _FormSpec.ClinicalPathway_LogicalOp_And)()), converted);
229
- }
230
- } else {
231
- return (0, _FormSpec.ClinicalPathway_TransitionCondition_Always)();
232
- }
233
- }
234
- function param(key, action) {
235
- return (0, _Option.defaultArg)((0, _Map.tryFind)(key, action.Params), "");
236
- }
237
- function tryParsePositiveInt(value) {
238
- let matchValue;
239
- let outArg = 0;
240
- matchValue = [
241
- (0, _Int32.tryParse)(value, 511, false, 32, new _Types.FSharpRef(()=>outArg, (v)=>{
242
- outArg = v | 0;
243
- })),
244
- outArg
245
- ];
246
- let matchResult;
247
- if (matchValue[0]) {
248
- if (matchValue[1] > 0) {
249
- matchResult = 0;
250
- } else {
251
- matchResult = 1;
252
- }
253
- } else {
254
- matchResult = 1;
255
- }
256
- switch(matchResult){
257
- case 0:
258
- return matchValue[1];
259
- default:
260
- return undefined;
261
- }
262
- }
263
- function paramInt(keys, action) {
264
- return (0, _List.tryPick)((key)=>(0, _Option.bind)(tryParsePositiveInt, (0, _Map.tryFind)(key, action.Params)), keys);
265
- }
266
- function convertAction(action) {
267
- let s, cn, tn;
268
- const matchValue = action.ActionType.toLowerCase();
269
- switch(matchValue){
270
- case "alert":
271
- {
272
- const categoryName = param("category_name", action);
273
- return (0, _FormSpec.ClinicalPathway_ActionInfo_Alert)(new _FormSpec.ClinicalPathway_AlertAction(paramInt((0, _List.ofArray)([
274
- "category_id",
275
- "id"
276
- ]), action), categoryName, `Alert: ${categoryName}`, (0, _FormSpec.ClinicalPathway_AlertSeverity_High)(), undefined));
277
- }
278
- case "task":
279
- {
280
- const category = param("category_name", action);
281
- const categoryId_1 = paramInt((0, _List.ofArray)([
282
- "id",
283
- "category_id",
284
- "cat_id"
285
- ]), action);
286
- let assignee;
287
- const parts = (0, _String.split)(category, [
288
- "-"
289
- ], undefined, 0);
290
- assignee = parts.length > 0 ? (0, _Array.item)(0, parts).trim() : "Staff";
291
- return (0, _FormSpec.ClinicalPathway_ActionInfo_Task)(new _FormSpec.ClinicalPathway_TaskAction(categoryId_1, category, param("description", action), convertPriority(param("priority", action)), parseDueDate(param("start", action)), assignee, undefined));
292
- }
293
- case "recurring_task":
294
- {
295
- const category_1 = param("category_name", action);
296
- const categoryId_2 = paramInt((0, _List.ofArray)([
297
- "id",
298
- "category_id",
299
- "cat_id"
300
- ]), action);
301
- let assignee_1;
302
- const parts_1 = (0, _String.split)(category_1, [
303
- "-"
304
- ], undefined, 0);
305
- assignee_1 = parts_1.length > 0 ? (0, _Array.item)(0, parts_1).trim() : "Staff";
306
- return (0, _FormSpec.ClinicalPathway_ActionInfo_Task)(new _FormSpec.ClinicalPathway_TaskAction(categoryId_2, category_1, param("description", action), convertPriority(param("priority", action)), parseDueDate(param("start", action)), assignee_1, parseRecurrence((0, _Map.tryFind)("end", action.Params))));
307
- }
308
- case "medset":
309
- return (0, _FormSpec.ClinicalPathway_ActionInfo_Medset)(new _FormSpec.ClinicalPathway_MedsetAction(paramInt((0, _List.singleton)("medset_id"), action), param("medset_name", action), paramInt((0, _List.ofArray)([
310
- "doctor",
311
- "provider"
312
- ]), action), paramInt((0, _List.singleton)("pharmacy_id"), action), parseDueDate((0, _Option.defaultArg)((0, _Map.tryFind)("date", action.Params), "today")), paramInt((0, _List.singleton)("category_id"), action)));
313
- case "problem":
314
- return (0, _FormSpec.ClinicalPathway_ActionInfo_Problem)(new _FormSpec.ClinicalPathway_ProblemAction(paramInt((0, _List.ofArray)([
315
- "problem_list_id",
316
- "category_id",
317
- "id"
318
- ]), action), (s = param("category_name", action), (0, _String.isNullOrEmpty)(s) ? "Problem" : s), undefined, (0, _DateOffset.utcNow)(), (0, _FormSpec.ClinicalPathway_ProblemStatus_Active)(), undefined, paramInt((0, _List.singleton)("chronic"), action), paramInt((0, _List.singleton)("severity"), action), paramInt((0, _List.singleton)("inflammation"), action)));
319
- case "treatment":
320
- return (0, _FormSpec.ClinicalPathway_ActionInfo_Treatment)(new _FormSpec.ClinicalPathway_TreatmentAction(paramInt((0, _List.singleton)("id"), action), (cn = param("category_name", action), (0, _String.isNullOrEmpty)(cn) ? (tn = param("treatment_name", action), (0, _String.isNullOrEmpty)(tn) ? "Treatment" : tn) : cn), paramInt((0, _List.ofArray)([
321
- "provider",
322
- "doctor"
323
- ]), action), paramInt((0, _List.singleton)("schedule_id"), action), (0, _Map.tryFind)("signature", action.Params), parseDueDate(param("start", action)), parseDueDate((0, _Option.defaultArg)((0, _Map.tryFind)("duration", action.Params), "+7 days")), (0, _Map.tryFind)("description", action.Params), (0, _Option.map)(convertPriority, (0, _Map.tryFind)("priority", action.Params)), paramInt((0, _List.singleton)("source_related_id"), action), paramInt((0, _List.singleton)("category_id"), action)));
324
- case "taskcomplete":
325
- return (0, _FormSpec.ClinicalPathway_ActionInfo_Task)(new _FormSpec.ClinicalPathway_TaskAction(undefined, `Complete: ${param("category_name", action)}`, "Mark task as complete", (0, _FormSpec.ClinicalPathway_TaskPriority_Medium)(), (0, _FormSpec.ClinicalPathway_DueDate_Today)(), "Staff", undefined));
326
- case "approval":
327
- return (0, _FormSpec.ClinicalPathway_ActionInfo_Task)(new _FormSpec.ClinicalPathway_TaskAction(undefined, "Approval Required", param("description", action), (0, _FormSpec.ClinicalPathway_TaskPriority_High)(), (0, _FormSpec.ClinicalPathway_DueDate_Today)(), "Supervisor", undefined));
328
- case "groups":
329
- return (0, _FormSpec.ClinicalPathway_ActionInfo_Documentation)(new _FormSpec.ClinicalPathway_DocumentationAction("Group Assignment", param("category_name", action), false));
330
- default:
331
- return (0, _FormSpec.ClinicalPathway_ActionInfo_Task)(new _FormSpec.ClinicalPathway_TaskAction(undefined, `Unknown action: ${matchValue}`, (0, _String.join)("; ", (0, _List.map)((tupledArg)=>`${tupledArg[0]}=${tupledArg[1]}`, (0, _Map.toList)(action.Params))), (0, _FormSpec.ClinicalPathway_TaskPriority_Medium)(), (0, _FormSpec.ClinicalPathway_DueDate_Today)(), "Staff", undefined));
332
- }
333
- }
334
- function generateEvaluationLabel(trigger, items) {
335
- let fieldLabel;
336
- const s = (0, _Option.defaultArg)((0, _Option.bind)((c)=>(0, _Option.map)((i_1)=>i_1.Text, (0, _List.tryFind)((i)=>i.ItemId === c.SourceFieldId, items)), (0, _List.tryHead)(trigger.Conditions)), "field");
337
- fieldLabel = s.length > 50 ? (0, _String.substring)(s, 0, 47) + "..." : s;
338
- const matchValue = trigger.Conditions;
339
- if (!(0, _List.isEmpty)(matchValue)) {
340
- if ((0, _List.isEmpty)((0, _List.tail)(matchValue))) {
341
- const matchValue_1 = (0, _List.head)(matchValue).Operator.toLowerCase();
342
- const matchValue_2 = (0, _List.head)(matchValue).Values;
343
- let matchResult, v, vals_2, vals_3, v_1, v_2, v_3, v_4, v_5, v_6, vals_4, op;
344
- switch(matchValue_1){
345
- case "any":
346
- {
347
- if (!(0, _List.isEmpty)(matchValue_2)) {
348
- if ((0, _List.isEmpty)((0, _List.tail)(matchValue_2))) {
349
- matchResult = 0;
350
- v = (0, _List.head)(matchValue_2);
351
- } else if ((0, _List.length)(matchValue_2) <= 3) {
352
- matchResult = 1;
353
- vals_2 = matchValue_2;
354
- } else {
355
- matchResult = 2;
356
- vals_3 = matchValue_2;
357
- }
358
- } else if ((0, _List.length)(matchValue_2) <= 3) {
359
- matchResult = 1;
360
- vals_2 = matchValue_2;
361
- } else {
362
- matchResult = 2;
363
- vals_3 = matchValue_2;
364
- }
365
- break;
366
- }
367
- case "equals":
368
- {
369
- if (!(0, _List.isEmpty)(matchValue_2)) {
370
- if ((0, _List.isEmpty)((0, _List.tail)(matchValue_2))) {
371
- matchResult = 3;
372
- v_1 = (0, _List.head)(matchValue_2);
373
- } else {
374
- matchResult = 10;
375
- op = matchValue_1;
376
- }
377
- } else {
378
- matchResult = 10;
379
- op = matchValue_1;
380
- }
381
- break;
382
- }
383
- case "not_equals":
384
- {
385
- if (!(0, _List.isEmpty)(matchValue_2)) {
386
- if ((0, _List.isEmpty)((0, _List.tail)(matchValue_2))) {
387
- matchResult = 4;
388
- v_2 = (0, _List.head)(matchValue_2);
389
- } else {
390
- matchResult = 10;
391
- op = matchValue_1;
392
- }
393
- } else {
394
- matchResult = 10;
395
- op = matchValue_1;
396
- }
397
- break;
398
- }
399
- case "greater_equals":
400
- {
401
- if (!(0, _List.isEmpty)(matchValue_2)) {
402
- if ((0, _List.isEmpty)((0, _List.tail)(matchValue_2))) {
403
- matchResult = 5;
404
- v_3 = (0, _List.head)(matchValue_2);
405
- } else {
406
- matchResult = 10;
407
- op = matchValue_1;
408
- }
409
- } else {
410
- matchResult = 10;
411
- op = matchValue_1;
412
- }
413
- break;
414
- }
415
- case "greater":
416
- {
417
- if (!(0, _List.isEmpty)(matchValue_2)) {
418
- if ((0, _List.isEmpty)((0, _List.tail)(matchValue_2))) {
419
- matchResult = 6;
420
- v_4 = (0, _List.head)(matchValue_2);
421
- } else {
422
- matchResult = 10;
423
- op = matchValue_1;
424
- }
425
- } else {
426
- matchResult = 10;
427
- op = matchValue_1;
428
- }
429
- break;
430
- }
431
- case "less_equals":
432
- {
433
- if (!(0, _List.isEmpty)(matchValue_2)) {
434
- if ((0, _List.isEmpty)((0, _List.tail)(matchValue_2))) {
435
- matchResult = 7;
436
- v_5 = (0, _List.head)(matchValue_2);
437
- } else {
438
- matchResult = 10;
439
- op = matchValue_1;
440
- }
441
- } else {
442
- matchResult = 10;
443
- op = matchValue_1;
444
- }
445
- break;
446
- }
447
- case "less":
448
- {
449
- if (!(0, _List.isEmpty)(matchValue_2)) {
450
- if ((0, _List.isEmpty)((0, _List.tail)(matchValue_2))) {
451
- matchResult = 8;
452
- v_6 = (0, _List.head)(matchValue_2);
453
- } else {
454
- matchResult = 10;
455
- op = matchValue_1;
456
- }
457
- } else {
458
- matchResult = 10;
459
- op = matchValue_1;
460
- }
461
- break;
462
- }
463
- case "all":
464
- {
465
- matchResult = 9;
466
- vals_4 = matchValue_2;
467
- break;
468
- }
469
- default:
470
- {
471
- matchResult = 10;
472
- op = matchValue_1;
473
- }
474
- }
475
- switch(matchResult){
476
- case 0:
477
- return `When ${fieldLabel} = ${v}`;
478
- case 1:
479
- return `When ${fieldLabel} is ${(0, _String.join)(" or ", vals_2)}`;
480
- case 2:
481
- return `When ${fieldLabel} is any of ${(0, _List.length)(vals_3)} values`;
482
- case 3:
483
- return `When ${fieldLabel} = ${v_1}`;
484
- case 4:
485
- return `When ${fieldLabel} ≠ ${v_2}`;
486
- case 5:
487
- return `When ${fieldLabel} ≥ ${v_3}`;
488
- case 6:
489
- return `When ${fieldLabel} > ${v_4}`;
490
- case 7:
491
- return `When ${fieldLabel} ≤ ${v_5}`;
492
- case 8:
493
- return `When ${fieldLabel} < ${v_6}`;
494
- case 9:
495
- return `When ${fieldLabel} has all of: ${(0, _String.join)(", ", vals_4)}`;
496
- default:
497
- return `When ${fieldLabel} ${op}`;
498
- }
499
- } else {
500
- return `When ${fieldLabel} (${(0, _List.length)(matchValue)} conditions)`;
501
- }
502
- } else {
503
- return `When ${fieldLabel} (always)`;
504
- }
505
- }
506
- function generateActionLabel(trigger) {
507
- const matchValue = trigger.Actions;
508
- if (!(0, _List.isEmpty)(matchValue)) {
509
- if ((0, _List.isEmpty)((0, _List.tail)(matchValue))) {
510
- const matchValue_1 = (0, _List.head)(matchValue).ActionType.toLowerCase();
511
- switch(matchValue_1){
512
- case "alert":
513
- return `Create Alert: ${param("category_name", (0, _List.head)(matchValue))}`;
514
- case "task":
515
- {
516
- const p = param("priority", (0, _List.head)(matchValue));
517
- return `Create ${p === "1" ? "High " : p === "3" ? "Low " : ""}Task: ${param("category_name", (0, _List.head)(matchValue))}`;
518
- }
519
- case "recurring_task":
520
- return `Schedule: ${param("category_name", (0, _List.head)(matchValue))}`;
521
- case "medset":
522
- return `Order Medset: ${param("medset_name", (0, _List.head)(matchValue))}`;
523
- case "problem":
524
- return "Add to Problem List";
525
- default:
526
- return `Execute: ${matchValue_1}`;
527
- }
528
- } else {
529
- const joined = (0, _String.join)(", ", (0, _Seq2.List_distinct)((0, _List.map)((a)=>a.ActionType, matchValue), {
530
- Equals: (x, y)=>x === y,
531
- GetHashCode: _Util.stringHash
532
- }));
533
- return `Execute ${(0, _List.length)(matchValue)} actions: ${joined}`;
534
- }
535
- } else {
536
- return "No actions";
537
- }
538
- }
539
- function convertTriggerToPathway(trigger, parentItemId, items, itemFieldKeyMap) {
540
- const tid = trigger.TriggerId | 0;
541
- const startKey = new _FormSpec.Shared_StateKey(stableGuid(`t${tid}_start`));
542
- const evalKey = new _FormSpec.Shared_StateKey(stableGuid(`t${tid}_eval`));
543
- const actionKey = new _FormSpec.Shared_StateKey(stableGuid(`t${tid}_action`));
544
- const endKey = new _FormSpec.Shared_StateKey(stableGuid(`t${tid}_end`));
545
- const evalLabel = generateEvaluationLabel(trigger, items);
546
- const actionLabel = generateActionLabel(trigger);
547
- const startState = new _FormSpec.ClinicalPathway_StateDefinition(startKey, "Start", 0, (0, _FormSpec.ClinicalPathway_StateType_Evaluation)(new _FormSpec.ClinicalPathway_EvaluationInfo("", undefined)), undefined);
548
- const evalState = new _FormSpec.ClinicalPathway_StateDefinition(evalKey, evalLabel, 1, (0, _FormSpec.ClinicalPathway_StateType_Evaluation)(new _FormSpec.ClinicalPathway_EvaluationInfo("", undefined)), undefined);
549
- let actionState;
550
- const actions = (0, _List.map)(convertAction, trigger.Actions);
551
- actionState = new _FormSpec.ClinicalPathway_StateDefinition(actionKey, actionLabel, 2, (0, _List.isEmpty)(actions) ? (0, _FormSpec.ClinicalPathway_StateType_CompoundAction)(actions) : (0, _List.isEmpty)((0, _List.tail)(actions)) ? (0, _FormSpec.ClinicalPathway_StateType_Action)((0, _List.head)(actions)) : (0, _FormSpec.ClinicalPathway_StateType_CompoundAction)(actions), undefined);
552
- const endState = new _FormSpec.ClinicalPathway_StateDefinition(endKey, "Complete", 3, (0, _FormSpec.ClinicalPathway_StateType_Terminal)(new _FormSpec.ClinicalPathway_TerminalInfo("Complete", "Trigger evaluation complete", undefined)), undefined);
553
- const condition = combineConditions(trigger.Conditions, itemFieldKeyMap);
554
- const transitions = (0, _List.ofArray)([
555
- new _FormSpec.ClinicalPathway_TransitionDefinition(new _FormSpec.Shared_TransitionKey(stableGuid(`t${tid}_start_to_eval`)), startKey, evalKey, (0, _FormSpec.ClinicalPathway_TransitionCondition_Always)(), undefined),
556
- new _FormSpec.ClinicalPathway_TransitionDefinition(new _FormSpec.Shared_TransitionKey(stableGuid(`t${tid}_eval_to_action`)), evalKey, actionKey, condition, 0),
557
- new _FormSpec.ClinicalPathway_TransitionDefinition(new _FormSpec.Shared_TransitionKey(stableGuid(`t${tid}_action_to_end`)), actionKey, endKey, (0, _FormSpec.ClinicalPathway_TransitionCondition_Always)(), undefined)
558
- ]);
559
- return new _FormSpec.ClinicalPathway_ClinicalPathwaySpec(`item_trigger_${tid}`, `Trigger ${tid}: ${actionLabel}`, "1.0.0", "CoreMR Conduit - Item Trigger", (0, _FormSpec.ClinicalPathway_PathwayExecutionMode_TriggerBased)(new _FormSpec.ClinicalPathway_TriggerBasedConfig(convertTiming(trigger.EventName), true)), startKey, (0, _List.ofArray)([
560
- startState,
561
- evalState,
562
- actionState,
563
- endState
564
- ]), transitions, (0, _List.empty)(), (0, _List.empty)(), (0, _DateOffset.utcNow)(), undefined, undefined, 1);
565
- }
566
- function convertFormTriggersToPathway(form, itemFieldKeyMap) {
567
- const allTriggers = (0, _List.filter)((tupledArg_1)=>{
568
- const t_2 = tupledArg_1[1];
569
- if (t_2.Enabled) {
570
- return !(0, _List.isEmpty)(t_2.Actions);
571
- } else {
572
- return false;
573
- }
574
- }, (0, _Seq2.List_distinctBy)((tupledArg)=>tupledArg[1].TriggerId, (0, _List.collect)((item)=>{
575
- const matchValue = item.Triggers;
576
- switch(matchValue.tag){
577
- case /* NotInRelease */ 1:
578
- case /* NotReadYet */ 2:
579
- return (0, _List.empty)();
580
- default:
581
- return (0, _List.map)((t)=>[
582
- item.ItemId,
583
- t
584
- ], matchValue.fields[0]);
585
- }
586
- }, form.Items), {
587
- Equals: (x, y)=>x === y,
588
- GetHashCode: _Util.numberHash
589
- }));
590
- if (!(0, _List.isEmpty)(allTriggers)) {
591
- if ((0, _List.isEmpty)((0, _List.tail)(allTriggers))) {
592
- return convertTriggerToPathway((0, _List.head)(allTriggers)[1], (0, _List.head)(allTriggers)[0], form.Items, itemFieldKeyMap);
593
- } else {
594
- const pathwayId = `form_${form.FormId}_pathway`;
595
- const startKey = new _FormSpec.Shared_StateKey(stableGuid(`${pathwayId}_start`));
596
- let allStates = (0, _List.singleton)(new _FormSpec.ClinicalPathway_StateDefinition(startKey, "Start", 0, (0, _FormSpec.ClinicalPathway_StateType_Evaluation)(new _FormSpec.ClinicalPathway_EvaluationInfo("", undefined)), undefined));
597
- let allTransitions = (0, _List.empty)();
598
- const enumerator = (0, _Util.getEnumerator)((0, _List.indexed)(allTriggers));
599
- try {
600
- while(enumerator["System.Collections.IEnumerator.MoveNext"]()){
601
- const forLoopVar = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
602
- const trigger = forLoopVar[1][1];
603
- const idx = forLoopVar[0] | 0;
604
- const tid = trigger.TriggerId | 0;
605
- const evalKey = new _FormSpec.Shared_StateKey(stableGuid(`${pathwayId}_eval_${tid}`));
606
- const actionKey = new _FormSpec.Shared_StateKey(stableGuid(`${pathwayId}_action_${tid}`));
607
- const endKey = new _FormSpec.Shared_StateKey(stableGuid(`${pathwayId}_end_${tid}`));
608
- const evalLabel = generateEvaluationLabel(trigger, form.Items);
609
- const actionLabel = generateActionLabel(trigger);
610
- const evalState = new _FormSpec.ClinicalPathway_StateDefinition(evalKey, evalLabel, idx * 3 + 1, (0, _FormSpec.ClinicalPathway_StateType_Evaluation)(new _FormSpec.ClinicalPathway_EvaluationInfo("", undefined)), undefined);
611
- const actions = (0, _List.map)(convertAction, trigger.Actions);
612
- const actionState = new _FormSpec.ClinicalPathway_StateDefinition(actionKey, actionLabel, idx * 3 + 2, (0, _List.isEmpty)(actions) ? (0, _FormSpec.ClinicalPathway_StateType_CompoundAction)(actions) : (0, _List.isEmpty)((0, _List.tail)(actions)) ? (0, _FormSpec.ClinicalPathway_StateType_Action)((0, _List.head)(actions)) : (0, _FormSpec.ClinicalPathway_StateType_CompoundAction)(actions), undefined);
613
- const endState = new _FormSpec.ClinicalPathway_StateDefinition(endKey, "Complete", idx * 3 + 3, (0, _FormSpec.ClinicalPathway_StateType_Terminal)(new _FormSpec.ClinicalPathway_TerminalInfo("Complete", `Trigger ${tid} complete`, undefined)), undefined);
614
- const condition = combineConditions(trigger.Conditions, itemFieldKeyMap);
615
- const transitions = (0, _List.ofArray)([
616
- new _FormSpec.ClinicalPathway_TransitionDefinition(new _FormSpec.Shared_TransitionKey(stableGuid(`${pathwayId}_start_to_eval_${tid}`)), startKey, evalKey, (0, _FormSpec.ClinicalPathway_TransitionCondition_Always)(), idx),
617
- new _FormSpec.ClinicalPathway_TransitionDefinition(new _FormSpec.Shared_TransitionKey(stableGuid(`${pathwayId}_eval_to_action_${tid}`)), evalKey, actionKey, condition, idx),
618
- new _FormSpec.ClinicalPathway_TransitionDefinition(new _FormSpec.Shared_TransitionKey(stableGuid(`${pathwayId}_action_to_end_${tid}`)), actionKey, endKey, (0, _FormSpec.ClinicalPathway_TransitionCondition_Always)(), undefined)
619
- ]);
620
- allStates = (0, _List.append)(allStates, (0, _List.ofArray)([
621
- evalState,
622
- actionState,
623
- endState
624
- ]));
625
- allTransitions = (0, _List.append)(allTransitions, transitions);
626
- }
627
- } finally{
628
- (0, _Util.disposeSafe)(enumerator);
629
- }
630
- const primaryTiming = (0, _Option.defaultArg)((0, _Option.map)((tuple_1)=>tuple_1[0], (0, _List.tryHead)((0, _List.sortByDescending)((tuple)=>tuple[1], (0, _Seq2.List_countBy)((x_1)=>x_1, (0, _List.map)((tupledArg_2)=>tupledArg_2[1].EventName, allTriggers), {
631
- Equals: (x_2, y_1)=>x_2 === y_1,
632
- GetHashCode: _Util.stringHash
633
- }), {
634
- Compare: _Util.comparePrimitives
635
- }))), "save");
636
- return new _FormSpec.ClinicalPathway_ClinicalPathwaySpec(pathwayId, `${form.Name} - Clinical Pathway`, "1.0.0", "CoreMR Conduit - Unified Item Triggers", (0, _List.length)(allTriggers) > 1 ? (0, _FormSpec.ClinicalPathway_PathwayExecutionMode_MultiPathway)(new _FormSpec.ClinicalPathway_MultiPathwayConfig((0, _FormSpec.ClinicalPathway_CombinationStrategy_AllMatching)(), (0, _FormSpec.ClinicalPathway_ConflictResolution_CombineActions)(), undefined)) : (0, _FormSpec.ClinicalPathway_PathwayExecutionMode_TriggerBased)(new _FormSpec.ClinicalPathway_TriggerBasedConfig(convertTiming(primaryTiming), true)), startKey, allStates, allTransitions, (0, _List.empty)(), (0, _List.empty)(), (0, _DateOffset.utcNow)(), undefined, undefined, 1);
637
- }
638
- } else {
639
- return undefined;
640
- }
641
- } //# sourceMappingURL=ItemTriggerConverter.ts.map
642
-
643
- //# sourceMappingURL=ItemTriggerConverter.js.map