Skip to main content

Interop Service — Application Logic

Status: populated Owner: TBD Last updated: 2026-04-18 Companion: Service Template · 03 platform-services · 02 DDD


1. Use Cases

Commands

Use caseCommandActor
Register integration connectorRegisterConnectorCommandIntegration admin
Activate / deactivate connectorSetConnectorStatusCommandIntegration admin
Process inbound HL7 v2 messageProcessHl7InboundCommandSystem (MLLP)
Send outbound HL7 v2 messageSendHl7OutboundCommandSystem (NATS event)
Start bulk FHIR exportStartBulkExportCommandAuthorized external client
Import FHIR resources (bulk)StartBulkImportCommandIntegration admin
Update FHIR routing ruleUpdateFhirRoutingRuleCommandPlatform admin
Validate FHIR resource against profileValidateFhirResourceCommandInternal / external

Queries

Use caseQueryReturns
FHIR resource readRouteFhirReadQueryProxied response from owning service
FHIR resource searchRouteFhirSearchQueryProxied / merged results
FHIR CapabilityStatementGetCapabilityStatementQueryConsolidated CapabilityStatement
Bulk export statusGetBulkExportStatusQueryJob status + file URLs
HL7 message logGetHl7MessageLogQueryPaginated message history
Connector listGetConnectorsQueryActive connectors for tenant

2. Orchestration Flows

2.1 FHIR Request Routing

2.2 HL7 v2 Inbound ADT Processing

2.3 HL7 v2 Outbound ORU (Result Export)

2.4 FHIR Bulk Export


3. Ports

PortDirectionAdapter
IMllpServerInboundTCP MLLP listener (node net module with framing)
IFhirServiceRouterOutboundHTTP adapter per owning service; routing table
IHl7MessageRepositoryOutboundDrizzle ORM → PostgreSQL
IBulkStoragePortOutboundMinIO adapter for NDJSON export files
IEventPublisherOutboundNATS JetStream
IAbacPortOutboundaccess-policy-service for FHIR boundary ABAC
IProfileValidatorPortOutboundHAPI FHIR validator or internal schema validator

4. Saga / Outbox Pattern

  • HL7 inbound processing uses an outbox worker: message stored first (ACK sent), then processed asynchronously. This ensures idempotent ACK even if downstream services are temporarily unavailable.
  • Outbound HL7 messages are queued in hl7_messages (outbound=true) and sent by the MLLP client worker. Retry on NACK or timeout with exponential backoff.
  • Bulk export jobs run as background workers; progress tracked in bulk_export_jobs.

5. Error Handling

ScenarioStrategy
FHIR owning service unreachableReturn FHIR OperationOutcome with transient severity; 503 to client
HL7 parse errorStore raw message; mark parse_failed; return AE ACK to sender; alert integration admin
ABAC denial on FHIR readReturn OperationOutcome 403 with security issue code
Bulk export resource service failurePartial export recorded; job status partial; client informed
MLLP connection timeoutRetry 3 times; mark connector degraded; alert
Duplicate HL7 messageCheck (connector_id, message_control_id, sending_app); return AA ACK; skip processing