import 'liveConsultation.m.dart';
import 'vitalContractRecord.m.dart';
import 'notification.m.dart';
import 'device.m.dart';

class CreateServicePackRequest extends TokenRequest{
	String? code;
	String? name;
	ServicePackTypeEnum servicePackType;
	String? content;

	CreateServicePackRequest({
		this.code,
		this.name,
		this.servicePackType = ServicePackTypeEnum.BasePack,
		this.content,
		String? token,
	}) : super(
			token: token,
		);

	factory CreateServicePackRequest.fromJson(Map<String, dynamic> map) {
		return CreateServicePackRequest( 
			code: map['Code'],
			name: map['Name'],
			servicePackType: ServicePackTypeEnum.values.firstWhere((e) => e.index == map['ServicePackType']),
			content: map['Content'],
			token: map['Token'],
		);
	}

	Map<String, dynamic> toJson() {
		final map = super.toJson();
		if (code != null)
			map['Code'] = code;
		if (name != null)
			map['Name'] = name;
		map['ServicePackType'] = servicePackType.index;
		if (content != null)
			map['Content'] = content;
		return map;
	}
}

class GetServicePackRequest extends TokenRequest{
	String? code;

	GetServicePackRequest({
		this.code,
		String? token,
	}) : super(
			token: token,
		);

	factory GetServicePackRequest.fromJson(Map<String, dynamic> map) {
		return GetServicePackRequest( 
			code: map['Code'],
			token: map['Token'],
		);
	}

	Map<String, dynamic> toJson() {
		final map = super.toJson();
		if (code != null)
			map['Code'] = code;
		return map;
	}
}

class ServicePackPageRequest extends PageRequest{

	ServicePackPageRequest({
		int pageIndex = 0,
		int pageSize = 0,
		String? token,
	}) : super(
			pageIndex: pageIndex,
			pageSize: pageSize,
			token: token,
		);

	factory ServicePackPageRequest.fromJson(Map<String, dynamic> map) {
		return ServicePackPageRequest( 
			pageIndex: map['PageIndex'],
			pageSize: map['PageSize'],
			token: map['Token'],
		);
	}

	Map<String, dynamic> toJson() {
		final map = super.toJson();
		return map;
	}
}

class RemovetServicePackRequest extends TokenRequest{
	String? code;

	RemovetServicePackRequest({
		this.code,
		String? token,
	}) : super(
			token: token,
		);

	factory RemovetServicePackRequest.fromJson(Map<String, dynamic> map) {
		return RemovetServicePackRequest( 
			code: map['Code'],
			token: map['Token'],
		);
	}

	Map<String, dynamic> toJson() {
		final map = super.toJson();
		if (code != null)
			map['Code'] = code;
		return map;
	}
}

class UpdateServicePackRequest extends TokenRequest{
	String? code;
	String? name;
	ServicePackTypeEnum servicePackType;
	String? content;

	UpdateServicePackRequest({
		this.code,
		this.name,
		this.servicePackType = ServicePackTypeEnum.BasePack,
		this.content,
		String? token,
	}) : super(
			token: token,
		);

	factory UpdateServicePackRequest.fromJson(Map<String, dynamic> map) {
		return UpdateServicePackRequest( 
			code: map['Code'],
			name: map['Name'],
			servicePackType: ServicePackTypeEnum.values.firstWhere((e) => e.index == map['ServicePackType']),
			content: map['Content'],
			token: map['Token'],
		);
	}

	Map<String, dynamic> toJson() {
		final map = super.toJson();
		if (code != null)
			map['Code'] = code;
		if (name != null)
			map['Name'] = name;
		map['ServicePackType'] = servicePackType.index;
		if (content != null)
			map['Content'] = content;
		return map;
	}
}

class UpdateServicePackForItemsRequest extends TokenRequest{
	String? code;
	List<String>? items;

	UpdateServicePackForItemsRequest({
		this.code,
		this.items,
		String? token,
	}) : super(
			token: token,
		);

	factory UpdateServicePackForItemsRequest.fromJson(Map<String, dynamic> map) {
		return UpdateServicePackForItemsRequest( 
			code: map['Code'],
			items: map['Items']?.cast<String>().toList(),
			token: map['Token'],
		);
	}

	Map<String, dynamic> toJson() {
		final map = super.toJson();
		if (code != null)
			map['Code'] = code;
		if (items != null)
			map['Items'] = items;
		return map;
	}
}

