|
|
|
|
class Hospital {
|
|
|
|
|
int id;
|
|
|
|
|
int customerCode;
|
|
|
|
|
String name;
|
|
|
|
|
List<Buildings> buildings;
|
|
|
|
|
|
|
|
|
|
Hospital({
|
|
|
|
|
this.id,
|
|
|
|
|
this.customerCode,
|
|
|
|
|
this.name,
|
|
|
|
|
this.buildings,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
factory Hospital.fromJson(Map<String, dynamic> parsedJson) {
|
|
|
|
|
List<Buildings> buildings = [];
|
|
|
|
|
|
|
|
|
|
if (parsedJson['buildings'] != null) {
|
|
|
|
|
buildings = [];
|
|
|
|
|
parsedJson['buildings'].forEach((v) {
|
|
|
|
|
buildings.add(Buildings.fromJson(v));
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Hospital(id: parsedJson["id"], name: parsedJson["custName"], customerCode: parsedJson["customerCode"], buildings: buildings);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
factory Hospital.fromHospital(Hospital hospital) {
|
|
|
|
|
return Hospital(id: hospital?.id, name: hospital?.name, customerCode: hospital?.customerCode, buildings: hospital?.buildings);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Map<String, dynamic> toMap() {
|
|
|
|
|
return {'id': id, 'customerCode': customerCode, 'custName': name, "buildings": buildings};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// class Data {
|
|
|
|
|
// int id;
|
|
|
|
|
// int customerCode;
|
|
|
|
|
// String custName;
|
|
|
|
|
// List<Buildings> buildings;
|
|
|
|
|
//
|
|
|
|
|
// Data({this.id, this.customerCode, this.custName, this.buildings});
|
|
|
|
|
//
|
|
|
|
|
// Data.fromJson(Map<String, dynamic> json) {
|
|
|
|
|
// id = json['id'];
|
|
|
|
|
// customerCode = json['customerCode'];
|
|
|
|
|
// custName = json['custName'];
|
|
|
|
|
// if (json['buildings'] != null) {
|
|
|
|
|
// buildings = new List<Buildings>();
|
|
|
|
|
// json['buildings'].forEach((v) {
|
|
|
|
|
// buildings.add(new Buildings.fromJson(v));
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// Map<String, dynamic> toJson() {
|
|
|
|
|
// final Map<String, dynamic> data = new Map<String, dynamic>();
|
|
|
|
|
// data['id'] = this.id;
|
|
|
|
|
// data['customerCode'] = this.customerCode;
|
|
|
|
|
// data['custName'] = this.custName;
|
|
|
|
|
// if (this.buildings != null) {
|
|
|
|
|
// data['buildings'] = this.buildings.map((v) => v.toJson()).toList();
|
|
|
|
|
// }
|
|
|
|
|
// return data;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
class Buildings {
|
|
|
|
|
int id;
|
|
|
|
|
String name;
|
|
|
|
|
int value;
|
|
|
|
|
List<Floors> floors;
|
|
|
|
|
|
|
|
|
|
Buildings({this.id, this.name, this.value, this.floors});
|
|
|
|
|
|
|
|
|
|
Buildings.fromJson(Map<String, dynamic> json) {
|
|
|
|
|
id = json['id'];
|
|
|
|
|
name = json['name'];
|
|
|
|
|
value = json['value'];
|
|
|
|
|
if (json['floors'] != null) {
|
|
|
|
|
floors = [];
|
|
|
|
|
json['floors'].forEach((v) {
|
|
|
|
|
floors.add(Floors.fromJson(v));
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Map<String, dynamic> toJson({bool includeFloors = true}) {
|
|
|
|
|
final Map<String, dynamic> data = <String, dynamic>{};
|
|
|
|
|
data['id'] = id;
|
|
|
|
|
data['name'] = name;
|
|
|
|
|
data['value'] = value;
|
|
|
|
|
if (floors != null && includeFloors) {
|
|
|
|
|
data['floors'] = floors.map((v) => v.toJson()).toList();
|
|
|
|
|
}
|
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class Floors {
|
|
|
|
|
int id;
|
|
|
|
|
String name;
|
|
|
|
|
int value;
|
|
|
|
|
List<Departments> departments;
|
|
|
|
|
|
|
|
|
|
Floors({this.id, this.name, this.value, this.departments});
|
|
|
|
|
|
|
|
|
|
Floors.fromJson(Map<String, dynamic> json) {
|
|
|
|
|
id = json['id'];
|
|
|
|
|
name = json['name'];
|
|
|
|
|
value = json['value'];
|
|
|
|
|
if (json['departments'] != null) {
|
|
|
|
|
departments = [];
|
|
|
|
|
json['departments'].forEach((v) {
|
|
|
|
|
departments.add(Departments.fromJson(v));
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Map<String, dynamic> toJson({bool includeDepartments = true}) {
|
|
|
|
|
final Map<String, dynamic> data = <String, dynamic>{};
|
|
|
|
|
data['id'] = id;
|
|
|
|
|
data['name'] = name;
|
|
|
|
|
data['value'] = value;
|
|
|
|
|
if (departments != null && includeDepartments) {
|
|
|
|
|
data['departments'] = departments.map((v) => v.toJson()).toList();
|
|
|
|
|
}
|
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class Departments {
|
|
|
|
|
int id;
|
|
|
|
|
String name;
|
|
|
|
|
|
|
|
|
|
Departments({this.id, this.name});
|
|
|
|
|
|
|
|
|
|
Departments.fromJson(Map<String, dynamic> json) {
|
|
|
|
|
id = json['id'];
|
|
|
|
|
name = json['name'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Map<String, dynamic> toJson() {
|
|
|
|
|
final Map<String, dynamic> data = <String, dynamic>{};
|
|
|
|
|
data['id'] = id;
|
|
|
|
|
data['name'] = name;
|
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
}
|