Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ LOG_LEVEL=info
# SQLite Configuration
SQLITE_DB_PATH=./data/fhirtogether.db

# MongoDB Configuration (if using mongo)
# MONGO_URI=mongodb://localhost:27017
# MONGO_DB_NAME=fhirtogether

# PostgreSQL Configuration (if using postgres)
# POSTGRES_HOST=localhost
# POSTGRES_PORT=5432
Expand Down
16 changes: 8 additions & 8 deletions IMPLEMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ When you run `npm run generate-data`:
Environment variables in `.env`:

```env
STORE_BACKEND=sqlite # Database backend (only sqlite for now)
STORE_BACKEND=sqlite # Database backend (sqlite or mongo)
PORT=4010 # Server port
HOST=0.0.0.0 # Server host
LOG_LEVEL=info # Logging level
Expand Down Expand Up @@ -225,16 +225,16 @@ curl "http://localhost:4010/Appointment?date=2025-12-09"

## 🎉 Success Criteria Met

✅ **Directory Framework**: Complete src/ structure with types, store, routes, examples
✅ **Database Backend**: Full CRUD operations for all FHIR resources
✅ **API Endpoints**: All Schedule, Slot, Appointment operations implemented
✅ **Busy Office Example**: 3 providers, 50-60 patients/day, 30 days ahead
✅ **Data Generation**: Automated script with statistics reporting
✅ **Data Regeneration**: Can refresh stale data anytime
✅ **Directory Framework**: Complete src/ structure with types, store, routes, examples
✅ **Database Backend**: Full CRUD operations for all FHIR resources
✅ **API Endpoints**: All Schedule, Slot, Appointment operations implemented
✅ **Busy Office Example**: 3 providers, 50-60 patients/day, 30 days ahead
✅ **Data Generation**: Automated script with statistics reporting
✅ **Data Regeneration**: Can refresh stale data anytime

## 🔮 Next Steps (Future Enhancements)

- [ ] Add PostgreSQL, MySQL, MongoDB store implementations
- [ ] Add PostgreSQL, MySQL store implementations
- [ ] Implement HL7v2 SIU message ingestion
- [ ] Add `$find-appointment` FHIR operation
- [ ] Implement SMART-on-FHIR authentication
Expand Down
8 changes: 6 additions & 2 deletions QUICKSTART.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,10 @@ LOG_LEVEL=info
# Database Configuration
SQLITE_DB_PATH=./data/fhirtogether.db

# MongoDB (used when STORE_BACKEND=mongo)
# MONGO_URI=mongodb://localhost:27017
# MONGO_DB_NAME=fhirtogether

# Enable test/admin endpoints (DELETE operations)
ENABLE_TEST_ENDPOINTS=true
```
Expand All @@ -184,7 +188,7 @@ The busy office example includes:

- **3 Providers**:
- Dr. Sarah Smith (Family Medicine) - 20 min appointments
- Dr. Michael Johnson (Internal Medicine) - 25 min appointments
- Dr. Michael Johnson (Internal Medicine) - 25 min appointments
- Dr. Emily Williams (Pediatrics) - 15 min appointments

- **Appointment Volume**: ~50-60 patients per provider per day
Expand Down Expand Up @@ -228,7 +232,7 @@ All endpoints follow FHIR R4 specifications for:

## 🧩 Next Steps

- Implement additional backend stores (PostgreSQL, MySQL, MongoDB)
- Implement additional backend stores (PostgreSQL, MySQL)
- Add HL7v2 message ingestion (`POST /$hl7v2-ingest`)
- Implement `$find-appointment` operation
- Add SMART-on-FHIR authentication
Expand Down
17 changes: 16 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ services:
app:
build: .
init: true
depends_on:
- mongo
ports:
- "4010:4010"
volumes:
Expand All @@ -12,4 +14,17 @@ services:
environment:
- NODE_ENV=production
- SQLITE_DB_PATH=/app/data/fhirtogether.db
command: npm run dev
- MONGO_URI=mongodb://mongo:27017
- MONGO_DB_NAME=fhirtogether
command: npm run dev
Comment on lines 2 to +19

mongo:
image: mongo:7
restart: unless-stopped
ports:
- "27017:27017"
volumes:
- mongo_data:/data/db

volumes:
mongo_data:
129 changes: 128 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"better-sqlite3": "^9.2.2",
"dotenv": "^16.3.1",
"fastify": "^5.8.5",
"mongodb": "^6.18.0",
"pino": "^8.17.2",
"pino-pretty": "^10.3.1",
"rrule": "^2.8.1",
Expand Down
15 changes: 15 additions & 0 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { config } from 'dotenv';
import path from 'path';
import fs from 'fs';
import { SqliteStore, SCHEMA_VERSION } from './store/sqliteStore';
import { MongoStore, MONGO_SCHEMA_VERSION } from './store/mongoStore';
import { slotRoutes } from './routes/slotRoutes';
import { scheduleRoutes } from './routes/scheduleRoutes';
import { appointmentRoutes } from './routes/appointmentRoutes';
Expand Down Expand Up @@ -171,6 +172,20 @@ async function buildServer() {
}

fastify.log.info('SQLite store initialized (schema v' + SCHEMA_VERSION + ')');
} else if (STORE_BACKEND === 'mongo') {
store = new MongoStore();
const schemaStatus = await store.initialize();

if (!schemaStatus.match) {
startupWarnings.push(
`⚠️ Mongo schema mismatch: database is v${schemaStatus.current}, code expects v${MONGO_SCHEMA_VERSION}`,
` Auto-migrated to v${MONGO_SCHEMA_VERSION}`,
);
} else if (schemaStatus.migrated && schemaStatus.current === 0) {
fastify.log.info('Fresh Mongo database - schema initialized at v' + MONGO_SCHEMA_VERSION);
}

fastify.log.info('Mongo store initialized (schema v' + MONGO_SCHEMA_VERSION + ')');
Comment on lines +175 to +188
} else {
throw new Error(`Unsupported store backend: ${STORE_BACKEND}`);
}
Expand Down
Loading
Loading