Overview
TheAiDiagnosticService analyzes equipment symptoms using heuristic pattern matching to identify potential causes, suggest replacement parts, estimate repair time, and provide cost calculations.
Namespace: App\Services\AiDiagnosticService
Methods
analyze
Analyzes equipment symptoms and returns diagnostic recommendations including potential causes, suggested parts, time estimates, and cost breakdowns.Parameters
The type of equipment (e.g., “Lavadora”, “Refrigerador”)
The brand name of the equipment
The model identifier. Can be null if unknown
Description of the symptoms or issues reported by the customer
Returns
Returns an associative array with the following structure:Behavior
The analysis uses pattern matching on the symptoms text to identify common issues:-
Power Issues: Detects “no enciende” or “enciende” patterns
- Suggests: Tarjeta electrónica, Fusible térmico
- Estimated time: 3-5 hours
- Labor cost: $850.00
-
Noise/Vibration: Detects “ruido” or “vibr” patterns
- Suggests: Rodamientos, Soportes antivibración
- Estimated time: 2-3 hours
- Labor cost: $700.00
-
Leaks: Detects “fuga” or “agua” patterns
- Suggests: Kit de sellos, Manguera de drenaje
- Estimated time: 1-2 hours
- Labor cost: $600.00
-
Generic: When no specific patterns match
- Suggests: Preventive maintenance and recalibration
- Labor cost: $450.00
Example Usage
Cost Calculation
Parts are costed at $320.00 per item. The total replacement cost is calculated as:repair_labor_cost are set to 0.
Implementation Notes
- The service performs case-insensitive pattern matching using
mb_strtolower() - Multiple patterns can match simultaneously, combining causes and parts
- Labor costs use
max()to ensure the highest applicable rate is used - All monetary values are rounded to 2 decimal places
- Duplicate parts are automatically removed using
array_unique()