---
title: "pk80001_LegalNet stored procedure documentation"
summary: "Analysis of Oracle package/procedure including business rules and operations."
status: draft
owner: "SAIF"
last_reviewed: "2026-07-24"
source_schema: "`WCIS_DBA`"
source_name: "pk80001_LegalNet"
source_type: "`Package`"
oracle_status: "found"
library: SAIF.Business
reference_type: package
---

# pk80001_LegalNet

## Overview

| Field | Value |
| --- | --- |
| **Schema** | `WCIS_DBA` |
| **Type** | `Package` |
| **Database** | Oracle |
| **Calling libraries** | `SAIF.Business` |
| **Calling classes** | `ImageServices` |

## Purpose

Legal-alert package that determines whether a claim has at least one legal case flagged for image alerts.

## Procedures / Methods

### alertlegalcase

| Field | Value |
| --- | --- |
| **Returns** | The procedure returns `Y` through `outAlertFlag` when at least one flagged legal case exists; otherwise it returns `N`. |
| **Called by** | `ImageServices.AlertLegalonClaim` |

**Description:** Counts flagged legal cases for a claim and returns a Y/N image-alert flag.

#### Parameters

| Parameter | Direction | Type | Default | Description |
| --- | --- | --- | --- | --- |
| `inClaimId` | IN | NUMBER | — | Claim identifier used by the package. |
| `OutAlertFlag` | OUT | VARCHAR2 | — | Returned Y/N flag indicating whether image alerts are enabled. |

## Business Rules

Rules extracted from this procedure's verified logic:

| Rule ID | Rule | Condition | Action |
| --- | --- | --- | --- |
| [PROC-RULE-004](../business-rules.md#proc-rule-004-claim-image-alerting-is-enabled-only-when-at-least-one-flagged-legal-case-exists-for-the-claim) | Claim image alerting is enabled only when at least one flagged legal case exists for the claim. | `v_cases > 0` after counting `LEGAL_CASE` rows with `claim_image_alerts_flag = 'Y'`. | Set `outAlertFlag` to `Y`; otherwise leave it as `N`. |

> These rules are documented in [business-rules.md](../business-rules.md).

## Operations

Operations and processes implemented in this procedure:

| Operation | Description | Trigger |
| --- | --- | --- |
| OP-004 | Counts legal cases for the claim where image alerts are enabled. | `ImageServices.AlertLegalonClaim` invokes the procedure. |

> These operations are also listed in [operations-processes.md](../operations-processes.md).

## Source Code

<details>
<summary>PL/SQL package specification</summary>

```sql
PROCEDURE alertlegalcase(inClaimId IN NUMBER, OutAlertFlag OUT VARCHAR2 ) ;
```

</details>

<details>
<summary>PL/SQL package/procedure body</summary>

```sql
PROCEDURE alertlegalcase(
   inClaimId   IN   NUMBER
, outAlertFlag OUT VARCHAR2)

IS
   v_cases    NUMBER      := 0;
   v_return   VARCHAR2(1) := 'N';

   CURSOR check_legal_cases
   IS
      SELECT COUNT(*)
        FROM LEGAL_CASE lc
       WHERE lc.claim_image_alerts_flag = 'Y'
         AND lc.claim_id = inClaimId;
BEGIN
   IF NOT check_legal_cases%ISOPEN THEN
      OPEN check_legal_cases;
   END IF;

   FETCH check_legal_cases
    INTO v_cases;

   IF check_legal_cases%FOUND THEN
      IF v_cases > 0 THEN
         v_return                   := 'Y';
      END IF;
   END IF;

   IF check_legal_cases%ISOPEN THEN
      CLOSE check_legal_cases;
   END IF;

   outAlertFlag := v_return;
END alertlegalcase;
```

</details>

## Related Documentation
- [Procedure catalog](index.md)
- [Business rules](../business-rules.md)
- [Operations and processes](../operations-processes.md)
- [SQL catalog](../sql/index.md)

## Sources
- `Business\SAIF.Business\ImageServices.vb`
