Skip to content

Commit

Permalink
feat(#662): show original phenotype on gene page and in PDF export
Browse files Browse the repository at this point in the history
  • Loading branch information
tamslo committed Oct 17, 2023
1 parent dc0f32a commit f0b0c67
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 15 deletions.
34 changes: 24 additions & 10 deletions app/lib/common/models/userdata/userdata.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ class PhenotypeInformation {
PhenotypeInformation({
this.phenotype,
this.adaptionText,
this.originalPhenotype,
this.overwrittenPhenotype,
});

String? phenotype;
String? adaptionText;
String? originalPhenotype;
String? overwrittenPhenotype;
}

/// UserData is a singleton data-class which contains various user-specific
Expand Down Expand Up @@ -60,21 +60,20 @@ class UserData {
if (originalPhenotype == null) {
return PhenotypeInformation();
}
final overwrittenLookup = UserData.overwrittenLookup(gene, drug: drug);
final activeInhibitors = UserData.activeInhibitorsFor(gene, drug: drug);
if (activeInhibitors.isEmpty) {
return PhenotypeInformation(phenotype: originalPhenotype);
}
final overwrittenLookup = UserData.overwrittenLookup(gene, drug: drug);
if (overwrittenLookup == null) {
final activeInhibitorsText = enumerationWithAnd(
activeInhibitors,
context
);
return PhenotypeInformation(
phenotype: originalPhenotype,
adaptionText: context.l10n.drugs_page_moderate_inhibitors(
userSalutation,
activeInhibitorsText,
enumerationWithAnd(
activeInhibitors,
context
),
),
);
}
Expand All @@ -84,6 +83,21 @@ class UserData {
final activeModerateInhibitors = activeInhibitors.filter(
isModerateInhibitor
).toList();
final overwritePhenotype = context.l10n.general_poor_metabolizer;
final currentPhenotypeEqualsOverwritePhenotype =
originalPhenotype.toLowerCase() == overwritePhenotype.toLowerCase();
if (currentPhenotypeEqualsOverwritePhenotype) {
return PhenotypeInformation(
phenotype: originalPhenotype,
adaptionText: context.l10n.drugs_page_inhibitors_poor_metabolizer(
userSalutation,
enumerationWithAnd(
activeInhibitors,
context
),
),
);
}
final adaptionText = activeModerateInhibitors.isEmpty
? context.l10n.drugs_page_strong_inhibitors(
userSalutation,
Expand All @@ -95,9 +109,9 @@ class UserData {
enumerationWithAnd(activeModerateInhibitors, context),
);
return PhenotypeInformation(
phenotype: context.l10n.general_poor_metabolizer,
phenotype: overwritePhenotype,
adaptionText: adaptionText,
originalPhenotype: originalPhenotype,
overwrittenPhenotype: originalPhenotype,
);
}

Expand Down
16 changes: 12 additions & 4 deletions app/lib/common/utilities/pdf_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,15 @@ String? _getPhenotypeInfo(String gene, Drug drug, BuildContext context) {
if (phenotypeInformation.adaptionText.isNullOrBlank) {
return phenotypeInformation.phenotype;
}
return '${phenotypeInformation.phenotype} '
'(${phenotypeInformation.originalPhenotype} '
'${phenotypeInformation.adaptionText})';
var phenotypeInformationText = '${phenotypeInformation.phenotype} ('
'${phenotypeInformation.adaptionText}';
if (phenotypeInformation.overwrittenPhenotype.isNotNullOrBlank) {
phenotypeInformationText = '$phenotypeInformationText; '
'${context.l10n.drugs_page_original_phenotype(
phenotypeInformation.overwrittenPhenotype!
)}';
}
return '$phenotypeInformationText)';
}

String? _getActivityScoreInfo(String gene, Drug drug, BuildContext context) {
Expand Down Expand Up @@ -165,7 +171,9 @@ String _userInfoPerGene(
if (drug.guidelines.isEmpty) return buildContext.l10n.pdf_no_value;
final guidelineGenes = drug.guidelines.first.lookupkey.keys.toList();
return guidelineGenes.map((gene) =>
'$gene: ${getInfo(gene, drug, buildContext) ?? buildContext.l10n.pdf_no_value}'
'$gene: ${
getInfo(gene, drug, buildContext) ?? buildContext.l10n.pdf_no_value
}'
).join(', ');
}

Expand Down
8 changes: 8 additions & 0 deletions app/lib/common/utilities/string.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,11 @@ String enumerationWithAnd(List<String> items, BuildContext context) {
final lastItem = itemsCopy.removeLast();
return '${itemsCopy.join(', ')} ${context.l10n.general_and} $lastItem';
}

String formatAsSentence(String text, {String ending = '.'}) {
var sentenceFormattedString = text.capitalize();
if (!sentenceFormattedString.endsWith(ending)) {
sentenceFormattedString = '$sentenceFormattedString$ending';
}
return sentenceFormattedString;
}
24 changes: 24 additions & 0 deletions app/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,20 @@
}
}
},
"drugs_page_inhibitors_poor_metabolizer": "this can be further influenced based on {salutation} taking {inhibitors}",
"@drugs_page_inhibitors_poor_metabolizer": {
"description": "Disclaimer for when the phenotype would be adjusted based on current drug(s) but is already poor metabolizer",
"placeholders": {
"salutation": {
"type": "String",
"example": "you"
},
"inhibitors": {
"type": "String",
"example": "bupropion and fluoxetine"
}
}
},
"drugs_page_moderate_and_strong_inhibitors": "phenotype adjusted based on {salutation} taking {strongInhibitors}; this can be further influenced by {moderateInhibitors}",
"@drugs_page_moderate_and_strong_inhibitors": {
"description": "Disclaimer for when the phenotype has been and might be adjusted based on current drug(s)",
Expand All @@ -120,6 +134,16 @@
}
}
},
"drugs_page_original_phenotype": "the genetics-based phenotype is {originalPhenotype}",
"@drugs_page_original_phenotype": {
"description": "Information on genetics-based phenotype if it was/might be adjusted based on current drug(s)",
"placeholders": {
"originalPhenotype": {
"type": "String",
"example": "Normal Metabolizer"
}
}
},
"drugs_page_your_genome": "Your genome",
"drugs_page_guidelines_empty": "No guidelines are present for {drugName}",
"@drugs_page_guidelines_empty": {
Expand Down
11 changes: 10 additions & 1 deletion app/lib/report/pages/gene.dart
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,18 @@ class GenePage extends HookWidget {
final furtherInhibitors = inhibitorsFor(gene).filter((drugName) =>
!UserData.activeInhibitorsFor(gene).contains(drugName)
);
var phenotypeInformationText = formatAsSentence(
phenotypeInformation.adaptionText!
);
if (phenotypeInformation.overwrittenPhenotype.isNotNullOrBlank) {
phenotypeInformationText = '$phenotypeInformationText ${
formatAsSentence(context.l10n.drugs_page_original_phenotype(
phenotypeInformation.overwrittenPhenotype!
))}';
}
return [
SizedBox(height: PharMeTheme.smallSpace),
Text('${phenotypeInformation.adaptionText!.capitalize()}.'),
Text(phenotypeInformationText),
SizedBox(height: PharMeTheme.smallSpace),
Text(context.l10n.gene_page_further_inhibitor_drugs),
SizedBox(height: PharMeTheme.smallSpace),
Expand Down

0 comments on commit f0b0c67

Please sign in to comment.