@aehrc/smart-forms-renderer 0.9.0 → 0.9.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  # Smart Forms Renderer
2
2
  This React-based package acts as the rendering engine for the [Smart Forms app](https://github.com/aehrc/smart-forms).
3
3
 
4
- Try out a minimal demo here: https://www.smartforms.io/standalone.
4
+ Try out a minimal demo here: https://smartforms.csiro.au/standalone.
5
5
 
6
6
  ## Installation
7
7
  ```bash
@@ -27,8 +27,10 @@ export default function App () {
27
27
  </div>
28
28
  )
29
29
  }
30
-
31
30
  ```
31
+ Note: The SmartFormsRenderer component is extremely basic and experimental, do not use it in production!
32
+
33
+
32
34
  ### SmartFormsRenderer Props
33
35
 
34
36
 
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  export declare const GroupCard: import("@emotion/styled").StyledComponent<import("@mui/material/Card").CardOwnProps & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
3
3
  ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
4
- }, "style" | "className" | "children" | "sx" | "classes" | "elevation" | "variant" | "square" | "raised"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme> & {
4
+ }, "style" | "children" | "className" | "sx" | "classes" | "elevation" | "variant" | "square" | "raised"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme> & {
5
5
  elevation: number;
6
6
  isRepeated: boolean;
7
7
  }, {}, {}>;
@@ -1,4 +1,4 @@
1
1
  /// <reference types="react" />
2
2
  export declare const PrimarySelectableList: import("@emotion/styled").StyledComponent<import("@mui/material/List").ListOwnProps & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLUListElement>, HTMLUListElement>, "ref"> & {
3
3
  ref?: ((instance: HTMLUListElement | null) => void) | import("react").RefObject<HTMLUListElement> | null | undefined;
4
- }, "style" | "className" | "children" | "sx" | "classes" | "dense" | "disablePadding" | "subheader"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
4
+ }, "style" | "children" | "className" | "sx" | "classes" | "dense" | "disablePadding" | "subheader"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
@@ -1,4 +1,4 @@
1
1
  /// <reference types="react" />
2
2
  export declare const PrimarySelectableList: import("@emotion/styled").StyledComponent<import("@mui/material/List").ListOwnProps & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLUListElement>, HTMLUListElement>, "ref"> & {
3
3
  ref?: ((instance: HTMLUListElement | null) => void) | import("react").RefObject<HTMLUListElement> | null | undefined;
4
- }, "style" | "className" | "children" | "sx" | "classes" | "dense" | "disablePadding" | "subheader"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
4
+ }, "style" | "children" | "className" | "sx" | "classes" | "dense" | "disablePadding" | "subheader"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
@@ -15,6 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  import React from 'react';
18
+ import ThemeProvider from '../../theme/Theme';
18
19
  import useInitialiseRenderer from '../../hooks/useInitialiseRenderer';
19
20
  import Box from '@mui/material/Box';
20
21
  import CircularProgress from '@mui/material/CircularProgress';
@@ -22,7 +23,6 @@ import Typography from '@mui/material/Typography';
22
23
  import { QueryClientProvider } from '@tanstack/react-query';
23
24
  import useQueryClient from '../../hooks/useQueryClient';
24
25
  import BaseRenderer from './BaseRenderer';
