---
title: Maintain provider notes
summary: Persists free-text notes attached to provider, provider location, bill, or claim data, requiring a note type and note text.
status: draft
owner: SAIF
last_reviewed: 2026-07-30
library: SAIF.Business.Provider
reference_type: package
operation_id: OP-PRV-12
trigger: Caller creates or retrieves a clsNote, edits properties, and calls Save() or Delete()
---

# Maintain provider notes

`clsNote` maintains a general-purpose note row that can be attached to a provider, provider location, bill, or claim through optional foreign-key fields, categorized by a note type/category code pair.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-PRV-12 |
| **Trigger** | Caller calls `NewCbpNote`/`GetCbpNote`, edits properties, and calls `Save()` or `Delete()` |
| **Inputs** | `ProviderLocationSeqNum` (create-time), `NoteTypeCode`, `NoteCategoryCode`, `ActiveFlag`, optional `BillID`/`ClaimID`/`ProviderSeqNum`/`ProviderLocationSeqNum`, `NoteTxt` |
| **Outputs** | Persisted [CBP_NOTE](../database-tables.md#cbp_note) row |
| **Primary components** | `clsNote.Create`, `BeforeInsert/BeforeUpdate/BeforeDelete` |
| **Entry point** | `Business\SAIF.Business.Provider\clsNote.vb` |

## Steps

1. **Create.** `NewCbpNote(inDataportal, inProviderLocSeqNum)`: if `ProviderLocationSeqNum > 0`, `Create()` assigns a new seq num via `GetNextSeqNum("CBP_NOTE_SEQ")`; otherwise it uses the criteria's note seq num directly. `m_CreateUser`/`m_CreateDate` are stamped, but the provider location seq num itself is **not** copied onto the object during create — it must be set explicitly before save.*
2. **Retrieve.** Reads [CBP_NOTE](../database-tables.md#cbp_note) joined to `CBP_NOTE_TYPE_CODE` (`NOTE_TYPE_CODE = CODE` and `NOTE_CATEGORY_CODE = CBP_NOTE_CATEGORY_CODE`) by `CBP_NOTE_SEQ_NUM` ([SQL-041](../sql/SQL-041-retrieve-note.md)), also reading `PROVIDER_CONTACT_NOTE_FLAG AS ContactNoteFlag` to derive `IsContactNote`.
3. **Validate before save** ([BR-015](../business-rules.md#br-015-notes-require-both-type-and-text)):
   - `CommonBusinessRules.TextRequired` on `NoteTypeCode`: `"Error: Missing Type."`
   - `CommonBusinessRules.TextRequired` on `NoteTxt`: `"Error: Missing note."`
4. **Insert.** Writes `CBP_NOTE_SEQ_NUM`, `NOTE_TYPE_CODE`, `NOTE_CATEGORY_CODE`, `ACTIVE_FLAG`, `CREATE_DATE`/`CREATE_USER`, `UPDATE_NUM`, optional `BILL_ID`/`CLAIM_ID`/`PROVIDER_SEQ_NUM`/`PROVIDER_LOCATION_SEQ_NUM`, and `NOTE_TXT` to [CBP_NOTE](../database-tables.md#cbp_note) ([SQL-017](../sql/SQL-017-insert-note.md)).
   - On a rows-affected value other than `1`: add `"Insert Failed"`.
5. **Update.** Writes type/category/active flag, `UPDATE_DATE`/`UPDATE_USER`, `UPDATE_NUM = UPDATE_NUM + 1`, and the optional foreign keys and note text to [CBP_NOTE](../database-tables.md#cbp_note) ([SQL-065](../sql/SQL-065-update-note.md)) with concurrency check `WHERE CBP_NOTE_SEQ_NUM = :CbpNoteSeqNum AND UPDATE_NUM = :UpdateNum`.
   - On a rows-affected value other than `1`: add the DB contention error; otherwise increment `m_UpdateNum` and `MarkOld()`.
6. **Delete.** Deletes the [CBP_NOTE](../database-tables.md#cbp_note) row by `CBP_NOTE_SEQ_NUM` and `UPDATE_NUM` ([SQL-087](../sql/SQL-087-delete-note.md)).
   - On a rows-affected value other than `1`: add the DB contention error; otherwise `MarkNew()`.

## Process flow

```mermaid
flowchart TD
	Start([Caller edits note]) --> TypeCheck{Note type entered?}
	TypeCheck -->|No| Fail([Missing type<br>or text blocks save])
	TypeCheck -->|Yes| TextCheck{Note text entered?}
	TextCheck -->|No| Fail
	TextCheck -->|Yes| Persist[Insert/update/delete CBP_NOTE]
	Persist --> Rows{RowsAffected = 1?}
	Rows -->|No| Contention([Insert Failed / DB contention error])
	Rows -->|Yes| Done([Save complete])
```

## Failure and edge-case behavior

- `Create()` does not copy the provider location seq num from the criteria onto the note object, so callers creating a location-scoped note must set that field explicitly before save or the association will be lost.*
- `IsContactNote` is entirely derived from the joined `CBP_NOTE_TYPE_CODE.PROVIDER_CONTACT_NOTE_FLAG`, not stored on the note row itself.
- Delete, unlike `clsProviderLocation`'s delete path, does enforce `UPDATE_NUM` concurrency.

## Related documentation

- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)
- [SQL catalog](../sql/index.md)
- [Database tables](../database-tables.md)

> **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\clsNote.vb`
