function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
BigPBigP 

Can this be done using apex trigger?

(Part 1)
Let us suppose that our Salesforce users are physicians working in a private clinic. Our Salesforce org is the clinic’s system with its own database and internal applications. Each physician has various in clinic visits with patients scheduled throughout the day. Physicians should be differentiated by other types of users like the System Administrator. A physician with the name John Doe needs to be registered on this Salesforce Org. Physicians can view and modify their own visit records, by changing time and date of the visit, description, or even the patient of the visit. They cannot, however, see or modify the records of their colleagues. The following information should be mandatory on every visit: Date/Time of visit and patient information (must include first name, last name and email). It should also have a timespan value of 15 minutes, 30 minutes or 1 hour. An optional information to be filled for patients will also be a ranking value which can vary between values: Low, Mid, High. Only the physician John Doe should be able to rank the patients, other physicians should not be able to see or interact with this ranking value. When a physician’s logs into the Salesforce log, they should be able to see directly on login, the interface to register the patient’s visitations.(Part2)
The visit records (from the first task) of the same physician are not allowed to overlap with each other.
(For example, if visit #1 is scheduled today on 13:30 and has a timespan of 1 hour, then if visit #2 has a timespan of 30 minutes, it should not be allowed to have a start time at 13: 15 or 14:00, but it can before 13:00 or after 14:30).
When a user creates, updates, or deletes a visit record on Salesforce, the patient receives an email notification letting them know the new time/date of the visit, or that the visit has been canceled.
In addition, every morning at 7:00AM, physicians must receive an email with their scheduled visits of the day.
Lukesh KarmoreLukesh Karmore
yes with the trigger you can prevent  the time overlapping
BigPBigP
But how can you do that ?