Skip to content

Commit

Permalink
feat(#684): rename Diplotype to GeneResult
Browse files Browse the repository at this point in the history
  • Loading branch information
tamslo committed Jan 3, 2024
1 parent b062cfa commit 2b53352
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion app/integration_test/drugs_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void main() {
lookupkey: '2')
};
UserData.instance.diplotypes = {
'CYP2C9': Diplotype(
'CYP2C9': GeneResult(
gene: 'CYP2C9',
phenotype: 'Normal Metabolizer',
genotype: '*1/*1',
Expand Down
2 changes: 1 addition & 1 deletion app/lib/common/models/module.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, dynamic> toJson() => _$DiplotypeToJson(this);
factory GeneResult.fromJson(dynamic json) => _$GeneResultFromJson(json);
Map<String, dynamic> toJson() => _$GeneResultToJson(this);

@HiveField(0)
String gene;
Expand All @@ -33,7 +33,7 @@ class Diplotype {
}

// assumes http reponse from lab server
List<Diplotype> diplotypesFromHTTPResponse(Response resp) {
List<GeneResult> geneResultsFromHTTPResponse(Response resp) {
final json = jsonDecode(resp.body)['diplotypes'] as List<dynamic>;
return json.map<Diplotype>(Diplotype.fromJson).toList();
return json.map<GeneResult>(GeneResult.fromJson).toList();
}
4 changes: 2 additions & 2 deletions app/lib/common/models/userdata/userdata.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class UserData {
}

@HiveField(0)
Map<String, Diplotype>? diplotypes;
Map<String, GeneResult>? diplotypes;

static PhenotypeInformation phenotypeInformationFor(
String gene,
Expand Down Expand Up @@ -222,7 +222,7 @@ Future<void> 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;
Expand Down
2 changes: 1 addition & 1 deletion app/lib/common/utilities/genome_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Future<void> _saveDiplotypeAndActiveDrugsResponse(
) async {
// parse response to list of user's diplotypes
final diplotypes =
diplotypesFromHTTPResponse(response);
geneResultsFromHTTPResponse(response);
final activeDrugList = activeDrugsFromHTTPResponse(response);

UserData.instance.diplotypes = {
Expand Down

0 comments on commit 2b53352

Please sign in to comment.