Core V.E.T.S. Procedures
Overview
These 10 procedures form the backbone of V.E.T.S. functionality, handling everything from user authentication and dashboard generation to animal management, veterinary operations, and AI content generation. Understanding these procedures is essential for developers extending or maintaining the V.E.T.S. platform.
Key Characteristics:
- Stored Procedure-Driven UI: All HTML is generated server-side in SQL procedures
- Mobile-Responsive: Automatic detection and optimization for mobile devices
- Permission-Aware: Built-in security and access control
- AJAX-First: No page refreshes - all interactions via asynchronous calls
- Multi-Tenant: Secure isolation between organizations
Scale: These procedures handle 11,928 active users, 36,553 animals, and 15,077 vaccination records in production.
🔒 Authentication & Dashboard
astp_SocialMedia_Admin_AuthenticatedNowMobile
Primary Purpose
Main authenticated dashboard and menu generation after user login. This is the first procedure called after authentication and sets up the entire user interface.
Key Parameters
@PrimKeyRawXML - XML containing selected animal primary keys for bulk operations
@ClientHistorySearch - Client search mode flag
@AnimalHistorySearch - Animal search mode flag
@PIMSLogin - Current user login name
@SocialMediaLogin - Social authentication identifier
@ViewDeceasedAlso - Include deceased animals flag
@isMobileDevice - Device type for responsive generation
@inHospital - Hospital status filter
@availHeight - Available screen height for layout
Core Logic
- Mode Detection: Determines ClientHistorySearch vs AnimalHistorySearch mode
- Social Integration: Processes OneAll social media authentication (Janrain deprecated)
- Grid Generation: Creates animal/client grids based on search criteria
- Mobile Optimization: Generates different HTML for mobile vs desktop
- Permission Filtering: Only shows data user has access to
Integration Points
- Called From:
AuthenticatedAJAX.aspx.vb.AuthenticatedNow()
- JavaScript: Multiple functions in
isMobileDevice.js
- Sub-Procedures: Various grid and menu generation procedures
Key Features
- ✅ Multi-mode support (Client vs Animal history search)
- ✅ Social media authentication integration
- ✅ Mobile-responsive dashboard generation
- ✅ Bulk animal selection via XML parameters
- ✅ Real-time permission filtering
- ✅ Hospital status and deceased animal filtering
📓 Item & Tree Management
astp_Items_TreeList_ViewTreeOrItemTeamDoc2
Primary Purpose
Generates TeamDoc viewer iframe for items and tree values. This procedure creates the interface for viewing documentation and automatically assigns appropriate permissions.
Key Parameters
@ClientRef - Client/organization identifier (passes through to links)
@AnimalRef - Specific animal identifier
@TreeListType - Category type (normalized from legacy codes)
@PrimKey - Item or tree value primary key
@SUSER_SNAME - Current user login name
@isMobileDevice - Device type flag
TreeListType Normalization
-- Legacy code mapping for backward compatibility
IF @TreeListType IN ('IM', 'Tran', 'TX', 'AN', 'Chiro', 'DG', 'DP', 'EE',
'FServ', 'GM', 'HBT', 'HO', 'IM', 'inst', 'LA',
'LMS', 'MS', 'oLA', 'PS', 'SX', '')
SET @TreeListType = 'ProfessionalServices'
IF @TreeListType IN ('Rx', 'DEA', 'NonRx')
SET @TreeListType = 'RxProducts'
Automatic Permission Assignment
Groups automatically granted access:
- Status Reporting - RO: Read-only access
- VETS [TreeListType] Doc Editor: Editor access for specific categories
- VETS_ groups: Manager/Editor/Reader based on configuration
- VETS Veterinarians: Editor access
- Developers: Manager access
Integration Points
- Called From:
MobileAJAX.aspx.vb.ViewTreeOrItemTeamDoc2()
- JavaScript:
ViewTreeOrItemTeamDoc2() in isMobileDevice.js
- Security: Executes as
pims_system_user for elevated permissions
Description Synchronization
Automatically syncs descriptions between:
atbl_Items_Items.Description (source of truth)
stbl_TeamDoc_Documents.DescriptionHTML (TeamDoc display)
astp_Items_TreeList_EditTreeOrItemTeamDoc2
Primary Purpose
Generates edit forms for items and tree values with AI integration. This is the primary interface for content editing and includes the AI content generation features.
Key Features
- 🎯 AI Integration Point: Shows AI icon in upper left of edit forms
- 📝 Context-Aware Forms: Generates different UI based on TransactionType
- [COLOR] Color-Coded Backgrounds: Visual categorization by service type
- [MOBILE] Mobile-Responsive: Optimized layouts for all devices
- [LOCK] Permission-Aware: Only shows fields user can edit
Color Coding System
| TransactionType | Background Color |
| ClientAppointmentServices | Light Green |
| RX | Tan |
| VA | Pink |
| DEA | Yellow |
| Services | Default |
Integration Points
- Called From:
MobileAJAX.aspx.vb.EditTreeOrItemTeamDoc2()
- JavaScript:
EditTreeOrItemTeamDoc2() in isMobileDevice.js
- AI Connection: Triggers
ShowAIWorkspace() when AI icon clicked
🏥 Veterinary Operations
sstp_Teamdoc_WebsiteGetVeterinaryMenuMobile
Primary Purpose
Generates the veterinary management menu for animal-specific operations. This provides the main interface for veterinarians working with individual animals.
Core Components
- [TAG] Animal Header: Displays animal name via
astp_VETS_NameHeader
- [+] Media Upload: Direct access to file upload functionality
- [+] Video Gallery: Integrated video management via
astp_Media_GetVideoGallery
- [+] Task Creation: Create veterinary tasks (requires Editor/Manager permissions)
- [+] Mobile Optimization: Different iframe heights for mobile vs desktop
Permission-Based Features
Some features only appear for users with appropriate permissions:
- Editor/Manager: Can create tasks and upload media
- Reader: Can view galleries and basic information
Integration Points
- Called From:
MobileAJAX.aspx.vb.openMobileVetMenu()
- Dependencies:
astp_VETS_NameHeader, astp_Media_GetVideoGallery
sstp_Teamdoc_WebsiteGetAnimalEditMenuMobile
Primary Purpose
Generates animal-specific edit menu with comprehensive media management capabilities.
Key Features
- [+] Image Gallery: Shows recent images (last 24 hours) and sales images
- [+] Video Gallery: Integrated video management
- [+] Media Upload: Only for Editor/Manager permissions
- [TAG] Animal Display: Shows animal name from
aviw_VETS_Animals
Image Display Logic
Shows images based on:
- Recent Images: Uploaded within last 24 hours
- Sales Images: Marked for sales display
- Permission Check: Uses
sviw_TeamDoc_MembersWithName
Integration Points
- Called From:
MobileAJAX.aspx.vb.GetAnimalEditMenu()
- JavaScript:
GetAnimalEditMenu() in isMobileDevice.js
- Dependencies:
aviw_VETS_Animals, aviw_VETS_AnimalImages
astp_Items_TreeList_GetByTreeListTypeandAnimalRefMobile
Primary Purpose
Retrieves and displays tree list items filtered by type and animal, optimized for mobile interfaces.
Filtering Capabilities
- [TAG] TreeListType Filter: ProfessionalServices, RxProducts, etc.
- [+] Animal Filter: Animal-specific items only
- [+] Parent Relationships: Hierarchical display support
- [+] Mobile Optimized: Touch-friendly HTML output
Output Format
Returns mobile-optimized HTML table/grid of items matching the specified criteria.
Integration Points
- Called From:
MobileAJAX.aspx.vb.ViewProfessionalServices()
- JavaScript: Various mobile navigation functions
astp_VETS_PatientHistory_A_ProfessionalServicesParent
Primary Purpose
Manages multi-step professional services workflow with parent-child relationships and shopping cart integration.
Workflow Stages
- Step 1: Initial service selection and parent record creation
- Step 2: Child service addition and relationship management
- Step 3: Shopping cart integration and pricing
- Step 4: Patient history record completion
Key Features
- [+] Step-Based Processing: Uses
@Step parameter for workflow progression
- [TAG][TAG][TAG][+] Parent-Child Relationships: Manages service hierarchies
- [+] Shopping Cart Integration: Links to e-commerce system
- [+] Patient History: Creates/updates medical records
Integration Points
- Called From: Multiple methods in
MobileAJAX.aspx.vb
- Examples:
ADDProfessionalServicesItem(), ViewAppointmentServicesItem()
📝 Task Management
astp_VETS_TeamDoc_Tasks_EditTask1
Primary Purpose
Generates comprehensive task edit forms with TeamDoc integration for veterinary and operational tasks.
Task Management Features
- [+] Assignment: Task assignment and ownership management
- [+] Scheduling: Due dates and priority settings
- [+] Status Tracking: Progress and completion monitoring
- [+] TeamDoc Integration: Document creation for task details
- [TAG] Categorization: Task type and category management
Integration Points
- Called From: Task-related methods in
MobileAJAX.aspx.vb
- JavaScript: Functions in
Tasks.js
- TeamDoc Creation: Automatically creates associated documentation
astp_VETS_TeamDoc_Tasks_CreateAnimalTask
Primary Purpose
Creates new tasks specifically linked to individual animals with automatic TeamDoc setup.
Creation Process
- Task Record: Create task record in database
- Animal Link: Associate with specific animal via
AnimalRef
- TeamDoc Setup: Create associated TeamDoc document
- Permissions: Assign default access permissions
- Form Return: Return edit form HTML for immediate editing
Automatic Setup
- [+] Animal Association: Links task to specific animal
- [+] TeamDoc Creation: Sets up documentation workspace
- [+] Permission Assignment: Grants appropriate access rights
- [+] Edit Form: Returns ready-to-edit interface
Integration Points
- Called From:
MobileAJAX.aspx.vb.CreateAnimalTask()
- Return: HTML for immediate task editing
➕ Animal Management
sstp_Teamdoc_WebsiteAddEditAnimal
Primary Purpose
Most frequently called procedure in V.E.T.S. - comprehensive animal add/edit form with tabbed interface.
🚨 Critical Statistics
- Usage: Most frequently called procedure in the entire system
- Complexity: Handles both add and edit modes
- Interface: Tabbed interface (Name, Classification, Age/Weight, Comments, Sales/Ownership)
- Wizard Support: Guided setup via
@isWizard parameter
Tabbed Interface Structure
| Tab | Purpose | Key Fields |
| Name | Basic identification | Name, Registration, Alias |
| Classification | Species, breed, category | Species, Breed, Category |
| Age/Weight | Physical characteristics | Birth date, Weight, Height |
| Comments | Additional notes | General comments, Notes |
| Sales/Ownership | Commercial information | Price, Owner, Transfer history |
Special Features
- [+] Wizard Mode: Guided setup for new users via
@isWizard parameter
- [+] Mobile Close: Special handling for mobile menu closure
- [+] Add/Edit Modes: Single procedure handles both operations
- [+] Comprehensive: All animal data management in one interface
Integration Points
- Called From: 10+ methods in
MobileAJAX.aspx.vb
- Examples:
AddAnimal(), EditAnimal(), AnimalWizard()
- Dependencies: Various animal data views and tables
[PATTERN] Common Integration Patterns
Standard AJAX Call Pattern
All V.E.T.S. procedures follow this consistent pattern:
- JavaScript Function: Client-side function initiates action
- AjaxHelper Class: Handles AJAX request preparation
- VB.NET Handler: Routes to specific stored procedure
- SQL Execution: Procedure generates HTML response
- DOM Injection: HTML injected into page without refresh
Key Integration Points
- Mobile Detection: Automatic device-specific HTML generation
- Permission Checks: Security enforced at HTML generation level
- Error Handling: Graceful failure with user feedback
- State Management: Session storage for complex workflows
[INSIGHT] Key Insights & Best Practices
Architecture Understanding
- Stored Procedure-Driven UI: HTML generated server-side in SQL
- View-Based Security: Never query tables directly
- AJAX-First Design: No page refreshes in modern interface
- Mobile-Responsive: Device-aware HTML generation
- Multi-Tenant: Isolated data with shared infrastructure
Development Guidelines
- Follow Patterns: Use established AJAX call structures
- Test Comprehensively: Mobile, desktop, and permission scenarios
- Document Dependencies: Track procedure relationships
- Monitor Performance: 36K+ animals in production
- Security First: Permissions checked at HTML generation
[COMPLETE] Core Procedures Documentation Complete
This page documents the 10 core stored procedures that form the backbone of V.E.T.S. functionality.
Page created successfully on November 14, 2025