Skip to content

Conversation

@vanitha1822
Copy link
Member

@vanitha1822 vanitha1822 commented May 21, 2025

Description

Jira ID: AMM-1419

Add the functionality to include the chief complaints data to store and retrieve from nurse and doctor module.

Type of change

  • Enhancement

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Please also note any relevant details for your test configuration.

  • Test A
  • Test B

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules

Summary by CodeRabbit

  • New Features

    • Chief complaints now include both visit ID and visit code details for each entry, enhancing data accuracy and traceability.
  • Bug Fixes

    • Chief complaints are now correctly sourced from each individual entry rather than from the overall case sheet, improving data integrity.
  • Improvements

    • Quick Consultation nurse workflows now provide actual master data for relevant visit categories instead of a static message.
    • Chief complaints are displayed in a more structured format during doctor visit details retrieval, ensuring only valid entries are shown.

@coderabbitai
Copy link

coderabbitai bot commented May 21, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

The changes update the handling of chief complaints in quick consultation workflows. Chief complaint data is now sourced from individual complaint objects rather than the root JSON. Additional logging is introduced. The master data service for nurses now returns actual data for QuickConsultation visits. Chief complaint insertion and retrieval logic is revised to use updated key names, add extra properties, and improve deserialization.

Changes

File(s) Change Summary
src/main/java/com/iemr/hwc/data/quickConsultation/BenChiefComplaint.java Added a static SLF4J logger. Modified getBenChiefComplaintList to extract benVisitID and visitCode from each chief complaint object instead of the root.
src/main/java/com/iemr/hwc/service/common/master/CommonMasterServiceImpl.java Changed handling for visitCategoryID 7: replaced fixed message return with call to ancMasterDataServiceImpl.getCommonNurseMasterDataForGenopdAncNcdcarePnc, providing actual master data for QuickConsultation visits.
src/main/java/com/iemr/hwc/service/quickConsultation/QuickConsultationServiceImpl.java Updated chief complaints handling: changed key from "chiefComplaints" to "chiefComplaintList", added visitCode to each complaint, updated insertion and retrieval logic to use new structure and improved deserialization and response logic.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant QuickConsultationServiceImpl
    participant BenChiefComplaint
    participant MasterDataService

    Client->>QuickConsultationServiceImpl: Insert nurse data (with chiefComplaintList)
    QuickConsultationServiceImpl->>BenChiefComplaint: For each chief complaint, set benVisitID & visitCode
    QuickConsultationServiceImpl->>QuickConsultationServiceImpl: Save chief complaints
    QuickConsultationServiceImpl->>MasterDataService: Get master data for nurse (visitCategoryID=7)
    MasterDataService-->>QuickConsultationServiceImpl: Return actual master data

    Client->>QuickConsultationServiceImpl: Get nurse-to-doctor visit details
    QuickConsultationServiceImpl->>BenChiefComplaint: Deserialize chiefComplaintList JSON
    QuickConsultationServiceImpl->>Client: Return response with chiefComplaintList (if non-empty)
Loading

Poem

In the warren of code, a change takes root,
Chief complaints now carry more loot—
With visit codes logged, and data refined,
Nurses and doctors more closely aligned.
QuickConsultation hops ahead with cheer,
As rabbits code onward, improvements appear! 🐇✨

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.


Note

⚡️ Faster reviews with caching

CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 30th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.
Enjoy the performance boost—your workflow just got faster.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between f9a95b1 and c60dba8.

