You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cloudsolutions-atoms/lib/models/service_request/service_request_search.dart

95 lines
2.3 KiB
Dart

import 'package:test_sa/models/hospital.dart';
import 'package:test_sa/models/lookup.dart';
import '../new_models/assigned_employee.dart';
class ServiceRequestSearch {
String callId;
String deviceSerialNumber;
String deviceNumber;
String deviceName;
Hospital hospital;
String model;
Lookup statusValue;
bool mostRecent;
String from, to;
Lookup dateOperator;
AssignedEmployee assignedEmployee;
ServiceRequestSearch({
this.deviceSerialNumber,
this.deviceNumber,
this.statusValue,
this.deviceName,
this.model,
this.hospital,
this.callId,
this.from,
this.to,
this.assignedEmployee,
this.dateOperator,
this.mostRecent = true,
});
fromSearch(ServiceRequestSearch newSearch) {
deviceSerialNumber = newSearch.deviceSerialNumber;
deviceNumber = newSearch.deviceNumber;
statusValue = newSearch.statusValue;
hospital = newSearch.hospital;
model = newSearch.model;
mostRecent = newSearch.mostRecent;
callId = newSearch.callId;
from = newSearch.from;
to = newSearch.to;
assignedEmployee = newSearch.assignedEmployee;
dateOperator = newSearch.dateOperator;
}
Map<String, dynamic> toMap() {
Map<String, dynamic> search = {};
if (deviceSerialNumber != null && deviceSerialNumber.isNotEmpty) {
search["assetSerialNumber"] = deviceSerialNumber;
}
if (mostRecent != null) {
search["mostRecent"] = mostRecent;
}
if (deviceNumber != null && deviceNumber.isNotEmpty) {
search["assetNo"] = deviceNumber;
}
if (statusValue != null) {
search["status"] = statusValue.toJson();
}
if (deviceName != null && deviceName.isNotEmpty) {
search["assetName"] = deviceName;
}
if (hospital != null) {
search["site"] = hospital.name;
}
if (model != null && model.isNotEmpty) {
search["modelDefinition"] = model;
}
if (callId != null && callId.isNotEmpty) {
search["callId"] = callId;
}
if (dateOperator != null && from != null) {
search["requestedDateSymbol"] = dateOperator.toJson();
search["requestedDateFrom"] = from;
}
if (dateOperator != null && to != null) {
search["requestedDateTo"] = to;
}
if (assignedEmployee != null) {
search["assignedEmployee"] = assignedEmployee.toJson();
}
return search;
}
}