Skip to content
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

[BO - Teamnet] Intégrer interfaçage à iDoss #2571

Merged
merged 14 commits into from
Jun 6, 2024

Conversation

numew
Copy link
Collaborator

@numew numew commented May 17, 2024

Ticket

#2515

Description

Interfaçage avec iDoss pour la création de dossier

Changements apportés

  • Réorganisation de la page création/édition d'un partenaire
  • Ajout des options iDoss configurable sur le partenaire
  • Envoie du dossier vers iDoss pour les partenaire configuré lors de l'acceptation de l'affectation

Pré-requis

Ajout dans env.dev (voir user et pass dans la collection postman dispo ici https://drive.google.com/drive/folders/1oH6EfN8raeA_-2iBNAX5LD0-j2M1aX_x?usp=drive_link)

FEATURE_IDOSS_ENABLE=1
IDOSS_USERNAME='XXX'
IDOSS_PASSWORD='YYY'

make load-fixtures
make worker-start

Tests

@@ -41,6 +41,8 @@ partners:
is_esabora_active: 1
type: "COMMUNE_SCHS"
competence: "VISITES"
is_idoss_active: 1
idoss_url: "https://idoss-dev.portail-familles.com/"
Copy link
Collaborator

@emilschn emilschn May 21, 2024

Choose a reason for hiding this comment

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

il faudrait peut-être un mock comme pour Esabora ?
Sinon on est tributaire de la disponibilité d'idoss pour notre CI :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

également pour le dev comme c'est arrivé lors de la coupure du web-service

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

En l'état cette URL c'est pour pouvoir tester à la main mais ce n'est pas utilisé par la CI (ceci dit je vais retravailler la partie test auto, mais on ne dépendra pas du service externe)

Copy link
Collaborator

@sfinx13 sfinx13 May 27, 2024

Choose a reason for hiding this comment

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

Comme évoqué mais pas d'urgence il faudra être capable de travailler en local (peut être fait plus tard)
Ex => http://histologe_wiremock:8080/ARS/ws/rest
Genre => http://histologe_wiremock:8080/idoss/ws/rest

Copy link
Collaborator

@emilschn emilschn left a comment

Choose a reason for hiding this comment

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

Quelques commentaires. Je n'ai pas encore testé.
Mais peut-être que ça manque de test ? (expiration du token, tester des cas qui ne sont pas censés marcher...?)

@hmeneuvrier
Copy link
Collaborator

J'ai testé le cas que tu as cité, et il est OK.
J'ai testé aussi une acceptattion d'affectation pour un partenaire ARS et c'est OK aussi (ça ne créé pas un job event).
J'ai testé la page partenaire pour différents utilisateurs et différents types de partenaires (d'où mes remarques)

Mais je pense qu'il faudrait un peu plus de TNR sur les autres interfaçages, et tester aussi les cas en erreur pour vérifier qu'on reçoit les erreurs convenablement.

migrations/Version20240517072810.php Show resolved Hide resolved
@@ -41,6 +41,8 @@ partners:
is_esabora_active: 1
type: "COMMUNE_SCHS"
competence: "VISITES"
is_idoss_active: 1
idoss_url: "https://idoss-dev.portail-familles.com/"
Copy link
Collaborator

Choose a reason for hiding this comment

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

également pour le dev comme c'est arrivé lors de la coupure du web-service

src/Entity/Partner.php Outdated Show resolved Hide resolved
src/Service/Idoss/IdossService.php Show resolved Hide resolved
src/Service/Idoss/IdossService.php Outdated Show resolved Hide resolved
Copy link
Collaborator

@sfinx13 sfinx13 left a comment

Choose a reason for hiding this comment

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

Proposition d'évolution pour éviter de s'appuyer sur le statut des affectations

Introduction d'événements explicites
Faudrait introduire des événements explicites pour éviter la dépendance au statut d'affectation et rendre le code plus lisible sur les conditions d'envoi

