Skip to content

Removed javascript SQL caching table for indexing#905

Draft
LiamStanziani wants to merge 5 commits intomaintenancefrom
899-update-consultant-test-data-refactor-javascript-sql-table
Draft

Removed javascript SQL caching table for indexing#905
LiamStanziani wants to merge 5 commits intomaintenancefrom
899-update-consultant-test-data-refactor-javascript-sql-table

Conversation

@LiamStanziani
Copy link
Copy Markdown
Collaborator

@LiamStanziani LiamStanziani commented Nov 25, 2025

In this PR, I have:

  • Removed all references/areas that used the "specialistsJavascript" SQL table (or needed it to work correctly, like specific java files that only were based on this table/implementation)
  • Replaced the above referenced SQL table with indexing on the 3 consultant related SQL tables (consultationServices, professionalSpecialists, and serviceSpecialists).
  • Created a migration update SQL file to have the required updates related to this (to allow for easy updates to the database without full db rebuild)

General overview of the changes

The "specialistJavascript" table is only used for caching the related consultation/specialist data as javascript for faster access when running the consultation functionality.

In terms of migration, the only changes needed for this is to remove all of the usage of this table (and connected functionality).

No actual logic updates are needed in the java files past removal of the javascript caching (since the table itself doesn't go and modify data in the actual consultation related tables, it is isolated to make changes to the "specialistJavascript" table itself).

PLEASE NOTE THAT:

This PR is a work in progress, as explained in the title, I would like to include updated consultant test data (which I'm pretty sure Yingbull has the data), and also test afterwards with the related functionality to ensure that the systems are functioning correctly and the speed of the related functionality is not hindered.

Not sure when this branch will be updated to include the new consultant test data/testing it. But this current version can be kept in draft until ready for visibility.

…exing in related tables (serviceSpecialists junction table, and consultationServices/professionalSpecialists tables). Added in cleanup for removed javascript table, and removed table from oscarinit.sql and development.sql
…eation, just incase the indexes already exist (to avoid errors overall when running)
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai bot commented Nov 25, 2025

Reviewer's Guide

Replaces the legacy specialistsJavascript pre-generated JS table and related Java code with direct use of the existing consultation tables optimized via new indexes, and adds a repeatable DB migration to apply these schema changes while keeping data intact.

Entity relationship diagram for updated consultation specialist tables

erDiagram
  consultationServices {
    int serviceId PK
    varchar serviceDesc
    char active
    index idx_consultationServices_active_desc
  }

  professionalSpecialists {
    int specId PK
    varchar lName
    varchar fName
    varchar referralNo
    varchar specType
    int institutionId
    int departmentId
    varchar province
    tinyint hideFromView
    tinyint deleted
    int eformId
    index idx_professionalSpecialists_name
    index idx_professionalSpecialists_referralNo
    index idx_professionalSpecialists_specType
    index idx_professionalSpecialists_institution
    index idx_professionalSpecialists_department
  }

  serviceSpecialists {
    int serviceId FK
    int specId FK
    index idx_serviceSpecialists_serviceId
    index idx_serviceSpecialists_specId
  }

  specialistsJavascript {
    int id PK
    char setId
    text javascriptString
  }

  consultationServices ||--o{ serviceSpecialists : has
  professionalSpecialists ||--o{ serviceSpecialists : linked_by
Loading

Class diagram for removal of SpecialistsJavascript caching layer

classDiagram
  class SpecialistsJavascript {
    int id
    char setId
    text javascriptString
  }

  class SpecialistsJavascriptDao

  class SpecialistsJavascriptDaoImpl

  class EctConConstructSpecialistsScriptsFile

  SpecialistsJavascriptDaoImpl ..|> SpecialistsJavascriptDao
  EctConConstructSpecialistsScriptsFile ..> SpecialistsJavascriptDao
  EctConConstructSpecialistsScriptsFile ..> SpecialistsJavascript
Loading

File-Level Changes

Change Details Files
Add performance-focused indexes to consultation-related tables and remove no-longer-needed specialistsJavascript table from the base schema.
  • Add composite index on consultationServices for active flag and description to speed up active-service searches and ordering.
  • Add multiple single-column indexes on professionalSpecialists (name, referralNo, specType, institutionId, departmentId) to support common lookup patterns and joins.
  • Add indexes on serviceSpecialists serviceId and specId to optimize junction-table lookups.
  • Remove the specialistsJavascript table definition from the initial schema and ensure serviceSpecialists is defined only as a junction table with indexes.
database/mysql/oscarinit.sql
Ensure dev/test seed data and truncation scripts no longer depend on specialistsJavascript.
  • Stop truncating the specialistsJavascript table in the dev environment reset script.
  • Remove the sample specialistsJavascript row insert from development seed data to avoid referencing a dropped table.
  • Keep existing serviceSpecialists seed data unchanged so junction-table behavior remains intact.
.devcontainer/db/scripts/development.sql
Remove Java-side generation and use of pre-generated specialists JavaScript, relying instead on live database queries against indexed tables.
  • Strip out calls to EctConConstructSpecialistsScriptsFile in various consultation configuration Struts actions so CRUD operations on services, specialists, institutions, and departments no longer regenerate JS blobs.
  • Remove now-unused helper action logic that injected the generated JS into the request scope (e.g., setting verd attribute).
src/main/java/ca/openosp/openo/encounter/oscarConsultationRequest/config/pageUtil/EctConEditDepartments2Action.java
src/main/java/ca/openosp/openo/encounter/oscarConsultationRequest/config/pageUtil/EctConEditInstitutions2Action.java
src/main/java/ca/openosp/openo/encounter/oscarConsultationRequest/config/pageUtil/EctConEditSpecialists2Action.java
src/main/java/ca/openosp/openo/encounter/oscarConsultationRequest/config/pageUtil/EctConAddSpecialist2Action.java
src/main/java/ca/openosp/openo/encounter/oscarConsultationRequest/config/pageUtil/EctConAddService2Action.java
src/main/java/ca/openosp/openo/encounter/oscarConsultationRequest/config/pageUtil/EctConDeleteServices2Action.java
src/main/java/ca/openosp/openo/encounter/oscarConsultationRequest/config/pageUtil/EctConDisplayInstitution2Action.java
src/main/java/ca/openosp/openo/encounter/oscarConsultationRequest/config/pageUtil/EctConDisplayService2Action.java
Add a repeatable MySQL migration script to apply the new indexes and drop the deprecated specialistsJavascript table on existing databases.
  • Create update-2025-11-25-serviceSpecialists-indexes.sql that adds indexes to consultationServices, professionalSpecialists, and serviceSpecialists using DROP INDEX IF EXISTS/CREATE INDEX for idempotency.
  • Drop the specialistsJavascript table in the migration using DROP TABLE IF EXISTS so it is safe on both new and upgraded environments.
  • Document in comments that this migration is purely schema/indexing and does not mutate business data.
database/mysql/updates/update-2025-11-25-serviceSpecialists-indexes.sql
Remove obsolete DAO, model, configuration data, and tests associated with specialistsJavascript.
  • Delete the SpecialistsJavascript JPA entity/model class and its DAO interface and implementation that mapped to the specialistsJavascript table.
  • Remove configuration/utility classes used only for generating and storing JS (EctConConfigurationJavascriptData and EctConConstructSpecialistsScriptsFile).
  • Delete SpecialistsJavascriptDaoTest since the underlying table and DAO no longer exist.
src/main/java/ca/openosp/openo/commn/dao/SpecialistsJavascriptDao.java
src/main/java/ca/openosp/openo/commn/dao/SpecialistsJavascriptDaoImpl.java
src/main/java/ca/openosp/openo/commn/model/SpecialistsJavascript.java
src/main/java/ca/openosp/openo/encounter/oscarConsultationRequest/config/data/EctConConfigurationJavascriptData.java
src/main/java/ca/openosp/openo/encounter/oscarConsultationRequest/config/pageUtil/EctConConstructSpecialistsScriptsFile.java
src/test/java/ca/openosp/openo/commn/dao/SpecialistsJavascriptDaoTest.java

Assessment against linked issues

Issue Objective Addressed Explanation
#899 Add or update Devcontainer database test data to include sufficient service/specialist data for testing consultant-related functionality (e.g., consultant forms in eCharts). The PR adjusts schema and indexes and removes the specialistsJavascript table and its references, but it does not add or update any consultant/service/specialist test data beyond removing existing specialistsJavascript test data. The PR description explicitly notes that updated consultant test data will be added in the future.
#899 Refactor and remove all remaining uses of the deprecated "specialistJavascript" SQL table from the codebase and database, replacing it with direct use of consultation-related tables where appropriate.

Possibly linked issues

  • #N/A: PR removes specialistJavascript table usage, adds indexes/migration, and updates dev DB, directly addressing most of the issue.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@github-actions
Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@LiamStanziani LiamStanziani changed the title Updated consultant test data and refactored javascript sql table Updated consultant test data and removed javascript SQL caching table for indexing Nov 25, 2025
@LiamStanziani LiamStanziani changed the title Updated consultant test data and removed javascript SQL caching table for indexing Removed javascript SQL caching table for indexing Nov 25, 2025
@LiamStanziani
Copy link
Copy Markdown
Collaborator Author

Removed:

Updated consultant test data

From the title as this isn't included into this draft PR yet

@keploy
Copy link
Copy Markdown

keploy bot commented Jan 15, 2026

To generate Unit Tests for this PR, please click here.

@sebastian-j-ibanez sebastian-j-ibanez changed the base branch from develop to maintenance March 13, 2026 22:12
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 13, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 98266f99-c9b3-4b3b-b88f-c9c8bc9a3f63

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 899-update-consultant-test-data-refactor-javascript-sql-table
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

CodeRabbit can generate a title for your PR based on the changes with custom instructions.

Set the reviews.auto_title_instructions setting to generate a title for your PR based on the changes in the PR with custom instructions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update the db test data to include service/specialist data and look into refactoring the remaining uses of "specialistJavascript" SQL table

2 participants