luis901101 / fhir_questionnaire

A library to render FHIR Questionnaires and generate a QuestionnaireResponse
BSD 2-Clause "Simplified" License
4 stars 4 forks source link

Update QuestionnaireController #12

Open easazade opened 3 months ago

easazade commented 3 months ago

This PR introduces a few fixes and improvements in QuestionnaireController class.

  1. Fixes only rendering nested questionnaire items that were a child of a QuestionnaireItem of type group. In FHIR any QuestionnaireItem can have child items. eg a QuestionnaireItem of type text, group, questions can have child items of any type. or any QuestionnaireItem can have a child display item with extension coding of help acting as the help text of the parent item. (Also done the same for generating QuestionnaireResponseItem objects)
  2. Updates the onGenerateItemResponse callback method to also provide the generated QuestionnaireResponseItem as an argument of this callback. This way when this callback is being implemented it is also possible to just modify the QuestionnaireResponseItem and return it. Many times it is only desired to modify a field or add an extra extension to a generated QuestionnaireResponseItem of certain type and just return it. Other than that it is required, since each generated QuestionnaireResponseItem can have generated children items. So by simply not providing the generated QuestionnaireResponseItem, its children are not being provided as well in the callback.
  3. Converts onBuildItemBundle to onBuildItemView since almost always it is just desired to render a custom item view to be rendered for a type of questionnaireItem. To delegate the entire generation of QuestionnaireBundleItem in the callback will be much harder for the implementors, If all they want is to just custom render a questionnaire item, the responsibility to also generate children and groupIds shouldn't fall to them.
  4. Fixes the enableWhen not working when the enable.question was not in the same group