class LabResult {
  String? description;
  dynamic femaleInterpretativeData;
  int? gender;
  int? lineItemNo;
  dynamic maleInterpretativeData;
  dynamic notes;
  String? packageID;
  int? patientID;
  String? projectID;
  String? referanceRange;
  String? resultValue;
  String? sampleCollectedOn;
  String? sampleReceivedOn;
  String? setupID;
  dynamic superVerifiedOn;
  String? testCode;
  String? uOM;
  String? verifiedOn;
  String? verifiedOnDateTime;
  String? changeResult;
  String? calculatedResultFlag;
  String? criticalHigh;
  String? referenceHigh;
  String? criticalLow;
  String? referenceLow;
  num? resultTypeID;
  String? packageShortDescription;
  int? testId;
  String? testShortDescription;
  String? PackageName;

  LabResult(
      {this.description,
        this.femaleInterpretativeData,
        this.gender,
        this.lineItemNo,
        this.maleInterpretativeData,
        this.notes,
        this.packageID,
        this.patientID,
        this.projectID,
        this.referanceRange,
        this.resultValue,
        this.sampleCollectedOn,
        this.sampleReceivedOn,
        this.setupID,
        this.superVerifiedOn,
        this.testCode,
        this.uOM,
        this.verifiedOn,
        this.calculatedResultFlag,
        this.verifiedOnDateTime,
        this.criticalHigh,
        this.referenceHigh,
        this.criticalLow,
        this.referenceLow,
        this.testId,
        this.testShortDescription,
        this.PackageName
      });

  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'];
    patientID = json['PatientID'];
    projectID = json['ProjectID'];
    referanceRange = json['ReferanceRange'];
    resultValue = json['ResultValue'];
    sampleCollectedOn = json['SampleCollectedOn'];
    sampleReceivedOn = json['SampleReceivedOn'];
    setupID = json['SetupID'];
    superVerifiedOn = json['SuperVerifiedOn'];
    testCode = json['TestCode'];
    uOM = json['UOM'];
    verifiedOn = json['VerifiedOn'];
    verifiedOnDateTime = json['VerifiedOnDateTime'];
    changeResult = json['ChangeResult'];
    calculatedResultFlag = json['CalculatedResultFlag'];
    criticalHigh = json['CriticalHigh'];
    referenceHigh = json['ReferenceHigh'];
    criticalLow = json['CriticalLow'];
    referenceLow = json['ReferenceLow'];
    packageShortDescription = json['PackageShortDescription'];
    resultTypeID = json['ResultTypeID'];
    testId = json['TestID'];
    testShortDescription = json['TestShortDescription'];
    PackageName = json['PackageName'];
  }

  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['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;
    data['ChangeResult'] = this.changeResult;
    data['CriticalHigh'] = this.criticalHigh;
    data['ReferenceHigh'] = this.referenceHigh;
    data['CriticalLow'] = this.criticalLow;
    data['ReferenceLow'] = this.referenceLow;
    data['TestID'] = this.testId;
    data['TestShortDescription'] = this.testShortDescription;
    data['PackageName'] = this.PackageName;
    return data;
  }

  bool checkIfGraphShouldBeDisplayed(){
    if (resultTypeID == null) return false;
    if (resultTypeID == 6) return false;
    if (referanceRange == null || referanceRange == "" || referanceRange == "\n") return false;
    bool isDigit =  RegExp(r"\\d+").hasMatch("$resultValue");
    if(isDigit) return true;
    try {
      num.parse(resultValue ?? "");
    } catch (e) {
      return false;
    }

    return true;
  }

  @override
  String toString() {
    return 'LabOrderResult(flag: $calculatedResultFlag, value: $resultValue, verifiedOn: $verifiedOnDateTime)';
  }
}
