@aehrc/smart-forms-renderer 0.31.6 → 0.32.1
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/README.md +3 -101
- package/lib/components/FormComponents/DateTimeItems/CustomDateTimeItem/CustomDateTimeItem.js +7 -4
- package/lib/components/FormComponents/DateTimeItems/CustomDateTimeItem/CustomDateTimeItem.js.map +1 -1
- package/lib/components/Renderer/SmartFormsRenderer.d.ts +1 -1
- package/lib/components/Renderer/SmartFormsRenderer.js +1 -1
- package/lib/stories/StorybookWrappers/InitialiseFormWrapperForStorybook.d.ts +4 -4
- package/lib/stories/StorybookWrappers/InitialiseFormWrapperForStorybook.js +4 -4
- package/lib/theme/Theme.d.ts +1 -1
- package/lib/theme/Theme.js +1 -1
- package/lib/utils/manageForm.d.ts +2 -1
- package/lib/utils/manageForm.js +2 -1
- package/lib/utils/manageForm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/FormComponents/DateTimeItems/CustomDateTimeItem/CustomDateTimeItem.tsx +8 -4
- package/src/components/Renderer/SmartFormsRenderer.tsx +1 -1
- package/src/stories/storybookWrappers/BuildFormButtonTesterWrapperForStorybook.tsx +1 -1
- package/src/stories/storybookWrappers/InitialiseFormWrapperForStorybook.tsx +4 -4
- package/src/stories/storybookWrappers/PrePopWrapperForStorybook.tsx +1 -1
- package/src/stories/storybookWrappers/populateCallbackForStorybook.ts +1 -1
- package/src/theme/Theme.tsx +1 -1
- package/src/utils/manageForm.ts +2 -1
- package/src/components/FormComponents/DateTimeItem/DateTimeField.tsx +0 -59
- package/src/components/FormComponents/DateTimeItem/DateTimeItem.tsx +0 -106
package/README.md
CHANGED
|
@@ -1,108 +1,10 @@
|
|
|
1
1
|
# Smart Forms Renderer
|
|
2
|
-
This React-based package acts as the rendering engine for the [Smart Forms app](https://github.com/aehrc/smart-forms).
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
A React-based library that contains the Questionnaire renderer used in the Smart Forms app.
|
|
4
|
+
It acts as a reference implementation for the [SDC Form Filler](https://hl7.org/fhir/uv/sdc/CapabilityStatement-sdc-form-filler.html).
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm install @aehrc/smart-forms-renderer
|
|
9
|
-
```
|
|
6
|
+
<h4><a href="https://smartforms.csiro.au/docs/devUsage">Check out the documentation 📚</a></h4>
|
|
10
7
|
|
|
11
|
-
## Basic Usage
|
|
12
|
-
|
|
13
|
-
```typescript jsx
|
|
14
|
-
import React from 'react';
|
|
15
|
-
import { SmartFormsRenderer, getResponse } from '@aehrc/smart-forms-renderer';
|
|
16
|
-
|
|
17
|
-
export default function App () {
|
|
18
|
-
const questionnaire = {...} // FHIR R4.Questionnaire
|
|
19
|
-
|
|
20
|
-
return (
|
|
21
|
-
<div>
|
|
22
|
-
<SmartFormsRenderer questionnaire={questionnaire}/>
|
|
23
|
-
<button onClick={() => {
|
|
24
|
-
const response = getResponse()
|
|
25
|
-
// Do something with the questionnaire response
|
|
26
|
-
}}/>
|
|
27
|
-
</div>
|
|
28
|
-
)
|
|
29
|
-
}
|
|
30
|
-
```
|
|
31
|
-
Note: The SmartFormsRenderer component trades customisability for simplicity. If you need more control over the rendering engine, refer to the Advanced Usage section.
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
### SmartFormsRenderer Props
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
| Name | Type | Description | Required? |
|
|
38
|
-
|-----------------------|-------------------------------|---------------------------------------------------------------------------------------------------------------------|-----------|
|
|
39
|
-
| questionnaire | FHIR R4.Questionnaire | Questionnaire to be rendered | Required |
|
|
40
|
-
| questionnaireResponse | FHIR R4.QuestionnaireResponse | Pre-populated QuestionnaireResponse to be rendered | Optional |
|
|
41
|
-
| additionalVariables | `Record<string, Extension>` | Key-value pair of [SDC variables](http://hl7.org/fhir/R4/extension-variable.html) `Record<name, variable extension>` | Optional |
|
|
42
|
-
| terminologyServerUrl | string | Terminology server url to fetch terminology | Optional |
|
|
43
|
-
|
|
44
|
-
The below props are not supported at the moment, but will be in the future.
|
|
45
|
-
|
|
46
|
-
| Name | Type | Description |
|
|
47
|
-
|----------------------|------------------------------------------------------|---------------------------------------------|
|
|
48
|
-
| fhirClient | [Client](https://github.com/smart-on-fhir/client-js) | FhirClient to perform further FHIR calls |
|
|
49
|
-
|
|
50
|
-
### Functions
|
|
51
|
-
|
|
52
|
-
```javascript
|
|
53
|
-
/**
|
|
54
|
-
* Get the filled QuestionnaireResponse at its current state.
|
|
55
|
-
* If no changes have been made to the form, the initial or an empty QuestionnaireResponse is returned.
|
|
56
|
-
*
|
|
57
|
-
* @returns {FHIR R4.QuestionnaireResponse} The filled QuestionnaireResponse
|
|
58
|
-
*/
|
|
59
|
-
function getResponse() {}
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
## Advanced Usage (If basic usage does not suffice)
|
|
64
|
-
|
|
65
|
-
```typescript
|
|
66
|
-
/* Components */
|
|
67
|
-
// A self-initialising wrapper around the rendering engine. This is sufficient for most use cases.
|
|
68
|
-
|
|
69
|
-
function SmartFormsRenderer(props: {
|
|
70
|
-
questionnaire: Questionnaire,
|
|
71
|
-
questionnaireResponse?: QuestionnaireResponse,
|
|
72
|
-
additionalVariables?: Record<string, Extension>,
|
|
73
|
-
terminologyServerUrl?: string,
|
|
74
|
-
}): JSX.Element {}
|
|
75
|
-
|
|
76
|
-
// BaseRenderer underneath the SmartFormsRenderer wrapper. Requires buildForm() to initialise form.
|
|
77
|
-
function BaseRenderer(): JSX.Element {}
|
|
78
|
-
|
|
79
|
-
/* Functions */
|
|
80
|
-
// Get the filled QuestionnaireResponse at its current state.
|
|
81
|
-
// If no changes have been made to the form, the initial QuestionnaireResponse is returned.
|
|
82
|
-
function getResponse(): QuestionnaireResponse {}
|
|
83
|
-
|
|
84
|
-
// Build the form with an initial Questionnaire and an optional filled QuestionnaireResponse.
|
|
85
|
-
// If a QuestionnaireResponse is not provided, an empty QuestionnaireResponse is set as the initial QuestionnaireResponse.
|
|
86
|
-
async function buildForm(
|
|
87
|
-
questionnaire: Questionnaire,
|
|
88
|
-
questionnaireResponse?: QuestionnaireResponse
|
|
89
|
-
): Promise<void> {}
|
|
90
|
-
|
|
91
|
-
// Destroy the form to clean up the questionnaire and questionnaireResponse stores.
|
|
92
|
-
function destroyForm(): void {}
|
|
93
|
-
|
|
94
|
-
// Remove all hidden answers from the filled QuestionnaireResponse.
|
|
95
|
-
// This takes into account the questionnaire-hidden extension, enableWhens and enableWhenExpressions.
|
|
96
|
-
function removeHiddenAnswersFromResponse(
|
|
97
|
-
questionnaire: Questionnaire,
|
|
98
|
-
questionnaireResponse: QuestionnaireResponse
|
|
99
|
-
): QuestionnaireResponse {}
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
The Smart Forms app uses a even finer-grained control which directly interacts with the state management stores.
|
|
103
|
-
|
|
104
|
-
At the moment there are no plans to document state management methods, but happy to do so if there is demand for it.
|
|
105
|
-
Raise a request in https://github.com/aehrc/smart-forms/issues if you want to see it happen!
|
|
106
8
|
|
|
107
9
|
---
|
|
108
10
|
|
package/lib/components/FormComponents/DateTimeItems/CustomDateTimeItem/CustomDateTimeItem.js
CHANGED
|
@@ -94,14 +94,17 @@ function CustomDateTimeItem(props) {
|
|
|
94
94
|
updateQRDateTime(dateInput, newTimeInput, newPeriodInput, is24HourNotation);
|
|
95
95
|
}
|
|
96
96
|
function updateQRDateTime(dateInput, timeInput, periodInput, is24HourNotation) {
|
|
97
|
-
let
|
|
97
|
+
let fhirDateTime = '';
|
|
98
98
|
if (timeInput) {
|
|
99
|
-
|
|
99
|
+
fhirDateTime = parseInputDateTimeToFhirDateTime(parseInputDateToFhirDate(dateInput), timeInput, periodInput, is24HourNotation);
|
|
100
100
|
}
|
|
101
101
|
else {
|
|
102
|
-
|
|
102
|
+
fhirDateTime = parseInputDateToFhirDate(dateInput);
|
|
103
103
|
}
|
|
104
|
-
|
|
104
|
+
if (fhirDateTime === 'Invalid Date') {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
onQrItemChange(Object.assign(Object.assign({}, createEmptyQrItem(qItem)), { answer: [{ valueDateTime: fhirDateTime }] }));
|
|
105
108
|
}
|
|
106
109
|
// FIXME entryFormat and displayPrompt, put them beneath the entire component instead of at the date field
|
|
107
110
|
if (isRepeated) {
|
package/lib/components/FormComponents/DateTimeItems/CustomDateTimeItem/CustomDateTimeItem.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomDateTimeItem.js","sourceRoot":"","sources":["../../../../../src/components/FormComponents/DateTimeItems/CustomDateTimeItem/CustomDateTimeItem.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAQxC,OAAO,WAAW,MAAM,+BAA+B,CAAC;AACxD,OAAO,sBAAsB,MAAM,0CAA0C,CAAC;AAC9E,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,aAAa,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,iBAAiB,MAAM,qCAAqC,CAAC;AACpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,0BAA0B,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACjF,OAAO,KAAK,MAAM,qBAAqB,CAAC;AAExC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EACL,0BAA0B,EAC1B,gCAAgC,EAChC,iBAAiB,EAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,iBAAiB,MAAM,qCAAqC,CAAC;AACpE,OAAO,yBAAyB,MAAM,uCAAuC,CAAC;AAC9E,OAAO,aAAa,MAAM,iBAAiB,C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IAED,SAAS,qBAAqB,CAAC,YAAoB,EAAE,cAAsB;QACzE,YAAY,CAAC,YAAY,CAAC,CAAC;QAC3B,cAAc,CAAC,cAAc,CAAC,CAAC;QAE/B,IAAI,YAAY,KAAK,EAAE,EAAE;YACvB,cAAc,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC;SAC1C;QAED,MAAM,EAAE,WAAW,EAAE,gBAAgB,EAAE,GAAG,iBAAiB,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC;QAC1F,IAAI,CAAC,iBAAiB,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,EAAE;YACjD,OAAO;SACR;QAED,gBAAgB,CAAC,SAAS,EAAE,YAAY,EAAE,cAAc,EAAE,gBAAgB,CAAC,CAAC;IAC9E,CAAC;IAED,SAAS,gBAAgB,CACvB,SAAiB,EACjB,SAAiB,EACjB,WAAmB,EACnB,gBAAyB;QAEzB,IAAI,
|
|
1
|
+
{"version":3,"file":"CustomDateTimeItem.js","sourceRoot":"","sources":["../../../../../src/components/FormComponents/DateTimeItems/CustomDateTimeItem/CustomDateTimeItem.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAQxC,OAAO,WAAW,MAAM,+BAA+B,CAAC;AACxD,OAAO,sBAAsB,MAAM,0CAA0C,CAAC;AAC9E,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,aAAa,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,iBAAiB,MAAM,qCAAqC,CAAC;AACpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,0BAA0B,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,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AC5B,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,iBAAiB,EAAE,qBAAqB,EACxC,YAAY,EAAE,gBAAgB,EAC9B,cAAc,EAAE,cAAc,EAC9B,iBAAiB,EAAE,qBAAqB,GACxC,CACY,CACU,CAC7B,CAAC;AACJ,CAAC;AAED,eAAe,kBAAkB,CAAC"}
|
|
@@ -24,7 +24,7 @@ export interface SmartFormsRendererProps {
|
|
|
24
24
|
/**
|
|
25
25
|
* A self-initialising wrapper around the BaseRenderer rendering engine.
|
|
26
26
|
* Will be deprecated in version 1.0.0. For alternative usage, see:
|
|
27
|
-
* - https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/
|
|
27
|
+
* - https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/storybookWrappers/InitialiseFormWrapperForStorybook.tsx#L40-L57
|
|
28
28
|
*
|
|
29
29
|
* @see SmartFormsRendererProps for props.
|
|
30
30
|
*
|
|
@@ -27,7 +27,7 @@ import BaseRenderer from './BaseRenderer';
|
|
|
27
27
|
/**
|
|
28
28
|
* A self-initialising wrapper around the BaseRenderer rendering engine.
|
|
29
29
|
* Will be deprecated in version 1.0.0. For alternative usage, see:
|
|
30
|
-
* - https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/
|
|
30
|
+
* - https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/storybookWrappers/InitialiseFormWrapperForStorybook.tsx#L40-L57
|
|
31
31
|
*
|
|
32
32
|
* @see SmartFormsRendererProps for props.
|
|
33
33
|
*
|
|
@@ -20,10 +20,10 @@ export interface InitialiseFormWrapperProps {
|
|
|
20
20
|
* - The initialised FHIRClient is only used for further FHIR calls. It does not provide pre-population capabilities.
|
|
21
21
|
*
|
|
22
22
|
* For button click usage examples of buildForm(), see:
|
|
23
|
-
* - https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/
|
|
24
|
-
* - https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/
|
|
25
|
-
* - https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/
|
|
26
|
-
* - https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/
|
|
23
|
+
* - https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/storybookWrappers/BuildFormButtonTesterWrapperForStorybook.tsx
|
|
24
|
+
* - https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/storybookWrappers/BuildFormButtonForStorybook.tsx
|
|
25
|
+
* - https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/storybookWrappers/PrePopWrapperForStorybook.tsx
|
|
26
|
+
* - https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/storybookWrappers/PrePopButtonForStorybook.tsx
|
|
27
27
|
*
|
|
28
28
|
* @author Sean Fong
|
|
29
29
|
*/
|
|
@@ -35,10 +35,10 @@ import Typography from '@mui/material/Typography';
|
|
|
35
35
|
* - The initialised FHIRClient is only used for further FHIR calls. It does not provide pre-population capabilities.
|
|
36
36
|
*
|
|
37
37
|
* For button click usage examples of buildForm(), see:
|
|
38
|
-
* - https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/
|
|
39
|
-
* - https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/
|
|
40
|
-
* - https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/
|
|
41
|
-
* - https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/
|
|
38
|
+
* - https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/storybookWrappers/BuildFormButtonTesterWrapperForStorybook.tsx
|
|
39
|
+
* - https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/storybookWrappers/BuildFormButtonForStorybook.tsx
|
|
40
|
+
* - https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/storybookWrappers/PrePopWrapperForStorybook.tsx
|
|
41
|
+
* - https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/storybookWrappers/PrePopButtonForStorybook.tsx
|
|
42
42
|
*
|
|
43
43
|
* @author Sean Fong
|
|
44
44
|
*/
|
package/lib/theme/Theme.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ declare module '@mui/material/styles' {
|
|
|
33
33
|
}
|
|
34
34
|
export declare const themeOptions: ThemeOptions;
|
|
35
35
|
/**
|
|
36
|
-
* Default
|
|
36
|
+
* Default theme used by the renderer using Material UI. You can customise your own theme by defining a new ThemeProvider.
|
|
37
37
|
* @see {@link https://mui.com/material-ui/customization/theming/}
|
|
38
38
|
*
|
|
39
39
|
* @author Sean Fong
|
package/lib/theme/Theme.js
CHANGED
|
@@ -27,7 +27,7 @@ export const themeOptions = {
|
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
29
|
/**
|
|
30
|
-
* Default
|
|
30
|
+
* Default theme used by the renderer using Material UI. You can customise your own theme by defining a new ThemeProvider.
|
|
31
31
|
* @see {@link https://mui.com/material-ui/customization/theming/}
|
|
32
32
|
*
|
|
33
33
|
* @author Sean Fong
|
|
@@ -37,8 +37,9 @@ export declare function initialiseFhirClient(fhirClient: Client): Promise<void>;
|
|
|
37
37
|
*/
|
|
38
38
|
export declare function getResponse(): QuestionnaireResponse;
|
|
39
39
|
/**
|
|
40
|
-
* Remove all hidden answers from the filled QuestionnaireResponse.
|
|
40
|
+
* Remove all empty/hidden answers from the filled QuestionnaireResponse.
|
|
41
41
|
* This takes into account enableWhens, enableWhenExpressions, items without item.answer, empty item.answer arrays and empty strings.
|
|
42
|
+
* This does not remove items that are hidden by the http://hl7.org/fhir/StructureDefinition/questionnaire-hidden extension.
|
|
42
43
|
*
|
|
43
44
|
* @author Sean Fong
|
|
44
45
|
*/
|
package/lib/utils/manageForm.js
CHANGED
|
@@ -87,8 +87,9 @@ export function getResponse() {
|
|
|
87
87
|
return questionnaireResponseStore.getState().updatableResponse;
|
|
88
88
|
}
|
|
89
89
|
/**
|
|
90
|
-
* Remove all hidden answers from the filled QuestionnaireResponse.
|
|
90
|
+
* Remove all empty/hidden answers from the filled QuestionnaireResponse.
|
|
91
91
|
* This takes into account enableWhens, enableWhenExpressions, items without item.answer, empty item.answer arrays and empty strings.
|
|
92
|
+
* This does not remove items that are hidden by the http://hl7.org/fhir/StructureDefinition/questionnaire-hidden extension.
|
|
92
93
|
*
|
|
93
94
|
* @author Sean Fong
|
|
94
95
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manageForm.js","sourceRoot":"","sources":["../../src/utils/manageForm.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EACL,0BAA0B,EAC1B,kBAAkB,EAClB,gBAAgB,EAChB,sBAAsB,EACvB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,+BAA+B,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAG1E;;;;;;;;;;;;GAYG;AACH,MAAM,UAAgB,SAAS,CAC7B,aAA4B,EAC5B,qBAA6C,EAC7C,QAAkB,EAClB,oBAA6B,EAC7B,mBAA4C;;QAE5C,IAAI,oBAAoB,EAAE;YACxB,sBAAsB,CAAC,QAAQ,EAAE,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC;SAChE;aAAM;YACL,sBAAsB,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC;SAC9C;QAED,yIAAyI;QACzI,MAAM,kBAAkB;aACrB,QAAQ,EAAE;aACV,wBAAwB,CAAC,aAAa,EAAE,SAAS,EAAE,mBAAmB,EAAE,oBAAoB,CAAC,CAAC;QAEjG,M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kBAAkB,CAAC;QACxB,aAAa;QACb,qBAAqB;QACrB,qBAAqB;QACrB,eAAe;QACf,qBAAqB;KACtB,CAAC,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
package/src/components/FormComponents/DateTimeItems/CustomDateTimeItem/CustomDateTimeItem.tsx
CHANGED
|
@@ -143,21 +143,25 @@ function CustomDateTimeItem(props: CustomDateTimeItemProps) {
|
|
|
143
143
|
periodInput: string,
|
|
144
144
|
is24HourNotation: boolean
|
|
145
145
|
) {
|
|
146
|
-
let
|
|
146
|
+
let fhirDateTime = '';
|
|
147
147
|
if (timeInput) {
|
|
148
|
-
|
|
148
|
+
fhirDateTime = parseInputDateTimeToFhirDateTime(
|
|
149
149
|
parseInputDateToFhirDate(dateInput),
|
|
150
150
|
timeInput,
|
|
151
151
|
periodInput,
|
|
152
152
|
is24HourNotation
|
|
153
153
|
);
|
|
154
154
|
} else {
|
|
155
|
-
|
|
155
|
+
fhirDateTime = parseInputDateToFhirDate(dateInput);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (fhirDateTime === 'Invalid Date') {
|
|
159
|
+
return;
|
|
156
160
|
}
|
|
157
161
|
|
|
158
162
|
onQrItemChange({
|
|
159
163
|
...createEmptyQrItem(qItem),
|
|
160
|
-
answer: [{ valueDateTime:
|
|
164
|
+
answer: [{ valueDateTime: fhirDateTime }]
|
|
161
165
|
});
|
|
162
166
|
}
|
|
163
167
|
|
|
@@ -54,7 +54,7 @@ export interface SmartFormsRendererProps {
|
|
|
54
54
|
/**
|
|
55
55
|
* A self-initialising wrapper around the BaseRenderer rendering engine.
|
|
56
56
|
* Will be deprecated in version 1.0.0. For alternative usage, see:
|
|
57
|
-
* - https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/
|
|
57
|
+
* - https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/storybookWrappers/InitialiseFormWrapperForStorybook.tsx#L40-L57
|
|
58
58
|
*
|
|
59
59
|
* @see SmartFormsRendererProps for props.
|
|
60
60
|
*
|
|
@@ -35,7 +35,7 @@ interface BuildFormButtonTesterWrapperForStorybookProps {
|
|
|
35
35
|
* It was done as a two-step process for demo purposes.
|
|
36
36
|
*
|
|
37
37
|
* Use this pattern if you already have a pre-populated/pre-filled/draft response.
|
|
38
|
-
* If you want to pre-pop on the fly, see https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/
|
|
38
|
+
* If you want to pre-pop on the fly, see https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/storybookWrappers/PrePopWrapperForStorybook.tsx instead
|
|
39
39
|
*
|
|
40
40
|
* @author Sean Fong
|
|
41
41
|
*/
|
|
@@ -48,10 +48,10 @@ export interface InitialiseFormWrapperProps {
|
|
|
48
48
|
* - The initialised FHIRClient is only used for further FHIR calls. It does not provide pre-population capabilities.
|
|
49
49
|
*
|
|
50
50
|
* For button click usage examples of buildForm(), see:
|
|
51
|
-
* - https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/
|
|
52
|
-
* - https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/
|
|
53
|
-
* - https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/
|
|
54
|
-
* - https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/
|
|
51
|
+
* - https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/storybookWrappers/BuildFormButtonTesterWrapperForStorybook.tsx
|
|
52
|
+
* - https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/storybookWrappers/BuildFormButtonForStorybook.tsx
|
|
53
|
+
* - https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/storybookWrappers/PrePopWrapperForStorybook.tsx
|
|
54
|
+
* - https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/storybookWrappers/PrePopButtonForStorybook.tsx
|
|
55
55
|
*
|
|
56
56
|
* @author Sean Fong
|
|
57
57
|
*/
|
|
@@ -41,7 +41,7 @@ interface PrePopWrapperForStorybookProps {
|
|
|
41
41
|
* This does in-app population and you have to define your own callback function to retrieve resources from your source server.
|
|
42
42
|
*
|
|
43
43
|
* Use this pattern if you do not have a pre-populated/pre-filled/draft response and want to pre-populate on the fly.
|
|
44
|
-
* If you already have a questionnaireResponse, see https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/
|
|
44
|
+
* If you already have a questionnaireResponse, see https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/storybookWrappers/BuildFormButtonTesterWrapperForStorybook.tsx instead
|
|
45
45
|
*
|
|
46
46
|
* @author Sean Fong
|
|
47
47
|
*/
|
|
@@ -27,7 +27,7 @@ interface RequestConfig {
|
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* Sample callback function to fetch resources from your source server when using populate() or populateQuestionnaire() from @aehrc/sdc-populate.
|
|
30
|
-
* See https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/
|
|
30
|
+
* See https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/storybookWrappers/PrePopWrapperForStorybook.tsx for usage.
|
|
31
31
|
*
|
|
32
32
|
* @author Sean Fong
|
|
33
33
|
*/
|
package/src/theme/Theme.tsx
CHANGED
|
@@ -90,7 +90,7 @@ export const themeOptions: ThemeOptions = {
|
|
|
90
90
|
};
|
|
91
91
|
|
|
92
92
|
/**
|
|
93
|
-
* Default
|
|
93
|
+
* Default theme used by the renderer using Material UI. You can customise your own theme by defining a new ThemeProvider.
|
|
94
94
|
* @see {@link https://mui.com/material-ui/customization/theming/}
|
|
95
95
|
*
|
|
96
96
|
* @author Sean Fong
|
package/src/utils/manageForm.ts
CHANGED
|
@@ -98,8 +98,9 @@ export function getResponse(): QuestionnaireResponse {
|
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
/**
|
|
101
|
-
* Remove all hidden answers from the filled QuestionnaireResponse.
|
|
101
|
+
* Remove all empty/hidden answers from the filled QuestionnaireResponse.
|
|
102
102
|
* This takes into account enableWhens, enableWhenExpressions, items without item.answer, empty item.answer arrays and empty strings.
|
|
103
|
+
* This does not remove items that are hidden by the http://hl7.org/fhir/StructureDefinition/questionnaire-hidden extension.
|
|
103
104
|
*
|
|
104
105
|
* @author Sean Fong
|
|
105
106
|
*/
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2024 Commonwealth Scientific and Industrial Research
|
|
3
|
-
* Organisation (CSIRO) ABN 41 687 119 230.
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
import React from 'react';
|
|
19
|
-
import type { PropsWithIsTabledAttribute } from '../../../interfaces/renderProps.interface';
|
|
20
|
-
import type { Dayjs } from 'dayjs';
|
|
21
|
-
import { DateTimePicker as MuiDateTimePicker, LocalizationProvider } from '@mui/x-date-pickers';
|
|
22
|
-
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
|
|
23
|
-
import Box from '@mui/material/Box';
|
|
24
|
-
import { TEXT_FIELD_WIDTH } from '../Textfield.styles';
|
|
25
|
-
|
|
26
|
-
interface DateTimeFieldProps extends PropsWithIsTabledAttribute {
|
|
27
|
-
value: Dayjs | null;
|
|
28
|
-
displayPrompt: string;
|
|
29
|
-
entryFormat: string;
|
|
30
|
-
readOnly: boolean;
|
|
31
|
-
onDateTimeChange: (newValue: Dayjs | null) => unknown;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function DateTimeField(props: DateTimeFieldProps) {
|
|
35
|
-
const { value, displayPrompt, entryFormat, readOnly, isTabled, onDateTimeChange } = props;
|
|
36
|
-
|
|
37
|
-
return (
|
|
38
|
-
<LocalizationProvider dateAdapter={AdapterDayjs}>
|
|
39
|
-
<Box data-test="q-item-date-time-field">
|
|
40
|
-
<MuiDateTimePicker
|
|
41
|
-
format={entryFormat !== '' ? entryFormat : 'DD/MM/YYYY hh:mm A'}
|
|
42
|
-
value={value}
|
|
43
|
-
disabled={readOnly}
|
|
44
|
-
label={displayPrompt}
|
|
45
|
-
sx={{ maxWidth: !isTabled ? TEXT_FIELD_WIDTH : 3000, minWidth: 160 }}
|
|
46
|
-
onChange={onDateTimeChange}
|
|
47
|
-
slotProps={{
|
|
48
|
-
textField: {
|
|
49
|
-
size: 'small',
|
|
50
|
-
fullWidth: true
|
|
51
|
-
}
|
|
52
|
-
}}
|
|
53
|
-
/>
|
|
54
|
-
</Box>
|
|
55
|
-
</LocalizationProvider>
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export default DateTimeField;
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2024 Commonwealth Scientific and Industrial Research
|
|
3
|
-
* Organisation (CSIRO) ABN 41 687 119 230.
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
import React from 'react';
|
|
19
|
-
import type {
|
|
20
|
-
PropsWithIsRepeatedAttribute,
|
|
21
|
-
PropsWithIsTabledAttribute,
|
|
22
|
-
PropsWithParentIsReadOnlyAttribute,
|
|
23
|
-
PropsWithQrItemChangeHandler
|
|
24
|
-
} from '../../../interfaces/renderProps.interface';
|
|
25
|
-
import type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';
|
|
26
|
-
import useRenderingExtensions from '../../../hooks/useRenderingExtensions';
|
|
27
|
-
import { createEmptyQrItem } from '../../../utils/qrItem';
|
|
28
|
-
import { FullWidthFormComponentBox } from '../../Box.styles';
|
|
29
|
-
import ItemFieldGrid from '../ItemParts/ItemFieldGrid';
|
|
30
|
-
import DateTimeField from './DateTimeField';
|
|
31
|
-
import type { Dayjs } from 'dayjs';
|
|
32
|
-
import dayjs from 'dayjs';
|
|
33
|
-
import useReadOnly from '../../../hooks/useReadOnly';
|
|
34
|
-
import { useQuestionnaireStore } from '../../../stores';
|
|
35
|
-
|
|
36
|
-
interface DateTimeItemProps
|
|
37
|
-
extends PropsWithQrItemChangeHandler,
|
|
38
|
-
PropsWithIsRepeatedAttribute,
|
|
39
|
-
PropsWithIsTabledAttribute,
|
|
40
|
-
PropsWithParentIsReadOnlyAttribute {
|
|
41
|
-
qItem: QuestionnaireItem;
|
|
42
|
-
qrItem: QuestionnaireResponseItem | null;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function DateTimeItem(props: DateTimeItemProps) {
|
|
46
|
-
const { qItem, qrItem, isRepeated, isTabled, parentIsReadOnly, onQrItemChange } = props;
|
|
47
|
-
|
|
48
|
-
const onFocusLinkId = useQuestionnaireStore.use.onFocusLinkId();
|
|
49
|
-
|
|
50
|
-
const readOnly = useReadOnly(qItem, parentIsReadOnly);
|
|
51
|
-
const { displayPrompt, entryFormat } = useRenderingExtensions(qItem);
|
|
52
|
-
|
|
53
|
-
// Init input value
|
|
54
|
-
let dateTimeString: string | null = null;
|
|
55
|
-
if (qrItem?.answer) {
|
|
56
|
-
if (qrItem?.answer[0].valueDate) {
|
|
57
|
-
dateTimeString = qrItem.answer[0].valueDate;
|
|
58
|
-
} else if (qrItem?.answer[0].valueDateTime) {
|
|
59
|
-
dateTimeString = qrItem.answer[0].valueDateTime;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
const dateTimeDayJs = dateTimeString ? dayjs(dateTimeString) : null;
|
|
63
|
-
|
|
64
|
-
// Event handlers
|
|
65
|
-
function handleDateTimeChange(newValue: Dayjs | null) {
|
|
66
|
-
const emptyQrItem = createEmptyQrItem(qItem);
|
|
67
|
-
if (newValue) {
|
|
68
|
-
onQrItemChange({ ...emptyQrItem, answer: [{ valueDateTime: newValue.format() }] });
|
|
69
|
-
} else {
|
|
70
|
-
onQrItemChange(emptyQrItem);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (isRepeated) {
|
|
75
|
-
return (
|
|
76
|
-
<DateTimeField
|
|
77
|
-
value={dateTimeDayJs}
|
|
78
|
-
displayPrompt={displayPrompt}
|
|
79
|
-
entryFormat={entryFormat}
|
|
80
|
-
readOnly={readOnly}
|
|
81
|
-
onDateTimeChange={handleDateTimeChange}
|
|
82
|
-
isTabled={isTabled}
|
|
83
|
-
/>
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
return (
|
|
88
|
-
<FullWidthFormComponentBox
|
|
89
|
-
data-test="q-item-date-time-box"
|
|
90
|
-
data-linkid={qItem.linkId}
|
|
91
|
-
onClick={() => onFocusLinkId(qItem.linkId)}>
|
|
92
|
-
<ItemFieldGrid qItem={qItem} readOnly={readOnly}>
|
|
93
|
-
<DateTimeField
|
|
94
|
-
value={dateTimeDayJs}
|
|
95
|
-
displayPrompt={displayPrompt}
|
|
96
|
-
entryFormat={entryFormat}
|
|
97
|
-
readOnly={readOnly}
|
|
98
|
-
onDateTimeChange={handleDateTimeChange}
|
|
99
|
-
isTabled={isTabled}
|
|
100
|
-
/>
|
|
101
|
-
</ItemFieldGrid>
|
|
102
|
-
</FullWidthFormComponentBox>
|
|
103
|
-
);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export default DateTimeItem;
|