|
| 1 | +## What is LForms? |
| 2 | + |
| 3 | +[LForms](http://lhncbc.github.io/lforms/), a.k.a. LHC-Forms, is a feature-rich, |
| 4 | +open-source Web Component that creates input forms, based on definition files, for |
| 5 | +Web-based applications. In addition to its native form-definition format, it |
| 6 | +partially supports the HL7 FHIR Questionnaire standard (SDC profile), and work |
| 7 | +is in progress to expand that support. |
| 8 | + |
| 9 | +It is being developed by the Lister Hill National Center for Biomedical |
| 10 | +Communications ([LHNCBC](https://lhncbc.nlm.nih.gov)), National Library of |
| 11 | +Medicine ([NLM](https://www.nlm.nih.gov)), part of the National Institutes of |
| 12 | +Health ([NIH](https://www.nih.gov)), with the collaboration and support from the |
| 13 | +[Regenstrief Institute](https://www.regenstrief.org/), Inc. and the |
| 14 | +[LOINC](https://loinc.org/) Committee. |
| 15 | + |
| 16 | +For features and demos, please visit the [project |
| 17 | +page](http://lhncbc.github.io/lforms/). |
| 18 | + |
| 19 | +## Licensing and Copyright Notice |
| 20 | +See [LICENSE.md](LICENSE.md). |
| 21 | + |
| 22 | +## Customizing and Contributing |
| 23 | +If you wish to revise this package, the following steps will allow you to make |
| 24 | +changes and test them: |
| 25 | + |
| 26 | +* Install Node.js (version 14 is what we are currently using, but it should work with later versions) |
| 27 | +* Clone the lforms repository and cd to its directory |
| 28 | +* `source bashrc.lforms` (make sure node dir is available at ~/) |
| 29 | +* `npm ci` |
| 30 | +* `source bashrc.lforms` # to add node_modules/.bin to your path |
| 31 | +* `npm run build` # build both FHIR libs and LHC-Forms web component |
| 32 | +* `npm run start` # starts the app we use for testing |
| 33 | +* `npm run test` # runs the unit tests and e2e tests |
| 34 | + |
| 35 | +If you are planning to contribute new functionality back to us, please |
| 36 | +coordinate with us, so that the new code is in the right places, and so that |
| 37 | +you don't accidentally add something that we are also working on. |
| 38 | + |
| 39 | +## Development server |
| 40 | + |
| 41 | +* Run `npm run start` for a dev server. Navigate to `http://localhost:4200/`. |
| 42 | + The app will automatically reload if you change any of the source files. |
| 43 | + |
| 44 | +* Run `npm run start-public` if you need to access to the dev server from a different machine. |
| 45 | + For example, to run Narrator from a Windows PC. |
| 46 | + |
| 47 | +## Build |
| 48 | + |
| 49 | +* Run `npm run build` to build the project and generate a production version of |
| 50 | + the js files, which are much smaller than the development version. It |
| 51 | + generates two versions of the js files, an ES5 version and ES2015 version, under |
| 52 | + dist/lforms. For details on the files to load, see ["Usng the LHC-Forms Web |
| 53 | + Component"](#using). The `dist` directory is deleted and recreated during the |
| 54 | + process. |
| 55 | + |
| 56 | + The build also concatenates all the js files (except for zone.min.js and the |
| 57 | + FHIR support files) into a single `lhc-forms.es5.js` and `lhc-forms.es2015.js` |
| 58 | + file, and these work, but we don't currently recommend their use because the |
| 59 | + source maps don't work with these files. Also, there is a dist/webcomponent |
| 60 | + directory that is created with a copy of the files in dist/lforms, but that |
| 61 | + is only needed for the tests. |
| 62 | + |
| 63 | +## Running tests |
| 64 | +1. Run `npm run test` to run unit tests and e2e tests, which also copies the FHIR lib files |
| 65 | + and built files in places for testing. |
| 66 | + |
| 67 | +## Running unit tests |
| 68 | + |
| 69 | +1. Run `npm run test:unit` to execute the unit tests via [Karma](https://karma-runner.github.io). |
| 70 | + |
| 71 | +## Running end-to-end tests |
| 72 | + |
| 73 | +1. Run `npm run test:e2e:prepare` to copy necessary files in places for the tests and to update the web driver. |
| 74 | + |
| 75 | +1. Run `npm run test:e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/). |
| 76 | + The e2e tests is configured to use Chrome. If Chrome has been updated, run `npm run update-webdriver` |
| 77 | + to update the Chrome web driver. |
| 78 | + |
| 79 | +## <a id="using">Using the LHC-Forms Web Component</a> |
| 80 | +There are several script files to load. If you are building this or installing via npm, these files will be |
| 81 | +under `dist/lforms`. If you are using the pre-built versions from |
| 82 | +https://clinicaltables.nlm.nih.gov/lforms-versions, then the file paths below |
| 83 | +are relative to those versioned directories. |
| 84 | +1. `webcomponent/styles.css` |
| 85 | + |
| 86 | +You need to include the following files in your project: |
| 87 | +1. `webcomponent/styles.css` |
| 88 | +2. `webcomponent/assets/lib/zone.min.js` (unless you already have zone.min.js on the page) |
| 89 | +3. `webcomponent/scripts.js` |
| 90 | +4. `webcomponent/runtime-[es5|es2015].js` |
| 91 | +5. `webcomponent/polyfills-[es5|es2015].js` |
| 92 | +6. `webcomponent/main-[es5|es2015].js` |
| 93 | +7. *One* of the FHIR support library files, assuming you are planning to use |
| 94 | + FHIR Questionnaires: |
| 95 | + * `fhir/lformsFHIRAll.min.js` |
| 96 | + * `fhir/R4/lformsFHIR.min.js` |
| 97 | + * `fhir/STU3/lformsFHIR.min.js` |
| 98 | + |
| 99 | +There is an example of an app using these files at https://lhcforms.nlm.nih.gov/lforms-fhir-app/. |
0 commit comments