This project is a Spring Boot microservice designed to handle:
- Invoice (Facture) generation
- Medical actions / services management
- Dynamic price calculation with insurance-based reductions
It is part of a microservices-based healthcare platform, where each service is independent and communicates via REST APIs.
- Create invoices linked to patients
- Automatic calculation of total amount
- Support for multiple actions/services per invoice
- Generate invoice as PDF document
-
CRUD operations for medical actions (consultation, analysis, etc.)
-
Each action includes:
- Name
- Base price
- Description
-
Actions can be reused across multiple invoices
-
Apply discounts automatically based on patient insurance plan
-
Flexible rule system for price calculation
- Generate payment link (Stripe / PayPal)
- Include link in email sent to patient
- Embed QR code in PDF invoice for quick payment
- Send invoice directly to patient via email
- Attach generated PDF
- Include payment link
This microservice follows a layered architecture:
Controller → Service → Repository → Database
-
Controller Layer
- Exposes REST APIs
- Handles HTTP requests/responses
-
Service Layer
- Business logic
- Invoice calculation
- Insurance reduction logic
-
Repository Layer
- Spring Data JPA
- Database interaction
-
Entities
- Facture (Invoice)
- Action
The final invoice amount is calculated as:
Total = Σ(Action Price) - Insurance Reduction
| Action | Price |
|---|---|
| Consultation | 100 |
| Analysis | 200 |
Subtotal = 300 Insurance (20%) = -60
👉 Final Total = 240
src/main/java/
├── controller/
├── service/
├── repository/
├── entity/
├── dto/
└── config/
POST /api/factures→ Create invoiceGET /api/factures/{id}→ Get invoice by IDGET /api/factures→ Get all invoicesDELETE /api/factures/{id}→ Delete invoice
POST /api/actions→ Create actionGET /api/actions→ List actions
- Java 17
- Spring Boot
- Spring Data JPA
- Hibernate
- MySQL (or MongoDB optional)
- OpenHTMLtoPDF (PDF generation)
- JavaMailSender (email service)
git clone https://github.com/your-repo/invoice-microservice.git
cd invoice-microservicespring.datasource.url=jdbc:mysql://localhost:3306/invoice_db
spring.datasource.username=root
spring.datasource.password=yourpassword
spring.jpa.hibernate.ddl-auto=updatemvn spring-boot:run- Microservice communication via Eureka & API Gateway
- Kafka for event-driven invoice generation
- Advanced insurance rule engine
- Dashboard analytics (revenue, payments)
- Multi-currency s