@f1studio/form-spec 5.0.0-alpha.101 → 5.0.0-alpha.103

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 (161) hide show
  1. package/Components/HelloComponent.d.ts +20 -0
  2. package/Components/HelloComponent.d.ts.map +1 -0
  3. package/Designer.d.ts.map +1 -0
  4. package/FormSpec.TS/Designer.js +2 -2
  5. package/FormSpec.TS/Designer.js.map +1 -1
  6. package/FormSpec.TS/Designer.ts.map +1 -1
  7. package/FormSpec.TS/FormSpec.js +210 -143
  8. package/FormSpec.TS/FormSpec.js.map +1 -1
  9. package/FormSpec.TS/FormSpec.ts.map +1 -1
  10. package/FormSpec.TS/FormSpecHelpers.js +62 -40
  11. package/FormSpec.TS/FormSpecHelpers.js.map +1 -1
  12. package/FormSpec.TS/FormSpecHelpers.ts.map +1 -1
  13. package/FormSpec.TS/FormSpecValues.js +207 -0
  14. package/FormSpec.TS/FormSpecValues.js.map +1 -0
  15. package/FormSpec.TS/FormSpecValues.ts.map +1 -0
  16. package/FormSpec.TS/Helpers.js +26 -25
  17. package/FormSpec.TS/Helpers.js.map +1 -1
  18. package/FormSpec.TS/Helpers.ts.map +1 -1
  19. package/FormSpec.TS/Interop/FormSpec.Api.Helpers.js +85 -125
  20. package/FormSpec.TS/Interop/FormSpec.Api.Helpers.js.map +1 -1
  21. package/FormSpec.TS/Interop/FormSpec.Api.Helpers.ts.map +1 -1
  22. package/FormSpec.TS/Interop/FormSpec.Api.Option.js +37 -7
  23. package/FormSpec.TS/Interop/FormSpec.Api.Option.js.map +1 -1
  24. package/FormSpec.TS/Interop/FormSpec.Api.Option.ts.map +1 -1
  25. package/FormSpec.TS/Interop/FormSpec.Values.Api.Option.js +103 -80
  26. package/FormSpec.TS/Interop/FormSpec.Values.Api.Option.js.map +1 -1
  27. package/FormSpec.TS/Interop/FormSpec.Values.Api.Option.ts.map +1 -1
  28. package/FormSpec.TS/PathwayExecutor.js +371 -125
  29. package/FormSpec.TS/PathwayExecutor.js.map +1 -1
  30. package/FormSpec.TS/PathwayExecutor.ts.map +1 -1
  31. package/FormSpec.TS/PathwayValidator.js +14 -26
  32. package/FormSpec.TS/PathwayValidator.js.map +1 -1
  33. package/FormSpec.TS/PathwayValidator.ts.map +1 -1
  34. package/FormSpec.TS/Renderers/FormSpecMarkdownRenderer.ts.map +1 -1
  35. package/FormSpec.TS/Renderers/PathwayRenderers.js +35 -26
  36. package/FormSpec.TS/Renderers/PathwayRenderers.js.map +1 -1
  37. package/FormSpec.TS/Renderers/PathwayRenderers.ts.map +1 -1
  38. package/FormSpec.TS/fable_modules/Fable.Form.3.0.0/Base.fs +0 -0
  39. package/FormSpec.TS/fable_modules/Fable.Form.3.0.0/Error.fs +0 -0
  40. package/FormSpec.TS/fable_modules/Fable.Form.3.0.0/Extensions.fs +0 -0
  41. package/FormSpec.TS/fable_modules/Fable.Form.3.0.0/Fable.Form.fableproj +0 -0
  42. package/FormSpec.TS/fable_modules/Fable.Form.3.0.0/Field.fs +0 -0
  43. package/FormSpec.TS/fable_modules/Fable.Form.Simple.5.0.1/Fable.Form.Simple.fableproj +0 -0
  44. package/FormSpec.TS/fable_modules/Fable.Form.Simple.5.0.1/Form.fs +0 -0
  45. package/FormSpec.TS/fable_modules/Fable.React.Types.18.3.0/Fable.React.Extensions.fs +0 -0
  46. package/FormSpec.TS/fable_modules/Fable.React.Types.18.3.0/Fable.React.Hooks.fs +0 -0
  47. package/FormSpec.TS/fable_modules/Fable.React.Types.18.3.0/Fable.React.Types.fableproj +0 -0
  48. package/FormSpec.TS/fable_modules/Fable.React.Types.18.3.0/Fable.React.fs +0 -0
  49. package/FormSpec.TS/fable_modules/Fable.ReactDom.Types.18.2.0/Fable.ReactDom.Types.fableproj +0 -0
  50. package/FormSpec.TS/fable_modules/Fable.ReactDom.Types.18.2.0/Fable.ReactDom.fs +0 -0
  51. package/FormSpec.TS/fable_modules/Feliz.2.7.0/BorderStyle.fs +0 -0
  52. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Colors.fs +0 -0
  53. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Feliz.fableproj +0 -0
  54. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Fonts.fs +0 -0
  55. package/FormSpec.TS/fable_modules/Feliz.2.7.0/GridTypes.fs +0 -0
  56. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Html.fs +0 -0
  57. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Interop.fs +0 -0
  58. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Key.fs +0 -0
  59. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Length.fs +0 -0
  60. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Locale.fs +0 -0
  61. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Properties.fs +0 -0
  62. package/FormSpec.TS/fable_modules/Feliz.2.7.0/React.fs +0 -0
  63. package/FormSpec.TS/fable_modules/Feliz.2.7.0/ReactDOM.fs +0 -0
  64. package/FormSpec.TS/fable_modules/Feliz.2.7.0/ReactInterop.js +0 -0
  65. package/FormSpec.TS/fable_modules/Feliz.2.7.0/ReactInterop.js.map +0 -0
  66. package/FormSpec.TS/fable_modules/Feliz.2.7.0/ReactTypes.fs +0 -0
  67. package/FormSpec.TS/fable_modules/Feliz.2.7.0/StyleTypes.fs +0 -0
  68. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Styles.fs +0 -0
  69. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Svg.fs +0 -0
  70. package/FormSpec.TS/fable_modules/Feliz.2.7.0/TextDecorationLine.fs +0 -0
  71. package/FormSpec.TS/fable_modules/Feliz.2.7.0/TextDecorationStyle.fs +0 -0
  72. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Transform.fs +0 -0
  73. package/FormSpec.TS/fable_modules/Feliz.2.7.0/TransformOrigin.fs +0 -0
  74. package/FormSpec.TS/fable_modules/Feliz.2.7.0/TransitionProperty.fs +0 -0
  75. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Types.fs +0 -0
  76. package/FormSpec.TS/fable_modules/Thoth.Json.10.4.1/Decode.fs +0 -0
  77. package/FormSpec.TS/fable_modules/Thoth.Json.10.4.1/Encode.fs +0 -0
  78. package/FormSpec.TS/fable_modules/Thoth.Json.10.4.1/Encode.fs.js.map +1 -1
  79. package/FormSpec.TS/fable_modules/Thoth.Json.10.4.1/Encode.fs.ts.map +1 -1
  80. package/FormSpec.TS/fable_modules/Thoth.Json.10.4.1/Extra.fs +0 -0
  81. package/FormSpec.TS/fable_modules/Thoth.Json.10.4.1/Thoth.Json.fableproj +0 -0
  82. package/FormSpec.TS/fable_modules/Thoth.Json.10.4.1/Types.fs +0 -0
  83. package/FormSpec.TS/fable_modules/project_cracked.json +1 -1
  84. package/FormSpec.d.ts +56 -43
  85. package/FormSpec.d.ts.map +1 -0
  86. package/FormSpecHelpers.d.ts +18 -12
  87. package/FormSpecHelpers.d.ts.map +1 -0
  88. package/FormSpecValues.d.ts +62 -0
  89. package/FormSpecValues.d.ts.map +1 -0
  90. package/Helpers.d.ts +11 -10
  91. package/Helpers.d.ts.map +1 -0
  92. package/Interfaces.d.ts.map +1 -0
  93. package/Interop/FormSpec.Api.Helpers.d.ts +25 -28
  94. package/Interop/FormSpec.Api.Helpers.d.ts.map +1 -1
  95. package/Interop/FormSpec.Api.Option.d.ts +10 -6
  96. package/Interop/FormSpec.Api.Option.d.ts.map +1 -1
  97. package/Interop/FormSpec.Values.Api.Option.d.ts +35 -22
  98. package/Interop/FormSpec.Values.Api.Option.d.ts.map +1 -1
  99. package/Logging/LogTypes.d.ts +112 -0
  100. package/Logging/LogTypes.d.ts.map +1 -0
  101. package/Migrator.d.ts.map +1 -0
  102. package/PathwayDataExtractor.d.ts.map +1 -0
  103. package/PathwayExecutor.d.ts +63 -33
  104. package/PathwayExecutor.d.ts.map +1 -0
  105. package/PathwayValidator.d.ts.map +1 -0
  106. package/PluginInterface.d.ts.map +1 -0
  107. package/Prelude.d.ts.map +1 -0
  108. package/README.TS.md +621 -621
  109. package/README.md +98 -85
  110. package/Renderers/FormSpecMarkdownRenderer.d.ts +11 -0
  111. package/Renderers/FormSpecMarkdownRenderer.d.ts.map +1 -0
  112. package/Renderers/MermaidRenderer.d.ts +48 -0
  113. package/Renderers/MermaidRenderer.d.ts.map +1 -0
  114. package/Renderers/PathwayRenderers.d.ts +59 -0
  115. package/Renderers/PathwayRenderers.d.ts.map +1 -0
  116. package/fable_modules/Thoth.Json.10.4.1/Decode.fs.d.ts +126 -0
  117. package/fable_modules/Thoth.Json.10.4.1/Decode.fs.d.ts.map +1 -0
  118. package/fable_modules/Thoth.Json.10.4.1/Encode.fs.d.ts +163 -0
  119. package/fable_modules/Thoth.Json.10.4.1/Encode.fs.d.ts.map +1 -0
  120. package/fable_modules/Thoth.Json.10.4.1/Types.fs.d.ts +66 -0
  121. package/fable_modules/Thoth.Json.10.4.1/Types.fs.d.ts.map +1 -0
  122. package/package.json +53 -39
  123. package/src/Components/HelloComponent.ts +48 -48
  124. package/src/Designer.ts +389 -389
  125. package/src/FormSpec.ts +3154 -3114
  126. package/src/FormSpecHelpers.ts +397 -374
  127. package/src/FormSpecValues.ts +158 -0
  128. package/src/Helpers.ts +766 -765
  129. package/src/Interfaces.ts +166 -166
  130. package/src/Interop/FormSpec.Api.Helpers.ts +835 -872
  131. package/src/Interop/FormSpec.Api.Option.ts +1637 -1618
  132. package/src/Interop/FormSpec.Values.Api.Option.ts +1241 -1214
  133. package/src/Logging/LogTypes.ts +212 -212
  134. package/src/Migrator.ts +156 -156
  135. package/src/PathwayDataExtractor.ts +290 -290
  136. package/src/PathwayExecutor.ts +1379 -1102
  137. package/src/PathwayValidator.ts +238 -244
  138. package/src/PluginInterface.ts +79 -79
  139. package/src/Prelude.ts +21 -21
  140. package/src/Renderers/FormSpecMarkdownRenderer.ts +875 -874
  141. package/src/Renderers/MermaidRenderer.ts +218 -218
  142. package/src/Renderers/PathwayRenderers.ts +208 -200
  143. package/src/Components/HelloComponent.ts.map +0 -1
  144. package/src/Designer.ts.map +0 -1
  145. package/src/FormSpec.ts.map +0 -1
  146. package/src/FormSpecHelpers.ts.map +0 -1
  147. package/src/Helpers.ts.map +0 -1
  148. package/src/Interfaces.ts.map +0 -1
  149. package/src/Interop/FormSpec.Api.Helpers.ts.map +0 -1
  150. package/src/Interop/FormSpec.Api.Option.ts.map +0 -1
  151. package/src/Interop/FormSpec.Values.Api.Option.ts.map +0 -1
  152. package/src/Logging/LogTypes.ts.map +0 -1
  153. package/src/Migrator.ts.map +0 -1
  154. package/src/PathwayDataExtractor.ts.map +0 -1
  155. package/src/PathwayExecutor.ts.map +0 -1
  156. package/src/PathwayValidator.ts.map +0 -1
  157. package/src/PluginInterface.ts.map +0 -1
  158. package/src/Prelude.ts.map +0 -1
  159. package/src/Renderers/FormSpecMarkdownRenderer.ts.map +0 -1
  160. package/src/Renderers/MermaidRenderer.ts.map +0 -1
  161. package/src/Renderers/PathwayRenderers.ts.map +0 -1
