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

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 (22) hide show
  1. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateMapper.d.ts +13 -13
  2. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateMapper.d.ts.map +1 -1
  3. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateMapper.js +25 -121
  4. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateMapper.js.map +1 -1
  5. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMREncoder.js.map +1 -1
  6. package/FormSpec.FS/Integrations/CorEMR/ItemTriggerConverter.d.ts.map +1 -1
  7. package/FormSpec.FS/Integrations/CorEMR/ItemTriggerConverter.js +13 -4
  8. package/FormSpec.FS/Integrations/CorEMR/ItemTriggerConverter.js.map +1 -1
  9. package/FormSpec.FS/Integrations/CorEMR/TemplateManifestDecoder.d.ts +98 -27
  10. package/FormSpec.FS/Integrations/CorEMR/TemplateManifestDecoder.d.ts.map +1 -1
  11. package/FormSpec.FS/Integrations/CorEMR/TemplateManifestDecoder.js +500 -81
  12. package/FormSpec.FS/Integrations/CorEMR/TemplateManifestDecoder.js.map +1 -1
  13. package/FormSpec.FS/Interop/Facade/FormItemLookup.d.ts +95 -0
  14. package/FormSpec.FS/Interop/Facade/FormItemLookup.d.ts.map +1 -0
  15. package/FormSpec.FS/Interop/Facade/FormItemLookup.js +155 -0
  16. package/FormSpec.FS/Interop/Facade/FormItemLookup.js.map +1 -0
  17. package/README.md +7 -7
  18. package/package.json +5 -1
  19. package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateMapper.ts +44 -105
  20. package/src/FormSpec.FS/Integrations/CorEMR/ItemTriggerConverter.ts +11 -2
  21. package/src/FormSpec.FS/Integrations/CorEMR/TemplateManifestDecoder.ts +469 -82
  22. package/src/FormSpec.FS/Interop/Facade/FormItemLookup.ts +179 -0
