{"id":46847515,"url":"https://github.com/amafjarkasi/rxflow","last_synced_at":"2026-03-10T15:11:09.539Z","repository":{"id":340880773,"uuid":"1166461792","full_name":"amafjarkasi/rxflow","owner":"amafjarkasi","description":"Event-driven prescription orchestration engine transforming FHIR R5 to NCPDP SCRIPT v2023011 at 5,000+ TPS with DEA EPCS compliance","archived":false,"fork":false,"pushed_at":"2026-02-26T23:47:53.000Z","size":86,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-02-27T05:48:05.995Z","etag":null,"topics":["e-prescribing","epcs","event-sourcing","fhir","golang","healthcare","healthcare-interoperability","high-throughput","hl7-fhir","kafka","ncpdp-script","pharmacy","prescription","redpanda","timescaledb"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/amafjarkasi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-02-25T08:49:57.000Z","updated_at":"2026-02-26T23:48:14.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/amafjarkasi/rxflow","commit_stats":null,"previous_names":["amafjarkasi/rxflow"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/amafjarkasi/rxflow","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amafjarkasi%2Frxflow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amafjarkasi%2Frxflow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amafjarkasi%2Frxflow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amafjarkasi%2Frxflow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/amafjarkasi","download_url":"https://codeload.github.com/amafjarkasi/rxflow/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amafjarkasi%2Frxflow/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30338980,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-10T15:03:31.997Z","status":"ssl_error","status_checked_at":"2026-03-10T15:01:30.431Z","response_time":106,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["e-prescribing","epcs","event-sourcing","fhir","golang","healthcare","healthcare-interoperability","high-throughput","hl7-fhir","kafka","ncpdp-script","pharmacy","prescription","redpanda","timescaledb"],"created_at":"2026-03-10T15:11:06.131Z","updated_at":"2026-03-10T15:11:09.530Z","avatar_url":"https://github.com/amafjarkasi.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RxFlow - High-Volume Prescription Orchestration Engine\n\n[![Go Version](https://img.shields.io/badge/Go-1.23+-00ADD8?style=flat\u0026logo=go)](https://go.dev/)\n[![FHIR R5](https://img.shields.io/badge/FHIR-R5-E73C3E?style=flat)](https://hl7.org/fhir/R5/)\n[![NCPDP SCRIPT](https://img.shields.io/badge/NCPDP%20SCRIPT-v2023011-1E88E5?style=flat)](https://www.ncpdp.org/)\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE)\n\n\u003e **Event-driven prescription orchestration engine transforming FHIR R5 to NCPDP SCRIPT v2023011 at 5,000+ TPS with DEA EPCS compliance**\n\nRxFlow (`go-oec`) is a high-performance prescription processing platform designed for healthcare interoperability. It bridges modern EHR systems using HL7 FHIR R5 with pharmacy networks via NCPDP SCRIPT v2023011, implementing event sourcing patterns for complete DEA audit compliance.\n\n---\n\n## Project Status\n\n| Aspect | Status |\n|--------|--------|\n| **Maturity** | Pre-Alpha / Development |\n| **Core Engine** | Implemented |\n| **FHIR R5 Models** | Complete |\n| **NCPDP SCRIPT v2023011** | Complete |\n| **Event Sourcing** | Complete |\n| **Distributed Patterns** | Complete |\n| **API Layer** | Implemented |\n| **Security/EPCS** | Stub Implementation |\n| **Production Ready** | No |\n\n### What's Working\n\n- FHIR R5 MedicationRequest ingestion via REST API\n- NCPDP SCRIPT v2023011 NewRx message generation\n- Bidirectional FHIR-to-SCRIPT transformation\n- Event-sourced prescription aggregate with TimescaleDB\n- Transactional outbox pattern for reliable messaging\n- Idempotency inbox for exactly-once processing\n- Circuit breaker pattern for pharmacy routing\n- Worker pool for concurrent processing\n- OpenTelemetry tracing and Prometheus metrics\n- Docker Compose development environment\n\n### What's Stubbed/Planned\n\n- DEA EPCS two-factor authentication\n- Digital signature infrastructure (PKI)\n- Surescripts production integration\n- State Prescription Monitoring Program (PMP) integration\n- Drug-drug interaction checking\n- Post-quantum cryptography (FIPS 203/204)\n\n---\n\n## Architecture Overview\n\n```\n                                    RxFlow Architecture\n    \n    +------------------+     +------------------+     +------------------+\n    |    EHR System    |     |   Ingestion API  |     |    Redpanda      |\n    |  (FHIR R5 JSON)  +----\u003e+  /api/v1/...     +----\u003e+  (Kafka Topics)  |\n    +------------------+     +--------+---------+     +--------+---------+\n                                      |                        |\n                                      v                        v\n                             +------------------+     +------------------+\n                             |   PostgreSQL     |     |  Routing Service |\n                             |  + TimescaleDB   |\u003c----+  + Worker Pool   |\n                             |  + pgvector      |     |  + Circuit Break |\n                             +------------------+     +--------+---------+\n                                      ^                        |\n                                      |                        v\n                             +------------------+     +------------------+\n                             |  Outbox Relay    |     |  Pharmacy        |\n                             |  (Transactional) |     |  (NCPDP SCRIPT)  |\n                             +------------------+     +------------------+\n```\n\n### Key Design Patterns\n\n| Pattern | Purpose |\n|---------|---------|\n| **Event Sourcing** | Immutable audit trail for DEA compliance |\n| **CQRS** | Separate read/write models for performance |\n| **Transactional Outbox** | Atomic DB + message queue writes |\n| **Idempotency Inbox** | Exactly-once message processing |\n| **Circuit Breaker** | Prevent cascade failures to pharmacies |\n| **Worker Pool** | Bounded concurrency for throughput control |\n\n---\n\n## Technology Stack\n\n| Component | Technology | Purpose |\n|-----------|------------|---------|\n| **Language** | Go 1.23+ | High-performance, type-safe |\n| **Message Broker** | Redpanda | Kafka-compatible, low-latency |\n| **Database** | PostgreSQL 16 | ACID compliance, JSON support |\n| **Time-Series** | TimescaleDB | Event compression, retention |\n| **Embeddings** | pgvector | AI-powered drug matching |\n| **HTTP Router** | chi | Lightweight, composable |\n| **Kafka Client** | franz-go | High-throughput batching |\n| **Tracing** | OpenTelemetry + Jaeger | Distributed observability |\n| **Metrics** | Prometheus + Grafana | Performance monitoring |\n\n---\n\n## Quick Start\n\n### Prerequisites\n\n- Go 1.23+\n- Docker \u0026 Docker Compose\n- Make\n\n### 1. Clone the Repository\n\n```bash\ngit clone https://github.com/yourusername/go-oec.git\ncd go-oec\n```\n\n### 2. Start Infrastructure\n\n```bash\n# Start Redpanda, PostgreSQL, Jaeger, Prometheus, Grafana\nmake docker-up\n\n# Run database migrations\nmake migrate-up\n```\n\n### 3. Build and Run\n\n```bash\n# Build all services\nmake build\n\n# Run the ingestion API\n./bin/ingestion-api\n\n# In another terminal, run the outbox relay\n./bin/outbox-relay\n\n# In another terminal, run the routing service\n./bin/routing-service\n```\n\n### 4. Test the API\n\n```bash\n# Create a prescription\ncurl -X POST http://localhost:8080/api/v1/prescriptions \\\n  -H \"Content-Type: application/json\" \\\n  -H \"X-API-Key: your-api-key\" \\\n  -d @test/fixtures/medication_request_lisinopril.json\n```\n\n---\n\n## API Reference\n\n### Create Prescription\n\n```http\nPOST /api/v1/prescriptions\nContent-Type: application/json\nX-API-Key: \u003capi-key\u003e\n```\n\n**Request Body:**\n```json\n{\n  \"medication_request\": { /* FHIR R5 MedicationRequest */ },\n  \"patient\": { /* FHIR R5 Patient */ },\n  \"practitioner\": { /* FHIR R5 Practitioner */ },\n  \"pharmacy\": { /* FHIR R5 Organization */ }\n}\n```\n\n**Response:**\n```json\n{\n  \"id\": \"uuid\",\n  \"status\": \"pending\",\n  \"idempotency_key\": \"sha256-hash\",\n  \"is_controlled\": false,\n  \"created_at\": \"2026-02-25T10:00:00Z\"\n}\n```\n\n### Get Prescription\n\n```http\nGET /api/v1/prescriptions/{id}\nX-API-Key: \u003capi-key\u003e\n```\n\n### Get Prescription Events\n\n```http\nGET /api/v1/prescriptions/{id}/events\nX-API-Key: \u003capi-key\u003e\n```\n\n### Route Prescription to Pharmacy\n\n```http\nPOST /api/v1/prescriptions/{id}/route\nX-API-Key: \u003capi-key\u003e\n```\n\n---\n\n## Project Structure\n\n```\ngo-oec/\n├── cmd/                          # Service entry points\n│   ├── ingestion-api/            # HTTP API service\n│   ├── outbox-relay/             # Outbox pattern processor\n│   └── routing-service/          # Pharmacy routing consumer\n├── internal/\n│   ├── api/                      # HTTP handlers and middleware\n│   ├── domain/prescription/      # Event-sourced aggregate\n│   ├── fhir/r5/                  # FHIR R5 data models\n│   ├── infrastructure/\n│   │   ├── postgres/             # PostgreSQL repositories\n│   │   └── redpanda/             # Kafka producer/consumer\n│   ├── ncpdp/\n│   │   ├── mapper/               # FHIR \u003c-\u003e SCRIPT transformation\n│   │   └── script2023011/        # NCPDP SCRIPT v2023011 types\n│   └── observability/            # Tracing and metrics\n├── pkg/\n│   ├── circuitbreaker/           # Circuit breaker pattern\n│   ├── idempotency/              # Inbox pattern\n│   └── workerpool/               # Bounded worker pool\n├── deploy/docker/                # Docker Compose environment\n├── migrations/                   # PostgreSQL migrations\n└── test/fixtures/                # Test data (FHIR JSON)\n```\n\n---\n\n## Kafka Topics\n\n| Topic | Purpose |\n|-------|---------|\n| `prescription.events` | Domain events (event sourcing) |\n| `prescription.commands` | Command messages |\n| `routing.requests` | Pharmacy routing requests |\n| `routing.responses` | Pharmacy responses |\n| `audit.trail` | DEA audit events |\n| `ncpdp.outbound` | SCRIPT messages to pharmacies |\n| `ncpdp.inbound` | SCRIPT responses from pharmacies |\n| `dead.letter` | Failed message handling |\n\n---\n\n## Configuration\n\n### Environment Variables\n\n| Variable | Default | Description |\n|----------|---------|-------------|\n| `PORT` | `8080` | HTTP server port |\n| `DATABASE_URL` | `postgres://...` | PostgreSQL connection |\n| `REDPANDA_BROKERS` | `localhost:9092` | Kafka brokers |\n| `OTEL_ENDPOINT` | `localhost:4317` | OpenTelemetry collector |\n| `LOG_LEVEL` | `info` | Logging verbosity |\n| `API_KEYS` | - | Comma-separated API keys |\n\n---\n\n## Development Roadmap\n\n### Phase 1: Foundation (Complete)\n- [x] Go module setup and Makefile\n- [x] Docker Compose infrastructure\n- [x] Database migrations with TimescaleDB\n- [x] FHIR R5 data models\n- [x] NCPDP SCRIPT v2023011 structures\n\n### Phase 2: Core Domain (Complete)\n- [x] Event-sourced prescription aggregate\n- [x] FHIR-to-SCRIPT mapper\n- [x] Idempotency key generation\n- [x] Transactional outbox pattern\n- [x] Idempotency inbox pattern\n\n### Phase 3: Orchestration (Complete)\n- [x] Redpanda producer/consumer\n- [x] Worker pool implementation\n- [x] Circuit breaker pattern\n- [x] Routing service\n\n### Phase 4: Integration (In Progress)\n- [ ] Pharmacy response handling\n- [ ] Structured Sig mapping\n- [ ] NPI/DEA validation\n- [ ] Drug database integration\n\n### Phase 5: Security \u0026 Compliance (Planned)\n- [ ] DEA EPCS two-factor auth\n- [ ] Digital signature (PKI)\n- [ ] Patient hash salting\n- [ ] Field-level encryption\n- [ ] Post-quantum cryptography\n\n### Phase 6: Production Readiness (Planned)\n- [ ] Surescripts integration\n- [ ] PMP integration\n- [ ] Performance optimization\n- [ ] Load testing (5,000 TPS)\n- [ ] Security audit\n\n---\n\n## Performance Targets\n\n| Metric | Target | Current |\n|--------|--------|---------|\n| **Throughput** | 5,000 TPS | Not tested |\n| **Latency (p99)** | \u003c 100ms | Not tested |\n| **Availability** | 99.99% | N/A |\n| **Event Retention** | 7 years | Configured |\n\n### Tuning Parameters\n\n```go\n// Producer (franz-go)\nBatchMaxBytes:     16 * 1024 * 1024,  // 16MB batches\nLinger:            50 * time.Millisecond,\nMaxBufferedRecords: 1_000_000,\n\n// Worker Pool\nWorkers:    100,\nQueueSize:  10_000,\nMaxRetries: 3,\n```\n\n---\n\n## Observability\n\n### Jaeger UI (Tracing)\n```\nhttp://localhost:16686\n```\n\n### Prometheus (Metrics)\n```\nhttp://localhost:9090\n```\n\n### Grafana (Dashboards)\n```\nhttp://localhost:3000\n```\n\n### Redpanda Console\n```\nhttp://localhost:8081\n```\n\n---\n\n## Testing\n\n```bash\n# Run unit tests\nmake test\n\n# Run integration tests\nmake test-integration\n\n# Run with coverage\nmake test-coverage\n```\n\n---\n\n## Contributing\n\nWe welcome contributions! Please see our contributing guidelines:\n\n1. Fork the repository\n2. Create a feature branch (`git checkout -b feature/amazing-feature`)\n3. Commit your changes (`git commit -m 'Add amazing feature'`)\n4. Push to the branch (`git push origin feature/amazing-feature`)\n5. Open a Pull Request\n\n### Code Standards\n\n- Follow Go idioms and conventions\n- Maintain test coverage above 80%\n- Document public APIs\n- Use meaningful commit messages\n\n---\n\n## License\n\nThis project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.\n\n---\n\n## Acknowledgments\n\n- [HL7 FHIR](https://hl7.org/fhir/) - Healthcare interoperability standard\n- [NCPDP SCRIPT](https://www.ncpdp.org/) - E-prescribing standard\n- [Redpanda](https://redpanda.com/) - Kafka-compatible streaming\n- [TimescaleDB](https://www.timescale.com/) - Time-series database\n- [franz-go](https://github.com/twmb/franz-go) - High-performance Kafka client\n\n---\n\n## Contact\n\nFor questions or support, please open an issue on GitHub.\n\n---\n\n**Disclaimer:** This software is provided for development and demonstration purposes. It is not certified for production use in healthcare settings. Proper regulatory compliance, security audits, and certifications are required before processing real patient data.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famafjarkasi%2Frxflow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famafjarkasi%2Frxflow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famafjarkasi%2Frxflow/lists"}