Maintain provider location¶
clsProviderLocation is the anchor record for a provider's practice location: it stores the business/individual identity, contact numbers, approval and eligibility flags, and its ProviderLocationSeqNum is the foreign key used by nearly every other class in this library. Every successful save or delete also pushes a ContactDto to Contact Manager through clsContactApi.
| Field | Value |
|---|---|
| Operation ID | OP-PRV-03 |
| Trigger | Caller calls NewProviderLocation/GetProviderLocation, edits properties, and calls Save() or Delete() |
| Inputs | ProviderSeqNum, ProviderTypeCode, BusinessFlag, name fields, phone/fax/toll-free numbers, WebSiteAddress, PayeeName, EmailAddr, approval/primary/fraud/ineligibility/activity flags |
| Outputs | Persisted PROVIDER_LOCATION row; Contact Manager ContactDto sync |
| Primary components | clsProviderLocation.Create, BeforeInsert/BeforeUpdate/BeforeDelete, FillContactDto, clsContactApi.AddContact/UpdateContact/RemoveContact |
| Entry point | Business\SAIF.Business.Provider\clsProviderLocation.vb |
Steps¶
- Create a new location.
Create()setsProviderSeqNumfrom the criteria, assigns a newProviderLocationSeqNumviaGetNextSeqNum("PROVIDER_LOCATION_SEQ"), defaultsApprovedUser = "SYSTEM", and stamps the acting user. - Name normalization on entity-type change. Setting
BusinessFlag = "Y"clearsFirstName/MiddleName/LastName; forBusinessFlag = "N", editing any ofFirstName/MiddleName/LastNamerebuildsBusinessNameas"First Middle Last"with collapsed double spaces; theBusinessNameandLastNamesetters also maintain uppercase shadow columns used for search. - Validate before save.
- BR-003:
HasDuplicatePrimaryLocationblocks a save whenPrimaryLocationFlag = "Y"and another primary location already exists for the same provider. - BR-004:
MissingProviderTyperequiresProviderTypeCode. - BR-005:
MissingBusinessNamerequiresBusinessNamewhenBusinessFlag = "Y". - BR-006:
MissingLastNamerequiresLastNamewhenBusinessFlag = "N". ValidPhoneNumber,ValidTollFreePhoneNumber,ValidFax,ValidTollFreeFax: hard errors requiring at least 12 formatted characters when a value is present.CommonBusinessRules.IsValidEmailAddressvalidatesEmailAddrwhen supplied.- Insert.
BeforeInsertwrites provider type, business/individual identity, approval/primary/fraud/ineligibility/activity flags, phone/fax/toll-free numbers,WebSiteAddress,PayeeName,EmailAddr, and audit fields into PROVIDER_LOCATION (SQL-028). FillContactDto()buildsContactDtowithcompanyName/firstName/lastName/isCompanyType,primaryPhone(digits only),fax,providerlocationSeqNumber,specialityType(viaclsProviderUtility.GetSpecialityDescriptionByCode),providerNumber, andtin(viaclsProviderUtility.GetTaxIdByProviderSeqNum).- On a rows-affected value other than
1: add"Insert Failed". - On success:
MarkOld(), then callclsContactApi.AddContact(...).clsContactApi.AddContactsends an HTTP insert to Provider API routeprovider/{providerlocationSeqNumber}with theContactDtobody.- On an API exception: serialize the DTO to JSON, log it via
Logging.clsLogError.CreateError(...), and add anApiInsertError— the database row remains committed; there is no compensating rollback.*
- Update.
BeforeUpdatewrites the same field set to PROVIDER_LOCATION (SQL-076) with concurrency checkWHERE PROVIDER_LOCATION_SEQ_NUM = :ProviderLocationSeqNum AND UPDATE_NUM = :UpdateNum. - On a rows-affected value other than
1: add the DB contention error. - On success: increment
m_ProviderLocationSeqNumlocally,MarkOld(), then callclsContactApi.UpdateContact(...)(routeprovider/{providerlocationSeqNumber}, same DTO); API failures are logged and surfaced asApiUpdateErrorwithout blocking the already-committed DB update. - Delete.
BeforeDeletedeletes the PROVIDER_LOCATION row byProviderLocationSeqNum(SQL-098); the delete statement does not include anUPDATE_NUMconcurrency check. - On a rows-affected value other than
1: add the DB contention error. - On success: call
clsContactApi.RemoveContact(...)(routeprovider/{providerlocationSeqNumber}/remove); API failures are logged and surfaced asApiDeleteError. - The delete path does not run any of the payment/audit/note usage checks that exist elsewhere in the codebase — a commented-out
IsBeingUsedguard suggests protective checks againstHasPayment(CL_FINANCIAL_TRANS),HasAudit(CBP_AUDITED_SERVICE), andHasNote(CBP_NOTE) were planned but are not active.*
Process flow¶
flowchart TD
Start([Caller creates or edits location]) --> Rules{Validation rules pass?}
Rules -->|No| Fail([Broken rules returned])
Rules -->|Yes| Which{Save or Delete?}
Which -->|Save/Insert| Insert[Insert PROVIDER_LOCATION]
Which -->|Save/Update| Update[Update PROVIDER_LOCATION]
Which -->|Delete| Delete[Delete PROVIDER_LOCATION,<br>no in-use check]
Insert --> RowsIns{RowsAffected = 1?}
Update --> RowsUpd{RowsAffected = 1?}
Delete --> RowsDel{RowsAffected = 1?}
RowsIns -->|No| InsErr([Insert Failed])
RowsIns -->|Yes| ApiAdd[Call clsContactApi.AddContact]
RowsUpd -->|No| Contention([DB contention error])
RowsUpd -->|Yes| ApiUpd[Call clsContactApi.UpdateContact]
RowsDel -->|No| Contention
RowsDel -->|Yes| ApiDel[Call clsContactApi.RemoveContact]
ApiAdd --> Done([Contact Manager synced;<br>API failures logged, not blocking])
ApiUpd --> Done
ApiDel --> Done
Failure and edge-case behavior¶
- Deletion has no in-use protection against existing payments, audits, or notes, unlike the analogous relationship-in-use check on
clsProviderRelationship.* - API synchronization failures (insert/update/delete) are logged and surfaced as error messages, but the underlying database change is never rolled back — the location can end up out of sync with Contact Manager.*
- A rows-affected value other than
1is treated uniformly as either an insert failure or DB contention error across insert, update, and delete.
Related documentation¶
Note: Statements marked with
*were inferred from code structure, naming conventions, or contextual evidence where direct confirmation was not available in source artifacts.
Sources¶
Business\SAIF.Business.Provider\clsProviderLocation.vbBusiness\SAIF.Business.Provider\Api\clsContactApi.vbBusiness\SAIF.Business.Provider\clsProviderUtility.vb