Skip to content

Conversation

@helenKaryamsetty
Copy link
Member

@helenKaryamsetty helenKaryamsetty commented Dec 30, 2025

πŸ“‹ Description

JIRA ID: AMM-1856, AMM-1885, AMM-1886, AMM-1884, AMM-1803

Merging abdmV3 to 3.6.1 for release


βœ… 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

Release Notes v3.6.1

  • New Features

    • Added care context token generation and linking functionality for ABDM V3 M2 API integration
    • Expanded medical record support to include immunization, wellness, and discharge summary records
  • Improvements

    • Updated core dependencies for enhanced performance and security

✏️ Tip: You can customize this high-level summary in your review settings.

helenKaryamsetty and others added 15 commits October 7, 2025 12:45
* Abdm Facility fetch services changes

* facility save after carecontext and patientcarecontextx update

* FacilityId save in mongo db and Variable declaration correction

* Mongo carecontext save query logic changes

* ABHA Creation M1 V3 API changes

* Abha V3 changes

* removed unused code

* v3- verify auth by abdm API changes

* feat: Abdm M2 V3 changes

---------

Co-authored-by: KA40094929 <KA40094929@10.152.32.202>
Co-authored-by: KA40094929 <KA40094929@APL-5CD1394ZJT>
Co-authored-by: Karyamsetty Helen Grace <ka40094929@wipro.com>
* Abdm Facility fetch services changes

* facility save after carecontext and patientcarecontextx update

* FacilityId save in mongo db and Variable declaration correction

* Mongo carecontext save query logic changes

* ABHA Creation M1 V3 API changes

* Abha V3 changes

* removed unused code

* v3- verify auth by abdm API changes

* feat: Abdm M2 V3 changes

* feat: mongo query change fetch for linktoken

---------

Co-authored-by: KA40094929 <KA40094929@10.152.32.202>
Co-authored-by: KA40094929 <KA40094929@APL-5CD1394ZJT>
Co-authored-by: Karyamsetty Helen Grace <ka40094929@wipro.com>
* Abdm Facility fetch services changes

* facility save after carecontext and patientcarecontextx update

* FacilityId save in mongo db and Variable declaration correction

* Mongo carecontext save query logic changes

* ABHA Creation M1 V3 API changes

* Abha V3 changes

* removed unused code

* v3- verify auth by abdm API changes

* feat: Abdm M2 V3 changes

* feat: mongo query change fetch for linktoken

* fix: link carecontext authorization error

---------

Co-authored-by: KA40094929 <KA40094929@10.152.32.202>
Co-authored-by: KA40094929 <KA40094929@APL-5CD1394ZJT>
Co-authored-by: Karyamsetty Helen Grace <ka40094929@wipro.com>
* Abdm Facility fetch services changes

* facility save after carecontext and patientcarecontextx update

* FacilityId save in mongo db and Variable declaration correction

* Mongo carecontext save query logic changes

* ABHA Creation M1 V3 API changes

* Abha V3 changes

* removed unused code

* v3- verify auth by abdm API changes

* feat: Abdm M2 V3 changes

* feat: mongo query change fetch for linktoken

* fix: link carecontext authorization error

* feat: hiTypes addition

* feat: version change for testing

* fix: corrected spelling mistake

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* fix: modified repo queries

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: KA40094929 <KA40094929@10.152.32.202>
Co-authored-by: KA40094929 <KA40094929@APL-5CD1394ZJT>
Co-authored-by: Karyamsetty Helen Grace <ka40094929@wipro.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Abdm Facility fetch services changes

* facility save after carecontext and patientcarecontextx update

* FacilityId save in mongo db and Variable declaration correction

* Mongo carecontext save query logic changes

* ABHA Creation M1 V3 API changes

* Abha V3 changes

* removed unused code

* v3- verify auth by abdm API changes

* feat: Abdm M2 V3 changes

* feat: mongo query change fetch for linktoken

* fix: link carecontext authorization error

* feat: hiTypes addition

* feat: version change for testing

* fix: minor change for empty response

* Simplify queries in CareContextRepo interface

Removed unnecessary 'order by 1 desc' clause from queries.

---------

Co-authored-by: KA40094929 <KA40094929@10.152.32.202>
Co-authored-by: KA40094929 <KA40094929@APL-5CD1394ZJT>
Co-authored-by: Karyamsetty Helen Grace <ka40094929@wipro.com>
* Abdm Facility fetch services changes

* facility save after carecontext and patientcarecontextx update

* FacilityId save in mongo db and Variable declaration correction

* Mongo carecontext save query logic changes

* ABHA Creation M1 V3 API changes

* Abha V3 changes

* removed unused code

* v3- verify auth by abdm API changes

* feat: Abdm M2 V3 changes

* feat: mongo query change fetch for linktoken

* fix: link carecontext authorization error

* feat: hiTypes addition

* feat: version change for testing

* fix: minor change for empty response

* Simplify queries in CareContextRepo interface

Removed unnecessary 'order by 1 desc' clause from queries.

* fix: corrected response format

---------

Co-authored-by: KA40094929 <KA40094929@10.152.32.202>
Co-authored-by: KA40094929 <KA40094929@APL-5CD1394ZJT>
Co-authored-by: Karyamsetty Helen Grace <ka40094929@wipro.com>
* Abdm Facility fetch services changes

* facility save after carecontext and patientcarecontextx update

* FacilityId save in mongo db and Variable declaration correction

* Mongo carecontext save query logic changes

* ABHA Creation M1 V3 API changes

* Abha V3 changes

* removed unused code

* v3- verify auth by abdm API changes

* feat: Abdm M2 V3 changes

* feat: mongo query change fetch for linktoken

* fix: link carecontext authorization error

* feat: hiTypes addition

* feat: version change for testing

* fix: minor change for empty response

* Simplify queries in CareContextRepo interface

Removed unnecessary 'order by 1 desc' clause from queries.

* fix: corrected response format

* fix: minor logic change for care context linking

---------

Co-authored-by: KA40094929 <KA40094929@10.152.32.202>
Co-authored-by: KA40094929 <KA40094929@APL-5CD1394ZJT>
Co-authored-by: Karyamsetty Helen Grace <ka40094929@wipro.com>
* Abdm Facility fetch services changes

* facility save after carecontext and patientcarecontextx update

* FacilityId save in mongo db and Variable declaration correction

* Mongo carecontext save query logic changes

* ABHA Creation M1 V3 API changes

* Abha V3 changes

* removed unused code

* v3- verify auth by abdm API changes

* feat: Abdm M2 V3 changes

* feat: mongo query change fetch for linktoken

* fix: link carecontext authorization error

* feat: hiTypes addition

* feat: version change for testing

* fix: minor change for empty response

* Simplify queries in CareContextRepo interface

Removed unnecessary 'order by 1 desc' clause from queries.

* fix: corrected response format

* fix: minor logic change for care context linking

* small correction in hiType and error message modification

* Fix display setting for patient care context

---------

Co-authored-by: KA40094929 <KA40094929@10.152.32.202>
Co-authored-by: KA40094929 <KA40094929@APL-5CD1394ZJT>
Co-authored-by: Karyamsetty Helen Grace <ka40094929@wipro.com>
* Abdm Facility fetch services changes

* facility save after carecontext and patientcarecontextx update

* FacilityId save in mongo db and Variable declaration correction

* Mongo carecontext save query logic changes

* ABHA Creation M1 V3 API changes

* Abha V3 changes

* removed unused code

* v3- verify auth by abdm API changes

* feat: Abdm M2 V3 changes

* feat: mongo query change fetch for linktoken

* fix: link carecontext authorization error

* feat: hiTypes addition

* feat: version change for testing

* fix: minor change for empty response

* Simplify queries in CareContextRepo interface

Removed unnecessary 'order by 1 desc' clause from queries.

* fix: corrected response format

* fix: minor logic change for care context linking

* small correction in hiType and error message modification

* modified error message

---------

Co-authored-by: KA40094929 <KA40094929@10.152.32.202>
Co-authored-by: KA40094929 <KA40094929@APL-5CD1394ZJT>
Co-authored-by: Karyamsetty Helen Grace <ka40094929@wipro.com>
* Abdm Facility fetch services changes

* facility save after carecontext and patientcarecontextx update

* FacilityId save in mongo db and Variable declaration correction

* Mongo carecontext save query logic changes

* ABHA Creation M1 V3 API changes

* Abha V3 changes

* removed unused code

* v3- verify auth by abdm API changes

* feat: Abdm M2 V3 changes

* feat: mongo query change fetch for linktoken

* fix: link carecontext authorization error

* feat: hiTypes addition

* feat: version change for testing

* fix: minor change for empty response

* Simplify queries in CareContextRepo interface

Removed unnecessary 'order by 1 desc' clause from queries.

* fix: corrected response format

* fix: minor logic change for care context linking

* small correction in hiType and error message modification

* modified error message

* feat: new standard FHIR bundles creation

* Fix environment variable for systemUrl

* Fix formatting of systemUrl property

* fix: taken coderabbitai comments and minor changes

---------

Co-authored-by: KA40094929 <KA40094929@10.152.32.202>
Co-authored-by: KA40094929 <KA40094929@APL-5CD1394ZJT>
Co-authored-by: Karyamsetty Helen Grace <ka40094929@wipro.com>
* Abdm Facility fetch services changes

* facility save after carecontext and patientcarecontextx update

* FacilityId save in mongo db and Variable declaration correction

* Mongo carecontext save query logic changes

* ABHA Creation M1 V3 API changes

* Abha V3 changes

* removed unused code

* v3- verify auth by abdm API changes

* feat: Abdm M2 V3 changes

* feat: mongo query change fetch for linktoken

* fix: link carecontext authorization error

* feat: hiTypes addition

* feat: version change for testing

* fix: minor change for empty response

* Simplify queries in CareContextRepo interface

Removed unnecessary 'order by 1 desc' clause from queries.

* fix: corrected response format

* fix: minor logic change for care context linking

* small correction in hiType and error message modification

* modified error message

* feat: new standard FHIR bundles creation

* Fix environment variable for systemUrl

* Fix formatting of systemUrl property

* fix: taken coderabbitai comments and minor changes

* fix: changed missed variable

---------

Co-authored-by: KA40094929 <KA40094929@10.152.32.202>
Co-authored-by: KA40094929 <KA40094929@APL-5CD1394ZJT>
Co-authored-by: Karyamsetty Helen Grace <ka40094929@wipro.com>
* Abdm Facility fetch services changes

* facility save after carecontext and patientcarecontextx update

* FacilityId save in mongo db and Variable declaration correction

* Mongo carecontext save query logic changes

* ABHA Creation M1 V3 API changes

* Abha V3 changes

* removed unused code

* v3- verify auth by abdm API changes

* feat: Abdm M2 V3 changes

* feat: mongo query change fetch for linktoken

* fix: link carecontext authorization error

* feat: hiTypes addition

* feat: version change for testing

* fix: minor change for empty response

* Simplify queries in CareContextRepo interface

Removed unnecessary 'order by 1 desc' clause from queries.

* fix: corrected response format

* fix: minor logic change for care context linking

* small correction in hiType and error message modification

* modified error message

* feat: new standard FHIR bundles creation

* Fix environment variable for systemUrl

* Fix formatting of systemUrl property

* fix: taken coderabbitai comments and minor changes

* fix: changed missed variable

* fix: modified the constructor

* Change exception message for Organization resource

* Fix typo in exception message for PractitionerDataModel

---------

Co-authored-by: KA40094929 <KA40094929@10.152.32.202>
Co-authored-by: KA40094929 <KA40094929@APL-5CD1394ZJT>
Co-authored-by: Karyamsetty Helen Grace <ka40094929@wipro.com>
* Abdm Facility fetch services changes

* facility save after carecontext and patientcarecontextx update

* FacilityId save in mongo db and Variable declaration correction

* Mongo carecontext save query logic changes

* ABHA Creation M1 V3 API changes

* Abha V3 changes

* removed unused code

* v3- verify auth by abdm API changes

* feat: Abdm M2 V3 changes

* feat: mongo query change fetch for linktoken

* fix: link carecontext authorization error

* feat: hiTypes addition

* feat: version change for testing

* fix: minor change for empty response

* Simplify queries in CareContextRepo interface

Removed unnecessary 'order by 1 desc' clause from queries.

* fix: corrected response format

* fix: minor logic change for care context linking

* small correction in hiType and error message modification

* modified error message

* feat: new standard FHIR bundles creation

* Fix environment variable for systemUrl

* Fix formatting of systemUrl property

* fix: taken coderabbitai comments and minor changes

* fix: changed missed variable

* fix: modified the constructor

* Change exception message for Organization resource

* Fix typo in exception message for PractitionerDataModel

* fix: corrected type error

---------

Co-authored-by: KA40094929 <KA40094929@10.152.32.202>
Co-authored-by: KA40094929 <KA40094929@APL-5CD1394ZJT>
Co-authored-by: Karyamsetty Helen Grace <ka40094929@wipro.com>
* Abdm Facility fetch services changes

* facility save after carecontext and patientcarecontextx update

* FacilityId save in mongo db and Variable declaration correction

* Mongo carecontext save query logic changes

* ABHA Creation M1 V3 API changes

* Abha V3 changes

* removed unused code

* v3- verify auth by abdm API changes

* feat: Abdm M2 V3 changes

* feat: mongo query change fetch for linktoken

* fix: link carecontext authorization error

* feat: hiTypes addition

* feat: version change for testing

* fix: minor change for empty response

* Simplify queries in CareContextRepo interface

Removed unnecessary 'order by 1 desc' clause from queries.

* fix: corrected response format

* fix: minor logic change for care context linking

* small correction in hiType and error message modification

* modified error message

* feat: new standard FHIR bundles creation

* Fix environment variable for systemUrl

* Fix formatting of systemUrl property

* fix: taken coderabbitai comments and minor changes

