Skip to content

BillMappingHelper

Centralizes the AutoMapper Mapper.CreateMap wiring shared by the bill-entry, bill-diagnosis, bill-query, and note services, so each service's static constructor can call a single method to register the object-to-object mappings it depends on rather than duplicating mapping configuration. Individual methods configure mappings for a specific data-model-to-contract pair (or a group of related pairs), several using ForMember/ResolveUsing/AfterMap to compute derived contract fields (for example worker display name, provider address fields, and confidentiality flags) from navigation properties on the EF data model.

Purpose

  • Registers AutoMapper mappings between SAIF.Data.Model entity types (bill, diagnosis, procedure, audit, note, condition, provider, code-table types) and their corresponding SAIF.Core.Contracts types, so calling services can use Mapper.Map without redefining the mapping rules.
  • Groups mapping registration into per-consumer entry points (MapBillService, MapBillQueryService, MapNoteService, MapForInboxQuery, MapForSearchQuery, MapForBillHeader, MapAuthorizationService) so each service registers only the mappings relevant to its own operations.
  • Computes several derived contract fields during mapping (formatted worker names, active physical/payment address fields, conflict-of-interest flags, resolved code descriptions) that are not simple property copies.

Context

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

Public members

Member Signature Purpose
MapCodeTables public static void MapCodeTables() Configures mappings between bill/note code-table entities (CbpBillStatusCode, CbpNoteCategoryCode, CbpNoteTypeCode, SpecialHandlingCode, CbpPrescribingProviderCode) and their contract equivalents, including reverse mappings for note category/type codes.
MapTables public static void MapTables() Configures mappings for the core bill aggregate and its child entities — CbpBillDiagnosis↔BillDiagnosis, CbpBillProcedure→BillProcedure, CbpAuditedService→AuditedService, CbpBillStatus→BillStatusItem, CbpNote↔Note/AuditNoteItem, ConditionCompensabilityDecision→Conditions, provider location, CbpBill↔Bill (with derived provider address/name fields via AfterMap), and CbpBillService↔BillService — plus CbpBill→BillEntryInboxItem with derived worker name, bill age, and conflict flag.
MapBillQueryService public static void MapBillQueryService() Registers the combined mapping set (MapCodeTables, MapTables, MapForInboxQuery, MapForSearchQuery) needed by bill query/search consumers.
MapBillService public static void MapBillService() Registers the mapping set (MapCodeTables, MapTables) needed by core bill and bill-diagnosis/bill-entry services.
MapNoteService public static void MapNoteService() Registers the mapping set (MapCodeTables, MapTables) needed by note-related services.
MapForInboxQuery public static void MapForInboxQuery() Configures CbpBill→InboxItem and BulkClaimData→InboxItem mappings, deriving bill age, allowed/charged amounts from the latest audit, provider name, formatted worker name, and conflict-of-interest flag.
MapForSearchQuery public static void MapForSearchQuery() Configures CbpBill→SearchResultItem and BulkClaimData→SearchResultItem mappings, deriving formatted worker name, allowed amount from the latest audit (guarding against a missing audit), and conflict-of-interest flag.
MapForBillHeader public static void MapForBillHeader() Configures the CbpBill→BillHeader mapping used for bill header display, deriving current status description, provider name/TIN/location, claim number, formatted worker name, and claim status description.
MapAuthorizationService public static void MapAuthorizationService() Configures the CbpAuthorization→AuthorizationItem mapping (resolving service type from the service PM group) plus authorization type/service-type/CPT/surgery code-table mappings used by AuthorizationService.

Behavioral notes

  • Every method is a pure configuration routine that calls AutoMapper.Mapper.CreateMap (a static, process-wide registration); none of these methods perform data access or return a value.
  • Because Mapper.CreateMap is global static state, calling the same Map* method more than once per app domain from multiple service static constructors is expected and tolerated by AutoMapper's configuration model.*
  • MapAuthorizationService duplicates the mapping configuration also inlined directly in AuthorizationService's own static constructor; the two are not called from the same code path in the files reviewed.*

Constraints and usage notes

  • Consumers should call the appropriate Map* entry point (not the lower-level MapCodeTables/MapTables directly) from their own static constructor to ensure all mappings their Mapper.Map calls depend on are registered before first use.

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/Claims/Bills/BillMappingHelper.cs