From 495c8fb3b067605a2ea86b057c3e8d1f152f9a4f Mon Sep 17 00:00:00 2001 From: mosazaid Date: Tue, 21 Sep 2021 16:27:10 +0300 Subject: [PATCH] change lab result design --- lib/core/model/labs/lab_result.dart | 67 +++++++++++++------ .../profile/lab_result/LabResultWidget.dart | 3 +- 2 files changed, 50 insertions(+), 20 deletions(-) diff --git a/lib/core/model/labs/lab_result.dart b/lib/core/model/labs/lab_result.dart index 1c09696b..ee9f981d 100644 --- a/lib/core/model/labs/lab_result.dart +++ b/lib/core/model/labs/lab_result.dart @@ -10,6 +10,8 @@ class LabResult { String projectID; String referanceRange; String resultValue; + String maxValue; + String minValue; String sampleCollectedOn; String sampleReceivedOn; String setupID; @@ -21,24 +23,26 @@ class LabResult { 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.verifiedOnDateTime}); + 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 json) { description = json['Description']; @@ -52,6 +56,8 @@ class LabResult { 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']; @@ -75,6 +81,8 @@ class LabResult { 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; @@ -85,8 +93,29 @@ class LabResult { 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 = ""; diff --git a/lib/screens/patients/profile/lab_result/LabResultWidget.dart b/lib/screens/patients/profile/lab_result/LabResultWidget.dart index e1b5cfc0..6ca92a4a 100644 --- a/lib/screens/patients/profile/lab_result/LabResultWidget.dart +++ b/lib/screens/patients/profile/lab_result/LabResultWidget.dart @@ -163,6 +163,7 @@ class LabResultWidget extends StatelessWidget { child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ + if(patientLabResultList[index].checkResultStatus() != 0) Container( decoration: BoxDecoration( shape: BoxShape.circle, @@ -172,7 +173,7 @@ class LabResultWidget extends StatelessWidget { // ), ), child: Icon( - Icons.arrow_upward, + patientLabResultList[index].checkResultStatus() == 1 ? Icons.arrow_upward : Icons.arrow_downward, color: Colors.white, size: 16, ),