Skip to content

Conversation

@devikasuresh20
Copy link
Contributor

@devikasuresh20 devikasuresh20 commented Jun 23, 2025

πŸ“‹ Description

JIRA ID: AMM-1536

Added changes for configuring tele consultation ( ESanjeevani or Swymed) from work location mapping screen.


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

  • New Features

    • Expanded tele consultation options in work location mapping, allowing selection between "ESanjeevani", "Swymed", or "Not Required" instead of a single option.
    • Updated user interface elements and layout for improved tele consultation selection and management.
  • Refactor

    • Replaced all references to "eSanjeevani" with a more general "Tele Consultation" concept throughout the work location mapping feature.
    • Updated pagination handling for tables to use separate paginators.
  • Chores

    • Updated API endpoint URLs for admin, superadmin, common, and FHIR services in environment configurations.

@coderabbitai
Copy link

coderabbitai bot commented Jun 23, 2025

Walkthrough

The changes generalize the "eSanjeevani" feature to a broader "Tele Consultation" concept in the work location mapping UI and logic, update API endpoint paths in environment files, and remove the file replacement configuration from the Angular development build. Pagination handling in the component is also refined.

Changes

File(s) Change Summary
angular.json Removed "fileReplacements" from the development build configuration.
src/environments/environment.prod.ts
src/environments/environment.test.ts
Updated API endpoint paths for admin, superadmin, common, and FHIR services to use new, shorter suffixes.
src/app/app-provider-admin/provider-admin/activities/work-location-mapping/work-location-mapping.component.html Replaced all "eSanjeevani" UI elements with a generic "Tele Consultation" option, updated form controls, table columns, and layout.
src/app/app-provider-admin/provider-admin/activities/work-location-mapping/work-location-mapping.component.ts Refactored logic and variable names from "eSanjeevani" to "teleConsultation", updated mapping logic, and separated paginators.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant WorkLocationMappingComponent
    participant BackendAPI

    User->>WorkLocationMappingComponent: Selects service line or role
    WorkLocationMappingComponent->>WorkLocationMappingComponent: Calls teleConsultationSaveFunction
    User->>WorkLocationMappingComponent: Chooses Tele Consultation option (ESanjeevani, Swymed, Not Required)
    WorkLocationMappingComponent->>WorkLocationMappingComponent: Updates teleConsultation variable
    User->>WorkLocationMappingComponent: Adds or edits work location mapping
    WorkLocationMappingComponent->>BackendAPI: Sends mapping data with teleConsultation value
    BackendAPI-->>WorkLocationMappingComponent: Responds with result
    WorkLocationMappingComponent-->>User: Updates UI tables and forms
Loading

Possibly related PRs

Suggested reviewers

  • helenKaryamsetty

Poem

A hop and a skip, the code takes a leap,
From eSanjeevani’s name, to Tele Consultation so deep.
Endpoints are tidied, configs made neat,
Two paginators now, no more compete!
With every new mapping, a bunny will cheerβ€”
For cleaner, smarter code is finally here!
πŸ‡βœ¨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

πŸ”§ ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

npm error code ERESOLVE
npm error ERESOLVE could not resolve
npm error
npm error While resolving: ngx-bootstrap@12.0.0
npm error Found: @angular/animations@16.2.12
npm error node_modules/@angular/animations
npm error dev @angular/animations@"^16.2.0" from the root project
npm error peer @angular/animations@"^16.0.0 || ^17.0.0" from @angular/material@16.2.12
npm error node_modules/@angular/material
npm error dev @angular/material@"^16.2.12" from the root project
npm error 1 more (@angular/platform-browser)
npm error
npm error Could not resolve dependency:
npm error peer @angular/animations@"^17.0.0" from ngx-bootstrap@12.0.0
npm error node_modules/ngx-bootstrap
npm error dev ngx-bootstrap@"^12.0.0" from the root project
npm error
npm error Conflicting peer dependency: @angular/animations@17.3.12
npm error node_modules/@angular/animations
npm error peer @angular/animations@"^17.0.0" from ngx-bootstrap@12.0.0
npm error node_modules/ngx-bootstrap
npm error dev ngx-bootstrap@"^12.0.0" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry
npm error this command with --force or --legacy-peer-deps
npm error to accept an incorrect (and potentially broken) dependency resolution.
npm error
npm error
npm error For a full report see:
npm error /.npm/_logs/2025-06-23T10_47_48_896Z-eresolve-report.txt
npm error A complete log of this run can be found in: /.npm/_logs/2025-06-23T10_47_48_896Z-debug-0.log

