This backend service manages Ontario medical billing claims for clinics using OHIP service codes and their corresponding OMA-approved pricing.
Built with NestJS, Prisma, and SQLite/MySQL (configurable), it exposes REST APIs to:
- Create billing claims
- List/filter claims
- Update claim statuses
- Retrieve OHIP service codes
- Generate daily summary reports
- ✅ Clean modular architecture with Repository/Service patterns
- ✅ Input validation with
class-validator
and DTOs - ✅ Auto-generated API docs with Swagger
- ✅ Database schema using Prisma ORM
- ✅ Seeded OHIP codes with OMA pricing
- ✅ Error handling and meaningful HTTP responses
- Node.js v18+
- npm or yarn
- (Optional) MySQL server if you want to switch from SQLite
git clone https://github.com/pSkywalker/interview-app-OHIP-Billing-Claims-API.git
cd interview-app-OHIP-Billing-Claims-API
npm install
# or
yarn install
Create .env
in root with:
DATABASE_URL="file:./dev.db" # For SQLite (default)
npx prisma migrate dev --name init
npm run seed
npm run start:dev
Access API at http://localhost:4000
Swagger UI at http://localhost:4000/api
Method | Endpoint | Description |
---|---|---|
POST | /claims | Create a new billing claim |
GET | /claims | List claims with optional filters |
PATCH | /claims/:id/status | Update status of a claim |
GET | claims/reports/summary | Get daily summary report |
GET | /service-codes | Retrieve OHIP service codes |
GET | /service-codes/{code} | Retrieve details of a specific OHIP service code |
src/
├── claims/ # Claim module (controller, service, dto, repo)
├── ohip-codes/ # OHIP codes module
├── reports/ # Report generation module
├── common/ # Shared utilities, exceptions, pipes
├── main.ts # App bootstrap with validation and Swagger
├── app.module.ts # Root module
prisma/
├── schema.prisma # Prisma schema file
- Repository/Service Pattern for clear separation of concerns
- DTOs + Validation Pipes for robust input validation
- Prisma for type-safe database access and easy migrations
- Swagger to keep API docs always up to date
- SQLite default for quick dev, easily switched to MySQL or Postgres
This backend is built with modularity and clean separation of concerns, enabling future billing enhancements with minimal friction. The architecture supports easy implementation of:
Add private billing support by extending the Claim
model with a paymentType
field:
enum PaymentType {
OHIP = 'OHIP',
PRIVATE = 'PRIVATE',
}
async createClaim(dto: CreateClaimDto, paymentType: PaymentType) {
const adapter = this.factory.getAdapter(paymentType);
return adapter.createClaim(dto);
}
This allows routing claims through different pricing or approval workflows.
To support OHIP billing modifiers or premiums, a new relation model can be introduced:
model FeeModifier {
id Int @id @default(autoincrement())
claimId Int
description String
amount Float
claim Claim @relation(fields: [claimId], references: [id])
}
Modifiers could be stacked and calculated dynamically during submission or reporting.
- Each domain (
claims
,ohip
,reports
) has its own module, DTOs, repository, and service. - Easy to introduce new billing domains (e.g.
insurance
,invoice
,patients
) as discrete modules.
- DTOs ensure flexible request/response shaping.
- Validation pipes support seamless extension without weakening input constraints.
💡 With this structure, it's easy to extend the system to support multiple payers, rule-based pricing, and future billing regulation changes.
pSkywalker