Interop Service — Testing Strategy
Status: populated Owner: TBD Last updated: 2026-04-18 Companion: Service Template · 03 platform-services · 02 DDD
1. Coverage Targets
| Layer | Target |
|---|---|
| Unit | ≥ 80% statement coverage |
| Integration | All use cases and message types covered |
| Contract | All FHIR interactions (FHIR conformance); management API (Pact) |
| E2E | ADT inbound → Patient updated; ORM outbound; ORU inbound; bulk export round-trip |
2. Mandatory Tests
| Test file | Coverage |
|---|---|
test/integration/tenant-isolation.spec.ts | Cross-tenant FHIR access blocked; HL7 messages scoped |
test/integration/outbox.spec.ts | HL7 processing events published to NATS |
test/integration/inbox.spec.ts | Outbound HL7 trigger from NATS event |
3. Unit Test Scenarios
| Module | Scenarios |
|---|---|
Hl7Parser | ADT A01/A03/A08/A40; ORM O01; ORU R01; VXU V04; malformed MSH |
AdtMapper | A01 → Patient + Encounter FHIR create; A08 → update; A03 → discharge; A40 → merge |
OruMapper | ORU^R01 → Observation + DiagnosticReport FHIR |
OrmMapper | ServiceRequest → ORM^O01 HL7 |
FhirRouter | Route by resource type + category; fan-out merge; routing rule priority |
ProfileValidator | US Core 6.1 required field validation; AFG-Core extension validation |
BulkExportWorker | Export lifecycle state machine; partial failure handling |
Hl7MessageDeduplicator | Same message control ID → idempotent |
4. Integration Test Scenarios
| Scenario | Description |
|---|---|
| ADT A01 inbound | Receive ADT^A01 MLLP; assert Patient + Encounter created; event published |
| ORU R01 inbound → lab result | Receive ORU^R01; assert Observation posted to laboratory-service |
| ORM outbound from order event | Consume clinical.orders.placed; assert ORM^O01 sent to connector |
| VXU V04 inbound | Receive VXU^V04; assert Immunization created via immunizations-service |
| Duplicate message control ID | Same ORU twice; assert second is deduplicated |
| FHIR read routing | GET /fhir/R4/Observation?category=laboratory routed to laboratory-service |
| FHIR fan-out search | GET /fhir/R4/Observation?patient=... (no category) → fan-out to all Observation owners |
| ABAC denial | External client without patient access → 403 OperationOutcome |
| Bulk $export round-trip | Initiate export; poll; download NDJSON; assert resource count |
| Owning service unavailable | Target returns 503 → gateway returns 503 OperationOutcome |
| Profile validation failure | Resource missing required field → 422 OperationOutcome |
5. Contract Tests
| Contract | Type |
|---|---|
GET /fhir/R4/metadata | FHIR CapabilityStatement conformance |
GET /fhir/R4/Patient/{id} | Pact provider + FHIR conformance |
GET /fhir/R4/Observation | Pact provider |
interop.hl7v2.adt.received schema | JSON schema — registration-service consumer |
interop.hl7v2.oru.received schema | JSON schema — laboratory-service consumer |
6. E2E Scenarios
| Scenario | Priority |
|---|---|
| External FHIR client reads patient data | P0 |
| ADT A01 triggers patient registration update | P0 |
| ORU^R01 results appear in clinician chart | P0 |
| Bulk export produces valid NDJSON for all resource types | P1 |
| ABAC-scoped portal FHIR reads return only permitted data | P1 |