diff --git a/app/lib/common/models/userdata/userdata.dart b/app/lib/common/models/userdata/userdata.dart index b2c13f3b..181b2865 100644 --- a/app/lib/common/models/userdata/userdata.dart +++ b/app/lib/common/models/userdata/userdata.dart @@ -11,6 +11,8 @@ part 'userdata.g.dart'; const _boxName = 'userdata'; +const overwritePhenotype = 'Poor Metabolizer'; + /// UserData is a singleton data-class which contains various user-specific /// data It is intended to be loaded from a Hive box once at app launch, from /// where it's contents can be modified by accessing it's properties. @@ -61,17 +63,9 @@ class UserData { genotypeResult.gene, drug: drug, ); - if (activeInhibitors.isEmpty) { + if (!isInhibited(genotypeResult, drug: drug)) { return PhenotypeInformation(phenotype: originalPhenotype); } - final overwritePhenotype = context.l10n.general_poor_metabolizer; - final currentPhenotypeEqualsOverwritePhenotype = - originalPhenotype.toLowerCase() == overwritePhenotype.toLowerCase(); - if (currentPhenotypeEqualsOverwritePhenotype) { - return PhenotypeInformation( - phenotype: originalPhenotype, - ); - } final overwrittenLookup = UserData.overwrittenLookup( genotypeResult.gene, drug: drug, @@ -235,3 +229,18 @@ List activeDrugsFromHTTPResponse(Response resp) { } return activeDrugs; } + +bool isInhibited( + GenotypeResult genotypeResult, + { String? drug } +) { + final activeInhibitors = UserData.activeInhibitorsFor( + genotypeResult.gene, + drug: drug, + ); + final originalPhenotype = genotypeResult.phenotypeDisplayString; + final phenotypeCanBeInhibited = + originalPhenotype.toLowerCase() != overwritePhenotype.toLowerCase(); + return activeInhibitors.isNotEmpty && phenotypeCanBeInhibited; +} + diff --git a/app/lib/l10n/app_en.arb b/app/lib/l10n/app_en.arb index 8624a07b..68020e06 100644 --- a/app/lib/l10n/app_en.arb +++ b/app/lib/l10n/app_en.arb @@ -48,7 +48,6 @@ "general_continue": "Continue", "general_retry": "Retry", "general_and": "and", - "general_poor_metabolizer": "Poor Metabolizer", "general_not_tested": "Not tested", "warning_level_green": "Standard precautions", diff --git a/app/lib/report/pages/gene.dart b/app/lib/report/pages/gene.dart index 8b16b11b..a07d0e8b 100644 --- a/app/lib/report/pages/gene.dart +++ b/app/lib/report/pages/gene.dart @@ -14,15 +14,6 @@ class GenePage extends HookWidget { final GenotypeResult genotypeResult; final DrugListCubit cubit; - bool _isInhibited(BuildContext context, GenotypeResult genotypeResult) { - final phenotypeInformation = UserData.phenotypeInformationFor( - genotypeResult, - context, - ); - return phenotypeInformation.overwrittenPhenotypeText.isNotNullOrBlank; - } - - @override Widget build(BuildContext context) { return Consumer( @@ -70,7 +61,7 @@ class GenePage extends HookWidget { _buildPhenotypeRow(context), ], ), - if (_isInhibited(context, genotypeResult)) + if (isInhibited(genotypeResult)) ...buildDrugInteractionInfo( context, genotypeResult, @@ -98,13 +89,9 @@ class GenePage extends HookWidget { } TableRow _buildPhenotypeRow(BuildContext context) { - final phenotypeInformation = UserData.phenotypeInformationFor( - genotypeResult, - context, - ); - final phenotypeText = phenotypeInformation.adaptionText.isNotNullOrBlank - ? '${phenotypeInformation.phenotype}$drugInteractionIndicator' - : phenotypeInformation.phenotype; + final phenotypeText = isInhibited(genotypeResult) + ? '${genotypeResult.phenotypeDisplayString}$drugInteractionIndicator' + : genotypeResult.phenotypeDisplayString; return _buildRow( context.l10n.gene_page_phenotype, phenotypeText, diff --git a/app/lib/report/pages/report.dart b/app/lib/report/pages/report.dart index c2d53d9c..08617b47 100644 --- a/app/lib/report/pages/report.dart +++ b/app/lib/report/pages/report.dart @@ -121,13 +121,9 @@ class GeneCard extends StatelessWidget { @override Widget build(BuildContext context) { - final phenotypeInformation = UserData.phenotypeInformationFor( - genotypeResult, - context, - ); - final phenotypeText = phenotypeInformation.adaptionText.isNullOrBlank - ? phenotypeInformation.phenotype - : '${phenotypeInformation.phenotype}$drugInteractionIndicator'; + final phenotypeText = isInhibited(genotypeResult) + ? genotypeResult.phenotypeDisplayString + : '${genotypeResult.phenotypeDisplayString}$drugInteractionIndicator'; final hasLegend = warningLevelCounts.values.any((count) => count > 0); return RoundedCard( onTap: () => context.router.push(