diff --git a/README.md b/README.md index 76223a9d7..bbec01e4d 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,9 @@ -

Smart Forms

An open source FHIR powered forms app built in React

Powered by SMART on FHIR and Structured Data Capture, Smart Forms allow you to easily integrate forms into your existing healthcare system.

Show me the app ➡️

-
-
--- Smart Forms is a Typescript-based [React](https://reactjs.org/) forms web application currently ongoing development by [CSIRO's Australian e-Health Research Centre](https://aehrc.csiro.au/) as part of the Primary Care Data Quality project funded by the Australian Government Department of Health. @@ -14,6 +11,10 @@ Smart Forms is a Typescript-based [React](https://reactjs.org/) forms web applic The web app is intended to demonstrate the use of [HL7 FHIR](https://hl7.org/fhir/) specifications, such as the [Questionnaire](https://hl7.org/fhir/questionnaire.html) and [QuestionnaireResponse](https://hl7.org/fhir/questionnaireresponse.html) resources, the Structured Data Capture (SDC) implementation guide, and most notably it leverages [SMART on FHIR capabilities](https://hl7.org/fhir/smart-app-launch/index.html) that allows the app to be launched by a primary care Clinical Management System (CMS) and capture standardised health check information for healthcare clients. This project was bootstrapped with [Vite](https://vitejs.dev/). +
+ +**If you are interested in using the rendering engine in your projects, a standalone package is published on NPM as [@aehrc/smart-forms-renderer](https://www.npmjs.com/package/@aehrc/smart-forms-renderer).** +**Try out the standalone package here: https://www.smartforms.io/standalone** ## Functionalities diff --git a/apps/smart-forms-app/package.json b/apps/smart-forms-app/package.json index ab7d14fcd..44bf4f966 100644 --- a/apps/smart-forms-app/package.json +++ b/apps/smart-forms-app/package.json @@ -1,8 +1,9 @@ { - "name": "smart-forms-app", + "name": "@aehrc/smart-forms-app", "private": true, - "version": "0.1.0", + "version": "0.2.0", "type": "module", + "description": "Typescript-based React web application implementing FHIR Structured Data Captured (SDC) specification", "scripts": { "dev": "vite", "start": "vite", @@ -13,8 +14,18 @@ "storybook": "storybook dev -p 6006", "build-storybook": "storybook build" }, + "repository": { + "type": "git", + "url": "git+https://github.com/aehrc/smart-forms.git" + }, + "author": "Sean Fong", + "license": "Apache-2.0", + "bugs": { + "url": "https://github.com/aehrc/smart-forms/issues" + }, + "homepage": "https://github.com/aehrc/smart-forms#readme", "dependencies": { - "@aehrc/smart-forms-renderer": "^0.6.1", + "@aehrc/smart-forms-renderer": "^0.6.6", "@emotion/react": "^11.11.1", "@emotion/styled": "^11.10.8", "@fontsource/material-icons": "^5.0.7", @@ -55,8 +66,8 @@ "react-router-dom": "6.15.0", "react-spinners": "^0.13.8", "react-to-print": "^2.14.13", - "sdc-assemble": "^1.0.1", - "sdc-populate": "^1.0.2", + "@aehrc/sdc-assemble": "^1.0.2", + "@aehrc/sdc-populate": "^1.0.3", "simplebar-react": "^3.2.4", "usehooks-ts": "^2.9.1", "zustand": "^4.4.1" diff --git a/apps/smart-forms-app/src/features/prepopulate/api/requestPopulate.ts b/apps/smart-forms-app/src/features/prepopulate/api/requestPopulate.ts index d5a4bec71..8c5ff3e03 100644 --- a/apps/smart-forms-app/src/features/prepopulate/api/requestPopulate.ts +++ b/apps/smart-forms-app/src/features/prepopulate/api/requestPopulate.ts @@ -16,8 +16,8 @@ */ import { IS_IN_APP_POPULATE } from '../../../utils/env.ts'; -import type { InputParameters, OutputParameters } from 'sdc-populate'; -import { isOutputParameters, populate } from 'sdc-populate'; +import type { InputParameters, OutputParameters } from '@aehrc/sdc-populate'; +import { isOutputParameters, populate } from '@aehrc/sdc-populate'; import type { RequestConfig } from '../utils/callback.ts'; import { fetchResourceCallback } from '../utils/callback.ts'; import { HEADERS } from '../../../api/headers.ts'; diff --git a/apps/smart-forms-app/src/features/prepopulate/utils/callback.ts b/apps/smart-forms-app/src/features/prepopulate/utils/callback.ts index e06a17e32..c6d2271da 100644 --- a/apps/smart-forms-app/src/features/prepopulate/utils/callback.ts +++ b/apps/smart-forms-app/src/features/prepopulate/utils/callback.ts @@ -15,7 +15,7 @@ * limitations under the License. */ -import type { FetchResourceCallback } from 'sdc-populate'; +import type { FetchResourceCallback } from '@aehrc/sdc-populate'; import axios from 'axios'; const ABSOLUTE_URL_REGEX = /^(https?|ftp):\/\/[^\s/$.?#].[^\s]*$/; diff --git a/apps/smart-forms-app/src/features/prepopulate/utils/populate.ts b/apps/smart-forms-app/src/features/prepopulate/utils/populate.ts index 8b7e1548d..ba5a44570 100644 --- a/apps/smart-forms-app/src/features/prepopulate/utils/populate.ts +++ b/apps/smart-forms-app/src/features/prepopulate/utils/populate.ts @@ -27,8 +27,8 @@ import { getQuestionnaireLevelXFhirQueryVariables, getSourceQueries } from './getExtensions.ts'; -import type { IssuesParameter, ResponseParameter } from 'sdc-populate'; -import { isInputParameters } from 'sdc-populate'; +import type { IssuesParameter, ResponseParameter } from '@aehrc/sdc-populate'; +import { isInputParameters } from '@aehrc/sdc-populate'; import type Client from 'fhirclient/lib/Client'; import { createPopulateInputParameters } from './createInputParameters.ts'; import { requestPopulate } from '../api/requestPopulate.ts'; diff --git a/apps/smart-forms-app/src/features/standalone/components/Standalone.tsx b/apps/smart-forms-app/src/features/standalone/components/Standalone.tsx index c45cda7a9..d15444f1d 100644 --- a/apps/smart-forms-app/src/features/standalone/components/Standalone.tsx +++ b/apps/smart-forms-app/src/features/standalone/components/Standalone.tsx @@ -24,6 +24,8 @@ import QCVDRiskJson from '../data/QCVDRisk.json'; import RCVDRiskJson from '../data/RCVDRisk.json'; import type { Questionnaire, QuestionnaireResponse } from 'fhir/r4'; import { + Box, + Button, Checkbox, Container, FormControl, @@ -39,7 +41,7 @@ import type { RendererPropsActions, RendererPropsState } from '../interfaces/standalone.interface.ts'; -import { SmartFormsRenderer } from '@aehrc/smart-forms-renderer'; +import { getResponse, SmartFormsRenderer } from '@aehrc/smart-forms-renderer'; const rendererPropsReducer = (state: RendererPropsState, action: RendererPropsActions) => { switch (action.type) { @@ -124,46 +126,49 @@ function Standalone() { return ( - - - } - label="Questionnaire" - /> - { - dispatch({ - type: 'SET_RESPONSE', - payload: state.response ? null : resource.response - }); - }} - /> - } - label="Questionnaire response" - /> - {resource.additionalVars ? ( + + + + } + label="Questionnaire" + /> { dispatch({ - type: 'SET_ADDITIONAL_VARS', - payload: state.additionalVars ? null : resource.additionalVars + type: 'SET_RESPONSE', + payload: state.response ? null : resource.response }); }} /> } - label="Additional variables" + label="Questionnaire response" /> - ) : null} - - + {resource.additionalVars ? ( + { + dispatch({ + type: 'SET_ADDITIONAL_VARS', + payload: state.additionalVars ? null : resource.additionalVars + }); + }} + /> + } + label="Additional variables" + /> + ) : null} + + + + =8" + } + }, + "node_modules/aws-cdk-lib/node_modules/ansi-styles": { + "version": "4.3.0", + "inBundle": true, + "license": "MIT", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/aws-cdk-lib/node_modules/astral-regex": { + "version": "2.0.0", + "inBundle": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/aws-cdk-lib/node_modules/balanced-match": { + "version": "1.0.2", + "inBundle": true, + "license": "MIT" + }, + "node_modules/aws-cdk-lib/node_modules/brace-expansion": { + "version": "1.1.11", + "inBundle": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/aws-cdk-lib/node_modules/case": { + "version": "1.6.3", + "inBundle": true, + "license": "(MIT OR GPL-3.0-or-later)", + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/aws-cdk-lib/node_modules/color-convert": { + "version": "2.0.1", + "inBundle": true, + "license": "MIT", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/aws-cdk-lib/node_modules/color-name": { + "version": "1.1.4", + "inBundle": true, + "license": "MIT" + }, + "node_modules/aws-cdk-lib/node_modules/concat-map": { + "version": "0.0.1", + "inBundle": true, + "license": "MIT" + }, + "node_modules/aws-cdk-lib/node_modules/emoji-regex": { + "version": "8.0.0", + "inBundle": true, + "license": "MIT" + }, + "node_modules/aws-cdk-lib/node_modules/fast-deep-equal": { + "version": "3.1.3", + "inBundle": true, + "license": "MIT" + }, + "node_modules/aws-cdk-lib/node_modules/fs-extra": { + "version": "11.1.1", + "inBundle": true, + "license": "MIT", + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "engines": { + "node": ">=14.14" + } + }, + "node_modules/aws-cdk-lib/node_modules/graceful-fs": { + "version": "4.2.11", + "inBundle": true, + "license": "ISC" + }, + "node_modules/aws-cdk-lib/node_modules/ignore": { + "version": "5.2.4", + "inBundle": true, + "license": "MIT", + "engines": { + "node": ">= 4" + } + }, + "node_modules/aws-cdk-lib/node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "inBundle": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/aws-cdk-lib/node_modules/json-schema-traverse": { + "version": "1.0.0", + "inBundle": true, + "license": "MIT" + }, + "node_modules/aws-cdk-lib/node_modules/jsonfile": { + "version": "6.1.0", + "inBundle": true, + "license": "MIT", + "dependencies": { + "universalify": "^2.0.0" + }, + "optionalDependencies": { + "graceful-fs": "^4.1.6" + } + }, + "node_modules/aws-cdk-lib/node_modules/jsonschema": { + "version": "1.4.1", + "inBundle": true, + "license": "MIT", + "engines": { + "node": "*" + } + }, + "node_modules/aws-cdk-lib/node_modules/lodash.truncate": { + "version": "4.4.2", + "inBundle": true, + "license": "MIT" + }, + "node_modules/aws-cdk-lib/node_modules/lru-cache": { + "version": "6.0.0", + "inBundle": true, + "license": "ISC", + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/aws-cdk-lib/node_modules/minimatch": { + "version": "3.1.2", + "inBundle": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/aws-cdk-lib/node_modules/punycode": { + "version": "2.3.0", + "inBundle": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/aws-cdk-lib/node_modules/require-from-string": { + "version": "2.0.2", + "inBundle": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/aws-cdk-lib/node_modules/semver": { + "version": "7.5.4", + "inBundle": true, + "license": "ISC", + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/aws-cdk-lib/node_modules/slice-ansi": { + "version": "4.0.0", + "inBundle": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.0.0", + "astral-regex": "^2.0.0", + "is-fullwidth-code-point": "^3.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/slice-ansi?sponsor=1" + } + }, + "node_modules/aws-cdk-lib/node_modules/string-width": { + "version": "4.2.3", + "inBundle": true, + "license": "MIT", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/aws-cdk-lib/node_modules/strip-ansi": { + "version": "6.0.1", + "inBundle": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/aws-cdk-lib/node_modules/table": { + "version": "6.8.1", + "inBundle": true, + "license": "BSD-3-Clause", + "dependencies": { + "ajv": "^8.0.1", + "lodash.truncate": "^4.4.2", + "slice-ansi": "^4.0.0", + "string-width": "^4.2.3", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=10.0.0" + } + }, + "node_modules/aws-cdk-lib/node_modules/universalify": { + "version": "2.0.0", + "inBundle": true, + "license": "MIT", + "engines": { + "node": ">= 10.0.0" + } + }, + "node_modules/aws-cdk-lib/node_modules/uri-js": { + "version": "4.4.1", + "inBundle": true, + "license": "BSD-2-Clause", + "dependencies": { + "punycode": "^2.1.0" + } + }, + "node_modules/aws-cdk-lib/node_modules/yallist": { + "version": "4.0.0", + "inBundle": true, + "license": "ISC" + }, + "node_modules/aws-cdk-lib/node_modules/yaml": { + "version": "1.10.2", + "inBundle": true, + "license": "ISC", + "engines": { + "node": ">= 6" + } + }, "node_modules/aws-cdk/node_modules/fsevents": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", @@ -12888,7 +13204,8 @@ "node_modules/balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "devOptional": true }, "node_modules/base-64": { "version": "0.1.0", @@ -13084,6 +13401,7 @@ "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "devOptional": true, "dependencies": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -13970,7 +14288,8 @@ "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "devOptional": true }, "node_modules/concat-stream": { "version": "1.6.2", @@ -17410,6 +17729,7 @@ "version": "11.1.1", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.1.1.tgz", "integrity": "sha512-MGIE4HOvQCeUCzmlHs0vXpih4ysz4wg9qiSAu6cd42lVwPbTM1TjV7RusoyQqMmk/95gdQZX72u+YW+c3eEpFQ==", + "dev": true, "dependencies": { "graceful-fs": "^4.2.0", "jsonfile": "^6.0.1", @@ -17423,6 +17743,7 @@ "version": "6.1.0", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", + "dev": true, "dependencies": { "universalify": "^2.0.0" }, @@ -17809,7 +18130,8 @@ "node_modules/graceful-fs": { "version": "4.2.11", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", - "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==" + "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", + "devOptional": true }, "node_modules/graphemer": { "version": "1.4.0", @@ -18259,6 +18581,7 @@ "version": "5.2.4", "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.4.tgz", "integrity": "sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ==", + "devOptional": true, "engines": { "node": ">= 4" } @@ -23396,6 +23719,7 @@ "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "devOptional": true, "dependencies": { "brace-expansion": "^1.1.7" }, @@ -25351,6 +25675,7 @@ "version": "2.3.0", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.0.tgz", "integrity": "sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==", + "dev": true, "engines": { "node": ">=6" } @@ -27276,18 +27601,11 @@ "url": "https://opencollective.com/webpack" } }, - "node_modules/sdc-assemble": { - "resolved": "packages/sdc-assemble", - "link": true - }, - "node_modules/sdc-populate": { - "resolved": "packages/sdc-populate", - "link": true - }, "node_modules/semver": { "version": "6.3.1", "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "devOptional": true, "bin": { "semver": "bin/semver.js" } @@ -27639,10 +27957,6 @@ "node": ">=8.0.0" } }, - "node_modules/smart-forms-app": { - "resolved": "apps/smart-forms-app", - "link": true - }, "node_modules/source-map": { "version": "0.5.7", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", @@ -29597,6 +29911,7 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==", + "devOptional": true, "engines": { "node": ">= 10.0.0" } @@ -30678,8 +30993,9 @@ } }, "packages/sdc-assemble": { - "version": "1.0.1", - "license": "ISC", + "name": "@aehrc/sdc-assemble", + "version": "1.0.2", + "license": "Apache-2.0", "dependencies": { "axios": "^1.5.0", "lodash.clonedeep": "^4.5.0" @@ -30690,8 +31006,9 @@ } }, "packages/sdc-populate": { - "version": "1.0.2", - "license": "ISC", + "name": "@aehrc/sdc-populate", + "version": "1.0.3", + "license": "Apache-2.0", "dependencies": { "dayjs": "^1.11.9", "fhirclient": "^2.5.2", @@ -30708,8 +31025,10 @@ }, "packages/smart-forms-renderer": { "name": "@aehrc/smart-forms-renderer", - "version": "0.6.1", + "version": "0.6.6", + "license": "Apache-2.0", "dependencies": { + "@aehrc/sdc-assemble": "^1.0.2", "@iconify/react": "^4.1.1", "@types/fhir": "^0.0.37", "dayjs": "^1.11.9", @@ -30720,7 +31039,6 @@ "lodash.debounce": "^4.0.8", "nanoid": "^4.0.2", "react-markdown": "^8.0.7", - "sdc-assemble": "^1.0.1", "zustand": "^4.4.1" }, "devDependencies": { @@ -30765,9 +31083,9 @@ "version": "1.0.1", "license": "ISC", "dependencies": { + "@aehrc/sdc-assemble": "^1.0.2", "cors": "^2.8.5", - "express": "^4.18.2", - "sdc-assemble": "^1.0.1" + "express": "^4.18.2" }, "devDependencies": { "@types/cors": "^2.8.13", @@ -30780,8 +31098,8 @@ "version": "1.0.1", "license": "ISC", "dependencies": { - "express": "^4.18.2", - "sdc-populate": "^1.0.2" + "@aehrc/sdc-populate": "^1.0.3", + "express": "^4.18.2" } } } diff --git a/packages/sdc-assemble/package.json b/packages/sdc-assemble/package.json index 80330da7e..0076b6bbe 100644 --- a/packages/sdc-assemble/package.json +++ b/packages/sdc-assemble/package.json @@ -1,16 +1,24 @@ { - "name": "sdc-assemble", - "version": "1.0.1", - "description": "Performs the $assemble operation for modular forms from the SDC (Structured Data Capture) Specification of HL7 FHIR: http://hl7.org/fhir/uv/sdc/modular.html", + "name": "@aehrc/sdc-assemble", + "version": "1.0.2", + "description": "Performs the $assemble operation for modular forms from the HL7 FHIR SDC (Structured Data Capture) specification: http://hl7.org/fhir/uv/sdc/modular.html", "main": "lib/index.js", "scripts": { - "prepare": "npm run compile", "compile": "tsc", "watch": "tsc -w", + "prepare": "npm run compile", "test": "echo \"Error: no test specified\" && exit 1" }, + "repository": { + "type": "git", + "url": "git+https://github.com/aehrc/smart-forms.git" + }, "author": "Sean Fong", - "license": "ISC", + "license": "Apache-2.0", + "bugs": { + "url": "https://github.com/aehrc/smart-forms/issues" + }, + "homepage": "https://github.com/aehrc/smart-forms#readme", "dependencies": { "axios": "^1.5.0", "lodash.clonedeep": "^4.5.0" diff --git a/packages/sdc-populate/package.json b/packages/sdc-populate/package.json index b07e31858..3a018b568 100644 --- a/packages/sdc-populate/package.json +++ b/packages/sdc-populate/package.json @@ -1,16 +1,24 @@ { - "name": "sdc-populate", - "version": "1.0.2", - "description": "Performs the $populate operation from the SDC (Structured Data Capture) Specification of HL7 FHIR: http://hl7.org/fhir/uv/sdc/", + "name": "@aehrc/sdc-populate", + "version": "1.0.3", + "description": "Performs the $populate operation from the HL7 FHIR SDC (Structured Data Capture) specification: http://hl7.org/fhir/uv/sdc", "main": "lib/index.js", "scripts": { - "prepare": "npm run compile", "compile": "tsc", "watch": "tsc -w", + "prepare": "npm run compile", "test": "jest --config ./jest.config.ts" }, + "repository": { + "type": "git", + "url": "git+https://github.com/aehrc/smart-forms.git" + }, "author": "Sean Fong", - "license": "ISC", + "license": "Apache-2.0", + "bugs": { + "url": "https://github.com/aehrc/smart-forms/issues" + }, + "homepage": "https://github.com/aehrc/smart-forms#readme", "dependencies": { "dayjs": "^1.11.9", "moment": "^2.29.4", diff --git a/packages/smart-forms-renderer/README.md b/packages/smart-forms-renderer/README.md new file mode 100644 index 000000000..7da28baa7 --- /dev/null +++ b/packages/smart-forms-renderer/README.md @@ -0,0 +1,104 @@ +# Smart Forms Renderer +This React-based package acts as the rendering engine for the [Smart Forms app](https://github.com/aehrc/smart-forms). + +## Installation +```bash +npm install @aehrc/smart-forms-renderer +``` + +## Basic Usage + +```typescript jsx +import React from 'react'; +import { SmartFormsRenderer, getResponse } from 'aehrc/smart-forms-renderer'; + +export default function App () { + const questionnaire = {...} // FHIR R4.Questionnaire + + return ( +
+ +
+ ) +} + +``` +### SmartFormsRenderer Props + + +| Name | Type | Description | Required? | +|-----------------------|------------------------------------------------------|------------------------------------------------------------------------------------------------|-----------| +| questionnaire | FHIR R4.Questionnaire | Questionnaire to be rendered | Required | +| questionnaireResponse | FHIR R4.QuestionnaireResponse | Pre-populated QuestionnaireResponse to be rendered | Optional | +| additionalVariables | Record | Key-value pair of [SDC variables](http://hl7.org/fhir/R4/extension-variable.html) | Optional | + +The below props are not supported at the moment, but will be in the future. + +| Name | Type | Description | +|----------------------|------------------------------------------------------|---------------------------------------------| +| fhirClient | [Client](https://github.com/smart-on-fhir/client-js) | FhirClient to perform further FHIR calls | +| terminologyServerUrl | string | Terminology server url to fetch terminology | + +### Functions + +```javascript +/** + * Get the filled QuestionnaireResponse at its current state. + * If no changes have been made to the form, the initial or an empty QuestionnaireResponse is returned. + * + * @returns {FHIR R4.QuestionnaireResponse} The filled QuestionnaireResponse + */ +function getResponse() {} +``` + + +## Advanced Usage (If basic usage does not suffice) + +```typescript +/* Components */ +// A self-initialising wrapper around the rendering engine. This is sufficient for most use cases. + +function SmartFormsRenderer(props: { + questionnaire: Questionnaire, + questionnaireResponse?: QuestionnaireResponse, + additionalVariables?: Record +}): JSX.Element {} + +// BaseRenderer underneath the SmartFormsRenderer wrapper. Requires buildForm() to initialise form. +function BaseRenderer(): JSX.Element {} + +/* Functions */ +// Get the filled QuestionnaireResponse at its current state. +// If no changes have been made to the form, the initial QuestionnaireResponse is returned. +function getResponse(): QuestionnaireResponse {} + +// Build the form with an initial Questionnaire and an optional filled QuestionnaireResponse. +// If a QuestionnaireResponse is not provided, an empty QuestionnaireResponse is set as the initial QuestionnaireResponse. +async function buildForm( + questionnaire: Questionnaire, + questionnaireResponse?: QuestionnaireResponse +): Promise {} + +// Destroy the form to clean up the questionnaire and questionnaireResponse stores. +function destroyForm(): void {} + +// Remove all hidden answers from the filled QuestionnaireResponse. +// This takes into account the questionnaire-hidden extension, enableWhens and enableWhenExpressions. +function removeHiddenAnswersFromResponse( + questionnaire: Questionnaire, + questionnaireResponse: QuestionnaireResponse +): QuestionnaireResponse {} +``` + +The Smart Forms app uses a even finer-grained control which directly interacts with the state management stores. + +At the moment there are no plans to document it, but I am happy to do so if there is demand for it. +Raise a request in https://github.com/aehrc/smart-forms/issues if you want to see it happen! + +--- + +Copyright © 2022, Commonwealth Scientific and Industrial Research Organisation (CSIRO) ABN 41 687 119 230. All rights reserved. \ No newline at end of file diff --git a/packages/smart-forms-renderer/package.json b/packages/smart-forms-renderer/package.json index 687146eaf..26d6c7b78 100644 --- a/packages/smart-forms-renderer/package.json +++ b/packages/smart-forms-renderer/package.json @@ -1,16 +1,27 @@ { "name": "@aehrc/smart-forms-renderer", - "version": "0.6.1", + "version": "0.6.6", + "description": "FHIR Structured Data Captured (SDC) rendering engine for Smart Forms", "main": "lib/index.js", "scripts": { "compile": "tsc", - "build:watch": "tsc --watch", + "compile:watch": "tsc -w", "prepare": "npm run compile", "test": "jest", "test:watch": "jest --watch", "storybook": "storybook dev -p 6006", "build-storybook": "storybook build" }, + "repository": { + "type": "git", + "url": "git+https://github.com/aehrc/smart-forms.git" + }, + "author": "Sean Fong", + "license": "Apache-2.0", + "bugs": { + "url": "https://github.com/aehrc/smart-forms/issues" + }, + "homepage": "https://github.com/aehrc/smart-forms#readme", "dependencies": { "@iconify/react": "^4.1.1", "dayjs": "^1.11.9", @@ -23,7 +34,7 @@ "@types/fhir": "^0.0.37", "zustand": "^4.4.1", "react-markdown": "^8.0.7", - "sdc-assemble": "^1.0.1" + "@aehrc/sdc-assemble": "^1.0.2" }, "peerDependencies": { "@emotion/react": ">=11.11.0", diff --git a/packages/smart-forms-renderer/src/hooks/index.ts b/packages/smart-forms-renderer/src/hooks/index.ts deleted file mode 100644 index 1e42a480c..000000000 --- a/packages/smart-forms-renderer/src/hooks/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default as useHidden } from './useHidden'; diff --git a/packages/smart-forms-renderer/src/index.ts b/packages/smart-forms-renderer/src/index.ts index c59301a84..6aa34a9d1 100644 --- a/packages/smart-forms-renderer/src/index.ts +++ b/packages/smart-forms-renderer/src/index.ts @@ -5,7 +5,6 @@ import useQuestionnaireResponseStore from './stores/useQuestionnaireResponseStor import { removeHiddenAnswers } from './utils/removeHidden'; export * from './components'; -export * from './hooks'; export * from './stores'; /** @@ -47,7 +46,7 @@ export function destroyForm(): void { * * @author Sean Fong */ -export function getUpdatableResponse(): QuestionnaireResponse { +export function getResponse(): QuestionnaireResponse { return useQuestionnaireResponseStore.getState().updatableResponse; } diff --git a/packages/smart-forms-renderer/src/interfaces/questionnaireStore.interface.ts b/packages/smart-forms-renderer/src/interfaces/questionnaireStore.interface.ts index 7b25eabc2..a806e0882 100644 --- a/packages/smart-forms-renderer/src/interfaces/questionnaireStore.interface.ts +++ b/packages/smart-forms-renderer/src/interfaces/questionnaireStore.interface.ts @@ -15,7 +15,7 @@ * limitations under the License. */ -import type { Tabs } from 'smart-forms-app/src/features/renderer/types/tab.interface'; +import type { Tabs } from './tab.interface'; import type { Variables } from './variables.interface'; import type { LaunchContext } from './populate.interface'; import type { EnableWhenExpression, EnableWhenItemProperties } from './enableWhen.interface'; diff --git a/packages/smart-forms-renderer/src/utils/removeHidden.ts b/packages/smart-forms-renderer/src/utils/removeHidden.ts index e0c421499..69ac7fe12 100644 --- a/packages/smart-forms-renderer/src/utils/removeHidden.ts +++ b/packages/smart-forms-renderer/src/utils/removeHidden.ts @@ -21,10 +21,7 @@ import type { QuestionnaireResponse, QuestionnaireResponseItem } from 'fhir/r4'; -import type { - EnableWhenExpression, - EnableWhenItems -} from 'smart-forms-app/src/types/enableWhen.interface'; +import type { EnableWhenExpression, EnableWhenItems } from '../interfaces/enableWhen.interface'; import { isHidden } from './qItem'; interface removeHiddenAnswersParams { diff --git a/services/assemble-express/package.json b/services/assemble-express/package.json index 419490028..3efa315f2 100644 --- a/services/assemble-express/package.json +++ b/services/assemble-express/package.json @@ -12,7 +12,7 @@ "license": "ISC", "dependencies": { "express": "^4.18.2", - "sdc-assemble": "^1.0.1", + "@aehrc/sdc-assemble": "^1.0.2", "cors": "^2.8.5" }, "devDependencies": { diff --git a/services/assemble-express/src/callback.ts b/services/assemble-express/src/callback.ts index 177098d41..aad4e1d9b 100644 --- a/services/assemble-express/src/callback.ts +++ b/services/assemble-express/src/callback.ts @@ -16,7 +16,7 @@ */ import axios from 'axios'; -import type { FetchQuestionnaireCallback } from 'sdc-assemble'; +import type { FetchQuestionnaireCallback } from '@aehrc/sdc-assemble'; const FORMS_SERVER_ENDPOINT = 'https://api.smartforms.io/fhir'; diff --git a/services/assemble-express/src/index.ts b/services/assemble-express/src/index.ts index db710f463..8df357354 100644 --- a/services/assemble-express/src/index.ts +++ b/services/assemble-express/src/index.ts @@ -17,7 +17,7 @@ import express from 'express'; import cors from 'cors'; -import { assemble, isInputParameters } from 'sdc-assemble'; +import { assemble, isInputParameters } from '@aehrc/sdc-assemble'; import { fetchQuestionnaireCallback } from './callback'; const app = express(); diff --git a/services/populate-express/package.json b/services/populate-express/package.json index 757fe86e0..b93d355c2 100644 --- a/services/populate-express/package.json +++ b/services/populate-express/package.json @@ -12,6 +12,6 @@ "license": "ISC", "dependencies": { "express": "^4.18.2", - "sdc-populate": "^1.0.2" + "@aehrc/sdc-populate": "^1.0.3" } } diff --git a/services/populate-express/src/callback.ts b/services/populate-express/src/callback.ts index 85e8c1341..457ed6562 100644 --- a/services/populate-express/src/callback.ts +++ b/services/populate-express/src/callback.ts @@ -16,7 +16,7 @@ */ import axios from 'axios'; -import type { FetchResourceCallback } from 'sdc-populate'; +import type { FetchResourceCallback } from '@aehrc/sdc-populate'; import type { RequestConfig } from 'smart-forms-app/src/features/prepopulate/utils/callback'; const ABSOLUTE_URL_REGEX = /^(https?|ftp):\/\/[^\s/$.?#].[^\s]*$/; diff --git a/services/populate-express/src/index.ts b/services/populate-express/src/index.ts index ef1b17124..da763efc2 100644 --- a/services/populate-express/src/index.ts +++ b/services/populate-express/src/index.ts @@ -16,7 +16,7 @@ */ import express from 'express'; -import populate, { isPopulateInputParameters } from 'sdc-populate'; +import populate, { isPopulateInputParameters } from '@aehrc/sdc-populate'; import type { OperationOutcome } from 'fhir/r4'; const app = express();