📒 Files selected for processing (1)
  • src/main/java/com/iemr/hwc/data/quickConsultation/BenChiefComplaint.java (4 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings

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.
    • Explain this complex logic.
    • 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. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • 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 src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

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

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

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

Documentation and Community

  • 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.

@vanitha1822 vanitha1822 requested a review from drtechie May 21, 2025 09:04
@vanitha1822 vanitha1822 self-assigned this May 21, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
src/main/java/com/iemr/hwc/data/quickConsultation/BenChiefComplaint.java (1)

376-379: Consider using debug level for diagnostic logs.

While adding logging is good, using info level for debugging details like IDs may generate excessive logs in production. Consider using debug level instead.

-logger.info("Visit id="+obj.get("benVisitID"));
-logger.info("Visit code="+obj.get("visitCode"));
+logger.debug("Visit id="+obj.get("benVisitID"));
+logger.debug("Visit code="+obj.get("visitCode"));
src/main/java/com/iemr/hwc/service/quickConsultation/QuickConsultationServiceImpl.java (1)

500-501: Consider converting to ArrayList instead of Arrays.asList.

Using Arrays.asList creates a fixed-size list backed by the array. If there's any chance the list might need modification later, consider using a new ArrayList instead.

-List<BenChiefComplaint> benChiefComplaints = Arrays.asList(complaintsArray);
+List<BenChiefComplaint> benChiefComplaints = new ArrayList<>(Arrays.asList(complaintsArray));
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 69f72dc and f9a95b1.

📒 Files selected for processing (3)
  • src/main/java/com/iemr/hwc/data/quickConsultation/BenChiefComplaint.java (4 hunks)
  • src/main/java/com/iemr/hwc/service/common/master/CommonMasterServiceImpl.java (1 hunks)
  • src/main/java/com/iemr/hwc/service/quickConsultation/QuickConsultationServiceImpl.java (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Analyze (java)
🔇 Additional comments (8)
src/main/java/com/iemr/hwc/data/quickConsultation/BenChiefComplaint.java (4)

34-36: Good addition of proper logging.

Adding SLF4J logger is a good practice for better log management and debugging capabilities.


348-349: Proper logger initialization.

The logger is correctly initialized as private static final, following best practices.


362-366: Correct refactor to improve data structure handling.

Commenting out the previous code that extracted benVisitID and visitCode from the root JSON object is the right approach, as the new implementation will extract these values from each individual complaint object.


380-384: Improved data extraction from individual complaint objects.

This change properly sets benVisitID and visitCode from each individual complaint object rather than from the root JSON, which aligns with the updated JSON structure. This ensures each complaint is properly associated with the correct visit.

src/main/java/com/iemr/hwc/service/common/master/CommonMasterServiceImpl.java (1)

129-133: Good enhancement to provide actual master data for QuickConsultation.

Replacing the static message with actual master data retrieval improves consistency across visit categories and provides necessary data for the QuickConsultation workflow. This change aligns well with the overall objective of enhancing chief complaints functionality.

src/main/java/com/iemr/hwc/service/quickConsultation/QuickConsultationServiceImpl.java (3)

249-259: Enhanced chief complaint handling with proper linking to visit data.

The updated code correctly augments each chief complaint with benVisitID and visitCode, ensuring proper data linkage between complaints and visits. This change supports the PR objective of enhancing chief complaints data storage.


262-262: Improved validation for chief complaint saving.

Adding a non-null and greater-than-zero check for benChiefComplaintID provides better validation for successful chief complaint data saving.


498-509: Improved chief complaint deserialization and conditional response inclusion.

The updated code properly deserializes the chief complaints JSON into an array of BenChiefComplaint objects and conditionally includes them in the response map only if the list is not empty. This improves data handling and prevents returning empty collections.

Comment on lines +251 to +259
JsonArray chiefComplaintArray = jsnOBJ.getAsJsonArray("chiefComplaintList");

for (JsonElement element : chiefComplaintArray) {
JsonObject complaint = element.getAsJsonObject();
complaint.addProperty("benVisitID", benVisitID);
complaint.addProperty("visitCode", benVisitCode);
}

benChiefComplaintID = saveBeneficiaryChiefComplaint(jsnOBJ);
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Validate JSON array existence before processing.

The code currently assumes chiefComplaintArray is not null. Add a null check to prevent potential NullPointerException if the array is missing.

-JsonArray chiefComplaintArray = jsnOBJ.getAsJsonArray("chiefComplaintList");
-
-for (JsonElement element : chiefComplaintArray) {
-    JsonObject complaint = element.getAsJsonObject();
-    complaint.addProperty("benVisitID", benVisitID);
-    complaint.addProperty("visitCode", benVisitCode);
-}
+if (jsnOBJ.has("chiefComplaintList") && !jsnOBJ.get("chiefComplaintList").isJsonNull()) {
+    JsonArray chiefComplaintArray = jsnOBJ.getAsJsonArray("chiefComplaintList");
+    
+    for (JsonElement element : chiefComplaintArray) {
+        JsonObject complaint = element.getAsJsonObject();
+        complaint.addProperty("benVisitID", benVisitID);
+        complaint.addProperty("visitCode", benVisitCode);
+    }
+}
🤖 Prompt for AI Agents
In
src/main/java/com/iemr/hwc/service/quickConsultation/QuickConsultationServiceImpl.java
around lines 251 to 259, the code assumes the JSON array chiefComplaintList
exists without checking for null, which can cause a NullPointerException. Add a
null check to verify that chiefComplaintArray is not null before iterating over
it. Only process the array elements if the array is present to prevent runtime
exceptions.

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
8.6% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@vanitha1822 vanitha1822 merged commit 246aafb into develop May 21, 2025
5 of 6 checks passed
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.

3 participants