Exploiting the potential of large databases of electronic health records for research using rapid search algorithms and an intuitive query interface