Skip to content

Date Format changes#21

Merged
helenKaryamsetty merged 2 commits intoPSMRI:developfrom
ravishanigarapu:develop
Apr 23, 2025
Merged

Date Format changes#21
helenKaryamsetty merged 2 commits intoPSMRI:developfrom
ravishanigarapu:develop

Conversation

@ravishanigarapu
Copy link
Copy Markdown
Contributor

@ravishanigarapu ravishanigarapu commented Apr 22, 2025

📋 Description

JIRA ID: AMM-1381

Date format in API response.


✅ 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

  • Style
    • Updated date formatting in JSON outputs across multiple features to use a consistent, user-friendly date format.
  • Bug Fixes
    • Improved readability of date fields in exported data and reports.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 22, 2025

Walkthrough

This update standardizes JSON serialization across multiple controllers and service implementation classes by configuring Gson instances with a specific date format ("MMM d, yyyy h:mm:ss a" or a close variant). The changes replace direct uses of the default Gson constructor with GsonBuilder to ensure consistent date formatting in all serialized JSON responses. No modifications are made to control flow, error handling, or method signatures.

Changes

File(s) Change Summary
src/main/java/com/iemr/flw/controller/CoupleController.java Updated JSON serialization in getEligibleCoupleTracking to use GsonBuilder with a specific date format.
src/main/java/com/iemr/flw/controller/DeathReportsController.java Replaced default Gson with GsonBuilder (specific date format) in getCdrRecords and getMdsrRecords.
src/main/java/com/iemr/flw/service/impl/CbacServiceImpl.java Updated getByUserId to serialize response using GsonBuilder with a specific date format.
src/main/java/com/iemr/flw/service/impl/HRNonPregnantServiceImpl.java Changed getAllTracking to use GsonBuilder with a date format for JSON serialization.
src/main/java/com/iemr/flw/service/impl/HRPregnantServiceImpl.java Modified getAllAssessments and getAllTracking to use GsonBuilder with a date format for JSON output.
src/main/java/com/iemr/flw/service/impl/HighRiskServiceImpl.java Replaced direct Gson usage with GsonBuilder (date format) for JSON serialization.
src/main/java/com/iemr/flw/service/impl/TBScreeningServiceImpl.java Updated getByUserId to use GsonBuilder with a date format for JSON serialization.

Possibly related PRs

  • Feature/bug fix #12: Modifies CoupleController to use a Gson instance with a specific date format for JSON output, directly overlapping with the current changes.
  • Feature/bug fix #13: Updates JSON serialization in another method of CoupleController to use a date-formatted Gson instance, similar to the changes here.
  • Feature/bug fix #17: Alters JSON serialization in CoupleController but changes the serialization approach and method return types, related to JSON handling in the same class.

Suggested reviewers

  • helenKaryamsetty
  • devikasuresh20

Poem

In fields of code where data grows,
The rabbits tweak how date-time flows.
With GsonBuilder, dates align,
"MMM d, yyyy"—now they shine!
JSON replies are neat and bright,
Each timestamp formatted just right.
🐇✨ Serialization delight!


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between efdad12 and 066b093.