25
- import ThemeProvider from '../../theme/Theme';
26
26
  function SmartFormsRenderer(props) {
27
27
  const { questionnaire, questionnaireResponse, additionalVariables, terminologyServerUrl, fhirClient } = props;
28
28
  const isLoading = useInitialiseRenderer(questionnaire, questionnaireResponse, additionalVariables, terminologyServerUrl, fhirClient);
@@ -1 +1 @@
1
- {"version":3,"file":"SmartFormsRenderer.js","sourceRoot":"","sources":["../../../src/components/Renderer/SmartFormsRenderer.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,qBAAqB,MAAM,mCAAmC,CAAC;AACtE,OAAO,GAAG,MAAM,mBAAmB,CAAC;AACpC,OAAO,gBAAgB,MAAM,gCAAgC,CAAC;AAC9D,OAAO,UAAU,MAAM,0BAA0B,CAAC;AAElD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,cAAc,MAAM,4BAA4B,CAAC;AACxD,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,aAAa,MAAM,mBAAmB,CAAC;AAW9C,SAAS,kBAAkB,CAAC,KAA8B;IACxD,MAAM,EACJ,aAAa,EACb,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,UAAU,EACX,GAAG,KAAK,CAAC;IAEV,MAAM,SAAS,GAAG,qBAAqB,CACrC,aAAa,EACb,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,UAAU,CACX,CAAC;IACF,MAAM,WAAW,GAAG,cAAc,EAAE,CAAC;IAErC,IAAI,SAAS,EAAE;QACb,OAAO,CACL,oBAAC,GAAG,IAAC,OAAO,EAAC,MAAM,EAAC,UAAU,EAAC,QAAQ,EAAC,SAAS,EAAE,CAAC;YAClD,oBAAC,gBAAgB,OAAG;YACpB,oBAAC,UAAU,mCAAsC,CAC7C,CACP,CAAC;KACH;IAED,OAAO,CACL,oBAAC,aAAa;QACZ,oBAAC,mBAAmB,IAAC,MAAM,EAAE,WAAW;YACtC,oBAAC,YAAY,OAAG,CACI,CACR,CACjB,CAAC;AACJ,CAAC;AAED,eAAe,kBAAkB,CAAC"}
1
+ {"version":3,"file":"SmartFormsRenderer.js","sourceRoot":"","sources":["../../../src/components/Renderer/SmartFormsRenderer.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,aAAa,MAAM,mBAAmB,CAAC;AAE9C,OAAO,qBAAqB,MAAM,mCAAmC,CAAC;AACtE,OAAO,GAAG,MAAM,mBAAmB,CAAC;AACpC,OAAO,gBAAgB,MAAM,gCAAgC,CAAC;AAC9D,OAAO,UAAU,MAAM,0BAA0B,CAAC;AAElD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,cAAc,MAAM,4BAA4B,CAAC;AACxD,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAY1C,SAAS,kBAAkB,CAAC,KAA8B;IACxD,MAAM,EACJ,aAAa,EACb,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,UAAU,EACX,GAAG,KAAK,CAAC;IAEV,MAAM,SAAS,GAAG,qBAAqB,CACrC,aAAa,EACb,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,UAAU,CACX,CAAC;IACF,MAAM,WAAW,GAAG,cAAc,EAAE,CAAC;IAErC,IAAI,SAAS,EAAE;QACb,OAAO,CACL,oBAAC,GAAG,IAAC,OAAO,EAAC,MAAM,EAAC,UAAU,EAAC,QAAQ,EAAC,SAAS,EAAE,CAAC;YAClD,oBAAC,gBAAgB,OAAG;YACpB,oBAAC,UAAU,mCAAsC,CAC7C,CACP,CAAC;KACH;IAED,OAAO,CACL,oBAAC,aAAa;QACZ,oBAAC,mBAAmB,IAAC,MAAM,EAAE,WAAW;YACtC,oBAAC,YAAY,OAAG,CACI,CACR,CACjB,CAAC;AACJ,CAAC;AAED,eAAe,kBAAkB,CAAC"}
@@ -36,7 +36,8 @@ export default function CustomGlobalStyles() {
36
36
  },
37
37
  '#root': {
38
38
  width: '100%',
39
- height: '100%'
39
+ height: '100%',
40
+ textAlign: 'left'
40
41
  },
41
42
  input: {
42
43
  '&[type=number]': {
@@ -1 +1 @@
1
- {"version":3,"file":"customGlobalStyles.js","sourceRoot":"","sources":["../../src/theme/customGlobalStyles.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,YAAY,MAAM,4BAA4B,CAAC;AAEtD,MAAM,CAAC,OAAO,UAAU,kBAAkB;IACxC,OAAO,CACL,oBAAC,YAAY,IACX,MAAM,EAAE;YACN,GAAG,EAAE;gBACH,SAAS,EAAE,YAAY;aACxB;YACD,IAAI,EAAE;gBACJ,MAAM,EAAE,CAAC;gBACT,OAAO,EAAE,CAAC;gBACV,KAAK,EAAE,MAAM;gBACb,MAAM,EAAE,MAAM;gBACd,uBAAuB,EAAE,OAAO;aACjC;YACD,IAAI,EAAE;gBACJ,MAAM,EAAE,CAAC;gBACT,OAAO,EAAE,CAAC;gBACV,KAAK,EAAE,MAAM;gBACb,MAAM,EAAE,MAAM;aACf;YACD,OAAO,EAAE;gBACP,KAAK,EAAE,MAAM;gBACb,MAAM,EAAE,MAAM;aACf;YACD,KAAK,EAAE;gBACL,gBAAgB,EAAE;oBAChB,aAAa,EAAE,WAAW;oBAC1B,8BAA8B,EAAE;wBAC9B,MAAM,EAAE,CAAC;wBACT,gBAAgB,EAAE,MAAM;qBACzB;oBACD,8BAA8B,EAAE;wBAC9B,MAAM,EAAE,CAAC;wBACT,gBAAgB,EAAE,MAAM;qBACzB;iBACF;aACF;YACD,GAAG,EAAE;gBACH,OAAO,EAAE,OAAO;gBAChB,QAAQ,EAAE,MAAM;aACjB;SACF,GACD,CACH,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"customGlobalStyles.js","sourceRoot":"","sources":["../../src/theme/customGlobalStyles.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,YAAY,MAAM,4BAA4B,CAAC;AAEtD,MAAM,CAAC,OAAO,UAAU,kBAAkB;IACxC,OAAO,CACL,oBAAC,YAAY,IACX,MAAM,EAAE;YACN,GAAG,EAAE;gBACH,SAAS,EAAE,YAAY;aACxB;YACD,IAAI,EAAE;gBACJ,MAAM,EAAE,CAAC;gBACT,OAAO,EAAE,CAAC;gBACV,KAAK,EAAE,MAAM;gBACb,MAAM,EAAE,MAAM;gBACd,uBAAuB,EAAE,OAAO;aACjC;YACD,IAAI,EAAE;gBACJ,MAAM,EAAE,CAAC;gBACT,OAAO,EAAE,CAAC;gBACV,KAAK,EAAE,MAAM;gBACb,MAAM,EAAE,MAAM;aACf;YACD,OAAO,EAAE;gBACP,KAAK,EAAE,MAAM;gBACb,MAAM,EAAE,MAAM;gBACd,SAAS,EAAE,MAAM;aAClB;YACD,KAAK,EAAE;gBACL,gBAAgB,EAAE;oBAChB,aAAa,EAAE,WAAW;oBAC1B,8BAA8B,EAAE;wBAC9B,MAAM,EAAE,CAAC;wBACT,gBAAgB,EAAE,MAAM;qBACzB;oBACD,8BAA8B,EAAE;wBAC9B,MAAM,EAAE,CAAC;wBACT,gBAAgB,EAAE,MAAM;qBACzB;iBACF;aACF;YACD,GAAG,EAAE;gBACH,OAAO,EAAE,OAAO;gBAChB,QAAQ,EAAE,MAAM;aACjB;SACF,GACD,CACH,CAAC;AACJ,CAAC"}
@@ -33,45 +33,45 @@ export function responsiveFontSizes(props) {
33
33
  }
34
34
  // ----------------------------------------------------------------------
35
35
  const typography = {
36
- fontFamily: ['Inter', 'sans-serif', 'Roboto', 'Arial', '"Helvetica Neue"', 'Helvetica'].join(','),
36
+ fontFamily: ['Inter', 'sans-serif', 'Helvetica', 'Arial', 'Roboto', '"Helvetica Neue"'].join(','),
37
37
  fontWeightRegular: 500,
38
38
  h1: Object.assign({ fontWeight: 800, lineHeight: 80 / 64, fontSize: pxToRem(36) }, responsiveFontSizes({ sm: 40, md: 48, lg: 54 })),
39
39
  h2: Object.assign({ fontWeight: 800, lineHeight: 64 / 48, fontSize: pxToRem(28) }, responsiveFontSizes({ sm: 32, md: 34, lg: 36 })),
40
40
  h3: Object.assign({ fontWeight: 700, lineHeight: 1.5, fontSize: pxToRem(20) }, responsiveFontSizes({ sm: 22, md: 26, lg: 28 })),
41
41
  h4: Object.assign({ fontWeight: 700, lineHeight: 1.5, fontSize: pxToRem(16) }, responsiveFontSizes({ sm: 18, md: 20, lg: 20 })),
42
42
  h5: Object.assign({ fontWeight: 700, lineHeight: 1.5, fontSize: pxToRem(14) }, responsiveFontSizes({ sm: 15, md: 16, lg: 16 })),
43
- h6: Object.assign({ fontWeight: 700, lineHeight: 28 / 18, fontSize: pxToRem(13) }, responsiveFontSizes({ sm: 14, md: 14, lg: 14 })),
43
+ h6: Object.assign({ fontWeight: 700, lineHeight: 28 / 18, fontSize: pxToRem(13.5) }, responsiveFontSizes({ sm: 14, md: 14, lg: 14 })),
44
44
  subtitle1: {
45
45
  fontWeight: 600,
46
46
  lineHeight: 1.5,
47
- fontSize: pxToRem(13)
47
+ fontSize: pxToRem(13.5)
48
48
  },
49
49
  subtitle2: {
50
50
  fontWeight: 600,
51
51
  lineHeight: 22 / 14,
52
- fontSize: pxToRem(11.5)
52
+ fontSize: pxToRem(12)
53
53
  },
54
54
  body1: {
55
55
  lineHeight: 1.5,
56
- fontSize: pxToRem(12.25)
56
+ fontSize: pxToRem(13)
57
57
  },
58
58
  body2: {
59
59
  lineHeight: 22 / 14,
60
- fontSize: pxToRem(11)
60
+ fontSize: pxToRem(11.5)
61
61
  },
62
62
  caption: {
63
63
  lineHeight: 1.5,
64
- fontSize: pxToRem(10)
64
+ fontSize: pxToRem(10.5)
65
65
  },
66
66
  overline: {
67
67
  fontWeight: 700,
68
68
  lineHeight: 1.5,
69
- fontSize: pxToRem(10)
69
+ fontSize: pxToRem(10.5)
70
70
  },
71
71
  button: {
72
72
  fontWeight: 700,
73
73
  lineHeight: 24 / 14,
74
- fontSize: pxToRem(12)
74
+ fontSize: pxToRem(12.5)
75
75
  }
76
76
  };
77
77
  export default typography;
@@ -1 +1 @@
1
- {"version":3,"file":"typography.js","sourceRoot":"","sources":["../../src/theme/typography.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,MAAM,UAAU,OAAO,CAAC,KAAa;IACnC,OAAO,GAAG,KAAK,GAAG,EAAE,KAAK,CAAC;AAC5B,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,KAA6C;IAC/E,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,KAAK,CAAC;IAC7B,OAAO;QACL,0BAA0B,EAAE;YAC1B,QAAQ,EAAE,OAAO,CAAC,EAAE,CAAC;SACtB;QACD,0BAA0B,EAAE;YAC1B,QAAQ,EAAE,OAAO,CAAC,EAAE,CAAC;SACtB;QACD,2BAA2B,EAAE;YAC3B,QAAQ,EAAE,OAAO,CAAC,EAAE,CAAC;SACtB;KACF,CAAC;AACJ,CAAC;AAED,yEAAyE;AAEzE,MAAM,UAAU,GAAG;IACjB,UAAU,EAAE,CAAC,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,OAAO,EAAE,kBAAkB,EAAE,WAAW,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;IACjG,iBAAiB,EAAE,GAAG;IACtB,EAAE,kBACA,UAAU,EAAE,GAAG,EACf,UAAU,EAAE,EAAE,GAAG,EAAE,EACnB,QAAQ,EAAE,OAAO,CAAC,EAAE,CAAC,IAClB,mBAAmB,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CACnD;IACD,EAAE,kBACA,UAAU,EAAE,GAAG,EACf,UAAU,EAAE,EAAE,GAAG,EAAE,EACnB,QAAQ,EAAE,OAAO,CAAC,EAAE,CAAC,IAClB,mBAAmB,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,E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EAAE,EAAE,EAAE,EAAE,CAAC,CACnD;IACD,SAAS,EAAE;QACT,UAAU,EAAE,GAAG;QACf,UAAU,EAAE,GAAG;QACf,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC;KACxB;IACD,SAAS,EAAE;QACT,UAAU,EAAE,GAAG;QACf,UAAU,EAAE,EAAE,GAAG,EAAE;QACnB,QAAQ,EAAE,OAAO,CAAC,EAAE,CAAC;KACtB;IACD,KAAK,EAAE;QACL,UAAU,EAAE,GAAG;QACf,QAAQ,EAAE,OAAO,CAAC,EAAE,CAAC;KACtB;IACD,KAAK,EAAE;QACL,UAAU,EAAE,EAAE,GAAG,EAAE;QACnB,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC;KACxB;IACD,OAAO,EAAE;QACP,UAAU,EAAE,GAAG;QACf,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC;KACxB;IACD,QAAQ,EAAE;QACR,UAAU,EAAE,GAAG;QACf,UAAU,EAAE,GAAG;QACf,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC;KACxB;IACD,MAAM,EAAE;QACN,UAAU,EAAE,GAAG;QACf,UAAU,EAAE,EAAE,GAAG,EAAE;QACnB,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC;KACxB;CACF,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -1,13 +1,3 @@
1
- import type { Extension, Questionnaire } from 'fhir/r4';
2
- import type { LaunchContext, QuestionnaireLevelXFhirQueryVariable, SourceQuery } from '../interfaces/populate.interface';
3
- export declare function getLaunchContexts(questionnaire: Questionnaire): LaunchContext[];
1
+ import type { Extension } from 'fhir/r4';
2
+ import type { LaunchContext } from '../interfaces/populate.interface';
4
3
  export declare function isLaunchContext(extension: Extension): extension is LaunchContext;
5
- export declare function getSourceQueries(questionnaire: Questionnaire): SourceQuery[];
6
- export declare function isSourceQuery(extension: Extension): extension is SourceQuery;
7
- /**
8
- * Filter x-fhir-query variables from questionnaire's extensions needed for population
9
- *
10
- * @author Sean Fong
11
- */
12
- export declare function getQuestionnaireLevelXFhirQueryVariables(questionnaire: Questionnaire): QuestionnaireLevelXFhirQueryVariable[];
13
- export declare function isXFhirQueryVariable(extension: Extension): extension is QuestionnaireLevelXFhirQueryVariable;
@@ -14,12 +14,6 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
- export function getLaunchContexts(questionnaire) {
18
- if (questionnaire.extension && questionnaire.extension.length > 0) {
19
- return questionnaire.extension.filter((extension) => isLaunchContext(extension));
20
- }
21
- return [];
22
- }
23
17
  export function isLaunchContext(extension) {
24
18
  var _a, _b;
25
19
  const hasLaunchContextName = extension.url ===
@@ -43,34 +37,4 @@ export function isLaunchContext(extension) {
43
37
  hasLaunchContextName &&
44
38
  hasLaunchContextType);
45
39
  }
46
- // get source query references
47
- export function getSourceQueries(questionnaire) {
48
- if (questionnaire.extension && questionnaire.extension.length > 0) {
49
- return questionnaire.extension.filter((extension) => isSourceQuery(extension));
50
- }
51
- return [];
52
- }
53
- export function isSourceQuery(extension) {
54
- return (extension.url ===
55
- 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-sourceQueries' &&
56
- !!extension.valueReference);
57
- }
58
- /**
59
- * Filter x-fhir-query variables from questionnaire's extensions needed for population
60
- *
61
- * @author Sean Fong
62
- */
63
- export function getQuestionnaireLevelXFhirQueryVariables(questionnaire) {
64
- if (questionnaire.extension && questionnaire.extension.length > 0) {
65
- return questionnaire.extension.filter((extension) => isXFhirQueryVariable(extension));
66
- }
67
- return [];
68
- }
69
- export function isXFhirQueryVariable(extension) {
70
- var _a, _b, _c;
71
- return (extension.url === 'http://hl7.org/fhir/StructureDefinition/variable' &&
72
- !!((_a = extension.valueExpression) === null || _a === void 0 ? void 0 : _a.name) &&
73
- ((_b = extension.valueExpression) === null || _b === void 0 ? void 0 : _b.language) === 'application/x-fhir-query' &&
74
- !!((_c = extension.valueExpression) === null || _c === void 0 ? void 0 : _c.expression));
75
- }
76
40
  //# sourceMappingURL=populateContexts.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"populateContexts.js","sourceRoot":"","sources":["../../src/utils/populateContexts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AASH,MAAM,UAAU,iBAAiB,CAAC,aAA4B;IAC5D,IAAI,aAAa,CAAC,SAAS,IAAI,aAAa,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE;QACjE,OAAO,aAAa,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,EAAE,CAClD,eAAe,CAAC,SAAS,CAAC,CACR,CAAC;KACtB;IAED,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,SAAoB;;IAClD,MAAM,oBAAoB,GACxB,SAAS,CAAC,GAAG;QACX,gFAAgF;QAClF,CAAC,CAAC,CAAA,MAAA,SAAS,CAAC,SAAS,0CAAE,IAAI,CACzB,CAAC,GAAG,EAAE,EAAE,CACN,GAAG,CAAC,GAAG,KAAK,MAAM;YAClB,CAAC,GAAG,CAAC,OAAO;gBACV,CAAC,GAAG,CAAC,WAAW;oBACd,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,KAAK,SAAS;wBACjC,GAAG,CAAC,WAAW,CAAC,IAAI,KAAK,WAAW;wBACpC,GAAG,CAAC,WAAW,CAAC,IAAI,KAAK,UAAU;wBACnC,GAAG,CAAC,WAAW,CAAC,IAAI,KAAK,MAAM;wBAC/B,GAAG,CAAC,WAAW,CAAC,IAAI,KAAK,OAAO;wBAChC,GAAG,CAAC,WAAW,CAAC,IAAI,KAAK,eAAe,CAAC,CAAC,CAAC,CACpD,CAAA,CAAC;IAEJ,MAAM,oBAAoB,GAAG,CAAC,CAAC,CAAA,MAAA,SAAS,CAAC,SAAS,0CAAE,IAAI,CACtD,CAAC,GAAG,EAAE,EAAE,CACN,GAAG,CAAC,GAAG,KAAK,MAAM;QAClB,GAAG,CAAC,SAAS;QACb,CAAC,GAAG,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CAAE,UAAU,CAAA,CACxC,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"populateContexts.js","sourceRoot":"","sources":["../../src/utils/populateContexts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAKH,MAAM,UAAU,eAAe,CAAC,SAAoB;;IAClD,MAAM,oBAAoB,GACxB,SAAS,CAAC,GAAG;QACX,gFAAgF;QAClF,CAAC,CAAC,CAAA,MAAA,SAAS,CAAC,SAAS,0CAAE,IAAI,CACzB,CAAC,GAAG,EAAE,EAAE,CACN,GAAG,CAAC,GAAG,KAAK,MAAM;YAClB,CAAC,GAAG,CAAC,OAAO;gBACV,CAAC,GAAG,CAAC,WAAW;oBACd,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,KAAK,SAAS;wBACjC,GAAG,CAAC,WAAW,CAAC,IAAI,KAAK,WAAW;wBACpC,GAAG,CAAC,WAAW,CAAC,IAAI,KAAK,UAAU;wBACnC,GAAG,CAAC,WAAW,CAAC,IAAI,KAAK,MAAM;wBAC/B,GAAG,CAAC,WAAW,CAAC,IAAI,KAAK,OAAO;wBAChC,GAAG,CAAC,WAAW,CAAC,IAAI,KAAK,eAAe,CAAC,CAAC,CAAC,CACpD,CAAA,CAAC;IAEJ,MAAM,oBAAoB,GAAG,CAAC,CAAC,CAAA,MAAA,SAAS,CAAC,SAAS,0CAAE,IAAI,CACtD,CAAC,GAAG,EAAE,EAAE,CACN,GAAG,CAAC,GAAG,KAAK,MAAM;QAClB,GAAG,CAAC,SAAS;QACb,CAAC,GAAG,CAAC,SAAS,KAAK,SAAS;YAC1B,GAAG,CAAC,SAAS,KAAK,cAAc;YAChC,GAAG,CAAC,SAAS,KAAK,WAAW,CAAC,CACnC,CAAA,CAAC;IAEF,OAAO,CACL,SAAS,CAAC,GAAG;QACX,gFAAgF;QAClF,oBAAoB;QACpB,oBAAoB,CACrB,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aehrc/smart-forms-renderer",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
4
4
  "description": "FHIR Structured Data Captured (SDC) rendering engine for Smart Forms",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -25,17 +25,18 @@
25
25
  "dependencies": {
26
26
  "@aehrc/sdc-assemble": "^1.0.2",
27
27
  "@iconify/react": "^4.1.1",
28
- "@types/fhir": "^0.0.37",
28
+ "@types/fhir": "^0.0.38",
29
29
  "dayjs": "^1.11.10",
30
30
  "deep-diff": "^1.0.2",
31
31
  "fhirclient": "^2.5.2",
32
32
  "fhirpath": "^3.7.1",
33
- "html-react-parser": "^4.2.0",
33
+ "html-react-parser": "^5.0.3",
34
34
  "lodash.clonedeep": "^4.5.0",
35
35
  "lodash.debounce": "^4.0.8",
36
36
  "nanoid": "^5.0.1",
37
37
  "react-markdown": "^8.0.7",
38
- "zustand": "^4.4.1"
38
+ "zustand": "^4.4.1",
39
+ "moment": "^2.29.4"
39
40
  },
40
41
  "peerDependencies": {
41
42
  "@emotion/react": ">=11.11.0",
@@ -49,13 +50,13 @@
49
50
  "react-dom": ">=18.0.0"
50
51
  },
51
52
  "devDependencies": {
52
- "@babel/core": "^7.23.0",
53
+ "@babel/core": "^7.23.3",
53
54
  "@storybook/addon-essentials": "^7.4.6",
54
55
  "@storybook/addon-interactions": "^7.4.6",
55
- "@storybook/addon-links": "^7.4.0",
56
+ "@storybook/addon-links": "^7.5.2",
56
57
  "@storybook/addon-onboarding": "^1.0.8",
57
58
  "@storybook/addon-styling": "^1.3.7",
58
- "@storybook/blocks": "^7.4.0",
59
+ "@storybook/blocks": "^7.5.2",
59
60
  "@storybook/react": "^7.4.3",
60
61
  "@storybook/react-vite": "^7.4.5",
61
62
  "@storybook/testing-library": "^0.2.1",
@@ -63,10 +64,10 @@
63
64
  "@testing-library/react": "^14.0.0",
64
65
  "@testing-library/react-hooks": "^7.0.2",
65
66
  "@types/deep-diff": "^1.0.4",
66
- "@types/jest": "^29.5.5",
67
+ "@types/jest": "^29.5.7",
67
68
  "@types/lodash.debounce": "^4.0.7",
68
69
  "@types/lodash.clonedeep": "^4.5.7",
69
- "@types/react": "^18.2.18",
70
+ "@types/react": "^18.2.37",
70
71
  "@types/react-dom": "^18.2.9",
71
72
  "jest": "^29.7.0",
72
73
  "jest-environment-jsdom": "^29.7.0",
@@ -16,6 +16,7 @@
16
16
  */
17
17
 
18
18
  import React from 'react';
19
+ import ThemeProvider from '../../theme/Theme';
19
20
  import type { Questionnaire, QuestionnaireResponse } from 'fhir/r4';
20
21
  import useInitialiseRenderer from '../../hooks/useInitialiseRenderer';
21
22
  import Box from '@mui/material/Box';
@@ -25,7 +26,6 @@ import Typography from '@mui/material/Typography';
25
26
  import { QueryClientProvider } from '@tanstack/react-query';
26
27
  import useQueryClient from '../../hooks/useQueryClient';
27
28
  import BaseRenderer from './BaseRenderer';
28
- import ThemeProvider from '../../theme/Theme';
29
29
  import type Client from 'fhirclient/lib/Client';
30
30
 
31
31
  interface SmartFormsRendererProps {
@@ -34,6 +34,7 @@ interface SmartFormsRendererProps {
34
34
  additionalVariables?: Record<string, object>;
35
35
  terminologyServerUrl?: string;
36
36
  fhirClient?: Client;
37
+ // getResponseCallback: (response: QuestionnaireResponse) => void;
37
38
  }
38
39
 
39
40
  function SmartFormsRenderer(props: SmartFormsRendererProps) {
@@ -39,7 +39,8 @@ export default function CustomGlobalStyles() {
39
39
  },
40
40
  '#root': {
41
41
  width: '100%',
42
- height: '100%'
42
+ height: '100%',
43
+ textAlign: 'left'
43
44
  },
44
45
  input: {
45
46
  '&[type=number]': {
@@ -37,7 +37,7 @@ export function responsiveFontSizes(props: { sm: number; md: number; lg: number
37
37
  // ----------------------------------------------------------------------
38
38
 
39
39
  const typography = {
40
- fontFamily: ['Inter', 'sans-serif', 'Roboto', 'Arial', '"Helvetica Neue"', 'Helvetica'].join(','),
40
+ fontFamily: ['Inter', 'sans-serif', 'Helvetica', 'Arial', 'Roboto', '"Helvetica Neue"'].join(','),
41
41
  fontWeightRegular: 500,
42
42
  h1: {
43
43
  fontWeight: 800,
@@ -72,40 +72,40 @@ const typography = {
72
72
  h6: {
73
73
  fontWeight: 700,
74
74
  lineHeight: 28 / 18,
75
- fontSize: pxToRem(13),
75
+ fontSize: pxToRem(13.5),
76
76
  ...responsiveFontSizes({ sm: 14, md: 14, lg: 14 })
77
77
  },
78
78
  subtitle1: {
79
79
  fontWeight: 600,
80
80
  lineHeight: 1.5,
81
- fontSize: pxToRem(13)
81
+ fontSize: pxToRem(13.5)
82
82
  },
83
83
  subtitle2: {
84
84
  fontWeight: 600,
85
85
  lineHeight: 22 / 14,
86
- fontSize: pxToRem(11.5)
86
+ fontSize: pxToRem(12)
87
87
  },
88
88
  body1: {
89
89
  lineHeight: 1.5,
90
- fontSize: pxToRem(12.25)
90
+ fontSize: pxToRem(13)
91
91
  },
92
92
  body2: {
93
93
  lineHeight: 22 / 14,
94
- fontSize: pxToRem(11)
94
+ fontSize: pxToRem(11.5)
95
95
  },
96
96
  caption: {
97
97
  lineHeight: 1.5,
98
- fontSize: pxToRem(10)
98
+ fontSize: pxToRem(10.5)
99
99
  },
100
100
  overline: {
101
101
  fontWeight: 700,
102
102
  lineHeight: 1.5,
103
- fontSize: pxToRem(10)
103
+ fontSize: pxToRem(10.5)
104
104
  },
105
105
  button: {
106
106
  fontWeight: 700,
107
107
  lineHeight: 24 / 14,
108
- fontSize: pxToRem(12)
108
+ fontSize: pxToRem(12.5)
109
109
  }
110
110
  };
111
111
 
@@ -15,22 +15,8 @@
15
15
  * limitations under the License.
16
16
  */
17
17
 
18
- import type { Extension, Questionnaire } from 'fhir/r4';
19
- import type {
20
- LaunchContext,
21
- QuestionnaireLevelXFhirQueryVariable,
22
- SourceQuery
23
- } from '../interfaces/populate.interface';
24
-
25
- export function getLaunchContexts(questionnaire: Questionnaire): LaunchContext[] {
26
- if (questionnaire.extension && questionnaire.extension.length > 0) {
27
- return questionnaire.extension.filter((extension) =>
28
- isLaunchContext(extension)
29
- ) as LaunchContext[];
30
- }
31
-
32
- return [];
33
- }
18
+ import type { Extension } from 'fhir/r4';
19
+ import type { LaunchContext } from '../interfaces/populate.interface';
34
20
 
35
21
  export function isLaunchContext(extension: Extension): extension is LaunchContext {
36
22
  const hasLaunchContextName =
@@ -65,48 +51,3 @@ export function isLaunchContext(extension: Extension): extension is LaunchContex
65
51
  hasLaunchContextType
66
52
  );
67
53
  }
68
-
69
- // get source query references
70
- export function getSourceQueries(questionnaire: Questionnaire): SourceQuery[] {
71
- if (questionnaire.extension && questionnaire.extension.length > 0) {
72
- return questionnaire.extension.filter((extension) => isSourceQuery(extension)) as SourceQuery[];
73
- }
74
-
75
- return [];
76
- }
77
-
78
- export function isSourceQuery(extension: Extension): extension is SourceQuery {
79
- return (
80
- extension.url ===
81
- 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-sourceQueries' &&
82
- !!extension.valueReference
83
- );
84
- }
85
-
86
- /**
87
- * Filter x-fhir-query variables from questionnaire's extensions needed for population
88
- *
89
- * @author Sean Fong
90
- */
91
- export function getQuestionnaireLevelXFhirQueryVariables(
92
- questionnaire: Questionnaire
93
- ): QuestionnaireLevelXFhirQueryVariable[] {
94
- if (questionnaire.extension && questionnaire.extension.length > 0) {
95
- return questionnaire.extension.filter((extension) =>
96
- isXFhirQueryVariable(extension)
97
- ) as QuestionnaireLevelXFhirQueryVariable[];
98
- }
99
-
100
- return [];
101
- }
102
-
103
- export function isXFhirQueryVariable(
104
- extension: Extension
105
- ): extension is QuestionnaireLevelXFhirQueryVariable {
106
- return (
107
- extension.url === 'http://hl7.org/fhir/StructureDefinition/variable' &&
108
- !!extension.valueExpression?.name &&
109
- extension.valueExpression?.language === 'application/x-fhir-query' &&
110
- !!extension.valueExpression?.expression
111
- );
112
- }
@@ -1,242 +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
- // If none are specified, then the subject is unlimited.
19
- import type {
20
- Encounter,
21
- FhirResource,
22
- Parameters,
23
- ParametersParameter,
24
- Patient,
25
- Practitioner,
26
- Questionnaire,
27
- Reference
28
- } from 'fhir/r4';
29
- import type {
30
- LaunchContext,
31
- QuestionnaireLevelXFhirQueryVariable,
32
- SourceQuery
33
- } from '../interfaces/populate.interface';
34
-
35
- function createPatientSubject(questionnaire: Questionnaire, patient: Patient): Reference | null {
36
- const subjectTypes = questionnaire.subjectType;
37
-
38
- // If subjectTypes array is not empty AND "Patient" is not in the array, we cannot create a Patient subject reference.
39
- if (subjectTypes && subjectTypes.length > 0) {
40
- const patientSubject = subjectTypes.find((subject) => subject === 'Patient');
41
- if (!patientSubject) {
42
- return null;
43
- }
44
- }
45
-
46
- return {
47
- type: 'Patient',
48
- reference: 'Patient/' + patient.id
49
- };
50
- }
51
-
52
- function createCanonicalParam(canonicalUrl: string): ParametersParameter {
53
- return {
54
- name: 'canonical',
55
- valueString: canonicalUrl
56
- };
57
- }
58
-
59
- // setting local parameter as false as we are calling $populate with an NPM package, not a server
60
- // package doesn't contain any fhir resources to "know" the context from
61
- function createLocalParam(): ParametersParameter {
62
- return {
63
- name: 'local',
64
- valueBoolean: false
65
- };
66
- }
67
-
68
- function createLaunchContextParam(
69
- launchContext: LaunchContext,
70
- patient: Patient,
71
- user: Practitioner,
72
- encounter: Encounter | null
73
- ): ParametersParameter | null {
74
- const name = launchContext.extension[0].valueId ?? launchContext.extension[0].valueCoding?.code;
75
- if (!name) {
76
- return null;
77
- }
78
-
79
- // let resource :string
80
- const resourceType = launchContext.extension[1].valueCode;
81
- let resource: FhirResource | null;
82
- switch (resourceType) {
83
- case 'Patient':
84
- resource = patient;
85
- break;
86
- case 'Practitioner':
87
- resource = user;
88
- break;
89
- case 'Encounter':
90
- resource = encounter;
91
- break;
92
- default:
93
- return null;
94
- }
95
-
96
- if (!resource) {
97
- return null;
98
- }
99
-
100
- return {
101
- name: 'context',
102
- part: [
103
- {
104
- name: 'name',
105
- valueString: name
106
- },
107
- {
108
- name: 'content',
109
- resource: resource
110
- }
111
- ]
112
- };
113
- }
114
-
115
- function createSourceQueryParams(sourceQuery: SourceQuery, index: number): ParametersParameter {
116
- const reference = sourceQuery.valueReference.reference;
117
- if (reference && reference.startsWith('#')) {
118
- const containedReference = reference.slice(1);
119
- return {
120
- name: 'context',
121
- part: [
122
- {
123
- name: 'name',
124
- valueString: containedReference
125
- },
126
- {
127
- name: 'content',
128
- valueReference: sourceQuery.valueReference
129
- }
130
- ]
131
- };
132
- }
133
-
134
- // if sourceQuery cannot be referenced to a contained bundle, return itself as a context
135
- // this most likely shouldn't happen
136
- return {
137
- name: 'context',
138
- part: [
139
- {
140
- name: 'name',
141
- valueString: `sourceQuery${index}`
142
- },
143
- {
144
- name: 'content',
145
- valueReference: sourceQuery.valueReference
146
- }
147
- ]
148
- };
149
- }
150
-
151
- function createVariableParam(variable: QuestionnaireLevelXFhirQueryVariable): ParametersParameter {
152
- const query = variable.valueExpression.expression;
153
- const resourceType = query.split('?')[0];
154
-
155
- return {
156
- name: 'context',
157
- part: [
158
- {
159
- name: 'name',
160
- valueString: variable.valueExpression.name
161
- },
162
- {
163
- name: 'content',
164
- valueReference: { reference: query, type: resourceType }
165
- }
166
- ]
167
- };
168
- }
169
-
170
- /**
171
- * Define population input parameters without any batch response contexts
172
- *
173
- * @author Sean Fong
174
- */
175
- export function createPopulateInputParameters(
176
- questionnaire: Questionnaire,
177
- patient: Patient,
178
- user: Practitioner,
179
- encounter: Encounter | null,
180
- launchContexts: LaunchContext[],
181
- sourceQueries: SourceQuery[],
182
- questionnaireLevelVariables: QuestionnaireLevelXFhirQueryVariable[]
183
- ): Parameters | null {
184
- const patientSubject = createPatientSubject(questionnaire, patient);
185
- if (!patientSubject) {
186
- return null;
187
- }
188
-
189
- const inputParameters: Parameters = {
190
- resourceType: 'Parameters',
191
- parameter: [
192
- {
193
- name: 'questionnaire',
194
- resource: questionnaire
195
- },
196
- {
197
- name: 'subject',
198
- valueReference: patientSubject
199
- }
200
- ]
201
- };
202
-
203
- // canonical
204
- if (questionnaire.url) {
205
- inputParameters.parameter?.push(createCanonicalParam(questionnaire.url));
206
- }
207
-
208
- // contexts
209
- const contexts: ParametersParameter[] = [];
210
- // add launch contexts
211
- if (launchContexts.length > 0) {
212
- for (const launchContext of launchContexts) {
213
- const launchContextParam = createLaunchContextParam(launchContext, patient, user, encounter);
214
- if (launchContextParam) {
215
- contexts.push(launchContextParam);
216
- }
217
- }
218
- }
219
-
220
- // add source queries
221
- if (sourceQueries.length > 0) {
222
- for (const [index, sourceQuery] of sourceQueries.entries()) {
223
- contexts.push(createSourceQueryParams(sourceQuery, index));
224
- }
225
- }
226
-
227
- // add questionnaire-level variables
228
- if (questionnaireLevelVariables.length > 0) {
229
- for (const variable of questionnaireLevelVariables) {
230
- contexts.push(createVariableParam(variable));
231
- }
232
- }
233
-
234
- if (contexts.length > 0) {
235
- inputParameters.parameter?.push(...contexts);
236
- }
237
-
238
- // local
239
- inputParameters.parameter?.push(createLocalParam());
240
-
241
- return inputParameters;
242
- }