The getCurrentlyLoggedInUser function actually returns a result from the database, not just the userid from the session, so this wouldn’t work.
Also, a cool feature in the new forums is markdown is fully supported. If you wrap your code blocks with three back ticks on you will notice you get syntax hylighting on your code, I edited your original post, if you go into edit mode you can see exactly how to set it up
You are right that we use the $_SESSION value in there, but that method actually returns an instance of User not just a string representing the ID of the user
Some aspects certainly do. We’ve been working hard to get some basics done so other debts can see working examples, but we can always try to provide more.
Unfortunately it seems to be a side effect of reorganizing legacy code.
I come from the enterprise world where ORMs are the way of the land. However, I realize the learning curve is pretty high.
As you may know, other OpenEMR projects have taken my attention as of late, but when I return to the backend modernization work, I believe organizing all of the SQL queries in domain-partitioned service layers (not using anything fancy) may be the better approach. I actually did this with the recent FacilityService openemr/FacilityService.php at master · openemr/openemr · GitHub and I think it’s pretty elegant. As a step further, a lightweight query builder may be nice to use too, but that’s mainly for syntatic sugar.
Hi @MatthewVita@robert.down
I did not find the Facility class in entities.
If Doctrine ORM will be the way of the land in OpenEMR. It will be better to get my hands dirty.
The Facility class is a service class that is NOT using Doctrine. The point I was making that it’s pretty simple without the ORM and appears to be elegant so we may skip out on ORMs because of the learning curve (not for you, because you’ll be able to pick up on it quickly but other contributors may not be up to date on more advanced patterns such as ORM)
Thank you so much for putting thought into this. I believe there is a better path than the one that I started us down.
If it’s okay I’m going to just respond to your email asking how to get started in the backend modernization project here.
Basically, there are MANY things that need to be cleaned up in the codebase to follow a proper MVC style codebase. I would say that where you can start is by removing all of the SQL queries in the views and putting them in centralized services. For instance, I recently removed about 100 (mostly copy/pasted) SQL queries in the views surrounding “Facilities” and I put them into a “FacilityService” that the views call out to. This is not only good from a code quality perspective, but it will help us in the future because the UI and the business logic are not tangled together (will help with making a REST API or a FHIR API).
The current services use Doctrine (except for the FacilityService, which is straight SQL). It appears that Doctrine may have too high of a learning curve for the greater community and we may want to just stick with straight SQL.
With this said, here are some tasks you can jump on: