-
Notifications
You must be signed in to change notification settings - Fork 3
[Feature] - Ajoute de nouveaux filtres pour Synapse #42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -91,7 +91,7 @@ private function importDiseases(): void | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $hierarchyLevel = strlen($explode[1] ?? '') + $basicHierarchyLevel; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $cim11Disease->setHierarchyLevel($hierarchyLevel); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $cim11Disease->setCim10Code($this->cim11Mapping[$data['code']] ?? null); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $cim11Disease->setCim10Code($this->getCim10Code($data['code'])); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $cim11Disease->setImportId($this->importId); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| foreach (ModifierType::cases() as $case) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -234,4 +234,24 @@ private function buildCim10Cim11Database(): void | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $this->cim11Mapping[$data['icd11Code']] = $data['icd10Code']; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private function getCim10Code(string $code): ?string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if ('SD82' === $code) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| dump($this->cim11Mapping[$code]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| exit; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+240
to
+244
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if ('SD82' === $code) { | |
| dump($this->cim11Mapping[$code]); | |
| exit; | |
| } |
Copilot
AI
Feb 27, 2026
There was a problem hiding this comment.
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.
| 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); |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -21,7 +21,7 @@ | |||||
| // Liste extracted from | ||||||
| // https://biologiepathologie.chu-lille.fr/fichiers/42_795catalogue-rast-i.pdf | ||||||
|
|
||||||
| #[ApiFilter(AllergenFilter::class, properties: ['search'])] | ||||||
| #[ApiFilter(AllergenFilter::class, properties: ['search', 'excluded_categories'])] | ||||||
| #[ORM\Entity(repositoryClass: AllergenRepository::class)] | ||||||
| #[ORM\Table(name: 'allergens')] | ||||||
| #[ORM\Index(columns: ['allergen_code'], name: 'allergens_index')] | ||||||
|
|
@@ -37,7 +37,7 @@ | |||||
| ), | ||||||
| ], | ||||||
| paginationClientEnabled: true, | ||||||
| paginationPartial: true, | ||||||
| paginationPartial: false, | ||||||
|
||||||
| paginationPartial: false, | |
| paginationPartial: true, |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -37,7 +37,7 @@ | |||||
| ), | ||||||
| ], | ||||||
| paginationClientEnabled: true, | ||||||
| paginationPartial: true, | ||||||
| paginationPartial: false, | ||||||
|
||||||
| paginationPartial: false, | |
| paginationPartial: true, |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -74,4 +74,27 @@ public function testGetData() : void | |||||||||
| $this->assertResponseStatusCodeSame(Response::HTTP_OK); | ||||||||||
| $this->assertEquals('Chymopapaïne', $data['name']); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| /** | ||||||||||
| * @throws ClientExceptionInterface | ||||||||||
| * @throws RedirectionExceptionInterface | ||||||||||
| * @throws ServerExceptionInterface | ||||||||||
| * @throws TransportExceptionInterface | ||||||||||
| */ | ||||||||||
| public function testExcludedCategoriesFilter(): void | ||||||||||
| { | ||||||||||
| // Test excluding a single group | ||||||||||
| $data = $this->get('allergens', ['excluded_categories' => 'Médicaments']); | ||||||||||
| $this->assertResponseStatusCodeSame(Response::HTTP_OK); | ||||||||||
| $this->assertCollectionKeyNotContains($data['hydra:member'], 'group', ['Médicaments']); | ||||||||||
|
|
||||||||||
| // Test excluding multiple groups | ||||||||||
| $excludedGroups = ['Médicaments', 'Pollens de graminées']; | ||||||||||
| $data = $this->get('allergens', ['excluded_categories' => $excludedGroups]); | ||||||||||
| $this->assertResponseStatusCodeSame(Response::HTTP_OK); | ||||||||||
| $this->assertCollectionKeyNotContains($data['hydra:member'], 'group', $excludedGroups); | ||||||||||
|
|
||||||||||
| // Verify that at least some allergens remain after exclusion | ||||||||||
| $this->assertEquals(0, count($data['hydra:member']), 'No more allergens available'); | ||||||||||
|
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'); | |
| // 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'); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -130,4 +130,40 @@ public function testGetData(): void | |
| $this->assertEquals('Acute Nasopharyngitis', $data['name']); | ||
| $this->assertEquals('This is an english synonym', $data['synonyms'][0]); | ||
| } | ||
|
|
||
| /** | ||
| * @throws ClientExceptionInterface | ||
| * @throws RedirectionExceptionInterface | ||
| * @throws ServerExceptionInterface | ||
| * @throws TransportExceptionInterface | ||
| */ | ||
| public function testWithCim10Filter(): void | ||
| { | ||
| // Test with withCim10=true - should only return entries with cim10Code | ||
| $data = $this->get('cim11s', ['withCim10' => 'true']); | ||
| $this->assertResponseStatusCodeSame(Response::HTTP_OK); | ||
|
|
||
| // All returned items should have a cim10Code | ||
| foreach ($data['hydra:member'] as $item) { | ||
| $this->assertNotNull($item['cim10Code'], 'All items should have a cim10Code when withCim10=true'); | ||
| } | ||
|
|
||
| // Verify we have the expected items with cim10Code | ||
| $this->assertCollectionKeyContains($data['hydra:member'], 'cim10Code', ['C50.9', 'J00', 'J0B']); | ||
|
|
||
| // Test with withCim10=false - should return all entries | ||
| $dataAll = $this->get('cim11s', ['withCim10' => 'false']); | ||
| $this->assertResponseStatusCodeSame(Response::HTTP_OK); | ||
|
|
||
| // Should have more or equal items when not filtering | ||
| $this->assertGreaterThanOrEqual(count($data['hydra:member']), count($dataAll['hydra:member'])); | ||
|
||
|
|
||
| // Test with withCim10=1 (also should be treated as true) | ||
| $data2 = $this->get('cim11s', ['withCim10' => '1']); | ||
| $this->assertResponseStatusCodeSame(Response::HTTP_OK); | ||
|
|
||
| foreach ($data2['hydra:member'] as $item) { | ||
| $this->assertNotNull($item['cim10Code'], 'All items should have a cim10Code when withCim10=1'); | ||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doctrine\ORM\Query\Expr\Joinis imported but not used anywhere in this file. Please remove the unuseduseto avoid dead imports and keep the file clean.