Skip to main content

Claims Service — Application Logic

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

Command Use Cases

IDUse CaseActorFR References
UC-CLM-C01AssembleClaimbilling-service (system)FR-CLAIMS-001, FR-CLM-001
UC-CLM-C02ScrubAndValidateClaimsystem (pre-submit)FR-CLAIMS-002, FR-CLM-002
UC-CLM-C03SubmitClaimbilling-staff, systemFR-CLAIMS-003, FR-CLM-003
UC-CLM-C04ProcessAcknowledgementsystem (adapter)FR-CLAIMS-004, FR-CLM-004
UC-CLM-C05ProcessRemittancesystem (adapter)FR-CLAIMS-005, FR-CLM-005
UC-CLM-C06FileDenialAppealbilling-staffFR-CLAIMS-006, FR-CLM-006
UC-CLM-C07ResubmitClaimbilling-staffFR-CLAIMS-007, FR-CLM-007
UC-CLM-C08CreateCoverageregistration-staff, systemFR-CLAIMS-008, FR-INS-001
UC-CLM-C09UpdateCoverageregistration-staffFR-CLAIMS-009, FR-INS-002
UC-CLM-C10VerifyEligibilitysystem (pre-visit), billing-staffFR-CLAIMS-010, FR-INS-003
UC-CLM-C11RequestPriorAuthorizationclinician, billing-staffFR-CLAIMS-011, FR-INS-006
UC-CLM-C12RecordAuthorizationDecisionsystem (adapter)FR-CLAIMS-012, FR-INS-007

Query Use Cases

IDUse CaseActorDescription
UC-CLM-Q01GetClaimbilling-staff, billing-serviceFull claim detail with line items and status
UC-CLM-Q02ListClaimsbilling-staffFiltered/paginated list; filter by status, date, patient
UC-CLM-Q03GetCoveragebilling-staff, patient-portalCoverage record with priority and benefit details
UC-CLM-Q04ListPatientCoveragesbilling-staff, patient-portalAll coverages for a patient, ordered by priority
UC-CLM-Q05GetEligibilityResultbilling-staffMost recent eligibility response for a coverage
UC-CLM-Q06GetRemittancebilling-staffERA summary with per-claim allocations
UC-CLM-Q07GetExplanationOfBenefitpatient-portal, billing-staffFHIR EOB for a specific claim
UC-CLM-Q08GetClaimsByEncounterbilling-serviceAll claims for a given encounter

Ports (Interfaces)

PortDirectionDescription
IClaimRepositoryOutboundPersist/load ClaimRecord aggregates
ICoverageRepositoryOutboundPersist/load Coverage aggregates
IEligibilityRepositoryOutboundPersist/load EligibilityTransaction records
IRemittanceRepositoryOutboundPersist/load RemittanceRecord aggregates
IClaimSubmissionAdapterOutboundPluggable: submit claim to payer/clearinghouse
IEligibilityAdapterOutboundPluggable: real-time eligibility inquiry
IAuthorizationAdapterOutboundPluggable: prior auth request/response
ITerminologyPortOutboundICD-10/CPT code validation via terminology-service
IOutboxRepositoryOutboundWrite domain events to transactional outbox
IAuditPortOutboundEmit audit records for PHI mutations
IFhirMapperInternalTranslate internal models ↔ FHIR R4 resources

Key Sequence Diagrams

Claim Assembly and Submission

Remittance Processing

Eligibility Verification

Outbox Pattern

All domain events are written in the same Postgres transaction as the aggregate mutation. A relay worker polls claims_outbox and publishes to NATS JetStream with at-least-once delivery. Consumer idempotency is enforced via the outboxId as CloudEvents id.

claims_outbox table:
id ULID PK
event_type TEXT (e.g. claims.claim.submitted.v1)
payload JSONB
published BOOL DEFAULT false
created_at TIMESTAMPTZ
tenant_id TEXT (for multi-tenant relay filtering)

Error Codes

CodeHTTPMeaning
CLAIM_NOT_FOUND404Claim ID does not exist for tenant
CLAIM_INVALID_STATE409Operation not valid in current claim state
CLAIM_VALIDATION_FAILED422Scrubbing found required field or coding errors
COVERAGE_NOT_FOUND404Coverage ID does not exist for tenant
COVERAGE_INACTIVE422Coverage is expired or cancelled
ELIGIBILITY_EXPIRED422Eligibility result is stale; re-verify required
AUTH_NOT_FOUND404Prior authorization not found
SUBMISSION_FAILED502Clearinghouse/payer submission error
CODING_INVALID422ICD-10 or CPT code failed terminology validation
MODULE_NOT_LICENSED403Tenant does not have ehr.claims entitlement
DUPLICATE_CLAIM409Identical claim already submitted within dedup window
REMITTANCE_ALREADY_APPLIED409ERA has already been processed