@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
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { QuestionnaireResponse } from 'fhir/r4';
|
|
2
|
+
import type { Diff } from 'deep-diff';
|
|
2
3
|
export interface UseQuestionnaireResponseStoreType {
|
|
3
4
|
sourceResponse: QuestionnaireResponse;
|
|
4
5
|
updatableResponse: QuestionnaireResponse;
|
|
5
|
-
formChangesHistory:
|
|
6
|
+
formChangesHistory: (Diff<QuestionnaireResponse, QuestionnaireResponse>[] | null)[];
|
|
6
7
|
buildSourceResponse: (response: QuestionnaireResponse) => void;
|
|
7
8
|
setUpdatableResponseAsPopulated: (populatedResponse: QuestionnaireResponse) => void;
|
|
8
9
|
updateResponse: (updatedResponse: QuestionnaireResponse) => void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { create } from 'zustand';
|
|
2
2
|
import { emptyResponse } from '../utils/emptyResource';
|
|
3
3
|
import cloneDeep from 'lodash.clonedeep';
|
|
4
|
-
import { diff } from '
|
|
4
|
+
import { diff } from 'deep-diff';
|
|
5
5
|
const useQuestionnaireResponseStore = create()((set, get) => ({
|
|
6
6
|
sourceResponse: cloneDeep(emptyResponse),
|
|
7
7
|
updatableResponse: cloneDeep(emptyResponse),
|
|
@@ -13,14 +13,16 @@ const useQuestionnaireResponseStore = create()((set, get) => ({
|
|
|
13
13
|
}));
|
|
14
14
|
},
|
|
15
15
|
setUpdatableResponseAsPopulated: (populatedResponse) => {
|
|
16
|
-
|
|
16
|
+
var _a;
|
|
17
|
+
const formChanges = (_a = diff(get().updatableResponse, populatedResponse)) !== null && _a !== void 0 ? _a : null;
|
|
17
18
|
set(() => ({
|
|
18
19
|
updatableResponse: populatedResponse,
|
|
19
20
|
formChangesHistory: [...get().formChangesHistory, formChanges]
|
|
20
21
|
}));
|
|
21
22
|
},
|
|
22
23
|
updateResponse: (updatedResponse) => {
|
|
23
|
-
|
|
24
|
+
var _a;
|
|
25
|
+
const formChanges = (_a = diff(get().updatableResponse, updatedResponse)) !== null && _a !== void 0 ? _a : null;
|
|
24
26
|
set(() => ({
|
|
25
27
|
updatableResponse: updatedResponse,
|
|
26
28
|
formChangesHistory: [...get().formChangesHistory, formChanges]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useQuestionnaireResponseStore.js","sourceRoot":"","sources":["../../src/stores/useQuestionnaireResponseStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,SAAS,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"useQuestionnaireResponseStore.js","sourceRoot":"","sources":["../../src/stores/useQuestionnaireResponseStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,SAAS,MAAM,kBAAkB,CAAC;AAEzC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAcjC,MAAM,6BAA6B,GAAG,MAAM,EAAqC,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;IAC/F,cAAc,EAAE,SAAS,CAAC,aAAa,CAAC;IACxC,iBAAiB,EAAE,SAAS,CAAC,aAAa,CAAC;IAC3C,kBAAkB,EAAE,EAAE;IACtB,mBAAmB,EAAE,CAAC,qBAA4C,EAAE,EAAE;QACpE,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC;YACT,cAAc,EAAE,qBAAqB;YACrC,iBAAiB,EAAE,qBAAqB;SACzC,CAAC,CAAC,CAAC;IACN,CAAC;IACD,+BAA+B,EAAE,CAAC,iBAAwC,EAAE,EAAE;;QAC5E,MAAM,WAAW,GAAG,MAAA,IAAI,CAAC,GAAG,EAAE,CAAC,iBAAiB,EAAE,iB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em, QuestionnaireResponse, QuestionnaireResponseItem } from 'fhir/r4';
|
|
2
2
|
import type { QrRepeatGroup } from '../interfaces/repeatGroup.interface';
|
|
3
3
|
/**
|
|
4
|
-
* Create
|
|
5
|
-
* A questionnaire form item is the first item of a questionnaire
|
|
4
|
+
* Create an empty questionnaireResponse from a given questionnaire
|
|
6
5
|
*
|
|
7
6
|
* @author Sean Fong
|
|
8
7
|
*/
|
|
9
|
-
export declare function
|
|
8
|
+
export declare function createEmptyQuestionnaireResponse(questionnaire: Questionnaire): QuestionnaireResponse;
|
|
10
9
|
/**
|
|
11
10
|
* Remove items with no answers from a given questionnaireResponse
|
|
12
11
|
* Also remove any starting or trailing whitespace from valueStrings
|
package/lib/utils/qrItem.js
CHANGED
|
@@ -15,12 +15,11 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
/**
|
|
18
|
-
* Create
|
|
19
|
-
* A questionnaire form item is the first item of a questionnaire
|
|
18
|
+
* Create an empty questionnaireResponse from a given questionnaire
|
|
20
19
|
*
|
|
21
20
|
* @author Sean Fong
|
|
22
21
|
*/
|
|
23
|
-
export function
|
|
22
|
+
export function createEmptyQuestionnaireResponse(questionnaire) {
|
|
24
23
|
var _a;
|
|
25
24
|
const questionnaireResponse = {
|
|
26
25
|
resourceType: 'QuestionnaireResponse',
|
package/lib/utils/qrItem.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"qrItem.js","sourceRoot":"","sources":["../../src/utils/qrItem.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAWH
|
|
1
|
+
{"version":3,"file":"qrItem.js","sourceRoot":"","sources":["../../src/utils/qrItem.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAWH;;;;GAIG;AACH,MAAM,UAAU,gCAAgC,CAC9C,aAA4B;;IAE5B,MAAM,qBAAqB,GAA0B;QACnD,YAAY,EAAE,uBAAuB;QACrC,MAAM,EAAE,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,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;yBAChC;6BAAM;4BACL,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;yBACzC;qBACF;oBACD,MAAM;iBACP;gBAED,IAAI,UAAU,CAAC,MAAM,GAAG,oBAAoB,EAAE;oBAC5C,sFAAsF;oBACtF,gEAAgE;oBAChE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,oBAAoB,EAAE,CAAC,EAAE,EAAE;wBAC7C,IAAI,CAAC,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE;4BAC9B,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;yBAChC;6BAAM;4BACL,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;yBAC1B;qBACF;oBACD,MAAM;iBACP;aACF;YAED,iFAAiF;YACjF,IAAI,cAAc,GAAG,mBAAmB,CAAC,CAAC,CAAC,EAAE;gBAC3C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;oBAC1C,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;iBACzC;gBACD,MAAM;aACP;SACF;KACF;AACH,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Questionnaire, QuestionnaireResponse } from 'fhir/r4';
|
|
2
|
-
import { ItemToRepopulate } from './repopulateItems';
|
|
1
|
+
import type { Questionnaire, QuestionnaireResponse } from 'fhir/r4';
|
|
2
|
+
import type { ItemToRepopulate } from './repopulateItems';
|
|
3
3
|
export declare function repopulateItemsIntoResponse(questionnaire: Questionnaire, updatableResponse: QuestionnaireResponse, checkedItemsToRepopulate: Record<string, ItemToRepopulate>): QuestionnaireResponse;
|
|
@@ -65,7 +65,6 @@ function getCorrespondingQuestionnaireItemsRecursive(qItem, heading, tabs, hasTa
|
|
|
65
65
|
heading = (_b = (_a = getShortText(qItem)) !== null && _a !== void 0 ? _a : qItem.text) !== null && _b !== void 0 ? _b : null;
|
|
66
66
|
}
|
|
67
67
|
// TODO it seems like there can only be one answer per linkId, we might need to do repeat groups differently
|
|
68
|
-
// so we need to fix this one first it seems like
|
|
69
68
|
/* Repeat group implementation */
|
|
70
69
|
if (qItem.type === 'group' && qItem.repeats) {
|
|
71
70
|
const isRepeatGroupToRepopulate = checkIsRepeatGroupToRepopulate(qItem, itemsToRepopulate);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repopulateItems.js","sourceRoot":"","sources":["../../src/utils/repopulateItems.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AASH,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EACL,8BAA8B,EAC9B,0BAA0B,EAC3B,MAAM,yBAAyB,CAAC;AASjC,MAAM,UAAU,oBAAoB,CAClC,mBAAkC,EAClC,SAAiC,EACjC,IAAU,EACV,iBAAwC,EACxC,iBAAwC;;IAExC,IACE,CAAC,mBAAmB,CAAC,IAAI;QACzB,mBAAmB,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC;QACrC,CAAC,iBAAiB,CAAC,IAAI;QACvB,iBAAiB,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC;QACnC,CAAC,iBAAiB,CAAC,IAAI;QACvB,iBAAiB,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,EACnC;QACA,OAAO,EAAE,CAAC;KACX;IAED,MAAM,cAAc,GAAgC,EAAE,CAAC;IACvD,KAAK,MAA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CAAwC;IACxC,OAAO,CAAC,MAAM,CAAC,CAAC;AAClB,CAAC;AAED,SAAS,mCAAmC,CAC1C,MAAiC,EACjC,SAAiC,EACjC,iBAAmD;;IAEnD,MAAM,QAAQ,GAAG,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC1C,IAAI,QAAQ,KAAK,OAAO,IAAI,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;QACjE,KAAK,MAAM,SAAS,IAAI,MAAM,CAAC,IAAI,EAAE;YACnC,mCAAmC,CAAC,SAAS,EAAE,SAAS,EAAE,iBAAiB,CAAC,CAAC;SAC9E;QAED,OAAO;KACR;IAED,MAAM,OAAO,GAAG,MAAM,CAAC;IACvB,MAAM,OAAO,GAAG,MAAA,iBAAiB,CAAC,MAAM,CAAC,MAAM,CAAC,0CAAE,SAAS,CAAC;IAE5D,IAAI,CAAC,OAAO,EAAE;QACZ,OAAO;KACR;IAED,IAAI,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE;QAC9B,OAAO,iBAAiB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACxC,OAAO;KACR;IAED,sFAAsF;IAEtF,iBAAiB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,GAAG,OAAO,CAAC;AACvD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aehrc/smart-forms-renderer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "FHIR Structured Data Captured (SDC) rendering engine for Smart Forms",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"homepage": "https://github.com/aehrc/smart-forms#readme",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"
|
|
26
|
+
"deep-diff": "^1.0.2",
|
|
27
27
|
"@iconify/react": "^4.1.1",
|
|
28
28
|
"dayjs": "^1.11.9",
|
|
29
29
|
"fhirclient": "^2.5.2",
|
|
@@ -49,28 +49,28 @@
|
|
|
49
49
|
"react-dom": ">=18.0.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@babel/core": "^7.
|
|
52
|
+
"@babel/core": "^7.22.17",
|
|
53
53
|
"@storybook/addon-essentials": "^7.4.0",
|
|
54
54
|
"@storybook/addon-interactions": "^7.4.0",
|
|
55
55
|
"@storybook/addon-links": "^7.4.0",
|
|
56
56
|
"@storybook/addon-onboarding": "^1.0.8",
|
|
57
57
|
"@storybook/addon-styling": "^1.3.7",
|
|
58
58
|
"@storybook/blocks": "^7.4.0",
|
|
59
|
-
"@storybook/react": "^7.4.
|
|
59
|
+
"@storybook/react": "^7.4.3",
|
|
60
60
|
"@storybook/react-vite": "^7.4.0",
|
|
61
|
-
"@storybook/testing-library": "^0.2.
|
|
61
|
+
"@storybook/testing-library": "^0.2.1",
|
|
62
62
|
"@testing-library/jest-dom": "^6.1.2",
|
|
63
63
|
"@testing-library/react": "^14.0.0",
|
|
64
64
|
"@testing-library/react-hooks": "^7.0.2",
|
|
65
65
|
"@types/jest": "^29.5.4",
|
|
66
|
-
"@types/
|
|
66
|
+
"@types/deep-diff": "^1.0.2",
|
|
67
67
|
"@types/react": "^18.2.18",
|
|
68
68
|
"@types/react-dom": "^18.2.7",
|
|
69
69
|
"jest": "^29.6.4",
|
|
70
70
|
"jest-environment-jsdom": "^29.6.4",
|
|
71
71
|
"react": "^18.2.0",
|
|
72
72
|
"react-dom": "^18.2.0",
|
|
73
|
-
"storybook": "^7.4.
|
|
73
|
+
"storybook": "^7.4.2",
|
|
74
74
|
"ts-jest": "^29.1.1",
|
|
75
75
|
"tslib": "^2.6.2",
|
|
76
76
|
"typescript": "^5.2.2"
|
|
@@ -66,7 +66,6 @@ function ChoiceAutocompleteItem(props: ChoiceAutocompleteItemProps) {
|
|
|
66
66
|
const { displayUnit, displayPrompt, displayInstructions, readOnly, entryFormat } =
|
|
67
67
|
useRenderingExtensions(qItem);
|
|
68
68
|
|
|
69
|
-
// Query ontoserver for options
|
|
70
69
|
const maxList = 10;
|
|
71
70
|
|
|
72
71
|
const [input, setInput] = useState('');
|
|
@@ -0,0 +1,85 @@
|
|
|
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 { ChoiceItemOrientation } from '../../../interfaces/choice.enum';
|
|
20
|
+
import type { QuestionnaireItem, QuestionnaireResponseItemAnswer } from 'fhir/r4';
|
|
21
|
+
import QItemChoiceCheckboxSingle from '../ItemParts/CheckboxSingle';
|
|
22
|
+
import { StyledFormGroup } from '../Item.styles';
|
|
23
|
+
|
|
24
|
+
interface ChoiceCheckboxAnswerOptionFieldsProps {
|
|
25
|
+
qItem: QuestionnaireItem;
|
|
26
|
+
answers: QuestionnaireResponseItemAnswer[];
|
|
27
|
+
orientation: ChoiceItemOrientation;
|
|
28
|
+
readOnly: boolean;
|
|
29
|
+
onCheckedChange: (newValue: string) => void;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function ChoiceCheckboxAnswerOptionFields(props: ChoiceCheckboxAnswerOptionFieldsProps) {
|
|
33
|
+
const { qItem, answers, orientation, readOnly, onCheckedChange } = props;
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<StyledFormGroup row={orientation === ChoiceItemOrientation.Horizontal}>
|
|
37
|
+
{qItem.answerOption?.map((option) => {
|
|
38
|
+
if (option['valueCoding']) {
|
|
39
|
+
return (
|
|
40
|
+
<QItemChoiceCheckboxSingle
|
|
41
|
+
key={option.valueCoding.code ?? ''}
|
|
42
|
+
value={option.valueCoding.code ?? ''}
|
|
43
|
+
label={option.valueCoding.display ?? `${option.valueCoding.code}`}
|
|
44
|
+
readOnly={readOnly}
|
|
45
|
+
isChecked={answers.some(
|
|
46
|
+
(answer) => JSON.stringify(answer) === JSON.stringify(option)
|
|
47
|
+
)}
|
|
48
|
+
onCheckedChange={onCheckedChange}
|
|
49
|
+
/>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (option['valueString']) {
|
|
54
|
+
return (
|
|
55
|
+
<QItemChoiceCheckboxSingle
|
|
56
|
+
key={option.valueString}
|
|
57
|
+
value={option.valueString}
|
|
58
|
+
label={option.valueString}
|
|
59
|
+
readOnly={readOnly}
|
|
60
|
+
isChecked={answers.some((answer) => answer.valueString === option.valueString)}
|
|
61
|
+
onCheckedChange={onCheckedChange}
|
|
62
|
+
/>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (option['valueInteger']) {
|
|
67
|
+
return (
|
|
68
|
+
<QItemChoiceCheckboxSingle
|
|
69
|
+
key={option.valueInteger}
|
|
70
|
+
value={option.valueInteger.toString()}
|
|
71
|
+
label={option.valueInteger.toString()}
|
|
72
|
+
readOnly={readOnly}
|
|
73
|
+
isChecked={answers.some((answer) => answer.valueInteger === option.valueInteger)}
|
|
74
|
+
onCheckedChange={onCheckedChange}
|
|
75
|
+
/>
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return null;
|
|
80
|
+
})}
|
|
81
|
+
</StyledFormGroup>
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export default ChoiceCheckboxAnswerOptionFields;
|
|
@@ -17,31 +17,32 @@
|
|
|
17
17
|
|
|
18
18
|
import React from 'react';
|
|
19
19
|
import Grid from '@mui/material/Grid';
|
|
20
|
-
import { ChoiceItemOrientation } from '../../../interfaces/choice.enum';
|
|
20
|
+
import type { ChoiceItemOrientation } from '../../../interfaces/choice.enum';
|
|
21
21
|
import type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';
|
|
22
|
-
import QItemChoiceCheckboxSingle from '../ItemParts/CheckboxSingle';
|
|
23
22
|
import { createEmptyQrItem } from '../../../utils/qrItem';
|
|
24
|
-
import { QFormGroup } from '../Item.styles';
|
|
25
23
|
import { updateQrCheckboxAnswers } from '../../../utils/choice';
|
|
26
24
|
import { FullWidthFormComponentBox } from '../../Box.styles';
|
|
27
25
|
import useRenderingExtensions from '../../../hooks/useRenderingExtensions';
|
|
28
26
|
import type {
|
|
29
27
|
PropsWithIsRepeatedAttribute,
|
|
30
|
-
PropsWithQrItemChangeHandler
|
|
28
|
+
PropsWithQrItemChangeHandler,
|
|
29
|
+
PropsWithTextShownAttribute
|
|
31
30
|
} from '../../../interfaces/renderProps.interface';
|
|
32
31
|
import DisplayInstructions from '../DisplayItem/DisplayInstructions';
|
|
33
32
|
import LabelWrapper from '../ItemParts/ItemLabelWrapper';
|
|
33
|
+
import ChoiceCheckboxAnswerValueSetFields from './ChoiceCheckboxAnswerOptionFields';
|
|
34
34
|
|
|
35
35
|
interface ChoiceCheckboxAnswerOptionItemProps
|
|
36
36
|
extends PropsWithQrItemChangeHandler<QuestionnaireResponseItem>,
|
|
37
|
-
PropsWithIsRepeatedAttribute
|
|
37
|
+
PropsWithIsRepeatedAttribute,
|
|
38
|
+
PropsWithTextShownAttribute {
|
|
38
39
|
qItem: QuestionnaireItem;
|
|
39
40
|
qrItem: QuestionnaireResponseItem;
|
|
40
41
|
orientation: ChoiceItemOrientation;
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
function ChoiceCheckboxAnswerOptionItem(props: ChoiceCheckboxAnswerOptionItemProps) {
|
|
44
|
-
const { qItem, qrItem, isRepeated, onQrItemChange, orientation } = props;
|
|
45
|
+
const { qItem, qrItem, isRepeated, onQrItemChange, orientation, textShown = true } = props;
|
|
45
46
|
|
|
46
47
|
// Init input value
|
|
47
48
|
const qrChoiceCheckbox = qrItem ?? createEmptyQrItem(qItem);
|
|
@@ -68,63 +69,39 @@ function ChoiceCheckboxAnswerOptionItem(props: ChoiceCheckboxAnswerOptionItemPro
|
|
|
68
69
|
}
|
|
69
70
|
}
|
|
70
71
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
<
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
72
|
+
if (textShown) {
|
|
73
|
+
return (
|
|
74
|
+
<FullWidthFormComponentBox data-test="q-item-choice-checkbox-answer-option-box">
|
|
75
|
+
<Grid container columnSpacing={6}>
|
|
76
|
+
<Grid item xs={5}>
|
|
77
|
+
<LabelWrapper qItem={qItem} />
|
|
78
|
+
</Grid>
|
|
79
|
+
<Grid item xs={7}>
|
|
80
|
+
<ChoiceCheckboxAnswerValueSetFields
|
|
81
|
+
qItem={qItem}
|
|
82
|
+
answers={answers}
|
|
83
|
+
orientation={orientation}
|
|
80
84
|
readOnly={readOnly}
|
|
81
|
-
isChecked={answers.some(
|
|
82
|
-
(answer) => JSON.stringify(answer) === JSON.stringify(option)
|
|
83
|
-
)}
|
|
84
85
|
onCheckedChange={handleCheckedChange}
|
|
85
86
|
/>
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
label={option.valueString}
|
|
93
|
-
readOnly={readOnly}
|
|
94
|
-
isChecked={answers.some((answer) => answer.valueString === option.valueString)}
|
|
95
|
-
onCheckedChange={handleCheckedChange}
|
|
96
|
-
/>
|
|
97
|
-
);
|
|
98
|
-
} else if (option['valueInteger']) {
|
|
99
|
-
return (
|
|
100
|
-
<QItemChoiceCheckboxSingle
|
|
101
|
-
key={option.valueInteger}
|
|
102
|
-
value={option.valueInteger.toString()}
|
|
103
|
-
label={option.valueInteger.toString()}
|
|
104
|
-
readOnly={readOnly}
|
|
105
|
-
isChecked={answers.some((answer) => answer.valueInteger === option.valueInteger)}
|
|
106
|
-
onCheckedChange={handleCheckedChange}
|
|
107
|
-
/>
|
|
108
|
-
);
|
|
109
|
-
} else {
|
|
110
|
-
return null;
|
|
111
|
-
}
|
|
112
|
-
})}
|
|
113
|
-
</QFormGroup>
|
|
114
|
-
);
|
|
87
|
+
<DisplayInstructions displayInstructions={displayInstructions} />
|
|
88
|
+
</Grid>
|
|
89
|
+
</Grid>
|
|
90
|
+
</FullWidthFormComponentBox>
|
|
91
|
+
);
|
|
92
|
+
}
|
|
115
93
|
|
|
116
94
|
return (
|
|
117
|
-
|
|
118
|
-
<
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
</FullWidthFormComponentBox>
|
|
95
|
+
<>
|
|
96
|
+
<ChoiceCheckboxAnswerValueSetFields
|
|
97
|
+
qItem={qItem}
|
|
98
|
+
answers={answers}
|
|
99
|
+
orientation={orientation}
|
|
100
|
+
readOnly={readOnly}
|
|
101
|
+
onCheckedChange={handleCheckedChange}
|
|
102
|
+
/>
|
|
103
|
+
<DisplayInstructions displayInstructions={displayInstructions} />
|
|
104
|
+
</>
|
|
128
105
|
);
|
|
129
106
|
}
|
|
130
107
|
|
|
@@ -0,0 +1,79 @@
|
|
|
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 { ChoiceItemOrientation } from '../../../interfaces/choice.enum';
|
|
20
|
+
import type { Coding, QuestionnaireResponseItemAnswer } from 'fhir/r4';
|
|
21
|
+
import CheckboxSingle from '../ItemParts/CheckboxSingle';
|
|
22
|
+
import { StyledFormGroup } from '../Item.styles';
|
|
23
|
+
import { StyledAlert } from '../../Alert.styles';
|
|
24
|
+
import ErrorOutlineIcon from '@mui/icons-material/ErrorOutline';
|
|
25
|
+
import Typography from '@mui/material/Typography';
|
|
26
|
+
|
|
27
|
+
interface ChoiceCheckboxAnswerValueSetFieldsProps {
|
|
28
|
+
codings: Coding[];
|
|
29
|
+
answers: QuestionnaireResponseItemAnswer[];
|
|
30
|
+
orientation: ChoiceItemOrientation;
|
|
31
|
+
readOnly: boolean;
|
|
32
|
+
serverError: Error | null;
|
|
33
|
+
onCheckedChange: (newValue: string) => void;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function ChoiceCheckboxAnswerValueSetFields(props: ChoiceCheckboxAnswerValueSetFieldsProps) {
|
|
37
|
+
const { codings, answers, orientation, readOnly, serverError, onCheckedChange } = props;
|
|
38
|
+
|
|
39
|
+
if (codings.length > 0) {
|
|
40
|
+
return (
|
|
41
|
+
<StyledFormGroup row={orientation === ChoiceItemOrientation.Horizontal}>
|
|
42
|
+
{codings.map((coding) => (
|
|
43
|
+
<CheckboxSingle
|
|
44
|
+
key={coding.code ?? ''}
|
|
45
|
+
value={coding.code ?? ''}
|
|
46
|
+
label={coding.display ?? `${coding.code}`}
|
|
47
|
+
readOnly={readOnly}
|
|
48
|
+
isChecked={answers.some(
|
|
49
|
+
(answer) => JSON.stringify(answer.valueCoding) === JSON.stringify(coding)
|
|
50
|
+
)}
|
|
51
|
+
onCheckedChange={onCheckedChange}
|
|
52
|
+
/>
|
|
53
|
+
))}
|
|
54
|
+
</StyledFormGroup>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (serverError) {
|
|
59
|
+
return (
|
|
60
|
+
<StyledAlert color="error">
|
|
61
|
+
<ErrorOutlineIcon color="error" sx={{ pr: 0.75 }} />
|
|
62
|
+
<Typography variant="subtitle2">
|
|
63
|
+
There was an error fetching options from the terminology server
|
|
64
|
+
</Typography>
|
|
65
|
+
</StyledAlert>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<StyledAlert color="error">
|
|
71
|
+
<ErrorOutlineIcon color="error" sx={{ pr: 0.75 }} />
|
|
72
|
+
<Typography variant="subtitle2">
|
|
73
|
+
Unable to fetch options from the questionnaire or launch context
|
|
74
|
+
</Typography>
|
|
75
|
+
</StyledAlert>
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export default ChoiceCheckboxAnswerValueSetFields;
|
|
@@ -17,36 +17,34 @@
|
|
|
17
17
|
|
|
18
18
|
import React from 'react';
|
|
19
19
|
import Grid from '@mui/material/Grid';
|
|
20
|
-
import Typography from '@mui/material/Typography';
|
|
21
|
-
|
|
22
20
|
import type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';
|
|
23
21
|
import { createEmptyQrItem } from '../../../utils/qrItem';
|
|
24
22
|
import useValueSetCodings from '../../../hooks/useValueSetCodings';
|
|
25
|
-
import { ChoiceItemOrientation } from '../../../interfaces/choice.enum';
|
|
23
|
+
import type { ChoiceItemOrientation } from '../../../interfaces/choice.enum';
|
|
26
24
|
import { mapCodingsToOptions, updateQrCheckboxAnswers } from '../../../utils/choice';
|
|
27
|
-
import CheckboxSingle from '../ItemParts/CheckboxSingle';
|
|
28
|
-
import { QFormGroup } from '../Item.styles';
|
|
29
25
|
import { FullWidthFormComponentBox } from '../../Box.styles';
|
|
30
26
|
import useRenderingExtensions from '../../../hooks/useRenderingExtensions';
|
|
31
|
-
import ErrorOutlineIcon from '@mui/icons-material/ErrorOutline';
|
|
32
27
|
import type {
|
|
33
28
|
PropsWithIsRepeatedAttribute,
|
|
34
|
-
PropsWithQrItemChangeHandler
|
|
29
|
+
PropsWithQrItemChangeHandler,
|
|
30
|
+
PropsWithTextShownAttribute
|
|
35
31
|
} from '../../../interfaces/renderProps.interface';
|
|
36
|
-
import { StyledAlert } from '../../Alert.styles';
|
|
37
32
|
import DisplayInstructions from '../DisplayItem/DisplayInstructions';
|
|
38
33
|
import LabelWrapper from '../ItemParts/ItemLabelWrapper';
|
|
34
|
+
import ChoiceCheckboxAnswerValueSetFields from './ChoiceCheckboxAnswerValueSetFields';
|
|
39
35
|
|
|
40
36
|
interface ChoiceCheckboxAnswerValueSetItemProps
|
|
41
37
|
extends PropsWithQrItemChangeHandler<QuestionnaireResponseItem>,
|
|
42
|
-
PropsWithIsRepeatedAttribute
|
|
38
|
+
PropsWithIsRepeatedAttribute,
|
|
39
|
+
PropsWithTextShownAttribute {
|
|
43
40
|
qItem: QuestionnaireItem;
|
|
44
41
|
qrItem: QuestionnaireResponseItem;
|
|
45
42
|
orientation: ChoiceItemOrientation;
|
|
43
|
+
showText?: boolean;
|
|
46
44
|
}
|
|
47
45
|
|
|
48
46
|
function ChoiceCheckboxAnswerValueSetItem(props: ChoiceCheckboxAnswerValueSetItemProps) {
|
|
49
|
-
const { qItem, qrItem, isRepeated,
|
|
47
|
+
const { qItem, qrItem, orientation, isRepeated, textShown = true, onQrItemChange } = props;
|
|
50
48
|
|
|
51
49
|
// Init input value
|
|
52
50
|
const qrChoiceCheckbox = qrItem ?? createEmptyQrItem(qItem);
|
|
@@ -75,52 +73,41 @@ function ChoiceCheckboxAnswerValueSetItem(props: ChoiceCheckboxAnswerValueSetIte
|
|
|
75
73
|
}
|
|
76
74
|
}
|
|
77
75
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
<
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
<
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
76
|
+
if (textShown) {
|
|
77
|
+
return (
|
|
78
|
+
<FullWidthFormComponentBox data-test="q-item-choice-checkbox-answer-value-set-box">
|
|
79
|
+
<Grid container columnSpacing={6}>
|
|
80
|
+
<Grid item xs={5}>
|
|
81
|
+
<LabelWrapper qItem={qItem} />
|
|
82
|
+
</Grid>
|
|
83
|
+
<Grid item xs={7}>
|
|
84
|
+
<ChoiceCheckboxAnswerValueSetFields
|
|
85
|
+
codings={codings}
|
|
86
|
+
answers={answers}
|
|
87
|
+
orientation={orientation}
|
|
87
88
|
readOnly={readOnly}
|
|
88
|
-
|
|
89
|
-
(answer) => JSON.stringify(answer.valueCoding) === JSON.stringify(coding)
|
|
90
|
-
)}
|
|
89
|
+
serverError={serverError}
|
|
91
90
|
onCheckedChange={handleCheckedChange}
|
|
92
91
|
/>
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
<StyledAlert color="error">
|
|
98
|
-
<ErrorOutlineIcon color="error" sx={{ pr: 0.75 }} />
|
|
99
|
-
<Typography variant="subtitle2">
|
|
100
|
-
There was an error fetching options from the terminology server
|
|
101
|
-
</Typography>
|
|
102
|
-
</StyledAlert>
|
|
103
|
-
) : (
|
|
104
|
-
<StyledAlert color="error">
|
|
105
|
-
<ErrorOutlineIcon color="error" sx={{ pr: 0.75 }} />
|
|
106
|
-
<Typography variant="subtitle2">
|
|
107
|
-
Unable to fetch options from the questionnaire or launch context
|
|
108
|
-
</Typography>
|
|
109
|
-
</StyledAlert>
|
|
92
|
+
<DisplayInstructions displayInstructions={displayInstructions} />
|
|
93
|
+
</Grid>
|
|
94
|
+
</Grid>
|
|
95
|
+
</FullWidthFormComponentBox>
|
|
110
96
|
);
|
|
97
|
+
}
|
|
111
98
|
|
|
112
99
|
return (
|
|
113
|
-
|
|
114
|
-
<
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
100
|
+
<>
|
|
101
|
+
<ChoiceCheckboxAnswerValueSetFields
|
|
102
|
+
codings={codings}
|
|
103
|
+
answers={answers}
|
|
104
|
+
orientation={orientation}
|
|
105
|
+
readOnly={readOnly}
|
|
106
|
+
serverError={serverError}
|
|
107
|
+
onCheckedChange={handleCheckedChange}
|
|
108
|
+
/>
|
|
109
|
+
<DisplayInstructions displayInstructions={displayInstructions} />
|
|
110
|
+
</>
|
|
124
111
|
);
|
|
125
112
|
}
|
|
126
113
|
|