@aehrc/smart-forms-renderer 0.40.0 → 0.40.2
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/lib/components/FormComponents/ItemParts/ItemFieldGrid.js +6 -2
- package/lib/components/FormComponents/ItemParts/ItemFieldGrid.js.map +1 -1
- package/lib/components/FormComponents/RepeatGroup/RepeatGroup.js +3 -3
- package/lib/components/FormComponents/RepeatGroup/RepeatGroup.js.map +1 -1
- package/lib/components/FormComponents/RepeatGroup/RepeatGroupView.js +6 -6
- package/lib/components/FormComponents/RepeatGroup/RepeatGroupView.js.map +1 -1
- package/lib/components/FormComponents/RepeatItem/RepeatItem.js +5 -5
- package/lib/components/FormComponents/RepeatItem/RepeatItem.js.map +1 -1
- package/lib/components/FormComponents/Tables/GroupTable.js +10 -10
- package/lib/components/FormComponents/Tables/GroupTable.js.map +1 -1
- package/lib/components/FormComponents/Tables/GroupTableBody.d.ts +1 -1
- package/lib/components/FormComponents/Tables/GroupTableBody.js +3 -3
- package/lib/components/FormComponents/Tables/GroupTableBody.js.map +1 -1
- package/lib/components/FormComponents/Tables/GroupTableRow.d.ts +1 -1
- package/lib/components/FormComponents/Tables/GroupTableRow.js +4 -4
- package/lib/components/FormComponents/Tables/GroupTableRow.js.map +1 -1
- package/lib/components/FormComponents/Tables/GroupTableView.d.ts +1 -1
- package/lib/components/Renderer/FormTopLevelItem.js +13 -1
- package/lib/components/Renderer/FormTopLevelItem.js.map +1 -1
- package/lib/hooks/useDateValidation.js +2 -2
- package/lib/hooks/useDateValidation.js.map +1 -1
- package/lib/hooks/useGroupTableRows.d.ts +1 -1
- package/lib/hooks/useGroupTableRows.js +3 -3
- package/lib/hooks/useGroupTableRows.js.map +1 -1
- package/lib/hooks/useInitialiseGroupTable.d.ts +1 -1
- package/lib/hooks/useInitialiseGroupTable.js +10 -16
- package/lib/hooks/useInitialiseGroupTable.js.map +1 -1
- package/lib/hooks/useInitialiseRepeatAnswers.d.ts +1 -1
- package/lib/hooks/useInitialiseRepeatAnswers.js +9 -12
- package/lib/hooks/useInitialiseRepeatAnswers.js.map +1 -1
- package/lib/hooks/useInitialiseRepeatGroups.d.ts +2 -2
- package/lib/hooks/useInitialiseRepeatGroups.js +11 -20
- package/lib/hooks/useInitialiseRepeatGroups.js.map +1 -1
- package/lib/hooks/useRepeatGroups.js +6 -2
- package/lib/hooks/useRepeatGroups.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/interfaces/groupTable.interface.d.ts +1 -1
- package/lib/interfaces/repeatGroup.interface.d.ts +1 -1
- package/lib/theme/palette.js +0 -4
- package/lib/theme/palette.js.map +1 -1
- package/lib/utils/groupTable.js +1 -1
- package/lib/utils/groupTable.js.map +1 -1
- package/lib/utils/index.d.ts +1 -1
- package/lib/utils/index.js +1 -1
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/manageForm.d.ts +7 -0
- package/lib/utils/manageForm.js +15 -1
- package/lib/utils/manageForm.js.map +1 -1
- package/lib/utils/repeatId.d.ts +4 -0
- package/lib/utils/repeatId.js +93 -0
- package/lib/utils/repeatId.js.map +1 -0
- package/package.json +1 -1
- package/src/components/FormComponents/ItemParts/ItemFieldGrid.tsx +8 -2
- package/src/components/FormComponents/RepeatGroup/RepeatGroup.tsx +3 -3
- package/src/components/FormComponents/RepeatGroup/RepeatGroupView.tsx +6 -6
- package/src/components/FormComponents/RepeatItem/RepeatItem.tsx +7 -5
- package/src/components/FormComponents/Tables/GroupTable.tsx +13 -10
- package/src/components/FormComponents/Tables/GroupTableBody.tsx +5 -5
- package/src/components/FormComponents/Tables/GroupTableRow.tsx +5 -5
- package/src/components/FormComponents/Tables/GroupTableView.tsx +1 -1
- package/src/components/Renderer/FormTopLevelItem.tsx +33 -1
- package/src/hooks/useDateValidation.tsx +2 -2
- package/src/hooks/useGroupTableRows.ts +3 -3
- package/src/hooks/useInitialiseGroupTable.ts +13 -17
- package/src/hooks/useInitialiseRepeatAnswers.ts +9 -12
- package/src/hooks/useInitialiseRepeatGroups.ts +14 -25
- package/src/hooks/useRepeatGroups.ts +8 -4
- package/src/index.ts +1 -0
- package/src/interfaces/groupTable.interface.ts +1 -1
- package/src/interfaces/repeatGroup.interface.ts +1 -1
- package/src/stories/assets/questionnaires/QIdRemoverDebugger.ts +161 -0
- package/src/stories/storybookWrappers/BuildFormButtonForStorybook.tsx +1 -1
- package/src/stories/storybookWrappers/IdRemoverButtonForStorybook.tsx +51 -0
- package/src/stories/storybookWrappers/IdRemoverDebuggerWrapperForStorybook.tsx +84 -0
- package/src/stories/testing/IdRemoverDebuggerWrapper.stories.tsx +39 -0
- package/src/tests/extractObservation.test.ts +2 -5
- package/src/theme/palette.ts +0 -4
- package/src/utils/groupTable.ts +1 -1
- package/src/utils/index.ts +7 -1
- package/src/utils/manageForm.ts +28 -1
- package/src/utils/repeatId.ts +123 -0
- package/CHANGELOG.md +0 -43
- package/lib/hooks/useRepeatAnswers.d.ts +0 -4
- package/lib/hooks/useRepeatAnswers.js +0 -34
- package/lib/hooks/useRepeatAnswers.js.map +0 -1
- package/lib/interfaces/repeatItem.interface.d.ts +0 -5
- package/lib/interfaces/repeatItem.interface.js +0 -2
- package/lib/interfaces/repeatItem.interface.js.map +0 -1
- package/lib/utils/answerExpression.d.ts +0 -18
- package/lib/utils/answerExpression.js +0 -133
- package/lib/utils/answerExpression.js.map +0 -1
- package/lib/utils/dynamicValueSet.d.ts +0 -5
- package/lib/utils/dynamicValueSet.js +0 -96
- package/lib/utils/dynamicValueSet.js.map +0 -1
- package/lib/utils/fhirpathAsyncUtils/fhirpath-async.d.ts +0 -14
- package/lib/utils/fhirpathAsyncUtils/fhirpath-async.js +0 -639
- package/lib/utils/fhirpathAsyncUtils/fhirpath-async.js.map +0 -1
- package/lib/utils/fhirpathAsyncUtils/outcome-utils.d.ts +0 -3
- package/lib/utils/fhirpathAsyncUtils/outcome-utils.js +0 -41
- package/lib/utils/fhirpathAsyncUtils/outcome-utils.js.map +0 -1
- package/lib/utils/questionnaireStoreUtils/extractPreferredTerminologyServerUrls.d.ts +0 -3
- package/lib/utils/questionnaireStoreUtils/extractPreferredTerminologyServerUrls.js +0 -34
- package/lib/utils/questionnaireStoreUtils/extractPreferredTerminologyServerUrls.js.map +0 -1
- package/lib/utils/updateQr.d.ts +0 -9
- package/lib/utils/updateQr.js +0 -55
- package/lib/utils/updateQr.js.map +0 -1
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2024 Commonwealth Scientific and Industrial Research
|
|
3
|
-
* Organisation (CSIRO) ABN 41 687 119 230.
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
import fhirpath from 'fhirpath';
|
|
18
|
-
import fhirpath_r4_model from 'fhirpath/fhir-context/r4';
|
|
19
|
-
import cloneDeep from 'lodash.clonedeep';
|
|
20
|
-
import _isEqual from 'lodash/isEqual';
|
|
21
|
-
export function evaluateDynamicValueSets(fhirPathContext, dynamicValueSets) {
|
|
22
|
-
var _a;
|
|
23
|
-
const updatedDynamicValueSets = cloneDeep(dynamicValueSets);
|
|
24
|
-
let isUpdated = false;
|
|
25
|
-
for (const linkId in updatedDynamicValueSets) {
|
|
26
|
-
const dynamicValueSet = updatedDynamicValueSets[linkId];
|
|
27
|
-
const completeResource = dynamicValueSet.sourceResource;
|
|
28
|
-
const valueSetComposeInclude = (_a = completeResource.compose) === null || _a === void 0 ? void 0 : _a.include;
|
|
29
|
-
if (valueSetComposeInclude && valueSetComposeInclude.length > 0) {
|
|
30
|
-
for (const include of valueSetComposeInclude) {
|
|
31
|
-
if (!include.filter) {
|
|
32
|
-
continue;
|
|
33
|
-
}
|
|
34
|
-
// There are filters present, check for fhirpath embeddings
|
|
35
|
-
const fhirPathEmbeddingsMap = {};
|
|
36
|
-
for (const filter of include.filter) {
|
|
37
|
-
const filterValue = filter.value;
|
|
38
|
-
if (filterValue.includes('{{') && filterValue.includes('}}')) {
|
|
39
|
-
if (filterValue) {
|
|
40
|
-
for (const embedding of readFhirPathEmbeddingsFromStr(filterValue)) {
|
|
41
|
-
if (embedding) {
|
|
42
|
-
fhirPathEmbeddingsMap[embedding] = '';
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
const evaluatedFhirPathEmbeddingsMap = evaluateFhirPathEmbeddings(fhirPathEmbeddingsMap, fhirPathContext);
|
|
49
|
-
const evaluatedFhirPathEmbeddingsTuple = Object.entries(evaluatedFhirPathEmbeddingsMap).filter(([, value]) => value != '');
|
|
50
|
-
for (const filter of include.filter) {
|
|
51
|
-
evaluatedFhirPathEmbeddingsTuple.forEach(([embedding, value]) => {
|
|
52
|
-
const filterValue = filter.value;
|
|
53
|
-
const pattern = new RegExp(`{{%${embedding}}}`, 'g');
|
|
54
|
-
filter.value = filterValue.replace(pattern, value);
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
// Complete resource has been updated, update the dynamicValueSet object
|
|
60
|
-
if (!_isEqual(dynamicValueSets[linkId].completeResource, completeResource)) {
|
|
61
|
-
isUpdated = true;
|
|
62
|
-
// If source response same as the complete resource, embeddings are not replaced, therefore ValueSet is not complete
|
|
63
|
-
updatedDynamicValueSets[linkId] = {
|
|
64
|
-
sourceResource: dynamicValueSets[linkId].sourceResource,
|
|
65
|
-
completeResource: dynamicValueSet.sourceResource,
|
|
66
|
-
version: dynamicValueSet.version + 1,
|
|
67
|
-
isComplete: !_isEqual(dynamicValueSets[linkId].sourceResource, completeResource)
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
// after that we need to update the dynamicvalueset object - iscomplete so that we can use it in useMemo - or potentially updated the version of the dynamic updatedcount
|
|
72
|
-
return {
|
|
73
|
-
dynamicValueSetsIsUpdated: isUpdated,
|
|
74
|
-
updatedDynamicValueSets: updatedDynamicValueSets
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
function evaluateFhirPathEmbeddings(fhirPathEmbeddingsMap, fhirPathContext) {
|
|
78
|
-
// evaluate fhirpath embeddings within map
|
|
79
|
-
Object.keys(fhirPathEmbeddingsMap).forEach((embedding) => {
|
|
80
|
-
try {
|
|
81
|
-
const result = fhirpath.evaluate({}, `%${embedding}`, fhirPathContext, fhirpath_r4_model)[0];
|
|
82
|
-
if (result !== undefined && result !== null) {
|
|
83
|
-
fhirPathEmbeddingsMap[embedding] = result;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
catch (e) {
|
|
87
|
-
console.warn(e);
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
return fhirPathEmbeddingsMap;
|
|
91
|
-
}
|
|
92
|
-
const FHIRPATH_EMBEDDING_REGEX = /{{%(.*?)}}/g;
|
|
93
|
-
function readFhirPathEmbeddingsFromStr(expression) {
|
|
94
|
-
return [...expression.matchAll(FHIRPATH_EMBEDDING_REGEX)].map((match) => { var _a; return (_a = match[1]) !== null && _a !== void 0 ? _a : ''; });
|
|
95
|
-
}
|
|
96
|
-
//# sourceMappingURL=dynamicValueSet.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dynamicValueSet.js","sourceRoot":"","sources":["../../src/utils/dynamicValueSet.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AA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AC,qBAAqB,CAAC,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE;QACvD,IAAI;YACF,MAAM,MAAM,GAAG,QAAQ,CAAC,QAAQ,CAAC,EAAE,EAAE,IAAI,SAAS,EAAE,EAAE,eAAe,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC;YAE7F,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,KAAK,IAAI,EAAE;gBAC3C,qBAAqB,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC;aAC3C;SACF;QAAC,OAAO,CAAC,EAAE;YACV,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACjB;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,qBAAqB,CAAC;AAC/B,CAAC;AAED,MAAM,wBAAwB,GAAG,aAAa,CAAC;AAE/C,SAAS,6BAA6B,CAAC,UAAkB;IACvD,OAAO,CAAC,GAAG,UAAU,CAAC,QAAQ,CAAC,wBAAwB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,WAAC,OAAA,MAAA,KAAK,CAAC,CAAC,CAAC,mCAAI,EAAE,CAAA,EAAA,CAAC,CAAC;AAC3F,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { DomainResource } from 'fhir/r4b';
|
|
2
|
-
/** Global debug variable to permit the logger to write information messages
|
|
3
|
-
to the OperationOutcome and console
|
|
4
|
-
*/
|
|
5
|
-
export declare const debugAsyncFhirpath: boolean;
|
|
6
|
-
/**
|
|
7
|
-
* Evaluate a FHIRPath expression asynchronously
|
|
8
|
-
* @param fhirData FHIR resource to run the FHIRPath expression against
|
|
9
|
-
* @param path FHIRPath expression to evaluate (string or Path object)
|
|
10
|
-
* @param context Environment to evaluate the expression in, mostly variables
|
|
11
|
-
* @param model which fhir version to use (r4/r4b/r5)
|
|
12
|
-
* @returns the result of the evaluation
|
|
13
|
-
*/
|
|
14
|
-
export declare function evaluateFhirpathAsync(fhirData: DomainResource, path: string | Path, context?: Record<string, any>, model?: Model): Promise<any[]>;
|