lab_result #2

Merged
Haroon6138 merged 3 commits from lab_result into update-to-3.32-sdk 6 months ago

@ -97,7 +97,7 @@ class LabsViewModel extends BaseViewModel {
} }
} }
getPatientLabResult({required PatientLabOrders patientLabOrder, required bool isVidaPlus}) async { getPatientLabResult({required PatientLabOrders patientLabOrder, required bool isVidaPlus, bool isTablet = false}) async {
setState(ViewState.Busy); setState(ViewState.Busy);
await _labsService.getPatientLabResult(patientLabOrder: patientLabOrder, isVidaPlus: isVidaPlus); await _labsService.getPatientLabResult(patientLabOrder: patientLabOrder, isVidaPlus: isVidaPlus);
if (_labsService.hasError) { if (_labsService.hasError) {
@ -107,7 +107,7 @@ class LabsViewModel extends BaseViewModel {
_labsService.labResultList.forEach((element) { _labsService.labResultList.forEach((element) {
List<LabResultList> patientLabOrdersClinic = labResultLists.where((elementClinic) => elementClinic.filterName == element.testCode).toList(); List<LabResultList> patientLabOrdersClinic = labResultLists.where((elementClinic) => elementClinic.filterName == element.testCode).toList();
element.percentage = element.percentage =
getPercentage(element.calculatedResultFlag ?? ResultFlag.N); getPercentage(element.calculatedResultFlag?? ResultFlag.N, isTablet);
if (patientLabOrdersClinic.length != 0) { if (patientLabOrdersClinic.length != 0) {
labResultLists[labResultLists.indexOf(patientLabOrdersClinic[0])].patientLabResultList!.add(element); labResultLists[labResultLists.indexOf(patientLabOrdersClinic[0])].patientLabResultList!.add(element);
} else { } else {
@ -121,29 +121,39 @@ class LabsViewModel extends BaseViewModel {
} }
} }
double getPercentage(ResultFlag flag) { recalculatePercentage(isTablet){
for(int i = 0;i<labResultLists.length;i++){
for (int j = 0; j<(labResultLists[i].patientLabResultList?.length??0 );j++){
labResultLists[i].patientLabResultList![j].percentage = getPercentage(labResultLists[i].patientLabResultList![j].calculatedResultFlag?? ResultFlag.N, isTablet);
}
}
}
double getPercentage(ResultFlag flag, bool isTablet) {
double percentage = 0.0; double percentage = 0.0;
final division = 0.2; var division = (1/15);
print("its a tablet $isTablet");
switch (flag) { switch (flag) {
case ResultFlag.N: //4 case ResultFlag.N:
percentage = division * 1.75; percentage = division * (isTablet?7.25:6.85);
break; break;
case ResultFlag.H: //5 case ResultFlag.H:
percentage = division * 2.8; percentage = division * (isTablet?11:10.9);
break; break;
case ResultFlag.L: //3 case ResultFlag.L:
percentage = division * .7; percentage = division * (isTablet?3.5:2.95);
break; break;
case ResultFlag.CL: //2 case ResultFlag.CL:
case ResultFlag.LCL: // case ResultFlag.LCL:
percentage = division * .07; percentage = division * (isTablet?0.7:.04);
break; break;
case ResultFlag.HCH: //7 case ResultFlag.HCH:
case ResultFlag.CH: //6 case ResultFlag.CH:
percentage = division * 3.4; percentage = division * (isTablet?13.5:13.3);
break; break;
case ResultFlag.IRR: case ResultFlag.IRR:
percentage = 0; percentage = 0;

@ -52,17 +52,34 @@ class _VitalSignDetailsWidgetState extends State<LabResultDetailsWidget> {
children: [ children: [
Utils.tableColumnValue(DateUtil.getDayMonthYearDateFormatted(DateUtil.convertStringToDate(labOrderResultList![i].verifiedOnDateTime!)), isLast: i == (labOrderResultList.length - 1), mProjectViewModel: projectViewModel), Utils.tableColumnValue(DateUtil.getDayMonthYearDateFormatted(DateUtil.convertStringToDate(labOrderResultList![i].verifiedOnDateTime!)), isLast: i == (labOrderResultList.length - 1), mProjectViewModel: projectViewModel),
Utils.tableColumnValue(labOrderResultList[i].resultValue!, isLast: i == (labOrderResultList.length - 1), mProjectViewModel: projectViewModel), Utils.tableColumnValue(labOrderResultList[i].resultValue!, isLast: i == (labOrderResultList.length - 1), mProjectViewModel: projectViewModel),
changeResult(labOrderResultList[i].changeResult ?? '8%') changeResult(labOrderResultList[i].changeResult ?? '', labOrderResultList[i].calculatedResultFlag??'IRR')
], ],
), ),
); );
return tableRow; return tableRow;
} }
Widget changeResult(String changeValue) => Padding(
Color getColorForResultType(String type) {
switch (type) {
case "LCL":
case "HCH":
case "CH":
case "CL":
return Color(0xFFDE7676);
case "L":
case "H":
return Color(0xFFEAB157);
case "N":
return Color(0xFF09AA28);
default:
return Color(0xFF09AA28);
}
}
Widget changeResult(String changeValue, String type) => Padding(
padding: const EdgeInsets.all(4.0), padding: const EdgeInsets.all(4.0),
child: Material( child: Material(
color: (changeValue.contains("-")) ? Colors.black : Color(0xffcecbcb), color: getColorForResultType(type),
shape: shape:
RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)), RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
child: Padding( child: Padding(
@ -71,9 +88,8 @@ class _VitalSignDetailsWidgetState extends State<LabResultDetailsWidget> {
child: Text( child: Text(
changeValue, changeValue,
style: TextStyle( style: TextStyle(
color: (changeValue.contains("-")) color: Colors.white
? Colors.white ,
: Colors.black,
fontSize: 11, fontSize: 11,
letterSpacing: -.64, letterSpacing: -.64,
fontWeight: FontWeight.w400), fontWeight: FontWeight.w400),

@ -31,19 +31,46 @@ class _LaboratoryResultWidgetState extends State<LaboratoryResultWidget> {
bool _isShowMore = true; bool _isShowMore = true;
late ProjectViewModel projectViewModel; late ProjectViewModel projectViewModel;
late String? labSpecialResult; late String? labSpecialResult;
bool isTabletScreen = false;
LabsViewModel? model;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
labSpecialResult = widget.details ?? TranslationBase.of(context).noDataAvailable; labSpecialResult = widget.details ?? TranslationBase.of(context).noDataAvailable;
} }
@override
void didChangeDependencies() {
super.didChangeDependencies();
print("did change dependency is called");
var oldStateTablateScreenState = isTabletScreen;
isTabletScreen = isTablet(context);
if(isTabletScreen != oldStateTablateScreenState);
{
print("the screen width is changed");
model?.recalculatePercentage(isTabletScreen);
}
}
bool isTablet(BuildContext context) {
final size = MediaQuery.of(context).size;
final shortestSide = size.shortestSide;
return shortestSide >= 550;
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
isTabletScreen = isTablet(context);
projectViewModel = Provider.of(context); projectViewModel = Provider.of(context);
return BaseView<LabsViewModel>( return BaseView<LabsViewModel>(
onModelReady: (model) => onModelReady: (model) {
model.getPatientLabResult(isVidaPlus: Utils.isVidaPlusProject(projectViewModel, int.parse(widget.patientLabOrder!.projectID!)), patientLabOrder: widget.patientLabOrder!), this.model = model;
model.getPatientLabResult(isVidaPlus: Utils.isVidaPlusProject(projectViewModel, int.parse(widget.patientLabOrder!.projectID!)), patientLabOrder: widget.patientLabOrder!, isTablet: isTabletScreen);
},
builder: (_, model, w) => NetworkBaseView( builder: (_, model, w) => NetworkBaseView(
baseViewModel: model, baseViewModel: model,
child: Column( child: Column(

@ -19,7 +19,7 @@ class LabItem extends StatefulWidget {
} }
class _LabItemState extends State<LabItem> { class _LabItemState extends State<LabItem> {
bool _isShowMoreGeneral = false; bool _isShowMoreGeneral = true;
bool showBottomSheet = false; bool showBottomSheet = false;
@override @override

@ -59,7 +59,13 @@ class CustomResultProgressBar extends StatelessWidget {
return LayoutBuilder(builder: (context, constraints) { return LayoutBuilder(builder: (context, constraints) {
final double totalWidth = constraints.maxWidth; final double totalWidth = constraints.maxWidth;
final double spacing = 2; final double spacing = 2;
final double tooltipPosition = (totalWidth * (percentage / 100)).clamp(0, totalWidth - 50); final int spacingCount = 4; // between 5 bars
final double flexWidth = totalWidth - 50;
final double tooltipPosition =
(flexWidth * (percentage / 100)).clamp(0, flexWidth);
return Stack( return Stack(
children: [ children: [
Row( Row(
@ -117,7 +123,7 @@ class CustomResultProgressBar extends StatelessWidget {
TextCloud( TextCloud(
text: "${value}", text: "${value}",
color: getColorForResultType(type), color: getColorForResultType(type),
width: 100, width: 75,
height: 20, height: 20,
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
axisDirection: AxisDirection.up, axisDirection: AxisDirection.up,

Loading…
Cancel
Save