✨ Finishing Touches
  • πŸ“ Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❀️ Share
πŸͺ§ Tips

Chat

There are 3 ways to chat with CodeRabbit:

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

Support

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

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

CodeRabbit Commands (Invoked using PR comments)

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

Other keywords and placeholders

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

CodeRabbit Configuration File (.coderabbit.yaml)

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

Documentation and Community

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

@sonarqubecloud
Copy link

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

πŸ”­ Outside diff range comments (1)
src/app/app-provider-admin/provider-admin/activities/work-location-mapping/work-location-mapping.component.ts (1)

841-1085: Refactor the addWorkLocation method to improve maintainability.

This method is over 240 lines long and handles multiple responsibilities. Consider breaking it down into smaller, service-specific methods.

Consider refactoring like this:

addWorkLocation(objectToBeAdded: any, role: any) {
  const serviceName = objectToBeAdded.serviceline.serviceName;
  
  switch(serviceName) {
    case '1097':
      this.handle1097Service(objectToBeAdded);
      break;
    case 'ECD':
      this.handleECDService(objectToBeAdded);
      break;
    case 'HWC':
      this.handleHWCService(objectToBeAdded);
      break;
    default:
      this.handleDefaultService(objectToBeAdded);
  }
}

private handle1097Service(objectToBeAdded: any): void {
  // Extract 1097-specific logic here
}

private handleECDService(objectToBeAdded: any): void {
  // Extract ECD-specific logic here
}

// ... other service-specific methods

This would make the code more modular and easier to test and maintain.

🧹 Nitpick comments (4)
src/app/app-provider-admin/provider-admin/activities/work-location-mapping/work-location-mapping.component.html (1)

628-651: Invoke teleConsultation logic on edit selection
Currently teleConsultationEditSaveFunction is bound to the mat-option click. For consistent behavior, consider moving this call to the selectionChange event on the mat-select instead of individual options.

src/app/app-provider-admin/provider-admin/activities/work-location-mapping/work-location-mapping.component.ts (3)

130-131: Consider renaming ViewChild references for clarity.

The paginator names paginatorFirst and paginatorSecond are not descriptive. Consider using more meaningful names that indicate their purpose.

-@ViewChild('paginatorFirst') paginatorFirst!: MatPaginator;
-@ViewChild('paginatorSecond') paginatorSecond!: MatPaginator;
+@ViewChild('mappedLocationsPaginator') mappedLocationsPaginator!: MatPaginator;
+@ViewChild('bufferArrayPaginator') bufferArrayPaginator!: MatPaginator;

229-230: Centralize paginator management to reduce code duplication.

The paginator assignments are repeated throughout the code. Consider creating helper methods to manage pagination centrally.

Add these helper methods:

private updateMappedLocationsPaginator(): void {
  if (this.mappedLocationsPaginator) {
    this.filteredmappedWorkLocationsList.paginator = this.mappedLocationsPaginator;
  }
}

private updateBufferArrayPaginator(): void {
  if (this.bufferArrayPaginator) {
    this.bufferArray.paginator = this.bufferArrayPaginator;
  }
}

private refreshPaginators(): void {
  this.updateMappedLocationsPaginator();
  this.updateBufferArrayPaginator();
}

Then replace all paginator assignments with calls to these methods.

Also applies to: 320-320, 552-552, 567-567, 584-584, 935-935, 948-948, 953-953, 1020-1020, 1080-1080, 1164-1164, 1186-1186, 1194-1194, 1202-1202, 1286-1286, 1310-1310, 1904-1904, 1955-1955


