A Java 21 Spring Boot REST API for modeling synthetic clinical patient flow through departments and encounters.
This project is built for healthcare backend practice: REST endpoints, DTOs, validation, exception handling, PostgreSQL persistence, JUnit tests, Docker, GitHub Actions, and Azure deployment readiness.
Important: this project uses synthetic data only. Do not use anything derived from actual Penn patients or any real patient population.
- Java 21
- Spring Boot
- Spring Web
- Spring Data JPA
- PostgreSQL
- DTOs
- Bean Validation
- Global exception handling
- JUnit 5 / Mockito
- Docker / Docker Compose
- GitHub Actions
- Azure Web App deployment workflow
| Method | Endpoint | Description |
|---|---|---|
POST |
/patients |
Create a synthetic patient |
GET |
/patients |
List patients |
GET |
/patients/{id} |
Get a patient by id |
POST |
/encounters |
Create an encounter |
GET |
/encounters/{id} |
Get an encounter by id |
PATCH |
/encounters/{id}/status |
Update encounter status |
GET |
/departments/{id}/queue |
Get active queue for a department |
Read the architecture document:
docker compose up --buildThe API will run at:
http://localhost:8080
Swagger UI:
http://localhost:8080/swagger-ui.html
Start PostgreSQL with a database named clinical_flow, then set:
export SPRING_DATASOURCE_URL=jdbc:postgresql://localhost:5432/clinical_flow
export SPRING_DATASOURCE_USERNAME=clinical_user
export SPRING_DATASOURCE_PASSWORD=clinical_password
mvn spring-boot:runPrepared HTTP requests are in:
docs/requests.http
POST /patients
Content-Type: application/json{
"firstName": "Avery",
"lastName": "Morgan",
"age": 31,
"medicalRecordNumber": "SYN-123456"
}POST /encounters
Content-Type: application/json{
"patientId": 1,
"departmentId": 1,
"chiefComplaint": "Synthetic chest discomfort scenario",
"status": "WAITING"
}PATCH /encounters/1/status
Content-Type: application/json{
"status": "IN_TREATMENT"
}WAITINGIN_TRIAGEIN_TREATMENTDISCHARGEDCANCELLED
The API also accepts common variants like in treatment and IN-TREATMENT.
On first run, the app creates fake departments, patients, and encounters. All names, complaints, and medical record numbers are synthetic.
mvn testThe CI workflow:
- checks out the repo
- sets up Java 21
- starts PostgreSQL service
- runs
mvn test - builds the jar
The workflow includes an optional Azure Web App deploy job.
Required GitHub configuration:
- Repository variable:
AZURE_WEBAPP_NAME - Repository secret:
AZURE_WEBAPP_PUBLISH_PROFILE
For production-style persistence, connect the Azure Web App to Azure Database for PostgreSQL and set:
SPRING_DATASOURCE_URLSPRING_DATASOURCE_USERNAMESPRING_DATASOURCE_PASSWORD
- Add Flyway database migrations
- Add controller integration tests with Testcontainers
- Add pagination and filtering
- Add role-based security
- Add Azure Container Apps deployment