@f1studio/form-spec 5.0.0-alpha.152 → 5.0.0-alpha.155

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 (47) hide show
  1. package/FormSpec.FS/BitmaskHelpers.d.ts.map +1 -1
  2. package/FormSpec.FS/FormSpec.d.ts +6 -3
  3. package/FormSpec.FS/FormSpec.d.ts.map +1 -1
  4. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateMapper.d.ts.map +1 -1
  5. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTriggerConverter.d.ts.map +1 -1
  6. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMREncoder.d.ts +1 -1
  7. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMREncoder.d.ts.map +1 -1
  8. package/FormSpec.FS/Integrations/Adapters/CorEMR/FormSpecToCoreMRInsert.d.ts +3 -1
  9. package/FormSpec.FS/Integrations/Adapters/CorEMR/FormSpecToCoreMRInsert.d.ts.map +1 -1
  10. package/FormSpec.FS/Integrations/CorEMR/ItemTriggerConverter.d.ts.map +1 -1
  11. package/FormSpec.FS/TriggerActionDto.d.ts +44 -0
  12. package/FormSpec.FS/TriggerActionDto.d.ts.map +1 -0
  13. package/FormSpec.TS/FormSpec.FS/BitmaskHelpers.js +1 -1
  14. package/FormSpec.TS/FormSpec.FS/BitmaskHelpers.js.map +1 -1
  15. package/FormSpec.TS/FormSpec.FS/FormSpec.js +18 -3
  16. package/FormSpec.TS/FormSpec.FS/FormSpec.js.map +1 -1
  17. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateMapper.js +20 -1
  18. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateMapper.js.map +1 -1
  19. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTriggerConverter.js +44 -6
  20. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTriggerConverter.js.map +1 -1
  21. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMREncoder.js +4 -8
  22. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMREncoder.js.map +1 -1
  23. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/FormSpecToCoreMRInsert.js +8 -2
  24. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/FormSpecToCoreMRInsert.js.map +1 -1
  25. package/FormSpec.TS/FormSpec.FS/Integrations/CorEMR/ItemTriggerConverter.js +53 -7
  26. package/FormSpec.TS/FormSpec.FS/Integrations/CorEMR/ItemTriggerConverter.js.map +1 -1
  27. package/FormSpec.TS/FormSpec.FS/Interop/FormSpec.Api.Helpers.js +1 -1
  28. package/FormSpec.TS/FormSpec.FS/Interop/FormSpec.Api.Helpers.js.map +1 -1
  29. package/FormSpec.TS/FormSpec.FS/TriggerActionDto.js +176 -0
  30. package/FormSpec.TS/FormSpec.FS/TriggerActionDto.js.map +1 -0
  31. package/FormSpec.TS/Thoth.Json/packages/Thoth.Json/Encode.js.map +1 -1
  32. package/FormSpec.TS/plugins/allergyfinder/src/AllergyLogic.js +0 -63
  33. package/FormSpec.TS/plugins/allergyfinder/src/AllergyLogic.js.map +1 -1
  34. package/README.md +7 -7
  35. package/package.json +1 -1
  36. package/plugins/allergyfinder/src/AllergyLogic.d.ts +0 -6
  37. package/plugins/allergyfinder/src/AllergyLogic.d.ts.map +1 -1
  38. package/src/FormSpec.FS/BitmaskHelpers.ts +3 -3
  39. package/src/FormSpec.FS/FormSpec.ts +12 -6
  40. package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateMapper.ts +27 -11
  41. package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTriggerConverter.ts +34 -8
  42. package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMREncoder.ts +6 -12
  43. package/src/FormSpec.FS/Integrations/Adapters/CorEMR/FormSpecToCoreMRInsert.ts +6 -3
  44. package/src/FormSpec.FS/Integrations/CorEMR/ItemTriggerConverter.ts +40 -8
  45. package/src/FormSpec.FS/Interop/FormSpec.Api.Helpers.ts +1 -1
  46. package/src/FormSpec.FS/TriggerActionDto.ts +135 -0
  47. package/src/plugins/allergyfinder/src/AllergyLogic.ts +4 -22
