Skip to content

Commit

Permalink
feat(#706): shorten phenoconversion text on gene page
Browse files Browse the repository at this point in the history
  • Loading branch information
tamslo committed Sep 4, 2024
1 parent fe8c73b commit ed15bb7
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 57 deletions.
50 changes: 49 additions & 1 deletion app/lib/common/models/drug/drug_inhibitors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,54 @@ String possiblyAdaptedPhenotype(GenotypeResult genotypeResult) {
return '$overwritePhenotype$drugInteractionIndicator';
}

String getDrugNames(String drugName) {
final drug = CachedDrugs.instance.drugs!.firstWhere(
(drug) => drug.name == drugName
);
if (drug.annotations.brandNames.isEmpty) return drugName;
return '$drugName (${drug.annotations.brandNames.join(', ')})';
}

String inhibitionTooltipText(
BuildContext context,
GenotypeResult genotypeResult,
{ String? drug }
) {
final activeInhibitors = activeInhibitorsFor(
genotypeResult.gene,
drug: drug,
);
final activeInhibitorsWithBrandNames =
activeInhibitors.map(getDrugNames).toList();
final inhibitorsString = enumerationWithAnd(
activeInhibitorsWithBrandNames,
context,
);
return context.l10n.inhibitors_tooltip(inhibitorsString);
}

Table buildDrugInteractionInfo(
BuildContext context,
GenotypeResult genotypeResult,
{ String? drug }
) {
final activeInhibitors = activeInhibitorsFor(
genotypeResult.gene,
drug: drug,
);
final consequence = activeInhibitors.all(isModerateInhibitor)
? context.l10n.inhibitors_consequence_not_adapted
: context.l10n.inhibitors_consequence_adapted(genotypeResult.phenotype);
return buildTable([
TableRowDefinition(
drugInteractionIndicator,
'${context.l10n.inhibitor_message} ($consequence)',
tooltip: inhibitionTooltipText(context, genotypeResult, drug: drug),
)],
boldHeader: false,
);
}

bool isInhibited(
GenotypeResult genotypeResult,
{ String? drug }
Expand Down Expand Up @@ -191,4 +239,4 @@ MapEntry<String, String>? getOverwrittenLookup (
});
if (lookup == null) return null;
return lookup;
}
}
21 changes: 19 additions & 2 deletions app/lib/common/widgets/annotation_table.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import '../../drug/widgets/tooltip_icon.dart';
import '../module.dart';

class TableRowDefinition {
const TableRowDefinition(this.key, this.value);
const TableRowDefinition(this.key, this.value, { this.tooltip });
final String key;
final String value;
final String? tooltip;
}

Table buildTable(
Expand All @@ -21,6 +23,7 @@ Table buildTable(
style ?? PharMeTheme.textTheme.bodyMedium!,
boldHeader: boldHeader,
isLast: index == rowDefinitions.length - 1,
tooltip: rowDefinition.tooltip,
)).toList(),
);
}
Expand All @@ -32,6 +35,7 @@ TableRow _buildRow(
{
required bool boldHeader,
required bool isLast,
String? tooltip,
}
) {
return TableRow(
Expand All @@ -48,7 +52,20 @@ TableRow _buildRow(
: textStyle,
),
),
Text(value, style: textStyle),
Text.rich(
TextSpan(
children: [
TextSpan(text: value),
if (tooltip.isNotNullOrBlank) ...[
TextSpan(text: ' '),
WidgetSpan(
child: TooltipIcon(tooltip!),
),
],
],
style: textStyle,
),
),
],
);
}
7 changes: 5 additions & 2 deletions app/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@
}
},

"inhibitor_message": "One or more of the medications you are currently taking may interact with your genetic result",
"inhibitors_consequence_adapted": "phenotype adapted from {originalPhenotype}",
"inhibitors_consequence_not_adapted": "phenotype not adapted",
"inhibitors_tooltip": "Current interacting medications: {inhibitors}",

"drugs_page_inhibitor_direct_salutation": "you are",
"drugs_page_inhibitor_direct_salutation_genitive": "your",
"drugs_page_inhibitor_third_person_salutation": "the user is",
Expand Down Expand Up @@ -271,8 +276,6 @@
}
},
"gene_page_no_relevant_drugs": "This gene has no known effect on any medications.",
"gene_page_inhibitor_drugs": "The following medications can interact with your results for this gene:",
"gene_page_further_inhibitor_drugs": "The following medications can also interact with your results for this gene:",
"gene_page_activity_score": "Activity score",


Expand Down
56 changes: 4 additions & 52 deletions app/lib/report/pages/gene.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,13 @@ class GenePage extends HookWidget {
_buildPhenotypeRow(context),
],
),
if (isInhibited(genotypeResult))
...buildDrugInteractionInfo(
if (isInhibited(genotypeResult)) ...[
SizedBox(height: PharMeTheme.smallSpace),
buildDrugInteractionInfo(
context,
genotypeResult,
),
]
],
)),
SizedBox(height: PharMeTheme.smallToMediumSpace),
Expand Down Expand Up @@ -117,54 +119,4 @@ class GenePage extends HookWidget {
),
Padding(padding: EdgeInsets.fromLTRB(0, 4, 0, 4), child: Text(value)),
]);

List<Widget> buildDrugInteractionInfo(
BuildContext context,
GenotypeResult genotypeResult,
) {
final phenotypeInformation = UserData.phenotypeInformationFor(
genotypeResult,
context,
useLongPrefix: true,
);
if (phenotypeInformation.adaptionText.isNotNullOrBlank) {
final furtherInhibitors = inhibitorsFor(genotypeResult.gene).filter(
(drugName) =>
!UserData.activeInhibitorsFor(genotypeResult.gene).contains(drugName)
);
var phenotypeInformationText = '';
if (phenotypeInformation.overwrittenPhenotypeText.isNotNullOrBlank) {
phenotypeInformationText = '${formatAsSentence(
phenotypeInformation.overwrittenPhenotypeText!
)} ';
}
phenotypeInformationText = '$phenotypeInformationText${formatAsSentence(
phenotypeInformation.adaptionText!
)}';
return [
SizedBox(height: PharMeTheme.smallSpace),
buildTable(
[TableRowDefinition(
drugInteractionIndicator,
phenotypeInformationText,
)],
boldHeader: false,
),
SizedBox(height: PharMeTheme.smallSpace),
Text(context.l10n.gene_page_further_inhibitor_drugs),
SizedBox(height: PharMeTheme.smallSpace),
Text(
furtherInhibitors.join(', ')
),
];
}
return [
SizedBox(height: PharMeTheme.smallSpace),
Text(context.l10n.gene_page_inhibitor_drugs),
SizedBox(height: PharMeTheme.smallSpace),
Text(
inhibitorsFor(genotypeResult.gene).join(', ')
),
];
}
}

0 comments on commit ed15bb7

Please sign in to comment.