saving tge current form before replacing it #506
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When performing upload-app-forms, and if the form to upload exists in the database
This is related to #505
Is your feature request related to a problem? Please describe.
the cht-conf version 10 add the xml_version json key to the form doc when the action upload-app-forms is executed, but the new form of a given form._id replaces the old one and the old xml file is overwritten.
The cht add the form version of the form doc to its data_records.
If a data analyst found a trouble with a current form, he can always learn about collected data using the form, but if the problem is with historical old data, he knows fields sent into the data_record but he is not able to investigate data collection processus and for example, learn about how such a value is possible in a variable;
Describe the solution you'd like
We propose that upload-app-forms does not replace old version but :
before to the replacing, the old form is copied to a new doc but with type: "old-form" and the _id of replaced form is stored in the doc with type "old-form" using the key "doc-id";=:"form:formId", attachements, xml, form_html and model are saved to this type:"old-form" new doc
the form is replaced as now
Additional context
some endpoints could be added to the cht-core forms API to retrieve all versions of a given form:formID; and to get the xml file of a given form version something like GET api/v1/forms/{formid}.{format]/{sha1}