openmrs / openmrs-esm-form-engine-lib

React Form Engine library for O3
Other
10 stars 59 forks source link

:wave: New to O3? Be sure to review the OpenMRS 3 Frontend Developer Documentation. :teacher:

openmrs-esm-form-engine-lib

https://raw.githubusercontent.com/openmrs/openmrs-esm-form-engine-lib/main/readme/form-engine.jpeg

The React Form Engine is a library that allows users to build and render forms for use in O3. These form schemas are written in JSON and conform to the O3 standard JSON schema spec. The O3 reference application ships an embedded Form Builder that users can leverage to build forms interactively, using the interactive schema builder, or by writing JSON code into the embedded schema editor.

and get built using the OpenMRS Form Builder within the O3 reference application. The form engine is a library that can be consumed by any frontend module that needs to render forms. It enables the rendering of forms in the following modes:

Documentation

You can find the full documentation for the OpenMRS Form Engine in the OpenMRS Wiki.

Key features include:

Getting started

NB: The engine is a library and not an O3 frontend module. That being said, it can be consumed by bundling it within an ESM or custom frontend app that incorporates it within a UI workflow.

Prerequisites

Installation

yarn add @openmrs/esm-form-engine-lib@latest

Local development

git clone git@github.com:openmrs/openmrs-esm-form-engine-lib.git

# OR with HTTPS

git clone https://github.com/openmrs/openmrs-esm-form-engine-lib.git

Install Dependencies

yarn

Build the library

yarn build

Link the library to the dependent frontend module

To test your changes locally, you need to link the library to the dependent frontend module. Presently, this library is used by the following modules:

To link the library to the dependent frontend module, run the following command from the root of the frontend module:

yarn link `path/to/openmrs-esm-form-engine-lib`

For example, if you are working on the openmrs-esm-form-builder module, you would run the following command:

pwd | pbcopy # copy the path to form-engine-lib to the to the clipboard
cd `path/to/openmrs-esm-form-builder`
yarn link `pbpaste` # paste the path to the openmrs-form-engine-lib

After linking the library, run the relevant start command from the frontend module. For example, if you are working on the form builder module, you would run the following command:

yarn start

Whereas for the patient chart you would have to start the form engine app within the patient chart that consumes the form engine like so:

yarn start --sources packages/esm-form-engine-app

You could also optionally proxy to a different backend where your forms are hosted by appending backend followed by the URL to the backend. For example:

yarn start --sources packages/esm-form-engine-app --backend https://link-to-my-backend.com

Production

To use the form engine as your default in your O3 instance, you will need to add this to your importmap.

{
  "frontendModules": {
    ...
    "@openmrs/esm-form-engine-app": "next"
    ...
  }
}

NB: *If you are currently using the form entry app (@openmrs/esm-form-entry-app), you will need to remove it from your importmap or replace it with the form engine app (@openmrs/esm-form-engine-app).**

Report an issue

https://github.com/openmrs/openmrs-esm-form-engine-lib/issues

Contributing

Contributions are what makes the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated. Read our contributing guide for more information on how to contribute.

License

Distributed under the MPLv2 with Healthcare Disclaimer License. See LICENSE.txt for more information.

(Back to top)