@@ -1,290 +1,290 @@
1
- import { ClinicalPathway_TerminalInfo, Shared_StateKey, ClinicalPathway_StateType_$union, ClinicalPathway_EvaluationInfo, ClinicalPathway_DecisionInfo, ClinicalPathway_ActionInfo_$union, ClinicalPathway_MedicationAction, ClinicalPathway_FieldValueSource_$union, ClinicalPathway_SetFieldValueAction, ClinicalPathway_NavigateToFormAction, ClinicalPathway_PrescriptionAction, ClinicalPathway_ProblemAction, ClinicalPathway_AlertAction, ClinicalPathway_TaskAction, ClinicalPathway_DocumentationAction, ClinicalPathway_ReferralAction, ClinicalPathway_TestAction, ClinicalPathway_EducationAction, ClinicalPathway_ProcedureAction } from "./FormSpec.js";
2
- import { split, replace, join, isNullOrWhiteSpace, substring, printf, toText } from "@fable-org/fable-library-js/String.js";
3
- import { singleton, append, map, empty, FSharpList, filter } from "@fable-org/fable-library-js/List.js";
4
- import { Option, value } from "@fable-org/fable-library-js/Option.js";
5
- import { item, map as map_1 } from "@fable-org/fable-library-js/Array.js";
6
- import { int32 } from "@fable-org/fable-library-js/Int32.js";
7
-
8
- export function extractActionText(action: ClinicalPathway_ActionInfo_$union): string {
9
- switch (action.tag) {
10
- case /* Procedure */ 4: {
11
- const p: ClinicalPathway_ProcedureAction = action.fields[0];
12
- return toText(printf("Procedure: %s"))(p.Name);
13
- }
14
- case /* Education */ 3: {
15
- const e: ClinicalPathway_EducationAction = action.fields[0];
16
- return "Education";
17
- }
18
- case /* Test */ 1: {
19
- const t: ClinicalPathway_TestAction = action.fields[0];
20
- return toText(printf("Test: %s"))(t.TestName);
21
- }
22
- case /* Referral */ 2: {
23
- const r: ClinicalPathway_ReferralAction = action.fields[0];
24
- return toText(printf("Refer to %s"))(r.Target);
25
- }
26
- case /* Documentation */ 5: {
27
- const d: ClinicalPathway_DocumentationAction = action.fields[0];
28
- return toText(printf("Document: %s"))(d.FormName);
29
- }
30
- case /* Task */ 6: {
31
- const t_1: ClinicalPathway_TaskAction = action.fields[0];
32
- return toText(printf("Task: %s"))(t_1.Description);
33
- }
34
- case /* Alert */ 7: {
35
- const a: ClinicalPathway_AlertAction = action.fields[0];
36
- return toText(printf("Alert: %s"))(a.Message);
37
- }
38
- case /* Problem */ 8: {
39
- const p_1: ClinicalPathway_ProblemAction = action.fields[0];
40
- return toText(printf("Problem: %s"))(p_1.ProblemName);
41
- }
42
- case /* Prescription */ 9: {
43
- const p_2: ClinicalPathway_PrescriptionAction = action.fields[0];
44
- return toText(printf("Prescription: %s"))(p_2.Medication);
45
- }
46
- case /* NavigateToForm */ 11: {
47
- const n: ClinicalPathway_NavigateToFormAction = action.fields[0];
48
- return toText(printf("Navigate to: %s"))(n.FormId);
49
- }
50
- case /* SetFieldValue */ 10: {
51
- const s: ClinicalPathway_SetFieldValueAction = action.fields[0];
52
- const fieldGuid: string = s.TargetField.fields[0];
53
- const shortGuid: string = (fieldGuid.length > 8) ? (substring(fieldGuid, 0, 8) + "...") : fieldGuid;
54
- let valueText: string;
55
- const matchValue: ClinicalPathway_FieldValueSource_$union = s.Value;
56
- switch (matchValue.tag) {
57
- case /* FieldReference */ 1: {
58
- const g: string = matchValue.fields[0].fields[0];
59
- valueText = "from field";
60
- break;
61
- }
62
- case /* OptionKey */ 2: {
63
- const g_1: string = matchValue.fields[0].fields[0];
64
- valueText = "option";
65
- break;
66
- }
67
- default: {
68
- const v: string = matchValue.fields[0];
69
- valueText = (isNullOrWhiteSpace(v) ? "(empty)" : v);
70
- }
71
- }
72
- return toText(printf("Set Field: %s = %s"))(shortGuid)(valueText);
73
- }
74
- default: {
75
- const m: ClinicalPathway_MedicationAction = action.fields[0];
76
- return toText(printf("Rx: %s"))(m.Name);
77
- }
78
- }
79
- }
80
-
81
- export function extractActionDetails(action: ClinicalPathway_ActionInfo_$union): string {
82
- switch (action.tag) {
83
- case /* Procedure */ 4:
84
- return action.fields[0].Name;
85
- case /* Education */ 3:
86
- return join("; ", action.fields[0].Topics);
87
- case /* Test */ 1: {
88
- const t: ClinicalPathway_TestAction = action.fields[0];
89
- return toText(printf("Test: %s"))(t.TestName);
90
- }
91
- case /* Referral */ 2: {
92
- const r: ClinicalPathway_ReferralAction = action.fields[0];
93
- return toText(printf("Refer to %s (%s)"))(r.Target)(r.Reason);
94
- }
95
- case /* Documentation */ 5: {
96
- const d: ClinicalPathway_DocumentationAction = action.fields[0];
97
- return toText(printf("Document: %s"))(d.FormName);
98
- }
99
- case /* Task */ 6: {
100
- const t_1: ClinicalPathway_TaskAction = action.fields[0];
101
- return toText(printf("Task: %s"))(t_1.Description);
102
- }
103
- case /* Alert */ 7: {
104
- const a: ClinicalPathway_AlertAction = action.fields[0];
105
- return toText(printf("Alert: %s"))(a.Message);
106
- }
107
- case /* Problem */ 8: {
108
- const p_1: ClinicalPathway_ProblemAction = action.fields[0];
109
- return toText(printf("Problem: %s"))(p_1.ProblemName);
110
- }
111
- case /* Prescription */ 9: {
112
- const p_2: ClinicalPathway_PrescriptionAction = action.fields[0];
113
- return toText(printf("Prescription: %s"))(p_2.Medication);
114
- }
115
- case /* NavigateToForm */ 11: {
116
- const n: ClinicalPathway_NavigateToFormAction = action.fields[0];
117
- return toText(printf("Navigate to: %s"))(n.FormId);
118
- }
119
- case /* SetFieldValue */ 10: {
120
- const s: ClinicalPathway_SetFieldValueAction = action.fields[0];
121
- const guid: string = s.TargetField.fields[0];
122
- let valueText: string;
123
- const matchValue: ClinicalPathway_FieldValueSource_$union = s.Value;
124
- switch (matchValue.tag) {
125
- case /* FieldReference */ 1: {
126
- valueText = (`from ${matchValue.fields[0].fields[0]}`);
127
- break;
128
- }
129
- case /* OptionKey */ 2: {
130
- valueText = (`option ${matchValue.fields[0].fields[0]}`);
131
- break;
132
- }
133
- default: {
134
- const v: string = matchValue.fields[0];
135
- valueText = (isNullOrWhiteSpace(v) ? "(empty)" : v);
136
- }
137
- }
138
- return toText(printf("Set Field %s = %s"))(guid)(valueText);
139
- }
140
- default: {
141
- const m: ClinicalPathway_MedicationAction = action.fields[0];
142
- return toText(printf("%s %s %s %s"))(m.Name)(m.Dose)(m.Route)(m.Frequency);
143
- }
144
- }
145
- }
146
-
147
- export function extractActionType(action: ClinicalPathway_ActionInfo_$union): string {
148
- switch (action.tag) {
149
- case /* Procedure */ 4:
150
- return "Procedure";
151
- case /* Education */ 3:
152
- return "Education";
153
- case /* Test */ 1:
154
- return "Test";
155
- case /* Referral */ 2:
156
- return "Referral";
157
- case /* Documentation */ 5:
158
- return "Documentation";
159
- case /* Task */ 6:
160
- return "Task";
161
- case /* Alert */ 7:
162
- return "Alert";
163
- case /* Problem */ 8:
164
- return "Problem";
165
- case /* Prescription */ 9:
166
- return "Prescription";
167
- case /* SetFieldValue */ 10:
168
- return "SetFieldValue";
169
- case /* NavigateToForm */ 11:
170
- return "NavigateToForm";
171
- default:
172
- return "Medication";
173
- }
174
- }
175
-
176
- export function extractDecisionDetails(decision: ClinicalPathway_DecisionInfo): [string, FSharpList<string>] {
177
- return [decision.Question, filter<string>((opt: string): boolean => {
178
- if ((opt !== "Yes") && (opt !== "No")) {
179
- return opt !== "None of the above";
180
- }
181
- else {
182
- return false;
183
- }
184
- }, decision.Options)] as [string, FSharpList<string>];
185
- }
186
-
187
- export function extractEvaluationDetails(evaluation: ClinicalPathway_EvaluationInfo): [string, FSharpList<string>] {
188
- let matchValue: Option<FSharpList<string>>;
189
- return [evaluation.EvaluationName, (matchValue = evaluation.CriticalFindings, (matchValue == null) ? empty<string>() : value(matchValue))] as [string, FSharpList<string>];
190
- }
191
-
192
- export function extractEvaluationName(evaluation: ClinicalPathway_EvaluationInfo): string {
193
- return evaluation.EvaluationName;
194
- }
195
-
196
- export function stateTypeToString(stateType: ClinicalPathway_StateType_$union): string {
197
- switch (stateType.tag) {
198
- case /* Decision */ 1:
199
- return "Decision";
200
- case /* Action */ 2:
201
- return "Action";
202
- case /* CompoundAction */ 3:
203
- return "CompoundAction";
204
- case /* ConditionalAction */ 4:
205
- return "ConditionalAction";
206
- case /* Terminal */ 5:
207
- return "Terminal";
208
- default:
209
- return "Evaluation";
210
- }
211
- }
212
-
213
- export function isTerminalState(stateType: ClinicalPathway_StateType_$union): boolean {
214
- if (stateType.tag === /* Terminal */ 5) {
215
- return true;
216
- }
217
- else {
218
- return false;
219
- }
220
- }
221
-
222
- export function extractCompoundActionTexts(actions: FSharpList<ClinicalPathway_ActionInfo_$union>): FSharpList<string> {
223
- return map<ClinicalPathway_ActionInfo_$union, string>(extractActionText, actions);
224
- }
225
-
226
- export function extractCompoundActionDetails(actions: FSharpList<ClinicalPathway_ActionInfo_$union>): FSharpList<string> {
227
- return map<ClinicalPathway_ActionInfo_$union, string>(extractActionDetails, actions);
228
- }
229
-
230
- export function sanitizeMermaidId(id: string): string {
231
- return replace(replace(replace(id, "-", "_"), " ", "_"), ".", "_");
232
- }
233
-
234
- export function sanitizeMermaidText(text: string): string {
235
- return replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(text, "\"", "\'"), "(", "-"), ")", "-"), "{", "-"), "}", "-"), "<", "-"), ">", "-"), "|", "/"), "`", "\'"), "\n", " "), "\r", " "), " ", " ");
236
- }
237
-
238
- export function wrapTextForReactFlow(text: string, maxWidth: int32): string {
239
- if (text.length <= maxWidth) {
240
- return text;
241
- }
242
- else {
243
- const words: string[] = map_1<string, string>((word: string): string => {
244
- if (text.indexOf(`${word} =`) >= 0) {
245
- return `${word} =`;
246
- }
247
- else if (text.indexOf(`${word},`) >= 0) {
248
- return `${word},`;
249
- }
250
- else if (text.indexOf(`${word};`) >= 0) {
251
- return `${word};`;
252
- }
253
- else if (text.indexOf(`${word}:`) >= 0) {
254
- return `${word}:`;
255
- }
256
- else {
257
- return word;
258
- }
259
- }, split(text, [" ", ",", ";", "=", ":"], undefined, 1));
260
- let lines: FSharpList<string> = empty<string>();
261
- let currentLine = "";
262
- for (let idx = 0; idx <= (words.length - 1); idx++) {
263
- const word_1: string = item(idx, words);
264
- if (currentLine === "") {
265
- currentLine = word_1;
266
- }
267
- else if (((currentLine + " ") + word_1).length <= maxWidth) {
268
- currentLine = ((currentLine + " ") + word_1);
269
- }
270
- else {
271
- lines = append(lines, singleton(currentLine));
272
- currentLine = word_1;
273
- }
274
- }
275
- if (currentLine !== "") {
276
- lines = append(lines, singleton(currentLine));
277
- }
278
- return join("\n", lines);
279
- }
280
- }
281
-
282
- export function extractStateKeyString(stateKey: Shared_StateKey): string {
283
- return stateKey.fields[0];
284
- }
285
-
286
- export function getTerminalOutcome(terminal: ClinicalPathway_TerminalInfo): string {
287
- return terminal.Outcome;
288
- }
289
-
290
- //# sourceMappingURL=PathwayDataExtractor.ts.map
1
+ import { ClinicalPathway_TerminalInfo, Shared_StateKey, ClinicalPathway_StateType_$union, ClinicalPathway_EvaluationInfo, ClinicalPathway_DecisionInfo, ClinicalPathway_ActionInfo_$union, ClinicalPathway_MedicationAction, ClinicalPathway_FieldValueSource_$union, ClinicalPathway_SetFieldValueAction, ClinicalPathway_NavigateToFormAction, ClinicalPathway_PrescriptionAction, ClinicalPathway_ProblemAction, ClinicalPathway_AlertAction, ClinicalPathway_TaskAction, ClinicalPathway_DocumentationAction, ClinicalPathway_ReferralAction, ClinicalPathway_TestAction, ClinicalPathway_EducationAction, ClinicalPathway_ProcedureAction } from "./FormSpec.js";
2
+ import { split, replace, join, isNullOrWhiteSpace, substring, printf, toText } from "@fable-org/fable-library-js/String.js";
3
+ import { singleton, append, map, empty, FSharpList, filter } from "@fable-org/fable-library-js/List.js";
4
+ import { Option, value } from "@fable-org/fable-library-js/Option.js";
5
+ import { item, map as map_1 } from "@fable-org/fable-library-js/Array.js";
6
+ import { int32 } from "@fable-org/fable-library-js/Int32.js";
7
+
8
+ export function extractActionText(action: ClinicalPathway_ActionInfo_$union): string {
9
+ switch (action.tag) {
10
+ case /* Procedure */ 4: {
11
+ const p: ClinicalPathway_ProcedureAction = action.fields[0];
12
+ return toText(printf("Procedure: %s"))(p.Name);
13
+ }
14
+ case /* Education */ 3: {
15
+ const e: ClinicalPathway_EducationAction = action.fields[0];
16
+ return "Education";
17
+ }
18
+ case /* Test */ 1: {
19
+ const t: ClinicalPathway_TestAction = action.fields[0];
20
+ return toText(printf("Test: %s"))(t.TestName);
21
+ }
22
+ case /* Referral */ 2: {
23
+ const r: ClinicalPathway_ReferralAction = action.fields[0];
24
+ return toText(printf("Refer to %s"))(r.Target);
25
+ }
26
+ case /* Documentation */ 5: {
27
+ const d: ClinicalPathway_DocumentationAction = action.fields[0];
28
+ return toText(printf("Document: %s"))(d.FormName);
29
+ }
30
+ case /* Task */ 6: {
31
+ const t_1: ClinicalPathway_TaskAction = action.fields[0];
32
+ return toText(printf("Task: %s"))(t_1.Description);
33
+ }
34
+ case /* Alert */ 7: {
35
+ const a: ClinicalPathway_AlertAction = action.fields[0];
36
+ return toText(printf("Alert: %s"))(a.Message);
37
+ }
38
+ case /* Problem */ 8: {
39
+ const p_1: ClinicalPathway_ProblemAction = action.fields[0];
40
+ return toText(printf("Problem: %s"))(p_1.ProblemName);
41
+ }
42
+ case /* Prescription */ 9: {
43
+ const p_2: ClinicalPathway_PrescriptionAction = action.fields[0];
44
+ return toText(printf("Prescription: %s"))(p_2.Medication);
45
+ }
46
+ case /* NavigateToForm */ 11: {
47
+ const n: ClinicalPathway_NavigateToFormAction = action.fields[0];
48
+ return toText(printf("Navigate to: %s"))(n.FormId);
49
+ }
50
+ case /* SetFieldValue */ 10: {
51
+ const s: ClinicalPathway_SetFieldValueAction = action.fields[0];
52
+ const fieldGuid: string = s.TargetField.fields[0];
53
+ const shortGuid: string = (fieldGuid.length > 8) ? (substring(fieldGuid, 0, 8) + "...") : fieldGuid;
54
+ let valueText: string;
55
+ const matchValue: ClinicalPathway_FieldValueSource_$union = s.Value;
56
+ switch (matchValue.tag) {
57
+ case /* FieldReference */ 1: {
58
+ const g: string = matchValue.fields[0].fields[0];
59
+ valueText = "from field";
60
+ break;
61
+ }
62
+ case /* OptionKey */ 2: {
63
+ const g_1: string = matchValue.fields[0].fields[0];
64
+ valueText = "option";
65
+ break;
66
+ }
67
+ default: {
68
+ const v: string = matchValue.fields[0];
69
+ valueText = (isNullOrWhiteSpace(v) ? "(empty)" : v);
70
+ }
71
+ }
72
+ return toText(printf("Set Field: %s = %s"))(shortGuid)(valueText);
73
+ }
74
+ default: {
75
+ const m: ClinicalPathway_MedicationAction = action.fields[0];
76
+ return toText(printf("Rx: %s"))(m.Name);
77
+ }
78
+ }
79
+ }
80
+
81
+ export function extractActionDetails(action: ClinicalPathway_ActionInfo_$union): string {
82
+ switch (action.tag) {
83
+ case /* Procedure */ 4:
84
+ return action.fields[0].Name;
85
+ case /* Education */ 3:
86
+ return join("; ", action.fields[0].Topics);
87
+ case /* Test */ 1: {
88
+ const t: ClinicalPathway_TestAction = action.fields[0];
89
+ return toText(printf("Test: %s"))(t.TestName);
90
+ }
91
+ case /* Referral */ 2: {
92
+ const r: ClinicalPathway_ReferralAction = action.fields[0];
93
+ return toText(printf("Refer to %s (%s)"))(r.Target)(r.Reason);
94
+ }
95
+ case /* Documentation */ 5: {
96
+ const d: ClinicalPathway_DocumentationAction = action.fields[0];
97
+ return toText(printf("Document: %s"))(d.FormName);
98
+ }
99
+ case /* Task */ 6: {
100
+ const t_1: ClinicalPathway_TaskAction = action.fields[0];
101
+ return toText(printf("Task: %s"))(t_1.Description);
102
+ }
103
+ case /* Alert */ 7: {
104
+ const a: ClinicalPathway_AlertAction = action.fields[0];
105
+ return toText(printf("Alert: %s"))(a.Message);
106
+ }
107
+ case /* Problem */ 8: {
108
+ const p_1: ClinicalPathway_ProblemAction = action.fields[0];
109
+ return toText(printf("Problem: %s"))(p_1.ProblemName);
110
+ }
111
+ case /* Prescription */ 9: {
112
+ const p_2: ClinicalPathway_PrescriptionAction = action.fields[0];
113
+ return toText(printf("Prescription: %s"))(p_2.Medication);
114
+ }
115
+ case /* NavigateToForm */ 11: {
116
+ const n: ClinicalPathway_NavigateToFormAction = action.fields[0];
117
+ return toText(printf("Navigate to: %s"))(n.FormId);
118
+ }
119
+ case /* SetFieldValue */ 10: {
120
+ const s: ClinicalPathway_SetFieldValueAction = action.fields[0];
121
+ const guid: string = s.TargetField.fields[0];
122
+ let valueText: string;
123
+ const matchValue: ClinicalPathway_FieldValueSource_$union = s.Value;
124
+ switch (matchValue.tag) {
125
+ case /* FieldReference */ 1: {
126
+ valueText = (`from ${matchValue.fields[0].fields[0]}`);
127
+ break;
128
+ }
129
+ case /* OptionKey */ 2: {
130
+ valueText = (`option ${matchValue.fields[0].fields[0]}`);
131
+ break;
132
+ }
133
+ default: {
134
+ const v: string = matchValue.fields[0];
135
+ valueText = (isNullOrWhiteSpace(v) ? "(empty)" : v);
136
+ }
137
+ }
138
+ return toText(printf("Set Field %s = %s"))(guid)(valueText);
139
+ }
140
+ default: {
141
+ const m: ClinicalPathway_MedicationAction = action.fields[0];
142
+ return toText(printf("%s %s %s %s"))(m.Name)(m.Dose)(m.Route)(m.Frequency);
143
+ }
144
+ }
145
+ }
146
+
147
+ export function extractActionType(action: ClinicalPathway_ActionInfo_$union): string {
148
+ switch (action.tag) {
149
+ case /* Procedure */ 4:
150
+ return "Procedure";
151
+ case /* Education */ 3:
152
+ return "Education";
153
+ case /* Test */ 1:
154
+ return "Test";
155
+ case /* Referral */ 2:
156
+ return "Referral";
157
+ case /* Documentation */ 5:
158
+ return "Documentation";
159
+ case /* Task */ 6:
160
+ return "Task";
161
+ case /* Alert */ 7:
162
+ return "Alert";
163
+ case /* Problem */ 8:
164
+ return "Problem";
165
+ case /* Prescription */ 9:
166
+ return "Prescription";
167
+ case /* SetFieldValue */ 10:
168
+ return "SetFieldValue";
169
+ case /* NavigateToForm */ 11:
170
+ return "NavigateToForm";
171
+ default:
172
+ return "Medication";
173
+ }
174
+ }
175
+
176
+ export function extractDecisionDetails(decision: ClinicalPathway_DecisionInfo): [string, FSharpList<string>] {
177
+ return [decision.Question, filter<string>((opt: string): boolean => {
178
+ if ((opt !== "Yes") && (opt !== "No")) {
179
+ return opt !== "None of the above";
180
+ }
181
+ else {
182
+ return false;
183
+ }
184
+ }, decision.Options)] as [string, FSharpList<string>];
185
+ }
186
+
187
+ export function extractEvaluationDetails(evaluation: ClinicalPathway_EvaluationInfo): [string, FSharpList<string>] {
188
+ let matchValue: Option<FSharpList<string>>;
189
+ return [evaluation.EvaluationName, (matchValue = evaluation.CriticalFindings, (matchValue == null) ? empty<string>() : value(matchValue))] as [string, FSharpList<string>];
190
+ }
191
+
192
+ export function extractEvaluationName(evaluation: ClinicalPathway_EvaluationInfo): string {
193
+ return evaluation.EvaluationName;
194
+ }
195
+
196
+ export function stateTypeToString(stateType: ClinicalPathway_StateType_$union): string {
197
+ switch (stateType.tag) {
198
+ case /* Decision */ 1:
199
+ return "Decision";
200
+ case /* Action */ 2:
201
+ return "Action";
202
+ case /* CompoundAction */ 3:
203
+ return "CompoundAction";
204
+ case /* ConditionalAction */ 4:
205
+ return "ConditionalAction";
206
+ case /* Terminal */ 5:
207
+ return "Terminal";
208
+ default:
209
+ return "Evaluation";
210
+ }
211
+ }
212
+
213
+ export function isTerminalState(stateType: ClinicalPathway_StateType_$union): boolean {
214
+ if (stateType.tag === /* Terminal */ 5) {
215
+ return true;
216
+ }
217
+ else {
218
+ return false;
219
+ }
220
+ }
221
+
222
+ export function extractCompoundActionTexts(actions: FSharpList<ClinicalPathway_ActionInfo_$union>): FSharpList<string> {
223
+ return map<ClinicalPathway_ActionInfo_$union, string>(extractActionText, actions);
224
+ }
225
+
226
+ export function extractCompoundActionDetails(actions: FSharpList<ClinicalPathway_ActionInfo_$union>): FSharpList<string> {
227
+ return map<ClinicalPathway_ActionInfo_$union, string>(extractActionDetails, actions);
228
+ }
229
+
230
+ export function sanitizeMermaidId(id: string): string {
231
+ return replace(replace(replace(id, "-", "_"), " ", "_"), ".", "_");
232
+ }
233
+
234
+ export function sanitizeMermaidText(text: string): string {
235
+ return replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(text, "\"", "\'"), "(", "-"), ")", "-"), "{", "-"), "}", "-"), "<", "-"), ">", "-"), "|", "/"), "`", "\'"), "\n", " "), "\r", " "), " ", " ");
236
+ }
237
+
238
+ export function wrapTextForReactFlow(text: string, maxWidth: int32): string {
239
+ if (text.length <= maxWidth) {
240
+ return text;
241
+ }
242
+ else {
243
+ const words: string[] = map_1<string, string>((word: string): string => {
244
+ if (text.indexOf(`${word} =`) >= 0) {
245
+ return `${word} =`;
246
+ }
247
+ else if (text.indexOf(`${word},`) >= 0) {
248
+ return `${word},`;
249
+ }
250
+ else if (text.indexOf(`${word};`) >= 0) {
251
+ return `${word};`;
252
+ }
253
+ else if (text.indexOf(`${word}:`) >= 0) {
254
+ return `${word}:`;
255
+ }
256
+ else {
257
+ return word;
258
+ }
259
+ }, split(text, [" ", ",", ";", "=", ":"], undefined, 1));
260
+ let lines: FSharpList<string> = empty<string>();
261
+ let currentLine = "";
262
+ for (let idx = 0; idx <= (words.length - 1); idx++) {
263
+ const word_1: string = item(idx, words);
264
+ if (currentLine === "") {
265
+ currentLine = word_1;
266
+ }
267
+ else if (((currentLine + " ") + word_1).length <= maxWidth) {
268
+ currentLine = ((currentLine + " ") + word_1);
269
+ }
270
+ else {
271
+ lines = append(lines, singleton(currentLine));
272
+ currentLine = word_1;
273
+ }
274
+ }
275
+ if (currentLine !== "") {
276
+ lines = append(lines, singleton(currentLine));
277
+ }
278
+ return join("\n", lines);
279
+ }
280
+ }
281
+
282
+ export function extractStateKeyString(stateKey: Shared_StateKey): string {
283
+ return stateKey.fields[0];
284
+ }
285
+
286
+ export function getTerminalOutcome(terminal: ClinicalPathway_TerminalInfo): string {
287
+ return terminal.Outcome;
288
+ }
289
+
290
+ //# sourceMappingURL=PathwayDataExtractor.ts.map