2227-2251: Rename variable to maintain consistency with teleConsultation refactoring.

The variable roleSanjArry still references the old "Sanj" naming convention. This should be updated for consistency.

-const roleSanjArry: any = [];
+const roleNamesArray: any = [];
 if (this.Role) {
   this.Role.filter((item: any) => {
-    roleSanjArry.push(item.roleName.toLowerCase());
+    roleNamesArray.push(item.roleName.toLowerCase());
   });
 }

 if (
   this.Serviceline.serviceName === 'HWC' &&
-  (roleSanjArry.includes('nurse') || roleSanjArry.includes('doctor'))
+  (roleNamesArray.includes('nurse') || roleNamesArray.includes('doctor'))
 ) {
πŸ“œ Review details

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

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 4fd5872 and cb9a83b.

πŸ“’ Files selected for processing (5)
  • angular.json (1 hunks)
  • src/app/app-provider-admin/provider-admin/activities/work-location-mapping/work-location-mapping.component.html (10 hunks)
  • src/app/app-provider-admin/provider-admin/activities/work-location-mapping/work-location-mapping.component.ts (36 hunks)
  • src/environments/environment.prod.ts (1 hunks)
  • src/environments/environment.test.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Build
πŸ”‡ Additional comments (11)
src/environments/environment.prod.ts (1)

30-33: Update base URL segments and verify removal of old ones
The API paths have been updated to admin-api/, common-api/, and fhir-api/. Ensure no legacy adminapi-v1.0, commonapi-v1.0, or fhirapi-v1.0 references remain.
Run:

#!/bin/bash
# Verify that no old versioned API paths persist
rg -H "adminapi-v1.0|commonapi-v1.0|fhirapi-v1.0"
src/environments/environment.test.ts (1)

30-33: Align test environment URLs with production
The test config now uses the same admin-api/, common-api/, and fhir-api/ suffixes. Confirm these endpoints are reachable in the test environment and check for any leftover v1.0 references.
Run:

#!/bin/bash
# Search for stale API references in test config
rg -H "adminapi-v1.0|commonapi-v1.0|fhirapi-v1.0"
angular.json (1)

63-70: Confirm development build environment file mapping
Removing the fileReplacements for development means environment.ts will now remain unaltered in dev builds. Verify that src/environments/environment.ts contains the correct development API URLs and update any developer documentation accordingly.

src/app/app-provider-admin/provider-admin/activities/work-location-mapping/work-location-mapping.component.html (8)

170-177: Introduce separate paginator for mapped list
Adding #paginatorFirst isolates pagination for the filtered mapped locations. Ensure the component class has @ViewChild('paginatorFirst') paginatorFirst: MatPaginator; and wires it up in ngAfterViewInit().


233-236: Trigger teleConsultation state on service change
The new calls to resetRole() and teleConsultationSaveFunction('Serviceline', Serviceline) reset dependent selections and propagate tele consultation defaults on service-line change. Confirm teleConsultationSaveFunction correctly updates teleConsultationFlag and resets other form fields.


373-380: Cascade teleConsultation on role selection
Invoking teleConsultationSaveFunction('Role', Role) when roles change ensures the radio-group options reflect the current context. Verify this handles both single and multi-role scenarios and toggles teleConsultationFlag as intended.


389-410: Add Tele Consultation options UI
The radio-group for teleConsultation replaces the old eSanjeevani checkbox, supporting ESanjeevani, Swymed, and Not Required. Ensure teleConsultationFlag controls visibility and that the [(ngModel)]="teleConsultation" binding aligns with the component property.


436-455: Include add button within form for new mappings
The FAB now appears only when the form is valid and roles are selected. Confirm that the addWorkLocation method signature in the component has been updated to accept and forward the teleConsultation value from workplaceform.value.


532-537: Display teleConsultation in buffer table
The new TeleConsultation column surfaces the selected option in the buffered list. Verify displayedColumnsTable2 includes 'TeleConsultation' and that each bufferArray.data object carries a teleConsultation property.


563-568: Add second paginator for buffered entries
The #paginatorSecond reference enables independent pagination of the buffer table. Ensure the component is injecting this via @ViewChild('paginatorSecond') and initializing it appropriately.


817-838: Add Tele Consultation options in edit form
The edit form radio-group bound to teleConsultationEdit mirrors the create form behavior. Confirm teleConsultationEditFlag is set on load and that teleConsultationEdit holds the existing mapping value.

Comment on lines +970 to 978
teleConsultation:
objectToBeAdded.serviceline.serviceName === 'HWC' &&
objectToBeAdded.role[a].roleName.toLowerCase() === 'nurse' &&
this.isSanjeevani
? true
: false,
(objectToBeAdded.role[a].roleName.toLowerCase() === 'nurse' ||
objectToBeAdded.role[a].roleName.toLowerCase() ===
'doctor') &&
this.teleConsultation
? this.teleConsultation
: null,
};
Copy link

