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/procedures/procedure_screen.dart

182 lines
8.1 KiB
Dart

import 'package:doctor_app_flutter/config/shared_pref_kay.dart';
import 'package:doctor_app_flutter/core/enum/viewstate.dart';
import 'package:doctor_app_flutter/core/viewModel/procedure_View_model.dart';
import 'package:doctor_app_flutter/core/model/doctor/doctor_profile_model.dart';
import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart';
import 'package:doctor_app_flutter/screens/base/base_view.dart';
import 'package:doctor_app_flutter/screens/procedures/update-procedure.dart';
import 'package:doctor_app_flutter/utils/translations_delegate_base_utils.dart';
import 'package:doctor_app_flutter/utils/utils.dart';
import 'package:doctor_app_flutter/widgets/patients/profile/app_bar/patient-profile-app-bar.dart';
import 'package:doctor_app_flutter/widgets/patients/patient_service_title.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/transitions/slide_up_page.dart';
import 'package:flutter/material.dart';
import '../../widgets/shared/errors/error_message.dart';
import 'ProcedureCard.dart';
import 'ProcedureType.dart';
import 'base_add_procedure_tab_page.dart';
class ProcedureScreen extends StatelessWidget {
int doctorNameP;
void initState() async {
Map profile = await sharedPref.getObj(DOCTOR_PROFILE);
DoctorProfileModel doctorProfile = DoctorProfileModel.fromJson(profile);
doctorNameP = doctorProfile.doctorID;
}
@override
Widget build(BuildContext context) {
final routeArgs = ModalRoute.of(context).settings.arguments as Map;
PatiantInformtion patient = routeArgs['patient'];
String patientType = routeArgs['patientType'];
bool isFromLiveCare = routeArgs['isFromLiveCare'];
bool isInpatient = routeArgs['isInpatient'];
return BaseView<ProcedureViewModel>(
onModelReady: (model) => model.getProcedure(
mrn: patient.patientId,
patientType: patientType,
appointmentNo: patient.appointmentNo),
builder: (BuildContext context, ProcedureViewModel model, Widget child) =>
AppScaffold(
isShowAppBar: true,
backgroundColor: Colors.grey[100],
baseViewModel: model,
appBar: PatientProfileAppBar(
patient,
isInpatient: isInpatient,
),
body: SingleChildScrollView(
child: Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: 12,
),
if (model.procedureList.length == 0 &&
patient.patientStatusType != 43)
ServiceTitle(
title: TranslationBase.of(context).orderTestOr,
subTitle: TranslationBase.of(context).procedure,
),
if (patient.patientStatusType != null &&
patient.patientStatusType == 43)
ServiceTitle(
title: TranslationBase.of(context).orderTestOr,
subTitle: TranslationBase.of(context).procedure,
),
if ((patient.patientStatusType != null &&
patient.patientStatusType == 43) ||
(isFromLiveCare && patient.appointmentNo != null))
InkWell(
onTap: () {
Navigator.push(
context,
SlideUpPageRoute(
widget: BaseAddProcedureTabPage(
patient: patient,
model: model,
procedureType: ProcedureType.PROCEDURE,
),
settingRoute: 'AddProcedureTabPage'),
);
},
child: Container(
width: double.maxFinite,
height: 140,
margin: EdgeInsets.all(10),
decoration: BoxDecoration(
color: Colors.grey[300],
borderRadius: BorderRadius.circular(10),
),
child: Center(
child: Container(
height: 90,
child: Column(
children: [
Container(
height: 40,
width: 40,
decoration: BoxDecoration(
color: Colors.grey[600],
borderRadius: BorderRadius.circular(10),
),
child: Center(
child: Icon(
Icons.add,
color: Colors.white,
),
),
),
SizedBox(
height: 10,
),
AppText(
TranslationBase.of(context).addMoreProcedure,
color: Colors.grey[600],
fontWeight: FontWeight.w600,
)
],
),
),
),
),
),
if (model.procedureList.isNotEmpty)
///TODO Elham* use list view builder
...List.generate(
model.procedureList[0].rowcount,
(index) => ProcedureCard(
categoryID: model.procedureList[0].entityList[index].categoryID,
entityList: model.procedureList[0].entityList[index],
onTap: () {
if (model.procedureList[0].entityList[index].categoryID ==
2 ||
model.procedureList[0].entityList[index].categoryID == 4)
updateProcedureForm(context,
model: model,
patient: patient,
remarks: model
.procedureList[0].entityList[index].remarks,
orderType: model
.procedureList[0].entityList[index].orderType
.toString(),
orderNo: model
.procedureList[0].entityList[index].orderNo,
procedureName: model.procedureList[0]
.entityList[index].procedureName,
categoreId: model
.procedureList[0].entityList[index].categoryID
.toString(),
procedureId: model.procedureList[0]
.entityList[index].procedureId,
limetNo: model.procedureList[0].entityList[index]
.lineItemNo);
// } else
// Helpers.showErrorToast(
// 'You Cant Update This Procedure');
},
patient: patient,
doctorID: model?.doctorProfile?.doctorID,
),
),
if (model.state == ViewState.ErrorLocal ||
(model.procedureList.isNotEmpty &&
model.procedureList[0].entityList.isEmpty))
Center(
child: ErrorMessage(
error: TranslationBase.of(context).noDataAvailable,
)),
],
),
),
),
),
);
}
}