Skip to content

Commit

Permalink
feat(app): add URL guidelines to PDF independent from userGuideline b…
Browse files Browse the repository at this point in the history
…eing present
  • Loading branch information
tamslo committed Feb 14, 2024
1 parent 3c6f22e commit f40c77c
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 26 deletions.
4 changes: 4 additions & 0 deletions app/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,9 @@
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
</dict>
</plist>
81 changes: 56 additions & 25 deletions app/lib/common/utilities/pdf_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -259,33 +259,73 @@ List<pw.Widget> _buildUserPart(
];
}

pw.Text _buildInfoText(String text) => pw.Text(
text,
style: pw.TextStyle(fontStyle: pw.FontStyle.italic),
);

List<pw.Widget> _buildExternalGuidelinePart(
Drug drug,
BuildContext buildContext
) {
final externalData = drug.userGuideline?.externalData;
final heading = _buildSubheading(
buildContext.l10n.pdf_heading_clinical_guidelines
);
return externalData == null ?
[ heading, _buildTextBlockSpacer(), pw.Text(buildContext.l10n.pdf_no_value) ] :
[
heading,
_buildTextBlockSpacer(),
pw.Text(
buildContext.l10n.pdf_info_clinical_guidelines,
style: pw.TextStyle(fontStyle: pw.FontStyle.italic),
final heading = [
_buildSubheading(
buildContext.l10n.pdf_heading_clinical_guidelines
),
_buildTextBlockSpacer(),
];
if (drug.userOrFirstGuideline == null) {
return [
...heading,
_buildInfoText(buildContext.l10n.drugs_page_guidelines_empty(drug.name)),
];
}
if (drug.userGuideline == null) {
return [
...heading,
_buildInfoText(
buildContext.l10n.pdf_info_clinical_guidelines_no_phenotype_guidelines,
),
...externalData.fold([], (externalGuidelines, guideline) =>
_buildTextBlockSpacer(),
..._buildGuidelineUrls(drug, buildContext),
];
}
return [
...heading,
_buildInfoText(buildContext.l10n.pdf_info_clinical_guidelines),
...drug.userGuideline!.externalData.fold([], (externalGuidelines, guideline) =>
[
...externalGuidelines,
_buildTextBlockSpacer(),
_buildTextDivider(),
..._buildGuidelinePart(guideline, buildContext)
]
),
_buildTextDivider()
];
_buildTextDivider(),
];
}

pw.UrlLink _buildLink(String destination, { String? displayText }) =>
pw.UrlLink(
child: pw.Text(
displayText ?? destination,
style: pw.TextStyle(
color: PdfColors.blue500,
decoration: pw.TextDecoration.underline,
)
),
destination: destination,
);

List<pw.Widget> _buildGuidelineUrls(Drug drug, BuildContext buildContext) {
return [
...drug.userOrFirstGuideline!.externalData.fold<List<String>>([], (links, guideline) =>
[
...links,
guideline.guidelineUrl,
]
).toSet().map(_buildLink),
];
}

List<pw.Widget> _buildGuidelinePart(
Expand All @@ -306,16 +346,7 @@ List<pw.Widget> _buildGuidelinePart(
),
),
_PdfSegment(child:
pw.UrlLink(
child: pw.Text(
guideline.guidelineUrl,
style: pw.TextStyle(
color: PdfColors.blue500,
decoration: pw.TextDecoration.underline,
)
),
destination: guideline.guidelineUrl,
)
_buildLink(guideline.guidelineUrl),
),
_buildTextSpacer(),
_PdfSegment(
Expand Down
3 changes: 2 additions & 1 deletion app/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,8 @@
"pdf_pgx_report": "PGx Report",
"pdf_heading_user_data": "User data",
"pdf_heading_clinical_guidelines": "Clinical guideline(s)",
"pdf_info_clinical_guidelines": "Clinical guideline(s) relevant for the phenotype. For more fine-grained information (e.g., in case of different guidelines for the user's phenotype) please refer to the original guideline (see URLs below).",
"pdf_info_clinical_guidelines": "For more fine-grained information please refer to the original guideline(s) by following the URL(s) below.",
"pdf_info_clinical_guidelines_no_phenotype_guidelines": "No guidelines were found for the user's phenotype. For further guideline information please refer to the URL(s) below.\n\nPlease note that it is possible that the guideline includes relevant information for the user's phenotype, although it could not be identified by PharMe.",
"pdf_no_value": "n/a",
"pdf_indication": "Indication",
"pdf_brand_names": "Brand names",
Expand Down

0 comments on commit f40c77c

Please sign in to comment.