From 30ae93054b79b4f7b659aa48a05013bcc40fc3be Mon Sep 17 00:00:00 2001
From: Paul Bui-Quang <paul.bui-quang@aphp.fr>
Date: Tue, 14 Jan 2025 15:23:23 +0100
Subject: [PATCH] fix: types and stuff

---
 package-lock.json                             | 96 +++++++++----------
 .../data/cohortCreation/conditionCriteria.ts  |  1 +
 .../data/cohortCreation/documentCriteria.ts   |  1 +
 .../data/cohortCreation/encounterCriteria.ts  |  1 +
 .../data/cohortCreation/medicationCriteria.ts |  1 +
 .../cohortCreation/observationCriteria.ts     |  3 +
 .../data/cohortCreation/procedureCriteria.ts  |  1 +
 .../CreationCohort/DataList_Criteria.tsx      | 22 +----
 .../CriteriaForm/components/index.tsx         |  5 +-
 .../CriteriaRightPanel/CriteriaForm/index.tsx |  9 +-
 .../CriteriaForm/mappers/buildMappers.ts      |  3 +-
 .../mappers/chipDisplayMapper.tsx             | 14 ++-
 .../CriteriaForm/mappers/index.ts             |  4 +-
 .../CriteriaForm/mappers/renderers.tsx        | 17 +++-
 .../CriteriaRightPanel/CriteriaForm/style.ts  |  3 +-
 .../CriteriaRightPanel/CriteriaForm/types.ts  |  7 +-
 .../CriteriaRightPanel/forms/BiologyForm.ts   | 12 ++-
 .../CriteriaRightPanel/forms/CCAMForm.ts      |  8 +-
 .../CriteriaRightPanel/forms/Cim10Form.ts     |  8 +-
 .../forms/DemographicForm.ts                  |  5 -
 .../CriteriaRightPanel/forms/GHMForm.tsx      |  8 +-
 .../CriteriaRightPanel/forms/IPPForm.ts       |  1 -
 .../forms/MedicationForm.ts                   | 10 +-
 src/components/CreationCohort/Requeteur.tsx   |  1 -
 src/components/ui/Collapse/index.tsx          |  1 -
 src/components/ui/Inputs/Occurences/index.tsx |  1 -
 src/hooks/useIsOverflow.ts                    |  2 +-
 src/state/valueSets.ts                        |  6 +-
 src/types.ts                                  |  2 -
 src/utils/cohortCreation.ts                   | 32 +++++--
 30 files changed, 149 insertions(+), 136 deletions(-)

diff --git a/package-lock.json b/package-lock.json
index 086bf92ad..3b4f292c7 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -21,6 +21,7 @@
         "antlr4": "^4.13.1-patch-1",
         "axios": "^1.6.0",
         "buffer": "^6.0.3",
+        "canvas": "^2.11.2",
         "client-oauth2": "^4.2.4",
         "d3": "^7.8.2",
         "d3-cloud": "^1.2.5",
@@ -45,6 +46,7 @@
         "react-router": "^6.9.0",
         "react-router-dom": "^6.9.0",
         "react-use-websocket": "4.8.1",
+        "react-window": "^1.8.10",
         "redux": "^4.2.1",
         "redux-devtools-extension": "^2.13.9",
         "redux-logger": "^3.0.6",
@@ -84,6 +86,7 @@
         "@types/react-redux": "^7.1.25",
         "@types/react-router": "^5.1.20",
         "@types/react-router-dom": "^5.3.3",
+        "@types/react-window": "^1.8.8",
         "@types/redux-logger": "^3.0.9",
         "@types/uuid": "^8.3.4",
         "@typescript-eslint/eslint-plugin": "^5.57.0",
@@ -4950,7 +4953,6 @@
       "resolved": "https://registry.npmjs.org/@mapbox/node-pre-gyp/-/node-pre-gyp-1.0.11.tgz",
       "integrity": "sha512-Yhlar6v9WQgUp/He7BdgzOz8lqMQ8sU+jkCq7Wx8Myc5YFJLbEe7lgui/V7G1qB1DJykHSGwreceSaD60Y0PUQ==",
       "license": "BSD-3-Clause",
-      "optional": true,
       "dependencies": {
         "detect-libc": "^2.0.0",
         "https-proxy-agent": "^5.0.0",
@@ -4971,7 +4973,6 @@
       "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz",
       "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==",
       "license": "MIT",
-      "optional": true,
       "dependencies": {
         "semver": "^6.0.0"
       },
@@ -4987,7 +4988,6 @@
       "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz",
       "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==",
       "license": "ISC",
-      "optional": true,
       "bin": {
         "semver": "bin/semver.js"
       }
@@ -4998,7 +4998,6 @@
       "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==",
       "deprecated": "Rimraf versions prior to v4 are no longer supported",
       "license": "ISC",
-      "optional": true,
       "dependencies": {
         "glob": "^7.1.3"
       },
@@ -7984,6 +7983,15 @@
         "@types/react": "*"
       }
     },
