https://github.com/geo-tp/medhead
POC service with Spring Boot to locate the nearest available hospital based on geographic coordinates using Google Maps API for distance calculations.
https://github.com/geo-tp/medhead
distance-matrix google-maps-api spring-boot
Last synced: 4 months ago
JSON representation
POC service with Spring Boot to locate the nearest available hospital based on geographic coordinates using Google Maps API for distance calculations.
- Host: GitHub
- URL: https://github.com/geo-tp/medhead
- Owner: geo-tp
- License: mit
- Created: 2024-07-30T00:21:13.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-09-13T21:43:27.000Z (10 months ago)
- Last Synced: 2025-01-11T01:44:10.636Z (6 months ago)
- Topics: distance-matrix, google-maps-api, spring-boot
- Language: Java
- Homepage:
- Size: 252 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MedHead - Nearest Hospital Finder
MedHead is a POC with Spring Boot to find the nearest hospital with available beds. The project leverages Google Maps Distance Matrix API to calculate distances between the user's location and hospitals.
## Prerequisites
### Backend
- Java 21 or higher
- Maven
- Google Maps API Key### Frontend
- Node 14 or higher## Configuration
Update the application.properties file in the src/main/resources directory with the following content:
```map.api.key=YOUR_GOOGLE_MAPS_API_KEY```## Authentication
Basic authentication has been implemented, requiring a username and password to access the service for added security.## Tests
There is a "scripts" folder containing:
- test_performance_distance_service.py : Calculate the average response time for the distance API
- test_nearest_hospital_end_to_end.py : Open the app in a browser and send a request to obtain an hospital reponse## Endpoints
### Get Hospitals
- **URL**: /hospitals
- **Method**: GET
- **Auth**: Not Protected
- **Query Parameters**: None
- **Example Request**: ```curl -X GET "http://localhost:9000/hospitals"```
- **Response**: Returns all hospitals.
```
[
{
"id": 1,
"name": "Hospital Saint John",
"address": "123 Main St, Springfield",
"latitude": 40.7128,
"longitude": -74.006,
"availableBeds": 150
},
{
"id": 2,
"name": "General Hospital",
"address": "456 Elm St, Shelbyville",
"latitude": 41.8781,
"longitude": -87.6298,
"availableBeds": 200
},
{
"id": 3,
"name": "City Clinic",
"address": "789 Oak St, Capital City",
"latitude": 34.0522,
"longitude": -118.2437,
"availableBeds": 75
}
]
```### Get an Hospital
- **URL**: /hospital/{ id }
- **Method**: GET
- **Auth**: Authentication required
- **Query Parameters**:
- id (required): Id of the hospital.
- **Example Request**: ```curl -X GET "http://localhost:9000/hospital/1"```
- **Response**: Returns an Hospital.
```
{
"id": 1,
"name": "Hospital Saint John",
"address": "123 Main St, Springfield",
"latitude": 40.7128,
"longitude": -74.006,
"availableBeds": 150
}
```### Get Nearest Available Hospital
- **URL**: /hospital/nearest
- **Method**: GET
- **Auth**: Authentication required
- **Query Parameters**:
- lat (required): Latitude of the user's location.
- lng (required): Longitude of the user's location.
- **Example Request**: ```curl -X GET "http://localhost:9000/hospital/nearest?lat=40.7128&lng=-74.0060"```
- **Response**: Returns the nearest hospital with available beds.
```
{
"id": 1,
"name": "Hospital Saint John",
"address": "123 Main St, Springfield",
"latitude": 40.7128,
"longitude": -74.0060,
"availableBeds": 150
}
```