@@ -0,0 +1,179 @@
1
+ import { class_type, TypeInfo } from "@fable-org/fable-library-js/Reflection.js";
2
+ import { isNullOrWhiteSpace } from "@fable-org/fable-library-js/String.js";
3
+ import { equals } from "@fable-org/fable-library-js/Util.js";
4
+ import { filter, tryLast, FSharpList, map, toArray } from "@fable-org/fable-library-js/List.js";
5
+ import { Spec_VendorScoreBand, Spec_FormSpec$1, Spec_VendorScore, Spec_FormField$1, Spec_FieldType_$union, Shared_FieldOption } from "../../FormSpec.js";
6
+ import { bind, value, Option, map as map_1 } from "@fable-org/fable-library-js/Option.js";
7
+ import { int32 } from "@fable-org/fable-library-js/Int32.js";
8
+
9
+ export type ItemKindAuthority =
10
+ | "site"
11
+ | "conduit"
12
+ | "nobody"
13
+
14
+ export class ItemKindInfoTS {
15
+ readonly "label@65": string;
16
+ readonly "isResolved@65": boolean;
17
+ readonly "control@65": string;
18
+ readonly "authority@65": ItemKindAuthority;
19
+ constructor(control: string, label: string, authority: ItemKindAuthority, isResolved: boolean) {
20
+ this["control@65"] = control;
21
+ this["label@65"] = label;
22
+ this["authority@65"] = authority;
23
+ this["isResolved@65"] = isResolved;
24
+ }
25
+ }
26
+
27
+ export function ItemKindInfoTS_$reflection(): TypeInfo {
28
+ return class_type("F1.Studio.FormItemLookup.ItemKindInfoTS", undefined, ItemKindInfoTS);
29
+ }
30
+
31
+ export function ItemKindInfoTS_$ctor_Z4A082755(control: string, label: string, authority: ItemKindAuthority, isResolved: boolean): ItemKindInfoTS {
32
+ return new ItemKindInfoTS(control, label, authority, isResolved);
33
+ }
34
+
35
+ /**
36
+ * The control the vendor renders.
37
+ */
38
+ export function ItemKindInfoTS__get_control(_: ItemKindInfoTS): string {
39
+ return _["control@65"];
40
+ }
41
+
42
+ /**
43
+ * The source's own words for it, or conduit's where the release states none.
44
+ */
45
+ export function ItemKindInfoTS__get_label(_: ItemKindInfoTS): string {
46
+ return _["label@65"];
47
+ }
48
+
49
+ /**
50
+ * ⭐ WHOSE WORD THIS IS.
51
+ */
52
+ export function ItemKindInfoTS__get_authority(_: ItemKindInfoTS): ItemKindAuthority {
53
+ return _["authority@65"];
54
+ }
55
+
56
+ /**
57
+ * ⛔ `false` when nothing states this kind. The item still exists and still has answers — what
58
+ * is missing is a MEANING, and a screen must say so rather than paint a plausible default.
59
+ */
60
+ export function ItemKindInfoTS__get_isResolved(_: ItemKindInfoTS): boolean {
61
+ return _["isResolved@65"];
62
+ }
63
+
64
+ export class StatedOptionTS {
65
+ readonly "text@81": string;
66
+ readonly "optionKey@81": string;
67
+ constructor(optionKey: string, text: string) {
68
+ this["optionKey@81"] = optionKey;
69
+ this["text@81"] = text;
70
+ }
71
+ }
72
+
73
+ export function StatedOptionTS_$reflection(): TypeInfo {
74
+ return class_type("F1.Studio.FormItemLookup.StatedOptionTS", undefined, StatedOptionTS);
75
+ }
76
+
77
+ export function StatedOptionTS_$ctor_Z384F8060(optionKey: string, text: string): StatedOptionTS {
78
+ return new StatedOptionTS(optionKey, text);
79
+ }
80
+
81
+ export function StatedOptionTS__get_optionKey(_: StatedOptionTS): string {
82
+ return _["optionKey@81"];
83
+ }
84
+
85
+ export function StatedOptionTS__get_text(_: StatedOptionTS): string {
86
+ return _["text@81"];
87
+ }
88
+
89
+ /**
90
+ * What kind is this item, and whose word is that?
91
+ *
92
+ * ⭐ THE REPLACEMENT FOR `getFieldCoreMRAnchor` + `getBitmaskChoiceAnalysis` in a diagnostics
93
+ * panel: it answers "what is this field, and can we trust the answer" without naming an
94
+ * encoding, a bit or a vendor integer.
95
+ *
96
+ * ⛔ An unresolved kind is NAMED (`isResolved = false`), never defaulted. Conduit spells an
97
+ * unstated kind `unresolved_<code>`; this reads that and says so rather than passing it on as
98
+ * if it were a control.
99
+ */
100
+ export function Lookup_getItemKindInfo(control: string, label: string, statedBy: string): ItemKindInfoTS {
101
+ const authority: ItemKindAuthority = (statedBy === "site") ? "site" : ((statedBy === "conduit") ? "conduit" : "nobody");
102
+ return ItemKindInfoTS_$ctor_Z4A082755(control, label, authority, (!isNullOrWhiteSpace(control) && !control.startsWith("unresolved_")) && !equals(authority, "nobody"));
103
+ }
104
+
105
+ /**
106
+ * The options a field states, as identity + the site's own text.
107
+ *
108
+ * ⭐ THE REPLACEMENT FOR `getFieldBitmaskChoiceTable`. That helper's table had `score` and
109
+ * `bitPosition` columns; neither is a fact about the option, both are CoreMR's encoding of it.
110
+ * ⛔ Whether one or several may be chosen is NOT answered here: it is a property of the item's
111
+ * own stated options, resolved in conduit, and a TypeScript panel has no business re-deciding it.
112
+ */
113
+ export function Lookup_getStatedOptions(field: Spec_FormField$1<Spec_FieldType_$union>): StatedOptionTS[] {
114
+ const ofOptions = (options: FSharpList<Shared_FieldOption>): StatedOptionTS[] => toArray<StatedOptionTS>(map<Shared_FieldOption, StatedOptionTS>((o: Shared_FieldOption): StatedOptionTS => StatedOptionTS_$ctor_Z384F8060(o.OptionKey.fields[0], o.Description), options));
115
+ const matchValue: Spec_FieldType_$union = field.FieldType;
116
+ switch (matchValue.tag) {
117
+ case /* Radio */ 12:
118
+ return ofOptions(matchValue.fields[0].Options);
119
+ case /* Dropdown */ 14:
120
+ return ofOptions(matchValue.fields[0].Options);
121
+ case /* CheckboxList */ 16:
122
+ return ofOptions(matchValue.fields[0].Options);
123
+ default:
124
+ return [];
125
+ }
126
+ }
127
+
128
+ /**
129
+ * Does this field offer options at all?
130
+ *
131
+ * ⭐ STRUCTURAL, per field — never per item type. Measured at St Johns: 21 items of type 20
132
+ * state no options while 73 of 132 type-140 items DO, so any type-level answer is wrong for
133
+ * every one of them (conduit `audit/260923-1655`).
134
+ */
135
+ export function Lookup_fieldStatesOptions(field: Spec_FormField$1<Spec_FieldType_$union>): boolean {
136
+ return Lookup_getStatedOptions(field).length > 0;
137
+ }
138
+
139
+ /**
140
+ * The scale a SOURCE stated for this form, if it stated one.
141
+ *
142
+ * ⛔ `Score` is NOT consulted: that is the f1 designer's authored scale, a different fact with a
143
+ * different author. ⚠️ And there is no maximum here because nothing states one — CoreMR's
144
+ * `form_scores` is `id · name · form_name · labels · deleted`.
145
+ */
146
+ export function Lookup_getVendorScaleName(formSpec: Spec_FormSpec$1<Spec_FieldType_$union>): Option<string> {
147
+ return map_1<Spec_VendorScore, string>((v: Spec_VendorScore): string => v.ScaleName, formSpec.VendorScore);
148
+ }
149
+
150
+ /**
151
+ * The bands a source stated, lowest first, as `[label, minimum]` pairs.
152
+ *
153
+ * ⭐ A band runs from its own minimum to the NEXT band's, and the last is unbounded — which is
154
+ * why no maximum is carried. Deriving the upper edge at the paint is correct; storing it is how
155
+ * bands acquire gaps and overlaps nobody stated.
156
+ */
157
+ export function Lookup_getVendorScaleBands(formSpec: Spec_FormSpec$1<Spec_FieldType_$union>): [string, int32][] {
158
+ const matchValue: Option<Spec_VendorScore> = formSpec.VendorScore;
159
+ if (matchValue != null) {
160
+ return toArray<[string, int32]>(map<Spec_VendorScoreBand, [string, int32]>((b: Spec_VendorScoreBand): [string, int32] => ([b.Label, b.Min] as [string, int32]), value(matchValue).Bands));
161
+ }
162
+ else {
163
+ return [];
164
+ }
165
+ }
166
+
167
+ /**
168
+ * Which stated band a total falls in, or `None` when no source stated a scale.
169
+ *
170
+ * ⛔ REFUSES to guess. If the form carries no stated scale there is no band, and a screen must
171
+ * show that rather than invent one. This function existing in F# is the whole point: until
172
+ * 2026-09-23 an importer invented Low/Medium/High at thirds and a CoreMR "Severe" rendered as
173
+ * "Low Risk" on five published instruments.
174
+ */
175
+ export function Lookup_getVendorScaleBandFor(formSpec: Spec_FormSpec$1<Spec_FieldType_$union>, total: int32): Option<string> {
176
+ return map_1<Spec_VendorScoreBand, string>((b_1: Spec_VendorScoreBand): string => b_1.Label, bind<Spec_VendorScore, Spec_VendorScoreBand>((v: Spec_VendorScore): Option<Spec_VendorScoreBand> => tryLast<Spec_VendorScoreBand>(filter<Spec_VendorScoreBand>((b: Spec_VendorScoreBand): boolean => (total >= b.Min), v.Bands)), formSpec.VendorScore));
177
+ }
178
+
179
+ //# sourceMappingURL=FormItemLookup.ts.map