The U.S. Food and Drug Administration (FDA) is encouraging great use of electronic health record data to supplement the traditional randomized clinical trials. But you need to use care. Here is some guidance on what the FDA is recommending to industry.
U.S. Food and Drug Administration. Use of Electronic Health Record Data in Clinical Investigations. Guidance for Industry. July 2018. Available in PDF format.