Extracting research-quality phenotypes from electronic health records to support precision medicine