Skip to content

Commit

Permalink
Merge branch 'release/0.3.76' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
erikvw committed Feb 11, 2024
2 parents 0abc3aa + b795d32 commit 633a926
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
&nbsp;{{ listboard_panel_title }}&nbsp; {% if results|length > 0 %}&nbsp;<span class="label label-{% if status == CLOSED %}success{% else %}danger{% endif %}">{{ results|length }} of {{ paginator.count }}</span>{% endif %}

<span class="pull-right">
{% include 'edc_dashboard/bootstrap3/search_form.html' %}
{% if subject_identifier %}
<a class="btn btn-sm btn-primary" role="button" title="go to list of reported visits for this subject" href="{% url subject_review_listboard_url|default:"subject_review_listboard_url_cannot_be_none" subject_identifier=subject_identifier %}?q={{ subject_identifier }}">Subject Review <i class="fas fa-share fa-fw"></i></a>
{% endif %}
{% include 'edc_dashboard/bootstrap3/search_form.html' %}
</span></span>

</div> <!--end panel heading -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,57 +14,63 @@
{% if may_access_page %}
{% for result in results %}
<div class="panel panel-default">
<div class="panel-heading"><h5><span class="badge">{{ forloop.counter }}</span> <span class="text text-uppercase">{{ result.subject_identifier }}</span> {% copy_string_to_clipboard_button result.subject_identifier %} <span class="text text-muted small">{{ utc_date|timeuntil:result.report_datetime.date }} ago</span></h5></div>
<div class="panel-heading clearfix">
<span class="badge">{{ forloop.counter }}</span> <span class="text text-uppercase">{{ result.subject_identifier }}</span> {% copy_string_to_clipboard_button result.subject_identifier %} <span class="text text-muted small">{{ utc_date|timeuntil:result.report_datetime.date }} ago</span>
<span class="pull-right">
<div class="btn-group">
<a class="btn btn-sm btn-default" role="button" title="Go to action item" href="{{ result.get_absolute_url }}?next={{ listboard_filter_url }},subject_identifier&subject_identifier={{ result.subject_identifier }}">{{ result.identifier }}</a>
<a class="btn btn-sm btn-primary" role="button" title="go to list of reported visits for this subject" href="{% url subject_review_listboard_url|default:"subject_review_listboard_url_cannot_be_none" subject_identifier=result.subject_identifier %}?q={{ result.subject_identifier }}">Subject Review <i class="fas fa-share fa-fw"></i></a>
</div>
</span>
</div>
<div class="panel-body">
<div class="row">
<div class="col-md-4">

