PHFrame will be an open-source framework for building public-health data systems, surveillance platforms, registries, dashboards, and AI-assisted reporting tools.
It should offer the extensibility of a backend framework and the reusable interface model of a frontend framework without requiring application developers to use Django or React directly. PHFrame will expose its own public APIs, conventions, component system, and development workflow while relying on stable lower-level standards and libraries.
The framework's main differentiator will be built-in understanding of public-health data, including indicators, reporting periods, organisation units, surveillance, data-quality rules, privacy, and interoperability.
- Framework name: PHFrame
- CLI command:
phframe - Repository:
public-health-framework - Initial specialization: Disease surveillance
- Long-term scope: Configurable public-health information systems
The intended developer experience is:
pip install phframe
phframe new malaria-surveillance
cd malaria-surveillance
phframe serve- Public-health workflows come before generic framework features.
- Developers should be able to extend every major subsystem.
- Verified calculations must remain deterministic and testable.
- AI assists professionals but does not make autonomous clinical decisions.
- Privacy, security, auditability, accessibility, and localization are core requirements.
- Local development should work with SQLite and minimal configuration.
- Production deployments should support PostgreSQL and background workers.
- Offline and low-bandwidth environments must be considered in architectural decisions.
- PHFrame will use proven protocols and low-level libraries instead of recreating database drivers, cryptography, or HTTP servers.
- A real surveillance application will guide framework development.
┌───────────────────────────────────────────┐
│ Public-health applications │
│ Surveillance · Registries · Dashboards │
├───────────────────────────────────────────┤
│ PHFrame UI │
│ Forms · Tables · Charts · Maps · Filters │
├───────────────────────────────────────────┤
│ Public-health engine │
│ Indicators · Validation · Aggregation │
├───────────────────────────────────────────┤
│ Backend framework │
│ Models · APIs · Auth · Jobs · Plugins │
├───────────────────────────────────────────┤
│ Data and integration layer │
│ Excel · DHIS2 · Kobo · FHIR · Databases │
└───────────────────────────────────────────┘
- Python as the primary framework language
- ASGI as the server protocol
- SQLite for development and small deployments
- PostgreSQL for production deployments
- SQLAlchemy or a thin PHFrame persistence abstraction
- Background jobs for imports, synchronization, reports, and AI processing
- OpenAPI-compatible HTTP APIs
Users will program against PHFrame concepts rather than Django concepts:
from phframe import Application, Dataset, Indicator
app = Application("Malaria Surveillance")
cases = Dataset(
name="malaria_cases",
fields={
"district": "location",
"report_date": "date",
"confirmed_cases": "integer",
"population": "integer",
},
)
incidence = Indicator(
name="Malaria incidence",
numerator="confirmed_cases",
denominator="population",
multiplier=100_000,
)
app.register(cases)
app.register(incidence)- TypeScript for maintainable browser code
- Standards-based Custom Elements and Web Components
- HTML and CSS design tokens
- No React requirement
- Reusable public-health components
- Server-provided metadata and dashboard definitions
- Progressive enhancement for low-bandwidth environments
Example component API:
<ph-kpi indicator="malaria-incidence" period="2026-Q1"></ph-kpi>
<ph-epi-curve
dataset="malaria-cases"
date-field="onset_date">
</ph-epi-curve>
<ph-map boundary="district" indicator="confirmed-cases"></ph-map>Responsibilities:
- Project creation and discovery
- Configuration and environment handling
- Development and production modes
- Application lifecycle
- Plugin registration
- Routing
- Logging
- Error handling
- Database migrations
- Deployment configuration
Planned commands:
phframe new <project-name>
phframe serve
phframe migrate
phframe import <source>
phframe check
phframe test
phframe buildPHFrame will provide health-specific field types and metadata:
- Patient or case identifier
- Protected personally identifiable information
- Disease and diagnosis codes
- Organisation units
- Administrative locations
- Health facilities
- Geographic points and boundaries
- Age and age groups
- Sex and gender
- Epidemiological week
- Reporting period
- Case classification
- Laboratory result
- Numerator and denominator
- Program targets
Example:
class CaseRecord(Model):
patient_id = Identifier(protected=True)
disease = DiseaseCode(required=True)
onset_date = Date()
facility = OrganisationUnit()
location = GeoPoint()
status = Choice(["suspected", "probable", "confirmed"])PHFrame should generate and support:
- Create, read, update, and delete APIs
- Validation
- Filtering and pagination
- Aggregate queries
- Indicator results
- Metadata discovery
- Import and export operations
- API documentation
- Versioned APIs
- Extension hooks
Public-health deployments commonly require hierarchical access. PHFrame should support:
- User accounts and secure sessions
- Role-based permissions
- Organisation-unit-based permissions
- National, regional, district, and facility scopes
- Field-level protection
- Data de-identification
- Approval workflows
- Audit logs
- Data-retention policies
- Single sign-on extensions
Background processing will handle:
- Large file imports
- Scheduled DHIS2 synchronization
- KoboToolbox and ODK synchronization
- Report generation
- Notifications
- Data-quality evaluation
- Outbreak detection
- AI-assisted analysis
The initial UI library should include:
- Application shell
- Navigation and routing
- KPI card
- Indicator chart
- Epidemiological curve
- Choropleth map
- Case line list
- Pivot table
- Date and reporting-period filters
- Organisation-unit selector
- Data-quality panel
- Alert panel
- Import wizard
- Metadata-driven form builder
- Accessible modal, notification, and confirmation components
The indicator engine is a central PHFrame capability. It should support:
- Counts
- Sums and averages
- Rates
- Ratios
- Percentages
- Coverage
- Positivity rates
- Incidence and prevalence
- Mortality rates
- Case-fatality rates
- Dropout rates
- Cumulative totals
- Moving averages
- Target achievement
- Disaggregation by location, time, age, sex, and other dimensions
Indicators should be definable in Python or configuration:
indicators:
malaria_incidence:
label: Malaria incidence
numerator: confirmed_cases
denominator: population
multiplier: 100000
dimensions:
- district
- reporting_periodThe engine should evaluate:
- Completeness
- Timeliness
- Internal consistency
- Duplicate records
- Outliers
- Impossible values
- Numerators exceeding denominators
- Missing organisation units
- Invalid geographic codes
- Reporting gaps
- Cross-field rules
Example rules:
rules:
- field: onset_date
must_be_before: notification_date
- expression: confirmed_cases <= tested
message: Confirmed cases cannot exceed tested casesSurveillance-specific capabilities should include:
- Epidemiological weeks and periods
- Case definitions
- Case line lists
- Epidemic curves
- Alert thresholds
- Outbreak alerts
- Contact-tracing data models
- Outbreak investigations
- Geographic clustering
- Weekly surveillance bulletins
Connectors will use a stable extension interface:
class KoboConnector(Connector):
def extract(self): ...
def transform(self): ...
def synchronize(self): ...Integration priorities:
- CSV and Excel
- SQLite and PostgreSQL
- KoboToolbox and ODK
- DHIS2
- Geographic boundary files
- FHIR
- OpenMRS
- Laboratory information systems
- Messaging and notification services
Connectors should support saved mappings, repeatable synchronization, error reports, and synchronization history.
AI will be optional, provider-independent, and protected by an explicit privacy layer.
- Suggest column mappings during imports
- Explain data-quality problems
- Recommend visualizations
- Generate dashboard descriptions
- Summarize weekly surveillance changes
- Draft situation reports and bulletins
- Generate indicator definitions from plain language
- Help developers create validation rules
- Answer authorized questions about aggregated datasets
- Explain unusual changes and anomalies with supporting evidence
Example command:
phframe ask "Which districts had an unusual increase in dengue this month?"app.ai.configure(
provider="openai",
model="configured-by-deployment",
protected_fields=["patient_name", "phone"],
)The abstraction should allow cloud and locally hosted models.
- Remove or mask personally identifiable information before external requests.
- Require authorization before accessing sensitive data.
- Record prompts, outputs, models, and relevant configuration.
- Provide evidence for generated conclusions.
- Display uncertainty and limitations.
- Require human approval for reports and alerts.
- Support local model deployment.
- Never make autonomous diagnoses or treatment decisions.
- Never use AI-generated values in place of deterministic indicator calculations.
Plugins will allow health programs and implementers to extend PHFrame without modifying its core.
Proposed plugin structure:
phframe-malaria/
├── phframe_plugin.toml
├── models/
├── indicators/
├── dashboards/
├── components/
├── translations/
└── tests/
Potential official plugins:
phframe-malariaphframe-denguephframe-immunizationphframe-nutritionphframe-maternal-healthphframe-outbreakphframe-dhis2phframe-kobophframe-ai
The project should begin as a monorepo. Subsystems can become separately published packages only after their public interfaces are stable.
public-health-framework/
├── packages/
│ ├── phframe-core/
│ ├── phframe-data/
│ ├── phframe-indicators/
│ ├── phframe-server/
│ ├── phframe-cli/
│ ├── phframe-ui/
│ ├── phframe-maps/
│ └── phframe-ai/
├── connectors/
│ ├── excel/
│ ├── kobo/
│ └── dhis2/
├── examples/
│ ├── malaria-surveillance/
│ └── immunization-dashboard/
├── docs/
└── tests/
The initial implementation may retain a simpler source tree while interfaces are being discovered.
Estimated scope: 6–10 weeks
Deliverables:
phframe newphframe serve- Project configuration
- Dataset schemas
- SQLite and PostgreSQL persistence
- Automatic CRUD API
- Database migrations
- Import framework
- Plugin interface
- Development server
- Logging and structured errors
- Test helpers
Success criterion:
phframe new surveillance
cd surveillance
phframe serveThis starts a customizable application with a persistent database and working APIs.
Estimated scope: 6–8 weeks
Deliverables:
- Indicator definitions
- Aggregation engine
- Epidemiological periods
- Data-quality rules
- Organisation-unit hierarchy
- Saved dimensions and filters
- Surveillance thresholds
- Reusable public-health field types
Success criterion: developers can define a dataset and its indicators without writing custom aggregation endpoints.
Estimated scope: 8–12 weeks
Deliverables:
- Web Component foundation
- Application shell and routing
- Form generator
- Tables and filters
- KPI and chart components
- Epidemiological curve
- Map component
- Dashboard configuration
- Themes and design tokens
- Localization foundation
Success criterion: a complete dashboard can be declared through configuration and extended with custom components.
Estimated scope: 6–10 weeks
Deliverables:
- Improved Excel and CSV import wizard
- Saved import templates
- DHIS2 connector
- KoboToolbox and ODK connector
- Scheduled synchronization
- Import history and error reports
Estimated scope: 6–8 weeks
Deliverables:
- AI provider abstraction
- Privacy and de-identification layer
- Column-mapping assistant
- Data-quality explanations
- Evidence-backed dataset questions
- Surveillance summary generator
- Human approval interface
- Complete audit trail
Deliverables:
- Security review
- Audit logging
- Performance and load testing
- Deployment templates
- Backups and recovery
- Migration strategy
- Documentation website
- Plugin development kit
- Internationalization
- Accessibility testing
- Reference production applications
The framework should initially be developed through one real application rather than disconnected infrastructure.
The first reference application must:
- Define a malaria case-reporting schema.
- Import CSV and Excel data.
- Store records in SQLite.
- Expose validated CRUD and aggregate APIs.
- Display a filterable case line list.
- Calculate incidence and test positivity.
- Generate an epidemiological curve.
- Evaluate data-quality rules.
- Produce an AI-assisted weekly summary.
- Preserve an audit history for imports and AI outputs.
This application will function as:
- A proof of concept
- An integration test
- A documentation example
- A demonstration for public-health organizations
- A basis for discovering stable framework APIs
The current version creates a one-time HTML dashboard. Version 0.2 should introduce a persistent, customizable application.
- Rename and stabilize the
phframeCLI - Add
phframe new <project-name> - Generate a standard project structure
- Add project configuration
- Add
phframe serve - Provide an ASGI application
- Store imported records in SQLite
- Define datasets through Python or YAML
- Generate basic CRUD APIs
- Preserve the current HTML dashboard as an export feature
- Add framework-level unit and integration tests
- A complete React-like rendering engine
- All health-program plugins
- Full DHIS2 synchronization
- Clinical decision support
- Automatic diagnosis
- Advanced forecasting
- Multi-tenant enterprise deployment
| Milestone | Outcome |
|---|---|
| 0.1 | CSV/Excel to portable HTML dashboard |
| 0.2 | Create and run a persistent PHFrame application |
| 0.3 | Dataset schemas, CRUD APIs, and database migrations |
| 0.4 | Indicators, reporting periods, and data-quality rules |
| 0.5 | Web Component application shell and dashboard UI |
| 0.6 | Organisation units, maps, and surveillance functions |
| 0.7 | Saved imports and Kobo/DHIS2 connectors |
| 0.8 | Privacy-aware AI assistance |
| 0.9 | Plugin SDK, security hardening, and deployment tools |
| 1.0 | Stable public APIs and production-ready reference application |
PHFrame should be considered successful when:
- A developer can create a working surveillance application in less than one hour.
- A public-health specialist can define common indicators without programming.
- Monthly imports can reuse saved mappings and validation rules.
- Applications work in low-bandwidth environments.
- Sensitive information remains protected and auditable.
- AI-generated summaries cite the underlying aggregates and require review.
- Health-program functionality can be installed as plugins.
- Reference applications are deployable by small public-health teams.
The next engineering priority is PHFrame 0.2: create and run a customizable malaria surveillance application with a persistent backend, API, and development server.
New features should be accepted when they strengthen this vertical slice or establish a clearly required framework interface. Features unrelated to the reference application should wait until the foundation is stable.