Skip to content

Commit

Permalink
feat(#684): adapt what is displayed
Browse files Browse the repository at this point in the history
  • Loading branch information
tamslo committed Feb 12, 2024
1 parent eb38c44 commit 4da0d8f
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 25 deletions.
19 changes: 11 additions & 8 deletions app/lib/common/models/userdata/genotype_key.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
14 changes: 13 additions & 1 deletion app/lib/common/models/userdata/genotype_result.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, GenotypeResult> {
Expand Down
2 changes: 1 addition & 1 deletion app/lib/common/models/userdata/userdata.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion app/lib/common/utilities/genome_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Future<void> 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;
Expand Down
12 changes: 6 additions & 6 deletions app/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -229,16 +229,16 @@
}
}
},
"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",
"example": "CYP2D6"
}
}
},
"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": {
Expand All @@ -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:",
Expand Down
15 changes: 10 additions & 5 deletions app/lib/report/pages/gene.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -21,7 +21,8 @@ class GenePage extends HookWidget {
create: (context) => cubit,
child: BlocBuilder<DrugListCubit, DrugListState>(
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(
Expand All @@ -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(
Expand All @@ -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),
Expand Down
6 changes: 3 additions & 3 deletions app/lib/report/pages/report.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -106,7 +106,7 @@ class GeneCard extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
genotypeResult.gene,
genotypeResult.geneDisplayString,
style: PharMeTheme.textTheme.titleMedium
),
SizedBox(height: 8),
Expand Down

0 comments on commit 4da0d8f

Please sign in to comment.