diff --git a/app/lib/common/models/drug/drug_inhibitors.dart b/app/lib/common/models/drug/drug_inhibitors.dart index e5525ae8..036735b1 100644 --- a/app/lib/common/models/drug/drug_inhibitors.dart +++ b/app/lib/common/models/drug/drug_inhibitors.dart @@ -85,12 +85,18 @@ List inhibitorsFor(String gene) { return _drugInhibitorsPerGene[gene] ?? []; } -String possiblyAdaptedPhenotype(GenotypeResult genotypeResult) { +String possiblyAdaptedPhenotype( + GenotypeResult genotypeResult, + { String? drug } +) { final originalPhenotype = genotypeResult.phenotypeDisplayString; - if (!isInhibited(genotypeResult)) { + if (!isInhibited(genotypeResult, drug: drug)) { return originalPhenotype; } - final overwrittenLookup = getOverwrittenLookup(genotypeResult.gene); + final overwrittenLookup = getOverwrittenLookup( + genotypeResult.gene, + drug: drug, + ); if (overwrittenLookup == null) { return '$originalPhenotype$drugInteractionIndicator'; } @@ -126,6 +132,29 @@ String inhibitionTooltipText( return '$consequence\n\n${context.l10n.inhibitors_tooltip(inhibitorsString)}'; } +Table buildDrugInteractionInfoForMultipleGenes( + BuildContext context, + List genotypeResults, + { String? drug } +) { + var tooltipText = ''; + for (final (index, genotypeResult) in genotypeResults.indexed) { + final separator = index == 0 ? '' : '\n\n'; + // ignore: use_string_buffers + tooltipText = '$tooltipText$separator${ + inhibitionTooltipText(context, genotypeResult, drug: drug) + }'; + } + return buildTable([ + TableRowDefinition( + drugInteractionIndicator, + context.l10n.inhibitor_message, + tooltip: tooltipText, + )], + boldHeader: false, + ); +} + Table buildDrugInteractionInfo( BuildContext context, GenotypeResult genotypeResult, diff --git a/app/lib/drug/widgets/annotation_cards/guideline.dart b/app/lib/drug/widgets/annotation_cards/guideline.dart index 31be158d..089f5a75 100644 --- a/app/lib/drug/widgets/annotation_cards/guideline.dart +++ b/app/lib/drug/widgets/annotation_cards/guideline.dart @@ -43,14 +43,14 @@ class GuidelineAnnotationCard extends StatelessWidget { child: SingleChildScrollView( child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ if (drug.guidelines.isNotEmpty) ...[ - _buildHeader(context), + ..._buildHeader(context), SizedBox(height: PharMeTheme.mediumSpace), _buildCard(context), SizedBox(height: PharMeTheme.mediumSpace), _buildSourcesSection(context), ] else ...[ - _buildHeader(context), + ..._buildHeader(context), SizedBox(height: PharMeTheme.smallSpace), _buildCard(context), ], @@ -181,29 +181,46 @@ class GuidelineAnnotationCard extends StatelessWidget { ); } - Widget _buildHeader(BuildContext context) { + List _buildHeader(BuildContext context) { if (drug.userGuideline == null && drug.guidelines.isEmpty) { - return Text( - context.l10n.drugs_page_guidelines_empty(drug.name), - style: TextStyle(fontStyle: FontStyle.italic), - ); + return [ + Text( + context.l10n.drugs_page_guidelines_empty(drug.name), + style: TextStyle(fontStyle: FontStyle.italic), + ), + ]; } else { + var inhibitedGenotypeResults = []; final geneDescriptions = drug.guidelineGenotypes.map((genotypeKey) { - final phenotypeInformation = phenotypeInformationFor( - UserData.instance.genotypeResults!.findOrMissing( - genotypeKey, - context, - ), + final genotypeResult = UserData.instance.genotypeResults!.findOrMissing( + genotypeKey, context, - drug: drug.name, ); - var description = phenotypeInformation.phenotype; - if (phenotypeInformation.adaptionText.isNotNullOrBlank) { - description = '$description (${phenotypeInformation.adaptionText})'; + if (isInhibited(genotypeResult, drug: drug.name)) { + inhibitedGenotypeResults = [ + ...inhibitedGenotypeResults, + genotypeResult, + ]; } - return TableRowDefinition(genotypeKey, description); + return TableRowDefinition( + genotypeKey, + possiblyAdaptedPhenotype( + genotypeResult, + drug: drug.name, + ), + ); }); - return buildTable(geneDescriptions.toList()); + return [ + buildTable(geneDescriptions.toList()), + if (inhibitedGenotypeResults.isNotEmpty) ...[ + SizedBox(height: PharMeTheme.smallSpace), + buildDrugInteractionInfoForMultipleGenes( + context, + inhibitedGenotypeResults, + drug: drug.name, + ), + ], + ]; } } diff --git a/app/lib/l10n/app_en.arb b/app/lib/l10n/app_en.arb index 8b8cc8d6..679a629c 100644 --- a/app/lib/l10n/app_en.arb +++ b/app/lib/l10n/app_en.arb @@ -104,8 +104,9 @@ }, "inhibitor_message": "One or more of the medications you are currently taking may interact with your genetic result", - "inhibitors_consequence_adapted": "Your phenotype was adapted from {originalPhenotype}.", - "inhibitors_consequence_not_adapted": "Your phenotype was not adapted.", + "inhibitors_consequence_adapted": "Your phenotype was adapted from {originalPhenotype}. Consult your pharmacist or doctor for more information.", + "inhibitors_consequence_per_gene_adapted": "Your {geneName} phenotype was adapted from {originalPhenotype}. Consult your pharmacist or doctor for more information.", + "inhibitors_consequence_not_adapted": "Your phenotype was not adapted but may need to be. Consult your pharmacist or doctor for more information.", "inhibitors_tooltip": "Current interacting medications: {inhibitors}", "drugs_page_inhibitor_direct_salutation": "you are",