@@ -0,0 +1,135 @@
1
+ import { Record } from "@fable-org/fable-library-js/Types.js";
2
+ import { int32 } from "@fable-org/fable-library-js/Int32.js";
3
+ import { map, value, Option } from "@fable-org/fable-library-js/Option.js";
4
+ import { IComparable, IEquatable } from "@fable-org/fable-library-js/Util.js";
5
+ import { record_type, bool_type, option_type, int32_type, string_type, TypeInfo } from "@fable-org/fable-library-js/Reflection.js";
6
+ import { ClinicalPathway_ActionInfo_$union, ClinicalPathway_ProblemAction, ClinicalPathway_AlertAction, ClinicalPathway_RecurrencePattern, ClinicalPathway_RecurrenceEnd_$union, ClinicalPathway_TaskAction, ClinicalPathway_DueDate_$union, ClinicalPathway_TaskPriority_$union } from "./FormSpec.js";
7
+ import { fromDateTimeOffset, today, addDays, toString } from "@fable-org/fable-library-js/Date.js";
8
+ import { FSharpList, choose } from "@fable-org/fable-library-js/List.js";
9
+
10
+ export class TriggerActionDto extends Record implements IEquatable<TriggerActionDto>, IComparable<TriggerActionDto> {
11
+ readonly ActionType: string;
12
+ readonly TriggerId: int32;
13
+ readonly TriggerActionId: int32;
14
+ readonly CategoryId: int32;
15
+ readonly CategoryName: string;
16
+ readonly Priority: Option<int32>;
17
+ readonly Description: Option<string>;
18
+ readonly DateStart: Option<string>;
19
+ readonly AllDay: Option<boolean>;
20
+ readonly ScheduleEnd: Option<string>;
21
+ readonly ProblemListId: Option<int32>;
22
+ readonly FormItemId: Option<int32>;
23
+ constructor(ActionType: string, TriggerId: int32, TriggerActionId: int32, CategoryId: int32, CategoryName: string, Priority: Option<int32>, Description: Option<string>, DateStart: Option<string>, AllDay: Option<boolean>, ScheduleEnd: Option<string>, ProblemListId: Option<int32>, FormItemId: Option<int32>) {
24
+ super();
25
+ this.ActionType = ActionType;
26
+ this.TriggerId = (TriggerId | 0);
27
+ this.TriggerActionId = (TriggerActionId | 0);
28
+ this.CategoryId = (CategoryId | 0);
29
+ this.CategoryName = CategoryName;
30
+ this.Priority = Priority;
31
+ this.Description = Description;
32
+ this.DateStart = DateStart;
33
+ this.AllDay = AllDay;
34
+ this.ScheduleEnd = ScheduleEnd;
35
+ this.ProblemListId = ProblemListId;
36
+ this.FormItemId = FormItemId;
37
+ }
38
+ }
39
+
40
+ export function TriggerActionDto_$reflection(): TypeInfo {
41
+ return record_type("F1.Studio.TriggerActions.TriggerActionDto", [], TriggerActionDto, () => [["ActionType", string_type], ["TriggerId", int32_type], ["TriggerActionId", int32_type], ["CategoryId", int32_type], ["CategoryName", string_type], ["Priority", option_type(int32_type)], ["Description", option_type(string_type)], ["DateStart", option_type(string_type)], ["AllDay", option_type(bool_type)], ["ScheduleEnd", option_type(string_type)], ["ProblemListId", option_type(int32_type)], ["FormItemId", option_type(int32_type)]]);
42
+ }
43
+
44
+ /**
45
+ * Convert ClinicalPathway.TaskPriority DU → CoreMR int (1=High, 2=Medium, 3=Low)
46
+ */
47
+ export function convertPriority(priority: ClinicalPathway_TaskPriority_$union): int32 {
48
+ switch (priority.tag) {
49
+ case /* Medium */ 1:
50
+ return 2;
51
+ case /* Low */ 2:
52
+ return 3;
53
+ default:
54
+ return 1;
55
+ }
56
+ }
57
+
58
+ /**
59
+ * Convert ClinicalPathway.DueDate DU → ISO 8601 date string
60
+ */
61
+ export function convertDueDate(dueDate: ClinicalPathway_DueDate_$union): string {
62
+ switch (dueDate.tag) {
63
+ case /* Tomorrow */ 1:
64
+ return toString(addDays(today(), 1), "o");
65
+ case /* DaysFromNow */ 2: {
66
+ const days: int32 = dueDate.fields[0] | 0;
67
+ return toString(addDays(today(), days), "o");
68
+ }
69
+ case /* SpecificDate */ 3:
70
+ return toString(fromDateTimeOffset(dueDate.fields[0], 0), "o");
71
+ default:
72
+ return toString(today(), "o");
73
+ }
74
+ }
75
+
76
+ function requireCategoryId(actionType: string, categoryName: string, categoryIdOpt: Option<int32>): int32 {
77
+ if (categoryIdOpt == null) {
78
+ throw new Error(`TriggerActionDto.convert: missing categoryId for actionType='${actionType}' category='${categoryName}'. CoreMR submit requires provenance category IDs.`);
79
+ }
80
+ else if (value(categoryIdOpt) > 0) {
81
+ const id_1: int32 = value(categoryIdOpt) | 0;
82
+ return id_1 | 0;
83
+ }
84
+ else {
85
+ const id_2: int32 = value(categoryIdOpt) | 0;
86
+ throw new Error(`TriggerActionDto.convert: invalid categoryId=${id_2} for actionType='${actionType}' category='${categoryName}'. categoryId must be > 0.`);
87
+ }
88
+ }
89
+
90
+ /**
91
+ * Convert a list of ClinicalPathway ActionInfo (from PathwayExecutor.ExecutedActions)
92
+ * into a list of TriggerActionDto ready for JSON serialization and bridge POST.
93
+ *
94
+ * Only converts CoreMR-actionable types: Task, Alert, Problem.
95
+ * Skips: Medication, Education, Referral, Procedure, Documentation, Prescription,
96
+ * SetFieldValue, NavigateToForm (these are either Phase 2 or F1-internal).
97
+ *
98
+ * Task with Recurrence.IsSome → ActionType = "recurring_task"
99
+ * Task with Recurrence.IsNone → ActionType = "task"
100
+ */
101
+ export function convert(actions: FSharpList<ClinicalPathway_ActionInfo_$union>): FSharpList<TriggerActionDto> {
102
+ return choose<ClinicalPathway_ActionInfo_$union, TriggerActionDto>((action: ClinicalPathway_ActionInfo_$union): Option<TriggerActionDto> => {
103
+ switch (action.tag) {
104
+ case /* Task */ 6: {
105
+ const taskAction: ClinicalPathway_TaskAction = action.fields[0];
106
+ const actionType: string = (taskAction.Recurrence != null) ? "recurring_task" : "task";
107
+ return new TriggerActionDto(actionType, 0, 0, requireCategoryId(actionType, taskAction.Category, taskAction.CategoryId), taskAction.Category, convertPriority(taskAction.Priority), taskAction.Description, convertDueDate(taskAction.DueDate), true, map<ClinicalPathway_RecurrencePattern, string>((r: ClinicalPathway_RecurrencePattern): string => {
108
+ const matchValue: ClinicalPathway_RecurrenceEnd_$union = r.Until;
109
+ switch (matchValue.tag) {
110
+ case /* AfterOccurrences */ 1: {
111
+ const n: int32 = matchValue.fields[0] | 0;
112
+ return toString(addDays(today(), n), "o");
113
+ }
114
+ case /* Never */ 2:
115
+ return toString(addDays(today(), 7), "o");
116
+ default:
117
+ return toString(fromDateTimeOffset(matchValue.fields[0], 0), "o");
118
+ }
119
+ }, taskAction.Recurrence), undefined, undefined);
120
+ }
121
+ case /* Alert */ 7: {
122
+ const alertAction: ClinicalPathway_AlertAction = action.fields[0];
123
+ return new TriggerActionDto("alert", 0, 0, requireCategoryId("alert", alertAction.Category, alertAction.CategoryId), alertAction.Category, undefined, undefined, undefined, undefined, undefined, undefined, undefined);
124
+ }
125
+ case /* Problem */ 8: {
126
+ const problemAction: ClinicalPathway_ProblemAction = action.fields[0];
127
+ return new TriggerActionDto("problem", 0, 0, requireCategoryId("problem", problemAction.ProblemName, problemAction.CategoryId), problemAction.ProblemName, undefined, undefined, undefined, undefined, undefined, undefined, undefined);
128
+ }
129
+ default:
130
+ return undefined;
131
+ }
132
+ }, actions);
133
+ }
134
+
135
+ //# sourceMappingURL=TriggerActionDto.ts.map
@@ -1,8 +1,8 @@
1
- import { FSharpRef, toString as toString_1, Record } from "@fable-org/fable-library-js/Types.js";
2
- import { uncurry2, int32ToString, stringHash, IComparable, IEquatable } from "@fable-org/fable-library-js/Util.js";
1
+ import { FSharpRef, Record } from "@fable-org/fable-library-js/Types.js";
2
+ import { uncurry2, stringHash, IComparable, IEquatable } from "@fable-org/fable-library-js/Util.js";
3
3
  import { int32_type, record_type, bool_type, array_type, string_type, TypeInfo } from "@fable-org/fable-library-js/Reflection.js";
