Calendar migration to twig

Three years ago, one of the project leads started the project to migrate the smarty calendar to twig. I have taken up this quest and pushed the rock forward to move the needle. If you would like to join me on this quest to make a major change in OpenEMR. Fork this repo

Make a branch and we can make this change reality. Current status is that the majority of the calendar has been migrated. There are a lot of nuances that need to be migrated.

Right now, we are working on the week view. We finally got the IN/OUT function migrated over. We can use a few more hands and testers because I am sure there will be things I have not thought about.

Calendar Display Progress Update
Watch Video

If you have any question, post them here and I will get to them as soon as I can. Otherwise, fork the repo and start work on the month view. Please let me know ahead of time what you will be working on so that we don’t have 5 people fixing or building the same thing. I would like to have this finished and ready for the lead engineers to bring this into the next version of the program. We can really use some JavaScript developers and UI people on board this project.

Side note: the repo started out as a place where I need to build a facility view. I thought it would be good addition to the calendar because of some difficulties in see all the providers scheduled in a particular facility. I have put that on the side burner for now unless one of you reading this would like to pick up the ball and run with it.

2 Likes

If you want to see the build as it stands now, or watch the progress. Go here

http://70.184.163.114/calendarTwigMigration
PHS-admin-86
5qy3xkMjP4A2US1u7Qv

Let me know what is broken that you want to work on. At this point, the calendar is fully on Twig, no Smarty.

Hi @juggernautsei ,
I am not a programmer but I do use AI to make changes in openemr that meet my needs. I suggest you try https://jules.google.com

  • Create an account
  • Connect your github.com account
  • Select your repository and the branch
  • Ask Google to make any changes you like, you will get a plan, review it and approve it. Google will create a new branch that you can use for testing

With your background, I think you can migrate everything in few hours / one day (while you do other things)

1 Like

@moussa thanks for the suggestion. The firs thing on Jules site is this

“small feature requests”

What we are doing with the calendar is not a small feature request. I do use Claude to assist with the migration. And it still gets things wrong. But hey, that is life. Best!

1 Like

Yes, I saw that. When I asked Jules to migrate the Smarty calendar to Twig, it did generate a plan to me. Unfortunately, I’m not a developer and I’m unsure what to expect, though I thought it was worth a shot anticipating adjustments might be needed.

Here is step 2, Migrate Core Calendar Views (Day, Week, Month):

  • For each core view (e.g., day.html, week.html, month.html found in interface/main/calendar/modules/PostCalendar/pntemplates/default/views/):
  • Create corresponding Twig template files (e.g., day.html.twig, week.html.twig, month.html.twig) in the new Twig template directory.
  • Convert Smarty syntax ([- ... -]) to Twig syntax ({{ ... }}, {% ... %}).
  • Replace Smarty variables with Twig variables passed from the controller.
  • Use Twig loops (for), conditionals (if), and includes (include) as needed. Crucially, apply appropriate escaping (e.g., |escape, |escape('html_attr')) to all dynamic data to prevent XSS, as autoescaping is off.
  • Utilize existing Twig extensions for translations (e.g., |xlt), date formatting (|shortDate, |oeFormatDateTime), and URL/asset generation if available, or construct them using globals.

@juggernautsei How does ths sound to you?

@moussa it sounds like what we have already completed. Thanks!

1 Like