From f0b0c67fbe1eb5d2042ff01ecb2a7578fb2ccff9 Mon Sep 17 00:00:00 2001 From: Tamara Slosarek Date: Tue, 17 Oct 2023 10:16:27 +0200 Subject: [PATCH] feat(#662): show original phenotype on gene page and in PDF export --- app/lib/common/models/userdata/userdata.dart | 34 ++++++++++++++------ app/lib/common/utilities/pdf_utils.dart | 16 ++++++--- app/lib/common/utilities/string.dart | 8 +++++ app/lib/l10n/app_en.arb | 24 ++++++++++++++ app/lib/report/pages/gene.dart | 11 ++++++- 5 files changed, 78 insertions(+), 15 deletions(-) diff --git a/app/lib/common/models/userdata/userdata.dart b/app/lib/common/models/userdata/userdata.dart index f8cda10f..aaa54349 100644 --- a/app/lib/common/models/userdata/userdata.dart +++ b/app/lib/common/models/userdata/userdata.dart @@ -15,12 +15,12 @@ class PhenotypeInformation { PhenotypeInformation({ this.phenotype, this.adaptionText, - this.originalPhenotype, + this.overwrittenPhenotype, }); String? phenotype; String? adaptionText; - String? originalPhenotype; + String? overwrittenPhenotype; } /// UserData is a singleton data-class which contains various user-specific @@ -60,21 +60,20 @@ class UserData { if (originalPhenotype == null) { return PhenotypeInformation(); } - final overwrittenLookup = UserData.overwrittenLookup(gene, drug: drug); final activeInhibitors = UserData.activeInhibitorsFor(gene, drug: drug); if (activeInhibitors.isEmpty) { return PhenotypeInformation(phenotype: originalPhenotype); } + final overwrittenLookup = UserData.overwrittenLookup(gene, drug: drug); if (overwrittenLookup == null) { - final activeInhibitorsText = enumerationWithAnd( - activeInhibitors, - context - ); return PhenotypeInformation( phenotype: originalPhenotype, adaptionText: context.l10n.drugs_page_moderate_inhibitors( userSalutation, - activeInhibitorsText, + enumerationWithAnd( + activeInhibitors, + context + ), ), ); } @@ -84,6 +83,21 @@ class UserData { final activeModerateInhibitors = activeInhibitors.filter( isModerateInhibitor ).toList(); + final overwritePhenotype = context.l10n.general_poor_metabolizer; + final currentPhenotypeEqualsOverwritePhenotype = + originalPhenotype.toLowerCase() == overwritePhenotype.toLowerCase(); + if (currentPhenotypeEqualsOverwritePhenotype) { + return PhenotypeInformation( + phenotype: originalPhenotype, + adaptionText: context.l10n.drugs_page_inhibitors_poor_metabolizer( + userSalutation, + enumerationWithAnd( + activeInhibitors, + context + ), + ), + ); + } final adaptionText = activeModerateInhibitors.isEmpty ? context.l10n.drugs_page_strong_inhibitors( userSalutation, @@ -95,9 +109,9 @@ class UserData { enumerationWithAnd(activeModerateInhibitors, context), ); return PhenotypeInformation( - phenotype: context.l10n.general_poor_metabolizer, + phenotype: overwritePhenotype, adaptionText: adaptionText, - originalPhenotype: originalPhenotype, + overwrittenPhenotype: originalPhenotype, ); } diff --git a/app/lib/common/utilities/pdf_utils.dart b/app/lib/common/utilities/pdf_utils.dart index 083bb2f0..39319a6d 100644 --- a/app/lib/common/utilities/pdf_utils.dart +++ b/app/lib/common/utilities/pdf_utils.dart @@ -134,9 +134,15 @@ String? _getPhenotypeInfo(String gene, Drug drug, BuildContext context) { if (phenotypeInformation.adaptionText.isNullOrBlank) { return phenotypeInformation.phenotype; } - return '${phenotypeInformation.phenotype} ' - '(${phenotypeInformation.originalPhenotype} ' - '${phenotypeInformation.adaptionText})'; + var phenotypeInformationText = '${phenotypeInformation.phenotype} (' + '${phenotypeInformation.adaptionText}'; + if (phenotypeInformation.overwrittenPhenotype.isNotNullOrBlank) { + phenotypeInformationText = '$phenotypeInformationText; ' + '${context.l10n.drugs_page_original_phenotype( + phenotypeInformation.overwrittenPhenotype! + )}'; + } + return '$phenotypeInformationText)'; } String? _getActivityScoreInfo(String gene, Drug drug, BuildContext context) { @@ -165,7 +171,9 @@ String _userInfoPerGene( if (drug.guidelines.isEmpty) return buildContext.l10n.pdf_no_value; final guidelineGenes = drug.guidelines.first.lookupkey.keys.toList(); return guidelineGenes.map((gene) => - '$gene: ${getInfo(gene, drug, buildContext) ?? buildContext.l10n.pdf_no_value}' + '$gene: ${ + getInfo(gene, drug, buildContext) ?? buildContext.l10n.pdf_no_value + }' ).join(', '); } diff --git a/app/lib/common/utilities/string.dart b/app/lib/common/utilities/string.dart index 5c7220ee..3ce7c5a1 100644 --- a/app/lib/common/utilities/string.dart +++ b/app/lib/common/utilities/string.dart @@ -15,3 +15,11 @@ String enumerationWithAnd(List items, BuildContext context) { final lastItem = itemsCopy.removeLast(); return '${itemsCopy.join(', ')} ${context.l10n.general_and} $lastItem'; } + +String formatAsSentence(String text, {String ending = '.'}) { + var sentenceFormattedString = text.capitalize(); + if (!sentenceFormattedString.endsWith(ending)) { + sentenceFormattedString = '$sentenceFormattedString$ending'; + } + return sentenceFormattedString; +} diff --git a/app/lib/l10n/app_en.arb b/app/lib/l10n/app_en.arb index a147dd63..e1bc795a 100644 --- a/app/lib/l10n/app_en.arb +++ b/app/lib/l10n/app_en.arb @@ -102,6 +102,20 @@ } } }, + "drugs_page_inhibitors_poor_metabolizer": "this can be further influenced based on {salutation} taking {inhibitors}", + "@drugs_page_inhibitors_poor_metabolizer": { + "description": "Disclaimer for when the phenotype would be adjusted based on current drug(s) but is already poor metabolizer", + "placeholders": { + "salutation": { + "type": "String", + "example": "you" + }, + "inhibitors": { + "type": "String", + "example": "bupropion and fluoxetine" + } + } + }, "drugs_page_moderate_and_strong_inhibitors": "phenotype adjusted based on {salutation} taking {strongInhibitors}; this can be further influenced by {moderateInhibitors}", "@drugs_page_moderate_and_strong_inhibitors": { "description": "Disclaimer for when the phenotype has been and might be adjusted based on current drug(s)", @@ -120,6 +134,16 @@ } } }, + "drugs_page_original_phenotype": "the genetics-based phenotype is {originalPhenotype}", + "@drugs_page_original_phenotype": { + "description": "Information on genetics-based phenotype if it was/might be adjusted based on current drug(s)", + "placeholders": { + "originalPhenotype": { + "type": "String", + "example": "Normal Metabolizer" + } + } + }, "drugs_page_your_genome": "Your genome", "drugs_page_guidelines_empty": "No guidelines are present for {drugName}", "@drugs_page_guidelines_empty": { diff --git a/app/lib/report/pages/gene.dart b/app/lib/report/pages/gene.dart index 8b1a2f9e..38bc4608 100644 --- a/app/lib/report/pages/gene.dart +++ b/app/lib/report/pages/gene.dart @@ -107,9 +107,18 @@ class GenePage extends HookWidget { final furtherInhibitors = inhibitorsFor(gene).filter((drugName) => !UserData.activeInhibitorsFor(gene).contains(drugName) ); + var phenotypeInformationText = formatAsSentence( + phenotypeInformation.adaptionText! + ); + if (phenotypeInformation.overwrittenPhenotype.isNotNullOrBlank) { + phenotypeInformationText = '$phenotypeInformationText ${ + formatAsSentence(context.l10n.drugs_page_original_phenotype( + phenotypeInformation.overwrittenPhenotype! + ))}'; + } return [ SizedBox(height: PharMeTheme.smallSpace), - Text('${phenotypeInformation.adaptionText!.capitalize()}.'), + Text(phenotypeInformationText), SizedBox(height: PharMeTheme.smallSpace), Text(context.l10n.gene_page_further_inhibitor_drugs), SizedBox(height: PharMeTheme.smallSpace),