@aehrc/smart-forms-renderer 0.7.2 → 0.8.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/ChoiceItems/ChoiceAutocompleteItem.js +0 -1
- package/lib/components/FormComponents/ChoiceItems/ChoiceAutocompleteItem.js.map +1 -1
- package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionFields.d.ts +12 -0
- package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionFields.js +39 -0
- package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionFields.js.map +1 -0
- package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionItem.d.ts +3 -3
- package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionItem.js +14 -27
- package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionItem.js.map +1 -1
- package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetFields.d.ts +13 -0
- package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetFields.js +42 -0
- package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetFields.js.map +1 -0
- package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetItem.d.ts +4 -3
- package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetItem.js +14 -22
- package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetItem.js.map +1 -1
- package/lib/components/FormComponents/ChoiceItems/ChoiceItemSwitcher.d.ts +2 -2
- package/lib/components/FormComponents/ChoiceItems/ChoiceItemSwitcher.js +3 -3
- package/lib/components/FormComponents/ChoiceItems/ChoiceItemSwitcher.js.map +1 -1
- package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionFields.d.ts +12 -0
- package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionFields.js +27 -0
- package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionFields.js.map +1 -0
- package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionItem.d.ts +1 -1
- package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionItem.js +9 -24
- package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionItem.js.map +1 -1
- package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetFields.d.ts +14 -0
- package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetFields.js +42 -0
- package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetFields.js.map +1 -0
- package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetItem.d.ts +1 -1
- package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetItem.js +8 -21
- package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetItem.js.map +1 -1
- package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionFields.d.ts +10 -0
- package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionFields.js +41 -0
- package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionFields.js.map +1 -0
- package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionItem.js +7 -23
- package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionItem.js.map +1 -1
- package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerValueSetFields.d.ts +12 -0
- package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerValueSetFields.js +42 -0
- package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerValueSetFields.js.map +1 -0
- package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerValueSetItem.js +8 -18
- package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerValueSetItem.js.map +1 -1
- package/lib/components/FormComponents/GroupItem/GroupItemSwitcher.js +4 -4
- package/lib/components/FormComponents/GroupItem/GroupItemSwitcher.js.map +1 -1
- package/lib/components/FormComponents/Item.styles.d.ts +2 -2
- package/lib/components/FormComponents/Item.styles.js +2 -2
- package/lib/components/FormComponents/Item.styles.js.map +1 -1
- package/lib/components/FormComponents/ItemParts/RadioAnswerOptionButtons.d.ts +8 -0
- package/lib/components/FormComponents/ItemParts/RadioAnswerOptionButtons.js +37 -0
- package/lib/components/FormComponents/ItemParts/RadioAnswerOptionButtons.js.map +1 -0
- package/lib/components/FormComponents/ItemParts/RadioButtons.d.ts +8 -0
- package/lib/components/FormComponents/ItemParts/RadioButtons.js +37 -0
- package/lib/components/FormComponents/ItemParts/RadioButtons.js.map +1 -0
- package/lib/components/FormComponents/ItemParts/RadioButtonsAnswerOption.d.ts +8 -0
- package/lib/components/FormComponents/ItemParts/RadioButtonsAnswerOption.js +37 -0
- package/lib/components/FormComponents/ItemParts/RadioButtonsAnswerOption.js.map +1 -0
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteField.d.ts +20 -0
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteField.js +49 -0
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteField.js.map +1 -0
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteFieldEndAdornment.d.ts +0 -0
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteFieldEndAdornment.js +2 -0
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteFieldEndAdornment.js.map +1 -0
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteItem.js +11 -35
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteItem.js.map +1 -1
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionFields.d.ts +17 -0
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionFields.js +42 -0
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionFields.js.map +1 -0
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionItem.d.ts +3 -3
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionItem.js +23 -36
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionItem.js.map +1 -1
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceItemSwitcher.d.ts +2 -2
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceItemSwitcher.js +3 -3
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceItemSwitcher.js.map +1 -1
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerOptionFields.d.ts +15 -0
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerOptionFields.js +29 -0
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerOptionFields.js.map +1 -0
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerOptionItem.d.ts +1 -1
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerOptionItem.js +3 -23
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerOptionItem.js.map +1 -1
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerOptionField.d.ts +11 -0
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerOptionField.js +14 -0
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerOptionField.js.map +1 -0
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerOptionFields.d.ts +0 -0
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerOptionFields.js +2 -0
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerOptionFields.js.map +1 -0
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerOptionItem.js +18 -23
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerOptionItem.js.map +1 -1
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerValueSetField.d.ts +12 -0
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerValueSetField.js +16 -0
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerValueSetField.js.map +1 -0
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerValueSetItem.js +8 -14
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerValueSetItem.js.map +1 -1
- package/lib/components/FormComponents/SingleItem/SingleItem.d.ts +2 -2
- package/lib/components/FormComponents/SingleItem/SingleItem.js +2 -2
- package/lib/components/FormComponents/SingleItem/SingleItem.js.map +1 -1
- package/lib/components/FormComponents/SingleItem/SingleItemSwitcher.d.ts +2 -2
- package/lib/components/FormComponents/SingleItem/SingleItemSwitcher.js +3 -3
- package/lib/components/FormComponents/SingleItem/SingleItemSwitcher.js.map +1 -1
- package/lib/components/FormComponents/Tables/AddItemButton.d.ts +8 -0
- package/lib/components/FormComponents/Tables/AddItemButton.js +28 -0
- package/lib/components/FormComponents/Tables/AddItemButton.js.map +1 -0
- package/lib/components/FormComponents/Tables/AddRowButton.d.ts +8 -0
- package/lib/components/FormComponents/Tables/AddRowButton.js +28 -0
- package/lib/components/FormComponents/Tables/AddRowButton.js.map +1 -0
- package/lib/components/FormComponents/Tables/GroupTable.d.ts +10 -0
- package/lib/components/FormComponents/Tables/GroupTable.js +108 -0
- package/lib/components/FormComponents/Tables/GroupTable.js.map +1 -0
- package/lib/components/FormComponents/Tables/GroupTableRow.d.ts +10 -0
- package/lib/components/FormComponents/Tables/GroupTableRow.js +46 -0
- package/lib/components/FormComponents/Tables/GroupTableRow.js.map +1 -0
- package/lib/components/FormComponents/Tables/index.d.ts +1 -1
- package/lib/components/FormComponents/Tables/index.js +1 -1
- package/lib/components/FormComponents/Tables/index.js.map +1 -1
- package/lib/components/Renderer/FormBodyTabbed.js +1 -1
- package/lib/components/Renderer/FormBodyTabbed.js.map +1 -1
- package/lib/components/Tabs/FormBodySingleTab.js +1 -1
- package/lib/components/Tabs/FormBodySingleTab.js.map +1 -1
- package/lib/components/Tabs/FormBodyTabList.d.ts +1 -0
- package/lib/components/Tabs/FormBodyTabList.js +3 -4
- package/lib/components/Tabs/FormBodyTabList.js.map +1 -1
- package/lib/components/Tabs/FormBodyTabListWrapper.d.ts +1 -1
- package/lib/components/Tabs/FormBodyTabListWrapper.js +6 -13
- package/lib/components/Tabs/FormBodyTabListWrapper.js.map +1 -1
- package/lib/components/Tabs/ShowCompletedTabsSection.d.ts +7 -0
- package/lib/components/Tabs/ShowCompletedTabsSection.js +34 -0
- package/lib/components/Tabs/ShowCompletedTabsSection.js.map +1 -0
- package/lib/hooks/useContextDisplayItems.d.ts +6 -0
- package/lib/hooks/useContextDisplayItems.js +30 -0
- package/lib/hooks/useContextDisplayItems.js.map +1 -0
- package/lib/hooks/useInitialiseRenderer.js +2 -2
- package/lib/hooks/useInitialiseRenderer.js.map +1 -1
- package/lib/hooks/useInitialiseRepeatGroups.d.ts +1 -1
- package/lib/hooks/useNumberInput.d.ts +1 -1
- package/lib/hooks/useNumberInput.js.map +1 -1
- package/lib/hooks/useStringInput.d.ts +1 -1
- package/lib/hooks/useStringInput.js.map +1 -1
- package/lib/hooks/useTerminologyServerQuery.js +3 -6
- package/lib/hooks/useTerminologyServerQuery.js.map +1 -1
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/lib/interfaces/renderProps.interface.d.ts +3 -0
- package/lib/stores/useQuestionnaireResponseStore.d.ts +2 -1
- package/lib/stores/useQuestionnaireResponseStore.js +5 -3
- package/lib/stores/useQuestionnaireResponseStore.js.map +1 -1
- package/lib/utils/qrItem.d.ts +2 -3
- package/lib/utils/qrItem.js +2 -3
- package/lib/utils/qrItem.js.map +1 -1
- package/lib/utils/repopulateIntoResponse.d.ts +2 -2
- package/lib/utils/repopulateItems.js +0 -1
- package/lib/utils/repopulateItems.js.map +1 -1
- package/package.json +7 -7
- package/src/components/FormComponents/ChoiceItems/ChoiceAutocompleteItem.tsx +0 -1
- package/src/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionFields.tsx +85 -0
- package/src/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionItem.tsx +35 -58
- package/src/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetFields.tsx +79 -0
- package/src/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetItem.tsx +37 -50
- package/src/components/FormComponents/ChoiceItems/ChoiceItemSwitcher.tsx +10 -5
- package/src/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionFields.tsx +48 -0
- package/src/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionItem.tsx +25 -53
- package/src/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetFields.tsx +83 -0
- package/src/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetItem.tsx +27 -49
- package/src/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionFields.tsx +81 -0
- package/src/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionItem.tsx +19 -54
- package/src/components/FormComponents/ChoiceItems/ChoiceSelectAnswerValueSetFields.tsx +97 -0
- package/src/components/FormComponents/ChoiceItems/ChoiceSelectAnswerValueSetItem.tsx +22 -60
- package/src/components/FormComponents/GroupItem/GroupItemSwitcher.tsx +4 -4
- package/src/components/FormComponents/Item.styles.ts +2 -2
- package/src/components/FormComponents/ItemParts/RadioAnswerOptionButtons.tsx +72 -0
- package/src/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteField.tsx +131 -0
- package/src/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteItem.tsx +38 -93
- package/src/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionFields.tsx +112 -0
- package/src/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionItem.tsx +57 -76
- package/src/components/FormComponents/OpenChoiceItems/OpenChoiceItemSwitcher.tsx +8 -5
- package/src/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerOptionFields.tsx +72 -0
- package/src/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerOptionItem.tsx +12 -59
- package/src/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerOptionField.tsx +54 -0
- package/src/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerOptionItem.tsx +40 -64
- package/src/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerValueSetField.tsx +63 -0
- package/src/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerValueSetItem.tsx +22 -50
- package/src/components/FormComponents/SingleItem/SingleItem.tsx +6 -3
- package/src/components/FormComponents/SingleItem/SingleItemSwitcher.tsx +7 -3
- package/src/components/FormComponents/Tables/AddRowButton.tsx +49 -0
- package/src/components/FormComponents/Tables/{QItemGroupTable.tsx → GroupTable.tsx} +6 -17
- package/src/components/FormComponents/Tables/{QItemGroupTableRow.tsx → GroupTableRow.tsx} +2 -2
- package/src/components/FormComponents/Tables/index.ts +1 -1
- package/src/components/Renderer/FormBodyTabbed.tsx +1 -1
- package/src/components/Tabs/FormBodySingleTab.tsx +1 -1
- package/src/components/Tabs/FormBodyTabList.tsx +5 -8
- package/src/components/Tabs/FormBodyTabListWrapper.tsx +15 -26
- package/src/components/Tabs/ShowCompletedTabsSection.tsx +52 -0
- package/src/hooks/useContextDisplayItems.ts +40 -0
- package/src/hooks/useInitialiseRenderer.ts +2 -2
- package/src/hooks/useInitialiseRepeatGroups.ts +1 -1
- package/src/hooks/useNumberInput.ts +2 -1
- package/src/hooks/useStringInput.ts +2 -1
- package/src/hooks/useTerminologyServerQuery.ts +3 -6
- package/src/index.ts +2 -2
- package/src/interfaces/renderProps.interface.ts +4 -0
- package/src/stores/useQuestionnaireResponseStore.ts +5 -4
- package/src/utils/qrItem.ts +4 -3
- package/src/utils/repopulateIntoResponse.ts +2 -2
- package/src/utils/repopulateItems.ts +0 -1
|
@@ -21,15 +21,13 @@ import Card from '@mui/material/Card';
|
|
|
21
21
|
import { PrimarySelectableList } from '../Lists.styles';
|
|
22
22
|
import type { QuestionnaireItem } from 'fhir/r4';
|
|
23
23
|
import type { Tabs } from '../../interfaces/tab.interface';
|
|
24
|
-
import { IconButton } from '@mui/material';
|
|
25
|
-
import ExpandLess from '@mui/icons-material/ExpandLess';
|
|
26
|
-
import ExpandMore from '@mui/icons-material/ExpandMore';
|
|
27
|
-
import Typography from '@mui/material/Typography';
|
|
28
24
|
import Divider from '@mui/material/Divider';
|
|
29
25
|
import FormBodyTabList from './FormBodyTabList';
|
|
26
|
+
import ShowCompletedTabsSection from './ShowCompletedTabsSection';
|
|
27
|
+
import useContextDisplayItems from '../../hooks/useContextDisplayItems';
|
|
30
28
|
|
|
31
29
|
interface FormBodyTabListWrapperProps {
|
|
32
|
-
|
|
30
|
+
topLevelItems: QuestionnaireItem[];
|
|
33
31
|
currentTabIndex: number;
|
|
34
32
|
tabs: Tabs;
|
|
35
33
|
}
|
|
@@ -37,39 +35,30 @@ interface FormBodyTabListWrapperProps {
|
|
|
37
35
|
const FormBodyTabListWrapper = memo(function FormBodyTabListWrapper(
|
|
38
36
|
props: FormBodyTabListWrapperProps
|
|
39
37
|
) {
|
|
40
|
-
const {
|
|
38
|
+
const { topLevelItems, currentTabIndex, tabs } = props;
|
|
41
39
|
|
|
42
40
|
const [completedTabsExpanded, setCompletedTabsExpanded] = useState(true);
|
|
43
41
|
|
|
42
|
+
const { allContextDisplayItems, completedDisplayItemExists } =
|
|
43
|
+
useContextDisplayItems(topLevelItems);
|
|
44
|
+
|
|
44
45
|
return (
|
|
45
46
|
<Card sx={{ p: 0.75, mb: 2 }}>
|
|
46
47
|
<Box sx={{ flexGrow: 1 }}>
|
|
47
48
|
<PrimarySelectableList dense disablePadding sx={{ mb: 1 }} data-test="renderer-tab-list">
|
|
48
|
-
|
|
49
|
-
<
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
</Typography>
|
|
55
|
-
<IconButton
|
|
56
|
-
size="small"
|
|
57
|
-
onClick={() => {
|
|
58
|
-
setCompletedTabsExpanded(!completedTabsExpanded);
|
|
59
|
-
}}>
|
|
60
|
-
{completedTabsExpanded ? (
|
|
61
|
-
<ExpandLess fontSize="small" />
|
|
62
|
-
) : (
|
|
63
|
-
<ExpandMore fontSize="small" />
|
|
64
|
-
)}
|
|
65
|
-
</IconButton>
|
|
66
|
-
</Box>
|
|
49
|
+
{completedDisplayItemExists ? (
|
|
50
|
+
<ShowCompletedTabsSection
|
|
51
|
+
completedTabsExpanded={completedTabsExpanded}
|
|
52
|
+
setCompletedTabsExpanded={setCompletedTabsExpanded}
|
|
53
|
+
/>
|
|
54
|
+
) : null}
|
|
67
55
|
<Divider sx={{ mx: 1 }} light />
|
|
68
56
|
<FormBodyTabList
|
|
69
|
-
topLevelItems={
|
|
57
|
+
topLevelItems={topLevelItems}
|
|
70
58
|
currentTabIndex={currentTabIndex}
|
|
71
59
|
tabs={tabs}
|
|
72
60
|
completedTabsCollapsed={!completedTabsExpanded}
|
|
61
|
+
allContextDisplayItems={allContextDisplayItems}
|
|
73
62
|
/>
|
|
74
63
|
</PrimarySelectableList>
|
|
75
64
|
</Box>
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 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 React from 'react';
|
|
19
|
+
import Box from '@mui/material/Box';
|
|
20
|
+
import Typography from '@mui/material/Typography';
|
|
21
|
+
import { IconButton } from '@mui/material';
|
|
22
|
+
import ExpandLess from '@mui/icons-material/ExpandLess';
|
|
23
|
+
import ExpandMore from '@mui/icons-material/ExpandMore';
|
|
24
|
+
|
|
25
|
+
interface ShowCompletedTabsSectionProps {
|
|
26
|
+
completedTabsExpanded: boolean;
|
|
27
|
+
setCompletedTabsExpanded: (newExpanded: boolean) => void;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function ShowCompletedTabsSection(props: ShowCompletedTabsSectionProps) {
|
|
31
|
+
const { completedTabsExpanded, setCompletedTabsExpanded } = props;
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<Box display="flex" justifyContent="center" alignItems="center" mx={2} columnGap={0.5}>
|
|
35
|
+
<Typography
|
|
36
|
+
variant="overline"
|
|
37
|
+
fontSize={9}
|
|
38
|
+
color={completedTabsExpanded ? 'text.secondary' : 'text.disabled'}>
|
|
39
|
+
Completed tabs {completedTabsExpanded ? 'shown' : 'hidden'}
|
|
40
|
+
</Typography>
|
|
41
|
+
<IconButton
|
|
42
|
+
size="small"
|
|
43
|
+
onClick={() => {
|
|
44
|
+
setCompletedTabsExpanded(!completedTabsExpanded);
|
|
45
|
+
}}>
|
|
46
|
+
{completedTabsExpanded ? <ExpandLess fontSize="small" /> : <ExpandMore fontSize="small" />}
|
|
47
|
+
</IconButton>
|
|
48
|
+
</Box>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export default ShowCompletedTabsSection;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 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 { useMemo } from 'react';
|
|
19
|
+
import { getContextDisplays } from '../utils/tabs';
|
|
20
|
+
import type { QuestionnaireItem } from 'fhir/r4';
|
|
21
|
+
|
|
22
|
+
function useContextDisplayItems(topLevelItems: QuestionnaireItem[]) {
|
|
23
|
+
return useMemo(() => {
|
|
24
|
+
let completedDisplayItemExists = false;
|
|
25
|
+
|
|
26
|
+
const allContextDisplayItems = topLevelItems.map((topLevelItem) =>
|
|
27
|
+
getContextDisplays(topLevelItem)
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
completedDisplayItemExists = allContextDisplayItems.some((contextDisplayItems) => {
|
|
31
|
+
return contextDisplayItems.some(
|
|
32
|
+
(contextDisplayItem) => contextDisplayItem.text === 'Complete'
|
|
33
|
+
);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
return { allContextDisplayItems, completedDisplayItemExists };
|
|
37
|
+
}, [topLevelItems]);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export default useContextDisplayItems;
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
import type { Questionnaire, QuestionnaireResponse } from 'fhir/r4';
|
|
19
19
|
import { useLayoutEffect, useState } from 'react';
|
|
20
|
-
import {
|
|
20
|
+
import { createEmptyQuestionnaireResponse } from '../utils/qrItem';
|
|
21
21
|
import useQuestionnaireStore from '../stores/useQuestionnaireStore';
|
|
22
22
|
import useQuestionnaireResponseStore from '../stores/useQuestionnaireResponseStore';
|
|
23
23
|
import type Client from 'fhirclient/lib/Client';
|
|
@@ -80,7 +80,7 @@ function useInitialiseRenderer(
|
|
|
80
80
|
additionalVariables,
|
|
81
81
|
terminologyServerUrl
|
|
82
82
|
).then(() => {
|
|
83
|
-
buildSourceResponse(
|
|
83
|
+
buildSourceResponse(createEmptyQuestionnaireResponse(questionnaire));
|
|
84
84
|
|
|
85
85
|
if (questionnaireResponse) {
|
|
86
86
|
const updatedResponse = updatePopulatedProperties(questionnaireResponse);
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
import type { QuestionnaireResponseItem } from 'fhir/r4';
|
|
19
|
-
import { QuestionnaireItem } from 'fhir/r4';
|
|
19
|
+
import type { QuestionnaireItem } from 'fhir/r4';
|
|
20
20
|
import { nanoid } from 'nanoid';
|
|
21
21
|
import type { RepeatGroupSingle } from '../interfaces/repeatGroup.interface';
|
|
22
22
|
import { useMemo } from 'react';
|
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
import { Dispatch, SetStateAction
|
|
18
|
+
import type { Dispatch, SetStateAction } from 'react';
|
|
19
|
+
import { useEffect, useState } from 'react';
|
|
19
20
|
|
|
20
21
|
function useNumberInput(valueFromProps: number): [number, Dispatch<SetStateAction<number>>] {
|
|
21
22
|
const [value, setValue] = useState(valueFromProps);
|
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
import { Dispatch, SetStateAction
|
|
18
|
+
import type { Dispatch, SetStateAction } from 'react';
|
|
19
|
+
import { useEffect, useState } from 'react';
|
|
19
20
|
|
|
20
21
|
function useStringInput(valueFromProps: string): [string, Dispatch<SetStateAction<string>>] {
|
|
21
22
|
const [input, setInput] = useState(valueFromProps);
|
|
@@ -34,7 +34,6 @@ function useTerminologyServerQuery(
|
|
|
34
34
|
|
|
35
35
|
let fullUrl = '';
|
|
36
36
|
let options: Coding[] = [];
|
|
37
|
-
let loading = false;
|
|
38
37
|
let feedback: { message: string; color: AlertColor } | undefined;
|
|
39
38
|
|
|
40
39
|
if (input.length === 0) {
|
|
@@ -64,7 +63,7 @@ function useTerminologyServerQuery(
|
|
|
64
63
|
|
|
65
64
|
// Perform query
|
|
66
65
|
const terminologyServerUrl = getTerminologyServerUrl(qItem) ?? defaultTerminologyServerUrl;
|
|
67
|
-
const {
|
|
66
|
+
const { isFetching, error, data } = useQuery<ValueSet>(
|
|
68
67
|
['expandValueSet', fullUrl],
|
|
69
68
|
() => getValueSetPromise(fullUrl, terminologyServerUrl),
|
|
70
69
|
{
|
|
@@ -72,9 +71,7 @@ function useTerminologyServerQuery(
|
|
|
72
71
|
}
|
|
73
72
|
);
|
|
74
73
|
|
|
75
|
-
|
|
76
|
-
loading = true;
|
|
77
|
-
}
|
|
74
|
+
console.log(isFetching);
|
|
78
75
|
|
|
79
76
|
if (error) {
|
|
80
77
|
console.warn('Ontoserver query failed. Details below: \n' + error);
|
|
@@ -95,6 +92,6 @@ function useTerminologyServerQuery(
|
|
|
95
92
|
}
|
|
96
93
|
}
|
|
97
94
|
|
|
98
|
-
return { options, loading, feedback };
|
|
95
|
+
return { options, loading: isFetching, feedback };
|
|
99
96
|
}
|
|
100
97
|
export default useTerminologyServerQuery;
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import useQuestionnaireStore from './stores/useQuestionnaireStore';
|
|
2
2
|
import type { Questionnaire, QuestionnaireResponse } from 'fhir/r4';
|
|
3
|
-
import {
|
|
3
|
+
import { createEmptyQuestionnaireResponse } from './utils/qrItem';
|
|
4
4
|
import useQuestionnaireResponseStore from './stores/useQuestionnaireResponseStore';
|
|
5
5
|
import { removeHiddenAnswers } from './utils/removeHidden';
|
|
6
6
|
import type { ItemToRepopulate } from './utils/repopulateItems';
|
|
@@ -28,7 +28,7 @@ export async function buildForm(
|
|
|
28
28
|
if (!questionnaireResponse) {
|
|
29
29
|
useQuestionnaireResponseStore
|
|
30
30
|
.getState()
|
|
31
|
-
.buildSourceResponse(
|
|
31
|
+
.buildSourceResponse(createEmptyQuestionnaireResponse(questionnaire));
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
34
|
|
|
@@ -2,12 +2,13 @@ import { create } from 'zustand';
|
|
|
2
2
|
import type { QuestionnaireResponse } from 'fhir/r4';
|
|
3
3
|
import { emptyResponse } from '../utils/emptyResource';
|
|
4
4
|
import cloneDeep from 'lodash.clonedeep';
|
|
5
|
-
import {
|
|
5
|
+
import type { Diff } from 'deep-diff';
|
|
6
|
+
import { diff } from 'deep-diff';
|
|
6
7
|
|
|
7
8
|
export interface UseQuestionnaireResponseStoreType {
|
|
8
9
|
sourceResponse: QuestionnaireResponse;
|
|
9
10
|
updatableResponse: QuestionnaireResponse;
|
|
10
|
-
formChangesHistory:
|
|
11
|
+
formChangesHistory: (Diff<QuestionnaireResponse, QuestionnaireResponse>[] | null)[];
|
|
11
12
|
buildSourceResponse: (response: QuestionnaireResponse) => void;
|
|
12
13
|
setUpdatableResponseAsPopulated: (populatedResponse: QuestionnaireResponse) => void;
|
|
13
14
|
updateResponse: (updatedResponse: QuestionnaireResponse) => void;
|
|
@@ -27,14 +28,14 @@ const useQuestionnaireResponseStore = create<UseQuestionnaireResponseStoreType>(
|
|
|
27
28
|
}));
|
|
28
29
|
},
|
|
29
30
|
setUpdatableResponseAsPopulated: (populatedResponse: QuestionnaireResponse) => {
|
|
30
|
-
const formChanges = diff(get().updatableResponse, populatedResponse
|
|
31
|
+
const formChanges = diff(get().updatableResponse, populatedResponse) ?? null;
|
|
31
32
|
set(() => ({
|
|
32
33
|
updatableResponse: populatedResponse,
|
|
33
34
|
formChangesHistory: [...get().formChangesHistory, formChanges]
|
|
34
35
|
}));
|
|
35
36
|
},
|
|
36
37
|
updateResponse: (updatedResponse: QuestionnaireResponse) => {
|
|
37
|
-
const formChanges = diff(get().updatableResponse, updatedResponse
|
|
38
|
+
const formChanges = diff(get().updatableResponse, updatedResponse) ?? null;
|
|
38
39
|
set(() => ({
|
|
39
40
|
updatableResponse: updatedResponse,
|
|
40
41
|
formChangesHistory: [...get().formChangesHistory, formChanges]
|
package/src/utils/qrItem.ts
CHANGED
|
@@ -25,12 +25,13 @@ import type {
|
|
|
25
25
|
import type { QrRepeatGroup } from '../interfaces/repeatGroup.interface';
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
|
-
* Create
|
|
29
|
-
* A questionnaire form item is the first item of a questionnaire
|
|
28
|
+
* Create an empty questionnaireResponse from a given questionnaire
|
|
30
29
|
*
|
|
31
30
|
* @author Sean Fong
|
|
32
31
|
*/
|
|
33
|
-
export function
|
|
32
|
+
export function createEmptyQuestionnaireResponse(
|
|
33
|
+
questionnaire: Questionnaire
|
|
34
|
+
): QuestionnaireResponse {
|
|
34
35
|
const questionnaireResponse: QuestionnaireResponse = {
|
|
35
36
|
resourceType: 'QuestionnaireResponse',
|
|
36
37
|
status: 'in-progress'
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type {
|
|
2
2
|
Questionnaire,
|
|
3
3
|
QuestionnaireItem,
|
|
4
4
|
QuestionnaireResponse,
|
|
5
5
|
QuestionnaireResponseItem
|
|
6
6
|
} from 'fhir/r4';
|
|
7
|
-
import { ItemToRepopulate } from './repopulateItems';
|
|
7
|
+
import type { ItemToRepopulate } from './repopulateItems';
|
|
8
8
|
import { getQrItemsIndex, mapQItemsIndex } from './mapItem';
|
|
9
9
|
import { updateQrItemsInGroup } from './qrItem';
|
|
10
10
|
|
|
@@ -114,7 +114,6 @@ function getCorrespondingQuestionnaireItemsRecursive(
|
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
// TODO it seems like there can only be one answer per linkId, we might need to do repeat groups differently
|
|
117
|
-
// so we need to fix this one first it seems like
|
|
118
117
|
|
|
119
118
|
/* Repeat group implementation */
|
|
120
119
|
if (qItem.type === 'group' && qItem.repeats) {
|