Skip to main content

Population Health Service — Testing Strategy

Status: populated Owner: TBD Last updated: 2026-04-18 Companion: Service Template · Testing Standards

1. Coverage Targets

LayerTarget
Domain logic (cohort DSL parser, risk models, QM calculators)≥ 90%
Application use cases≥ 85%
Infrastructure adapters≥ 80%
Overall service≥ 80%

2. Test Layers

2.1 Unit Tests

ScenarioFile
Cohort DSL parser: valid expression treescohort-expression.spec.ts
Cohort DSL parser: rejects invalid operatorscohort-expression.spec.ts
Quality metric: numerator/denominator/exclusion calculationquality-metric-calculator.spec.ts
Quality metric: empty denominator returns null ratequality-metric-calculator.spec.ts
Risk score: tier assignment from computed scorerisk-score.spec.ts
Risk score: override invariants (reason required)risk-score.spec.ts
Outreach FSM: valid transitionsoutreach-item.spec.ts
Outreach FSM: invalid transitions throw domain erroroutreach-item.spec.ts
De-identification: k-threshold validationdeident-config.spec.ts
De-identification: ε ≤ 1.0 enforcementdeident-config.spec.ts
HMIS period overlap: duplicate job detectionhmis-export-job.spec.ts

2.2 Integration Tests (mandatory)

TestFile
Tenant isolation — cohort query never returns rows from another tenanttenant-isolation.integration.spec.ts
Outbox — domain events published after use-case commitoutbox.integration.spec.ts
Inbox — duplicate CloudEvent IDs are deduplicatedinbox.integration.spec.ts
Dashboard query returns aggregate metrics scoped to nodedashboard.integration.spec.ts
Cohort refresh job coalesces duplicate triggerscohort-refresh.integration.spec.ts
HMIS export job retries and reaches terminal failurehmis-export.integration.spec.ts
De-ident export blocked when k-threshold not metdeident-export.integration.spec.ts
Consent check blocks export when secondary use not approvedconsent-enforcement.integration.spec.ts
RLS blocks cross-tenant row access at DB levelrls-enforcement.integration.spec.ts

2.3 Contract Tests

TestFile
OpenAPI contract — dashboard endpointdashboard.pact.spec.ts
OpenAPI contract — cohort CRUDcohorts.pact.spec.ts
Event schema — cohort.refreshed.v1 payload conformancecohort-refreshed.schema.spec.ts
Event schema — hmis_export.completed.v1 payload conformancehmis-export-completed.schema.spec.ts
DHIS2 adapter — mock DHIS2 API contractdhis2-rest.pact.spec.ts

2.4 E2E Tests

ScenarioFile
Analyst creates cohort, triggers refresh, views membership countcohort-lifecycle.e2e.spec.ts
MoPH admin triggers HMIS export; DHIS2 mock confirms receipthmis-export.e2e.spec.ts
Researcher requests de-identified export; receives download URLdeident-export.e2e.spec.ts
Clinician views disease registry, updates outreach item statusoutreach-workflow.e2e.spec.ts

3. Test Data / Seed Requirements

  • Seed 3 tenants: tenant-a (facility A, B), tenant-b (facility C), tenant-platform
  • Seed 10,000 synthetic patient rows per tenant with realistic age/gender/condition distributions
  • Seed pre-computed cohorts and quality metric snapshots for dashboard tests
  • DHIS2 mock server with configurable response (success / 502 failure)

4. Performance Tests

TestThreshold
Dashboard query at 100k patient populationp95 ≤ 2500 ms
Cohort refresh for 50k member cohortCompletes within 60 s
Quality metric snapshot for HEDIS full setCompletes within 120 s
De-identification pipeline for 50k rowsCompletes within 10 min