Skip to content

feat: AMM-1267 ECD Quality Supervisor- Question Configuration - #104

Merged
5Amogh merged 3 commits into
release-3.5.0from
amo-1267
Aug 12, 2025
Merged

feat: AMM-1267 ECD Quality Supervisor- Question Configuration#104
5Amogh merged 3 commits into
release-3.5.0from
amo-1267

Conversation

@5Amogh

@5Amogh 5Amogh commented Aug 12, 2025

Copy link
Copy Markdown
Contributor

📋 Description

JIRA ID: AMM-1267

Makes the necessary changes for Quality related role mapping in Question Configuration

✅ Type of Change

  • New feature (non-breaking change which adds functionality)

Summary by CodeRabbit

  • New Features
    • Added support for roles on quality audit questions, including multiple roles per question.
    • Roles are now displayed/populated in call rating question sections and included in audit responses.
  • Chores
    • Updated application version to 3.4.0.

@coderabbitai

coderabbitai Bot commented Aug 12, 2025

Copy link
Copy Markdown

Walkthrough

Adds role/roles handling across entities, DTOs, and services: introduces persistent String role and transient List roles, normalization via flattenRoles(), parsing/splitting/composing roles in service methods, and updates version in pom.xml from 3.1.0 to 3.4.0.

Changes

Cohort / File(s) Summary
Build version bump
pom.xml
Update artifact version to 3.4.0; no other build changes.
DAO entities (roles support)
src/main/java/com/iemr/ecd/dao/QualityAuditQuestionConfig.java, src/main/java/com/iemr/ecd/dao/V_get_Qualityaudit_SectionQuestionaireValues.java
Add persistent role column mapping; add transient roles list in QualityAuditQuestionConfig; add flattenRoles() to join list into comma-separated string.
DTOs (roles exposure)
src/main/java/com/iemr/ecd/dto/QualityAuditorSectionQuestionaireResponseDTO.java, src/main/java/com/iemr/ecd/dto/ResponseCallAuditSectionQuestionMapDTO.java
Add List<String> roles field to both DTOs.
Services (roles parsing/normalization)
src/main/java/com/iemr/ecd/service/quality/QualityAuditImpl.java, src/main/java/com/iemr/ecd/service/quality/QualityAuditQuestionConfigurationImpl.java
Parse comma-separated role to roles list when reading; call flattenRoles() to store roles as CSV when creating/updating; populate roles from result set (column index 14).

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant Service as QualityAuditQuestionConfigurationImpl
  participant DAO as QualityAuditQuestionConfig (DAO)
  participant DB

  Client->>Service: create/update Questionnaire (roles: List<String>)
  Service->>DAO: question.flattenRoles() (join list -> CSV)
  DAO->>DB: Persist role (String, CSV)
  DB-->>DAO: Save OK
  DAO-->>Service: Result
  Service-->>Client: Acknowledgement
Loading
sequenceDiagram
  participant Client
  participant Service as QualityAuditImpl / Q.A. Config Impl
  participant View as V_get_Qualityaudit_SectionQuestionaireValues
  participant DB

  Client->>Service: Fetch questions/sections
  Service->>DB: Query view/entity
  DB-->>Service: Rows with Role (CSV)
  Service->>Service: Split CSV -> roles List<String>
  Service-->>Client: DTOs with roles
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • vanitha1822
  • vishwab1
  • drtechie

Poem

A bunny taps keys with delighted goals,
Stitching one string into many roles.
Hop-split, hop-join, commas in tow,
DTO meadows where new fields grow.
Version bumped—thump-thump!—we roll,
Carrots for code, and a well-shaped role. 🥕🐇

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch amo-1267

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@5Amogh
5Amogh changed the base branch from main to release-3.5.0 August 12, 2025 03:10
@sonarqubecloud

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: 2

🔭 Outside diff range comments (1)
src/main/java/com/iemr/ecd/service/quality/QualityAuditQuestionConfigurationImpl.java (1)

58-88: Critical: optionsSet leaks across iterations and can save previous question’s options on subsequent questions

optionsSet is declared outside the loop and only reinitialized when options are present. For a question without options, the previous iteration’s optionsSet will be reused, causing duplication and misassociation with the new questionId.

Fix by reinitializing optionsSet per iteration and validating options/scores length:

