From 6e99122f2002180a2293b55223e9b12e46e0216e Mon Sep 17 00:00:00 2001 From: Tamara Slosarek Date: Wed, 3 Jan 2024 13:51:50 +0100 Subject: [PATCH] feat(#684): introduce Genotype interface --- app/lib/common/models/module.dart | 1 + app/lib/common/models/userdata/cpic_lookup.dart | 6 +++++- app/lib/common/models/userdata/gene_result.dart | 5 ++++- app/lib/common/models/userdata/genotype.dart | 9 +++++++++ 4 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 app/lib/common/models/userdata/genotype.dart diff --git a/app/lib/common/models/module.dart b/app/lib/common/models/module.dart index 0b5f1a3b..c1f60b2e 100644 --- a/app/lib/common/models/module.dart +++ b/app/lib/common/models/module.dart @@ -7,4 +7,5 @@ export 'drug/warning_level.dart'; export 'metadata.dart'; export 'userdata/cpic_lookup.dart'; export 'userdata/gene_result.dart'; +export 'userdata/genotype.dart'; export 'userdata/userdata.dart'; diff --git a/app/lib/common/models/userdata/cpic_lookup.dart b/app/lib/common/models/userdata/cpic_lookup.dart index 6a95b391..c5b9a25e 100644 --- a/app/lib/common/models/userdata/cpic_lookup.dart +++ b/app/lib/common/models/userdata/cpic_lookup.dart @@ -1,11 +1,13 @@ import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:hive/hive.dart'; +import 'genotype.dart'; + part 'cpic_lookup.g.dart'; @HiveType(typeId: 2) @JsonSerializable() -class CpicLookup{ +class CpicLookup implements Genotype { CpicLookup({ required this.gene, required this.phenotype, @@ -19,10 +21,12 @@ class CpicLookup{ return _$CpicLookupFromJson(json); } + @override @HiveField(0) @JsonKey(name: 'genesymbol') String gene; + @override @HiveField(1) @JsonKey(name: 'diplotype') String genotype; diff --git a/app/lib/common/models/userdata/gene_result.dart b/app/lib/common/models/userdata/gene_result.dart index ce4d08c1..be017389 100644 --- a/app/lib/common/models/userdata/gene_result.dart +++ b/app/lib/common/models/userdata/gene_result.dart @@ -3,12 +3,13 @@ import 'dart:convert'; import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:hive/hive.dart'; import 'package:http/http.dart'; +import 'genotype.dart'; part 'gene_result.g.dart'; @HiveType(typeId: 1) @JsonSerializable() -class GeneResult { +class GeneResult implements Genotype { GeneResult({ required this.gene, required this.genotype, @@ -19,9 +20,11 @@ class GeneResult { factory GeneResult.fromJson(dynamic json) => _$GeneResultFromJson(json); Map toJson() => _$GeneResultToJson(this); + @override @HiveField(0) String gene; + @override @HiveField(1) String genotype; diff --git a/app/lib/common/models/userdata/genotype.dart b/app/lib/common/models/userdata/genotype.dart new file mode 100644 index 00000000..2586a54d --- /dev/null +++ b/app/lib/common/models/userdata/genotype.dart @@ -0,0 +1,9 @@ +abstract class Genotype{ + Genotype({ + required this.gene, + required this.genotype, + }); + + String gene; + String genotype; +} \ No newline at end of file