---
# System prepended metadata

title: Dispatching

---

# Dispatching

## Notes
- team availability could be used to get inspector working hours
- The system will prioritize the locations that are limited to certain users (labels) then dispatch other locations
- User Labels is a list assigned to user with 2 properties (Name, Value)
    - Example: Label Name = `Gender`, Label Value = `Male`
    - Example: Label Name = `Nationality`, Label Value = `Egyptian`
- New Table to track dispatching generated schedule should be added
- Add new flag to schedule (Is System)
- We have two jobs (create interval activities - adjust missing visits)

## Model
- Id
- Name
- Locations Filters (List)
	- Filter Type [Type, Category, SubCategory, Account, Landmark, Ids]
	- Filter Values (list) [TypeIds, CategoryIds, SubCategoryIds, AccountIds, Landmarks, Location Ids]
	- Allowed Users (not a list)
	    - Filter Type [Any, Type, Ids, Labels]
        - User Type [User, Unit User, Location User]
	    - User Ids (list) (nullable)
	    - Labels
            - Label Name (new column added to user)
            - Label Value (new column added to user)
- Location Grouping [Category, Type, Direct Parent, GPS and Distance(later)]
- Dispatch Schedule
	- Start Date
	- End Date (nullable)
	- Interval (Days, Weeks, Months)
	- Number of Visits Per Interval
- Activity Configs
    - Form
    - Workflow
    - Event Type
    - Submit The Report At Site
    - Activity Type
- Users Limits
	- [x] Max Visits Per Day
	- [x] Max Visits Per Week
	- [x] Max Visits Per Month
	- [x] Visit Interval (Hours)
- Location Limits
	- [ ] Max Visits Per Day
	- [x] Max Visits Per Week
	- [x] Max Visits Per Month
- Follow-ups
	- Event Status (nullable)
	- Min Readiness (nullable)
	- Max Readiness (nullable)
	- Notice Period (Days)
	- Follow-up User
		- Same Inspector
		- Different Inspector
		- Inspector Supervisor

## JSON

```json=
{
  "id": "",
  "name": "Dispatching Name 1",
  "locationsFilter": [
    {
      "filterType": "",
      "filterValue": [ "" ],
      "allowedUser": {
        "filtertype": "",
        "userType": "",
        "userId": [],
        "lable": {
          "name": "",
          "value": ""        }
      }
    }
  ],
  "dispatchSchedule": {
    "startDate": "01-04-2023",
    "endDate": "",
    "interval": "",
    "numberOfVisit": 5  },
  "activityConfiguration": {
    "form": "",
    "workflow": "",
    "eventType": "",
    "submitTheReportAtSite": true,
    "activityType": ""  },
  "usersLimits": {
    "maxVisitsPerDay": 5,
    "maxVisitsPerWeek": 5,
    "maxVisitsPerMonth": 5,
    "visitInterval": 5  },
  "locationLimits": {
    "maxVisitsPerDay": 5,
    "maxVisitsPerWeek": 5,
    "maxVisitsPerMonth": 5  },
  "followUps": {
    "eventStatus": null,
    "minReadinness": null,
    "maxReadinness": null,
    "noticPeriodInDays": 0,
    "FollowUpUser": {
      "SameInspector": "",
      "DifferentInspector": "",
      "InspectorSupervisor":""    }
  }
}
```