From 050e0b21203fad707d5ccf07be939cdbcf0ccb16 Mon Sep 17 00:00:00 2001 From: Tamara Slosarek Date: Tue, 24 Sep 2024 17:33:12 +0200 Subject: [PATCH] test(app): add test for specific no result guidelines --- app/integration_test/drugs_test.dart | 44 ++++++++---- ...rosuvastatin_with_no_result_guideline.dart | 69 +++++++++++++++++++ .../fixtures/set_app_data.dart | 4 +- pharme.code-workspace | 9 +++ 4 files changed, 110 insertions(+), 16 deletions(-) create mode 100644 app/integration_test/fixtures/drugs/rosuvastatin_with_no_result_guideline.dart diff --git a/app/integration_test/drugs_test.dart b/app/integration_test/drugs_test.dart index 90e1113b..25257454 100644 --- a/app/integration_test/drugs_test.dart +++ b/app/integration_test/drugs_test.dart @@ -11,6 +11,7 @@ import 'fixtures/drugs/aripiprazole_with_any_not_handled_guideline.dart'; import 'fixtures/drugs/ibuprofen_with_proper_guideline.dart'; import 'fixtures/drugs/mirabegron_without_guidelines.dart'; import 'fixtures/drugs/pazopanib_with_multiple_any_not_handled_fallback_guidelines.dart'; +import 'fixtures/drugs/rosuvastatin_with_no_result_guideline.dart'; import 'fixtures/drugs/warfarin_with_any_fallback_guideline.dart'; import 'fixtures/set_app_data.dart'; import 'mocks/drug_cubit.dart'; @@ -160,21 +161,6 @@ void main() { findsOneWidget, ); } - if (explicitNoResult != null) { - for (final noResultGene in explicitNoResult) { - final geneRowFinder = find.ancestor( - of: find.text(noResultGene), - matching: find.byType(Table), - ); - expect( - find.descendant( - of: geneRowFinder, - matching: find.textContaining(context.l10n.general_not_tested), - ), - findsOneWidget, - ); - } - } } else { expect(card.color, relevantGuideline!.annotations.warningLevel.color); expect( @@ -208,6 +194,29 @@ void main() { } } } + final noResultGenes = [ + ...(explicitNoResult ?? []), + ...(relevantGuideline?.lookupkey.entries.filter( + (lookupEntry) => lookupEntry.value.any( + (variant) => variant == SpecialLookup.noResult.value + ) + ).map((lookupEntry) => lookupEntry.key).toList() ?? []) + ]; + if (noResultGenes.isNotEmpty) { + for (final noResultGene in noResultGenes) { + final geneRowFinder = find.ancestor( + of: find.text(noResultGene), + matching: find.byType(Table), + ); + expect( + find.descendant( + of: geneRowFinder, + matching: find.textContaining(context.l10n.general_not_tested), + ), + findsOneWidget, + ); + } + } } Future runTestCases(List<_TestCase> testCases) async { @@ -308,6 +317,11 @@ void main() { }, expectNoMappedGuidelines: true, ), + _TestCase( + description: 'mappable no result', + drug: rosuvastatinWithNoResultGuidelines, + expectNoMappedGuidelines: false, + ), ]); }); diff --git a/app/integration_test/fixtures/drugs/rosuvastatin_with_no_result_guideline.dart b/app/integration_test/fixtures/drugs/rosuvastatin_with_no_result_guideline.dart new file mode 100644 index 00000000..e78ac087 --- /dev/null +++ b/app/integration_test/fixtures/drugs/rosuvastatin_with_no_result_guideline.dart @@ -0,0 +1,69 @@ +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 rosuvastatinWithNoResultGuidelines = Drug( + id: '6407768c92a4868065b6d18e', + version: 1, + name: 'rosuvastatin', + rxNorm: 'RxNorm:301542', + annotations: DrugAnnotations( + drugclass: 'Anti-cholesterol', + indication: 'Statins lower high cholesterol and triglyceride levels and reduce risk of heart related health conditions.', + brandNames: ['Crestor', 'Ezallor', 'Roszet'], + ), + guidelines: [ + Guideline( + id: '64552859a1b68082babc8e09', + version: 1, + lookupkey: { + 'ABCG2': ['No Result'], + 'SLCO1B1': ['Normal Function'], + }, + externalData: [ + GuidelineExtData( + source: 'CPIC', + guidelineName: 'SLCO1B1, ABCG2, CYP2C9, and Statins', + guidelineUrl: 'https://cpicpgx.org/guidelines/cpic-guideline-for-statins/', + implications: { + 'ABCG2': 'n/a', + 'SLCO1B1': 'Typical myopathy risk and statin exposure', + }, + recommendation: 'Based on SLCO1B1 status, prescribe desired starting dose and adjust doses based on disease-specific guidelines. ABCG2 genotype result is not available.', + comments: 'The potential for drug-drug interactions and dose limits based on renal and hepatic function and ancestry should be evaluated prior to initiating a statin.', + ), + ], + annotations: GuidelineAnnotations( + implication: 'You have a normal risk for side effects. (One missing)', + recommendation: 'You can use rosuvastatin at standard dose. Consult your pharmacist or doctor for more information. (One missing)', + warningLevel: WarningLevel.green, + ), + ), + Guideline( + id: '64552859a1b68082babc8e14', + version: 1, + lookupkey: { + 'ABCG2': ['Normal Function'], + 'SLCO1B1': ['Normal Function'], + }, + externalData: [ + GuidelineExtData( + source: 'CPIC', + guidelineName: 'SLCO1B1, ABCG2, CYP2C9, and Statins', + guidelineUrl: 'https://cpicpgx.org/guidelines/cpic-guideline-for-statins/', + implications: { + 'ABCG2': 'Typical myopathy risk and rosuvastatin exposure', + 'SLCO1B1': 'Typical myopathy risk and statin exposure', + }, + recommendation: 'Based on SLCO1B1 status, prescribe desired starting dose and adjust doses based on disease-specific guidelines. ABCG2 genotype result is not available.', + comments: 'The potential for drug-drug interactions and dose limits based on renal and hepatic function and ancestry should be evaluated prior to initiating a statin.', + ), + ], + annotations: GuidelineAnnotations( + implication: 'You have a normal risk for side effects. (Both normal)', + recommendation: 'You can use rosuvastatin at standard dose. Consult your pharmacist or doctor for more information. (Both normal)', + warningLevel: WarningLevel.green, + ), + ), + ], +); \ No newline at end of file diff --git a/app/integration_test/fixtures/set_app_data.dart b/app/integration_test/fixtures/set_app_data.dart index 36bf3852..3b6b1abf 100644 --- a/app/integration_test/fixtures/set_app_data.dart +++ b/app/integration_test/fixtures/set_app_data.dart @@ -49,7 +49,9 @@ void setUserDataForGuideline( // multiple HLA-B variants in the tests or overwrite a specific HLA-B // variant, we will need to check for the genotype key (which is in the // current setup not possible without the proper variant) - if (!(explicitNoResult?.contains(gene) ?? false)) { + final lookupIsMissing = lookupkey == SpecialLookup.noResult.value || + (explicitNoResult?.contains(gene) ?? false); + if (!lookupIsMissing) { UserData.instance.labData = UserData.instance.labData!.filter( (labResult) => labResult.gene != gene ).toList(); diff --git a/pharme.code-workspace b/pharme.code-workspace index 50f5def8..290bb5fe 100644 --- a/pharme.code-workspace +++ b/pharme.code-workspace @@ -32,6 +32,7 @@ "settings": { "typescript.preferences.importModuleSpecifier": "relative", "cSpell.words": [ + "ABCG", "Abilify", "abiraterone", "anni", @@ -45,6 +46,7 @@ "clopidogrel", "Coumadin", "CPIC", + "Crestor", "Cupertino", "dartx", "datetime", @@ -56,6 +58,7 @@ "drugid", "drugrecommendation", "duloxetine", + "Ezallor", "fluorouracil", "fullscreen", "haplotype", @@ -80,6 +83,7 @@ "Metabolizer", "mirabegron", "mocktail", + "myopathy", "Myrbetriq", "Neoprofen", "noto", @@ -99,12 +103,17 @@ "Proprinal", "pubspec", "RGBO", + "rosuvastatin", + "Roszet", "rxnorm", "screencast", "Screencasts", "screendocs", "sertraline", "simvastatin", + "SLCO", + "statin", + "Statins", "subfolders", "tacrolimus", "terbinafine",