@f1studio/form-spec 5.0.0-alpha.167 → 5.0.0-alpha.169
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.d.ts +6 -3
- package/FormSpec.FS/BlueprintValidation.d.ts.map +1 -1
- package/FormSpec.FS/BlueprintValidation.js +39 -15
- package/FormSpec.FS/BlueprintValidation.js.map +1 -1
- package/FormSpec.FS/Designer.d.ts.map +1 -1
- package/FormSpec.FS/Designer.js +1 -1
- package/FormSpec.FS/Designer.js.map +1 -1
- package/FormSpec.FS/FormSpec.d.ts +108 -58
- package/FormSpec.FS/FormSpec.d.ts.map +1 -1
- package/FormSpec.FS/FormSpec.js +319 -129
- package/FormSpec.FS/FormSpec.js.map +1 -1
- package/FormSpec.FS/FormSpecHelpers.d.ts.map +1 -1
- package/FormSpec.FS/FormSpecHelpers.js +1 -1
- package/FormSpec.FS/FormSpecHelpers.js.map +1 -1
- package/FormSpec.FS/FormSpecValues.d.ts.map +1 -1
- package/FormSpec.FS/FormSpecValues.js +5 -2
- package/FormSpec.FS/FormSpecValues.js.map +1 -1
- package/FormSpec.FS/Helpers.d.ts.map +1 -1
- package/FormSpec.FS/Helpers.js +14 -9
- package/FormSpec.FS/Helpers.js.map +1 -1
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRFieldTypeMapper.d.ts.map +1 -1
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRFieldTypeMapper.js +1 -1
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRFieldTypeMapper.js.map +1 -1
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRFormSpecValidator.d.ts +1 -1
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRFormSpecValidator.d.ts.map +1 -1
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRFormSpecValidator.js +1 -1
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRFormSpecValidator.js.map +1 -1
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRSectioning.d.ts +3 -3
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRSectioning.d.ts.map +1 -1
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRSectioning.js +7 -5
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRSectioning.js.map +1 -1
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRSemanticReportBuilder.d.ts.map +1 -1
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRSemanticReportBuilder.js +11 -10
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRSemanticReportBuilder.js.map +1 -1
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRStepsBuilder.d.ts.map +1 -1
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRStepsBuilder.js +1 -9
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRStepsBuilder.js.map +1 -1
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateMapper.d.ts +11 -4
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateMapper.d.ts.map +1 -1
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateMapper.js +30 -28
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateMapper.js.map +1 -1
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateToFormSpec.d.ts +3 -9
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateToFormSpec.d.ts.map +1 -1
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateToFormSpec.js +4 -31
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateToFormSpec.js.map +1 -1
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMREncoder.d.ts.map +1 -1
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMREncoder.js +2 -6
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMREncoder.js.map +1 -1
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRImportPipeline.d.ts +45 -0
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRImportPipeline.d.ts.map +1 -0
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRImportPipeline.js +141 -0
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRImportPipeline.js.map +1 -0
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRImporterAnalysis.d.ts +326 -0
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRImporterAnalysis.d.ts.map +1 -0
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRImporterAnalysis.js +1743 -0
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRImporterAnalysis.js.map +1 -0
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRSourceMap.d.ts +8 -8
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRSourceMap.d.ts.map +1 -1
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRSourceMap.js +6 -6
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRSourceMap.js.map +1 -1
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRTriggerEnrichment.d.ts +21 -15
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRTriggerEnrichment.d.ts.map +1 -1
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRTriggerEnrichment.js +83 -80
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRTriggerEnrichment.js.map +1 -1
- package/FormSpec.FS/Integrations/CorEMR/CoreMRPathwayMapper.d.ts +51 -0
- package/FormSpec.FS/Integrations/CorEMR/CoreMRPathwayMapper.d.ts.map +1 -0
- package/FormSpec.FS/Integrations/CorEMR/CoreMRPathwayMapper.js +939 -0
- package/FormSpec.FS/Integrations/CorEMR/CoreMRPathwayMapper.js.map +1 -0
- package/FormSpec.FS/Integrations/CorEMR/CoreMRTypes.d.ts +2 -17
- package/FormSpec.FS/Integrations/CorEMR/CoreMRTypes.d.ts.map +1 -1
- package/FormSpec.FS/Integrations/CorEMR/CoreMRTypes.js +1 -66
- package/FormSpec.FS/Integrations/CorEMR/{TemplateManifestDecoder.d.ts → FormTemplateDecoder.d.ts} +53 -45
- package/FormSpec.FS/Integrations/CorEMR/FormTemplateDecoder.d.ts.map +1 -0
- package/FormSpec.FS/Integrations/CorEMR/{TemplateManifestDecoder.js → FormTemplateDecoder.js} +544 -254
- package/FormSpec.FS/Integrations/CorEMR/FormTemplateDecoder.js.map +1 -0
- package/FormSpec.FS/Integrations/CorEMR/FormTemplateDomainDecoder.d.ts +7 -0
- package/FormSpec.FS/Integrations/CorEMR/FormTemplateDomainDecoder.d.ts.map +1 -0
- package/FormSpec.FS/Integrations/CorEMR/FormTemplateDomainDecoder.js +280 -0
- package/FormSpec.FS/Integrations/CorEMR/FormTemplateDomainDecoder.js.map +1 -0
- package/FormSpec.FS/Interop/FormSpec.Api.Helpers.d.ts +16 -4
- package/FormSpec.FS/Interop/FormSpec.Api.Helpers.d.ts.map +1 -1
- package/FormSpec.FS/Interop/FormSpec.Api.Helpers.js +63 -18
- package/FormSpec.FS/Interop/FormSpec.Api.Helpers.js.map +1 -1
- package/FormSpec.FS/Interop/FormSpec.Api.Option.d.ts +4 -4
- package/FormSpec.FS/Interop/FormSpec.Api.Option.d.ts.map +1 -1
- package/FormSpec.FS/Interop/FormSpec.Api.Option.js +2 -2
- package/FormSpec.FS/Interop/FormSpec.Api.Option.js.map +1 -1
- package/FormSpec.FS/PathwayDataExtractor.d.ts.map +1 -1
- package/FormSpec.FS/PathwayDataExtractor.js +39 -18
- package/FormSpec.FS/PathwayDataExtractor.js.map +1 -1
- package/FormSpec.FS/PathwayExecutor.d.ts +10 -10
- package/FormSpec.FS/PathwayExecutor.d.ts.map +1 -1
- package/FormSpec.FS/PathwayExecutor.js +14 -14
- package/FormSpec.FS/PathwayExecutor.js.map +1 -1
- package/FormSpec.FS/PathwayValidator.d.ts.map +1 -1
- package/FormSpec.FS/PathwayValidator.js +8 -5
- package/FormSpec.FS/PathwayValidator.js.map +1 -1
- package/FormSpec.FS/Provenance.d.ts +15 -7
- package/FormSpec.FS/Provenance.d.ts.map +1 -1
- package/FormSpec.FS/Provenance.js +11 -11
- package/FormSpec.FS/Provenance.js.map +1 -1
- package/FormSpec.FS/Renderers/FormSpecMarkdownRenderer.d.ts.map +1 -1
- package/FormSpec.FS/Renderers/FormSpecMarkdownRenderer.js +16 -7
- package/FormSpec.FS/Renderers/FormSpecMarkdownRenderer.js.map +1 -1
- package/FormSpec.FS/Renderers/MermaidRenderer.d.ts.map +1 -1
- package/FormSpec.FS/Renderers/MermaidRenderer.js +4 -8
- package/FormSpec.FS/Renderers/MermaidRenderer.js.map +1 -1
- package/FormSpec.FS/Renderers/PathwayRenderers.d.ts.map +1 -1
- package/FormSpec.FS/Renderers/PathwayRenderers.js +5 -4
- package/FormSpec.FS/Renderers/PathwayRenderers.js.map +1 -1
- package/FormSpec.FS/TriggerActionDto.d.ts +32 -21
- package/FormSpec.FS/TriggerActionDto.d.ts.map +1 -1
- package/FormSpec.FS/TriggerActionDto.js +247 -61
- package/FormSpec.FS/TriggerActionDto.js.map +1 -1
- package/README.md +7 -7
- package/package.json +1 -1
- package/plugins/allergyfinder/src/AllergyFinderField.d.ts.map +1 -1
- package/plugins/allergyfinder/src/AllergyFinderField.js +2 -2
- package/plugins/allergyfinder/src/AllergyFinderField.js.map +1 -1
- package/plugins/bmi/src/BMIField.d.ts.map +1 -1
- package/plugins/bmi/src/BMIField.js +21 -15
- package/plugins/bmi/src/BMIField.js.map +1 -1
- package/plugins/demographics/src/DemographicsField.d.ts.map +1 -1
- package/plugins/demographics/src/DemographicsField.js +4 -4
- package/plugins/demographics/src/DemographicsField.js.map +1 -1
- package/plugins/likert/src/LikertField.d.ts.map +1 -1
- package/plugins/likert/src/LikertField.js +40 -35
- package/plugins/likert/src/LikertField.js.map +1 -1
- package/plugins/signature/src/SignatureField.d.ts.map +1 -1
- package/plugins/signature/src/SignatureField.js +4 -3
- package/plugins/signature/src/SignatureField.js.map +1 -1
- package/plugins/vitals/src/VitalsField.d.ts.map +1 -1
- package/plugins/vitals/src/VitalsField.js +4 -4
- package/plugins/vitals/src/VitalsField.js.map +1 -1
- package/src/FormSpec.FS/BlueprintValidation.ts +55 -24
- package/src/FormSpec.FS/Designer.ts +2 -2
- package/src/FormSpec.FS/FormSpec.ts +223 -100
- package/src/FormSpec.FS/FormSpecHelpers.ts +2 -2
- package/src/FormSpec.FS/FormSpecValues.ts +6 -3
- package/src/FormSpec.FS/Helpers.ts +16 -11
- package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRFieldTypeMapper.ts +2 -2
- package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRFormSpecValidator.ts +3 -3
- package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRSectioning.ts +10 -8
- package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRSemanticReportBuilder.ts +6 -5
- package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRStepsBuilder.ts +1 -10
- package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateMapper.ts +35 -30
- package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateToFormSpec.ts +7 -26
- package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMREncoder.ts +2 -6
- package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRImportPipeline.ts +115 -0
- package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRImporterAnalysis.ts +1059 -0
- package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRSourceMap.ts +10 -10
- package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRTriggerEnrichment.ts +61 -88
- package/src/FormSpec.FS/Integrations/CorEMR/CoreMRPathwayMapper.ts +926 -0
- package/src/FormSpec.FS/Integrations/CorEMR/CoreMRTypes.ts +3 -37
- package/src/FormSpec.FS/Integrations/CorEMR/FormTemplateDecoder.ts +1284 -0
- package/src/FormSpec.FS/Integrations/CorEMR/FormTemplateDomainDecoder.ts +287 -0
- package/src/FormSpec.FS/Interop/FormSpec.Api.Helpers.ts +76 -25
- package/src/FormSpec.FS/Interop/FormSpec.Api.Option.ts +6 -6
- package/src/FormSpec.FS/PathwayDataExtractor.ts +40 -20
- package/src/FormSpec.FS/PathwayExecutor.ts +26 -26
- package/src/FormSpec.FS/PathwayValidator.ts +8 -5
- package/src/FormSpec.FS/Provenance.ts +23 -15
- package/src/FormSpec.FS/Renderers/FormSpecMarkdownRenderer.ts +18 -8
- package/src/FormSpec.FS/Renderers/MermaidRenderer.ts +6 -10
- package/src/FormSpec.FS/Renderers/PathwayRenderers.ts +5 -5
- package/src/FormSpec.FS/TriggerActionDto.ts +247 -74
- package/src/plugins/allergyfinder/src/AllergyFinderField.ts +3 -3
- package/src/plugins/bmi/src/BMIField.ts +12 -5
- package/src/plugins/demographics/src/DemographicsField.ts +5 -5
- package/src/plugins/likert/src/LikertField.ts +16 -11
- package/src/plugins/signature/src/SignatureField.ts +4 -3
- package/src/plugins/vitals/src/VitalsField.ts +5 -5
- package/src/vye-os-contracts-fs/src/Core/Ids.ts +8 -8
- package/src/vye-os-contracts-fs/src/CoreMR/FormTemplate.ts +715 -0
- package/vye-os-contracts-fs/src/Core/Ids.d.ts +4 -4
- package/vye-os-contracts-fs/src/Core/Ids.d.ts.map +1 -1
- package/vye-os-contracts-fs/src/Core/Ids.js +18 -18
- package/vye-os-contracts-fs/src/CoreMR/FormTemplate.d.ts +310 -0
- package/vye-os-contracts-fs/src/CoreMR/FormTemplate.d.ts.map +1 -0
- package/vye-os-contracts-fs/src/CoreMR/FormTemplate.js +1242 -0
- package/vye-os-contracts-fs/src/CoreMR/FormTemplate.js.map +1 -0
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTriggerConverter.d.ts +0 -69
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTriggerConverter.d.ts.map +0 -1
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTriggerConverter.js +0 -447
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTriggerConverter.js.map +0 -1
- package/FormSpec.FS/Integrations/CorEMR/ItemTriggerConverter.d.ts +0 -19
- package/FormSpec.FS/Integrations/CorEMR/ItemTriggerConverter.d.ts.map +0 -1
- package/FormSpec.FS/Integrations/CorEMR/ItemTriggerConverter.js +0 -643
- package/FormSpec.FS/Integrations/CorEMR/ItemTriggerConverter.js.map +0 -1
- package/FormSpec.FS/Integrations/CorEMR/TemplateManifestDecoder.d.ts.map +0 -1
- package/FormSpec.FS/Integrations/CorEMR/TemplateManifestDecoder.js.map +0 -1
- package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTriggerConverter.ts +0 -412
- package/src/FormSpec.FS/Integrations/CorEMR/ItemTriggerConverter.ts +0 -588
- package/src/FormSpec.FS/Integrations/CorEMR/TemplateManifestDecoder.ts +0 -1054
|
@@ -0,0 +1,939 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
get combineConditions () {
|
|
13
|
+
return combineConditions;
|
|
14
|
+
},
|
|
15
|
+
get convertAction () {
|
|
16
|
+
return convertAction;
|
|
17
|
+
},
|
|
18
|
+
get convertCondition () {
|
|
19
|
+
return convertCondition;
|
|
20
|
+
},
|
|
21
|
+
get convertFormTriggersToPathway () {
|
|
22
|
+
return convertFormTriggersToPathway;
|
|
23
|
+
},
|
|
24
|
+
get convertOperator () {
|
|
25
|
+
return convertOperator;
|
|
26
|
+
},
|
|
27
|
+
get convertTiming () {
|
|
28
|
+
return convertTiming;
|
|
29
|
+
},
|
|
30
|
+
get convertTriggerToPathway () {
|
|
31
|
+
return convertTriggerToPathway;
|
|
32
|
+
},
|
|
33
|
+
get generateActionLabel () {
|
|
34
|
+
return generateActionLabel;
|
|
35
|
+
},
|
|
36
|
+
get generateEvaluationLabel () {
|
|
37
|
+
return generateEvaluationLabel;
|
|
38
|
+
},
|
|
39
|
+
get liveTriggers () {
|
|
40
|
+
return liveTriggers;
|
|
41
|
+
},
|
|
42
|
+
get refusalFor () {
|
|
43
|
+
return refusalFor;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
const _Helpers = require("../../Helpers.js");
|
|
47
|
+
const _FormTemplate = require("../../../vye-os-contracts-fs/src/CoreMR/FormTemplate.js");
|
|
48
|
+
const _List = require("@fable-org/fable-library-js/List.js");
|
|
49
|
+
const _Util = require("@fable-org/fable-library-js/Util.js");
|
|
50
|
+
const _Option = require("@fable-org/fable-library-js/Option.js");
|
|
51
|
+
const _Int32 = require("@fable-org/fable-library-js/Int32.js");
|
|
52
|
+
const _FormSpec = require("../../FormSpec.js");
|
|
53
|
+
const _RegExp = require("@fable-org/fable-library-js/RegExp.js");
|
|
54
|
+
const _Map = require("@fable-org/fable-library-js/Map.js");
|
|
55
|
+
const _String = require("@fable-org/fable-library-js/String.js");
|
|
56
|
+
const _Set = require("@fable-org/fable-library-js/Set.js");
|
|
57
|
+
const _Seq2 = require("@fable-org/fable-library-js/Seq2.js");
|
|
58
|
+
const _Seq = require("@fable-org/fable-library-js/Seq.js");
|
|
59
|
+
function stableGuid(name) {
|
|
60
|
+
return (0, _Helpers.Helpers_generateDeterministicGuidRaw)(`coremr:item_trigger:${name}`);
|
|
61
|
+
}
|
|
62
|
+
function comparisonWord(c) {
|
|
63
|
+
switch(c.tag){
|
|
64
|
+
case /* LessOrEqual */ 1:
|
|
65
|
+
return "less_equals";
|
|
66
|
+
case /* Equal */ 2:
|
|
67
|
+
return "equals";
|
|
68
|
+
case /* NotEqual */ 3:
|
|
69
|
+
return "not_equals";
|
|
70
|
+
case /* GreaterOrEqual */ 4:
|
|
71
|
+
return "greater_equals";
|
|
72
|
+
case /* Greater */ 5:
|
|
73
|
+
return "greater";
|
|
74
|
+
default:
|
|
75
|
+
return "less";
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function textsOf(items, c) {
|
|
79
|
+
const chosen = (ids)=>{
|
|
80
|
+
const matchValue = (0, _List.tryFind)((i)=>(0, _Util.equals)(i.ItemId, c.SourceItem), items);
|
|
81
|
+
if (matchValue != null) {
|
|
82
|
+
const item = (0, _Option.value)(matchValue);
|
|
83
|
+
return (0, _List.choose)((_arg)=>{
|
|
84
|
+
const id = _arg.fields[0] | 0;
|
|
85
|
+
return (0, _Option.map)((ch_1)=>ch_1.Text, (0, _List.tryFind)((ch)=>ch.ChoiceId === id, item.Choices));
|
|
86
|
+
}, ids);
|
|
87
|
+
} else {
|
|
88
|
+
return (0, _List.empty)();
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
const matchValue_1 = c.Test;
|
|
92
|
+
switch(matchValue_1.tag){
|
|
93
|
+
case /* AllChosen */ 1:
|
|
94
|
+
return [
|
|
95
|
+
"all",
|
|
96
|
+
chosen(matchValue_1.fields[0])
|
|
97
|
+
];
|
|
98
|
+
case /* NoneChosen */ 2:
|
|
99
|
+
return [
|
|
100
|
+
"none",
|
|
101
|
+
chosen(matchValue_1.fields[0])
|
|
102
|
+
];
|
|
103
|
+
case /* VitalIs */ 3:
|
|
104
|
+
{
|
|
105
|
+
const threshold = matchValue_1.fields[2];
|
|
106
|
+
return [
|
|
107
|
+
comparisonWord(matchValue_1.fields[1]),
|
|
108
|
+
(0, _List.singleton)(threshold.toString())
|
|
109
|
+
];
|
|
110
|
+
}
|
|
111
|
+
case /* BooleanIs */ 4:
|
|
112
|
+
return [
|
|
113
|
+
"equals",
|
|
114
|
+
(0, _List.singleton)(matchValue_1.fields[0] ? "true" : "false")
|
|
115
|
+
];
|
|
116
|
+
case /* TextCompares */ 5:
|
|
117
|
+
{
|
|
118
|
+
const text = matchValue_1.fields[1];
|
|
119
|
+
return [
|
|
120
|
+
comparisonWord(matchValue_1.fields[0]),
|
|
121
|
+
(0, _List.singleton)(text)
|
|
122
|
+
];
|
|
123
|
+
}
|
|
124
|
+
case /* UnmodelledCondition */ 6:
|
|
125
|
+
throw new Error(`CoreMRPathwayMapper: condition \`${matchValue_1.fields[0]} ${matchValue_1.fields[1]}\` is not modelled (${matchValue_1.fields[2]}) — \`refusalFor\` refuses it first`);
|
|
126
|
+
default:
|
|
127
|
+
return [
|
|
128
|
+
"any",
|
|
129
|
+
chosen(matchValue_1.fields[0])
|
|
130
|
+
];
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
function convertOperator(test, values) {
|
|
134
|
+
const canonValues = (0, _List.map)(_Helpers.Helpers_canonicalizeFieldKey, values);
|
|
135
|
+
let matchResult, cmp;
|
|
136
|
+
switch(test.tag){
|
|
137
|
+
case /* AllChosen */ 1:
|
|
138
|
+
{
|
|
139
|
+
matchResult = 1;
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
case /* NoneChosen */ 2:
|
|
143
|
+
{
|
|
144
|
+
matchResult = 2;
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
case /* VitalIs */ 3:
|
|
148
|
+
{
|
|
149
|
+
matchResult = 3;
|
|
150
|
+
cmp = test.fields[1];
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
case /* TextCompares */ 5:
|
|
154
|
+
{
|
|
155
|
+
matchResult = 3;
|
|
156
|
+
cmp = test.fields[0];
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
case /* BooleanIs */ 4:
|
|
160
|
+
{
|
|
161
|
+
matchResult = 4;
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
case /* UnmodelledCondition */ 6:
|
|
165
|
+
{
|
|
166
|
+
matchResult = 5;
|
|
167
|
+
break;
|
|
168
|
+
}
|
|
169
|
+
default:
|
|
170
|
+
matchResult = 0;
|
|
171
|
+
}
|
|
172
|
+
switch(matchResult){
|
|
173
|
+
case 0:
|
|
174
|
+
return (0, _FormSpec.ClinicalPathway_FieldEvaluator_InSet)(canonValues);
|
|
175
|
+
case 1:
|
|
176
|
+
return (0, _FormSpec.ClinicalPathway_FieldEvaluator_ContainsAll)(canonValues);
|
|
177
|
+
case 2:
|
|
178
|
+
return (0, _FormSpec.ClinicalPathway_FieldEvaluator_NotInSet)(canonValues);
|
|
179
|
+
case 3:
|
|
180
|
+
{
|
|
181
|
+
const _arg = cmp;
|
|
182
|
+
switch(_arg.tag){
|
|
183
|
+
case /* NotEqual */ 3:
|
|
184
|
+
return (0, _FormSpec.ClinicalPathway_FieldEvaluator_NotEquals)();
|
|
185
|
+
case /* Greater */ 5:
|
|
186
|
+
return (0, _FormSpec.ClinicalPathway_FieldEvaluator_GreaterThan)();
|
|
187
|
+
case /* GreaterOrEqual */ 4:
|
|
188
|
+
return (0, _FormSpec.ClinicalPathway_FieldEvaluator_GreaterOrEqual)();
|
|
189
|
+
case /* Less */ 0:
|
|
190
|
+
return (0, _FormSpec.ClinicalPathway_FieldEvaluator_LessThan)();
|
|
191
|
+
case /* LessOrEqual */ 1:
|
|
192
|
+
return (0, _FormSpec.ClinicalPathway_FieldEvaluator_LessOrEqual)();
|
|
193
|
+
default:
|
|
194
|
+
return (0, _FormSpec.ClinicalPathway_FieldEvaluator_Equals)();
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
case 4:
|
|
198
|
+
return (0, _FormSpec.ClinicalPathway_FieldEvaluator_Equals)();
|
|
199
|
+
default:
|
|
200
|
+
throw new Error(`CoreMRPathwayMapper: unmodelled condition \`${test.fields[0]} ${test.fields[1]}\` reached the mapper`);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
function convertTiming(timing) {
|
|
204
|
+
switch(timing.tag){
|
|
205
|
+
case /* OnLock */ 1:
|
|
206
|
+
return (0, _FormSpec.ClinicalPathway_TriggerTiming_OnFormSubmit)();
|
|
207
|
+
case /* OnFirstOpen */ 2:
|
|
208
|
+
return (0, _FormSpec.ClinicalPathway_TriggerTiming_OnFormLoad)();
|
|
209
|
+
case /* UnrecognisedTiming */ 3:
|
|
210
|
+
throw new Error(`CoreMRPathwayMapper: event \`${timing.fields[0]}\` is not modelled — \`refusalFor\` refuses it first`);
|
|
211
|
+
default:
|
|
212
|
+
return (0, _FormSpec.ClinicalPathway_TriggerTiming_OnFormSave)();
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
function convertPriority(_arg) {
|
|
216
|
+
const p = _arg.fields[0] | 0;
|
|
217
|
+
switch(p){
|
|
218
|
+
case 1:
|
|
219
|
+
return (0, _FormSpec.ClinicalPathway_TaskPriority_High)();
|
|
220
|
+
case 2:
|
|
221
|
+
return (0, _FormSpec.ClinicalPathway_TaskPriority_Medium)();
|
|
222
|
+
case 3:
|
|
223
|
+
return (0, _FormSpec.ClinicalPathway_TaskPriority_Low)();
|
|
224
|
+
default:
|
|
225
|
+
return (0, _FormSpec.ClinicalPathway_TaskPriority_Stated)(p);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
function parseDueDate(stated) {
|
|
229
|
+
const m = (0, _RegExp.match)(/^\+\s*(\d+)\s*(day|days|week|weeks)$/gu, stated.trim().toLowerCase());
|
|
230
|
+
const matchValue = stated.trim().toLowerCase();
|
|
231
|
+
switch(matchValue){
|
|
232
|
+
case "today":
|
|
233
|
+
return (0, _FormSpec.ClinicalPathway_DueDate_Today)();
|
|
234
|
+
case "tomorrow":
|
|
235
|
+
return (0, _FormSpec.ClinicalPathway_DueDate_Tomorrow)();
|
|
236
|
+
default:
|
|
237
|
+
if (m != null) {
|
|
238
|
+
const n = (0, _Int32.parse)(m[1] || "", 511, false, 32) | 0;
|
|
239
|
+
return (0, _FormSpec.ClinicalPathway_DueDate_DaysFromNow)((m[2] || "").startsWith("week") ? 7 * n : n);
|
|
240
|
+
} else {
|
|
241
|
+
return (0, _FormSpec.ClinicalPathway_DueDate_AsStated)(stated);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
function requiredDue(what, stated) {
|
|
246
|
+
if (stated == null) {
|
|
247
|
+
throw new Error(`CoreMRPathwayMapper: ${what} states no date — none is invented`);
|
|
248
|
+
} else {
|
|
249
|
+
return parseDueDate((0, _Option.value)(stated));
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
function convertCondition(items, cond, itemFieldKeyMap) {
|
|
253
|
+
let fieldKey;
|
|
254
|
+
const matchValue = (0, _Option.bind)((item)=>(0, _Map.tryFind)(item, itemFieldKeyMap), cond.SourceItem);
|
|
255
|
+
if (matchValue == null) {
|
|
256
|
+
throw new Error((0, _String.toText)((0, _String.interpolate)("CoreMRPathwayMapper: condition on item %A%P() is not a field — `nonFieldRefusal` refuses it first", [
|
|
257
|
+
cond.SourceItem
|
|
258
|
+
])));
|
|
259
|
+
} else {
|
|
260
|
+
fieldKey = (0, _Option.value)(matchValue);
|
|
261
|
+
}
|
|
262
|
+
const values = textsOf(items, cond)[1];
|
|
263
|
+
const evaluator = convertOperator(cond.Test, values);
|
|
264
|
+
const canonicalize = _Helpers.Helpers_canonicalizeFieldKey;
|
|
265
|
+
let condValue;
|
|
266
|
+
const matchValue_1 = cond.Test;
|
|
267
|
+
switch(matchValue_1.tag){
|
|
268
|
+
case /* AnyChosen */ 0:
|
|
269
|
+
case /* AllChosen */ 1:
|
|
270
|
+
case /* NoneChosen */ 2:
|
|
271
|
+
{
|
|
272
|
+
condValue = (0, _FormSpec.Shared_ConditionValue_Multiple)((0, _Set.ofList)((0, _List.map)(canonicalize, values), {
|
|
273
|
+
Compare: _Util.comparePrimitives
|
|
274
|
+
}));
|
|
275
|
+
break;
|
|
276
|
+
}
|
|
277
|
+
default:
|
|
278
|
+
condValue = (0, _List.isEmpty)(values) ? (0, _FormSpec.Shared_ConditionValue_Single)("") : (0, _FormSpec.Shared_ConditionValue_Single)(canonicalize((0, _List.head)(values)));
|
|
279
|
+
}
|
|
280
|
+
const matchValue_2 = cond.Test;
|
|
281
|
+
let matchResult;
|
|
282
|
+
if (matchValue_2.tag === /* VitalIs */ 3) {
|
|
283
|
+
switch(matchValue_2.fields[0].tag){
|
|
284
|
+
case /* SystolicBP */ 0:
|
|
285
|
+
{
|
|
286
|
+
matchResult = 0;
|
|
287
|
+
break;
|
|
288
|
+
}
|
|
289
|
+
case /* DiastolicBP */ 1:
|
|
290
|
+
{
|
|
291
|
+
matchResult = 1;
|
|
292
|
+
break;
|
|
293
|
+
}
|
|
294
|
+
default:
|
|
295
|
+
matchResult = 2;
|
|
296
|
+
}
|
|
297
|
+
} else {
|
|
298
|
+
matchResult = 2;
|
|
299
|
+
}
|
|
300
|
+
switch(matchResult){
|
|
301
|
+
case 0:
|
|
302
|
+
return (0, _FormSpec.ClinicalPathway_TransitionCondition_PluginPropertyCondition)(fieldKey, new _FormSpec.Shared_PluginPropertyKey(stableGuid("bp_systolic")), evaluator, condValue);
|
|
303
|
+
case 1:
|
|
304
|
+
return (0, _FormSpec.ClinicalPathway_TransitionCondition_PluginPropertyCondition)(fieldKey, new _FormSpec.Shared_PluginPropertyKey(stableGuid("bp_diastolic")), evaluator, condValue);
|
|
305
|
+
default:
|
|
306
|
+
return (0, _FormSpec.ClinicalPathway_TransitionCondition_FieldCondition)(fieldKey, evaluator, condValue);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
function combineConditions(items, conditions, itemFieldKeyMap) {
|
|
310
|
+
if (!(0, _List.isEmpty)(conditions)) {
|
|
311
|
+
if ((0, _List.isEmpty)((0, _List.tail)(conditions))) {
|
|
312
|
+
return convertCondition(items, (0, _List.head)(conditions), itemFieldKeyMap);
|
|
313
|
+
} else {
|
|
314
|
+
const ops = (0, _List.map)((c)=>{
|
|
315
|
+
const matchValue = c.Join;
|
|
316
|
+
if (matchValue == null) {
|
|
317
|
+
throw new Error("CoreMRPathwayMapper: a later condition states no join — the release cannot say how it combines");
|
|
318
|
+
} else {
|
|
319
|
+
switch((0, _Option.value)(matchValue).tag){
|
|
320
|
+
case /* Or */ 1:
|
|
321
|
+
return (0, _FormSpec.ClinicalPathway_LogicalOp_Or)();
|
|
322
|
+
case /* UnrecognisedJoin */ 2:
|
|
323
|
+
{
|
|
324
|
+
const j = (0, _Option.value)(matchValue).fields[0];
|
|
325
|
+
throw new Error(`CoreMRPathwayMapper: join \`${j}\` is not modelled — \`refusalFor\` refuses it first`);
|
|
326
|
+
}
|
|
327
|
+
default:
|
|
328
|
+
return (0, _FormSpec.ClinicalPathway_LogicalOp_And)();
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}, (0, _List.tail)(conditions));
|
|
332
|
+
const matchValue_1 = (0, _Seq2.List_distinct)(ops, {
|
|
333
|
+
Equals: _Util.equals,
|
|
334
|
+
GetHashCode: _Util.safeHash
|
|
335
|
+
});
|
|
336
|
+
let matchResult, op;
|
|
337
|
+
if (!(0, _List.isEmpty)(matchValue_1)) {
|
|
338
|
+
if ((0, _List.isEmpty)((0, _List.tail)(matchValue_1))) {
|
|
339
|
+
matchResult = 0;
|
|
340
|
+
op = (0, _List.head)(matchValue_1);
|
|
341
|
+
} else {
|
|
342
|
+
matchResult = 1;
|
|
343
|
+
}
|
|
344
|
+
} else {
|
|
345
|
+
matchResult = 1;
|
|
346
|
+
}
|
|
347
|
+
switch(matchResult){
|
|
348
|
+
case 0:
|
|
349
|
+
return (0, _FormSpec.ClinicalPathway_TransitionCondition_CompositeCondition)(op, (0, _List.map)((c_1)=>convertCondition(items, c_1, itemFieldKeyMap), conditions));
|
|
350
|
+
default:
|
|
351
|
+
{
|
|
352
|
+
const list_3 = (0, _List.zip)(ops, (0, _List.tail)(conditions));
|
|
353
|
+
return (0, _List.fold)((acc, tupledArg)=>(0, _FormSpec.ClinicalPathway_TransitionCondition_CompositeCondition)(tupledArg[0], (0, _List.ofArray)([
|
|
354
|
+
acc,
|
|
355
|
+
convertCondition(items, tupledArg[1], itemFieldKeyMap)
|
|
356
|
+
])), convertCondition(items, (0, _List.head)(conditions), itemFieldKeyMap), list_3);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
} else {
|
|
361
|
+
return (0, _FormSpec.ClinicalPathway_TransitionCondition_Always)();
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
function kindWord(a) {
|
|
365
|
+
switch(a.tag){
|
|
366
|
+
case /* Alert */ 2:
|
|
367
|
+
return "alert";
|
|
368
|
+
case /* Problem */ 3:
|
|
369
|
+
return "problem";
|
|
370
|
+
case /* Medset */ 4:
|
|
371
|
+
return "medset";
|
|
372
|
+
case /* StandingOrder */ 1:
|
|
373
|
+
if (a.fields[1].tag === /* Treatment */ 1) {
|
|
374
|
+
return "treatment";
|
|
375
|
+
} else {
|
|
376
|
+
return "recurring_task";
|
|
377
|
+
}
|
|
378
|
+
case /* ChangeGroups */ 5:
|
|
379
|
+
return "groups";
|
|
380
|
+
default:
|
|
381
|
+
return "task";
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
function nameOf(r) {
|
|
385
|
+
return (0, _Option.defaultArg)(r.Name, "");
|
|
386
|
+
}
|
|
387
|
+
function modelledActions(t) {
|
|
388
|
+
return (0, _List.map)((a)=>{
|
|
389
|
+
const matchValue = a.Read;
|
|
390
|
+
if (matchValue.tag === /* Unmodelled */ 1) {
|
|
391
|
+
throw new Error(`CoreMRPathwayMapper: action ${a.ActionId} (\`${matchValue.fields[0]}\`) is unmodelled (${matchValue.fields[1]}) — \`refusalFor\` refuses it first`);
|
|
392
|
+
} else {
|
|
393
|
+
return matchValue.fields[0];
|
|
394
|
+
}
|
|
395
|
+
}, t.Actions);
|
|
396
|
+
}
|
|
397
|
+
function standingOf(cadence) {
|
|
398
|
+
if (cadence.tag === /* Every */ 1) {
|
|
399
|
+
const until = cadence.fields[1];
|
|
400
|
+
return new _FormSpec.ClinicalPathway_StandingSchedule((0, _FormSpec.ClinicalPathway_Cadence_Every)(cadence.fields[0], until), parseDueDate(until));
|
|
401
|
+
} else {
|
|
402
|
+
const schedule = cadence.fields[0];
|
|
403
|
+
return new _FormSpec.ClinicalPathway_StandingSchedule((0, _FormSpec.ClinicalPathway_Cadence_OnSchedule)(schedule.Id, schedule.Name), (0, _Option.map)(parseDueDate, cadence.fields[1]));
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
function taskOf(task, standing) {
|
|
407
|
+
return (0, _FormSpec.ClinicalPathway_ActionInfo_Task)(new _FormSpec.ClinicalPathway_TaskAction(task.Category.Id, nameOf(task.Category), task.Description, convertPriority(task.Priority), requiredDue("a task", task.Due), undefined, standing));
|
|
408
|
+
}
|
|
409
|
+
function convertAction(action) {
|
|
410
|
+
switch(action.tag){
|
|
411
|
+
case /* OneOffTask */ 0:
|
|
412
|
+
{
|
|
413
|
+
const task = action.fields[0];
|
|
414
|
+
return taskOf(task, undefined);
|
|
415
|
+
}
|
|
416
|
+
case /* StandingOrder */ 1:
|
|
417
|
+
if (action.fields[1].tag === /* Treatment */ 1) {
|
|
418
|
+
const cadence_1 = action.fields[0];
|
|
419
|
+
const treatment = action.fields[1].fields[0];
|
|
420
|
+
return (0, _FormSpec.ClinicalPathway_ActionInfo_Treatment)(new _FormSpec.ClinicalPathway_TreatmentAction(treatment.Treatment.Id, treatment.Treatment.Name, (0, _Option.map)((r)=>r.Id, treatment.Provider), treatment.Instructions, parseDueDate(treatment.Start), standingOf(cadence_1), undefined, undefined, undefined));
|
|
421
|
+
} else {
|
|
422
|
+
const cadence = action.fields[0];
|
|
423
|
+
const task_1 = action.fields[1].fields[0];
|
|
424
|
+
return taskOf(task_1, standingOf(cadence));
|
|
425
|
+
}
|
|
426
|
+
case /* Medset */ 4:
|
|
427
|
+
{
|
|
428
|
+
const medset = action.fields[0];
|
|
429
|
+
return (0, _FormSpec.ClinicalPathway_ActionInfo_Medset)(new _FormSpec.ClinicalPathway_MedsetAction(medset.Medset.Id, nameOf(medset.Medset), (0, _Option.map)((r_1)=>r_1.Id, medset.Prescriber), (0, _Option.map)((r_2)=>r_2.Id, medset.Pharmacy), requiredDue("a medset", medset.Start)));
|
|
430
|
+
}
|
|
431
|
+
case /* Problem */ 3:
|
|
432
|
+
{
|
|
433
|
+
const problem = action.fields[0];
|
|
434
|
+
return (0, _FormSpec.ClinicalPathway_ActionInfo_Problem)(new _FormSpec.ClinicalPathway_ProblemAction(problem.Problem.Id, problem.Problem.Name, undefined, undefined, (0, _FormSpec.ClinicalPathway_ProblemStatus_Active)(), undefined, problem.Chronic, problem.Severity, problem.Inflammation));
|
|
435
|
+
}
|
|
436
|
+
case /* ChangeGroups */ 5:
|
|
437
|
+
{
|
|
438
|
+
const change = action.fields[0];
|
|
439
|
+
const patternInput = change.tag === /* RemoveFrom */ 1 ? [
|
|
440
|
+
(0, _FormSpec.ClinicalPathway_GroupChange_RemoveFromGroups)(),
|
|
441
|
+
change.fields[0]
|
|
442
|
+
] : [
|
|
443
|
+
(0, _FormSpec.ClinicalPathway_GroupChange_AddToGroups)(),
|
|
444
|
+
change.fields[0]
|
|
445
|
+
];
|
|
446
|
+
return (0, _FormSpec.ClinicalPathway_ActionInfo_ChangeGroups)(new _FormSpec.ClinicalPathway_GroupChangeAction(patternInput[0], (0, _List.map)((r_3)=>new _FormSpec.ClinicalPathway_GroupRef(r_3.Id, r_3.Name), (0, _FormTemplate.NonEmpty_toList)(patternInput[1]))));
|
|
447
|
+
}
|
|
448
|
+
default:
|
|
449
|
+
{
|
|
450
|
+
const category = action.fields[0];
|
|
451
|
+
const categoryName = nameOf(category);
|
|
452
|
+
return (0, _FormSpec.ClinicalPathway_ActionInfo_Alert)(new _FormSpec.ClinicalPathway_AlertAction(category.Id, categoryName, categoryName, undefined, undefined));
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
function generateEvaluationLabel(trigger, items) {
|
|
457
|
+
let item_1, item_2;
|
|
458
|
+
let fieldLabel;
|
|
459
|
+
const matchValue = trigger.Conditions;
|
|
460
|
+
if (!(0, _List.isEmpty)(matchValue)) {
|
|
461
|
+
const head = (0, _List.head)(matchValue);
|
|
462
|
+
const matchValue_1 = (0, _Option.bind)((id)=>(0, _List.tryFind)((i)=>i.ItemId === id, items), head.SourceItem);
|
|
463
|
+
if (matchValue_1 == null) {
|
|
464
|
+
throw new Error((0, _String.toText)((0, _String.interpolate)("CoreMRPathwayMapper: trigger %P() reads item %A%P(), not on this form — refused first", [
|
|
465
|
+
trigger.TriggerId,
|
|
466
|
+
head.SourceItem
|
|
467
|
+
])));
|
|
468
|
+
} else {
|
|
469
|
+
fieldLabel = (0, _String.isNullOrEmpty)((0, _Option.value)(matchValue_1).Text) ? (item_1 = (0, _Option.value)(matchValue_1), "(no text)") : (item_2 = (0, _Option.value)(matchValue_1), item_2.Text.length > 50 ? (0, _String.substring)(item_2.Text, 0, 47) + "..." : item_2.Text);
|
|
470
|
+
}
|
|
471
|
+
} else {
|
|
472
|
+
throw new Error(`CoreMRPathwayMapper: trigger ${trigger.TriggerId} states no condition — \`liveTriggers\` keeps none such`);
|
|
473
|
+
}
|
|
474
|
+
const matchValue_2 = trigger.Conditions;
|
|
475
|
+
if (!(0, _List.isEmpty)(matchValue_2)) {
|
|
476
|
+
if ((0, _List.isEmpty)((0, _List.tail)(matchValue_2))) {
|
|
477
|
+
const matchValue_3 = textsOf(items, (0, _List.head)(matchValue_2));
|
|
478
|
+
let matchResult, v, vals_2, vals_3, v_1, v_2, v_3, v_4, v_5, v_6, vals_4, op;
|
|
479
|
+
switch(matchValue_3[0]){
|
|
480
|
+
case "any":
|
|
481
|
+
{
|
|
482
|
+
if (!(0, _List.isEmpty)(matchValue_3[1])) {
|
|
483
|
+
if ((0, _List.isEmpty)((0, _List.tail)(matchValue_3[1]))) {
|
|
484
|
+
matchResult = 0;
|
|
485
|
+
v = (0, _List.head)(matchValue_3[1]);
|
|
486
|
+
} else if ((0, _List.length)(matchValue_3[1]) <= 3) {
|
|
487
|
+
matchResult = 1;
|
|
488
|
+
vals_2 = matchValue_3[1];
|
|
489
|
+
} else {
|
|
490
|
+
matchResult = 2;
|
|
491
|
+
vals_3 = matchValue_3[1];
|
|
492
|
+
}
|
|
493
|
+
} else if ((0, _List.length)(matchValue_3[1]) <= 3) {
|
|
494
|
+
matchResult = 1;
|
|
495
|
+
vals_2 = matchValue_3[1];
|
|
496
|
+
} else {
|
|
497
|
+
matchResult = 2;
|
|
498
|
+
vals_3 = matchValue_3[1];
|
|
499
|
+
}
|
|
500
|
+
break;
|
|
501
|
+
}
|
|
502
|
+
case "equals":
|
|
503
|
+
{
|
|
504
|
+
if (!(0, _List.isEmpty)(matchValue_3[1])) {
|
|
505
|
+
if ((0, _List.isEmpty)((0, _List.tail)(matchValue_3[1]))) {
|
|
506
|
+
matchResult = 3;
|
|
507
|
+
v_1 = (0, _List.head)(matchValue_3[1]);
|
|
508
|
+
} else {
|
|
509
|
+
matchResult = 10;
|
|
510
|
+
op = matchValue_3[0];
|
|
511
|
+
}
|
|
512
|
+
} else {
|
|
513
|
+
matchResult = 10;
|
|
514
|
+
op = matchValue_3[0];
|
|
515
|
+
}
|
|
516
|
+
break;
|
|
517
|
+
}
|
|
518
|
+
case "not_equals":
|
|
519
|
+
{
|
|
520
|
+
if (!(0, _List.isEmpty)(matchValue_3[1])) {
|
|
521
|
+
if ((0, _List.isEmpty)((0, _List.tail)(matchValue_3[1]))) {
|
|
522
|
+
matchResult = 4;
|
|
523
|
+
v_2 = (0, _List.head)(matchValue_3[1]);
|
|
524
|
+
} else {
|
|
525
|
+
matchResult = 10;
|
|
526
|
+
op = matchValue_3[0];
|
|
527
|
+
}
|
|
528
|
+
} else {
|
|
529
|
+
matchResult = 10;
|
|
530
|
+
op = matchValue_3[0];
|
|
531
|
+
}
|
|
532
|
+
break;
|
|
533
|
+
}
|
|
534
|
+
case "greater_equals":
|
|
535
|
+
{
|
|
536
|
+
if (!(0, _List.isEmpty)(matchValue_3[1])) {
|
|
537
|
+
if ((0, _List.isEmpty)((0, _List.tail)(matchValue_3[1]))) {
|
|
538
|
+
matchResult = 5;
|
|
539
|
+
v_3 = (0, _List.head)(matchValue_3[1]);
|
|
540
|
+
} else {
|
|
541
|
+
matchResult = 10;
|
|
542
|
+
op = matchValue_3[0];
|
|
543
|
+
}
|
|
544
|
+
} else {
|
|
545
|
+
matchResult = 10;
|
|
546
|
+
op = matchValue_3[0];
|
|
547
|
+
}
|
|
548
|
+
break;
|
|
549
|
+
}
|
|
550
|
+
case "greater":
|
|
551
|
+
{
|
|
552
|
+
if (!(0, _List.isEmpty)(matchValue_3[1])) {
|
|
553
|
+
if ((0, _List.isEmpty)((0, _List.tail)(matchValue_3[1]))) {
|
|
554
|
+
matchResult = 6;
|
|
555
|
+
v_4 = (0, _List.head)(matchValue_3[1]);
|
|
556
|
+
} else {
|
|
557
|
+
matchResult = 10;
|
|
558
|
+
op = matchValue_3[0];
|
|
559
|
+
}
|
|
560
|
+
} else {
|
|
561
|
+
matchResult = 10;
|
|
562
|
+
op = matchValue_3[0];
|
|
563
|
+
}
|
|
564
|
+
break;
|
|
565
|
+
}
|
|
566
|
+
case "less_equals":
|
|
567
|
+
{
|
|
568
|
+
if (!(0, _List.isEmpty)(matchValue_3[1])) {
|
|
569
|
+
if ((0, _List.isEmpty)((0, _List.tail)(matchValue_3[1]))) {
|
|
570
|
+
matchResult = 7;
|
|
571
|
+
v_5 = (0, _List.head)(matchValue_3[1]);
|
|
572
|
+
} else {
|
|
573
|
+
matchResult = 10;
|
|
574
|
+
op = matchValue_3[0];
|
|
575
|
+
}
|
|
576
|
+
} else {
|
|
577
|
+
matchResult = 10;
|
|
578
|
+
op = matchValue_3[0];
|
|
579
|
+
}
|
|
580
|
+
break;
|
|
581
|
+
}
|
|
582
|
+
case "less":
|
|
583
|
+
{
|
|
584
|
+
if (!(0, _List.isEmpty)(matchValue_3[1])) {
|
|
585
|
+
if ((0, _List.isEmpty)((0, _List.tail)(matchValue_3[1]))) {
|
|
586
|
+
matchResult = 8;
|
|
587
|
+
v_6 = (0, _List.head)(matchValue_3[1]);
|
|
588
|
+
} else {
|
|
589
|
+
matchResult = 10;
|
|
590
|
+
op = matchValue_3[0];
|
|
591
|
+
}
|
|
592
|
+
} else {
|
|
593
|
+
matchResult = 10;
|
|
594
|
+
op = matchValue_3[0];
|
|
595
|
+
}
|
|
596
|
+
break;
|
|
597
|
+
}
|
|
598
|
+
case "all":
|
|
599
|
+
{
|
|
600
|
+
matchResult = 9;
|
|
601
|
+
vals_4 = matchValue_3[1];
|
|
602
|
+
break;
|
|
603
|
+
}
|
|
604
|
+
default:
|
|
605
|
+
{
|
|
606
|
+
matchResult = 10;
|
|
607
|
+
op = matchValue_3[0];
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
switch(matchResult){
|
|
611
|
+
case 0:
|
|
612
|
+
return `When ${fieldLabel} = ${v}`;
|
|
613
|
+
case 1:
|
|
614
|
+
return `When ${fieldLabel} is ${(0, _String.join)(" or ", vals_2)}`;
|
|
615
|
+
case 2:
|
|
616
|
+
return `When ${fieldLabel} is any of ${(0, _List.length)(vals_3)} values`;
|
|
617
|
+
case 3:
|
|
618
|
+
return `When ${fieldLabel} = ${v_1}`;
|
|
619
|
+
case 4:
|
|
620
|
+
return `When ${fieldLabel} ≠ ${v_2}`;
|
|
621
|
+
case 5:
|
|
622
|
+
return `When ${fieldLabel} ≥ ${v_3}`;
|
|
623
|
+
case 6:
|
|
624
|
+
return `When ${fieldLabel} > ${v_4}`;
|
|
625
|
+
case 7:
|
|
626
|
+
return `When ${fieldLabel} ≤ ${v_5}`;
|
|
627
|
+
case 8:
|
|
628
|
+
return `When ${fieldLabel} < ${v_6}`;
|
|
629
|
+
case 9:
|
|
630
|
+
return `When ${fieldLabel} has all of: ${(0, _String.join)(", ", vals_4)}`;
|
|
631
|
+
default:
|
|
632
|
+
return `When ${fieldLabel} ${op}`;
|
|
633
|
+
}
|
|
634
|
+
} else {
|
|
635
|
+
return `When ${fieldLabel} (${(0, _List.length)(matchValue_2)} conditions)`;
|
|
636
|
+
}
|
|
637
|
+
} else {
|
|
638
|
+
throw new Error(`CoreMRPathwayMapper: trigger ${trigger.TriggerId} states no condition`);
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
function generateActionLabel(trigger) {
|
|
642
|
+
let matchValue_1;
|
|
643
|
+
const matchValue = modelledActions(trigger);
|
|
644
|
+
if (!(0, _List.isEmpty)(matchValue)) {
|
|
645
|
+
if ((0, _List.isEmpty)((0, _List.tail)(matchValue))) {
|
|
646
|
+
let matchResult, category, task, medset, task_1, other;
|
|
647
|
+
switch((0, _List.head)(matchValue).tag){
|
|
648
|
+
case /* Alert */ 2:
|
|
649
|
+
{
|
|
650
|
+
matchResult = 0;
|
|
651
|
+
category = (0, _List.head)(matchValue).fields[0];
|
|
652
|
+
break;
|
|
653
|
+
}
|
|
654
|
+
case /* OneOffTask */ 0:
|
|
655
|
+
{
|
|
656
|
+
matchResult = 1;
|
|
657
|
+
task = (0, _List.head)(matchValue).fields[0];
|
|
658
|
+
break;
|
|
659
|
+
}
|
|
660
|
+
case /* Medset */ 4:
|
|
661
|
+
{
|
|
662
|
+
matchResult = 2;
|
|
663
|
+
medset = (0, _List.head)(matchValue).fields[0];
|
|
664
|
+
break;
|
|
665
|
+
}
|
|
666
|
+
case /* Problem */ 3:
|
|
667
|
+
{
|
|
668
|
+
matchResult = 3;
|
|
669
|
+
break;
|
|
670
|
+
}
|
|
671
|
+
case /* StandingOrder */ 1:
|
|
672
|
+
{
|
|
673
|
+
if ((0, _List.head)(matchValue).fields[1].tag === /* RecurringTask */ 0) {
|
|
674
|
+
matchResult = 4;
|
|
675
|
+
task_1 = (0, _List.head)(matchValue).fields[1].fields[0];
|
|
676
|
+
} else {
|
|
677
|
+
matchResult = 5;
|
|
678
|
+
other = (0, _List.head)(matchValue);
|
|
679
|
+
}
|
|
680
|
+
break;
|
|
681
|
+
}
|
|
682
|
+
default:
|
|
683
|
+
{
|
|
684
|
+
matchResult = 5;
|
|
685
|
+
other = (0, _List.head)(matchValue);
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
switch(matchResult){
|
|
689
|
+
case 0:
|
|
690
|
+
return `Create Alert: ${nameOf(category)}`;
|
|
691
|
+
case 1:
|
|
692
|
+
return `Create ${matchValue_1 = task.Priority, matchValue_1.fields[0] === 1 ? "High " : matchValue_1.fields[0] === 3 ? "Low " : ""}Task: ${nameOf(task.Category)}`;
|
|
693
|
+
case 2:
|
|
694
|
+
return `Order Medset: ${nameOf(medset.Medset)}`;
|
|
695
|
+
case 3:
|
|
696
|
+
return "Add to Problem List";
|
|
697
|
+
case 4:
|
|
698
|
+
return `Schedule: ${nameOf(task_1.Category)}`;
|
|
699
|
+
default:
|
|
700
|
+
return `Execute: ${kindWord(other)}`;
|
|
701
|
+
}
|
|
702
|
+
} else {
|
|
703
|
+
const joined = (0, _String.join)(", ", (0, _Seq2.List_distinct)((0, _List.map)(kindWord, matchValue), {
|
|
704
|
+
Equals: (x, y)=>x === y,
|
|
705
|
+
GetHashCode: _Util.stringHash
|
|
706
|
+
}));
|
|
707
|
+
return `Execute ${(0, _List.length)(matchValue)} actions: ${joined}`;
|
|
708
|
+
}
|
|
709
|
+
} else {
|
|
710
|
+
return "No actions";
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
function pathwayActions(t) {
|
|
714
|
+
let sourceItem;
|
|
715
|
+
const matchValue = t.Conditions;
|
|
716
|
+
if ((0, _List.isEmpty)(matchValue)) {
|
|
717
|
+
throw new Error(`CoreMRPathwayMapper: trigger ${t.TriggerId} states no condition — \`liveTriggers\` keeps none such`);
|
|
718
|
+
} else if ((0, _List.head)(matchValue).SourceItem == null) {
|
|
719
|
+
throw new Error(`CoreMRPathwayMapper: trigger ${t.TriggerId}'s head condition reads no item — \`refusalFor\` refuses it first`);
|
|
720
|
+
} else {
|
|
721
|
+
const item = (0, _Option.value)((0, _List.head)(matchValue).SourceItem) | 0;
|
|
722
|
+
sourceItem = item;
|
|
723
|
+
}
|
|
724
|
+
return (0, _List.map)((a)=>{
|
|
725
|
+
const matchValue_1 = a.Read;
|
|
726
|
+
if (matchValue_1.tag === /* Unmodelled */ 1) {
|
|
727
|
+
throw new Error(`CoreMRPathwayMapper: action ${a.ActionId} (\`${matchValue_1.fields[0]}\`) is unmodelled (${matchValue_1.fields[1]}) — \`refusalFor\` refuses it first`);
|
|
728
|
+
} else {
|
|
729
|
+
return new _FormSpec.ClinicalPathway_PathwayAction(convertAction(matchValue_1.fields[0]), (0, _FormSpec.ClinicalPathway_ActionOrigin_CoreMRTrigger)(new _FormSpec.ClinicalPathway_CoreMRTriggerRef(t.TriggerId, a.ActionId, sourceItem)));
|
|
730
|
+
}
|
|
731
|
+
}, t.Actions);
|
|
732
|
+
}
|
|
733
|
+
function actionStateType(t) {
|
|
734
|
+
const matchValue = pathwayActions(t);
|
|
735
|
+
if (!(0, _List.isEmpty)(matchValue)) {
|
|
736
|
+
if ((0, _List.isEmpty)((0, _List.tail)(matchValue))) {
|
|
737
|
+
return (0, _FormSpec.ClinicalPathway_StateType_Action)((0, _List.head)(matchValue));
|
|
738
|
+
} else {
|
|
739
|
+
return (0, _FormSpec.ClinicalPathway_StateType_CompoundAction)(matchValue);
|
|
740
|
+
}
|
|
741
|
+
} else {
|
|
742
|
+
throw new Error(`CoreMRPathwayMapper: trigger ${t.TriggerId} states no action — \`liveTriggers\` keeps none such`);
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
function convertTriggerToPathway(importedAt, trigger, items, itemFieldKeyMap) {
|
|
746
|
+
const tid = trigger.TriggerId | 0;
|
|
747
|
+
const startKey = new _FormSpec.Shared_StateKey(stableGuid(`t${tid}_start`));
|
|
748
|
+
const evalKey = new _FormSpec.Shared_StateKey(stableGuid(`t${tid}_eval`));
|
|
749
|
+
const actionKey = new _FormSpec.Shared_StateKey(stableGuid(`t${tid}_action`));
|
|
750
|
+
const endKey = new _FormSpec.Shared_StateKey(stableGuid(`t${tid}_end`));
|
|
751
|
+
const evalLabel = generateEvaluationLabel(trigger, items);
|
|
752
|
+
const actionLabel = generateActionLabel(trigger);
|
|
753
|
+
const startState = new _FormSpec.ClinicalPathway_StateDefinition(startKey, "Start", 0, (0, _FormSpec.ClinicalPathway_StateType_Evaluation)(new _FormSpec.ClinicalPathway_EvaluationInfo("", undefined)), undefined);
|
|
754
|
+
const evalState = new _FormSpec.ClinicalPathway_StateDefinition(evalKey, evalLabel, 1, (0, _FormSpec.ClinicalPathway_StateType_Evaluation)(new _FormSpec.ClinicalPathway_EvaluationInfo("", undefined)), undefined);
|
|
755
|
+
const actionState = new _FormSpec.ClinicalPathway_StateDefinition(actionKey, actionLabel, 2, actionStateType(trigger), undefined);
|
|
756
|
+
const endState = new _FormSpec.ClinicalPathway_StateDefinition(endKey, "Complete", 3, (0, _FormSpec.ClinicalPathway_StateType_Terminal)(new _FormSpec.ClinicalPathway_TerminalInfo("Complete", "Trigger evaluation complete", undefined)), undefined);
|
|
757
|
+
const condition = combineConditions(items, trigger.Conditions, itemFieldKeyMap);
|
|
758
|
+
const transitions = (0, _List.ofArray)([
|
|
759
|
+
new _FormSpec.ClinicalPathway_TransitionDefinition(new _FormSpec.Shared_TransitionKey(stableGuid(`t${tid}_start_to_eval`)), startKey, evalKey, (0, _FormSpec.ClinicalPathway_TransitionCondition_Always)(), undefined),
|
|
760
|
+
new _FormSpec.ClinicalPathway_TransitionDefinition(new _FormSpec.Shared_TransitionKey(stableGuid(`t${tid}_eval_to_action`)), evalKey, actionKey, condition, 0),
|
|
761
|
+
new _FormSpec.ClinicalPathway_TransitionDefinition(new _FormSpec.Shared_TransitionKey(stableGuid(`t${tid}_action_to_end`)), actionKey, endKey, (0, _FormSpec.ClinicalPathway_TransitionCondition_Always)(), undefined)
|
|
762
|
+
]);
|
|
763
|
+
return new _FormSpec.ClinicalPathway_ClinicalPathwaySpec(`item_trigger_${tid}`, `Trigger ${tid}: ${actionLabel}`, "1.0.0", "CoreMR Conduit - Item Trigger", (0, _FormSpec.ClinicalPathway_PathwayExecutionMode_TriggerBased)(new _FormSpec.ClinicalPathway_TriggerBasedConfig(convertTiming(trigger.Timing), true)), startKey, (0, _List.ofArray)([
|
|
764
|
+
startState,
|
|
765
|
+
evalState,
|
|
766
|
+
actionState,
|
|
767
|
+
endState
|
|
768
|
+
]), transitions, (0, _List.empty)(), (0, _List.empty)(), importedAt, undefined, undefined, 1);
|
|
769
|
+
}
|
|
770
|
+
function liveTriggers(form, reads) {
|
|
771
|
+
switch(reads.tag){
|
|
772
|
+
case /* Stated */ 0:
|
|
773
|
+
{
|
|
774
|
+
const byId = (0, _List.sortBy)((t)=>t.TriggerId, reads.fields[0], {
|
|
775
|
+
Compare: _Util.comparePrimitives
|
|
776
|
+
});
|
|
777
|
+
return (0, _List.filter)((t_3)=>{
|
|
778
|
+
if (t_3.Enabled) {
|
|
779
|
+
return !(0, _List.isEmpty)(t_3.Actions);
|
|
780
|
+
} else {
|
|
781
|
+
return false;
|
|
782
|
+
}
|
|
783
|
+
}, (0, _Seq2.List_distinctBy)((t_2)=>t_2.TriggerId, (0, _List.collect)((item)=>(0, _List.filter)((t_1)=>(0, _List.exists)((c)=>(0, _Util.equals)(c.SourceItem, item.ItemId), t_1.Conditions), byId), form.Items), {
|
|
784
|
+
Equals: (x_1, y_1)=>x_1 === y_1,
|
|
785
|
+
GetHashCode: _Util.numberHash
|
|
786
|
+
}));
|
|
787
|
+
}
|
|
788
|
+
default:
|
|
789
|
+
return (0, _List.empty)();
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
function refusalFor(form, reads) {
|
|
793
|
+
let arg, arg_1;
|
|
794
|
+
const live = liveTriggers(form, reads);
|
|
795
|
+
const kinds = (0, _List.sort)((0, _Seq2.List_distinct)((0, _List.collect)((t)=>(0, _List.choose)((a)=>{
|
|
796
|
+
const matchValue = a.Read;
|
|
797
|
+
if (matchValue.tag === /* Modelled */ 0) {
|
|
798
|
+
return undefined;
|
|
799
|
+
} else {
|
|
800
|
+
const kind = matchValue.fields[0];
|
|
801
|
+
return kind.toLowerCase();
|
|
802
|
+
}
|
|
803
|
+
}, t.Actions), live), {
|
|
804
|
+
Equals: (x, y)=>x === y,
|
|
805
|
+
GetHashCode: _Util.stringHash
|
|
806
|
+
}), {
|
|
807
|
+
Compare: _Util.comparePrimitives
|
|
808
|
+
});
|
|
809
|
+
const conditions = (0, _List.sort)((0, _Seq2.List_distinct)((0, _List.append)(reads.tag === /* NotInRelease */ 1 ? (0, _List.empty)() : reads.tag === /* NotReadYet */ 2 ? (0, _List.empty)() : (0, _List.map)((t_3)=>`trigger ${t_3.TriggerId} reads no item`, (0, _List.filter)((t_2)=>(0, _List.exists)((c)=>c.SourceItem == null, t_2.Conditions), (0, _List.filter)((t_1)=>{
|
|
810
|
+
if (t_1.Enabled) {
|
|
811
|
+
return !(0, _List.isEmpty)(t_1.Actions);
|
|
812
|
+
} else {
|
|
813
|
+
return false;
|
|
814
|
+
}
|
|
815
|
+
}, reads.fields[0]))), (0, _List.collect)((t_4)=>(0, _Seq.toList)((0, _Seq.delay)(()=>(0, _Seq.append)((0, _Seq.collect)((c_1)=>{
|
|
816
|
+
let matchValue_1;
|
|
817
|
+
return (0, _Seq.append)((matchValue_1 = c_1.Test, matchValue_1.tag === /* UnmodelledCondition */ 6 ? (0, _Seq.singleton)(`${matchValue_1.fields[0]} ${matchValue_1.fields[1]}`) : (0, _Seq.empty)()), (0, _Seq.delay)(()=>{
|
|
818
|
+
const matchValue_2 = c_1.Join;
|
|
819
|
+
let matchResult, j;
|
|
820
|
+
if (matchValue_2 != null) {
|
|
821
|
+
if ((0, _Option.value)(matchValue_2).tag === /* UnrecognisedJoin */ 2) {
|
|
822
|
+
matchResult = 0;
|
|
823
|
+
j = (0, _Option.value)(matchValue_2).fields[0];
|
|
824
|
+
} else {
|
|
825
|
+
matchResult = 1;
|
|
826
|
+
}
|
|
827
|
+
} else {
|
|
828
|
+
matchResult = 1;
|
|
829
|
+
}
|
|
830
|
+
switch(matchResult){
|
|
831
|
+
case 0:
|
|
832
|
+
return (0, _Seq.singleton)(`join ${j}`);
|
|
833
|
+
default:
|
|
834
|
+
{
|
|
835
|
+
return (0, _Seq.empty)();
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
}));
|
|
839
|
+
}, t_4.Conditions), (0, _Seq.delay)(()=>{
|
|
840
|
+
const matchValue_3 = t_4.Timing;
|
|
841
|
+
if (matchValue_3.tag === /* UnrecognisedTiming */ 3) {
|
|
842
|
+
return (0, _Seq.singleton)(`event ${matchValue_3.fields[0]}`);
|
|
843
|
+
} else {
|
|
844
|
+
return (0, _Seq.empty)();
|
|
845
|
+
}
|
|
846
|
+
})))), live)), {
|
|
847
|
+
Equals: (x_2, y_2)=>x_2 === y_2,
|
|
848
|
+
GetHashCode: _Util.stringHash
|
|
849
|
+
}), {
|
|
850
|
+
Compare: _Util.comparePrimitives
|
|
851
|
+
});
|
|
852
|
+
if ((0, _List.isEmpty)(kinds)) {
|
|
853
|
+
if ((0, _List.isEmpty)(conditions)) {
|
|
854
|
+
return undefined;
|
|
855
|
+
} else {
|
|
856
|
+
return arg = (0, _String.join)(", ", conditions), (0, _String.toText)((0, _String.printf)("refused — its triggers state what the CoreMR trigger domain cannot evaluate yet: %s. Nothing is imported rather than a pathway that cannot be evaluated."))(arg);
|
|
857
|
+
}
|
|
858
|
+
} else {
|
|
859
|
+
return arg_1 = (0, _String.join)(", ", kinds), (0, _String.toText)((0, _String.printf)("refused — its triggers use action kinds the 5.5.0+10245 converter does not model faithfully yet: %s. Nothing is imported rather than a pathway with invented actions."))(arg_1);
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
function convertFormTriggersToPathway(importedAt, form, reads, itemFieldKeyMap) {
|
|
863
|
+
let arg;
|
|
864
|
+
const matchValue = refusalFor(form, reads);
|
|
865
|
+
if (matchValue == null) {} else {
|
|
866
|
+
throw new Error((0, _Option.value)(matchValue));
|
|
867
|
+
}
|
|
868
|
+
const nonField = (0, _Seq2.List_distinct)((0, _List.collect)((t)=>(0, _List.choose)((c)=>{
|
|
869
|
+
const matchValue_1 = c.SourceItem;
|
|
870
|
+
let matchResult, item_1;
|
|
871
|
+
if (matchValue_1 != null) {
|
|
872
|
+
if (!(0, _Map.FSharpMap__ContainsKey)(itemFieldKeyMap, (0, _Option.value)(matchValue_1))) {
|
|
873
|
+
matchResult = 0;
|
|
874
|
+
item_1 = (0, _Option.value)(matchValue_1);
|
|
875
|
+
} else {
|
|
876
|
+
matchResult = 1;
|
|
877
|
+
}
|
|
878
|
+
} else {
|
|
879
|
+
matchResult = 1;
|
|
880
|
+
}
|
|
881
|
+
switch(matchResult){
|
|
882
|
+
case 0:
|
|
883
|
+
return `trigger ${t.TriggerId} reads item ${item_1}`;
|
|
884
|
+
default:
|
|
885
|
+
return undefined;
|
|
886
|
+
}
|
|
887
|
+
}, t.Conditions), liveTriggers(form, reads)), {
|
|
888
|
+
Equals: (x, y)=>x === y,
|
|
889
|
+
GetHashCode: _Util.stringHash
|
|
890
|
+
});
|
|
891
|
+
if ((0, _List.isEmpty)(nonField)) {} else {
|
|
892
|
+
throw new Error((arg = (0, _String.join)(", ", nonField), (0, _String.toText)((0, _String.printf)("refused — its triggers read items that are not fields of this blueprint, so their branches could never fire: %s. Nothing is imported rather than a pathway with branches that can never fire."))(arg)));
|
|
893
|
+
}
|
|
894
|
+
const matchValue_2 = liveTriggers(form, reads);
|
|
895
|
+
if (!(0, _List.isEmpty)(matchValue_2)) {
|
|
896
|
+
if ((0, _List.isEmpty)((0, _List.tail)(matchValue_2))) {
|
|
897
|
+
return convertTriggerToPathway(importedAt, (0, _List.head)(matchValue_2), form.Items, itemFieldKeyMap);
|
|
898
|
+
} else {
|
|
899
|
+
const pathwayId = `form_${form.FormId}_pathway`;
|
|
900
|
+
const startKey = new _FormSpec.Shared_StateKey(stableGuid(`${pathwayId}_start`));
|
|
901
|
+
let allStates = (0, _List.singleton)(new _FormSpec.ClinicalPathway_StateDefinition(startKey, "Start", 0, (0, _FormSpec.ClinicalPathway_StateType_Evaluation)(new _FormSpec.ClinicalPathway_EvaluationInfo("", undefined)), undefined));
|
|
902
|
+
let allTransitions = (0, _List.empty)();
|
|
903
|
+
const enumerator = (0, _Util.getEnumerator)((0, _List.indexed)(matchValue_2));
|
|
904
|
+
try {
|
|
905
|
+
while(enumerator["System.Collections.IEnumerator.MoveNext"]()){
|
|
906
|
+
const forLoopVar = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
|
|
907
|
+
const trigger = forLoopVar[1];
|
|
908
|
+
const idx = forLoopVar[0] | 0;
|
|
909
|
+
const tid = trigger.TriggerId | 0;
|
|
910
|
+
const evalKey = new _FormSpec.Shared_StateKey(stableGuid(`${pathwayId}_eval_${tid}`));
|
|
911
|
+
const actionKey = new _FormSpec.Shared_StateKey(stableGuid(`${pathwayId}_action_${tid}`));
|
|
912
|
+
const endKey = new _FormSpec.Shared_StateKey(stableGuid(`${pathwayId}_end_${tid}`));
|
|
913
|
+
const evalState = new _FormSpec.ClinicalPathway_StateDefinition(evalKey, generateEvaluationLabel(trigger, form.Items), idx * 3 + 1, (0, _FormSpec.ClinicalPathway_StateType_Evaluation)(new _FormSpec.ClinicalPathway_EvaluationInfo("", undefined)), undefined);
|
|
914
|
+
const actionState = new _FormSpec.ClinicalPathway_StateDefinition(actionKey, generateActionLabel(trigger), idx * 3 + 2, actionStateType(trigger), undefined);
|
|
915
|
+
const endState = new _FormSpec.ClinicalPathway_StateDefinition(endKey, "Complete", idx * 3 + 3, (0, _FormSpec.ClinicalPathway_StateType_Terminal)(new _FormSpec.ClinicalPathway_TerminalInfo("Complete", `Trigger ${tid} complete`, undefined)), undefined);
|
|
916
|
+
const condition = combineConditions(form.Items, trigger.Conditions, itemFieldKeyMap);
|
|
917
|
+
const transitions = (0, _List.ofArray)([
|
|
918
|
+
new _FormSpec.ClinicalPathway_TransitionDefinition(new _FormSpec.Shared_TransitionKey(stableGuid(`${pathwayId}_start_to_eval_${tid}`)), startKey, evalKey, (0, _FormSpec.ClinicalPathway_TransitionCondition_Always)(), idx),
|
|
919
|
+
new _FormSpec.ClinicalPathway_TransitionDefinition(new _FormSpec.Shared_TransitionKey(stableGuid(`${pathwayId}_eval_to_action_${tid}`)), evalKey, actionKey, condition, idx),
|
|
920
|
+
new _FormSpec.ClinicalPathway_TransitionDefinition(new _FormSpec.Shared_TransitionKey(stableGuid(`${pathwayId}_action_to_end_${tid}`)), actionKey, endKey, (0, _FormSpec.ClinicalPathway_TransitionCondition_Always)(), undefined)
|
|
921
|
+
]);
|
|
922
|
+
allStates = (0, _List.append)(allStates, (0, _List.ofArray)([
|
|
923
|
+
evalState,
|
|
924
|
+
actionState,
|
|
925
|
+
endState
|
|
926
|
+
]));
|
|
927
|
+
allTransitions = (0, _List.append)(allTransitions, transitions);
|
|
928
|
+
}
|
|
929
|
+
} finally{
|
|
930
|
+
(0, _Util.disposeSafe)(enumerator);
|
|
931
|
+
}
|
|
932
|
+
return new _FormSpec.ClinicalPathway_ClinicalPathwaySpec(pathwayId, `${form.Name} - Clinical Pathway`, "1.0.0", "CoreMR Conduit - Unified Item Triggers", (0, _FormSpec.ClinicalPathway_PathwayExecutionMode_MultiPathway)(new _FormSpec.ClinicalPathway_MultiPathwayConfig((0, _FormSpec.ClinicalPathway_CombinationStrategy_AllMatching)(), (0, _FormSpec.ClinicalPathway_ConflictResolution_CombineActions)(), undefined)), startKey, allStates, allTransitions, (0, _List.empty)(), (0, _List.empty)(), importedAt, undefined, undefined, 1);
|
|
933
|
+
}
|
|
934
|
+
} else {
|
|
935
|
+
return undefined;
|
|
936
|
+
}
|
|
937
|
+
} //# sourceMappingURL=CoreMRPathwayMapper.ts.map
|
|
938
|
+
|
|
939
|
+
//# sourceMappingURL=CoreMRPathwayMapper.js.map
|