enum ServiceItemTypeEnum {
	LimitCount,
	UnlimitedCount,
}

class CreateServiceItemRequest extends TokenRequest{
	String? name;
	String? content;
	ServiceItemTypeEnum serviceItemType;
	String? serviceNumber;
	String? department;
	String? guidancePrice;
	String? adjustedPrice;
	String? totalPrice;
	String? priceExplanation;

	CreateServiceItemRequest({
		this.name,
		this.content,
		this.serviceItemType = ServiceItemTypeEnum.LimitCount,
		this.serviceNumber,
		this.department,
		this.guidancePrice,
		this.adjustedPrice,
		this.totalPrice,
		this.priceExplanation,
		String? token,
	}) : super(
			token: token,
		);

	factory CreateServiceItemRequest.fromJson(Map<String, dynamic> map) {
		return CreateServiceItemRequest( 
			name: map['Name'],
			content: map['Content'],
			serviceItemType: ServiceItemTypeEnum.values.firstWhere((e) => e.index == map['ServiceItemType']),
			serviceNumber: map['ServiceNumber'],
			department: map['Department'],
			guidancePrice: map['GuidancePrice'],
			adjustedPrice: map['AdjustedPrice'],
			totalPrice: map['TotalPrice'],
			priceExplanation: map['PriceExplanation'],
			token: map['Token'],
		);
	}

	Map<String, dynamic> toJson() {
		final map = super.toJson();
		if (name != null)
			map['Name'] = name;
		if (content != null)
			map['Content'] = content;
		map['ServiceItemType'] = serviceItemType.index;
		if (serviceNumber != null)
			map['ServiceNumber'] = serviceNumber;
		if (department != null)
			map['Department'] = department;
		if (guidancePrice != null)
			map['GuidancePrice'] = guidancePrice;
		if (adjustedPrice != null)
			map['AdjustedPrice'] = adjustedPrice;
		if (totalPrice != null)
			map['TotalPrice'] = totalPrice;
		if (priceExplanation != null)
			map['PriceExplanation'] = priceExplanation;
		return map;
	}
}

class ServiceItemDTO extends BaseDTO{
	String? code;
	String? name;
	String? content;
	ServiceItemTypeEnum serviceItemType;
	String? serviceNumber;
	String? department;
	String? guidancePrice;
	String? adjustedPrice;
	String? totalPrice;
	String? priceExplanation;

	ServiceItemDTO({
		this.code,
		this.name,
		this.content,
		this.serviceItemType = ServiceItemTypeEnum.LimitCount,
		this.serviceNumber,
		this.department,
		this.guidancePrice,
		this.adjustedPrice,
		this.totalPrice,
		this.priceExplanation,
		DateTime? createTime,
		DateTime? updateTime,
	}) : super(
			createTime: createTime,
			updateTime: updateTime,
		);

	factory ServiceItemDTO.fromJson(Map<String, dynamic> map) {
		return ServiceItemDTO( 
			code: map['Code'],
			name: map['Name'],
			content: map['Content'],
			serviceItemType: ServiceItemTypeEnum.values.firstWhere((e) => e.index == map['ServiceItemType']),
			serviceNumber: map['ServiceNumber'],
			department: map['Department'],
			guidancePrice: map['GuidancePrice'],
			adjustedPrice: map['AdjustedPrice'],
			totalPrice: map['TotalPrice'],
			priceExplanation: map['PriceExplanation'],
			createTime: map['CreateTime'] != null ? DateTime.parse(map['CreateTime']) : null,
			updateTime: map['UpdateTime'] != null ? DateTime.parse(map['UpdateTime']) : null,
		);
	}

	Map<String, dynamic> toJson() {
		final map = super.toJson();
		if (code != null)
			map['Code'] = code;
		if (name != null)
			map['Name'] = name;
		if (content != null)
			map['Content'] = content;
		map['ServiceItemType'] = serviceItemType.index;
		if (serviceNumber != null)
			map['ServiceNumber'] = serviceNumber;
		if (department != null)
			map['Department'] = department;
		if (guidancePrice != null)
			map['GuidancePrice'] = guidancePrice;
		if (adjustedPrice != null)
			map['AdjustedPrice'] = adjustedPrice;
		if (totalPrice != null)
			map['TotalPrice'] = totalPrice;
		if (priceExplanation != null)
			map['PriceExplanation'] = priceExplanation;
		return map;
	}
}

