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/screens/patients/profile/referral/referred-patient-screen.dart

210 lines
9.2 KiB
Dart

import 'package:doctor_app_flutter/core/enum/PatientType.dart';
import 'package:doctor_app_flutter/core/viewModel/patient-referral-viewmodel.dart';
import 'package:doctor_app_flutter/screens/base/base_view.dart';
import 'package:doctor_app_flutter/screens/patients/profile/referral/referred_patient_detail_in-paint.dart';
import 'package:doctor_app_flutter/util/date-utils.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/patients/patient-referral-item-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/loader/gif_loader_dialog_utils.dart';
import 'package:doctor_app_flutter/widgets/transitions/fade_page.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
class ReferredPatientScreen extends StatefulWidget {
@override
_ReferredPatientScreenState createState() => _ReferredPatientScreenState();
}
class _ReferredPatientScreenState extends State<ReferredPatientScreen> {
PatientType patientType = PatientType.IN_PATIENT;
@override
Widget build(BuildContext context) {
return BaseView<PatientReferralViewModel>(
onModelReady: (model) => model.getMyReferredPatient(),
builder: (_, model, w) => AppScaffold(
baseViewModel: model,
isShowAppBar: false,
appBarTitle: TranslationBase.of(context).referredPatient,
body: Column(
children: [
Container(
margin: EdgeInsets.only(top: 70),
child: PatientTypeRadioWidget(
(patientType) async {
setState(() {
this.patientType = patientType;
});
GifLoaderDialogUtils.showMyDialog(context);
if (patientType == PatientType.IN_PATIENT) {
await model.getMyReferredPatient(isFirstTime: false);
} else {
await model.getMyReferredOutPatient(isFirstTime: false);
}
GifLoaderDialogUtils.hideDialog(context);
},
),
),
model.listMyReferredPatientModel == null ||
model.listMyReferredPatientModel.length == 0
? Center(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
height: 100,
),
Image.asset('assets/images/no-data.png'),
Padding(
padding: const EdgeInsets.all(8.0),
child: AppText(
TranslationBase.of(context).referralEmptyMsg,
color: Theme.of(context).errorColor,
),
)
],
),
)
: Expanded(
child: SingleChildScrollView(
// DoctorApplication.svc/REST/GtMyReferredPatient
child: Container(
child: Column(
children: [
ListView.builder(
itemCount:
model.listMyReferredPatientModel.length,
scrollDirection: Axis.vertical,
physics: ScrollPhysics(),
shrinkWrap: true,
itemBuilder: (context, index) {
return InkWell(
onTap: () {
Navigator.push(
context,
FadePage(
page: ReferredPatientDetailScreen(
model.getReferredPatientItem(index),
this.patientType),
),
);
},
child: PatientReferralItemWidget(
referralStatus: model
.getReferredPatientItem(index)
.referralStatusDesc,
referralStatusCode: model
.getReferredPatientItem(index)
.referralStatus,
patientName:
"${model.getReferredPatientItem(index).firstName} ${model.getReferredPatientItem(index).middleName} ${model.getReferredPatientItem(index).lastName}",
patientGender: model
.getReferredPatientItem(index)
.gender,
referredDate: AppDateUtils
.convertDateFromServerFormat(
model
.getReferredPatientItem(index)
.referralDate,
"dd/MM/yyyy"),
referredTime: AppDateUtils
.convertDateFromServerFormat(
model
.getReferredPatientItem(index)
.referralDate,
"hh:mm a"),
patientID:
"${model.getReferredPatientItem(index).patientID}",
isSameBranch: model
.getReferredPatientItem(index)
.isReferralDoctorSameBranch,
isReferral: false,
remark: model
.getReferredPatientItem(index)
.referringDoctorRemarks,
nationality: model
.getReferredPatientItem(index)
.nationalityName,
nationalityFlag: model
.getReferredPatientItem(index)
.nationalityFlagURL,
doctorAvatar: model
.getReferredPatientItem(index)
.doctorImageURL,
referralDoctorName:
"${TranslationBase.of(context).dr} ${model.getReferredPatientItem(index).referralDoctorName}",
clinicDescription: model
.getReferredPatientItem(index)
.referralClinicDescription,
infoIcon: Icon(FontAwesomeIcons.arrowRight,
size: 25, color: Colors.black),
),
);
},
),
],
),
),
),
),
],
),
),
);
}
}
class PatientTypeRadioWidget extends StatefulWidget {
final Function(PatientType) radioOnChange;
PatientTypeRadioWidget(this.radioOnChange);
@override
_PatientTypeRadioWidgetState createState() =>
_PatientTypeRadioWidgetState(this.radioOnChange);
}
class _PatientTypeRadioWidgetState extends State<PatientTypeRadioWidget> {
final Function(PatientType) radioOnChange;
_PatientTypeRadioWidgetState(this.radioOnChange);
PatientType patientType = PatientType.IN_PATIENT;
@override
Widget build(BuildContext context) {
return Row(
children: [
Expanded(
child: RadioListTile<PatientType>(
title: AppText(TranslationBase.of(context).inPatient),
value: PatientType.IN_PATIENT,
groupValue: patientType,
onChanged: (PatientType value) {
setState(() {
patientType = value;
radioOnChange(value);
});
},
),
),
Expanded(
child: RadioListTile<PatientType>(
title: AppText(TranslationBase.of(context).outpatient),
value: PatientType.OUT_PATIENT,
groupValue: patientType,
onChanged: (PatientType value) {
setState(() {
patientType = value;
radioOnChange(value);
});
},
),
),
],
);
}
}