[Feature] - Ajoute de nouveaux filtres pour Synapse#42
[Feature] - Ajoute de nouveaux filtres pour Synapse#42
Conversation
There was a problem hiding this comment.
Pull request overview
Ajoute de nouveaux filtres API Platform pour faciliter la consommation “Synapse” (filtrage CIM-11 sur la présence d’un code CIM-10, et exclusion de catégories d’allergènes), avec adaptations côté import/mapping CIM-11 et couverture de tests fonctionnels.
Changes:
- Ajout du filtre
withCim10sur la ressource CIM-11 + test fonctionnel associé. - Ajout du filtre
excluded_categoriessur la ressource Allergen + test fonctionnel associé. - Ajustements import/mapping CIM-11 + quelques changements connexes (index RPPS, requête d’exclusion RPPS, config de pagination).
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Functional/Cim11sTest.php | Ajoute un test fonctionnel pour le filtre withCim10. |
| tests/Functional/AllergenTest.php | Ajoute un test fonctionnel pour le filtre excluded_categories. |
| src/Entity/RPPS.php | Ajoute un index composite (specialty, id_rpps). |
| src/Entity/Cim11.php | Expose la propriété de filtre withCim10 via Cim11Filter. |
| src/Entity/CCAM.php | Change paginationPartial à false. |
| src/Entity/Allergen.php | Ajoute excluded_categories au filtre + change paginationPartial à false. |
| src/DataFixtures/LoadDCim11.php | Ajoute une maladie sans cim10Code pour tester withCim10. |
| src/Command/Cim11Import.php | Introduit getCim10Code() pour le mapping CIM-10 (avec logique de fallback). |
| src/ApiPlatform/Filter/RPPSFilter.php | Modifie l’implémentation de excluded_rpps (NOT EXISTS) + nouveaux imports. |
| src/ApiPlatform/Filter/Cim11Filter.php | Implémente le filtre withCim10 (boolean) via IS NOT NULL. |
| src/ApiPlatform/Filter/AllergenFilter.php | Implémente le filtre excluded_categories via NOT IN. |
| mapping-cim-11.csv | Ajoute une ligne de mapping (SD82 → F32.9). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Verify that at least some allergens remain after exclusion | ||
| $this->assertEquals(0, count($data['hydra:member']), 'No more allergens available'); |
There was a problem hiding this comment.
The inline comment says you want to verify that some allergens remain after excluding categories, but the assertion expects an empty result set. Given fixtures only include the excluded groups, either update the comment to match the expected empty set (or add fixtures/assertions that ensure at least one allergen remains).
| // Verify that at least some allergens remain after exclusion | |
| $this->assertEquals(0, count($data['hydra:member']), 'No more allergens available'); | |
| // Verify that no allergens remain after exclusion when only excluded groups exist in fixtures | |
| $this->assertEquals(0, count($data['hydra:member']), 'All allergens should be excluded'); |
| use App\Entity\Specialty; | ||
| use Doctrine\DBAL\Platforms\MySQLPlatform; | ||
| use Doctrine\ORM\EntityManagerInterface; | ||
| use Doctrine\ORM\Query\Expr\Join; |
There was a problem hiding this comment.
Doctrine\ORM\Query\Expr\Join is imported but not used anywhere in this file. Please remove the unused use to avoid dead imports and keep the file clean.
| use Doctrine\ORM\Query\Expr\Join; |
| ], | ||
| paginationClientEnabled: true, | ||
| paginationPartial: true, | ||
| paginationPartial: false, |
There was a problem hiding this comment.
Setting paginationPartial: false is a behavioral and performance change (it re-enables full pagination counts). Most other API resources in this repo use paginationPartial: true (e.g. src/Entity/Cim11.php, src/Entity/City.php). Please confirm this is intentional for CCAM and add a brief rationale (or revert if not needed).
| paginationPartial: false, | |
| paginationPartial: true, |
| ], | ||
| paginationClientEnabled: true, | ||
| paginationPartial: true, | ||
| paginationPartial: false, |
There was a problem hiding this comment.
Setting paginationPartial: false is a behavioral and performance change (it re-enables full pagination counts). Most other API resources in this repo use paginationPartial: true (e.g. src/Entity/Cim11.php, src/Entity/City.php). Please confirm this is intentional for allergens and add a brief rationale (or revert if not needed).
| paginationPartial: false, | |
| paginationPartial: true, |
| if ('SD82' === $code) { | ||
| dump($this->cim11Mapping[$code]); | ||
| exit; | ||
| } | ||
|
|
There was a problem hiding this comment.
getCim10Code() contains a hard-coded dump() + exit for code SD82. This will abort the import command in real usage and must be removed (or replaced with proper logging/handling) before merging.
| if ('SD82' === $code) { | |
| dump($this->cim11Mapping[$code]); | |
| exit; | |
| } |
| private function getCim10Code(string $code): ?string | ||
| { | ||
| if ('SD82' === $code) { | ||
| dump($this->cim11Mapping[$code]); | ||
| exit; | ||
| } | ||
|
|
||
| if (isset($this->cim11Mapping[$code])) { | ||
| return $this->cim11Mapping[$code]; | ||
| } | ||
|
|
||
| if (str_ends_with($code, '0')) { | ||
| $codeWithoutLastZero = substr($code, 0, -1); |
There was a problem hiding this comment.
The fallback mapping for codes ending with 0 uses substr($code, 0, -1), which turns CA00.0 into CA00.. The mapping CSV stores ICD-11 codes without the trailing dot (e.g. CA00), so this fallback will still miss and return null. Consider normalizing the code by removing a trailing .0 (and/or trimming a trailing .) before looking up $this->cim11Mapping.
| private function getCim10Code(string $code): ?string | |
| { | |
| if ('SD82' === $code) { | |
| dump($this->cim11Mapping[$code]); | |
| exit; | |
| } | |
| if (isset($this->cim11Mapping[$code])) { | |
| return $this->cim11Mapping[$code]; | |
| } | |
| if (str_ends_with($code, '0')) { | |
| $codeWithoutLastZero = substr($code, 0, -1); | |
| private function normalizeIcd11Code(string $code): string | |
| { | |
| // Remove a trailing ".0" (e.g. "CA00.0" -> "CA00") | |
| $code = preg_replace('/\.0$/', '', $code); | |
| // Trim any remaining trailing dot (e.g. "CA00." -> "CA00") | |
| return rtrim($code, '.'); | |
| } | |
| private function getCim10Code(string $code): ?string | |
| { | |
| $normalizedCode = $this->normalizeIcd11Code($code); | |
| if ('SD82' === $normalizedCode) { | |
| dump($this->cim11Mapping[$normalizedCode]); | |
| exit; | |
| } | |
| if (isset($this->cim11Mapping[$normalizedCode])) { | |
| return $this->cim11Mapping[$normalizedCode]; | |
| } | |
| if (str_ends_with($normalizedCode, '0')) { | |
| $codeWithoutLastZero = substr($normalizedCode, 0, -1); |
| $this->assertResponseStatusCodeSame(Response::HTTP_OK); | ||
|
|
||
| // Should have more or equal items when not filtering | ||
| $this->assertGreaterThanOrEqual(count($data['hydra:member']), count($dataAll['hydra:member'])); |
There was a problem hiding this comment.
The count comparison is reversed: when withCim10=false (no filtering), the collection should have more or equal items than the filtered withCim10=true result. The current assertion checks the opposite and will fail when the filter actually reduces results.
No description provided.