Skip to content

Commit

Permalink
feat(app): start implementing any other fallback [work in progress]
Browse files Browse the repository at this point in the history
  • Loading branch information
tamslo committed Sep 19, 2024
1 parent 33be194 commit 4cb24b0
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 5 deletions.
35 changes: 31 additions & 4 deletions app/integration_test/drugs_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:mocktail/mocktail.dart';
import 'package:provider/provider.dart';

import 'fixtures/drugs/with_any_fallback_guideline.dart';
import 'fixtures/drugs/with_multiple_any_other_fallback_guidelines.dart';
import 'fixtures/drugs/with_proper_guideline.dart';
import 'fixtures/drugs/without_guidelines.dart';
import 'fixtures/set_user_data_for_drug.dart';
Expand Down Expand Up @@ -74,6 +75,30 @@ void main() {
drug: drugWithAnyFallbackGuideline,
);
});

testWidgets('test drug content with any other fallback guidelines', (tester) async {
// Work in progress; this should fail!
// Open TODOs:
// 1. Start with easy case (not pazopanib, add fixture for FDA w/ HLA-B)
// 2. Set user data for different guidelines and test that selected
// guidelines are different (may want to refactor set user data
// to be useful here)
// 3. Add all pazopanib guidelines for complex case
Future<void> testPerGuideline(Drug drug) async {
for (
final guideline in drug.guidelines
) {
await _expectDrugContent(
tester,
mockDrugsCubit,
drug: drug,
guideline: guideline,
);
}
}
// await testPerGuideline(drugWithAnyOtherFallbackGuideline);
await testPerGuideline(drugWithMultipleAnyOtherFallbackGuidelines);
});
});
}

Expand All @@ -84,9 +109,11 @@ Future<void> _expectDrugContent(
bool isLoading = false,
bool expectNoGuidelines = false,
bool expectDrugToBeActive = false,
Guideline? guideline,
}) async {
when(() => mockDrugsCubit.state)
.thenReturn(isLoading ? DrugState.loading() : DrugState.loaded());
final relevantGuideline = guideline ?? drug.guidelines.first;
await tester.pumpWidget(
ChangeNotifierProvider(
create: (context) => ActiveDrugs(),
Expand Down Expand Up @@ -138,7 +165,7 @@ Future<void> _expectDrugContent(
card.color,
expectNoGuidelines
? WarningLevel.green.color
: drug.guidelines.first.annotations.warningLevel.color,
: relevantGuideline.annotations.warningLevel.color,
);
expect(find.byType(Disclaimer), findsOneWidget);
final context = tester.element(find.byType(Scaffold).first);
Expand All @@ -158,16 +185,16 @@ Future<void> _expectDrugContent(
} else {
expect(
find.byTooltip(context.l10n.drugs_page_tooltip_guideline_present(
drug.guidelines.first.externalData.first.source,
relevantGuideline.externalData.first.source,
)),
findsOneWidget,
);
expect(
find.text(drug.guidelines.first.annotations.implication),
find.text(relevantGuideline.annotations.implication),
findsOneWidget,
);
expect(
find.textContaining(drug.guidelines.first.annotations.recommendation),
find.textContaining(relevantGuideline.annotations.recommendation),
findsOneWidget,
);
for (final genotypeKey in drug.guidelineGenotypes) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import 'package:app/common/models/drug/drug.dart';
import 'package:app/common/models/drug/guideline.dart';
import 'package:app/common/models/drug/warning_level.dart';

final drugWithMultipleAnyOtherFallbackGuidelines = Drug(
id: '6686a865826414ec5b05c44e',
version: 1,
name: 'pazopanib',
rxNorm: 'RxNorm:714438',
annotations: DrugAnnotations(
drugclass: 'Anti-cancer',
indication: 'Pazopanib is used to treat cancer.',
brandNames: ['Votrient'],
),
guidelines: [
Guideline(
id: '66b50b2433cbe5c07ee31651',
version: 1,
lookupkey: {
'HLA-B': ['~'],
'UGT1A1': ['Poor Metabolizer'],
},
externalData: [
GuidelineExtData(
source: 'CPIC',
guidelineName: 'Table of Pharmacogenetic Associations (Section 2)',
guidelineUrl: 'https://www.fda.gov/medical-devices/precision-medicine/table-pharmacogenetic-associations#section2',
implications: {
'HLA-B': 'Standard procedure',
'UGT1A1': 'Results in higher adverse reaction risk (hyperbilirubinemia).',
},
recommendation: 'Might be included in implication text (imported from FDA, source only states one text per guideline)',
comments: null,
),
],
annotations: GuidelineAnnotations(
implication: 'You have an increased risk for side effects.',
recommendation: 'You can still use pazopanib at standard dose. Consult your pharmacist or doctor for more information.',
warningLevel: WarningLevel.yellow,
),
),
],
);
3 changes: 2 additions & 1 deletion pharme.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@
"unstaged",
"userdata",
"Vicoprofen",
"voriconazole"
"voriconazole",
"Votrient"
]
}
}

0 comments on commit 4cb24b0

Please sign in to comment.