Multiselects

To add a multiselect using the usual field enumerations:

  • Open the form in Admin edit and create a new field of type "enum", input type "Multiselect:enum."
    • Note the special processing of multiselect_enum when the source is generated in DynasiteSourceGenerator - it does not create a field in the class.
    • In special circumstances, you may wish to use "Multiselect: Enum Input Field" instead. This version creates a field in the class.
  • Add enums to this new field.
  • Enter the number of fields that will store the results of this submission in the "Size" box.
  • Make fields that will store the results of the submission. If you specified 10 fields to be saved in the previous item, create 10 fields.
    • Field type Enum.
    • Input type "Multiselect: Item."
    • Name the label what the field represents - if your making a list of drugs, name them "Drug 1", Drug 2", "Drug 3", etc.
    • Select the field that you had setup as "Multiselect:enum" from the Dependent Field(s) for Visibility, Enum 1 - this attaches this enum field to the list of enumerations.
    • For each field, enter its order in the "Size" box, starting at 0 for Drug 1. If it’s Drug 3, enter "2" in the size box.
    • No need to uncheck "Visible".

Getting the multiselected items to display when the form is rendered is accomplished in FormDisplayAction. A Map called multiValues is populated using the id of the multiselect widget as the key, and the value as the , well, value. The multiselect_enum tag loops through this map.

There’s code in WidgetUtils to render the enums from the (parent) multiselect_enum for a multiselect_item when editing a record.

In ZEPRS, the Current Medicine form (form 55) uses a hard-coded jsp (forms/current_medicine_fields.jsp) called from encounter_form_layout_chart.jsp to render the page. Drug1-10 are defined in the admin page.

To use this same drug listing, complete the following instructions:

  • Add the shared field "Medical Treatments"
  • Add the shared fields Drug1, drug2, etc.

Using the Current Medicine code is deprecated - better to use the Multiselect widget.