---
title: ProtectionNeed
slug: oip-next/cvabrtda-xgdydsbvpze
icon: {"lucideIcon":"📘"}
createdAt: 2024-04-08T10:17:29.000Z
---

# ProtectionNeed

## Description

L'entité ProtectionNeed regroupe les critères liés au recueil des besoins d'un parcours `Prévoyance`.

## Relations

### Ascendantes

| Entité         | Propriété       |
| -------------- | --------------- |
| CollectionNeed | protectionNeeds |

### Descendantes

| Entité  | Propriété |
| ------- | --------- |
| History | history   |

## Propriétés

| Nom              | Type                      | Description                                                                              | Validateur | Lecture seule ? | Dépréciée ? | Dernière version modifiée |
| ---------------- | ------------------------- | ---------------------------------------------------------------------------------------- | ---------- | --------------- | ----------- | ------------------------- |
| category         | `String`                  | Catégorie (Décès, Invalidité)                                                            |            |                 |             | 2.2.0                     |
| guarantee        | `String`                  | Garantie (Double accident, Rente d'invalidité permanente, ...)                           |            |                 |             | 2.2.0                     |
| isSelected       | `Boolean`                 | Est sélectionné ?                                                                        |            |                 |             | 2.2.0                     |
| level            | `ProtectionNeedLevelEnum` | Niveau de la garantie ou du module                                                       |            |                 |             | 2.6.0                     |
| id               | `String`                  | Identifiant de l'entité `ProtectionNeed`                                                 |            | X               |             |                           |
| code             | `String`                  | Codification fonctionnelle de l'entité `ProtectionNeed`                                  |            |                 |             |                           |
| externalId       | `String`                  | Identifiant de l'entité `ProtectionNeed` dans le système client                          |            |                 |             |                           |
| externalCode     | `String`                  | Codification fonctionnelle de l'entité `ProtectionNeed` dans le système client           |            |                 |             |                           |
| protectionNeedId | `String`                  | Identifiant public de l'entité `ProtectionNeed` dans l'OIP                               |            |                 |             |                           |
| label            | `String`                  | Information relative au nom de l'entité `ProtectionNeed` dans son contexte d'utilisation |            |                 |             |                           |
| createdAt        | `Date`                    | Date de création de l'entité `ProtectionNeed`                                            |            | X               |             |                           |
| updatedAt        | `Date`                    | Date de modification de l'entité `ProtectionNeed`                                        |            | X               |             |                           |

## Enumérations

### ProtectionNeedLevelEnum

- `ONE`
- `TWO`
- `THREE`
- `FOUR`

## Enumérations génériques

Aucune enumération générique.

## Exemple

```javascript
import { Entities } from '@fasstech/oip-core';
import { getCollectionNeedId } from '@fasstech/oip-core/entities/CollectionNeed';
import { getProjectId } from '@fasstech/oip-core/entities/Project';
import { getProtectionNeedCategory, getProtectionNeedCode, getProtectionNeedExternalCode, getProtectionNeedExternalId, getProtectionNeedGuarantee, getProtectionNeedId, getProtectionNeedIsSelected, getProtectionNeedLabel, getProtectionNeedLevel, getProtectionNeedProtectionNeedId, setProtectionNeedCategory, setProtectionNeedCode, setProtectionNeedExternalCode, setProtectionNeedExternalId, setProtectionNeedGuarantee, setProtectionNeedIsSelected, setProtectionNeedLabel, setProtectionNeedLevel, setProtectionNeedProtectionNeedId } from '@fasstech/oip-core/entities/ProtectionNeed';
import { ProtectionNeedLevelEnum } from '@fasstech/oip-core/entities/ProtectionNeed/enums';

(async () => {
  let project = await Entities('Project').create();
  let collectionNeed = await Entities('CollectionNeed').create();
  const protectionNeed = await Entities('ProtectionNeed').create();
  
  setProtectionNeedCategory('category', protectionNeed);
  setProtectionNeedGuarantee('guarantee', protectionNeed);
  setProtectionNeedIsSelected(false, protectionNeed);
  setProtectionNeedLevel(ProtectionNeedLevelEnum.FOUR, protectionNeed);
  setProtectionNeedCode('code', protectionNeed);
  setProtectionNeedExternalId('externalId', protectionNeed);
  setProtectionNeedExternalCode('externalCode', protectionNeed);
  setProtectionNeedProtectionNeedId('protectionNeedId', protectionNeed);
  setProtectionNeedLabel('label', protectionNeed);
  
  collectionNeed = await Entities('ProtectionNeed').save(collectionNeed, protectionNeed);
  project = await Entities('CollectionNeed').save(project, collectionNeed);
  await Entities('Project').save(project);
  
  const projectToTest = await Entities('Project').get({ id: getProjectId(project) });
  const collectionNeedToTest = await Entities('CollectionNeed').get(projectToTest, { filter: ({ id }) => id === getCollectionNeedId(collectionNeed) });
  const protectionNeedToTest = await Entities('ProtectionNeed').get(collectionNeedToTest, { filter: ({ id }) => id === getProtectionNeedId(protectionNeed) });
  
  getProtectionNeedCategory(protectionNeedToTest); // 'category'
  getProtectionNeedGuarantee(protectionNeedToTest); // 'guarantee'
  getProtectionNeedIsSelected(protectionNeedToTest); // false
  getProtectionNeedLevel(protectionNeedToTest); // ProtectionNeedLevelEnum.FOUR
  getProtectionNeedCode(protectionNeedToTest); // 'code'
  getProtectionNeedExternalId(protectionNeedToTest); // 'externalId'
  getProtectionNeedExternalCode(protectionNeedToTest); // 'externalCode'
  getProtectionNeedProtectionNeedId(protectionNeedToTest); // 'protectionNeedId'
  getProtectionNeedLabel(protectionNeedToTest); // 'label'
})();
```
