Skip to content

BillMappingHelper

Static AutoMapper configuration class that registers every mapping between the legal-bill EF data models (SAIF.Data.Model.Legal.Bills, SAIF.Data.Model.Legal.Notes) and their contract equivalents (SAIF.Core.Contracts.Legal.Bills, SAIF.Core.Contracts.Legal.Notes), including code-table lookups, payment-authority limits, financial transactions, and the composite InboxItem/LegalBillReview/PaymentLetterReport view models consumed by BillService, BillPaymentService, and related legal-bill services.

Purpose

  • Registers AutoMapper maps for legal-bill code tables (adjustment reasons, bill statuses, bill service codes, rate types, note categories, special handling, authority business-process/payment/approval codes).
  • Registers AutoMapper maps for supporting authority/financial-transaction tables, including custom field resolution for payee type and business-process code.
  • Registers the primary domain-to-contract maps for LegalBill, LegalBillService, LegalCase, LegalNote, InboxItem, LegalBillReview, and PaymentLetterReport, including bulk-claim-data merges and mail-merge/currency-formatted report fields.
  • Provides a single entry point (MapBillService) that runs all three mapping groups once, invoked from static constructors of the bill-related services.

Context

  • Namespace: SAIF.Services.Legal.Bills
  • Assembly/package: SAIF.Services (packaged inside the SAIF.SAIFCode.Core NuGet package).

Public members

Member Signature Purpose
MapCodeTables public static void MapCodeTables() Registers AutoMapper maps for bill-related code tables (adjustment reason, bill status, bill service, rate type, note category, special handling, authority business-process/payment-type/approval-type codes), including a computed LongDescription (Code - Description) for BillServiceCode.
MapSupportingTables public static void MapSupportingTables() Registers maps for EmployeeAuthorityLimit → PaymentAuthorityLimit (remapping maximum-amount and authorized-by fields and rebuilding the nested business-process code after mapping) and FinancialTransaction, including a payee-type null-safe projection and an empty Details collection.
MapTables public static void MapTables() Registers the primary domain-to-contract maps: LegalBillService, LegalNote (falling back to create date/user when update fields are null), LegalCase, LegalBill → LegalBill/InboxItem/LegalBillReview (deriving case number from the first non-null jurisdiction number and building ProviderData from billing/rendering provider), BulkClaimData merges into LegalBill/InboxItem/LegalBillReview (falling back to claim number when case number is blank), BillServiceFee, and LegalBillService/InjuryClaim → PaymentLetterReport (formatting currency amounts and mail-merge text, conditioned on non-null source values).
MapBillService public static void MapBillService() Runs MapCodeTables, MapSupportingTables, and MapTables in sequence; this is the single entry point called once per process from the static constructors of BillService and BillPaymentService.

Behavioral notes

  • All maps are registered against the static AutoMapper Mapper configuration; calling any of these methods more than once for the same map pair would throw at runtime, so callers rely on being invoked from a type's static constructor to guarantee once-per-process execution.*
  • The LegalBillService→PaymentLetterReport map formats billed/paid amounts as quoted currency strings and derives MailMergeText from either the adjustment reason's free-form text or its configured mail-merge text.
  • The class carries CA1506:AvoidExcessiveClassCoupling, CA1505:AvoidUnmaintainableCode, and CA1502:AvoidExcessiveComplexity suppressions on MapCodeTables/MapTables, reflecting the large number of type pairs and conditional mapping expressions registered.*

Constraints and usage notes

  • Intended to be called once per application domain; repeated calls are not guarded against duplicate-map registration.*

Note: Statements marked with * were inferred from code structure, naming conventions, or contextual evidence where direct confirmation was not available in source artifacts. Statements marked with ** could not be confirmed; treat as unknown until verified.

Sources

  • Services/SAIF.Services/Legal/Bills/BillMappingHelper.cs