Build a dropdown component to select a medication, then fetch data from an API and display it on screen.
Model the component as an event processor. select events start requests, while success and error events represent API completions. Return the final rendered state and ignore completions belonging to older selections.
Implement def medication_dropdown(events):. Each event is a dictionary with type and relevant fields. Selection events contain medication_id; completion events contain request_id and either data or error. Return a dictionary containing selectedMedication, status, data, and error.
def medication_dropdown(events):