diff --git a/resources/ticket_motives_import/README.md b/resources/ticket_motives_import/README.md new file mode 100644 index 000000000..a24a80e5a --- /dev/null +++ b/resources/ticket_motives_import/README.md @@ -0,0 +1,8 @@ +In this directory, you find an example of file for the command `chill:main:ticket_motives_import`. + +This file contains a list of ticket motives to import into the system. Each entry is a dictionary with two keys: `code` and `label`. The `code` key contains the unique code for the ticket motive, and the `label` key contains the human-readable label for the ticket motive. + +The `stored_objects` key contains the documents that will be associated with the tickets. They must be found in the same directory. + +The command `chill:main:ticket_motives_import` uses this file to import the specified ticket motives into the system. + diff --git a/resources/ticket_motives_import/motives.yaml b/resources/ticket_motives_import/motives.yaml new file mode 100644 index 000000000..fb6bcb159 --- /dev/null +++ b/resources/ticket_motives_import/motives.yaml @@ -0,0 +1,136 @@ +- label: + fr: Appel famille pour annonce de décès + urgent: false + supplementary_informations: + - label: + fr: Date du décès + - label: + fr: lieu du décès (domicile ou hôpital) + - label: + fr: nom de l’hôpital + - label: + fr: service concerné + stored_objects: + - label: + fr: ☀️ De 07h à 21h + filename: 2_doc_20250402_Pelotons flux externes consolidés.pdf + - label: + fr: 🌙 De 21h à 07h du matin + filename: 3_doc_20250402_Pelotons flux externes consolidés.pdf + - label: + fr: 🗓️ Dimanches et jours fériés + filename: 4_doc_20250402_Pelotons flux externes consolidés.pdf +- label: + fr: 'Appel famille pour annonce absence : hospitalisation ou consultation' + urgent: false + supplementary_informations: + - label: + fr: Quel hôpital + - label: + fr: quel service + - label: + fr: pour quelles raisons + - label: + fr: 'consultation : date et heure' + - label: + fr: hospitalisation complète ou HDJ + stored_objects: + - label: + fr: ☀️ De 07h à 21h + filename: 5_doc_20250402_Pelotons flux externes consolidés.pdf + - label: + fr: 🌙 De 21h à 07h du matin + filename: 6_doc_20250402_Pelotons flux externes consolidés.pdf + - label: + fr: 🗓️ Dimanches et jours fériés + filename: 7_doc_20250402_Pelotons flux externes consolidés.pdf +- label: + fr: 'Appel famille pour annonce absence : interruption de prise en charge' + urgent: false + supplementary_informations: + - label: + fr: Pour quelles raisons ? Date + - label: + fr: durée + - label: + fr: accord médical ? + stored_objects: + - label: + fr: ☀️ De 07h à 21h + filename: 8_doc_20250402_Pelotons flux externes consolidés.pdf + - label: + fr: 🌙 De 21h à 07h du matin + filename: 9_doc_20250402_Pelotons flux externes consolidés.pdf + - label: + fr: 🗓️ Dimanches et jours fériés + filename: 10_doc_20250402_Pelotons flux externes consolidés.pdf +- label: + fr: 'Appel famille pour annonce absence : changement d’adresse' + urgent: false + supplementary_informations: + - label: + fr: Où + - label: + fr: Pourquoi ? Pour combien de temps ? Besoin d’un relais des soins ? Nouvelle adresse ? + stored_objects: + - label: + fr: ☀️ De 07h à 21h + filename: 11_doc_20250402_Pelotons flux externes consolidés.pdf + - label: + fr: 🌙 De 21h à 07h du matin + filename: 12_doc_20250402_Pelotons flux externes consolidés.pdf + - label: + fr: 🗓️ Dimanches et jours fériés + filename: 13_doc_20250402_Pelotons flux externes consolidés.pdf +- label: + fr: Appel famille pour altération de l’état général du patient + urgent: true + supplementary_informations: + - label: + fr: Recherche des symptômes + - label: + fr: Attentes par rapport à la demande + stored_objects: + - label: + fr: ☀️ De 07h à 21h + filename: 14_doc_20250402_Pelotons flux externes consolidés.pdf + - label: + fr: 🌙 De 21h à 07h du matin + filename: 15_doc_20250402_Pelotons flux externes consolidés.pdf + - label: + fr: 🗓️ Dimanches et jours fériés + filename: 16_doc_20250402_Pelotons flux externes consolidés.pdf +- label: + fr: Appel famille pour prise en charge de la douleur + urgent: true + supplementary_informations: + - label: + fr: Localisation douleur + - label: + fr: Horaire dernier passage + - label: + fr: Traitements en cours + stored_objects: + - label: + fr: ☀️ De 07h à 21h + filename: 17_doc_20250402_Pelotons flux externes consolidés.pdf + - label: + fr: 🌙 De 21h à 07h du matin + filename: 18_doc_20250402_Pelotons flux externes consolidés.pdf + - label: + fr: 🗓️ Dimanches et jours fériés + filename: 19_doc_20250402_Pelotons flux externes consolidés.pdf +- label: + fr: Appel famille pour information sur la date de prise en charge + urgent: false + supplementary_informations: [] + stored_objects: + - label: + fr: ☀️ De 07h à 21h + filename: 20_doc_20250402_Pelotons flux externes consolidés.pdf + - label: + fr: 🌙 De 21h à 07h du matin + filename: 21_doc_20250402_Pelotons flux externes consolidés.pdf + - label: + fr: 🗓️ Dimanches et jours fériés + filename: 22_doc_20250402_Pelotons flux externes consolidés.pdf diff --git a/resources/translation_override/README.md b/resources/translation_override/README.md new file mode 100644 index 000000000..837f071fd --- /dev/null +++ b/resources/translation_override/README.md @@ -0,0 +1,6 @@ +In this directory, you find an example of file for the command `chill:main:override_translation`. + +This file contains a list of translations to override in the translation catalogue. Each entry is a dictionary with two keys: `from` and `to`. The `from` key contains the original translation string, and the `to` key contains the replacement string. + +The command `chill:main:override_translation` uses this file to generate a new translation catalogue with the specified overrides applied. + diff --git a/resources/translation_override/overrides.yaml b/resources/translation_override/overrides.yaml new file mode 100644 index 000000000..c9f896df0 --- /dev/null +++ b/resources/translation_override/overrides.yaml @@ -0,0 +1,8 @@ +- {from: "de l'usager", to: "du patient"} +- {from: "l'usager", to: "le patient"} +- {from: "L'usager", to: "Le patient"} +- {from: "d'usagers", to: "de patients"} +- {from: "usagers", to: "patients"} +- {from: "Usagers", to: "Patients"} +- {from: "usager", to: "patient"} +- {from: "Usager", to: "Patient"} diff --git a/src/Bundle/ChillMainBundle/Command/OverrideTranslationCommand.php b/src/Bundle/ChillMainBundle/Command/OverrideTranslationCommand.php new file mode 100644 index 000000000..0f8070456 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Command/OverrideTranslationCommand.php @@ -0,0 +1,115 @@ +setName('chill:main:override_translation'); + parent::__construct(); + } + + protected function configure(): void + { + $this + ->setDescription('Generate a translation catalogue with translation remplacements based on replacements provided in a YAML file.') + ->addArgument('locale', InputArgument::REQUIRED, 'The locale to process (e.g. fr, en).') + ->addArgument('overrides', InputArgument::REQUIRED, 'Path to the overrides YAML file (list of {from, to}).'); + } + + protected function execute(InputInterface $input, OutputInterface $output): int + { + $locale = (string) $input->getArgument('locale'); + $overridesPath = (string) $input->getArgument('overrides'); + + $catalogue = $this->loadCatalogue($locale); + $overrides = $this->loadOverrides($overridesPath); + + + $toOverrideCatalogue = new MessageCatalogue($locale); + foreach ($catalogue->getDomains() as $domain) { + // hack: we have to replace the suffix ".intl-icu" by "+intl-ic" + $domain = str_replace('.intl-icu', '+intl-icu', $domain); + foreach ($catalogue->all($domain) as $key => $translation) { + foreach ($overrides as $changes) { + $from = $changes['from']; + $to = $changes['to']; + + if (is_string($translation) && str_contains($translation, $from)) { + $newTranslation = strtr($translation, [$from => $to]); + $toOverrideCatalogue->set($key, $newTranslation, $domain); + $translation = $newTranslation; + } + } + } + } + + /** @var KernelInterface $kernel */ + /* @phpstan-ignore-next-line */ + $kernel = $this->getApplication()->getKernel(); + $outputDir = rtrim($kernel->getProjectDir(), '/').'/translations'; + if (!is_dir($outputDir)) { + @mkdir($outputDir, 0775, true); + } + + // Writer expects the 'path' option to be a directory; it will create the proper file name + $this->writer->write($toOverrideCatalogue, 'yaml', ['path' => $outputDir]); + + $output->writeln(sprintf('Override catalogue written to %s (domain: messages, locale: %s).', $outputDir, $locale)); + + return Command::SUCCESS; + } + + /** + * @return list + */ + private function loadOverrides(string $path): array + { + return Yaml::parseFile($path); + } + + private function loadCatalogue(string $locale): MessageCatalogue + { + /** @var KernelInterface $kernel */ + /* @phpstan-ignore-next-line */ + $kernel = $this->getApplication()->getKernel(); + + // collect path for translations + $transPaths = []; + foreach ($kernel->getBundles() as $bundle) { + $bundleDir = $bundle->getPath(); + $transPaths[] = is_dir($bundleDir.'/Resources/translations') ? $bundleDir.'/Resources/translations' : $bundle->getPath().'/translations'; + } + + $currentCatalogue = new MessageCatalogue($locale); + foreach ($transPaths as $path) { + if (is_dir($path)) { + $this->reader->read($path, $currentCatalogue); + } + } + + return $currentCatalogue; + } +} diff --git a/src/Bundle/ChillMainBundle/config/services/command.yaml b/src/Bundle/ChillMainBundle/config/services/command.yaml index 313ca28c5..2b765a1c1 100644 --- a/src/Bundle/ChillMainBundle/config/services/command.yaml +++ b/src/Bundle/ChillMainBundle/config/services/command.yaml @@ -42,38 +42,26 @@ services: - { name: console.command } Chill\MainBundle\Command\LoadAddressesFRFromBANOCommand: - autoconfigure: true - autowire: true tags: - { name: console.command } Chill\MainBundle\Command\LoadAddressesFRFromBANCommand: - autoconfigure: true - autowire: true tags: - { name: console.command } Chill\MainBundle\Command\LoadAddressesBEFromBestAddressCommand: - autoconfigure: true - autowire: true tags: - { name: console.command } Chill\MainBundle\Command\LoadPostalCodeFR: - autoconfigure: true - autowire: true tags: - { name: console.command } Chill\MainBundle\Command\LoadAddressesLUFromBDAddressCommand: - autoconfigure: true - autowire: true tags: - { name: console.command } Chill\MainBundle\Command\ExecuteCronJobCommand: - autoconfigure: true - autowire: true tags: - {name: console.command } @@ -81,6 +69,6 @@ services: tags: - {name: console.command} - Chill\MainBundle\Command\DumpListPermissionsCommand: - autoconfigure: true - autowire: true + Chill\MainBundle\Command\DumpListPermissionsCommand: ~ + + Chill\MainBundle\Command\OverrideTranslationCommand: ~