@coderabbitai coderabbitai bot Jun 23, 2025

Choose a reason for hiding this comment

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

πŸ› οΈ Refactor suggestion

⚠️ Potential issue

Extract duplicated teleConsultation logic into a helper method.

The teleConsultation assignment logic is repeated four times with identical conditions. This violates the DRY principle and makes the code harder to maintain.

Add a helper method at the class level:

private getTeleConsultationValue(serviceName: string, roleName: string): string | null {
  return serviceName === 'HWC' &&
    (roleName.toLowerCase() === 'nurse' || roleName.toLowerCase() === 'doctor') &&
    this.teleConsultation
    ? this.teleConsultation
    : null;
}

Then replace all occurrences with:

-teleConsultation:
-  objectToBeAdded.serviceline.serviceName === 'HWC' &&
-  (objectToBeAdded.role[a].roleName.toLowerCase() === 'nurse' ||
-    objectToBeAdded.role[a].roleName.toLowerCase() === 'doctor') &&
-  this.teleConsultation
-    ? this.teleConsultation
-    : null,
+teleConsultation: this.getTeleConsultationValue(
+  objectToBeAdded.serviceline.serviceName,
+  objectToBeAdded.role[a].roleName
+),

Also applies to: 996-1005, 1032-1040, 1058-1067

πŸ€– Prompt for AI Agents
In
src/app/app-provider-admin/provider-admin/activities/work-location-mapping/work-location-mapping.component.ts
around lines 970 to 978, 996 to 1005, 1032 to 1040, and 1058 to 1067, the
teleConsultation assignment logic is duplicated with identical conditions. To
fix this, create a private helper method in the class that takes serviceName and
roleName as parameters and returns the teleConsultation value or null based on
the condition. Then replace all repeated teleConsultation assignment code blocks
with calls to this new helper method to adhere to the DRY principle and improve
maintainability.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The logic was part of the existing code and I have only restructured it without introducing new duplications.

Copy link

Choose a reason for hiding this comment

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

@devikasuresh20 You're absolutely right! I can see that you were refactoring the existing isSanjeevani logic to the new teleConsultation approach, and the duplication pattern was likely already present in the original code structure.

Thank you for clarifying that - it's completely reasonable to focus on the core refactoring (eSanjeevani β†’ teleConsultation) without addressing pre-existing code patterns in the same PR. The suggestion remains valuable for future code improvements, but I understand it's outside the scope of your current changes.

Your refactoring from the boolean isSanjeevani to the more flexible string-based teleConsultation that supports multiple options ('ESanjeevani', 'Swymed', 'Not Required') is a solid improvement to the functionality! 🐰

  /|   /|   
 ( :v:  )
  |(_)|

✏️ Learnings added
Learnt from: devikasuresh20
PR: PSMRI/ADMIN-UI#89
File: src/app/app-provider-admin/provider-admin/activities/work-location-mapping/work-location-mapping.component.ts:970-978
Timestamp: 2025-06-23T11:04:02.816Z
Learning: When users are refactoring existing code logic (like changing from isSanjeevani boolean to teleConsultation string values), pre-existing code duplication patterns should be acknowledged as separate from the refactoring scope, and suggestions for addressing such duplication should be framed as future improvements rather than requirements for the current PR.

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.

