class LabResult {
  String? description;
  dynamic femaleInterpretativeData;
  int? gender;
  int? lineItemNo;
  dynamic maleInterpretativeData;
  String? notes;
  String? packageID;
  int? patientID;
  String? projectID;
  String? referanceRange;
  String? resultValue;
  String? maxValue;
  String? minValue;
  String? sampleCollectedOn;
  String? sampleReceivedOn;
  String? setupID;
  dynamic superVerifiedOn;
  String? testCode;
  String? uOM;
  String? verifiedOn;
  dynamic verifiedOnDateTime;

  LabResult(
      {this.description,
      this.femaleInterpretativeData,
      this.gender,
      this.lineItemNo,
      this.maleInterpretativeData,
      this.notes,
      this.packageID,
      this.patientID,
      this.projectID,
      this.referanceRange,
      this.resultValue,
      this.maxValue,
      this.minValue,
      this.sampleCollectedOn,
      this.sampleReceivedOn,
      this.setupID,
      this.superVerifiedOn,
      this.testCode,
      this.uOM,
      this.verifiedOn,
      this.verifiedOnDateTime});

  LabResult.fromJson(Map<String, dynamic> json) {
    description = json['Description'];
    femaleInterpretativeData = json['FemaleInterpretativeData'];
    gender = json['Gender'];
    lineItemNo = json['LineItemNo'];
    maleInterpretativeData = json['MaleInterpretativeData'];
    notes = json['Notes'];
    packageID = json['PackageID'].toString();
    patientID = json['PatientID'];
    projectID = json['ProjectID'].toString();
    referanceRange = json['ReferenceRange'] ?? json['ReferanceRange'];
    resultValue = json['ResultValue'];
    maxValue = json['MaxValue'];
    minValue = json['MinValue'];
    sampleCollectedOn = json['SampleCollectedOn'];
    sampleReceivedOn = json['SampleReceivedOn'];
    setupID = json['SetupID'];
    superVerifiedOn = json['SuperVerifiedOn'];
    testCode = json['TestCode'];
    uOM = json['UOM'];
    verifiedOn = json['VerifiedOn'];
    verifiedOnDateTime = json['VerifiedOnDateTime'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['Description'] = this.description;
    data['FemaleInterpretativeData'] = this.femaleInterpretativeData;
    data['Gender'] = this.gender;
    data['LineItemNo'] = this.lineItemNo;
    data['MaleInterpretativeData'] = this.maleInterpretativeData;
    data['Notes'] = this.notes;
    data['PackageID'] = this.packageID;
    data['PatientID'] = this.patientID;
    data['ProjectID'] = this.projectID;
    data['ReferanceRange'] = this.referanceRange;
    data['ResultValue'] = this.resultValue;
    data['MaxValue'] = this.maxValue;
    data['MinValue'] = this.minValue;
    data['SampleCollectedOn'] = this.sampleCollectedOn;
    data['SampleReceivedOn'] = this.sampleReceivedOn;
    data['SetupID'] = this.setupID;
    data['SuperVerifiedOn'] = this.superVerifiedOn;
    data['TestCode'] = this.testCode;
    data['UOM'] = this.uOM;
    data['VerifiedOn'] = this.verifiedOn;
    data['VerifiedOnDateTime'] = this.verifiedOnDateTime;
    return data;
  }

  int? checkResultStatus() {
    try {
      var max = double?.tryParse(maxValue!) ?? null;
      var min = double?.tryParse(minValue!) ?? null;
      var result = double?.tryParse(resultValue!) ?? null;
      if (max != null && min != null && result != null) {
        if (result > max) {
          return 1;
        } else if (result < min) {
          return -1;
        } else {
          return 0;
        }
      } else {
        return 0;
      }
    } catch (e) {
      return 0;
    }
  }
}

class LabResultList {
  String filterName = "";
  List<LabResult> patientLabResultList = [];

  LabResultList({required this.filterName, LabResult? lab}) {
    patientLabResultList.add(lab!);
  }
}
