# Location sheet & map notes

## Doctor locations
- **pLat** and **pLng** (or `p_lat`, `p_long`, `lat`, `lng` in the sheet) are the **locations of the doctors**. They are stored on the `doctors` table as `geom_point` and used for map pins and territory classification.

## Hierarchy
- **ASM** is the Manager of the MIO (MR / employee).
- **HOS** is the Manager of the ASM.
- The location sheet can include columns **ASM** and **HOS**; these are stored on the `mrs` table as `asm_name` and `hos_name`.

## Doctor route map (base routes)
- The **Map** page shows a Leaflet map with:
  - **Base routes** (from DB): one pin per doctor at (pLat, pLng), path in row order per employee. Data flows from the location sheet: import → `doctors.geom_point` and `mr_doctor_route` (sequence).
  - **Custom drawings**: you can draw on the map (markers, lines, shapes). Drawings are stored in `saved_maps` and do not modify the original route data. You can save the current drawing and load a saved map as an overlay.
- **Data flow**: Location sheet (columns: territory, employee, doctor, p_lat / p_long, optional ASM, HOS) → Import → areas, mrs, doctors (with geom_point), mr_doctor_route (row order) → Map page reads routes and draws pins + polylines. Lat/lng parsing supports comma decimals and trimmed values.
