Package: edc-action-item
edc-action-itemsAdd patientaction itemsto the EdcOverviewAction items are reminders to submit a form.Action items can be configured to drive data collectionfor forms that do not fit well in a visit schedule;for forms that are required based on some clinical event.Action items are tracked. Each is allocated a uniqueaction_identifierand maintain status (New, Open, Closed).Actions can be chained. One action can create another action, group of actions or recreate itself.Adverse Events, Death, OffSchedule are all good candidates.Adverse Event reports are required based on some clinical event. Since the event must be reported, leaving the decision to report the user is not sufficient. An action item can be opened based on the clinical event and the status of the action item tracked administratively. The action item is associtaed with the AE report. Once the report is submitted, the action item closes. If additional data is required after an initial AE report is submitted, a follow-up action can automatically be opened.See moduleambition-ae.action_itemsfor examples.Defining action itemsIn the root of your App, define anaction_itemsmodule. The edc-action-item site controller willautodiscoverthis module andregisterthe action item classes.Register action item classes in theaction_itemsmodule like thissite_action_items.register(AeInitialAction)A simple action itemIn it define actions using theActionclass.fromedc_action_item.actionimportActionfromedc_action_item.site_action_itemsimportsite_action_itemsfromedc_constants.constantsHIGH_PRIORITYfromambition_ae.action_itemsimportAeFollowupAction,AeTmgActionclassAeInitialAction(Action):name=AE_INITIAL_ACTIONdisplay_name='Submit AE Initial Report'model='ambition_ae.aeinitial'show_on_dashboard=Trueinstructions='Complete the initial report and forward to the TMG'priority=HIGH_PRIORITYThe action item is associated with its modelfromedc_action_item.model_mixinsimportActionModelMixinfromedc_identifier.model_mixinsimportNonUniqueSubjectIdentifierFieldMixinclassAeInitial(ActionModelMixin,NonUniqueSubjectIdentifierFieldMixin,BaseUuidModel):action_cls=AeInitialAction...# field classesSomewhere in your code, instantiate the action itemAeInitialAction(subject_identifier='12345')This creates anActionItemmodel instance for this subject with astatusofNew(if it does not exist).Now create the associated model instanceAeInitial.objects.create(subject_identifier='12345',...)TheActionItemmodel instance now has a status ofClosed.Changing the criteria to close an actionBy default an action is closed once the associated model instance has been saved. For more refined behavior defineclose_action_item_on_saveon the action item classclassAeInitialAction(Action):...defclose_action_item_on_save(self):self.delete_children_if_new(action_cls=self)returnself.model_obj.report_status==CLOSEDSingleton action itemsTo ensure an action item does not create more than one instance per subject, use thesingletonattribute.classEnrollToSubstudyAction(Action):name='My Action'display_name='Enroll to sub-study'model='myapp.enroll'show_link_to_changelist=Trueadmin_site_name='myapp_admin'priority=HIGH_PRIORITYcreate_by_user=Falsesingleton=TrueAction items that create anextaction itemFor an action item to open another action item(s) once closed, setnext_actions.classAeInitialAction(Action):name=AE_INITIAL_ACTIONdisplay_name='Submit AE Initial Report'model='ambition_ae.aeinitial'show_on_dashboard=Trueinstructions='Complete the initial report and forward to the TMG'priority=HIGH_PRIORITYnext_actions=[AeFollowupAction]If the criteria for the next action is based on some other information declareget_next_actionson the action item and return the list of action items needed.classAeInitialAction(Action):...defget_next_actions(self):next_actions=[]try:self.reference_model_cls().objects.get(ae_initial=self.model_obj.ae_initial)exceptMultipleObjectsReturned:passelse:if(self.model_obj.ae_initial.ae_classification!=self.model_obj.ae_classification):next_actions=[self]returnnext_actionsAction items with a notificationAn action item can be associated with a notification fromedc_notificationso that when an action is created a notification (email or sms) is sent to those registered to receive it.A subclass of ‘’Action``,ActionWithNotification`adds notifications to the action. The notification for the action is automatically registered when the action is registered bysite_action_items.For example:classAeTmgAction(ActionWithNotification):name=AE_TMG_ACTIONdisplay_name="TMG AE Report pending"notification_display_name="TMG AE Report"parent_action_names=[AE_INITIAL_ACTION],reference_model="ambition_ae.aetmg"related_reference_model="ambition_ae.aeinitial"related_reference_fk_attr="ae_initial"show_link_to_changelist=Trueadmin_site_name="ambition_ae_admin"