R functions for retrieving medical data