From 1cae81de5ff0470b607ba9bbcb4ef5189df42603 Mon Sep 17 00:00:00 2001 From: Tamara Slosarek Date: Wed, 3 Jan 2024 15:38:27 +0100 Subject: [PATCH] refactor(#684): rename UserData.diplotypes to geneResults --- app/integration_test/drugs_test.dart | 2 +- app/lib/common/models/userdata/userdata.dart | 8 ++++---- app/lib/common/utilities/genome_data.dart | 8 ++++---- app/lib/report/pages/report.dart | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/integration_test/drugs_test.dart b/app/integration_test/drugs_test.dart index b0e73914..9a25b506 100644 --- a/app/integration_test/drugs_test.dart +++ b/app/integration_test/drugs_test.dart @@ -55,7 +55,7 @@ void main() { variant: '*1/*1', lookupkey: '2') }; - UserData.instance.diplotypes = { + UserData.instance.geneResults = { 'CYP2C9': GeneResult( gene: 'CYP2C9', phenotype: 'Normal Metabolizer', diff --git a/app/lib/common/models/userdata/userdata.dart b/app/lib/common/models/userdata/userdata.dart index 733eac6c..5ad8efe9 100644 --- a/app/lib/common/models/userdata/userdata.dart +++ b/app/lib/common/models/userdata/userdata.dart @@ -46,7 +46,7 @@ class UserData { } @HiveField(0) - Map? diplotypes; + Map? geneResults; static PhenotypeInformation phenotypeInformationFor( String gene, @@ -63,7 +63,7 @@ class UserData { final strongInhibitorTextPrefix = useLongPrefix ? context.l10n.strong_inhibitor_long_prefix : context.l10n.gene_page_phenotype.toLowerCase(); - final originalPhenotype = UserData.instance.diplotypes?[gene]?.phenotype; + final originalPhenotype = UserData.instance.geneResults?[gene]?.phenotype; if (originalPhenotype == null) { return PhenotypeInformation( phenotype: context.l10n.general_not_tested, @@ -112,10 +112,10 @@ class UserData { } static String? variantFor(String gene) => - UserData.instance.diplotypes?[gene]?.variant; + UserData.instance.geneResults?[gene]?.variant; static String? allelesTestedFor(String gene) => - UserData.instance.diplotypes?[gene]?.allelesTested; + UserData.instance.geneResults?[gene]?.allelesTested; @HiveField(1) Map? lookups; diff --git a/app/lib/common/utilities/genome_data.dart b/app/lib/common/utilities/genome_data.dart index a29cb4ef..e69830cb 100644 --- a/app/lib/common/utilities/genome_data.dart +++ b/app/lib/common/utilities/genome_data.dart @@ -30,7 +30,7 @@ Future _saveDiplotypeAndActiveDrugsResponse( geneResultsFromHTTPResponse(response); final activeDrugList = activeDrugsFromHTTPResponse(response); - UserData.instance.diplotypes = { + UserData.instance.geneResults = { for (final diplotype in diplotypes) diplotype.gene: diplotype }; await UserData.save(); @@ -50,7 +50,7 @@ Future fetchAndSaveLookups() async { final json = jsonDecode(response.body) as List; final lookups = json.map((e) => CpicLookup.fromJson(e as Map)); - final usersDiplotypes = UserData.instance.diplotypes; + final usersDiplotypes = UserData.instance.geneResults; if (usersDiplotypes == null) throw Exception(); // use a HashMap for better time complexity @@ -88,13 +88,13 @@ Future fetchAndSaveLookups() async { bool shouldFetchLookups() { final lookupsPresent = UserData.instance.lookups?.isNotEmpty ?? false; - final diplotypesPresent = UserData.instance.diplotypes?.isNotEmpty ?? false; + final diplotypesPresent = UserData.instance.geneResults?.isNotEmpty ?? false; final result = (_isOutDated() || !lookupsPresent) && diplotypesPresent; return result; } bool shouldFetchDiplotypes() { - return UserData.instance.diplotypes == null; + return UserData.instance.geneResults == null; } bool _isOutDated() { diff --git a/app/lib/report/pages/report.dart b/app/lib/report/pages/report.dart index f641460a..1bd669a1 100644 --- a/app/lib/report/pages/report.dart +++ b/app/lib/report/pages/report.dart @@ -23,7 +23,7 @@ class ReportPage extends StatelessWidget { // phenotype will be overwritten with phenotype from lab or inhibited // phenotype using PhenotypeInformation in GeneCard and GenePage phenotype: notTestedString, - variant: UserData.instance.diplotypes?[gene]?.variant ?? + variant: UserData.instance.geneResults?[gene]?.variant ?? notTestedString, lookupkey: notTestedString )