Skip to content

Commit

Permalink
fix(app): correctly map HLA-B counts and guidelines
Browse files Browse the repository at this point in the history
  • Loading branch information
tamslo committed Sep 6, 2024
1 parent df02e86 commit 3bfde6f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
8 changes: 6 additions & 2 deletions app/lib/common/models/drug/drug.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,12 @@ extension DrugExtension on Drug {

Guideline? get userGuideline => guidelines.firstOrNullWhere(
(guideline) => guideline.lookupkey.all(
(gene, variants) =>
variants.contains(UserData.lookupFor(gene, drug: name))
(gene, variants) => variants.any((variant) =>
variants.contains(UserData.lookupFor(
GenotypeKey(gene, variant).value,
drug: name,
)
)),
),
);

Expand Down
7 changes: 6 additions & 1 deletion app/lib/common/models/drug/drug_inhibitors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,12 @@ bool isInhibitor(String drugName) {
var drugIsInhibitor = false;
for (final gene in _drugInhibitorsPerGene.keys) {
final influencingDrugs = _drugInhibitorsPerGene[gene];
final originalLookup = UserData.lookupFor(gene, drug: drugName, useOverwrite: false);
// WARNING: this does not work for non-unique genes, such as HLA-B
final originalLookup = UserData.lookupFor(
gene,
drug: drugName,
useOverwrite: false,
);
if (influencingDrugs!.contains(drugName) && originalLookup != '0.0') {
drugIsInhibitor = true;
break;
Expand Down
10 changes: 5 additions & 5 deletions app/lib/report/pages/report.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,19 @@ class ReportPage extends StatelessWidget {
];
final warningLevelCounts = <String, WarningLevelCounts>{};
for (final genotypeResult in userGenotypes) {
warningLevelCounts[genotypeResult.gene] = {};
warningLevelCounts[genotypeResult.key.value] = {};
final affectedDrugs = CachedDrugs.instance.drugs?.filter(
(drug) => drug.guidelineGenotypes.contains(genotypeResult.key.value)
) ?? [];
for (final warningLevel in WarningLevel.values) {
warningLevelCounts[genotypeResult.gene]![warningLevel] =
warningLevelCounts[genotypeResult.key.value]![warningLevel] =
affectedDrugs.filter(
(drug) => drug.warningLevel == warningLevel
).length;
}
}
var sortedGenotypes = userGenotypes.sortedBy(
(genotypeResult) => genotypeResult.gene
(genotypeResult) => genotypeResult.key.value
);
final sortedWarningLevelSeverities = Set<int>.from(
WarningLevel.values
Expand All @@ -57,7 +57,7 @@ class ReportPage extends StatelessWidget {
for (final severity in sortedWarningLevelSeverities) {
sortedGenotypes = sortedGenotypes.sortedByDescending((genotypeResult) =>
_getSeverityCount(
warningLevelCounts[genotypeResult.gene]!,
warningLevelCounts[genotypeResult.key.value]!,
severity,
),
);
Expand Down Expand Up @@ -86,7 +86,7 @@ class ReportPage extends StatelessWidget {
),
...sortedGenotypes.map((genotypeResult) => GeneCard(
genotypeResult,
warningLevelCounts[genotypeResult.gene]!,
warningLevelCounts[genotypeResult.key.value]!,
key: Key('gene-card-${genotypeResult.key.value}')
)),
],
Expand Down

0 comments on commit 3bfde6f

Please sign in to comment.