@f1studio/form-spec 5.0.0-alpha.163 → 5.0.0-alpha.165
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.
- package/FormSpec.FS/BlueprintValidation.js +1 -1
- package/FormSpec.FS/BlueprintValidation.js.map +1 -1
- package/FormSpec.FS/Designer.js +1 -1
- package/FormSpec.FS/Designer.js.map +1 -1
- package/FormSpec.FS/FormSpec.d.ts +14 -1
- package/FormSpec.FS/FormSpec.d.ts.map +1 -1
- package/FormSpec.FS/FormSpec.js +56 -1
- package/FormSpec.FS/FormSpec.js.map +1 -1
- package/FormSpec.FS/FormSpecHelpers.js +1 -1
- package/FormSpec.FS/FormSpecHelpers.js.map +1 -1
- package/FormSpec.FS/FormSpecValues.js +1 -1
- package/FormSpec.FS/FormSpecValues.js.map +1 -1
- package/FormSpec.FS/Helpers.js +11 -11
- package/FormSpec.FS/Helpers.js.map +1 -1
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRAdapter.d.ts +13 -3
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRAdapter.d.ts.map +1 -1
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRAdapter.js +19 -13
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRAdapter.js.map +1 -1
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRFieldTypeMapper.d.ts +20 -0
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRFieldTypeMapper.d.ts.map +1 -1
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRFieldTypeMapper.js +20 -40
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRFieldTypeMapper.js.map +1 -1
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRFormSpecValidator.d.ts +21 -9
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRFormSpecValidator.d.ts.map +1 -1
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRFormSpecValidator.js +46 -25
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRFormSpecValidator.js.map +1 -1
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateMapper.d.ts +3 -4
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateMapper.d.ts.map +1 -1
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateMapper.js +93 -36
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateMapper.js.map +1 -1
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateToFormSpec.d.ts +33 -8
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateToFormSpec.d.ts.map +1 -1
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateToFormSpec.js +25 -29
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateToFormSpec.js.map +1 -1
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMREncoder.js.map +1 -1
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRSourceMap.d.ts +4 -1
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRSourceMap.d.ts.map +1 -1
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRSourceMap.js +4 -4
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRSourceMap.js.map +1 -1
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRTriggerEnrichment.js +1 -1
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRTriggerEnrichment.js.map +1 -1
- package/FormSpec.FS/Integrations/Adapters/CorEMR/FormSpecToCoreMRInsert.js +1 -1
- package/FormSpec.FS/Integrations/Adapters/CorEMR/FormSpecToCoreMRInsert.js.map +1 -1
- package/FormSpec.FS/Integrations/CorEMR/TemplateManifestDecoder.d.ts +40 -8
- package/FormSpec.FS/Integrations/CorEMR/TemplateManifestDecoder.d.ts.map +1 -1
- package/FormSpec.FS/Integrations/CorEMR/TemplateManifestDecoder.js +201 -22
- package/FormSpec.FS/Integrations/CorEMR/TemplateManifestDecoder.js.map +1 -1
- package/FormSpec.FS/Interop/FormSpec.Api.Helpers.js +4 -4
- package/FormSpec.FS/Interop/FormSpec.Api.Helpers.js.map +1 -1
- package/FormSpec.FS/Interop/FormSpec.Api.Option.d.ts +26 -2
- package/FormSpec.FS/Interop/FormSpec.Api.Option.d.ts.map +1 -1
- package/FormSpec.FS/Interop/FormSpec.Api.Option.js +77 -3
- package/FormSpec.FS/Interop/FormSpec.Api.Option.js.map +1 -1
- package/FormSpec.FS/Provenance.d.ts +20 -2
- package/FormSpec.FS/Provenance.d.ts.map +1 -1
- package/FormSpec.FS/Provenance.js +66 -3
- package/FormSpec.FS/Provenance.js.map +1 -1
- package/README.md +7 -7
- package/package.json +1 -1
- package/src/FormSpec.FS/BlueprintValidation.ts +1 -1
- package/src/FormSpec.FS/Designer.ts +1 -1
- package/src/FormSpec.FS/FormSpec.ts +32 -2
- package/src/FormSpec.FS/FormSpecHelpers.ts +1 -1
- package/src/FormSpec.FS/FormSpecValues.ts +1 -1
- package/src/FormSpec.FS/Helpers.ts +11 -11
- package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRAdapter.ts +25 -12
- package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRFieldTypeMapper.ts +41 -41
- package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRFormSpecValidator.ts +62 -30
- package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateMapper.ts +77 -30
- package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateToFormSpec.ts +52 -27
- package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRSourceMap.ts +7 -5
- package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRTriggerEnrichment.ts +1 -1
- package/src/FormSpec.FS/Integrations/Adapters/CorEMR/FormSpecToCoreMRInsert.ts +1 -1
- package/src/FormSpec.FS/Integrations/CorEMR/TemplateManifestDecoder.ts +160 -25
- package/src/FormSpec.FS/Interop/FormSpec.Api.Helpers.ts +4 -4
- package/src/FormSpec.FS/Interop/FormSpec.Api.Option.ts +63 -8
- package/src/FormSpec.FS/Provenance.ts +50 -4
|
@@ -30,7 +30,7 @@ export function buildFormSpecFromResultStepsMap(details: FormSpecMetadata, steps
|
|
|
30
30
|
})));
|
|
31
31
|
}, sortBy<[Values_StepOrder, FSharpMap<Shared_FieldKey, FieldDetails$1<Spec_FieldType_$union>>], int32>((tupledArg: [Values_StepOrder, FSharpMap<Shared_FieldKey, FieldDetails$1<Spec_FieldType_$union>>]): int32 => tupledArg[0].fields[0], toList<Values_StepOrder, FSharpMap<Shared_FieldKey, FieldDetails$1<Spec_FieldType_$union>>>(stepsMap), {
|
|
32
32
|
Compare: comparePrimitives,
|
|
33
|
-
})), empty<string>(), details.MaxScore, empty<string>(), false, false, undefined, Spec_FormLifecycle_Draft(newGuid()), undefined, undefined, undefined, Spec_FormClassification_General());
|
|
33
|
+
})), empty<string>(), details.MaxScore, undefined, empty<string>(), false, false, undefined, Spec_FormLifecycle_Draft(newGuid()), undefined, undefined, undefined, Spec_FormClassification_General());
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
/**
|
|
@@ -123,7 +123,7 @@ export function updateField<FieldType>(spec: Spec_FormSpec$1<FieldType>, fieldKe
|
|
|
123
123
|
else {
|
|
124
124
|
return step;
|
|
125
125
|
}
|
|
126
|
-
}, spec.Steps), spec.CategoryTags, spec.Score, spec.AssociatedCodes, spec.RequiresReview, spec.RequiresReviewAndApproval, spec.ClinicalPathway, spec.Lifecycle, spec.FilledMeta, spec.CustomData, spec.Provenance, spec.Classification);
|
|
126
|
+
}, spec.Steps), spec.CategoryTags, spec.Score, spec.VendorScore, spec.AssociatedCodes, spec.RequiresReview, spec.RequiresReviewAndApproval, spec.ClinicalPathway, spec.Lifecycle, spec.FilledMeta, spec.CustomData, spec.Provenance, spec.Classification);
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
/**
|
|
@@ -413,7 +413,7 @@ export function Helpers_FormSpecMutators_updateFormFieldInFormSpecStep<UserField
|
|
|
413
413
|
else {
|
|
414
414
|
return s;
|
|
415
415
|
}
|
|
416
|
-
}, formSpec.Steps), formSpec.CategoryTags, formSpec.Score, formSpec.AssociatedCodes, formSpec.RequiresReview, formSpec.RequiresReviewAndApproval, formSpec.ClinicalPathway, formSpec.Lifecycle, formSpec.FilledMeta, formSpec.CustomData, formSpec.Provenance, formSpec.Classification);
|
|
416
|
+
}, formSpec.Steps), formSpec.CategoryTags, formSpec.Score, formSpec.VendorScore, formSpec.AssociatedCodes, formSpec.RequiresReview, formSpec.RequiresReviewAndApproval, formSpec.ClinicalPathway, formSpec.Lifecycle, formSpec.FilledMeta, formSpec.CustomData, formSpec.Provenance, formSpec.Classification);
|
|
417
417
|
}
|
|
418
418
|
|
|
419
419
|
/**
|
|
@@ -427,7 +427,7 @@ export function Helpers_FormSpecMutators_updateFormStepInFormSpec<UserField>(for
|
|
|
427
427
|
else {
|
|
428
428
|
return s;
|
|
429
429
|
}
|
|
430
|
-
}, formSpec.Steps), formSpec.CategoryTags, formSpec.Score, formSpec.AssociatedCodes, formSpec.RequiresReview, formSpec.RequiresReviewAndApproval, formSpec.ClinicalPathway, formSpec.Lifecycle, formSpec.FilledMeta, formSpec.CustomData, formSpec.Provenance, formSpec.Classification);
|
|
430
|
+
}, formSpec.Steps), formSpec.CategoryTags, formSpec.Score, formSpec.VendorScore, formSpec.AssociatedCodes, formSpec.RequiresReview, formSpec.RequiresReviewAndApproval, formSpec.ClinicalPathway, formSpec.Lifecycle, formSpec.FilledMeta, formSpec.CustomData, formSpec.Provenance, formSpec.Classification);
|
|
431
431
|
}
|
|
432
432
|
|
|
433
433
|
/**
|
|
@@ -442,7 +442,7 @@ export function Helpers_FormSpecMutators_addFormFieldToStep<UserField>(formStep:
|
|
|
442
442
|
else {
|
|
443
443
|
return s;
|
|
444
444
|
}
|
|
445
|
-
}, formSpec.Steps), formSpec.CategoryTags, formSpec.Score, formSpec.AssociatedCodes, formSpec.RequiresReview, formSpec.RequiresReviewAndApproval, formSpec.ClinicalPathway, formSpec.Lifecycle, formSpec.FilledMeta, formSpec.CustomData, formSpec.Provenance, formSpec.Classification);
|
|
445
|
+
}, formSpec.Steps), formSpec.CategoryTags, formSpec.Score, formSpec.VendorScore, formSpec.AssociatedCodes, formSpec.RequiresReview, formSpec.RequiresReviewAndApproval, formSpec.ClinicalPathway, formSpec.Lifecycle, formSpec.FilledMeta, formSpec.CustomData, formSpec.Provenance, formSpec.Classification);
|
|
446
446
|
}
|
|
447
447
|
|
|
448
448
|
/**
|
|
@@ -456,7 +456,7 @@ export function Helpers_FormSpecMutators_removeFormFieldFromFormSpec<UserField>(
|
|
|
456
456
|
else {
|
|
457
457
|
return s;
|
|
458
458
|
}
|
|
459
|
-
}, formSpec.Steps), formSpec.CategoryTags, formSpec.Score, formSpec.AssociatedCodes, formSpec.RequiresReview, formSpec.RequiresReviewAndApproval, formSpec.ClinicalPathway, formSpec.Lifecycle, formSpec.FilledMeta, formSpec.CustomData, formSpec.Provenance, formSpec.Classification);
|
|
459
|
+
}, formSpec.Steps), formSpec.CategoryTags, formSpec.Score, formSpec.VendorScore, formSpec.AssociatedCodes, formSpec.RequiresReview, formSpec.RequiresReviewAndApproval, formSpec.ClinicalPathway, formSpec.Lifecycle, formSpec.FilledMeta, formSpec.CustomData, formSpec.Provenance, formSpec.Classification);
|
|
460
460
|
}
|
|
461
461
|
|
|
462
462
|
/**
|
|
@@ -489,7 +489,7 @@ export function Helpers_FormSpecMutators_moveFormFieldUpInFormSpec<UserField>(fo
|
|
|
489
489
|
else {
|
|
490
490
|
return s;
|
|
491
491
|
}
|
|
492
|
-
}, formSpec.Steps), formSpec.CategoryTags, formSpec.Score, formSpec.AssociatedCodes, formSpec.RequiresReview, formSpec.RequiresReviewAndApproval, formSpec.ClinicalPathway, formSpec.Lifecycle, formSpec.FilledMeta, formSpec.CustomData, formSpec.Provenance, formSpec.Classification);
|
|
492
|
+
}, formSpec.Steps), formSpec.CategoryTags, formSpec.Score, formSpec.VendorScore, formSpec.AssociatedCodes, formSpec.RequiresReview, formSpec.RequiresReviewAndApproval, formSpec.ClinicalPathway, formSpec.Lifecycle, formSpec.FilledMeta, formSpec.CustomData, formSpec.Provenance, formSpec.Classification);
|
|
493
493
|
}
|
|
494
494
|
|
|
495
495
|
/**
|
|
@@ -515,7 +515,7 @@ export function Helpers_FormSpecMutators_moveFormFieldDownInFormSpec<UserField>(
|
|
|
515
515
|
else {
|
|
516
516
|
return s;
|
|
517
517
|
}
|
|
518
|
-
}, formSpec.Steps), formSpec.CategoryTags, formSpec.Score, formSpec.AssociatedCodes, formSpec.RequiresReview, formSpec.RequiresReviewAndApproval, formSpec.ClinicalPathway, formSpec.Lifecycle, formSpec.FilledMeta, formSpec.CustomData, formSpec.Provenance, formSpec.Classification);
|
|
518
|
+
}, formSpec.Steps), formSpec.CategoryTags, formSpec.Score, formSpec.VendorScore, formSpec.AssociatedCodes, formSpec.RequiresReview, formSpec.RequiresReviewAndApproval, formSpec.ClinicalPathway, formSpec.Lifecycle, formSpec.FilledMeta, formSpec.CustomData, formSpec.Provenance, formSpec.Classification);
|
|
519
519
|
}
|
|
520
520
|
|
|
521
521
|
/**
|
|
@@ -535,7 +535,7 @@ export function Helpers_FormSpecMutators_moveFieldByKeyToPositionInFormStepSpec<
|
|
|
535
535
|
else {
|
|
536
536
|
return s;
|
|
537
537
|
}
|
|
538
|
-
}, formSpec.Steps), formSpec.CategoryTags, formSpec.Score, formSpec.AssociatedCodes, formSpec.RequiresReview, formSpec.RequiresReviewAndApproval, formSpec.ClinicalPathway, formSpec.Lifecycle, formSpec.FilledMeta, formSpec.CustomData, formSpec.Provenance, formSpec.Classification);
|
|
538
|
+
}, formSpec.Steps), formSpec.CategoryTags, formSpec.Score, formSpec.VendorScore, formSpec.AssociatedCodes, formSpec.RequiresReview, formSpec.RequiresReviewAndApproval, formSpec.ClinicalPathway, formSpec.Lifecycle, formSpec.FilledMeta, formSpec.CustomData, formSpec.Provenance, formSpec.Classification);
|
|
539
539
|
}
|
|
540
540
|
else {
|
|
541
541
|
return formSpec;
|
|
@@ -558,7 +558,7 @@ export function Helpers_FormSpecMutators_moveFormStepUpInFormSpec<UserField>(for
|
|
|
558
558
|
}
|
|
559
559
|
}, formSpec.Steps), {
|
|
560
560
|
Compare: comparePrimitives,
|
|
561
|
-
})), formSpec.CategoryTags, formSpec.Score, formSpec.AssociatedCodes, formSpec.RequiresReview, formSpec.RequiresReviewAndApproval, formSpec.ClinicalPathway, formSpec.Lifecycle, formSpec.FilledMeta, formSpec.CustomData, formSpec.Provenance, formSpec.Classification);
|
|
561
|
+
})), formSpec.CategoryTags, formSpec.Score, formSpec.VendorScore, formSpec.AssociatedCodes, formSpec.RequiresReview, formSpec.RequiresReviewAndApproval, formSpec.ClinicalPathway, formSpec.Lifecycle, formSpec.FilledMeta, formSpec.CustomData, formSpec.Provenance, formSpec.Classification);
|
|
562
562
|
}
|
|
563
563
|
|
|
564
564
|
/**
|
|
@@ -577,14 +577,14 @@ export function Helpers_FormSpecMutators_moveFormStepDownInFormSpec<UserField>(f
|
|
|
577
577
|
}
|
|
578
578
|
}, formSpec.Steps), {
|
|
579
579
|
Compare: comparePrimitives,
|
|
580
|
-
})), formSpec.CategoryTags, formSpec.Score, formSpec.AssociatedCodes, formSpec.RequiresReview, formSpec.RequiresReviewAndApproval, formSpec.ClinicalPathway, formSpec.Lifecycle, formSpec.FilledMeta, formSpec.CustomData, formSpec.Provenance, formSpec.Classification);
|
|
580
|
+
})), formSpec.CategoryTags, formSpec.Score, formSpec.VendorScore, formSpec.AssociatedCodes, formSpec.RequiresReview, formSpec.RequiresReviewAndApproval, formSpec.ClinicalPathway, formSpec.Lifecycle, formSpec.FilledMeta, formSpec.CustomData, formSpec.Provenance, formSpec.Classification);
|
|
581
581
|
}
|
|
582
582
|
|
|
583
583
|
/**
|
|
584
584
|
* Removes a form step from a FormSpec.
|
|
585
585
|
*/
|
|
586
586
|
export function Helpers_FormSpecMutators_removeFormStepFromFormSpec<UserField>(formStepOrder: int32, formSpec: Spec_FormSpec$1<UserField>): Spec_FormSpec$1<UserField> {
|
|
587
|
-
return new Spec_FormSpec$1(formSpec.Id, formSpec.Code, formSpec.Title, formSpec.Abstract, formSpec.Version, formSpec.FormSpecVersion, mapIndexed<Spec_FormStep$1<UserField>, Spec_FormStep$1<UserField>>((i: int32, s_1: Spec_FormStep$1<UserField>): Spec_FormStep$1<UserField> => (new Spec_FormStep$1(i + 1, s_1.StepLabel, s_1.Fields)), filter<Spec_FormStep$1<UserField>>((s: Spec_FormStep$1<UserField>): boolean => (s.StepOrder !== formStepOrder), formSpec.Steps)), formSpec.CategoryTags, formSpec.Score, formSpec.AssociatedCodes, formSpec.RequiresReview, formSpec.RequiresReviewAndApproval, formSpec.ClinicalPathway, formSpec.Lifecycle, formSpec.FilledMeta, formSpec.CustomData, formSpec.Provenance, formSpec.Classification);
|
|
587
|
+
return new Spec_FormSpec$1(formSpec.Id, formSpec.Code, formSpec.Title, formSpec.Abstract, formSpec.Version, formSpec.FormSpecVersion, mapIndexed<Spec_FormStep$1<UserField>, Spec_FormStep$1<UserField>>((i: int32, s_1: Spec_FormStep$1<UserField>): Spec_FormStep$1<UserField> => (new Spec_FormStep$1(i + 1, s_1.StepLabel, s_1.Fields)), filter<Spec_FormStep$1<UserField>>((s: Spec_FormStep$1<UserField>): boolean => (s.StepOrder !== formStepOrder), formSpec.Steps)), formSpec.CategoryTags, formSpec.Score, formSpec.VendorScore, formSpec.AssociatedCodes, formSpec.RequiresReview, formSpec.RequiresReviewAndApproval, formSpec.ClinicalPathway, formSpec.Lifecycle, formSpec.FilledMeta, formSpec.CustomData, formSpec.Provenance, formSpec.Classification);
|
|
588
588
|
}
|
|
589
589
|
|
|
590
590
|
/**
|
|
@@ -608,7 +608,7 @@ export function Helpers_FormSpecTransformers_flattenSpecSteps<UserField>(formSpe
|
|
|
608
608
|
break;
|
|
609
609
|
}
|
|
610
610
|
};
|
|
611
|
-
return new Spec_FormSpec$1(formSpec.Id, formSpec.Code, formSpec.Title, formSpec.Abstract, formSpec.Version, formSpec.FormSpecVersion, singleton(new Spec_FormStep$1(1, "Complete Form", flatten(formSpec.Steps, empty<Spec_FormField$1<UserField>>()))), formSpec.CategoryTags, formSpec.Score, formSpec.AssociatedCodes, formSpec.RequiresReview, formSpec.RequiresReviewAndApproval, formSpec.ClinicalPathway, formSpec.Lifecycle, formSpec.FilledMeta, formSpec.CustomData, formSpec.Provenance, formSpec.Classification);
|
|
611
|
+
return new Spec_FormSpec$1(formSpec.Id, formSpec.Code, formSpec.Title, formSpec.Abstract, formSpec.Version, formSpec.FormSpecVersion, singleton(new Spec_FormStep$1(1, "Complete Form", flatten(formSpec.Steps, empty<Spec_FormField$1<UserField>>()))), formSpec.CategoryTags, formSpec.Score, formSpec.VendorScore, formSpec.AssociatedCodes, formSpec.RequiresReview, formSpec.RequiresReviewAndApproval, formSpec.ClinicalPathway, formSpec.Lifecycle, formSpec.FilledMeta, formSpec.CustomData, formSpec.Provenance, formSpec.Classification);
|
|
612
612
|
}
|
|
613
613
|
|
|
614
614
|
/**
|
|
@@ -3,40 +3,53 @@ import { exists, length, isEmpty, FSharpList, cons, singleton, empty } from "@fa
|
|
|
3
3
|
import { FSharpResult$2_$union, FSharpResult$2_Ok, FSharpResult$2_Error } from "@fable-org/fable-library-js/Result.js";
|
|
4
4
|
import { Spec_FieldType_$union, Spec_FormSpec$1 } from "../../../FormSpec.js";
|
|
5
5
|
import { ListMetadata, convertWithMapAndProvenance } from "./CoreMRSourceMap.js";
|
|
6
|
+
import { ImportOrigin } from "../../../Provenance.js";
|
|
6
7
|
import { CoreMRChoice, CoreMRItem, CoreMRFormData } from "../../CorEMR/CoreMRTypes.js";
|
|
7
8
|
import { defaultArg, Option } from "@fable-org/fable-library-js/Option.js";
|
|
8
9
|
import { FSharpMap } from "@fable-org/fable-library-js/Map.js";
|
|
9
10
|
import { int32 } from "@fable-org/fable-library-js/Int32.js";
|
|
10
11
|
import { ElementTypeInfo } from "./CorEMRElementTypeMap.js";
|
|
12
|
+
import { FormSystemAdapter$1, FormMetadata, FormSystemFeatures } from "../FormSystemAdapter.js";
|
|
11
13
|
import { buildReport } from "./CorEMRSemanticReportBuilder.js";
|
|
12
14
|
import { nonHeadingItems } from "./CorEMRSectioning.js";
|
|
13
15
|
import { compare } from "@fable-org/fable-library-js/BigInt.js";
|
|
14
16
|
import { int32ToString } from "@fable-org/fable-library-js/Util.js";
|
|
15
|
-
import { FormSystemAdapter$1, FormSystemFeatures, FormMetadata } from "../FormSystemAdapter.js";
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
19
|
* Convert with list metadata (IsScored, EncounterTypes) from FormListItem.
|
|
19
20
|
* Use when importing from fetch-coremr-forms where FormListItem is available.
|
|
20
21
|
* When elementTypes is Some (from bridge templates endpoint), use it for ValueEncoding; else fallback to CorEMRElementTypeMap.
|
|
22
|
+
* ⭐ `origin` is REQUIRED — the tenant and database this import is being made FROM. Without them the
|
|
23
|
+
* provenance names a product and nothing else, and its ids resolve to no database.
|
|
21
24
|
*/
|
|
22
|
-
export function convertWithListMetadata(formData: CoreMRFormData, listMetadata: ListMetadata, elementTypes: Option<FSharpMap<int32, ElementTypeInfo>>): FSharpResult$2_$union<Spec_FormSpec$1<Spec_FieldType_$union>, FSharpList<string>> {
|
|
25
|
+
export function convertWithListMetadata(origin: ImportOrigin, formData: CoreMRFormData, listMetadata: ListMetadata, elementTypes: Option<FSharpMap<int32, ElementTypeInfo>>): FSharpResult$2_$union<Spec_FormSpec$1<Spec_FieldType_$union>, FSharpList<string>> {
|
|
23
26
|
let arg: string;
|
|
24
27
|
try {
|
|
25
|
-
return FSharpResult$2_Ok<Spec_FormSpec$1<Spec_FieldType_$union>, FSharpList<string>>(convertWithMapAndProvenance(formData, listMetadata, elementTypes));
|
|
28
|
+
return FSharpResult$2_Ok<Spec_FormSpec$1<Spec_FieldType_$union>, FSharpList<string>>(convertWithMapAndProvenance(origin, formData, listMetadata, elementTypes));
|
|
26
29
|
}
|
|
27
30
|
catch (ex: any) {
|
|
28
31
|
return FSharpResult$2_Error<Spec_FormSpec$1<Spec_FieldType_$union>, FSharpList<string>>(cons((arg = ex.message, toText(printf("CorEMR conversion failed: %s"))(arg)), (ex.stack == null) ? empty<string>() : singleton(" Stack: " + ex.stack)));
|
|
29
32
|
}
|
|
30
33
|
}
|
|
31
34
|
|
|
32
|
-
export const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
35
|
+
export const supportedFeatures: FormSystemFeatures = new FormSystemFeatures(true, true, true, true, true);
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* CorEMR adapter implementation.
|
|
39
|
+
* ⭐ A FUNCTION OF ITS ORIGIN, not a value. There is no adapter that does not know which tenant and
|
|
40
|
+
* which database it is importing from — that is what makes a site-less import unrepresentable rather
|
|
41
|
+
* than merely discouraged.
|
|
42
|
+
*/
|
|
43
|
+
export function adapterFor(origin: ImportOrigin): FormSystemAdapter$1<CoreMRFormData> {
|
|
44
|
+
return new FormSystemAdapter$1("coremr", (template: CoreMRFormData): FSharpResult$2_$union<Spec_FormSpec$1<Spec_FieldType_$union>, FSharpList<string>> => {
|
|
45
|
+
let arg: string;
|
|
46
|
+
try {
|
|
47
|
+
return FSharpResult$2_Ok<Spec_FormSpec$1<Spec_FieldType_$union>, FSharpList<string>>(convertWithMapAndProvenance(origin, template, undefined, undefined));
|
|
48
|
+
}
|
|
49
|
+
catch (ex: any) {
|
|
50
|
+
return FSharpResult$2_Error<Spec_FormSpec$1<Spec_FieldType_$union>, FSharpList<string>>(cons((arg = ex.message, toText(printf("CorEMR conversion failed: %s"))(arg)), (ex.stack == null) ? empty<string>() : singleton(" Stack: " + ex.stack)));
|
|
51
|
+
}
|
|
52
|
+
}, buildReport, (template_2: CoreMRFormData): FSharpResult$2_$union<void, FSharpList<string>> => (isEmpty(template_2.Items) ? FSharpResult$2_Error<void, FSharpList<string>>(singleton("Template has no items")) : (isNullOrWhiteSpace(template_2.Metadata.FormName) ? FSharpResult$2_Error<void, FSharpList<string>>(singleton("Template has no name")) : FSharpResult$2_Ok<void, FSharpList<string>>(undefined))), (template_3: CoreMRFormData): FormMetadata => (new FormMetadata(template_3.Metadata.FormName, defaultArg(template_3.Metadata.Description, ""), length<CoreMRItem>(nonHeadingItems(template_3.Items)), exists<CoreMRChoice>((c: CoreMRChoice): boolean => (compare(c.Score, 0n) > 0), template_3.Choices), !isEmpty(template_3.Triggers), int32ToString(template_3.Metadata.VersionNumber))), supportedFeatures);
|
|
53
|
+
}
|
|
41
54
|
|
|
42
55
|
//# sourceMappingURL=CorEMRAdapter.ts.map
|
|
@@ -2,7 +2,7 @@ import { isNullOrWhiteSpace } from "@fable-org/fable-library-js/String.js";
|
|
|
2
2
|
import { Helpers_generateDeterministicGuidRaw, Helpers_canonicalizeFieldKey } from "../../../Helpers.js";
|
|
3
3
|
import { int32 } from "@fable-org/fable-library-js/Int32.js";
|
|
4
4
|
import { CoreMRChoice, CoreMRItem } from "../../CorEMR/CoreMRTypes.js";
|
|
5
|
-
import { Spec_FormField$1, Spec_FieldType_$union, Spec_FieldType_UnsupportedField, Spec_UnsupportedFieldInfo, Spec_FieldType_PluginField, Spec_PluginFieldConfig, Spec_FieldType_Message, Spec_MessageInfo, Spec_MessageType_Info,
|
|
5
|
+
import { Spec_FormField$1, Spec_FieldType_$union, Spec_FieldType_UnsupportedField, Spec_UnsupportedFieldInfo, Spec_FieldType_PluginField, Spec_PluginFieldConfig, Spec_FieldType_Message, Spec_MessageInfo, Spec_MessageType_Info, Spec_FieldType_Signature, Spec_SignatureInfo, Spec_FieldType_DateTimeLocal, Spec_FieldType_Date, Spec_FieldType_CheckboxList, Spec_MultiChoiceInfo, Spec_FieldType_Dropdown, Spec_FieldType_Radio, Spec_SingleChoiceInfo, Spec_FieldType_TextArea, Spec_FieldType_Text, Spec_TextInfo, Shared_FieldOption, Shared_FieldOptionKey, Shared_FieldKey } from "../../../FormSpec.js";
|
|
6
6
|
import { isEmpty, ofArray, FSharpList, sortBy, map } from "@fable-org/fable-library-js/List.js";
|
|
7
7
|
import { comparePrimitives } from "@fable-org/fable-library-js/Util.js";
|
|
8
8
|
import { getElementTypeInfo } from "./CorEMRElementTypeMap.js";
|
|
@@ -45,62 +45,62 @@ export function isNeedsDocumentationType(item: CoreMRItem): boolean {
|
|
|
45
45
|
return getElementTypeInfo(item.ItemTypeId).IsNeedsDocumentation;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
/**
|
|
49
|
+
* CoreMR item → FormSpec `FieldType`, decided by THE CONTROL THE SITE STATES.
|
|
50
|
+
*
|
|
51
|
+
* ⚖️ RE-KEYED 2026-09-23 (FLIP-9 Part D). This was `match item.ItemTypeId with` over 24 hardcoded
|
|
52
|
+
* integers — 24 arms producing 11 distinct outcomes, 13 of them byte-identical duplicates — and
|
|
53
|
+
* `item.ItemTypeName` was never read, so the site's own vocabulary was DECORATIVE. Even at
|
|
54
|
+
* 5.5.0+9704, which states `form_item_types` in full, a type-61 item still became whatever the
|
|
55
|
+
* constant said.
|
|
56
|
+
*
|
|
57
|
+
* ⭐ `ItemTypeName` now carries THE CONTROL: stated by the site at 9704 (`form_item_types.php_class`)
|
|
58
|
+
* and declared by conduit at 10245, which ships no such table. ⇒ **No CoreMR integer appears in this
|
|
59
|
+
* function.** A second EHR supplies controls and needs no new branch here.
|
|
60
|
+
*
|
|
61
|
+
* 🔴 WHAT THIS FUNCTION DELIBERATELY DOES NOT DECIDE — measured, conduit `audit/260923-1655`:
|
|
62
|
+
* • whether several options may be chosen — that is the ITEM's own stated `item_choices.score`
|
|
63
|
+
* (FLIP-8), never the type. A "multi-select" type produces ONE answer row per cell 99.6% of
|
|
64
|
+
* the time.
|
|
65
|
+
* • whether it offers options at all — STRUCTURAL: `hasChoices`, below, from the item's own rows.
|
|
66
|
+
* 21 items of type 20 state none, and 73 of 132 type-140 items state some.
|
|
67
|
+
*/
|
|
48
68
|
export function mapFieldType(item: CoreMRItem, choices: FSharpList<CoreMRChoice>): Spec_FieldType_$union {
|
|
49
69
|
const mappedChoices: FSharpList<Shared_FieldOption> = mapChoices(choices);
|
|
50
70
|
const hasChoices: boolean = !isEmpty(mappedChoices);
|
|
51
|
-
const matchValue:
|
|
71
|
+
const matchValue: string = item.ItemTypeName;
|
|
52
72
|
switch (matchValue) {
|
|
53
|
-
case
|
|
73
|
+
case "ShortAnswer":
|
|
54
74
|
return Spec_FieldType_Text(new Spec_TextInfo(undefined));
|
|
55
|
-
case
|
|
75
|
+
case "NoteEssay":
|
|
56
76
|
return Spec_FieldType_TextArea(new Spec_TextInfo(undefined));
|
|
57
|
-
case
|
|
58
|
-
|
|
59
|
-
case 21:
|
|
60
|
-
return Spec_FieldType_Radio(new Spec_SingleChoiceInfo(mappedChoices));
|
|
61
|
-
case 25:
|
|
62
|
-
return Spec_FieldType_Dropdown(new Spec_SingleChoiceInfo(mappedChoices));
|
|
63
|
-
case 26:
|
|
64
|
-
return Spec_FieldType_CheckboxList(new Spec_MultiChoiceInfo(mappedChoices));
|
|
65
|
-
case 30:
|
|
66
|
-
return Spec_FieldType_Radio(new Spec_SingleChoiceInfo(hasChoices ? mappedChoices : buildImplicitYesNoOptions(item)));
|
|
67
|
-
case 31:
|
|
77
|
+
case "MultipleChoice":
|
|
78
|
+
case "MultipleChoicePlusNotes":
|
|
68
79
|
return Spec_FieldType_Radio(new Spec_SingleChoiceInfo(hasChoices ? mappedChoices : buildImplicitYesNoOptions(item)));
|
|
69
|
-
case
|
|
80
|
+
case "DropDown":
|
|
81
|
+
case "DropDownPlusNotes":
|
|
70
82
|
return Spec_FieldType_Dropdown(new Spec_SingleChoiceInfo(mappedChoices));
|
|
71
|
-
case
|
|
72
|
-
|
|
73
|
-
case 41:
|
|
83
|
+
case "CheckboxSeries":
|
|
84
|
+
case "CheckboxSeriesPlusNotes":
|
|
74
85
|
return Spec_FieldType_CheckboxList(new Spec_MultiChoiceInfo(mappedChoices));
|
|
75
|
-
case
|
|
86
|
+
case "DateField":
|
|
76
87
|
return Spec_FieldType_Date(new Spec_TextInfo(undefined));
|
|
77
|
-
case
|
|
78
|
-
return Spec_FieldType_Signature(new Spec_SignatureInfo(undefined));
|
|
79
|
-
case 60:
|
|
88
|
+
case "DateFieldWithTime":
|
|
80
89
|
return Spec_FieldType_DateTimeLocal(new Spec_TextInfo(undefined));
|
|
81
|
-
case
|
|
90
|
+
case "SignatureAndDate":
|
|
91
|
+
case "SignatureAndDateWithTime":
|
|
82
92
|
return Spec_FieldType_Signature(new Spec_SignatureInfo(undefined));
|
|
83
|
-
case
|
|
84
|
-
throw new Error(
|
|
85
|
-
case
|
|
86
|
-
|
|
87
|
-
case 121:
|
|
93
|
+
case "FormHeading":
|
|
94
|
+
throw new Error(`a heading reached mapFieldType (item ${item.ItemId}); headings become Steps and must be filtered by CorEMRSectioning first`);
|
|
95
|
+
case "FormInstructions":
|
|
96
|
+
case "DisplayFormId":
|
|
88
97
|
return Spec_FieldType_Message(new Spec_MessageInfo("", Spec_MessageType_Info(), item.Label, undefined));
|
|
89
|
-
case
|
|
98
|
+
case "PatientVitals":
|
|
90
99
|
return Spec_FieldType_PluginField(new Spec_PluginFieldConfig("Fable.Form.Simple.Bulma.Fields.VitalsField", undefined, undefined));
|
|
91
|
-
case
|
|
92
|
-
case 132:
|
|
93
|
-
return Spec_FieldType_Message(new Spec_MessageInfo("", Spec_MessageType_Info(), item.Label, undefined));
|
|
94
|
-
case 133:
|
|
95
|
-
case 134:
|
|
96
|
-
case 135:
|
|
97
|
-
return Spec_FieldType_Message(new Spec_MessageInfo("", Spec_MessageType_Info(), item.Label, undefined));
|
|
98
|
-
case 140:
|
|
100
|
+
case "AllergyFinder":
|
|
99
101
|
return Spec_FieldType_PluginField(new Spec_PluginFieldConfig("Fable.Form.Simple.Bulma.Fields.AllergyFinderField", undefined, undefined));
|
|
100
|
-
case 143:
|
|
101
|
-
return Spec_FieldType_CheckboxList(new Spec_MultiChoiceInfo(mappedChoices));
|
|
102
102
|
default:
|
|
103
|
-
return Spec_FieldType_UnsupportedField(new Spec_UnsupportedFieldInfo(item.ItemId, defaultArg(item.Code, ""),
|
|
103
|
+
return Spec_FieldType_UnsupportedField(new Spec_UnsupportedFieldInfo(item.ItemId, defaultArg(item.Code, ""), item.ItemTypeId));
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
|
|
@@ -2,16 +2,17 @@ import { toString, Record, Union } from "@fable-org/fable-library-js/Types.js";
|
|
|
2
2
|
import { int32 } from "@fable-org/fable-library-js/Int32.js";
|
|
3
3
|
import { defaultArg, value as value_3, map as map_1, Option } from "@fable-org/fable-library-js/Option.js";
|
|
4
4
|
import { record_type, list_type, union_type, option_type, bool_type, string_type, int32_type, TypeInfo } from "@fable-org/fable-library-js/Reflection.js";
|
|
5
|
-
import { isEmpty, filter,
|
|
5
|
+
import { isEmpty, filter, singleton as singleton_1, empty as empty_1, ofSeq, choose, collect, sortBy, map, sumBy, length, FSharpList } from "@fable-org/fable-library-js/List.js";
|
|
6
6
|
import { IDisposable, disposeSafe, IEnumerator, getEnumerator, compare, int32ToString, comparePrimitives, numberHash, IComparable, IEquatable } from "@fable-org/fable-library-js/Util.js";
|
|
7
7
|
import { HeadingItem, detectHeadings } from "./CorEMRSectioning.js";
|
|
8
8
|
import { CoreMRTrigger, CoreMRFormData, CoreMRFormMetadata, CoreMRChoice, CoreMRItem } from "../../CorEMR/CoreMRTypes.js";
|
|
9
|
-
import { ClinicalPathway_ClinicalPathwaySpec,
|
|
9
|
+
import { ClinicalPathway_ClinicalPathwaySpec, Spec_VendorScore, Spec_VendorScoreBand, Spec_SingleChoiceInfo, Spec_MultiChoiceInfo, Spec_FormField$1, Shared_FieldKey, Spec_FormSpec$1, Spec_FieldType_$union, Spec_FormStep$1 } from "../../../FormSpec.js";
|
|
10
10
|
import { tryFind, FSharpMap, ofList } from "@fable-org/fable-library-js/Map.js";
|
|
11
11
|
import { List_groupBy } from "@fable-org/fable-library-js/Seq2.js";
|
|
12
|
-
import {
|
|
12
|
+
import { join } from "@fable-org/fable-library-js/String.js";
|
|
13
13
|
import { empty, singleton, append, delay, toList } from "@fable-org/fable-library-js/Seq.js";
|
|
14
14
|
import { getElementTypeInfo } from "./CorEMRElementTypeMap.js";
|
|
15
|
+
import { FormScoring, ScoringLabel } from "../../CorEMR/TemplateManifestDecoder.js";
|
|
15
16
|
import { FSharpResult$2_$union, FSharpResult$2_Ok, FSharpResult$2_Error } from "@fable-org/fable-library-js/Result.js";
|
|
16
17
|
|
|
17
18
|
export type ValidationError_$union =
|
|
@@ -44,7 +45,7 @@ export type ValidationError_$cases = {
|
|
|
44
45
|
7: ["MissingStep", [string]],
|
|
45
46
|
8: ["ChoiceCountMismatch", [int32, string, int32, int32]],
|
|
46
47
|
9: ["RequiredFieldMismatch", [int32, string, boolean, boolean]],
|
|
47
|
-
10: ["ScoreMismatch", [
|
|
48
|
+
10: ["ScoreMismatch", [string, Option<string>]],
|
|
48
49
|
11: ["TagCountMismatch", [int32, int32]],
|
|
49
50
|
12: ["PathwayMissing", [int32]],
|
|
50
51
|
13: ["PathwayStateCountInvalid", [string, int32, int32]],
|
|
@@ -93,7 +94,7 @@ export function ValidationError_RequiredFieldMismatch(itemId: int32, itemLabel:
|
|
|
93
94
|
return new ValidationError<9>(9, [itemId, itemLabel, expected, actual]);
|
|
94
95
|
}
|
|
95
96
|
|
|
96
|
-
export function ValidationError_ScoreMismatch(expected:
|
|
97
|
+
export function ValidationError_ScoreMismatch(expected: string, actual: Option<string>) {
|
|
97
98
|
return new ValidationError<10>(10, [expected, actual]);
|
|
98
99
|
}
|
|
99
100
|
|
|
@@ -131,7 +132,7 @@ export class ValidationError<Tag extends keyof ValidationError_$cases> extends U
|
|
|
131
132
|
}
|
|
132
133
|
|
|
133
134
|
export function ValidationError_$reflection(): TypeInfo {
|
|
134
|
-
return union_type("FormSpec.Integrations.CorEMR.CorEMRFormSpecValidator.ValidationError", [], ValidationError, () => [[["expected", int32_type], ["actual", int32_type]], [["expected", int32_type], ["actual", int32_type]], [["step", string_type], ["expected", int32_type], ["actual", int32_type]], [["field", string_type], ["expected", string_type], ["actual", string_type]], [["itemId", int32_type], ["itemLabel", string_type]], [["itemId", int32_type], ["itemType", string_type], ["reason", string_type]], [["itemId", int32_type], ["heading", string_type]], [["heading", string_type]], [["itemId", int32_type], ["itemLabel", string_type], ["expected", int32_type], ["actual", int32_type]], [["itemId", int32_type], ["itemLabel", string_type], ["expected", bool_type], ["actual", bool_type]], [["expected",
|
|
135
|
+
return union_type("FormSpec.Integrations.CorEMR.CorEMRFormSpecValidator.ValidationError", [], ValidationError, () => [[["expected", int32_type], ["actual", int32_type]], [["expected", int32_type], ["actual", int32_type]], [["step", string_type], ["expected", int32_type], ["actual", int32_type]], [["field", string_type], ["expected", string_type], ["actual", string_type]], [["itemId", int32_type], ["itemLabel", string_type]], [["itemId", int32_type], ["itemType", string_type], ["reason", string_type]], [["itemId", int32_type], ["heading", string_type]], [["heading", string_type]], [["itemId", int32_type], ["itemLabel", string_type], ["expected", int32_type], ["actual", int32_type]], [["itemId", int32_type], ["itemLabel", string_type], ["expected", bool_type], ["actual", bool_type]], [["expected", string_type], ["actual", option_type(string_type)]], [["expected", int32_type], ["actual", int32_type]], [["triggerCount", int32_type]], [["pathwayId", string_type], ["expected", int32_type], ["actual", int32_type]], [["pathwayId", string_type], ["expected", int32_type], ["actual", int32_type]], [["triggerId", int32_type], ["expected", int32_type], ["actual", int32_type]], [["triggerId", int32_type], ["expected", int32_type], ["actual", int32_type]]]);
|
|
135
136
|
}
|
|
136
137
|
|
|
137
138
|
export class ValidationResult extends Record implements IEquatable<ValidationResult>, IComparable<ValidationResult> {
|
|
@@ -213,14 +214,10 @@ export function FormSpecValidator_getChoicesPerItem(choices: FSharpList<CoreMRCh
|
|
|
213
214
|
});
|
|
214
215
|
}
|
|
215
216
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
return sumBy<CoreMRChoice, int32>((c: CoreMRChoice): int32 => ~~toInt32(c.Score), choices, {
|
|
221
|
-
GetZero: (): int32 => 0,
|
|
222
|
-
Add: (x: int32, y: int32): int32 => (x + y),
|
|
223
|
-
});
|
|
217
|
+
function FormSpecValidator_describeScale(name: string, bands: FSharpList<[string, int32]>): string {
|
|
218
|
+
return `${name} [${join(", ", map<[string, int32], string>((tupledArg: [string, int32]): string => (`${tupledArg[0]}>=${tupledArg[1]}`), sortBy<[string, int32], int32>((tuple: [string, int32]): int32 => tuple[1], bands, {
|
|
219
|
+
Compare: comparePrimitives,
|
|
220
|
+
})))}]`;
|
|
224
221
|
}
|
|
225
222
|
|
|
226
223
|
/**
|
|
@@ -398,27 +395,62 @@ export function FormSpecValidator_validateRequiredFields(coreMR: CoreMRFormData,
|
|
|
398
395
|
}
|
|
399
396
|
|
|
400
397
|
/**
|
|
401
|
-
*
|
|
398
|
+
* Does the blueprint carry exactly the scale CoreMR stated for this form?
|
|
399
|
+
*
|
|
400
|
+
* ⭐ THE ORACLE IS THE SITE, NOT US. `scoring` is the form's own `form_scores` row as conduit
|
|
401
|
+
* published it — the scale's name and its bands. This function only asks whether the
|
|
402
|
+
* blueprint says the same thing.
|
|
403
|
+
*
|
|
404
|
+
* It catches, by construction, the defect that shipped for months and that no validator saw:
|
|
405
|
+
* a blueprint carrying bands nobody stated. ⛔ It must never grow a branch that computes a
|
|
406
|
+
* scale of its own to compare against — that is precisely how it went blind the first time.
|
|
407
|
+
*
|
|
408
|
+
* | the site | the blueprint | verdict |
|
|
409
|
+
* |---|---|---|
|
|
410
|
+
* | states a scale | carries the same one | ✅ |
|
|
411
|
+
* | states a scale | carries a different one, or none | 🚨 `ScoreMismatch` |
|
|
412
|
+
* | states none | carries none | ✅ |
|
|
413
|
+
* | states none | carries one | 🚨 `ScoreMismatch` — invented out of nothing |
|
|
402
414
|
*/
|
|
403
|
-
export function FormSpecValidator_validateScoring(
|
|
404
|
-
const
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
return singleton_1(ValidationError_ScoreMismatch(expectedScore, score.MaxScore));
|
|
415
|
+
export function FormSpecValidator_validateScoring(scoring: Option<FormScoring>, formSpec: Spec_FormSpec$1<Spec_FieldType_$union>): FSharpList<ValidationError_$union> {
|
|
416
|
+
const statedText: Option<string> = map_1<FormScoring, string>((s: FormScoring): string => FormSpecValidator_describeScale(s.ScoreName, map<ScoringLabel, [string, int32]>((l: ScoringLabel): [string, int32] => ([l.Name, l.Min] as [string, int32]), s.Labels)), scoring);
|
|
417
|
+
const carriedText: Option<string> = map_1<Spec_VendorScore, string>((sc: Spec_VendorScore): string => FormSpecValidator_describeScale(sc.ScaleName, map<Spec_VendorScoreBand, [string, int32]>((b: Spec_VendorScoreBand): [string, int32] => ([b.Label, b.Min] as [string, int32]), sc.Bands)), formSpec.VendorScore);
|
|
418
|
+
let matchResult: int32, carried_1: string, stated_1: string, carried_2: Option<string>, stated_2: string, carried_3: string;
|
|
419
|
+
if (statedText != null) {
|
|
420
|
+
if (carriedText != null) {
|
|
421
|
+
if (value_3(statedText) === value_3(carriedText)) {
|
|
422
|
+
matchResult = 1;
|
|
423
|
+
carried_1 = value_3(carriedText);
|
|
424
|
+
stated_1 = value_3(statedText);
|
|
414
425
|
}
|
|
415
426
|
else {
|
|
416
|
-
|
|
427
|
+
matchResult = 2;
|
|
428
|
+
carried_2 = carriedText;
|
|
429
|
+
stated_2 = value_3(statedText);
|
|
417
430
|
}
|
|
418
431
|
}
|
|
432
|
+
else {
|
|
433
|
+
matchResult = 2;
|
|
434
|
+
carried_2 = carriedText;
|
|
435
|
+
stated_2 = value_3(statedText);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
else if (carriedText != null) {
|
|
439
|
+
matchResult = 3;
|
|
440
|
+
carried_3 = value_3(carriedText);
|
|
419
441
|
}
|
|
420
442
|
else {
|
|
421
|
-
|
|
443
|
+
matchResult = 0;
|
|
444
|
+
}
|
|
445
|
+
switch (matchResult) {
|
|
446
|
+
case 0:
|
|
447
|
+
return empty_1<ValidationError_$union>();
|
|
448
|
+
case 1:
|
|
449
|
+
return empty_1<ValidationError_$union>();
|
|
450
|
+
case 2:
|
|
451
|
+
return singleton_1(ValidationError_ScoreMismatch(stated_2!, carried_2!));
|
|
452
|
+
default:
|
|
453
|
+
return singleton_1(ValidationError_ScoreMismatch("(CoreMR states no scale for this form)", carried_3!));
|
|
422
454
|
}
|
|
423
455
|
}
|
|
424
456
|
|
|
@@ -478,9 +510,9 @@ export function FormSpecValidator_validatePathways(triggers: FSharpList<CoreMRTr
|
|
|
478
510
|
/**
|
|
479
511
|
* Main validation function
|
|
480
512
|
*/
|
|
481
|
-
export function FormSpecValidator_validateConversion(coreMR: CoreMRFormData, formSpec: Spec_FormSpec$1<Spec_FieldType_$union>): FSharpResult$2_$union<ValidationResult, string> {
|
|
513
|
+
export function FormSpecValidator_validateConversion(scoring: Option<FormScoring>, coreMR: CoreMRFormData, formSpec: Spec_FormSpec$1<Spec_FieldType_$union>): FSharpResult$2_$union<ValidationResult, string> {
|
|
482
514
|
try {
|
|
483
|
-
const allErrors: FSharpList<ValidationError_$union> = toList<ValidationError_$union>(delay<ValidationError_$union>((): Iterable<ValidationError_$union> => append<ValidationError_$union>(FormSpecValidator_validateMetadata(coreMR.Metadata, formSpec), delay<ValidationError_$union>((): Iterable<ValidationError_$union> => append<ValidationError_$union>(FormSpecValidator_validateCounts(coreMR, formSpec), delay<ValidationError_$union>((): Iterable<ValidationError_$union> => append<ValidationError_$union>(FormSpecValidator_validateChoices(coreMR, formSpec), delay<ValidationError_$union>((): Iterable<ValidationError_$union> => append<ValidationError_$union>(FormSpecValidator_validateRequiredFields(coreMR, formSpec), delay<ValidationError_$union>((): Iterable<ValidationError_$union> => append<ValidationError_$union>(FormSpecValidator_validateScoring(
|
|
515
|
+
const allErrors: FSharpList<ValidationError_$union> = toList<ValidationError_$union>(delay<ValidationError_$union>((): Iterable<ValidationError_$union> => append<ValidationError_$union>(FormSpecValidator_validateMetadata(coreMR.Metadata, formSpec), delay<ValidationError_$union>((): Iterable<ValidationError_$union> => append<ValidationError_$union>(FormSpecValidator_validateCounts(coreMR, formSpec), delay<ValidationError_$union>((): Iterable<ValidationError_$union> => append<ValidationError_$union>(FormSpecValidator_validateChoices(coreMR, formSpec), delay<ValidationError_$union>((): Iterable<ValidationError_$union> => append<ValidationError_$union>(FormSpecValidator_validateRequiredFields(coreMR, formSpec), delay<ValidationError_$union>((): Iterable<ValidationError_$union> => append<ValidationError_$union>(FormSpecValidator_validateScoring(scoring, formSpec), delay<ValidationError_$union>((): Iterable<ValidationError_$union> => append<ValidationError_$union>(FormSpecValidator_validateTags(coreMR, formSpec), delay<ValidationError_$union>((): Iterable<ValidationError_$union> => FormSpecValidator_validatePathways(coreMR.Triggers, formSpec.ClinicalPathway)))))))))))))));
|
|
484
516
|
return FSharpResult$2_Ok<ValidationResult, string>(new ValidationResult(isEmpty(allErrors), allErrors, empty_1<ValidationError_$union>(), FormSpecValidator_createSummary(coreMR, formSpec)));
|
|
485
517
|
}
|
|
486
518
|
catch (ex: any) {
|
|
@@ -1,41 +1,93 @@
|
|
|
1
1
|
import { FSharpRef, Record } from "@fable-org/fable-library-js/Types.js";
|
|
2
|
-
import {
|
|
2
|
+
import { comparePrimitives, int32ToString, IComparable, IEquatable } from "@fable-org/fable-library-js/Util.js";
|
|
3
3
|
import { record_type, string_type, TypeInfo } from "@fable-org/fable-library-js/Reflection.js";
|
|
4
|
-
import { FSharpSet__Contains, contains, FSharpSet, ofSeq } from "@fable-org/fable-library-js/Set.js";
|
|
5
4
|
import { tryParse, int32 } from "@fable-org/fable-library-js/Int32.js";
|
|
6
5
|
import { Spec_FormClassification_$union, Spec_FormClassification_General, Spec_FormClassification_Screening, Spec_FormClassification_Intake, Spec_FormClassification_ClinicalInstrument, Spec_ClinicalInstrumentInfo } from "../../../FormSpec.js";
|
|
7
|
-
import { bind, orElse, map as map_1,
|
|
6
|
+
import { bind, orElse, map as map_1, defaultArg, Option, value as value_5 } from "@fable-org/fable-library-js/Option.js";
|
|
8
7
|
import { isNullOrEmpty } from "@fable-org/fable-library-js/String.js";
|
|
9
8
|
import { int64, toInt32 } from "@fable-org/fable-library-js/BigInt.js";
|
|
10
9
|
import { CoreMRFormDetail, CoreMRTag, CoreMRTrigger, CoreMRTriggerEvent, CoreMRTriggerCondition, CoreMRChoice, CoreMRItem, CoreMRFormMetadata } from "../../CorEMR/CoreMRTypes.js";
|
|
11
10
|
import { empty, choose, item as item_3, length, mapIndexed, sortBy, collect, FSharpList, isEmpty, map } from "@fable-org/fable-library-js/List.js";
|
|
12
|
-
import { FSharpMap,
|
|
13
|
-
import { ElementTypeInfo, getElementTypeInfo } from "./CorEMRElementTypeMap.js";
|
|
11
|
+
import { FSharpMap, tryFind } from "@fable-org/fable-library-js/Map.js";
|
|
14
12
|
import { TemplateForm, ItemTrigger, TriggerAction, TriggerCondition, TemplateChoice, TemplateItem } from "../../CorEMR/TemplateManifestDecoder.js";
|
|
13
|
+
import { FSharpSet__Contains, FSharpSet, ofSeq } from "@fable-org/fable-library-js/Set.js";
|
|
15
14
|
import { normalizeChoiceScores } from "../../../BitmaskHelpers.js";
|
|
16
15
|
|
|
17
16
|
export class BridgeElementTypeInfo extends Record implements IEquatable<BridgeElementTypeInfo>, IComparable<BridgeElementTypeInfo> {
|
|
18
|
-
readonly
|
|
19
|
-
readonly
|
|
20
|
-
|
|
21
|
-
constructor(Code: string, ValueEncoding: string, TextFieldRole: string) {
|
|
17
|
+
readonly Label: string;
|
|
18
|
+
readonly Control: string;
|
|
19
|
+
constructor(Label: string, Control: string) {
|
|
22
20
|
super();
|
|
23
|
-
this.
|
|
24
|
-
this.
|
|
25
|
-
this.TextFieldRole = TextFieldRole;
|
|
21
|
+
this.Label = Label;
|
|
22
|
+
this.Control = Control;
|
|
26
23
|
}
|
|
27
24
|
}
|
|
28
25
|
|
|
29
26
|
export function BridgeElementTypeInfo_$reflection(): TypeInfo {
|
|
30
|
-
return record_type("FormSpec.Integrations.CorEMR.CorEMRTemplateMapper.BridgeElementTypeInfo", [], BridgeElementTypeInfo, () => [["
|
|
27
|
+
return record_type("FormSpec.Integrations.CorEMR.CorEMRTemplateMapper.BridgeElementTypeInfo", [], BridgeElementTypeInfo, () => [["Label", string_type], ["Control", string_type]]);
|
|
31
28
|
}
|
|
32
29
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
30
|
+
function carriesTextOrDate(control: string): [boolean, boolean] {
|
|
31
|
+
let matchResult: int32, c_3: string;
|
|
32
|
+
switch (control) {
|
|
33
|
+
case "DateField":
|
|
34
|
+
case "DateFieldWithTime": {
|
|
35
|
+
matchResult = 0;
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
case "SignatureAndDate":
|
|
39
|
+
case "SignatureAndDateWithTime": {
|
|
40
|
+
matchResult = 1;
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
case "ShortAnswer":
|
|
44
|
+
case "NoteEssay": {
|
|
45
|
+
matchResult = 2;
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
case "PatientVitals": {
|
|
49
|
+
if (control.endsWith("PlusNotes")) {
|
|
50
|
+
matchResult = 3;
|
|
51
|
+
c_3 = control;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
matchResult = 4;
|
|
55
|
+
}
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
case "AllergyFinder": {
|
|
59
|
+
if (control.endsWith("PlusNotes")) {
|
|
60
|
+
matchResult = 3;
|
|
61
|
+
c_3 = control;
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
matchResult = 4;
|
|
65
|
+
}
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
default:
|
|
69
|
+
if (control.endsWith("PlusNotes")) {
|
|
70
|
+
matchResult = 3;
|
|
71
|
+
c_3 = control;
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
matchResult = 5;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
switch (matchResult) {
|
|
78
|
+
case 0:
|
|
79
|
+
return [true, true] as [boolean, boolean];
|
|
80
|
+
case 1:
|
|
81
|
+
return [true, true] as [boolean, boolean];
|
|
82
|
+
case 2:
|
|
83
|
+
return [true, false] as [boolean, boolean];
|
|
84
|
+
case 3:
|
|
85
|
+
return [true, false] as [boolean, boolean];
|
|
86
|
+
case 4:
|
|
87
|
+
return [true, false] as [boolean, boolean];
|
|
88
|
+
default:
|
|
89
|
+
return [false, false] as [boolean, boolean];
|
|
90
|
+
}
|
|
39
91
|
}
|
|
40
92
|
|
|
41
93
|
/**
|
|
@@ -99,19 +151,14 @@ export function mapFormClassification(formCategory: Option<string>, instrumentTy
|
|
|
99
151
|
export function mapNewTemplateToCoreMRDetail(elementTypes: FSharpMap<int32, BridgeElementTypeInfo>, template: TemplateForm): CoreMRFormDetail {
|
|
100
152
|
const metadata: CoreMRFormMetadata = new CoreMRFormMetadata(template.FormId, template.Name, isNullOrEmpty(template.Description) ? undefined : template.Description, ~~toInt32(template.CurrentVersionId), 1, undefined, template.RequiresSignature, template.IsIntake, template.FormCode, "");
|
|
101
153
|
const items: FSharpList<CoreMRItem> = map<TemplateItem, CoreMRItem>((item: TemplateItem): CoreMRItem => {
|
|
102
|
-
let
|
|
154
|
+
let info: BridgeElementTypeInfo;
|
|
103
155
|
const itemTypeId: int32 = item.Type | 0;
|
|
104
|
-
const value: BridgeElementTypeInfo = new BridgeElementTypeInfo(`
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}), value);
|
|
109
|
-
const patternInput: [boolean, boolean] = hasTextHasDateFromBridge(info_1.TextFieldRole);
|
|
110
|
-
return new CoreMRItem(item.ItemId, item.Sequence, item.NestingLevel, item.SequenceText, item.Type, info_1.Code, !isEmpty(item.Choices), patternInput[0], patternInput[1], item.Text, item.IsRequired, item.GenderRequired, map_1<int32, string>(int32ToString, item.Highlight), item.Code, item.Uuid, undefined, undefined, 0, 0, undefined);
|
|
156
|
+
const value: BridgeElementTypeInfo = new BridgeElementTypeInfo(`unresolved item kind ${itemTypeId}`, `unresolved_${itemTypeId}`);
|
|
157
|
+
info = defaultArg(tryFind<int32, BridgeElementTypeInfo>(itemTypeId, elementTypes), value);
|
|
158
|
+
const patternInput: [boolean, boolean] = carriesTextOrDate(info.Control);
|
|
159
|
+
return new CoreMRItem(item.ItemId, item.Sequence, item.NestingLevel, item.SequenceText, item.Type, info.Control, !isEmpty(item.Choices), patternInput[0], patternInput[1], item.Text, item.IsRequired, item.GenderRequired, map_1<int32, string>(int32ToString, item.Highlight), item.Code, item.Uuid, undefined, undefined, 0, 0, undefined);
|
|
111
160
|
}, template.Items);
|
|
112
|
-
const multiSelectTypes: FSharpSet<int32> =
|
|
113
|
-
Compare: comparePrimitives,
|
|
114
|
-
}) : ofSeq<int32>(keys<int32, BridgeElementTypeInfo>(filter<int32, BridgeElementTypeInfo>((_arg: int32, info_2: BridgeElementTypeInfo): boolean => contains<string>(info_2.Code, multiSelectCodes), elementTypes)), {
|
|
161
|
+
const multiSelectTypes: FSharpSet<int32> = ofSeq([26, 40, 41, 143], {
|
|
115
162
|
Compare: comparePrimitives,
|
|
116
163
|
});
|
|
117
164
|
return new CoreMRFormDetail(metadata, items, collect<TemplateItem, CoreMRChoice>((item_1: TemplateItem): FSharpList<CoreMRChoice> => {
|