Comment on lines +90 to 95
teleConsultationFlag = false;
teleConsultation: any;
teleConsultationEditFlag = false;
esanjFlag = false;
eSanjeevaniEdit = false;
teleConsultationEdit: any;
foundDuplicate = false;
Copy link

@coderabbitai coderabbitai bot Jun 23, 2025

Choose a reason for hiding this comment

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

πŸ› οΈ Refactor suggestion

Improve type safety and eliminate magic strings.

The code uses any type extensively and contains magic strings that should be constants or enums.

Consider creating enums and interfaces:

enum ServiceName {
  HWC = 'HWC',
  ECD = 'ECD',
  HELPLINE = '1097',
  FLW = 'FLW',
  TM = 'TM',
  MMU = 'MMU'
}

enum RoleName {
  NURSE = 'nurse',
  DOCTOR = 'doctor',
  SUPERVISOR = 'supervisor',
  TC_SPECIALIST = 'TC Specialist'
}

enum TeleConsultationType {
  ESANJEEVANI = 'ESanjeevani',
  SWYMED = 'Swymed',
  NOT_REQUIRED = 'Not Required'
}

interface TeleConsultationConfig {
  teleConsultationFlag: boolean;
  teleConsultation: TeleConsultationType | null;
  teleConsultationEditFlag: boolean;
  teleConsultationEdit: TeleConsultationType | null;
}

This would make the code more maintainable and less error-prone.

Also applies to: 970-978, 2236-2238

πŸ€– Prompt for AI Agents
In
src/app/app-provider-admin/provider-admin/activities/work-location-mapping/work-location-mapping.component.ts
around lines 90 to 95, replace the use of 'any' types and magic strings with
well-defined enums and interfaces to improve type safety and maintainability.
Define enums for service names, role names, and teleconsultation types, and
create an interface for teleconsultation configuration. Update the variables
teleConsultation and teleConsultationEdit to use the TeleConsultationType enum
or null instead of any, and replace all magic string literals with the
corresponding enum values. Apply similar changes to lines 970-978 and 2236-2238
as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These variables and types are part of existing code and my changes were limited to configuration updates without altering the type structure.

Copy link

Choose a reason for hiding this comment

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

@devikasuresh20 I understand completely! You're absolutely right to limit the scope to configuration changes only. Keeping the existing type structure intact while focusing specifically on the tele consultation configuration updates is a sensible approach for this PR. It maintains consistency with the existing codebase and keeps the changes focused on the specific feature requirement.

Thank you for clarifying your approach - it's good practice to keep refactoring separate from feature changes.

🐰✨ curiosity satisfied


✏️ Learnings added
Learnt from: devikasuresh20
PR: PSMRI/ADMIN-UI#89
File: src/app/app-provider-admin/provider-admin/activities/work-location-mapping/work-location-mapping.component.ts:90-95
Timestamp: 2025-06-23T11:05:44.626Z
Learning: The user prefers to limit PR scope to specific feature changes without altering existing type structures, keeping configuration updates separate from broader refactoring efforts.

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.

