Spaces:
Sleeping
Sleeping
| from datetime import timedelta | |
| def predict_next_service(last_service_date, usage_hours, days_per_week, equipment_type): | |
| """ | |
| Predict AMC date based on usage + type of equipment. | |
| """ | |
| # Usage intensity score | |
| usage_score = usage_hours * days_per_week | |
| # Base interval in days | |
| base_interval = 180 # standard | |
| # Adjust interval based on usage | |
| if usage_score >= 120: | |
| interval = 90 | |
| elif usage_score >= 80: | |
| interval = 120 | |
| elif usage_score >= 40: | |
| interval = 150 | |
| else: | |
| interval = 180 | |
| # Further adjustment based on equipment type (example rules) | |
| if equipment_type in ["Analyzer", "Centrifuge"]: | |
| interval -= 15 # more sensitive | |
| elif equipment_type == "Incubator": | |
| interval += 15 # more stable | |
| next_date = last_service_date + timedelta(days=interval) | |
| return next_date | |