@aehrc/smart-forms-renderer 0.13.0 → 0.13.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/Box.styles.d.ts +0 -6
- package/lib/components/Box.styles.js +1 -29
- package/lib/components/Box.styles.js.map +1 -1
- package/lib/components/FormComponents/BooleanItem/BooleanItem.js +1 -3
- package/lib/components/FormComponents/BooleanItem/BooleanItem.js.map +1 -1
- package/lib/components/FormComponents/ChoiceItems/ChoiceAutocompleteItem.js +1 -3
- package/lib/components/FormComponents/ChoiceItems/ChoiceAutocompleteItem.js.map +1 -1
- package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionItem.js +2 -2
- package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionItem.js.map +1 -1
- package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetItem.js +2 -2
- package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetItem.js.map +1 -1
- package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionItem.js +1 -3
- package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionItem.js.map +1 -1
- package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetItem.js +1 -3
- package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetItem.js.map +1 -1
- package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionItem.js +1 -3
- package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionItem.js.map +1 -1
- package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerValueSetItem.js +1 -3
- package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerValueSetItem.js.map +1 -1
- package/lib/components/FormComponents/CustomDateItem/CustomDateItem.js +2 -2
- package/lib/components/FormComponents/CustomDateItem/CustomDateItem.js.map +1 -1
- package/lib/components/FormComponents/DateItem/DateItem.js +2 -2
- package/lib/components/FormComponents/DateItem/DateItem.js.map +1 -1
- package/lib/components/FormComponents/DateTimeItem/DateTimeItem.js +2 -2
- package/lib/components/FormComponents/DateTimeItem/DateTimeItem.js.map +1 -1
- package/lib/components/FormComponents/DecimalItem/DecimalItem.js +2 -2
- package/lib/components/FormComponents/DecimalItem/DecimalItem.js.map +1 -1
- package/lib/components/FormComponents/IntegerItem/IntegerItem.js +2 -2
- package/lib/components/FormComponents/IntegerItem/IntegerItem.js.map +1 -1
- package/lib/components/FormComponents/ItemParts/ItemFieldGrid.d.ts +1 -3
- package/lib/components/FormComponents/ItemParts/ItemFieldGrid.js +9 -10
- package/lib/components/FormComponents/ItemParts/ItemFieldGrid.js.map +1 -1
- package/lib/components/FormComponents/ItemParts/ItemLabelText.js +1 -1
- package/lib/components/FormComponents/ItemParts/ItemLabelText.js.map +1 -1
- package/lib/components/FormComponents/ItemParts/ItemLabelWrapper.js +20 -1
- package/lib/components/FormComponents/ItemParts/ItemLabelWrapper.js.map +1 -1
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteItem.js +1 -3
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteItem.js.map +1 -1
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionItem.js +2 -2
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionItem.js.map +1 -1
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerOptionItem.js +1 -3
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerOptionItem.js.map +1 -1
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerOptionItem.js +1 -3
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerOptionItem.js.map +1 -1
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerValueSetItem.js +1 -3
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerValueSetItem.js.map +1 -1
- package/lib/components/FormComponents/RepeatItem/RepeatItem.js +1 -3
- package/lib/components/FormComponents/RepeatItem/RepeatItem.js.map +1 -1
- package/lib/components/FormComponents/SliderItem/SliderItem.js +1 -3
- package/lib/components/FormComponents/SliderItem/SliderItem.js.map +1 -1
- package/lib/components/FormComponents/StringItem/StringItem.js +2 -2
- package/lib/components/FormComponents/StringItem/StringItem.js.map +1 -1
- package/lib/components/FormComponents/TextItem/TextItem.js +2 -2
- package/lib/components/FormComponents/TextItem/TextItem.js.map +1 -1
- package/lib/components/FormComponents/TimeItem/TimeItem.js +2 -2
- package/lib/components/FormComponents/TimeItem/TimeItem.js.map +1 -1
- package/lib/components/FormComponents/UrlItem/UrlItem.js +2 -2
- package/lib/components/FormComponents/UrlItem/UrlItem.js.map +1 -1
- package/lib/components/Renderer/BaseRenderer.js +0 -4
- package/lib/components/Renderer/BaseRenderer.js.map +1 -1
- package/lib/hooks/useRenderingExtensions.d.ts +1 -0
- package/lib/hooks/useRenderingExtensions.js +2 -1
- package/lib/hooks/useRenderingExtensions.js.map +1 -1
- package/lib/setup-jest.js +1 -0
- package/lib/stories/MedicalHistoryTable.stories.js +45 -0
- package/lib/stories/SmartFormsRenderer.stories.js +117 -0
- package/lib/utils/itemControl.d.ts +6 -0
- package/lib/utils/itemControl.js +15 -0
- package/lib/utils/itemControl.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Box.styles.ts +1 -31
- package/src/components/FormComponents/BooleanItem/BooleanItem.tsx +1 -7
- package/src/components/FormComponents/ChoiceItems/ChoiceAutocompleteItem.tsx +1 -7
- package/src/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionItem.tsx +2 -6
- package/src/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetItem.tsx +2 -6
- package/src/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionItem.tsx +1 -7
- package/src/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetItem.tsx +1 -7
- package/src/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionItem.tsx +1 -7
- package/src/components/FormComponents/ChoiceItems/ChoiceSelectAnswerValueSetItem.tsx +1 -7
- package/src/components/FormComponents/CustomDateItem/CustomDateItem.tsx +2 -7
- package/src/components/FormComponents/DateItem/DateItem.tsx +2 -7
- package/src/components/FormComponents/DateTimeItem/DateTimeItem.tsx +2 -7
- package/src/components/FormComponents/DecimalItem/DecimalItem.tsx +3 -15
- package/src/components/FormComponents/IntegerItem/IntegerItem.tsx +3 -15
- package/src/components/FormComponents/ItemParts/ItemFieldGrid.tsx +13 -16
- package/src/components/FormComponents/ItemParts/ItemLabelText.tsx +1 -1
- package/src/components/FormComponents/ItemParts/ItemLabelWrapper.tsx +30 -1
- package/src/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteItem.tsx +1 -7
- package/src/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionItem.tsx +2 -6
- package/src/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerOptionItem.tsx +1 -7
- package/src/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerOptionItem.tsx +1 -7
- package/src/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerValueSetItem.tsx +1 -7
- package/src/components/FormComponents/RepeatItem/RepeatItem.tsx +1 -7
- package/src/components/FormComponents/SliderItem/SliderItem.tsx +1 -7
- package/src/components/FormComponents/StringItem/StringItem.tsx +3 -15
- package/src/components/FormComponents/TextItem/TextItem.tsx +3 -15
- package/src/components/FormComponents/TimeItem/TimeItem.tsx +2 -7
- package/src/components/FormComponents/UrlItem/UrlItem.tsx +3 -15
- package/src/components/Renderer/BaseRenderer.tsx +0 -6
- package/src/hooks/useRenderingExtensions.ts +3 -0
- package/src/utils/itemControl.ts +16 -0
- package/lib/components/FormComponents/ItemParts/ItemExtensionLabels.js +0 -30
- package/lib/components/FormComponents/ItemParts/ItemExtensionLabels.js.map +0 -1
- package/src/components/FormComponents/ItemParts/ItemExtensionLabels.tsx +0 -42
|
@@ -15,38 +15,35 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
import type {
|
|
18
|
+
import type { ReactNode } from 'react';
|
|
19
19
|
import React from 'react';
|
|
20
20
|
import Grid from '@mui/material/Grid';
|
|
21
21
|
import type { QuestionnaireItem } from 'fhir/r4';
|
|
22
22
|
import DisplayInstructions from '../DisplayItem/DisplayInstructions';
|
|
23
23
|
import LabelWrapper from './ItemLabelWrapper';
|
|
24
|
-
import
|
|
24
|
+
import useRenderingExtensions from '../../../hooks/useRenderingExtensions';
|
|
25
25
|
|
|
26
26
|
interface ItemFieldGridProps {
|
|
27
27
|
children: ReactNode;
|
|
28
28
|
qItem: QuestionnaireItem;
|
|
29
|
-
displayInstructions: string | ReactElement;
|
|
30
|
-
required: boolean;
|
|
31
29
|
readOnly: boolean;
|
|
32
30
|
}
|
|
33
31
|
|
|
34
32
|
function ItemFieldGrid(props: ItemFieldGridProps) {
|
|
35
|
-
const { children, qItem,
|
|
33
|
+
const { children, qItem, readOnly } = props;
|
|
34
|
+
|
|
35
|
+
const { displayInstructions } = useRenderingExtensions(qItem);
|
|
36
36
|
|
|
37
37
|
return (
|
|
38
|
-
|
|
39
|
-
<
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
<
|
|
45
|
-
{children}
|
|
46
|
-
<DisplayInstructions displayInstructions={displayInstructions} readOnly={readOnly} />
|
|
47
|
-
</Grid>
|
|
38
|
+
<Grid container columnSpacing={6}>
|
|
39
|
+
<Grid item xs={5}>
|
|
40
|
+
<LabelWrapper qItem={qItem} readOnly={readOnly} />
|
|
41
|
+
</Grid>
|
|
42
|
+
<Grid item xs={7}>
|
|
43
|
+
{children}
|
|
44
|
+
<DisplayInstructions displayInstructions={displayInstructions} readOnly={readOnly} />
|
|
48
45
|
</Grid>
|
|
49
|
-
|
|
46
|
+
</Grid>
|
|
50
47
|
);
|
|
51
48
|
}
|
|
52
49
|
|
|
@@ -54,7 +54,7 @@ const ItemLabelText = memo(function ItemLabelText(props: ItemLabelTextProps) {
|
|
|
54
54
|
|
|
55
55
|
// parse regular text
|
|
56
56
|
return (
|
|
57
|
-
<Typography color={readOnly ? 'text.
|
|
57
|
+
<Typography color={readOnly ? 'text.disabled' : 'text.primary'} sx={{ mt: 0.25 }}>
|
|
58
58
|
{qItem.text}
|
|
59
59
|
</Typography>
|
|
60
60
|
);
|
|
@@ -21,6 +21,9 @@ import ContextDisplayItem from './ContextDisplayItem';
|
|
|
21
21
|
import type { QuestionnaireItem } from 'fhir/r4';
|
|
22
22
|
import { getContextDisplays } from '../../../utils/tabs';
|
|
23
23
|
import ItemLabelText from './ItemLabelText';
|
|
24
|
+
import Tooltip from '@mui/material/Tooltip';
|
|
25
|
+
import Typography from '@mui/material/Typography';
|
|
26
|
+
import useRenderingExtensions from '../../../hooks/useRenderingExtensions';
|
|
24
27
|
|
|
25
28
|
interface LabelWrapperProps {
|
|
26
29
|
qItem: QuestionnaireItem;
|
|
@@ -30,11 +33,37 @@ interface LabelWrapperProps {
|
|
|
30
33
|
function ItemLabelWrapper(props: LabelWrapperProps) {
|
|
31
34
|
const { qItem, readOnly } = props;
|
|
32
35
|
|
|
36
|
+
const { required, displayFlyover } = useRenderingExtensions(qItem);
|
|
33
37
|
const contextDisplayItems = getContextDisplays(qItem);
|
|
34
38
|
|
|
35
39
|
return (
|
|
36
40
|
<Box display="flex" alignItems="center" justifyContent="space-between">
|
|
37
|
-
<
|
|
41
|
+
<Tooltip
|
|
42
|
+
title={displayFlyover}
|
|
43
|
+
placement="top"
|
|
44
|
+
slotProps={{
|
|
45
|
+
popper: {
|
|
46
|
+
modifiers: [
|
|
47
|
+
{
|
|
48
|
+
name: 'offset',
|
|
49
|
+
options: {
|
|
50
|
+
offset: [0, -8]
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
}}>
|
|
56
|
+
<span>
|
|
57
|
+
<Box display="flex" columnGap={0.4} justifyContent="space-between">
|
|
58
|
+
{required ? (
|
|
59
|
+
<Typography color="red" sx={{ ml: -1.15 }}>
|
|
60
|
+
*
|
|
61
|
+
</Typography>
|
|
62
|
+
) : null}
|
|
63
|
+
<ItemLabelText qItem={qItem} readOnly={readOnly} />
|
|
64
|
+
</Box>
|
|
65
|
+
</span>
|
|
66
|
+
</Tooltip>
|
|
38
67
|
|
|
39
68
|
<Box display="flex" columnGap={0.5}>
|
|
40
69
|
{contextDisplayItems.map((item) => {
|
|
@@ -23,7 +23,6 @@ import { createEmptyQrItem } from '../../../utils/qrItem';
|
|
|
23
23
|
import { FullWidthFormComponentBox } from '../../Box.styles';
|
|
24
24
|
import useDebounce from '../../../hooks/useDebounce';
|
|
25
25
|
import useTerminologyServerQuery from '../../../hooks/useTerminologyServerQuery';
|
|
26
|
-
import useRenderingExtensions from '../../../hooks/useRenderingExtensions';
|
|
27
26
|
import type {
|
|
28
27
|
PropsWithIsRepeatedAttribute,
|
|
29
28
|
PropsWithIsTabledAttribute,
|
|
@@ -48,7 +47,6 @@ function OpenChoiceAutocompleteItem(props: OpenChoiceAutocompleteItemProps) {
|
|
|
48
47
|
const { qItem, qrItem, isRepeated, isTabled, parentIsReadOnly, onQrItemChange } = props;
|
|
49
48
|
|
|
50
49
|
const readOnly = useReadOnly(qItem, parentIsReadOnly);
|
|
51
|
-
const { displayInstructions, required } = useRenderingExtensions(qItem);
|
|
52
50
|
|
|
53
51
|
const qrOpenChoice = qrItem ?? createEmptyQrItem(qItem);
|
|
54
52
|
|
|
@@ -133,11 +131,7 @@ function OpenChoiceAutocompleteItem(props: OpenChoiceAutocompleteItemProps) {
|
|
|
133
131
|
|
|
134
132
|
return (
|
|
135
133
|
<FullWidthFormComponentBox>
|
|
136
|
-
<ItemFieldGrid
|
|
137
|
-
qItem={qItem}
|
|
138
|
-
displayInstructions={displayInstructions}
|
|
139
|
-
required={required}
|
|
140
|
-
readOnly={readOnly}>
|
|
134
|
+
<ItemFieldGrid qItem={qItem} readOnly={readOnly}>
|
|
141
135
|
<OpenChoiceAutocompleteField
|
|
142
136
|
qItem={qItem}
|
|
143
137
|
options={options}
|
package/src/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionItem.tsx
CHANGED
|
@@ -63,7 +63,7 @@ function OpenChoiceCheckboxAnswerOptionItem(props: OpenChoiceCheckboxAnswerOptio
|
|
|
63
63
|
|
|
64
64
|
const readOnly = useReadOnly(qItem, parentIsReadOnly);
|
|
65
65
|
const openLabelText = getOpenLabelText(qItem);
|
|
66
|
-
const { displayInstructions
|
|
66
|
+
const { displayInstructions } = useRenderingExtensions(qItem);
|
|
67
67
|
|
|
68
68
|
// Init answers
|
|
69
69
|
const qrOpenChoiceCheckbox = qrItem ?? createEmptyQrItem(qItem);
|
|
@@ -158,11 +158,7 @@ function OpenChoiceCheckboxAnswerOptionItem(props: OpenChoiceCheckboxAnswerOptio
|
|
|
158
158
|
|
|
159
159
|
return (
|
|
160
160
|
<FullWidthFormComponentBox data-test="q-item-open-choice-checkbox-answer-option-box">
|
|
161
|
-
<ItemFieldGrid
|
|
162
|
-
qItem={qItem}
|
|
163
|
-
displayInstructions={displayInstructions}
|
|
164
|
-
required={required}
|
|
165
|
-
readOnly={readOnly}>
|
|
161
|
+
<ItemFieldGrid qItem={qItem} readOnly={readOnly}>
|
|
166
162
|
<OpenChoiceCheckboxAnswerOptionFields
|
|
167
163
|
qItem={qItem}
|
|
168
164
|
answers={answers}
|
|
@@ -23,7 +23,6 @@ import { getOpenLabelText } from '../../../utils/itemControl';
|
|
|
23
23
|
import { getOldOpenLabelAnswer } from '../../../utils/openChoice';
|
|
24
24
|
import { FullWidthFormComponentBox } from '../../Box.styles';
|
|
25
25
|
import { findInAnswerOptions, getQrChoiceValue } from '../../../utils/choice';
|
|
26
|
-
import useRenderingExtensions from '../../../hooks/useRenderingExtensions';
|
|
27
26
|
import type {
|
|
28
27
|
PropsWithIsRepeatedAttribute,
|
|
29
28
|
PropsWithParentIsReadOnlyAttribute,
|
|
@@ -47,7 +46,6 @@ function OpenChoiceRadioAnswerOptionItem(props: OpenChoiceRadioAnswerOptionItemP
|
|
|
47
46
|
|
|
48
47
|
const readOnly = useReadOnly(qItem, parentIsReadOnly);
|
|
49
48
|
const openLabelText = getOpenLabelText(qItem);
|
|
50
|
-
const { displayInstructions, required } = useRenderingExtensions(qItem);
|
|
51
49
|
|
|
52
50
|
// Init answers
|
|
53
51
|
const qrOpenChoiceRadio = qrItem ?? createEmptyQrItem(qItem);
|
|
@@ -119,11 +117,7 @@ function OpenChoiceRadioAnswerOptionItem(props: OpenChoiceRadioAnswerOptionItemP
|
|
|
119
117
|
|
|
120
118
|
return (
|
|
121
119
|
<FullWidthFormComponentBox data-test="q-item-open-choice-radio-answer-option-box">
|
|
122
|
-
<ItemFieldGrid
|
|
123
|
-
qItem={qItem}
|
|
124
|
-
displayInstructions={displayInstructions}
|
|
125
|
-
required={required}
|
|
126
|
-
readOnly={readOnly}>
|
|
120
|
+
<ItemFieldGrid qItem={qItem} readOnly={readOnly}>
|
|
127
121
|
<OpenChoiceRadioAnswerOptionFields
|
|
128
122
|
qItem={qItem}
|
|
129
123
|
valueRadio={valueRadio}
|
|
@@ -23,7 +23,6 @@ import type {
|
|
|
23
23
|
} from 'fhir/r4';
|
|
24
24
|
import { createEmptyQrItem } from '../../../utils/qrItem';
|
|
25
25
|
import { FullWidthFormComponentBox } from '../../Box.styles';
|
|
26
|
-
import useRenderingExtensions from '../../../hooks/useRenderingExtensions';
|
|
27
26
|
import type {
|
|
28
27
|
PropsWithIsRepeatedAttribute,
|
|
29
28
|
PropsWithIsTabledAttribute,
|
|
@@ -47,7 +46,6 @@ function OpenChoiceSelectAnswerOptionItem(props: OpenChoiceSelectAnswerOptionIte
|
|
|
47
46
|
const { qItem, qrItem, isRepeated, isTabled, parentIsReadOnly, onQrItemChange } = props;
|
|
48
47
|
|
|
49
48
|
const readOnly = useReadOnly(qItem, parentIsReadOnly);
|
|
50
|
-
const { displayInstructions, required } = useRenderingExtensions(qItem);
|
|
51
49
|
|
|
52
50
|
// Init input value
|
|
53
51
|
const answerOptions = qItem.answerOption;
|
|
@@ -107,11 +105,7 @@ function OpenChoiceSelectAnswerOptionItem(props: OpenChoiceSelectAnswerOptionIte
|
|
|
107
105
|
|
|
108
106
|
return (
|
|
109
107
|
<FullWidthFormComponentBox data-test="q-item-open-choice-select-answer-option-box">
|
|
110
|
-
<ItemFieldGrid
|
|
111
|
-
qItem={qItem}
|
|
112
|
-
displayInstructions={displayInstructions}
|
|
113
|
-
required={required}
|
|
114
|
-
readOnly={readOnly}>
|
|
108
|
+
<ItemFieldGrid qItem={qItem} readOnly={readOnly}>
|
|
115
109
|
<OpenChoiceSelectAnswerOptionField
|
|
116
110
|
qItem={qItem}
|
|
117
111
|
options={answerOptions}
|
package/src/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerValueSetItem.tsx
CHANGED
|
@@ -20,7 +20,6 @@ import type { Coding, QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/
|
|
|
20
20
|
import { createEmptyQrItem } from '../../../utils/qrItem';
|
|
21
21
|
import { FullWidthFormComponentBox } from '../../Box.styles';
|
|
22
22
|
import useValueSetCodings from '../../../hooks/useValueSetCodings';
|
|
23
|
-
import useRenderingExtensions from '../../../hooks/useRenderingExtensions';
|
|
24
23
|
import type {
|
|
25
24
|
PropsWithIsRepeatedAttribute,
|
|
26
25
|
PropsWithIsTabledAttribute,
|
|
@@ -44,7 +43,6 @@ function OpenChoiceSelectAnswerValueSetItem(props: OpenChoiceSelectAnswerValueSe
|
|
|
44
43
|
const { qItem, qrItem, isRepeated, isTabled, parentIsReadOnly, onQrItemChange } = props;
|
|
45
44
|
|
|
46
45
|
const readOnly = useReadOnly(qItem, parentIsReadOnly);
|
|
47
|
-
const { displayInstructions, required } = useRenderingExtensions(qItem);
|
|
48
46
|
|
|
49
47
|
// Init input value
|
|
50
48
|
const qrOpenChoice = qrItem ?? createEmptyQrItem(qItem);
|
|
@@ -91,11 +89,7 @@ function OpenChoiceSelectAnswerValueSetItem(props: OpenChoiceSelectAnswerValueSe
|
|
|
91
89
|
|
|
92
90
|
return (
|
|
93
91
|
<FullWidthFormComponentBox>
|
|
94
|
-
<ItemFieldGrid
|
|
95
|
-
qItem={qItem}
|
|
96
|
-
displayInstructions={displayInstructions}
|
|
97
|
-
required={required}
|
|
98
|
-
readOnly={readOnly}>
|
|
92
|
+
<ItemFieldGrid qItem={qItem} readOnly={readOnly}>
|
|
99
93
|
<OpenChoiceSelectAnswerValueSetField
|
|
100
94
|
qItem={qItem}
|
|
101
95
|
options={codings}
|
|
@@ -23,7 +23,6 @@ import type {
|
|
|
23
23
|
} from '../../../interfaces/renderProps.interface';
|
|
24
24
|
import type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';
|
|
25
25
|
import { nanoid } from 'nanoid';
|
|
26
|
-
import useRenderingExtensions from '../../../hooks/useRenderingExtensions';
|
|
27
26
|
import { createEmptyQrItem } from '../../../utils/qrItem';
|
|
28
27
|
import { FullWidthFormComponentBox } from '../../Box.styles';
|
|
29
28
|
import AddItemButton from './AddItemButton';
|
|
@@ -46,7 +45,6 @@ function RepeatItem(props: RepeatItemProps) {
|
|
|
46
45
|
const { qItem, qrItem, showMinimalView, parentIsReadOnly, onQrItemChange } = props;
|
|
47
46
|
|
|
48
47
|
const readOnly = useReadOnly(qItem, parentIsReadOnly);
|
|
49
|
-
const { displayInstructions, required } = useRenderingExtensions(qItem);
|
|
50
48
|
|
|
51
49
|
const initialRepeatAnswers = useInitialiseRepeatAnswers(qItem, qrItem);
|
|
52
50
|
|
|
@@ -119,11 +117,7 @@ function RepeatItem(props: RepeatItemProps) {
|
|
|
119
117
|
|
|
120
118
|
return (
|
|
121
119
|
<FullWidthFormComponentBox data-test="q-item-repeat-box">
|
|
122
|
-
<ItemFieldGrid
|
|
123
|
-
qItem={qItem}
|
|
124
|
-
displayInstructions={displayInstructions}
|
|
125
|
-
required={required}
|
|
126
|
-
readOnly={readOnly}>
|
|
120
|
+
<ItemFieldGrid qItem={qItem} readOnly={readOnly}>
|
|
127
121
|
<TransitionGroup>
|
|
128
122
|
{repeatAnswers.map(({ nanoId, answer }, index) => {
|
|
129
123
|
const repeatAnswerQrItem = createEmptyQrItem(qItem);
|
|
@@ -23,7 +23,6 @@ import type {
|
|
|
23
23
|
PropsWithQrItemChangeHandler
|
|
24
24
|
} from '../../../interfaces/renderProps.interface';
|
|
25
25
|
import type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';
|
|
26
|
-
import useRenderingExtensions from '../../../hooks/useRenderingExtensions';
|
|
27
26
|
import { createEmptyQrItem } from '../../../utils/qrItem';
|
|
28
27
|
import { FullWidthFormComponentBox } from '../../Box.styles';
|
|
29
28
|
import ItemFieldGrid from '../ItemParts/ItemFieldGrid';
|
|
@@ -45,7 +44,6 @@ function SliderItem(props: SliderItemProps) {
|
|
|
45
44
|
const { qItem, qrItem, isRepeated, isTabled, parentIsReadOnly, onQrItemChange } = props;
|
|
46
45
|
|
|
47
46
|
const readOnly = useReadOnly(qItem, parentIsReadOnly);
|
|
48
|
-
const { displayInstructions, required } = useRenderingExtensions(qItem);
|
|
49
47
|
const { minValue, maxValue, stepValue, minLabel, maxLabel } = useSliderExtensions(qItem);
|
|
50
48
|
|
|
51
49
|
const isInteracted = !!qrItem?.answer;
|
|
@@ -91,11 +89,7 @@ function SliderItem(props: SliderItemProps) {
|
|
|
91
89
|
|
|
92
90
|
return (
|
|
93
91
|
<FullWidthFormComponentBox data-test="q-item-slider-box">
|
|
94
|
-
<ItemFieldGrid
|
|
95
|
-
qItem={qItem}
|
|
96
|
-
displayInstructions={displayInstructions}
|
|
97
|
-
required={required}
|
|
98
|
-
readOnly={readOnly}>
|
|
92
|
+
<ItemFieldGrid qItem={qItem} readOnly={readOnly}>
|
|
99
93
|
<Box px={4}>
|
|
100
94
|
<SliderField
|
|
101
95
|
linkId={qItem.linkId}
|
|
@@ -47,16 +47,8 @@ function StringItem(props: StringItemProps) {
|
|
|
47
47
|
const { qItem, qrItem, isRepeated, isTabled, parentIsReadOnly, onQrItemChange } = props;
|
|
48
48
|
|
|
49
49
|
const readOnly = useReadOnly(qItem, parentIsReadOnly);
|
|
50
|
-
const {
|
|
51
|
-
|
|
52
|
-
displayPrompt,
|
|
53
|
-
displayInstructions,
|
|
54
|
-
entryFormat,
|
|
55
|
-
required,
|
|
56
|
-
regexValidation,
|
|
57
|
-
minLength,
|
|
58
|
-
maxLength
|
|
59
|
-
} = useRenderingExtensions(qItem);
|
|
50
|
+
const { displayUnit, displayPrompt, entryFormat, regexValidation, minLength, maxLength } =
|
|
51
|
+
useRenderingExtensions(qItem);
|
|
60
52
|
|
|
61
53
|
// Init input value
|
|
62
54
|
let valueString = '';
|
|
@@ -115,11 +107,7 @@ function StringItem(props: StringItemProps) {
|
|
|
115
107
|
}
|
|
116
108
|
return (
|
|
117
109
|
<FullWidthFormComponentBox data-test="q-item-string-box">
|
|
118
|
-
<ItemFieldGrid
|
|
119
|
-
qItem={qItem}
|
|
120
|
-
displayInstructions={displayInstructions}
|
|
121
|
-
required={required}
|
|
122
|
-
readOnly={readOnly}>
|
|
110
|
+
<ItemFieldGrid qItem={qItem} readOnly={readOnly}>
|
|
123
111
|
<StringField
|
|
124
112
|
linkId={qItem.linkId}
|
|
125
113
|
input={input}
|
|
@@ -46,16 +46,8 @@ function TextItem(props: TextItemProps) {
|
|
|
46
46
|
const { qItem, qrItem, isRepeated, parentIsReadOnly, onQrItemChange } = props;
|
|
47
47
|
|
|
48
48
|
const readOnly = useReadOnly(qItem, parentIsReadOnly);
|
|
49
|
-
const {
|
|
50
|
-
|
|
51
|
-
displayPrompt,
|
|
52
|
-
displayInstructions,
|
|
53
|
-
entryFormat,
|
|
54
|
-
required,
|
|
55
|
-
regexValidation,
|
|
56
|
-
minLength,
|
|
57
|
-
maxLength
|
|
58
|
-
} = useRenderingExtensions(qItem);
|
|
49
|
+
const { displayUnit, displayPrompt, entryFormat, regexValidation, minLength, maxLength } =
|
|
50
|
+
useRenderingExtensions(qItem);
|
|
59
51
|
|
|
60
52
|
// Init input value
|
|
61
53
|
let valueText = '';
|
|
@@ -113,11 +105,7 @@ function TextItem(props: TextItemProps) {
|
|
|
113
105
|
}
|
|
114
106
|
return (
|
|
115
107
|
<FullWidthFormComponentBox data-test="q-item-text-box">
|
|
116
|
-
<ItemFieldGrid
|
|
117
|
-
qItem={qItem}
|
|
118
|
-
displayInstructions={displayInstructions}
|
|
119
|
-
required={required}
|
|
120
|
-
readOnly={readOnly}>
|
|
108
|
+
<ItemFieldGrid qItem={qItem} readOnly={readOnly}>
|
|
121
109
|
<TextField
|
|
122
110
|
linkId={qItem.linkId}
|
|
123
111
|
input={input}
|
|
@@ -45,8 +45,7 @@ function TimeItem(props: TimeItemProps) {
|
|
|
45
45
|
const { qItem, qrItem, isRepeated, isTabled, parentIsReadOnly, onQrItemChange } = props;
|
|
46
46
|
|
|
47
47
|
const readOnly = useReadOnly(qItem, parentIsReadOnly);
|
|
48
|
-
const { displayPrompt,
|
|
49
|
-
useRenderingExtensions(qItem);
|
|
48
|
+
const { displayPrompt, entryFormat } = useRenderingExtensions(qItem);
|
|
50
49
|
|
|
51
50
|
// Init input value
|
|
52
51
|
let timeString: string | null = null;
|
|
@@ -80,11 +79,7 @@ function TimeItem(props: TimeItemProps) {
|
|
|
80
79
|
|
|
81
80
|
return (
|
|
82
81
|
<FullWidthFormComponentBox>
|
|
83
|
-
<ItemFieldGrid
|
|
84
|
-
qItem={qItem}
|
|
85
|
-
displayInstructions={displayInstructions}
|
|
86
|
-
required={required}
|
|
87
|
-
readOnly={readOnly}>
|
|
82
|
+
<ItemFieldGrid qItem={qItem} readOnly={readOnly}>
|
|
88
83
|
<TimeField
|
|
89
84
|
value={timeDayJs}
|
|
90
85
|
displayPrompt={displayPrompt}
|
|
@@ -45,16 +45,8 @@ function UrlItem(props: UrlItemProps) {
|
|
|
45
45
|
const { qItem, qrItem, isRepeated, isTabled, parentIsReadOnly, onQrItemChange } = props;
|
|
46
46
|
|
|
47
47
|
const readOnly = useReadOnly(qItem, parentIsReadOnly);
|
|
48
|
-
const {
|
|
49
|
-
|
|
50
|
-
displayPrompt,
|
|
51
|
-
displayInstructions,
|
|
52
|
-
entryFormat,
|
|
53
|
-
required,
|
|
54
|
-
regexValidation,
|
|
55
|
-
minLength,
|
|
56
|
-
maxLength
|
|
57
|
-
} = useRenderingExtensions(qItem);
|
|
48
|
+
const { displayUnit, displayPrompt, entryFormat, regexValidation, minLength, maxLength } =
|
|
49
|
+
useRenderingExtensions(qItem);
|
|
58
50
|
|
|
59
51
|
// Init input value
|
|
60
52
|
let valueUri = '';
|
|
@@ -102,11 +94,7 @@ function UrlItem(props: UrlItemProps) {
|
|
|
102
94
|
}
|
|
103
95
|
return (
|
|
104
96
|
<FullWidthFormComponentBox data-test="q-item-string-box">
|
|
105
|
-
<ItemFieldGrid
|
|
106
|
-
qItem={qItem}
|
|
107
|
-
displayInstructions={displayInstructions}
|
|
108
|
-
required={required}
|
|
109
|
-
readOnly={readOnly}>
|
|
97
|
+
<ItemFieldGrid qItem={qItem} readOnly={readOnly}>
|
|
110
98
|
<UrlField
|
|
111
99
|
linkId={qItem.linkId}
|
|
112
100
|
input={input}
|
|
@@ -35,9 +35,6 @@ function BaseRenderer() {
|
|
|
35
35
|
const updateRequiredValidity = useQuestionnaireResponseStore.use.validateQuestionnaire();
|
|
36
36
|
const updateResponse = useQuestionnaireResponseStore.use.updateResponse();
|
|
37
37
|
|
|
38
|
-
const invalidItems = useQuestionnaireResponseStore.use.invalidItems();
|
|
39
|
-
const responseIsValid = useQuestionnaireResponseStore.use.responseIsValid();
|
|
40
|
-
|
|
41
38
|
const qItemsIndexMap = useMemo(() => mapQItemsIndex(sourceQuestionnaire), [sourceQuestionnaire]);
|
|
42
39
|
|
|
43
40
|
function handleTopLevelQRItemSingleChange(newTopLevelQRItem: QuestionnaireResponseItem) {
|
|
@@ -76,9 +73,6 @@ function BaseRenderer() {
|
|
|
76
73
|
// If an item has multiple answers, it is a repeat group
|
|
77
74
|
const topLevelQRItemsByIndex = getQrItemsIndex(topLevelQItems, topLevelQRItems, qItemsIndexMap);
|
|
78
75
|
|
|
79
|
-
console.log(invalidItems);
|
|
80
|
-
console.log(responseIsValid);
|
|
81
|
-
|
|
82
76
|
return (
|
|
83
77
|
<Fade in={true} timeout={500}>
|
|
84
78
|
<Container maxWidth="xl">
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
import {
|
|
19
19
|
getRegexValidation,
|
|
20
|
+
getTextDisplayFlyover,
|
|
20
21
|
getTextDisplayInstructions,
|
|
21
22
|
getTextDisplayPrompt,
|
|
22
23
|
getTextDisplayUnit
|
|
@@ -30,6 +31,7 @@ interface RenderingExtensions {
|
|
|
30
31
|
displayUnit: string;
|
|
31
32
|
displayPrompt: string;
|
|
32
33
|
displayInstructions: string;
|
|
34
|
+
displayFlyover: string;
|
|
33
35
|
readOnly: boolean;
|
|
34
36
|
entryFormat: string;
|
|
35
37
|
required: boolean;
|
|
@@ -44,6 +46,7 @@ function useRenderingExtensions(qItem: QuestionnaireItem): RenderingExtensions {
|
|
|
44
46
|
displayUnit: getTextDisplayUnit(qItem),
|
|
45
47
|
displayPrompt: getTextDisplayPrompt(qItem),
|
|
46
48
|
displayInstructions: getTextDisplayInstructions(qItem),
|
|
49
|
+
displayFlyover: getTextDisplayFlyover(qItem),
|
|
47
50
|
readOnly: !!qItem.readOnly,
|
|
48
51
|
entryFormat: structuredDataCapture.getEntryFormat(qItem) ?? '',
|
|
49
52
|
required: qItem.required ?? false,
|
package/src/utils/itemControl.ts
CHANGED
|
@@ -295,6 +295,22 @@ export function getTextDisplayInstructions(qItem: QuestionnaireItem): string {
|
|
|
295
295
|
return '';
|
|
296
296
|
}
|
|
297
297
|
|
|
298
|
+
/**
|
|
299
|
+
* Get text display flyover for items with itemControlCode flyover and has an flyover childItem
|
|
300
|
+
*
|
|
301
|
+
* @author Sean Fong
|
|
302
|
+
*/
|
|
303
|
+
export function getTextDisplayFlyover(qItem: QuestionnaireItem): string {
|
|
304
|
+
if (qItem.item) {
|
|
305
|
+
for (const childItem of qItem.item) {
|
|
306
|
+
if (childItem.type === 'display' && isSpecificItemControl(childItem, 'flyover')) {
|
|
307
|
+
return `${childItem.text}`;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
return '';
|
|
312
|
+
}
|
|
313
|
+
|
|
298
314
|
/**
|
|
299
315
|
* Get entry format if its extension is present
|
|
300
316
|
* i.e. DD-MM-YYYY for dates, HH:MM for times etc.
|
|
@@ -1,30 +0,0 @@
|
|
|
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
|
-
import React from 'react';
|
|
18
|
-
import { ReadOnlyLabel, RequiredLabel } from '../../Box.styles';
|
|
19
|
-
import Box from '@mui/material/Box';
|
|
20
|
-
function ItemExtensionLabels(props) {
|
|
21
|
-
const { required, readOnly } = props;
|
|
22
|
-
if (!required && !readOnly) {
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
25
|
-
return (React.createElement(Box, { display: "flex", columnGap: 0.5 },
|
|
26
|
-
required ? React.createElement(RequiredLabel, null, "Required") : null,
|
|
27
|
-
readOnly ? React.createElement(ReadOnlyLabel, null, "Read-only") : null));
|
|
28
|
-
}
|
|
29
|
-
export default ItemExtensionLabels;
|
|
30
|
-
//# sourceMappingURL=ItemExtensionLabels.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ItemExtensionLabels.js","sourceRoot":"","sources":["../../../../src/components/FormComponents/ItemParts/ItemExtensionLabels.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,GAAG,MAAM,mBAAmB,CAAC;AAOpC,SAAS,mBAAmB,CAAC,KAA+B;IAC1D,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAErC,IAAI,CAAC,QAAQ,IAAI,CAAC,QAAQ,EAAE;QAC1B,OAAO,IAAI,CAAC;KACb;IAED,OAAO,CACL,oBAAC,GAAG,IAAC,OAAO,EAAC,MAAM,EAAC,SAAS,EAAE,GAAG;QAC/B,QAAQ,CAAC,CAAC,CAAC,oBAAC,aAAa,mBAAyB,CAAC,CAAC,CAAC,IAAI;QACzD,QAAQ,CAAC,CAAC,CAAC,oBAAC,aAAa,oBAA0B,CAAC,CAAC,CAAC,IAAI,CACvD,CACP,CAAC;AACJ,CAAC;AAED,eAAe,mBAAmB,CAAC"}
|
|
@@ -1,42 +0,0 @@
|
|
|
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 { ReadOnlyLabel, RequiredLabel } from '../../Box.styles';
|
|
20
|
-
import Box from '@mui/material/Box';
|
|
21
|
-
|
|
22
|
-
interface ItemExtensionLabelsProps {
|
|
23
|
-
required: boolean;
|
|
24
|
-
readOnly: boolean;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function ItemExtensionLabels(props: ItemExtensionLabelsProps) {
|
|
28
|
-
const { required, readOnly } = props;
|
|
29
|
-
|
|
30
|
-
if (!required && !readOnly) {
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return (
|
|
35
|
-
<Box display="flex" columnGap={0.5}>
|
|
36
|
-
{required ? <RequiredLabel>Required</RequiredLabel> : null}
|
|
37
|
-
{readOnly ? <ReadOnlyLabel>Read-only</ReadOnlyLabel> : null}
|
|
38
|
-
</Box>
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export default ItemExtensionLabels;
|