Under GDPR, you must have a valid lawful basis in order to process personal data.
Most lawful bases require that processing is ‘necessary’. If you can reasonably achieve the same purpose without the processing, you won’t have a lawful basis.
There are six available lawful bases for processing. The most appropriate for GP practices would appear to be (e) Public Task
(a) Consent: the individual has given clear consent for you to process their personal data for a specific purpose.
(b) Contract: the processing is necessary for a contract you have with the individual, or because they have asked you to take specific steps before entering into a contract.
(c) Legal obligation: the processing is necessary for you to comply with the law (not including contractual obligations).
(d) Vital interests: the processing is necessary to protect someone’s life.
(e) Public task: the processing is necessary for you to perform a task in the public interest or for your official functions, and the task or function has a clear basis in law.
(f) Legitimate interests: the processing is necessary for your legitimate interests or the legitimate interests of a third party unless there is a good reason to protect the individual’s personal data which overrides those legitimate interests. (This cannot apply if you are a public authority processing data to perform your official tasks.)
You must determine your lawful basis before you begin processing, and you should document it.
Your privacy notice should include your lawful basis for processing as well as the purposes of the processing.
If you are processing special category data you need to identify both a lawful basis for general processing and an additional condition for processing this type of data.