A comprehensive Health-Related Social Needs (HRSN) FHIR Bundle Processing Server built with FastAPI and PostgreSQL, deployed on Railway. This server processes FHIR bundles containing patient screening data and provides analytics for healthcare organizations.
Web Interface: https://fhir.sharemy.org/
API Documentation: https://fhir.sharemy.org/docs
Alternative URL: https://hrsnfhir-production.up.railway.app/
- Patient/Member Processing: Extract demographics from FHIR Patient resources
- Member Deduplication: Prevent duplicate members using FHIR ID matching
- Questionnaire Processing: Process QuestionnaireResponse resources for HRSN screenings
- Safety Score Calculation: Automated calculation of safety scores from questions 9-12
- HRSN Category Support: Food insecurity, transportation, housing assessments
- LOINC Code Mapping: Support for standardized medical coding
- PostgreSQL Database: Robust relational database with proper schema
- Member Management: Complete member lifecycle with demographics and assessments
- Screening Sessions: Track multiple screening sessions per member
- Response Storage: Detailed question-answer pairs with scoring
- Data Integrity: Foreign key relationships and validation
- File Upload: Drag & drop or click to select FHIR JSON bundles
- Auto-Processing: Files process automatically upon upload
- Real-time Processing: Live feedback during bundle processing
- Results Display: Structured display of processed data with clean card-based design
- Member Browser: View and search members with assessment history
- Assessment Details: Click-through navigation to individual assessment responses
- CSV Export: Download member data for analysis
- Demo Site Warning: Clear PHI protection messaging for demonstration use
- Responsive Design: Works on desktop and mobile devices
- OpenAPI Documentation: Complete API documentation with Swagger UI
- Authentication: API key-based security for protected endpoints
- Member Endpoints: CRUD operations for member data
- FHIR Endpoints: Standards-compliant FHIR bundle submission
- Health Monitoring: System health and status endpoints
-
Visit the Application: Go to https://fhir.sharemy.org/
-
Upload FHIR Bundle:
- Drag and drop a FHIR JSON file onto the upload area, or
- Click "Choose File" to select a file from your computer
-
Process Bundle: Click "π Process FHIR Bundle" to submit for processing
-
View Results: Review the processed member data, screenings, and analytics
-
Browse Members: Use the members interface to view individual member details and assessment history
All protected endpoints require an API key in the Authorization header:
Authorization: Bearer MookieWilsoncurl -X POST "https://fhir.sharemy.org/fhir/Bundle" \
-H "Authorization: Bearer MookieWilson" \
-H "Content-Type: application/json" \
-d @your-fhir-bundle.jsoncurl -X GET "https://fhir.sharemy.org/members" \
-H "Authorization: Bearer MookieWilson"curl -X GET "https://fhir.sharemy.org/members/{member_id}" \
-H "Authorization: Bearer MookieWilson"curl -X GET "https://fhir.sharemy.org/members/export/csv" \
-H "Authorization: Bearer MookieWilson" \
--output members_export.csv| Method | Endpoint | Description |
|---|---|---|
GET |
/ |
Web interface homepage |
GET |
/health |
System health check |
GET |
/docs |
API documentation |
GET |
/members/count |
Get total member count |
POST |
/api/process-bundle |
Process FHIR bundle (web interface) |
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
GET |
/members |
List all members | β |
GET |
/members/{id} |
Get member details | β |
DELETE |
/members/{id} |
Delete member and data | β |
GET |
/members/export/csv |
Export members to CSV | β |
GET |
/assessments/{id} |
Get assessment details | β |
POST |
/fhir/Bundle |
Submit FHIR bundle | β |
- Backend: FastAPI (Python)
- Database: PostgreSQL
- Deployment: Railway
- ORM: SQLAlchemy
- Authentication: API Key with HTTPBearer
- Documentation: OpenAPI/Swagger
members (
id UUID PRIMARY KEY,
fhir_id VARCHAR(64) UNIQUE,
mrn VARCHAR(50),
first_name VARCHAR(100),
last_name VARCHAR(100),
date_of_birth TIMESTAMP,
gender VARCHAR(20),
address VARCHAR(500),
address_line1 VARCHAR(200),
city VARCHAR(100),
state VARCHAR(2),
zip_code VARCHAR(10),
phone VARCHAR(20),
created_at TIMESTAMP
)screening_sessions (
id UUID PRIMARY KEY,
member_id UUID FOREIGN KEY,
bundle_id VARCHAR(64),
fhir_questionnaire_response_id VARCHAR(64),
screening_date TIMESTAMP,
consent_given BOOLEAN,
screening_complete BOOLEAN,
total_safety_score INTEGER,
positive_screens_count INTEGER,
questions_answered INTEGER,
created_at TIMESTAMP
)screening_responses (
id UUID PRIMARY KEY,
screening_session_id UUID FOREIGN KEY,
question_code VARCHAR(20),
question_text VARCHAR(500),
answer_code VARCHAR(20),
answer_text VARCHAR(200),
sdoh_category VARCHAR(50),
positive_screen BOOLEAN,
data_absent_reason VARCHAR(50),
created_at TIMESTAMP
)- Extraction: Demographics, contact information, identifiers
- Deduplication: Automatic detection and prevention of duplicate members
- Validation: FHIR ID requirements and structure validation
- Question Processing: Support for LOINC-coded questions
- Answer Types: valueCoding, valueString, valueBoolean, valueInteger
- Safety Scoring: Automated calculation for questions 9-12
- Category Mapping: HRSN categories (food, housing, transportation, safety)
- 95618-5: Physical hurt frequency
- 95617-7: Insult/talk down frequency
- 95616-9: Threat frequency
- 95615-1: Scream/curse frequency
Scoring Scale: Never (1) β Rarely (2) β Sometimes (3) β Fairly Often (4) β Frequently (5)
- 88122-7: Food worry (12 months)
- 88123-5: Food didn't last (12 months)
- 93030-5: Transportation barriers
- Bundle Validation: Verify FHIR Bundle structure and required fields
- Resource Extraction: Parse Patient and QuestionnaireResponse resources
- Member Processing: Create or update member records with deduplication
- Screening Processing: Create screening sessions and individual responses
- Score Calculation: Calculate safety scores and positive screen counts
- Database Storage: Persist all processed data with relationships
- Response Generation: Return processing results and analytics
The application is deployed on Railway with:
- PostgreSQL Database: Managed database service
- Automatic Deployments: Connected to GitHub for CI/CD
- Environment Variables: Secure configuration management
- Custom Domain: Production-ready URL
| Variable | Description | Required |
|---|---|---|
DATABASE_URL |
PostgreSQL connection string | β |
DEFAULT_API_KEY |
API authentication key | β |
PORT |
Application port (auto-set by Railway) | β |
- API Key Authentication: HTTPBearer token-based authentication
- Protected Endpoints: Member data and FHIR submission require authentication
- Public Endpoints: Health check and documentation remain open
- Database Security: PostgreSQL with connection encryption
- Input Validation: Comprehensive FHIR bundle validation
- Error Handling: Secure error responses without data leakage
- Member Count: Total registered members
- Age Demographics: Age distribution analysis
- Geographic Distribution: ZIP code mapping
- Assessment History: Complete screening timeline per member
- Safety Scores: Risk assessment scoring (0-20 scale)
- High-Risk Identification: Members with safety scores β₯11
- Positive Screens: Count of unmet social needs
- Completion Rates: Question response completion tracking
- Food Insecurity: Identification and prevalence
- Housing Issues: Housing instability and inadequate housing
- Transportation Barriers: Transportation-related access issues
- Safety Concerns: Interpersonal violence and safety risks
-
Clone Repository:
git clone https://github.com/jacobmr/hrsnfhir.git cd hrsnfhir -
Install Dependencies:
pip install -r requirements.txt
-
Set Environment Variables:
export DATABASE_URL="postgresql://user:password@localhost:5432/hrsn_db" export DEFAULT_API_KEY="your-api-key"
-
Run Application:
uvicorn simple_main:app --host 0.0.0.0 --port 8000 --reload
βββ simple_main.py # Main application file
βββ app/
β βββ static/
β β βββ index.html # Web interface
β β βββ members.html # Members browser
β β βββ member.html # Individual member view
β βββ models.py # Database models (legacy)
β βββ schemas.py # Pydantic schemas (legacy)
β βββ config.py # Configuration (legacy)
βββ requirements.txt # Python dependencies
βββ Dockerfile # Container configuration
βββ README.md # This file
- Connection Pooling: SQLAlchemy connection management
- Query Optimization: Efficient member and screening queries
- Index Strategy: Primary keys and foreign key indexes
- Async Processing: FastAPI async/await support
- Response Caching: Efficient data serialization
- Error Handling: Graceful error responses
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
- Python Style: Follow PEP 8 guidelines
- Type Hints: Use type annotations
- Documentation: Document all functions and classes
- Testing: Include tests for new features
This project is licensed under the MIT License - see the LICENSE file for details.
- API Documentation: Available at
/docsendpoint - Health Monitoring: Use
/healthendpoint for system status
- GitHub Issues: Report bugs and feature requests
- Health Endpoint: Monitor system status and database connectivity
- Repository: https://github.com/jacobmr/hrsnfhir
- Live Application: https://fhir.sharemy.org/
- β Full FHIR bundle processing capability
- β Complete database integration with PostgreSQL
- β Member deduplication and management
- β Safety score calculation and analytics
- β Web interface for file upload and processing
- β REST API with OpenAPI documentation
- β Railway deployment with managed database
- β Authentication and security implementation
Status: Production Ready π
The HRSN FHIR Processing Server is fully operational and ready to process healthcare screening data for health-related social needs assessment and analytics.