class ServiceRequestSearch {
  String? deviceSerialNumber;
  String? deviceName;
  String? hospital;
  String? model;
  int? statusValue;

  ServiceRequestSearch({
    this.deviceSerialNumber,
    this.statusValue,
    this.deviceName,
    this.model,
    this.hospital,
  });

  fromSearch(ServiceRequestSearch newSearch) {
    deviceSerialNumber = newSearch.deviceSerialNumber;
    statusValue = newSearch.statusValue;
    hospital = newSearch.hospital;
    model = newSearch.model;
  }

  String toSearchString() {
    String search = "";
    if (deviceSerialNumber != null && (deviceSerialNumber?.isNotEmpty ?? false)) {
      search += "&sn_id=$deviceSerialNumber";
    }

    if (statusValue != null) {
      search += "&status=$statusValue";
    }

    if (deviceName != null && (deviceName?.isNotEmpty ?? false)) {
      search += "&equipment_en_name=$deviceName";
    }

    if (hospital != null && (hospital?.isNotEmpty ?? false)) {
      search += "&client=$hospital";
    }
    if (model != null && (model?.isNotEmpty ?? false)) {
      search += "&model=$model";
    }
    return search;
  }
}
