diff --git a/src/Bundle/ChillTicketBundle/src/DataFixtures/ORM/LoadMotives.php b/src/Bundle/ChillTicketBundle/src/DataFixtures/ORM/LoadMotives.php index e29470a3f..965787059 100644 --- a/src/Bundle/ChillTicketBundle/src/DataFixtures/ORM/LoadMotives.php +++ b/src/Bundle/ChillTicketBundle/src/DataFixtures/ORM/LoadMotives.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace Chill\TicketBundle\DataFixtures\ORM; +use Chill\TicketBundle\Entity\EmergencyStatusEnum; use Chill\TicketBundle\Entity\Motive; use Doctrine\Bundle\FixturesBundle\Fixture; use Doctrine\Bundle\FixturesBundle\FixtureGroupInterface; @@ -25,58 +26,73 @@ final class LoadMotives extends Fixture implements FixtureGroupInterface public function load(ObjectManager $manager) { - foreach (explode("\n", self::MOTIVES) as $label) { - if ('' === trim($label)) { + foreach (explode("\n", self::MOTIVES) as $row) { + if ('' === trim($row)) { + continue; + } + + $data = str_getcsv($row); + if ('' === $data[0]) { continue; } $motive = new Motive(); - $motive->setLabel(['fr' => trim($label)]); + $motive->setLabel(['fr' => trim((string) $data[0])]); + $motive->setMakeTicketEmergency(match ($data[1]) { + 'true' => EmergencyStatusEnum::YES, + 'false' => EmergencyStatusEnum::NO, + default => throw new \UnexpectedValueException('Unexpected value'), + }); + + foreach (array_slice($data, 2) as $supplementaryComment) { + if ('' !== trim((string) $supplementaryComment)) { + $motive->addSupplementaryComment(['label' => trim((string) $supplementaryComment)]); + } + } $manager->persist($motive); } - $manager->flush(); } - private const MOTIVES = <<<'TXT' - Coordonnées - Horaire de passage - Retard de livraison - Erreur de livraison - Colis incomplet - MATLOC - Retard DASRI - Planning d'astreintes - Planning des tournées - Contrôle pompe - Changement de rendez-vous - Renseignement facturation/prestation - Décès patient - Demande de prise en charge - Information absence - Demande bulletin de situation - Difficultés accès logement - Déplacement inutile - Problème de prélèvement/de commande - Parc auto - Demande d'admission - Retrait de matériel au domicile - Comptes-rendus - Démarchage commercial - Demande de transport - Demande laboratoire - Demande admission - Suivi de prise en charge - Mauvaise adresse - Patient absent - Annulation - Colis perdu - Changement de rendez-vous - Coordination interservices - Problème de substitution produits - Problème ordonnance - Réclamations facture - Préparation urgente - TXT; + private const MOTIVES = <<<'CSV' + "Coordonnées",false,"Nouvelles coordonnées", + "Horaire de passage",false, + "Retard de livraison",false, + "Erreur de livraison",false, + "Colis incomplet",false, + "MATLOC",false, + "Retard DASRI",false, + "Planning d'astreintes",false, + "Planning des tournées",false, + "Contrôle pompe",true, + "Changement de rendez-vous",false,"Date du nouveau rendez-vous","Lieu du nouveau rendez-vous", + "Renseignement facturation/prestation",false, + "Décès patient",false,"Date et heures du décès","Autorisation préalable du médecin pour le décès", + "Demande de prise en charge",false, + "Information absence",false, + "Demande bulletin de situation",false, + "Difficultés accès logement",false, + "Déplacement inutile",false, + "Problème de prélèvement/de commande",false, + "Parc auto",false, + "Demande d'admission",false, + "Retrait de matériel au domicile",false, + "Comptes-rendus",false, + "Démarchage commercial",false, + "Demande de transport",false, + "Demande laboratoire",false, + "Demande admission",false, + "Suivi de prise en charge",false, + "Mauvaise adresse",false, + "Patient absent",false, + "Annulation",false, + "Colis perdu",false, + "Changement de rendez-vous",false, + "Coordination interservices",false, + "Problème de substitution produits",true, + "Problème ordonnance",false, + "Réclamations facture",false,"Numéro de facture concerné", + "Préparation urgente",true, + CSV; } diff --git a/src/Bundle/ChillTicketBundle/src/Entity/Motive.php b/src/Bundle/ChillTicketBundle/src/Entity/Motive.php index 8dadecde0..2ea3b47c2 100644 --- a/src/Bundle/ChillTicketBundle/src/Entity/Motive.php +++ b/src/Bundle/ChillTicketBundle/src/Entity/Motive.php @@ -37,6 +37,10 @@ class Motive #[Serializer\Groups(['read'])] private ?EmergencyStatusEnum $makeTicketEmergency = null; + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON, nullable: false, options: ['jsonb' => true, 'default' => '[]'])] + #[Serializer\Groups(['read'])] + private array $supplementaryComments = []; + public function isActive(): bool { return $this->active; @@ -76,4 +80,22 @@ class Motive { return null !== $this->makeTicketEmergency; } + + /** + * Get the supplementary comments. + * + * @return array + */ + public function getSupplementaryComments(): array + { + return $this->supplementaryComments; + } + + /** + * @param array{label: string} $supplementaryComments + */ + public function addSupplementaryComment(array $supplementaryComments): void + { + $this->supplementaryComments[] = $supplementaryComments; + } } diff --git a/src/Bundle/ChillTicketBundle/src/Resources/public/types.ts b/src/Bundle/ChillTicketBundle/src/Resources/public/types.ts index fddc5b74b..7cb2e257b 100644 --- a/src/Bundle/ChillTicketBundle/src/Resources/public/types.ts +++ b/src/Bundle/ChillTicketBundle/src/Resources/public/types.ts @@ -55,6 +55,9 @@ export interface Comment { updatedBy: User | null; updatedAt: DateTime | null; deleted: boolean; + supplementaryComments: { + label: string; + }; } export interface AddresseeHistory { diff --git a/src/Bundle/ChillTicketBundle/src/migrations/Version20250711131126.php b/src/Bundle/ChillTicketBundle/src/migrations/Version20250711131126.php new file mode 100644 index 000000000..37ea00373 --- /dev/null +++ b/src/Bundle/ChillTicketBundle/src/migrations/Version20250711131126.php @@ -0,0 +1,33 @@ +addSql('ALTER TABLE chill_ticket.motive ADD supplementaryComments JSONB DEFAULT \'[]\' NOT NULL'); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE chill_ticket.motive DROP supplementaryComments'); + } +} diff --git a/src/Bundle/ChillTicketBundle/tests/Controller/ReplaceMotiveControllerTest.php b/src/Bundle/ChillTicketBundle/tests/Controller/ReplaceMotiveControllerTest.php index 409cbcf0e..5e899e2b4 100644 --- a/src/Bundle/ChillTicketBundle/tests/Controller/ReplaceMotiveControllerTest.php +++ b/src/Bundle/ChillTicketBundle/tests/Controller/ReplaceMotiveControllerTest.php @@ -99,6 +99,8 @@ class ReplaceMotiveControllerTest extends KernelTestCase $entityManager->flush()->shouldBeCalled(); $changeEmergencyCommandHandler = $this->prophesize(ChangeEmergencyStateCommandHandler::class); + $changeEmergencyCommandHandler->__invoke(Argument::any(), Argument::any())->shouldBeCalled() + ->will(fn (array $args) => $args[0]); $handler = new ReplaceMotiveCommandHandler( new MockClock(),