openemr / openemr

The most popular open source electronic health records and medical practice management solution.
https://open-emr.org/
GNU General Public License v3.0
3.17k stars 2.15k forks source link

Lazy load service classes that extend BaseService in Telehealth module #6208

Open adunsulag opened 1 year ago

adunsulag commented 1 year ago

The BaseService class does a hit to the database for the database fields available for the table. Several class constructors in the Telehealth module instantiates the instances of the BaseService such as AppointmentService and TeleHealthUserRepository.

Anywhere we are subscribing to events needs to defer instantiation of these classes to mitigate the db hit. A future enhancement might be to have some kind of cache generation for our service classes for tables that don't have connection to LBF. No point in hitting the database to find the fields when they should be static at runtime.

sjpadgett commented 1 year ago

I'm the one who put base in mainly for API services. Perhaps we could have done it differently but I wouldn't have expected any extensive routines as it mainly was a target for utility's/helpers. But I may have broken that rule with the query builder.