refactor the lab result structure
parent
c96939e6b0
commit
286dbe0a3f
@ -1,163 +0,0 @@
|
||||
import 'package:doctor_app_flutter/config/size_config.dart';
|
||||
import 'package:doctor_app_flutter/core/model/labs/patient_lab_orders.dart';
|
||||
import 'package:doctor_app_flutter/core/viewModel/labs_view_model.dart';
|
||||
import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart';
|
||||
import 'package:doctor_app_flutter/screens/base/base_view.dart';
|
||||
import 'package:doctor_app_flutter/utils/translations_delegate_base_utils.dart';
|
||||
import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart';
|
||||
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
|
||||
import 'package:doctor_app_flutter/widgets/shared/errors/error_message.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class LabResultHistoryPage extends StatelessWidget {
|
||||
final PatientLabOrders patientLabOrder;
|
||||
final String filterName;
|
||||
final PatiantInformtion patient;
|
||||
|
||||
LabResultHistoryPage({this.patientLabOrder, this.filterName, this.patient});
|
||||
|
||||
// TODO Elham* UI changes and add translation
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BaseView<LabsViewModel>(
|
||||
onModelReady: (model) => model.getPatientLabResultHistoryByDescription(
|
||||
patientLabOrder: patientLabOrder,
|
||||
procedureDescription: filterName,
|
||||
patient: patient),
|
||||
builder: (context, model, w) => AppScaffold(
|
||||
isShowAppBar: true,
|
||||
appBarTitle: filterName,
|
||||
baseViewModel: model,
|
||||
body: model.labOrdersResultHistoryList.length > 0
|
||||
? SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
...List.generate(model.labOrdersResultHistoryList.length,
|
||||
(index) {
|
||||
return Container(
|
||||
margin: EdgeInsets.symmetric(
|
||||
vertical: 8.0, horizontal: 16.0),
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
AppText(
|
||||
TranslationBase.of(context).description,
|
||||
fontSize: SizeConfig
|
||||
.getTextMultiplierBasedOnWidth() *
|
||||
3,
|
||||
color: Color(0xFF575757),
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
SizedBox(
|
||||
width: 1,
|
||||
),
|
||||
AppText(
|
||||
model.labOrdersResultHistoryList[index]
|
||||
.description,
|
||||
fontSize: SizeConfig
|
||||
.getTextMultiplierBasedOnWidth() *
|
||||
3.5,
|
||||
color: Color(0xFF2E303A),
|
||||
fontWeight: FontWeight.w700,
|
||||
isCopyable: true,
|
||||
),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
AppText(
|
||||
"Reference Range",
|
||||
fontSize: SizeConfig
|
||||
.getTextMultiplierBasedOnWidth() *
|
||||
3,
|
||||
color: Color(0xFF575757),
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
SizedBox(
|
||||
width: 1,
|
||||
),
|
||||
AppText(
|
||||
model.labOrdersResultHistoryList[index]
|
||||
.referanceRange,
|
||||
fontSize: SizeConfig
|
||||
.getTextMultiplierBasedOnWidth() *
|
||||
3.5,
|
||||
color: Color(0xFF2E303A),
|
||||
fontWeight: FontWeight.w700,
|
||||
isCopyable: true,
|
||||
),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
AppText(
|
||||
"Result Value",
|
||||
fontSize: SizeConfig
|
||||
.getTextMultiplierBasedOnWidth() *
|
||||
3,
|
||||
color: Color(0xFF575757),
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
SizedBox(
|
||||
width: 1,
|
||||
),
|
||||
AppText(
|
||||
model.labOrdersResultHistoryList[index]
|
||||
.resultValue,
|
||||
fontSize: SizeConfig
|
||||
.getTextMultiplierBasedOnWidth() *
|
||||
3.5,
|
||||
color: Color(0xFF2E303A),
|
||||
fontWeight: FontWeight.w700,
|
||||
isCopyable: true,
|
||||
),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
AppText(
|
||||
"Verified On",
|
||||
fontSize: SizeConfig
|
||||
.getTextMultiplierBasedOnWidth() *
|
||||
3,
|
||||
color: Color(0xFF575757),
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
SizedBox(
|
||||
width: 1,
|
||||
),
|
||||
AppText(
|
||||
model.labOrdersResultHistoryList[index]
|
||||
.verifiedOn,
|
||||
fontSize: SizeConfig
|
||||
.getTextMultiplierBasedOnWidth() *
|
||||
3.5,
|
||||
color: Color(0xFF2E303A),
|
||||
fontWeight: FontWeight.w700,
|
||||
isCopyable: true,
|
||||
),
|
||||
],
|
||||
),
|
||||
Divider(
|
||||
color: Colors.grey,
|
||||
height: 0.75,
|
||||
thickness: 0.75,
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}),
|
||||
],
|
||||
),
|
||||
)
|
||||
: ErrorMessage(
|
||||
error: "No data",
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -1,232 +0,0 @@
|
||||
import 'package:doctor_app_flutter/config/size_config.dart';
|
||||
import 'package:doctor_app_flutter/utils/date-utils.dart';
|
||||
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
|
||||
import 'package:fl_chart/fl_chart.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../core/model/labs/LabOrderResult.dart';
|
||||
|
||||
class LineChartCurved extends StatefulWidget {
|
||||
final String title;
|
||||
final List<LabOrderResult> labResult;
|
||||
|
||||
LineChartCurved({this.title, this.labResult});
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => LineChartCurvedState();
|
||||
}
|
||||
|
||||
class LineChartCurvedState extends State<LineChartCurved> {
|
||||
bool isShowingMainData;
|
||||
List<int> xAxixs = List();
|
||||
int indexes = 0;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
getXaxix();
|
||||
isShowingMainData = true;
|
||||
}
|
||||
|
||||
getXaxix() {
|
||||
indexes = widget.labResult.length ~/ 3.5;
|
||||
for (int index = 0; index < widget.labResult.length; index++) {
|
||||
int mIndex = indexes * index;
|
||||
if (mIndex < widget.labResult.length) {
|
||||
xAxixs.add(mIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AspectRatio(
|
||||
aspectRatio: 1.23,
|
||||
child: Container(
|
||||
decoration: const BoxDecoration(
|
||||
borderRadius: BorderRadius.all(Radius.circular(18)),
|
||||
// color: Colors.white,
|
||||
),
|
||||
child: Stack(
|
||||
children: <Widget>[
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: <Widget>[
|
||||
const SizedBox(
|
||||
height: 4,
|
||||
),
|
||||
AppText(
|
||||
widget.title,
|
||||
fontSize: SizeConfig.textMultiplier * 2.1,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontFamily: 'Poppins',
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(right: 16.0, left: 8.0),
|
||||
child: LineChart(
|
||||
sampleData1(),
|
||||
swapAnimationDuration: const Duration(milliseconds: 250),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
LineChartData sampleData1() {
|
||||
return LineChartData(
|
||||
lineTouchData: LineTouchData(
|
||||
touchTooltipData: LineTouchTooltipData(
|
||||
tooltipBgColor: Colors.white,
|
||||
),
|
||||
touchCallback: (LineTouchResponse touchResponse) {},
|
||||
handleBuiltInTouches: true,
|
||||
),
|
||||
gridData: FlGridData(
|
||||
show: true, drawVerticalLine: true, drawHorizontalLine: true),
|
||||
titlesData: FlTitlesData(
|
||||
bottomTitles: SideTitles(
|
||||
showTitles: true,
|
||||
getTextStyles: (context, value) {
|
||||
return TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 10,
|
||||
);
|
||||
},
|
||||
margin: 28,
|
||||
rotateAngle: -65,
|
||||
getTitles: (value) {
|
||||
print(value);
|
||||
DateTime date = AppDateUtils.convertStringToDate(
|
||||
widget.labResult[value.toInt()].verifiedOnDateTime);
|
||||
if (widget.labResult.length < 8) {
|
||||
if (widget.labResult.length > value.toInt()) {
|
||||
return '${date.day}/ ${date.year}';
|
||||
} else
|
||||
return '';
|
||||
} else {
|
||||
if (value.toInt() == 0) return '${date.day}/ ${date.year}';
|
||||
if (value.toInt() == widget.labResult.length - 1)
|
||||
return '${date.day}/ ${date.year}';
|
||||
if (xAxixs.contains(value.toInt())) {
|
||||
return '${date.day}/ ${date.year}';
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
},
|
||||
),
|
||||
leftTitles: SideTitles(
|
||||
showTitles: true,
|
||||
getTextStyles: (context, value) {
|
||||
return TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 10,
|
||||
);
|
||||
},
|
||||
getTitles: (value) {
|
||||
return '${value.toInt()}';
|
||||
},
|
||||
margin: 8,
|
||||
//reservedSize: 30,
|
||||
),
|
||||
),
|
||||
borderData: FlBorderData(
|
||||
show: true,
|
||||
border: const Border(
|
||||
bottom: BorderSide(
|
||||
color: Colors.black,
|
||||
width: 0.5,
|
||||
),
|
||||
left: BorderSide(
|
||||
color: Colors.black,
|
||||
),
|
||||
right: BorderSide(
|
||||
color: Colors.black,
|
||||
),
|
||||
top: BorderSide(
|
||||
color: Colors.transparent,
|
||||
),
|
||||
),
|
||||
),
|
||||
minX: 0,
|
||||
maxX: (widget.labResult.length - 1).toDouble(),
|
||||
maxY: getMaxY() + 2,
|
||||
minY: getMinY(),
|
||||
lineBarsData: getData(),
|
||||
);
|
||||
}
|
||||
|
||||
double getMaxY() {
|
||||
double max = 0;
|
||||
widget.labResult.forEach((element) {
|
||||
try {
|
||||
double resultValueDouble = double.parse(element.resultValue);
|
||||
if (resultValueDouble > max) max = resultValueDouble;
|
||||
} catch (e) {
|
||||
print(e);
|
||||
}
|
||||
});
|
||||
|
||||
return max.roundToDouble();
|
||||
}
|
||||
|
||||
double getMinY() {
|
||||
double min = 0;
|
||||
try {
|
||||
min = double.parse(widget.labResult[0].resultValue);
|
||||
|
||||
widget.labResult.forEach((element) {
|
||||
double resultValueDouble = double.parse(element.resultValue);
|
||||
if (resultValueDouble < min) min = resultValueDouble;
|
||||
});
|
||||
} catch (e) {
|
||||
print(e);
|
||||
}
|
||||
int value = min.toInt();
|
||||
|
||||
return value.toDouble();
|
||||
}
|
||||
|
||||
List<LineChartBarData> getData() {
|
||||
List<FlSpot> spots = List();
|
||||
for (int index = 0; index < widget.labResult.length; index++) {
|
||||
try {
|
||||
var resultValueDouble =
|
||||
double.parse(widget.labResult[index].resultValue);
|
||||
spots.add(FlSpot(index.toDouble(), resultValueDouble));
|
||||
} catch (e) {
|
||||
print(e);
|
||||
spots.add(FlSpot(index.toDouble(), 0.0));
|
||||
}
|
||||
}
|
||||
|
||||
final LineChartBarData lineChartBarData1 = LineChartBarData(
|
||||
spots: spots,
|
||||
isCurved: true,
|
||||
colors: [Colors.red],
|
||||
barWidth: 3,
|
||||
isStrokeCapRound: true,
|
||||
curveSmoothness: 0.12,
|
||||
dotData: FlDotData(
|
||||
show: false,
|
||||
),
|
||||
belowBarData: BarAreaData(
|
||||
show: false,
|
||||
),
|
||||
);
|
||||
|
||||
return [
|
||||
lineChartBarData1,
|
||||
];
|
||||
}
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
import 'package:doctor_app_flutter/config/size_config.dart';
|
||||
import 'package:doctor_app_flutter/core/model/labs/LabOrderResult.dart';
|
||||
import 'package:doctor_app_flutter/utils/translations_delegate_base_utils.dart';
|
||||
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'Lab_Result_details_wideget.dart';
|
||||
import 'LineChartCurved.dart';
|
||||
|
||||
class LabResultChartAndDetails extends StatelessWidget {
|
||||
LabResultChartAndDetails({
|
||||
Key key,
|
||||
@required this.labResult,
|
||||
@required this.name,
|
||||
}) : super(key: key);
|
||||
|
||||
final List<LabOrderResult> labResult;
|
||||
final String name;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
margin: EdgeInsets.symmetric(horizontal: 8),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white, borderRadius: BorderRadius.circular(12)),
|
||||
child: LineChartCurved(
|
||||
title: name,
|
||||
labResult: labResult,
|
||||
),
|
||||
),
|
||||
Container(
|
||||
margin: EdgeInsets.symmetric(horizontal: 8, vertical: 16),
|
||||
padding: EdgeInsets.only(top: 16, right: 18.0, left: 16.0),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white, borderRadius: BorderRadius.circular(12)),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
AppText(
|
||||
TranslationBase.of(context).graphDetails,
|
||||
fontSize: SizeConfig.textMultiplier * 2.1,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontFamily: 'Poppins',
|
||||
),
|
||||
SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
LabResultDetailsWidget(
|
||||
labResult: labResult.reversed.toList(),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -1,86 +0,0 @@
|
||||
import 'package:doctor_app_flutter/config/size_config.dart';
|
||||
import 'package:doctor_app_flutter/core/viewModel/patient_view_model.dart';
|
||||
import 'package:doctor_app_flutter/core/model/patient/lab_orders/lab_orders_res_model.dart';
|
||||
import 'package:doctor_app_flutter/screens/base/base_view.dart';
|
||||
import 'package:doctor_app_flutter/utils/translations_delegate_base_utils.dart';
|
||||
import 'package:doctor_app_flutter/widgets/doctor/lab_result_widget.dart';
|
||||
import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart';
|
||||
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
|
||||
import 'package:doctor_app_flutter/widgets/shared/card_with_bgNew_widget.dart';
|
||||
import 'package:doctor_app_flutter/widgets/shared/errors/dr_app_embedded_error.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class LabResult extends StatefulWidget {
|
||||
final LabOrdersResModel labOrders;
|
||||
|
||||
LabResult({Key key, this.labOrders});
|
||||
|
||||
@override
|
||||
_LabResultState createState() => _LabResultState();
|
||||
}
|
||||
|
||||
class _LabResultState extends State<LabResult> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BaseView<PatientViewModel>(
|
||||
onModelReady: (model) => model.getLabResult(widget.labOrders),
|
||||
builder: (_, model, w) => AppScaffold(
|
||||
baseViewModel: model,
|
||||
appBarTitle: TranslationBase.of(context).labOrders,
|
||||
body: model.labResultList.length == 0
|
||||
? DrAppEmbeddedError(
|
||||
error: TranslationBase.of(context).errorNoLabOrders)
|
||||
: Container(
|
||||
margin: EdgeInsets.fromLTRB(SizeConfig.realScreenWidth * 0.05,
|
||||
0, SizeConfig.realScreenWidth * 0.05, 0),
|
||||
child: ListView(
|
||||
children: <Widget>[
|
||||
CardWithBgWidgetNew(
|
||||
widget: Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
AppText(
|
||||
TranslationBase.of(context).orderNo,
|
||||
fontSize: 2 * SizeConfig.textMultiplier,
|
||||
color: Colors.grey[800],
|
||||
),
|
||||
AppText(
|
||||
' ${widget.labOrders.orderNo}',
|
||||
fontSize: 2 * SizeConfig.textMultiplier,
|
||||
color: Colors.grey[800],
|
||||
),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
AppText(
|
||||
TranslationBase.of(context).invoiceNo,
|
||||
fontSize: 2 * SizeConfig.textMultiplier,
|
||||
color: Colors.grey[800],
|
||||
),
|
||||
AppText(
|
||||
' ${widget.labOrders.invoiceNo}',
|
||||
fontSize: 2 * SizeConfig.textMultiplier,
|
||||
color: Colors.grey[800],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
CardWithBgWidgetNew(
|
||||
widget: LabResultWidget(
|
||||
labResult: model.labResultList,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue