@aehrc/smart-forms-renderer 0.40.3 → 0.41.0
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/AttachmentItem/AttachmentItem.js +2 -3
- package/lib/components/FormComponents/AttachmentItem/AttachmentItem.js.map +1 -1
- package/lib/components/FormComponents/DateTimeItems/CustomDateItem/CustomDateItem.js +1 -2
- package/lib/components/FormComponents/DateTimeItems/CustomDateItem/CustomDateItem.js.map +1 -1
- package/lib/components/FormComponents/DateTimeItems/CustomDateTimeItem/CustomDateTimeItem.js +3 -4
- package/lib/components/FormComponents/DateTimeItems/CustomDateTimeItem/CustomDateTimeItem.js.map +1 -1
- package/lib/components/FormComponents/DecimalItem/DecimalItem.js +2 -3
- package/lib/components/FormComponents/DecimalItem/DecimalItem.js.map +1 -1
- package/lib/components/FormComponents/IntegerItem/IntegerItem.js +2 -3
- package/lib/components/FormComponents/IntegerItem/IntegerItem.js.map +1 -1
- package/lib/components/FormComponents/QuantityItem/QuantityItem.js +1 -2
- package/lib/components/FormComponents/QuantityItem/QuantityItem.js.map +1 -1
- package/lib/components/FormComponents/RepeatGroup/AddItemButton.d.ts +2 -2
- package/lib/components/FormComponents/RepeatGroup/RepeatGroup.js +2 -3
- package/lib/components/FormComponents/RepeatGroup/RepeatGroup.js.map +1 -1
- package/lib/components/FormComponents/RepeatGroup/RepeatGroupView.d.ts +2 -2
- package/lib/components/FormComponents/StringItem/StringItem.js +2 -3
- package/lib/components/FormComponents/StringItem/StringItem.js.map +1 -1
- package/lib/components/FormComponents/Tables/AddRowButton.d.ts +2 -2
- package/lib/components/FormComponents/Tables/GroupTable.js +3 -1
- package/lib/components/FormComponents/Tables/GroupTable.js.map +1 -1
- package/lib/components/FormComponents/TextItem/TextItem.js +2 -3
- package/lib/components/FormComponents/TextItem/TextItem.js.map +1 -1
- package/lib/components/FormComponents/UrlItem/UrlItem.js +2 -3
- package/lib/components/FormComponents/UrlItem/UrlItem.js.map +1 -1
- package/lib/components/Renderer/BaseRenderer.js +4 -3
- package/lib/components/Renderer/BaseRenderer.js.map +1 -1
- package/lib/hooks/useGroupTableRows.d.ts +4 -4
- package/lib/hooks/useGroupTableRows.js +3 -5
- package/lib/hooks/useGroupTableRows.js.map +1 -1
- package/lib/hooks/useInitialiseGroupTableRows.d.ts +4 -0
- package/lib/hooks/{useNumberInput.js → useInitialiseGroupTableRows.js} +16 -13
- package/lib/hooks/useInitialiseGroupTableRows.js.map +1 -0
- package/lib/hooks/useInitialiseRepeatGroups.d.ts +2 -2
- package/lib/interfaces/repeatGroup.interface.d.ts +1 -1
- package/lib/stores/questionnaireResponseStore.d.ts +3 -0
- package/lib/stores/questionnaireResponseStore.js +5 -0
- package/lib/stores/questionnaireResponseStore.js.map +1 -1
- package/lib/tests/test-data/removeIdSample.d.ts +3 -0
- package/lib/tests/test-data/removeIdSample.js +99 -0
- package/lib/tests/test-data/removeIdSample.js.map +1 -0
- package/lib/theme/Theme.js +0 -2
- package/lib/theme/Theme.js.map +1 -1
- package/lib/utils/calculatedExpression.js +4 -4
- package/lib/utils/calculatedExpression.js.map +1 -1
- package/lib/utils/extractObservation.d.ts +1 -0
- package/lib/utils/extractObservation.js +1 -1
- package/lib/utils/extractObservation.js.map +1 -1
- package/lib/utils/initialise.js +0 -3
- package/lib/utils/initialise.js.map +1 -1
- package/lib/utils/openChoice.js +3 -3
- package/lib/utils/openChoice.js.map +1 -1
- package/lib/utils/repopulateItems.js +8 -8
- package/lib/utils/repopulateItems.js.map +1 -1
- package/package.json +6 -2
- package/src/components/FormComponents/AttachmentItem/AttachmentItem.tsx +2 -3
- package/src/components/FormComponents/DateTimeItems/CustomDateItem/CustomDateItem.tsx +1 -2
- package/src/components/FormComponents/DateTimeItems/CustomDateTimeItem/CustomDateTimeItem.tsx +3 -4
- package/src/components/FormComponents/DecimalItem/DecimalItem.tsx +2 -3
- package/src/components/FormComponents/IntegerItem/IntegerItem.tsx +2 -3
- package/src/components/FormComponents/QuantityItem/QuantityItem.tsx +1 -2
- package/src/components/FormComponents/RepeatGroup/AddItemButton.tsx +2 -2
- package/src/components/FormComponents/RepeatGroup/RepeatGroup.tsx +2 -3
- package/src/components/FormComponents/RepeatGroup/RepeatGroupView.tsx +2 -2
- package/src/components/FormComponents/StringItem/StringItem.tsx +2 -3
- package/src/components/FormComponents/Tables/AddRowButton.tsx +2 -2
- package/src/components/FormComponents/Tables/GroupTable.tsx +5 -5
- package/src/components/FormComponents/TextItem/TextItem.tsx +2 -3
- package/src/components/FormComponents/UrlItem/UrlItem.tsx +2 -3
- package/src/components/Renderer/BaseRenderer.tsx +4 -3
- package/src/hooks/useGroupTableRows.ts +4 -9
- package/src/hooks/{useInitialiseGroupTable.ts → useInitialiseGroupTableRows.ts} +15 -11
- package/src/hooks/useInitialiseRepeatGroups.ts +2 -2
- package/src/interfaces/repeatGroup.interface.ts +1 -1
- package/src/stores/questionnaireResponseStore.ts +7 -0
- package/src/stories/assets/questionnaires/QButtonTester.ts +117 -0
- package/src/stories/storybookWrappers/IdRemoverButtonForStorybook.tsx +3 -5
- package/{lib/hooks/useInitialiseGroupTable.js → src/tests/removeId.test.ts} +11 -14
- package/src/tests/test-data/removeIdSample.ts +101 -0
- package/src/theme/Theme.tsx +0 -2
- package/src/utils/calculatedExpression.ts +4 -4
- package/src/utils/extractObservation.ts +1 -1
- package/src/utils/initialise.ts +0 -4
- package/src/utils/openChoice.ts +3 -3
- package/src/utils/repopulateItems.ts +8 -8
- package/lib/hooks/useInitialiseGroupTable.d.ts +0 -4
- package/lib/hooks/useInitialiseGroupTable.js.map +0 -1
- package/lib/hooks/useNumberInput.d.ts +0 -3
- package/lib/hooks/useNumberInput.js.map +0 -1
- package/lib/hooks/useRepeatGroups.d.ts +0 -4
- package/lib/hooks/useRepeatGroups.js +0 -38
- package/lib/hooks/useRepeatGroups.js.map +0 -1
- package/lib/hooks/useStringInput.d.ts +0 -3
- package/lib/hooks/useStringInput.js +0 -32
- package/lib/hooks/useStringInput.js.map +0 -1
- package/src/hooks/useNumberInput.ts +0 -38
- package/src/hooks/useRepeatGroups.ts +0 -51
- package/src/hooks/useStringInput.ts +0 -39
|
@@ -238,6 +238,67 @@ export const qButtonTester: Questionnaire = {
|
|
|
238
238
|
'https://healthterminologies.gov.au/fhir/ValueSet/australian-states-territories-2'
|
|
239
239
|
}
|
|
240
240
|
]
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
extension: [
|
|
244
|
+
{
|
|
245
|
+
url: 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-itemPopulationContext',
|
|
246
|
+
valueExpression: {
|
|
247
|
+
name: 'PostalAddressRepeat',
|
|
248
|
+
language: 'text/fhirpath',
|
|
249
|
+
expression: "%patient.address.where(type='postal')"
|
|
250
|
+
}
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
url: 'http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl',
|
|
254
|
+
valueCodeableConcept: {
|
|
255
|
+
coding: [
|
|
256
|
+
{
|
|
257
|
+
system: 'http://hl7.org/fhir/questionnaire-item-control',
|
|
258
|
+
code: 'gtable'
|
|
259
|
+
}
|
|
260
|
+
]
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
],
|
|
264
|
+
linkId: 'repeats-gtable',
|
|
265
|
+
type: 'group',
|
|
266
|
+
repeats: true,
|
|
267
|
+
text: 'Repeats Group Table Test',
|
|
268
|
+
item: [
|
|
269
|
+
{
|
|
270
|
+
extension: [
|
|
271
|
+
{
|
|
272
|
+
url: 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-initialExpression',
|
|
273
|
+
valueExpression: {
|
|
274
|
+
language: 'text/fhirpath',
|
|
275
|
+
expression: '%PostalAddressRepeat.city'
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
],
|
|
279
|
+
linkId: 'repeats-gtable-string',
|
|
280
|
+
text: 'String',
|
|
281
|
+
type: 'string',
|
|
282
|
+
repeats: false
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
extension: [
|
|
286
|
+
{
|
|
287
|
+
url: 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-initialExpression',
|
|
288
|
+
valueExpression: {
|
|
289
|
+
language: 'text/fhirpath',
|
|
290
|
+
expression: '%PostalAddressRepeat.state'
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
],
|
|
294
|
+
linkId: 'repeats-gtable-choice',
|
|
295
|
+
text: 'Choice',
|
|
296
|
+
type: 'choice',
|
|
297
|
+
repeats: false,
|
|
298
|
+
answerValueSet:
|
|
299
|
+
'https://healthterminologies.gov.au/fhir/ValueSet/australian-states-territories-2'
|
|
300
|
+
}
|
|
301
|
+
]
|
|
241
302
|
}
|
|
242
303
|
]
|
|
243
304
|
};
|
|
@@ -373,6 +434,62 @@ export const qrButtonTesterResponse: QuestionnaireResponse = {
|
|
|
373
434
|
]
|
|
374
435
|
}
|
|
375
436
|
]
|
|
437
|
+
},
|
|
438
|
+
{
|
|
439
|
+
linkId: 'repeats-gtable',
|
|
440
|
+
text: 'Repeats Group Table Test',
|
|
441
|
+
item: [
|
|
442
|
+
{
|
|
443
|
+
linkId: 'repeats-gtable-string',
|
|
444
|
+
text: 'String',
|
|
445
|
+
answer: [
|
|
446
|
+
{
|
|
447
|
+
valueString: 'Group Table String 1'
|
|
448
|
+
}
|
|
449
|
+
]
|
|
450
|
+
},
|
|
451
|
+
{
|
|
452
|
+
linkId: 'repeats-gtable-choice',
|
|
453
|
+
text: 'Choice',
|
|
454
|
+
answer: [
|
|
455
|
+
{
|
|
456
|
+
valueCoding: {
|
|
457
|
+
system:
|
|
458
|
+
'https://healthterminologies.gov.au/fhir/CodeSystem/australian-states-territories-1',
|
|
459
|
+
code: 'NSW'
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
]
|
|
463
|
+
}
|
|
464
|
+
]
|
|
465
|
+
},
|
|
466
|
+
{
|
|
467
|
+
linkId: 'repeats-gtable',
|
|
468
|
+
text: 'Repeats Group Table Test',
|
|
469
|
+
item: [
|
|
470
|
+
{
|
|
471
|
+
linkId: 'repeats-gtable-string',
|
|
472
|
+
text: 'String',
|
|
473
|
+
answer: [
|
|
474
|
+
{
|
|
475
|
+
valueString: 'Group Table String 2'
|
|
476
|
+
}
|
|
477
|
+
]
|
|
478
|
+
},
|
|
479
|
+
{
|
|
480
|
+
linkId: 'repeats-gtable-choice',
|
|
481
|
+
text: 'Choice',
|
|
482
|
+
answer: [
|
|
483
|
+
{
|
|
484
|
+
valueCoding: {
|
|
485
|
+
system:
|
|
486
|
+
'https://healthterminologies.gov.au/fhir/CodeSystem/australian-states-territories-1',
|
|
487
|
+
code: 'SA'
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
]
|
|
491
|
+
}
|
|
492
|
+
]
|
|
376
493
|
}
|
|
377
494
|
],
|
|
378
495
|
|
|
@@ -20,8 +20,7 @@ import React from 'react';
|
|
|
20
20
|
import type { Questionnaire, QuestionnaireResponse } from 'fhir/r4';
|
|
21
21
|
import { Box, IconButton, Tooltip } from '@mui/material';
|
|
22
22
|
import ContentCutIcon from '@mui/icons-material/ContentCut';
|
|
23
|
-
import {
|
|
24
|
-
import { removeInternalIdsFromResponse } from '../../utils/manageForm';
|
|
23
|
+
import { buildForm, removeInternalIdsFromResponse } from '../../utils/manageForm';
|
|
25
24
|
|
|
26
25
|
interface IdRemoverButtonProps {
|
|
27
26
|
questionnaire: Questionnaire;
|
|
@@ -31,10 +30,9 @@ interface IdRemoverButtonProps {
|
|
|
31
30
|
function IdRemoverButtonForStorybook(props: IdRemoverButtonProps) {
|
|
32
31
|
const { questionnaire, questionnaireResponse } = props;
|
|
33
32
|
|
|
34
|
-
const updateResponse = useQuestionnaireResponseStore.use.updateResponse();
|
|
35
|
-
|
|
36
33
|
async function handleRemoveIds() {
|
|
37
|
-
|
|
34
|
+
const updatedResponse = removeInternalIdsFromResponse(questionnaire, questionnaireResponse);
|
|
35
|
+
await buildForm(questionnaire, updatedResponse);
|
|
38
36
|
}
|
|
39
37
|
|
|
40
38
|
return (
|
|
@@ -14,17 +14,14 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
export default useInitialiseGroupTable;
|
|
30
|
-
//# sourceMappingURL=useInitialiseGroupTable.js.map
|
|
17
|
+
|
|
18
|
+
import { expect, test } from '@jest/globals';
|
|
19
|
+
import { removeInternalIdsFromResponse } from '../utils';
|
|
20
|
+
import { qrRemoveIdResult, qrRemoveIdSample } from './test-data/removeIdSample';
|
|
21
|
+
import { qMyPatient } from '../stories/assets/questionnaires/QIdRemoverDebugger';
|
|
22
|
+
|
|
23
|
+
test('item.initial is properly pre-filled into QuestionnaireResponse', () => {
|
|
24
|
+
const outputResponse = removeInternalIdsFromResponse(qMyPatient, qrRemoveIdSample);
|
|
25
|
+
|
|
26
|
+
expect(outputResponse).toStrictEqual(qrRemoveIdResult);
|
|
27
|
+
});
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { QuestionnaireResponse } from 'fhir/r4';
|
|
2
|
+
|
|
3
|
+
export const qrRemoveIdSample: QuestionnaireResponse = {
|
|
4
|
+
resourceType: 'QuestionnaireResponse',
|
|
5
|
+
status: 'in-progress',
|
|
6
|
+
questionnaire: 'http://canshare.co.nz/questionnaire/myPatient1',
|
|
7
|
+
item: [
|
|
8
|
+
{
|
|
9
|
+
linkId: 'myPatient1',
|
|
10
|
+
text: 'myPatient1',
|
|
11
|
+
item: [
|
|
12
|
+
{
|
|
13
|
+
linkId: 'myPatient1.name',
|
|
14
|
+
text: 'name *',
|
|
15
|
+
item: [
|
|
16
|
+
{
|
|
17
|
+
linkId: 'myPatient1.name.first',
|
|
18
|
+
text: 'firstName *',
|
|
19
|
+
answer: [
|
|
20
|
+
{
|
|
21
|
+
id: 'myPatient1.name.first-repeat-000000',
|
|
22
|
+
valueString: '1st firstName 1.0'
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
linkId: 'myPatient1.name',
|
|
30
|
+
text: 'name *',
|
|
31
|
+
item: [
|
|
32
|
+
{
|
|
33
|
+
linkId: 'myPatient1.name.first',
|
|
34
|
+
text: 'firstName *',
|
|
35
|
+
answer: [
|
|
36
|
+
{
|
|
37
|
+
id: 'myPatient1.name.first-repeat-000000',
|
|
38
|
+
valueString: '2nd firstName 1.0'
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
id: 'myPatient1.name.first-repeat-O-r6YSxx81TBFf_yiHWk6',
|
|
42
|
+
valueString: '2nd firstName 2.0'
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
id: 'myPatient1.name.first-repeat-ZQR77gdy6utsT_JkbuHKc'
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export const qrRemoveIdResult: QuestionnaireResponse = {
|
|
57
|
+
resourceType: 'QuestionnaireResponse',
|
|
58
|
+
status: 'in-progress',
|
|
59
|
+
questionnaire: 'http://canshare.co.nz/questionnaire/myPatient1',
|
|
60
|
+
item: [
|
|
61
|
+
{
|
|
62
|
+
linkId: 'myPatient1',
|
|
63
|
+
text: 'myPatient1',
|
|
64
|
+
item: [
|
|
65
|
+
{
|
|
66
|
+
linkId: 'myPatient1.name',
|
|
67
|
+
text: 'name *',
|
|
68
|
+
item: [
|
|
69
|
+
{
|
|
70
|
+
linkId: 'myPatient1.name.first',
|
|
71
|
+
text: 'firstName *',
|
|
72
|
+
answer: [
|
|
73
|
+
{
|
|
74
|
+
valueString: '1st firstName 1.0'
|
|
75
|
+
}
|
|
76
|
+
]
|
|
77
|
+
}
|
|
78
|
+
]
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
linkId: 'myPatient1.name',
|
|
82
|
+
text: 'name *',
|
|
83
|
+
item: [
|
|
84
|
+
{
|
|
85
|
+
linkId: 'myPatient1.name.first',
|
|
86
|
+
text: 'firstName *',
|
|
87
|
+
answer: [
|
|
88
|
+
{
|
|
89
|
+
valueString: '2nd firstName 1.0'
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
valueString: '2nd firstName 2.0'
|
|
93
|
+
}
|
|
94
|
+
]
|
|
95
|
+
}
|
|
96
|
+
]
|
|
97
|
+
}
|
|
98
|
+
]
|
|
99
|
+
}
|
|
100
|
+
]
|
|
101
|
+
};
|
package/src/theme/Theme.tsx
CHANGED
|
@@ -23,7 +23,6 @@ import {
|
|
|
23
23
|
StyledEngineProvider,
|
|
24
24
|
ThemeProvider as MUIThemeProvider
|
|
25
25
|
} from '@mui/material/styles';
|
|
26
|
-
import CssBaseline from '@mui/material/CssBaseline';
|
|
27
26
|
import palette from './palette';
|
|
28
27
|
import typography from './typography';
|
|
29
28
|
import CustomGlobalStyles from './customGlobalStyles';
|
|
@@ -102,7 +101,6 @@ export function RendererThemeProvider({ children }: { children: ReactNode }) {
|
|
|
102
101
|
return (
|
|
103
102
|
<StyledEngineProvider injectFirst>
|
|
104
103
|
<MUIThemeProvider theme={theme}>
|
|
105
|
-
<CssBaseline />
|
|
106
104
|
<CustomGlobalStyles />
|
|
107
105
|
{children}
|
|
108
106
|
</MUIThemeProvider>
|
|
@@ -27,7 +27,6 @@ import type {
|
|
|
27
27
|
QuestionnaireResponseItem,
|
|
28
28
|
QuestionnaireResponseItemAnswer
|
|
29
29
|
} from 'fhir/r4';
|
|
30
|
-
import _isEqual from 'lodash/isEqual';
|
|
31
30
|
import { emptyResponse } from './emptyResource';
|
|
32
31
|
import { createFhirPathContext } from './fhirpath';
|
|
33
32
|
import { getQrItemsIndex, mapQItemsIndex } from './mapItem';
|
|
@@ -35,6 +34,7 @@ import { updateQrItemsInGroup } from './qrItem';
|
|
|
35
34
|
import cloneDeep from 'lodash.clonedeep';
|
|
36
35
|
import dayjs from 'dayjs';
|
|
37
36
|
import { updateQuestionnaireResponse } from './genericRecursive';
|
|
37
|
+
import isEqual from 'lodash.isequal';
|
|
38
38
|
|
|
39
39
|
interface EvaluateInitialCalculatedExpressionsParams {
|
|
40
40
|
initialResponse: QuestionnaireResponse;
|
|
@@ -60,7 +60,7 @@ export function evaluateInitialCalculatedExpressions(
|
|
|
60
60
|
|
|
61
61
|
// Return early if initialResponse is empty or there are no calculated expressions to evaluate
|
|
62
62
|
if (
|
|
63
|
-
|
|
63
|
+
isEqual(initialResponse, cloneDeep(emptyResponse)) ||
|
|
64
64
|
Object.keys(calculatedExpressions).length === 0
|
|
65
65
|
) {
|
|
66
66
|
return {
|
|
@@ -93,7 +93,7 @@ export function evaluateInitialCalculatedExpressions(
|
|
|
93
93
|
);
|
|
94
94
|
|
|
95
95
|
// Only update calculatedExpressions if length of result array > 0
|
|
96
|
-
if (result.length > 0 && !
|
|
96
|
+
if (result.length > 0 && !isEqual(calcExpression.value, result[0])) {
|
|
97
97
|
calcExpression.value = result[0];
|
|
98
98
|
}
|
|
99
99
|
} catch (e) {
|
|
@@ -136,7 +136,7 @@ export function evaluateCalculatedExpressions(
|
|
|
136
136
|
|
|
137
137
|
// Update calculatedExpressions if length of result array > 0
|
|
138
138
|
// Only update when current calcExpression value is different from the result, otherwise it will result in an infinite loop as per issue #733
|
|
139
|
-
if (result.length > 0 && !
|
|
139
|
+
if (result.length > 0 && !isEqual(calcExpression.value, result[0])) {
|
|
140
140
|
isUpdated = true;
|
|
141
141
|
calcExpression.value = result[0];
|
|
142
142
|
}
|
package/src/utils/initialise.ts
CHANGED
|
@@ -58,10 +58,6 @@ export function initialiseQuestionnaireResponse(
|
|
|
58
58
|
questionnaireResponse.status = 'in-progress';
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
// if (!questionnaireResponse.id) {
|
|
62
|
-
// questionnaireResponse.id = 'in-progress';
|
|
63
|
-
// }
|
|
64
|
-
|
|
65
61
|
const firstTopLevelItem = questionnaire?.item?.[0];
|
|
66
62
|
if (firstTopLevelItem && !questionnaireResponse.item) {
|
|
67
63
|
const initialItems = readQuestionnaireResponse(
|
package/src/utils/openChoice.ts
CHANGED
|
@@ -23,7 +23,7 @@ import type {
|
|
|
23
23
|
} from 'fhir/r4';
|
|
24
24
|
import { OpenChoiceItemControl } from '../interfaces/choice.enum';
|
|
25
25
|
import { isSpecificItemControl } from './itemControl';
|
|
26
|
-
import
|
|
26
|
+
import isEqual from 'lodash.isequal';
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* Update open choice answer based on open label value
|
|
@@ -100,7 +100,7 @@ export function updateOpenLabelAnswer(
|
|
|
100
100
|
|
|
101
101
|
// Old open label answer equals to new open label answer
|
|
102
102
|
// This should not happen, but return oldQrItem
|
|
103
|
-
if (
|
|
103
|
+
if (isEqual(oldOpenLabelAnswer, newOpenLabelAnswer)) {
|
|
104
104
|
return oldQrItem;
|
|
105
105
|
}
|
|
106
106
|
|
|
@@ -122,7 +122,7 @@ export function getOldOpenLabelAnswer(
|
|
|
122
122
|
options: QuestionnaireItemAnswerOption[]
|
|
123
123
|
): QuestionnaireResponseItemAnswer | null {
|
|
124
124
|
const openLabelAnswer = answers.find(
|
|
125
|
-
(answer) => !options.some((option) =>
|
|
125
|
+
(answer) => !options.some((option) => isEqual(option, answer))
|
|
126
126
|
);
|
|
127
127
|
return openLabelAnswer ?? null;
|
|
128
128
|
}
|
|
@@ -22,9 +22,6 @@ import type {
|
|
|
22
22
|
QuestionnaireResponseItem
|
|
23
23
|
} from 'fhir/r4';
|
|
24
24
|
import type { Tabs } from '../interfaces/tab.interface';
|
|
25
|
-
import _isEqual from 'lodash/isEqual';
|
|
26
|
-
import _intersection from 'lodash/intersection';
|
|
27
|
-
import _difference from 'lodash/difference';
|
|
28
25
|
import { containsTabs, isTabContainer } from './tabs';
|
|
29
26
|
import { getShortText, isSpecificItemControl } from './itemControl';
|
|
30
27
|
import { getQrItemsIndex, mapQItemsIndex } from './mapItem';
|
|
@@ -34,6 +31,9 @@ import { questionnaireResponseStore, questionnaireStore } from '../stores';
|
|
|
34
31
|
import cloneDeep from 'lodash.clonedeep';
|
|
35
32
|
import { createQuestionnaireResponseItemMap } from './questionnaireResponseStoreUtils/updatableResponseItems';
|
|
36
33
|
import { getQuestionnaireItem, getSectionHeading } from './misc';
|
|
34
|
+
import difference from 'lodash.difference';
|
|
35
|
+
import intersection from 'lodash.intersection';
|
|
36
|
+
import isEqual from 'lodash.isequal';
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
39
|
* ItemToRepopulate interface
|
|
@@ -99,11 +99,11 @@ export function generateItemsToRepopulate(populatedResponse: QuestionnaireRespon
|
|
|
99
99
|
// Get linkIds that are different between current QRItems and populated QRItems
|
|
100
100
|
// Doesn't work with repeat groups, but at the same time I'm not sure if it's needed, given you can't delete completely the first repeat group
|
|
101
101
|
const populatedResponseItemMap = createQuestionnaireResponseItemMap(populatedResponse);
|
|
102
|
-
const diffLinkIds =
|
|
102
|
+
const diffLinkIds = difference(
|
|
103
103
|
Object.keys(updatableResponseItems),
|
|
104
104
|
Object.keys(populatedResponseItemMap)
|
|
105
105
|
);
|
|
106
|
-
const diffLinkIdsWithInitialExpressions =
|
|
106
|
+
const diffLinkIdsWithInitialExpressions = intersection(
|
|
107
107
|
Object.keys(initialExpressions),
|
|
108
108
|
diffLinkIds
|
|
109
109
|
);
|
|
@@ -468,7 +468,7 @@ function retrieveSingleOldQRItem(
|
|
|
468
468
|
return;
|
|
469
469
|
}
|
|
470
470
|
|
|
471
|
-
if (
|
|
471
|
+
if (isEqual(oldQRItem, newQRItem)) {
|
|
472
472
|
delete itemsToRepopulate[qItem.linkId];
|
|
473
473
|
return;
|
|
474
474
|
}
|
|
@@ -490,7 +490,7 @@ function retrieveRepeatGroupOldQRItems(
|
|
|
490
490
|
return;
|
|
491
491
|
}
|
|
492
492
|
|
|
493
|
-
if (
|
|
493
|
+
if (isEqual(oldQRItems, newQRItems)) {
|
|
494
494
|
delete itemsToRepopulate[qItem.linkId];
|
|
495
495
|
return;
|
|
496
496
|
}
|
|
@@ -535,7 +535,7 @@ function retrieveGridGroupOldQRItems(
|
|
|
535
535
|
continue;
|
|
536
536
|
}
|
|
537
537
|
|
|
538
|
-
if (
|
|
538
|
+
if (isEqual(oldGridChildQrItem, newGridChildQRItem)) {
|
|
539
539
|
newGridChildQRItemMap.delete(gridChildQItem.linkId);
|
|
540
540
|
} else {
|
|
541
541
|
oldGridChildQRItems.push(oldGridChildQrItem);
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { QuestionnaireResponseItem } from 'fhir/r4';
|
|
2
|
-
import type { GroupTableRowModel } from '../interfaces/groupTable.interface';
|
|
3
|
-
declare function useInitialiseGroupTable(linkId: string, qrItems: QuestionnaireResponseItem[]): GroupTableRowModel[];
|
|
4
|
-
export default useInitialiseGroupTable;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useInitialiseGroupTable.js","sourceRoot":"","sources":["../../src/hooks/useInitialiseGroupTable.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAElF,SAAS,uBAAuB,CAC9B,MAAc,EACd,OAAoC;IAEpC,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;QACxB,OAAO,CAAC,EAAE,EAAE,EAAE,mBAAmB,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;KAC5D;IAED,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;QACnC,OAAO;YACL,EAAE,EAAE,wBAAwB,CAAC,MAAM,EAAE,KAAK,CAAC;YAC3C,MAAM;SACP,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAED,eAAe,uBAAuB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useNumberInput.js","sourceRoot":"","sources":["../../src/hooks/useNumberInput.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,SAAS,cAAc,CAAC,cAAsB;IAC5C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,cAAc,CAAC,CAAC;IAEnD,SAAS,CACP,GAAG,EAAE;QACH,IAAI,KAAK,KAAK,cAAc,EAAE;YAC5B,QAAQ,CAAC,cAAc,CAAC,CAAC;SAC1B;IACH,CAAC;IACD,iDAAiD;IACjD,uDAAuD;IACvD,CAAC,cAAc,CAAC,CACjB,CAAC;IAEF,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;AAC3B,CAAC;AAED,eAAe,cAAc,CAAC"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { Dispatch, SetStateAction } from 'react';
|
|
2
|
-
import type { RepeatGroupSingle } from '../interfaces/repeatGroup.interface';
|
|
3
|
-
declare function useRepeatGroups(valueFromProps: RepeatGroupSingle[]): [RepeatGroupSingle[], Dispatch<SetStateAction<RepeatGroupSingle[]>>];
|
|
4
|
-
export default useRepeatGroups;
|
|
@@ -1,38 +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 { useEffect, useState } from 'react';
|
|
18
|
-
import _isEqual from 'lodash/isEqual';
|
|
19
|
-
function useRepeatGroups(valueFromProps) {
|
|
20
|
-
const [repeatGroups, setRepeatGroups] = useState(valueFromProps);
|
|
21
|
-
useEffect(() => {
|
|
22
|
-
const valueFromPropsQRItems = valueFromProps
|
|
23
|
-
.map((repeatGroupSingle) => repeatGroupSingle.qrItem)
|
|
24
|
-
.filter((qrItem) => qrItem !== null);
|
|
25
|
-
const repeatGroupsQRItems = repeatGroups
|
|
26
|
-
.map((repeatGroupSingle) => repeatGroupSingle.qrItem)
|
|
27
|
-
.filter((qrItem) => qrItem !== null);
|
|
28
|
-
if (!_isEqual(valueFromPropsQRItems, repeatGroupsQRItems)) {
|
|
29
|
-
setRepeatGroups(valueFromProps);
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
// Only trigger this effect if prop value changes
|
|
33
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
34
|
-
[valueFromProps]);
|
|
35
|
-
return [repeatGroups, setRepeatGroups];
|
|
36
|
-
}
|
|
37
|
-
export default useRepeatGroups;
|
|
38
|
-
//# sourceMappingURL=useRepeatGroups.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useRepeatGroups.js","sourceRoot":"","sources":["../../src/hooks/useRepeatGroups.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AAGtC,SAAS,eAAe,CACtB,cAAmC;IAEnC,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAC,cAAc,CAAC,CAAC;IAEjE,SAAS,CACP,GAAG,EAAE;QACH,MAAM,qBAAqB,GAAG,cAAc;aACzC,GAAG,CAAC,CAAC,iBAAiB,EAAE,EAAE,CAAC,iBAAiB,CAAC,MAAM,CAAC;aACpD,MAAM,CAAC,CAAC,MAAM,EAAuC,EAAE,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC;QAE5E,MAAM,mBAAmB,GAAG,YAAY;aACrC,GAAG,CAAC,CAAC,iBAAiB,EAAE,EAAE,CAAC,iBAAiB,CAAC,MAAM,CAAC;aACpD,MAAM,CAAC,CAAC,MAAM,EAAuC,EAAE,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC;QAE5E,IAAI,CAAC,QAAQ,CAAC,qBAAqB,EAAE,mBAAmB,CAAC,EAAE;YACzD,eAAe,CAAC,cAAc,CAAC,CAAC;SACjC;IACH,CAAC;IACD,iDAAiD;IACjD,uDAAuD;IACvD,CAAC,cAAc,CAAC,CACjB,CAAC;IAEF,OAAO,CAAC,YAAY,EAAE,eAAe,CAAC,CAAC;AACzC,CAAC;AAED,eAAe,eAAe,CAAC"}
|
|
@@ -1,32 +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 { useEffect, useState } from 'react';
|
|
18
|
-
// The purpose of this hook to sync the string state from external changes i.e. re-population changes etc.
|
|
19
|
-
function useStringInput(valueFromProps) {
|
|
20
|
-
const [input, setInput] = useState(valueFromProps);
|
|
21
|
-
useEffect(() => {
|
|
22
|
-
if (input !== valueFromProps) {
|
|
23
|
-
setInput(valueFromProps);
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
// Only trigger this effect if prop value changes
|
|
27
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
28
|
-
[valueFromProps]);
|
|
29
|
-
return [input, setInput];
|
|
30
|
-
}
|
|
31
|
-
export default useStringInput;
|
|
32
|
-
//# sourceMappingURL=useStringInput.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useStringInput.js","sourceRoot":"","sources":["../../src/hooks/useStringInput.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,0GAA0G;AAC1G,SAAS,cAAc,CAAC,cAAsB;IAC5C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,cAAc,CAAC,CAAC;IAEnD,SAAS,CACP,GAAG,EAAE;QACH,IAAI,KAAK,KAAK,cAAc,EAAE;YAC5B,QAAQ,CAAC,cAAc,CAAC,CAAC;SAC1B;IACH,CAAC;IACD,iDAAiD;IACjD,uDAAuD;IACvD,CAAC,cAAc,CAAC,CACjB,CAAC;IAEF,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;AAC3B,CAAC;AAED,eAAe,cAAc,CAAC"}
|
|
@@ -1,38 +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
|
-
|
|
18
|
-
import type { Dispatch, SetStateAction } from 'react';
|
|
19
|
-
import { useEffect, useState } from 'react';
|
|
20
|
-
|
|
21
|
-
function useNumberInput(valueFromProps: number): [number, Dispatch<SetStateAction<number>>] {
|
|
22
|
-
const [value, setValue] = useState(valueFromProps);
|
|
23
|
-
|
|
24
|
-
useEffect(
|
|
25
|
-
() => {
|
|
26
|
-
if (value !== valueFromProps) {
|
|
27
|
-
setValue(valueFromProps);
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
// Only trigger this effect if prop value changes
|
|
31
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
32
|
-
[valueFromProps]
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
return [value, setValue];
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export default useNumberInput;
|
|
@@ -1,51 +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
|
-
|
|
18
|
-
import type { Dispatch, SetStateAction } from 'react';
|
|
19
|
-
import { useEffect, useState } from 'react';
|
|
20
|
-
import type { RepeatGroupSingle } from '../interfaces/repeatGroup.interface';
|
|
21
|
-
import _isEqual from 'lodash/isEqual';
|
|
22
|
-
import type { QuestionnaireResponseItem } from 'fhir/r4';
|
|
23
|
-
|
|
24
|
-
function useRepeatGroups(
|
|
25
|
-
valueFromProps: RepeatGroupSingle[]
|
|
26
|
-
): [RepeatGroupSingle[], Dispatch<SetStateAction<RepeatGroupSingle[]>>] {
|
|
27
|
-
const [repeatGroups, setRepeatGroups] = useState(valueFromProps);
|
|
28
|
-
|
|
29
|
-
useEffect(
|
|
30
|
-
() => {
|
|
31
|
-
const valueFromPropsQRItems = valueFromProps
|
|
32
|
-
.map((repeatGroupSingle) => repeatGroupSingle.qrItem)
|
|
33
|
-
.filter((qrItem): qrItem is QuestionnaireResponseItem => qrItem !== null);
|
|
34
|
-
|
|
35
|
-
const repeatGroupsQRItems = repeatGroups
|
|
36
|
-
.map((repeatGroupSingle) => repeatGroupSingle.qrItem)
|
|
37
|
-
.filter((qrItem): qrItem is QuestionnaireResponseItem => qrItem !== null);
|
|
38
|
-
|
|
39
|
-
if (!_isEqual(valueFromPropsQRItems, repeatGroupsQRItems)) {
|
|
40
|
-
setRepeatGroups(valueFromProps);
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
// Only trigger this effect if prop value changes
|
|
44
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
45
|
-
[valueFromProps]
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
return [repeatGroups, setRepeatGroups];
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export default useRepeatGroups;
|