class ConsultationServerConfig {
  ////预约会诊显示的会诊申请信息字段是从Server获取的
  List<AppointmentModel> appointmentKeyList;
  ////预约会诊显示的病人信息字段是从Server获取的
  List<PatientModel> patientKeyList;
  String version;
  ConsultationServerConfig(
      this.patientKeyList, this.appointmentKeyList, this.version);

  factory ConsultationServerConfig.fromJson(
      Map<String, dynamic> json, String version) {
    return ConsultationServerConfig(
      json['Patient'] == null
          ? []
          : (json['Patient'] as Map<String, dynamic>)
              .entries
              .map((e) => PatientModel.fromJson(e.value, e.key))
              .toList(),
      json['ConsultationBaseInfo'] == null
          ? []
          : (json['ConsultationBaseInfo'] as Map<String, dynamic>)
              .entries
              .map((e) => AppointmentModel.fromJson(e.value, e.key))
              .toList(),
      version,
    );
  }
}

class PatientModel {
  final String key;
  final String type;
  final String showType;
  final bool required;
  final String desc;
  String? defaultValue;

  /// 数据是dynamic格式的
  final List<dynamic>? source;

  PatientModel({
    required this.key,
    required this.type,
    required this.showType,
    required this.required,
    required this.desc,
    this.defaultValue = '',
    this.source,
  });

  factory PatientModel.fromJson(Map<String, dynamic> json, String key) {
    return PatientModel(
        key: key,
        type: json['Type'],
        showType: json['ShowType'],
        required: json['Required'],
        desc: json['Desc'],
        source: json['Source'],
        defaultValue: json['DefaultValue']);
  }
}

class AppointmentModel {
  final String key;
  final bool isDefault;
  final bool required;
  final bool? isShow;
  AppointmentModel({
    required this.key,
    required this.isDefault,
    required this.required,
    this.isShow = true,
  });

  factory AppointmentModel.fromJson(Map<String, dynamic> json, String key) {
    return AppointmentModel(
      key: key,
      isDefault: json['IsDefult'],
      required: json['Required'],
      isShow: json['IsShow'],
    );
  }
}