* fix: changed missed variable

* fix: modified the constructor

* Change exception message for Organization resource

* Fix typo in exception message for PractitionerDataModel

* fix: corrected type error

* fix: correct medication histoory model class

---------

Co-authored-by: KA40094929 <KA40094929@10.152.32.202>
Co-authored-by: KA40094929 <KA40094929@APL-5CD1394ZJT>
Co-authored-by: Karyamsetty Helen Grace <ka40094929@wipro.com>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 30, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

πŸ“ Walkthrough

Walkthrough

Major refactoring of FHIR resource bundle creation, including relocation and renaming of bundle processing interfaces/implementations from resource_gateway to bundle_creation package, addition of care context linking support, new data models, updated resource factories, and dependency version upgrades (Jackson, HAPI FHIR, Lombok).

Changes

Cohort / File(s) Summary
Dependency Updates
.factorypath, pom.xml
Updated Lombok (1.18.36β†’1.18.30), Jackson (2.14.2β†’2.15.2), and HAPI FHIR (6.10.0β†’8.4.0) with validation/caching modules; project version bumped to 3.6.1.
Configuration Properties
src/main/environment/common_*.properties
Added ABDM V3 M2 API endpoints (generateTokenForLinkCareContext, linkCareContext) and hipSystemUrl configuration across CI, Docker, and example properties files.
Bundle Service Refactoring – Old Interfaces/Implementations Removed
src/main/java/com/wipro/fhir/service/resource_gateway/OPConsultRecordBundle.java, OPConsultRecordBundleImpl.java, PrescriptionRecordBundle.java, PrescriptionRecordBundleImpl.java, DiagnosticReportRecord.java, DiagnosticReportRecordImpl.java
Removed deprecated bundle interfaces and implementations from resource_gateway; these are replaced by new versions in bundle_creation.
Bundle Service Refactoring – New Interfaces
src/main/java/com/wipro/fhir/service/bundle_creation/OPConsultResourceBundle.java, PrescriptionResourceBundle.java, DiagnosticRecordResourceBundle.java, ImmunizationRecordResourceBundle.java, DischargeSummaryResourceBundle.java, WellnessRecordResourceBundle.java
New interfaces defining contracts for bundle population and processing; includes composition, bundle generation, and record handling methods.
Bundle Service Refactoring – New Implementations
src/main/java/com/wipro/fhir/service/bundle_creation/OPConsultResourceBundleImpl.java, PrescriptionResourceBundleImpl.java, DiagnosticRecordResourceBundleImpl.java, ImmunizationRecordResourceBundleImpl.java, DischargeSummaryResourceBundleImpl.java, WellnessRecordResourceBundleImpl.java
New Spring service implementations with autowired resources, bundle serialization, and Mongo persistence logic for each document type. Each includes composition builders and resource aggregation.
Bundle Utility & Validation
src/main/java/com/wipro/fhir/service/bundle_creation/BundleValidator.java
New standalone utility for FHIR bundle validation setup (context, validation support chain, FhirValidator initialization).
Data Models – Resource-Specific
src/main/java/com/wipro/fhir/data/resource_model/ImmunizationDataModel.java, MedicalHistoryDataModel.java, OrganizationDataModel.java, PractitionerDataModel.java
New data model classes with constructors for Object[] mapping, null-safe field assignments, and factory methods for converting result sets to typed lists.
Data Models – Care Context DTOs
src/main/java/com/wipro/fhir/data/v3/careContext/AddCareContextRequest.java, CareContextLinkTokenRequest.java, GenerateCareContextTokenRequest.java, LinkCareContextRequest.java, PatientCareContext.java, CareContexts.java
New Lombok @Data DTOs for care context linking requests/responses; define fields for ABHA identifiers, tokens, facility/visit details, and reference/display info.
MongoDB Entities & Repositories
src/main/java/com/wipro/fhir/data/mongo/care_context/GenerateTokenAbdmResponses.java, src/main/java/com/wipro/fhir/repo/mongo/generateToken_response/GenerateTokenAbdmResponsesRepo.java
New MongoDB document entity with id, abhaAddress, requestId, response, createdDate fields; new Spring Data MongoDB repository with find methods by abhaAddress and requestId.
JPA Repository Extensions
src/main/java/com/wipro/fhir/repo/common/PatientEligibleForResourceCreationRepo.java, src/main/java/com/wipro/fhir/repo/v3/careContext/CareContextRepo.java
Added four SP wrapper methods to existing repo; new CareContextRepo with four native query methods (hasPhyVitals, hasPrescribedDrugs, hasLabtestsDone, hasVaccineDetails) for existence checks by visitCode.
Care Context Service Layer
src/main/java/com/wipro/fhir/service/v3/careContext/CareContextLinkingService.java, CareContextLinkingServiceImpl.java
New interface and Spring service implementation for token generation and care context linking with ABDM endpoint calls, Mongo lookups, header building, and JSON response mapping.
Care Context REST Controller
src/main/java/com/wipro/fhir/controller/v3/careContext/CareContextLinkingController.java
New Spring REST controller with two POST endpoints: /careContext/generateCareContextToken and /careContext/linkCareContext, delegating to CareContextLinkingService with error handling.
Controller & Gateway Updates
src/main/java/com/wipro/fhir/controller/generateresource/ResourceRequestGateway.java, src/main/java/com/wipro/fhir/controller/test/Test.java, src/main/java/com/wipro/fhir/controller/v3/abha/CreateAbhaV3Controller.java
Updated bundle class types and method names (DiagnosticReportRecord→DiagnosticRecordResourceBundle, method getXXXBundle→PopulateXXXResourceBundle); added @CrossOrigin to verifyAuthByAbdm endpoint.
Common Service Refactoring
src/main/java/com/wipro/fhir/service/common/CommonServiceImpl.java
Replaced old bundle component references with new interfaces; added conditional processing guards via CareContextRepo existence checks; introduced cumulative processed flag for multiple resource types (OP consult, lab tests, prescriptions, wellness, immunization, discharge summary).
NDHM Service Updates
src/main/java/com/wipro/fhir/service/ndhm/Common_NDHMService.java, Common_NDHMServiceImpl.java
Added getLinkToken interface method and implementation with GenerateTokenAbdmResponsesRepo query; added logging for token retrieval.
Resource Model Services – Refactored
src/main/java/com/wipro/fhir/service/resource_model/EncounterResource.java, ObservationResource.java, OrganizationResource.java, PractitionerResource.java, MedicationRequestResource.java
Removed unused imports (BigInteger); refactored to accept data models instead of hard-coded values; updated method signatures (removed Encounter/Appointment params); added database-driven resource generation and systemUrl configuration.
Resource Model Services – New
src/main/java/com/wipro/fhir/service/resource_model/ImmunizationResource.java, MedicalHistoryResource.java
New services for building Immunization and MedicationStatement resources from data models; fetch via SP calls and transform into FHIR R4 resources.
Miscellaneous
src/main/java/com/wipro/fhir/service/ndhm/LinkCareContext_NDHMServiceImpl.java, src/main/java/com/wipro/fhir/service/v3/abha/CreateAbhaV3ServiceImpl.java
Added log statement for HTTP response in LinkCareContext service; removed empty line in CreateAbhaV3ServiceImpl (formatting only).

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant CareContextCtrl as CareContextLinkingController
    participant Service as CareContextLinkingServiceImpl
    participant Repo as GenerateTokenAbdmResponsesRepo
    participant ABDM as ABDM API
    participant Mongo as MongoDB

    Client->>CareContextCtrl: POST /careContext/generateCareContextToken
    activate CareContextCtrl
    CareContextCtrl->>Service: generateTokenForCareContext(request)
    activate Service
    Service->>Service: Parse request, extract abhaAddress
    Service->>Repo: findByAbhaAddress(abhaAddress)
    activate Repo
    Repo-->>Service: Prior response (if exists & valid)
    deactivate Repo
    
    alt Token exists & valid (< 3 months)
        Service-->>CareContextCtrl: Return cached linkToken
    else Token missing or expired
        Service->>ABDM: POST /api/hiecm/v3/token/generate-token
        activate ABDM
        ABDM-->>Service: 202 Accepted with requestId
        deactivate ABDM
        Service->>Service: Poll/retrieve LinkToken from Mongo
        Service->>Mongo: Store generateTokenAbdmResponses
        activate Mongo
        Mongo-->>Service: Saved
        deactivate Mongo
    end
    Service-->>CareContextCtrl: JSON response (linkToken/error)
    deactivate Service
    CareContextCtrl-->>Client: OutputResponse with linkToken
    deactivate CareContextCtrl

    Client->>CareContextCtrl: POST /careContext/linkCareContext
    activate CareContextCtrl
    CareContextCtrl->>Service: linkCareContext(request)
    activate Service
    Service->>Service: Extract/resolve linkToken
    Service->>ABDM: POST /api/hiecm/hip/v3/link/carecontext
    activate ABDM
    ABDM-->>Service: Success or error response
    deactivate ABDM
    Service-->>CareContextCtrl: JSON response (success/error)
    deactivate Service
    CareContextCtrl-->>Client: OutputResponse
    deactivate CareContextCtrl
Loading
sequenceDiagram
    participant Request as Patient Resource Request
    participant CommonSvc as CommonServiceImpl
    participant OPBundle as OPConsultResourceBundleImpl
    participant Resources as Resource Factories
    participant FHIRCtx as FHIR Context
    participant Mongo as MongoDB

    Request->>CommonSvc: processResourceOperation()
    activate CommonSvc
    
    CommonSvc->>CommonSvc: Check visit category & type
    
    alt OP Consult (General OPD)
        CommonSvc->>OPBundle: processOpConsultRecordBundle()
        activate OPBundle
        OPBundle->>Resources: Fetch Practitioner, Organization, Patient
        activate Resources
        Resources-->>OPBundle: Resource objects
        deactivate Resources
        OPBundle->>OPBundle: PopulateOpConsultRecordResourceBundle()
        OPBundle->>FHIRCtx: Serialize Bundle to JSON
        activate FHIRCtx
        FHIRCtx-->>OPBundle: JSON bundle string
        deactivate FHIRCtx
        OPBundle->>OPBundle: Create AMRIT_ResourceMongo
        OPBundle->>Mongo: Save via commonService
        activate Mongo
        Mongo-->>OPBundle: Persisted
        deactivate Mongo
        OPBundle-->>CommonSvc: Success/int status
        deactivate OPBundle
    end
    
    CommonSvc->>CommonSvc: Check lab tests, prescriptions, wellness, immunization
    CommonSvc->>CommonSvc: Mark processed & update patient record
    CommonSvc-->>Request: Response
    deactivate CommonSvc
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • M2 FHIR bundles creationΒ #123: Direct refactoring companion PR that performs identical bundle service relocation (resource_gatewayβ†’bundle_creation) with new care context components and dependency updates (HAPI/Jackson/Lombok versions, hipSystemUrl property).

Suggested reviewers

  • 5Amogh

Poem

🐰 Bundles hop to new homes today,
Care contexts link the healthy way,
Old gateways fade, fresh services play,
FHIR resources in bundles stay! πŸ₯✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 6.80% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title check ❓ Inconclusive The title 'Abdm v3' is vague and generic, using a non-descriptive term that does not convey meaningful information about the primary changes in the changeset. Replace with a more specific title that summarizes the main change, such as 'Implement ABDM V3 M2 API endpoints for care context linking' or 'Add ABDM V3 care context linking and resource bundle enhancements'.
βœ… Passed checks (1 passed)
Check name Status Explanation
Description Check βœ… Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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.

spring.redis.host=${REDIS_HOST}
spring.redis.host=${REDIS_HOST}

hipSystemUrl= ${HIP_SYSTEM_URL}
Copy link
Member

Choose a reason for hiding this comment

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

linkCareContext, generateTokenForLinkCareContext missing here?

Copy link
Member Author

Choose a reason for hiding this comment

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

@drtechie added the urls missed bymistake

Copy link
Member

Choose a reason for hiding this comment

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

is this a new file? not required I guess

Copy link
Member Author

Choose a reason for hiding this comment

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

@drtechie yes not required removed

@helenKaryamsetty
Copy link
Member Author

@coderabbitai full review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 30, 2025

βœ… Actions performed

Full review triggered.

Copy link
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: 12

Note

Due to the large number of review comments, Critical, Major severity comments were prioritized as inline comments.

🟑 Minor comments (12)
.factorypath-2-2 (1)

2-2: Version mismatch between .factorypath and pom.xml.

The .factorypath references Lombok 1.18.30, but pom.xml defines <org.projectlombok.version>1.18.36</org.projectlombok.version>. This inconsistency may cause annotation processing issues in Eclipse IDE. Consider aligning both to the same version.

src/main/java/com/wipro/fhir/service/bundle_creation/BundleValidator.java-48-50 (1)

48-50: Use println for readable output.

System.out.print will concatenate all messages on a single line without newlines.

Suggested fix
-			System.out.print("Error - " +  next.getSeverity() + " - " + next.getLocationString() + " - " + next.getMessage());
+			System.out.println(next.getSeverity() + " - " + next.getLocationString() + " - " + next.getMessage());
pom.xml-218-224 (1)

218-224: Duplicate dependency declaration.

hapi-fhir-structures-r4 version 8.4.0 is declared twice (lines 204-208 and lines 220-224). Remove the duplicate to avoid confusion.

Suggested fix
-	<!--
-	https://mvnrepository.com/artifact/ca.uhn.hapi.fhir/hapi-fhir-structures-r4 -->
-	<dependency>
-		<groupId>ca.uhn.hapi.fhir</groupId>
-		<artifactId>hapi-fhir-structures-r4</artifactId>
-		<version>8.4.0</version>
-	</dependency>
src/main/java/com/wipro/fhir/service/bundle_creation/BundleValidator.java-28-28 (1)

28-28: Placeholder path will cause runtime failure.

