diff --git a/lib/config/config.dart b/lib/config/config.dart index 3f68aa34..1345cc67 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -32,7 +32,7 @@ const GET_Patient_LAB_ORDERS = 'Services/Patients.svc/REST/GetPatientLabOrders'; const GET_Patient_LAB_SPECIAL_RESULT = 'Services/Patients.svc/REST/GetPatientLabSpecialResults'; const GET_Patient_LAB_RESULT = - '/Services/Patients.svc/REST/GetPatientLabResults'; + 'Services/Patients.svc/REST/GetPatientLabResults'; /// const GET_PATIENT_ORDERS = 'Services/Patients.svc/REST/GetPatientRadOrders'; diff --git a/lib/core/model/labs/lab_result.dart b/lib/core/model/labs/lab_result.dart index 23b3363d..c9acd809 100644 --- a/lib/core/model/labs/lab_result.dart +++ b/lib/core/model/labs/lab_result.dart @@ -86,3 +86,14 @@ class LabResult { return data; } } + + +class LabResultList { + String filterName = ""; + List patientLabResultList = List(); + + LabResultList( + {this.filterName, LabResult lab}) { + patientLabResultList.add(lab); + } +} diff --git a/lib/core/service/medical/labs_service.dart b/lib/core/service/medical/labs_service.dart index 367ca4b9..b9b9a16c 100644 --- a/lib/core/service/medical/labs_service.dart +++ b/lib/core/service/medical/labs_service.dart @@ -65,7 +65,6 @@ class LabsService extends BaseService { body['SetupID'] = patientLabOrder.setupID; body['ProjectID'] = patientLabOrder.projectID; body['ClinicID'] = patientLabOrder.clinicID; - //TODO Check the res await baseAppClient.post(GET_Patient_LAB_RESULT, onSuccess: (dynamic response, int statusCode) { patientLabSpecialResult.clear(); diff --git a/lib/core/viewModels/medical/labs_view_model.dart b/lib/core/viewModels/medical/labs_view_model.dart index 8cbf0efc..582ee745 100644 --- a/lib/core/viewModels/medical/labs_view_model.dart +++ b/lib/core/viewModels/medical/labs_view_model.dart @@ -82,6 +82,8 @@ class LabsViewModel extends BaseViewModel { List get labResultList => _labsService.labResultList; + List labResultLists = List(); + getLaboratoryResult( {String projectID, int clinicID, @@ -110,6 +112,24 @@ class LabsViewModel extends BaseViewModel { error = _labsService.error; setState(ViewState.Error); } else { + _labsService.labResultList.forEach((element) { + List patientLabOrdersClinic = + labResultLists + .where((elementClinic) => + elementClinic.filterName == element.testCode) + .toList(); + + if (patientLabOrdersClinic.length != 0) { + labResultLists[labResultLists.indexOf(patientLabOrdersClinic[0])] + .patientLabResultList + .add(element); + } else { + labResultLists.add(LabResultList( + filterName: element.testCode, + lab: element)); + } + + }); setState(ViewState.Idle); } } diff --git a/lib/widgets/data_display/medical/LabResultWidget.dart b/lib/widgets/data_display/medical/LabResultWidget.dart new file mode 100644 index 00000000..225b4076 --- /dev/null +++ b/lib/widgets/data_display/medical/LabResultWidget.dart @@ -0,0 +1,160 @@ +import 'package:diplomaticquarterapp/core/model/labs/lab_result.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +import '../text.dart'; + +class LabResultWidget extends StatelessWidget { + + final String filterName ; + final List patientLabResultList; + + LabResultWidget({Key key, this.filterName, this.patientLabResultList}) : super(key: key); + ProjectViewModel projectViewModel; + @override + Widget build(BuildContext context) { + projectViewModel = Provider.of(context); + + return Container( + width: double.infinity, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Texts(filterName), + InkWell( + onTap: () { + //TODO model.getPatientLabResult(patientLabOrder: widget.patientLabOrder); + }, + child: Texts( + 'Flow Chart', + decoration: TextDecoration.underline, + color: Colors.blue, + ), + ), + ], + ), + Table( + border: TableBorder.symmetric( + inside: BorderSide( + width: 2.0, color: Colors.grey[300]), + ), + children: fullData(patientLabResultList), + ), + ], + ), + ); + } + List fullData(List labResultList) { + List tableRow = []; + tableRow.add( + TableRow( + children: [ + Container( + child: Container( + decoration: BoxDecoration( + color: Color(0xff515B5D), + borderRadius: BorderRadius.only( + topLeft: projectViewModel.isArabic + ? Radius.circular(0.0) + : Radius.circular(10.0), + topRight: projectViewModel.isArabic + ? Radius.circular(10.0) + : Radius.circular(0.0), + ), + ), + child: Center( + child: Texts( + 'Description', + color: Colors.white, + ), + ), + height: 60, + ), + ), + Container( + child: Container( + decoration: BoxDecoration( + color: Color(0xff515B5D), + ), + child: Center( + child: Texts('Value', color: Colors.white), + ), + height: 60), + ), + Container( + child: Container( + decoration: BoxDecoration( + color: Color(0xff515B5D), + borderRadius: BorderRadius.only( + topLeft: projectViewModel.isArabic + ? Radius.circular(10.0) + : Radius.circular(0.0), + topRight: projectViewModel.isArabic + ? Radius.circular(0.0) + : Radius.circular(10.0), + ), + ), + child: Center( + child: Texts('Range', color: Colors.white), + ), + height: 60), + ), + ], + ), + ); + labResultList.forEach((lab) { + tableRow.add( + TableRow( + children: [ + Container( + child: Container( + padding: EdgeInsets.all(10), + color: Colors.white, + child: Center( + child: Texts( + lab.description, + textAlign: TextAlign.center, + ), + ), + ), + ), + Container( + child: Container( + padding: EdgeInsets.all(10), + color: Colors.white, + child: Center( + child: Texts( + lab.resultValue, + textAlign: TextAlign.center, + ), + ), + ), + ), + Container( + child: Container( + padding: EdgeInsets.all(10), + color: Colors.white, + child: Center( + child: Texts( + lab.referanceRange, + textAlign: TextAlign.center, + ), + ), + ), + ), + ], + ), + ); + }); + return tableRow; + } + +} + + diff --git a/lib/widgets/data_display/medical/laboratory_result_widget.dart b/lib/widgets/data_display/medical/laboratory_result_widget.dart index 8662b9b0..f763def1 100644 --- a/lib/widgets/data_display/medical/laboratory_result_widget.dart +++ b/lib/widgets/data_display/medical/laboratory_result_widget.dart @@ -11,6 +11,7 @@ import 'package:hexcolor/hexcolor.dart'; import 'package:provider/provider.dart'; import '../text.dart'; +import 'LabResultWidget.dart'; class LaboratoryResultWidget extends StatefulWidget { final GestureTapCallback onTap; @@ -155,9 +156,7 @@ class _LaboratoryResultWidgetState extends State { child: Container( width: double.infinity, child: Html( - // data:"
BCG
HEPATITIS B
"//model.creteVaccinationTableModelList[index].vaccinesDescription - data:widget.details ?? 'No Data', - + data: widget.details ?? 'No Data', )), ), SizedBox( @@ -227,32 +226,16 @@ class _LaboratoryResultWidgetState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Texts('U/A'), - InkWell( - onTap: () { - model.getPatientLabResult( - patientLabOrder: - widget.patientLabOrder); - }, - child: Texts( - 'Flow Chart', - decoration: TextDecoration.underline, - color: Colors.blue, - ), - ), - ], - ), - Table( - border: TableBorder.symmetric( - inside: BorderSide( - width: 2.0, color: Colors.grey[300]), + ...List.generate( + model.labResultLists.length, + (index) => LabResultWidget( + filterName: model + .labResultLists[index].filterName, + patientLabResultList: model + .labResultLists[index] + .patientLabResultList, ), - children: fullData(model.labResultList), - ), + ) ], ), ), @@ -269,108 +252,5 @@ class _LaboratoryResultWidgetState extends State { ); } - List fullData(List labResultList) { - List tableRow = []; - tableRow.add( - TableRow( - children: [ - Container( - child: Container( - decoration: BoxDecoration( - color: HexColor('#515B5D'), - borderRadius: BorderRadius.only( - topLeft: projectViewModel.isArabic - ? Radius.circular(0.0) - : Radius.circular(10.0), - topRight: projectViewModel.isArabic - ? Radius.circular(10.0) - : Radius.circular(0.0), - ), - ), - child: Center( - child: Texts( - 'Description', - color: Colors.white, - ), - ), - height: 60, - ), - ), - Container( - child: Container( - decoration: BoxDecoration( - color: HexColor('#515B5D'), - ), - child: Center( - child: Texts('Value', color: Colors.white), - ), - height: 60), - ), - Container( - child: Container( - decoration: BoxDecoration( - color: HexColor('#515B5D'), - borderRadius: BorderRadius.only( - topLeft: projectViewModel.isArabic - ? Radius.circular(10.0) - : Radius.circular(0.0), - topRight: projectViewModel.isArabic - ? Radius.circular(0.0) - : Radius.circular(10.0), - ), - ), - child: Center( - child: Texts('Range', color: Colors.white), - ), - height: 60), - ), - ], - ), - ); - labResultList.forEach((lab) { - tableRow.add( - TableRow( - children: [ - Container( - child: Container( - padding: EdgeInsets.all(10), - color: Colors.white, - child: Center( - child: Texts( - lab.description, - textAlign: TextAlign.center, - ), - ), - ), - ), - Container( - child: Container( - padding: EdgeInsets.all(10), - color: Colors.white, - child: Center( - child: Texts( - lab.resultValue, - textAlign: TextAlign.center, - ), - ), - ), - ), - Container( - child: Container( - padding: EdgeInsets.all(10), - color: Colors.white, - child: Center( - child: Texts( - lab.referanceRange, - textAlign: TextAlign.center, - ), - ), - ), - ), - ], - ), - ); - }); - return tableRow; - } + }