---
title: ProtectionNeed
slug: oip-next/otzwst1bpwluzwq8mrg0l
createdAt: 2024-02-21T13:26:17.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   |

## Liste des propriétés

| Nom        | Type        | Dernière version modifiée | Description                                                             | Getter                      | Setter                      | Deprecated |
| ---------- | ----------- | ------------------------- | ----------------------------------------------------------------------- | --------------------------- | --------------------------- | ---------- |
| category   | `String`    | 2.2.0                     | Catégorie (Décès, Invalidité)                                           | getProtectionNeedCategory   | setProtectionNeedCategory   | -          |
| createdAt  | `Date`      |                           | Date de création de l'entité `ProtectionNeed`                           | getProtectionNeedCreatedAt  | Lecture seule               | -          |
| createdBy  | `String`    |                           | Utilisateur à l'origine de la création de l'entité `ProtectionNeed`     | getProtectionNeedCreatedBy  | Lecture seule               | -          |
| guarantee  | `String`    | 2.2.0                     | Garantie (Double accident, Rente d'invalidité permanente, ...)          | getProtectionNeedGuarantee  | setProtectionNeedGuarantee  | -          |
| id         | `String`    |                           | Identifiant unique de l'entité `ProtectionNeed`                         | getProtectionNeedId         | Lecture seule               | -          |
| isSelected | `Boolean`   | 2.2.0                     | Est sélectionné ?                                                       | getProtectionNeedIsSelected | setProtectionNeedIsSelected | -          |
| level      | `levelEnum` | 2.6.0                     | Niveau de la garantie ou du module                                      | getProtectionNeedLevel      | setProtectionNeedLevel      | -          |
| updatedAt  | `Date`      |                           | Date de modification de l'entité `ProtectionNeed`                       | getProtectionNeedUpdatedAt  | Lecture seule               | -          |
| updatedBy  | `String`    |                           | Utilisateur à l'origine de la modification de l'entité `ProtectionNeed` | getProtectionNeedUpdatedBy  | Lecture seule               | -          |

## Enums

### levelEnum

- `levelEnum.ONE`
- `levelEnum.TWO`
- `levelEnum.THREE`
- `levelEnum.FOUR`

## 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, getProtectionNeedGuarantee, getProtectionNeedIsSelected, getProtectionNeedLevel, getprotectionNeedId, setProtectionNeedCategory, setProtectionNeedGuarantee, setProtectionNeedIsSelected, setProtectionNeedLevel } from '@fasstech/oip-core/entities/protectionNeed';
import { levelEnum } from '@fasstech/oip-core/entities/protectionNeed/enums';

(async () => {
  let ProjectEntity = await Entities('Project').get({ id: projectId });
  let CollectionNeedEntity = await Entities('CollectionNeed').create();
  const ProtectionNeedEntity = await Entities('ProtectionNeed').create();
  
  setProtectionNeedCategory('category', ProtectionNeedEntity);
  setProtectionNeedGuarantee('guarantee', ProtectionNeedEntity);
  setProtectionNeedIsSelected(false, ProtectionNeedEntity);
  setProtectionNeedLevel(levelEnum.FOUR, ProtectionNeedEntity);
  
  CollectionNeedEntity = await Entities('ProtectionNeed').save(CollectionNeedEntity, ProtectionNeedEntity);
  ProjectEntity = await Entities('CollectionNeed').save(ProjectEntity, CollectionNeedEntity);
  await Entities('Project').save(ProjectEntity);
  
  const ProjectEntityToTest = await Entities('Project').get({ id: getProjectId(ProjectEntity) });
  const CollectionNeedEntityToTest = await Entities('CollectionNeed').get(ProjectEntityToTest, getCollectionNeedId(CollectionNeedEntity));
  const ProtectionNeedEntityToTest = await Entities('ProtectionNeed').get(CollectionNeedEntityToTest, getProtectionNeedId(ProtectionNeedEntity));
  
  getProtectionNeedCategory(ProtectionNeedEntityToTest); // 'category'
  getProtectionNeedGuarantee(ProtectionNeedEntityToTest); // 'guarantee'
  getProtectionNeedIsSelected(ProtectionNeedEntityToTest); // false
  getProtectionNeedLevel(ProtectionNeedEntityToTest); // levelEnum.FOUR
})();
```
