Clínica CPAE - CRM & EHR SaaS

Imagem personagem

Technologies

TypeScript 75% SCSS 15% PLpgSQL 10%

Topics

saas ehr nestjs nextjs expo rbac minio redis postgresql

Developed Clínica CPAE, a complete B2B multi-tenant SaaS platform designed for clinical management and high-performance Electronic Health Records (EHR), structured with NestJS (backend), Next.js (frontend), and React Native/Expo (mobile).

As a commercial software product, the platform features a robust data isolation architecture (Multi-tenancy) employing AsyncLocalStorage in the HTTP cycle and Row-Level Security (RLS) dynamically configured through Prisma ORM for PostgreSQL. This setup enables selling the platform to multiple independent clinics operating under a single database.

For daily operations, the reception coordinates bookings using a modular scheduling system mapped to room and professional availability. Each patient profile stores a longitudinal health record containing clinical histories and progress logs. The system consolidates evolution charts and anamneses reports submitted by health specialists (such as psychologists and speech therapists).

To ensure privacy and compliance with LGPD, I designed a sanitization service that detects and redacts sensitive data like registration and phone numbers using regular expressions before sending records to external AI models, alongside an active token budget control on API keys.

The complete source code repository and Playwright test suites are available on GitHub.

Technical Highlights

Multi-Tenant SaaS

Logical patient data isolation between multiple client clinics in PostgreSQL using AsyncLocalStorage in the HTTP cycle and native Row-Level Security (RLS) via Prisma ORM.

PII Sanitization

Privacy filter based on regular expressions (Regex) to detect and redact patient CPFs, phone numbers, and names from medical charts before sending to external AI APIs.

Billing & Insurances

Complex transactional engine validating Health Guide quotes before batch scheduling, combined with dynamic AI token budget control to prevent billing overruns.

Infrastructure & Queues

Microservices isolated in Docker containers, Redis (Bull Queue) for background job processing, MinIO for S3 storage, and integrated Playwright testing.