You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
doctor_app_flutter/lib/widgets/patients/patient_card/PatientCard.dart

511 lines
26 KiB
Dart

import 'package:doctor_app_flutter/config/config.dart';
import 'package:doctor_app_flutter/config/size_config.dart';
import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart';
import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart';
import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart';
import 'package:doctor_app_flutter/util/date-utils.dart';
import 'package:doctor_app_flutter/util/helpers.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/card_with_bg_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/user-guid/CusomRow.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:hexcolor/hexcolor.dart';
import 'package:provider/provider.dart';
import '../../../util/extenstions.dart';
import 'ShowTimer.dart';
class PatientCard extends StatelessWidget {
final PatiantInformtion patientInfo;
final Function onTap;
final String patientType;
final String arrivalType;
final bool isInpatient;
final bool isMyPatient;
final bool isFromSearch;
final bool isFromLiveCare;
PatientCard(
{Key key,
this.patientInfo,
this.onTap,
this.patientType,
this.arrivalType,
this.isInpatient,
this.isMyPatient = false,
this.isFromSearch = false,
this.isFromLiveCare = false})
: super(key: key);
@override
Widget build(BuildContext context) {
ProjectViewModel projectViewModel = Provider.of(context);
String nationalityName = patientInfo.nationalityName != null
? patientInfo.nationalityName.trim()
: patientInfo.nationality != null
? patientInfo.nationality.trim()
: patientInfo.nationalityId !=
null
? patientInfo.nationalityId
: "";
return Container(
width: SizeConfig.screenWidth * 0.9,
margin: EdgeInsets.all(6),
padding: EdgeInsets.only(left: projectViewModel.isArabic?5:0, right: projectViewModel.isArabic?0:5, bottom: 0, top: 0),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Colors.white,
shape: BoxShape.rectangle,
boxShadow: [
BoxShadow(
color: Color(0x0000000D),
spreadRadius: 10,
blurRadius: 2.7,
offset: Offset(0, -3 ), // changes position of shadow
),
],
),
child: CardWithBgWidget(
padding: 0,
marginLeft: (!isMyPatient && isInpatient) ? 0 : 10,
marginSymmetric: isFromSearch ? 10 : 0.0,
hasBorder: false,
bgColor: isFromLiveCare
? Colors.white
: (isMyPatient && !isFromSearch)
? AppGlobal.appGreenColor
: patientInfo.patientStatusType == 43
? AppGlobal.appGreenColor
: isMyPatient
? AppGlobal.appGreenColor
: isInpatient
? Colors.white
: !isFromSearch
? Colors.red[800]
: Colors.white,
widget: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Colors.white,
),
// padding: EdgeInsets.only(left: 10, right: 0, bottom: 0),
child: InkWell(
child: Column(
children: [
SizedBox(
height: 10,
),
!(isInpatient && !isFromSearch)
? Padding(
padding: EdgeInsets.only(left: 12.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
patientInfo.patientStatusType == 43
? Row(
children: [
AppText(
TranslationBase.of(context)
.arrivedP,
color: AppGlobal.appGreenColor,
fontWeight: FontWeight.bold,
fontFamily: 'Poppins',
fontSize: 10,
),
SizedBox(
width: 8,
),
SizedBox(
height: 12,
width: 1.5,
child: Container(
color: Colors.grey,
),
),
SizedBox(
width: 8,
),
AppText(
patientInfo.status == 2
? 'Confirmed'
: 'Booked',
color: patientInfo.status == 2
? AppGlobal.appGreenColor
: Colors.grey,
fontWeight: FontWeight.bold,
fontFamily: 'Poppins',
fontSize: 10,
),
],
)
: patientInfo.patientStatusType == 42
? Row(
children: [
AppText(
TranslationBase.of(context)
.notArrived,
color: Colors.red[800],
fontWeight: FontWeight.bold,
fontFamily: 'Poppins',
fontSize: 10,
),
SizedBox(
width: 8,
),
SizedBox(
height: 12,
width: 1.5,
child: Container(
color: Colors.grey,
),
),
SizedBox(
width: 8,
),
AppText(
patientInfo.status == 2
? 'Confirmed'
: 'Booked',
color: patientInfo.status == 2
? AppGlobal.appGreenColor
: Colors.grey,
fontWeight: FontWeight.bold,
fontFamily: 'Poppins',
fontSize: 10,
),
],
)
: !isFromSearch &&
!isFromLiveCare &&
patientInfo.patientStatusType ==
null
? Row(
children: [
AppText(
TranslationBase.of(context)
.notArrived,
color: Colors.red[800],
fontWeight: FontWeight.bold,
fontFamily: 'Poppins',
fontSize: 12,
),
SizedBox(
width: 8,
),
SizedBox(
height: 12,
width: 1.5,
child: Container(
color: Colors.grey,
),
),
SizedBox(
width: 8,
),
AppText(
patientInfo.status == 2
? 'Booked'
: 'Confirmed',
color:
patientInfo.status == 2
? Colors.grey
: AppGlobal.appGreenColor,
fontWeight: FontWeight.bold,
fontFamily: 'Poppins',
fontSize: 12,
)
],
)
: SizedBox(),
this.arrivalType == '1'
? AppText(
patientInfo.startTime != null
? patientInfo.startTime
: patientInfo.startTimes,
fontFamily: 'Poppins',
fontWeight: FontWeight.w400,
)
: patientInfo.arrivedOn != null
? AppText(
AppDateUtils.getDayMonthYearDate(
AppDateUtils
.convertStringToDate(
patientInfo.arrivedOn,
)) +
" " +
"${AppDateUtils.getStartTime(patientInfo.startTime)}",
fontFamily: 'Poppins',
fontWeight: FontWeight.w400,
fontSize: 15,
)
: (patientInfo.appointmentDate !=
null &&
patientInfo
.appointmentDate.isNotEmpty)
? AppText(
"${AppDateUtils.getDayMonthYearDate(AppDateUtils.convertStringToDate(
patientInfo.appointmentDate,
))} ${AppDateUtils.getStartTime(patientInfo.startTime)}",
fontFamily: 'Poppins',
fontWeight: FontWeight.w400,
fontSize: 15,
)
: SizedBox()
],
))
: SizedBox(),
if (isInpatient && isMyPatient && !isFromSearch)
Row(
children: [
SizedBox(
width: 12,
),
AppText(
'My Patient',
color: AppGlobal.appGreenColor,
fontWeight: FontWeight.bold,
fontFamily: 'Poppins',
fontSize: 12,
),
],
),
Padding(
padding: EdgeInsets.only(left: 12.0),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
flex: 2,
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment:
MainAxisAlignment.start,
children: [
Expanded(
// width: MediaQuery.of(context).size.width*0.51,
child: AppText(
isFromLiveCare
? Helpers.capitalize(
patientInfo.fullName)
: (Helpers.capitalize(
patientInfo.firstName) +
" " +
Helpers.capitalize(
patientInfo.lastName)),
fontSize: 16,
color: Color(0xff2e303a),
fontWeight: FontWeight.w700,
fontFamily: 'Poppins',
textOverflow: TextOverflow.ellipsis,
),
),
if (patientInfo.gender == 1)
Icon(
DoctorApp.male_2,
color: Colors.blue,
)
else
Icon(
DoctorApp.female_1,
color: Colors.pink,
),
if (isFromLiveCare)
ShowTimer(
patientInfo: patientInfo,
),
]),
),
Expanded(
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Container(
alignment: Alignment.centerRight,
child: AppText(
nationalityName.truncate(14),
fontWeight: FontWeight.bold,
fontSize: 14,
textOverflow: TextOverflow.ellipsis,
),
),
),
patientInfo.nationality != null ||
patientInfo.nationalityId != null
? ClipRRect(
borderRadius:
BorderRadius.circular(20.0),
child: CachedNetworkImage(
imageUrl: patientInfo
.nationalityFlagURL !=
null
? patientInfo.nationalityFlagURL
: '',
height: 25,
width: 30,
errorWidget:
(context, url, error) =>
AppText(
'No Image',
fontSize: 10,
),
))
: SizedBox()
],
),
)
],
)),
Row(children: <Widget>[
Column(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Padding(
padding: EdgeInsets.only(left: 12.0),
child: Container(
width: 60,
height: 60,
child: Image.asset(
patientInfo.gender == 1
? 'assets/images/male_avatar.png'
: 'assets/images/female_avatar.png',
fit: BoxFit.cover,
),
),
),
],
),
SizedBox(
width: 10,
),
Expanded(
child: Row(
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
CustomRow(
label:
TranslationBase.of(context).fileNumber,
value: patientInfo.patientId.toString(),
),
CustomRow(
label:
TranslationBase.of(context).age + " : ",
value:
"${AppDateUtils.getAgeByBirthday(patientInfo.dateofBirth, context, isServerFormat: !isFromLiveCare)}",
),
if (isInpatient)
CustomRow(
label: patientInfo.admissionDate == null
? ""
: TranslationBase.of(context)
.admissionDate +
" : ",
value: patientInfo.admissionDate == null
? ""
: "${AppDateUtils.convertDateFromServerFormat(patientInfo.admissionDate.toString(), 'yyyy-MM-dd')}",
),
if (patientInfo.admissionDate != null)
CustomRow(
label: TranslationBase.of(context)
.numOfDays +
" : ",
value:
"${DateTime.now().difference(AppDateUtils.getDateTimeFromServerFormat(patientInfo.admissionDate)).inDays + 1}",
),
if (patientInfo.admissionDate != null)
CustomRow(
label: TranslationBase.of(context)
.clinicName +
" : ",
value: "${patientInfo.clinicDescription}",
),
if (patientInfo.admissionDate != null)
CustomRow(
label:
TranslationBase.of(context).roomNo +
" : ",
value: "${patientInfo.roomId}",
),
if (isFromLiveCare)
Column(
children: [
CustomRow(
label: TranslationBase.of(context)
.clinic +
" : ",
value: patientInfo.clinicName,
),
],
),
]),
),
Icon(
Icons.arrow_forward,
size: 24,
),
],
))
]),
isFromLiveCare
? Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Container(
padding: EdgeInsets.all(4),
child: Image.asset(
'assets/images/livecare.png',
height: 25,
width: 35,
color: Colors.grey.shade700,
)),
],
)
: !isInpatient && !isFromSearch
? Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Container(
padding: EdgeInsets.all(4),
child: Image.asset(
patientInfo.appointmentType ==
'Regular' &&
patientInfo.visitTypeId == 100
? 'assets/images/livecare.png'
: patientInfo.appointmentType ==
'Walkin'
? 'assets/images/walkin.png'
: 'assets/images/booked.png',
height: 25,
width: 35,
)),
])
: (isInpatient == true)
? Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Container(
padding: EdgeInsets.all(4),
child: Image.asset(
'assets/images/inpatient.png',
height: 25,
width: 35,
)),
])
: SizedBox()
],
),
onTap: onTap,
)),
));
}
}