logic to fetch the medicine for