Stockage des événements en base
Dans le champ de type JSON discuté en PR event_name peut être ajouté pour stocker le type d'événement (acceptation ou affectation).
En constante dans le dossierMessageFactories ça sera plus simple

Modification du contrôleur
Le contrôleur doit être capable de différencier si l'événement est une acceptation ou une affectation.

    $this->interconnectionBus->dispatch($affectation, $event);

Mise à jour du bus d'interconnexion
La méthode dispatch du InterconnectionBus doit être mise à jour pour inclure l'événement en tant que paramètre.

    public function dispatch(Affectation $affectation, string $event): void
    {
        /** @var DossierMessageFactoryInterface $dossierMessageFactory */
        foreach ($this->dossierMessageFactories as $dossierMessageFactory) {
            if ($dossierMessageFactory->supports($affectation, $event) {
                $this->messageBus->dispatch($dossierMessageFactory->createInstance($affectation));
            }
        }
    }

Les dossierMessageFactories doivent supporter ce nouveau paramètre

    public function supports(Affectation $affectation, string $event): bool
    {
        return $event === $dossierMessageFactory->getEvent()
            && $this->isEsaboraPartnerActive($affectation)
            && PartnerType::ARS === $affectation->getPartner()->getType();
    }

Faire évoluer l'interface pour forcer la déclaration d’événement pour chaque dossier factory

#[AutoconfigureTag('app.dossier_message_factory')]
interface DossierMessageFactoryInterface
{
    public function getEvent() : string;

    public function supports(Affectation $affectation, string $event): bool;

    public function createInstance(Affectation $affectation): DossierMessageInterface;
}

Copy link
Collaborator

@sfinx13 sfinx13 left a comment

Choose a reason for hiding this comment

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

J'ai laissé 3 com mais lecture et test OK

} catch (\Exception $e) {
$responseContent = $e->getMessage();
$status = JobEvent::STATUS_FAILED;
$statusCode = 9999;
Copy link
Collaborator

Choose a reason for hiding this comment

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

restons sur les codes erreur http (500 fera l'affaire)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Je préfère garder un code à part en cas d'exception pour justement savoir que ce n'est pas un retour erreur serveur

private ?string $idossToken = null;

#[ORM\Column(type: Types::DATETIME_IMMUTABLE, nullable: true)]
private ?\DateTimeInterface $idossTokenExpirationDate = null;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Rendre le type php en DateTimeImmutable, il sera donc pas nécessaire d'ajouter le paramètre doctrine type, ça sera automatique
image

@@ -41,6 +41,8 @@ partners:
is_esabora_active: 1
type: "COMMUNE_SCHS"
competence: "VISITES"
is_idoss_active: 1
idoss_url: "https://idoss-dev.portail-familles.com/"
Copy link
Collaborator

@sfinx13 sfinx13 May 27, 2024

Choose a reason for hiding this comment

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

Comme évoqué mais pas d'urgence il faudra être capable de travailler en local (peut être fait plus tard)
Ex => http://histologe_wiremock:8080/ARS/ws/rest
Genre => http://histologe_wiremock:8080/idoss/ws/rest

@numew numew force-pushed the feature/2515-interfacage-idoss branch 2 times, most recently from 17d6b85 to ec1fc60 Compare May 30, 2024 08:44
@numew numew force-pushed the feature/2515-interfacage-idoss branch from 6f37b75 to b8d2e70 Compare June 6, 2024 08:02
Copy link

sonarcloud bot commented Jun 6, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
4.2% Duplication on New Code (required ≤ 3%)

See analysis details on SonarCloud

Copy link
Collaborator

@hmeneuvrier hmeneuvrier left a comment

Choose a reason for hiding this comment

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

Relecture et retests OK pour moi

@hmeneuvrier hmeneuvrier merged commit 6a21a11 into develop Jun 6, 2024
2 of 3 checks passed
@hmeneuvrier hmeneuvrier deleted the feature/2515-interfacage-idoss branch June 11, 2024 10:28
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.

4 participants