Skip to content

adrianaditech/interview-app-OHIP-Billing-Claims-API

 
 

Repository files navigation

🏥 Ontario Medical Billing Claims API

NestJS Prisma Node.js


📋 Overview

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

🚀 Features

  • ✅ 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

🛠️ Setup & Installation

Prerequisites

  • Node.js v18+
  • npm or yarn
  • (Optional) MySQL server if you want to switch from SQLite

Clone repo

git clone https://github.com/pSkywalker/interview-app-OHIP-Billing-Claims-API.git
cd interview-app-OHIP-Billing-Claims-API

Install dependencies

npm install
# or
yarn install

Configure environment

Create .env in root with:

DATABASE_URL="file:./dev.db"       # For SQLite (default)

Run migrations & seed data

npx prisma migrate dev --name init
npm run seed

Start development server

npm run start:dev

Access API at http://localhost:4000
Swagger UI at http://localhost:4000/api


📚 API Endpoints

Method Endpoint Description
POST/claimsCreate a new billing claim
GET/claimsList claims with optional filters
PATCH/claims/:id/statusUpdate status of a claim
GETclaims/reports/summaryGet daily summary report
GET/service-codesRetrieve OHIP service codes
GET/service-codes/{code}Retrieve details of a specific OHIP service code

🧩 Project Structure

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

📝 Design Decisions

  • 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

🧩 Scalability & Extensibility

This backend is built with modularity and clean separation of concerns, enabling future billing enhancements with minimal friction. The architecture supports easy implementation of:

🔒 Private Pay Support

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.

💰 Fee Modifiers (After-hours, Emergency, etc.)

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.

🧱 Modular Domain-Driven Design

  • 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.

🌐 API Contracts via DTOs

  • 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.


🙋‍♂️ Author

pSkywalker


About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 95.4%
  • JavaScript 4.6%