<div class="list-group">
{# AE TMG #}
{% render_tmg_panel action_item=result by_user_created_only=True counter=forloop.counter report_status=result.reference_obj.report_status %}
</div>
<div class="list-group-item list-group-item-default"><i class="fa-solid fa-folder-tree fa-fw"></i> TMG documents in workflow</div>
{% render_tmg_panel action_item=result by_user_created_only=True counter=forloop.counter report_status=result.reference_obj.report_status next_url_name=listboard_filter_url %}

{% death_report_tmg_queryset action_item=result as qs %}
{% for death_report_tmg in qs %}
{% render_tmg_panel reference_obj=death_report_tmg by_user_created_only=True counter=forloop.counter %}
{% render_tmg_panel reference_obj=death_report_tmg by_user_created_only=True counter=forloop.counter next_url_name=listboard_filter_url %}
{% endfor %}

{% death_report_tmg2_queryset action_item=result as qs %}
{% for death_report_tmg2 in qs %}
{% render_tmg_panel reference_obj=death_report_tmg2 by_user_created_only=True counter=forloop.counter %}
{% render_tmg_panel reference_obj=death_report_tmg2 by_user_created_only=True counter=forloop.counter next_url_name=listboard_filter_url %}
{% endfor %}

</div>
</div>

<div class="col-md-4">
<div class="list-group">
{# AE INTIAL #}
{% render_tmg_panel action_item=result.parent_action_item counter=forloop.counter %}
{% if result.parent_action_item.reference_obj.action_identifier != result.related_action_item.reference_obj.action_identifier %}
{% render_tmg_panel action_item=result.related_action_item counter=forloop.counter %}
<div class="list-group-item"><i class="fa-regular fa-file fa-fw"></i> First document in workflow</div>
{% if result.parent_action_item %}
{% render_tmg_panel action_item=result.parent_action_item counter=forloop.counter next_url_name=listboard_filter_url %}
{% if result.related_action_item and result.parent_action_item.reference_obj.action_identifier != result.related_action_item.reference_obj.action_identifier %}
{% render_tmg_panel action_item=result.related_action_item counter=forloop.counter next_url_name=listboard_filter_url %}
{% endif %}
{% endif %}
</div>
</div>

<div class="col-md-4">

<div class="list-group">
<div class="list-group-item"><i class="fa-solid fa-folder-tree fa-fw"></i> Clinical documents in workflow</div>
{% ae_followup_queryset ae_initial=result.parent_action_item.reference_obj as qs %}
{% if qs.count == 0 %}<div class="list-group-item">There are no follow-ups to this AE</div>{% endif %}
{% for ae_followup in qs %}
{% render_tmg_panel reference_obj=ae_followup counter=forloop.counter %}
{% render_tmg_panel reference_obj=ae_followup counter=forloop.counter next_url_name=listboard_filter_url %}
{% endfor %}

{% death_report_queryset subject_identifier=result.subject_identifier as qs %}
{% for death_report in qs %}
{% render_tmg_panel reference_obj=death_report counter=forloop.counter %}
{% render_tmg_panel reference_obj=death_report counter=forloop.counter next_url_name=listboard_filter_url %}
{% endfor %}

<div class="list-group-item">
<a class="btn btn-sm btn-primary" role="button" title="go to list of reported visits for this subject" href="{% url subject_review_listboard_url|default:"subject_review_listboard_url_cannot_be_none" %}?q={{ result.subject_identifier }}">Subject Review <i class="fas fa-share"></i></a>
</div>

<div class="list-group-item">
<a class="btn btn-sm btn-default" role="button" title="Go to action item" href="{{ result.get_absolute_url }}?next=edc_adverse_event:open_tmg_ae_listboard_url">{{ result.identifier }}</a> {{ result.display_name }}
</div>

</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{% if subject_identifier %}
<div class="btn-group">
<a class="btn btn-sm btn-default" href="{% url "edc_adverse_event:tmg_home_url" %}">TMG</a>
<a class="btn btn-sm btn-primary" href="{% url "edc_adverse_event:new_tmg_ae_listboard_url" subject_identifier=subject_identifier %}">New</a>
<a class="btn btn-sm btn-primary" href="{% url "edc_adverse_event:open_tmg_ae_listboard_url" subject_identifier=subject_identifier %}">Open</a>
<a class="btn btn-sm btn-primary" href="{% url "edc_adverse_event:closed_tmg_ae_listboard_url" subject_identifier=subject_identifier %}">Closed</a>
</div>
{% endif %}
81 changes: 48 additions & 33 deletions edc_adverse_event/templatetags/edc_adverse_event_extras.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,44 +189,49 @@ def render_tmg_panel(
by_user_created_only: bool | None = None,
counter: int = None,
report_status: str | None = None,
next_url_name: str | None = None,
) -> dict:
reference_obj = reference_obj or get_reference_obj(action_item)
if not action_item and reference_obj:
action_item = reference_obj.action_item
disable_all = True if not has_valid_tmg_perms(request=context["request"]) else False
btn = TmgButton(
user=context["request"].user,
subject_identifier=action_item.subject_identifier,
model_obj=reference_obj,
model_cls=action_item.action_cls.reference_model_cls(),
request=context["request"],
only_user_created_may_access=by_user_created_only,
forloop_counter=counter,
current_site=context["request"].site,
disable_all=disable_all,
)
if view_only:
panel_color = "info"
elif not reference_obj:
panel_color = "warning"
else:
panel_color = "success"

# panel_label
display_name = action_item.display_name.replace("Submit", "").replace("pending", "")
identifier = action_item.identifier or "New"
panel_label = _(f"{display_name} {identifier}")

return dict(
btn=btn,
panel_color=panel_color,
reference_obj=reference_obj,
action_item=action_item,
OPEN=OPEN,
CLOSED=CLOSED,
report_status=report_status,
panel_label=panel_label,
)
if action_item:
params = dict(
user=context["request"].user,
subject_identifier=action_item.subject_identifier,
model_obj=reference_obj,
model_cls=action_item.action_cls.reference_model_cls(),
request=context["request"],
only_user_created_may_access=by_user_created_only,
forloop_counter=counter,
current_site=context["request"].site,
disable_all=disable_all,
action_item=action_item,
)
if next_url_name:
params.update(next_url_name=next_url_name.split(":")[1])
btn = TmgButton(**params)
if view_only:
panel_color = "info"
elif not reference_obj:
panel_color = "warning"
else:
panel_color = "success"
# panel_label
display_name = action_item.display_name.replace("Submit", "").replace("pending", "")
identifier = action_item.identifier or "New"
panel_label = _(f"{display_name} {identifier}")
return dict(
btn=btn,
panel_color=panel_color,
reference_obj=reference_obj,
action_item=action_item,
OPEN=OPEN,
CLOSED=CLOSED,
report_status=report_status,
panel_label=panel_label,
)
return {}


@register.simple_tag(takes_context=True)
Expand All @@ -253,3 +258,13 @@ def get_empty_qs_message(status: str, search_term: str):
if search_term:
msg = f"{msg[:-1]} for your search criteria"
return _(msg)


@register.inclusion_tag(
f"edc_adverse_event/bootstrap{get_bootstrap_version()}/tmg/tmg_button_group.html",
takes_context=True,
)
def render_tmg_button_group(context, subject_identifier: str):
if context["request"].user.userprofile.roles.filter(name=TMG_ROLE).exists():
return dict(subject_identifier=subject_identifier)
return {}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class TmgAeListboardViewMixin(
navbar_name = get_default_navbar()
navbar_selected_item = "tmg_home"
ordering = "-report_datetime"
paginate_by = 50
paginate_by = 10
search_form_url = "tmg_ae_listboard_url"
action_type_names = [AE_TMG_ACTION]

Expand All @@ -54,6 +54,7 @@ def get_context_data(self, **kwargs) -> dict[str, Any]:
kwargs.update(
AE_TMG_ACTION=AE_TMG_ACTION,
utc_date=get_utcnow().date(),
subject_identifier=self.kwargs.get("subject_identifier"),
)
return super().get_context_data(**kwargs)

Expand Down
25 changes: 24 additions & 1 deletion edc_adverse_event/view_utils/tmg_button.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from edc_subject_dashboard.view_utils import ModelButton

if TYPE_CHECKING:
from edc_action_item.models import ActionItem
from edc_model.models import BaseUuidModel

from edc_adverse_event.model_mixins import (
Expand All @@ -28,11 +29,12 @@ class DeathReportModel(DeathReportModelMixin, BaseUuidModel): ...
@dataclass
class TmgButton(ModelButton):
model_obj: DeathReportTmgModel | DeathReportModel | AeFollowupModel | AeInitialModel = None
next_url_name: str = "open_tmg_ae_listboard_url"
next_url_name: str | None = field(default="open_tmg_ae_listboard_url")
only_user_created_may_access: bool | None = None
forloop_counter: int | None = None
colors: tuple[str, str, str] = field(default=("warning", "success", "success"))
titles: tuple[str, str, str] = field(default=(_("Add"), _("Change"), _("View")))
action_item: ActionItem = (None,)

disable_all: bool = False

Expand Down Expand Up @@ -88,3 +90,24 @@ def label(self) -> str:
):
return _("View")
return _(super().label)

@property
def extra_kwargs(self) -> dict[str, str | int]:
opts = {}
if self.action_item.parent_action_item:
parent_action_item = getattr(self.action_item, "parent_action_item", None)
if parent_action_item:
opts.update(
parent_action_item=str(parent_action_item.id),
)
related_action_item = getattr(self.action_item, "parent_action_item", None)
if related_action_item:
opts.update(
related_action_item=str(related_action_item.id),
)
opts = dict(
ae_initial=str(self.action_item.parent_action_item.reference_obj.id),
action_identifier=self.action_item.action_identifier,
action_item=str(self.action_item.id),
)
return opts
6 changes: 3 additions & 3 deletions edc_adverse_event/views/tmg/status_listboards.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ class NewTmgAeListboardView(StatusTmgAeListboardView):
listboard_url = "new_tmg_ae_listboard_url"
search_form_url = "new_tmg_ae_listboard_url"
status = NEW
listboard_panel_title = "TMG: New AE Reports"
listboard_panel_title = "TMG AE Reports: New"


class OpenTmgAeListboardView(StatusTmgAeListboardView):
listboard_url = "open_tmg_ae_listboard_url"
search_form_url = "open_tmg_ae_listboard_url"
status = OPEN
listboard_panel_title = "TMG: Open AE Reports"
listboard_panel_title = "TMG AE Reports: Open"


class ClosedTmgAeListboardView(StatusTmgAeListboardView):
listboard_url = "closed_tmg_ae_listboard_url"
search_form_url = "closed_tmg_ae_listboard_url"
status = CLOSED
listboard_panel_title = "TMG: Closed AE Reports"
listboard_panel_title = "TMG AE Reports: Closed"

0 comments on commit 633a926

Please sign in to comment.