4
4
  import { tryParse, int32 } from "@fable-org/fable-library-js/Int32.js";
5
- import { compare, isNullOrEmpty, isNullOrWhiteSpace } from "@fable-org/fable-library-js/String.js";
5
+ import { compare, isNullOrWhiteSpace } from "@fable-org/fable-library-js/String.js";
6
6
  import { tryFind, append as append_1, map, contains } from "@fable-org/fable-library-js/Array.js";
7
7
  import { empty, singleton, append, delay, toArray } from "@fable-org/fable-library-js/Seq.js";
8
8
  import { fromString, IOptionalGetter, IGetters, bool, array as array_3, IRequiredGetter, string, object } from "../../../Thoth.Json/packages/Thoth.Json/Decode.js";
@@ -10,10 +10,7 @@ import { bind, map as map_1, Option, defaultArgWith, orElse, defaultArg } from "
10
10
  import { FSharpResult$2_$union } from "@fable-org/fable-library-js/Result.js";
11
11
  import { ErrorReason_$union } from "../../../Thoth.Json/packages/Thoth.Json/Types.js";
12
12
  import { newGuid } from "@fable-org/fable-library-js/Guid.js";
13
- import { Shared_FieldValue_PluginData, Shared_PluginDataProperty, Shared_PluginPropertyKey } from "../../../FormSpec.FS/FormSpec.js";
14
- import { toString, list, nil, object as object_1 } from "../../../Thoth.Json/packages/Thoth.Json/Encode.js";
15
- import { ofArray } from "@fable-org/fable-library-js/List.js";
16
- import { Convert_fieldValueToTs } from "../../../FormSpec.FS/Interop/Facade/BlueprintFilledForm.js";
13
+ import { Shared_PluginDataProperty, Shared_PluginPropertyKey } from "../../../FormSpec.FS/FormSpec.js";
17
14
 
