Skip to content

Commit

Permalink
feat(#706): add phenoconversion FAQ item
Browse files Browse the repository at this point in the history
  • Loading branch information
tamslo committed Sep 5, 2024
1 parent ac22d62 commit be9f27e
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 6 deletions.
23 changes: 17 additions & 6 deletions app/lib/common/models/drug/drug.dart
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,25 @@ extension CriticalDrugs on List<Drug> {
}
}

List<String> getDrugsWithBrandNames(List<String>? drugNames) {
return drugNames?.map(getDrugWithBrandNames).toList() ?? [];
List<String> getDrugsWithBrandNames(
List<String>? drugNames,
{ bool capitalize = false }
) {
return drugNames?.map(
(drugName) => _getDrugWithBrandNames(drugName, capitalize: capitalize)
).toList() ?? [];
}

String getDrugWithBrandNames(String drugName) {
final drug = CachedDrugs.instance.drugs!.firstWhere(
String _getDrugWithBrandNames(
String drugName,
{ required bool capitalize }
) {
final drug = CachedDrugs.instance.drugs!.firstOrNullWhere(
(drug) => drug.name == drugName
);
if (drug.annotations.brandNames.isEmpty) return drugName;
return '$drugName (${drug.annotations.brandNames.join(', ')})';
final displayedDrugName = capitalize ? drugName.capitalize() : drugName;
if (drug == null || drug.annotations.brandNames.isEmpty) {
return displayedDrugName;
}
return '$displayedDrugName (${drug.annotations.brandNames.join(', ')})';
}
1 change: 1 addition & 0 deletions app/lib/common/widgets/module.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ export 'scroll_list.dart';
export 'subheader_divider.dart';
export 'tutorial/show_app_tour.dart';
export 'tutorial/show_drug_selection_intro.dart';
export 'unordered_list.dart';
36 changes: 36 additions & 0 deletions app/lib/common/widgets/unordered_list.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import '../module.dart';

// Based on https://stackoverflow.com/a/62341566

class UnorderedList extends StatelessWidget {
const UnorderedList(this.texts);
final List<String> texts;

@override
Widget build(BuildContext context) {
final widgetList = <Widget>[];
for (final text in texts) {
widgetList.add(UnorderedListItem(text));
widgetList.add(SizedBox(height: 5));
}
return Column(children: widgetList);
}
}

class UnorderedListItem extends StatelessWidget {
const UnorderedListItem(this.text);
final String text;

@override
Widget build(BuildContext context) {
return Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text('• '),
Expanded(
child: Text(text),
),
],
);
}
}
44 changes: 44 additions & 0 deletions app/lib/faq/pages/content.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,31 @@ class FaqWidgetAnswerQuestion extends FaqQuestion {
});
}

Column _getPhenoconversionString(
Map<String, Map<String, dynamic>> modulators,
String Function(String) getDescriptionPerGene,
) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
...modulators.keys.flatMap(
(geneName) => [
Text(
getDescriptionPerGene(geneName),
style: TextStyle(fontStyle: FontStyle.italic),
),
SizedBox(height: PharMeTheme.smallSpace * 0.5),
UnorderedList(
getDrugsWithBrandNames(
modulators[geneName]!.keys.toList(),
capitalize: true,
),
),
]),
],
);
}

final faqContent = <FaqSection>[
FaqSection(
title: (context) => context.l10n.faq_section_title_pgx,
Expand Down Expand Up @@ -63,6 +88,25 @@ final faqContent = <FaqSection>[
question: context.l10n.faq_question_which_medications,
answer: context.l10n.faq_answer_which_medications,
),
(context) => FaqWidgetAnswerQuestion(
question: context.l10n.faq_question_phenoconversion,
answer: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(context.l10n.faq_answer_phenoconversion),
SizedBox(height: PharMeTheme.smallSpace * 0.5),
_getPhenoconversionString(
strongDrugInhibitors,
context.l10n.faq_strong_inhibitors,
),
SizedBox(height: PharMeTheme.smallSpace * 0.5),
_getPhenoconversionString(
moderateDrugInhibitors,
context.l10n.faq_moderate_inhibitors,
),
],
),
),
(context) => FaqTextAnswerQuestion(
question: context.l10n.faq_question_family,
answer: context.l10n.faq_answer_family,
Expand Down
4 changes: 4 additions & 0 deletions app/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,10 @@
"faq_answer_genetics_info": "To learn more about genetics, we recommend MedlinePlus, a service of the National Library of Medicine:",
"faq_question_which_medications": "Which medications have known gene interactions?",
"faq_answer_which_medications": "Examples of medication classes with known gene interactions include anti-clotting medications (like clopidogrel and warfarin), antidepressants (like sertraline, citalopram, and paroxetine), anti-cholesterol medications (like simvastatin and atorvastatin), acid reducers (like pantoprazole and omeprazole), pain killers (like codeine, tramadol, and ibuprofen), antifungals (like voriconazole), medications that suppress the immune system (like tacrolimus), and anti-cancer medications (like fluorouracil and irinotecan).\n\nSearch a medication in the Medications tab to find out whether it has known gene interactions according to CPIC® and FDA guidelines.",
"faq_question_phenoconversion": "Why do my results change when I take certain medications?",
"faq_answer_phenoconversion": "Certain medications can change your phenotype that descries how your body responds to medications. Typically, medications either inhibit or induce the activity of a gene. In PharMe, the following interactions are included:",
"faq_strong_inhibitors": "Strong {geneName} inhibitors:",
"faq_moderate_inhibitors": "Moderate {geneName} inhibitors:",
"faq_question_family": "Will my results affect my family members?",
"faq_answer_family": "Yes, since this is a genetic test, it is possible that your results were passed down to you and your siblings from your parents and you will also pass them down to your children.",
"faq_question_share": "Who can I share my results with?",
Expand Down

0 comments on commit be9f27e

Please sign in to comment.