Skip to content

Commit

Permalink
feat(#706): add new text to drug page
Browse files Browse the repository at this point in the history
  • Loading branch information
tamslo committed Sep 4, 2024
1 parent b71e503 commit 946d302
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 23 deletions.
35 changes: 32 additions & 3 deletions app/lib/common/models/drug/drug_inhibitors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,18 @@ List<String> 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';
}
Expand Down Expand Up @@ -126,6 +132,29 @@ String inhibitionTooltipText(
return '$consequence\n\n${context.l10n.inhibitors_tooltip(inhibitorsString)}';
}

Table buildDrugInteractionInfoForMultipleGenes(
BuildContext context,
List<GenotypeResult> 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,
Expand Down
53 changes: 35 additions & 18 deletions app/lib/drug/widgets/annotation_cards/guideline.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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),
],
Expand Down Expand Up @@ -181,29 +181,46 @@ class GuidelineAnnotationCard extends StatelessWidget {
);
}

Widget _buildHeader(BuildContext context) {
List<Widget> _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 = <GenotypeResult>[];
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,
),
],
];
}
}

Expand Down
5 changes: 3 additions & 2 deletions app/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 946d302

Please sign in to comment.