import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/models/new_models/site.dart';
import 'package:test_sa/modules/loan_module/models/medical_department_model.dart';
import 'package:test_sa/modules/medical_gas_inspection/models/medical_gas_supplier_model.dart';

class MedicalGasFormModel {
  int? id;
  int? requestOrderTypeId;
  Lookup? orderType;
  Lookup? itemType;
  int? itemTypeId;
  int? siteId;
  Site? site;
  MedicalDepartmentModel? department;
  MedicalGasSupplierModel? supplier;
  int? supplierId;
  bool? isSubmitted;
  List<MedicalGasFormDetailModel>? gasRequestDetail;

  MedicalGasFormModel({
    this.id,
    this.requestOrderTypeId,
    this.itemTypeId,
    this.siteId,
    this.supplierId,
    this.supplier,
    this.isSubmitted,
    this.orderType,
    this.itemType,
    this.site,
    this.department,
    this.gasRequestDetail,
  });

  MedicalGasFormModel.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    requestOrderTypeId = json['requestOrderTypeId'];
    itemTypeId = json['itemTypeId'];
    siteId = json['siteId'];
    supplierId = json['supplierId'];
    isSubmitted = json['isSubmitted'];
    if (json['gasRequestDetailDtos'] != null) {
      gasRequestDetail = [];
      json['gasRequestDetailDtos'].forEach((v) {
        gasRequestDetail!.add(MedicalGasFormDetailModel.fromJson(v));
      });
    }
  }

  Map<String, dynamic> toJson() {
    return {
      'id': id ?? 0,
      'requestOrderTypeId': orderType?.id,
      'itemTypeId': itemType?.id,
      'siteId': site?.id,
      'supplierId': supplier?.id,
      'isSubmitted': isSubmitted,
      'gasRequestDetailDtos': gasRequestDetail?.map((e) => e.toJson()).toList(),
    };
  }
}

class MedicalGasFormDetailModel {
  int? id;
  int? medicalGasAttributeId;
  num? requestedQuantity;

  MedicalGasFormDetailModel({
    this.id,
    this.medicalGasAttributeId,
    this.requestedQuantity,
  });

  MedicalGasFormDetailModel.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    medicalGasAttributeId = json['medicalGasAttributeId'];
    requestedQuantity = json['requestedQuantity'];
  }

  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'medicalGasAttributeId': medicalGasAttributeId,
      'requestedQuantity': requestedQuantity??0,
    };
  }
}
