Skip to content

Commit

Permalink
feat(app): remove warfarin extra code
Browse files Browse the repository at this point in the history
  • Loading branch information
tamslo committed Sep 19, 2024
1 parent fdb30f4 commit 84d21fa
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 75 deletions.
1 change: 1 addition & 0 deletions app/integration_test/drugs_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ void main() {
brandNames: ['brand name', 'another brand name']),
guidelines: [],
);

UserData.instance.activeDrugNames = ['Ibuprofen'];

group('integration test for the drugs page', () {
Expand Down
79 changes: 8 additions & 71 deletions app/lib/drug/widgets/annotation_cards/guideline.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,6 @@ import 'package:url_launcher/url_launcher.dart';
import '../../../common/module.dart';
import '../module.dart';

enum WarfarinContent {
tooltip,
implication,
recommendation,
color,
icon,
heading,
}

final warfarinProperties = <WarfarinContent, dynamic Function(BuildContext)>{
WarfarinContent.tooltip: (context) =>
context.l10n.drugs_page_tooltip_warfarin,
WarfarinContent.implication: (context) =>
context.l10n.drugs_page_implication_warfarin,
WarfarinContent.recommendation: (context) =>
context.l10n.drugs_page_recommendation_warfarin,
WarfarinContent.color: (_) => WarningLevel.none.color,
WarfarinContent.icon: (_) => WarningLevel.none.icon,
WarfarinContent.heading: (context) => WarningLevel.none.getLabel(context),
};

class GuidelineAnnotationCard extends StatelessWidget {
const GuidelineAnnotationCard(this.drug);

Expand Down Expand Up @@ -61,45 +40,19 @@ class GuidelineAnnotationCard extends StatelessWidget {
);
}

dynamic actualOrWarfarinContent(String drugName, BuildContext context, {
required dynamic actualContent,
required WarfarinContent warfarinContent,
}) {
if (drugName.toLowerCase() == 'warfarin') {
final getWarfarinContent = warfarinProperties[warfarinContent]!;
return getWarfarinContent(context);
}
return actualContent;
}

Widget _buildCard(BuildContext context) {
final implicationText = actualOrWarfarinContent(
drug.name,
context,
actualContent: drug.userGuideline?.annotations.implication ??
final implicationText = drug.userGuideline?.annotations.implication ??
context.l10n.drugs_page_no_guidelines_for_phenotype_implication(
drug.name
),
warfarinContent: WarfarinContent.implication,
);
final recommendationText = actualOrWarfarinContent(
drug.name,
context,
actualContent: drug.userGuideline?.annotations.recommendation ??
context.l10n.drugs_page_no_guidelines_for_phenotype_recommendation,
warfarinContent: WarfarinContent.recommendation,
);
);
final recommendationText = drug.userGuideline?.annotations.recommendation ??
context.l10n.drugs_page_no_guidelines_for_phenotype_recommendation;
return RoundedCard(
key: Key('annotationCard'),
radius: PharMeTheme.innerCardRadius,
outerHorizontalPadding: 0,
outerVerticalPadding: 0,
color: actualOrWarfarinContent(
drug.name,
context,
actualContent: drug.warningLevel.color,
warfarinContent: WarfarinContent.color,
),
color: drug.warningLevel.color,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expand All @@ -108,23 +61,13 @@ class GuidelineAnnotationCard extends StatelessWidget {
WidgetSpan(
alignment: PlaceholderAlignment.middle,
child: Icon(
actualOrWarfarinContent(
drug.name,
context,
actualContent: drug.warningLevel.icon,
warfarinContent: WarfarinContent.icon,
),
drug.warningLevel.icon,
color: PharMeTheme.onSurfaceText,
size: PharMeTheme.mediumToLargeSpace,
),
),
TextSpan(
text: ' ${actualOrWarfarinContent(
drug.name,
context,
actualContent: drug.warningLevel.getLabel(context),
warfarinContent: WarfarinContent.heading,
)}',
text: ' ${drug.warningLevel.getLabel(context)}',
),
]),
style: PharMeTheme.textTheme.titleMedium!.copyWith(
Expand Down Expand Up @@ -155,7 +98,7 @@ class GuidelineAnnotationCard extends StatelessWidget {
}

String _buildGuidelineTooltipText(BuildContext context) {
final actualTooltip = drug.userGuideline != null
return drug.userGuideline != null
// Case 1: a guideline is present
? context.l10n.drugs_page_tooltip_guideline(
drug.userGuideline!.externalData.first.source
Expand All @@ -173,12 +116,6 @@ class GuidelineAnnotationCard extends StatelessWidget {
: context.l10n.drugs_page_tooltip_missing_guideline_for_drug_or_genotype(
context.l10n.drugs_page_tooltip_missing_drug
);
return actualOrWarfarinContent(
drug.name,
context,
actualContent: actualTooltip,
warfarinContent: WarfarinContent.tooltip,
);
}

List<Widget> _buildHeader(BuildContext context) {
Expand Down
4 changes: 0 additions & 4 deletions app/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,7 @@
}
},
"drugs_page_tooltip_missing_guideline_not_tested": "Guidelines provide recommendations on which medications to use based on your DNA. However, your genetic test result does not include the information needed to make such a recommendation for this medication.",

"drugs_page_tooltip_warfarin": "CPIC guidelines provide recommendations on which medications to use based on your DNA. However, to calculate your warfarin dose, more information is needed.",
"drugs_page_recommendation_description": "What to do: ",
"drugs_page_implication_warfarin": "More information is needed to calculate your warfarin dose.",
"drugs_page_recommendation_warfarin": "Consult your pharmacist or doctor for more information.",

"report_content_explanation": "This is your PGx test report. Tap on a gene name for more details on your results and a list of implicated medications.",
"report_legend_text": "Next to your gene result the number of implicated medications per guideline result is shown:",
Expand Down

0 comments on commit 84d21fa

Please sign in to comment.