diff --git a/app/Modules/Group/Events/GroupEvent.php b/app/Modules/Group/Events/GroupEvent.php index ae2374c8b..efcf1f4c2 100644 --- a/app/Modules/Group/Events/GroupEvent.php +++ b/app/Modules/Group/Events/GroupEvent.php @@ -66,7 +66,10 @@ public function getTopic(): string */ public function shouldPublish(): bool { - return $this->group->isEp; + + return $this->group->isEp || $this->group->isWg || $this->group->isCdwg; + + } abstract public function getLogEntry() :string; diff --git a/app/Modules/Group/Events/GroupStatusUpdated.php b/app/Modules/Group/Events/GroupStatusUpdated.php index ddad56e6b..81dc856a5 100644 --- a/app/Modules/Group/Events/GroupStatusUpdated.php +++ b/app/Modules/Group/Events/GroupStatusUpdated.php @@ -23,6 +23,11 @@ class GroupStatusUpdated extends GroupEvent */ public function __construct(public Group $group, public GroupStatus $newStatus, public GroupStatus $oldStatus) { + + // Only process the event if the status is 2 or 5 + if (!in_array($this->group->group_status_id, [2, 5])) { + return; + } } public function getLogEntry(): string diff --git a/app/Modules/Group/Events/Traits/IsPublishableApplicationEvent.php b/app/Modules/Group/Events/Traits/IsPublishableApplicationEvent.php index 5f6e62b19..f2ebc8f41 100644 --- a/app/Modules/Group/Events/Traits/IsPublishableApplicationEvent.php +++ b/app/Modules/Group/Events/Traits/IsPublishableApplicationEvent.php @@ -18,16 +18,26 @@ public function getEventType(): string } public function getPublishableMessage(): array - { - return [ - 'expert_panel' => [ - 'id' => $this->group->uuid, - 'name' => $this->group->displayName, - 'type' => $this->group->fullType->name, - 'affiliation_id' => $this->group->expertPanel->affiliation_id - ], - ]; - } +{ + return [ + 'expert_panel' => array_merge([ + 'id' => $this->group->uuid, + 'long_name' => $this->group->name, + 'short_name' => $this->group->expertPanel->short_base_name, + 'status' => optional($this->group->groupStatus)->name, // Retrieve the status name + 'parent_group' => optional($this->group->parentGroup)->name, + 'type' => $this->group->fullType->name, + 'affiliation_id' => $this->group->expertPanel->affiliation_id, + ], + // Conditionally add vcep fields below if type is 'vcep' + $this->group->fullType->name === 'vcep' ? ['clinvar_id' => null] : [], + $this->group->fullType->name === 'vcep' ? ['clinvar_url' => null] : [], + $this->group->fullType->name === 'vcep' ? ['cspec_url' => $this->group->expertPanel->affiliation_id] : [], + $this->group->fullType->name === 'vcep' ? ['vspec_web_address' => null] : [], + ) + ]; +} + public function mapGeneForMessage($gene): array { diff --git a/app/Modules/Group/Models/Group.php b/app/Modules/Group/Models/Group.php index 6fbb777b3..3688274c5 100644 --- a/app/Modules/Group/Models/Group.php +++ b/app/Modules/Group/Models/Group.php @@ -268,4 +268,11 @@ protected static function newFactory() { return new GroupFactory(); } + + public function parentGroup(): BelongsTo + { + return $this->belongsTo(Group::class, 'parent_id', 'id'); + } + + } diff --git a/app/Modules/Person/Events/Traits/PublishesEvent.php b/app/Modules/Person/Events/Traits/PublishesEvent.php index 829add47f..46c037923 100644 --- a/app/Modules/Person/Events/Traits/PublishesEvent.php +++ b/app/Modules/Person/Events/Traits/PublishesEvent.php @@ -27,6 +27,7 @@ public function shouldPublish(): bool return true; } + public function getPublishableMessage(): array { return [ @@ -46,9 +47,6 @@ public function getPublishableMessage(): array ]; } - - - private function getInstitutionMessage(): ?array { if (!$this->person->institution_id) { diff --git a/config/dx.php b/config/dx.php index cae08a0eb..18cb0e49a 100644 --- a/config/dx.php +++ b/config/dx.php @@ -55,8 +55,8 @@ * The current schema version of messsages sent to a particular topic. */ 'schema_versions' => [ - 'gpm-general-events' => '1.1.0', - 'gpm-person-events' => '1.1.0' + 'gpm-general-events' => '1.2.0', + 'gpm-person-events' => '1.2.0' ] ];