How can we add drop down in lab test result

In the lab test results, we currently have fields such as value (for integer results) and text_result (for string results). However, some tests require fixed options, such as “Positive” or “Negative,” or predefined values like blood groups. To enhance usability and accuracy, I want to introduce a single field that can dynamically switch between a dropdown and a text input based on the test requirements.
For tests with predefined options, a dropdown should be displayed, showing relevant values specific to the test. For other tests, a text input should be available for custom results. The selected value—whether from the dropdown or text input—should be stored as the test result.

I need guidance on effectively implementing this flexible and dynamic functionality.

I would use a Dict field and define a schema of result for each test.

Is there an example of a Dict field in action?

“Attributes” in product_attribute module

1 Like

@ced @maxx
There are many classes involved, so where do you think we should implement this? I want the functionality to allow defining the dropdown or text field option when creating a test and adding analytics. Then, when adding the result, a dropdown should appear if it was defined earlier; otherwise, a text field should be displayed.