- Set<QualityAuditQuestionnaireValues> optionsSet = null;
+ Set<QualityAuditQuestionnaireValues> optionsSet = null;

 for (QualityAuditQuestionConfig question : qualityAuditQuestionConfig) {
+   // ensure a fresh set per question
+   optionsSet = new java.util.HashSet<>();

    if (question.getRoles() != null && !question.getRoles().isEmpty()) {
        question.flattenRoles();
    }

-   if (question.getOptions() != null && question.getOptions().length > 0) {
-     int j = 0;
-     Integer[] scoreArr = question.getScores();
-     optionsSet = new HashSet<>();
-     for (String option : question.getOptions()) {
-       questionnaireOptions = new QualityAuditQuestionnaireValues();
-       questionnaireOptions.setQuestionValues(option);
-       questionnaireOptions.setScore(scoreArr[j]);
-       questionnaireOptions.setPsmId(question.getPsmId());
-       questionnaireOptions.setCreatedBy(question.getCreatedBy());
-       optionsSet.add(questionnaireOptions);
-       j++;
-     }
-   }
+   if (question.getOptions() != null && question.getOptions().length > 0) {
+     Integer[] scoreArr = question.getScores();
+     if (scoreArr == null || scoreArr.length != question.getOptions().length) {
+       throw new ECDException("Options and scores length mismatch for question: " + question.getQuestionnaire());
+     }
+     for (int j = 0; j < question.getOptions().length; j++) {
+       questionnaireOptions = new QualityAuditQuestionnaireValues();
+       questionnaireOptions.setQuestionValues(question.getOptions()[j]);
+       questionnaireOptions.setScore(scoreArr[j]);
+       questionnaireOptions.setPsmId(question.getPsmId());
+       questionnaireOptions.setCreatedBy(question.getCreatedBy());
+       optionsSet.add(questionnaireOptions);
+     }
+   }

    QualityAuditQuestionConfig resultSet = qualityAuditQuestionConfigRepo.save(question);
-   if (resultSet != null && resultSet.getId() != null && optionsSet != null && optionsSet.size() > 0) {
+   if (resultSet != null && resultSet.getId() != null && optionsSet != null && !optionsSet.isEmpty()) {
      for (QualityAuditQuestionnaireValues optionsValues : optionsSet) {
        optionsValues.setQuestionId(resultSet.getId());
      }
      qualityAuditQuestionnaireValuesRepo.saveAll(optionsSet);
    }
 }
🧹 Nitpick comments (3)
src/main/java/com/iemr/ecd/dto/ResponseCallAuditSectionQuestionMapDTO.java (1)

51-52: Roles field addition: consider suppressing nulls in JSON output

If roles is often absent, consider omitting it from serialized JSON when null to reduce payload noise.

Outside selected lines, you can annotate the DTO:

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;

@JsonInclude(Include.NON_NULL)
public class ResponseCallAuditSectionQuestionMapDTO {
  // ...
}
src/main/java/com/iemr/ecd/service/quality/QualityAuditImpl.java (1)

369-371: Trim and de-duplicate roles when splitting

Splitting on commas can leave leading/trailing spaces and empty tokens. Normalize to avoid UI/logic issues.

Apply this change:

- if(obj.getRole() != null && !obj.getRole().isEmpty()) {
-   responseDTO.setRoles(Arrays.asList(obj.getRole().split(",")));
- }
+ if (obj.getRole() != null && !obj.getRole().isEmpty()) {
+   responseDTO.setRoles(Arrays.stream(obj.getRole().split(","))
+       .map(String::trim)
+       .filter(s -> !s.isEmpty())
+       .distinct()
+       .toList());
+ }

Outside selected lines, add the import if needed:

import java.util.stream.Collectors; // if using collect(Collectors.toList())
src/main/java/com/iemr/ecd/service/quality/QualityAuditQuestionConfigurationImpl.java (1)

144-146: Trim and filter roles when splitting from SP output

Avoid whitespace/null entries and duplicates for cleaner downstream behavior.

Apply this diff:

- if (strArr[14] != null && !strArr[14].isEmpty()) {
-     obj.setRoles(Arrays.asList(strArr[14].split(",")));
- }
+ if (strArr[14] != null && !strArr[14].isEmpty()) {
+   obj.setRoles(Arrays.stream(strArr[14].split(","))
+       .map(String::trim)
+       .filter(s -> !s.isEmpty())
+       .distinct()
+       .toList());
+ }

Outside selected lines, add import if needed:

import java.util.stream.Collectors; // if using collect(Collectors.toList())
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 134779a and 4cae260.

📒 Files selected for processing (7)
  • pom.xml (1 hunks)
  • src/main/java/com/iemr/ecd/dao/QualityAuditQuestionConfig.java (2 hunks)
  • src/main/java/com/iemr/ecd/dao/V_get_Qualityaudit_SectionQuestionaireValues.java (1 hunks)
  • src/main/java/com/iemr/ecd/dto/QualityAuditorSectionQuestionaireResponseDTO.java (1 hunks)
  • src/main/java/com/iemr/ecd/dto/ResponseCallAuditSectionQuestionMapDTO.java (1 hunks)
  • src/main/java/com/iemr/ecd/service/quality/QualityAuditImpl.java (1 hunks)
  • src/main/java/com/iemr/ecd/service/quality/QualityAuditQuestionConfigurationImpl.java (4 hunks)
🔇 Additional comments (4)
pom.xml (1)

14-14: No hard-coded WAR names detected; artifact name is dynamic

  • pom.xml (line 253) defines <finalName>${artifactId}-${version}</finalName>
  • No occurrences of ecd-api-3.1.0.war or other versioned WAR filenames were found in the repository

Since the WAR name is derived from the updated <version>3.4.0</version>, no further changes are needed in CI/CD scripts within this repo.

src/main/java/com/iemr/ecd/dao/V_get_Qualityaudit_SectionQuestionaireValues.java (1)

79-81: Confirm DB view column and reserved word handling for "Role"

Ensure the view V_get_Qualityaudit_Sectionquestionairevalues exposes a column named Role exactly as mapped here. Also verify your RDBMS doesn’t require quoting for ROLE (reserved in some versions) to avoid runtime mapping errors.

src/main/java/com/iemr/ecd/dto/QualityAuditorSectionQuestionaireResponseDTO.java (1)

57-58: LGTM: roles added to response DTO

The addition aligns with service-side parsing and should serialize as expected with Lombok @DaTa.

src/main/java/com/iemr/ecd/service/quality/QualityAuditQuestionConfigurationImpl.java (1)

62-65: Good: flatten roles before persistence

Flattening early ensures consistent storage for Role while accepting a List in input.

Comment thread src/main/java/com/iemr/ecd/dao/QualityAuditQuestionConfig.java
@5Amogh
5Amogh requested review from drtechie and vanitha1822 August 12, 2025 03:27
@5Amogh
5Amogh merged commit a7fab10 into release-3.5.0 Aug 12, 2025
2 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Oct 29, 2025
1 task
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.

2 participants