@f1studio/form-spec 5.0.0-alpha.132 → 5.0.0-alpha.134

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 (21) hide show
  1. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRSourceMap.d.ts +4 -4
  2. package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRSourceMap.d.ts.map +1 -1
  3. package/FormSpec.FS/Integrations/CorEMR/TemplateManifestDecoder.d.ts.map +1 -1
  4. package/FormSpec.FS/Interop/FormSpec.Api.Helpers.d.ts +37 -0
  5. package/FormSpec.FS/Interop/FormSpec.Api.Helpers.d.ts.map +1 -1
  6. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRSourceMap.js +14 -23
  7. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRSourceMap.js.map +1 -1
  8. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRSourceMap.ts.map +1 -1
  9. package/FormSpec.TS/FormSpec.FS/Integrations/CorEMR/TemplateManifestDecoder.js +1 -13
  10. package/FormSpec.TS/FormSpec.FS/Integrations/CorEMR/TemplateManifestDecoder.js.map +1 -1
  11. package/FormSpec.TS/FormSpec.FS/Integrations/CorEMR/TemplateManifestDecoder.ts.map +1 -1
  12. package/FormSpec.TS/FormSpec.FS/Interop/FormSpec.Api.Helpers.js +86 -0
  13. package/FormSpec.TS/FormSpec.FS/Interop/FormSpec.Api.Helpers.js.map +1 -1
  14. package/FormSpec.TS/FormSpec.FS/Interop/FormSpec.Api.Helpers.ts.map +1 -1
  15. package/FormSpec.TS/Thoth.Json/packages/Thoth.Json/Encode.js.map +1 -1
  16. package/FormSpec.TS/Thoth.Json/packages/Thoth.Json/Encode.ts.map +1 -1
  17. package/README.md +7 -7
  18. package/package.json +1 -1
  19. package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRSourceMap.ts +11 -17
  20. package/src/FormSpec.FS/Integrations/CorEMR/TemplateManifestDecoder.ts +6 -16
  21. package/src/FormSpec.FS/Interop/FormSpec.Api.Helpers.ts +109 -4
@@ -4,14 +4,11 @@ import { equals, toInt32, int64 } from "@fable-org/fable-library-js/BigInt.js";
4
4
  import { map as map_1, defaultArg, Option } from "@fable-org/fable-library-js/Option.js";
5
5
  import { int32ToString, uncurry2, comparePrimitives, IComparable, IEquatable } from "@fable-org/fable-library-js/Util.js";
6
6
  import { class_type, list_type, bool_type, record_type, option_type, string_type, int64_type, int32_type, TypeInfo } from "@fable-org/fable-library-js/Reflection.js";
7
- import { filter, length, sumBy as sumBy_1, empty as empty_1, collect, map as map_2, isEmpty, FSharpList } from "@fable-org/fable-library-js/List.js";
8
- import { toSeq, ofList, add, FSharpMap } from "@fable-org/fable-library-js/Map.js";
9
- import { newGuid } from "@fable-org/fable-library-js/Guid.js";
10
- import { int64 as int64_1 } from "../../../Thoth.Json/packages/Thoth.Json/Encode.js";
11
- import { Auto_generateBoxedDecoder_Z6670B51, int64 as int64_2 } from "../../../Thoth.Json/packages/Thoth.Json/Decode.js";
7
+ import { filter, length, sumBy as sumBy_1, empty, collect, map as map_2, isEmpty, FSharpList } from "@fable-org/fable-library-js/List.js";
8
+ import { toSeq, ofList, FSharpMap } from "@fable-org/fable-library-js/Map.js";
9
+ import { Auto_generateBoxedDecoder_Z6670B51 } from "../../../Thoth.Json/packages/Thoth.Json/Decode.js";
12
10
  import { FSharpResult$2_$union } from "@fable-org/fable-library-js/Result.js";
13
- import { ExtraCoders, ErrorReason_$union } from "../../../Thoth.Json/packages/Thoth.Json/Types.js";
14
- import { empty } from "../../../Thoth.Json/packages/Thoth.Json/Extra.js";
11
+ import { ErrorReason_$union } from "../../../Thoth.Json/packages/Thoth.Json/Types.js";
15
12
  import { isNullOrEmpty, toConsole, printf, toText } from "@fable-org/fable-library-js/String.js";