18
15
  export class AllergyEntryData extends Record implements IEquatable<AllergyEntryData>, IComparable<AllergyEntryData> {
19
16
  readonly Id: string;
@@ -153,21 +150,6 @@ export const PropertyKeys_HasSevereAllergy: Shared_PluginPropertyKey = new Share
153
150
 
154
151
  export const PropertyKeys_AllergiesJson: Shared_PluginPropertyKey = new Shared_PluginPropertyKey("af100003-af10-af10-af10-af10af10af10");
155
152
 
156
- function allergyEntryEncoder(a: AllergyEntryData): any {
157
- return object_1([["Id", a.Id] as [string, any], ["Name", a.Name] as [string, any], ["SubstanceName", a.SubstanceName] as [string, any], ["NdcCode", isNullOrEmpty(a.NdcCode) ? nil : a.NdcCode] as [string, any], ["Category", a.Category] as [string, any], ["Severity", a.Severity] as [string, any], ["Reactions", list(ofArray<any>(map<string, any>((value_6: string): any => value_6, a.Reactions)))] as [string, any], ["Remedy", isNullOrEmpty(a.Remedy) ? nil : a.Remedy] as [string, any], ["OnsetTiming", isNullOrEmpty(a.OnsetTiming) ? nil : a.OnsetTiming] as [string, any], ["StaffOnly", a.StaffOnly] as [string, any], ["Notes", isNullOrEmpty(a.Notes) ? nil : a.Notes] as [string, any]]);
158
- }
159
-
160
- /**
161
- * Serialize allergy entries to the canonical TS wire format.
162
- * Returns the output of Convert.fieldValueToTs(FieldValue.PluginData [...]).
163
- * TypeScript passes this directly to onValueChange — zero ad-hoc construction.
164
- */
165
- export function serializeAllergiesToCanonical(entries: AllergyEntryData[]): any {
166
- const hasSevere: boolean = entries.some((e: AllergyEntryData): boolean => isSevere(e.Severity));
167
- const allergiesJson: string = toString(0, list(ofArray<any>(map<AllergyEntryData, any>(allergyEntryEncoder, entries))));
168
- return Convert_fieldValueToTs(Shared_FieldValue_PluginData(ofArray([new Shared_PluginDataProperty(PropertyKeys_AllergyCount, "allergy_count", "int", int32ToString(entries.length), "Allergy Count", undefined, undefined), new Shared_PluginDataProperty(PropertyKeys_HasSevereAllergy, "has_severe_allergy", "bool", toString_1(hasSevere).toLowerCase(), "Has Severe Allergy", undefined, undefined), new Shared_PluginDataProperty(PropertyKeys_AllergiesJson, "allergies_json", "string", allergiesJson, "Allergies Data", undefined, undefined)])));
169
- }
170
-
171
153
  /**
172
154
  * Validate plugin data from the wire format.
173
155
  * Takes array (not list) of PluginDataProperty for TS interop.