The loadPackageFromClasspath(" ") call uses a space character as the path, which will fail. The comment suggests downloading a package from ABDM - consider adding proper documentation or a more descriptive placeholder that fails fast with a clear message.

Suggested improvement
-		npmPackageValidationSupport.loadPackageFromClasspath(" "); // download the package from ABDM and add in resources
+		// TODO: Download the ABDM validation package and add to classpath at: classpath:packages/abdm-fhir-package.tgz
+		npmPackageValidationSupport.loadPackageFromClasspath("classpath:packages/abdm-fhir-package.tgz");
src/main/environment/common_docker.properties-102-103 (1)

102-103: Fix placeholder format inconsistency.

Lines 102-103 use @env.ABDM_HIECM_BASE_URL@ placeholder format, but the rest of the Docker properties file consistently uses ${ENV_VAR} format (e.g., lines 1, 12-14, 37-38). This inconsistency may cause configuration resolution issues.

πŸ”Ž Proposed fix
-generateTokenForLinkCareContext = @env.ABDM_HIECM_BASE_URL@/api/hiecm/v3/token/generate-token
-linkCareContext = @env.ABDM_HIECM_BASE_URL@/api/hiecm/hip/v3/link/carecontext
+generateTokenForLinkCareContext = ${ABDM_HIECM_BASE_URL}/api/hiecm/v3/token/generate-token
+linkCareContext = ${ABDM_HIECM_BASE_URL}/api/hiecm/hip/v3/link/carecontext
src/main/java/com/wipro/fhir/service/resource_model/ImmunizationResource.java-66-73 (1)

66-73: Verify the semantic correctness of NOTDONE status.

Line 72 sets ImmunizationStatus.NOTDONE when receivedDate is null. In FHIR, NOTDONE means the immunization was not performed (e.g., refused, contraindicated), not "date unknown." This semantic mismatch could cause issues with downstream FHIR consumers.

Consider:

  1. Omitting immunizations without a receivedDate (add continue; at line 72)
  2. Using a different status or extension if partial data must be represented
πŸ”Ž Option to omit records without receivedDate
 		if (im.getReceivedDate() != null) {
 			immune.setStatus(Immunization.ImmunizationStatus.COMPLETED);
 			immune.setOccurrence(new DateTimeType(im.getReceivedDate()));
 		} else {
-			// If you prefer to exclude not-done, comment the next line and add a
-			// `continue;`
-			immune.setStatus(Immunization.ImmunizationStatus.NOTDONE);
+			// Skip immunizations without a received date
+			continue;
 		}
src/main/java/com/wipro/fhir/service/bundle_creation/WellnessRecordResourceBundle.java-23-24 (1)

23-24: Fix inconsistent exception type declaration.

The method processWellnessRecordBundle declares org.hl7.fhir.exceptions.FHIRException while other methods in this interface use com.wipro.fhir.utils.exception.FHIRException (imported at line 12). This inconsistency can cause confusion and potential exception handling issues.

πŸ”Ž Proposed fix
 	int processWellnessRecordBundle(ResourceRequestHandler resourceRequestHandler, PatientEligibleForResourceCreation p)
-		throws org.hl7.fhir.exceptions.FHIRException, Exception;
+		throws FHIRException, Exception;
src/main/java/com/wipro/fhir/service/v3/careContext/CareContextLinkingServiceImpl.java-336-365 (1)

336-365: Method name typo and logger format issue.

  1. Method name checkRecordExisits has a typo - should be checkRecordExists.
  2. Line 357: logger.info("failed abha exists check with exception - ", e.getMessage()) uses a comma, which treats e.getMessage() as a separate argument rather than concatenating it. The message won't appear in logs.
πŸ”Ž Proposed fix
-	public String checkRecordExisits(String abhaAddress) {
+	public String checkRecordExists(String abhaAddress) {
 		GenerateTokenAbdmResponses result = generateTokenAbdmResponsesRepo.findByAbhaAddress(abhaAddress);
-		logger.info("find by abha address result - ", result);
+		logger.info("find by abha address result - {}", result);
 		String linkResponse = null;
 		// ...
 					} catch (Exception e) {
-						logger.info("failed abha exists check with exception - ", e.getMessage());
+						logger.info("failed abha exists check with exception - {}", e.getMessage());
 						return null;
 					}

Note: Update the caller at line 96 to use the corrected method name.

src/main/java/com/wipro/fhir/service/bundle_creation/DiagnosticRecordResourceBundleImpl.java-83-85 (1)

83-85: TODO placeholder in exception message.

The exception message contains a TODO placeholder ("TODO - exception - later will implement") instead of a descriptive error message. This should be updated to match other bundle implementations.

πŸ”Ž Proposed fix
 		} else
-			throw new FHIRException("TODO - exception - later will implement");
+			throw new FHIRException("Issue in processing the Diagnostic Report bundle");
src/main/java/com/wipro/fhir/service/bundle_creation/OPConsultResourceBundleImpl.java-254-256 (1)

254-256: Typo in SNOMED display text.

There's a backtick character at the end of "Clinical consultation report`". This typo will appear in the generated FHIR bundle.

πŸ”Ž Proposed fix
 		composition  
-				.setType(new CodeableConcept(new Coding("http://snomed.info/sct", "371530004", "Clinical consultation report`")));
+				.setType(new CodeableConcept(new Coding("http://snomed.info/sct", "371530004", "Clinical consultation report")));
src/main/java/com/wipro/fhir/service/bundle_creation/ImmunizationRecordResourceBundleImpl.java-189-195 (1)

189-195: Duplicate setCustodian call.

setCustodian is called unconditionally at line 190, then again conditionally at lines 193-195. The second call is redundant since organization cannot be null at that point (it would have thrown an exception from getOrganizationResource).

πŸ”Ž Proposed fix
 	composition.addAuthor(new Reference(practitioner.getIdElement().getValue()));
 	composition.setCustodian(new Reference(organization.getIdElement().getValue()));
 	composition.setTitle("Immunization Record");
-
-    if (organization != null) {
-        composition.setCustodian(new Reference(organization.getIdElement().getValue()));
-    }
src/main/java/com/wipro/fhir/service/bundle_creation/WellnessRecordResourceBundleImpl.java-237-255 (1)

237-255: Copy/paste error: method name refers to Prescription but handles Wellness.

The private method is named createPrescriptionBundleMongo but it creates a Wellness bundle (sets resourceType to "WellnessRecord" at line 252). Rename for clarity.

