A Node.js service that processes patient CSV data to geocode patient addresses using the MapMyIndia (Mappls) API. It calculates the distance between each patient and their assigned healthcare facility.
- Bulk geocoding of patient addresses via MapMyIndia API
- Chunked CSV processing with concurrent workers
- Auto-resume: skips already-processed rows on restart
- Start-from-ID support to resume mid-chunk
- Distance calculation (patient ↔ facility) in metres
patient_geo/
├── src/
│ ├── index.js # Express API server entry point
│ ├── api/
│ │ └── geolocation.js # MapMyIndia API calls (eLoc + coords)
│ ├── services/
│ │ ├── csvService.js # Core CSV stream processor
│ │ └── splitService.js # CSV chunker/splitter
│ └── utils/
│ └── distance.js # Haversine distance calculator
├── run_multiple_chunks.js # Batch runner for multiple chunk files
├── run_specific_chunk.js # Runner for a single chunk
├── sample.csv # Example input CSV
└── .env.example # Environment variable template
npm installcp .env.example .envEdit .env and add your MapMyIndia API credentials.
npm start
# or for development with auto-reload:
npm run devEdit run_multiple_chunks.js to set your chunk directory and range, then:
node run_multiple_chunks.jsThe input CSV should contain at minimum:
alternate_idorpatient_id— unique row identifieraddressorpatient_address— full patient address- Facility geolocation:
geolocationcolumn (e.g."lat, lon") ORlatitude/longitudecolumns
Processed CSVs are written to the processed/ directory with added columns:
patient_eLoc— MapMyIndia place codepatient_latitudepatient_longitudedistance_to_facility_m— distance in metres
| Variable | Description |
|---|---|
MAP_MY_INDIA_KEY |
MapMyIndia REST API key |
MAPMYINDIA_CLIENT_ID |
OAuth2 client ID |
MAPMYINDIA_CLIENT_SECRET |
OAuth2 client secret |
Get credentials at: https://apis.mappls.com/console/