Skip to content

Commit

Permalink
refactor(#684): rename UserData.diplotypes to geneResults
Browse files Browse the repository at this point in the history
  • Loading branch information
tamslo committed Jan 3, 2024
1 parent 3643a46 commit 1cae81d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 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 @@ -55,7 +55,7 @@ void main() {
variant: '*1/*1',
lookupkey: '2')
};
UserData.instance.diplotypes = {
UserData.instance.geneResults = {
'CYP2C9': GeneResult(
gene: 'CYP2C9',
phenotype: 'Normal Metabolizer',
Expand Down
8 changes: 4 additions & 4 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, GeneResult>? diplotypes;
Map<String, GeneResult>? geneResults;

static PhenotypeInformation phenotypeInformationFor(
String gene,
Expand All @@ -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,
Expand Down Expand Up @@ -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<String, CpicLookup>? lookups;
Expand Down
8 changes: 4 additions & 4 deletions app/lib/common/utilities/genome_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Future<void> _saveDiplotypeAndActiveDrugsResponse(
geneResultsFromHTTPResponse(response);
final activeDrugList = activeDrugsFromHTTPResponse(response);

UserData.instance.diplotypes = {
UserData.instance.geneResults = {
for (final diplotype in diplotypes) diplotype.gene: diplotype
};
await UserData.save();
Expand All @@ -50,7 +50,7 @@ Future<void> fetchAndSaveLookups() async {
final json = jsonDecode(response.body) as List<dynamic>;
final lookups =
json.map((e) => CpicLookup.fromJson(e as Map<String, dynamic>));
final usersDiplotypes = UserData.instance.diplotypes;
final usersDiplotypes = UserData.instance.geneResults;
if (usersDiplotypes == null) throw Exception();

// use a HashMap for better time complexity
Expand Down Expand Up @@ -88,13 +88,13 @@ Future<void> 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() {
Expand Down
2 changes: 1 addition & 1 deletion app/lib/report/pages/report.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down

0 comments on commit 1cae81d

Please sign in to comment.