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/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/locator.dart b/lib/locator.dart index f9ba83be..d4695f84 100644 --- a/lib/locator.dart +++ b/lib/locator.dart @@ -1,3 +1,5 @@ +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'; @@ -24,6 +26,7 @@ void setupLocator() { locator.registerLazySingleton(() => ReferralPatientService()); locator.registerLazySingleton(() => ReferredPatientService()); locator.registerLazySingleton(() => MedicineService()); + locator.registerLazySingleton(() => PatientService()); /// View Model locator.registerFactory(() => HospitalViewModel()); @@ -32,4 +35,5 @@ void setupLocator() { locator.registerFactory(() => ReferralPatientViewModel()); locator.registerFactory(() => ReferredPatientViewModel()); locator.registerFactory(() => MedicineViewModel()); + locator.registerFactory(() => PatientViewModel()); } diff --git a/lib/providers/patients_provider.dart b/lib/providers/patients_provider.dart index ace7cd1a..a562790c 100644 --- a/lib/providers/patients_provider.dart +++ b/lib/providers/patients_provider.dart @@ -1,4 +1,3 @@ -import 'dart:convert'; import 'package:doctor_app_flutter/client/base_app_client.dart'; import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; @@ -8,13 +7,12 @@ import 'package:doctor_app_flutter/models/patient/get_doctor_by_clinic_id_reques 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.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'; @@ -114,166 +112,7 @@ class PatientsProvider with ChangeNotifier { 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 @@ -289,254 +128,155 @@ class PatientsProvider with ChangeNotifier { 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: 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); - } - } + // 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/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..627f5f31 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/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'; 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/patients/out_patient_prescription_details_screen.dart b/lib/screens/patients/out_patient_prescription_details_screen.dart index bd3834ab..5966b3a8 100644 --- a/lib/screens/patients/out_patient_prescription_details_screen.dart +++ b/lib/screens/patients/out_patient_prescription_details_screen.dart @@ -1,15 +1,14 @@ +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; @@ -26,41 +25,32 @@ class _OutPatientPrescriptionDetailsScreenState 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, itemBuilder: (BuildContext context, int index) { return OutPatientPrescriptionDetailsItem( prescriptionReport: - patientsProvider.prescriptionReport[index], + model.prescriptionReport[index], ); }), ), - ); + ),); } } 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/profile/insurance_approvals_screen.dart b/lib/screens/patients/profile/insurance_approvals_screen.dart index d6786a4b..e6b4dd70 100644 --- a/lib/screens/patients/profile/insurance_approvals_screen.dart +++ b/lib/screens/patients/profile/insurance_approvals_screen.dart @@ -1,12 +1,13 @@ 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'; @@ -15,7 +16,6 @@ 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(); @@ -46,7 +46,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 +61,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 +426,13 @@ class _InsuranceApprovalsState extends State { ], ), ], - )); - }), - ), - ), - ], - ), - ); + )); + }), + ), + ), + ], + ), + ),); } InputDecoration buildInputDecoration(BuildContext context, hint) { @@ -455,21 +452,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..20e30850 100644 --- a/lib/screens/patients/profile/lab_result/lab_orders_screen.dart +++ b/lib/screens/patients/profile/lab_result/lab_orders_screen.dart @@ -1,10 +1,11 @@ +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'; @@ -14,11 +15,7 @@ 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 +33,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 +53,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 5b30b487..00f6b59a 100644 --- a/lib/screens/patients/profile/patient_orders_screen.dart +++ b/lib/screens/patients/profile/patient_orders_screen.dart @@ -1,10 +1,11 @@ -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'; @@ -13,8 +14,6 @@ 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(); @@ -45,7 +44,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 +58,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 +82,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 +150,7 @@ class _PatientsOrdersState extends State { ), ], ), - ); + ),); } InputDecoration buildInputDecoration(BuildContext context, hint) { @@ -182,7 +170,7 @@ class _PatientsOrdersState extends State { )); } - searchData(String str) { + searchData(String str, PatientViewModel model) { var strExist = str.length > 0 ? true : false; if (strExist) { @@ -196,7 +184,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..2a1b60f3 100644 --- a/lib/screens/patients/profile/prescriptions/prescriptions_screen.dart +++ b/lib/screens/patients/profile/prescriptions/prescriptions_screen.dart @@ -1,23 +1,20 @@ +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(); @@ -46,7 +43,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 +55,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 +64,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 25b14874..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) { @@ -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..5eb08d31 100644 --- a/lib/screens/patients/profile/radiology/radiology_screen.dart +++ b/lib/screens/patients/profile/radiology/radiology_screen.dart @@ -1,9 +1,11 @@ +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'; @@ -13,7 +15,6 @@ 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(); @@ -41,7 +42,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 +59,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: 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: 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: patientsProv + .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 6ab2bbdb..f7a969e8 100644 --- a/lib/screens/patients/profile/refer_patient_screen.dart +++ b/lib/screens/patients/profile/refer_patient_screen.dart @@ -1,22 +1,23 @@ 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 +35,6 @@ class ReferPatientScreen extends StatefulWidget { } class _ReferPatientState extends State { - PatientsProvider patientsProv; var doctorsList; final _remarksController = TextEditingController(); final _extController = TextEditingController(); @@ -51,46 +51,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).myReferralPatient, - 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).myReferralPatient, + 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: 30, borderColor: Color(0xff707070), width: double.infinity, @@ -112,7 +98,7 @@ class _ReferPatientState extends State { elevation: 16, selectedItemBuilder: (BuildContext context) { - return patientsProv + return model .getClinicNameList() .map((item) { return Row( @@ -132,7 +118,7 @@ class _ReferPatientState extends State { setState(() { _selectedDoctor = null; _selectedClinic = newValue; - var clinicInfo = patientsProv + var clinicInfo = model .clinicsList .where((i) => i['ClinicDescription'] @@ -144,10 +130,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( @@ -197,7 +183,7 @@ class _ReferPatientState extends State { elevation: 16, selectedItemBuilder: (BuildContext context) { - return patientsProv + return model .getDoctorNameList() .map((item) { return Row( @@ -217,7 +203,7 @@ class _ReferPatientState extends State { setState(() { _selectedDoctor = newValue; doctorsList = - patientsProv.doctorsList; + model.doctorsList; var doctorInfo = doctorsList .where((i) => i['DoctorName'] @@ -228,7 +214,7 @@ class _ReferPatientState extends State { .toString(); }) }, - items: patientsProv + items: model .getDoctorNameList() .map((item) { return DropdownMenuItem( @@ -311,7 +297,7 @@ class _ReferPatientState extends State { elevation: 16, selectedItemBuilder: (BuildContext context) { - return patientsProv + return model .getReferralNamesList() .map((item) { return Row( @@ -330,7 +316,7 @@ class _ReferPatientState extends State { onChanged: (newValue) => { setState(() { _selectedReferralFrequancy = newValue; - var freqInfo = patientsProv + var freqInfo = model .referalFrequancyList .singleWhere((i) => i[ 'Description'] @@ -342,7 +328,7 @@ class _ReferPatientState extends State { myFocusNode.requestFocus(); }) }, - items: patientsProv + items: model .getReferralNamesList() .map((item) { return DropdownMenuItem( @@ -389,17 +375,23 @@ class _ReferPatientState extends State { visibility: isValid == null ? false : !isValid, ), + // TODO replace AppButton with secondary button and add loading AppButton( - title: TranslationBase.of(context).send, + title: TranslationBase + .of(context) + .send, color: Color(PRIMARY_COLOR), - onPressed: () => {referToDoctor(context)}, + onPressed: () => + { + referToDoctor(context, model) + }, ) ], )) - ], - ), - ), - ); + ], + ), + ), + ),); } Widget priorityBar(BuildContext _context) { @@ -488,25 +480,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..75b8be03 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,8 +1,9 @@ +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'; @@ -14,7 +15,6 @@ 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(); @@ -38,7 +38,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 +57,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 +68,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 +97,7 @@ class _VitalSignDetailsScreenState extends State { des: TranslationBase.of(context) .bodyMeasurements, url: url + 'heartbeat.png', - lastVal: patientsProv + lastVal: model .patientVitalSignOrderdSubList[0] .heightCm .toString(), @@ -129,7 +120,7 @@ class _VitalSignDetailsScreenState extends State { des: TranslationBase.of(context) .temperature, url: url + 'heartbeat.png', - lastVal: patientsProv + lastVal: model .patientVitalSignOrderdSubList[0] .temperatureCelcius .toString(), @@ -154,7 +145,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 +166,7 @@ class _VitalSignDetailsScreenState extends State { des: TranslationBase.of(context).respiration, url: url + 'heartbeat.png', - lastVal: patientsProv + lastVal: model .patientVitalSignOrderdSubList[0] .respirationBeatPerMinute .toString(), @@ -200,7 +191,7 @@ class _VitalSignDetailsScreenState extends State { des: TranslationBase.of(context) .bloodPressure, url: url + 'heartbeat.png', - lastVal: patientsProv + lastVal: model .patientVitalSignOrderdSubList[0] .bloodPressure .toString(), @@ -221,7 +212,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 +234,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_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] - }); - }, - ); - }), - ), - ); - } -}