class GetServiceItemRequest extends TokenRequest{
	String? code;

	GetServiceItemRequest({
		this.code,
		String? token,
	}) : super(
			token: token,
		);

	factory GetServiceItemRequest.fromJson(Map<String, dynamic> map) {
		return GetServiceItemRequest( 
			code: map['Code'],
			token: map['Token'],
		);
	}

	Map<String, dynamic> toJson() {
		final map = super.toJson();
		if (code != null)
			map['Code'] = code;
		return map;
	}
}

class GetServiceItemListRequest extends TokenRequest{
	List<String>? codes;

	GetServiceItemListRequest({
		this.codes,
		String? token,
	}) : super(
			token: token,
		);

	factory GetServiceItemListRequest.fromJson(Map<String, dynamic> map) {
		return GetServiceItemListRequest( 
			codes: map['Codes']?.cast<String>().toList(),
			token: map['Token'],
		);
	}

	Map<String, dynamic> toJson() {
		final map = super.toJson();
		if (codes != null)
			map['Codes'] = codes;
		return map;
	}
}

class RemovetServiceItemRequest extends TokenRequest{
	String? code;

	RemovetServiceItemRequest({
		this.code,
		String? token,
	}) : super(
			token: token,
		);

	factory RemovetServiceItemRequest.fromJson(Map<String, dynamic> map) {
		return RemovetServiceItemRequest( 
			code: map['Code'],
			token: map['Token'],
		);
	}

	Map<String, dynamic> toJson() {
		final map = super.toJson();
		if (code != null)
			map['Code'] = code;
		return map;
	}
}

class UpdateServiceItemRequest extends TokenRequest{
	String? code;
	String? name;
	String? content;
	ServiceItemTypeEnum serviceItemType;
	String? serviceNumber;
	String? department;
	String? guidancePrice;
	String? adjustedPrice;
	String? totalPrice;
	String? priceExplanation;

	UpdateServiceItemRequest({
		this.code,
		this.name,
		this.content,
		this.serviceItemType = ServiceItemTypeEnum.LimitCount,
		this.serviceNumber,
		this.department,
		this.guidancePrice,
		this.adjustedPrice,
		this.totalPrice,
		this.priceExplanation,
		String? token,
	}) : super(
			token: token,
		);

	factory UpdateServiceItemRequest.fromJson(Map<String, dynamic> map) {
		return UpdateServiceItemRequest( 
			code: map['Code'],
			name: map['Name'],
			content: map['Content'],
			serviceItemType: ServiceItemTypeEnum.values.firstWhere((e) => e.index == map['ServiceItemType']),
			serviceNumber: map['ServiceNumber'],
			department: map['Department'],
			guidancePrice: map['GuidancePrice'],
			adjustedPrice: map['AdjustedPrice'],
			totalPrice: map['TotalPrice'],
			priceExplanation: map['PriceExplanation'],
			token: map['Token'],
		);
	}

	Map<String, dynamic> toJson() {
		final map = super.toJson();
		if (code != null)
			map['Code'] = code;
		if (name != null)
			map['Name'] = name;
		if (content != null)
			map['Content'] = content;
		map['ServiceItemType'] = serviceItemType.index;
		if (serviceNumber != null)
			map['ServiceNumber'] = serviceNumber;
		if (department != null)
			map['Department'] = department;
		if (guidancePrice != null)
			map['GuidancePrice'] = guidancePrice;
		if (adjustedPrice != null)
			map['AdjustedPrice'] = adjustedPrice;
		if (totalPrice != null)
			map['TotalPrice'] = totalPrice;
		if (priceExplanation != null)
			map['PriceExplanation'] = priceExplanation;
		return map;
	}
}

class UpdateServicePackForLabelsRequest extends TokenRequest{
	String? code;
	List<String>? labels;

	UpdateServicePackForLabelsRequest({
		this.code,
		this.labels,
		String? token,
	}) : super(
			token: token,
		);

	factory UpdateServicePackForLabelsRequest.fromJson(Map<String, dynamic> map) {
		return UpdateServicePackForLabelsRequest( 
			code: map['Code'],
			labels: map['Labels']?.cast<String>().toList(),
			token: map['Token'],
		);
	}

	Map<String, dynamic> toJson() {
		final map = super.toJson();
		if (code != null)
			map['Code'] = code;
		if (labels != null)
			map['Labels'] = labels;
		return map;
	}
}