diff --git a/.gitignore b/.gitignore index 5178923f..7115609f 100644 --- a/.gitignore +++ b/.gitignore @@ -29,6 +29,7 @@ .pub-cache/ .pub/ /build/ +pubspec.lock # Except for application packages # Web related lib/generated_plugin_registrant.dart diff --git a/assets/images/ic_circle_arrow.png b/assets/images/ic_circle_arrow.png new file mode 100644 index 00000000..81c4a77b Binary files /dev/null and b/assets/images/ic_circle_arrow.png differ diff --git a/lib/client/base_app_client.dart b/lib/client/base_app_client.dart index 2521cf07..454f4d04 100644 --- a/lib/client/base_app_client.dart +++ b/lib/client/base_app_client.dart @@ -3,7 +3,7 @@ import 'dart:convert'; import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; import 'package:doctor_app_flutter/models/doctor/doctor_profile_model.dart'; -import 'package:doctor_app_flutter/providers/project_provider.dart'; +import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; import 'package:doctor_app_flutter/util/helpers.dart'; import 'package:http/http.dart' as http; diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 03306e37..84d2a7c7 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -222,10 +222,10 @@ const Map> localizedValues = { 'endcall': {'en': 'End Call', 'ar': 'إنهاء المكالمة'}, 'transfertoadmin': {'en': 'Transfer to admin', 'ar': 'نقل إلى المسؤول'}, "searchMedicineImageCaption": { - 'en': 'Type or speak the medicine name to search', - 'ar': ' اكتب أو انطق اسم الدواء للبحث' + 'en': 'Type the medicine name to search', + 'ar': ' اكتب اسم الدواء للبحث' }, - "type": {'en': 'Type or Speak', 'ar': 'اكتب أو تحدث '}, + "type": {'en': 'Type ', 'ar': 'اكتب'}, "fromDate": {'en': 'From Date', 'ar': 'من تاريخ'}, "toDate": {'en': 'To Date', 'ar': 'الى تاريخ'}, "searchPatientImageCaptionTitle": { @@ -242,6 +242,7 @@ const Map> localizedValues = { 'ar': 'لا يوجد اي نتائج' }, 'typeMedicineName': {'en': 'Type Medicine Name', 'ar': 'اكتب اسم الدواء'}, + 'moreThan3Letter': { 'en': 'Medicine Name Should Be More Than 3 letter', 'ar': 'يجب أن يكون اسم الدواء أكثر من 3 أحرف' @@ -249,4 +250,8 @@ const Map> localizedValues = { 'gender2': {'en': 'Gender: ', 'ar': 'الجنس: '}, 'age2': {'en': 'Age: ', 'ar': 'العمر: '}, 'referralPatient': {'en': 'Referral Patient', 'ar': 'المريض المحال '}, + 'replySuccessfully': { + 'en': 'Reply Successfully', + 'ar': 'تم الرد بنجاح' + }, }; diff --git a/lib/core/service/hospital/hospitals_service.dart b/lib/core/service/hospital/hospitals_service.dart deleted file mode 100644 index 1fb24c6b..00000000 --- a/lib/core/service/hospital/hospitals_service.dart +++ /dev/null @@ -1,23 +0,0 @@ -import 'package:doctor_app_flutter/config/config.dart'; -import 'package:doctor_app_flutter/core/model/hospitals_model.dart'; -import 'package:doctor_app_flutter/core/service/base/base_service.dart'; - -///This service just an example -class HospitalService extends BaseService { - List _hospitals = List(); - - List get hospitals => _hospitals; - - Future getHospitals() async { - await baseAppClient.post(GET_PROJECTS, - onSuccess: (dynamic response, int statusCode) { - _hospitals.clear(); - response['ListProject'].forEach((hospital) { - _hospitals.add(HospitalsModel.fromJson(hospital)); - }); - }, onFailure: (String error, int statusCode) { - hasError = true; - super.error = error; - }, body: Map()); - } -} diff --git a/lib/core/service/medicine_service.dart b/lib/core/service/medicine_service.dart new file mode 100644 index 00000000..df23172f --- /dev/null +++ b/lib/core/service/medicine_service.dart @@ -0,0 +1,49 @@ +import 'package:doctor_app_flutter/config/config.dart'; +import 'package:doctor_app_flutter/core/service/base/base_service.dart'; +import 'package:doctor_app_flutter/models/doctor/request_schedule.dart'; +import 'package:doctor_app_flutter/models/pharmacies/pharmacies_List_request_model.dart'; +import 'package:doctor_app_flutter/models/pharmacies/pharmacies_items_request_model.dart'; + +class MedicineService extends BaseService { + var _pharmacyItemsList = []; + var _pharmaciesList = []; + get pharmacyItemsList => _pharmacyItemsList; + get pharmaciesList => _pharmaciesList; + + PharmaciesItemsRequestModel _itemsRequestModel = + PharmaciesItemsRequestModel(); + PharmaciesListRequestModel _listRequestModel = PharmaciesListRequestModel(); + + + Future getMedicineItem(String itemName) async { + _itemsRequestModel.pHRItemName = itemName; + await baseAppClient.post( + PHARMACY_ITEMS_URL, + onSuccess: (dynamic response, int statusCode) { + _pharmacyItemsList.clear(); + _pharmacyItemsList = response['ListPharmcy_Region_enh']; + }, + onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, + body: _itemsRequestModel.toJson(), + ); + } + + Future getPharmaciesList(int itemId) async { + _listRequestModel.itemID = itemId; + await baseAppClient.post( + PHARMACY_LIST_URL, + onSuccess: (dynamic response, int statusCode) { + _pharmaciesList.clear(); + _pharmaciesList = response['PharmList']; + }, + onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, + body: _listRequestModel.toJson(), + ); + } +} diff --git a/lib/core/service/patient_service.dart b/lib/core/service/patient_service.dart new file mode 100644 index 00000000..b16753f5 --- /dev/null +++ b/lib/core/service/patient_service.dart @@ -0,0 +1,412 @@ +import 'package:doctor_app_flutter/client/base_app_client.dart'; +import 'package:doctor_app_flutter/config/config.dart'; +import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; +import 'package:doctor_app_flutter/core/service/base/base_service.dart'; +import 'package:doctor_app_flutter/models/doctor/doctor_profile_model.dart'; +import 'package:doctor_app_flutter/models/doctor/request_schedule.dart'; +import 'package:doctor_app_flutter/models/patient/get_clinic_by_project_id_request.dart'; +import 'package:doctor_app_flutter/models/patient/get_doctor_by_clinic_id_request.dart'; +import 'package:doctor_app_flutter/models/patient/get_list_stp_referral_frequency_request.dart'; +import 'package:doctor_app_flutter/models/patient/lab_orders/lab_orders_res_model.dart'; +import 'package:doctor_app_flutter/models/patient/lab_result/lab_result.dart'; +import 'package:doctor_app_flutter/models/patient/lab_result/lab_result_req_model.dart'; +import 'package:doctor_app_flutter/models/patient/patient_model.dart'; +import 'package:doctor_app_flutter/models/patient/prescription/prescription_report.dart'; +import 'package:doctor_app_flutter/models/patient/prescription/prescription_report_for_in_patient.dart'; +import 'package:doctor_app_flutter/models/patient/prescription/prescription_res_model.dart'; +import 'package:doctor_app_flutter/models/patient/radiology/radiology_res_model.dart'; +import 'package:doctor_app_flutter/models/patient/refer_to_doctor_request.dart'; +import 'package:doctor_app_flutter/models/patient/vital_sign/vital_sign_res_model.dart'; + +class PatientService extends BaseService { + List _patientVitalSignList = []; + List patientVitalSignOrderdSubList = []; + + List get patientVitalSignList => _patientVitalSignList; + + List _patientLabResultOrdersList = []; + + List get patientLabResultOrdersList => + _patientLabResultOrdersList; + + List get patientPrescriptionsList => + _patientPrescriptionsList; + List _patientPrescriptionsList = []; + + List get prescriptionReportForInPatientList => + _prescriptionReportForInPatientList; + List _prescriptionReportForInPatientList = []; + + List _patientRadiologyList = []; + + List get patientRadiologyList => _patientRadiologyList; + + List _prescriptionReport = []; + + List get prescriptionReport => _prescriptionReport; + + List _labResultList = []; + + List get labResultList => _labResultList; + + // TODO: replace var with model + var _patientProgressNoteList = []; + + get patientProgressNoteList => _patientProgressNoteList; + + // TODO: replace var with model + var _insuranceApporvalsList = []; + + get insuranceApporvalsList => _insuranceApporvalsList; + + // TODO: replace var with model + var _doctorsList = []; + + get doctorsList => _doctorsList; + + // TODO: replace var with model + var _clinicsList = []; + + get clinicsList => _clinicsList; + + // TODO: replace var with model + var _referalFrequancyList = []; + + get referalFrequancyList => _referalFrequancyList; + + DoctorsByClinicIdRequest _doctorsByClinicIdRequest = + DoctorsByClinicIdRequest(); + STPReferralFrequencyRequest _referralFrequencyRequest = + STPReferralFrequencyRequest(); + ClinicByProjectIdRequest _clinicByProjectIdRequest = + ClinicByProjectIdRequest(); + ReferToDoctorRequest _referToDoctorRequest; + + RequestSchedule _requestSchedule = RequestSchedule(); + + Future getPatientList(PatientModel patient, patientType) async { + hasError = false; + int val = int.parse(patientType); + + dynamic localRes; + await baseAppClient.post( + GET_PATIENT + SERVICES_PATIANT[val], + onSuccess: (dynamic response, int statusCode) { + localRes = response; + }, + onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, + body: { + "ProjectID": patient.ProjectID, + "ClinicID": patient.ClinicID, + "DoctorID": patient.DoctorID, + "FirstName": patient.FirstName, + "MiddleName": patient.MiddleName, + "LastName": patient.LastName, + "PatientMobileNumber": patient.PatientMobileNumber, + "PatientIdentificationID": patient.PatientIdentificationID, + "PatientID": patient.PatientID, + "From": patient.From, + "To": patient.To, + "LanguageID": patient.LanguageID, + "stamp": patient.stamp, + "IPAdress": patient.IPAdress, + "VersionID": patient.VersionID, + "Channel": patient.Channel, + "TokenID": patient.TokenID, + "SessionID": patient.SessionID, + "IsLoginForDoctorApp": patient.IsLoginForDoctorApp, + "PatientOutSA": patient.PatientOutSA + }, + ); + + return Future.value(localRes); + } + + Future getPatientVitalSign(patient) async { + hasError = false; + await baseAppClient.post( + GET_PATIENT_VITAL_SIGN, + onSuccess: (dynamic response, int statusCode) { + _patientVitalSignList = []; + response['List_DoctorPatientVitalSign'].forEach((v) { + _patientVitalSignList.add(new VitalSignResModel.fromJson(v)); + }); + + if (_patientVitalSignList.length > 0) { + List patientVitalSignOrderdSubListTemp = []; + patientVitalSignOrderdSubListTemp = _patientVitalSignList; + patientVitalSignOrderdSubListTemp + .sort((VitalSignResModel a, VitalSignResModel b) { + return b.vitalSignDate.microsecondsSinceEpoch - + a.vitalSignDate.microsecondsSinceEpoch; + }); + patientVitalSignOrderdSubList.clear(); + int length = patientVitalSignOrderdSubListTemp.length >= 20 + ? 20 + : patientVitalSignOrderdSubListTemp.length; + for (int x = 0; x < length; x++) { + patientVitalSignOrderdSubList + .add(patientVitalSignOrderdSubListTemp[x]); + } + } + }, + onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, + body: patient, + ); + } + + Future getLabResultOrders(patient) async { + hasError = false; + await baseAppClient.post( + GET_PATIENT_LAB_OREDERS, + onSuccess: (dynamic response, int statusCode) { + _patientLabResultOrdersList = []; + response['List_GetLabOreders'].forEach((v) { + _patientLabResultOrdersList.add(new LabOrdersResModel.fromJson(v)); + }); + }, + onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, + body: patient, + ); + } + + Future getOutPatientPrescriptions(patient) async { + hasError = false; + await baseAppClient.post( + GET_PRESCRIPTION, + onSuccess: (dynamic response, int statusCode) { + _patientPrescriptionsList = []; + response['PatientPrescriptionList'].forEach((v) { + _patientPrescriptionsList.add(new PrescriptionResModel.fromJson(v)); + }); + }, + onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, + body: patient, + ); + } + + Future getInPatientPrescriptions(patient) async { + hasError = false; + await baseAppClient.post( + GET_PRESCRIPTION_REPORT_FOR_IN_PATIENT, + onSuccess: (dynamic response, int statusCode) { + _prescriptionReportForInPatientList = []; + response['List_PrescriptionReportForInPatient'].forEach((v) { + prescriptionReportForInPatientList + .add(PrescriptionReportForInPatient.fromJson(v)); + }); + }, + onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, + body: patient, + ); + } + + Future getPrescriptionReport(prescriptionReqModel) async { + hasError = false; + await baseAppClient.post( + GET_PRESCRIPTION_REPORT, + onSuccess: (dynamic response, int statusCode) { + _prescriptionReport = []; + response['ListPRM'].forEach((v) { + _prescriptionReport.add(PrescriptionReport.fromJson(v)); + }); + }, + onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, + body: prescriptionReqModel, + ); + } + + Future getPatientRadiology(patient) async { + hasError = false; + await baseAppClient.post( + GET_RADIOLOGY, + onSuccess: (dynamic response, int statusCode) { + _patientRadiologyList = []; + response['List_GetRadOreders'].forEach((v) { + _patientRadiologyList.add(new RadiologyResModel.fromJson(v)); + }); + }, + onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, + body: patient, + ); + } + + Future getLabResult(LabOrdersResModel labOrdersResModel) async { + hasError = false; + + RequestLabResult requestLabResult = RequestLabResult(); + requestLabResult.sessionID = labOrdersResModel.setupID; + requestLabResult.orderNo = labOrdersResModel.orderNo; + requestLabResult.invoiceNo = labOrdersResModel.invoiceNo; + requestLabResult.patientTypeID = labOrdersResModel.patientType; + await baseAppClient.post( + GET_PATIENT_LAB_RESULTS, + onSuccess: (dynamic response, int statusCode) { + _labResultList = []; + response['List_GetLabNormal'].forEach((v) { + _labResultList.add(new LabResult.fromJson(v)); + }); + }, + onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, + body: requestLabResult.toJson(), + ); + } + + Future getPatientInsuranceApprovals(patient) async { + hasError = false; + + await baseAppClient.post( + PATIENT_INSURANCE_APPROVALS_URL, + onSuccess: (dynamic response, int statusCode) { + _insuranceApporvalsList = []; + _insuranceApporvalsList = response['List_ApprovalMain_InPatient']; + }, + onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, + body: patient, + ); + } + + Future getPatientProgressNote(patient) async { + hasError = false; + + await baseAppClient.post( + PATIENT_PROGRESS_NOTE_URL, + onSuccess: (dynamic response, int statusCode) { + _patientProgressNoteList = []; + _patientProgressNoteList = response['List_GetPregressNoteForInPatient']; + }, + onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, + body: patient, + ); + } + + + Future getClinicsList() async { + hasError = false; + + await baseAppClient.post( + PATIENT_GET_CLINIC_BY_PROJECT_URL, + onSuccess: (dynamic response, int statusCode) { + _clinicsList = []; + _clinicsList = response['List_Clinic_All']; + }, + onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, + body: _clinicByProjectIdRequest.toJson(), + ); + } + + + Future getReferralFrequancyList() async { + hasError = false; + + await baseAppClient.post( + PATIENT_GET_LIST_REFERAL_URL, + onSuccess: (dynamic response, int statusCode) { + _referalFrequancyList = []; + _referalFrequancyList = response['list_STPReferralFrequency']; + }, + onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, + body: _referralFrequencyRequest.toJson(), + ); + } + + Future getDoctorsList(String clinicId) async { + hasError = false; + _doctorsByClinicIdRequest.clinicID = clinicId; + await baseAppClient.post( + PATIENT_GET_DOCTOR_BY_CLINIC_URL, + onSuccess: (dynamic response, int statusCode) { + _doctorsList = []; + _doctorsList = response['List_Doctors_All']; + }, + onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, + body: _doctorsByClinicIdRequest.toJson(), + ); + } + + + // TODO send the total model insted of each parameter + Future referToDoctor({String selectedDoctorID, + String selectedClinicID, + int admissionNo, + String extension, + String priority, + String frequency, + String referringDoctorRemarks, + int patientID, + int patientTypeID, + String roomID, + int projectID}) async { + hasError = false; + // TODO Change it to use it when we implement authentication user + Map profile = await sharedPref.getObj(DOCTOR_PROFILE); + DoctorProfileModel doctorProfile = new DoctorProfileModel.fromJson(profile); + int doctorID = doctorProfile.doctorID; + int clinicId = doctorProfile.clinicID; + _referToDoctorRequest = ReferToDoctorRequest( + projectID: projectID, + admissionNo: admissionNo, + roomID: roomID, + referralClinic: selectedClinicID.toString(), + referralDoctor: selectedDoctorID.toString(), + createdBy: doctorID, + editedBy: doctorID, + patientID: patientID, + patientTypeID: patientTypeID, + referringClinic: clinicId, + referringDoctor: doctorID, + referringDoctorRemarks: referringDoctorRemarks, + priority: priority, + frequency: frequency, + extension: extension, + ); + await baseAppClient.post( + PATIENT_PROGRESS_NOTE_URL, + onSuccess: (dynamic response, int statusCode) {}, + onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, + body: _referToDoctorRequest.toJson(), + ); + } +} diff --git a/lib/providers/auth_provider.dart b/lib/core/viewModel/auth_view_model.dart similarity index 97% rename from lib/providers/auth_provider.dart rename to lib/core/viewModel/auth_view_model.dart index eaca545d..9b656d31 100644 --- a/lib/providers/auth_provider.dart +++ b/lib/core/viewModel/auth_view_model.dart @@ -5,12 +5,12 @@ import 'package:doctor_app_flutter/models/doctor/doctor_profile_model.dart'; import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; import 'package:flutter/cupertino.dart'; import 'package:doctor_app_flutter/config/config.dart'; -import '../models/doctor/user_model.dart'; +import '../../models/doctor/user_model.dart'; DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); enum APP_STATUS { LOADING, UNAUTHENTICATED, AUTHENTICATED } -class AuthProvider with ChangeNotifier { +class AuthViewModel with ChangeNotifier { List doctorsClinicList = []; String selectedClinicName; bool isLogin = false; @@ -23,7 +23,7 @@ class AuthProvider with ChangeNotifier { } - AuthProvider() { + AuthViewModel() { getUserAuthentication(); } diff --git a/lib/core/viewModel/doctor_replay_view_model.dart b/lib/core/viewModel/doctor_replay_view_model.dart index ac212578..29d3b125 100644 --- a/lib/core/viewModel/doctor_replay_view_model.dart +++ b/lib/core/viewModel/doctor_replay_view_model.dart @@ -1,7 +1,5 @@ import 'package:doctor_app_flutter/core/enum/viewstate.dart'; -import 'package:doctor_app_flutter/core/model/hospitals_model.dart'; import 'package:doctor_app_flutter/core/service/doctor_reply_service.dart'; -import 'package:doctor_app_flutter/core/service/hospital/hospitals_service.dart'; import 'package:doctor_app_flutter/models/doctor/list_gt_my_patients_question_model.dart'; import '../../locator.dart'; diff --git a/lib/core/viewModel/hospital_view_model.dart b/lib/core/viewModel/hospital_view_model.dart index cac49dac..56f03686 100644 --- a/lib/core/viewModel/hospital_view_model.dart +++ b/lib/core/viewModel/hospital_view_model.dart @@ -1,23 +1,31 @@ -import 'package:doctor_app_flutter/core/enum/viewstate.dart'; -import 'package:doctor_app_flutter/core/model/hospitals_model.dart'; -import 'package:doctor_app_flutter/core/service/hospital/hospitals_service.dart'; +import 'package:doctor_app_flutter/client/base_app_client.dart'; +import 'package:doctor_app_flutter/config/config.dart'; +import 'package:flutter/cupertino.dart'; -import '../../locator.dart'; -import 'base_view_model.dart'; +// TODO change it when change login +class HospitalViewModel with ChangeNotifier { + BaseAppClient baseAppClient = BaseAppClient(); -///This View Model just an example -class HospitalViewModel extends BaseViewModel { - HospitalService _hospitalService = locator(); + Future getProjectsList() async { + const url = GET_PROJECTS; + // TODO create model or remove it if no info need + var info = { + "LanguageID": 1, + "stamp": "2020-02-26T13:51:44.111Z", + "IPAdress": "11.11.11.11", + "VersionID": 1.2, + "Channel": 9, + "TokenID": "", + "SessionID": "i1UJwCTSqt", + "IsLoginForDoctorApp": true + }; + dynamic localRes; - List get hospitals => _hospitalService.hospitals; - - Future getHospitals() async { - setState(ViewState.Busy); - await _hospitalService.getHospitals(); - if (_hospitalService.hasError) { - error = _hospitalService.error; - setState(ViewState.Error); - } else - setState(ViewState.Idle); + await baseAppClient.post(url, onSuccess: (response, statusCode) async { + localRes = response; + }, onFailure: (String error, int statusCode) { + throw error; + }, body: info); + return Future.value(localRes); } } diff --git a/lib/providers/livecare_provider.dart b/lib/core/viewModel/livecare_view_model.dart similarity index 97% rename from lib/providers/livecare_provider.dart rename to lib/core/viewModel/livecare_view_model.dart index 7af6585f..f6ef42e7 100644 --- a/lib/providers/livecare_provider.dart +++ b/lib/core/viewModel/livecare_view_model.dart @@ -1,7 +1,7 @@ -import 'dart:convert'; import 'package:doctor_app_flutter/client/base_app_client.dart'; import 'package:doctor_app_flutter/config/config.dart'; +import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; import 'package:doctor_app_flutter/models/livecare/end_call_req.dart'; import 'package:doctor_app_flutter/models/livecare/get_panding_req_list.dart'; import 'package:doctor_app_flutter/models/livecare/get_pending_res_list.dart'; @@ -9,11 +9,10 @@ import 'package:doctor_app_flutter/models/livecare/start_call_req.dart'; import 'package:doctor_app_flutter/models/livecare/start_call_res.dart'; import 'package:doctor_app_flutter/models/livecare/transfer_to_admin.dart'; import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; -import 'package:doctor_app_flutter/util/helpers.dart'; import 'package:flutter/cupertino.dart'; -import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; -class LiveCareProvider with ChangeNotifier { +//TODO: change it when Live care return back. +class LiveCareViewModel with ChangeNotifier { DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); List liveCarePendingList = []; diff --git a/lib/core/viewModel/medicine_view_model.dart b/lib/core/viewModel/medicine_view_model.dart new file mode 100644 index 00000000..a86f6dfb --- /dev/null +++ b/lib/core/viewModel/medicine_view_model.dart @@ -0,0 +1,32 @@ +import 'package:doctor_app_flutter/core/enum/viewstate.dart'; +import 'package:doctor_app_flutter/core/service/medicine_service.dart'; + +import '../../locator.dart'; +import 'base_view_model.dart'; + +class MedicineViewModel extends BaseViewModel { + MedicineService _medicineService = locator(); + get pharmacyItemsList => _medicineService.pharmacyItemsList; + get pharmaciesList => _medicineService.pharmaciesList; + + + Future getMedicineItem(String itemName) async { + setState(ViewState.Busy); + await _medicineService.getMedicineItem(itemName); + if (_medicineService.hasError) { + error = _medicineService.error; + setState(ViewState.Error); + } else + setState(ViewState.Idle); + } + + Future getPharmaciesList(int itemId) async { + setState(ViewState.Busy); + await _medicineService.getPharmaciesList(itemId); + if (_medicineService.hasError) { + error = _medicineService.error; + setState(ViewState.Error); + } else + setState(ViewState.Idle); + } +} diff --git a/lib/core/viewModel/patient_view_model.dart b/lib/core/viewModel/patient_view_model.dart new file mode 100644 index 00000000..f39a3d48 --- /dev/null +++ b/lib/core/viewModel/patient_view_model.dart @@ -0,0 +1,244 @@ +import 'package:doctor_app_flutter/core/enum/viewstate.dart'; +import 'package:doctor_app_flutter/core/service/patient_service.dart'; +import 'package:doctor_app_flutter/models/patient/lab_orders/lab_orders_res_model.dart'; +import 'package:doctor_app_flutter/models/patient/lab_result/lab_result.dart'; +import 'package:doctor_app_flutter/models/patient/patient_model.dart'; +import 'package:doctor_app_flutter/models/patient/prescription/prescription_report.dart'; +import 'package:doctor_app_flutter/models/patient/prescription/prescription_report_for_in_patient.dart'; +import 'package:doctor_app_flutter/models/patient/prescription/prescription_res_model.dart'; +import 'package:doctor_app_flutter/models/patient/radiology/radiology_res_model.dart'; +import 'package:doctor_app_flutter/models/patient/vital_sign/vital_sign_res_model.dart'; + +import '../../locator.dart'; +import 'base_view_model.dart'; + +class PatientViewModel extends BaseViewModel { + PatientService _patientService = locator(); + + List get patientVitalSignList => + _patientService.patientVitalSignList; + + List get patientVitalSignOrderdSubList => + _patientService.patientVitalSignOrderdSubList; + + List get patientLabResultOrdersList => + _patientService.patientLabResultOrdersList; + + List get patientPrescriptionsList => + _patientService.patientPrescriptionsList; + + List get prescriptionReportForInPatientList => + _patientService.prescriptionReportForInPatientList; + + List get prescriptionReport => + _patientService.prescriptionReport; + + List get patientRadiologyList => + _patientService.patientRadiologyList; + + List get labResultList => _patientService.labResultList; + + get insuranceApporvalsList => _patientService.insuranceApporvalsList; + + get patientProgressNoteList => _patientService.patientProgressNoteList; + + get clinicsList => _patientService.clinicsList; + get doctorsList => _patientService.doctorsList; + + get referalFrequancyList => _patientService.referalFrequancyList; + Future getPatientList(PatientModel patient, patientType, + {bool isBusyLocal = false}) async { + if(isBusyLocal) { + setState(ViewState.BusyLocal); + } else { + setState(ViewState.Busy); + } + return _patientService.getPatientList(patient, patientType); + if (_patientService.hasError) { + error = _patientService.error; + if(isBusyLocal) { + setState(ViewState.ErrorLocal); + } else { + setState(ViewState.Error); + } } else + setState(ViewState.Idle); + } + + Future getPatientVitalSign(patient) async { + setState(ViewState.Busy); + await _patientService.getPatientVitalSign(patient); + if (_patientService.hasError) { + error = _patientService.error; + setState(ViewState.Error); + } else + setState(ViewState.Idle); + } + + Future getLabResultOrders(patient) async { + setState(ViewState.Busy); + await _patientService.getLabResultOrders(patient); + if (_patientService.hasError) { + error = _patientService.error; + setState(ViewState.Error); + } else + setState(ViewState.Idle); + } + + Future getOutPatientPrescriptions(patient) async { + setState(ViewState.Busy); + await _patientService.getOutPatientPrescriptions(patient); + if (_patientService.hasError) { + error = _patientService.error; + setState(ViewState.Error); + } else + setState(ViewState.Idle); + } + + Future getInPatientPrescriptions(patient) async { + setState(ViewState.Busy); + await _patientService.getInPatientPrescriptions(patient); + if (_patientService.hasError) { + error = _patientService.error; + setState(ViewState.Error); + } else + setState(ViewState.Idle); + } + + Future getPrescriptionReport(patient) async { + setState(ViewState.Busy); + await _patientService.getPrescriptionReport(patient); + if (_patientService.hasError) { + error = _patientService.error; + setState(ViewState.Error); + } else + setState(ViewState.Idle); + } + + Future getPatientRadiology(patient) async { + setState(ViewState.Busy); + await _patientService.getPatientRadiology(patient); + if (_patientService.hasError) { + error = _patientService.error; + setState(ViewState.Error); + } else + setState(ViewState.Idle); + } + + Future getLabResult(LabOrdersResModel labOrdersResModel) async { + setState(ViewState.Busy); + await _patientService.getLabResult(labOrdersResModel); + if (_patientService.hasError) { + error = _patientService.error; + setState(ViewState.Error); + } else + setState(ViewState.Idle); + } + + Future getPatientInsuranceApprovals(patient) async { + setState(ViewState.Busy); + await _patientService.getPatientInsuranceApprovals(patient); + if (_patientService.hasError) { + error = _patientService.error; + setState(ViewState.Error); + } else + setState(ViewState.Idle); + } + + Future getPatientProgressNote(patient) async { + setState(ViewState.Busy); + await _patientService.getPatientProgressNote(patient); + if (_patientService.hasError) { + error = _patientService.error; + setState(ViewState.Error); + } else + setState(ViewState.Idle); + } + + Future getClinicsList() async { + setState(ViewState.Busy); + await _patientService.getClinicsList(); + if (_patientService.hasError) { + error = _patientService.error; + setState(ViewState.Error); + } else { + { + await getReferralFrequancyList(); + setState(ViewState.Idle); + } + } + } + Future getDoctorsList(String clinicId) async { + setState(ViewState.BusyLocal); + await _patientService.getDoctorsList(clinicId); + if (_patientService.hasError) { + error = _patientService.error; + setState(ViewState.ErrorLocal); + } else { + { + await getReferralFrequancyList(); + setState(ViewState.Idle); + } + } + } + + List getDoctorNameList() { + var doctorNamelist = + _patientService.doctorsList.map((value) => value['DoctorName'].toString()).toList(); + return doctorNamelist; + } + + List getClinicNameList() { + var clinicsNameslist = _patientService.clinicsList + .map((value) => value['ClinicDescription'].toString()) + .toList(); + return clinicsNameslist; + } + Future getReferralFrequancyList() async { + setState(ViewState.Busy); + await _patientService.getReferralFrequancyList(); + if (_patientService.hasError) { + error = _patientService.error; + setState(ViewState.Error); + } else + setState(ViewState.Idle); + } + + List getReferralNamesList() { + var referralNamesList = _patientService.referalFrequancyList + .map((value) => value['Description'].toString()) + .toList(); + return referralNamesList; + } + + Future referToDoctor( + {String selectedDoctorID, + String selectedClinicID, + int admissionNo, + String extension, + String priority, + String frequency, + String referringDoctorRemarks, + int patientID, + int patientTypeID, + String roomID, + int projectID}) async { + setState(ViewState.BusyLocal); + await _patientService.referToDoctor( + selectedClinicID: selectedClinicID, + selectedDoctorID: selectedDoctorID, + admissionNo: admissionNo, + extension: extension, + priority: priority, + frequency: frequency, + referringDoctorRemarks: referringDoctorRemarks, + patientID: patientID, + patientTypeID: patientTypeID, + roomID: roomID, + projectID: projectID); + if (_patientService.hasError) { + error = _patientService.error; + setState(ViewState.ErrorLocal); + } else + setState(ViewState.Idle); + } +} diff --git a/lib/providers/project_provider.dart b/lib/core/viewModel/project_view_model.dart similarity index 96% rename from lib/providers/project_provider.dart rename to lib/core/viewModel/project_view_model.dart index db912c3c..a12846c7 100644 --- a/lib/providers/project_provider.dart +++ b/lib/core/viewModel/project_view_model.dart @@ -7,7 +7,7 @@ import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; import 'package:doctor_app_flutter/models/doctor/clinic_model.dart'; import 'package:doctor_app_flutter/models/doctor/doctor_profile_model.dart'; import 'package:doctor_app_flutter/models/doctor/profile_req_Model.dart'; -import 'package:doctor_app_flutter/providers/auth_provider.dart'; +import 'package:doctor_app_flutter/core/viewModel/auth_view_model.dart'; import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; import 'package:doctor_app_flutter/util/helpers.dart'; import 'package:flutter/cupertino.dart'; @@ -121,7 +121,7 @@ class ProjectProvider with ChangeNotifier { tokenID: '', languageID: 2); - Provider.of(AppGlobal.CONTEX, listen: false) + Provider.of(AppGlobal.CONTEX, listen: false) .getDocProfiles(docInfo.toJson()) .then((res) async { sharedPref.setObj(DOCTOR_PROFILE, res['DoctorProfileList'][0]); diff --git a/lib/core/viewModel/referral_view_model.dart b/lib/core/viewModel/referral_view_model.dart index 54c3fd8a..2e99cc3a 100644 --- a/lib/core/viewModel/referral_view_model.dart +++ b/lib/core/viewModel/referral_view_model.dart @@ -1,11 +1,5 @@ import 'package:doctor_app_flutter/core/enum/viewstate.dart'; -import 'package:doctor_app_flutter/core/model/hospitals_model.dart'; -import 'package:doctor_app_flutter/core/service/doctor_reply_service.dart'; -import 'package:doctor_app_flutter/core/service/hospital/hospitals_service.dart'; import 'package:doctor_app_flutter/core/service/referral_patient_service.dart'; -import 'package:doctor_app_flutter/core/service/schedule_service.dart'; -import 'package:doctor_app_flutter/models/doctor/list_doctor_working_hours_table_model.dart'; -import 'package:doctor_app_flutter/models/doctor/list_gt_my_patients_question_model.dart'; import 'package:doctor_app_flutter/models/patient/my_referral/my_referral_patient_model.dart'; import '../../locator.dart'; diff --git a/lib/core/viewModel/referred_view_model.dart b/lib/core/viewModel/referred_view_model.dart index b12241e3..b5e3ecdc 100644 --- a/lib/core/viewModel/referred_view_model.dart +++ b/lib/core/viewModel/referred_view_model.dart @@ -1,13 +1,5 @@ import 'package:doctor_app_flutter/core/enum/viewstate.dart'; -import 'package:doctor_app_flutter/core/model/hospitals_model.dart'; -import 'package:doctor_app_flutter/core/service/doctor_reply_service.dart'; -import 'package:doctor_app_flutter/core/service/hospital/hospitals_service.dart'; -import 'package:doctor_app_flutter/core/service/referral_patient_service.dart'; import 'package:doctor_app_flutter/core/service/referred_patient_service.dart'; -import 'package:doctor_app_flutter/core/service/schedule_service.dart'; -import 'package:doctor_app_flutter/models/doctor/list_doctor_working_hours_table_model.dart'; -import 'package:doctor_app_flutter/models/doctor/list_gt_my_patients_question_model.dart'; -import 'package:doctor_app_flutter/models/patient/my_referral/my_referral_patient_model.dart'; import 'package:doctor_app_flutter/models/patient/my_referral/my_referred_patient_model.dart'; import '../../locator.dart'; diff --git a/lib/core/viewModel/schedule_view_model.dart b/lib/core/viewModel/schedule_view_model.dart index cfaa1be4..8aebc4cb 100644 --- a/lib/core/viewModel/schedule_view_model.dart +++ b/lib/core/viewModel/schedule_view_model.dart @@ -1,10 +1,6 @@ import 'package:doctor_app_flutter/core/enum/viewstate.dart'; -import 'package:doctor_app_flutter/core/model/hospitals_model.dart'; -import 'package:doctor_app_flutter/core/service/doctor_reply_service.dart'; -import 'package:doctor_app_flutter/core/service/hospital/hospitals_service.dart'; import 'package:doctor_app_flutter/core/service/schedule_service.dart'; import 'package:doctor_app_flutter/models/doctor/list_doctor_working_hours_table_model.dart'; -import 'package:doctor_app_flutter/models/doctor/list_gt_my_patients_question_model.dart'; import '../../locator.dart'; import 'base_view_model.dart'; diff --git a/lib/landing_page.dart b/lib/landing_page.dart index f802ddb8..f67957d3 100644 --- a/lib/landing_page.dart +++ b/lib/landing_page.dart @@ -39,8 +39,10 @@ class _LandingPageState extends State { return Scaffold( appBar: AppBar( elevation: 0, - backgroundColor: Hexcolor('#515B5D'), - textTheme: TextTheme(headline6: TextStyle(color: Colors.white)), + backgroundColor: HexColor('#515B5D'), + textTheme: TextTheme( + headline6: + TextStyle(color: Colors.white)), title: Text(getText(currentTab).toUpperCase()), leading: Builder( builder: (BuildContext context) { diff --git a/lib/locator.dart b/lib/locator.dart index 47fce510..550b4666 100644 --- a/lib/locator.dart +++ b/lib/locator.dart @@ -1,12 +1,14 @@ +import 'package:doctor_app_flutter/core/service/patient_service.dart'; +import 'package:doctor_app_flutter/core/viewModel/patient_view_model.dart'; import 'package:get_it/get_it.dart'; import 'core/service/doctor_reply_service.dart'; -import 'core/service/hospital/hospitals_service.dart'; +import 'core/service/medicine_service.dart'; import 'core/service/referral_patient_service.dart'; import 'core/service/referred_patient_service.dart'; import 'core/service/schedule_service.dart'; import 'core/viewModel/doctor_replay_view_model.dart'; -import 'core/viewModel/hospital_view_model.dart'; +import 'core/viewModel/medicine_view_model.dart'; import 'core/viewModel/referral_view_model.dart'; import 'core/viewModel/referred_view_model.dart'; import 'core/viewModel/schedule_view_model.dart'; @@ -16,16 +18,18 @@ GetIt locator = GetIt.instance; ///di void setupLocator() { /// Services - locator.registerLazySingleton(() => HospitalService()); locator.registerLazySingleton(() => DoctorReplyService()); locator.registerLazySingleton(() => ScheduleService()); locator.registerLazySingleton(() => ReferralPatientService()); locator.registerLazySingleton(() => ReferredPatientService()); + locator.registerLazySingleton(() => MedicineService()); + locator.registerLazySingleton(() => PatientService()); /// View Model - locator.registerFactory(() => HospitalViewModel()); locator.registerFactory(() => DoctorReplayViewModel()); locator.registerFactory(() => ScheduleViewModel()); locator.registerFactory(() => ReferralPatientViewModel()); locator.registerFactory(() => ReferredPatientViewModel()); + locator.registerFactory(() => MedicineViewModel()); + locator.registerFactory(() => PatientViewModel()); } diff --git a/lib/main.dart b/lib/main.dart index 3b32e732..06d0ecfa 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,6 +1,5 @@ -import 'package:doctor_app_flutter/providers/livecare_provider.dart'; -import 'package:doctor_app_flutter/providers/medicine_provider.dart'; -import 'package:doctor_app_flutter/providers/project_provider.dart'; +import 'package:doctor_app_flutter/core/viewModel/livecare_view_model.dart'; +import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:flutter/material.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; @@ -8,9 +7,8 @@ import 'package:hexcolor/hexcolor.dart'; import 'package:provider/provider.dart'; import './config/size_config.dart'; -import './providers/auth_provider.dart'; -import './providers/patients_provider.dart'; -import './providers/hospital_provider.dart'; +import 'core/viewModel/auth_view_model.dart'; +import 'core/viewModel/hospital_view_model.dart'; import './routes.dart'; import 'config/config.dart'; import 'locator.dart'; @@ -31,19 +29,16 @@ class MyApp extends StatelessWidget { SizeConfig().init(constraints, orientation); return MultiProvider( providers: [ - ChangeNotifierProvider( - create: (context) => PatientsProvider()), - ChangeNotifierProvider( - create: (context) => AuthProvider()), - ChangeNotifierProvider( - create: (context) => HospitalProvider()), + ChangeNotifierProvider( + create: (context) => AuthViewModel()), + ChangeNotifierProvider( + create: (context) => HospitalViewModel()), ChangeNotifierProvider( create: (context) => ProjectProvider(), ), - ChangeNotifierProvider( - create: (context) => LiveCareProvider(), + ChangeNotifierProvider( + create: (context) => LiveCareViewModel(), ), - ChangeNotifierProvider(create: (context) => MedicineProvider(),), ], child: Consumer( builder: (context,projectProvider,child) => MaterialApp( @@ -62,7 +57,7 @@ class MyApp extends StatelessWidget { theme: ThemeData( primarySwatch: Colors.grey, primaryColor: Colors.grey, - buttonColor: Hexcolor('#B8382C'), + buttonColor: HexColor('#B8382C'), fontFamily: 'WorkSans', dividerColor: Colors.grey[350], backgroundColor: Color.fromRGBO(255,255,255, 1) diff --git a/lib/providers/hospital_provider.dart b/lib/providers/hospital_provider.dart deleted file mode 100644 index 3b1c7d03..00000000 --- a/lib/providers/hospital_provider.dart +++ /dev/null @@ -1,29 +0,0 @@ -import 'package:doctor_app_flutter/client/base_app_client.dart'; -import 'package:doctor_app_flutter/config/config.dart'; -import 'package:flutter/cupertino.dart'; - -class HospitalProvider with ChangeNotifier { - BaseAppClient baseAppClient = BaseAppClient(); - - Future getProjectsList() async { - const url = GET_PROJECTS; - var info = { - "LanguageID": 1, - "stamp": "2020-02-26T13:51:44.111Z", - "IPAdress": "11.11.11.11", - "VersionID": 1.2, - "Channel": 9, - "TokenID": "", - "SessionID": "i1UJwCTSqt", - "IsLoginForDoctorApp": true - }; - dynamic localRes; - - await baseAppClient.post(url, onSuccess: (response, statusCode) async { - localRes = response; - }, onFailure: (String error, int statusCode) { - throw error; - }, body: info); - return Future.value(localRes); - } -} diff --git a/lib/providers/medicine_provider.dart b/lib/providers/medicine_provider.dart deleted file mode 100644 index 99674f18..00000000 --- a/lib/providers/medicine_provider.dart +++ /dev/null @@ -1,78 +0,0 @@ -import 'package:doctor_app_flutter/client/base_app_client.dart'; -import 'package:doctor_app_flutter/config/config.dart'; -import 'package:doctor_app_flutter/models/pharmacies/pharmacies_List_request_model.dart'; -import 'package:doctor_app_flutter/models/pharmacies/pharmacies_items_request_model.dart'; -import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; -import 'package:flutter/cupertino.dart'; - -class MedicineProvider with ChangeNotifier { - DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); - - var pharmacyItemsList = []; - var pharmaciesList = []; - bool isFinished = true; - bool hasError = false; - String errorMsg = ''; - BaseAppClient baseAppClient = BaseAppClient(); - - PharmaciesItemsRequestModel _itemsRequestModel = - PharmaciesItemsRequestModel(); - PharmaciesListRequestModel _listRequestModel = PharmaciesListRequestModel(); - - clearPharmacyItemsList() { - pharmacyItemsList.clear(); - notifyListeners(); - } - - getMedicineItem(String itemName) async { - _itemsRequestModel.pHRItemName = itemName; - resetDefaultValues(); - pharmacyItemsList.clear(); - notifyListeners(); - try { - await baseAppClient.post(PHARMACY_ITEMS_URL, - onSuccess: (dynamic response, int statusCode) { - pharmacyItemsList = response['ListPharmcy_Region_enh']; - hasError = false; - isFinished = true; - errorMsg = "Done"; - }, onFailure: (String error, int statusCode) { - isFinished = true; - hasError = true; - errorMsg = error; - }, body: _itemsRequestModel.toJson()); - notifyListeners(); - } catch (error) { - throw error; - } - } - - getPharmaciesList(int itemId) async { - resetDefaultValues(); - try { - _listRequestModel.itemID = itemId; - isFinished = false; - await baseAppClient.post(PHARMACY_LIST_URL, - onSuccess: (dynamic response, int statusCode) { - pharmaciesList = response['PharmList']; - hasError = false; - isFinished = true; - errorMsg = "Done"; - }, onFailure: (String error, int statusCode) { - isFinished = true; - hasError = true; - errorMsg = error; - }, body: _listRequestModel.toJson()); - notifyListeners(); - } catch (error) { - throw error; - } - } - - resetDefaultValues() { - isFinished = false; - hasError = false; - errorMsg = ''; - notifyListeners(); - } -} diff --git a/lib/providers/patients_provider.dart b/lib/providers/patients_provider.dart deleted file mode 100644 index ace7cd1a..00000000 --- a/lib/providers/patients_provider.dart +++ /dev/null @@ -1,542 +0,0 @@ -import 'dart:convert'; - -import 'package:doctor_app_flutter/client/base_app_client.dart'; -import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; -import 'package:doctor_app_flutter/models/doctor/doctor_profile_model.dart'; -import 'package:doctor_app_flutter/models/patient/get_clinic_by_project_id_request.dart'; -import 'package:doctor_app_flutter/models/patient/get_doctor_by_clinic_id_request.dart'; -import 'package:doctor_app_flutter/models/patient/get_list_stp_referral_frequency_request.dart'; -import 'package:doctor_app_flutter/models/patient/lab_orders/lab_orders_res_model.dart'; -import 'package:doctor_app_flutter/models/patient/lab_result/lab_result.dart'; -import 'package:doctor_app_flutter/models/patient/lab_result/lab_result_req_model.dart'; -import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; -import 'package:doctor_app_flutter/models/patient/prescription/prescription_report_for_in_patient.dart'; -import 'package:doctor_app_flutter/models/patient/prescription/prescription_res_model.dart'; -import 'package:doctor_app_flutter/models/patient/radiology/radiology_res_model.dart'; -import 'package:doctor_app_flutter/models/patient/refer_to_doctor_request.dart'; -import 'package:doctor_app_flutter/models/patient/prescription/prescription_report.dart'; -import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; -import 'package:flutter/cupertino.dart'; - -import '../config/config.dart'; -import '../models/patient/lab_orders/lab_orders_res_model.dart'; -import '../models/patient/patiant_info_model.dart'; -import '../models/patient/patient_model.dart'; -import '../models/patient/prescription/prescription_res_model.dart'; -import '../models/patient/radiology/radiology_res_model.dart'; -import '../models/patient/vital_sign/vital_sign_res_model.dart'; -import '../util/helpers.dart'; - -Helpers helpers = Helpers(); -DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); - -class PatientsProvider with ChangeNotifier { - bool isLoading = false; - bool isError = false; - String error = ''; - List patientVitalSignList = []; - List patientVitalSignOrderdSubList = []; - List patientLabResultOrdersList = []; - List patientPrescriptionsList = []; - List patientRadiologyList = []; - List prescriptionReportForInPatientList = []; - List prescriptionReport = []; - BaseAppClient baseAppClient = BaseAppClient(); - - /*@author: ibrahe albitar - *@Date:2/6/2020 - *@desc: getPatientPrescriptions - */ - - List labResultList = []; - - var patientProgressNoteList = []; - var insuranceApporvalsList = []; - - var doctorsList = []; - var clinicsList = []; - var referalFrequancyList = []; - - DoctorsByClinicIdRequest _doctorsByClinicIdRequest = - DoctorsByClinicIdRequest(); - STPReferralFrequencyRequest _referralFrequencyRequest = - STPReferralFrequencyRequest(); - ClinicByProjectIdRequest _clinicByProjectIdRequest = - ClinicByProjectIdRequest(); - ReferToDoctorRequest _referToDoctorRequest; - - PatiantInformtion _selectedPatient; - - Future getPatientList(PatientModel patient, patientType) async { - int val = int.parse(patientType); - - try { - dynamic localRes; - await baseAppClient.post(GET_PATIENT + SERVICES_PATIANT[val], - onSuccess: (dynamic response, int statusCode) { - localRes = response; - }, onFailure: (String error, int statusCode) { - throw error; - }, body: { - "ProjectID": patient.ProjectID, - "ClinicID": patient.ClinicID, - "DoctorID": patient.DoctorID, - "FirstName": patient.FirstName, - "MiddleName": patient.MiddleName, - "LastName": patient.LastName, - "PatientMobileNumber": patient.PatientMobileNumber, - "PatientIdentificationID": patient.PatientIdentificationID, - "PatientID": patient.PatientID, - "From": patient.From, - "To": patient.To, - "LanguageID": patient.LanguageID, - "stamp": patient.stamp, - "IPAdress": patient.IPAdress, - "VersionID": patient.VersionID, - "Channel": patient.Channel, - "TokenID": patient.TokenID, - "SessionID": patient.SessionID, - "IsLoginForDoctorApp": patient.IsLoginForDoctorApp, - "PatientOutSA": patient.PatientOutSA - }); - - return Future.value(localRes); - } catch (error) { - print(error); - throw error; - } - } - - setBasicData() { - isLoading = true; - isError = false; - error = ''; - notifyListeners(); - } - -/* - *@author: Elham Rababah - *@Date:27/4/2020 - *@param: patient - *@return: - *@desc: getPatientVitalSign - */ - getPatientVitalSign(patient) async { - setBasicData(); - - try { - await baseAppClient.post(GET_PATIENT_VITAL_SIGN, - onSuccess: (dynamic response, int statusCode) { - patientVitalSignList = []; - response['List_DoctorPatientVitalSign'].forEach((v) { - patientVitalSignList.add(new VitalSignResModel.fromJson(v)); - }); - - if (patientVitalSignList.length > 0) { - List patientVitalSignOrderdSubListTemp = []; - patientVitalSignOrderdSubListTemp = patientVitalSignList; - patientVitalSignOrderdSubListTemp - .sort((VitalSignResModel a, VitalSignResModel b) { - return b.vitalSignDate.microsecondsSinceEpoch - - a.vitalSignDate.microsecondsSinceEpoch; - }); - patientVitalSignOrderdSubList.clear(); - int length = patientVitalSignOrderdSubListTemp.length >= 20 - ? 20 - : patientVitalSignOrderdSubListTemp.length; - for (int x = 0; x < length; x++) { - patientVitalSignOrderdSubList - .add(patientVitalSignOrderdSubListTemp[x]); - } - } - isLoading = false; - isError = false; - this.error = ''; - }, onFailure: (String error, int statusCode) { - isLoading = false; - isError = true; - this.error = error; - }, body: patient); - notifyListeners(); - } catch (err) { - handelCatchErrorCase(err); - } - } - -/*@author: Elham Rababah - *@Date:27/4/2020 - *@param: patient - *@return: - *@desc: getLabResult Orders - */ - getLabResultOrders(patient) async { - // isLoading = true; - // notifyListeners(); - setBasicData(); - - try { - await baseAppClient.post(GET_PATIENT_LAB_OREDERS, - onSuccess: (dynamic response, int statusCode) { - patientLabResultOrdersList = []; - response['List_GetLabOreders'].forEach((v) { - patientLabResultOrdersList.add(new LabOrdersResModel.fromJson(v)); - }); - isLoading = false; - isError = false; - this.error = ''; - }, onFailure: (String error, int statusCode) { - isLoading = false; - isError = true; - this.error = error; - }, body: patient); - notifyListeners(); - } catch (err) { - handelCatchErrorCase(err); - } - } - -/*@author: Elham Rababah - *@Date:3/5/2020 - *@param: patient - *@return: - *@desc: geOutPatientPrescriptions - */ - getOutPatientPrescriptions(patient) async { - setBasicData(); - try { - await baseAppClient.post(GET_PRESCRIPTION, - onSuccess: (dynamic response, int statusCode) { - patientPrescriptionsList = []; - response['PatientPrescriptionList'].forEach((v) { - patientPrescriptionsList.add(new PrescriptionResModel.fromJson(v)); - }); - isLoading = false; - isError = false; - this.error = ''; - }, onFailure: (String error, int statusCode) { - isLoading = false; - isError = true; - this.error = error; - }, body: patient); - notifyListeners(); - } catch (err) { - handelCatchErrorCase(err); - } - } - - /*@author: Mohammad Aljammal - *@Date:4/6/2020 - *@param: patient - *@return: - *@desc: getInPatientPrescriptions - */ - getInPatientPrescriptions(patient) async { - setBasicData(); - try { - prescriptionReportForInPatientList = []; - notifyListeners(); - await baseAppClient.post(GET_PRESCRIPTION_REPORT_FOR_IN_PATIENT, - onSuccess: (dynamic response, int statusCode) { - response['List_PrescriptionReportForInPatient'].forEach((v) { - prescriptionReportForInPatientList - .add(PrescriptionReportForInPatient.fromJson(v)); - }); - isError = false; - isLoading = false; - }, onFailure: (String error, int statusCode) { - isError = true; - isLoading = false; - this.error = error; - }, body: patient); - notifyListeners(); - } catch (err) { - handelCatchErrorCase(err); - } - } - - getPrescriptionReport(prescriptionReqModel) async { - prescriptionReport = []; - isLoading = true; - isError = false; - error = ""; - notifyListeners(); - await baseAppClient.post(GET_PRESCRIPTION_REPORT, - onSuccess: (dynamic response, int statusCode) { - response['ListPRM'].forEach((v) { - prescriptionReport.add(PrescriptionReport.fromJson(v)); - }); - isError = false; - isLoading = false; - }, onFailure: (String error, int statusCode) { - isError = true; - isLoading = false; - this.error = error; - }, body: prescriptionReqModel); - notifyListeners(); - } - - /*@author: Elham Rababah - *@Date:12/5/2020 - *@param: patient - *@return: - *@desc: getPatientRadiology - */ - handelCatchErrorCase(err) { - isLoading = false; - isError = true; - error = helpers.generateContactAdminMsg(err); - notifyListeners(); - throw err; - } - -/*@author: Elham Rababah - *@Date:3/5/2020 - *@param: patient - *@return: - *@desc: getPatientRadiology - */ - getPatientRadiology(patient) async { - // isLoading = true; - // notifyListeners(); - setBasicData(); - try { - await baseAppClient.post(GET_RADIOLOGY, - onSuccess: (dynamic response, int statusCode) { - patientRadiologyList = []; - response['List_GetRadOreders'].forEach((v) { - patientRadiologyList.add(new RadiologyResModel.fromJson(v)); - }); - isLoading = false; - isError = false; - this.error = ''; - }, onFailure: (String error, int statusCode) { - isLoading = false; - isError = true; - this.error = error; - }, body: patient); - notifyListeners(); - } catch (err) { - handelCatchErrorCase(err); - } - } - - getLabResult(LabOrdersResModel labOrdersResModel) async { - labResultList.clear(); - isLoading = true; - notifyListeners(); - RequestLabResult requestLabResult = RequestLabResult(); - requestLabResult.sessionID = labOrdersResModel.setupID; - requestLabResult.orderNo = labOrdersResModel.orderNo; - requestLabResult.invoiceNo = labOrdersResModel.invoiceNo; - requestLabResult.patientTypeID = labOrdersResModel.patientType; - await baseAppClient.post(GET_PATIENT_LAB_RESULTS, - onSuccess: (dynamic response, int statusCode) { - isError = false; - isLoading = false; - response['List_GetLabNormal'].forEach((v) { - labResultList.add(new LabResult.fromJson(v)); - }); - }, onFailure: (String error, int statusCode) { - isError = true; - isLoading = false; - this.error = error; - }, body: requestLabResult.toJson()); - notifyListeners(); - } - - getPatientInsuranceApprovals(patient) async { - setBasicData(); - try { - await baseAppClient.post(PATIENT_INSURANCE_APPROVALS_URL, - onSuccess: (dynamic response, int statusCode) { - insuranceApporvalsList = response['List_ApprovalMain_InPatient']; - isLoading = false; - isError = false; - this.error = ''; - }, onFailure: (String error, int statusCode) { - isLoading = false; - isError = true; - this.error = error; - }, body: patient); - notifyListeners(); - } catch (err) { - handelCatchErrorCase(err); - } - } - -/*@author: ibrahe albitar - *@Date:2/6/2020 - *@desc: getPatientProgressNote - */ - getPatientProgressNote(patient) async { - setBasicData(); - try { - await baseAppClient.post(PATIENT_PROGRESS_NOTE_URL, - onSuccess: (dynamic response, int statusCode) { - patientProgressNoteList = response['List_GetPregressNoteForInPatient']; - isLoading = false; - isError = false; - this.error = ''; - }, onFailure: (String error, int statusCode) { - isLoading = false; - isError = true; - this.error = error; - }, body: patient); - notifyListeners(); - } catch (err) { - handelCatchErrorCase(err); - } - } - - /*@author: ibrahem albitar - *@Date:3/6/2020 - *@desc: getDoctorsList - */ - getDoctorsList(String clinicId) async { - setBasicData(); - try { - _doctorsByClinicIdRequest.clinicID = clinicId; - await baseAppClient.post(PATIENT_GET_DOCTOR_BY_CLINIC_URL, - onSuccess: (dynamic response, int statusCode) { - doctorsList = response['List_Doctors_All']; - isLoading = false; - isError = false; - this.error = ''; - }, onFailure: (String error, int statusCode) { - isLoading = false; - isError = true; - this.error = error; - }, body: _doctorsByClinicIdRequest.toJson()); - notifyListeners(); - } catch (err) { - handelCatchErrorCase(err); - } - } - - List getDoctorNameList() { - var doctorNamelist = - doctorsList.map((value) => value['DoctorName'].toString()).toList(); - return doctorNamelist; - } - - /*@author: ibrahem albitar - *@Date:3/6/2020 - *@desc: getClinicsList - */ - getClinicsList() async { - setBasicData(); - try { - await baseAppClient.post(PATIENT_GET_CLINIC_BY_PROJECT_URL, - onSuccess: (dynamic response, int statusCode) { - clinicsList = response['List_Clinic_All']; - isLoading = false; - isError = false; - this.error = ''; - }, onFailure: (String error, int statusCode) { - isLoading = false; - isError = true; - this.error = error; - }, body: _clinicByProjectIdRequest.toJson()); - notifyListeners(); - } catch (err) { - handelCatchErrorCase(err); - } - } - - List getClinicNameList() { - var clinicsNameslist = clinicsList - .map((value) => value['ClinicDescription'].toString()) - .toList(); - return clinicsNameslist; - } - - /*@author: ibrahem albitar - *@Date:3/6/2020 - *@desc: getReferralFrequancyList - */ - getReferralFrequancyList() async { - setBasicData(); - try { - await baseAppClient.post(PATIENT_GET_LIST_REFERAL_URL, - onSuccess: (dynamic response, int statusCode) { - referalFrequancyList = response['list_STPReferralFrequency']; - isLoading = false; - isError = false; - this.error = ''; - }, onFailure: (String error, int statusCode) { - isLoading = false; - isError = true; - this.error = error; - }, body: _referralFrequencyRequest.toJson()); - notifyListeners(); - } catch (err) { - handelCatchErrorCase(err); - } - } - - List getReferralNamesList() { - var referralNamesList = referalFrequancyList - .map((value) => value['Description'].toString()) - .toList(); - return referralNamesList; - } - - /*@author: ibrahem albitar - *@Date:3/6/2020 - *@desc: referToDoctor - */ - referToDoctor(context, - {String selectedDoctorID, - String selectedClinicID, - int admissionNo, - String extension, - String priority, - String frequency, - String referringDoctorRemarks, - int patientID, - int patientTypeID, - String roomID, - int projectID}) async { - setBasicData(); - try { - String token = await sharedPref.getString(TOKEN); - Map profile = await sharedPref.getObj(DOCTOR_PROFILE); - DoctorProfileModel doctorProfile = - new DoctorProfileModel.fromJson(profile); - int doctorID = doctorProfile.doctorID; - int clinicId = doctorProfile.clinicID; - _referToDoctorRequest = ReferToDoctorRequest( - projectID: projectID, - admissionNo: admissionNo, - roomID: roomID, - referralClinic: selectedClinicID.toString(), - referralDoctor: selectedDoctorID.toString(), - createdBy: doctorID, - editedBy: doctorID, - patientID: patientID, - patientTypeID: patientTypeID, - referringClinic: clinicId, - referringDoctor: doctorID, - referringDoctorRemarks: referringDoctorRemarks, - priority: priority, - frequency: frequency, - extension: extension, - tokenID: token); - await baseAppClient.post(PATIENT_REFER_TO_DOCTOR_URL, - onSuccess: (dynamic response, int statusCode) { - // print('Done : \n $res'); - Navigator.pop(context); - }, - onFailure: (String error, int statusCode) { - isLoading = false; - isError = true; - this.error = error; - }, - body: _referToDoctorRequest.toJson()); - notifyListeners(); - - } catch (err) { - handelCatchErrorCase(err); - } - } -} diff --git a/lib/root_page.dart b/lib/root_page.dart index e361e42c..fe35a246 100644 --- a/lib/root_page.dart +++ b/lib/root_page.dart @@ -1,4 +1,4 @@ -import 'package:doctor_app_flutter/providers/auth_provider.dart'; +import 'package:doctor_app_flutter/core/viewModel/auth_view_model.dart'; import 'package:doctor_app_flutter/screens/auth/login_screen.dart'; import 'package:doctor_app_flutter/widgets/shared/dr_app_circular_progress_Indeicator.dart'; import 'package:flutter/cupertino.dart'; @@ -11,7 +11,7 @@ import 'landing_page.dart'; class RootPage extends StatelessWidget { @override Widget build(BuildContext context) { - AuthProvider authProvider = Provider.of(context); + AuthViewModel authProvider = Provider.of(context); Widget buildRoot() { switch (authProvider.stutas) { case APP_STATUS.LOADING: diff --git a/lib/routes.dart b/lib/routes.dart index d820e83e..dff02129 100644 --- a/lib/routes.dart +++ b/lib/routes.dart @@ -32,7 +32,6 @@ import './screens/patients/profile/progress_note_screen.dart'; import './screens/patients/profile/radiology/radiology_screen.dart'; import './screens/patients/profile/vital_sign/vital_sign_details_screen.dart'; import './screens/patients/profile/vital_sign/vital_sign_item_details_screen.dart'; -import './screens/patients/profile/vital_sign/vital_sign_screen.dart'; import './screens/profile_screen.dart'; import './screens/settings/settings_screen.dart'; import 'landing_page.dart'; @@ -96,7 +95,6 @@ var routes = { PHARMACIES_LIST: (_) => PharmaciesListScreen( itemID: null, ), - VITAL_SIGN: (_) => VitalSignScreen(), MESSAGES: (_) => MessagesScreen(), SERVICES: (_) => ServicesScreen(), LAB_ORDERS: (_) => LabOrdersScreen(), diff --git a/lib/screens/QR_reader_screen.dart b/lib/screens/QR_reader_screen.dart index 28c6702a..825abb83 100644 --- a/lib/screens/QR_reader_screen.dart +++ b/lib/screens/QR_reader_screen.dart @@ -1,23 +1,23 @@ import 'package:barcode_scan/platform_wrapper.dart'; import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; import 'package:doctor_app_flutter/config/size_config.dart'; -import 'package:doctor_app_flutter/models/doctor/doctor_profile_model.dart'; +import 'package:doctor_app_flutter/core/viewModel/patient_view_model.dart'; import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/models/patient/patient_model.dart'; import 'package:doctor_app_flutter/models/patient/topten_users_res_model.dart'; -import 'package:doctor_app_flutter/providers/patients_provider.dart'; import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; import 'package:doctor_app_flutter/util/dr_app_toast_msg.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_button.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/card_with_bg_widget.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; -import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import '../routes.dart'; +import 'base/base_view.dart'; +Helpers helpers = Helpers(); class QrReaderScreen extends StatefulWidget { @override @@ -55,18 +55,22 @@ class _QrReaderScreenState extends State { @override Widget build(BuildContext context) { - return AppScaffold( - appBarTitle: TranslationBase.of(context).qr+ TranslationBase.of(context).reader, - body: Center( - child: Container( - margin: EdgeInsets.only(top: SizeConfig.realScreenHeight / 7), - child: FractionallySizedBox( - widthFactor: 0.9, - child: ListView( - children: [ - AppText( - TranslationBase.of(context).startScanning, - fontSize: 18, + return BaseView( + onModelReady: (model) => model.getClinicsList(), + builder: (_, model, w) => AppScaffold( + baseViewModel: model, + appBarTitle: + TranslationBase.of(context).qr + TranslationBase.of(context).reader, + body: Center( + child: Container( + margin: EdgeInsets.only(top: SizeConfig.realScreenHeight / 7), + child: FractionallySizedBox( + widthFactor: 0.9, + child: ListView( + children: [ + AppText( + TranslationBase.of(context).startScanning, + fontSize: 18, fontWeight: FontWeight.bold, textAlign: TextAlign.center, ), @@ -89,7 +93,7 @@ class _QrReaderScreenState extends State { ), Button( onTap: () { - _scanQrAndGetPatient(context); + _scanQrAndGetPatient(context, model); }, title: TranslationBase.of(context).scanQr, loading: isLoading, @@ -111,20 +115,22 @@ class _QrReaderScreenState extends State { error ?? TranslationBase.of(context) .errorMessage, - color: Theme.of(context).errorColor)), + color: Theme + .of(context) + .errorColor)), ], ), - ) + ) : Container(), - ], + ], + ), + ), + ), ), - ), - ), - ), - ); + ),); } - _scanQrAndGetPatient(BuildContext context) async { + _scanQrAndGetPatient(BuildContext context, PatientViewModel model) async { /// When give qr we will change this method to get data /// var result = await BarcodeScanner.scan(); /// int patientID = get from qr result @@ -148,8 +154,8 @@ class _QrReaderScreenState extends State { // Provider.of(context, listen: false); patient.PatientID = 8808; patient.TokenID = token; - Provider.of(context, listen: false) - .getPatientList(patient, "1") + model + .getPatientList(patient, "1", isBusyLocal: true) .then((response) { if (response['MessageStatus'] == 1) { switch (patientType) { diff --git a/lib/screens/dashboard_screen.dart b/lib/screens/dashboard_screen.dart index bb1f8252..80697352 100644 --- a/lib/screens/dashboard_screen.dart +++ b/lib/screens/dashboard_screen.dart @@ -4,10 +4,9 @@ import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart'; import 'package:doctor_app_flutter/models/doctor/clinic_model.dart'; import 'package:doctor_app_flutter/models/doctor/doctor_profile_model.dart'; import 'package:doctor_app_flutter/models/doctor/profile_req_Model.dart'; -import 'package:doctor_app_flutter/providers/auth_provider.dart'; -import 'package:doctor_app_flutter/providers/hospital_provider.dart'; -import 'package:doctor_app_flutter/providers/medicine_provider.dart'; -import 'package:doctor_app_flutter/providers/project_provider.dart'; +import 'package:doctor_app_flutter/core/viewModel/auth_view_model.dart'; +import 'package:doctor_app_flutter/core/viewModel/hospital_view_model.dart'; +import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; import 'package:doctor_app_flutter/util/helpers.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; @@ -39,8 +38,8 @@ class DashboardScreen extends StatefulWidget { } class _DashboardScreenState extends State { - HospitalProvider hospitalProvider; - AuthProvider authProvider; + HospitalViewModel hospitalProvider; + AuthViewModel authProvider; bool isLoading = false; ProjectProvider projectsProvider; var _isInit = true; @@ -83,7 +82,7 @@ class _DashboardScreenState extends State { children: [ Container( height: 140, - color: Hexcolor('#515B5D'), + color: HexColor('#515B5D'), width: double.infinity, child: FractionallySizedBox( widthFactor: 0.9, @@ -222,7 +221,7 @@ class _DashboardScreenState extends State { bottom: 19, child: Container( decoration: BoxDecoration( - color: Hexcolor("#DED8CF"), + color: HexColor("#DED8CF"), borderRadius: BorderRadius.all( Radius.circular(10.0), ), @@ -250,20 +249,20 @@ class _DashboardScreenState extends State { AppText("38", fontSize: SizeConfig.textMultiplier * 3.7, - color: Hexcolor('#5D4C35'), + color: HexColor('#5D4C35'), fontWeight: FontWeight.bold,), AppText(TranslationBase .of(context) .outPatients, fontWeight: FontWeight.normal, fontSize: SizeConfig.textMultiplier * 1.4, - color: Hexcolor('#5D4C35'), + color: HexColor('#5D4C35'), ), ], ), circularStrokeCap: CircularStrokeCap.butt, backgroundColor: Colors.blueGrey[100], - progressColor: Hexcolor('#B8382C'), + progressColor: HexColor('#B8382C'), ), ), Container( @@ -277,7 +276,7 @@ class _DashboardScreenState extends State { border: TableBorder.symmetric( inside: BorderSide( width: 0.5, - color: Hexcolor('#5D4C35'), + color: HexColor('#5D4C35'), ), ), children: [ @@ -291,13 +290,13 @@ class _DashboardScreenState extends State { TranslationBase.of(context).arrived, fontSize: SizeConfig.textMultiplier * 1.5, - color: Hexcolor('#5D4C35'), + color: HexColor('#5D4C35'), ), AppText( "23", fontSize: SizeConfig.textMultiplier * 2.7, - color: Hexcolor('#5D4C35'), + color: HexColor('#5D4C35'), fontWeight: FontWeight.bold, ), SizedBox( @@ -313,13 +312,13 @@ class _DashboardScreenState extends State { TranslationBase.of(context).er, fontSize: SizeConfig.textMultiplier * 1.5, - color: Hexcolor('#5D4C35'), + color: HexColor('#5D4C35'), ), AppText( "03", fontSize: SizeConfig.textMultiplier * 2.7, - color: Hexcolor('#5D4C35'), + color: HexColor('#5D4C35'), fontWeight: FontWeight.bold, ), SizedBox( @@ -342,13 +341,13 @@ class _DashboardScreenState extends State { TranslationBase.of(context).notArrived, fontSize: SizeConfig.textMultiplier * 1.5, - color: Hexcolor('#5D4C35'), + color: HexColor('#5D4C35'), ), AppText( "15", fontSize: SizeConfig.textMultiplier * 2.7, - color: Hexcolor('#5D4C35'), + color: HexColor('#5D4C35'), fontWeight: FontWeight.bold, ), ], @@ -364,13 +363,13 @@ class _DashboardScreenState extends State { TranslationBase.of(context).walkIn, fontSize: SizeConfig.textMultiplier * 1.5, - color: Hexcolor('#5D4C35'), + color: HexColor('#5D4C35'), ), AppText( "04", fontSize: SizeConfig.textMultiplier * 2.7, - color: Hexcolor('#5D4C35'), + color: HexColor('#5D4C35'), fontWeight: FontWeight.bold, ), ], @@ -554,7 +553,7 @@ class _DashboardScreenState extends State { ), ), imageName: '4.png', - color: Hexcolor('#B8382C'), + color: HexColor('#B8382C'), hasBorder: false, width: MediaQuery .of(context) @@ -608,7 +607,7 @@ class _DashboardScreenState extends State { ), ), imageName: '5.png', - color: Hexcolor('#B8382C'), + color: HexColor('#B8382C'), hasBorder: false, width: MediaQuery .of(context) @@ -744,10 +743,7 @@ class _DashboardScreenState extends State { context, MaterialPageRoute( builder: (context) => - ChangeNotifierProvider( - create: (_) => MedicineProvider(), - child: MedicineSearchScreen(), - ), + MedicineSearchScreen(), ), ); }, @@ -1015,7 +1011,7 @@ class DashboardItem extends StatelessWidget { .height * 0.35, decoration: BoxDecoration( - color: !hasBorder ? color != null ? color : Hexcolor('#050705') + color: !hasBorder ? color != null ? color : HexColor('#050705') .withOpacity(opacity) : Colors .white, borderRadius: BorderRadius.circular(6.0), diff --git a/lib/screens/doctor/my_referral_patient_screen.dart b/lib/screens/doctor/my_referral_patient_screen.dart index c29ce606..960bbdd9 100644 --- a/lib/screens/doctor/my_referral_patient_screen.dart +++ b/lib/screens/doctor/my_referral_patient_screen.dart @@ -7,8 +7,14 @@ import 'package:flutter/material.dart'; import '../../widgets/shared/app_scaffold_widget.dart'; -class MyReferralPatient extends StatelessWidget { +class MyReferralPatient extends StatefulWidget { + int expandedItemIndex = -1; + @override + _MyReferralPatientState createState() => _MyReferralPatientState(); +} + +class _MyReferralPatientState extends State { @override Widget build(BuildContext context) { return BaseView( @@ -35,12 +41,28 @@ class MyReferralPatient extends StatelessWidget { ), Container( child: Column( - children: model.listMyReferralPatientModel - .map((item) { - return MyReferralPatientWidget( - myReferralPatientModel: item, model:model - ); - }).toList(), + children: [ + ...List.generate( + model.listMyReferralPatientModel.length, + (index) => MyReferralPatientWidget( + myReferralPatientModel: model + .listMyReferralPatientModel[index], + model: model, + expandClick: () { + setState(() { + if (widget.expandedItemIndex == + index) { + widget.expandedItemIndex = -1; + } else { + widget.expandedItemIndex = index; + } + }); + }, + isExpand: + widget.expandedItemIndex == index, + ), + ) + ], ), ), ], diff --git a/lib/screens/doctor/my_referred_patient_screen.dart b/lib/screens/doctor/my_referred_patient_screen.dart index 5fd18cd0..cd9112e2 100644 --- a/lib/screens/doctor/my_referred_patient_screen.dart +++ b/lib/screens/doctor/my_referred_patient_screen.dart @@ -13,8 +13,8 @@ class MyReferredPatient extends StatelessWidget { Widget build(BuildContext context) { return BaseView( onModelReady: (model) => model.getMyReferredPatient(), - builder: (_, model, w) => AppScaffold( - baseViewModel: model, + builder: (_, model, w) => AppScaffold( + baseViewModel: model, appBarTitle: TranslationBase.of(context).myReferredPatient, body: model.listMyReferredPatientModel.length == 0 ? Center( diff --git a/lib/screens/live_care/panding_list.dart b/lib/screens/live_care/panding_list.dart index a59d7f05..251f9594 100644 --- a/lib/screens/live_care/panding_list.dart +++ b/lib/screens/live_care/panding_list.dart @@ -1,5 +1,5 @@ import 'package:doctor_app_flutter/config/size_config.dart'; -import 'package:doctor_app_flutter/providers/livecare_provider.dart'; +import 'package:doctor_app_flutter/core/viewModel/livecare_view_model.dart'; import 'package:doctor_app_flutter/screens/live_care/video_call.dart'; import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; import 'package:doctor_app_flutter/util/helpers.dart'; @@ -33,12 +33,12 @@ class _LiveCarePandingListState extends State { List _data = []; Helpers helpers = new Helpers(); bool _isInit = true; - LiveCareProvider _liveCareProvider; + LiveCareViewModel _liveCareProvider; @override void didChangeDependencies() { super.didChangeDependencies(); if (_isInit) { - _liveCareProvider = Provider.of(context); + _liveCareProvider = Provider.of(context); pendingList(); } _isInit = false; diff --git a/lib/screens/live_care/video_call.dart b/lib/screens/live_care/video_call.dart index c4c59af1..f6d011a7 100644 --- a/lib/screens/live_care/video_call.dart +++ b/lib/screens/live_care/video_call.dart @@ -3,7 +3,7 @@ import 'dart:async'; import 'package:doctor_app_flutter/models/livecare/get_pending_res_list.dart'; import 'package:doctor_app_flutter/models/livecare/session_status_model.dart'; import 'package:doctor_app_flutter/models/livecare/start_call_res.dart'; -import 'package:doctor_app_flutter/providers/livecare_provider.dart'; +import 'package:doctor_app_flutter/core/viewModel/livecare_view_model.dart'; import 'package:doctor_app_flutter/screens/live_care/panding_list.dart'; import 'package:doctor_app_flutter/util/VideoChannel.dart'; import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; @@ -30,7 +30,7 @@ class _VideoCallPageState extends State { Timer _timmerInstance; int _start = 0; String _timmer = ''; - LiveCareProvider _liveCareProvider; + LiveCareViewModel _liveCareProvider; bool _isInit = true; var _tokenData; bool isTransfer = false; @@ -43,7 +43,7 @@ class _VideoCallPageState extends State { void didChangeDependencies() { super.didChangeDependencies(); if (_isInit) { - _liveCareProvider = Provider.of(context); + _liveCareProvider = Provider.of(context); startCall(false); } _isInit = false; diff --git a/lib/screens/medicine/medicine_search_screen.dart b/lib/screens/medicine/medicine_search_screen.dart index 764c1b34..3a2ff96c 100644 --- a/lib/screens/medicine/medicine_search_screen.dart +++ b/lib/screens/medicine/medicine_search_screen.dart @@ -2,8 +2,9 @@ import 'dart:math'; import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/config/size_config.dart'; +import 'package:doctor_app_flutter/core/viewModel/medicine_view_model.dart'; import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart'; -import 'package:doctor_app_flutter/providers/medicine_provider.dart'; +import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/screens/medicine/pharmacies_list_screen.dart'; import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart'; @@ -14,10 +15,9 @@ import 'package:doctor_app_flutter/widgets/shared/app_buttons_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_text_form_field.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; -import 'package:doctor_app_flutter/widgets/shared/dr_app_circular_progress_Indeicator.dart'; +import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart'; import 'package:flutter/material.dart'; import 'package:permission_handler/permission_handler.dart'; -import 'package:provider/provider.dart'; import 'package:speech_to_text/speech_recognition_error.dart'; import 'package:speech_to_text/speech_recognition_result.dart'; import 'package:speech_to_text/speech_to_text.dart'; @@ -40,7 +40,6 @@ class _MedicineSearchState extends State { final myController = TextEditingController(); Helpers helpers = new Helpers(); bool _hasSpeech = false; - MedicineProvider _medicineProvider; String _currentLocaleId = ""; bool _isInit = true; final SpeechToText speech = SpeechToText(); @@ -57,12 +56,6 @@ class _MedicineSearchState extends State { @override void didChangeDependencies() { super.didChangeDependencies(); - if (_isInit) { - _medicineProvider = Provider.of(context); - // requestPermissions(); - // initSpeechState(); - } - _isInit = false; } void requestPermissions() async { @@ -92,7 +85,8 @@ class _MedicineSearchState extends State { @override Widget build(BuildContext context) { - return AppScaffold( + return BaseView( + builder: (_, model, w) => AppScaffold( appBarTitle: TranslationBase.of(context).searchMedicine, body: FractionallySizedBox( widthFactor: 0.97, @@ -140,7 +134,7 @@ class _MedicineSearchState extends State { controller: myController, onSaved: (value) {}, onFieldSubmitted: (value) { - searchMedicine(context); + searchMedicine(context, model); }, textInputAction: TextInputAction.search, // TODO return it back when it needed @@ -165,109 +159,115 @@ class _MedicineSearchState extends State { child: Wrap( alignment: WrapAlignment.center, children: [ + // TODO change it secondary button and add loading AppButton( title: TranslationBase.of(context).search, onPressed: () { - searchMedicine(context); + searchMedicine(context, model); }, ), ], ), ), - Container( - margin: EdgeInsets.only( - left: SizeConfig.heightMultiplier * 2), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - AppText( - TranslationBase.of(context).youCanFind + - _medicineProvider.pharmacyItemsList.length - .toString() + - " " + - TranslationBase.of(context).itemsInSearch, - fontWeight: FontWeight.bold, - ), - ], - ), - ), - Container( - height: MediaQuery.of(context).size.height * 0.35, - child: Container( - child: !_medicineProvider.isFinished - ? DrAppCircularProgressIndeicator() - : _medicineProvider.hasError - ? Center( - child: Text( - _medicineProvider.errorMsg, - style: TextStyle( - color: - Theme.of(context).errorColor), - ), - ) - : ListView.builder( - scrollDirection: Axis.vertical, - shrinkWrap: true, - itemCount: - _medicineProvider.pharmacyItemsList == - null - ? 0 - : _medicineProvider - .pharmacyItemsList.length, - itemBuilder: - (BuildContext context, int index) { - return InkWell( - child: MedicineItemWidget( - label: _medicineProvider - .pharmacyItemsList[index] - ["ItemDescription"], - url: _medicineProvider - .pharmacyItemsList[index] - ["ImageSRCUrl"], - ), - onTap: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => - PharmaciesListScreen( - itemID: _medicineProvider + + NetworkBaseView( + baseViewModel: model, + child: Column( + children: [ + Container( + margin: EdgeInsets.only( + left: SizeConfig.heightMultiplier * 2), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AppText( + TranslationBase + .of(context) + .youCanFind + + model.pharmacyItemsList.length + .toString() + + " " + + TranslationBase + .of(context) + .itemsInSearch, + fontWeight: FontWeight.bold, + ), + ], + ), + ), + Container( + height: MediaQuery + .of(context) + .size + .height * 0.35, + child: Container( + child: ListView.builder( + scrollDirection: Axis.vertical, + shrinkWrap: true, + itemCount: + model.pharmacyItemsList == + null + ? 0 + : model + .pharmacyItemsList.length, + itemBuilder: + (BuildContext context, int index) { + return InkWell( + child: MedicineItemWidget( + label: model + .pharmacyItemsList[index] + ["ItemDescription"], + url: model + .pharmacyItemsList[index] + ["ImageSRCUrl"], + ), + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => + PharmaciesListScreen( + itemID: model .pharmacyItemsList[ index]["ItemID"], - url: _medicineProvider + url: model .pharmacyItemsList[ index]["ImageSRCUrl"]), - ), + ), + ); + }, ); - }, - ); - }, - ), - ), - ), + }, + ), + ), + ), + ], + )), ], ), ), - ], - ), - ), - )); + ], + ), + ), + ),),); } - searchMedicine(context) { + searchMedicine(context, MedicineViewModel model) { FocusScope.of(context).unfocus(); if (myController.text.isNullOrEmpty()) { - _medicineProvider.clearPharmacyItemsList(); - helpers.showErrorToast(TranslationBase.of(context).typeMedicineName) ; + helpers.showErrorToast(TranslationBase + .of(context) + .typeMedicineName); //"Type Medicine Name") return; } if (myController.text.length < 3) { - _medicineProvider.clearPharmacyItemsList(); - helpers.showErrorToast(TranslationBase.of(context).moreThan3Letter); + helpers.showErrorToast(TranslationBase + .of(context) + .moreThan3Letter); return; } - _medicineProvider.getMedicineItem(myController.text); + model.getMedicineItem(myController.text); } startVoiceSearch() { @@ -292,7 +292,7 @@ class _MedicineSearchState extends State { lastStatus = ''; myController.text = reconizedWord; Future.delayed(const Duration(seconds: 2), () { - searchMedicine(context); + // searchMedicine(context); }); }); } diff --git a/lib/screens/medicine/pharmacies_list_screen.dart b/lib/screens/medicine/pharmacies_list_screen.dart index dd0a3649..6057bf23 100644 --- a/lib/screens/medicine/pharmacies_list_screen.dart +++ b/lib/screens/medicine/pharmacies_list_screen.dart @@ -2,14 +2,14 @@ import 'dart:convert'; import 'dart:typed_data'; import 'package:doctor_app_flutter/config/size_config.dart'; -import 'package:doctor_app_flutter/providers/medicine_provider.dart'; -import 'package:doctor_app_flutter/providers/project_provider.dart'; +import 'package:doctor_app_flutter/core/viewModel/medicine_view_model.dart'; +import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; +import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/util/dr_app_shared_pref.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_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; -import 'package:doctor_app_flutter/widgets/shared/dr_app_circular_progress_Indeicator.dart'; import 'package:doctor_app_flutter/widgets/shared/rounded_container_widget.dart'; import 'package:flutter/material.dart'; import 'package:maps_launcher/maps_launcher.dart'; @@ -34,7 +34,6 @@ class PharmaciesListScreen extends StatefulWidget { class _PharmaciesListState extends State { var _data; Helpers helpers = new Helpers(); - MedicineProvider _medicineProvider; ProjectProvider projectsProvider; bool _isInit = true; @@ -43,47 +42,38 @@ class _PharmaciesListState extends State { @override void didChangeDependencies() { super.didChangeDependencies(); - if (_isInit) { - _medicineProvider = Provider.of(context); - pharmaciesList(); - } _isInit = false; } @override Widget build(BuildContext context) { projectsProvider = Provider.of(context); - return AppScaffold( + return BaseView( + onModelReady: (model) => model.getPharmaciesList(widget.itemID), + builder: (_, model, w) => AppScaffold( + baseViewModel: model, appBarTitle: TranslationBase.of(context).pharmaciesList, - body: !_medicineProvider.isFinished - ? DrAppCircularProgressIndeicator() - : _medicineProvider.hasError - ? Center( - child: Text( - _medicineProvider.errorMsg, - style: TextStyle( - color: Theme.of(context).errorColor), - ), - ) - :Container( + body: Container( height: SizeConfig.screenHeight, child: ListView( shrinkWrap: true, scrollDirection: Axis.vertical, physics: const AlwaysScrollableScrollPhysics(), children: [ - _medicineProvider.pharmaciesList.length >0 ?RoundedContainer( - child: Row( - children: [ - Expanded( - flex: 1, - child: ClipRRect( - borderRadius: BorderRadius.all( - Radius.circular(7)), - child: widget.url != null ?Image.network( - widget.url, - height: - SizeConfig.imageSizeMultiplier * + model.pharmaciesList.length > 0 + ? RoundedContainer( + child: Row( + children: [ + Expanded( + flex: 1, + child: ClipRRect( + borderRadius: + BorderRadius.all(Radius.circular(7)), + child: widget.url != null + ? Image.network( + widget.url, + height: + SizeConfig.imageSizeMultiplier * 21, width: SizeConfig.imageSizeMultiplier * @@ -110,7 +100,7 @@ class _PharmaciesListState extends State { fontWeight: FontWeight.bold, ), AppText( - _medicineProvider.pharmaciesList[0]["ItemDescription"], + model.pharmaciesList[0]["ItemDescription"], marginLeft: 10, marginTop: 0, marginRight: 10, @@ -125,7 +115,7 @@ class _PharmaciesListState extends State { fontWeight: FontWeight.bold, ), AppText( - _medicineProvider.pharmaciesList[0]["SellingPrice"] + model.pharmaciesList[0]["SellingPrice"] .toString(), marginLeft: 10, marginTop: 0, @@ -161,7 +151,8 @@ class _PharmaciesListState extends State { child: ListView.builder( shrinkWrap: true, physics: const NeverScrollableScrollPhysics(), - itemCount: _medicineProvider.pharmaciesList == null ? 0 : _medicineProvider.pharmaciesList.length, + itemCount: model.pharmaciesList == null ? 0 : model + .pharmaciesList.length, itemBuilder: (BuildContext context, int index) { return RoundedContainer( child: Row( @@ -170,13 +161,14 @@ class _PharmaciesListState extends State { flex: 1, child: ClipRRect( borderRadius: - BorderRadius.all(Radius.circular(7)), + BorderRadius.all(Radius.circular(7)), child: Image.network( - _medicineProvider.pharmaciesList[index]["ProjectImageURL"], + model + .pharmaciesList[index]["ProjectImageURL"], height: - SizeConfig.imageSizeMultiplier * 15, + SizeConfig.imageSizeMultiplier * 15, width: - SizeConfig.imageSizeMultiplier * 15, + SizeConfig.imageSizeMultiplier * 15, fit: BoxFit.cover, ), ), @@ -184,7 +176,8 @@ class _PharmaciesListState extends State { Expanded( flex: 4, child: AppText( - _medicineProvider.pharmaciesList[index]["LocationDescription"], + model + .pharmaciesList[index]["LocationDescription"], margin: 10, ), ), @@ -202,8 +195,10 @@ class _PharmaciesListState extends State { Icons.call, color: Colors.red, ), - onTap: () => launch("tel://" + - _medicineProvider.pharmaciesList[index]["PhoneNumber"]), + onTap: () => + launch("tel://" + + model + .pharmaciesList[index]["PhoneNumber"]), ), ), Padding( @@ -216,11 +211,13 @@ class _PharmaciesListState extends State { onTap: () { MapsLauncher.launchCoordinates( double.parse( - _medicineProvider.pharmaciesList[index]["Latitude"]), + model + .pharmaciesList[index]["Latitude"]), double.parse( - _medicineProvider.pharmaciesList[index]["Longitude"]), - _medicineProvider.pharmaciesList[index] - ["LocationDescription"]); + model + .pharmaciesList[index]["Longitude"]), + model.pharmaciesList[index] + ["LocationDescription"]); }, ), ), @@ -233,13 +230,10 @@ class _PharmaciesListState extends State { }), ), ) - ]), - )); + ]), + ),),); } - pharmaciesList() async { - _medicineProvider.getPharmaciesList(widget.itemID); - } Image imageFromBase64String(String base64String) { return Image.memory(base64Decode(base64String)); diff --git a/lib/screens/patients/out_patient_prescription_details_screen.dart b/lib/screens/patients/out_patient_prescription_details_screen.dart index bd3834ab..c7056ce3 100644 --- a/lib/screens/patients/out_patient_prescription_details_screen.dart +++ b/lib/screens/patients/out_patient_prescription_details_screen.dart @@ -1,15 +1,13 @@ +import 'package:doctor_app_flutter/core/viewModel/patient_view_model.dart'; import 'package:doctor_app_flutter/models/patient/prescription/prescription_res_model.dart'; import 'package:doctor_app_flutter/models/patient/prescription/request_prescription_report.dart'; -import 'package:doctor_app_flutter/providers/patients_provider.dart'; +import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/screens/patients/profile/prescriptions/out_patient_prescription_details_item.dart'; +import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/card_with_bgNew_widget.dart'; -import 'package:doctor_app_flutter/widgets/shared/dr_app_circular_progress_Indeicator.dart'; -import 'package:doctor_app_flutter/widgets/shared/errors/dr_app_embedded_error.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; -import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; class OutPatientPrescriptionDetailsScreen extends StatefulWidget { final PrescriptionResModel prescriptionResModel; @@ -23,44 +21,33 @@ class OutPatientPrescriptionDetailsScreen extends StatefulWidget { class _OutPatientPrescriptionDetailsScreenState extends State { - bool _isInit = true; - PatientsProvider patientsProvider; - @override - void didChangeDependencies() { - super.didChangeDependencies(); - if (_isInit) { - patientsProvider = Provider.of(context); - RequestPrescriptionReport prescriptionReqModel = - RequestPrescriptionReport( - appointmentNo: widget.prescriptionResModel.appointmentNo, - episodeID: widget.prescriptionResModel.episodeID, - setupID: widget.prescriptionResModel.setupID, - patientTypeID: widget.prescriptionResModel.patientID); - patientsProvider.getPrescriptionReport(prescriptionReqModel.toJson()); - } - _isInit = false; + getPrescriptionReport(BuildContext context,PatientViewModel model ){ + RequestPrescriptionReport prescriptionReqModel = + RequestPrescriptionReport( + appointmentNo: widget.prescriptionResModel.appointmentNo, + episodeID: widget.prescriptionResModel.episodeID, + setupID: widget.prescriptionResModel.setupID, + patientTypeID: widget.prescriptionResModel.patientID); + model.getPrescriptionReport(prescriptionReqModel.toJson()); } - @override Widget build(BuildContext context) { - return AppScaffold( - appBarTitle: TranslationBase.of(context).prescriptionDetails, - body: patientsProvider.isLoading - ? DrAppCircularProgressIndeicator() - : patientsProvider.isError - ? DrAppEmbeddedError(error: patientsProvider.error) - : CardWithBgWidgetNew( + return BaseView( + onModelReady: (model) => getPrescriptionReport(context, model), + builder: (_, model, w) => AppScaffold( + appBarTitle: TranslationBase.of(context).prescriptionDetails, + body: CardWithBgWidgetNew( widget: ListView.builder( - itemCount: patientsProvider.prescriptionReport.length, + itemCount: model.prescriptionReport.length, itemBuilder: (BuildContext context, int index) { return OutPatientPrescriptionDetailsItem( prescriptionReport: - patientsProvider.prescriptionReport[index], + model.prescriptionReport[index], ); }), ), - ); + ),); } } diff --git a/lib/screens/patients/patient_search_screen.dart b/lib/screens/patients/patient_search_screen.dart index ac5cbd84..204d2336 100644 --- a/lib/screens/patients/patient_search_screen.dart +++ b/lib/screens/patients/patient_search_screen.dart @@ -1,7 +1,7 @@ import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart'; import 'package:doctor_app_flutter/models/patient/patient_model.dart'; -import 'package:doctor_app_flutter/providers/project_provider.dart'; +import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; import 'package:doctor_app_flutter/routes.dart'; import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; import 'package:doctor_app_flutter/util/helpers.dart'; @@ -176,7 +176,7 @@ class _PatientSearchScreenState extends State { side: BorderSide( width: 1.0, style: BorderStyle.solid, - color: Hexcolor("#CCCCCC")), + color: HexColor("#CCCCCC")), borderRadius: BorderRadius.all(Radius.circular(6.0)), ), @@ -255,7 +255,7 @@ class _PatientSearchScreenState extends State { borderRadius: BorderRadius.all(Radius.circular(6.0)), border: Border.all( - width: 1.0, color: Hexcolor("#CCCCCC"))), + width: 1.0, color: HexColor("#CCCCCC"))), padding: EdgeInsets.only(top: 5), child: AppTextFormField( labelText: @@ -285,7 +285,7 @@ class _PatientSearchScreenState extends State { borderRadius: BorderRadius.all(Radius.circular(6.0)), border: Border.all( - width: 1.0, color: Hexcolor("#CCCCCC"))), + width: 1.0, color: HexColor("#CCCCCC"))), padding: EdgeInsets.only(top: 5), child: AppTextFormField( labelText: @@ -315,7 +315,7 @@ class _PatientSearchScreenState extends State { borderRadius: BorderRadius.all(Radius.circular(6.0)), border: Border.all( - width: 1.0, color: Hexcolor("#CCCCCC"))), + width: 1.0, color: HexColor("#CCCCCC"))), padding: EdgeInsets.only(top: 5), child: AppTextFormField( labelText: TranslationBase.of(context).lastName, @@ -340,7 +340,7 @@ class _PatientSearchScreenState extends State { borderRadius: BorderRadius.all(Radius.circular(6.0)), border: Border.all( - width: 1.0, color: Hexcolor("#CCCCCC"))), + width: 1.0, color: HexColor("#CCCCCC"))), padding: EdgeInsets.only(top: 5), child: AppTextFormField( labelText: @@ -370,7 +370,7 @@ class _PatientSearchScreenState extends State { borderRadius: BorderRadius.all(Radius.circular(6.0)), border: Border.all( - width: 1.0, color: Hexcolor("#CCCCCC"))), + width: 1.0, color: HexColor("#CCCCCC"))), padding: EdgeInsets.only(top: 5), child: AppTextFormField( labelText: @@ -397,7 +397,7 @@ class _PatientSearchScreenState extends State { borderRadius: BorderRadius.all(Radius.circular(6.0)), border: Border.all( - width: 1.0, color: Hexcolor("#CCCCCC"))), + width: 1.0, color: HexColor("#CCCCCC"))), padding: EdgeInsets.only(top: 5), child: AppTextFormField( labelText: @@ -423,7 +423,7 @@ class _PatientSearchScreenState extends State { side: BorderSide( width: 1.0, style: BorderStyle.solid, - color: Hexcolor("#CCCCCC")), + color: HexColor("#CCCCCC")), borderRadius: BorderRadius.all(Radius.circular(6.0)), ), @@ -505,12 +505,12 @@ class _PatientSearchScreenState extends State { Radius.circular(6.0)), border: Border.all( width: 1.0, - color: Hexcolor("#CCCCCC"))), + color: HexColor("#CCCCCC"))), height: 25, width: 25, child: Checkbox( value: true, - checkColor: Hexcolor("#2A930A"), + checkColor: HexColor("#2A930A"), activeColor: Colors.white, onChanged: (bool newValue) {}), ), diff --git a/lib/screens/patients/patients_list_screen.dart b/lib/screens/patients/patients_list_screen.dart deleted file mode 100644 index 6d0b97a8..00000000 --- a/lib/screens/patients/patients_list_screen.dart +++ /dev/null @@ -1,67 +0,0 @@ -import 'package:doctor_app_flutter/models/patient/patient_model.dart'; -import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; - -import '../../providers/patients_provider.dart'; - -class PatientsListScreen extends StatefulWidget { - @override - _PatientsListScreenState createState() => _PatientsListScreenState(); -} - -class _PatientsListScreenState extends State { - var _isInit = true; - var _isLoading = true; - var _hasError; - @override - void didChangeDependencies() { - final routeArgs = ModalRoute.of(context).settings.arguments as Map; - PatientModel patient = routeArgs['patientSearchForm']; - print(patient.TokenID+"EEEEEE"); - String patientType = routeArgs['selectedType']; - print(patientType); - if (_isInit) { - PatientsProvider patientsProv = Provider.of(context); - patientsProv.getPatientList(patient, patientType).then((res) { - // print('MessageStatus${res['MessageStatus']}'); - print('List_MyInPatient${(res['List_MyInPatient'][0])}'); - setState(() { - _isLoading = false; - _hasError = res['ErrorEndUserMessage']; - - }); - print(res); - }).catchError((error) { - print(error); - }); - } - _isInit = false; - super.didChangeDependencies(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - title: Text('PatientsListScreen'), - ), - body: _isLoading - ? Center( - child: CircularProgressIndicator(), - ) - : Container( - child: _hasError != null - ? Center( - child: Text( - _hasError, - style: TextStyle(color: Theme.of(context).errorColor), - ), - ) - : Text('EEEEEEEEEEEEEE'), - ), - ); - } -} -/* -{ProjectID: 15, ClinicID: null, DoctorID: 4709, PatientID: 1288076, DoctorName: SHAZIA MAQSOOD, DoctorNameN: null, FirstName: LAMA, MiddleName: ABDULLAH, LastName: AL-SALOOM, FirstNameN: null, MiddleNameN: null, LastNameN: null, Gender: 2, DateofBirth: /Date(522363600000+0300)/, NationalityID: null, MobileNumber: 0543133371, EmailAddress: Lala_as@hotmail.com, PatientIdentificationNo: 1040451369, PatientType: 1, AdmissionNo: 2020008493, AdmissionDate: /Date(1587589200000+0300)/, RoomID: 119, BedID: 119, NursingStationID: null, Description: null, ClinicDescription: OB-GYNE, ClinicDescriptionN: null, NationalityName: Saudi, NationalityNameN: null, Age: 34 Yr, GenderDescription: Female, NursingStationName: Post Natal Ward – A2} -*/ \ No newline at end of file diff --git a/lib/screens/patients/patients_screen.dart b/lib/screens/patients/patients_screen.dart index 2437fa1a..4ca3e587 100644 --- a/lib/screens/patients/patients_screen.dart +++ b/lib/screens/patients/patients_screen.dart @@ -8,13 +8,14 @@ */ import 'package:doctor_app_flutter/config/config.dart'; +import 'package:doctor_app_flutter/core/viewModel/patient_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/models/patient/patient_model.dart'; import 'package:doctor_app_flutter/models/patient/topten_users_res_model.dart'; -import 'package:doctor_app_flutter/providers/patients_provider.dart'; -import 'package:doctor_app_flutter/providers/project_provider.dart'; +import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; import 'package:doctor_app_flutter/routes.dart'; +import 'package:doctor_app_flutter/screens/base/base_view.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/dr_app_circular_progress_Indeicator.dart'; @@ -55,70 +56,15 @@ class _PatientsScreenState extends State { bool _isInit = true; String patientType; String patientTypeTitle; - var _isLoading = false; + var _isLoading = true; - bool _isError = true; + bool _isError = false; String error = ""; ProjectProvider projectsProvider; final _controller = TextEditingController(); PatientModel patient; - PatientsProvider patientsProv; - - @override - void didChangeDependencies() { - projectsProvider = Provider.of(context); - - final routeArgs = ModalRoute.of(context).settings.arguments as Map; - - patient = routeArgs['patientSearchForm']; - - patientType = routeArgs['selectedType']; - - if (!projectsProvider.isArabic) - patientTypeTitle = SERVICES_PATIANT_HEADER[int.parse(patientType)]; - else - patientTypeTitle = SERVICES_PATIANT_HEADER_AR[int.parse(patientType)]; - - print(patientType); - - if (_isInit) { - PatientsProvider patientsProv = Provider.of(context); - setState(() { - _isLoading = true; - _isError = false; - error = ""; - }); - patientsProv.getPatientList(patient, patientType).then((res) { - setState(() { - _isLoading = false; - if (res['MessageStatus'] == 1) { - int val2 = int.parse(patientType); - lItems = res[SERVICES_PATIANT2[val2]]; - parsed = lItems; - responseModelList = new ModelResponse.fromJson(parsed).list; - responseModelList2 = responseModelList; - _isError = false; - } else { - _isError = true; - error = res['ErrorEndUserMessage'] ?? res['ErrorMessage']; - } - }); - }).catchError((error) { - print(error); - setState(() { - _isError = true; - _isLoading = false; - this.error = error; - }); - }); - } - - _isInit = false; - - super.didChangeDependencies(); - } /* *@author: Amjad Amireh @@ -300,24 +246,74 @@ class _PatientsScreenState extends State { @override Widget build(BuildContext context) { _locations = [ - TranslationBase.of(context).all, - TranslationBase.of(context).today, - TranslationBase.of(context).tomorrow, - TranslationBase.of(context).nextWeek, + TranslationBase + .of(context) + .all, + TranslationBase + .of(context) + .today, + TranslationBase + .of(context) + .tomorrow, + TranslationBase + .of(context) + .nextWeek, ]; - PatientsProvider patientsProv = Provider.of(context); - - return AppScaffold( - appBarTitle: patientTypeTitle, - body: _isLoading - ? DrAppCircularProgressIndeicator() - : _isError - ? DrAppEmbeddedError(error: error) - : lItems == null || lItems.length == 0 - ? DrAppEmbeddedError( - error: TranslationBase.of(context).youDontHaveAnyPatient) - : Container( - child: ListView( + projectsProvider = Provider.of(context); + final routeArgs = ModalRoute + .of(context) + .settings + .arguments as Map; + + patient = routeArgs['patientSearchForm']; + + patientType = routeArgs['selectedType']; + + if (!projectsProvider.isArabic) + patientTypeTitle = SERVICES_PATIANT_HEADER[int.parse(patientType)]; + else + patientTypeTitle = SERVICES_PATIANT_HEADER_AR[int.parse(patientType)]; + + return BaseView( + onModelReady: (model) { + // TODO : change all the logic here to make it work with the model and remove future + model.getPatientList(patient, patientType).then((res) { + setState(() { + _isLoading = false; + if (res['MessageStatus'] == 1) { + int val2 = int.parse(patientType); + lItems = res[SERVICES_PATIANT2[val2]]; + parsed = lItems; + responseModelList = new ModelResponse.fromJson(parsed).list; + responseModelList2 = responseModelList; + _isError = false; + } else { + _isError = true; + error = res['ErrorEndUserMessage'] ?? res['ErrorMessage']; + } + }); + }).catchError((error) { + setState(() { + _isError = true; + _isLoading = false; + this.error = error; + }); + }); + }, + builder: (_, model, w) => + AppScaffold( + appBarTitle: patientTypeTitle, + body: _isLoading + ? DrAppCircularProgressIndeicator() + : _isError + ? DrAppEmbeddedError(error: error) + : lItems == null || lItems.length == 0 + ? DrAppEmbeddedError( + error: TranslationBase + .of(context) + .youDontHaveAnyPatient) + : Container( + child: ListView( scrollDirection: Axis.vertical, children: [ Container( @@ -529,6 +525,21 @@ class _PatientsScreenState extends State { ? Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ + Container( + height: 15, + width: 60, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(25), + color: HexColor("#20A169"), + ), + child: AppText( + item.startTime, + color: Colors.white, + fontSize: 1.5 * SizeConfig.textMultiplier, + textAlign: TextAlign.center, + fontWeight: FontWeight.bold, + ), + ), SizedBox( width: 3.5, ), @@ -611,6 +622,21 @@ class _PatientsScreenState extends State { ? Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ + Container( + height: 15, + width: 60, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(25), + color: HexColor("#20A169"), + ), + child: AppText( + item.startTime, + color: Colors.white, + fontSize: 1.5 * SizeConfig.textMultiplier, + textAlign: TextAlign.center, + fontWeight: FontWeight.bold, + ), + ), SizedBox( width: 3.5, ), @@ -654,17 +680,17 @@ class _PatientsScreenState extends State { : Center( child: DrAppEmbeddedError( error: TranslationBase.of( - context) + context) .youDontHaveAnyPatient), - ), + ), ), ], - ), + ), ) ], - ), - ), - ); + ), + ), + ),); } InputDecoration buildInputDecoration(BuildContext context, hint) { @@ -676,7 +702,7 @@ class _PatientsScreenState extends State { hintStyle: TextStyle(fontSize: 1.66 * SizeConfig.textMultiplier), enabledBorder: OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(10.0)), - borderSide: BorderSide(color: Hexcolor('#CCCCCC')), + borderSide: BorderSide(color: HexColor('#CCCCCC')), ), focusedBorder: OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(10.0)), @@ -716,7 +742,7 @@ class _PatientsScreenState extends State { topLeft: Radius.circular(9.5), bottomLeft: Radius.circular(9.5)), color: - _isActive ? Hexcolor("#B8382B") : Colors.white, + _isActive ? HexColor("#B8382B") : Colors.white, ), child: Center( child: Text( @@ -734,7 +760,6 @@ class _PatientsScreenState extends State { ), ), onTap: () { - print(_locations.indexOf(item)); filterBooking(item.toString()); diff --git a/lib/screens/patients/profile/insurance_approvals_screen.dart b/lib/screens/patients/profile/insurance_approvals_screen.dart index 51619dc9..9105338b 100644 --- a/lib/screens/patients/profile/insurance_approvals_screen.dart +++ b/lib/screens/patients/profile/insurance_approvals_screen.dart @@ -1,21 +1,20 @@ import 'package:doctor_app_flutter/config/config.dart'; +import 'package:doctor_app_flutter/core/viewModel/patient_view_model.dart'; import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart'; import 'package:doctor_app_flutter/models/patient/insurance_aprovals_request.dart'; +import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/shared/errors/dr_app_embedded_error.dart'; import 'package:doctor_app_flutter/widgets/shared/rounded_container_widget.dart'; import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; -import 'package:provider/provider.dart'; import '../../../config/shared_pref_kay.dart'; import '../../../config/size_config.dart'; import '../../../models/patient/patiant_info_model.dart'; -import '../../../providers/patients_provider.dart'; import '../../../util/dr_app_shared_pref.dart'; import '../../../widgets/shared/app_scaffold_widget.dart'; import '../../../widgets/shared/app_texts_widget.dart'; -import '../../../widgets/shared/dr_app_circular_progress_Indeicator.dart'; DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); @@ -33,11 +32,9 @@ class InsuranceApprovalsScreen extends StatefulWidget { } class _InsuranceApprovalsState extends State { - PatientsProvider patientsProv; var approvalsList; var filteredApprovalsList; final _controller = TextEditingController(); - var _isInit = true; /* *@author: ibrahim al bitar @@ -46,7 +43,8 @@ class _InsuranceApprovalsState extends State { *@return: *@desc: */ - getInsuranceApprovalsList(context) async { + getInsuranceApprovalsList( + BuildContext context, PatientViewModel model) async { final routeArgs = ModalRoute.of(context).settings.arguments as Map; PatiantInformtion patient = routeArgs['patient']; String token = await sharedPref.getString(TOKEN); @@ -60,62 +58,58 @@ class _InsuranceApprovalsState extends State { tokenID: token, patientTypeID: patient.patientType, languageID: 2); - patientsProv + model .getPatientInsuranceApprovals(insuranceApprovalsRequest.toJson()).then((c){ - approvalsList = patientsProv.insuranceApporvalsList; + approvalsList = model.insuranceApporvalsList; }); } - @override - void didChangeDependencies() { - super.didChangeDependencies(); - if (_isInit) { - patientsProv = Provider.of(context); - getInsuranceApprovalsList(context); - approvalsList = patientsProv.insuranceApporvalsList; - _isInit = false; - } - } @override Widget build(BuildContext context) { - return AppScaffold( - appBarTitle: TranslationBase.of(context).insuranceApprovals, - body: patientsProv.isLoading - ? DrAppCircularProgressIndeicator() - : patientsProv.isError - ? DrAppEmbeddedError(error: patientsProv.error) - : patientsProv.insuranceApporvalsList == null || patientsProv.insuranceApporvalsList.length == 0 - ? DrAppEmbeddedError( - error: - TranslationBase.of(context).errorNoInsuranceApprovals) - : Column( - children: [ - Container( - margin: EdgeInsets.all(10), - width: SizeConfig.screenWidth * 0.80, - child: TextField( - controller: _controller, - onChanged: (String str) { - this.searchData(str); - }, - textInputAction: TextInputAction.done, - decoration: buildInputDecoration( - context, - TranslationBase.of(context) - .searchInsuranceApprovals), - ), - ), - Expanded( - child: Container( - margin: EdgeInsets.fromLTRB( - SizeConfig.realScreenWidth * 0.05, - 0, - SizeConfig.realScreenWidth * 0.05, - 0), - child: ListView.builder( - itemCount: approvalsList.length, - itemBuilder: (BuildContext ctxt, int index) { + return BaseView( + onModelReady: (model) => getInsuranceApprovalsList(context, model), + builder: (_, model, w) => + AppScaffold( + baseViewModel: model, + appBarTitle: TranslationBase + .of(context) + .insuranceApprovals, + body: model.insuranceApporvalsList == null || + model.insuranceApporvalsList.length == 0 + ? DrAppEmbeddedError( + error: + TranslationBase + .of(context) + .errorNoInsuranceApprovals) + : Column( + children: [ + Container( + margin: EdgeInsets.all(10), + width: SizeConfig.screenWidth * 0.80, + child: TextField( + controller: _controller, + onChanged: (String str) { + this.searchData(str, model); + }, + textInputAction: TextInputAction.done, + decoration: buildInputDecoration( + context, + TranslationBase + .of(context) + .searchInsuranceApprovals), + ), + ), + Expanded( + child: Container( + margin: EdgeInsets.fromLTRB( + SizeConfig.realScreenWidth * 0.05, + 0, + SizeConfig.realScreenWidth * 0.05, + 0), + child: ListView.builder( + itemCount: approvalsList.length, + itemBuilder: (BuildContext ctxt, int index) { return RoundedContainer( child: Column( crossAxisAlignment: @@ -429,13 +423,13 @@ class _InsuranceApprovalsState extends State { ], ), ], - )); - }), - ), - ), - ], - ), - ); + )); + }), + ), + ), + ], + ), + ),); } InputDecoration buildInputDecoration(BuildContext context, hint) { @@ -447,7 +441,7 @@ class _InsuranceApprovalsState extends State { hintStyle: TextStyle(fontSize: 2 * SizeConfig.textMultiplier), enabledBorder: OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(10)), - borderSide: BorderSide(color: Hexcolor('#CCCCCC')), + borderSide: BorderSide(color: HexColor('#CCCCCC')), ), focusedBorder: OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(10.0)), @@ -455,21 +449,21 @@ class _InsuranceApprovalsState extends State { )); } - searchData(String str) { + searchData(String str, PatientViewModel model) { var strExist = str.length > 0 ? true : false; if (strExist) { filteredApprovalsList = null; filteredApprovalsList = approvalsList .where((note) => - note["ClinicName"].toString().contains(str.toUpperCase())) + note["ClinicName"].toString().contains(str.toUpperCase())) .toList(); setState(() { approvalsList = filteredApprovalsList; }); } else { setState(() { - approvalsList = patientsProv.insuranceApporvalsList; + approvalsList = model.insuranceApporvalsList; }); } } diff --git a/lib/screens/patients/profile/lab_result/lab_orders_screen.dart b/lib/screens/patients/profile/lab_result/lab_orders_screen.dart index 1fa71dc0..41f58564 100644 --- a/lib/screens/patients/profile/lab_result/lab_orders_screen.dart +++ b/lib/screens/patients/profile/lab_result/lab_orders_screen.dart @@ -1,24 +1,20 @@ +import 'package:doctor_app_flutter/core/viewModel/patient_view_model.dart'; +import 'package:doctor_app_flutter/screens/base/base_view.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/large_avatar.dart'; -import 'package:doctor_app_flutter/widgets/shared/card_with_bgNew_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/errors/dr_app_embedded_error.dart'; import 'package:eva_icons_flutter/eva_icons_flutter.dart'; import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; import '../../../../config/shared_pref_kay.dart'; import '../../../../config/size_config.dart'; import '../../../../models/patient/lab_orders/lab_orders_req_model.dart'; import '../../../../models/patient/patiant_info_model.dart'; -import '../../../../providers/patients_provider.dart'; import '../../../../util/dr_app_shared_pref.dart'; import '../../../../widgets/shared/app_scaffold_widget.dart'; import '../../../../widgets/shared/app_texts_widget.dart'; -import '../../../../widgets/shared/card_with_bg_widget.dart'; -import '../../../../widgets/shared/dr_app_circular_progress_Indeicator.dart'; -import '../../../../widgets/shared/profile_image_widget.dart'; import 'lab_result_secreen.dart'; -import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); @@ -36,17 +32,16 @@ class LabOrdersScreen extends StatefulWidget { } class _LabOrdersScreenState extends State { - PatientsProvider patientsProv; - var _isInit = true; + /* *@author: Elham Rababah *@Date:28/4/2020 *@param: context *@return: - *@desc: getVitalSignList Function + *@desc: getLabResultOrders Function */ - getLabResultOrders(context) async { + getLabResultOrders(BuildContext context, PatientViewModel model) async { final routeArgs = ModalRoute.of(context).settings.arguments as Map; PatiantInformtion patient = routeArgs['patient']; String token = await sharedPref.getString(TOKEN); @@ -57,181 +52,184 @@ class _LabOrdersScreenState extends State { patientTypeID: patient.patientType, languageID: 2); - patientsProv.getLabResultOrders(labOrdersReqModel.toJson()); - } - - @override - void didChangeDependencies() { - super.didChangeDependencies(); - if (_isInit) { - patientsProv = Provider.of(context); - getLabResultOrders(context); - } - _isInit = false; + model.getLabResultOrders(labOrdersReqModel.toJson()); } @override Widget build(BuildContext context) { - return AppScaffold( - appBarTitle: TranslationBase.of(context).labOrders, - body: patientsProv.isLoading - ? DrAppCircularProgressIndeicator() - : patientsProv.isError - ? DrAppEmbeddedError(error: patientsProv.error) - : patientsProv.patientLabResultOrdersList.length == 0 - ? DrAppEmbeddedError( - error: TranslationBase.of(context).errorNoLabOrders) - : Container( - margin: EdgeInsets.fromLTRB( - SizeConfig.realScreenWidth * 0.05, - 0, - SizeConfig.realScreenWidth * 0.05, - 0), - child: Container( - margin: EdgeInsets.symmetric(vertical: 10), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.all( - Radius.circular(20.0), + return BaseView( + onModelReady: (model) => getLabResultOrders(context, model), + builder: (_, model, w) => + AppScaffold( + baseViewModel: model, + appBarTitle: TranslationBase + .of(context) + .labOrders, + body: model.patientLabResultOrdersList.length == 0 + ? DrAppEmbeddedError( + error: TranslationBase + .of(context) + .errorNoLabOrders) + : Container( + margin: EdgeInsets.fromLTRB( + SizeConfig.realScreenWidth * 0.05, + 0, + SizeConfig.realScreenWidth * 0.05, + 0), + child: Container( + margin: EdgeInsets.symmetric(vertical: 10), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.all( + Radius.circular(20.0), + ), + ), + child: ListView.builder( + itemCount: + model.patientLabResultOrdersList.length, + itemBuilder: (BuildContext context, int index) { + return InkWell( + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => + LabResult( + labOrders: model + .patientLabResultOrdersList[index], + ), + ), + ); + }, + child: Container( + padding: EdgeInsets.all(10), + margin: EdgeInsets.all(10), + decoration: BoxDecoration( + borderRadius: + BorderRadius.all(Radius.circular(10)), + border: Border( + bottom: BorderSide( + color: Colors.grey, width: 0.5), + top: BorderSide( + color: Colors.grey, width: 0.5), + left: BorderSide( + color: Colors.grey, width: 0.5), + right: BorderSide( + color: Colors.grey, width: 0.5), + ), ), - ), - child: ListView.builder( - itemCount: - patientsProv.patientLabResultOrdersList.length, - itemBuilder: (BuildContext context, int index) { - return InkWell( - onTap: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => LabResult( - labOrders: patientsProv - .patientLabResultOrdersList[index], - ), - ), - ); - }, - child: Container( - padding: EdgeInsets.all(10), - margin: EdgeInsets.all(10), - decoration: BoxDecoration( - borderRadius: - BorderRadius.all(Radius.circular(10)), - border: Border( - bottom: BorderSide( - color: Colors.grey, width: 0.5), - top: BorderSide( - color: Colors.grey, width: 0.5), - left: BorderSide( - color: Colors.grey, width: 0.5), - right: BorderSide( - color: Colors.grey, width: 0.5), - ), + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Row( + children: [ + LargeAvatar( + url: model + .patientLabResultOrdersList[ + index] + .doctorImageURL, + name: model + .patientLabResultOrdersList[ + index] + .doctorName, ), - child: Column( - crossAxisAlignment: + Expanded( + child: Padding( + padding: + const EdgeInsets.fromLTRB( + 8, 0, 0, 0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( children: [ - LargeAvatar( - url: patientsProv - .patientLabResultOrdersList[ - index] - .doctorImageURL, - name: patientsProv - .patientLabResultOrdersList[ - index] - .doctorName, + AppText( + '${model + .patientLabResultOrdersList[index] + .doctorName}', + fontSize: 1.7 * + SizeConfig + .textMultiplier, + fontWeight: FontWeight.w600, ), - Expanded( - child: Padding( - padding: - const EdgeInsets.fromLTRB( - 8, 0, 0, 0), - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - AppText( - '${patientsProv.patientLabResultOrdersList[index].doctorName}', - fontSize: 1.7 * - SizeConfig - .textMultiplier, - fontWeight: FontWeight.w600, - ), - SizedBox( - height: 8, - ), - AppText( - ' ${patientsProv.patientLabResultOrdersList[index].projectName}', - fontSize: 2 * - SizeConfig - .textMultiplier, - color: Colors.grey[800]), - SizedBox( - height: 8, - ), - Row( - mainAxisAlignment: - MainAxisAlignment.start, - children: [ - AppText( - ' Invoice No :', - fontSize: 2 * - SizeConfig - .textMultiplier, - color: Colors.grey[800], - ), - AppText( - ' ${patientsProv.patientLabResultOrdersList[index].invoiceNo}', - fontSize: 2 * - SizeConfig - .textMultiplier, - color: Colors.grey[800], - ), - ], - ) - ], - ), - ), - ) - ], - ), - SizedBox( - height: 3, - ), - Divider( - color: Colors.grey, - ), - SizedBox( - height: 3, - ), - Row( - children: [ - Icon( - EvaIcons.calendar, - color: Colors.grey[700], + SizedBox( + height: 8, ), + AppText( + ' ${model + .patientLabResultOrdersList[index] + .projectName}', + fontSize: 2 * + SizeConfig + .textMultiplier, + color: Colors.grey[800]), SizedBox( - width: 10, + height: 8, ), - Expanded( - child: AppText( - '${Helpers.getDate(patientsProv.patientLabResultOrdersList[index].createdOn)}', - fontSize: 2.0 * - SizeConfig.textMultiplier, - ), + Row( + mainAxisAlignment: + MainAxisAlignment.start, + children: [ + AppText( + ' Invoice No :', + fontSize: 2 * + SizeConfig + .textMultiplier, + color: Colors.grey[800], + ), + AppText( + ' ${model + .patientLabResultOrdersList[index] + .invoiceNo}', + fontSize: 2 * + SizeConfig + .textMultiplier, + color: Colors.grey[800], + ), + ], ) ], - ) - ], + ), + ), + ) + ], + ), + SizedBox( + height: 3, + ), + Divider( + color: Colors.grey, + ), + SizedBox( + height: 3, + ), + Row( + children: [ + Icon( + EvaIcons.calendar, + color: Colors.grey[700], + ), + SizedBox( + width: 10, ), - ), - ); - }), - ), - ), - ); + Expanded( + child: AppText( + '${Helpers.getDate(model + .patientLabResultOrdersList[index] + .createdOn)}', + fontSize: 2.0 * + SizeConfig.textMultiplier, + ), + ) + ], + ) + ], + ), + ), + ); + }), + ), + ), + ),); } } diff --git a/lib/screens/patients/profile/lab_result/lab_result_secreen.dart b/lib/screens/patients/profile/lab_result/lab_result_secreen.dart index 70f4b8a3..d41f388d 100644 --- a/lib/screens/patients/profile/lab_result/lab_result_secreen.dart +++ b/lib/screens/patients/profile/lab_result/lab_result_secreen.dart @@ -1,18 +1,15 @@ import 'package:doctor_app_flutter/config/size_config.dart'; +import 'package:doctor_app_flutter/core/viewModel/patient_view_model.dart'; import 'package:doctor_app_flutter/models/patient/lab_orders/lab_orders_res_model.dart'; -import 'package:doctor_app_flutter/providers/patients_provider.dart'; -import 'package:doctor_app_flutter/util/helpers.dart'; +import 'package:doctor_app_flutter/screens/base/base_view.dart'; +import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/doctor/lab_result_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/card_with_bgNew_widget.dart'; -import 'package:doctor_app_flutter/widgets/shared/dr_app_circular_progress_Indeicator.dart'; import 'package:doctor_app_flutter/widgets/shared/errors/dr_app_embedded_error.dart'; -import 'package:eva_icons_flutter/eva_icons_flutter.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; -import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; class LabResult extends StatefulWidget { final LabOrdersResModel labOrders; @@ -24,63 +21,46 @@ class LabResult extends StatefulWidget { } class _LabResultState extends State { - PatientsProvider patientsProv; - bool _isInit = true; - - @override - void didChangeDependencies() { - super.didChangeDependencies(); - if (_isInit) { - patientsProv = Provider.of(context); - patientsProv.getLabResult(widget.labOrders); - // getLabResultOrders(context); - } - _isInit = false; - } - @override Widget build(BuildContext context) { - return AppScaffold( - appBarTitle: TranslationBase.of(context).labOrders, - body: patientsProv.isLoading - ? DrAppCircularProgressIndeicator() - : patientsProv.isError - ? DrAppEmbeddedError(error: patientsProv.error) - : patientsProv.labResultList.length == 0 - ? DrAppEmbeddedError( - error: TranslationBase.of(context).errorNoLabOrders) - : Container( - margin: EdgeInsets.fromLTRB( - SizeConfig.realScreenWidth * 0.05, - 0, - SizeConfig.realScreenWidth * 0.05, - 0), - child: ListView( + return BaseView( + onModelReady: (model) => model.getLabResult(widget.labOrders), + builder: (_, model, w) => AppScaffold( + baseViewModel: model, + appBarTitle: TranslationBase.of(context).labOrders, + body: model.labResultList.length == 0 + ? DrAppEmbeddedError( + error: TranslationBase.of(context).errorNoLabOrders) + : Container( + margin: EdgeInsets.fromLTRB(SizeConfig.realScreenWidth * 0.05, + 0, SizeConfig.realScreenWidth * 0.05, 0), + child: ListView( + children: [ + CardWithBgWidgetNew( + widget: Row( + mainAxisAlignment: MainAxisAlignment.start, children: [ - CardWithBgWidgetNew( - widget: Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - AppText( - TranslationBase.of(context).invoiceNo, - fontSize: 2 * SizeConfig.textMultiplier, - color: Colors.grey[800], - ), - AppText( - ' ${widget.labOrders.invoiceNo}', - fontSize: 2 * SizeConfig.textMultiplier, - color: Colors.grey[800], - ), - ], - ), + AppText( + TranslationBase.of(context).invoiceNo, + fontSize: 2 * SizeConfig.textMultiplier, + color: Colors.grey[800], + ), + AppText( + ' ${widget.labOrders.invoiceNo}', + fontSize: 2 * SizeConfig.textMultiplier, + color: Colors.grey[800], ), - CardWithBgWidgetNew( - widget: LabResultWidget( - labResult: patientsProv.labResultList, - )) ], ), ), + CardWithBgWidgetNew( + widget: LabResultWidget( + labResult: model.labResultList, + )) + ], + ), + ), + ), ); } } diff --git a/lib/screens/patients/profile/patient_orders_screen.dart b/lib/screens/patients/profile/patient_orders_screen.dart index 05cdbfea..09834d50 100644 --- a/lib/screens/patients/profile/patient_orders_screen.dart +++ b/lib/screens/patients/profile/patient_orders_screen.dart @@ -1,20 +1,18 @@ -import 'package:doctor_app_flutter/config/config.dart'; +import 'package:doctor_app_flutter/core/viewModel/patient_view_model.dart'; import 'package:doctor_app_flutter/models/patient/progress_note_request.dart'; +import 'package:doctor_app_flutter/screens/base/base_view.dart'; +import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/shared/errors/dr_app_embedded_error.dart'; import 'package:doctor_app_flutter/widgets/shared/rounded_container_widget.dart'; import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; -import 'package:provider/provider.dart'; import '../../../config/shared_pref_kay.dart'; import '../../../config/size_config.dart'; import '../../../models/patient/patiant_info_model.dart'; -import '../../../providers/patients_provider.dart'; import '../../../util/dr_app_shared_pref.dart'; import '../../../widgets/shared/app_scaffold_widget.dart'; import '../../../widgets/shared/app_texts_widget.dart'; -import '../../../widgets/shared/dr_app_circular_progress_Indeicator.dart'; -import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); @@ -32,7 +30,6 @@ class PatientsOrdersScreen extends StatefulWidget { } class _PatientsOrdersState extends State { - PatientsProvider patientsProv; var notesList; var filteredNotesList; final _controller = TextEditingController(); @@ -45,7 +42,7 @@ class _PatientsOrdersState extends State { *@return: *@desc: */ - getProgressNoteList(context) async { + getProgressNoteList(BuildContext context, PatientViewModel model ) async { final routeArgs = ModalRoute.of(context).settings.arguments as Map; PatiantInformtion patient = routeArgs['patient']; String token = await sharedPref.getString(TOKEN); @@ -59,31 +56,20 @@ class _PatientsOrdersState extends State { tokenID: token, patientTypeID: patient.patientType, languageID: 2); - patientsProv.getPatientProgressNote(progressNoteRequest.toJson()).then((c){ - notesList = patientsProv.patientProgressNoteList; + model.getPatientProgressNote(progressNoteRequest.toJson()).then((c){ + notesList = model.patientProgressNoteList; }); } - @override - void didChangeDependencies() { - super.didChangeDependencies(); - if (_isInit) { - patientsProv = Provider.of(context); - getProgressNoteList(context); - notesList = patientsProv.patientProgressNoteList; - } - _isInit = false; - } @override Widget build(BuildContext context) { - return AppScaffold( - appBarTitle: TranslationBase.of(context).orders, - body: patientsProv.isLoading - ? DrAppCircularProgressIndeicator() - : patientsProv.isError - ? DrAppEmbeddedError(error: patientsProv.error) - : notesList == null || notesList.length == 0 + return BaseView( + onModelReady: (model) => getProgressNoteList(context, model), + builder: (_, model, w) => AppScaffold( + baseViewModel: model, + appBarTitle: TranslationBase.of(context).orders, + body: notesList == null || notesList.length == 0 ? DrAppEmbeddedError( error: TranslationBase.of(context).errorNoOrders) : Column( @@ -94,7 +80,7 @@ class _PatientsOrdersState extends State { child: TextField( controller: _controller, onChanged: (String str) { - this.searchData(str); + this.searchData(str, model); }, textInputAction: TextInputAction.done, decoration: buildInputDecoration(context, @@ -162,7 +148,7 @@ class _PatientsOrdersState extends State { ), ], ), - ); + ),); } InputDecoration buildInputDecoration(BuildContext context, hint) { @@ -174,7 +160,7 @@ class _PatientsOrdersState extends State { hintStyle: TextStyle(fontSize: 2 * SizeConfig.textMultiplier), enabledBorder: OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(20)), - borderSide: BorderSide(color: Hexcolor('#CCCCCC')), + borderSide: BorderSide(color: HexColor('#CCCCCC')), ), focusedBorder: OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(50.0)), @@ -182,7 +168,7 @@ class _PatientsOrdersState extends State { )); } - searchData(String str) { + searchData(String str, PatientViewModel model) { var strExist = str.length > 0 ? true : false; if (strExist) { @@ -196,7 +182,7 @@ class _PatientsOrdersState extends State { }); } else { setState(() { - notesList = patientsProv.patientProgressNoteList; + notesList = model.patientProgressNoteList; }); } } diff --git a/lib/screens/patients/profile/prescriptions/prescriptions_screen.dart b/lib/screens/patients/profile/prescriptions/prescriptions_screen.dart index afb880b4..496e5478 100644 --- a/lib/screens/patients/profile/prescriptions/prescriptions_screen.dart +++ b/lib/screens/patients/profile/prescriptions/prescriptions_screen.dart @@ -1,23 +1,17 @@ +import 'package:doctor_app_flutter/core/viewModel/patient_view_model.dart'; import 'package:doctor_app_flutter/models/patient/reauest_prescription_report_for_in_patient.dart'; -import 'package:doctor_app_flutter/widgets/patients/profile/large_avatar.dart'; +import 'package:doctor_app_flutter/screens/base/base_view.dart'; +import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/prescription_in_patinets_widget.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/prescription_out_patinets_widget.dart'; -import 'package:doctor_app_flutter/widgets/shared/card_with_bgNew_widget.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; import '../../../../config/shared_pref_kay.dart'; -import '../../../../config/size_config.dart'; import '../../../../models/patient/patiant_info_model.dart'; import '../../../../models/patient/prescription/prescription_req_model.dart'; -import '../../../../providers/patients_provider.dart'; import '../../../../util/dr_app_shared_pref.dart'; import '../../../../widgets/shared/app_scaffold_widget.dart'; -import '../../../../widgets/shared/app_texts_widget.dart'; -import '../../../../widgets/shared/dr_app_circular_progress_Indeicator.dart'; -import '../../../../widgets/shared/errors/dr_app_embedded_error.dart'; -import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); @@ -35,8 +29,6 @@ class PrescriptionScreen extends StatefulWidget { } class _PrescriptionScreenState extends State { - PatientsProvider patientsProv; - bool _isInit = true; String type = '2'; /* @@ -46,7 +38,7 @@ class _PrescriptionScreenState extends State { *@return: *@desc: getPrescriptionsList Function */ - getPrescriptionsList(context) async { + getPrescriptionsList(BuildContext context, PatientViewModel model) async { final routeArgs = ModalRoute.of(context).settings.arguments as Map; PatiantInformtion patient = routeArgs['patient']; String token = await sharedPref.getString(TOKEN); @@ -58,7 +50,7 @@ class _PrescriptionScreenState extends State { patientID: patient.patientId, patientTypeID: patient.patientType, admissionNo: int.parse(patient.admissionNo)); - patientsProv.getInPatientPrescriptions(prescriptionReqModel.toJson()); + model.getInPatientPrescriptions(prescriptionReqModel.toJson()); } else { PrescriptionReqModel prescriptionReqModel = PrescriptionReqModel( patientID: patient.patientId, @@ -67,37 +59,30 @@ class _PrescriptionScreenState extends State { patientTypeID: patient.patientType, languageID: 2, setupID: 0); - patientsProv.getOutPatientPrescriptions(prescriptionReqModel.toJson()); + model.getOutPatientPrescriptions(prescriptionReqModel.toJson()); } } - @override - void didChangeDependencies() { - super.didChangeDependencies(); - if (_isInit) { - patientsProv = Provider.of(context); - getPrescriptionsList(context); - } - _isInit = false; - } @override Widget build(BuildContext context) { - return AppScaffold( - appBarTitle: TranslationBase.of(context).prescription, - body: patientsProv.isLoading - ? DrAppCircularProgressIndeicator() - : patientsProv.isError - ? DrAppEmbeddedError(error: patientsProv.error) - : type == '1' - ? PrescriptionInPatientWidget( - prescriptionReportForInPatientList: - patientsProv.prescriptionReportForInPatientList, - ) - : PrescriptionOutPatientWidget( - patientPrescriptionsList: - patientsProv.patientPrescriptionsList, - ), - ); + return BaseView( + onModelReady: (model) => getPrescriptionsList(context, model), + builder: (_, model, w) => + AppScaffold( + baseViewModel: model, + appBarTitle: TranslationBase + .of(context) + .prescription, + body: type == '1' + ? PrescriptionInPatientWidget( + prescriptionReportForInPatientList: + model.prescriptionReportForInPatientList, + ) + : PrescriptionOutPatientWidget( + patientPrescriptionsList: + model.patientPrescriptionsList, + ), + ),); } } diff --git a/lib/screens/patients/profile/progress_note_screen.dart b/lib/screens/patients/profile/progress_note_screen.dart index aba49d7b..88e34cdb 100644 --- a/lib/screens/patients/profile/progress_note_screen.dart +++ b/lib/screens/patients/profile/progress_note_screen.dart @@ -1,20 +1,18 @@ -import 'package:doctor_app_flutter/config/config.dart'; +import 'package:doctor_app_flutter/core/viewModel/patient_view_model.dart'; import 'package:doctor_app_flutter/models/patient/progress_note_request.dart'; +import 'package:doctor_app_flutter/screens/base/base_view.dart'; +import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/shared/errors/dr_app_embedded_error.dart'; import 'package:doctor_app_flutter/widgets/shared/rounded_container_widget.dart'; import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; -import 'package:provider/provider.dart'; import '../../../config/shared_pref_kay.dart'; import '../../../config/size_config.dart'; import '../../../models/patient/patiant_info_model.dart'; -import '../../../providers/patients_provider.dart'; import '../../../util/dr_app_shared_pref.dart'; import '../../../widgets/shared/app_scaffold_widget.dart'; import '../../../widgets/shared/app_texts_widget.dart'; -import '../../../widgets/shared/dr_app_circular_progress_Indeicator.dart'; -import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); @@ -32,7 +30,6 @@ class ProgressNoteScreen extends StatefulWidget { } class _ProgressNoteState extends State { - PatientsProvider patientsProv; var notesList; var filteredNotesList; final _controller = TextEditingController(); @@ -45,7 +42,7 @@ class _ProgressNoteState extends State { *@return: *@desc: */ - getProgressNoteList(context) async { + getProgressNoteList(BuildContext context, PatientViewModel model) async { final routeArgs = ModalRoute.of(context).settings.arguments as Map; PatiantInformtion patient = routeArgs['patient']; String token = await sharedPref.getString(TOKEN); @@ -53,51 +50,46 @@ class _ProgressNoteState extends State { print(type); ProgressNoteRequest progressNoteRequest = ProgressNoteRequest( - visitType: 5, // if equal 5 then this will return progress note + visitType: 5, + // if equal 5 then this will return progress note admissionNo: int.parse(patient.admissionNo), projectID: patient.projectId, tokenID: token, patientTypeID: patient.patientType, languageID: 2); - patientsProv.getPatientProgressNote(progressNoteRequest.toJson()).then((c){ - notesList = patientsProv.patientProgressNoteList; + model.getPatientProgressNote(progressNoteRequest.toJson()).then((c) { + notesList = model.patientProgressNoteList; }); } - @override - void didChangeDependencies() { - super.didChangeDependencies(); - if (_isInit) { - patientsProv = Provider.of(context); - getProgressNoteList(context); - notesList = patientsProv.patientProgressNoteList; - } - _isInit = false; - } @override Widget build(BuildContext context) { - return AppScaffold( - appBarTitle: TranslationBase.of(context).progressNote, - body: patientsProv.isLoading - ? DrAppCircularProgressIndeicator() - : patientsProv.isError - ? DrAppEmbeddedError(error: patientsProv.error) - : notesList == null || notesList.length == 0 - ? DrAppEmbeddedError( - error: TranslationBase.of(context).errorNoProgressNote) - : Column( - children: [ - Container( - margin: EdgeInsets.all(10), - width: SizeConfig.screenWidth * 0.80, - child: TextField( - controller: _controller, - onChanged: (String str) { - this.searchData(str); - }, - textInputAction: TextInputAction.done, - decoration: buildInputDecoration(context, + return BaseView( + onModelReady: (model) => getProgressNoteList(context, model), + builder: (_, model, w) => + AppScaffold( + baseViewModel: model, + appBarTitle: TranslationBase + .of(context) + .progressNote, + body: notesList == null || notesList.length == 0 + ? DrAppEmbeddedError( + error: TranslationBase + .of(context) + .errorNoProgressNote) + : Column( + children: [ + Container( + margin: EdgeInsets.all(10), + width: SizeConfig.screenWidth * 0.80, + child: TextField( + controller: _controller, + onChanged: (String str) { + this.searchData(str, model); + }, + textInputAction: TextInputAction.done, + decoration: buildInputDecoration(context, TranslationBase.of(context).searchNote), ), ), @@ -160,9 +152,9 @@ class _ProgressNoteState extends State { }), ), ), - ], - ), - ); + ], + ), + ),); } InputDecoration buildInputDecoration(BuildContext context, hint) { @@ -174,7 +166,7 @@ class _ProgressNoteState extends State { hintStyle: TextStyle(fontSize: 2 * SizeConfig.textMultiplier), enabledBorder: OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(10)), - borderSide: BorderSide(color: Hexcolor('#CCCCCC')), + borderSide: BorderSide(color: HexColor('#CCCCCC')), ), focusedBorder: OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(10.0)), @@ -182,21 +174,21 @@ class _ProgressNoteState extends State { )); } - searchData(String str) { + searchData(String str, PatientViewModel model) { var strExist = str.length > 0 ? true : false; if (strExist) { filteredNotesList = null; - filteredNotesList = patientsProv.patientProgressNoteList + filteredNotesList = model.patientProgressNoteList .where((note) => - note["DoctorName"].toString().contains(str.toUpperCase())) + note["DoctorName"].toString().contains(str.toUpperCase())) .toList(); setState(() { notesList = filteredNotesList; }); } else { setState(() { - notesList = patientsProv.patientProgressNoteList; + notesList = model.patientProgressNoteList; }); } } diff --git a/lib/screens/patients/profile/radiology/radiology_screen.dart b/lib/screens/patients/profile/radiology/radiology_screen.dart index 2d1790ee..cdab5bca 100644 --- a/lib/screens/patients/profile/radiology/radiology_screen.dart +++ b/lib/screens/patients/profile/radiology/radiology_screen.dart @@ -1,19 +1,18 @@ +import 'package:doctor_app_flutter/core/viewModel/patient_view_model.dart'; import 'package:doctor_app_flutter/models/patient/radiology/radiology_req_model.dart'; +import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/screens/patients/profile/radiology/radiology_report_screen.dart'; +import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/large_avatar.dart'; import 'package:doctor_app_flutter/widgets/shared/errors/dr_app_embedded_error.dart'; import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; import '../../../../config/shared_pref_kay.dart'; import '../../../../config/size_config.dart'; import '../../../../models/patient/patiant_info_model.dart'; -import '../../../../providers/patients_provider.dart'; import '../../../../util/dr_app_shared_pref.dart'; import '../../../../widgets/shared/app_scaffold_widget.dart'; import '../../../../widgets/shared/app_texts_widget.dart'; -import '../../../../widgets/shared/dr_app_circular_progress_Indeicator.dart'; -import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); @@ -31,8 +30,6 @@ class RadiologyScreen extends StatefulWidget { } class _RadiologyScreenState extends State { - PatientsProvider patientsProv; - var _isInit = true; /* *@author: Elham Rababah @@ -41,7 +38,7 @@ class _RadiologyScreenState extends State { *@return: *@desc: getRadiologyList Function */ - getRadiologyList(context) async { + getRadiologyList(context, PatientViewModel model) async { final routeArgs = ModalRoute.of(context).settings.arguments as Map; PatiantInformtion patient = routeArgs['patient']; String token = await sharedPref.getString(TOKEN); @@ -58,140 +55,136 @@ class _RadiologyScreenState extends State { patientTypeID: patient.patientType, languageID: 2, ); - patientsProv.getPatientRadiology(radiologyReqModel.toJson()); + model.getPatientRadiology(radiologyReqModel.toJson()); } - @override - void didChangeDependencies() { - super.didChangeDependencies(); - if (_isInit) { - patientsProv = Provider.of(context); - getRadiologyList(context); - } - _isInit = false; - } @override Widget build(BuildContext context) { - return AppScaffold( - appBarTitle: TranslationBase.of(context).radiology, - body: patientsProv.isLoading - ? DrAppCircularProgressIndeicator() - : patientsProv.isError - ? DrAppEmbeddedError(error: patientsProv.error) - : patientsProv.patientRadiologyList.length == 0 - ? DrAppEmbeddedError( - error: TranslationBase.of(context).youDoNotHaveAnyItem) - : Container( - margin: EdgeInsets.fromLTRB( - SizeConfig.realScreenWidth * 0.05, - 0, - SizeConfig.realScreenWidth * 0.05, - 0), - child: Container( - margin: EdgeInsets.symmetric(vertical: 10), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.all( - Radius.circular(20.0), + return BaseView( + onModelReady: (model) => getRadiologyList(context, model), + builder: (_, model, w) => + AppScaffold( + baseViewModel: model, + appBarTitle: TranslationBase + .of(context) + .radiology, + body: + model.patientRadiologyList.length == 0 + ? DrAppEmbeddedError( + error: TranslationBase + .of(context) + .youDoNotHaveAnyItem) + : Container( + margin: EdgeInsets.fromLTRB( + SizeConfig.realScreenWidth * 0.05, + 0, + SizeConfig.realScreenWidth * 0.05, + 0), + child: Container( + margin: EdgeInsets.symmetric(vertical: 10), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.all( + Radius.circular(20.0), + ), + ), + child: ListView.builder( + itemCount: model.patientRadiologyList.length, + itemBuilder: (BuildContext context, int index) { + return InkWell( + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => + RadiologyReportScreen( + reportData: model + .patientRadiologyList[index] + .reportData, + )), + ); + }, + child: Container( + padding: EdgeInsets.all(10), + margin: EdgeInsets.all(10), + decoration: BoxDecoration( + borderRadius: + BorderRadius.all(Radius.circular(10)), + border: Border( + bottom: BorderSide( + color: Colors.grey, width: 0.5), + top: BorderSide( + color: Colors.grey, width: 0.5), + left: BorderSide( + color: Colors.grey, width: 0.5), + right: BorderSide( + color: Colors.grey, width: 0.5), + ), ), - ), - child: ListView.builder( - itemCount: patientsProv.patientRadiologyList.length, - itemBuilder: (BuildContext context, int index) { - return InkWell( - onTap: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => - RadiologyReportScreen( - reportData: patientsProv - .patientRadiologyList[index] - .reportData, - )), - ); - }, - child: Container( - padding: EdgeInsets.all(10), - margin: EdgeInsets.all(10), - decoration: BoxDecoration( - borderRadius: - BorderRadius.all(Radius.circular(10)), - border: Border( - bottom: BorderSide( - color: Colors.grey, width: 0.5), - top: BorderSide( - color: Colors.grey, width: 0.5), - left: BorderSide( - color: Colors.grey, width: 0.5), - right: BorderSide( - color: Colors.grey, width: 0.5), - ), + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Row( + children: [ + LargeAvatar( + url: model + .patientRadiologyList[index] + .doctorImageURL, ), - child: Column( - crossAxisAlignment: + Expanded( + child: Padding( + padding: + const EdgeInsets.fromLTRB( + 8, 0, 0, 0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( children: [ - LargeAvatar( - url: patientsProv - .patientRadiologyList[index] - .doctorImageURL, + AppText( + '${model.patientRadiologyList[index].doctorName}', + fontSize: 2.5 * + SizeConfig + .textMultiplier, + fontWeight: + FontWeight.bold), + SizedBox( + height: 8, + ), + AppText( + 'Invoice No:${model.patientRadiologyList[index].invoiceNo}', + fontSize: 2 * + SizeConfig + .textMultiplier, + ), + SizedBox( + height: 8, + ), + AppText( + ' ${model.patientRadiologyList[index].clinicName}', + fontSize: 2 * + SizeConfig + .textMultiplier, + color: Theme.of(context) + .primaryColor, + ), + SizedBox( + height: 8, ), - Expanded( - child: Padding( - padding: - const EdgeInsets.fromLTRB( - 8, 0, 0, 0), - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - AppText( - '${patientsProv.patientRadiologyList[index].doctorName}', - fontSize: 2.5 * - SizeConfig - .textMultiplier, - fontWeight: - FontWeight.bold), - SizedBox( - height: 8, - ), - AppText( - 'Invoice No:${patientsProv.patientRadiologyList[index].invoiceNo}', - fontSize: 2 * - SizeConfig - .textMultiplier, - ), - SizedBox( - height: 8, - ), - AppText( - ' ${patientsProv.patientRadiologyList[index].clinicName}', - fontSize: 2 * - SizeConfig - .textMultiplier, - color: Theme.of(context) - .primaryColor, - ), - SizedBox( - height: 8, - ), - ], - ), - ), - ) ], ), - ], - ), - ), - ); - }), - ), - ), - ); + ), + ) + ], + ), + ], + ), + ), + ); + }), + ), + ), + ),); } } diff --git a/lib/screens/patients/profile/refer_patient_screen.dart b/lib/screens/patients/profile/refer_patient_screen.dart index 22ed20b5..dfb61d95 100644 --- a/lib/screens/patients/profile/refer_patient_screen.dart +++ b/lib/screens/patients/profile/refer_patient_screen.dart @@ -1,22 +1,22 @@ import 'package:doctor_app_flutter/config/config.dart'; +import 'package:doctor_app_flutter/core/viewModel/patient_view_model.dart'; import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; +import 'package:doctor_app_flutter/screens/base/base_view.dart'; +import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart'; +import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/shared/app_buttons_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_text_form_field.dart'; import 'package:doctor_app_flutter/widgets/shared/errors/dr_app_embedded_error.dart'; import 'package:doctor_app_flutter/widgets/shared/rounded_container_widget.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/scheduler.dart'; import 'package:hexcolor/hexcolor.dart'; import 'package:intl/intl.dart'; -import 'package:provider/provider.dart'; + import '../../../config/size_config.dart'; -import '../../../providers/patients_provider.dart'; import '../../../util/dr_app_shared_pref.dart'; +import '../../../util/extenstions.dart'; import '../../../widgets/shared/app_scaffold_widget.dart'; import '../../../widgets/shared/app_texts_widget.dart'; -import '../../../widgets/shared/dr_app_circular_progress_Indeicator.dart'; -import '../../../util/extenstions.dart'; -import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); @@ -34,7 +34,6 @@ class ReferPatientScreen extends StatefulWidget { } class _ReferPatientState extends State { - PatientsProvider patientsProv; var doctorsList; final _remarksController = TextEditingController(); final _extController = TextEditingController(); @@ -51,46 +50,32 @@ class _ReferPatientState extends State { int _activePriority = 1; - FocusNode myFocusNode; - - @override - void didChangeDependencies() { - super.didChangeDependencies(); - if (_isInit) { - myFocusNode = FocusNode(); - doctorsList = null; - patientsProv = Provider.of(context); - patientsProv.getClinicsList(); - patientsProv.getReferralFrequancyList(); - } - _isInit = false; - } + FocusNode myFocusNode = FocusNode(); @override Widget build(BuildContext context) { - return AppScaffold( - appBarTitle: TranslationBase.of(context).referralPatient, - body: patientsProv.isLoading - ? DrAppCircularProgressIndeicator() - : patientsProv.isError - ? DrAppEmbeddedError(error: patientsProv.error) - : patientsProv.clinicsList == null - ? DrAppEmbeddedError(error: 'Something Wrong!') - : SingleChildScrollView( - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - AppText( - TranslationBase.of(context).clinic, - fontSize: 18, - fontWeight: FontWeight.bold, - marginLeft: 15, - marginTop: 15, - ), - RoundedContainer( - margin: 10, - showBorder: true, + return BaseView( + onModelReady: (model) => model.getClinicsList(), + builder: (_, model, w) => AppScaffold( + baseViewModel: model, + appBarTitle: TranslationBase.of(context).referralPatient, + body: model.clinicsList == null + ? DrAppEmbeddedError(error: 'Something Wrong!') + : SingleChildScrollView( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AppText( + TranslationBase.of(context).clinic, + fontSize: 18, + fontWeight: FontWeight.bold, + marginLeft: 15, + marginTop: 15, + ), + RoundedContainer( + margin: 10, + showBorder: true, raduis: 10, borderColor: Color(0xff707070), width: double.infinity, @@ -106,14 +91,13 @@ class _ReferPatientState extends State { Expanded( // add Expanded to have your dropdown button fill remaining space child: DropdownButton( - //hint: Text('Select Clinnic'), isExpanded: true, value: _selectedClinic, iconSize: 40, elevation: 16, selectedItemBuilder: (BuildContext context) { - return patientsProv + return model .getClinicNameList() .map((item) { return Row( @@ -133,7 +117,7 @@ class _ReferPatientState extends State { setState(() { _selectedDoctor = null; _selectedClinic = newValue; - var clinicInfo = patientsProv + var clinicInfo = model .clinicsList .where((i) => i['ClinicDescription'] @@ -145,10 +129,10 @@ class _ReferPatientState extends State { clinicId = clinicInfo[0]['ClinicID'] .toString(); - patientsProv.getDoctorsList(clinicId); + model.getDoctorsList(clinicId); }) }, - items: patientsProv + items: model .getClinicNameList() .map((item) { return DropdownMenuItem( @@ -198,43 +182,27 @@ class _ReferPatientState extends State { elevation: 16, selectedItemBuilder: (BuildContext context) { - return _selectedDoctor == '' - ? [ - Row( - mainAxisSize: - MainAxisSize.max, - children: [ - AppText( - "eeeee", - fontSize: SizeConfig - .textMultiplier * - 2.1, - ), - ], - ) - ] - : patientsProv - .getDoctorNameList() - .map((item) { - return Row( - mainAxisSize: - MainAxisSize.max, - children: [ - AppText( - item, - fontSize: SizeConfig - .textMultiplier * - 2.1, - ), - ], - ); - }).toList(); + return model + .getDoctorNameList() + .map((item) { + return Row( + mainAxisSize: MainAxisSize.max, + children: [ + AppText( + item, + fontSize: + SizeConfig.textMultiplier * + 2.1, + ), + ], + ); + }).toList(); }, onChanged: (newValue) => { setState(() { _selectedDoctor = newValue; doctorsList = - patientsProv.doctorsList; + model.doctorsList; var doctorInfo = doctorsList .where((i) => i['DoctorName'] @@ -245,7 +213,7 @@ class _ReferPatientState extends State { .toString(); }) }, - items: patientsProv + items: model .getDoctorNameList() .map((item) { return DropdownMenuItem( @@ -279,6 +247,13 @@ class _ReferPatientState extends State { onChanged: (value) => {}, ), ), + AppText( + TranslationBase.of(context).priority, + fontSize: 18, + fontWeight: FontWeight.bold, + marginLeft: 15, + marginTop: 15, + ), priorityBar(context), @@ -321,7 +296,7 @@ class _ReferPatientState extends State { elevation: 16, selectedItemBuilder: (BuildContext context) { - return patientsProv + return model .getReferralNamesList() .map((item) { return Row( @@ -340,7 +315,7 @@ class _ReferPatientState extends State { onChanged: (newValue) => { setState(() { _selectedReferralFrequancy = newValue; - var freqInfo = patientsProv + var freqInfo = model .referalFrequancyList .singleWhere((i) => i[ 'Description'] @@ -352,7 +327,7 @@ class _ReferPatientState extends State { myFocusNode.requestFocus(); }) }, - items: patientsProv + items: model .getReferralNamesList() .map((item) { return DropdownMenuItem( @@ -399,17 +374,26 @@ class _ReferPatientState extends State { visibility: isValid == null ? false : !isValid, ), + // TODO replace AppButton with secondary button and add loading AppButton( + title: TranslationBase + .of(context) + .send, + color: Color(PRIMARY_COLOR), + onPressed: () => + { + referToDoctor(context, model) + }, title: TranslationBase.of(context).send, color: (Hexcolor("#B8382B")), onPressed: () => {referToDoctor(context)}, ) ], )) - ], - ), - ), - ); + ], + ), + ), + ),); } Widget priorityBar(BuildContext _context) { @@ -418,49 +402,39 @@ class _ReferPatientState extends State { TranslationBase.of(context).urgent.toUpperCase(), TranslationBase.of(context).routine.toUpperCase(), ]; - return Center( - child: Container( - height: MediaQuery.of(context).size.height * 0.061999, - width: SizeConfig.screenWidth * 0.90, - margin: EdgeInsets.only(top: 10), - decoration: BoxDecoration( - color: Color(0Xffffffff), - borderRadius: BorderRadius.circular(10), - border: Border.all(width: 0.3), - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - mainAxisSize: MainAxisSize.max, - crossAxisAlignment: CrossAxisAlignment.center, - children: _priorities.map((item) { - bool _isActive = - _priorities[_activePriority] == item ? true : false; - return Column(mainAxisSize: MainAxisSize.min, children: [ - InkWell( - child: Center( - child: Container( - height: MediaQuery.of(context).size.height * 0.0559, - width: SizeConfig.screenWidth * 0.297, - decoration: BoxDecoration( - borderRadius: BorderRadius.only( - topLeft: Radius.circular(8.0), - bottomLeft: Radius.circular(8.0), - topRight: Radius.circular(10.0), - bottomRight: Radius.circular(10.0), - ), - color: _isActive ? Hexcolor("#B8382B") : Colors.white, - ), - child: Center( - child: Text( - item, - style: TextStyle( - fontSize: 12, - color: _isActive - ? Colors.white - : Colors.black, //Colors.black, - // backgroundColor:_isActive - // ? Hexcolor("#B8382B") - // : Colors.white,//sideColor, + return Container( + height: MediaQuery.of(context).size.height * 0.065, + width: SizeConfig.screenWidth * 0.9, + margin: EdgeInsets.only(top: 10), + decoration: BoxDecoration( + color: Color(0Xffffffff), borderRadius: BorderRadius.circular(20)), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + mainAxisSize: MainAxisSize.max, + crossAxisAlignment: CrossAxisAlignment.center, + children: _priorities.map((item) { + bool _isActive = _priorities[_activePriority] == item ? true : false; + return Column(mainAxisSize: MainAxisSize.min, children: [ + InkWell( + child: Center( + child: Container( + height: 40, + width: 90, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(50), + color: _isActive ? HexColor("#B8382B") : Colors.white, + ), + child: Center( + child: Text( + item, + style: TextStyle( + fontSize: 12, + color: _isActive + ? Colors.white + : Colors.black, //Colors.black, + // backgroundColor:_isActive + // ? Hexcolor("#B8382B") + // : Colors.white,//sideColor, fontWeight: FontWeight.bold, ), @@ -509,25 +483,37 @@ class _ReferPatientState extends State { return time; } - void referToDoctor(context) { + referToDoctor(BuildContext context, PatientViewModel model) async { if (!validation()) { return; } - final routeArgs = ModalRoute.of(context).settings.arguments as Map; + final routeArgs = ModalRoute + .of(context) + .settings + .arguments as Map; PatiantInformtion patient = routeArgs['patient']; - patientsProv.referToDoctor(context, - extension: _extController.value.text, - admissionNo: int.parse(patient.admissionNo), - referringDoctorRemarks: _remarksController.value.text, - frequency: freqId, - patientID: patient.patientId, - patientTypeID: patient.patientType, - priority: (_activePriority + 1).toString(), - roomID: patient.roomId, - selectedClinicID: clinicId.toString(), - selectedDoctorID: doctorId.toString(), - projectID: patient.projectId); + + try { + await model.referToDoctor( + extension: _extController.value.text, + admissionNo: int.parse(patient.admissionNo), + referringDoctorRemarks: _remarksController.value.text, + frequency: freqId, + patientID: patient.patientId, + patientTypeID: patient.patientType, + priority: (_activePriority + 1).toString(), + roomID: patient.roomId, + selectedClinicID: clinicId.toString(), + selectedDoctorID: doctorId.toString(), + projectID: patient.projectId); + // TODO: Add Translation + DrAppToastMsg.showSuccesToast( + 'Reply Successfully'); + Navigator.pop(context); + } catch (e) { + DrAppToastMsg.showErrorToast(e); + } } bool validation() { diff --git a/lib/screens/patients/profile/vital_sign/vital_sign_details_screen.dart b/lib/screens/patients/profile/vital_sign/vital_sign_details_screen.dart index 7d00a7ae..cf8ee839 100644 --- a/lib/screens/patients/profile/vital_sign/vital_sign_details_screen.dart +++ b/lib/screens/patients/profile/vital_sign/vital_sign_details_screen.dart @@ -1,20 +1,19 @@ +import 'package:doctor_app_flutter/core/viewModel/patient_view_model.dart'; import 'package:doctor_app_flutter/models/patient/vital_sign/vital_sign_req_model.dart'; -import 'package:doctor_app_flutter/widgets/shared/dr_app_circular_progress_Indeicator.dart'; +import 'package:doctor_app_flutter/screens/base/base_view.dart'; +import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/shared/errors/dr_app_embedded_error.dart'; import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; import '../../../../config/shared_pref_kay.dart'; import '../../../../config/size_config.dart'; import '../../../../lookups/patient_lookup.dart'; import '../../../../models/patient/patiant_info_model.dart'; import '../../../../models/patient/vital_sign/vital_sign_res_model.dart'; -import '../../../../providers/patients_provider.dart'; import '../../../../routes.dart'; import '../../../../screens/patients/profile/vital_sign/vital_sign_item.dart'; import '../../../../util/dr_app_shared_pref.dart'; import '../../../../widgets/shared/app_scaffold_widget.dart'; -import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); @@ -28,8 +27,6 @@ class _VitalSignDetailsScreenState extends State { VitalSignResModel vitalSing; String url = "assets/images/"; - PatientsProvider patientsProv; - var _isInit = true; /* *@author: Elham Rababah @@ -38,7 +35,7 @@ class _VitalSignDetailsScreenState extends State { *@return: *@desc: getVitalSignList Function */ - getVitalSignList(context) async { + getVitalSignList(BuildContext context, PatientViewModel model) async { final routeArgs = ModalRoute.of(context).settings.arguments as Map; PatiantInformtion patient = routeArgs['patient']; String token = await sharedPref.getString(TOKEN); @@ -57,18 +54,10 @@ class _VitalSignDetailsScreenState extends State { languageID: 2, transNo: patient.admissionNo != null ? int.parse(patient.admissionNo) : 0); - patientsProv.getPatientVitalSign(vitalSignReqModel.toJson()); + model.getPatientVitalSign(vitalSignReqModel.toJson()); } - @override - void didChangeDependencies() { - super.didChangeDependencies(); - if (_isInit) { - patientsProv = Provider.of(context); - getVitalSignList(context); - } - _isInit = false; - } + final double contWidth = SizeConfig.realScreenWidth * 0.70; @@ -76,13 +65,12 @@ class _VitalSignDetailsScreenState extends State { Widget build(BuildContext context) { final routeArgs = ModalRoute.of(context).settings.arguments as Map; vitalSing = routeArgs['vitalSing']; - return AppScaffold( + return BaseView( + onModelReady: (model) => getVitalSignList(context, model), + builder: (_, model, w) => AppScaffold( + baseViewModel: model, appBarTitle: TranslationBase.of(context).vitalSign, - body: patientsProv.isLoading - ? DrAppCircularProgressIndeicator() - : patientsProv.isError - ? DrAppEmbeddedError(error: patientsProv.error) - : patientsProv.patientVitalSignOrderdSubList.length == 0 + body: model.patientVitalSignOrderdSubList.length == 0 ? DrAppEmbeddedError( error: 'You don\'t have any vital Sings') : Container( @@ -106,7 +94,7 @@ class _VitalSignDetailsScreenState extends State { des: TranslationBase.of(context) .bodyMeasurements, url: url + 'heartbeat.png', - lastVal: patientsProv + lastVal: model .patientVitalSignOrderdSubList[0] .heightCm .toString(), @@ -129,7 +117,7 @@ class _VitalSignDetailsScreenState extends State { des: TranslationBase.of(context) .temperature, url: url + 'heartbeat.png', - lastVal: patientsProv + lastVal: model .patientVitalSignOrderdSubList[0] .temperatureCelcius .toString(), @@ -154,7 +142,7 @@ class _VitalSignDetailsScreenState extends State { child: VitalSignItem( des: TranslationBase.of(context).pulse, url: url + 'heartbeat.png', - lastVal: patientsProv + lastVal: model .patientVitalSignOrderdSubList[0] .pulseBeatPerMinute .toString(), @@ -175,7 +163,7 @@ class _VitalSignDetailsScreenState extends State { des: TranslationBase.of(context).respiration, url: url + 'heartbeat.png', - lastVal: patientsProv + lastVal: model .patientVitalSignOrderdSubList[0] .respirationBeatPerMinute .toString(), @@ -200,7 +188,7 @@ class _VitalSignDetailsScreenState extends State { des: TranslationBase.of(context) .bloodPressure, url: url + 'heartbeat.png', - lastVal: patientsProv + lastVal: model .patientVitalSignOrderdSubList[0] .bloodPressure .toString(), @@ -221,7 +209,7 @@ class _VitalSignDetailsScreenState extends State { des: TranslationBase.of(context).oxygenation, url: url + 'heartbeat.png', - lastVal: patientsProv + lastVal: model .patientVitalSignOrderdSubList[0].fIO2 .toString(), unit: '', @@ -243,14 +231,16 @@ class _VitalSignDetailsScreenState extends State { }); }, child: VitalSignItem( - des: TranslationBase.of(context).painScale, + des: TranslationBase + .of(context) + .painScale, url: url + 'heartbeat.png', ), ), ], ), ], - ), - )); + ), + ),),); } } diff --git a/lib/screens/patients/profile/vital_sign/vital_sign_item.dart b/lib/screens/patients/profile/vital_sign/vital_sign_item.dart index d84d8ca0..1e0ce2cf 100644 --- a/lib/screens/patients/profile/vital_sign/vital_sign_item.dart +++ b/lib/screens/patients/profile/vital_sign/vital_sign_item.dart @@ -48,7 +48,7 @@ class VitalSignItem extends StatelessWidget { des, style: TextStyle( fontSize: 1.7 * SizeConfig.textMultiplier, - color: Hexcolor('#B8382C'), + color: HexColor('#B8382C'), fontWeight: FontWeight.bold), ), ), @@ -71,7 +71,7 @@ class VitalSignItem extends StatelessWidget { new TextSpan( text: ' ${unit}', style: TextStyle( - color: Hexcolor('#B8382C'), + color: HexColor('#B8382C'), ), ), ], diff --git a/lib/screens/patients/profile/vital_sign/vital_sign_item_details_screen.dart b/lib/screens/patients/profile/vital_sign/vital_sign_item_details_screen.dart index ef7c35fa..853bec15 100644 --- a/lib/screens/patients/profile/vital_sign/vital_sign_item_details_screen.dart +++ b/lib/screens/patients/profile/vital_sign/vital_sign_item_details_screen.dart @@ -1 +1 @@ -import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/shared/errors/dr_app_embedded_error.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../../../../lookups/patient_lookup.dart'; import '../../../../models/patient/vital_sign/vital_sign_res_model.dart'; import '../../../../providers/patients_provider.dart'; import '../../../../screens/patients/profile/vital_sign/vital_sing_chart_and_detials.dart'; import '../../../../widgets/shared/app_scaffold_widget.dart'; /* *@author: Elham Rababah *@Date:03/6/2020 *@param: *@return: *@desc: VitalSignItemDetailsScreen */ class VitalSignItemDetailsScreen extends StatelessWidget { VitalSignItemDetailsScreen(); // ; PatientsProvider patientsProv; List vitalList = []; String pageTitle; @override Widget build(BuildContext context) { patientsProv = Provider.of(context); final routeArgs = ModalRoute.of(context).settings.arguments as Map; pageTitle = routeArgs['title']; var pageKey = routeArgs['key']; List VSchart; vitalList = patientsProv.patientVitalSignOrderdSubList; switch (pageKey) { case vitalSignDetails.bodyMeasurements: VSchart = [ { 'name': 'Highet', 'title1': 'Date', 'title2': 'Cm', 'viewKey': 'HeightCm', }, { 'name': 'Weight Kg', 'title1': 'Date', 'title2': 'Kg', 'viewKey': 'WeightKg', }, { 'name': 'BodyMassIndex', 'title1': 'Date', 'title2': 'BodyMass', 'viewKey': 'BodyMassIndex', }, { 'name': 'HeadCircumCm', 'title1': 'Date', 'title2': 'Cm', 'viewKey': 'HeadCircumCm', }, { 'name': 'Ideal Body Weight (Lbs)', 'title1': 'Date', 'title2': 'Ideal Weight', 'viewKey': 'IdealBodyWeightLbs', }, { 'name': 'LeanBodyWeightLbs (Lbs)', 'title1': 'Date', 'title2': 'Lean Weight', 'viewKey': 'LeanBodyWeightLbs', } ]; break; case vitalSignDetails.temperature: VSchart = [ { 'name': 'Temperature In Celcius', 'title1': 'Date', 'title2': 'C', 'viewKey': 'TemperatureCelcius', }, ]; break; case vitalSignDetails.pulse: VSchart = [ { 'name': 'Pulse Beat Per Minute', 'title1': 'Date', 'title2': 'Minute', 'viewKey': 'PulseBeatPerMinute', }, ]; break; case vitalSignDetails.pespiration: VSchart = [ { 'name': 'Respiration Beat Per Minute', 'title1': 'Date', 'title2': 'Beat Per Minute', 'viewKey': 'RespirationBeatPerMinute', }, ]; break; case vitalSignDetails.bloodPressure: VSchart = [ { 'name': 'Blood Pressure Higher', 'title1': 'Date', 'title2': 'Minute', 'viewKey': 'BloodPressureHigher', }, { 'name': 'Blood Pressure Lower', 'title1': 'Date', 'title2': 'Minute', 'viewKey': 'BloodPressureLower', } ]; break; case vitalSignDetails.oxygenation: VSchart = [ { 'name': 'FIO2', 'title1': 'Date', 'title2': 'Cm', 'viewKey': 'FIO2', }, { 'name': 'SAO2', 'title1': 'Date', 'title2': 'Cm', 'viewKey': 'SAO2', }, ]; break; case vitalSignDetails.painScale: VSchart = [ { 'name': 'PainScore', 'title1': 'Date', 'title2': 'Cm', 'viewKey': 'PainScore', }, ]; break; default: } return AppScaffold( appBarTitle: pageTitle, body: ListView( children: VSchart.map((chartInfo) { var vitalListTemp = vitalList.where( (element) => element.toJson()[chartInfo['viewKey']] != null, ); return vitalListTemp.length != 0 ? VitalSingChartAndDetials( vitalList: vitalList, name: chartInfo['name'], title1: chartInfo['title1'], title2: chartInfo['title2'], viewKey: chartInfo['viewKey']) : Center( child: Container( margin: EdgeInsets.only( top: MediaQuery.of(context).size.height * 0.45), child: Center( child: DrAppEmbeddedError( error: TranslationBase.of(context).youDoNotHaveAnyItem), ), )); }).toList(), ), ); } } \ No newline at end of file +import 'package:doctor_app_flutter/core/viewModel/patient_view_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/shared/errors/dr_app_embedded_error.dart'; import 'package:flutter/material.dart'; import '../../../../lookups/patient_lookup.dart'; import '../../../../models/patient/vital_sign/vital_sign_res_model.dart'; import '../../../../screens/patients/profile/vital_sign/vital_sing_chart_and_detials.dart'; import '../../../../widgets/shared/app_scaffold_widget.dart'; /* *@author: Elham Rababah *@Date:03/6/2020 *@param: *@return: *@desc: VitalSignItemDetailsScreen */ class VitalSignItemDetailsScreen extends StatelessWidget { VitalSignItemDetailsScreen(); List vitalList = []; String pageTitle; @override Widget build(BuildContext context) { final routeArgs = ModalRoute.of(context).settings.arguments as Map; pageTitle = routeArgs['title']; var pageKey = routeArgs['key']; List VSchart; switch (pageKey) { case vitalSignDetails.bodyMeasurements: VSchart = [ { 'name': 'Highet', 'title1': 'Date', 'title2': 'Cm', 'viewKey': 'HeightCm', }, { 'name': 'Weight Kg', 'title1': 'Date', 'title2': 'Kg', 'viewKey': 'WeightKg', }, { 'name': 'BodyMassIndex', 'title1': 'Date', 'title2': 'BodyMass', 'viewKey': 'BodyMassIndex', }, { 'name': 'HeadCircumCm', 'title1': 'Date', 'title2': 'Cm', 'viewKey': 'HeadCircumCm', }, { 'name': 'Ideal Body Weight (Lbs)', 'title1': 'Date', 'title2': 'Ideal Weight', 'viewKey': 'IdealBodyWeightLbs', }, { 'name': 'LeanBodyWeightLbs (Lbs)', 'title1': 'Date', 'title2': 'Lean Weight', 'viewKey': 'LeanBodyWeightLbs', } ]; break; case vitalSignDetails.temperature: VSchart = [ { 'name': 'Temperature In Celcius', 'title1': 'Date', 'title2': 'C', 'viewKey': 'TemperatureCelcius', }, ]; break; case vitalSignDetails.pulse: VSchart = [ { 'name': 'Pulse Beat Per Minute', 'title1': 'Date', 'title2': 'Minute', 'viewKey': 'PulseBeatPerMinute', }, ]; break; case vitalSignDetails.pespiration: VSchart = [ { 'name': 'Respiration Beat Per Minute', 'title1': 'Date', 'title2': 'Beat Per Minute', 'viewKey': 'RespirationBeatPerMinute', }, ]; break; case vitalSignDetails.bloodPressure: VSchart = [ { 'name': 'Blood Pressure Higher', 'title1': 'Date', 'title2': 'Minute', 'viewKey': 'BloodPressureHigher', }, { 'name': 'Blood Pressure Lower', 'title1': 'Date', 'title2': 'Minute', 'viewKey': 'BloodPressureLower', } ]; break; case vitalSignDetails.oxygenation: VSchart = [ { 'name': 'FIO2', 'title1': 'Date', 'title2': 'Cm', 'viewKey': 'FIO2', }, { 'name': 'SAO2', 'title1': 'Date', 'title2': 'Cm', 'viewKey': 'SAO2', }, ]; break; case vitalSignDetails.painScale: VSchart = [ { 'name': 'PainScore', 'title1': 'Date', 'title2': 'Cm', 'viewKey': 'PainScore', }, ]; break; default: } return BaseView( onModelReady: (model) { vitalList = model.patientVitalSignOrderdSubList; }, builder: (_, model, w) => AppScaffold( baseViewModel: model, appBarTitle: pageTitle, body: ListView( children: VSchart.map((chartInfo) { var vitalListTemp = vitalList.where( (element) => element.toJson()[chartInfo['viewKey']] != null, ); return vitalListTemp.length != 0 ? VitalSingChartAndDetials( vitalList: vitalList, name: chartInfo['name'], title1: chartInfo['title1'], title2: chartInfo['title2'], viewKey: chartInfo['viewKey']) : Center( child: Container( margin: EdgeInsets.only( top: MediaQuery.of(context).size.height * 0.45), child: Center( child: DrAppEmbeddedError( error: TranslationBase.of(context).youDoNotHaveAnyItem), ), )); }).toList(), ), ), ); } } \ No newline at end of file diff --git a/lib/screens/patients/profile/vital_sign/vital_sign_screen.dart b/lib/screens/patients/profile/vital_sign/vital_sign_screen.dart deleted file mode 100644 index 64ab7bf3..00000000 --- a/lib/screens/patients/profile/vital_sign/vital_sign_screen.dart +++ /dev/null @@ -1,154 +0,0 @@ -import 'package:doctor_app_flutter/models/patient/vital_sign/vital_sign_req_model.dart'; -import 'package:doctor_app_flutter/routes.dart'; -import 'package:doctor_app_flutter/widgets/shared/errors/dr_app_embedded_error.dart'; -import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; - -import '../../../../config/shared_pref_kay.dart'; -import '../../../../config/size_config.dart'; -import '../../../../models/patient/patiant_info_model.dart'; -import '../../../../providers/patients_provider.dart'; -import '../../../../util/dr_app_shared_pref.dart'; -import '../../../../widgets/shared/app_scaffold_widget.dart'; -import '../../../../widgets/shared/app_texts_widget.dart'; -import '../../../../widgets/shared/card_with_bg_widget.dart'; -import '../../../../widgets/shared/dr_app_circular_progress_Indeicator.dart'; -import '../../../../widgets/shared/profile_image_widget.dart'; - -DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); - -/* - *@author: Elham Rababah - *@Date:26/4/2020 - *@param: - *@return:VitalSignScreen - *@desc: VitalSignScreen class - */ - -class VitalSignScreen extends StatefulWidget { - @override - _VitalSignScreenState createState() => _VitalSignScreenState(); -} - -class _VitalSignScreenState extends State { - PatientsProvider patientsProv; - var _isInit = true; - - /* - *@author: Elham Rababah - *@Date:28/4/2020 - *@param: context - *@return: - *@desc: getVitalSignList Function - */ - getVitalSignList(context) async { - final routeArgs = ModalRoute.of(context).settings.arguments as Map; - PatiantInformtion patient = routeArgs['patient']; - String token = await sharedPref.getString(TOKEN); - String type = await sharedPref.getString(SLECTED_PATIENT_TYPE); - int inOutpatientType = 1; - if (type == '0') { - inOutpatientType = 2; - } - print(type); - VitalSignReqModel vitalSignReqModel = VitalSignReqModel( - patientID: patient.patientId, - projectID: patient.projectId, - tokenID: token, - patientTypeID: patient.patientType, - inOutpatientType: inOutpatientType, - languageID: 2, - transNo: - patient.admissionNo != null ? int.parse(patient.admissionNo) : 0); - patientsProv.getPatientVitalSign(vitalSignReqModel.toJson()); - } - - @override - void didChangeDependencies() { - super.didChangeDependencies(); - if (_isInit) { - patientsProv = Provider.of(context); - getVitalSignList(context); - } - _isInit = false; - } - - @override - Widget build(BuildContext context) { - return AppScaffold( - appBarTitle: "VITAL SIGN", - body: patientsProv.isLoading - ? DrAppCircularProgressIndeicator() - : patientsProv.isError - ? DrAppEmbeddedError(error: patientsProv.error) - : patientsProv.patientVitalSignList.length == 0 - ? DrAppEmbeddedError(error: 'You don\'t have any Vital Sign') - : Container( - margin: EdgeInsets.fromLTRB( - SizeConfig.realScreenWidth * 0.05, - 0, - SizeConfig.realScreenWidth * 0.05, - 0), - child: ListView.builder( - itemCount: patientsProv.patientVitalSignList.length, - itemBuilder: (BuildContext ctxt, int index) { - return InkWell( - child: CardWithBgWidget( - widget: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - ProfileImageWidget( - url: patientsProv - .patientVitalSignList[index] - .doctorImageURL), - Expanded( - child: Padding( - padding: const EdgeInsets.fromLTRB( - 8, 0, 0, 0), - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - AppText( - '${patientsProv.patientVitalSignList[index].doctorName}', - fontSize: 2.5 * - SizeConfig.textMultiplier, - fontWeight: FontWeight.bold, - ), - SizedBox( - height: 8, - ), - AppText( - ' ${patientsProv.patientVitalSignList[index].clinicName}', - fontSize: 2 * - SizeConfig.textMultiplier, - color: Theme.of(context) - .primaryColor, - ), - SizedBox( - height: 8, - ), - ], - ), - ), - ) - ], - ), - ], - ), - ), - onTap: () { - Navigator.of(context) - .pushNamed(VITAL_SIGN_DETAILS, arguments: { - 'vitalSing': - patientsProv.patientVitalSignList[index] - }); - }, - ); - }), - ), - ); - } -} diff --git a/lib/screens/settings/settings_screen.dart b/lib/screens/settings/settings_screen.dart index c205f49d..79cd827e 100644 --- a/lib/screens/settings/settings_screen.dart +++ b/lib/screens/settings/settings_screen.dart @@ -1,5 +1,5 @@ -import 'package:doctor_app_flutter/providers/project_provider.dart'; -import 'package:doctor_app_flutter/providers/hospital_provider.dart'; +import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; +import 'package:doctor_app_flutter/core/viewModel/hospital_view_model.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; @@ -34,7 +34,7 @@ class SettingsScreen extends StatelessWidget { child: AnimatedContainer( duration: Duration(milliseconds: 350), decoration: BoxDecoration( - color: !projectsProvider.isArabic ? Hexcolor('#58434F') : Colors.transparent, + color: !projectsProvider.isArabic ? HexColor('#58434F') : Colors.transparent, border: Border(right: BorderSide(color: Colors.grey[200], width: 2.0)) ), child: Center(child: AppText(TranslationBase.of(context).lanEnglish, color: !projectsProvider.isArabic ? Colors.white : Colors.grey[500])) @@ -47,7 +47,7 @@ class SettingsScreen extends StatelessWidget { child: AnimatedContainer( duration: Duration(milliseconds: 350), decoration: BoxDecoration( - color: projectsProvider.isArabic ? Hexcolor('#58434F') : Colors.transparent, + color: projectsProvider.isArabic ? HexColor('#58434F') : Colors.transparent, border: Border(right: BorderSide(color: Colors.grey[200], width: 2.0)) ), child: Center(child: AppText(TranslationBase.of(context).lanArabic, color: projectsProvider.isArabic ? Colors.white : Colors.grey[500],)) diff --git a/lib/util/translations_delegate_base.dart b/lib/util/translations_delegate_base.dart index 313012fb..b0c12122 100644 --- a/lib/util/translations_delegate_base.dart +++ b/lib/util/translations_delegate_base.dart @@ -33,6 +33,8 @@ class TranslationBase { String get mobileNo => localizedValues['mobileNo'][locale.languageCode]; + String get replySuccessfully => localizedValues['replySuccessfully'][locale.languageCode]; + String get messagesScreenToolbarTitle => localizedValues['messagesScreenToolbarTitle'][locale.languageCode]; diff --git a/lib/widgets/auth/auth_header.dart b/lib/widgets/auth/auth_header.dart index fb2cf322..8ab79b5c 100644 --- a/lib/widgets/auth/auth_header.dart +++ b/lib/widgets/auth/auth_header.dart @@ -108,7 +108,7 @@ class AuthHeader extends StatelessWidget { Text( text2, style: TextStyle( - color: Hexcolor('#B8382C'), + color: HexColor('#B8382C'), fontSize: textFontSize, fontWeight: FontWeight.w800), ) @@ -156,7 +156,7 @@ class AuthHeader extends StatelessWidget { fontSize: SizeConfig.isMobile ? 26 : SizeConfig.realScreenWidth * 0.030, fontWeight: FontWeight.w800, - color: Hexcolor('#B8382C')), + color: HexColor('#B8382C')), ), ); } @@ -172,7 +172,7 @@ class AuthHeader extends StatelessWidget { style: TextStyle( fontWeight: FontWeight.w800, fontSize: SizeConfig.isMobile ? 24 : SizeConfig.realScreenWidth * 0.029, - color: Hexcolor('#B8382C'), + color: HexColor('#B8382C'), ), ); } diff --git a/lib/widgets/auth/change_password.dart b/lib/widgets/auth/change_password.dart index 020c0472..3eb9b975 100644 --- a/lib/widgets/auth/change_password.dart +++ b/lib/widgets/auth/change_password.dart @@ -30,7 +30,7 @@ class ChangePassword extends StatelessWidget { TextStyle(fontSize: 2 * SizeConfig.textMultiplier), enabledBorder: OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(20)), - borderSide: BorderSide(color: Hexcolor('#CCCCCC')), + borderSide: BorderSide(color: HexColor('#CCCCCC')), ), focusedBorder: OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(10.0)), @@ -69,7 +69,7 @@ class ChangePassword extends StatelessWidget { TextStyle(fontSize: 2 * SizeConfig.textMultiplier), enabledBorder: OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(20)), - borderSide: BorderSide(color: Hexcolor('#CCCCCC')), + borderSide: BorderSide(color: HexColor('#CCCCCC')), ), focusedBorder: OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(10.0)), @@ -98,7 +98,7 @@ class ChangePassword extends StatelessWidget { TextStyle(fontSize: 2 * SizeConfig.textMultiplier), enabledBorder: OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(20)), - borderSide: BorderSide(color: Hexcolor('#CCCCCC')), + borderSide: BorderSide(color: HexColor('#CCCCCC')), ), focusedBorder: OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(10.0)), @@ -137,7 +137,7 @@ class ChangePassword extends StatelessWidget { ), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10), - side: BorderSide(width: 0.5, color: Hexcolor('#CCCCCC'))), + side: BorderSide(width: 0.5, color: HexColor('#CCCCCC'))), ), SizedBox( height: 10, diff --git a/lib/widgets/auth/known_user_login.dart b/lib/widgets/auth/known_user_login.dart index 317d7e39..4df37d66 100644 --- a/lib/widgets/auth/known_user_login.dart +++ b/lib/widgets/auth/known_user_login.dart @@ -8,7 +8,7 @@ import 'package:provider/provider.dart'; import 'package:shared_preferences/shared_preferences.dart'; import '../../config/size_config.dart'; -import '../../providers/auth_provider.dart'; +import '../../core/viewModel/auth_view_model.dart'; import '../../routes.dart'; import '../../util/dr_app_shared_pref.dart'; import '../../util/dr_app_toast_msg.dart'; @@ -69,7 +69,7 @@ class _KnownUserLoginState extends State { @override Widget build(BuildContext context) { - AuthProvider authProv = Provider.of(context); + AuthViewModel authProv = Provider.of(context); var imeiModel = {'IMEI': _platformImei}; _loginTypeFuture = authProv.selectDeviceImei(imeiModel); return FutureBuilder( @@ -97,7 +97,7 @@ class _KnownUserLoginState extends State { Container( decoration: BoxDecoration( border: Border.all( - color: Hexcolor('#CCCCCC'), + color: HexColor('#CCCCCC'), ), borderRadius: BorderRadius.circular(50)), margin: const EdgeInsets.fromLTRB(0, 20.0, 30, 0), @@ -111,7 +111,7 @@ class _KnownUserLoginState extends State { // color: Colors.green, // border color shape: BoxShape.circle, border: - Border.all(color: Hexcolor('#CCCCCC'))), + Border.all(color: HexColor('#CCCCCC'))), child: CircleAvatar( child: Image.asset( 'assets/images/dr_avatar.png', @@ -129,7 +129,7 @@ class _KnownUserLoginState extends State { _loggedUser['List_MemberInformation'][0] ['MemberName'], style: TextStyle( - color: Hexcolor('515A5D'), + color: HexColor('515A5D'), fontSize: 2.5 * SizeConfig.textMultiplier, fontWeight: FontWeight.w800), @@ -137,7 +137,7 @@ class _KnownUserLoginState extends State { Text( 'ENT Spec', style: TextStyle( - color: Hexcolor('515A5D'), + color: HexColor('515A5D'), fontSize: 1.5 * SizeConfig.textMultiplier), ) @@ -203,7 +203,7 @@ class _KnownUserLoginState extends State { ), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10), - side: BorderSide(width: 0.5, color: Hexcolor('#CCCCCC'))), + side: BorderSide(width: 0.5, color: HexColor('#CCCCCC'))), ), SizedBox( height: 10, diff --git a/lib/widgets/auth/login_form.dart b/lib/widgets/auth/login_form.dart index b87cc800..8cf5f3d4 100644 --- a/lib/widgets/auth/login_form.dart +++ b/lib/widgets/auth/login_form.dart @@ -10,8 +10,8 @@ import 'package:provider/provider.dart'; import '../../config/shared_pref_kay.dart'; import '../../config/size_config.dart'; import '../../models/doctor/user_model.dart'; -import '../../providers/auth_provider.dart'; -import '../../providers/hospital_provider.dart'; +import '../../core/viewModel/auth_view_model.dart'; +import '../../core/viewModel/hospital_view_model.dart'; import '../../routes.dart'; import '../../util/dr_app_shared_pref.dart'; import '../../util/dr_app_toast_msg.dart'; @@ -51,7 +51,7 @@ class _LoginFormState extends State { channel: 9, sessionID: "i1UJwCTSqt"); - AuthProvider authProv; + AuthViewModel authProv; @override void initState() { super.initState(); @@ -61,7 +61,7 @@ class _LoginFormState extends State { @override void didChangeDependencies() { super.didChangeDependencies(); - authProv = Provider.of(context); + authProv = Provider.of(context); if (_isInit) { if (projectsList.length == 0) { @@ -159,7 +159,7 @@ class _LoginFormState extends State { padding: const EdgeInsets.all(0.0), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10), - side: BorderSide(width: 0.5, color: Hexcolor('#CCCCCC'))), + side: BorderSide(width: 0.5, color: HexColor('#CCCCCC'))), child: Container( padding: const EdgeInsets.all(10.0), height: 50, @@ -199,7 +199,7 @@ class _LoginFormState extends State { hintStyle: TextStyle(fontSize: 2 * SizeConfig.textMultiplier), enabledBorder: OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(20)), - borderSide: BorderSide(color: Hexcolor('#CCCCCC')), + borderSide: BorderSide(color: HexColor('#CCCCCC')), ), focusedBorder: OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(10.0)), @@ -222,7 +222,7 @@ class _LoginFormState extends State { ); } - login(context, AuthProvider authProv, Function changeLoadingStata) { + login(context, AuthViewModel authProv, Function changeLoadingStata) { FocusScopeNode currentFocus = FocusScope.of(context); // if (!currentFocus.hasPrimaryFocus) { @@ -258,7 +258,7 @@ class _LoginFormState extends State { } } - insertDeviceImei(preRes, AuthProvider authProv) { + insertDeviceImei(preRes, AuthViewModel authProv) { if (_platformImei != 'Unknown') { var imeiInfo = { "IMEI": _platformImei, @@ -323,7 +323,7 @@ class _LoginFormState extends State { } getProjectsList() { - HospitalProvider projectsProv = Provider.of(context); + HospitalViewModel projectsProv = Provider.of(context); projectsProv.getProjectsList().then((res) { if (res['MessageStatus'] == 1) { setState(() { diff --git a/lib/widgets/auth/show_timer_text.dart b/lib/widgets/auth/show_timer_text.dart index 1b77fd9a..fd09ec25 100644 --- a/lib/widgets/auth/show_timer_text.dart +++ b/lib/widgets/auth/show_timer_text.dart @@ -2,12 +2,13 @@ import 'dart:async'; import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/config/size_config.dart'; -import 'package:doctor_app_flutter/providers/auth_provider.dart'; -import 'package:doctor_app_flutter/providers/patients_provider.dart'; +import 'package:doctor_app_flutter/core/viewModel/auth_view_model.dart'; import 'package:doctor_app_flutter/routes.dart'; +import 'package:doctor_app_flutter/util/helpers.dart'; import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; import 'package:provider/provider.dart'; +Helpers helpers = Helpers(); class ShowTimerText extends StatefulWidget { ShowTimerText({Key key, this.model}); @@ -23,7 +24,7 @@ class _ShowTimerTextState extends State { int sec = 59; Timer _timer; - AuthProvider authProv; + AuthViewModel authProv; resendCode() { min = TIMER_MIN - 1; @@ -63,7 +64,7 @@ class _ShowTimerTextState extends State { @override Widget build(BuildContext context) { - authProv = Provider.of(context); + authProv = Provider.of(context); return Center( child: Row( mainAxisAlignment: MainAxisAlignment.center, @@ -78,7 +79,7 @@ class _ShowTimerTextState extends State { timerText, style: TextStyle( fontSize: 3.0 * SizeConfig.textMultiplier, - color: Hexcolor('#B8382C'), + color: HexColor('#B8382C'), fontWeight: FontWeight.bold), ), ), diff --git a/lib/widgets/auth/verfiy_account.dart b/lib/widgets/auth/verfiy_account.dart index 8a43a42f..43e9e988 100644 --- a/lib/widgets/auth/verfiy_account.dart +++ b/lib/widgets/auth/verfiy_account.dart @@ -10,7 +10,7 @@ import 'package:hexcolor/hexcolor.dart'; import 'package:provider/provider.dart'; import '../../config/size_config.dart'; -import '../../providers/auth_provider.dart'; +import '../../core/viewModel/auth_view_model.dart'; import '../../routes.dart'; import '../../util/dr_app_shared_pref.dart'; import '../../util/dr_app_toast_msg.dart'; @@ -40,7 +40,7 @@ class _VerifyAccountState extends State { }; Future _loggedUserFuture; var _loggedUser; - AuthProvider authProv; + AuthViewModel authProv; bool _isInit = true; var model; TextEditingController digit1 = TextEditingController(text: ""); @@ -64,7 +64,7 @@ class _VerifyAccountState extends State { void didChangeDependencies() { super.didChangeDependencies(); if (_isInit) { - authProv = Provider.of(context); + authProv = Provider.of(context); final routeArgs = ModalRoute.of(context).settings.arguments as Map; model = routeArgs['model']; } @@ -73,7 +73,7 @@ class _VerifyAccountState extends State { @override Widget build(BuildContext context) { - authProv = Provider.of(context); + authProv = Provider.of(context); final focusD1 = FocusNode(); final focusD2 = FocusNode(); final focusD3 = FocusNode(); @@ -227,7 +227,7 @@ class _VerifyAccountState extends State { borderRadius: BorderRadius.circular(10), side: BorderSide( width: 0.5, - color: Hexcolor('#CCCCCC'))), + color: HexColor('#CCCCCC'))), ), buildSizedBox(20), ShowTimerText(model: model), @@ -335,7 +335,7 @@ class _VerifyAccountState extends State { *@return: *@desc: verify Account func call sendActivationCodeByOtpNotificationType service */ - verifyAccount(AuthProvider authProv, Function changeLoadingStata) async { + verifyAccount(AuthViewModel authProv, Function changeLoadingStata) async { if (verifyAccountForm.currentState.validate()) { changeLoadingStata(true); diff --git a/lib/widgets/auth/verification_methods.dart b/lib/widgets/auth/verification_methods.dart index 6360c352..2102a125 100644 --- a/lib/widgets/auth/verification_methods.dart +++ b/lib/widgets/auth/verification_methods.dart @@ -6,7 +6,7 @@ import 'package:hexcolor/hexcolor.dart'; import 'package:provider/provider.dart'; import '../../config/size_config.dart'; -import '../../providers/auth_provider.dart'; +import '../../core/viewModel/auth_view_model.dart'; import '../../routes.dart'; import '../../util/dr_app_shared_pref.dart'; import '../../util/helpers.dart'; @@ -57,7 +57,7 @@ class _VerificationMethodsState extends State { @override Widget build(BuildContext context) { - AuthProvider authProv = Provider.of(context); + AuthViewModel authProv = Provider.of(context); return FutureBuilder( future: Future.wait([_loggedUserFuture]), builder: (BuildContext context, AsyncSnapshot snapshot) { @@ -145,7 +145,7 @@ class _VerificationMethodsState extends State { *@return: Center widget *@desc: buildSMSMethod Methods widget */ - Center buildSMSMethod(BuildContext context, AuthProvider authProv) { + Center buildSMSMethod(BuildContext context, AuthViewModel authProv) { return buildVerificationMethod( context, 'assets/images/verification_sms_icon.png', @@ -161,7 +161,7 @@ class _VerificationMethodsState extends State { *@return: Center widget *@desc: build WhatsApp Methods widget */ - Center buildWhatsAppMethod(BuildContext context, AuthProvider authProv) { + Center buildWhatsAppMethod(BuildContext context, AuthViewModel authProv) { return buildVerificationMethod( context, 'assets/images/verification_whatsapp_icon.png', @@ -177,7 +177,7 @@ class _VerificationMethodsState extends State { *@return: Center widget *@desc: build FaceID Methods widget */ - Center buildFaceIDMethod(BuildContext context, AuthProvider authProv) { + Center buildFaceIDMethod(BuildContext context, AuthViewModel authProv) { return buildVerificationMethod( context, 'assets/images/verification_faceid_icon.png', @@ -193,7 +193,7 @@ class _VerificationMethodsState extends State { *@return: Center widget *@desc: build Fingerprint Methods widget */ - Center buildFingerprintMethod(BuildContext context, AuthProvider authProv) { + Center buildFingerprintMethod(BuildContext context, AuthViewModel authProv) { return buildVerificationMethod( context, 'assets/images/verification_fingerprint_icon.png', @@ -222,7 +222,7 @@ class _VerificationMethodsState extends State { decoration: BoxDecoration( border: Border.all( width: 1, - color: Hexcolor( + color: HexColor( '#CCCCCC') // <--- border width here ), borderRadius: BorderRadius.all(Radius.circular(10))), @@ -262,7 +262,7 @@ class _VerificationMethodsState extends State { *@return: *@desc: send Activation Code By Otp Notification Type */ - sendActivationCodeByOtpNotificationType(oTPSendType, AuthProvider authProv) { + sendActivationCodeByOtpNotificationType(oTPSendType, AuthViewModel authProv) { // TODO : build enum for verfication method if (oTPSendType == 1 || oTPSendType == 2) { widget.changeLoadingStata(true); diff --git a/lib/widgets/dashboard/dashboard_item_texts_widget.dart b/lib/widgets/dashboard/dashboard_item_texts_widget.dart index cd52e064..c3e4986d 100644 --- a/lib/widgets/dashboard/dashboard_item_texts_widget.dart +++ b/lib/widgets/dashboard/dashboard_item_texts_widget.dart @@ -1,4 +1,4 @@ -import 'package:doctor_app_flutter/providers/project_provider.dart'; +import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; import 'package:provider/provider.dart'; import '../shared/rounded_container_widget.dart'; diff --git a/lib/widgets/doctor/doctor_reply_widget.dart b/lib/widgets/doctor/doctor_reply_widget.dart index 51f0e94d..e9126ba3 100644 --- a/lib/widgets/doctor/doctor_reply_widget.dart +++ b/lib/widgets/doctor/doctor_reply_widget.dart @@ -28,7 +28,7 @@ class _DoctorReplyWidgetState extends State { margin: EdgeInsets.symmetric(vertical: 10.0), width: double.infinity, decoration: BoxDecoration( - color: Hexcolor('#FFFFFF'), + color: HexColor('#FFFFFF'), borderRadius: BorderRadius.all( Radius.circular(20.0), ), diff --git a/lib/widgets/doctor/lab_result_widget.dart b/lib/widgets/doctor/lab_result_widget.dart index 3f6facce..8b2ab0c4 100644 --- a/lib/widgets/doctor/lab_result_widget.dart +++ b/lib/widgets/doctor/lab_result_widget.dart @@ -81,7 +81,7 @@ class _LabResultWidgetState extends State { Expanded( child: Container( decoration: BoxDecoration( - color: Hexcolor('#515B5D'), + color: HexColor('#515B5D'), borderRadius: BorderRadius.only( topLeft: Radius.circular(10.0), ), @@ -98,7 +98,7 @@ class _LabResultWidgetState extends State { ), Expanded( child: Container( - color: Hexcolor('#515B5D'), + color: HexColor('#515B5D'), child: Center( child: Texts( TranslationBase.of(context).value, @@ -109,7 +109,7 @@ class _LabResultWidgetState extends State { Expanded( child: Container( decoration: BoxDecoration( - color: Hexcolor('#515B5D'), + color: HexColor('#515B5D'), borderRadius: BorderRadius.only( topRight: Radius.circular(10.0), ), diff --git a/lib/widgets/doctor/my_referral_patient_widget.dart b/lib/widgets/doctor/my_referral_patient_widget.dart index 46167975..98371a9f 100644 --- a/lib/widgets/doctor/my_referral_patient_widget.dart +++ b/lib/widgets/doctor/my_referral_patient_widget.dart @@ -10,13 +10,18 @@ import 'package:doctor_app_flutter/widgets/shared/TextFields.dart'; import 'package:doctor_app_flutter/widgets/shared/app_button.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/card_with_bgNew_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/expandable-widget-header-body.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; class MyReferralPatientWidget extends StatefulWidget { final MyReferralPatientModel myReferralPatientModel; final ReferralPatientViewModel model; - MyReferralPatientWidget({Key key, this.myReferralPatientModel, this.model}); + final bool isExpand; + final Function expandClick; + + MyReferralPatientWidget({Key key, this.myReferralPatientModel, this.model, this.isExpand, this.expandClick}); @override _MyReferralPatientWidgetState createState() => @@ -24,7 +29,6 @@ class MyReferralPatientWidget extends StatefulWidget { } class _MyReferralPatientWidgetState extends State { - bool _showDetails = false; bool _isLoading = false; final _formKey = GlobalKey(); String error; @@ -39,299 +43,416 @@ class _MyReferralPatientWidgetState extends State { @override Widget build(BuildContext context) { - return CardWithBgWidgetNew( - widget: Container( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - InkWell( - onTap: () { - setState(() { - _showDetails = !_showDetails; - }); - }, - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - AppText( - '${widget.myReferralPatientModel.firstName} ${widget.myReferralPatientModel.lastName}', - fontSize: 2.5 * SizeConfig.textMultiplier, - fontWeight: FontWeight.bold, - ), - Icon(_showDetails - ? Icons.keyboard_arrow_up - : Icons.keyboard_arrow_down), - ], - ), - ), - !_showDetails - ? Container() - : AnimatedContainer( - duration: Duration(milliseconds: 200), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - height: 5, - ), - Divider( - color: Color(0xFF000000), - height: 0.5, + return Container( + width: double.infinity, + margin: EdgeInsets.symmetric(horizontal: 8), + padding: EdgeInsets.only(left: 0, top: 8, right: 0, bottom: 0), + decoration: BoxDecoration( + shape: BoxShape.rectangle, + borderRadius: BorderRadius.circular(8), + border: Border.fromBorderSide(BorderSide( + color: Color(0xffCCCCCC), + width: 2, + )), + color: Color(0xffffffff), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + HeaderBodyExpandableNotifier( + headerWidget: Column( + children: [ + Container( + padding: + EdgeInsets.only(left: 16, top: 8, right: 8, bottom: 0), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + color: Color(0xFFB8382C), + padding: EdgeInsets.symmetric( + vertical: 4, horizontal: 4), + child: AppText( + '${widget.myReferralPatientModel.priorityDescription}', + fontSize: 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.bold, + textAlign: TextAlign.start, + color: Colors.white, + ), + ), + SizedBox( + height: 10, + ), + AppText( + '${widget.myReferralPatientModel.firstName} ${widget.myReferralPatientModel.middleName} ${widget.myReferralPatientModel.lastName}', + fontSize: 2 * SizeConfig.textMultiplier, + fontWeight: FontWeight.bold, + textAlign: TextAlign.start, + color: Colors.black, + ), + SizedBox( + height: 10, + ), + Row( + children: [ + AppText( + TranslationBase.of(context).fileNo, + fontSize: 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.bold, + textAlign: TextAlign.start, + color: Colors.black, + ), + SizedBox( + width: 20, + ), + AppText( + '${widget.myReferralPatientModel.referralDoctor}', + fontSize: 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.normal, + textAlign: TextAlign.start, + color: Colors.black, + ), + ], + ), + ], ), - Table( - border: TableBorder.symmetric( - inside: BorderSide(width: 0.5), + ), + Container( + margin: + EdgeInsets.symmetric(horizontal: 8, vertical: 8), + child: InkWell( + onTap: widget.expandClick, + child: Image.asset( + "assets/images/ic_circle_arrow.png", + width: 25, + height: 25, + color: Colors.black, ), - children: [ - TableRow(children: [ - Container( - margin: EdgeInsets.all(2.5), - padding: EdgeInsets.all(5), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - AppText( - TranslationBase.of(context).fileNo, - fontSize: 1.7 * SizeConfig.textMultiplier, - fontWeight: FontWeight.bold, - ), - SizedBox( - height: 5, - ), - AppText( - '${widget.myReferralPatientModel.referringDoctor}', - fontSize: 1.7 * SizeConfig.textMultiplier, - fontWeight: FontWeight.w300, - ) - ], + ), + ) + ], + ), + ), + SizedBox( + height: 10, + ), + ], + ), + bodyWidget: Container( + child: Column( + children: [ + const Divider( + color: Color(0xffCCCCCC), + height: 1, + thickness: 2, + indent: 0, + endIndent: 0, + ), + Container( + height: 1.8 * SizeConfig.textMultiplier * 6, + padding: + EdgeInsets.only(left: 16, top: 0, right: 8, bottom: 0), + child: Expanded( + child: Row( + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + height: 8, ), - ), - Container( - margin: EdgeInsets.only( - left: 4, top: 2.5, right: 2.5, bottom: 2.5), - padding: EdgeInsets.all(5), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - AppText( - TranslationBase.of(context) - .referralDoctor, - fontSize: 1.7 * SizeConfig.textMultiplier, - fontWeight: FontWeight.bold, - ), - SizedBox( - height: 5, - ), - AppText( - widget.myReferralPatientModel - .referringClinicDescription, - fontSize: 1.7 * SizeConfig.textMultiplier, - fontWeight: FontWeight.w300, - ) - ], + SizedBox( + child: AppText( + TranslationBase.of(context).referralDoctor, + fontSize: 1.9 * SizeConfig.textMultiplier, + fontWeight: FontWeight.bold, + textAlign: TextAlign.start, + color: Colors.black, + ), ), - ), - ]), - TableRow(children: [ - Container( - margin: EdgeInsets.all(2.5), - padding: EdgeInsets.all(5), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - AppText( - TranslationBase.of(context) - .referringClinic, - fontSize: 1.7 * SizeConfig.textMultiplier, - fontWeight: FontWeight.bold, - ), - SizedBox( - height: 5, - ), - AppText( - '${widget.myReferralPatientModel.referringClinicDescription}', - fontSize: 1.7 * SizeConfig.textMultiplier, - fontWeight: FontWeight.w300, - ) - ], + SizedBox( + height: 4, + ), + SizedBox( + child: AppText( + '${widget.myReferralPatientModel.referringDoctorName}', + fontSize: 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.normal, + textAlign: TextAlign.start, + color: Colors.black, + ), ), + SizedBox( + height: 8, + ), + ], + ), + ), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 8), + child: SizedBox( + child: Container( + color: Color(0xffCCCCCC), ), - Container( - margin: EdgeInsets.only( - left: 4, top: 2.5, right: 2.5, bottom: 2.5), - padding: EdgeInsets.all(5), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - AppText( - TranslationBase.of(context).frequency, - fontSize: 1.7 * SizeConfig.textMultiplier, - fontWeight: FontWeight.bold, - ), - SizedBox( - height: 5, - ), - AppText( - widget.myReferralPatientModel - .frequencyDescription, - fontSize: 1.7 * SizeConfig.textMultiplier, - fontWeight: FontWeight.w300, - ) - ], + width: 1, + ), + ), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + height: 8, ), - ) - ]), - TableRow( + SizedBox( + child: AppText( + TranslationBase.of(context).referringClinic, + fontSize: 1.9 * SizeConfig.textMultiplier, + fontWeight: FontWeight.bold, + textAlign: TextAlign.start, + color: Colors.black, + ), + ), + SizedBox( + height: 4, + ), + SizedBox( + child: AppText( + '${widget.myReferralPatientModel.referringClinicDescription}', + fontSize: 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.normal, + textAlign: TextAlign.start, + color: Colors.black, + ), + ), + SizedBox( + height: 8, + ), + ], + ), + ), + ], + ), + ), + ), + const Divider( + color: Color(0xffCCCCCC), + height: 1, + thickness: 2, + indent: 0, + endIndent: 0, + ), + SizedBox( + height: 10, + ), + Container( + height: 1.8 * SizeConfig.textMultiplier * 6, + padding: + EdgeInsets.only(left: 16, top: 0, right: 8, bottom: 0), + child: Expanded( + child: Row( + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Container( - margin: EdgeInsets.all(2.5), - padding: EdgeInsets.all(5), - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - AppText( - TranslationBase.of(context).priority, - fontSize: - 1.7 * SizeConfig.textMultiplier, - fontWeight: FontWeight.bold, - ), - SizedBox( - height: 5, - ), - AppText( - '${widget.myReferralPatientModel.priorityDescription}', - fontSize: - 1.7 * SizeConfig.textMultiplier, - fontWeight: FontWeight.w300, - ) - ], + SizedBox( + height: 8, + ), + SizedBox( + child: AppText( + TranslationBase.of(context).frequency, + fontSize: 1.9 * SizeConfig.textMultiplier, + fontWeight: FontWeight.bold, + textAlign: TextAlign.start, + color: Colors.black, ), ), - Container( - margin: EdgeInsets.only( - left: 4, - top: 2.5, - right: 2.5, - bottom: 2.5), - padding: EdgeInsets.all(5), - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - AppText( - TranslationBase.of(context) - .maxResponseTime, - fontSize: - 1.7 * SizeConfig.textMultiplier, - fontWeight: FontWeight.bold, - ), - SizedBox( - height: 5, - ), - AppText( - Helpers.getDateFormatted(widget - .myReferralPatientModel - .mAXResponseTime), - fontSize: - 1.7 * SizeConfig.textMultiplier, - fontWeight: FontWeight.w300, - ) - ], + SizedBox( + height: 4, + ), + SizedBox( + child: AppText( + '${widget.myReferralPatientModel.frequencyDescription}', + fontSize: 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.normal, + textAlign: TextAlign.start, + color: Colors.black, ), - ) + ), + SizedBox( + height: 8, + ), ], ), - ], - ), - Divider( - color: Color(0xFF000000), - height: 0.5, - ), - SizedBox( - height: 5, - ), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - AppText( - TranslationBase.of(context) - .clinicDetailsandRemarks, - fontSize: 1.7 * SizeConfig.textMultiplier, - fontWeight: FontWeight.bold, - textAlign: TextAlign.start, + ), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 8), + child: SizedBox( + child: Container( + color: Color(0xffCCCCCC), + ), + width: 1, ), - Texts( - '${widget.myReferralPatientModel.referringDoctorRemarks}', - style: "bodyText1", - readMore: true, - textAlign: TextAlign.start, - maxLength: 100) - ], - ), - SizedBox( - height: 5, - ), - AppText( - TranslationBase.of(context).answerSuggestions, - fontSize: 1.7 * SizeConfig.textMultiplier, - fontWeight: FontWeight.bold, - textAlign: TextAlign.start, - ), - SizedBox( - height: 5, - ), - Form( - key: _formKey, - child: TextFields( - controller:answerController, - - maxLines: 2, - minLines: 2, - hintText: - TranslationBase.of(context).answerThePatient, - fontWeight: FontWeight.normal, - readOnly: _isLoading, - validator: (value) { - if (value.isEmpty) - return TranslationBase.of(context) - .pleaseEnterAnswer; - else - return null; - }, ), - ), - SizedBox(height: 10.0), - SizedBox(height: 10.0), - Container( - width: double.infinity, - margin: EdgeInsets.only(left: 10, right: 10), - child: Button( - onTap: () async { - final form = _formKey.currentState; - if (form.validate()) { - - try { - await widget.model - .replay(answerController.text.toString(), - widget.myReferralPatientModel); - // TODO: Add Translation - DrAppToastMsg.showSuccesToast( - 'Reply Successfully'); - } catch (e) { - DrAppToastMsg.showErrorToast(e); - } - } - }, - title: TranslationBase.of(context).replay, - loading: widget.model.state == ViewState.BusyLocal, + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + height: 8, + ), + SizedBox( + child: AppText( + TranslationBase.of(context).maxResponseTime, + fontSize: 1.9 * SizeConfig.textMultiplier, + fontWeight: FontWeight.bold, + textAlign: TextAlign.start, + color: Colors.black, + ), + ), + SizedBox( + height: 4, + ), + SizedBox( + child: AppText( + '${DateFormat('dd/MM/yyyy').format(widget.myReferralPatientModel.mAXResponseTime)}', + fontSize: 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.normal, + textAlign: TextAlign.start, + color: Colors.black, + ), + ), + SizedBox( + height: 8, + ), + ], + ), + ), + ], + ), + ), + ), + const Divider( + color: Color(0xffCCCCCC), + height: 1, + thickness: 2, + indent: 0, + endIndent: 0, + ), + SizedBox( + height: 10, + ), + Container( + padding: + EdgeInsets.only(left: 16, top: 0, right: 8, bottom: 0), + child: Expanded( + child: Row( + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + height: 8, + ), + SizedBox( + child: AppText( + TranslationBase.of(context) + .clinicDetailsandRemarks, + fontSize: 1.9 * SizeConfig.textMultiplier, + fontWeight: FontWeight.bold, + textAlign: TextAlign.start, + color: Colors.black, + ), + ), + SizedBox( + height: 4, + ), + SizedBox( + child: AppText( + '${widget.myReferralPatientModel.referringDoctorRemarks}', + fontSize: 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.normal, + textAlign: TextAlign.start, + color: Colors.black, + ), + ), + SizedBox( + height: 8, + ), + ], + ), ), - ) - ], + ], + ), + ), + ), + const Divider( + color: Color(0xffCCCCCC), + height: 1, + thickness: 2, + indent: 0, + endIndent: 0, + ), + SizedBox( + height: 10, + ), + Container( + color: Colors.white, + padding: EdgeInsets.all(8), + child: Form( + key: _formKey, + child: TextFields( + controller: answerController, + maxLines: 3, + minLines: 2, + hintText: TranslationBase.of(context).answerThePatient, + fontWeight: FontWeight.normal, + readOnly: _isLoading, + validator: (value) { + if (value.isEmpty) + return TranslationBase.of(context) + .pleaseEnterAnswer; + else + return null; + }, + ), + ), + ), + Container( + width: double.infinity, + margin: EdgeInsets.only(left: 10, right: 10), + child: Button( + onTap: () async { + final form = _formKey.currentState; + if (form.validate()) { + try { + await widget.model.replay( + answerController.text.toString(), + widget.myReferralPatientModel); + DrAppToastMsg.showSuccesToast( + TranslationBase.of(context).replySuccessfully); + } catch (e) { + DrAppToastMsg.showErrorToast(e); + } + } + }, + title: TranslationBase.of(context).replay, + loading: widget.model.state == ViewState.BusyLocal, ), ) - ], - ), + ], + ), + ), + isExpand: widget.isExpand, + ), + ], ), ); } diff --git a/lib/widgets/patients/profile/Profile_general_info_Widget.dart b/lib/widgets/patients/profile/Profile_general_info_Widget.dart index 53b46884..e0eb5b12 100644 --- a/lib/widgets/patients/profile/Profile_general_info_Widget.dart +++ b/lib/widgets/patients/profile/Profile_general_info_Widget.dart @@ -1,8 +1,5 @@ import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; -import 'package:doctor_app_flutter/providers/patients_provider.dart'; - import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; import './profile_general_info_content_widget.dart'; import '../../../config/size_config.dart'; diff --git a/lib/widgets/patients/profile/profile_general_info_content_widget.dart b/lib/widgets/patients/profile/profile_general_info_content_widget.dart index 7ef4c8f2..713a98e1 100644 --- a/lib/widgets/patients/profile/profile_general_info_content_widget.dart +++ b/lib/widgets/patients/profile/profile_general_info_content_widget.dart @@ -30,11 +30,11 @@ class ProfileGeneralInfoContentWidget extends StatelessWidget { title, fontSize: SizeConfig.textMultiplier * 3, fontWeight: FontWeight.w700, - color: Hexcolor('#58434F'), + color: HexColor('#58434F'), ), AppText( info, - color: Hexcolor('#707070'), + color: HexColor('#707070'), fontSize: SizeConfig.textMultiplier * 2, ) ], diff --git a/lib/widgets/patients/profile/profile_header_widget.dart b/lib/widgets/patients/profile/profile_header_widget.dart index 1a5aec8a..df958106 100644 --- a/lib/widgets/patients/profile/profile_header_widget.dart +++ b/lib/widgets/patients/profile/profile_header_widget.dart @@ -33,7 +33,7 @@ class ProfileHeaderWidget extends StatelessWidget { des: patient.patientId.toString(), height: SizeConfig.heightMultiplier * 17, width: SizeConfig.heightMultiplier * 17, - color: Hexcolor('#58434F')), + color: HexColor('#58434F')), ); } } diff --git a/lib/widgets/patients/profile/profile_medical_info_widget.dart b/lib/widgets/patients/profile/profile_medical_info_widget.dart index 679d266d..092edb02 100644 --- a/lib/widgets/patients/profile/profile_medical_info_widget.dart +++ b/lib/widgets/patients/profile/profile_medical_info_widget.dart @@ -114,7 +114,7 @@ class CircleAvatarWidget extends StatelessWidget { decoration: new BoxDecoration( // color: Colors.green, // border color shape: BoxShape.circle, - border: Border.all(color: Hexcolor('#B7831A'), width: 1.5)), + border: Border.all(color: HexColor('#B7831A'), width: 1.5)), child: CircleAvatar( radius: SizeConfig.imageSizeMultiplier * 12, child: Image.asset(url), diff --git a/lib/widgets/patients/profile/profile_status_info_widget.dart b/lib/widgets/patients/profile/profile_status_info_widget.dart index c8983f83..d616c36f 100644 --- a/lib/widgets/patients/profile/profile_status_info_widget.dart +++ b/lib/widgets/patients/profile/profile_status_info_widget.dart @@ -32,11 +32,11 @@ class ProfileStatusInfoWidget extends StatelessWidget { 'Insurance approval', fontSize: SizeConfig.textMultiplier * 3, fontWeight: FontWeight.w700, - color: Hexcolor('#58434F'), + color: HexColor('#58434F'), ), AppText( 'Approved', - color: Hexcolor('#707070'), + color: HexColor('#707070'), fontSize: SizeConfig.textMultiplier * 2.5, ) ], diff --git a/lib/widgets/patients/vital_sign_details_wideget.dart b/lib/widgets/patients/vital_sign_details_wideget.dart index 166680ca..41af8e1d 100644 --- a/lib/widgets/patients/vital_sign_details_wideget.dart +++ b/lib/widgets/patients/vital_sign_details_wideget.dart @@ -54,7 +54,7 @@ class _VitalSignDetailsWidgetState extends State { Container( child: Container( decoration: BoxDecoration( - color: Hexcolor('#515B5D'), + color: HexColor('#515B5D'), borderRadius: BorderRadius.only( topLeft: Radius.circular(10.0), ), @@ -71,7 +71,7 @@ class _VitalSignDetailsWidgetState extends State { Container( child: Container( decoration: BoxDecoration( - color: Hexcolor('#515B5D'), + color: HexColor('#515B5D'), borderRadius: BorderRadius.only( topRight: Radius.circular(10.0), ), diff --git a/lib/widgets/shared/Text.dart b/lib/widgets/shared/Text.dart index 95b55127..9f6dfdf1 100644 --- a/lib/widgets/shared/Text.dart +++ b/lib/widgets/shared/Text.dart @@ -226,7 +226,7 @@ class _TextsState extends State { }, child: Text(hidden ? "Read More" : "Read less", style: _getFontStyle().copyWith( - color: Hexcolor('#FF0000'), + color: HexColor('#FF0000'), fontWeight: FontWeight.w800, fontFamily: "WorkSans" ) diff --git a/lib/widgets/shared/app_button.dart b/lib/widgets/shared/app_button.dart index 32f5b139..984d4350 100644 --- a/lib/widgets/shared/app_button.dart +++ b/lib/widgets/shared/app_button.dart @@ -95,7 +95,7 @@ class _ButtonState extends State