import 'package:fis_jsonrpc/services/contractRecord.m.dart';
import 'package:fis_jsonrpc/services/diagnosis.m.dart';

class DiagnosisAggregationRecordModel extends DiagnosisAggregationRecord {
  bool? isExistLocalData;
  DiagnosisAggregationRecordModel({
    this.isExistLocalData,
    super.patientCode,
    super.doctorCode,
    super.doctorName,
    super.patientName,
    super.patientGender,
    super.phone,
    super.cardNo,
    super.birthday,
    super.patientAddress,
    super.crowdLabels,
    super.organizationName,
    super.appDataId,
    super.diagnosisTime,
    super.registTime,
    super.diagnosisAggregationData,
    super.national,
  });

  factory DiagnosisAggregationRecordModel.fromJson(Map<String, dynamic> map) {
    return DiagnosisAggregationRecordModel(
      patientCode: map['PatientCode'],
      doctorCode: map['DoctorCode'],
      doctorName: map['DoctorName'],
      patientName: map['PatientName'],
      patientGender:
          GenderEnum.values.firstWhere((e) => e.index == map['PatientGender']),
      phone: map['Phone'],
      cardNo: map['CardNo'],
      birthday:
          map['Birthday'] != null ? DateTime.parse(map['Birthday']) : null,
      patientAddress: map['PatientAddress'],
      crowdLabels: map['CrowdLabels']?.cast<String>().toList(),
      organizationName: map['OrganizationName'],
      appDataId: map['AppDataId'],
      diagnosisTime: map['DiagnosisTime'] != null
          ? DateTime.parse(map['DiagnosisTime'])
          : null,
      registTime:
          map['RegistTime'] != null ? DateTime.parse(map['RegistTime']) : null,
      diagnosisAggregationData: map['DiagnosisAggregationData'],
      national: map['National'],
    );
  }
}
