Merge branch 'scan_qr' into 'development'

Scan qr code refactoring

See merge request Cloud_Solution/doctor_app_flutter!740
merge-requests/742/merge
Mohammad Aljammal 5 years ago
commit 6b44a1c3aa

@ -0,0 +1,41 @@
import 'package:doctor_app_flutter/config/config.dart';
import 'package:doctor_app_flutter/core/model/patient_muse/PatientSearchRequestModel.dart';
import 'package:doctor_app_flutter/core/service/base/base_service.dart';
import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart';
class ScanQrService extends BaseService {
List<PatiantInformtion> myInPatientList = List();
List<PatiantInformtion> inPatientList = List();
Future getInPatient(PatientSearchRequestModel requestModel, bool isMyInpatient) async {
hasError = false;
await getDoctorProfile();
if (isMyInpatient) {
requestModel.doctorID = doctorProfile.doctorID;
} else {
requestModel.doctorID = 0;
}
await baseAppClient.post(
GET_PATIENT_IN_PATIENT_LIST,
onSuccess: (dynamic response, int statusCode) {
inPatientList.clear();
myInPatientList.clear();
response['List_MyInPatient'].forEach((v) {
PatiantInformtion patient = PatiantInformtion.fromJson(v);
inPatientList.add(patient);
if (patient.doctorId == doctorProfile.doctorID) {
myInPatientList.add(patient);
}
});
},
onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
},
body: requestModel.toJson(),
);
}
}

@ -0,0 +1,26 @@
import 'package:doctor_app_flutter/core/enum/viewstate.dart';
import 'package:doctor_app_flutter/core/model/patient_muse/PatientSearchRequestModel.dart';
import 'package:doctor_app_flutter/core/service/home/scan_qr_service.dart';
import 'package:doctor_app_flutter/core/viewModel/base_view_model.dart';
import 'package:doctor_app_flutter/locator.dart';
import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart';
class ScanQrViewModel extends BaseViewModel {
ScanQrService _scanQrService = locator<ScanQrService>();
List<PatiantInformtion> get inPatientList => _scanQrService.inPatientList;
Future getInPatientList(PatientSearchRequestModel requestModel, {bool isMyInpatient = false}) async {
await getDoctorProfile();
setState(ViewState.Busy);
await _scanQrService.getInPatient(requestModel, false);
if (_scanQrService.hasError) {
error = _scanQrService.error;
setState(ViewState.ErrorLocal);
} else {
// setDefaultInPatientList();
setState(ViewState.Idle);
}
}
}

@ -1,10 +1,12 @@
import 'package:doctor_app_flutter/core/service/authentication_service.dart';
import 'package:doctor_app_flutter/core/service/home/scan_qr_service.dart';
import 'package:doctor_app_flutter/core/viewModel/dashboard_view_model.dart';
import 'package:doctor_app_flutter/core/viewModel/hospitals_view_model.dart';
import 'package:doctor_app_flutter/core/viewModel/medical_file_view_model.dart';
import 'package:doctor_app_flutter/core/viewModel/patient_view_model.dart';
import 'package:doctor_app_flutter/core/viewModel/prescription_view_model.dart';
import 'package:doctor_app_flutter/core/viewModel/procedure_View_model.dart';
import 'package:doctor_app_flutter/core/viewModel/scan_qr_view_model.dart';
import 'package:doctor_app_flutter/core/viewModel/sick_leave_view_model.dart';
import 'package:get_it/get_it.dart';
@ -91,6 +93,7 @@ void setupLocator() {
locator.registerLazySingleton(() => PatientMedicalReportService());
locator.registerLazySingleton(() => LiveCarePatientServices());
locator.registerLazySingleton(() => NavigationService());
locator.registerLazySingleton(() => ScanQrService());
/// View Model
locator.registerFactory(() => DoctorReplayViewModel());
@ -118,4 +121,5 @@ void setupLocator() {
locator.registerFactory(() => HospitalViewModel());
locator.registerFactory(() => LiveCarePatientViewModel());
locator.registerFactory(() => PatientMedicalReportViewModel());
locator.registerFactory(() => ScanQrViewModel());
}

@ -3,6 +3,7 @@ import 'package:doctor_app_flutter/config/size_config.dart';
import 'package:doctor_app_flutter/core/enum/viewstate.dart';
import 'package:doctor_app_flutter/core/model/patient_muse/PatientSearchRequestModel.dart';
import 'package:doctor_app_flutter/core/viewModel/patient_view_model.dart';
import 'package:doctor_app_flutter/core/viewModel/scan_qr_view_model.dart';
import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart';
import 'package:doctor_app_flutter/util/helpers.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
@ -25,7 +26,7 @@ class QrReaderScreen extends StatefulWidget {
class _QrReaderScreenState extends State<QrReaderScreen> {
@override
Widget build(BuildContext context) {
return BaseView<PatientViewModel>(
return BaseView<ScanQrViewModel>(
builder: (_, model, w) => AppScaffold(
baseViewModel: model,
isShowAppBar: false,
@ -74,7 +75,7 @@ class _QrReaderScreenState extends State<QrReaderScreen> {
);
}
_scanQrAndGetPatient(BuildContext context, PatientViewModel model) async {
_scanQrAndGetPatient(BuildContext context, ScanQrViewModel model) async {
/// When give qr we will change this method to get data
/// var result = await BarcodeScanner.scan();
/// int patientID = get from qr result

Loading…
Cancel
Save