activeAllergy static method

List<AllergyIntolerance> activeAllergy(
  1. List<AllergyIntoleranceRelayEdge?>? allergies
)

Implementation

static List<AllergyIntolerance> activeAllergy(
    List<AllergyIntoleranceRelayEdge?>? allergies) {
  final List<AllergyIntolerance> activeAllergyIntolerance =
      List<AllergyIntolerance>.empty(growable: true);

  // no active allergy intolerance record
  if (allergies == null) return activeAllergyIntolerance;

  for (int i = 0; i < allergies.length; ++i) {
    final AllergyIntolerance? allergyIntolerance = allergies[i]?.node;

    if (allergyIntolerance == null) return activeAllergyIntolerance;

    if (allergyIntolerance.clinicalStatus?.text == 'Active') {
      activeAllergyIntolerance.add(allergyIntolerance);
    }
  }
  return activeAllergyIntolerance;
}