16
13
  import { fromString, list as list_5, bool, IOptionalGetter, IGetters, string, int, IRequiredGetter, object, map, keyValuePairs } from "../../../Thoth.Json/packages/Thoth.Json/Decode.js";
17
14
  import { CoreMRFormData, CoreMRTag, CoreMRTrigger, CoreMRFormMetadata, CoreMRItem, CoreMRChoice } from "./CoreMRTypes.js";
@@ -317,13 +314,6 @@ export function TemplateManifest_$reflection(): TypeInfo {
317
314
  return record_type("FormSpec.Integrations.CorEMR.TemplateManifestDecoder.TemplateManifest", [], TemplateManifest, () => [["Schema", option_type(string_type)], ["Version", int32_type], ["GeneratedAt", string_type], ["GeneratedFrom", string_type], ["CoreEmr", CoreEmrInfo_$reflection()], ["Stats", TemplateStats_$reflection()], ["ElementTypes", class_type("Microsoft.FSharp.Collections.FSharpMap`2", [string_type, ElementTypeEntry_$reflection()])], ["Forms", class_type("Microsoft.FSharp.Collections.FSharpMap`2", [string_type, TemplateForm_$reflection()])], ["InstrumentMap", class_type("Microsoft.FSharp.Collections.FSharpMap`2", [string_type, InstrumentMapEntry_$reflection()])], ["InstrumentMapStats", InstrumentMapStats_$reflection()]]);
318
315
  }
319
316
 
320
- const extraWithInt64: ExtraCoders = new ExtraCoders((() => {
321
- let copyOfStruct: string = newGuid();
322
- return copyOfStruct;
323
- })(), add<string, [((arg0: any) => any), ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<any, [string, ErrorReason_$union]>))]>("System.Int64", [int64_1, (path: string): ((arg0: any) => FSharpResult$2_$union<int64, [string, ErrorReason_$union]>) => ((value_1: any): FSharpResult$2_$union<int64, [string, ErrorReason_$union]> => int64_2(path, value_1))] as [((arg0: any) => any), ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<any, [string, ErrorReason_$union]>))], empty.Coders));
324
-
325
- const int64Decoder: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<int64, [string, ErrorReason_$union]>)) = Auto_generateBoxedDecoder_Z6670B51(int64_type, undefined, extraWithInt64);
326
-
327
317
  const liberatedInt64Decoder: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<int64, [string, ErrorReason_$union]>)) = Auto_generateBoxedDecoder_Z6670B51(int64_type, undefined, undefined);
328
318
 