📒 Files selected for processing (1)
  • src/main/java/com/iemr/flw/service/impl/CbacServiceImpl.java (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/java/com/iemr/flw/service/impl/CbacServiceImpl.java

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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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

Copy link
Copy Markdown

@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

🔭 Outside diff range comments (1)
src/main/java/com/iemr/flw/service/impl/HRNonPregnantServiceImpl.java (1)

42-42: ⚠️ Potential issue

Inconsistent date formatting implementation

While date formatting has been standardized in the getAllTracking method, the getAllAssessment method still uses the default Gson constructor without specifying a date format. This inconsistency could result in different date formats across API responses.

-        return (new Gson().toJson(userDataDTO));
+        Gson gson = new GsonBuilder()
+                .setDateFormat("MMM d, yyyy h:mm:ss a")  // Set the desired date format
+                .create();
+        return gson.toJson(userDataDTO);
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between d14705b and efdad12.

📒 Files selected for processing (7)
  • src/main/java/com/iemr/flw/controller/CoupleController.java (1 hunks)
  • src/main/java/com/iemr/flw/controller/DeathReportsController.java (3 hunks)
  • src/main/java/com/iemr/flw/service/impl/CbacServiceImpl.java (1 hunks)
  • src/main/java/com/iemr/flw/service/impl/HRNonPregnantServiceImpl.java (2 hunks)
  • src/main/java/com/iemr/flw/service/impl/HRPregnantServiceImpl.java (3 hunks)
  • src/main/java/com/iemr/flw/service/impl/HighRiskServiceImpl.java (2 hunks)
  • src/main/java/com/iemr/flw/service/impl/TBScreeningServiceImpl.java (2 hunks)
🔇 Additional comments (8)
src/main/java/com/iemr/flw/service/impl/HighRiskServiceImpl.java (1)

38-41: Consistent date formatting enhancement

Good implementation using GsonBuilder to standardize date formatting in JSON responses. This follows best practices for controlling JSON serialization formats.

src/main/java/com/iemr/flw/controller/CoupleController.java (1)

115-118: Consistent date formatting implementation

Good implementation using GsonBuilder to standardize date formatting in JSON responses. This ensures dates appear in a consistent, readable format in API outputs.

src/main/java/com/iemr/flw/service/impl/TBScreeningServiceImpl.java (1)

64-67: Consistent date formatting approach

Good implementation using GsonBuilder to standardize date formatting in JSON responses, matching the pattern used in other service classes.

src/main/java/com/iemr/flw/service/impl/HRPregnantServiceImpl.java (2)

42-45: Improved date formatting standardization

The change from using the default Gson constructor to a GsonBuilder with a specific date format will ensure consistent date representation in the API responses for assessment data.


104-107: Consistent date formatting applied

Similar to the change in the getAllAssessments method, this modification ensures consistent date formatting in the tracking data responses, maintaining uniformity across the API.

src/main/java/com/iemr/flw/service/impl/HRNonPregnantServiceImpl.java (1)

77-80: Consistent date formatting applied

The change properly implements the standardized date format for the tracking data.

src/main/java/com/iemr/flw/controller/DeathReportsController.java (2)

90-93: Standardized date formatting for CDR records

The addition of a specific date format pattern ensures consistent date representation in CDR record responses, which is particularly important for death-related data where date accuracy is critical.


118-121: Standardized date formatting for MDSR records

Similar to the CDR records, this change applies consistent date formatting to MDSR record responses, ensuring uniformity in how dates are presented to API consumers.

Comment on lines +95 to +96
Gson gson = new GsonBuilder().setDateFormat("MMM dd, yyyy HH:mm:ss a").create();
return gson.toJson(response);
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

Date format inconsistency detected

While the implementation follows the correct pattern of using GsonBuilder, the date format pattern is inconsistent with other files:

  • Here: "MMM dd, yyyy HH:mm:ss a" (24-hour format with leading zeros for days)
  • Other files: "MMM d, yyyy h:mm:ss a" (12-hour format without leading zeros for days)

This inconsistency is also present within this same file, where line 130 uses the other format pattern.

Consider standardizing to one format pattern across all files:

-Gson gson = new GsonBuilder().setDateFormat("MMM dd, yyyy HH:mm:ss a").create();
+Gson gson = new GsonBuilder().setDateFormat("MMM d, yyyy h:mm:ss a").create();
📝 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
Gson gson = new GsonBuilder().setDateFormat("MMM dd, yyyy HH:mm:ss a").create();
return gson.toJson(response);
Gson gson = new GsonBuilder().setDateFormat("MMM d, yyyy h:mm:ss a").create();
return gson.toJson(response);

@helenKaryamsetty helenKaryamsetty merged commit 54a46e5 into PSMRI:develop Apr 23, 2025
@coderabbitai coderabbitai bot mentioned this pull request Apr 23, 2025
10 tasks
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