###Background This started as an effort to have an easier way to create and consume forms in angular. We adopted an approach that leverages the features provided by angular formly which is an angular module that provide an easy way to create and use forms in angular applications. We created what we call an OpenMRS JSON schema (here is an example) to facilitate an easy way of capturing OpenMRS specific information. The schema is translated into the format that can be consumed by the angular formly module. It worked pretty well for a while.
As we dived into creating more forms we realized the benefits of creating a separate form management module. We refactored our code and the form management part was taken out in its own new module which conveniently is named openmrs-angularFormentry. It can now be utilized independently.
During all this time we were also thinking of creating reusable form components. This was inevitable for us because most of our forms are answering the same questions with minor differences that depend on things like age and the associated program/project; For example you can have two versions of the same form for childrens & adults. The idea is to provide an ability for someone to define a form and reuse some of the already existing components if they wish to instead of having to redefine the same thing over and over. Also since for all this time our forms have been part of the code we need to take them out and have them stored in OpenMRS for ease of management. That way forms & code can evolve independently.
###Challenges & Proposed Solutions
The components will have to evolve with time inevitably but since the old components may have already been used to collect data, there arise a need of versioning and being able to tell which form uses what version. One simple approach is storing components as forms themselves and once any form is published, it is essentially frozen. The components will have versions as well as forms and once you identify a form version you can be sure to know exactly what components versions are associated with it. In essence publishing a form means making sure all associated components are published and any edit to an existing published component/form means creation of a new version. Remembering the form that was used to collect data is enough to load the correct form needed for editing.
Tracking the number of forms a particular component has been used in. This is a bit difficult with the existing OpenMRS form model. Forms and components are json schemas stored as form resources and the used components are directly referenced in those schema so figuring out how many forms uses a particular component means scanning these schemas trying to find those references which can be done but without a place to store this information without creating new tables. Anyhow this is low priority currently.
The main objective of this thread is to get ideas on how to best approach this endeavor bearing in my mind that we want to get to the point where an end user can easily create/compose, store, retrieve and consume forms using the json schemas ( and eventually UI form builders) without requiring programming skills.
It would be nice also to point out things we might have missed.