GSoC Week 3 Experience: Migrating EHR to Laravel - User Module & Roles Module

GSoC Week 3 Experience: Migrating EHR to Laravel - User Module & Roles Module

Laratrust Role Management and Seeder.

ยท

3 min read

Introduction:

Hello everyone! Welcome to my blog post where I will be sharing my experiences and progress during the third week of my Google Summer of Code 2023. As you all know by now, I have been working on migrating the Electronic Health Records (EHR) for the Users and Roles Module of LibreHealth to the Laravel framework. Currently, I have been implementing the Roles modules. So, let's dive into what I accomplished this week and what my plans are for the upcoming week.

Issues and Learning:

Before delving into the progress I made this week, I want to take a moment to address an issue that I encountered. It's crucial to acknowledge and learn from even the seemingly trivial or easily solvable challenges that arise during the course of a project.

Last week I was unable to access the Advance Access Control List of the legacy codebase. It was a Smarty module error where it can't have permissions for the directory. I was running the legacy codebase in my WSL in docker.

I tried giving read-write access to this directory but nothing works. But I later found that the web server user is different. I then found some solutions to find the correct web server user in docker and these commands help me.

docker exec -it <container_name> /bin/bash
ps aux | grep apache

I found my webserver user www-data and then provided the necessary permissions for it.

sudo chown -R www-data:www-data /var/www/html/gacl/admin/templates_c

Though this issue may appear trivial in hindsight, it consumed a significant amount of time to pinpoint the exact problem and devise an effective solution. However, the valuable lessons I learned along the way make the time invested unquestionably worthwhile. Let's move into this week's progress.

Progress Made

At first, I worked on updating the reviewed changes from the previous pull request. In my last commit, I used traditional routes but I was suggested to use Ziggy.

Ziggy is a package for Laravel that simplifies JavaScript routing by generating route helpers based on your application's routes. This approach enhances the maintainability and readability of the codebase, making it easier to work with and ensuring a smoother user experience.

Since we are using Laratrust for the Roles, my next task for this week is to create the Roles Seeder which will assign some initial permissions to each role.

From the legacy codebase, I found these major roles:

  • LibreEHR Users

  • Accounting

  • Administrators

  • Clinicians

  • Emergency Login

  • Front Office

  • Physicians

  • Super Student.

By associating specific CRUD permissions with each role, we establish fine-grained access control and ensure that users have appropriate privileges for their respective roles.

To provide comprehensive access control, I assigned CRUD permissions to various modules, including Calendar, Flow Board, Messages, Patient/Client, Fees, Inventory, Procedures, Administration, Reports, Miscellaneous, Popups, QA Measures, and Help. This granularity allows for precise control over user actions within each module, maintaining data security and adhering to the principle of least privilege.

Here is the code of how the seeder files look like

Once the changes were completed, I committed them for review. After a review with my mentor, I will update the changes and integrate the Roles Module. You can track my progress and review the details of the pull request through the following link: [PR Link: github.com/LibreHealthIO/lh-ehr-laravel/pul..

Next Week Plan:

In the upcoming week, I have planned the following tasks:

  1. Update the final changes on the Roles module

  2. Test and Integrate the Roles module in the project (login).

  3. Start working in User Module

Conclusion:

This week was well-balanced. Overall, it has been a challenging and rewarding experience, and I'm grateful for this opportunity full of learning.

Like the blog if you loved the content. Also, you can subscribe to the newsletter for email feeds of the blog.

Stay tuned for more updates in the next blog post as I continue to contribute to the migration of EHR to Laravel. ๐Ÿš€

ย