Skip to content

Commit

Permalink
rdrf #2444 use custom naming for proms forms in Traffic light
Browse files Browse the repository at this point in the history
  • Loading branch information
id2359 committed Apr 11, 2023
1 parent 5f3071d commit b38d7cf
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
15 changes: 13 additions & 2 deletions rdrf/dashboards/components/tl.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,19 @@ def _fix_ordering_of_static_followups(self, df):
changed = True

if changed:
logger.debug("sequence changed for static, renaming")
df = assign_seq_names(df).sort_values(by="SEQ")
from rdrf.models.definition.models import RegistryForm

def static_get_seq_name(seq, form):
if form == self.static_followups["baseline"]:
form_model = RegistryForm.objects.get(name=form)
return form_model.display_name
else:
for form_dict in self.static_followups["followups"]:
if form_dict["name"] == form:
form_model = RegistryForm.objects.get(name=form)
return form_model.display_name

df = assign_seq_names(df, static_get_seq_name).sort_values(by="SEQ")

return df

Expand Down
14 changes: 10 additions & 4 deletions rdrf/dashboards/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,14 @@ def get_aus_date(row):
return ""


def assign_seq_names(df):
df["SEQ_NAME"] = df.apply(
lambda row: get_seq_name(row["SEQ"]) + get_aus_date(row), axis=1
)
def assign_seq_names(df, func=None):
if func is None:
df["SEQ_NAME"] = df.apply(
lambda row: get_seq_name(row["SEQ"]) + get_aus_date(row), axis=1
)
else:
df["SEQ_NAME"] = df.apply(
lambda row: func(row["SEQ"], row["FORM"]) + get_aus_date(row), axis=1
)

return df

0 comments on commit b38d7cf

Please sign in to comment.