diff --git a/app/lib/common/models/userdata/genotype_result.dart b/app/lib/common/models/userdata/genotype_result.dart index 6f2ae8fd..aa90cb0c 100644 --- a/app/lib/common/models/userdata/genotype_result.dart +++ b/app/lib/common/models/userdata/genotype_result.dart @@ -63,9 +63,13 @@ class GenotypeResult implements Genotype { } extension FindGenotypeResultByKey on Map { + bool isMissing(String genotypeKey) => this[genotypeKey] == null; + GenotypeResult findOrMissing(String genotypeKey, BuildContext context) => - this[genotypeKey] ?? GenotypeResult.missingResult( - GenotypeKey.extractGene(genotypeKey), - context, - ); -} \ No newline at end of file + isMissing(genotypeKey) + ? GenotypeResult.missingResult( + GenotypeKey.extractGene(genotypeKey), + context, + ) + : this[genotypeKey]!; +} diff --git a/app/lib/drug/widgets/annotation_cards/guideline.dart b/app/lib/drug/widgets/annotation_cards/guideline.dart index 305bb0d9..1657da1d 100644 --- a/app/lib/drug/widgets/annotation_cards/guideline.dart +++ b/app/lib/drug/widgets/annotation_cards/guideline.dart @@ -136,14 +136,20 @@ class GuidelineAnnotationCard extends StatelessWidget { String _buildGuidelineTooltipText(BuildContext context) { final actualTooltip = drug.userGuideline != null + // Case 1: a guideline is present ? context.l10n.drugs_page_tooltip_guideline( drug.userGuideline!.externalData.first.source ) : drug.userOrFirstGuideline != null - // Guideline for drug is present but not for genotype - ? context.l10n.drugs_page_tooltip_missing_guideline_for_drug_or_genotype( + // Case 2: a guideline for the drug is present but not for the genotype + ? drug.guidelineGenotypes.all(UserData.instance.genotypeResults!.isMissing) + // Case 2.1: all genes are not tested + ? context.l10n.drugs_page_tooltip_missing_guideline_not_tested + // Case 2.2: at least some genes tested + : context.l10n.drugs_page_tooltip_missing_guideline_for_drug_or_genotype( context.l10n.drugs_page_tooltip_missing_genotype ) + // Case 3: the drug has no guidelines : context.l10n.drugs_page_tooltip_missing_guideline_for_drug_or_genotype( context.l10n.drugs_page_tooltip_missing_drug ); diff --git a/app/lib/l10n/app_en.arb b/app/lib/l10n/app_en.arb index 3d53b695..5578f4f6 100644 --- a/app/lib/l10n/app_en.arb +++ b/app/lib/l10n/app_en.arb @@ -210,6 +210,7 @@ } } }, + "drugs_page_tooltip_missing_guideline_not_tested": "Guidelines provide recommendations on which drugs to use based on your DNA. However, your genetic test result does not include the information needed to make such a recommendation for this drug.", "drugs_page_tooltip_warfarin": "CPIC guidelines provide recommendations on which drugs to use based on your DNA. However, to calculate your warfarin dose, more information is needed.", "drugs_page_implication_warfarin": "More information is needed to calculate your warfarin dose.",