Skip to content

Update getServices API to V3#70

Merged
ravishanigarapu merged 40 commits intoPSMRI:developfrom
helenKaryamsetty:develop
Apr 9, 2025
Merged

Update getServices API to V3#70
ravishanigarapu merged 40 commits intoPSMRI:developfrom
helenKaryamsetty:develop

Conversation

@helenKaryamsetty
Copy link
Copy Markdown
Member

@helenKaryamsetty helenKaryamsetty commented Apr 8, 2025

📋 Description

JIRA ID: AMM-871

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
    • Updated facility service endpoints across environments for a more consistent and reliable data retrieval process.
  • Refactor
    • Enhanced facility information retrieval with improved authentication and error handling to ensure smoother and more stable operations.

KA40094929 and others added 30 commits December 13, 2024 18:38
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Apr 8, 2025

Quality Gate Failed Quality Gate failed

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

See analysis details on SonarQube Cloud

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 8, 2025

Walkthrough

This pull request updates the ABDM facility services endpoint across several configuration files, replacing the previous development service URL with a new structured API URL. Additionally, the FacilityServiceImpl.java file has been modified to replace the NDHM authentication mechanism with an ABHA-based approach, update HTTP header construction, and improve error handling with the use of RestTemplate for HTTP requests.

Changes

Files Change Summary
src/main/environment/common_ci.properties, src/main/environment/common_dev.properties, src/main/environment/common_example.properties, src/main/environment/common_test.properties Updated the getAbdmFacilityServicies URL from /devservice/v1/bridges/getServices to /api/hiecm/gateway/v3/bridge-services to reflect a new API structure.
src/main/java/com/wipro/.../facility/FacilityServiceImpl.java Replaced the NDHM authentication mechanism with ABHA authentication; added the xCMId variable; updated HTTP request handling using RestTemplate.exchange with improved headers and response validation.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant FacilityService
    participant GenerateAuthSessionService
    participant ABHA_Service_API

    Client->>FacilityService: Request Registered Facilities
    FacilityService->>GenerateAuthSessionService: Retrieve ABHA Token
    GenerateAuthSessionService-->>FacilityService: Return ABHA Token
    FacilityService->>ABHA_Service_API: Send HTTP request with new headers
    ABHA_Service_API-->>FacilityService: Return Response (Status 200 & Body)
    FacilityService-->>Client: Return Facilities Data
Loading

Possibly related PRs

Suggested reviewers

  • ravishanigarapu

Poem

I hopped through lines of code so fine,
Changing endpoints in a straight line.
From NDHM to ABHA, a leap so grand,
With headers updated as planned.
In a world of bits, I dance with glee,
A little rabbit celebrating our new API!
🐰🚀

✨ 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.
    • 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 plan to trigger planning for file edits and PR creation.
  • @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
Contributor

@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: 0

🧹 Nitpick comments (2)
src/main/java/com/wipro/fhir/service/facility/FacilityServiceImpl.java (2)

65-65: Creating a new RestTemplate instance locally.

Instantiating RestTemplate directly here is fine. For maintainability, consider using a Spring-managed bean if advanced configurations (e.g., timeouts, interceptors) become necessary.


86-86: Status code check with HttpStatusCode.valueOf(200).

This condition is correct, but you might prefer readability by directly comparing to HttpStatus.OK. For example:

- if (responseEntity.getStatusCode() == HttpStatusCode.valueOf(200) && responseEntity.hasBody()) {
+ if (responseEntity.getStatusCode() == HttpStatus.OK && responseEntity.hasBody()) {
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between ac14536 and 355e7f2.

📒 Files selected for processing (5)
  • src/main/environment/common_ci.properties (1 hunks)
  • src/main/environment/common_dev.properties (1 hunks)
  • src/main/environment/common_example.properties (1 hunks)
  • src/main/environment/common_test.properties (1 hunks)
  • src/main/java/com/wipro/fhir/service/facility/FacilityServiceImpl.java (4 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
src/main/java/com/wipro/fhir/service/facility/FacilityServiceImpl.java (2)
src/main/java/com/wipro/fhir/service/v3/abha/LoginAbhaV3ServiceImpl.java (1)
  • Service (41-377)
src/main/java/com/wipro/fhir/service/v3/abha/CreateAbhaV3ServiceImpl.java (1)
  • Service (48-459)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Analyze (java)
🔇 Additional comments (10)
src/main/environment/common_example.properties (1)

88-88: Consistent endpoint update to V3.

The new endpoint https://dev.abdm.gov.in/api/hiecm/gateway/v3/bridge-services aligns with the pull request goal of upgrading to version 3. No issues detected with this configuration change.

src/main/environment/common_test.properties (1)

85-85: Consistent endpoint update to V3.

This matches the other environment files and ensures the test configuration also points to the new V3 endpoint. Looks good.

src/main/environment/common_ci.properties (1)

85-85: Property updated to use V3 endpoint.

Switching to @env.ABDM_BASE_URL@/api/hiecm/gateway/v3/bridge-services appears correct for the CI environment. Ensure CI environment variables match the new endpoint needs.

src/main/environment/common_dev.properties (1)

85-85: Update to new getServices URL for dev environment.

The updated endpoint is consistent with the V3 migration. No concerns identified.

src/main/java/com/wipro/fhir/service/facility/FacilityServiceImpl.java (6)

3-10: New date/time imports.

These imports (DateFormat, SimpleDateFormat, Date, TimeZone, UUID) are introduced to format timestamps and generate unique request IDs. They appear correct for constructing V3-compliant headers.


14-18: Spring & service imports for updated HTTP handling.

The additional imports (HttpEntity, HttpMethod, HttpStatusCode, MediaType, LinkedMultiValueMap, RestTemplate) and the new GenerateAuthSessionService are consistent with the revised approach for ABHA-based authentication and request handling. They look properly integrated.

Also applies to: 21-23, 34-34


46-48: Added xCMId property.

Pulling "x-CM-ID" from properties is useful, especially if the gateway requires it as a custom header. This helps keep environment-specific values configurable.


56-56: Replaced NDHM session fetch with ABHA session.

Using GenerateAuthSessionService instead of GenerateSession_NDHMService aligns with the migration to ABHA-based auth. Ensure that dependent code or references to the old NDHM service are fully removed to avoid confusion.


68-80: Building request headers with ABHA token, timestamp, and X-CM-ID.

This setup properly includes:

  • Random REQUEST-ID
  • UTC-based timestamp
  • Authorization header with ABHA token
  • X-CM-ID header

These headers align with typical ABHA gateway requirements. The logic appears correct and consistent.


81-84: Using RestTemplate.exchange for the GET request.

Switching to exchange for more flexible request handling is a good move. Just ensure any downstream exceptions are handled or logged adequately.

Copy link
Copy Markdown
Contributor

@ravishanigarapu ravishanigarapu left a comment

Choose a reason for hiding this comment

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

looks fine

@ravishanigarapu ravishanigarapu merged commit 2ecec43 into PSMRI:develop Apr 9, 2025
6 of 7 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.

2 participants