Skip to main content

Registration Service — Testing Strategy

Status: populated Owner: TBD Last updated: 2026-04-17 Companion: Service Template · TESTING_STANDARDS

1. Coverage Targets

LayerTarget
Global line coverage≥ 80%
Critical-path files (MPI, merge, vital status)≥ 90%
Domain layer≥ 95%

2. Test Types

TypeFrameworkLocation
UnitVitesttest/unit/
IntegrationVitest + testcontainers (Postgres)test/integration/
Contract (Pact)Pact.jstest/contract/
E2EPlaywright / Supertesttest/e2e/

3. Mandatory Tests

Test fileWhat it covers
test/integration/tenant-isolation.integration.spec.tsPatient rows never leak across tenants; RLS verified
test/integration/outbox.integration.spec.tsEvents written to outbox in same transaction as patient save
test/integration/inbox.integration.spec.tsConsumed events deduplicated via inbox table

4. Scenario Coverage Matrix

ScenarioTypePriority
Register patient with all fieldsUnit + IntegrationMust
Register with only mandatory fieldsUnitMust
Duplicate detection blocks create (score ≥ 85)Unit + IntegrationMust
Unidentified create bypasses 409 blockUnitMust
Idempotent create replay returns cached 201IntegrationMust
MRN generated correctly per tenantUnitMust
Merge — survivorship rules appliedUnit + IntegrationMust
Merge — source deactivated, identifiers transferredIntegrationMust
Unmerge — source reactivatedUnit + IntegrationShould
Vital status record (deceased)Unit + IntegrationMust
Vital status correction (authorized role)UnitMust
Vital status rejected (unauthorized role)UnitMust
Encounter create and status machine (all transitions)Unit + IntegrationMust
Invalid encounter transition rejectedUnitMust
Optimistic lock conflict on patient updateIntegrationMust
Patient search: minimum-necessary criteria enforcementUnit + IntegrationMust
Break-glass audit metadata includedIntegrationMust
Tenant isolation: cross-tenant patient access blockedIntegration (mandatory)Must
Portrait upload with consentUnit + IntegrationShould
Portrait denied (clinical display = false)UnitShould
Extension schema validationUnitShould
Extension payload rejection on schema failureUnitShould
FHIR Patient read includes deceased mappingUnitMust
FHIR Encounter create maps to internal modelUnitMust
HL7 ADT A01 inbound creates patient (adapter test)IntegrationShould
Provisional patient reconciliation mergeIntegrationShould
Newborn registration with mother linkageUnitShould

5. Contract Tests

ContractConsumerPact provider test
GET /api/v1/patients/:idscheduling-servicepatient-by-id.pact.spec.ts
patient.created event schemaorders-servicepatient-created.schema.spec.ts
patient.merged event schemapatient-chart-servicepatient-merged.schema.spec.ts
FHIR Patient resourceinterop-servicefhir-patient.schema.spec.ts