Skip to content

Adding STOP TB tables#131

Open
vishwab1 wants to merge 8 commits into
mainfrom
vb/db
Open

Adding STOP TB tables#131
vishwab1 wants to merge 8 commits into
mainfrom
vb/db

Conversation

@vishwab1

@vishwab1 vishwab1 commented Jun 1, 2026

Copy link
Copy Markdown
Member

📋 Description

JIRA ID:

Please provide a summary of the change and the motivation behind it. Include relevant context and details.


✅ Type of Change

  • 🐞 Bug fix (non-breaking change which resolves an issue)
  • New feature (non-breaking change which adds functionality)
  • 🔥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 🛠 Refactor (change that is neither a fix nor a new feature)
  • ⚙️ Config change (configuration file or build script updates)
  • 📚 Documentation (updates to docs or readme)
  • 🧪 Tests (adding new or updating existing tests)
  • 🎨 UI/UX (changes that affect the user interface)
  • 🚀 Performance (improves performance)
  • 🧹 Chore (miscellaneous changes that don't modify src or test files)

ℹ️ Additional Information

Please describe how the changes were tested, and include any relevant screenshots, logs, or other information that provides additional context.

Summary by CodeRabbit

  • Chores
    • Database schema enhancements supporting TB clinical examination, diagnostic assessment, and screening workflows with extended clinical data parameters and audit capabilities.

vishwab1 and others added 8 commits March 30, 2026 13:01
…lter

Changed isoutbound filter from "is false" to "IS NOT TRUE" in
Pr_104BeneficiaryReport stored procedure to include NULL records.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…as V64__Facility_Hierarchy.sql

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Creates tb_stoptb_general_examination, tb_stoptb_general_opd,
tb_stoptb_diagnostics tables. Adds Stop TB nurse flow columns
(_id variants + referral/screening/diagnostic fields) to tb_screening.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 1, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This pull request adds a Flyway database migration that establishes the Stop TB clinical module schema. It creates three new tables for general examination, outpatient, and diagnostics data, then extends the existing screening table with investigation recommendations and symptom-tracking columns using safe conditional additions.

Changes

Stop TB Schema Expansion

Layer / File(s) Summary
New Stop TB Clinical Tables
src/main/resources/db/migration/dbiemr/V82__StopTB_tables.sql (lines 1–99)
Defines three new tables (tb_stoptb_general_examination, tb_stoptb_general_opd, tb_stoptb_diagnostics) with primary keys, beneficiary/provider references, clinical fields, audit timestamps (created_date, last_mod_date), and soft-delete flags.
Screening Table Investigation & Audit Extension
src/main/resources/db/migration/dbiemr/V82__StopTB_tables.sql (lines 100–287)
Adds investigation recommendation columns (digital chest x-ray, sputum collection, truenat, liquid culture), symptom-tracking fields (cough, blood, fever, weight, sweats, history, family drugs), referral and denial flags, and audit columns to tb_screening using dynamic prepared ALTER TABLE statements with INFORMATION_SCHEMA column-existence guards.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested reviewers

  • paras-dba

Poem

🐰 New tables spring forth, clean and bright,
Stop TB screening takes its flight,
With audit trails and soft deletes,
The schema dances, migration completes! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Adding STOP TB tables' accurately reflects the main change: the PR creates three new Stop TB schema tables and extends the tb_screening table with Stop TB-related columns.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch vb/db

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.

@sonarqubecloud

sonarqubecloud Bot commented Jun 1, 2026

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/main/resources/db/migration/dbiemr/V82__StopTB_tables.sql`:
- Around line 7-39: The column name in tb_stoptb_general_examination is
inconsistent: change beneficiary_reg_id to match the other Stop TB tables
(ben_reg_id) to avoid query/join confusion; update the CREATE TABLE statement in
V82__StopTB_tables.sql (table tb_stoptb_general_examination and column
beneficiary_reg_id) to use ben_reg_id, and also search/update any related
migration SQL, foreign key references, indexes, and application/entity code that
reference beneficiary_reg_id so they reference ben_reg_id instead.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0dcfc356-61f1-421a-86de-f86067ad0cc3

📥 Commits

Reviewing files that changed from the base of the PR and between 5ac862a and 498e188.

📒 Files selected for processing (1)
  • src/main/resources/db/migration/dbiemr/V82__StopTB_tables.sql

Comment on lines +7 to +39
CREATE TABLE IF NOT EXISTS `tb_stoptb_general_examination` (
`id` BIGINT NOT NULL AUTO_INCREMENT,
`beneficiary_reg_id` BIGINT DEFAULT NULL,
`provider_service_map_id` INT DEFAULT NULL,
`pulse_rate` INT DEFAULT NULL,
`systolic_bp` INT DEFAULT NULL,
`diastolic_bp` INT DEFAULT NULL,
`random_blood_sugar` DOUBLE DEFAULT NULL,
`pallor_id` INT DEFAULT NULL,
`pallor` VARCHAR(50) DEFAULT NULL,
`icterus_id` INT DEFAULT NULL,
`icterus` VARCHAR(50) DEFAULT NULL,
`lymphadenopathy_id` INT DEFAULT NULL,
`lymphadenopathy` VARCHAR(50) DEFAULT NULL,
`oedema_id` INT DEFAULT NULL,
`oedema` VARCHAR(50) DEFAULT NULL,
`cyanosis_id` INT DEFAULT NULL,
`cyanosis` VARCHAR(50) DEFAULT NULL,
`clubbing_id` INT DEFAULT NULL,
`clubbing` VARCHAR(50) DEFAULT NULL,
`key_population_risk_factor_ids` TEXT DEFAULT NULL,
`key_population_risk_factors` TEXT DEFAULT NULL,
`hiv_status_id` INT DEFAULT NULL,
`hiv_status` VARCHAR(50) DEFAULT NULL,
`referral_to_hwc_needed_id` INT DEFAULT NULL,
`referral_to_hwc_needed` TINYINT(1) DEFAULT NULL,
`created_by` VARCHAR(255) DEFAULT NULL,
`created_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`modified_by` VARCHAR(255) DEFAULT NULL,
`last_mod_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`deleted` TINYINT(1) DEFAULT 0,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Inconsistent beneficiary column naming across tables.

This table uses beneficiary_reg_id while tb_stoptb_general_opd and tb_stoptb_diagnostics use ben_reg_id. This inconsistency can cause confusion when writing queries or JOINs across these related Stop TB tables.

Consider standardizing on one naming convention across all three tables.

Proposed fix to align naming
 CREATE TABLE IF NOT EXISTS `tb_stoptb_general_examination` (
   `id`                              BIGINT       NOT NULL AUTO_INCREMENT,
-  `beneficiary_reg_id`              BIGINT       DEFAULT NULL,
+  `ben_reg_id`                      BIGINT       DEFAULT NULL,
   `provider_service_map_id`         INT          DEFAULT NULL,
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
CREATE TABLE IF NOT EXISTS `tb_stoptb_general_examination` (
`id` BIGINT NOT NULL AUTO_INCREMENT,
`beneficiary_reg_id` BIGINT DEFAULT NULL,
`provider_service_map_id` INT DEFAULT NULL,
`pulse_rate` INT DEFAULT NULL,
`systolic_bp` INT DEFAULT NULL,
`diastolic_bp` INT DEFAULT NULL,
`random_blood_sugar` DOUBLE DEFAULT NULL,
`pallor_id` INT DEFAULT NULL,
`pallor` VARCHAR(50) DEFAULT NULL,
`icterus_id` INT DEFAULT NULL,
`icterus` VARCHAR(50) DEFAULT NULL,
`lymphadenopathy_id` INT DEFAULT NULL,
`lymphadenopathy` VARCHAR(50) DEFAULT NULL,
`oedema_id` INT DEFAULT NULL,
`oedema` VARCHAR(50) DEFAULT NULL,
`cyanosis_id` INT DEFAULT NULL,
`cyanosis` VARCHAR(50) DEFAULT NULL,
`clubbing_id` INT DEFAULT NULL,
`clubbing` VARCHAR(50) DEFAULT NULL,
`key_population_risk_factor_ids` TEXT DEFAULT NULL,
`key_population_risk_factors` TEXT DEFAULT NULL,
`hiv_status_id` INT DEFAULT NULL,
`hiv_status` VARCHAR(50) DEFAULT NULL,
`referral_to_hwc_needed_id` INT DEFAULT NULL,
`referral_to_hwc_needed` TINYINT(1) DEFAULT NULL,
`created_by` VARCHAR(255) DEFAULT NULL,
`created_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`modified_by` VARCHAR(255) DEFAULT NULL,
`last_mod_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`deleted` TINYINT(1) DEFAULT 0,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `tb_stoptb_general_examination` (
`id` BIGINT NOT NULL AUTO_INCREMENT,
`ben_reg_id` BIGINT DEFAULT NULL,
`provider_service_map_id` INT DEFAULT NULL,
`pulse_rate` INT DEFAULT NULL,
`systolic_bp` INT DEFAULT NULL,
`diastolic_bp` INT DEFAULT NULL,
`random_blood_sugar` DOUBLE DEFAULT NULL,
`pallor_id` INT DEFAULT NULL,
`pallor` VARCHAR(50) DEFAULT NULL,
`icterus_id` INT DEFAULT NULL,
`icterus` VARCHAR(50) DEFAULT NULL,
`lymphadenopathy_id` INT DEFAULT NULL,
`lymphadenopathy` VARCHAR(50) DEFAULT NULL,
`oedema_id` INT DEFAULT NULL,
`oedema` VARCHAR(50) DEFAULT NULL,
`cyanosis_id` INT DEFAULT NULL,
`cyanosis` VARCHAR(50) DEFAULT NULL,
`clubbing_id` INT DEFAULT NULL,
`clubbing` VARCHAR(50) DEFAULT NULL,
`key_population_risk_factor_ids` TEXT DEFAULT NULL,
`key_population_risk_factors` TEXT DEFAULT NULL,
`hiv_status_id` INT DEFAULT NULL,
`hiv_status` VARCHAR(50) DEFAULT NULL,
`referral_to_hwc_needed_id` INT DEFAULT NULL,
`referral_to_hwc_needed` TINYINT(1) DEFAULT NULL,
`created_by` VARCHAR(255) DEFAULT NULL,
`created_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`modified_by` VARCHAR(255) DEFAULT NULL,
`last_mod_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`deleted` TINYINT(1) DEFAULT 0,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/main/resources/db/migration/dbiemr/V82__StopTB_tables.sql` around lines 7
- 39, The column name in tb_stoptb_general_examination is inconsistent: change
beneficiary_reg_id to match the other Stop TB tables (ben_reg_id) to avoid
query/join confusion; update the CREATE TABLE statement in
V82__StopTB_tables.sql (table tb_stoptb_general_examination and column
beneficiary_reg_id) to use ben_reg_id, and also search/update any related
migration SQL, foreign key references, indexes, and application/entity code that
reference beneficiary_reg_id so they reference ben_reg_id instead.

@vishwab1 vishwab1 requested a review from paras-dba June 1, 2026 05:12
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.

1 participant