// TODO = it have to be changed.

import 'package:doctor_app_flutter/utils/date-utils.dart';
import 'package:doctor_app_flutter/utils/utils.dart';

class PatiantInformtion {
  PatiantInformtion? patientDetails;
  int? genderInt;
  dynamic age;
  String? appointmentDate;
  DateTime? appointmentDateWithDateTimeForm;
  dynamic appointmentNo;
  dynamic appointmentType;
  String? arrivalTime;
  String? arrivalTimeD;
  int? callStatus;
  dynamic callStatusDisc;
  int? callTypeID;
  String? clientRequestID;
  String? clinicName;
  String? consoltationEnd;
  String? consultationNotes;
  int? appointmentTypeId;
  String? arrivedOn;
  int? clinicGroupId;
  String? companyName;
  dynamic dischargeStatus;
  dynamic doctorDetails;
  int? doctorId;
  String? endTime;
  int? episodeNo;
  int? fallRiskScore;
  bool? isSigned;
  int? medicationOrders;
  String? mobileNumber;
  String? nationality;
  int? projectId;
  int? clinicId;
  dynamic patientId;
  String? doctorName;
  String? doctorNameN;
  String? firstName;
  String? middleName;
  String? lastName;
  String? firstNameN;
  String? middleNameN;
  String? lastNameN;
  String? fullName;
  String? fullNameN;
  int? gender;
  String? dateofBirth;
  String? nationalityId;
  String? emailAddress;
  String? patientIdentificationNo;
  int? patientType;
  int? patientMRN;
  String? admissionNo;
  int? admissionID;
  int? admissionRequestNo;
  String? admissionDate;
  DateTime? admissionDateWithDateTimeForm;
  String? createdOn;
  String? roomId;
  String? bedId;
  String? nursingStationId;
  String? description;
  String? clinicDescription;
  String? clinicDescriptionN;
  String? nationalityName;
  String? nationalityNameN;
  String? genderDescription;
  String? nursingStationName;
  String? startTime;
  String? visitType;
  String? nationalityFlagURL;
  int? patientStatus;
  int? patientStatusType;
  int? visitTypeId;
  String? startTimes;
  String? dischargeDate;
  int? status;
  int? vcId;
  String? voipToken;
  String? pomrId;

  int? rowId;
  int? createdBy;
  int? editedBy;
  String? editedOn;

  PatiantInformtion(
      {this.patientDetails,
      this.projectId,
      this.clinicId,
      this.doctorId,
      this.patientId,
      this.doctorName,
      this.doctorNameN,
      this.firstName,
      this.middleName,
      this.lastName,
      this.firstNameN,
      this.middleNameN,
      this.lastNameN,
      this.gender,
      this.dateofBirth,
      this.nationalityId,
      this.mobileNumber,
      this.emailAddress,
      this.patientIdentificationNo,
      this.patientType,
      this.admissionNo,
      this.admissionDate,
      this.createdOn,
      this.roomId,
      this.bedId,
      this.nursingStationId,
      this.description,
      this.clinicDescription,
      this.clinicDescriptionN,
      this.nationalityName,
      this.nationalityNameN,
      this.age,
      this.genderDescription,
      this.nursingStationName,
      this.appointmentDate,
      this.startTime,
      this.appointmentNo,
      this.arrivalTime,
      this.arrivalTimeD,
      this.callStatus,
      this.callStatusDisc,
      this.callTypeID,
      this.clientRequestID,
      this.clinicName,
      this.consoltationEnd,
      this.consultationNotes,
      this.appointmentType,
      this.appointmentTypeId,
      this.arrivedOn,
      this.clinicGroupId,
      this.companyName,
      this.dischargeStatus,
      this.doctorDetails,
      this.endTime,
      this.episodeNo,
      this.fallRiskScore,
      this.genderInt,
      this.isSigned,
      this.medicationOrders,
      this.nationality,
      this.patientMRN,
      this.visitType,
      this.fullName,
      this.fullNameN,
      this.nationalityFlagURL,
      this.patientStatusType,
      this.patientStatus,
      this.visitTypeId,
      this.startTimes,
      this.dischargeDate,
      this.status,
      this.vcId,
      this.voipToken,
      this.admissionDateWithDateTimeForm,
      this.appointmentDateWithDateTimeForm,
      this.pomrId,
      this.admissionID,
      this.admissionRequestNo
      });

