getHeightAndFilterData static method
calculates the height of the container based on the number of items
Additional: Filters all relevant and active problems, allergies and medications for this patient based on their clinical status
Implementation
static double getHeightAndFilterData(int index) {
final SecondaryBannerInfoObject secondaryBannerInfoObject =
SecondaryBannerInfoObject();
final List<AllergyIntoleranceRelayEdge?>? allergies =
secondaryBannerInfoObject.allergiesList.valueOrNull;
final List<ConditionEdgeRelay?>? conditions =
secondaryBannerInfoObject.problemsList.valueOrNull;
final List<MedicationEdgeRelay?>? medications =
secondaryBannerInfoObject.medicationsList.valueOrNull;
const double defaultHeight = 230.0;
switch (index) {
case 0:
if (conditions == null) {
return defaultHeight;
}
final List<ConditionEdgeRelay?> all = conditions
.where((ConditionEdgeRelay? e) =>
(e!.node!.clinicalStatus!.text == 'Active') &&
(e.node!.category![0]!.text ==
ConditionCategory.problemListItem.name))
.toList();
return all.isEmpty ? defaultHeight : kProblemItemHeight * all.length;
case 1:
final List<dynamic> all =
BeWellSecondaryPatientBannerLogic.activeAllergy(allergies);
return all.isEmpty ? defaultHeight : kProblemItemHeight * all.length;
default:
if (medications == null) {
return defaultHeight;
}
final List<MedicationEdgeRelay?> all = medications
.where(
(MedicationEdgeRelay? e) => e!.node!.status!.name == 'Active')
.toList();
return all.isEmpty ? defaultHeight : kProblemItemHeight * all.length;
}
}