πŸ”Ž Proposed fix
-	private AMRIT_ResourceMongo createPrescriptionBundleMongo(PatientEligibleForResourceCreation p,
+	private AMRIT_ResourceMongo createWellnessBundleMongo(PatientEligibleForResourceCreation p,
 			String wellnessBundle) {

Also update the caller at line 70:

-		AMRIT_ResourceMongo aMRIT_ResourceMongo = createPrescriptionBundleMongo(p, wellnessBundle);
+		AMRIT_ResourceMongo aMRIT_ResourceMongo = createWellnessBundleMongo(p, wellnessBundle);

Committable suggestion skipped: line range outside the PR's diff.

🧹 Nitpick comments (32)
src/main/java/com/wipro/fhir/service/resource_model/MedicationRequestResource.java (1)

152-157: Good defensive null check added.

The guard prevents NullPointerException when conditionDiagnosis is null or empty.

Optional: Consider using isEmpty()
-		if(conditionDiagnosis != null && conditionDiagnosis.size() > 0) {
+		if(conditionDiagnosis != null && !conditionDiagnosis.isEmpty()) {
src/main/java/com/wipro/fhir/data/v3/careContext/GenerateCareContextTokenRequest.java (1)

5-13: Simple DTO structure looks correct.

The DTO follows the same pattern as other care-context request classes in this package.

Consider using Integer instead of int for yearOfBirth if null is a valid input state (e.g., optional field). Using int defaults to 0 when not provided, which may be indistinguishable from an intentional value.

src/main/java/com/wipro/fhir/service/bundle_creation/BundleValidator.java (1)

44-44: Empty bundle JSON placeholder.

The hardcoded empty string will not produce meaningful validation results. Consider accepting the bundle JSON as a command-line argument or reading from a file.

Suggested improvement
-		String bundleJson = ""; // add bundle json here
+		if (args.length == 0) {
+			System.err.println("Usage: BundleValidator <bundle.json>");
+			return;
+		}
+		String bundleJson = new String(java.nio.file.Files.readAllBytes(java.nio.file.Paths.get(args[0])));
src/main/java/com/wipro/fhir/service/bundle_creation/DischargeSummaryResourceBundle.java (1)

26-31: Consider reducing parameter count.

The PopulateDischargeSummaryComposition method has 13 parameters, which is excessive. Consider grouping related parameters into a dedicated context or builder object to improve readability and maintainability.

src/main/java/com/wipro/fhir/data/mongo/care_context/GenerateTokenAbdmResponses.java (1)

3-3: Remove unused import.

LocalDateTime is imported but never used. The createdDate field uses java.util.Date instead.

πŸ”Ž Proposed fix
-import java.time.LocalDateTime;
 import java.util.Date;
src/main/java/com/wipro/fhir/service/resource_model/ImmunizationResource.java (1)

28-29: Consider making the data model utility static or refactoring the pattern.

ImmunizationDataModel is autowired but used only as a factory/utility to call getImmunizationList(). Autowiring a stateless utility class is unconventional. Consider either:

  1. Making getImmunizationList() a static method
  2. Not annotating ImmunizationDataModel with @Component and instantiating it locally
πŸ”Ž Option 1: Static utility method

In ImmunizationDataModel.java:

-	public List<ImmunizationDataModel> getImmunizationList(List<Object[]> resultSetList) {
+	public static List<ImmunizationDataModel> getImmunizationList(List<Object[]> resultSetList) {

In ImmunizationResource.java:

-	@Autowired
-	private ImmunizationDataModel immunizationDataModel;
-
 	...
-		List<ImmunizationDataModel> immunizationList = immunizationDataModel.getImmunizationList(rsObjList);
+		List<ImmunizationDataModel> immunizationList = ImmunizationDataModel.getImmunizationList(rsObjList);
src/main/java/com/wipro/fhir/data/resource_model/OrganizationDataModel.java (1)

16-16: Remove unused serialVersionUID or implement Serializable.

The field serialVersionUID is declared but the class doesn't implement Serializable. Either implement the interface if serialization is needed, or remove this field. Note that similar data models in the codebase (e.g., MedicalHistoryDataModel) do implement Serializable.

πŸ”Ž Proposed fix
+import java.io.Serializable;
+
 @Component
 @Data
-public class OrganizationDataModel {
+public class OrganizationDataModel implements Serializable {
src/main/java/com/wipro/fhir/service/bundle_creation/PrescriptionResourceBundle.java (1)

16-24: Fix inconsistent method naming to follow Java conventions.

The interface methods use inconsistent naming:

  • PopulatePrescriptionResourceBundle and PopulatePrescriptionComposition start with uppercase (non-standard)
  • processPrescriptionRecordBundle follows proper Java naming (lowercase start)

Java method names should start with a lowercase letter. Consider renaming to maintain consistency and follow standard conventions: populatePrescriptionResourceBundle, populatePrescriptionComposition.

πŸ”Ž Proposed fix
-	 String PopulatePrescriptionResourceBundle(ResourceRequestHandler resourceRequestHandler,
+	 String populatePrescriptionResourceBundle(ResourceRequestHandler resourceRequestHandler,
 		PatientEligibleForResourceCreation p) throws FHIRException;
 
-	Composition PopulatePrescriptionComposition(ResourceRequestHandler resourceRequestHandler,
+	Composition populatePrescriptionComposition(ResourceRequestHandler resourceRequestHandler,
 		PatientEligibleForResourceCreation p, List<MedicationRequest> medicationRequest, Practitioner practitioner,
 		Organization organization);
src/main/java/com/wipro/fhir/data/resource_model/PractitionerDataModel.java (1)

16-16: Remove unused serialVersionUID or implement Serializable.

The field serialVersionUID is declared but the class doesn't implement Serializable. For consistency with similar data models like MedicalHistoryDataModel (which does implement Serializable), either implement the interface or remove this field.

πŸ”Ž Proposed fix
+import java.io.Serializable;
+
 @Data
 @Component
-public class PractitionerDataModel {
+public class PractitionerDataModel implements Serializable {
src/main/java/com/wipro/fhir/service/bundle_creation/WellnessRecordResourceBundle.java (1)

16-21: Fix method naming to follow Java conventions.

The methods PopulateWellnessRecordResourceBundle and PopulateWellnessRecordComposition start with uppercase letters, violating Java naming conventions. Method names should start with lowercase: populateWellnessRecordResourceBundle and populateWellnessRecordComposition.

πŸ”Ž Proposed fix
-	String PopulateWellnessRecordResourceBundle(ResourceRequestHandler resourceRequestHandler,
+	String populateWellnessRecordResourceBundle(ResourceRequestHandler resourceRequestHandler,
 		PatientEligibleForResourceCreation p) throws FHIRException;
 
-	Composition PopulateWellnessRecordComposition(ResourceRequestHandler resourceRequestHandler,
+	Composition populateWellnessRecordComposition(ResourceRequestHandler resourceRequestHandler,
 		PatientEligibleForResourceCreation p, Practitioner practitioner, Organization organization,
 		List<Observation> observationVitalList);
src/main/java/com/wipro/fhir/service/bundle_creation/ImmunizationRecordResourceBundle.java (1)

15-25: Method naming convention inconsistency.

PopulateImmunizationResourceBundle uses PascalCase while populateImmunizationComposition and processImmunizationRecordBundle follow Java's standard camelCase convention. For consistency with Java naming standards, consider renaming to populateImmunizationResourceBundle.

This pattern appears across other new interfaces in this PR (DiagnosticRecordResourceBundle, OPConsultResourceBundle), so a consistent decision should be made.

src/main/java/com/wipro/fhir/service/bundle_creation/DiagnosticRecordResourceBundle.java (1)

14-27: Interface design looks good with same naming caveat.

The interface appropriately abstracts diagnostic report bundle operations. Same observation as the other bundle interfaces: PopulateDiagnosticReportComposition and PopulateDiagnosticReportResourceBundle use PascalCase instead of Java's conventional camelCase.

src/main/java/com/wipro/fhir/service/bundle_creation/OPConsultResourceBundle.java (1)

17-30: Consider a parameter object for PopulateOpConsultComposition.

The method signature has 9 parameters, which can be unwieldy. Consider grouping related parameters into a dedicated data class (e.g., OpConsultCompositionData) to improve readability and maintainability. This is an optional refactor for future consideration.

Same naming convention observation applies: PopulateOpConsultComposition and PopulateOPConsultRecordResourceBundle use PascalCase.

src/main/java/com/wipro/fhir/service/resource_model/PractitionerResource.java (2)

46-53: Unusual use of @Autowired for data model as factory.

PractitionerDataModel is injected as a Spring component but used as a factory/mapper (line 64). Since PractitionerDataModel is a @Component (singleton), this works but is unconventional. The getPractitioner method on the data model doesn't rely on instance state, so it could be a static method or extracted to a separate mapper class.

This pattern appears consistent with other data models in the PR (e.g., OrganizationDataModel, ImmunizationDataModel), so maintaining consistency is reasonable.


24-25: Unused imports.

ArrayList and List imports appear unused after refactoring. These can be safely removed.

πŸ”Ž Proposed fix
-import java.util.ArrayList;
-import java.util.List;
-
src/main/java/com/wipro/fhir/data/resource_model/MedicalHistoryDataModel.java (2)

30-49: Inconsistent exception type - consider using FHIRException.

Other data models in this PR (PractitionerDataModel, OrganizationDataModel) throw FHIRException on parsing errors, but MedicalHistoryDataModel throws a generic Exception. For consistency and to allow callers to handle errors uniformly, consider using FHIRException.

πŸ”Ž Proposed fix
+import com.wipro.fhir.utils.exception.FHIRException;
+
 @Data
 @Component
 public class MedicalHistoryDataModel implements Serializable {
     // ...
 
-	public MedicalHistoryDataModel(Object[] objArr) throws Exception {
+	public MedicalHistoryDataModel(Object[] objArr) throws FHIRException {
 		    try {
 		        // ... parsing logic ...
 		    } catch (Exception e) {
-		    	throw new Exception("Medical History resource model failed with error - " + e.getMessage());
+		    	throw new FHIRException("Medical History resource model failed with error - " + e.getMessage());
 		    }
 	}
 
-	public List<MedicalHistoryDataModel> getMedicalList(List<Object[]> resultSetList) throws Exception {
+	public List<MedicalHistoryDataModel> getMedicalList(List<Object[]> resultSetList) throws FHIRException {

51-61: Minor: prefer isEmpty() over size() > 0.

Line 54 uses resultSetList.size() > 0, which is equivalent to but less idiomatic than !resultSetList.isEmpty().

src/main/java/com/wipro/fhir/service/v3/careContext/CareContextLinkingServiceImpl.java (4)

16-16: Unused import.

org.joda.time.DateTime is imported but never used in this file.

πŸ”Ž Proposed fix
-import org.joda.time.DateTime;

148-149: Unused variable and deprecated API usage.

  1. responseStrLogin (line 148) is assigned but never used.
  2. new JsonParser() (line 149) is deprecated. Use JsonParser.parseString() directly instead.
πŸ”Ž Proposed fix
-				String responseStrLogin = common_NDHMService.getBody(responseEntity);
-				JsonParser jsnParser = new JsonParser();
 				if (responseEntity.getStatusCode() == HttpStatusCode.valueOf(202)) {
 					// ...
-				    JsonElement jsonElement = jsnParser.parse(abhaResponse);
+				    JsonElement jsonElement = JsonParser.parseString(abhaResponse);

294-296: Unused variable.

responseStrLogin is assigned but never used.

πŸ”Ž Proposed fix
-				String responseStrLogin = common_NDHMService.getBody(responseEntity);
 				if (responseEntity.getStatusCode() == HttpStatusCode.valueOf(202)) {

367-397: LGTM - HI types determination logic.

The findHiTypes method correctly determines applicable HI types based on visit category and repository checks. The logic properly gates WellnessRecord, Prescription, DiagnosticReport, and ImmunizationRecord based on data presence.

Minor: Line 395 logger.info("HiTypes", hiTypes) should use {} placeholder for proper logging.

πŸ”Ž Minor logging fix
-		logger.info("HiTypes", hiTypes);		
+		logger.info("HiTypes: {}", hiTypes);		
src/main/java/com/wipro/fhir/controller/generateresource/ResourceRequestGateway.java (1)

81-81: Method naming convention inconsistency.

The new method names use PascalCase (PopulateOPConsultRecordResourceBundle) instead of the standard Java camelCase convention (populateOPConsultRecordResourceBundle). This is consistent across all new bundle implementations in this PR, but deviates from Java naming standards.

src/main/java/com/wipro/fhir/service/bundle_creation/PrescriptionResourceBundleImpl.java (3)

62-62: Unused logger field.

The Logger is declared but never used in this class. Either remove it or add appropriate logging for debugging and monitoring bundle creation.


160-162: Exception handling loses stack trace details.

Using + e in the exception message only includes toString(), losing the full stack trace. Consider using + e.getMessage() for the message and logging the full exception separately, or use proper exception chaining.

πŸ”Ž Proposed fix
 		} catch (Exception e) {
-			throw new FHIRException("Prescription FHIR Resource Bundle failed with error - " + e);
+			logger.error("Prescription FHIR Resource Bundle failed", e);
+			throw new FHIRException("Prescription FHIR Resource Bundle failed with error - " + e.getMessage());
 		}

155-157: Cache the FhirContext instance to avoid expensive repeated initialization.

FhirContext.forR4() is expensive to create and is thread-safe once constructed. Creating it on every bundle serialization degrades performance. Cache it as a class-level field initialized once via @PostConstruct, then create a fresh parser on each request via fhirContext.newJsonParser() (parsers are not thread-safe but are cheap to create).

πŸ”Ž Suggested approach
+import jakarta.annotation.PostConstruct;
+
 @Service
 public class PrescriptionResourceBundleImpl implements PrescriptionResourceBundle {
+
+	private FhirContext fhirContext;
+
+	@PostConstruct
+	public void init() {
+		this.fhirContext = FhirContext.forR4();
+	}
 
 	// ... in PopulatePrescriptionResourceBundle method:
-	FhirContext ctx = FhirContext.forR4();
-	IParser parser = ctx.newJsonParser();
+	IParser parser = fhirContext.newJsonParser();

Alternatively, define a @Bean in a configuration class and inject it across all bundle implementations.

src/main/java/com/wipro/fhir/service/bundle_creation/DischargeSummaryResourceBundleImpl.java (2)

331-341: Inconsistent section structure - one section per item.

Each chief complaint creates a new section with the same title and code. This differs from the approach used for "Past Medical History" (lines 368-380), which groups all entries in a single section. Consider consolidating into one "Chief complaints" section with multiple entries for consistency.

πŸ”Ž Suggested consolidation
-		if (chiefComplaints != null) {
-			for (Condition condition : chiefComplaints) {
-				SectionComponent s = new SectionComponent();
-				s.setTitle("Chief complaints");
-				s.setCode(new CodeableConcept().addCoding(
-						new Coding("http://snomed.info/sct", "422843007", "Chief complaint section")));
-				s.addEntry(new Reference(condition.getIdElement().getValue()));
-				sectionList.add(s);
-			}
-		}
+		if (chiefComplaints != null && !chiefComplaints.isEmpty()) {
+			SectionComponent s = new SectionComponent();
+			s.setTitle("Chief complaints");
+			s.setCode(new CodeableConcept().addCoding(
+					new Coding("http://snomed.info/sct", "422843007", "Chief complaint section")));
+			for (Condition condition : chiefComplaints) {
+				s.addEntry(new Reference(condition.getIdElement().getValue()));
+			}
+			sectionList.add(s);
+		}

Apply similar consolidation for Physical examination (lines 344-353), Allergies (lines 356-365), and Medications (lines 408-417).


279-281: Same FhirContext performance concern.

Same issue as in PrescriptionResourceBundleImpl - FhirContext.forR4() is expensive and should be shared across bundle implementations.

src/main/java/com/wipro/fhir/service/bundle_creation/WellnessRecordResourceBundleImpl.java (1)

63-64: Redundant exception declaration.

The method declares throws FHIRException, Exception, but Exception is a superclass that already covers FHIRException. This is redundant and differs from other bundle implementations which only throw FHIRException.

πŸ”Ž Proposed fix
 	public int processWellnessRecordBundle(ResourceRequestHandler resourceRequestHandler,
-			PatientEligibleForResourceCreation p) throws FHIRException, Exception {
+			PatientEligibleForResourceCreation p) throws FHIRException {
src/main/java/com/wipro/fhir/service/bundle_creation/ImmunizationRecordResourceBundleImpl.java (1)

87-88: Variable name mismatch - diagReportBundle used for Immunization.

The variable is named diagReportBundle but represents an Immunization bundle. This is a copy/paste remnant that reduces code clarity.

πŸ”Ž Proposed fix
-		Bundle diagReportBundle = new Bundle();
+		Bundle immunizationBundle = new Bundle();

Update all subsequent references (lines 92-106, 151, 155) to use the corrected name.

src/main/java/com/wipro/fhir/service/bundle_creation/OPConsultResourceBundleImpl.java (1)

265-300: Same section structure issue as DischargeSummary.

Each chief complaint, diagnosis, allergy, and medication statement creates a separate section instead of grouping by type. Consider consolidating for cleaner FHIR output.

src/main/java/com/wipro/fhir/service/common/CommonServiceImpl.java (2)

229-288: Individual bundle failures prevent subsequent bundle processing.

If any bundle processing throws an exception, subsequent bundles won't be processed since there's no try/catch around each individual bundle call. The outer try/catch (line 303) catches the error but skips the rest of the bundles for that patient. Consider wrapping each bundle processing in its own try/catch to allow partial success.

πŸ”Ž Suggested approach
// Example for one bundle - apply pattern to all
try {
    if (p.getVisitCategory().equalsIgnoreCase("General OPD")
            || p.getVisitCategory().equalsIgnoreCase("General OPD (QC)")) {
        int opConsult = oPConsultResourceBundle.processOpConsultRecordBundle(resourceRequestHandler, p);
        if (opConsult <= 0)
            processed = false;
        logger.info(" The value of opConsult processed: " + processed);
    }
} catch (Exception e) {
    logger.error("OP Consult bundle processing failed", e);
    processed = false;
}

66-67: Stale comment - refers to Prescription but context is Immunization.

Line 66 comment says "call method to generate Prescription resource" but this is in the context of processImmunizationRecordBundle. This is a copy/paste artifact.

Similar stale comments appear at lines 89, 105 in other bundle implementations reviewed above.

πŸ“œ Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 998b5ab and cd22115.

πŸ“’ Files selected for processing (58)
  • .factorypath
  • pom.xml
  • src/main/environment/common_ci.properties
  • src/main/environment/common_docker.properties
  • src/main/environment/common_example.properties
  • src/main/java/com/wipro/fhir/controller/generateresource/ResourceRequestGateway.java
  • src/main/java/com/wipro/fhir/controller/test/Test.java
  • src/main/java/com/wipro/fhir/controller/v3/abha/CreateAbhaV3Controller.java
  • src/main/java/com/wipro/fhir/controller/v3/careContext/CareContextLinkingController.java
  • src/main/java/com/wipro/fhir/data/mongo/care_context/GenerateTokenAbdmResponses.java
  • src/main/java/com/wipro/fhir/data/resource_model/ImmunizationDataModel.java
  • src/main/java/com/wipro/fhir/data/resource_model/MedicalHistoryDataModel.java
  • src/main/java/com/wipro/fhir/data/resource_model/OrganizationDataModel.java
  • src/main/java/com/wipro/fhir/data/resource_model/PractitionerDataModel.java
  • src/main/java/com/wipro/fhir/data/v3/careContext/AddCareContextRequest.java
  • src/main/java/com/wipro/fhir/data/v3/careContext/CareContextLinkTokenRequest.java
  • src/main/java/com/wipro/fhir/data/v3/careContext/CareContexts.java
  • src/main/java/com/wipro/fhir/data/v3/careContext/GenerateCareContextTokenRequest.java
  • src/main/java/com/wipro/fhir/data/v3/careContext/LinkCareContextRequest.java
  • src/main/java/com/wipro/fhir/data/v3/careContext/PatientCareContext.java
  • src/main/java/com/wipro/fhir/repo/common/PatientEligibleForResourceCreationRepo.java
  • src/main/java/com/wipro/fhir/repo/mongo/generateToken_response/GenerateTokenAbdmResponsesRepo.java
  • src/main/java/com/wipro/fhir/repo/v3/careContext/CareContextRepo.java
  • src/main/java/com/wipro/fhir/service/bundle_creation/BundleValidator.java
  • src/main/java/com/wipro/fhir/service/bundle_creation/DiagnosticRecordResourceBundle.java
  • src/main/java/com/wipro/fhir/service/bundle_creation/DiagnosticRecordResourceBundleImpl.java
  • src/main/java/com/wipro/fhir/service/bundle_creation/DischargeSummaryResourceBundle.java
  • src/main/java/com/wipro/fhir/service/bundle_creation/DischargeSummaryResourceBundleImpl.java
  • src/main/java/com/wipro/fhir/service/bundle_creation/ImmunizationRecordResourceBundle.java
  • src/main/java/com/wipro/fhir/service/bundle_creation/ImmunizationRecordResourceBundleImpl.java
  • src/main/java/com/wipro/fhir/service/bundle_creation/OPConsultResourceBundle.java
  • src/main/java/com/wipro/fhir/service/bundle_creation/OPConsultResourceBundleImpl.java
  • src/main/java/com/wipro/fhir/service/bundle_creation/PrescriptionResourceBundle.java
  • src/main/java/com/wipro/fhir/service/bundle_creation/PrescriptionResourceBundleImpl.java
  • src/main/java/com/wipro/fhir/service/bundle_creation/WellnessRecordResourceBundle.java
  • src/main/java/com/wipro/fhir/service/bundle_creation/WellnessRecordResourceBundleImpl.java
  • src/main/java/com/wipro/fhir/service/common/CommonServiceImpl.java
  • src/main/java/com/wipro/fhir/service/ndhm/Common_NDHMService.java
  • src/main/java/com/wipro/fhir/service/ndhm/Common_NDHMServiceImpl.java
  • src/main/java/com/wipro/fhir/service/ndhm/LinkCareContext_NDHMServiceImpl.java
  • src/main/java/com/wipro/fhir/service/resource_gateway/DiagnosticReportRecord.java
  • src/main/java/com/wipro/fhir/service/resource_gateway/DiagnosticReportRecordImpl.java
  • src/main/java/com/wipro/fhir/service/resource_gateway/OPConsultRecordBundle.java
  • src/main/java/com/wipro/fhir/service/resource_gateway/OPConsultRecordBundleImpl.java
  • src/main/java/com/wipro/fhir/service/resource_gateway/PrescriptionRecordBundle.java
  • src/main/java/com/wipro/fhir/service/resource_gateway/PrescriptionRecordBundleImpl.java
  • src/main/java/com/wipro/fhir/service/resource_model/DiagnosticReportResource.java
  • src/main/java/com/wipro/fhir/service/resource_model/EncounterResource.java
  • src/main/java/com/wipro/fhir/service/resource_model/ImmunizationResource.java
  • src/main/java/com/wipro/fhir/service/resource_model/MedicalHistoryResource.java
  • src/main/java/com/wipro/fhir/service/resource_model/MedicationRequestResource.java
  • src/main/java/com/wipro/fhir/service/resource_model/ObservationResource.java
  • src/main/java/com/wipro/fhir/service/resource_model/OrganizationResource.java
  • src/main/java/com/wipro/fhir/service/resource_model/PatientResource.java
  • src/main/java/com/wipro/fhir/service/resource_model/PractitionerResource.java
  • src/main/java/com/wipro/fhir/service/v3/abha/CreateAbhaV3ServiceImpl.java
  • src/main/java/com/wipro/fhir/service/v3/careContext/CareContextLinkingService.java
  • src/main/java/com/wipro/fhir/service/v3/careContext/CareContextLinkingServiceImpl.java
πŸ’€ Files with no reviewable changes (9)
  • src/main/java/com/wipro/fhir/service/resource_model/DiagnosticReportResource.java
  • src/main/java/com/wipro/fhir/service/resource_gateway/DiagnosticReportRecord.java
  • src/main/java/com/wipro/fhir/service/resource_gateway/DiagnosticReportRecordImpl.java
  • src/main/java/com/wipro/fhir/service/resource_gateway/PrescriptionRecordBundleImpl.java
  • src/main/java/com/wipro/fhir/service/resource_gateway/OPConsultRecordBundle.java
  • src/main/java/com/wipro/fhir/service/resource_model/PatientResource.java
  • src/main/java/com/wipro/fhir/service/resource_gateway/OPConsultRecordBundleImpl.java
  • src/main/java/com/wipro/fhir/service/resource_gateway/PrescriptionRecordBundle.java
  • src/main/java/com/wipro/fhir/service/v3/abha/CreateAbhaV3ServiceImpl.java
🧰 Additional context used
🧠 Learnings (12)
πŸ“š Learning: 2025-01-09T12:17:11.789Z
Learnt from: helenKaryamsetty
Repo: PSMRI/FHIR-API PR: 58
File: src/main/java/com/wipro/fhir/service/v3/abha/LoginAbhaV3ServiceImpl.java:0-0
Timestamp: 2025-01-09T12:17:11.789Z
Learning: In the FHIR-API project's ABDM integration, complete responseEntity logging is preferred over just status codes for better debugging capabilities, particularly in the LoginAbhaV3ServiceImpl class when handling ABDM API responses.

Applied to files:

  • src/main/environment/common_example.properties
  • src/main/java/com/wipro/fhir/service/ndhm/Common_NDHMService.java
  • src/main/java/com/wipro/fhir/data/mongo/care_context/GenerateTokenAbdmResponses.java
  • src/main/java/com/wipro/fhir/service/ndhm/LinkCareContext_NDHMServiceImpl.java
  • src/main/java/com/wipro/fhir/service/ndhm/Common_NDHMServiceImpl.java
πŸ“š Learning: 2024-12-09T16:01:39.809Z
Learnt from: helenKaryamsetty
Repo: PSMRI/FHIR-API PR: 52
File: src/main/java/com/wipro/fhir/service/v3/abha/LoginAbhaV3ServiceImpl.java:84-91
Timestamp: 2024-12-09T16:01:39.809Z
Learning: In the `requestOtpForAbhaLogin` and `verifyAbhaLogin` methods of `LoginAbhaV3ServiceImpl.java`, `loginId` is mandatory, but even if it is null, the process can proceed without input validation.

Applied to files:

  • src/main/environment/common_example.properties
πŸ“š Learning: 2025-06-17T12:45:58.739Z
Learnt from: vishwab1
Repo: PSMRI/FHIR-API PR: 107
File: src/main/java/com/wipro/fhir/config/CorsConfig.java:24-26
Timestamp: 2025-06-17T12:45:58.739Z
Learning: FHIR APIs often require allowing all headers (`allowedHeaders("*")`) in CORS configuration due to the need for custom headers for various integrations and healthcare standards compliance, making restrictive header lists impractical.

Applied to files:

  • src/main/environment/common_example.properties
πŸ“š Learning: 2024-12-09T16:09:31.513Z
Learnt from: helenKaryamsetty
Repo: PSMRI/FHIR-API PR: 52
File: src/main/java/com/wipro/fhir/controller/v3/abha/LoginAbhaV3Controller.java:18-20
Timestamp: 2024-12-09T16:09:31.513Z
Learning: In the Java Spring Boot project, all controllers, including `LoginAbhaV3Controller.java` at `src/main/java/com/wipro/fhir/controller/v3/abha/`, use the `CrossOrigin` annotation without parameters to maintain consistency across the codebase.

Applied to files:

  • src/main/java/com/wipro/fhir/controller/v3/abha/CreateAbhaV3Controller.java
  • src/main/java/com/wipro/fhir/controller/v3/careContext/CareContextLinkingController.java
  • src/main/java/com/wipro/fhir/service/ndhm/Common_NDHMServiceImpl.java
πŸ“š Learning: 2024-12-10T14:52:59.847Z
Learnt from: helenKaryamsetty
Repo: PSMRI/FHIR-API PR: 52
File: src/main/java/com/wipro/fhir/controller/v3/abha/CreateAbhaV3Controller.java:51-68
Timestamp: 2024-12-10T14:52:59.847Z
Learning: In the FHIR-API project, when reviewing code in Java controllers (e.g., `CreateAbhaV3Controller.java`), the team prefers to retain raw request logging for debugging purposes. Therefore, suggestions to remove or modify logging statements related to raw requests should be ignored.

Applied to files:

  • src/main/java/com/wipro/fhir/controller/v3/abha/CreateAbhaV3Controller.java
  • src/main/java/com/wipro/fhir/controller/v3/careContext/CareContextLinkingController.java
πŸ“š Learning: 2024-11-20T07:41:40.038Z
Learnt from: helenKaryamsetty
Repo: PSMRI/FHIR-API PR: 46
File: src/main/java/com/wipro/fhir/data/mongo/care_context/SaveFacilityIdForVisit.java:7-8
Timestamp: 2024-11-20T07:41:40.038Z
Learning: In the `SaveFacilityIdForVisit` class (`src/main/java/com/wipro/fhir/data/mongo/care_context/SaveFacilityIdForVisit.java`), the handling of the MongoDB ID field and indexing is provided in another module and is not required in this class.

Applied to files:

  • src/main/java/com/wipro/fhir/data/v3/careContext/CareContexts.java
  • src/main/java/com/wipro/fhir/repo/v3/careContext/CareContextRepo.java
  • src/main/java/com/wipro/fhir/service/v3/careContext/CareContextLinkingServiceImpl.java
  • src/main/java/com/wipro/fhir/service/common/CommonServiceImpl.java
  • src/main/java/com/wipro/fhir/data/v3/careContext/PatientCareContext.java
  • src/main/java/com/wipro/fhir/service/bundle_creation/DiagnosticRecordResourceBundleImpl.java
  • src/main/java/com/wipro/fhir/service/bundle_creation/OPConsultResourceBundleImpl.java
  • src/main/java/com/wipro/fhir/data/mongo/care_context/GenerateTokenAbdmResponses.java
  • src/main/java/com/wipro/fhir/service/bundle_creation/WellnessRecordResourceBundleImpl.java
  • src/main/java/com/wipro/fhir/data/v3/careContext/AddCareContextRequest.java
πŸ“š Learning: 2025-02-10T10:34:55.588Z
Learnt from: indraniBan
Repo: PSMRI/FHIR-API PR: 53
File: src/main/java/com/wipro/fhir/utils/JwtUserIdValidationFilter.java:53-54
Timestamp: 2025-02-10T10:34:55.588Z
Learning: In the FHIR-API project, logging JWT token processing (without the actual token value) is acceptable and required for analysis purposes.

Applied to files:

  • src/main/java/com/wipro/fhir/controller/v3/careContext/CareContextLinkingController.java
πŸ“š Learning: 2025-04-08T10:36:02.237Z
Learnt from: helenKaryamsetty
Repo: PSMRI/FHIR-API PR: 68
File: src/main/java/com/wipro/fhir/controller/healthID/CreateHealthIDWithMobileOTP.java:165-165
Timestamp: 2025-04-08T10:36:02.237Z
Learning: In the FHIR-API project, logging beneficiary IDs in response logs (e.g., "NDHM_FHIR get beneficiary Ids for HealthID response:") is acceptable and useful for debugging purposes as these IDs do not pose a security threat according to the domain expert.

Applied to files:

  • src/main/java/com/wipro/fhir/controller/v3/careContext/CareContextLinkingController.java
  • src/main/java/com/wipro/fhir/service/ndhm/LinkCareContext_NDHMServiceImpl.java
πŸ“š Learning: 2025-02-10T10:35:18.033Z
Learnt from: indraniBan
Repo: PSMRI/FHIR-API PR: 53
File: src/main/java/com/wipro/fhir/utils/JwtUserIdValidationFilter.java:67-68
Timestamp: 2025-02-10T10:35:18.033Z
Learning: In security-related components like JWT filters, avoid logging sensitive information like tokens. Instead, log boolean indicators or events/outcomes for debugging purposes.

Applied to files:

  • src/main/java/com/wipro/fhir/controller/v3/careContext/CareContextLinkingController.java
πŸ“š Learning: 2025-02-03T12:55:47.722Z
Learnt from: indraniBan
Repo: PSMRI/FHIR-API PR: 53
File: src/main/java/com/wipro/fhir/utils/JwtAuthenticationUtil.java:49-52
Timestamp: 2025-02-03T12:55:47.722Z
Learning: In the FHIR-API project, detailed error messages in JWT authentication responses (e.g., "Invalid JWT Token!") are required as per project specifications and should not be replaced with generic messages.

Applied to files:

  • src/main/java/com/wipro/fhir/controller/v3/careContext/CareContextLinkingController.java
πŸ“š Learning: 2024-11-20T07:45:51.578Z
Learnt from: helenKaryamsetty
Repo: PSMRI/FHIR-API PR: 46
File: src/main/java/com/wipro/fhir/service/common/CommonServiceImpl.java:365-381
Timestamp: 2024-11-20T07:45:51.578Z
Learning: In `CommonServiceImpl.java`, within the `addCareContextToMongo` method, prefer using direct switch-case statements for gender mapping instead of introducing separate enums.

Applied to files:

  • src/main/java/com/wipro/fhir/service/v3/careContext/CareContextLinkingServiceImpl.java
  • src/main/java/com/wipro/fhir/service/common/CommonServiceImpl.java
πŸ“š Learning: 2024-12-09T15:56:01.466Z
Learnt from: helenKaryamsetty
Repo: PSMRI/FHIR-API PR: 52
File: src/main/java/com/wipro/fhir/data/v3/abhaCard/EnrollByAadhaar.java:10-13
Timestamp: 2024-12-09T15:56:01.466Z
Learning: Fields `authData` and `consent` in the `EnrollByAadhaar` class (`src/main/java/com/wipro/fhir/data/v3/abhaCard/EnrollByAadhaar.java`) are not required and can remain public.

Applied to files:

  • src/main/java/com/wipro/fhir/data/v3/careContext/GenerateCareContextTokenRequest.java
  • src/main/java/com/wipro/fhir/data/v3/careContext/AddCareContextRequest.java
  • src/main/java/com/wipro/fhir/data/v3/careContext/CareContextLinkTokenRequest.java
🧬 Code graph analysis (16)
src/main/java/com/wipro/fhir/service/resource_model/ImmunizationResource.java (1)
src/main/java/com/wipro/fhir/service/bundle_creation/ImmunizationRecordResourceBundleImpl.java (1)
  • Service (38-236)
src/main/java/com/wipro/fhir/data/resource_model/MedicalHistoryDataModel.java (3)
src/main/java/com/wipro/fhir/data/resource_model/OrganizationDataModel.java (1)
  • Component (12-88)
src/main/java/com/wipro/fhir/data/resource_model/PractitionerDataModel.java (1)
  • Data (12-83)
src/main/java/com/wipro/fhir/data/resource_model/ImmunizationDataModel.java (1)
  • Data (12-59)
src/main/java/com/wipro/fhir/data/v3/careContext/CareContexts.java (2)
src/main/java/com/wipro/fhir/data/v3/careContext/PatientCareContext.java (1)
  • Data (6-16)
src/main/java/com/wipro/fhir/data/mongo/care_context/CareContexts.java (1)
  • CareContexts (26-72)
src/main/java/com/wipro/fhir/service/v3/careContext/CareContextLinkingServiceImpl.java (3)
src/main/java/com/wipro/fhir/service/ndhm/Common_NDHMServiceImpl.java (1)
  • Service (45-202)
src/main/java/com/wipro/fhir/service/v3/abha/CreateAbhaV3ServiceImpl.java (1)
  • Service (48-460)
src/main/java/com/wipro/fhir/data/mongo/care_context/CareContexts.java (1)
  • CareContexts (26-72)
src/main/java/com/wipro/fhir/data/v3/careContext/GenerateCareContextTokenRequest.java (6)
src/main/java/com/wipro/fhir/data/mongo/care_context/GenerateTokenAbdmResponses.java (1)
  • Data (14-39)
src/main/java/com/wipro/fhir/data/v3/careContext/AddCareContextRequest.java (1)
  • Data (5-20)
src/main/java/com/wipro/fhir/data/v3/careContext/CareContextLinkTokenRequest.java (1)
  • Data (5-15)
src/main/java/com/wipro/fhir/data/v3/careContext/CareContexts.java (1)
  • Data (5-11)
src/main/java/com/wipro/fhir/data/v3/careContext/LinkCareContextRequest.java (1)
  • Data (6-14)
src/main/java/com/wipro/fhir/data/v3/careContext/PatientCareContext.java (1)
  • Data (6-16)
src/main/java/com/wipro/fhir/data/resource_model/PractitionerDataModel.java (3)
src/main/java/com/wipro/fhir/data/resource_model/OrganizationDataModel.java (1)
  • Component (12-88)
src/main/java/com/wipro/fhir/data/resource_model/MedicalHistoryDataModel.java (1)
  • Data (14-63)
src/main/java/com/wipro/fhir/data/resource_model/ImmunizationDataModel.java (1)
  • Data (12-59)
src/main/java/com/wipro/fhir/data/v3/careContext/PatientCareContext.java (1)
src/main/java/com/wipro/fhir/data/v3/careContext/CareContexts.java (1)
  • Data (5-11)
src/main/java/com/wipro/fhir/service/bundle_creation/DiagnosticRecordResourceBundleImpl.java (13)
src/main/java/com/wipro/fhir/service/resource_model/MedicalHistoryResource.java (1)
  • Service (19-73)
src/main/java/com/wipro/fhir/service/bundle_creation/DischargeSummaryResourceBundleImpl.java (1)
  • Service (56-444)
src/main/java/com/wipro/fhir/service/bundle_creation/ImmunizationRecordResourceBundleImpl.java (1)
  • Service (38-236)
src/main/java/com/wipro/fhir/service/bundle_creation/OPConsultResourceBundleImpl.java (1)
  • Service (49-340)
src/main/java/com/wipro/fhir/service/bundle_creation/PrescriptionResourceBundleImpl.java (1)
  • Service (43-228)
src/main/java/com/wipro/fhir/service/bundle_creation/WellnessRecordResourceBundleImpl.java (1)
  • Service (38-257)
src/main/java/com/wipro/fhir/service/common/CommonServiceImpl.java (1)
  • Service (94-742)
src/main/java/com/wipro/fhir/service/resource_model/ImmunizationResource.java (1)
  • Service (22-103)
src/main/java/com/wipro/fhir/service/resource_model/MedicationRequestResource.java (1)
  • Service (52-168)
src/main/java/com/wipro/fhir/service/resource_model/OrganizationResource.java (1)
  • Service (37-110)
src/main/java/com/wipro/fhir/service/resource_model/PractitionerResource.java (1)
  • Service (43-142)
src/main/java/com/wipro/fhir/service/resource_model/PatientResource.java (1)
  • Service (50-168)
src/main/java/com/wipro/fhir/service/resource_model/DiagnosticReportResource.java (1)
  • Service (52-136)
src/main/java/com/wipro/fhir/service/bundle_creation/OPConsultResourceBundleImpl.java (12)
src/main/java/com/wipro/fhir/service/resource_model/MedicalHistoryResource.java (1)
  • Service (19-73)
src/main/java/com/wipro/fhir/service/bundle_creation/DiagnosticRecordResourceBundleImpl.java (1)
  • Service (42-253)
src/main/java/com/wipro/fhir/service/bundle_creation/DischargeSummaryResourceBundleImpl.java (1)
  • Service (56-444)
src/main/java/com/wipro/fhir/service/bundle_creation/ImmunizationRecordResourceBundleImpl.java (1)
  • Service (38-236)
src/main/java/com/wipro/fhir/service/bundle_creation/PrescriptionResourceBundleImpl.java (1)
  • Service (43-228)
src/main/java/com/wipro/fhir/service/bundle_creation/WellnessRecordResourceBundleImpl.java (1)
  • Service (38-257)
src/main/java/com/wipro/fhir/service/common/CommonServiceImpl.java (1)
  • Service (94-742)
src/main/java/com/wipro/fhir/service/resource_model/ImmunizationResource.java (1)
  • Service (22-103)
src/main/java/com/wipro/fhir/service/resource_model/OrganizationResource.java (1)
  • Service (37-110)
src/main/java/com/wipro/fhir/service/resource_model/PractitionerResource.java (1)
  • Service (43-142)
src/main/java/com/wipro/fhir/service/resource_model/PatientResource.java (1)
  • Service (50-168)
src/main/java/com/wipro/fhir/service/resource_model/DiagnosticReportResource.java (1)
  • Service (52-136)
src/main/java/com/wipro/fhir/data/mongo/care_context/GenerateTokenAbdmResponses.java (4)
src/main/java/com/wipro/fhir/data/v3/careContext/AddCareContextRequest.java (1)
  • Data (5-20)
src/main/java/com/wipro/fhir/data/v3/careContext/CareContexts.java (1)
  • Data (5-11)
src/main/java/com/wipro/fhir/data/v3/careContext/GenerateCareContextTokenRequest.java (1)
  • Data (5-14)
src/main/java/com/wipro/fhir/data/v3/careContext/LinkCareContextRequest.java (1)
  • Data (6-14)
src/main/java/com/wipro/fhir/service/bundle_creation/ImmunizationRecordResourceBundleImpl.java (8)
src/main/java/com/wipro/fhir/service/bundle_creation/DiagnosticRecordResourceBundleImpl.java (1)
  • Service (42-253)
src/main/java/com/wipro/fhir/service/bundle_creation/OPConsultResourceBundleImpl.java (1)
  • Service (49-340)
src/main/java/com/wipro/fhir/service/bundle_creation/PrescriptionResourceBundleImpl.java (1)
  • Service (43-228)
src/main/java/com/wipro/fhir/service/common/CommonServiceImpl.java (1)
  • Service (94-742)
src/main/java/com/wipro/fhir/service/resource_model/ImmunizationResource.java (1)
  • Service (22-103)
src/main/java/com/wipro/fhir/service/resource_model/OrganizationResource.java (1)
  • Service (37-110)
src/main/java/com/wipro/fhir/service/resource_model/PractitionerResource.java (1)
  • Service (43-142)
src/main/java/com/wipro/fhir/service/resource_model/PatientResource.java (1)
  • Service (50-168)
src/main/java/com/wipro/fhir/service/bundle_creation/DischargeSummaryResourceBundleImpl.java (14)
src/main/java/com/wipro/fhir/service/resource_model/MedicalHistoryResource.java (1)
  • Service (19-73)
src/main/java/com/wipro/fhir/service/bundle_creation/DiagnosticRecordResourceBundleImpl.java (1)
  • Service (42-253)
src/main/java/com/wipro/fhir/service/bundle_creation/ImmunizationRecordResourceBundleImpl.java (1)
  • Service (38-236)
src/main/java/com/wipro/fhir/service/bundle_creation/OPConsultResourceBundleImpl.java (1)
  • Service (49-340)
src/main/java/com/wipro/fhir/service/bundle_creation/PrescriptionResourceBundleImpl.java (1)
  • Service (43-228)
src/main/java/com/wipro/fhir/service/bundle_creation/WellnessRecordResourceBundleImpl.java (1)
  • Service (38-257)
src/main/java/com/wipro/fhir/service/common/CommonServiceImpl.java (1)
  • Service (94-742)
src/main/java/com/wipro/fhir/service/resource_model/EncounterResource.java (1)
  • Service (52-195)
src/main/java/com/wipro/fhir/service/resource_model/ImmunizationResource.java (1)
  • Service (22-103)
src/main/java/com/wipro/fhir/service/resource_model/MedicationRequestResource.java (1)
  • Service (52-168)
src/main/java/com/wipro/fhir/service/resource_model/OrganizationResource.java (1)
  • Service (37-110)
src/main/java/com/wipro/fhir/service/resource_model/PractitionerResource.java (1)
  • Service (43-142)
src/main/java/com/wipro/fhir/service/resource_model/PatientResource.java (1)
  • Service (50-168)
src/main/java/com/wipro/fhir/service/resource_model/DiagnosticReportResource.java (1)
  • Service (52-136)
src/main/java/com/wipro/fhir/data/v3/careContext/LinkCareContextRequest.java (6)
src/main/java/com/wipro/fhir/data/mongo/care_context/GenerateTokenAbdmResponses.java (1)
  • Data (14-39)
src/main/java/com/wipro/fhir/data/v3/careContext/AddCareContextRequest.java (1)
  • Data (5-20)
src/main/java/com/wipro/fhir/data/v3/careContext/CareContextLinkTokenRequest.java (1)
  • Data (5-15)
src/main/java/com/wipro/fhir/data/v3/careContext/CareContexts.java (1)
  • Data (5-11)
src/main/java/com/wipro/fhir/data/v3/careContext/GenerateCareContextTokenRequest.java (1)
  • Data (5-14)
src/main/java/com/wipro/fhir/data/v3/careContext/PatientCareContext.java (1)
  • Data (6-16)
src/main/java/com/wipro/fhir/service/ndhm/Common_NDHMServiceImpl.java (1)
src/main/java/com/wipro/fhir/service/v3/careContext/CareContextLinkingServiceImpl.java (1)
  • Service (53-399)
src/main/java/com/wipro/fhir/data/v3/careContext/AddCareContextRequest.java (6)
src/main/java/com/wipro/fhir/data/mongo/care_context/GenerateTokenAbdmResponses.java (1)
  • Data (14-39)
src/main/java/com/wipro/fhir/data/v3/careContext/CareContextLinkTokenRequest.java (1)
  • Data (5-15)
src/main/java/com/wipro/fhir/data/v3/careContext/CareContexts.java (1)
  • Data (5-11)
src/main/java/com/wipro/fhir/data/v3/careContext/GenerateCareContextTokenRequest.java (1)
  • Data (5-14)
src/main/java/com/wipro/fhir/data/v3/careContext/LinkCareContextRequest.java (1)
  • Data (6-14)
src/main/java/com/wipro/fhir/data/v3/careContext/PatientCareContext.java (1)
  • Data (6-16)
src/main/java/com/wipro/fhir/data/v3/careContext/CareContextLinkTokenRequest.java (5)
src/main/java/com/wipro/fhir/data/mongo/care_context/GenerateTokenAbdmResponses.java (1)
  • Data (14-39)
src/main/java/com/wipro/fhir/data/v3/careContext/AddCareContextRequest.java (1)
  • Data (5-20)
src/main/java/com/wipro/fhir/data/v3/careContext/CareContexts.java (1)
  • Data (5-11)
src/main/java/com/wipro/fhir/data/v3/careContext/GenerateCareContextTokenRequest.java (1)
  • Data (5-14)
src/main/java/com/wipro/fhir/data/v3/careContext/PatientCareContext.java (1)
  • Data (6-16)
πŸͺ› GitHub Actions: Commit Compliance
src/main/environment/common_docker.properties

[error] 1-1: commitlint: subject may not be empty [subject-empty]. type may not be empty [type-empty].

Comment on lines +43 to +77
public OrganizationDataModel(Object[] objArr) throws FHIRException {

try {

this.benVisitID = objArr[0] != null ? Long.parseLong(objArr[0].toString()) : null;
this.serviceProviderID = objArr[1] != null ? Short.parseShort(objArr[1].toString()) : null;
this.serviceProviderName = objArr[2] != null ? objArr[2].toString() : null;

this.stateID = objArr[3] != null ? Integer.parseInt(objArr[3].toString()) : null;
this.stateName = objArr[4] != null ? objArr[4].toString() : null;

this.districtID = objArr[5] != null ? Integer.parseInt(objArr[5].toString()) : null;
this.districtName = objArr[6] != null ? objArr[6].toString() : null;

this.locationName = objArr[7] != null ? objArr[7].toString() : null;
this.address = objArr[8] != null ? objArr[8].toString() : null;

this.serviceID = objArr[9] != null ? Short.parseShort(objArr[9].toString()) : null;
this.serviceName = objArr[10] != null ? objArr[10].toString() : null;

this.isNational = objArr[11] != null
? objArr[11].toString().equalsIgnoreCase("true") || objArr[11].toString().equals("1")
: null;

this.abdmFacilityId = objArr[12] != null ? objArr[12].toString() : null;
this.abdmFacilityName = objArr[13] != null ? objArr[13].toString() : null;

this.psAddMapID = objArr[14] != null ? Integer.parseInt(objArr[14].toString()) : null;
this.providerServiceMapID = objArr[15] != null ? Integer.parseInt(objArr[15].toString()) : null;

} catch (Exception e) {
throw new FHIRException("Organization resource failed with error - " + e.getMessage());
}

}
Copy link
Contributor

@coderabbitai coderabbitai bot Dec 30, 2025

Choose a reason for hiding this comment

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

πŸ› οΈ Refactor suggestion | 🟠 Major

Add array length validation to prevent ArrayIndexOutOfBoundsException.

The constructor accesses array indices 0-15 without first validating that objArr has sufficient length. This could lead to ArrayIndexOutOfBoundsException if the stored procedure returns fewer columns than expected.

πŸ”Ž Proposed fix
 public OrganizationDataModel(Object[] objArr) throws FHIRException {
 
 	try {
+		if (objArr == null || objArr.length < 16) {
+			throw new FHIRException("Invalid organization data array: expected at least 16 elements");
+		}
 
 		this.benVisitID = objArr[0] != null ? Long.parseLong(objArr[0].toString()) : 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
public OrganizationDataModel(Object[] objArr) throws FHIRException {
try {
this.benVisitID = objArr[0] != null ? Long.parseLong(objArr[0].toString()) : null;
this.serviceProviderID = objArr[1] != null ? Short.parseShort(objArr[1].toString()) : null;
this.serviceProviderName = objArr[2] != null ? objArr[2].toString() : null;
this.stateID = objArr[3] != null ? Integer.parseInt(objArr[3].toString()) : null;
this.stateName = objArr[4] != null ? objArr[4].toString() : null;
this.districtID = objArr[5] != null ? Integer.parseInt(objArr[5].toString()) : null;
this.districtName = objArr[6] != null ? objArr[6].toString() : null;
this.locationName = objArr[7] != null ? objArr[7].toString() : null;
this.address = objArr[8] != null ? objArr[8].toString() : null;
this.serviceID = objArr[9] != null ? Short.parseShort(objArr[9].toString()) : null;
this.serviceName = objArr[10] != null ? objArr[10].toString() : null;
this.isNational = objArr[11] != null
? objArr[11].toString().equalsIgnoreCase("true") || objArr[11].toString().equals("1")
: null;
this.abdmFacilityId = objArr[12] != null ? objArr[12].toString() : null;
this.abdmFacilityName = objArr[13] != null ? objArr[13].toString() : null;
this.psAddMapID = objArr[14] != null ? Integer.parseInt(objArr[14].toString()) : null;
this.providerServiceMapID = objArr[15] != null ? Integer.parseInt(objArr[15].toString()) : null;
} catch (Exception e) {
throw new FHIRException("Organization resource failed with error - " + e.getMessage());
}
}
public OrganizationDataModel(Object[] objArr) throws FHIRException {
try {
if (objArr == null || objArr.length < 16) {
throw new FHIRException("Invalid organization data array: expected at least 16 elements");
}
this.benVisitID = objArr[0] != null ? Long.parseLong(objArr[0].toString()) : null;
this.serviceProviderID = objArr[1] != null ? Short.parseShort(objArr[1].toString()) : null;
this.serviceProviderName = objArr[2] != null ? objArr[2].toString() : null;
this.stateID = objArr[3] != null ? Integer.parseInt(objArr[3].toString()) : null;
this.stateName = objArr[4] != null ? objArr[4].toString() : null;
this.districtID = objArr[5] != null ? Integer.parseInt(objArr[5].toString()) : null;
this.districtName = objArr[6] != null ? objArr[6].toString() : null;
this.locationName = objArr[7] != null ? objArr[7].toString() : null;
this.address = objArr[8] != null ? objArr[8].toString() : null;
this.serviceID = objArr[9] != null ? Short.parseShort(objArr[9].toString()) : null;
this.serviceName = objArr[10] != null ? objArr[10].toString() : null;
this.isNational = objArr[11] != null
? objArr[11].toString().equalsIgnoreCase("true") || objArr[11].toString().equals("1")
: null;
this.abdmFacilityId = objArr[12] != null ? objArr[12].toString() : null;
this.abdmFacilityName = objArr[13] != null ? objArr[13].toString() : null;
this.psAddMapID = objArr[14] != null ? Integer.parseInt(objArr[14].toString()) : null;
this.providerServiceMapID = objArr[15] != null ? Integer.parseInt(objArr[15].toString()) : null;
} catch (Exception e) {
throw new FHIRException("Organization resource failed with error - " + e.getMessage());
}
}
πŸ€– Prompt for AI Agents
In src/main/java/com/wipro/fhir/data/resource_model/OrganizationDataModel.java
around lines 43 to 77, the constructor reads objArr[0]..objArr[15] without
verifying objArr length which can cause ArrayIndexOutOfBoundsException; add a
guard that objArr is not null and objArr.length >= 16 before accessing indices,
and if the check fails either throw a clear FHIRException indicating
insufficient columns (including actual length) or set missing fields to null
based on expected behavior; implement the simplest fix consistent with project
error handling (validate length up-front and throw a descriptive FHIRException)
so subsequent index accesses are safe.

Copy link
Member Author

Choose a reason for hiding this comment

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

@coderabbitai this is checked before calling this method, so not required here

Copy link
Contributor

Choose a reason for hiding this comment

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

@helenKaryamsetty, understood! Thank you for clarifying that the array length validation is handled before calling the constructor. I've noted this pattern for future reviews.


✏️ Learnings added
Learnt from: helenKaryamsetty
Repo: PSMRI/FHIR-API PR: 128
File: src/main/java/com/wipro/fhir/data/resource_model/OrganizationDataModel.java:43-77
Timestamp: 2025-12-30T10:16:44.915Z
Learning: In the FHIR-API project, data model constructors (such as OrganizationDataModel, PractitionerDataModel, MedicalHistoryDataModel, ImmunizationDataModel) that accept Object[] arrays have validation performed at the caller level before invoking the constructor. Array length validation is not required within these constructors.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.


🧠 Learnings used
Learnt from: helenKaryamsetty
Repo: PSMRI/FHIR-API PR: 46
File: src/main/java/com/wipro/fhir/data/mongo/care_context/SaveFacilityIdForVisit.java:7-8
Timestamp: 2024-11-20T07:41:40.038Z
Learning: In the `SaveFacilityIdForVisit` class (`src/main/java/com/wipro/fhir/data/mongo/care_context/SaveFacilityIdForVisit.java`), the handling of the MongoDB ID field and indexing is provided in another module and is not required in this class.

Comment on lines +42 to +73
public PractitionerDataModel(Object[] objArr) throws FHIRException {

try {

this.benVisitID = objArr[0] != null ? Integer.parseInt(objArr[0].toString()) : null;
this.userID = objArr[1] != null ? Integer.parseInt(objArr[1].toString()) : null;

this.fullName = objArr[2] != null ? objArr[2].toString() : null;

this.dob = objArr[3] != null ? (objArr[3] instanceof Date ? (Date) objArr[3] : null) : null;

this.employeeID = objArr[4] != null ? objArr[4].toString() : null;
this.contactNo = objArr[5] != null ? objArr[5].toString() : null;
this.emailID = objArr[6] != null ? objArr[6].toString() : null;
this.qualificationName = objArr[7] != null ? objArr[7].toString() : null;
this.designationName = objArr[8] != null ? objArr[8].toString() : null;
this.genderName = objArr[9] != null ? objArr[9].toString() : null;

this.genderID = objArr[10] != null ? Integer.parseInt(objArr[10].toString()) : null;
this.serviceProviderID = objArr[11] != null ? Integer.parseInt(objArr[11].toString()) : null;

this.visitCode = objArr[12] != null ? Long.parseLong(objArr[12].toString()) : null;

this.createdBy = objArr[13] != null ? objArr[13].toString() : null;

this.createdDate = objArr[14] != null ? (objArr[14] instanceof Timestamp ? (Timestamp) objArr[14] : null)
: null;
} catch (Exception e) {
throw new FHIRException("Practitioner resource failed with error - " + e.getMessage());
}

}
Copy link
Contributor

@coderabbitai coderabbitai bot Dec 30, 2025

Choose a reason for hiding this comment

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

πŸ› οΈ Refactor suggestion | 🟠 Major

Add array length validation to prevent ArrayIndexOutOfBoundsException.

The constructor accesses array indices 0-14 without validating that objArr has sufficient length. Add a length check at the beginning to fail fast with a clear error message if the array is too short.

πŸ”Ž Proposed fix
 public PractitionerDataModel(Object[] objArr) throws FHIRException {
 
 	try {
+		if (objArr == null || objArr.length < 15) {
+			throw new FHIRException("Invalid practitioner data array: expected at least 15 elements");
+		}
 
 		this.benVisitID = objArr[0] != null ? Integer.parseInt(objArr[0].toString()) : null;
πŸ€– Prompt for AI Agents
In src/main/java/com/wipro/fhir/data/resource_model/PractitionerDataModel.java
around lines 42 to 73, the constructor reads indices 0–14 from objArr without
validating the array length; add a defensive check at the start: verify objArr
is not null and objArr.length >= 15 and if not throw a FHIRException with a
clear message like "PractitionerDataModel expects an Object[] of length >=15,
got X" so the method fails fast and avoids ArrayIndexOutOfBoundsException; keep
the existing try/catch for parsing errors after this initial validation.

Copy link
Member Author

Choose a reason for hiding this comment

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

@coderabbitai this was checked in previous method, so not required here

Copy link
Contributor

Choose a reason for hiding this comment

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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check the full PractitionerDataModel class to see if there's a getPractitioner factory method
cat src/main/java/com/wipro/fhir/data/resource_model/PractitionerDataModel.java

Length of output: 2451


🏁 Script executed:

#!/bin/bash
# Search for all places where PractitionerDataModel constructor is called
rg -n "new PractitionerDataModel" --type java -C 5

Length of output: 925


🏁 Script executed:

#!/bin/bash
# Check similar data model classes for validation patterns
cat src/main/java/com/wipro/fhir/data/resource_model/OrganizationDataModel.java

Length of output: 2597


🏁 Script executed:

#!/bin/bash
# Check MedicalHistoryDataModel for similar patterns
cat src/main/java/com/wipro/fhir/data/resource_model/MedicalHistoryDataModel.java

Length of output: 1910


@helenKaryamsetty, you're right that the getPractitioner(Object[] resultSet) method validates the array before calling the constructor. I can see it checks for null and empty arrays at line 77-78 before instantiating the object.

That said, the current validation only checks resultSet.length == 0, not whether it has at least 15 elements, so arrays with length 1-14 would still cause an ArrayIndexOutOfBoundsException. But if the stored procedure always returns the expected column count, this shouldn't be an issue in practice.

I understand your design decision to keep the validation at the factory method level. Thanks for the clarification!

Comment on lines 10 to 23
public interface CareContextRepo extends CrudRepository<PatientEligibleForResourceCreation, BigInteger> {

@Query(value="SELECT COUNT(*) FROM t_phy_vitals WHERE VisitCode = :visitCode", nativeQuery = true)
public int hasPhyVitals(String visitCode);

@Query(value="SELECT COUNT(*) FROM t_prescribeddrug WHERE VisitCode = :visitCode", nativeQuery = true)
public int hasPrescribedDrugs(String visitCode);

@Query(value="SELECT COUNT(*) FROM t_lab_testorder WHERE VisitCode = :visitCode", nativeQuery = true)
public int hasLabtestsDone(String visitCode);

@Query(value="SELECT COUNT(*) FROM t_childvaccinedetail1 WHERE VisitCode = :visitCode", nativeQuery = true)
public int hasVaccineDetails(String visitCode);

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | πŸ”΄ Critical

Missing @Param annotations will cause runtime failures.

The native query methods use named parameters (:visitCode) but the method parameters lack the @Param annotation. Spring Data JPA requires explicit @Param bindings for named parameters in native queries; otherwise, a runtime exception will occur.

πŸ”Ž Proposed fix to add @param annotations
 package com.wipro.fhir.repo.v3.careContext;
 
 import java.math.BigInteger;
 
 import org.springframework.data.jpa.repository.Query;
 import org.springframework.data.repository.CrudRepository;
+import org.springframework.data.repository.query.Param;
 
 import com.wipro.fhir.data.request_handler.PatientEligibleForResourceCreation;
 
 public interface CareContextRepo extends CrudRepository<PatientEligibleForResourceCreation, BigInteger> {
 	
 	@Query(value="SELECT COUNT(*) FROM t_phy_vitals WHERE VisitCode = :visitCode", nativeQuery = true)
-	public int hasPhyVitals(String visitCode);
+	public int hasPhyVitals(@Param("visitCode") String visitCode);
 	
 	@Query(value="SELECT COUNT(*) FROM t_prescribeddrug WHERE VisitCode = :visitCode", nativeQuery = true)
-	public int hasPrescribedDrugs(String visitCode);
+	public int hasPrescribedDrugs(@Param("visitCode") String visitCode);
 	
 	@Query(value="SELECT COUNT(*) FROM t_lab_testorder WHERE VisitCode = :visitCode", nativeQuery = true)
-	public int hasLabtestsDone(String visitCode);
+	public int hasLabtestsDone(@Param("visitCode") String visitCode);
 	
 	@Query(value="SELECT COUNT(*) FROM t_childvaccinedetail1 WHERE VisitCode = :visitCode", nativeQuery = true)
-	public int hasVaccineDetails(String visitCode);
+	public int hasVaccineDetails(@Param("visitCode") String visitCode);
 	
 }
πŸ€– Prompt for AI Agents
In src/main/java/com/wipro/fhir/repo/v3/careContext/CareContextRepo.java around
lines 10 to 23, the native query methods declare named parameter :visitCode but
the method parameters are missing @Param bindings which will fail at runtime;
fix each method by annotating the visitCode parameter with @Param("visitCode")
(and add the import org.springframework.data.repository.query.Param if not
present) so Spring Data JPA can bind the named parameter for hasPhyVitals,
hasPrescribedDrugs, hasLabtestsDone, and hasVaccineDetails.

Comment on lines 26 to 34
Composition PopulateDischargeSummaryComposition(ResourceRequestHandler resourceRequestHandler,
PatientEligibleForResourceCreation p, Practitioner practitioner, Organization organization, Patient patient,
Encounter encounter, List<Condition> chiefComplaints, List<Condition> physicalExam,
List<AllergyIntolerance> allergyList, FamilyMemberHistory familyMemberHistory,
List<MedicationStatement> pastMedicalHistoryConditions, List<MedicationRequest> medicationRequests,
List<DiagnosticReport> procedures);

String PopulateDischargeSummaryResourceBundle(ResourceRequestHandler resourceRequestHandler,
PatientEligibleForResourceCreation p) throws FHIRException;
Copy link
Contributor

Choose a reason for hiding this comment

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

πŸ› οΈ Refactor suggestion | 🟠 Major

Method names should follow camelCase convention.

Java convention is to start method names with a lowercase letter. PopulateDischargeSummaryComposition and PopulateDischargeSummaryResourceBundle should be populateDischargeSummaryComposition and populateDischargeSummaryResourceBundle.

Suggested fix
-	Composition PopulateDischargeSummaryComposition(ResourceRequestHandler resourceRequestHandler,
+	Composition populateDischargeSummaryComposition(ResourceRequestHandler resourceRequestHandler,
 			PatientEligibleForResourceCreation p, Practitioner practitioner, Organization organization, Patient patient,
 			Encounter encounter, List<Condition> chiefComplaints, List<Condition> physicalExam,
 			List<AllergyIntolerance> allergyList, FamilyMemberHistory familyMemberHistory,
 			List<MedicationStatement> pastMedicalHistoryConditions, List<MedicationRequest> medicationRequests,
 			List<DiagnosticReport> procedures);

-	String PopulateDischargeSummaryResourceBundle(ResourceRequestHandler resourceRequestHandler,
+	String populateDischargeSummaryResourceBundle(ResourceRequestHandler resourceRequestHandler,
 			PatientEligibleForResourceCreation p) throws FHIRException;
πŸ“ 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
Composition PopulateDischargeSummaryComposition(ResourceRequestHandler resourceRequestHandler,
PatientEligibleForResourceCreation p, Practitioner practitioner, Organization organization, Patient patient,
Encounter encounter, List<Condition> chiefComplaints, List<Condition> physicalExam,
List<AllergyIntolerance> allergyList, FamilyMemberHistory familyMemberHistory,
List<MedicationStatement> pastMedicalHistoryConditions, List<MedicationRequest> medicationRequests,
List<DiagnosticReport> procedures);
String PopulateDischargeSummaryResourceBundle(ResourceRequestHandler resourceRequestHandler,
PatientEligibleForResourceCreation p) throws FHIRException;
Composition populateDischargeSummaryComposition(ResourceRequestHandler resourceRequestHandler,
PatientEligibleForResourceCreation p, Practitioner practitioner, Organization organization, Patient patient,
Encounter encounter, List<Condition> chiefComplaints, List<Condition> physicalExam,
List<AllergyIntolerance> allergyList, FamilyMemberHistory familyMemberHistory,
List<MedicationStatement> pastMedicalHistoryConditions, List<MedicationRequest> medicationRequests,
List<DiagnosticReport> procedures);
String populateDischargeSummaryResourceBundle(ResourceRequestHandler resourceRequestHandler,
PatientEligibleForResourceCreation p) throws FHIRException;
πŸ€– Prompt for AI Agents
In
src/main/java/com/wipro/fhir/service/bundle_creation/DischargeSummaryResourceBundle.java
around lines 26 to 34, the two method declarations use PascalCase names
(`PopulateDischargeSummaryComposition`,
`PopulateDischargeSummaryResourceBundle`) instead of Java camelCase; rename them
to `populateDischargeSummaryComposition` and
`populateDischargeSummaryResourceBundle` (update declaration and any
references/implementations) and ensure method calls, overrides, and implementing
classes/interfaces are updated to match the new names and compile.

Comment on lines +114 to +119
if (null != careContextLinkRequest.getAbdmFacilityId()
&& "" != careContextLinkRequest.getAbdmFacilityId()) {
headers.add("X-HIP-ID", careContextLinkRequest.getAbdmFacilityId());
} else {
headers.add("X-HIP-ID", abdmFacilityId);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | πŸ”΄ Critical

Critical: String comparison using != instead of !equals().

Lines 115 and 248 use "" != string for string comparison, which compares object references rather than values. This will almost always evaluate to true even for empty strings, causing the condition to incorrectly pass.

πŸ”Ž Proposed fix
-				if (null != careContextLinkRequest.getAbdmFacilityId()
-						&& "" != careContextLinkRequest.getAbdmFacilityId()) {
+				if (null != careContextLinkRequest.getAbdmFacilityId()
+						&& !careContextLinkRequest.getAbdmFacilityId().isEmpty()) {
πŸ“ 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
if (null != careContextLinkRequest.getAbdmFacilityId()
&& "" != careContextLinkRequest.getAbdmFacilityId()) {
headers.add("X-HIP-ID", careContextLinkRequest.getAbdmFacilityId());
} else {
headers.add("X-HIP-ID", abdmFacilityId);
}
if (null != careContextLinkRequest.getAbdmFacilityId()
&& !careContextLinkRequest.getAbdmFacilityId().isEmpty()) {
headers.add("X-HIP-ID", careContextLinkRequest.getAbdmFacilityId());
} else {
headers.add("X-HIP-ID", abdmFacilityId);
}
πŸ€– Prompt for AI Agents
In
src/main/java/com/wipro/fhir/service/v3/careContext/CareContextLinkingServiceImpl.java
around lines 114-119 (and the other occurrence at ~248), the code uses reference
comparison ("" != string) which is incorrect; change the checks to a proper
value check such as: ensure the string is not null and not empty using either
!careContextLinkRequest.getAbdmFacilityId().isEmpty() or
!careContextLinkRequest.getAbdmFacilityId().equals("") (or use
StringUtils.isNotBlank/getAbdmFacilityId() != null &&
!getAbdmFacilityId().isBlank() for Java 11+), and apply the same fix at the
other occurrence to correctly choose between
careContextLinkRequest.getAbdmFacilityId() and abdmFacilityId.

Comment on lines 122 to 126
if (null != careContextLinkRequest.getAbhaNumber() && "" != careContextLinkRequest.getAbhaNumber()) {
String abha = careContextLinkRequest.getAbhaNumber();
String abhaNumber = abha.replace("-", "");
generateTokenRequest.setAbhaNumber(abhaNumber);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | πŸ”΄ Critical

Same string comparison issue with !=.

Line 122 has the same problem: "" != careContextLinkRequest.getAbhaNumber() should use !string.isEmpty() or !string.equals("").

πŸ”Ž Proposed fix
-				if (null != careContextLinkRequest.getAbhaNumber() && "" != careContextLinkRequest.getAbhaNumber()) {
+				if (null != careContextLinkRequest.getAbhaNumber() && !careContextLinkRequest.getAbhaNumber().isEmpty()) {
πŸ“ 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
if (null != careContextLinkRequest.getAbhaNumber() && "" != careContextLinkRequest.getAbhaNumber()) {
String abha = careContextLinkRequest.getAbhaNumber();
String abhaNumber = abha.replace("-", "");
generateTokenRequest.setAbhaNumber(abhaNumber);
}
if (null != careContextLinkRequest.getAbhaNumber() && !careContextLinkRequest.getAbhaNumber().isEmpty()) {
String abha = careContextLinkRequest.getAbhaNumber();
String abhaNumber = abha.replace("-", "");
generateTokenRequest.setAbhaNumber(abhaNumber);
}
πŸ€– Prompt for AI Agents
In
src/main/java/com/wipro/fhir/service/v3/careContext/CareContextLinkingServiceImpl.java
around lines 122 to 126, the code uses the incorrect string comparison "" !=
careContextLinkRequest.getAbhaNumber(); update the condition to properly check
for non-null and non-empty string (e.g., careContextLinkRequest.getAbhaNumber()
!= null && !careContextLinkRequest.getAbhaNumber().isEmpty() or use
!careContextLinkRequest.getAbhaNumber().trim().isEmpty() if trimming is
desired), keeping the null check first, then extract and replace hyphens as
before and set generateTokenRequest.setAbhaNumber(abhaNumber).

Comment on lines 247 to 252
if (null != addCareContextRequest.getAbdmFacilityId()
&& "" != addCareContextRequest.getAbdmFacilityId()) {
headers.add("X-HIP-ID", addCareContextRequest.getAbdmFacilityId());
} else {
headers.add("X-HIP-ID", abdmFacilityId);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | πŸ”΄ Critical

Same string comparison issue repeated.

πŸ”Ž Proposed fix
-				if (null != addCareContextRequest.getAbdmFacilityId()
-						&& "" != addCareContextRequest.getAbdmFacilityId()) {
+				if (null != addCareContextRequest.getAbdmFacilityId()
+						&& !addCareContextRequest.getAbdmFacilityId().isEmpty()) {
πŸ“ 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
if (null != addCareContextRequest.getAbdmFacilityId()
&& "" != addCareContextRequest.getAbdmFacilityId()) {
headers.add("X-HIP-ID", addCareContextRequest.getAbdmFacilityId());
} else {
headers.add("X-HIP-ID", abdmFacilityId);
}
if (null != addCareContextRequest.getAbdmFacilityId()
&& !addCareContextRequest.getAbdmFacilityId().isEmpty()) {
headers.add("X-HIP-ID", addCareContextRequest.getAbdmFacilityId());
} else {
headers.add("X-HIP-ID", abdmFacilityId);
}
πŸ€– Prompt for AI Agents
In
src/main/java/com/wipro/fhir/service/v3/careContext/CareContextLinkingServiceImpl.java
around lines 247 to 252, the code uses "" !=
addCareContextRequest.getAbdmFacilityId() to check for an empty string which is
an incorrect reference comparison; replace this with a proper emptiness check
such as addCareContextRequest.getAbdmFacilityId() != null &&
!addCareContextRequest.getAbdmFacilityId().isEmpty() (or use
StringUtils.hasText/addAbdmFacilityId().isBlank() depending on project
conventions) so the header selection uses a correct null/empty check and avoids
incorrect string comparison.

Comment on lines 278 to 282
if (null != addCareContextRequest.getAbhaNumber() && "" != addCareContextRequest.getAbhaNumber()) {
String abha = addCareContextRequest.getAbhaNumber();
String abhaNumber = abha.replace("-", "");
linkCareContextRequest.setAbhaNumber(abhaNumber);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | πŸ”΄ Critical

Same string comparison issue repeated.

πŸ”Ž Proposed fix
-				if (null != addCareContextRequest.getAbhaNumber() && "" != addCareContextRequest.getAbhaNumber()) {
+				if (null != addCareContextRequest.getAbhaNumber() && !addCareContextRequest.getAbhaNumber().isEmpty()) {
πŸ“ 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
if (null != addCareContextRequest.getAbhaNumber() && "" != addCareContextRequest.getAbhaNumber()) {
String abha = addCareContextRequest.getAbhaNumber();
String abhaNumber = abha.replace("-", "");
linkCareContextRequest.setAbhaNumber(abhaNumber);
}
if (null != addCareContextRequest.getAbhaNumber() && !addCareContextRequest.getAbhaNumber().isEmpty()) {
String abha = addCareContextRequest.getAbhaNumber();
String abhaNumber = abha.replace("-", "");
linkCareContextRequest.setAbhaNumber(abhaNumber);
}
πŸ€– Prompt for AI Agents
In
src/main/java/com/wipro/fhir/service/v3/careContext/CareContextLinkingServiceImpl.java
around lines 278 to 282, the code uses an incorrect string comparison ("" !=
addCareContextRequest.getAbhaNumber()); replace this with a proper check such as
retrieving the value into a local String, trimming it, and using !abha.isEmpty()
or !abha.isBlank() (or StringUtils.isNotBlank(abha) if the project uses Apache
Commons) before removing dashes and setting
linkCareContextRequest.setAbhaNumber(abhaNumber); ensure null check remains and
avoid using ==/!= for string content comparison.

helenKaryamsetty and others added 2 commits December 30, 2025 15:43
* Abdm Facility fetch services changes

* facility save after carecontext and patientcarecontextx update

* FacilityId save in mongo db and Variable declaration correction

* Mongo carecontext save query logic changes

* ABHA Creation M1 V3 API changes

* Abha V3 changes

* removed unused code

* v3- verify auth by abdm API changes

* feat: Abdm M2 V3 changes

* feat: mongo query change fetch for linktoken

* fix: link carecontext authorization error

* feat: hiTypes addition

* feat: version change for testing

* fix: minor change for empty response

* Simplify queries in CareContextRepo interface

Removed unnecessary 'order by 1 desc' clause from queries.

* fix: corrected response format

* fix: minor logic change for care context linking

* small correction in hiType and error message modification

* modified error message

* feat: new standard FHIR bundles creation

* Fix environment variable for systemUrl

* Fix formatting of systemUrl property

* fix: taken coderabbitai comments and minor changes

* fix: changed missed variable

* fix: modified the constructor

* Change exception message for Organization resource

* Fix typo in exception message for PractitionerDataModel

* fix: corrected type error

* fix: correct medication histoory model class

* fix: taken coderabbitai comments

---------

Co-authored-by: KA40094929 <KA40094929@10.152.32.202>
Co-authored-by: KA40094929 <KA40094929@APL-5CD1394ZJT>
Co-authored-by: Karyamsetty Helen Grace <ka40094929@wipro.com>
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
1 Security Hotspot
10.4% Duplication on New Code (required ≀ 3%)

See analysis details on SonarQube Cloud

@helenKaryamsetty helenKaryamsetty merged commit c2cd720 into release-3.6.1 Dec 30, 2025
1 of 3 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