  PatiantInformtion.fromJson(Map<String, dynamic> json) {
    {
      patientDetails = json['patientDetails'] != null
          ? new PatiantInformtion.fromJson(json['patientDetails'])
          : null;
      projectId = json["ProjectID"] ?? json["projectID"];
      clinicId = json["ClinicID"] ?? json["clinicID"];
      doctorId = json["DoctorID"] ?? json["doctorID"];
      patientId = json["PatientID"] != null
          ? json["PatientID"] is String
              ? int?.parse(json["PatientID"])
              : json["PatientID"]
          : json["patientID"] ?? json['patientMRN'] ?? json['PatientMRN'];
      doctorName = json["DoctorName"] ?? json["doctorName"];
      doctorNameN = json["DoctorNameN"] ?? json["doctorNameN"];
      firstName = json["FirstName"] ?? json["firstName"];
      middleName = json["MiddleName"] ?? json["middleName"];
      lastName = json["LastName"] ?? json["lastName"];
      firstNameN = json["FirstNameN"] ?? json["firstNameN"];
      middleNameN = json["MiddleNameN"] ?? json["middleNameN"];
      lastNameN = json["LastNameN"] ?? json["lastNameN"];
      gender = json["Gender"] != null
          ? json["Gender"] is String
              ? int?.parse(json["Gender"])
              : json["Gender"]
          : json["gender"];
      fullName = json["fullName"] ?? json["fullName"] ?? json["PatientName"];
      fullNameN = json["fullNameN"] ?? json["fullNameN"] ?? json["PatientName"];
      dateofBirth = json["DateofBirth"] ?? json["dob"] ?? json['DateOfBirth'];
      nationalityId = json["NationalityID"] ?? json["nationalityID"];
      mobileNumber = json["MobileNumber"] ?? json["mobileNumber"];
      emailAddress = json["EmailAddress"] ?? json["emailAddress"];
      patientIdentificationNo =
          json["PatientIdentificationNo"] ?? json["patientIdentificationNo"];
      //TODO make 7 dynamic when the backend retrun it in patient arrival
      patientType = json["PatientType"] ?? json["patientType"] ?? 1;
      admissionNo = json["AdmissionNo"] ?? json["admissionNo"];
      admissionDate = json["AdmissionDate"] ?? json["admissionDate"];
      createdOn = json["CreatedOn"] ?? json["CreatedOn"];
      roomId = json["RoomID"] ?? json["roomID"];
      bedId = json["BedID"] ?? json["bedID"];
      nursingStationId = json["NursingStationID"] ?? json["nursingStationID"];
      description = json["Description"] ?? json["description"];
      clinicDescription = Utils.convertToTitleCase(
          json["ClinicDescription"] ?? json["clinicDescription"]??'');
      clinicDescriptionN =
          json["ClinicDescriptionN"] ?? json["clinicDescriptionN"];
      nationalityName = json["NationalityName"] ??
          json["nationalityName"] ??
          json['NationalityName'];
      nationalityNameN = json["NationalityNameN"] ??
          json["nationalityNameN"] ??
          json['NationalityNameN'];
      age = json["Age"] ?? json["age"];
      genderDescription = json["GenderDescription"];
      nursingStationName = json["NursingStationName"];
      appointmentDate = json["AppointmentDate"] ?? '';
      startTime = json["startTime"] ?? json['StartTime'];
      appointmentNo = json['appointmentNo'] ?? json['AppointmentNo'];
      appointmentType = json['appointmentType'];
      appointmentTypeId =
          json['appointmentTypeId'] ?? json['appointmentTypeid'];
      arrivedOn = json['ArrivedOn'] ?? json['arrivedOn'] ?? json['ArrivedOn'];
      clinicGroupId = json['clinicGroupId'];
      companyName = json['companyName'];
      dischargeStatus = json['dischargeStatus'];
      doctorDetails = json['doctorDetails'];
      endTime = json['endTime'];
      episodeNo = json['episodeNo'] ?? json['EpisodeID'] ?? json['EpisodeNo'];
      fallRiskScore = json['fallRiskScore'];
      isSigned = json['IsSigned'];
      medicationOrders = json['medicationOrders'];
      nationality = json['nationality'] ?? json['NationalityNameN'];
      patientMRN = json['patientMRN'] ??
          json['PatientMRN'] ??
          (json["PatientID"] != null
              ? int?.parse(json["PatientID"].toString())
              : json["patientID"] != null
                  ? int?.parse(json["patientID"].toString())
                  : json["patientId"] != null
                      ? int?.parse(json["patientId"].toString())
                      : '');
      visitType = json['visitType'] ?? json['visitType'] ?? json['visitType'];
      nationalityFlagURL =
          json['NationalityFlagURL'] ?? json['NationalityFlagURL'];
      patientStatusType =
          json['patientStatusType'] ?? json['PatientStatusType'];
      visitTypeId =
          json['visitTypeId'] ?? json['visitTypeId'] ?? json['visitTypeid'];
      startTimes = json['StartTime'] ?? json['StartTime'];
      dischargeDate = json['DischargeDate'];
      status = json['Status'];
      vcId = json['VC_ID'];

      arrivalTime = json['ArrivalTime'];
      arrivalTimeD = json['ArrivalTimeD'];
      callStatus = json['CallStatus'];
      callStatusDisc = json['CallStatusDisc'];
      callTypeID = json['CallTypeID'];
      clientRequestID = json['ClientRequestID'];
      clinicName = json['ClinicName'];
      consoltationEnd = json['ConsoltationEnd'];
      consultationNotes = json['ConsultationNotes'];
      patientStatus = json['PatientStatus'];
      voipToken = json['VoipToken'];
      pomrId = json['pomrId']??(json["PatientPomrID"]?.toString());
      admissionDateWithDateTimeForm = json["AdmissionDate"] != null
          ? AppDateUtils.convertStringToDate(json["AdmissionDate"])
          : json["admissionDate"] != null
              ? AppDateUtils.convertStringToDate(json["admissionDate"])
              : null;

      appointmentDateWithDateTimeForm = json["AppointmentDate"] != null
          ? AppDateUtils.convertStringToDate(json["AppointmentDate"])
          : null;
      rowId = json['RowID'];
      createdBy = json['CreatedBy'];
      editedBy = json['EditedBy'];
      admissionID = json['AdmissionID'];
      admissionRequestNo = json['AdmissionRequestNo'];
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();

    data['patientDetails'] = this.patientDetails;
    data["ProjectID"] = this.projectId;
    data["projectID"] = this.projectId;
    data["ClinicID"] = this.clinicId;
    data["clinicID"] = this.clinicId;
    data["DoctorID"] = this.doctorId;
    data["doctorID"] = this.doctorId;
    data["PatientID"] = this.patientId;
    data["patientID"] = this.patientId;
    data['patientMRN'] = this.patientMRN;
    data['PatientMRN'] = this.patientMRN;

    data['episodeNo'] = this.episodeNo;
    data['EpisodeID'] = this.episodeNo;
    data['EpisodeNo'] = this.episodeNo;

    data["DoctorName"] = this.doctorName;
    data["doctorName"] = this.doctorName;
    data["DoctorNameN"] = this.doctorNameN;
    data["doctorNameN"] = this.doctorNameN;
    data["FirstName"] = this.firstName;
    data["firstName"] = this.firstName;
    data["MiddleName"] = this.middleName;
    data["middleName"] = this.middleName;
    data["LastName"] = this.lastName;
    data["lastName"] = this.lastName;
    data["FirstNameN"] = this.firstNameN;
    data["firstNameN"] = this.firstNameN;
    data["MiddleNameN"] = this.middleNameN;
    data["middleNameN"] = this.middleNameN;
    data["LastNameN"] = this.lastNameN;
    data["lastNameN"] = this.lastNameN;

    data["fullName"] = this.fullName;
    data["fullName"] = this.fullName;
    data["PatientName"] = this.fullName;

    data["Gender"] = this.gender;
    data["gender"] = this.gender;

    data['Age'] = this.age;
    data['AppointmentDate'] =
        this.appointmentDate!.isNotEmpty ? this.appointmentDate : null;

    data['AppointmentNo'] = this.appointmentNo;
    data['ArrivalTime'] = this.arrivalTime;
    data['ArrivalTimeD'] = this.arrivalTimeD;
    data['CallStatus'] = this.callStatus;
    data['CallStatusDisc'] = this.callStatusDisc;
    data['CallTypeID'] = this.callTypeID;
    data['ClientRequestID'] = this.clientRequestID;
    data['ClinicName'] = this.clinicName;
    data['ConsoltationEnd'] = this.consoltationEnd;
    data['ConsultationNotes'] = this.consultationNotes;
    data['CreatedOn'] = this.createdOn;
    data['DoctorName'] = this.doctorName;
    data['Gender'] = this.gender;
    data['MobileNumber'] = this.mobileNumber;
    data['PatientID'] = this.patientId;
    data['PatientStatus'] = this.patientStatus;
    data['ProjectID'] = this.projectId;
    data['VC_ID'] = this.vcId;
    data['VoipToken'] = this.voipToken;
    data['pomrId'] = this.pomrId;
    data["DateofBirth"] = this.dateofBirth;
    data["dob"] = this.dateofBirth;
    data['DateOfBirth'] = this.dateofBirth;
    return data;
  }
}
