Skip to content

Commit

Permalink
SCKAN-275 feat: Add automatic creation of anatomical entities
Browse files Browse the repository at this point in the history
  • Loading branch information
afonsobspinto committed Mar 21, 2024
1 parent 7b735ed commit fadd3aa
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions backend/composer/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
from django_fsm.signals import post_transition

from .enums import CSState, NoteType
from .models import ConnectivityStatement, ExportBatch, Note, Sentence, AnatomicalEntity
from .models import ConnectivityStatement, ExportBatch, Note, Sentence, AnatomicalEntity, AnatomicalEntityIntersection, \
AnatomicalEntityMeta
from .services.export_services import compute_metrics, ConnectivityStatementStateService


Expand Down Expand Up @@ -41,8 +42,20 @@ def post_transition_callback(sender, instance, name, source, target, **kwargs):
def post_transition_cs(sender, instance, name, source, target, **kwargs):
if issubclass(sender, ConnectivityStatement):
if target == CSState.COMPOSE_NOW and source in (
CSState.NPO_APPROVED,
CSState.EXPORTED,
CSState.NPO_APPROVED,
CSState.EXPORTED,
):
# add important tag to CS when transition to COMPOSE_NOW from NPO Approved or Exported
instance = ConnectivityStatementStateService.add_important_tag(instance)
instance = ConnectivityStatementStateService.add_important_tag(instance)


@receiver(post_save, sender=AnatomicalEntityIntersection)
def create_region_layer_anatomical_entity(sender, instance=None, created=False, **kwargs):
if created and instance:
AnatomicalEntity.objects.create(region_layer=instance)


@receiver(post_save, sender=AnatomicalEntityMeta)
def create_simple_anatomical_entity(sender, instance=None, created=False, **kwargs):
if created and instance:
AnatomicalEntity.objects.create(simple_entity=instance)

0 comments on commit fadd3aa

Please sign in to comment.