Skip to content

[Feature] - Ajoute de nouveaux filtres pour Synapse#42

Open
Xusifob wants to merge 5 commits intostagingfrom
feature/allergens-filters
Open

[Feature] - Ajoute de nouveaux filtres pour Synapse#42
Xusifob wants to merge 5 commits intostagingfrom
feature/allergens-filters

Conversation

@Xusifob
Copy link
Member

@Xusifob Xusifob commented Feb 27, 2026

No description provided.

Copilot AI review requested due to automatic review settings February 27, 2026 06:50
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 withCim10 sur la ressource CIM-11 + test fonctionnel associé.
  • Ajout du filtre excluded_categories sur 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.

Comment on lines +97 to +98
// Verify that at least some allergens remain after exclusion
$this->assertEquals(0, count($data['hydra:member']), 'No more allergens available');
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Suggested change
// 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');

Copilot uses AI. Check for mistakes.
use App\Entity\Specialty;
use Doctrine\DBAL\Platforms\MySQLPlatform;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Query\Expr\Join;
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
use Doctrine\ORM\Query\Expr\Join;

Copilot uses AI. Check for mistakes.
],
paginationClientEnabled: true,
paginationPartial: true,
paginationPartial: false,
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Suggested change
paginationPartial: false,
paginationPartial: true,

Copilot uses AI. Check for mistakes.
],
paginationClientEnabled: true,
paginationPartial: true,
paginationPartial: false,
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Suggested change
paginationPartial: false,
paginationPartial: true,

Copilot uses AI. Check for mistakes.
Comment on lines +240 to +244
if ('SD82' === $code) {
dump($this->cim11Mapping[$code]);
exit;
}

Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
if ('SD82' === $code) {
dump($this->cim11Mapping[$code]);
exit;
}

Copilot uses AI. Check for mistakes.
Comment on lines +238 to +250
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);
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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);

Copilot uses AI. Check for mistakes.
$this->assertResponseStatusCodeSame(Response::HTTP_OK);

// Should have more or equal items when not filtering
$this->assertGreaterThanOrEqual(count($data['hydra:member']), count($dataAll['hydra:member']));
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants