Skip to content

Commit

Permalink
refactor(#706): add function to get possibly inhibited phenotype
Browse files Browse the repository at this point in the history
  • Loading branch information
tamslo committed Sep 4, 2024
1 parent 7fba3f0 commit 247c390
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
12 changes: 12 additions & 0 deletions app/lib/common/models/userdata/userdata.dart
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,18 @@ List<String> activeDrugsFromHTTPResponse(Response resp) {
return activeDrugs;
}

String possiblyAdaptedPhenotype(GenotypeResult genotypeResult) {
final originalPhenotype = genotypeResult.phenotypeDisplayString;
if (!isInhibited(genotypeResult)) {
return originalPhenotype;
}
final overwrittenLookup = UserData.overwrittenLookup(genotypeResult.gene);
if (overwrittenLookup == null) {
return '$originalPhenotype$drugInteractionIndicator';
}
return '$overwritePhenotype$drugInteractionIndicator';
}

bool isInhibited(
GenotypeResult genotypeResult,
{ String? drug }
Expand Down
5 changes: 1 addition & 4 deletions app/lib/report/pages/gene.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,9 @@ class GenePage extends HookWidget {
}

TableRow _buildPhenotypeRow(BuildContext context) {
final phenotypeText = isInhibited(genotypeResult)
? '${genotypeResult.phenotypeDisplayString}$drugInteractionIndicator'
: genotypeResult.phenotypeDisplayString;
return _buildRow(
context.l10n.gene_page_phenotype,
phenotypeText,
possiblyAdaptedPhenotype(genotypeResult),
tooltip:
context.l10n.gene_page_phenotype_tooltip,
);
Expand Down
5 changes: 1 addition & 4 deletions app/lib/report/pages/report.dart
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,6 @@ class GeneCard extends StatelessWidget {

@override
Widget build(BuildContext context) {
final phenotypeText = isInhibited(genotypeResult)
? genotypeResult.phenotypeDisplayString
: '${genotypeResult.phenotypeDisplayString}$drugInteractionIndicator';
final hasLegend = warningLevelCounts.values.any((count) => count > 0);
return RoundedCard(
onTap: () => context.router.push(
Expand All @@ -143,7 +140,7 @@ class GeneCard extends StatelessWidget {
),
SizedBox(height: 8),
Text(
phenotypeText,
possiblyAdaptedPhenotype(genotypeResult),
style: PharMeTheme.textTheme.titleSmall,
),
],
Expand Down

0 comments on commit 247c390

Please sign in to comment.