import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/config/size_config.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:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:intl/intl.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; const PatientCard( {Key? key, this.patientInfo, this.onTap, this.patientType, this.arrivalType, this.isInpatient, this.isMyPatient = false, this.isFromSearch = false}) : super(key: key); @override Widget build(BuildContext context) { return Container( width: SizeConfig.screenWidth! * 0.9, margin: EdgeInsets.all(6), padding: EdgeInsets.only(left: 0, right: 5, bottom: 0, top: 0), decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), color: Colors.white, ), child: CardWithBgWidget( padding: 0, marginLeft: (!isMyPatient && isInpatient!)?0:10, marginSymmetric:isFromSearch ? 10 : 0.0, hasBorder: false, bgColor:(isMyPatient && !isFromSearch)?Colors.green[500]: patientInfo!.patientStatusType == 43 ? Colors.green[500] :isMyPatient? Colors.green[500]:isInpatient!?Colors.white:!isFromSearch?Colors.red[800]:Colors.white, widget: Container( 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: Colors.green, 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? Colors.green: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? Colors.green:Colors.grey , fontWeight: FontWeight.bold, fontFamily: 'Poppins', fontSize: 10, ), ], ): !isFromSearch && 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:Colors.green , 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: Colors.green, fontWeight: FontWeight.bold, fontFamily: 'Poppins', fontSize: 12, ), ], ), Padding( padding: EdgeInsets.only(left: 12.0), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Expanded( child: Row(children: [ Expanded( // width: MediaQuery.of(context).size.width*0.51, child: AppText( (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, ), ]), ), Row( children: [ AppText( patientInfo!.nationalityName != null ? patientInfo!.nationalityName!.trim() : patientInfo!.nationality != null ? patientInfo!.nationality!.trim() : patientInfo!.nationalityId != null ? patientInfo!.nationalityId : "", fontWeight: FontWeight.bold, fontSize: 14, textOverflow: TextOverflow.ellipsis, ), patientInfo!.nationality != null || patientInfo!.nationalityId != null ? ClipRRect( borderRadius: BorderRadius.circular(20.0), child: Image.network( patientInfo!.nationalityFlagURL != null ? patientInfo!.nationalityFlagURL! : '', height: 25, width: 30, errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) { return AppText( 'No Image', fontSize: 10, ); }, )) : SizedBox() ], ) ], )), Row(children: [ Column( mainAxisAlignment: MainAxisAlignment.start, children: [ 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: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( child: RichText( text: new TextSpan( style: new TextStyle( fontSize: 2.0 * SizeConfig.textMultiplier, color: Colors.black), children: [ new TextSpan( text: TranslationBase.of(context)! .fileNumber, style: TextStyle( fontSize: 12, fontFamily: 'Poppins')), new TextSpan( text: patientInfo!.patientId.toString(), style: TextStyle( fontWeight: FontWeight.w700, fontFamily: 'Poppins', fontSize: 13)), ], ), ), ), //if (isInpatient) Container( child: RichText( text: new TextSpan( style: new TextStyle( fontSize: 2.0 * SizeConfig.textMultiplier, color: Colors.black, fontFamily: 'Poppins', ), children: [ new TextSpan( text: TranslationBase.of(context)!.age! + " : ", style: TextStyle(fontSize: 12)), new TextSpan( text: "${AppDateUtils.getAgeByBirthday(patientInfo!.dateofBirth, context)}", style: TextStyle( fontWeight: FontWeight.w700, fontSize: 13)), ], ), ), ), if (isInpatient! ) Container( child: RichText( text: new TextSpan( style: new TextStyle( fontSize: 2.0 * SizeConfig.textMultiplier, color: Colors.black, fontFamily: 'Poppins', ), children: [ new TextSpan( text: patientInfo!.admissionDate == null ? "" : TranslationBase.of(context)! .admissionDate! + " : ", style: TextStyle(fontSize: 12)), new TextSpan( text: patientInfo!.admissionDate == null ? "" : "${AppDateUtils.convertDateFromServerFormat(patientInfo!.admissionDate.toString(), 'yyyy-MM-dd')}", style: TextStyle( fontWeight: FontWeight.w700, fontSize: 13)), ]))), if (patientInfo!.admissionDate != null) Container( child: RichText( text: new TextSpan( style: new TextStyle( fontSize: 2.0 * SizeConfig.textMultiplier, color: Colors.black, fontFamily: 'Poppins', ), children: [ new TextSpan( text: TranslationBase.of(context)!.numOfDays! + " : ", style: TextStyle(fontSize: 12)), new TextSpan( text: "${DateTime.now().difference(AppDateUtils.getDateTimeFromServerFormat(patientInfo!.admissionDate)).inDays + 1}", style: TextStyle( fontWeight: FontWeight.w700, fontSize: 13)), ]))), ])) ]), !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 as void Function()?, )), )); } }