@f1studio/form-spec 5.0.0-alpha.117 → 5.0.0-alpha.123
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/FormSpec.d.ts +41 -1
- package/FormSpec.FS/FormSpec.d.ts.map +1 -1
- package/FormSpec.FS/FormSpecHelpers.d.ts.map +1 -1
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRAdapter.d.ts +6 -1
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRAdapter.d.ts.map +1 -1
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRElementTypeMap.d.ts +5 -0
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRElementTypeMap.d.ts.map +1 -1
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateMapper.d.ts +72 -0
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateMapper.d.ts.map +1 -0
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateToFormSpec.d.ts.map +1 -1
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMREncoder.d.ts.map +1 -1
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRSourceMap.d.ts +15 -9
- package/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRSourceMap.d.ts.map +1 -1
- package/FormSpec.FS/Interop/FormSpec.Api.Helpers.d.ts +0 -7
- package/FormSpec.FS/Interop/FormSpec.Api.Helpers.d.ts.map +1 -1
- package/FormSpec.FS/Interop/FormSpec.Api.Option.d.ts.map +1 -1
- package/FormSpec.TS/FormSpec.FS/BlueprintValidation.js +1 -1
- package/FormSpec.TS/FormSpec.FS/BlueprintValidation.js.map +1 -1
- package/FormSpec.TS/FormSpec.FS/BlueprintValidation.ts.map +1 -1
- package/FormSpec.TS/FormSpec.FS/Designer.js +1 -1
- package/FormSpec.TS/FormSpec.FS/Designer.js.map +1 -1
- package/FormSpec.TS/FormSpec.FS/Designer.ts.map +1 -1
- package/FormSpec.TS/FormSpec.FS/FormSpec.js +129 -1
- package/FormSpec.TS/FormSpec.FS/FormSpec.js.map +1 -1
- package/FormSpec.TS/FormSpec.FS/FormSpec.ts.map +1 -1
- package/FormSpec.TS/FormSpec.FS/FormSpecHelpers.js +1 -1
- package/FormSpec.TS/FormSpec.FS/FormSpecHelpers.js.map +1 -1
- package/FormSpec.TS/FormSpec.FS/FormSpecHelpers.ts.map +1 -1
- package/FormSpec.TS/FormSpec.FS/FormSpecValues.js +2 -2
- package/FormSpec.TS/FormSpec.FS/FormSpecValues.js.map +1 -1
- package/FormSpec.TS/FormSpec.FS/FormSpecValues.ts.map +1 -1
- package/FormSpec.TS/FormSpec.FS/Helpers.js +11 -11
- package/FormSpec.TS/FormSpec.FS/Helpers.js.map +1 -1
- package/FormSpec.TS/FormSpec.FS/Helpers.ts.map +1 -1
- package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRAdapter.js +4 -4
- package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRAdapter.js.map +1 -1
- package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRAdapter.ts.map +1 -1
- package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRElementTypeMap.js +9 -2
- package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRElementTypeMap.js.map +1 -1
- package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRElementTypeMap.ts.map +1 -1
- package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateMapper.js +360 -0
- package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateMapper.js.map +1 -0
- package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateMapper.ts.map +1 -0
- package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateToFormSpec.js +1 -1
- package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateToFormSpec.js.map +1 -1
- package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateToFormSpec.ts.map +1 -1
- package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMREncoder.js +119 -46
- package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMREncoder.js.map +1 -1
- package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMREncoder.ts.map +1 -1
- package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRSourceMap.js +40 -24
- package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRSourceMap.js.map +1 -1
- package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRSourceMap.ts.map +1 -1
- package/FormSpec.TS/FormSpec.FS/Interop/FormSpec.Api.Helpers.js +41 -106
- package/FormSpec.TS/FormSpec.FS/Interop/FormSpec.Api.Helpers.js.map +1 -1
- package/FormSpec.TS/FormSpec.FS/Interop/FormSpec.Api.Helpers.ts.map +1 -1
- package/FormSpec.TS/FormSpec.FS/Interop/FormSpec.Api.Option.js +1 -1
- package/FormSpec.TS/FormSpec.FS/Interop/FormSpec.Api.Option.js.map +1 -1
- package/FormSpec.TS/FormSpec.FS/Interop/FormSpec.Api.Option.ts.map +1 -1
- package/FormSpec.TS/fable_modules/Thoth.Json.10.4.1/Encode.fs.js.map +1 -1
- package/FormSpec.TS/fable_modules/Thoth.Json.10.4.1/Encode.fs.ts.map +1 -1
- package/FormSpec.TS/fable_modules/project_cracked.json +1 -1
- package/FormSpec.TS/plugins/bmi/src/BMIField.js +193 -275
- package/FormSpec.TS/plugins/bmi/src/BMIField.js.map +1 -1
- package/FormSpec.TS/plugins/bmi/src/BMIField.ts.map +1 -1
- package/FormSpec.TS/plugins/likert/src/LikertField.js +19 -138
- package/FormSpec.TS/plugins/likert/src/LikertField.js.map +1 -1
- package/FormSpec.TS/plugins/likert/src/LikertField.ts.map +1 -1
- package/README.md +19 -13
- package/package.json +1 -1
- package/plugins/bmi/src/BMIField.d.ts.map +1 -1
- package/plugins/likert/src/LikertField.d.ts.map +1 -1
- package/src/FormSpec.FS/BlueprintValidation.ts +1 -1
- package/src/FormSpec.FS/Designer.ts +1 -1
- package/src/FormSpec.FS/FormSpec.ts +92 -2
- package/src/FormSpec.FS/FormSpecHelpers.ts +2 -2
- package/src/FormSpec.FS/FormSpecValues.ts +2 -2
- package/src/FormSpec.FS/Helpers.ts +11 -11
- package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRAdapter.ts +8 -4
- package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRElementTypeMap.ts +11 -2
- package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateMapper.ts +222 -0
- package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateToFormSpec.ts +2 -2
- package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMREncoder.ts +123 -51
- package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMRSourceMap.ts +44 -25
- package/src/FormSpec.FS/Interop/FormSpec.Api.Helpers.ts +57 -102
- package/src/FormSpec.FS/Interop/FormSpec.Api.Option.ts +2 -2
- package/src/plugins/bmi/src/BMIField.ts +62 -82
- package/src/plugins/likert/src/LikertField.ts +20 -95
- package/FormSpec.FS/Interop/PluginPropertyKeyRegistry.d.ts +0 -16
- package/FormSpec.FS/Interop/PluginPropertyKeyRegistry.d.ts.map +0 -1
- package/FormSpec.TS/FormSpec.FS/Interop/PluginPropertyKeyRegistry.js +0 -121
- package/FormSpec.TS/FormSpec.FS/Interop/PluginPropertyKeyRegistry.js.map +0 -1
- package/FormSpec.TS/FormSpec.FS/Interop/PluginPropertyKeyRegistry.ts.map +0 -1
- package/fable_modules/Feliz.2.8.0/Colors.fs.d.ts +0 -9
- package/fable_modules/Feliz.2.8.0/Colors.fs.d.ts.map +0 -1
- package/src/FormSpec.FS/Interop/PluginPropertyKeyRegistry.ts +0 -96
|
@@ -2,20 +2,20 @@ import { CoreMRStepMap, CoreMRSourceMap, CoreMRSourceMap_$reflection, CoreMRFiel
|
|
|
2
2
|
import { CaseStrategy_CamelCase, ErrorReason_$union, ExtraCoders } from "../../../../fable_modules/Thoth.Json.10.4.1/Types.fs.js";
|
|
3
3
|
import { fromString, Auto_generateBoxedDecoder_Z6670B51 } from "../../../../fable_modules/Thoth.Json.10.4.1/Decode.fs.js";
|
|
4
4
|
import { FSharpResult$2_Ok, FSharpResult$2_Error, FSharpResult$2_$union } from "@fable-org/fable-library-js/Result.js";
|
|
5
|
-
import { Spec_FormSpec$1, Spec_FormStep$1,
|
|
5
|
+
import { Spec_FormSpec$1, Spec_FormStep$1, Spec_FormField$1, Shared_PluginDataProperty, Shared_MatrixItemKey, Shared_MatrixAnswer, Shared_FieldAnswer, Shared_FieldValue, Shared_FieldValue_$union, Spec_FieldType_$union, Spec_MultiChoiceInfo, Spec_SingleChoiceInfo, Shared_FieldOption, Shared_FieldOptionKey, Shared_FieldKey, Shared_FieldKey_$reflection } from "../../../FormSpec.js";
|
|
6
6
|
import { toString, Auto_generateBoxedEncoder_437914C6 } from "../../../../fable_modules/Thoth.Json.10.4.1/Encode.fs.js";
|
|
7
7
|
import { newGuid } from "@fable-org/fable-library-js/Guid.js";
|
|
8
8
|
import { FSharpMap, ofList, tryFind as tryFind_1, add } from "@fable-org/fable-library-js/Map.js";
|
|
9
9
|
import { IOptionalGetter, IRequiredGetter, IGetters, list as list_9, bool, string, int, object } from "../../../../fable_modules/Thoth.Json.10.4.1/Decode.fs.js";
|
|
10
10
|
import { comparePrimitives, uncurry2 } from "@fable-org/fable-library-js/Util.js";
|
|
11
11
|
import { int32 } from "@fable-org/fable-library-js/Int32.js";
|
|
12
|
-
import { collect, exists,
|
|
12
|
+
import { collect, exists, head, tail, choose, isEmpty, map as map_1, singleton, tryFind, empty, FSharpList } from "@fable-org/fable-library-js/List.js";
|
|
13
13
|
import { orElse, value as value_10, Option, map, bind, defaultArg } from "@fable-org/fable-library-js/Option.js";
|
|
14
14
|
import { CoreMRAnswer, CoreMRFormInsertRequest, CoreMRFormInsertRequest_$reflection } from "./FormSpecToCoreMRInsert.js";
|
|
15
15
|
import { isNullOrWhiteSpace } from "@fable-org/fable-library-js/String.js";
|
|
16
16
|
import { int64, fromInt32, toInt64 } from "@fable-org/fable-library-js/BigInt.js";
|
|
17
|
+
import { toList, FSharpSet } from "@fable-org/fable-library-js/Set.js";
|
|
17
18
|
import { computeBitmask } from "../../../BitmaskHelpers.js";
|
|
18
|
-
import { FSharpSet, toList } from "@fable-org/fable-library-js/Set.js";
|
|
19
19
|
|
|
20
20
|
const baseExtra: ExtraCoders = coreMRExtra;
|
|
21
21
|
|
|
@@ -72,6 +72,15 @@ function getScoreFromOption(options: FSharpList<Shared_FieldOption>, selectedVal
|
|
|
72
72
|
return bind<Shared_FieldOption, int64>((opt_1: Shared_FieldOption): Option<int64> => map<int32, int64>((value: int32): int64 => toInt64(fromInt32(value)), opt_1.Score), tryFind<Shared_FieldOption>((opt: Shared_FieldOption): boolean => (canonicalize(opt.Value) === canonicalSelected), options));
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
+
function supportsTextContent(anchor: CoreMRFieldAnchor): boolean {
|
|
76
|
+
if (anchor.Encoding.TextFieldRole === "content") {
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
return anchor.Encoding.TextFieldRole === "iso_date";
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
75
84
|
function getOptionsFromFieldType(ft: Spec_FieldType_$union): FSharpList<Shared_FieldOption> {
|
|
76
85
|
let matchResult: int32, info: Spec_SingleChoiceInfo, info_1: Spec_MultiChoiceInfo;
|
|
77
86
|
switch (ft.tag) {
|
|
@@ -129,42 +138,8 @@ function getOptionsFromFieldType(ft: Spec_FieldType_$union): FSharpList<Shared_F
|
|
|
129
138
|
}
|
|
130
139
|
}
|
|
131
140
|
|
|
132
|
-
function withDocumentation(field: Spec_FormField$1<Spec_FieldType_$union>, answers: FSharpList<CoreMRAnswer>): FSharpList<CoreMRAnswer> {
|
|
133
|
-
if (!field.NeedsDocumentation) {
|
|
134
|
-
return answers;
|
|
135
|
-
}
|
|
136
|
-
else {
|
|
137
|
-
const matchValue: Option<string> = field.Documentation;
|
|
138
|
-
let matchResult: int32, doc: string;
|
|
139
|
-
if (matchValue != null) {
|
|
140
|
-
if (value_10(matchValue) === "") {
|
|
141
|
-
matchResult = 0;
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
matchResult = 1;
|
|
145
|
-
doc = value_10(matchValue);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
else {
|
|
149
|
-
matchResult = 0;
|
|
150
|
-
}
|
|
151
|
-
switch (matchResult) {
|
|
152
|
-
case 0:
|
|
153
|
-
return answers;
|
|
154
|
-
default:
|
|
155
|
-
if (!isEmpty(answers)) {
|
|
156
|
-
const first: CoreMRAnswer = head(answers);
|
|
157
|
-
return cons(new CoreMRAnswer(first.Sequence, first.Value, doc!), tail(answers));
|
|
158
|
-
}
|
|
159
|
-
else {
|
|
160
|
-
return answers;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
141
|
function fieldToAnswers(field: Spec_FormField$1<Spec_FieldType_$union>, anchor: CoreMRFieldAnchor): FSharpList<CoreMRAnswer> {
|
|
167
|
-
let
|
|
142
|
+
let canonicalAnswer: string;
|
|
168
143
|
if (anchor.Encoding.IsSkip) {
|
|
169
144
|
return empty<CoreMRAnswer>();
|
|
170
145
|
}
|
|
@@ -172,21 +147,118 @@ function fieldToAnswers(field: Spec_FormField$1<Spec_FieldType_$union>, anchor:
|
|
|
172
147
|
return singleton(new CoreMRAnswer(anchor.Sequence, 2n, undefined));
|
|
173
148
|
}
|
|
174
149
|
else {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
150
|
+
const matchValue: Option<Shared_FieldValue_$union> = field.Value;
|
|
151
|
+
if (matchValue != null) {
|
|
152
|
+
switch (value_10(matchValue).tag) {
|
|
153
|
+
case /* Multiple */ 1: {
|
|
154
|
+
const answers: FSharpSet<Shared_FieldAnswer> = (value_10(matchValue) as Shared_FieldValue<1>).fields[0];
|
|
155
|
+
if (anchor.Encoding.ValueEncoding !== "choice_score") {
|
|
156
|
+
return empty<CoreMRAnswer>();
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
const options_1: FSharpList<Shared_FieldOption> = getOptionsFromFieldType(field.FieldType);
|
|
160
|
+
const choicesWithBitPos: FSharpList<[string, int32]> = map_1<CoreMRChoiceAnchor, [string, int32]>((c_2: CoreMRChoiceAnchor): [string, int32] => {
|
|
161
|
+
const bit: int32 = defaultArg(c_2.BitPosition, c_2.Sequence - 1) | 0;
|
|
162
|
+
return [getFieldOptionKeyGuid(c_2.FieldOptionKey), bit] as [string, int32];
|
|
163
|
+
}, anchor.Choices);
|
|
164
|
+
if (isEmpty(choicesWithBitPos)) {
|
|
165
|
+
return empty<CoreMRAnswer>();
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
return singleton(new CoreMRAnswer(anchor.Sequence, computeBitmask(choose<string, int32>((key: string): Option<int32> => map<[string, int32], int32>((tuple: [string, int32]): int32 => tuple[1], tryFind<[string, int32]>((tupledArg: [string, int32]): boolean => (tupledArg[0] === key), choicesWithBitPos)), choose<string, string>((valStr_1: string): Option<string> => map<Shared_FieldOption, string>((opt_2: Shared_FieldOption): string => getFieldOptionKeyGuid(opt_2.OptionKey), tryFind<Shared_FieldOption>((opt_1: Shared_FieldOption): boolean => (canonicalize(opt_1.Value) === canonicalize(valStr_1)), options_1)), map_1<Shared_FieldAnswer, string>((a: Shared_FieldAnswer): string => a.Value, toList<Shared_FieldAnswer>(answers))))), undefined));
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
case /* Matrix */ 2: {
|
|
173
|
+
const matrixAnswer: Shared_MatrixAnswer = (value_10(matchValue) as Shared_FieldValue<2>).fields[0];
|
|
174
|
+
if (isEmpty(anchor.MatrixItemAnchors)) {
|
|
175
|
+
return empty<CoreMRAnswer>();
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
const options_2: FSharpList<Shared_FieldOption> = getOptionsFromFieldType(field.FieldType);
|
|
179
|
+
return choose<CoreMRMatrixItemAnchor, CoreMRAnswer>((rowAnchor: CoreMRMatrixItemAnchor): Option<CoreMRAnswer> => map<string, CoreMRAnswer>((selectedValue: string): CoreMRAnswer => (new CoreMRAnswer(rowAnchor.Sequence, defaultArg(getScoreFromOption(options_2, selectedValue), 0n), undefined)), tryFind_1<Shared_MatrixItemKey, string>(rowAnchor.MatrixItemKey, matrixAnswer.Values)), anchor.MatrixItemAnchors);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
case /* PluginData */ 3: {
|
|
183
|
+
const props: FSharpList<Shared_PluginDataProperty> = (value_10(matchValue) as Shared_FieldValue<3>).fields[0];
|
|
184
|
+
let matchResult: int32, p_1: Shared_PluginDataProperty;
|
|
185
|
+
if (!isEmpty(props)) {
|
|
186
|
+
if (isEmpty(tail(props))) {
|
|
187
|
+
if (!isNullOrWhiteSpace(head(props).Value)) {
|
|
188
|
+
matchResult = 0;
|
|
189
|
+
p_1 = head(props);
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
matchResult = 1;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
matchResult = 1;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
matchResult = 1;
|
|
201
|
+
}
|
|
202
|
+
switch (matchResult) {
|
|
203
|
+
case 0:
|
|
204
|
+
return singleton(new CoreMRAnswer(anchor.Sequence, 0n, supportsTextContent(anchor) ? p_1!.Value : undefined));
|
|
205
|
+
default:
|
|
206
|
+
return empty<CoreMRAnswer>();
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
default: {
|
|
210
|
+
const answer: Shared_FieldAnswer = (value_10(matchValue) as Shared_FieldValue<0>).fields[0];
|
|
211
|
+
const options: FSharpList<Shared_FieldOption> = getOptionsFromFieldType(field.FieldType);
|
|
212
|
+
const matchValue_2: string = anchor.Encoding.ValueEncoding;
|
|
213
|
+
switch (matchValue_2) {
|
|
214
|
+
case "choice_score": {
|
|
215
|
+
const matchValue_3: Option<int64> = orElse(getScoreFromOption(options, answer.Value), (canonicalAnswer = canonicalize(answer.Value), map<CoreMRChoiceAnchor, int64>((c_1: CoreMRChoiceAnchor): int64 => c_1.Score, tryFind<CoreMRChoiceAnchor>((c: CoreMRChoiceAnchor): boolean => exists<Shared_FieldOption>((opt: Shared_FieldOption): boolean => {
|
|
216
|
+
if (getFieldOptionKeyGuid(opt.OptionKey) === getFieldOptionKeyGuid(c.FieldOptionKey)) {
|
|
217
|
+
return canonicalize(opt.Value) === canonicalAnswer;
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
return false;
|
|
221
|
+
}
|
|
222
|
+
}, options), anchor.Choices))));
|
|
223
|
+
if (matchValue_3 == null) {
|
|
224
|
+
return singleton(new CoreMRAnswer(anchor.Sequence, 0n, undefined));
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
return singleton(new CoreMRAnswer(anchor.Sequence, value_10(matchValue_3), undefined));
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
case "1_yes_2_no": {
|
|
231
|
+
const valStr: string = canonicalize(answer.Value);
|
|
232
|
+
return singleton(new CoreMRAnswer(anchor.Sequence, (((valStr === "yes") ? true : (valStr === "true")) ? true : (valStr === "1")) ? (1n) : (2n), undefined));
|
|
233
|
+
}
|
|
234
|
+
case "zero":
|
|
235
|
+
case "scaffold":
|
|
236
|
+
case "unknown":
|
|
237
|
+
return singleton(new CoreMRAnswer(anchor.Sequence, 0n, supportsTextContent(anchor) ? answer.Value : undefined));
|
|
238
|
+
default:
|
|
239
|
+
return singleton(new CoreMRAnswer(anchor.Sequence, 0n, supportsTextContent(anchor) ? answer.Value : undefined));
|
|
240
|
+
}
|
|
241
|
+
}
|
|
185
242
|
}
|
|
186
|
-
|
|
187
|
-
|
|
243
|
+
}
|
|
244
|
+
else {
|
|
245
|
+
const matchValue_1: string = anchor.Encoding.ValueEncoding;
|
|
246
|
+
switch (matchValue_1) {
|
|
247
|
+
case "1_yes_2_no":
|
|
248
|
+
return singleton(new CoreMRAnswer(anchor.Sequence, 2n, undefined));
|
|
249
|
+
case "choice_score":
|
|
250
|
+
if (isEmpty(anchor.Choices)) {
|
|
251
|
+
return empty<CoreMRAnswer>();
|
|
252
|
+
}
|
|
253
|
+
else {
|
|
254
|
+
return singleton(new CoreMRAnswer(anchor.Sequence, 0n, undefined));
|
|
255
|
+
}
|
|
256
|
+
case "zero":
|
|
257
|
+
return singleton(new CoreMRAnswer(anchor.Sequence, 0n, undefined));
|
|
258
|
+
default:
|
|
259
|
+
return empty<CoreMRAnswer>();
|
|
188
260
|
}
|
|
189
|
-
}
|
|
261
|
+
}
|
|
190
262
|
}
|
|
191
263
|
}
|
|
192
264
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { newGuid } from "@fable-org/fable-library-js/Guid.js";
|
|
2
|
-
import {
|
|
2
|
+
import { ofList, FSharpMap, tryFind, add } from "@fable-org/fable-library-js/Map.js";
|
|
3
3
|
import { Auto_generateBoxedEncoder_437914C6, toString, int64 } from "../../../../fable_modules/Thoth.Json.10.4.1/Encode.fs.js";
|
|
4
4
|
import { int64 as int64_1 } from "@fable-org/fable-library-js/BigInt.js";
|
|
5
5
|
import { int64 as int64_2 } from "../../../../fable_modules/Thoth.Json.10.4.1/Decode.fs.js";
|
|
@@ -11,9 +11,9 @@ import { numberHash, comparePrimitives, IComparable, IEquatable } from "@fable-o
|
|
|
11
11
|
import { class_type, list_type, option_type, int64_type, int32_type, record_type, bool_type, string_type, TypeInfo } from "@fable-org/fable-library-js/Reflection.js";
|
|
12
12
|
import { getElementTypeInfo, ElementTypeInfo } from "./CorEMRElementTypeMap.js";
|
|
13
13
|
import { int32 } from "@fable-org/fable-library-js/Int32.js";
|
|
14
|
-
import { map, value as value_2
|
|
15
|
-
import { Spec_FormStep$1, Spec_FormField$1, Spec_MultiChoiceInfo, Spec_SingleChoiceInfo, Shared_FieldOption, Spec_FormSpec$1_$reflection, Spec_FieldType_$reflection, Spec_FieldType_$union, Spec_FormSpec$1, Shared_FieldKey_$reflection, Shared_FieldKey, Shared_MatrixItemKey_$reflection, Shared_MatrixItemKey, Shared_FieldOptionKey_$reflection, Shared_FieldOptionKey } from "../../../FormSpec.js";
|
|
16
|
-
import { tryFind, choose, item as item_1, length, mapIndexed, sortBy, empty as empty_1, FSharpList } from "@fable-org/fable-library-js/List.js";
|
|
14
|
+
import { map, defaultArg, Option, value as value_2 } from "@fable-org/fable-library-js/Option.js";
|
|
15
|
+
import { Spec_FormClassification_General, Spec_FormStep$1, Spec_FormField$1, Spec_MultiChoiceInfo, Spec_SingleChoiceInfo, Shared_FieldOption, Spec_FormSpec$1_$reflection, Spec_FieldType_$reflection, Spec_FieldType_$union, Spec_FormSpec$1, Spec_FormClassification_$reflection, Spec_FormClassification_$union, Shared_FieldKey_$reflection, Shared_FieldKey, Shared_MatrixItemKey_$reflection, Shared_MatrixItemKey, Shared_FieldOptionKey_$reflection, Shared_FieldOptionKey } from "../../../FormSpec.js";
|
|
16
|
+
import { tryFind as tryFind_1, choose, item as item_1, length, mapIndexed, sortBy, empty as empty_1, FSharpList } from "@fable-org/fable-library-js/List.js";
|
|
17
17
|
import { CoreMRFormData, CoreMRItem, CoreMRChoice, CoreMRTag_$reflection, CoreMRTrigger_$reflection, CoreMRTag, CoreMRTrigger } from "../../CorEMR/CoreMRTypes.js";
|
|
18
18
|
import { List_groupBy } from "@fable-org/fable-library-js/Seq2.js";
|
|
19
19
|
import { detectHeadings, groupItemsByHeadings, Section, HeadingItem } from "./CorEMRSectioning.js";
|
|
@@ -53,6 +53,21 @@ function getValueEncoding(itemTypeId: int32): ValueEncodingInfo {
|
|
|
53
53
|
return toValueEncodingInfo(getElementTypeInfo(itemTypeId));
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
+
function getValueEncodingWithOverride(elementTypes: Option<FSharpMap<int32, ElementTypeInfo>>, itemTypeId: int32): ValueEncodingInfo {
|
|
57
|
+
if (elementTypes == null) {
|
|
58
|
+
return getValueEncoding(itemTypeId);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
const matchValue: Option<ElementTypeInfo> = tryFind<int32, ElementTypeInfo>(itemTypeId, value_2(elementTypes));
|
|
62
|
+
if (matchValue == null) {
|
|
63
|
+
return getValueEncoding(itemTypeId);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
return toValueEncodingInfo(value_2(matchValue));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
56
71
|
export class CoreMRChoiceAnchor extends Record implements IEquatable<CoreMRChoiceAnchor>, IComparable<CoreMRChoiceAnchor> {
|
|
57
72
|
readonly ChoiceId: int32;
|
|
58
73
|
readonly Sequence: int32;
|
|
@@ -191,11 +206,10 @@ export class CoreMRSourceMap extends Record implements IEquatable<CoreMRSourceMa
|
|
|
191
206
|
readonly FormCode: string;
|
|
192
207
|
readonly FormCodeSource: string;
|
|
193
208
|
readonly Description: Option<string>;
|
|
194
|
-
readonly IsIntake: boolean;
|
|
195
209
|
readonly RequiresSignature: boolean;
|
|
196
|
-
readonly IsScored: Option<boolean>;
|
|
197
210
|
readonly EncounterTypes: FSharpList<string>;
|
|
198
211
|
readonly Usage: Option<string>;
|
|
212
|
+
readonly Classification: Spec_FormClassification_$union;
|
|
199
213
|
readonly StructureHash: Option<string>;
|
|
200
214
|
readonly ClinicalHash: Option<string>;
|
|
201
215
|
readonly CosmeticHash: Option<string>;
|
|
@@ -204,7 +218,7 @@ export class CoreMRSourceMap extends Record implements IEquatable<CoreMRSourceMa
|
|
|
204
218
|
readonly Triggers: FSharpList<CoreMRTrigger>;
|
|
205
219
|
readonly Tags: FSharpList<CoreMRTag>;
|
|
206
220
|
readonly FormSpecId: string;
|
|
207
|
-
constructor(FormId: int32, VersionId: int32, VersionNumber: int32, FormName: Option<string>, FormCode: string, FormCodeSource: string, Description: Option<string>,
|
|
221
|
+
constructor(FormId: int32, VersionId: int32, VersionNumber: int32, FormName: Option<string>, FormCode: string, FormCodeSource: string, Description: Option<string>, RequiresSignature: boolean, EncounterTypes: FSharpList<string>, Usage: Option<string>, Classification: Spec_FormClassification_$union, StructureHash: Option<string>, ClinicalHash: Option<string>, CosmeticHash: Option<string>, Steps: FSharpList<CoreMRStepMap>, AbsorbedItems: FSharpList<CoreMRAbsorbedItem>, Triggers: FSharpList<CoreMRTrigger>, Tags: FSharpList<CoreMRTag>, FormSpecId: string) {
|
|
208
222
|
super();
|
|
209
223
|
this.FormId = (FormId | 0);
|
|
210
224
|
this.VersionId = (VersionId | 0);
|
|
@@ -213,11 +227,10 @@ export class CoreMRSourceMap extends Record implements IEquatable<CoreMRSourceMa
|
|
|
213
227
|
this.FormCode = FormCode;
|
|
214
228
|
this.FormCodeSource = FormCodeSource;
|
|
215
229
|
this.Description = Description;
|
|
216
|
-
this.IsIntake = IsIntake;
|
|
217
230
|
this.RequiresSignature = RequiresSignature;
|
|
218
|
-
this.IsScored = IsScored;
|
|
219
231
|
this.EncounterTypes = EncounterTypes;
|
|
220
232
|
this.Usage = Usage;
|
|
233
|
+
this.Classification = Classification;
|
|
221
234
|
this.StructureHash = StructureHash;
|
|
222
235
|
this.ClinicalHash = ClinicalHash;
|
|
223
236
|
this.CosmeticHash = CosmeticHash;
|
|
@@ -230,7 +243,7 @@ export class CoreMRSourceMap extends Record implements IEquatable<CoreMRSourceMa
|
|
|
230
243
|
}
|
|
231
244
|
|
|
232
245
|
export function CoreMRSourceMap_$reflection(): TypeInfo {
|
|
233
|
-
return record_type("FormSpec.Integrations.CorEMR.CoreMRSourceMap.CoreMRSourceMap", [], CoreMRSourceMap, () => [["FormId", int32_type], ["VersionId", int32_type], ["VersionNumber", int32_type], ["FormName", option_type(string_type)], ["FormCode", string_type], ["FormCodeSource", string_type], ["Description", option_type(string_type)], ["
|
|
246
|
+
return record_type("FormSpec.Integrations.CorEMR.CoreMRSourceMap.CoreMRSourceMap", [], CoreMRSourceMap, () => [["FormId", int32_type], ["VersionId", int32_type], ["VersionNumber", int32_type], ["FormName", option_type(string_type)], ["FormCode", string_type], ["FormCodeSource", string_type], ["Description", option_type(string_type)], ["RequiresSignature", bool_type], ["EncounterTypes", list_type(string_type)], ["Usage", option_type(string_type)], ["Classification", Spec_FormClassification_$reflection()], ["StructureHash", option_type(string_type)], ["ClinicalHash", option_type(string_type)], ["CosmeticHash", option_type(string_type)], ["Steps", list_type(CoreMRStepMap_$reflection())], ["AbsorbedItems", list_type(CoreMRAbsorbedItem_$reflection())], ["Triggers", list_type(CoreMRTrigger_$reflection())], ["Tags", list_type(CoreMRTag_$reflection())], ["FormSpecId", class_type("System.Guid")]]);
|
|
234
247
|
}
|
|
235
248
|
|
|
236
249
|
export class CoreMRConversionResult extends Record implements IEquatable<CoreMRConversionResult>, IComparable<CoreMRConversionResult> {
|
|
@@ -298,8 +311,8 @@ function getFieldOptions(field: Spec_FormField$1<Spec_FieldType_$union>): FSharp
|
|
|
298
311
|
/**
|
|
299
312
|
* Build a FieldAnchor from a CoreMR item and its mapped FormField
|
|
300
313
|
*/
|
|
301
|
-
export function buildFieldAnchor(item: CoreMRItem, choices: FSharpList<CoreMRChoice>, field: Spec_FormField$1<Spec_FieldType_$union>): CoreMRFieldAnchor {
|
|
302
|
-
const encoding: ValueEncodingInfo =
|
|
314
|
+
export function buildFieldAnchor(elementTypes: Option<FSharpMap<int32, ElementTypeInfo>>, item: CoreMRItem, choices: FSharpList<CoreMRChoice>, field: Spec_FormField$1<Spec_FieldType_$union>): CoreMRFieldAnchor {
|
|
315
|
+
const encoding: ValueEncodingInfo = getValueEncodingWithOverride(elementTypes, item.ItemTypeId);
|
|
303
316
|
const sortedChoices: FSharpList<CoreMRChoice> = sortBy<CoreMRChoice, int32>((c: CoreMRChoice): int32 => c.Sequence, choices, {
|
|
304
317
|
Compare: comparePrimitives,
|
|
305
318
|
});
|
|
@@ -311,24 +324,28 @@ export class ListMetadata extends Record implements IEquatable<ListMetadata>, IC
|
|
|
311
324
|
readonly IsIntake: Option<boolean>;
|
|
312
325
|
readonly IsScored: Option<boolean>;
|
|
313
326
|
readonly EncounterTypes: FSharpList<string>;
|
|
314
|
-
|
|
327
|
+
readonly Usage: Option<string>;
|
|
328
|
+
readonly Classification: Spec_FormClassification_$union;
|
|
329
|
+
constructor(IsIntake: Option<boolean>, IsScored: Option<boolean>, EncounterTypes: FSharpList<string>, Usage: Option<string>, Classification: Spec_FormClassification_$union) {
|
|
315
330
|
super();
|
|
316
331
|
this.IsIntake = IsIntake;
|
|
317
332
|
this.IsScored = IsScored;
|
|
318
333
|
this.EncounterTypes = EncounterTypes;
|
|
334
|
+
this.Usage = Usage;
|
|
335
|
+
this.Classification = Classification;
|
|
319
336
|
}
|
|
320
337
|
}
|
|
321
338
|
|
|
322
339
|
export function ListMetadata_$reflection(): TypeInfo {
|
|
323
|
-
return record_type("FormSpec.Integrations.CorEMR.CoreMRSourceMap.ListMetadata", [], ListMetadata, () => [["IsIntake", option_type(bool_type)], ["IsScored", option_type(bool_type)], ["EncounterTypes", list_type(string_type)]]);
|
|
340
|
+
return record_type("FormSpec.Integrations.CorEMR.CoreMRSourceMap.ListMetadata", [], ListMetadata, () => [["IsIntake", option_type(bool_type)], ["IsScored", option_type(bool_type)], ["EncounterTypes", list_type(string_type)], ["Usage", option_type(string_type)], ["Classification", Spec_FormClassification_$reflection()]]);
|
|
324
341
|
}
|
|
325
342
|
|
|
326
343
|
/**
|
|
327
344
|
* Build the complete SourceMap from raw CoreMR data and the resulting FormSpec.
|
|
328
345
|
* When listMetadata is Some (from FormListItem during import), IsScored and EncounterTypes are populated.
|
|
346
|
+
* When elementTypes is Some (from bridge templates endpoint), use it for ValueEncoding; else fallback to CorEMRElementTypeMap.
|
|
329
347
|
*/
|
|
330
|
-
export function buildSourceMap(formData: CoreMRFormData, formSpec: Spec_FormSpec$1<Spec_FieldType_$union>, listMetadata: Option<ListMetadata>): CoreMRSourceMap {
|
|
331
|
-
let matchValue: Option<boolean>;
|
|
348
|
+
export function buildSourceMap(elementTypes: Option<FSharpMap<int32, ElementTypeInfo>>, formData: CoreMRFormData, formSpec: Spec_FormSpec$1<Spec_FieldType_$union>, listMetadata: Option<ListMetadata>): CoreMRSourceMap {
|
|
332
349
|
const formCode: string = defaultArg(formSpec.Code, `CORE-${formData.Metadata.FormId}`);
|
|
333
350
|
const choicesByItem: FSharpMap<int32, FSharpList<CoreMRChoice>> = ofList<int32, FSharpList<CoreMRChoice>>(List_groupBy<CoreMRChoice, int32>((c: CoreMRChoice): int32 => c.ItemId, formData.Choices, {
|
|
334
351
|
Equals: (x: int32, y: int32): boolean => (x === y),
|
|
@@ -339,7 +356,7 @@ export function buildSourceMap(formData: CoreMRFormData, formSpec: Spec_FormSpec
|
|
|
339
356
|
let stepOrder = 0;
|
|
340
357
|
const stepMaps: FSharpList<CoreMRStepMap> = choose<Section, CoreMRStepMap>((section: Section): Option<CoreMRStepMap> => {
|
|
341
358
|
stepOrder = ((stepOrder + 1) | 0);
|
|
342
|
-
const formStep: Option<Spec_FormStep$1<Spec_FieldType_$union>> =
|
|
359
|
+
const formStep: Option<Spec_FormStep$1<Spec_FieldType_$union>> = tryFind_1<Spec_FormStep$1<Spec_FieldType_$union>>((s: Spec_FormStep$1<Spec_FieldType_$union>): boolean => (s.StepOrder === stepOrder), formSpec.Steps);
|
|
343
360
|
if (formStep != null) {
|
|
344
361
|
const step: Spec_FormStep$1<Spec_FieldType_$union> = value_2(formStep);
|
|
345
362
|
if (length(section.Items) !== length(step.Fields)) {
|
|
@@ -347,7 +364,7 @@ export function buildSourceMap(formData: CoreMRFormData, formSpec: Spec_FormSpec
|
|
|
347
364
|
}
|
|
348
365
|
const fieldAnchors: FSharpList<CoreMRFieldAnchor> = mapIndexed<CoreMRItem, CoreMRFieldAnchor>((i: int32, item: CoreMRItem): CoreMRFieldAnchor => {
|
|
349
366
|
const field: Spec_FormField$1<Spec_FieldType_$union> = item_1(i, step.Fields);
|
|
350
|
-
return buildFieldAnchor(item, defaultArg(
|
|
367
|
+
return buildFieldAnchor(elementTypes, item, defaultArg(tryFind<int32, FSharpList<CoreMRChoice>>(item.ItemId, choicesByItem), empty_1<CoreMRChoice>()), field);
|
|
351
368
|
}, section.Items);
|
|
352
369
|
const headingItemId: Option<int32> = map<HeadingItem, int32>((h: HeadingItem): int32 => h.ItemId, section.Heading);
|
|
353
370
|
return new CoreMRStepMap(stepOrder, new CoreMRStepAnchor(headingItemId, section.HeadingSequence, section.HeadingLabel), fieldAnchors);
|
|
@@ -356,27 +373,29 @@ export function buildSourceMap(formData: CoreMRFormData, formSpec: Spec_FormSpec
|
|
|
356
373
|
return undefined;
|
|
357
374
|
}
|
|
358
375
|
}, groupItemsByHeadings(detectHeadings(formData.Items), formData.Items));
|
|
359
|
-
const listMeta: ListMetadata = defaultArg<ListMetadata>(listMetadata, new ListMetadata(undefined, undefined, empty_1<string>()));
|
|
360
|
-
return new CoreMRSourceMap(formData.Metadata.FormId, formData.Metadata.VersionId, formData.Metadata.VersionNumber, formData.Metadata.FormName, formCode, "name", formData.Metadata.Description,
|
|
376
|
+
const listMeta: ListMetadata = defaultArg<ListMetadata>(listMetadata, new ListMetadata(undefined, undefined, empty_1<string>(), undefined, Spec_FormClassification_General()));
|
|
377
|
+
return new CoreMRSourceMap(formData.Metadata.FormId, formData.Metadata.VersionId, formData.Metadata.VersionNumber, formData.Metadata.FormName, formCode, "name", formData.Metadata.Description, formData.Metadata.RequiresSignature, listMeta.EncounterTypes, listMeta.Usage, listMeta.Classification, undefined, undefined, undefined, stepMaps, empty_1<CoreMRAbsorbedItem>(), formData.Triggers, formData.Tags, formSpec.Id);
|
|
361
378
|
}
|
|
362
379
|
|
|
363
380
|
/**
|
|
364
381
|
* Convert CoreMR form data to FormSpec with full source mapping.
|
|
365
382
|
* When listMetadata is Some (from FormListItem during import), IsScored and EncounterTypes are populated in the SourceMap.
|
|
383
|
+
* When elementTypes is Some (from bridge templates endpoint), use it for ValueEncoding; else fallback to CorEMRElementTypeMap.
|
|
366
384
|
*/
|
|
367
|
-
export function convertWithMap(formData: CoreMRFormData, listMetadata: Option<ListMetadata
|
|
385
|
+
export function convertWithMap(formData: CoreMRFormData, listMetadata: Option<ListMetadata>, elementTypes: Option<FSharpMap<int32, ElementTypeInfo>>): CoreMRConversionResult {
|
|
368
386
|
const formSpec: Spec_FormSpec$1<Spec_FieldType_$union> = convertToFormSpec(formData);
|
|
369
|
-
return new CoreMRConversionResult(formSpec, buildSourceMap(formData, formSpec, listMetadata));
|
|
387
|
+
return new CoreMRConversionResult(formSpec, buildSourceMap(elementTypes, formData, formSpec, listMetadata));
|
|
370
388
|
}
|
|
371
389
|
|
|
372
390
|
/**
|
|
373
391
|
* Convert CoreMR form data to FormSpec with Provenance attached (for persist on import).
|
|
374
392
|
* When listMetadata is Some (from FormListItem during import), IsScored and EncounterTypes are populated.
|
|
393
|
+
* When elementTypes is Some (from bridge templates endpoint), use it for ValueEncoding; else fallback to CorEMRElementTypeMap.
|
|
375
394
|
*/
|
|
376
|
-
export function convertWithMapAndProvenance(formData: CoreMRFormData, listMetadata: Option<ListMetadata
|
|
377
|
-
const result: CoreMRConversionResult = convertWithMap(formData, listMetadata);
|
|
395
|
+
export function convertWithMapAndProvenance(formData: CoreMRFormData, listMetadata: Option<ListMetadata>, elementTypes: Option<FSharpMap<int32, ElementTypeInfo>>): Spec_FormSpec$1<Spec_FieldType_$union> {
|
|
396
|
+
const result: CoreMRConversionResult = convertWithMap(formData, listMetadata, elementTypes);
|
|
378
397
|
const bind$0040: Spec_FormSpec$1<Spec_FieldType_$union> = result.FormSpec;
|
|
379
|
-
return new Spec_FormSpec$1(bind$0040.Id, bind$0040.Code, bind$0040.Title, bind$0040.Abstract, bind$0040.Version, bind$0040.FormSpecVersion, bind$0040.Steps, bind$0040.CategoryTags, bind$0040.Score, bind$0040.AssociatedCodes, bind$0040.RequiresReview, bind$0040.RequiresReviewAndApproval, bind$0040.ClinicalPathway, bind$0040.Lifecycle, bind$0040.FilledMeta, bind$0040.CustomData, new IntegrationProvenance("coremr", toString(0, Auto_generateBoxedEncoder_437914C6(CoreMRSourceMap_$reflection(), undefined, coreMRExtra, undefined)(result.SourceMap))));
|
|
398
|
+
return new Spec_FormSpec$1(bind$0040.Id, bind$0040.Code, bind$0040.Title, bind$0040.Abstract, bind$0040.Version, bind$0040.FormSpecVersion, bind$0040.Steps, bind$0040.CategoryTags, bind$0040.Score, bind$0040.AssociatedCodes, bind$0040.RequiresReview, bind$0040.RequiresReviewAndApproval, bind$0040.ClinicalPathway, bind$0040.Lifecycle, bind$0040.FilledMeta, bind$0040.CustomData, new IntegrationProvenance("coremr", toString(0, Auto_generateBoxedEncoder_437914C6(CoreMRSourceMap_$reflection(), undefined, coreMRExtra, undefined)(result.SourceMap))), result.SourceMap.Classification);
|
|
380
399
|
}
|
|
381
400
|
|
|
382
401
|
//# sourceMappingURL=CoreMRSourceMap.ts.map
|