Skip to content

Commit

Permalink
test(app): add test for specific no result guidelines
Browse files Browse the repository at this point in the history
  • Loading branch information
tamslo committed Sep 24, 2024
1 parent 033ebbd commit 050e0b2
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 16 deletions.
44 changes: 29 additions & 15 deletions app/integration_test/drugs_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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<void> runTestCases(List<_TestCase> testCases) async {
Expand Down Expand Up @@ -308,6 +317,11 @@ void main() {
},
expectNoMappedGuidelines: true,
),
_TestCase(
description: 'mappable no result',
drug: rosuvastatinWithNoResultGuidelines,
expectNoMappedGuidelines: false,
),
]);
});

Expand Down
Original file line number Diff line number Diff line change
@@ -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,
),
),
],
);
4 changes: 3 additions & 1 deletion app/integration_test/fixtures/set_app_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
9 changes: 9 additions & 0 deletions pharme.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"settings": {
"typescript.preferences.importModuleSpecifier": "relative",
"cSpell.words": [
"ABCG",
"Abilify",
"abiraterone",
"anni",
Expand All @@ -45,6 +46,7 @@
"clopidogrel",
"Coumadin",
"CPIC",
"Crestor",
"Cupertino",
"dartx",
"datetime",
Expand All @@ -56,6 +58,7 @@
"drugid",
"drugrecommendation",
"duloxetine",
"Ezallor",
"fluorouracil",
"fullscreen",
"haplotype",
Expand All @@ -80,6 +83,7 @@
"Metabolizer",
"mirabegron",
"mocktail",
"myopathy",
"Myrbetriq",
"Neoprofen",
"noto",
Expand All @@ -99,12 +103,17 @@
"Proprinal",
"pubspec",
"RGBO",
"rosuvastatin",
"Roszet",
"rxnorm",
"screencast",
"Screencasts",
"screendocs",
"sertraline",
"simvastatin",
"SLCO",
"statin",
"Statins",
"subfolders",
"tacrolimus",
"terbinafine",
Expand Down

0 comments on commit 050e0b2

Please sign in to comment.