329
319
  function scoreSurveillanceLog(score: int64): void {
@@ -376,7 +366,7 @@ const formScoringDecoder = (path_2: string): ((arg0: any) => FSharpResult$2_$uni
376
366
 
377
367
  const formDecoder = (path_13: string): ((arg0: any) => FSharpResult$2_$union<TemplateForm, [string, ErrorReason_$union]>) => ((v: any): FSharpResult$2_$union<TemplateForm, [string, ErrorReason_$union]> => object<TemplateForm>((get$: IGetters): TemplateForm => {
378
368
  let objectArg: IRequiredGetter, objectArg_1: IRequiredGetter, objectArg_2: IRequiredGetter, objectArg_3: IRequiredGetter, objectArg_4: IRequiredGetter, objectArg_5: IRequiredGetter, objectArg_6: IRequiredGetter, objectArg_7: IRequiredGetter, objectArg_8: IRequiredGetter, objectArg_9: IRequiredGetter, objectArg_10: IRequiredGetter, objectArg_11: IRequiredGetter, objectArg_12: IRequiredGetter, objectArg_13: IRequiredGetter, objectArg_14: IRequiredGetter, objectArg_15: IRequiredGetter, objectArg_16: IOptionalGetter;
379
- return new TemplateForm((objectArg = get$.Required, objectArg.Field<int32>("formId", uncurry2(int))), (objectArg_1 = get$.Required, objectArg_1.Field<string>("name", string)), (objectArg_2 = get$.Required, objectArg_2.Field<string>("formCode", string)), (objectArg_3 = get$.Required, objectArg_3.Field<string>("formCodeSource", string)), (objectArg_4 = get$.Required, objectArg_4.Field<string>("description", string)), (objectArg_5 = get$.Required, objectArg_5.Field<int64>("currentVersionId", uncurry2(int64Decoder))), (objectArg_6 = get$.Required, objectArg_6.Field<boolean>("isIntake", bool)), (objectArg_7 = get$.Required, objectArg_7.Field<string>("usage", string)), (objectArg_8 = get$.Required, objectArg_8.Field<boolean>("requiresSignature", bool)), (objectArg_9 = get$.Required, objectArg_9.Field<EncounterTypes>("encounterTypes", uncurry2(encounterTypesDecoder))), (objectArg_10 = get$.Required, objectArg_10.Field<boolean>("onceAYear", bool)), (objectArg_11 = get$.Required, objectArg_11.Field<string>("structureHash", string)), (objectArg_12 = get$.Required, objectArg_12.Field<string>("clinicalHash", string)), (objectArg_13 = get$.Required, objectArg_13.Field<string>("cosmeticHash", string)), (objectArg_14 = get$.Required, objectArg_14.Field<string>("hash", string)), (objectArg_15 = get$.Required, objectArg_15.Field<FSharpList<TemplateItem>>("items", (path_12: string, value_12: any): FSharpResult$2_$union<FSharpList<TemplateItem>, [string, ErrorReason_$union]> => list_5<TemplateItem>(uncurry2(itemDecoder), path_12, value_12))), (objectArg_16 = get$.Optional, objectArg_16.Field<FormScoring>("scoring", uncurry2(formScoringDecoder))));
369
+ return new TemplateForm((objectArg = get$.Required, objectArg.Field<int32>("formId", uncurry2(int))), (objectArg_1 = get$.Required, objectArg_1.Field<string>("name", string)), (objectArg_2 = get$.Required, objectArg_2.Field<string>("formCode", string)), (objectArg_3 = get$.Required, objectArg_3.Field<string>("formCodeSource", string)), (objectArg_4 = get$.Required, objectArg_4.Field<string>("description", string)), (objectArg_5 = get$.Required, objectArg_5.Field<int64>("currentVersionId", uncurry2(liberatedInt64Decoder))), (objectArg_6 = get$.Required, objectArg_6.Field<boolean>("isIntake", bool)), (objectArg_7 = get$.Required, objectArg_7.Field<string>("usage", string)), (objectArg_8 = get$.Required, objectArg_8.Field<boolean>("requiresSignature", bool)), (objectArg_9 = get$.Required, objectArg_9.Field<EncounterTypes>("encounterTypes", uncurry2(encounterTypesDecoder))), (objectArg_10 = get$.Required, objectArg_10.Field<boolean>("onceAYear", bool)), (objectArg_11 = get$.Required, objectArg_11.Field<string>("structureHash", string)), (objectArg_12 = get$.Required, objectArg_12.Field<string>("clinicalHash", string)), (objectArg_13 = get$.Required, objectArg_13.Field<string>("cosmeticHash", string)), (objectArg_14 = get$.Required, objectArg_14.Field<string>("hash", string)), (objectArg_15 = get$.Required, objectArg_15.Field<FSharpList<TemplateItem>>("items", (path_12: string, value_12: any): FSharpResult$2_$union<FSharpList<TemplateItem>, [string, ErrorReason_$union]> => list_5<TemplateItem>(uncurry2(itemDecoder), path_12, value_12))), (objectArg_16 = get$.Optional, objectArg_16.Field<FormScoring>("scoring", uncurry2(formScoringDecoder))));
380
370
  }, path_13, v));
381
371
 
382
372
  const elementTypeDecoder = (path_3: string): ((arg0: any) => FSharpResult$2_$union<ElementTypeEntry, [string, ErrorReason_$union]>) => ((v: any): FSharpResult$2_$union<ElementTypeEntry, [string, ErrorReason_$union]> => object<ElementTypeEntry>((get$: IGetters): ElementTypeEntry => {
@@ -426,7 +416,7 @@ function toCoreMRItem(item: TemplateItem): CoreMRItem {
426
416
  * Convert a TemplateForm to CoreMRFormData — the universal pipeline input.
427
417
  */
428
418
  export function toCoreMRFormData(form: TemplateForm): CoreMRFormData {
429
- return new CoreMRFormData(new CoreMRFormMetadata(form.FormId, form.Name, isNullOrEmpty(form.Description) ? undefined : form.Description, ~~toInt32(form.CurrentVersionId), 1, undefined, form.RequiresSignature, form.IsIntake, "", ""), map_2<TemplateItem, CoreMRItem>(toCoreMRItem, form.Items), collect<TemplateItem, CoreMRChoice>((item_1: TemplateItem): FSharpList<CoreMRChoice> => map_2<TemplateChoice, CoreMRChoice>((c: TemplateChoice): CoreMRChoice => toCoreMRChoice(item_1.ItemId, c), item_1.Choices), form.Items), empty_1<CoreMRTrigger>(), empty_1<CoreMRTag>());
419
+ return new CoreMRFormData(new CoreMRFormMetadata(form.FormId, form.Name, isNullOrEmpty(form.Description) ? undefined : form.Description, ~~toInt32(form.CurrentVersionId), 1, undefined, form.RequiresSignature, form.IsIntake, "", ""), map_2<TemplateItem, CoreMRItem>(toCoreMRItem, form.Items), collect<TemplateItem, CoreMRChoice>((item_1: TemplateItem): FSharpList<CoreMRChoice> => map_2<TemplateChoice, CoreMRChoice>((c: TemplateChoice): CoreMRChoice => toCoreMRChoice(item_1.ItemId, c), item_1.Choices), form.Items), empty<CoreMRTrigger>(), empty<CoreMRTag>());
430
420
  }
431
421
 
432
422
  /**
@@ -1,10 +1,10 @@
1
1
  import { map, unwrap, value as value_19, orElseWith, orElse, defaultArgWith as defaultArgWith_1, Option, defaultArg as defaultArg_1 } from "@fable-org/fable-library-js/Option.js";
2
- import { toArray as toArray_1, length as length_1, tryPick, filter, mapIndexed as mapIndexed_1, isEmpty, map as map_3, empty, ofArray as ofArray_1, ofSeq, fold, singleton, collect, tryFind, FSharpList } from "@fable-org/fable-library-js/List.js";
3
- import { toText, isNullOrEmpty, join, isNullOrWhiteSpace, printf, toConsole } from "@fable-org/fable-library-js/String.js";
2
+ import { exists, sortBy, toArray as toArray_1, length as length_1, tryPick, filter, mapIndexed as mapIndexed_1, isEmpty, map as map_3, empty, ofArray as ofArray_1, ofSeq, fold, singleton, collect, tryFind, FSharpList } from "@fable-org/fable-library-js/List.js";
3
+ import { isNullOrEmpty, toText, join, isNullOrWhiteSpace, printf, toConsole } from "@fable-org/fable-library-js/String.js";
4
4
  import { Auto_generateBoxedEncoder_437914C6, toString } from "../../Thoth.Json/packages/Thoth.Json/Encode.js";
5
5
  import { Spec_SingleChoiceInfo, Spec_ClinicalInstrumentInfo, Spec_FormClassification_$union, ClinicalPathway_StateType_$union, ClinicalPathway_TaskPriority_$union, ClinicalPathway_AlertSeverity_$union, ClinicalPathway_ReferralUrgency_$union, ClinicalPathway_ActionInfo_$union, ClinicalPathway_NavigateToFormAction, ClinicalPathway_ProblemAction, ClinicalPathway_AlertAction, ClinicalPathway_EducationAction, ClinicalPathway_ProcedureAction, ClinicalPathway_TestAction, ClinicalPathway_DocumentationAction, ClinicalPathway_FieldValueSource_$union, ClinicalPathway_SetFieldValueAction, ClinicalPathway_PrescriptionAction, ClinicalPathway_MedicationAction, ClinicalPathway_ReferralAction, Shared_FieldValue, Shared_FieldValue_$union, ClinicalPathway_ClinicalPathwaySpec, ClinicalPathway_PathRequirement, ClinicalPathway_ConstraintDefinition, ClinicalPathway_PathwayExecutionMode_SinglePathway, ClinicalPathway_SinglePathwayConfig, ClinicalPathway_SelectionStrategy_HighestPriority, ClinicalPathway_TransitionDefinition, ClinicalPathway_TransitionCondition_FieldCondition, Shared_ConditionValue_Single, ClinicalPathway_FieldEvaluator_Equals, Shared_TransitionKey, ClinicalPathway_StateType_Terminal, ClinicalPathway_TerminalInfo, ClinicalPathway_StateDefinition, ClinicalPathway_StateType_Action, ClinicalPathway_ActionInfo_Task, ClinicalPathway_TaskAction, ClinicalPathway_DueDate_Today, ClinicalPathway_TaskPriority_Medium, ClinicalPathway_TaskPriority_Low, ClinicalPathway_TaskPriority_High, Shared_StateKey, Spec_FieldType_PluginField, Spec_PluginFieldConfig, Spec_FieldType_Matrix, Spec_MatrixInfo, Spec_FormClassification_General, Spec_FormLifecycle_Blueprint, Spec_FieldType_Text, Spec_TextInfo, Spec_FieldType_CheckboxList, Spec_MultiChoiceInfo, Shared_FieldOptionKey, Spec_FieldType_Checkbox, Spec_BooleanInfo, Shared_FieldKey, Shared_FieldOption, Shared_FieldValue_Single, Shared_FieldValue_PluginData, Shared_PluginDataProperty, Shared_PluginPropertyKey, Shared_FieldValue_Matrix, Shared_MatrixAnswer, Shared_MatrixItemKey, Shared_FieldValue_Multiple, Shared_FieldAnswer, Spec_FormStep$1, Spec_FormField$1, Spec_FieldType_$union, Spec_FormSpec$1, Spec_FormSpec$1_$reflection, Spec_FieldType_$reflection } from "../FormSpec.js";
6
6
  import { Auto_generateBoxedDecoder_Z6670B51, fromString } from "../../Thoth.Json/packages/Thoth.Json/Decode.js";
7
- import { comparePrimitives, defaultOf, equals, createObj, stringHash, compare, IDisposable, disposeSafe, IEnumerator, getEnumerator, IMap, isArrayLike, uncurry2 } from "@fable-org/fable-library-js/Util.js";
7
+ import { comparePrimitives, int32ToString, int64ToString, defaultOf, equals, createObj, stringHash, compare, IDisposable, disposeSafe, IEnumerator, getEnumerator, IMap, isArrayLike, uncurry2 } from "@fable-org/fable-library-js/Util.js";
8
8
  import { FSharpResult$2_Ok, FSharpResult$2_Error, FSharpResult$2_$union } from "@fable-org/fable-library-js/Result.js";
9
9
  import { newGuid, parse, tryParse } from "@fable-org/fable-library-js/Guid.js";
10
10
  import { Union, FSharpRef } from "@fable-org/fable-library-js/Types.js";
@@ -22,8 +22,10 @@ import { now } from "@fable-org/fable-library-js/DateOffset.js";
22
22
  import { initializeExecution } from "../PathwayExecutor.js";
23
23
  import { List_distinct, distinct } from "@fable-org/fable-library-js/Seq2.js";
24
24
  import { encodeToFormAnswers, tryDecodeSourceMap as tryDecodeSourceMap_1 } from "../Integrations/Adapters/CorEMR/CoreMREncoder.js";
25
- import { CoreMRSourceMap } from "../Integrations/Adapters/CorEMR/CoreMRSourceMap.js";
25
+ import { CoreMRStepMap, CoreMRSourceMap_$reflection, CoreMRFieldAnchor, CoreMRChoiceAnchor, CoreMRSourceMap } from "../Integrations/Adapters/CorEMR/CoreMRSourceMap.js";
26
26
  import { CoreMRAnswer, CoreMRFormInsertRequest } from "../Integrations/Adapters/CorEMR/FormSpecToCoreMRInsert.js";
27
+ import { compare as compare_1 } from "@fable-org/fable-library-js/BigInt.js";
28
+ import { IntegrationProvenance } from "../Provenance.js";
27
29
 
28
30
  /**
29
31
  * Get value from Option or return default (SAFE - recommended)
@@ -1289,6 +1291,109 @@ export function getAllFieldKeys(formSpec: Spec_FormSpec$1<Spec_FieldType_$union>
1289
1291
  return toArray_1<string>(map_3<Spec_FormField$1<Spec_FieldType_$union>, string>((field: Spec_FormField$1<Spec_FieldType_$union>): string => getFieldKeyString(field.FieldKey), collect<Spec_FormStep$1<Spec_FieldType_$union>, Spec_FormField$1<Spec_FieldType_$union>>((step: Spec_FormStep$1<Spec_FieldType_$union>): FSharpList<Spec_FormField$1<Spec_FieldType_$union>> => step.Fields, formSpec.Steps)));
1290
1292
  }
1291
1293
 
1294
+ /**
1295
+ * Get choice score signal count (choices with non-zero scores) for a field with CoreMR provenance.
1296
+ * TypeScript: getFieldChoiceScoreSignal(fieldAnchor: CoreMRFieldAnchor | null) => number
1297
+ * Replaces ad-hoc filtering in UI components!
1298
+ */
1299
+ export function getFieldChoiceScoreSignal(fieldAnchor: Option<CoreMRFieldAnchor>): int32 {
1300
+ if (fieldAnchor == null) {
1301
+ return 0;
1302
+ }
1303
+ else {
1304
+ return length_1<CoreMRChoiceAnchor>(filter<CoreMRChoiceAnchor>((c: CoreMRChoiceAnchor): boolean => (compare_1(c.Score, 0n) > 0), value_19(fieldAnchor).Choices)) | 0;
1305
+ }
1306
+ }
1307
+
1308
+ /**
1309
+ * Get bitmask choice analysis table data for a field with CoreMR provenance.
1310
+ * TypeScript: getFieldBitmaskChoiceTable(fieldAnchor: CoreMRFieldAnchor | null) => {sequence: number, text: string, score: string, bitPosition: string | null, code: string | null}[]
1311
+ * THE SINGLE SOURCE OF TRUTH for choice breakdown tables!
1312
+ */
1313
+ export function getFieldBitmaskChoiceTable(fieldAnchor: Option<CoreMRFieldAnchor>): { bitPosition?: string, code?: string, score: string, sequence: int32, text: string }[] {
1314
+ if (fieldAnchor == null) {
1315
+ return [];
1316
+ }
1317
+ else {
1318
+ const collection: FSharpList<{ bitPosition?: string, code?: string, score: string, sequence: int32, text: string }> = map_3<CoreMRChoiceAnchor, { bitPosition?: string, code?: string, score: string, sequence: int32, text: string }>((choice: CoreMRChoiceAnchor): { bitPosition?: string, code?: string, score: string, sequence: int32, text: string } => {
1319
+ const score: string = int64ToString(choice.Score);
1320
+ return {
1321
+ bitPosition: unwrap(map<int32, string>(int32ToString, choice.BitPosition)),
1322
+ code: unwrap(choice.Code),
1323
+ score: score,
1324
+ sequence: choice.Sequence,
1325
+ text: choice.Text,
1326
+ };
1327
+ }, sortBy<CoreMRChoiceAnchor, int32>((c: CoreMRChoiceAnchor): int32 => c.Sequence, value_19(fieldAnchor).Choices, {
1328
+ Compare: comparePrimitives,
1329
+ }));
1330
+ return Array.from(collection);
1331
+ }
1332
+ }
1333
+
1334
+ /**
1335
+ * Get bitmask analysis summary for a field with CoreMR provenance.
1336
+ * TypeScript: getBitmaskChoiceAnalysis(fieldAnchor: CoreMRFieldAnchor | null) => {totalChoices: number, scoredChoices: number, hasBitPositions: boolean, fieldTypeInfo: string}
1337
+ * Comprehensive bitmask intelligence for debugging panels!
1338
+ */
1339
+ export function getBitmaskChoiceAnalysis(fieldAnchor: Option<CoreMRFieldAnchor>): { fieldTypeInfo: string, hasBitPositions: boolean, scoredChoices: int32, totalChoices: int32 } {
1340
+ if (fieldAnchor == null) {
1341
+ return {
1342
+ fieldTypeInfo: "No CoreMR anchor",
1343
+ hasBitPositions: false,
1344
+ scoredChoices: 0,
1345
+ totalChoices: 0,
1346
+ };
1347
+ }
1348
+ else {
1349
+ const anchor: CoreMRFieldAnchor = value_19(fieldAnchor);
1350
+ const totalChoices: int32 = length_1(anchor.Choices) | 0;
1351
+ const scoredChoices: int32 = length_1<CoreMRChoiceAnchor>(filter<CoreMRChoiceAnchor>((c: CoreMRChoiceAnchor): boolean => (compare_1(c.Score, 0n) > 0), anchor.Choices)) | 0;
1352
+ const hasBitPositions: boolean = exists<CoreMRChoiceAnchor>((c_1: CoreMRChoiceAnchor): boolean => (c_1.BitPosition != null), anchor.Choices);
1353
+ return {
1354
+ fieldTypeInfo: toText(printf("CoreMR ItemType %d (%s)"))(anchor.ItemTypeId)(anchor.Encoding.ValueEncoding),
1355
+ hasBitPositions: hasBitPositions,
1356
+ scoredChoices: scoredChoices,
1357
+ totalChoices: totalChoices,
1358
+ };
1359
+ }
1360
+ }
1361
+
1362
+ /**
1363
+ * Extract CoreMR field anchor from FormSpec provenance (if available).
1364
+ * TypeScript: getFieldCoreMRAnchor(formSpec: FormSpec, fieldKey: string) => CoreMRFieldAnchor | null
1365
+ * Safely decode provenance payload and find the field anchor.
1366
+ * Uses IDENTICAL decoding logic as F1 Studio BlueprintImporter!
1367
+ */
1368
+ export function getFieldCoreMRAnchor(formSpec: Spec_FormSpec$1<Spec_FieldType_$union>, fieldKeyString: string): Option<CoreMRFieldAnchor> {
1369
+ const matchValue: Option<IntegrationProvenance> = formSpec.Provenance;
1370
+ let matchResult: int32, provenance_1: IntegrationProvenance;
1371
+ if (matchValue != null) {
1372
+ if (value_19(matchValue).IntegrationKey === "coremr") {
1373
+ matchResult = 0;
1374
+ provenance_1 = value_19(matchValue);
1375
+ }
1376
+ else {
1377
+ matchResult = 1;
1378
+ }
1379
+ }
1380
+ else {
1381
+ matchResult = 1;
1382
+ }
1383
+ switch (matchResult) {
1384
+ case 0:
1385
+ try {
1386
+ const matchValue_1: FSharpResult$2_$union<CoreMRSourceMap, string> = fromString<CoreMRSourceMap>(uncurry2(Auto_generateBoxedDecoder_Z6670B51(CoreMRSourceMap_$reflection(), undefined, undefined)), provenance_1!.Payload);
1387
+ return (matchValue_1.tag === /* Error */ 1) ? undefined : tryFind<CoreMRFieldAnchor>((anchor: CoreMRFieldAnchor): boolean => (getFieldKeyString(anchor.FieldKey) === fieldKeyString), collect<CoreMRStepMap, CoreMRFieldAnchor>((step: CoreMRStepMap): FSharpList<CoreMRFieldAnchor> => step.FieldAnchors, matchValue_1.fields[0].Steps));
1388
+ }
1389
+ catch (matchValue_2: any) {
1390
+ return undefined;
1391
+ }
1392
+ default:
1393
+ return undefined;
1394
+ }
1395
+ }
1396
+
1292
1397
  /**
1293
1398
  * Get comprehensive validation telemetry - structure, data, and provenance validation.
1294
1399
  * TypeScript: getFullValidationTelemetry(formSpec: FormSpec, values: any) => ValidationTelemetry