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.