AuthorizationService¶
Manages medical authorization records, their surgery dates, and CPT code assignments for a claim, coordinating persistence through IUnitOfWork, current-user attribution through IUserProfileService, and business-rule enforcement through IValidationService. It applies optimistic-concurrency checks via an UpdateNumber comparison before overwriting an existing CbpAuthorization, and reconciles the CPT code set on update by diffing the incoming comma-separated code list against the authorization's current codes, removing stale codes and validating/adding new ones.
Purpose¶
- Creates, updates, and deletes claim authorizations and their associated CPT codes and surgery dates.
- Validates candidate CPT codes against the
CbpServiceCodereference table before allowing them onto an authorization. - Detects concurrent-edit conflicts on authorization updates by comparing
UpdateNumber. - Supplies reference/code-table lookups (authorization type codes, service type codes, and a static "timely" yes/no list) for authorization entry forms.
Context¶
- Namespace:
SAIF.Services.Claims.Bills - Assembly/package:
SAIF.Services(packaged inside theSAIF.SAIFCode.CoreNuGet package)
Public members¶
| Member | Signature | Purpose |
|---|---|---|
| AuthorizationService (constructor) | public AuthorizationService(IUnitOfWork uow, IUserProfileService uprof, IValidationService val) |
Wires the repository unit of work, current-user resolver, and validation service used by all authorization operations; throws if uow is null. |
| GetAuthorizations | public IEnumerable<AuthorizationItem> GetAuthorizations(long claimId) |
Returns every authorization recorded for the given claim, mapped to AuthorizationItem contracts. |
| ValidCptCode | public bool ValidCptCode(string code) |
Returns whether code exists in the service-code table as a service type "M" (medical) code; returns false instead of throwing if the lookup fails. |
| GetSurgeryDates | public IEnumerable<AuthorizationSurgery> GetSurgeryDates(long claimId) |
Returns the surgery dates recorded for the claim's authorizations. |
| AddSurgeryDate | public bool AddSurgeryDate(long claimId, string surgeryDate) |
Adds a new surgery date to the claim unless a matching date already exists for it; always returns true. |
| DeleteSurgeryDate | public bool DeleteSurgeryDate(long claimId, string surgeryDate) |
Removes the matching surgery date record for the claim if one exists; always returns true. |
| GetAuthorizationTypeCodes | public IEnumerable<AuthorizationTypeCode> GetAuthorizationTypeCodes() |
Returns the full authorization type code reference list. |
| GetServiceTypeCodes | public IEnumerable<ServiceTypeCode> GetServiceTypeCodes() |
Returns the full service/PM group type code reference list. |
| GetTimelyTypeCodes | public IEnumerable<TimelyTypeCode> GetTimelyTypeCodes() |
Returns a static two-item Yes/No code list used for the "received timely" flag on authorization forms.* |
| UpdateAuthorization | public bool UpdateAuthorization(long authorizationId, AuthorizationItemEdit authorization, string cptCodes, IMessageContainer messages) |
Applies edits to an existing authorization (type, service group, dates, visit max, billing provider) and reconciles its CPT codes against the supplied comma-separated cptCodes list; rejects the update and returns false if the update numbers no longer match or validation fails, otherwise commits and returns true. |
| CreateAuthorization | public AuthorizationItem CreateAuthorization(AuthorizationItemEdit authorization, long claimId, string cptCode, IMessageContainer messages) |
Creates a new authorization for the claim with the supplied CPT codes, commits it if validation passes, and returns the mapped AuthorizationItem. |
| DeleteAuthorization | public bool DeleteAuthorization(long authorizationId, IMessageContainer messages) |
Deletes the authorization with the given ID and commits the change; always returns true. |
Behavioral notes¶
- A static constructor registers AutoMapper mappings (
CbpAuthorization→AuthorizationItemand related code-table types) once per app domain viaMapper.CreateMap, so mapping failures would surface at first type use rather than per-call. UpdateAuthorizationandCreateAuthorizationboth run the authorization throughIValidationService.Validatebefore committing, adding any validation errors to the suppliedIMessageContainerand aborting the commit on failure.- All mutating operations (
AddSurgeryDate,DeleteSurgeryDate,UpdateAuthorization,CreateAuthorization,DeleteAuthorization) wrap their changes inunitOfWork.Begin()/unitOfWork.Commit()transaction boundaries. ValidCptCodedeliberately swallows all exceptions from the lookup query and treats any failure as an invalid code.*
Constraints and usage notes¶
UpdateAuthorizationsilently rejects the update (returnsfalsewith no message) when the caller'sUpdateNumberdoes not match the persisted record, so callers must reload and retry on conflict.- CPT codes passed to
UpdateAuthorization/CreateAuthorizationmust be a single comma-separated string; codes failingValidCptCodeare silently skipped rather than reported as errors.*
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/AuthorizationService.cs