Skip to content

Commit

Permalink
feat(#684): use lookup instead of phenotype across app
Browse files Browse the repository at this point in the history
  • Loading branch information
tamslo committed Jan 3, 2024
1 parent 6e99122 commit c107750
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
6 changes: 3 additions & 3 deletions app/lib/common/models/drug/drug_inhibitors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ List<String> inhibitorsFor(String gene) {
return _drugInhibitorsPerGene[gene] ?? [];
}

bool canBeInhibited(CpicLookup phenotype) {
return inhibitableGenes.contains(phenotype.gene) &&
phenotype.lookupkey != '0.0';
bool canBeInhibited(CpicLookup lookup) {
return inhibitableGenes.contains(lookup.gene) &&
lookup.lookupkey != '0.0';
}
20 changes: 10 additions & 10 deletions app/lib/report/pages/gene.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import '../../drug/widgets/module.dart';

@RoutePage()
class GenePage extends HookWidget {
GenePage(this.phenotype)
GenePage(this.lookup)
: cubit = DrugListCubit(
initialFilter: FilterState.forGene(phenotype.gene),
initialFilter: FilterState.forGene(lookup.gene),
);

final CpicLookup phenotype;
final CpicLookup lookup;
final DrugListCubit cubit;

@override
Expand All @@ -20,7 +20,7 @@ class GenePage extends HookWidget {
create: (context) => cubit,
child: BlocBuilder<DrugListCubit, DrugListState>(
builder: (context, state) => pageScaffold(
title: context.l10n.gene_page_headline(phenotype.gene),
title: context.l10n.gene_page_headline(lookup.gene),
body: [
Padding(
padding: EdgeInsets.symmetric(
Expand All @@ -31,9 +31,9 @@ class GenePage extends HookWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SubHeader(
context.l10n.gene_page_your_variant(phenotype.gene),
context.l10n.gene_page_your_variant(lookup.gene),
tooltip: context.l10n
.gene_page_name_tooltip(phenotype.gene),
.gene_page_name_tooltip(lookup.gene),
),
SizedBox(height: PharMeTheme.smallToMediumSpace),
RoundedCard(
Expand All @@ -49,16 +49,16 @@ class GenePage extends HookWidget {
children: [
_buildRow(
context.l10n.gene_page_genotype,
phenotype.genotype,
lookup.genotype,
tooltip: context.l10n.gene_page_genotype_tooltip
),
_buildPhenotypeRow(context),
],
),
if (canBeInhibited(phenotype))
if (canBeInhibited(lookup))
...buildDrugInteractionInfo(
context,
phenotype.gene,
lookup.gene,
),
],
)),
Expand All @@ -80,7 +80,7 @@ class GenePage extends HookWidget {

TableRow _buildPhenotypeRow(BuildContext context) {
final phenotypeInformation = UserData.phenotypeInformationFor(
phenotype.gene,
lookup.gene,
context,
);
final phenotypeText = phenotypeInformation.adaptionText.isNotNullOrBlank
Expand Down
22 changes: 11 additions & 11 deletions app/lib/report/pages/report.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ReportPage extends StatelessWidget {
Widget _buildReportPage(BuildContext context, ActiveDrugs activeDrugs) {
final hasActiveInhibitors = activeDrugs.names.any(isInhibitor);
final notTestedString = context.l10n.general_not_tested;
final userPhenotypes = CachedDrugs.instance.allGuidelineGenes.map(
final userLookus = CachedDrugs.instance.allGuidelineGenes.map(
(gene) => UserData.instance.lookups![gene] ??
// Add CpicLookup for unmatched lookup
CpicLookup(
Expand All @@ -27,7 +27,7 @@ class ReportPage extends StatelessWidget {
notTestedString,
lookupkey: notTestedString
)
).sortedBy((phenotype) => phenotype.gene);
).sortedBy((lookup) => lookup.gene);
return PopScope(
canPop: false,
child: unscrollablePageScaffold(
Expand All @@ -36,9 +36,9 @@ class ReportPage extends StatelessWidget {
children: [
PageDescription(context.l10n.report_content_explanation),
scrollList(
userPhenotypes.map((phenotype) => GeneCard(
phenotype,
key: Key('gene-card-${phenotype.gene}')
userLookus.map((lookup) => GeneCard(
lookup,
key: Key('gene-card-${lookup.gene}')
)).toList(),
),
if (hasActiveInhibitors) PageIndicatorExplanation(
Expand All @@ -55,21 +55,21 @@ class ReportPage extends StatelessWidget {
}

class GeneCard extends StatelessWidget {
const GeneCard(this.phenotype, { super.key });
const GeneCard(this.lookup, { super.key });

final CpicLookup phenotype;
final CpicLookup lookup;

@override
Widget build(BuildContext context) {
final phenotypeInformation = UserData.phenotypeInformationFor(
phenotype.gene,
lookup.gene,
context,
);
final phenotypeText = phenotypeInformation.adaptionText.isNullOrBlank
? phenotypeInformation.phenotype
: '${phenotypeInformation.phenotype}$drugInteractionIndicator';
final affectedDrugs = CachedDrugs.instance.drugs?.filter(
(drug) => drug.guidelineGenes.contains(phenotype.gene)
(drug) => drug.guidelineGenes.contains(lookup.gene)
) ?? [];
final warningLevelIndicators = WarningLevel.values.map(
(warningLevel) {
Expand Down Expand Up @@ -98,15 +98,15 @@ class GeneCard extends StatelessWidget {
}
).toList();
return RoundedCard(
onTap: () => context.router.push(GeneRoute(phenotype: phenotype)),
onTap: () => context.router.push(GeneRoute(lookup: lookup)),
radius: 16,
child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
phenotype.gene,
lookup.gene,
style: PharMeTheme.textTheme.titleMedium
),
SizedBox(height: 8),
Expand Down

0 comments on commit c107750

Please sign in to comment.