Open adriaanbd opened 4 years ago
We can talk about this more when we get to the frontend part. High level idea of it is this:
This search box component we can build from scratch or even find a react component for it. For the backend it's just a matter of creating an "autocomplete" controller which have an action that might look like the ff:
def index
query_str = params[:query_string]
autocomplete_results = Medication.find_by_terms(query_str)
# find_by_terms is a method we can define in the Medication model
render :autocomplete_results, locals: { results: autocomplete_results }, status: :ok
end
Of course there are gems that can help us with "find_by_terms" method above. So yeah this should not be a big problem for us later on :)
When a user is adding a medication name, autocomplete should suggest available options from general Medicine table.
Here are some resources I found:
Let's talk about how we will implement this feature. It looks simple from high-level. Just send the params on the searchbar to a database query and get back results with top x amount of results. It has to be fast though.