+    "node_modules/@types/react-window": {
+      "version": "1.8.8",
+      "resolved": "https://registry.npmjs.org/@types/react-window/-/react-window-1.8.8.tgz",
+      "integrity": "sha512-8Ls660bHR1AUA2kuRvVG9D/4XpRC6wjAaPT9dil7Ckc76eP9TKWZwwmgfq8Q1LANX3QNDnoU4Zp48A3w+zK69Q==",
+      "dev": true,
+      "dependencies": {
+        "@types/react": "*"
+      }
+    },
     "node_modules/@types/redux-logger": {
       "version": "3.0.13",
       "resolved": "https://registry.npmjs.org/@types/redux-logger/-/redux-logger-3.0.13.tgz",
@@ -8714,8 +8722,7 @@
       "version": "1.1.1",
       "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz",
       "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==",
-      "license": "ISC",
-      "optional": true
+      "license": "ISC"
     },
     "node_modules/accepts": {
       "version": "1.3.8",
@@ -9000,8 +9007,7 @@
       "version": "2.0.0",
       "resolved": "https://registry.npmjs.org/aproba/-/aproba-2.0.0.tgz",
       "integrity": "sha512-lYe4Gx7QT+MKGbDsA+Z+he/Wtef0BiwDOlK/XkBrdfsh9J/jPPXbX0tE9x9cl27Tmu5gg3QUbUrQYa/y+KOHPQ==",
-      "license": "ISC",
-      "optional": true
+      "license": "ISC"
     },
     "node_modules/are-we-there-yet": {
       "version": "2.0.0",
@@ -9009,7 +9015,6 @@
       "integrity": "sha512-Ci/qENmwHnsYo9xKIcUJN5LeDKdJ6R1Z1j9V/J5wyq8nh/mYPEpIKJbBZXtZjG04HiK7zV/p6Vs9952MrMeUIw==",
       "deprecated": "This package is no longer supported.",
       "license": "ISC",
-      "optional": true,
       "dependencies": {
         "delegates": "^1.0.0",
         "readable-stream": "^3.6.0"
@@ -10197,7 +10202,6 @@
       "integrity": "sha512-ItanGBMrmRV7Py2Z+Xhs7cT+FNt5K0vPL4p9EZ/UX/Mu7hFbkxSjKF2KVtPwX7UYWp7dRKnrTvReflgrItJbdw==",
       "hasInstallScript": true,
       "license": "MIT",
-      "optional": true,
       "dependencies": {
         "@mapbox/node-pre-gyp": "^1.0.0",
         "nan": "^2.17.0",
@@ -10325,7 +10329,6 @@
       "resolved": "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz",
       "integrity": "sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==",
       "license": "ISC",
-      "optional": true,
       "engines": {
         "node": ">=10"
       }
@@ -10495,7 +10498,6 @@
       "resolved": "https://registry.npmjs.org/color-support/-/color-support-1.1.3.tgz",
       "integrity": "sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg==",
       "license": "ISC",
-      "optional": true,
       "bin": {
         "color-support": "bin.js"
       }
@@ -10634,8 +10636,7 @@
       "version": "1.1.0",
       "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz",
       "integrity": "sha512-ty/fTekppD2fIwRvnZAVdeOiGd1c7YXEixbgJTNzqcxJWKQnjJ/V1bNEEE6hygpM3WjwHFUVK6HTjWSzV4a8sQ==",
-      "license": "ISC",
-      "optional": true
+      "license": "ISC"
     },
     "node_modules/content-disposition": {
       "version": "0.5.4",
@@ -11784,7 +11785,6 @@
       "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-4.2.1.tgz",
       "integrity": "sha512-jOSne2qbyE+/r8G1VU+G/82LBs2Fs4LAsTiLSHOCOMZQl2OKZ6i8i4IyHemTe+/yIXOtTcRQMzPcgyhoFlqPkw==",
       "license": "MIT",
-      "optional": true,
       "dependencies": {
         "mimic-response": "^2.0.0"
       },
@@ -11941,8 +11941,7 @@
       "version": "1.0.0",
       "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz",
       "integrity": "sha512-bd2L678uiWATM6m5Z1VzNCErI3jiGzt6HGY8OVICs40JQq/HALfbyNJmp0UDakEY4pMMaN0Ly5om/B1VI/+xfQ==",
-      "license": "MIT",
-      "optional": true
+      "license": "MIT"
     },
     "node_modules/depd": {
       "version": "2.0.0",
@@ -11975,7 +11974,6 @@
       "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.3.tgz",
       "integrity": "sha512-bwy0MGW55bG41VqxxypOsdSdGqLwXPI/focwgTYCFMbdUiBAxLg9CFzG08sz2aqzknwiX7Hkl0bQENjg8iLByw==",
       "license": "Apache-2.0",
-      "optional": true,
       "engines": {
         "node": ">=8"
       }
@@ -14305,7 +14303,6 @@
       "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-2.1.0.tgz",
       "integrity": "sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg==",
       "license": "ISC",
-      "optional": true,
       "dependencies": {
         "minipass": "^3.0.0"
       },
@@ -14318,7 +14315,6 @@
       "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz",
       "integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==",
       "license": "ISC",
-      "optional": true,
       "dependencies": {
         "yallist": "^4.0.0"
       },
@@ -14330,8 +14326,7 @@
       "version": "4.0.0",
       "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
       "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==",
-      "license": "ISC",
-      "optional": true
+      "license": "ISC"
     },
     "node_modules/fs-monkey": {
       "version": "1.0.6",
@@ -14388,7 +14383,6 @@
       "integrity": "sha512-+5J6MS/5XksCuXq++uFRsnUd7Ovu1XenbeuIuNRJxYWjgQbPuFhT14lAvsWfqfAmnwluf1OwMjz39HjfLPci0Q==",
       "deprecated": "This package is no longer supported.",
       "license": "ISC",
-      "optional": true,
       "dependencies": {
         "aproba": "^1.0.3 || ^2.0.0",
         "color-support": "^1.1.2",
@@ -14793,8 +14787,7 @@
       "version": "2.0.1",
       "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz",
       "integrity": "sha512-8Rf9Y83NBReMnx0gFzA8JImQACstCYWUplepDa9xprwwtmgEZUF0h/i5xSA625zB/I37EtrswSST6OXxwaaIJQ==",
-      "license": "ISC",
-      "optional": true
+      "license": "ISC"
     },
     "node_modules/hasown": {
       "version": "2.0.2",
@@ -20541,6 +20534,11 @@
         "node": ">= 4.0.0"
       }
     },
+    "node_modules/memoize-one": {
+      "version": "5.2.1",
+      "resolved": "https://registry.npmjs.org/memoize-one/-/memoize-one-5.2.1.tgz",
+      "integrity": "sha512-zYiwtZUcYyXKo/np96AGZAckk+FWWsUdJ3cHGGmld7+AhvcWmQyGCYUh1hc4Q/pkOhb65dQR/pqCyK0cOaHz4Q=="
+    },
     "node_modules/memoizerific": {
       "version": "1.11.3",
       "resolved": "https://registry.npmjs.org/memoizerific/-/memoizerific-1.11.3.tgz",
@@ -20664,7 +20662,6 @@
       "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-2.1.0.tgz",
       "integrity": "sha512-wXqjST+SLt7R009ySCglWBCFpjUygmCIfD790/kVbiGmUgfYGuB14PiTd5DwVxSV4NcYHjzMkoj5LjQZwTQLEA==",
       "license": "MIT",
-      "optional": true,
       "engines": {
         "node": ">=8"
       },
@@ -20745,7 +20742,6 @@
       "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-2.1.2.tgz",
       "integrity": "sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg==",
       "license": "MIT",
-      "optional": true,
       "dependencies": {
         "minipass": "^3.0.0",
         "yallist": "^4.0.0"
@@ -20759,7 +20755,6 @@
       "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz",
       "integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==",
       "license": "ISC",
-      "optional": true,
       "dependencies": {
         "yallist": "^4.0.0"
       },
@@ -20771,8 +20766,7 @@
       "version": "4.0.0",
       "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
       "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==",
-      "license": "ISC",
-      "optional": true
+      "license": "ISC"
     },
     "node_modules/mkdirp": {
       "version": "0.5.6",
@@ -20842,8 +20836,7 @@
       "version": "2.20.0",
       "resolved": "https://registry.npmjs.org/nan/-/nan-2.20.0.tgz",
       "integrity": "sha512-bk3gXBZDGILuuo/6sKtr0DQmSThYHLtNCdSdXk9YkxD/jK6X2vmCyyXBBxyqZ4XcnzTyYEAThfX3DCEnLf6igw==",
-      "license": "MIT",
-      "optional": true
+      "license": "MIT"
     },
     "node_modules/nano-time": {
       "version": "1.0.0",
@@ -20915,7 +20908,6 @@
       "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz",
       "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==",
       "license": "MIT",
-      "optional": true,
       "dependencies": {
         "whatwg-url": "^5.0.0"
       },
@@ -20959,7 +20951,6 @@
       "resolved": "https://registry.npmjs.org/nopt/-/nopt-5.0.0.tgz",
       "integrity": "sha512-Tbj67rffqceeLpcRXrT7vKAN8CwfPeIBgM7E6iBkmKLV7bEMwpGgYLGv0jACUsECaa/vuxP0IjEont6umdMgtQ==",
       "license": "ISC",
-      "optional": true,
       "dependencies": {
         "abbrev": "1"
       },
@@ -21021,7 +21012,6 @@
       "integrity": "sha512-AqZtDUWOMKs1G/8lwylVjrdYgqA4d9nu8hc+0gzRxlDb1I10+FHBGMXs6aiQHFdCUUlqH99MUMuLfzWDNDtfxw==",
       "deprecated": "This package is no longer supported.",
       "license": "ISC",
-      "optional": true,
       "dependencies": {
         "are-we-there-yet": "^2.0.0",
         "console-control-strings": "^1.1.0",
@@ -24101,6 +24091,22 @@
         "react-dom": ">= 18.0.0"
       }
     },
+    "node_modules/react-window": {
+      "version": "1.8.11",
+      "resolved": "https://registry.npmjs.org/react-window/-/react-window-1.8.11.tgz",
+      "integrity": "sha512-+SRbUVT2scadgFSWx+R1P754xHPEqvcfSfVX10QYg6POOz+WNgkN48pS+BtZNIMGiL1HYrSEiCkwsMS15QogEQ==",
+      "dependencies": {
+        "@babel/runtime": "^7.0.0",
+        "memoize-one": ">=3.1.1 <6"
+      },
+      "engines": {
+        "node": ">8.0.0"
+      },
+      "peerDependencies": {
+        "react": "^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
+        "react-dom": "^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
+      }
+    },
     "node_modules/read-cache": {
       "version": "1.0.0",
       "resolved": "https://registry.npmjs.org/read-cache/-/read-cache-1.0.0.tgz",
@@ -25216,8 +25222,7 @@
       "version": "2.0.0",
       "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz",
       "integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==",
-      "license": "ISC",
-      "optional": true
+      "license": "ISC"
     },
     "node_modules/set-function-length": {
       "version": "1.2.2",
@@ -25336,15 +25341,13 @@
           "url": "https://feross.org/support"
         }
       ],
-      "license": "MIT",
-      "optional": true
+      "license": "MIT"
     },
     "node_modules/simple-get": {
       "version": "3.1.1",
       "resolved": "https://registry.npmjs.org/simple-get/-/simple-get-3.1.1.tgz",
       "integrity": "sha512-CQ5LTKGfCpvE1K0n2us+kuMPbk/q0EKl82s4aheV9oXjFEz6W/Y7oQFVJuU6QG77hRT4Ghb5RURteF5vnWjupA==",
       "license": "MIT",
-      "optional": true,
       "dependencies": {
         "decompress-response": "^4.2.0",
         "once": "^1.3.1",
@@ -26397,7 +26400,6 @@
       "resolved": "https://registry.npmjs.org/tar/-/tar-6.2.1.tgz",
       "integrity": "sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==",
       "license": "ISC",
-      "optional": true,
       "dependencies": {
         "chownr": "^2.0.0",
         "fs-minipass": "^2.0.0",
@@ -26415,7 +26417,6 @@
       "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz",
       "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==",
       "license": "MIT",
-      "optional": true,
       "bin": {
         "mkdirp": "bin/cmd.js"
       },
@@ -26427,8 +26428,7 @@
       "version": "4.0.0",
       "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
       "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==",
-      "license": "ISC",
-      "optional": true
+      "license": "ISC"
     },
     "node_modules/telejson": {
       "version": "7.2.0",
@@ -26825,8 +26825,7 @@
       "version": "0.0.3",
       "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
       "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==",
-      "license": "MIT",
-      "optional": true
+      "license": "MIT"
     },
     "node_modules/tryer": {
       "version": "1.0.1",
@@ -28522,7 +28521,6 @@
       "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
       "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==",
       "license": "MIT",
-      "optional": true,
       "dependencies": {
         "tr46": "~0.0.3",
         "webidl-conversions": "^3.0.0"
@@ -28532,8 +28530,7 @@
       "version": "3.0.1",
       "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
       "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==",
-      "license": "BSD-2-Clause",
-      "optional": true
+      "license": "BSD-2-Clause"
     },
     "node_modules/which": {
       "version": "2.0.2",
@@ -28651,7 +28648,6 @@
       "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.5.tgz",
       "integrity": "sha512-eDMORYaPNZ4sQIuuYPDHdQvf4gyCF9rEEV/yPxGfwPkRodwEgiMUUXTx/dex+Me0wxx53S+NgUHaP7y3MGlDmg==",
       "license": "ISC",
-      "optional": true,
       "dependencies": {
         "string-width": "^1.0.2 || 2 || 3 || 4"
       }
diff --git a/src/__tests__/data/cohortCreation/conditionCriteria.ts b/src/__tests__/data/cohortCreation/conditionCriteria.ts
index ca2664c46..c088676a3 100644
--- a/src/__tests__/data/cohortCreation/conditionCriteria.ts
+++ b/src/__tests__/data/cohortCreation/conditionCriteria.ts
@@ -3,6 +3,7 @@ import {
   form
 } from 'components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/forms/Cim10Form'
 import { Comparators } from 'types/requestCriterias'
+import { System } from 'types/scope'
 
 export const defaultConditionCriteria: Cim10DataType = {
   id: 1,
diff --git a/src/__tests__/data/cohortCreation/documentCriteria.ts b/src/__tests__/data/cohortCreation/documentCriteria.ts
index 059cd80a3..23dde5089 100644
--- a/src/__tests__/data/cohortCreation/documentCriteria.ts
+++ b/src/__tests__/data/cohortCreation/documentCriteria.ts
@@ -3,6 +3,7 @@ import {
   form
 } from 'components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/forms/DocumentsForm'
 import { Comparators } from 'types/requestCriterias'
+import { System } from 'types/scope'
 import { DocumentStatuses, SearchByTypes } from 'types/searchCriterias'
 
 export const defaultDocumentCriteria: DocumentDataType = {
diff --git a/src/__tests__/data/cohortCreation/encounterCriteria.ts b/src/__tests__/data/cohortCreation/encounterCriteria.ts
index cde990195..b71ff8200 100644
--- a/src/__tests__/data/cohortCreation/encounterCriteria.ts
+++ b/src/__tests__/data/cohortCreation/encounterCriteria.ts
@@ -3,6 +3,7 @@ import {
   form
 } from 'components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/forms/EncounterForm'
 import { Comparators } from 'types/requestCriterias'
+import { System } from 'types/scope'
 
 export const defaultEncounterCriteira: EncounterDataType = {
   id: 1,
diff --git a/src/__tests__/data/cohortCreation/medicationCriteria.ts b/src/__tests__/data/cohortCreation/medicationCriteria.ts
index 49939a292..50a21cfb7 100644
--- a/src/__tests__/data/cohortCreation/medicationCriteria.ts
+++ b/src/__tests__/data/cohortCreation/medicationCriteria.ts
@@ -3,6 +3,7 @@ import {
   form
 } from 'components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/forms/MedicationForm'
 import { Comparators, CriteriaType } from 'types/requestCriterias'
+import { System } from 'types/scope'
 
 export const defaultMedicationCriteria: MedicationDataType = {
   id: 1,
diff --git a/src/__tests__/data/cohortCreation/observationCriteria.ts b/src/__tests__/data/cohortCreation/observationCriteria.ts
index 2ff004d82..1100d0c3b 100644
--- a/src/__tests__/data/cohortCreation/observationCriteria.ts
+++ b/src/__tests__/data/cohortCreation/observationCriteria.ts
@@ -3,6 +3,7 @@ import {
   form
 } from 'components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/forms/BiologyForm'
 import { Comparators } from 'types/requestCriterias'
+import { System } from 'types/scope'
 
 export const defaultObservationCriteria: ObservationDataType = {
   id: 1,
@@ -21,6 +22,8 @@ export const completeObservationCriteria: ObservationDataType = {
       id: 'I3356',
       label: 'I3356 - Erythrocytes Foetaux /érythrocytes Adultes_sang_cytochimie_hf/10000 Ha',
       system: 'https://terminology.eds.aphp.fr/aphp-itm-anabio',
+      above_levels_ids: '*',
+      inferior_levels_ids: '',
       isLeaf: true
     }
   ],
diff --git a/src/__tests__/data/cohortCreation/procedureCriteria.ts b/src/__tests__/data/cohortCreation/procedureCriteria.ts
index 97e889e8d..1601a42bb 100644
--- a/src/__tests__/data/cohortCreation/procedureCriteria.ts
+++ b/src/__tests__/data/cohortCreation/procedureCriteria.ts
@@ -3,6 +3,7 @@ import {
   form
 } from 'components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/forms/CCAMForm'
 import { Comparators } from 'types/requestCriterias'
+import { System } from 'types/scope'
 
 export const defaultProcedureCriteria: CcamDataType = {
   id: 1,
diff --git a/src/components/CreationCohort/DataList_Criteria.tsx b/src/components/CreationCohort/DataList_Criteria.tsx
index 7306bfae9..20c1551cb 100644
--- a/src/components/CreationCohort/DataList_Criteria.tsx
+++ b/src/components/CreationCohort/DataList_Criteria.tsx
@@ -1,4 +1,4 @@
-import { Back_API_Response, CriteriaItemType } from 'types'
+import { CriteriaItemType } from 'types'
 
 import RequestForm from './DiagramView/components/LogicalOperator/components/CriteriaRightPanel/RequestForm/RequestForm'
 
@@ -16,7 +16,6 @@ import { form as biologyForm } from './DiagramView/components/LogicalOperator/co
 import { form as pregnantForm } from './DiagramView/components/LogicalOperator/components/CriteriaRightPanel/forms/PregnancyForm'
 import { form as medicationForm } from './DiagramView/components/LogicalOperator/components/CriteriaRightPanel/forms/MedicationForm'
 import { form as ippForm } from './DiagramView/components/LogicalOperator/components/CriteriaRightPanel/forms/IPPForm'
-import { HIERARCHY_ROOT, getChildrenFromCodes, getCodeList } from 'services/aphp/serviceValueSets'
 
 export enum CriteriaTypeLabels {
   REQUEST = 'Mes requêtes',
@@ -38,25 +37,6 @@ export enum CriteriaTypeLabels {
   HOSPIT = "Fiche d'hospitalisation"
 }
 
-import docTypes from 'assets/docTypes.json'
-import { birthStatusData, booleanFieldsData, booleanOpenChoiceFieldsData, vmeData } from 'data/questionnaire_data'
-import { VitalStatusLabel } from 'types/searchCriterias'
-import { FhirItem } from 'types/valueSet'
-import { createHierarchyRoot } from 'utils/hierarchy'
-
-const async = (fetch: () => Promise<Back_API_Response<FhirItem>>) => async () => (await fetch()).results
-
-const getCodesForValueSet = async (code: string, systems: string[]) => {
-  if (code === HIERARCHY_ROOT && systems.length) return [createHierarchyRoot(systems[0])]
-  for (const system of systems) {
-    try {
-      return (await getChildrenFromCodes(system, [code])).results
-    } catch {
-      console.error("Ce n'est pas une erreur.")
-    }
-  }
-}
-
 const criteriaList: () => CriteriaItemType[] = () => {
   const ODD_QUESTIONNAIRE = getConfig().features.questionnaires.enabled
   const ODD_BIOLOGY = getConfig().features.observation.enabled
diff --git a/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/CriteriaForm/components/index.tsx b/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/CriteriaForm/components/index.tsx
index 99a7673b6..4c0baabe0 100644
--- a/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/CriteriaForm/components/index.tsx
+++ b/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/CriteriaForm/components/index.tsx
@@ -26,6 +26,7 @@ type CriteriaItemRuntimeProps<T> = {
   getValueSetOptions: CriteriaFormItemViewProps<never>['getValueSetOptions']
   viewRenderers: { [key in CriteriaFormItemType]: CriteriaFormItemView<key> }
   deidentified: boolean
+  withinTitledSection?: boolean
 }
 
 type CritieraItemProps<T, U extends DataTypeMappings> = CriteriaItemRuntimeProps<T> & CriteriaItem<T, U>
@@ -85,6 +86,7 @@ export const CFItem = <T, V extends DataTypeMappings, U extends CriteriaItem<T,
       data={data}
       value={fieldValue}
       context={context}
+      withinTitledSection={props.withinTitledSection}
     >
       <View
         value={fieldValue as DataTypeMapping[U['type']]['dataType']}
@@ -121,6 +123,7 @@ export function CFItemWrapper<T>(
     data: T
     value: DataTypes
     displayValueSummary?: string | ((value: DataTypes) => string)
+    withinTitledSection?: boolean
     context: Context
   }>
 ) {
@@ -142,7 +145,7 @@ export function CFItemWrapper<T>(
     ((isFunction(label) && label(data as Record<string, DataTypes>, context)) ||
       (isString(label) && eval(label)(data, context)))
   return (
-    <BlockWrapper className={classes.inputItem}>
+    <BlockWrapper className={classes.inputItem} style={props.withinTitledSection ? { maxWidth: '100%' } : {}}>
       {labelValue ? <CriteriaLabel label={labelValue} style={{ marginTop: '1em' }} infoIcon={props.info} /> : ''}
       {valueSummary && <Typography style={{ fontWeight: 'bold', marginBottom: '1em' }}>{valueSummary}</Typography>}
       {props.children}
diff --git a/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/CriteriaForm/index.tsx b/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/CriteriaForm/index.tsx
index 3eb63e704..8efea0825 100644
--- a/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/CriteriaForm/index.tsx
+++ b/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/CriteriaForm/index.tsx
@@ -2,7 +2,6 @@ import React, { useEffect, useState } from 'react'
 import CriteriaLayout from 'components/ui/CriteriaLayout'
 import {
   CriteriaForm as CriteriaFormDefinition,
-  CriteriaFormItemViewProps,
   NumberAndComparatorDataType,
   NewDurationRangeType,
   CommonCriteriaData,
@@ -11,7 +10,6 @@ import {
 import { CFItem, CFSection } from './components'
 import FORM_ITEM_RENDERER from './mappers/renderers'
 import { useAppSelector } from 'state'
-import { LabelObject } from 'types/searchCriterias'
 import { isFunction, isString } from 'lodash'
 
 export type CriteriaFormRuntimeProps<T> = {
@@ -65,8 +63,6 @@ export default function CriteriaForm<T extends CommonCriteriaData>(props: Criter
     onDataChange?.(criteriaData)
   }, [criteriaData, onDataChange])
 
-  console.log('rendering form')
-  console.log('test itemSections', itemSections)
   return (
     <CriteriaLayout
       criteriaLabel={`${label}`}
@@ -99,8 +95,6 @@ export default function CriteriaForm<T extends CommonCriteriaData>(props: Criter
                 const duration = value as NewDurationRangeType
                 isNull = isNull || (duration.start === null && duration.end === null)
               }
-              if (!isNull) console.log(isNull, item.valueKey, value)
-
               return isNull
             }
             return true
@@ -109,12 +103,13 @@ export default function CriteriaForm<T extends CommonCriteriaData>(props: Criter
           {section.items.map((item, index) => (
             <CFItem
               key={index}
+              withinTitledSection={!!section.title}
               {...{
                 viewRenderers: FORM_ITEM_RENDERER,
                 ...item,
                 data: criteriaData,
                 getValueSetOptions: (valueSetId) => {
-                  return (valueSets.entities[valueSetId]?.options || []) as LabelObject[]
+                  return Object.values(valueSets.entities[valueSetId]?.options || {})
                 },
                 updateData: (newData: T) => {
                   setCriteriaData({ ...criteriaData, ...newData })
diff --git a/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/CriteriaForm/mappers/buildMappers.ts b/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/CriteriaForm/mappers/buildMappers.ts
index e153bca10..d89f4b978 100644
--- a/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/CriteriaForm/mappers/buildMappers.ts
+++ b/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/CriteriaForm/mappers/buildMappers.ts
@@ -96,7 +96,8 @@ const unbuildEncounterServiceFilter = async (
   existingValue?: Hierarchy<ScopeElement, string>[]
 ) => {
   if (value) {
-    const encounterServices: ScopeElement[] = (await services.perimeters.getPerimeters({ ids: value })).results
+    const encounterServices: Hierarchy<ScopeElement>[] = (await services.perimeters.getPerimeters({ ids: value }))
+      .results
     return encounterServices.concat(existingValue || [])
   }
   return Promise.resolve(existingValue || [])
diff --git a/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/CriteriaForm/mappers/chipDisplayMapper.tsx b/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/CriteriaForm/mappers/chipDisplayMapper.tsx
index dee82c63c..6984cf0ab 100644
--- a/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/CriteriaForm/mappers/chipDisplayMapper.tsx
+++ b/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/CriteriaForm/mappers/chipDisplayMapper.tsx
@@ -23,6 +23,7 @@ import allDocTypes from 'assets/docTypes.json'
 import moment from 'moment'
 import { getDurationRangeLabel } from 'utils/age'
 import { getConfig } from 'config'
+import { FhirItem } from 'types/valueSet'
 
 /************************************************************************************/
 /*                        Criteria Form Item Chip Display                           */
@@ -138,7 +139,9 @@ const getLabelsForCodeSearchItem = (
   return val
     .map((value) => {
       return (
-        (value.system ? valueSets.cache[value.system] : item.valueSetIds.flatMap((vid) => valueSets.cache[vid])) || []
+        (value.system
+          ? valueSets.cache[value.system]
+          : item.valueSetsInfo.flatMap((valueset) => valueSets.cache[valueset.url])) || []
       ).find((code) => code && code.id === value.id) as LabelObject
     })
     .filter((code) => code !== undefined)
@@ -151,11 +154,14 @@ const getLabelsForAutoCompleteItem = (
 ): LabelObject[] => {
   return val
     .map((value) => {
-      return (item.valueSetData || Object.values(valueSets.entities[item.valueSetId]?.options || {}) || []).find(
-        (code) => code.id === value.id
-      )
+      return (
+        item.valueSetData ||
+        Object.values(valueSets.entities[item.valueSetId]?.options || {}).map((i) => i as LabelObject) ||
+        []
+      ).find((code) => code.id === value.id)
     })
     .filter((code) => code !== undefined)
+    .map((code) => code as LabelObject)
 }
 
 const chipFromAutoComplete = (
diff --git a/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/CriteriaForm/mappers/index.ts b/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/CriteriaForm/mappers/index.ts
index 5faef3a1b..dff13abf0 100644
--- a/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/CriteriaForm/mappers/index.ts
+++ b/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/CriteriaForm/mappers/index.ts
@@ -133,7 +133,7 @@ const DEFAULT_BUILD_METHOD: Record<CriteriaFormItemType, BuilderMethod> = {
   select: BUILD_MAPPERS.buildSelect,
   autocomplete: BUILD_MAPPERS.buildSelect,
   number: BUILD_MAPPERS.buildSearch,
-  executiveUnit: BUILD_MAPPERS.buildLabelObject,
+  executiveUnit: BUILD_MAPPERS.buildEncounterService,
   numberAndComparator: BUILD_MAPPERS.buildComparator,
   boolean: BUILD_MAPPERS.buildSearch,
   textWithCheck: BUILD_MAPPERS.buildSearch,
@@ -243,7 +243,7 @@ export const unbuildCriteriaDataFromDefinition = async <T extends SelectedCriter
   const emptyCriterion: T = { ...criteriaDefinition.initialData } as T
   emptyCriterion.id = element._id
   emptyCriterion.type = criteriaDefinition.buildInfo.type[element.resourceType] as SelectedCriteriaType['type']
-  emptyCriterion.title = element.name
+  emptyCriterion.title = element.name ?? criteriaDefinition.title
   emptyCriterion.isInclusive = element.isInclusive
 
   if (element.occurrence && 'occurrence' in emptyCriterion) {
diff --git a/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/CriteriaForm/mappers/renderers.tsx b/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/CriteriaForm/mappers/renderers.tsx
index a7dc72769..5603cad7b 100644
--- a/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/CriteriaForm/mappers/renderers.tsx
+++ b/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/CriteriaForm/mappers/renderers.tsx
@@ -28,6 +28,7 @@ import { CriteriaLabel } from 'components/ui/CriteriaLabel'
 import { Comparators } from 'types/requestCriterias'
 import SimpleSelect from 'components/ui/Inputs/SimpleSelect'
 import ValueSetField from 'components/SearchValueSet/ValueSetField'
+import { HIERARCHY_ROOT } from 'services/aphp/serviceValueSets'
 
 /************************************************************************************/
 /*                        Criteria Form Item Renderer                               */
@@ -122,7 +123,7 @@ const FORM_ITEM_RENDERER: { [key in CriteriaFormItemType]: CriteriaFormItemView<
     )
   },
   autocomplete: (props) => {
-    const arrayPropValue = isArray(props.value) ? props.value : [props.value]
+    const arrayPropValue = isArray(props.value) ? props.value : !!props.value ? [props.value] : []
     const codeSystem = props.getValueSetOptions(props.definition.valueSetId)
     const groupBy = props.definition.groupBy
     const valueWithLabels = (arrayPropValue ?? []).map(
@@ -288,7 +289,19 @@ const FORM_ITEM_RENDERER: { [key in CriteriaFormItemType]: CriteriaFormItemView<
       <ValueSetField
         value={valueWithLabels}
         references={props.definition.valueSetsInfo}
-        onSelect={(value) => props.updateData(value)}
+        onSelect={(value) => {
+          if (props.definition.checkIsLeaf) {
+            const valuesWithLeafInfo = value.map((v) => {
+              return {
+                ...v,
+                isLeaf: !v.inferior_levels_ids && v.id !== HIERARCHY_ROOT
+              }
+            })
+            props.updateData(valuesWithLeafInfo)
+          } else {
+            props.updateData(value)
+          }
+        }}
         placeholder={props.definition.label ?? 'Code(s) sélectionné(s)'}
       />
       // <AsyncAutocomplete
diff --git a/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/CriteriaForm/style.ts b/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/CriteriaForm/style.ts
index 8b74dcc13..80f428050 100644
--- a/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/CriteriaForm/style.ts
+++ b/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/CriteriaForm/style.ts
@@ -2,7 +2,8 @@ import { makeStyles } from 'tss-react/mui'
 
 const useStyles = makeStyles()(() => ({
   inputItem: {
-    margin: '1em 1em 0'
+    margin: '1em 1em 0',
+    maxWidth: 'calc(100% - 2em)'
   }
 }))
 
diff --git a/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/CriteriaForm/types.ts b/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/CriteriaForm/types.ts
index 8b63c116f..8dea6c089 100644
--- a/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/CriteriaForm/types.ts
+++ b/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/CriteriaForm/types.ts
@@ -6,7 +6,7 @@ import { SourceType } from 'types/scope'
 import { LabelObject } from 'types/searchCriterias'
 import { CHIPS_DISPLAY_METHODS } from './mappers/chipDisplayMapper'
 import { BUILD_MAPPERS, UNBUILD_MAPPERS } from './mappers/buildMappers'
-import { Reference } from 'types/valueSet'
+import { FhirItem, Reference } from 'types/valueSet'
 
 /********************************************************************************/
 /*                                  Criteria Types                              */
@@ -124,8 +124,6 @@ export type CodeSearchItem = BaseCriteriaItem & {
   type: 'codeSearch'
   noOptionsText: string
   checkIsLeaf?: boolean
-  /** Ids (urls) of valuesets that are allowed to be used for this code search */
-  valueSetIds: string[]
   valueSetsInfo: Reference[]
 }
 
@@ -180,6 +178,7 @@ export type DataTypes =
   | string
   | string[]
   | LabelObject[]
+  | Hierarchy<FhirItem>[]
   | number
   | Hierarchy<ScopeElement, string>[]
   | NumberAndComparatorDataType
@@ -207,7 +206,7 @@ export type DataTypeMapping = {
   numberAndComparator: CriteriaTypeMapping<NumberWithComparatorCriteriaItem, NumberAndComparatorDataType>
   boolean: CriteriaTypeMapping<BooleanCriteriaItem, boolean>
   textWithCheck: CriteriaTypeMapping<TextWithCheckItem, string>
-  codeSearch: CriteriaTypeMapping<CodeSearchItem, LabelObject[]>
+  codeSearch: CriteriaTypeMapping<CodeSearchItem, Hierarchy<FhirItem>[]>
   textWithRegex: CriteriaTypeMapping<TextWithRegexCriteriaItem, string>
   radioChoice: CriteriaTypeMapping<RadioChoiceCriteriaItem, string>
   info: CriteriaTypeMapping<InfoCriteriaItem, string>
diff --git a/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/forms/BiologyForm.ts b/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/forms/BiologyForm.ts
index 746e4b639..ceda8a25d 100644
--- a/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/forms/BiologyForm.ts
+++ b/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/forms/BiologyForm.ts
@@ -7,17 +7,19 @@ import {
   WithEncounterStatusDataType,
   WithOccurenceCriteriaDataType
 } from '../CriteriaForm/types'
-import { LabelObject } from 'types/searchCriterias'
 import { SourceType } from 'types/scope'
 import { getConfig } from 'config'
 import { BiologyStatus } from 'types'
+import { getValueSetsFromSystems } from 'utils/valueSets'
+import { FhirItem } from 'types/valueSet'
+import { Hierarchy } from 'types/hierarchy'
 
 export type ObservationDataType = CommonCriteriaData &
   WithOccurenceCriteriaDataType &
   WithEncounterDateDataType &
   WithEncounterStatusDataType & {
     type: CriteriaType.OBSERVATION
-    code: LabelObject[] | null
+    code: Hierarchy<FhirItem & { isLeaf?: boolean }>[] | null
     searchByValue: NumberAndComparatorDataType | null
     enableSearchByValue: boolean
   }
@@ -66,13 +68,13 @@ export const form: () => CriteriaForm<ObservationDataType> = () => ({
           type: 'codeSearch',
           label: 'Codes de biologie',
           checkIsLeaf: true,
-          valueSetIds: [
+          valueSetsInfo: getValueSetsFromSystems([
             getConfig().features.observation.valueSets.biologyHierarchyAnabio.url,
             getConfig().features.observation.valueSets.biologyHierarchyLoinc.url
-          ],
+          ]),
           noOptionsText: 'Veuillez entrer un code de biologie',
           buildInfo: {
-            fhirKey: ObservationParamsKeys.ANABIO_LOINC,
+            fhirKey: ObservationParamsKeys.CODE,
             buildMethodExtraArgs: [
               { type: 'string', value: getConfig().features.observation.valueSets.biologyHierarchyAnabio.url },
               { type: 'boolean', value: true }
diff --git a/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/forms/CCAMForm.ts b/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/forms/CCAMForm.ts
index a93005999..fe61d2f63 100644
--- a/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/forms/CCAMForm.ts
+++ b/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/forms/CCAMForm.ts
@@ -6,16 +6,18 @@ import {
   WithEncounterStatusDataType,
   WithOccurenceCriteriaDataType
 } from '../CriteriaForm/types'
-import { LabelObject } from 'types/searchCriterias'
 import { SourceType } from 'types/scope'
 import { getConfig } from 'config'
+import { getValueSetsFromSystems } from 'utils/valueSets'
+import { Hierarchy } from 'types/hierarchy'
+import { FhirItem } from 'types/valueSet'
 
 export type CcamDataType = CommonCriteriaData &
   WithOccurenceCriteriaDataType &
   WithEncounterDateDataType &
   WithEncounterStatusDataType & {
     type: CriteriaType.PROCEDURE
-    code: LabelObject[] | null
+    code: Hierarchy<FhirItem>[] | null
     source: string | null
   }
 
@@ -86,7 +88,7 @@ export const form: () => CriteriaForm<CcamDataType> = () => ({
           valueKey: 'code',
           type: 'codeSearch',
           label: "Codes d'actes CCAM",
-          valueSetIds: [getConfig().features.procedure.valueSets.procedureHierarchy.url],
+          valueSetsInfo: getValueSetsFromSystems([getConfig().features.procedure.valueSets.procedureHierarchy.url]),
           noOptionsText: 'Veuillez entrer un code ou un acte CCAM',
           buildInfo: {
             fhirKey: ProcedureParamsKeys.CODE,
diff --git a/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/forms/Cim10Form.ts b/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/forms/Cim10Form.ts
index c7b8404fe..b6f0cb50e 100644
--- a/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/forms/Cim10Form.ts
+++ b/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/forms/Cim10Form.ts
@@ -6,16 +6,18 @@ import {
   WithEncounterStatusDataType,
   WithOccurenceCriteriaDataType
 } from '../CriteriaForm/types'
-import { LabelObject } from 'types/searchCriterias'
 import { SourceType } from 'types/scope'
 import { getConfig } from 'config'
+import { getValueSetsFromSystems } from 'utils/valueSets'
+import { FhirItem } from 'types/valueSet'
+import { Hierarchy } from 'types/hierarchy'
 
 export type Cim10DataType = CommonCriteriaData &
   WithOccurenceCriteriaDataType &
   WithEncounterDateDataType &
   WithEncounterStatusDataType & {
     type: CriteriaType.CONDITION
-    code: LabelObject[] | null
+    code: Hierarchy<FhirItem>[] | null
     source: string | null
     diagnosticType: string[] | null
   }
@@ -87,7 +89,7 @@ export const form: () => CriteriaForm<Cim10DataType> = () => ({
         {
           valueKey: 'code',
           type: 'codeSearch',
-          valueSetIds: [getConfig().features.condition.valueSets.conditionHierarchy.url],
+          valueSetsInfo: getValueSetsFromSystems([getConfig().features.condition.valueSets.conditionHierarchy.url]),
           noOptionsText: 'Veuillez entrer un code ou un diagnostic CIM10',
           label: 'Code CIM10',
           buildInfo: {
diff --git a/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/forms/DemographicForm.ts b/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/forms/DemographicForm.ts
index 4b0105a22..4da365dd4 100644
--- a/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/forms/DemographicForm.ts
+++ b/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/forms/DemographicForm.ts
@@ -98,11 +98,6 @@ export const form: () => CriteriaForm<DemographicDataType> = () => ({
           },
           disableCondition: (data) => {
             const typedData = data as DemographicDataType
-            console.log(
-              'disabled',
-              typedData.birthdates !== null &&
-                (typedData.birthdates.start !== null || typedData.birthdates.end !== null)
-            )
             return (
               typedData.birthdates !== null &&
               (typedData.birthdates.start !== null || typedData.birthdates.end !== null)
diff --git a/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/forms/GHMForm.tsx b/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/forms/GHMForm.tsx
index e2b6c9504..c96fb5000 100644
--- a/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/forms/GHMForm.tsx
+++ b/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/forms/GHMForm.tsx
@@ -7,17 +7,19 @@ import {
   WithEncounterStatusDataType,
   WithOccurenceCriteriaDataType
 } from '../CriteriaForm/types'
-import { LabelObject } from 'types/searchCriterias'
 import { Link } from '@mui/material'
 import { SourceType } from 'types/scope'
 import { getConfig } from 'config'
+import { getValueSetsFromSystems } from 'utils/valueSets'
+import { Hierarchy } from 'types/hierarchy'
+import { FhirItem } from 'types/valueSet'
 
 export type GhmDataType = CommonCriteriaData &
   WithOccurenceCriteriaDataType &
   WithEncounterDateDataType &
   WithEncounterStatusDataType & {
     type: CriteriaType.CLAIM
-    code: LabelObject[] | null
+    code: Hierarchy<FhirItem>[] | null
   }
 
 export const form: () => CriteriaForm<GhmDataType> = () => ({
@@ -71,7 +73,7 @@ export const form: () => CriteriaForm<GhmDataType> = () => ({
         {
           valueKey: 'code',
           type: 'codeSearch',
-          valueSetIds: [getConfig().features.claim.valueSets.claimHierarchy.url],
+          valueSetsInfo: getValueSetsFromSystems([getConfig().features.claim.valueSets.claimHierarchy.url]),
           noOptionsText: 'Aucun GHM trouvé',
           label: 'Code GHM',
           buildInfo: {
diff --git a/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/forms/IPPForm.ts b/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/forms/IPPForm.ts
index 2359a7a18..02539c2d1 100644
--- a/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/forms/IPPForm.ts
+++ b/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/forms/IPPForm.ts
@@ -23,7 +23,6 @@ export const form: () => CriteriaForm<IPPListDataType> = () => ({
     AT_LEAST_ONE_IPP: 'Merci de renseigner au moins un IPP'
   },
   globalErrorCheck: (data) => {
-    console.log('errocheck', data)
     if (data.search && (data.search as string).length > 0) {
       return undefined
     }
diff --git a/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/forms/MedicationForm.ts b/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/forms/MedicationForm.ts
index cf7ff2e23..225314a07 100644
--- a/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/forms/MedicationForm.ts
+++ b/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/forms/MedicationForm.ts
@@ -13,15 +13,17 @@ import {
   WithEncounterStatusDataType,
   WithOccurenceCriteriaDataType
 } from '../CriteriaForm/types'
-import { LabelObject } from 'types/searchCriterias'
 import { SourceType } from 'types/scope'
 import { getConfig } from 'config'
+import { getValueSetsFromSystems } from 'utils/valueSets'
+import { Hierarchy } from 'types/hierarchy'
+import { FhirItem } from 'types/valueSet'
 
 export type MedicationDataType = CommonCriteriaData &
   WithOccurenceCriteriaDataType &
   WithEncounterDateDataType &
   WithEncounterStatusDataType & {
-    code: LabelObject[] | null
+    code: Hierarchy<FhirItem>[] | null
     administration: string[] | null
     type: CriteriaType.MEDICATION_REQUEST | CriteriaType.MEDICATION_ADMINISTRATION
     prescriptionType: string[] | null
@@ -90,10 +92,10 @@ export const form: () => CriteriaForm<MedicationDataType> = () => ({
           type: 'codeSearch',
           label: 'Code(s) sélectionné(s)',
           noOptionsText: 'Veuillez entrer un code de médicament',
-          valueSetIds: [
+          valueSetsInfo: getValueSetsFromSystems([
             getConfig().features.medication.valueSets.medicationAtc.url,
             getConfig().features.medication.valueSets.medicationUcd.url
-          ],
+          ]),
           buildInfo: {
             fhirKey: PrescriptionParamsKeys.CODE,
             buildMethodExtraArgs: [
diff --git a/src/components/CreationCohort/Requeteur.tsx b/src/components/CreationCohort/Requeteur.tsx
index 7effe4d40..0e92652d9 100644
--- a/src/components/CreationCohort/Requeteur.tsx
+++ b/src/components/CreationCohort/Requeteur.tsx
@@ -189,7 +189,6 @@ const Requeteur = () => {
   useEffect(() => {
     ;(async () => {
       if (!valueSets.loading && !valueSets.loaded) {
-        console.log('fetching valuesets')
         await dispatch(initValueSets(criteriaList())).unwrap()
       }
       setValueSetsLoading(false)
diff --git a/src/components/ui/Collapse/index.tsx b/src/components/ui/Collapse/index.tsx
index 0ac43d5ae..d7f705699 100644
--- a/src/components/ui/Collapse/index.tsx
+++ b/src/components/ui/Collapse/index.tsx
@@ -17,7 +17,6 @@ type CollapseProps = {
 
 const Collapse = ({ value = true, title, children, info }: PropsWithChildren<CollapseProps>) => {
   const [checked, setChecked] = useState(value)
-  console.log('test children', children)
 
   return (
     <Grid container direction="column">
diff --git a/src/components/ui/Inputs/Occurences/index.tsx b/src/components/ui/Inputs/Occurences/index.tsx
index 321e24e1e..039d78167 100644
--- a/src/components/ui/Inputs/Occurences/index.tsx
+++ b/src/components/ui/Inputs/Occurences/index.tsx
@@ -99,7 +99,6 @@ const OccurenceInput = ({
     }
     return null
   }
-  console.log('comparatorValue', comparatorValue)
 
   return (
     <>
diff --git a/src/hooks/useIsOverflow.ts b/src/hooks/useIsOverflow.ts
index beb8dd350..6430390a6 100644
--- a/src/hooks/useIsOverflow.ts
+++ b/src/hooks/useIsOverflow.ts
@@ -1,4 +1,4 @@
-import React, { MutableRefObject, useLayoutEffect, useState } from 'react'
+import { MutableRefObject, useLayoutEffect, useState } from 'react'
 
 type UseIsOverflowArgs = {
   ref: MutableRefObject<HTMLDivElement | null>
diff --git a/src/state/valueSets.ts b/src/state/valueSets.ts
index a5b896486..ffe4ce8d4 100644
--- a/src/state/valueSets.ts
+++ b/src/state/valueSets.ts
@@ -7,7 +7,7 @@ import {
   createSelector
 } from '@reduxjs/toolkit'
 import { CriteriaItemType } from 'types'
-import { CodesCache } from 'types/hierarchy'
+import { CodesCache, Hierarchy } from 'types/hierarchy'
 import { logout } from './me'
 import { LabelObject } from 'types/searchCriterias'
 import { RootState } from 'state'
@@ -18,7 +18,7 @@ import { getCodeList } from 'services/aphp/serviceValueSets'
 
 const valueSetsAdapter = createEntityAdapter<CodesCache<FhirItem>>()
 
-export type CodeCache = { [system: string]: LabelObject[] }
+export type CodeCache = { [system: string]: Hierarchy<FhirItem>[] }
 
 export type ValueSetStore = { entities: Dictionary<CodesCache<FhirItem>>; cache: CodeCache }
 
@@ -84,7 +84,7 @@ const valueSetsSlice = createSlice({
   }),
   reducers: {
     saveValueSets: (state, action) => valueSetsAdapter.setMany(state, action.payload),
-    updateCache: (state, action: PayloadAction<{ [system: string]: LabelObject[] }>) => {
+    updateCache: (state, action: PayloadAction<{ [system: string]: Hierarchy<FhirItem>[] }>) => {
       return {
         ...state,
         cache: action.payload
diff --git a/src/types.ts b/src/types.ts
index ead6bd0ea..83f4e1474 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -363,8 +363,6 @@ export type CriteriaDrawerComponentProps = {
   isOpen?: boolean
   parentId?: number | null
   selectedCriteria: SelectedCriteriaType | null
-  // TODO remove this when we have the new code search component
-  onChangeValue?: (key: string, value: any, hierarchy: Hierarchy<any, any>[]) => void
   onChangeSelectedCriteria: (newCriteria: SelectedCriteriaType) => void
   goBack: () => void
 }
diff --git a/src/utils/cohortCreation.ts b/src/utils/cohortCreation.ts
index 2d4040f0e..0978fbcbc 100644
--- a/src/utils/cohortCreation.ts
+++ b/src/utils/cohortCreation.ts
@@ -17,10 +17,12 @@ import {
 import { editAllCriteria, editAllCriteriaGroup, pseudonimizeCriteria, buildCohortCreation } from 'state/cohortCreation'
 import { AppDispatch } from 'state'
 import { Hierarchy } from 'types/hierarchy'
-import { fetchValueSet } from 'services/aphp/callApi'
 import { CodeCache } from 'state/valueSets'
 import { NewDurationRangeType } from 'components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/CriteriaForm/types'
 import criteriaList, { getAllCriteriaItems } from 'components/CreationCohort/DataList_Criteria'
+import { getChildrenFromCodes, HIERARCHY_ROOT } from 'services/aphp/serviceValueSets'
+import { createHierarchyRoot } from './hierarchy'
+import { FhirItem } from 'types/valueSet'
 
 const REQUETEUR_VERSION = 'v1.5.1'
 
@@ -520,6 +522,17 @@ export async function unbuildRequest(_json: string): Promise<any> {
   }
 }
 
+const getCodesForValueSet = async (code: string, systems: string[]): Promise<Hierarchy<FhirItem>[] | undefined> => {
+  if (code === HIERARCHY_ROOT && systems.length) return [createHierarchyRoot(systems[0])]
+  for (const system of systems) {
+    try {
+      return (await getChildrenFromCodes(system, [code])).results
+    } catch {
+      console.error("Ce n'est pas une erreur.")
+    }
+  }
+}
+
 /**
  * Fetches all codes for the criteria within the query
  * @param criteriaList list of criteria definitions
@@ -532,7 +545,6 @@ export const fetchCriteriasCodes = async (
   selectedCriteria: SelectedCriteriaType[],
   oldCriteriaCache?: CodeCache
 ): Promise<CodeCache> => {
-  console.log('fetching criteria codes')
   const updatedCriteriaData: CodeCache = { ...oldCriteriaCache }
   const allCriterias = getAllCriteriaItems(criteriaList)
   for (const criteria of allCriterias) {
@@ -542,22 +554,22 @@ export const fetchCriteriasCodes = async (
     for (const section of criteria.formDefinition?.itemSections || []) {
       for (const item of section.items || []) {
         if (item.type === 'codeSearch') {
-          const defaultValueSet = item.valueSetIds[0]
+          const defaultValueSet = item.valueSetsInfo[0].url
           for (const criterion of criteriaValues) {
             const dataKey = item.valueKey as keyof SelectedCriteriaType
             const labelValues = criterion[dataKey] as unknown as LabelObject[]
             if (labelValues && labelValues.length > 0) {
               for (const code of labelValues) {
-                console.log('fetching code', code)
                 const codeSystem = code.system ?? defaultValueSet
-                const valueSetCodeCache = updatedCriteriaData[codeSystem] ?? []
+                const valueSetCodeCache = [...(updatedCriteriaData[codeSystem] ?? [])]
                 if (!valueSetCodeCache.find((data) => data.id === code.id)) {
                   try {
-                    const fetchedCode = (await fetchValueSet(codeSystem, {
-                      search: code.id || '',
-                      noStar: true
-                    })) as LabelObject[]
-                    valueSetCodeCache.push(...fetchedCode)
+                    const fetchedCode = await getCodesForValueSet(code.id, [codeSystem])
+                    if (fetchedCode) {
+                      valueSetCodeCache.push(...fetchedCode)
+                    } else {
+                      console.warn(`Code ${code.id} not found in system ${codeSystem}`)
+                    }
                   } catch (e) {
                     // fail silently
                     console.error(`Error fetching code ${code.id} from system ${codeSystem}`, e)