Comment on lines +411 to 427
!this.editMode &&
parseInt(mappedWorkLocations.stateID) === this.State.stateID &&
parseInt(mappedWorkLocations.workingDistrictID) ===
this.District.districtID &&
!mappedWorkLocations.userServciceRoleDeleted
) {
this.existingRoles.push(mappedWorkLocations.roleID);
} else if (
(serviceID === 2 || serviceID === 4) &&
this.editMode &&
parseInt(mappedWorkLocations.stateID) === this.stateID_duringEdit &&
parseInt(mappedWorkLocations.workingDistrictID) ===
this.district_duringEdit &&
!mappedWorkLocations.userServciceRoleDeleted
) {
this.existingRoles.push(mappedWorkLocations.roleID);
} else if (
Copy link

@coderabbitai coderabbitai bot Jun 23, 2025

Choose a reason for hiding this comment

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

πŸ› οΈ Refactor suggestion

Refactor duplicated role existence logic.

The role existence check logic is duplicated for edit mode and non-edit mode. Consider extracting this into a helper method to improve maintainability.

-if (
-  (serviceID === 2 || serviceID === 4) &&
-  !this.editMode &&
-  parseInt(mappedWorkLocations.stateID) === this.State.stateID &&
-  parseInt(mappedWorkLocations.workingDistrictID) ===
-    this.District.districtID &&
-  !mappedWorkLocations.userServciceRoleDeleted
-) {
-  this.existingRoles.push(mappedWorkLocations.roleID);
-} else if (
-  (serviceID === 2 || serviceID === 4) &&
-  this.editMode &&
-  parseInt(mappedWorkLocations.stateID) === this.stateID_duringEdit &&
-  parseInt(mappedWorkLocations.workingDistrictID) ===
-    this.district_duringEdit &&
-  !mappedWorkLocations.userServciceRoleDeleted
-) {
-  this.existingRoles.push(mappedWorkLocations.roleID);
+const stateID = this.editMode ? this.stateID_duringEdit : this.State?.stateID;
+const districtID = this.editMode ? this.district_duringEdit : this.District?.districtID;
+
+if (
+  (serviceID === 2 || serviceID === 4) &&
+  parseInt(mappedWorkLocations.stateID) === stateID &&
+  parseInt(mappedWorkLocations.workingDistrictID) === districtID &&
+  !mappedWorkLocations.userServciceRoleDeleted
+) {
+  this.existingRoles.push(mappedWorkLocations.roleID);
πŸ“ 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
!this.editMode &&
parseInt(mappedWorkLocations.stateID) === this.State.stateID &&
parseInt(mappedWorkLocations.workingDistrictID) ===
this.District.districtID &&
!mappedWorkLocations.userServciceRoleDeleted
) {
this.existingRoles.push(mappedWorkLocations.roleID);
} else if (
(serviceID === 2 || serviceID === 4) &&
this.editMode &&
parseInt(mappedWorkLocations.stateID) === this.stateID_duringEdit &&
parseInt(mappedWorkLocations.workingDistrictID) ===
this.district_duringEdit &&
!mappedWorkLocations.userServciceRoleDeleted
) {
this.existingRoles.push(mappedWorkLocations.roleID);
} else if (
const stateID = this.editMode
? this.stateID_duringEdit
: this.State?.stateID;
const districtID = this.editMode
? this.district_duringEdit
: this.District?.districtID;
if (
(serviceID === 2 || serviceID === 4) &&
parseInt(mappedWorkLocations.stateID) === stateID &&
parseInt(mappedWorkLocations.workingDistrictID) === districtID &&
!mappedWorkLocations.userServciceRoleDeleted
) {
this.existingRoles.push(mappedWorkLocations.roleID);
} else if (
πŸ€– Prompt for AI Agents
In
src/app/app-provider-admin/provider-admin/activities/work-location-mapping/work-location-mapping.component.ts
around lines 411 to 427, the logic checking role existence for edit mode and
non-edit mode is duplicated. Refactor by extracting this repeated conditional
logic into a single helper method that accepts parameters for mode and relevant
IDs, then use this method in the if-else blocks to push roleIDs to
existingRoles. This will improve code maintainability and reduce duplication.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The logic was part of the existing code and I have only restructured it without introducing new duplications.

Copy link

Choose a reason for hiding this comment

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

@devikasuresh20 I understand your perspective. You're absolutely right that when working with existing code, sometimes it's more practical to maintain consistency with the current patterns rather than introducing broader refactoring changes. Your approach of restructuring the existing logic to handle the edit mode requirements makes sense in this context.

Thank you for the clarification!

   (\   /)
  ( ._. )
 o_(")(")  *understanding rabbit*

@devikasuresh20 devikasuresh20 changed the title Tele consultation configuration changes in work location mapping screen AMM-1536 Tele consultation configuration changes in work location mapping screen Jun 23, 2025
@helenKaryamsetty helenKaryamsetty merged commit a6748c4 into PSMRI:develop Jun 24, 2025
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants