Skip to content

Component Name: myPracticeSite

Last Updated: 2025-09-29 Source Code: https://bitbucket.org/i2cinc/i2c.salesforce.metadata/src/STAGING/force-app/main/default/lwc/myPracticeSite

API Name: c-myPracticeSite Type: Page Component (Account Management) Target: Community pages

Business Purpose

Comprehensive practice site management for NP members. Allows members to create, edit, delete up to 3 practice sites with full details (name, address, phone, hours, payors, age groups, clinical focus, etc.). Includes toggle to show/hide sites on NP Finder directory. Validates address via geocoding, phone numbers, websites, zip codes.

Component Structure

Files: myPracticeSite.html, myPracticeSite.js (677 lines), myPracticeSite.js-meta.xml, stateCodesUtils.js

JavaScript Controller

Properties (API)

  • @api accountId - Account ID (can be passed or loaded from wire)
  • @api accountType - Default: 'Person'
  • Various @api flags for account status

Key Features

  • CRUD Operations: Create, Read, Update, Delete practice sites
  • Validation: Phone (+1 10-digits or international), website URL, ZIP code (5 or 9-digit)
  • Address Parsing: Splits Address__Street__s into 3 address lines
  • NP Finder Toggle: Show/hide site on public directory
  • Limit Enforcement: Max 3 sites per account
  • Picklist Loading: Dynamically loads picklists for Worksite Focus and NP Work Setting
  • Age Group Validation: Requires at least one age group selected
  • Google Maps Integration: Generates map links from address

Wire Adapters

  • @wire(getUserInfo) - Loads current user account
  • @wire(getPracticeSites) - Not used (called manually in connectedCallback)

Validation Rules

  • Required Fields: Name, Address Line 1, City, State, Zip, Overall Focus
  • Phone: +1NNNNNNNNNN (10 digits) or +N{1-3}NNNNNNN{7-15}
  • Website: Must match URL pattern
  • Zip: 12345 or 12345-6789 format
  • Age Groups: At least one must be checked

Event Handlers

  • handleEditSite() - Opens site for editing
  • handleNewSite() - Opens new site form
  • handleSubmit() - Validates and saves/creates site
  • handleDeleteAction() - Deletes practice site
  • handleDisplayInFinder() - Toggles NP Finder visibility
  • handleInputChange() - Updates form fields
  • handleAddressLineChange() - Concatenates address lines
  • handleCheckboxChange() - Updates boolean fields
  • handleAcceptingPatientsChange() - Updates accepting patients

Private Methods (Selected)

  • fetchPracticeSite() - Loads sites from Apex
  • processPracticeSites() - Adds computed properties (map link, phone href, etc.)
  • saveNewPracticeSite() - Creates new site via Apex
  • handleUpdateAction() - Updates existing site
  • fetchAllPicklistOptions() - Loads dynamic picklists
  • reloadPage() - Full page refresh after changes

Dependencies

  • Apex: PracticeSiteController (getPicklistValues, getPracticeSites, createPracticeSite, updatePracticeSite, deletePracticeSite, updatePracticeSiteDisplay)
  • Apex: AccountController.getUserInfo()
  • Custom Object: PracticeSite__c (30+ fields)
  • Utility: stateCodesUtils.js (state picklist values)

Usage

<!-- In account management page -->
<c-my-practice-site account-id={accountId}></c-my-practice-site>

⚠️ Pre-Go-Live Concerns

CRITICAL

  • Full page reload after every action: Lines 351, 382, 404, 602, 621, 627 - very poor UX, should refresh component data instead
  • No address validation: Component accepts any address - should validate with geocoding service
  • Lat/Long check insufficient: Lines 138-140 check for non-zero but doesn't validate accuracy

HIGH

  • No unit tests: Zero coverage for 677 lines
  • Form validation incomplete: Only validates on submit, not on blur
  • Error messages lost: Lines 336-347, 369-379 build error messages but never display them to user
  • Console.log everywhere: Lines 100, 172-174, 306, 313, 394, 474
  • Max 3 sites not enforced in Apex: Client-side check only (line 436)
  • Address parsing fragile: Splits on comma (lines 115-121, 196-202) - breaks for addresses with commas

MEDIUM

  • Hardcoded field name mappings: Lines 509-532 map display names to API names (should use field metadata)
  • Regex patterns inline: Should extract to constants (lines 74-78)
  • NP Finder eligibility complex: Lines 449-453 check member type (should be Apex validation)
  • Timezone issues: Lines 58-69 in getter but getter doesn't exist in shown code

LOW

  • Unused getFullAddress getter: Line 423-425 has syntax error and appears unused
  • Variable naming: concatenatedAddressLine vs concatenatedFullAddress (inconsistent)

Maintenance Notes

Complexity: High Key Notes: - CRITICAL: Component reloads entire page after every action (create/update/delete/toggle) - Manages up to 3 practice sites per NP member - Address parsing splits on comma (fragile) - Phone validation supports international formats - Toggle for NP Finder directory visibility (public-facing) - Only members (not Associate/Student) can add to NP Finder - Form validation on submit only (not field-by-field) - Google Maps links generated from address - Geolocation validated by lat/long presence - Picklists loaded dynamically from Salesforce - Complex form with 30+ fields across multiple sections - Error messages built but not displayed to users - Consider replacing page reloads with data refreshes

Browser Compatibility: - Standard browser support - Google Maps links work on all browsers