diff --git a/app/lib/common/models/userdata/genotype_key.dart b/app/lib/common/models/userdata/genotype_key.dart index 152b5074..cba84c4a 100644 --- a/app/lib/common/models/userdata/genotype_key.dart +++ b/app/lib/common/models/userdata/genotype_key.dart @@ -12,15 +12,18 @@ class GenotypeKey implements Genotype { @override String variant; - String get value { - final geneData = UserData.instance.labData!.where( + bool get isGeneUnique => UserData.instance.labData!.where( (labData) => labData.gene == gene - ); - if (geneData.length > 1) { - return '$gene ${variant.split(' ').first}'; - } - return gene; - } + ).length <= 1; + + // heavily relies on "non-unique" gene HLA-B, for which the variant is + // in the format "[allele] [positive/negative]" (which currently is the only) + // relevant case for "non-unique" genes) + String get allele => isGeneUnique ? variant : variant.split(' ').first; + + String get value => isGeneUnique + ? gene + : '$gene $allele'; static String extractGene(String genotypeKey) => genotypeKey.split(' ').first; diff --git a/app/lib/common/models/userdata/genotype_result.dart b/app/lib/common/models/userdata/genotype_result.dart index ab5ffbfb..6f2ae8fd 100644 --- a/app/lib/common/models/userdata/genotype_result.dart +++ b/app/lib/common/models/userdata/genotype_result.dart @@ -47,7 +47,19 @@ class GenotypeResult implements Genotype { @HiveField(4) String allelesTested; - String get key => GenotypeKey.fromGenotype(this).value; + GenotypeKey get key => GenotypeKey.fromGenotype(this); + + String get geneDisplayString => key.value; + + String _removeAllele(String textWithAllele) => + textWithAllele.removePrefix(key.allele).trim().capitalize(); + + String get phenotypeDisplayString => key.isGeneUnique + ? phenotype + : _removeAllele(phenotype); + String get genotypeDisplayString => key.isGeneUnique + ? variant + : _removeAllele(variant); } extension FindGenotypeResultByKey on Map { diff --git a/app/lib/common/models/userdata/userdata.dart b/app/lib/common/models/userdata/userdata.dart index 39055653..92593f81 100644 --- a/app/lib/common/models/userdata/userdata.dart +++ b/app/lib/common/models/userdata/userdata.dart @@ -56,7 +56,7 @@ class UserData { final strongInhibitorTextPrefix = useLongPrefix ? context.l10n.strong_inhibitor_long_prefix : context.l10n.gene_page_phenotype.toLowerCase(); - final originalPhenotype = genotypeResult.phenotype; + final originalPhenotype = genotypeResult.phenotypeDisplayString; final activeInhibitors = UserData.activeInhibitorsFor( genotypeResult.gene, drug: drug, diff --git a/app/lib/common/utilities/genome_data.dart b/app/lib/common/utilities/genome_data.dart index 844fc2fe..f4aa9ada 100644 --- a/app/lib/common/utilities/genome_data.dart +++ b/app/lib/common/utilities/genome_data.dart @@ -59,7 +59,7 @@ Future updateGenotypeResults() async { final lookup = lookupsHashMap[key]; if (lookup == null) continue; final genotypeResult = GenotypeResult.fromGenotypeData(labResult, lookup); - genotypeResults[genotypeResult.key] = genotypeResult; + genotypeResults[genotypeResult.key.value] = genotypeResult; } UserData.instance.genotypeResults = genotypeResults; diff --git a/app/lib/l10n/app_en.arb b/app/lib/l10n/app_en.arb index b5e5f999..4a92d88d 100644 --- a/app/lib/l10n/app_en.arb +++ b/app/lib/l10n/app_en.arb @@ -229,8 +229,8 @@ } } }, - "gene_page_your_variant": "Your {gene} variant", - "@gene_page_your_variant": { + "gene_page_your_result": "Your {gene} result", + "@gene_page_your_result": { "placeholders": { "gene": { "type": "String", @@ -238,7 +238,7 @@ } } }, - "gene_page_name_tooltip": "{gene} is the name of a gene.", + "gene_page_name_tooltip": "{gene} is the name of a segment of your DNA.", "@gene_page_name_tooltip": { "placeholders": { "gene": { @@ -248,11 +248,11 @@ } }, "gene_page_genotype": "Genotype", - "gene_page_genotype_tooltip": "The genotype is the variant you carry for this gene.", + "gene_page_genotype_tooltip": "The genotype is the variant you carry for this DNA segment.", "gene_page_phenotype": "Phenotype", - "gene_page_phenotype_tooltip": "The phenotype is the activity level you have for this protein based on your genotype.", + "gene_page_phenotype_tooltip": "The phenotype is the observable impact that your genotype has for this protein. It often describes the gene's activity level or whether a specific variant is present.", "gene_page_affected_drugs": "Affected drugs", - "gene_page_affected_drugs_tooltip": "The drugs listed here are influenced by your phenotype for this gene.", + "gene_page_affected_drugs_tooltip": "The drugs listed here are influenced by your phenotype for this DNA segment.", "gene_page_no_affected_drugs": "This gene has no known effect on any drug.", "gene_page_inhibitor_drugs": "Your results for this gene can be influenced if you are currently taking any of the following drugs:", "gene_page_further_inhibitor_drugs": "Your results for this gene can also be influenced by taking any of the following drugs:", diff --git a/app/lib/report/pages/gene.dart b/app/lib/report/pages/gene.dart index 2a7b25c1..defc5abd 100644 --- a/app/lib/report/pages/gene.dart +++ b/app/lib/report/pages/gene.dart @@ -8,7 +8,7 @@ class GenePage extends HookWidget { GenePage(this.genotypeResult) : cubit = DrugListCubit( initialFilter: - FilterState.forGenotypeKey(genotypeResult.key), + FilterState.forGenotypeKey(genotypeResult.key.value), ); final GenotypeResult genotypeResult; @@ -21,7 +21,8 @@ class GenePage extends HookWidget { create: (context) => cubit, child: BlocBuilder( builder: (context, state) => pageScaffold( - title: context.l10n.gene_page_headline(genotypeResult.gene), + title: + context.l10n.gene_page_headline(genotypeResult.geneDisplayString), body: [ Padding( padding: EdgeInsets.symmetric( @@ -32,9 +33,13 @@ class GenePage extends HookWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ SubHeader( - context.l10n.gene_page_your_variant(genotypeResult.gene), + context.l10n.gene_page_your_result( + genotypeResult.geneDisplayString, + ), tooltip: context.l10n - .gene_page_name_tooltip(genotypeResult.gene), + .gene_page_name_tooltip( + genotypeResult.geneDisplayString, + ), ), SizedBox(height: PharMeTheme.smallToMediumSpace), RoundedCard( @@ -50,7 +55,7 @@ class GenePage extends HookWidget { children: [ _buildRow( context.l10n.gene_page_genotype, - genotypeResult.variant, + genotypeResult.genotypeDisplayString, tooltip: context.l10n.gene_page_genotype_tooltip ), _buildPhenotypeRow(context), diff --git a/app/lib/report/pages/report.dart b/app/lib/report/pages/report.dart index 7bd34585..b8294000 100644 --- a/app/lib/report/pages/report.dart +++ b/app/lib/report/pages/report.dart @@ -36,7 +36,7 @@ class ReportPage extends StatelessWidget { scrollList( userGenotypes.map((genotypeResult) => GeneCard( genotypeResult, - key: Key('gene-card-${genotypeResult.key}') + key: Key('gene-card-${genotypeResult.key.value}') )).toList(), ), if (hasActiveInhibitors) PageIndicatorExplanation( @@ -67,7 +67,7 @@ class GeneCard extends StatelessWidget { ? phenotypeInformation.phenotype : '${phenotypeInformation.phenotype}$drugInteractionIndicator'; final affectedDrugs = CachedDrugs.instance.drugs?.filter( - (drug) => drug.guidelineGenotypes.contains(genotypeResult.key) + (drug) => drug.guidelineGenotypes.contains(genotypeResult.key.value) ) ?? []; final warningLevelIndicators = WarningLevel.values.map( (warningLevel) { @@ -106,7 +106,7 @@ class GeneCard extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - genotypeResult.gene, + genotypeResult.geneDisplayString, style: PharMeTheme.textTheme.titleMedium ), SizedBox(height: 8),