From 2b533523179477beddfc3d22b0a91d8c87867f31 Mon Sep 17 00:00:00 2001 From: Tamara Slosarek Date: Wed, 3 Jan 2024 13:13:40 +0100 Subject: [PATCH] feat(#684): rename Diplotype to GeneResult --- app/integration_test/drugs_test.dart | 2 +- app/lib/common/models/module.dart | 2 +- .../userdata/{diplotype.dart => gene_result.dart} | 14 +++++++------- app/lib/common/models/userdata/userdata.dart | 4 ++-- app/lib/common/utilities/genome_data.dart | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) rename app/lib/common/models/userdata/{diplotype.dart => gene_result.dart} (64%) diff --git a/app/integration_test/drugs_test.dart b/app/integration_test/drugs_test.dart index 28bdad81..47ecad9e 100644 --- a/app/integration_test/drugs_test.dart +++ b/app/integration_test/drugs_test.dart @@ -56,7 +56,7 @@ void main() { lookupkey: '2') }; UserData.instance.diplotypes = { - 'CYP2C9': Diplotype( + 'CYP2C9': GeneResult( gene: 'CYP2C9', phenotype: 'Normal Metabolizer', genotype: '*1/*1', diff --git a/app/lib/common/models/module.dart b/app/lib/common/models/module.dart index a1c47b71..8c98e150 100644 --- a/app/lib/common/models/module.dart +++ b/app/lib/common/models/module.dart @@ -6,5 +6,5 @@ export 'drug/guideline.dart'; export 'drug/warning_level.dart'; export 'metadata.dart'; export 'userdata/cpic_phenotype.dart'; -export 'userdata/diplotype.dart'; +export 'userdata/gene_result.dart'; export 'userdata/userdata.dart'; diff --git a/app/lib/common/models/userdata/diplotype.dart b/app/lib/common/models/userdata/gene_result.dart similarity index 64% rename from app/lib/common/models/userdata/diplotype.dart rename to app/lib/common/models/userdata/gene_result.dart index b59a6adf..ce4d08c1 100644 --- a/app/lib/common/models/userdata/diplotype.dart +++ b/app/lib/common/models/userdata/gene_result.dart @@ -4,20 +4,20 @@ import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:hive/hive.dart'; import 'package:http/http.dart'; -part 'diplotype.g.dart'; +part 'gene_result.g.dart'; @HiveType(typeId: 1) @JsonSerializable() -class Diplotype { - Diplotype({ +class GeneResult { + GeneResult({ required this.gene, required this.genotype, required this.phenotype, required this.allelesTested, }); - factory Diplotype.fromJson(dynamic json) => _$DiplotypeFromJson(json); - Map toJson() => _$DiplotypeToJson(this); + factory GeneResult.fromJson(dynamic json) => _$GeneResultFromJson(json); + Map toJson() => _$GeneResultToJson(this); @HiveField(0) String gene; @@ -33,7 +33,7 @@ class Diplotype { } // assumes http reponse from lab server -List diplotypesFromHTTPResponse(Response resp) { +List geneResultsFromHTTPResponse(Response resp) { final json = jsonDecode(resp.body)['diplotypes'] as List; - return json.map(Diplotype.fromJson).toList(); + return json.map(GeneResult.fromJson).toList(); } diff --git a/app/lib/common/models/userdata/userdata.dart b/app/lib/common/models/userdata/userdata.dart index 3846c3bf..41a4aad3 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? diplotypes; static PhenotypeInformation phenotypeInformationFor( String gene, @@ -222,7 +222,7 @@ Future initUserData() async { // session which has not yet been written to local storage. try { Hive.registerAdapter(UserDataAdapter()); - Hive.registerAdapter(DiplotypeAdapter()); + Hive.registerAdapter(GeneResultAdapter()); Hive.registerAdapter(CpicPhenotypeAdapter()); } catch (e) { return; diff --git a/app/lib/common/utilities/genome_data.dart b/app/lib/common/utilities/genome_data.dart index a63644a6..21e289a3 100644 --- a/app/lib/common/utilities/genome_data.dart +++ b/app/lib/common/utilities/genome_data.dart @@ -27,7 +27,7 @@ Future _saveDiplotypeAndActiveDrugsResponse( ) async { // parse response to list of user's diplotypes final diplotypes = - diplotypesFromHTTPResponse(response); + geneResultsFromHTTPResponse(response); final activeDrugList = activeDrugsFromHTTPResponse(response); UserData.instance.diplotypes = {