A Fastify-based backend service for managing prescriptions with SignatureRx API integration.
- OAuth2 Authentication: Client credentials flow with automatic token caching and refresh
- Prescription Management: Issue prescriptions via SignatureRx API with retry logic
- Webhook Processing: Receive and process SignatureRx webhook events
- Database Integration: MongoDB for storing prescriptions and webhook logs
- Error Handling: Comprehensive error handling with structured responses
- Rate Limiting: Built-in rate limiting and security features
-
Install Dependencies
npm install
-
Environment Setup
cp env.example .env # Edit .env with your SignatureRx credentials -
Start Development Server
npm run dev
-
Test Endpoints
node test-endpoints.js
POST /api/v1/auth/token- Get OAuth2 tokenGET /api/v1/auth/test-connection- Test SignatureRx connectionGET /api/v1/auth/token-status- Get token cache status
POST /api/v1/prescriptions/issue- Issue prescriptionGET /api/v1/prescriptions/{id}/status- Get prescription statusGET /api/v1/prescriptions/medicines- Get available medicinesGET /api/v1/prescriptions/patient/mock- Get mock patient data
POST /api/v1/webhooks/signaturerx- Receive SignatureRx webhooksGET /api/v1/webhooks/logs- Get webhook logsGET /api/v1/webhooks/stats/overview- Get webhook statistics
src/
├── app.ts # Main Fastify application
├── server.ts # Server startup
├── config/ # Configuration files
├── controllers/ # Request handlers
├── services/ # Business logic
├── models/ # Database models
├── dao/ # Data access objects
├── route/ # API routes
└── utils/ # Utility functions