Vb/release 3.8.2 merge - #155
Conversation
…pping Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
feat: Facility Hierarchy, Work Location Mapping & Inventory changes for HWC
Add service line dropdown to item-to-facility-mapping
#133) * fix: wrap SaveWorkLocationMapping payload in array for grouped role update The userRoleMappings API expects an array but was receiving a single object when adding new roles during grouped edit, causing "Failed to update mapping" error. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: add search to dropdowns, Volunteer role logic, Select All and compareWith fixes - Add search filter to User, State, District, Block dropdowns in work location mapping - Add search icon to all dropdown search boxes across components - Show village dropdown instead of facility for Volunteer role in FLW/HWC - Fix Select All villages not updating UI (new array reference for change detection) - Fix village search losing selection in facility creation (add compareWith) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: select all facilities by ID, move village after role for volunteer - fix select all facilities using ID-based comparison instead of reference/length so filtered search selections are preserved across different searches - move village dropdown after role in both create and edit modes so it appears only after volunteer role is selected Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: keep selected items visible in search dropdowns across all components Selected items no longer disappear when typing in search — filter always includes already-selected items so mat-select retains the selection. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * feat: enable Block and Village dropdowns for Stop TB serviceline Add 'Stop TB' to showBlockDrop and showEditBlockDrop so the work-location form renders Block (required) and Village (required, multi-select) for the new Stop TB serviceline, matching the FLW non-facility flow used by the Volunteer role. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * feat: show Work Location dropdown for non-facility servicelines Re-add Select Work Location field in both create and edit forms, shown only when !isFacilityServiceline. HWC and FLW keep their facility sub-component; TM, MMU, Stop TB and other non-facility servicelines see the dropdown backed by showofficedetails / m_providerserviceaddmapping. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * refactor: remove Volunteer special-case from FLW/HWC flow Volunteer role now belongs to the new Stop TB serviceline (non-facility flow), not to FLW/HWC. Drop all isVolunteerSelected / isVolunteerSelectedEdit branches that previously routed Volunteer users around the Facility sub-component. FLW and HWC always use Facility hierarchy; Stop TB uses the old Block/Village/Work Location flow. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * feat: add Search and Select All to create-form Village dropdown Mirror the UX of the facility picker and the edit-form village dropdown: the create-form multi-select for Village now has an in-dropdown search box and a Select All checkbox. Affects Stop TB, TM, MMU flows where Village is picked via the parent form (non-facility servicelines). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: hide Work Location dropdown for Stop TB in create and edit forms Stop TB uses block+village mapping, not work location. Work Location is now hidden (create and edit) when isBlockRequired/isBlockRequiredEdit is true, keeping it visible for all other non-facility servicelines. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: show Village for Stop TB by guarding against stale villageFlag Village *ngIf now uses (villageFlag || isBlockRequired) so it renders even when villageFlag is out of sync with isBlockRequired. Also reset isBlockRequired and isVillageRequired in resetAllFields() and in the showBlockDrop else-branch to prevent stale state for non-block servicelines. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: load Block/Village in edit mode for Stop TB serviceline getEditBlockPatchMaster was not called for Stop TB, so the Block and Village dropdowns never appeared when editing a Stop TB mapping. Added Stop TB to the serviceline guard alongside FLW/HWC/TM/MMU. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
New cascading multi-select dropdowns (TU, Health Facility, Village), shown only for Stop TB, sourced from Admin-API's new Nikshay endpoints. Create flow saves one row per TU x Facility combination, same pattern already used for ASHA Supervisor's multi-facility mapping. Edit flow pre-fills existing selections (including for pre-Nikshay users, who see empty-but-usable dropdowns to migrate onto the new fields), and reconciles changes on save by deactivating old rows and creating fresh ones for the current selection. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The nikshay tu/facility/village dropdown feature only had its endpoint urls defined in the gitignored environment.ts, so ng build failed against every real environment config (production, ci, test, local).
saveWorkLocations() built the request payload before the Nikshay TU/ Facility fields existed on the buffer object, so it only referenced facilityID (unused by Stop TB) and never sent nikshayTUID or nikshayFacilityID. The Admin-API backend already accepts and persists both fields, so mappings saved with a NULL facility/TU (shown as N/A in the grid). Also stop showing the standard block/village "Select Village" field for Stop TB in both create and edit mode, since that service line now has its own Nikshay TU -> Facility -> Village cascade; the extra field was redundant and blocked Save until filled. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
setWorkLocationObject()'s Stop TB branch built the buffer row without blockID/blockName, so every Stop TB mapping saved those columns as NULL even though the Select Block field is filled in and required in the UI. saveWorkLocations() already reads blockID/blockName generically for every service line, so this just supplies the values using the same objectToBeAdded.Serviceblock pattern other service lines use. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
AMRIT's own Block master is sparser than Nikshay's TU list per district, so the generic Block dropdown often had no matching entry for Stop TB users. Hide it for Stop TB and derive blockID/blockName from the selected Nikshay TU instead, in both create and edit flows. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…archy - Fix Roles loading: move getAllRoles() trigger from District's selectionChange to State's, since it only depends on State.providerServiceMapID — was previously empty if District hadn't been selected yet, for every service line. - Add resolveNikshayDistrictAndLoadTUs(): bridges AMRIT's selected State/District to Nikshay's own State/District by name match, then loads the TU list. AMRIT's State/District dropdowns stay as the single source of truth (still drive getAllRoles/getAllWorkLocations/ getBlockMaster for every service line) — this only resolves the corresponding Nikshay IDs, no new dropdowns added. - Add a genuine single-select "Block" field (TU-sourced) alongside the existing multi-select "TU" field, per updated Stop TB requirements. - Fix 3 leftover districtBranchID references (old AMRIT-village ID field) to nikshayVillageID in Nikshay-specific save/edit code paths, matching the new NikshayVillage entity built in Admin-API today.
…opdowns Remove resolveNikshayDistrictAndLoadTUs (bridged AMRIT's District to Nikshay's by name match). AMRIT's own m_District proved unreliable for this: 144 orphaned district rows across all 10 covered states from an earlier abandoned import attempt, plus inconsistent data between dev environments (one had Andhra Pradesh's post-2022 districts, another didn't). Bridging through it meant inheriting that unreliability. Add dedicated "Select State (Nikshay)" / "Select District (Nikshay)" dropdowns instead, shown only for Stop TB, sourced entirely from the independent m_nikshay_state/m_nikshay_district tables — zero AMRIT dependency. AMRIT's own State/District dropdowns are untouched, still driving getAllRoles/getAllWorkLocations/getBlockMaster for every service line as before.
Live testing showed a real bug from the separate Nikshay State/District dropdowns added previously: getAllRoles() only fires on AMRIT State's selectionChange, so if an admin filled the Nikshay-labeled fields but skipped the plain AMRIT ones, Role stayed empty with no explanation. Restore resolveNikshayDistrictAndLoadTUs as the single bridge: AMRIT's State/District are the only fields shown (unchanged, still drive getAllRoles/getAllWorkLocations/getBlockMaster), and selecting District silently resolves the matching Nikshay State/District by name to load the TU list. Shows a clear error if either isn't in Nikshay's data yet, instead of failing silently. Removed the now-dead selectedNikshayState/ selectedNikshayDistrict/nikshayDistrictList/nikshayStateSearch/ nikshayDistrictSearch fields and their filtered-list getters.
…strict-level AMRIT matching Live testing confirmed the district-level bridge was the wrong tradeoff: even when it worked, "Select District" still showed AMRIT's incomplete list (missing newer districts like Alluri Sitharama Raju entirely on some environments). District-level matching was also the exact layer where AMRIT's data proved unreliable all session (144 orphaned rows, stale post-2022 reorganization, inconsistent between environments) — no reason to keep depending on it here. New flow: selecting AMRIT State resolves the matching Nikshay state by name (low-risk — ~10 stable names, no reorganization ambiguity) and loads that state's district list directly from m_nikshay_district into "Select District". From there, District is 100% Nikshay data — no further matching. Selecting it loads TUs directly via nikshayDistrictID, no bridge step. AMRIT's districtID goes into the save payload as null for Stop TB rows now (District is a Nikshay object there) — accepted as-is; nothing confirmed to depend on it, not solving for it speculatively.
… either/or Verified directly against both databases: AMRIT's m_state spells it "Chattisgarh" (one 'h'), Nikshay's own data spells it "Chhattisgarh" (two 'h's, correct). All other ~9 covered states match exactly. Add a small explicit alias for this one verified exception rather than general fuzzy matching. Also fix State's selectionChange calling AMRIT's getAllDistricts() unconditionally alongside the Nikshay resolution — for Stop TB it was firing uselessly (its result was already being ignored by the District dropdown). Now it's a real either/or: Stop TB calls only resolveNikshayStateAndLoadDistricts, every other service line calls only getAllDistricts, matching what each actually needs.
…ity rows Edit was passing an AMRIT district ID straight into the Nikshay TU lookup instead of resolving it by name first, same bug Create had. Also stop creating one row per TU x Facility combination on save (10 TUs x 100 facilities = 1,000 rows for one user) — now a single row per user-role with comma-joined NikshayTUID/NikshayFacilityID, matching the TEXT columns. Edit-mode pre-selection now splits those CSVs back into IDs. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
editGroupedRow() is the actual live Edit entry point (editRow() with the correct Stop TB handling was dead code, never called from the template) - it never set isStopTBServicelineEdit or loaded Nikshay selections, so Edit always fell through to the generic AMRIT Work Location field with an empty required District and no roles loaded. Also fixes DistrictID always saving as null for Stop TB: the Create form's District control binds the NikshayDistrict object, whose ID field is nikshayDistrictID, not districtID - reading .districtID silently returned null every time. DistrictID is repurposed to hold the Nikshay district ID directly (AMRIT's own is unused for Stop TB), so Edit can now resolve it straight from the saved row instead of name-matching against fields Stop TB never populates. BlockName also now keeps only the first selected TU's name instead of joining all of them, since Block is meant to stay single-value - the full multi-TU list already lives in NikshayTUID/NikshayTUName. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
mappedWorkLocationsList (backing loadNikshayEditSelections) never carried DistrictID/NikshayTUID/NikshayFacilityID, since the view it comes from doesn't expose those columns - Edit's TU/Facility/Village pickers always loaded empty as a result, regardless of what was actually saved. Fetches them from Admin-API's new /nikshay/location/userMapping endpoint by USRMappingID instead. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
fragile row re-filter Select District in edit mode sourced its options from districts_array (AMRIT), but the resolved value is a Nikshay district ID - no option ever matched, so it always displayed blank even when correctly resolved internally. Now sources from nikshayDistrictList for Stop TB, populated via a new helper since the ID-based resolution path never loaded it. loadNikshayEditSelections() also re-filtered mappedWorkLocationsList by roleName to find "this row" again, even though edit_Details already IS that row - if the filter came up empty for any reason, district-list loading and village pre-selection silently broke while TU/Facility kept working fine (they come from the new endpoint, not this filter). Reads stateName/villageidDb directly off edit_Details instead. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The Update button calls updateGroupedWorkLocation(), which only special-cased ASHA Supervisor before falling through to a generic rolesToKeep update path with no idea about NikshayTUID/ NikshayFacilityID/Nikshay village IDs - it would silently save a payload missing all of them. updateStopTBWorkLocation() already had the correct TU/Facility/Village reconciliation logic but was never actually called from here, only from the unrelated updateWorkLocation() function the Update button doesn't use for grouped rows. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…nothing buildNewRows() sent a flat object shape directly to /userRoleMappings, but that endpoint parses a specific nested structure (previleges[].ID[]) - confirmed by comparing against saveWorkLocations(), the Create flow's actual working payload builder. The mismatched shape meant the backend's nested-array parsing found nothing to iterate over, so it silently created zero rows, no error surfaced. Combined with the delete calls that run first (deactivating the old row), every Update click was quietly deleting the mapping with nothing to replace it. buildNewRows() now builds the same previleges/ID nested shape saveWorkLocations() already sends successfully. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
updateStopTBWorkLocation()'s deactivate-then-recreate approach left a trail of deactivated ghost rows behind on every single edit (confirmed: updateUserRoleMapping, the true in-place update endpoint, already handles NikshayTUID/NikshayFacilityID correctly - the deactivate/ recreate dance was never actually necessary). updateGroupedWorkLocation()'s existing rolesToKeep/rolesToRemove/ rolesToAdd reconciliation - already used by every other serviceline - is now Nikshay-aware: block/village/nikshayTUID/nikshayFacilityID come from the Nikshay TU/Facility/Village pickers for Stop TB instead of the generic AMRIT block/village pickers. Existing roles update in place via their existing USRMappingID, only genuinely new roles create a new row. Removed updateStopTBWorkLocation() and its dead-code guard in updateWorkLocation() entirely - fully unreachable now, not just unused. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…d overwrite Old-style Stop TB users have no saved NikshayTUID/DistrictID, so Edit had no way to even start a District->TU->Facility->Village pick for them. Select District is now editable for Stop TB and tries, in order: auto-select from saved data (unchanged), name-match against a genuinely old row's real AMRIT WorkingDistrictName (only ever populated for pre-Nikshay rows, which went through the old AMRIT work-location flow), then falls back to populated-but-unselected options for the admin to pick manually. Also stops the Nikshay Village picker's selection from ever reaching Villageid, in either Create or Edit. Villageid holds AMRIT village IDs everywhere else in the system, including the mobile app's own beneficiary worklist match (BenFlowStatus.villageID) - saving Nikshay village IDs into it breaks that match, silently cutting a worker off from beneficiaries they can already see. Create sends null (safe, nothing to erase yet); Edit round-trips the row's existing villageidDb/villageNameDb unchanged, since updateUserRoleMapping's setVillageID/setVillageName are unconditional overwrites with no null-check - sending null there would have erased real data instead of leaving it alone. Revisit once a Nikshay-village-to-AMRIT-village bridge table exists to translate safely. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
… in Edit Select Block existed in Create but never actually did anything - selectedNikshayBlock wasn't read anywhere, just a decorative single-select. Picking a Block now adds that TU into the Select TU multi-select (onNikshayBlockChange), covering the common one-TU case fast while Select TU still handles picking more. Edit gets the same two-field layout Create already had (previously Edit only had one combined "Select TU (Block)" field). Also, per explicit instruction: Edit now saves the Nikshay Village picker's selection directly into Villageid/VillageName, overwriting whatever was there before (Create is unchanged, still sends null for new users). This reverses the round-trip-existing-value safety behavior from earlier - Villageid still holds AMRIT village IDs everywhere else in the system, including the mobile app's own beneficiary worklist match, so a worker edited through this path will not see beneficiaries in these villages in their worklist until a Nikshay-village-to-AMRIT-village bridge table exists to translate between the two numbering systems. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
New cascading multi-select dropdowns (TU, Health Facility, Village), shown only for Stop TB, sourced from Admin-API's new Nikshay endpoints. Create flow saves one row per TU x Facility combination, same pattern already used for ASHA Supervisor's multi-facility mapping. Edit flow pre-fills existing selections (including for pre-Nikshay users, who see empty-but-usable dropdowns to migrate onto the new fields), and reconciles changes on save by deactivating old rows and creating fresh ones for the current selection. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The nikshay tu/facility/village dropdown feature only had its endpoint urls defined in the gitignored environment.ts, so ng build failed against every real environment config (production, ci, test, local).
Valid Till previously defaulted to the creation date, so a provider created without the admin explicitly extending it would fail login the very next day (validTill > now() check in Common-API login). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
# Conflicts: # pom.xml # src/app/app-provider-admin/provider-admin/activities/employee-master-new/employee-master-new.component.html # src/app/app-provider-admin/provider-admin/activities/services/work-location-mapping.service.ts # src/app/app-provider-admin/provider-admin/activities/work-location-mapping/work-location-mapping.component.html # src/app/app-provider-admin/provider-admin/activities/work-location-mapping/work-location-mapping.component.ts # src/environments/environment.ci.ts.template # src/environments/environment.local.ts # src/environments/environment.prod.ts # src/environments/environment.test.ts
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
|



📋 Description
JIRA ID:
Please provide a summary of the change and the motivation behind it. Include relevant context and details.
✅ Type of Change
ℹ️ Additional Information
Please describe how the changes were tested, and include any relevant screenshots, logs, or other information that provides additional context.