diff --git a/lib/core/viewModel/procedure_View_model.dart b/lib/core/viewModel/procedure_View_model.dart index 5c4bfbfe..9627353f 100644 --- a/lib/core/viewModel/procedure_View_model.dart +++ b/lib/core/viewModel/procedure_View_model.dart @@ -225,7 +225,7 @@ class ProcedureViewModel extends BaseViewModel { await _labsService.getPatientLabOrdersList(patient); if (_labsService.hasError) { error = _labsService.error; - setState(ViewState.Error); + setState(ViewState.ErrorLocal); } else { _labsService.patientLabOrdersList.forEach((element) { List patientLabOrdersClinic = diff --git a/lib/screens/procedures/ProcedureCard.dart b/lib/screens/procedures/ProcedureCard.dart new file mode 100644 index 00000000..d023dbc2 --- /dev/null +++ b/lib/screens/procedures/ProcedureCard.dart @@ -0,0 +1,142 @@ +import 'package:doctor_app_flutter/core/model/procedure/get_ordered_procedure_model.dart'; +import 'package:doctor_app_flutter/core/viewModel/project_view_model.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/shared/Text.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +class ProcedureCard extends StatelessWidget { + final Function onTap; + final EntityList entityList; + + const ProcedureCard({Key key, this.onTap, this.entityList}) : super(key: key); + + @override + Widget build(BuildContext context) { + ProjectViewModel projectViewModel = Provider.of(context); + return Container( + width: double.maxFinite, + height: MediaQuery.of(context).size.height * .22, + margin: EdgeInsets.all(10), + padding: EdgeInsets.only(left: 0, right: 5, bottom: 5, top: 5), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(15), + color: Colors.white, + ), + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Container( + height: MediaQuery.of(context).size.height * .20, + width: 5, + decoration: BoxDecoration( + borderRadius: BorderRadius.only( + topLeft: Radius.circular(10), + bottomLeft: Radius.circular(10), + ), + color: entityList.orderType == 1 + ? Colors.red[500] + : Colors.black, + ), + ), + Expanded( + child: Container( + padding: EdgeInsets.only( + left: projectViewModel.isArabic ? 0 : 15, + right: projectViewModel.isArabic ? 15 : 0), + child: InkWell( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Texts( + entityList.orderType == 0 + ? 'Routine' + : 'Urgent', + color: entityList.orderType == 0 + ? Colors.black + : Colors.red[800], + fontWeight: FontWeight.w600, + ), + SizedBox( + height: 5, + ), + Texts( + entityList.procedureName, + bold: true, + fontSize: 14, + ), + ], + ), + ), + SizedBox( + width: 5, + ), + Column( + crossAxisAlignment: CrossAxisAlignment.end, + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Texts( + '${DateUtils.getDayMonthYearDateFormatted(DateUtils.convertISOStringToDateTime(entityList.orderDate), isArabic: projectViewModel.isArabic)}', + color: Colors.black, + fontWeight: FontWeight.w600, + fontSize: 14, + ), + Texts( + '${DateUtils.getHour(DateUtils.convertISOStringToDateTime(entityList.orderDate))}', + fontWeight: FontWeight.w600, + color: Colors.grey[700], + fontSize: 14, + ), + ], + ), + ], + ), + Row( + children: [ + Texts( + TranslationBase.of(context).orderNo, + color: Colors.grey, + fontSize: 12, + ), + Texts( + entityList.orderNo.toString(), + color: Colors.grey, + fontSize: 12, + ), + ], + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Texts( + entityList.remarks ?? '', + fontSize: 12, + ), + Icon(Icons.edit) + ], + ) + ], + ), + onTap: onTap, + ), + ), + ), + ], + ), + ), + ), + ); + } +} diff --git a/lib/screens/procedures/procedure_screen.dart b/lib/screens/procedures/procedure_screen.dart index fd3b78b9..4f47da43 100644 --- a/lib/screens/procedures/procedure_screen.dart +++ b/lib/screens/procedures/procedure_screen.dart @@ -7,601 +7,122 @@ import 'package:doctor_app_flutter/screens/procedures/update-procedure.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/patients/profile/patient-page-header-widget.dart'; +import 'package:doctor_app_flutter/widgets/patients/profile/patient-profile-header-new-design.dart'; +import 'package:doctor_app_flutter/widgets/shared/Text.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/network_base_view.dart'; import 'package:flutter/material.dart'; -class ProcedureScreen extends StatefulWidget { - @override - _ProcedureScreenState createState() => _ProcedureScreenState(); -} - -class _ProcedureScreenState extends State { - int selectedType = 0; - int testNum = 1; - PatiantInformtion patient; - setSelectedType(int val) { - setState(() { - selectedType = val; - }); - } +import 'ProcedureCard.dart'; - TextEditingController procedureController = TextEditingController(); - //TODO Jammal +class ProcedureScreen extends StatelessWidget { @override Widget build(BuildContext context) { final routeArgs = ModalRoute.of(context).settings.arguments as Map; - patient = routeArgs['patient']; + PatiantInformtion patient = routeArgs['patient']; + String patientType = routeArgs['patientType']; + String arrivalType = routeArgs['arrivalType']; return BaseView( onModelReady: (model) => model.getProcedure(mrn: patient.patientId), builder: (BuildContext context, ProcedureViewModel model, Widget child) => AppScaffold( - isShowAppBar: true, - appBarTitle: TranslationBase.of(context).orderProcedure, - body: NetworkBaseView( - baseViewModel: model, - child: SingleChildScrollView( - child: Container( - color: Colors.white, + isShowAppBar: false, + appBarTitle: TranslationBase.of(context).orderProcedure, + body: NetworkBaseView( + baseViewModel: model, + child: SingleChildScrollView( + child: Container( + color: Colors.white, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + PatientProfileHeaderNewDesign( + patient, arrivalType ?? '0', patientType), + SizedBox( + height: 12, + ), + Padding( + padding: const EdgeInsets.all(8.0), child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - PatientPageHeaderWidget(patient), - Divider( - height: 1.0, - thickness: 1.0, - color: Colors.grey, + Texts( + 'Order Test or', + style: "caption2", + color: Colors.black, + fontSize: 13, + ), + Texts( + 'Procedure', + bold: true, + fontSize: 22, ), - (model.procedureList.length != 0) - ? SizedBox( - height: model.procedureList[0].rowcount == 0 - ? 200.0 - : 10.0) - : SizedBox(height: 200.0), - //model.prescriptionList == null - (model.procedureList.length != 0) - ? model.procedureList[0].rowcount == 0 - ? Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: - CrossAxisAlignment.stretch, - children: [ - InkWell( - onTap: () { - model - .getProcedureCategory() - .then((value) { - addSelectedProcedure( - context, model, patient); - }); - - //model.postPrescription(); - }, - child: CircleAvatar( - radius: 65, - backgroundColor: Color(0XFFB8382C), - child: CircleAvatar( - radius: 60, - backgroundColor: Colors.white, - child: Icon( - Icons.add, - color: Colors.black, - size: 45.0, - ), - ), - ), - ), - SizedBox( - height: 15.0, - ), - Row( - mainAxisAlignment: - MainAxisAlignment.center, - children: [ - AppText( - 'NO ORDER FOR PROCEDURE LISTED', - color: Colors.black, - fontWeight: FontWeight.w900, - ), - ], - ), - Row( - mainAxisAlignment: - MainAxisAlignment.center, - children: [ - AppText( - TranslationBase.of(context).addNow, - color: Color(0XFFB8382C), - fontWeight: FontWeight.w700, - ), - ], - ), - ], - ) - : Padding( - padding: EdgeInsets.all(16.0), - child: NetworkBaseView( - baseViewModel: model, - child: Column( - mainAxisAlignment: - MainAxisAlignment.start, - children: [ - InkWell( - child: Container( - height: 50.0, - width: 450.0, - decoration: BoxDecoration( - color: Colors.white, - border: Border.all( - color: Colors.grey), - borderRadius: - BorderRadius.circular(10.0), - ), - child: Padding( - padding: EdgeInsets.all(8.0), - child: Row( - mainAxisAlignment: - MainAxisAlignment - .spaceBetween, - children: [ - AppText( - TranslationBase.of( - context) - .addMoreProcedure, - fontWeight: - FontWeight.w100, - fontSize: 12.5, - ), - Icon( - Icons.add, - color: Color(0XFFB8382C), - ) - ], - ), - ), - ), - onTap: () { - model - .getProcedureCategory() - .then((value) { - addSelectedProcedure( - context, model, patient); - }); - - //model.postPrescription(); - }, - ), - // Container( - // decoration: BoxDecoration( - // borderRadius: BorderRadius.all( - // Radius.circular(6.0)), - // border: Border.all( - // width: 1.0, - // color: HexColor("#CCCCCC"))), - // child: AppTextFormField( - // labelText: 'Add more procedure', - // borderColor: Colors.white, - // //suffixIcon: Icons.search, - // - // //textInputType: TextInputType.number, - // inputFormatter: ONLY_NUMBERS, - // onTap: () { - // addSelectedProcedure(context); - // }, - // ), - // ), - SizedBox( - height: 10.0, - ), - ...List.generate( - model.procedureList[0].rowcount, - (index) => Container( - color: Colors.white, - child: Column( - children: [ - SizedBox( - height: - MediaQuery.of(context) - .size - .height * - 0.022, - ), - Row( - mainAxisAlignment: - MainAxisAlignment - .spaceBetween, - children: [ - Container( - height: MediaQuery.of( - context) - .size - .height * - 0.18, - width: MediaQuery.of( - context) - .size - .width * - 0.135, - child: Column( - children: [ - AppText( - DateTime.parse(model - .procedureList[ - 0] - .entityList[ - index] - .orderDate) - .year - .toString(), - color: model - .procedureList[ - 0] - .entityList[ - index] - .orderType == - 1 - ? Color( - 0xFFB9382C) - : Colors - .green), - AppText( - Helpers.getMonth(model.procedureList[0].entityList[index].orderDate != - null - ? (DateTime.parse(model.procedureList[0].entityList[index].orderDate) - .month) - : DateTime.now() - .month) - .toUpperCase(), - color: model - .procedureList[ - 0] - .entityList[ - index] - .orderType == - 1 - ? Color( - 0xFFB9382C) - : Colors - .green), - AppText( - DateTime.parse(model - .procedureList[ - 0] - .entityList[ - index] - .orderDate) - .day - .toString(), - color: model - .procedureList[ - 0] - .entityList[ - index] - .orderType == - 1 - ? Color( - 0xFFB9382C) - : Colors - .green), - ], - ), - ), - Expanded( - child: Container( - width: MediaQuery.of( - context) - .size - .width * - 0.05, - child: Column( - children: [ - Row( - children: [ - AppText( - TranslationBase.of(context) - .codeNo + - " : ", - fontWeight: - FontWeight - .w700, - fontSize: - 13.0, - ), - AppText( - model - .procedureList[ - 0] - .entityList[ - index] - .procedureId - .toString(), - fontSize: - 12.0, - ), - SizedBox( - width: 12.0, - ), - AppText( - TranslationBase.of(context) - .orderType + - " : ", - fontWeight: - FontWeight - .w700, - fontSize: - 13.0, - ), - Expanded( - child: AppText( - model.procedureList[0].entityList[index].orderType == - 0 - ? 'Routine' - : 'Urgent', - fontSize: - 13.5, - color: model.procedureList[0].entityList[index].orderType == - 1 - ? Color(0xFFB9382C) - : Colors.green), - ), - ], - ), - Row( - children: [ - AppText( - 'Order.NO' + - " : ", - fontWeight: - FontWeight - .w700, - fontSize: - 15.0, - ), - AppText( - model - .procedureList[ - 0] - .entityList[ - index] - .orderNo - .toString(), - fontSize: - 13.0, - ), - ], - ), - Row( - children: [ - Container( - child: - Expanded( - child: - AppText( - model - .procedureList[0] - .entityList[index] - .procedureName, - fontWeight: - FontWeight.w800, - ), - ), - ) - ], - ), - - Row( - children: [ - // AppText( - // TranslationBase.of(context) - // .price + - // " : ", - // fontWeight: - // FontWeight - // .w700, - // ), - // Expanded( - // child: AppText( - // model - // .procedureList[ - // 0] - // .entityList[ - // index] - // .price - // .toString(), - // fontSize: - // 13.0), - // ) - ], - ), - SizedBox( - height: 10.0, - ), - - Row( - children: [ - Expanded( - child: - Container( - height: MediaQuery.of(context) - .size - .height * - 0.047, - width: MediaQuery.of(context) - .size - .width * - 0.10, - child: - AppText( - model.procedureList[0].entityList[index].remarks != - null - ? model.procedureList[0].entityList[index].remarks.toString() - : "", - fontSize: - 11.5, - ), - ), - ), - ], - ), - SizedBox( - height: 20.0, - ), - - // SizedBox( - // height: 40, - // ), - ], - ), - ), - ), - Container( - child: Column( - children: [ - InkWell( - child: Icon( - Icons.edit), - onTap: () { - // model - // .updateProcedure(); - if (model.procedureList[0].entityList[index].categoryID == 02 || - model - .procedureList[ - 0] - .entityList[ - index] - .categoryID == - 03 || - model - .procedureList[0] - .entityList[index] - .categoryID == - 55) { - updateProcedureForm( - context, - limetNo: model - .procedureList[ - 0] - .entityList[ - index] - .lineItemNo, - model: - model, - orderNo: model - .procedureList[ - 0] - .entityList[ - index] - .orderNo, - remarks: model - .procedureList[ - 0] - .entityList[ - index] - .remarks, - procedureName: model - .procedureList[ - 0] - .entityList[ - index] - .procedureName, - patient: - patient, - procedureId: model - .procedureList[ - 0] - .entityList[ - index] - .procedureId, - categoreId: model - .procedureList[ - 0] - .entityList[ - index] - .categoryID - .toString()); - } else { - helpers.showErrorToast( - 'You cant Update this Procedure'); - } - }, - ) - ], - ), - ), - ], - ), - Divider( - height: 1.0, - thickness: 1.0, - color: Colors.grey, - ), - ], - ), - ), - ), - ], - ), - ), - ) - : Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - InkWell( - onTap: () { - model - .getProcedureCategory() - .then((value) { - addSelectedProcedure( - context, model, patient); - }); - - //model.postPrescription(); - }, - child: CircleAvatar( - radius: 65, - backgroundColor: Color(0XFFB8382C), - child: CircleAvatar( - radius: 60, - backgroundColor: Colors.white, - child: Icon( - Icons.add, - color: Colors.black, - size: 45.0, - ), - ), - ), - ), - SizedBox( - height: 15.0, - ), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - AppText( - 'NO ORDER FOR PROCEDURE LISTED', - color: Colors.black, - fontWeight: FontWeight.w900, - ), - ], - ), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - AppText( - TranslationBase.of(context).addNow, - color: Color(0XFFB8382C), - fontWeight: FontWeight.w700, - ), - ], - ), - ], - ) ], ), ), - ), - )), + if (patientType != null && patientType == '7') + InkWell( + onTap: () { + //TODO Hussam call the add page here + }, + 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, + ), + Texts( + 'Add More Procedure', + color: Colors.grey[600], + fontWeight: FontWeight.w600, + ) + ], + ), + ), + ), + ), + ), + if (model.procedureList.isNotEmpty) + ...List.generate( + model.procedureList[0].rowcount, + (index) => ProcedureCard( + entityList: model.procedureList[0].entityList[index], + onTap: (){ + //TODO Hussam call the edit page here + }, + ), + ), + ], + ), + ), + ), + ), + ), ); } } diff --git a/lib/util/date-utils.dart b/lib/util/date-utils.dart index ef292220..d55675c3 100644 --- a/lib/util/date-utils.dart +++ b/lib/util/date-utils.dart @@ -7,6 +7,14 @@ class DateUtils { return DateFormat(dateFormat).format(dateTime); } + static DateTime convertISOStringToDateTime(String date){ + DateTime newDate; + + newDate = DateTime.parse(date); + + return newDate; + } + static String convertStringToDateFormat(String date, String dateFormat) { DateTime dateTime = DateTime.parse(date); return convertDateToFormat(dateTime, dateFormat);