second step from patient provider

pull/181/head
Elham Rababah 4 years ago
parent 6ab73916eb
commit 1b1e8f0712

@ -1,5 +1,8 @@
import 'package:doctor_app_flutter/client/base_app_client.dart';
import 'package:doctor_app_flutter/config/config.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/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/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_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_doctor_by_clinic_id_request.dart';
@ -7,6 +10,7 @@ import 'package:doctor_app_flutter/models/patient/get_list_stp_referral_frequenc
import 'package:doctor_app_flutter/models/patient/lab_orders/lab_orders_res_model.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.dart';
import 'package:doctor_app_flutter/models/patient/lab_result/lab_result_req_model.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.dart';
import 'package:doctor_app_flutter/models/patient/prescription/prescription_report_for_in_patient.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/prescription/prescription_res_model.dart';
@ -42,22 +46,33 @@ class PatientService extends BaseService {
List<PrescriptionReport> get prescriptionReport => _prescriptionReport; List<PrescriptionReport> get prescriptionReport => _prescriptionReport;
List<LabResult> _labResultList = []; List<LabResult> _labResultList = [];
List<LabResult> get labResultList => _labResultList; List<LabResult> get labResultList => _labResultList;
// TODO: replace var with model // TODO: replace var with model
var _patientProgressNoteList = []; var _patientProgressNoteList = [];
get patientProgressNoteList => _patientProgressNoteList; get patientProgressNoteList => _patientProgressNoteList;
// TODO: replace var with model // TODO: replace var with model
var _insuranceApporvalsList = []; var _insuranceApporvalsList = [];
get insuranceApporvalsList => _insuranceApporvalsList; get insuranceApporvalsList => _insuranceApporvalsList;
// TODO: replace var with model // TODO: replace var with model
var doctorsList = []; var _doctorsList = [];
get doctorsList => _doctorsList;
// TODO: replace var with model // TODO: replace var with model
var clinicsList = []; var _clinicsList = [];
get clinicsList => _clinicsList;
// TODO: replace var with model // TODO: replace var with model
var referalFrequancyList = []; var _referalFrequancyList = [];
get referalFrequancyList => _referalFrequancyList;
DoctorsByClinicIdRequest _doctorsByClinicIdRequest = DoctorsByClinicIdRequest _doctorsByClinicIdRequest =
DoctorsByClinicIdRequest(); DoctorsByClinicIdRequest();
@ -69,6 +84,47 @@ class PatientService extends BaseService {
RequestSchedule _requestSchedule = RequestSchedule(); RequestSchedule _requestSchedule = RequestSchedule();
Future<dynamic> 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 { Future getPatientVitalSign(patient) async {
hasError = false; hasError = false;
await baseAppClient.post( await baseAppClient.post(
@ -219,6 +275,7 @@ class PatientService extends BaseService {
body: requestLabResult.toJson(), body: requestLabResult.toJson(),
); );
} }
Future getPatientInsuranceApprovals(patient) async { Future getPatientInsuranceApprovals(patient) async {
hasError = false; hasError = false;
@ -227,7 +284,6 @@ class PatientService extends BaseService {
onSuccess: (dynamic response, int statusCode) { onSuccess: (dynamic response, int statusCode) {
_insuranceApporvalsList = []; _insuranceApporvalsList = [];
_insuranceApporvalsList = response['List_ApprovalMain_InPatient']; _insuranceApporvalsList = response['List_ApprovalMain_InPatient'];
}, },
onFailure: (String error, int statusCode) { onFailure: (String error, int statusCode) {
hasError = true; hasError = true;
@ -236,6 +292,7 @@ class PatientService extends BaseService {
body: patient, body: patient,
); );
} }
Future getPatientProgressNote(patient) async { Future getPatientProgressNote(patient) async {
hasError = false; hasError = false;
@ -244,7 +301,6 @@ class PatientService extends BaseService {
onSuccess: (dynamic response, int statusCode) { onSuccess: (dynamic response, int statusCode) {
_patientProgressNoteList = []; _patientProgressNoteList = [];
_patientProgressNoteList = response['List_GetPregressNoteForInPatient']; _patientProgressNoteList = response['List_GetPregressNoteForInPatient'];
}, },
onFailure: (String error, int statusCode) { onFailure: (String error, int statusCode) {
hasError = true; hasError = true;
@ -253,4 +309,104 @@ class PatientService extends BaseService {
body: patient, 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(),
);
}
} }

@ -2,6 +2,7 @@ import 'package:doctor_app_flutter/core/enum/viewstate.dart';
import 'package:doctor_app_flutter/core/service/patient_service.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_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.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.dart';
import 'package:doctor_app_flutter/models/patient/prescription/prescription_report_for_in_patient.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/prescription/prescription_res_model.dart';
@ -36,9 +37,33 @@ class PatientViewModel extends BaseViewModel {
_patientService.patientRadiologyList; _patientService.patientRadiologyList;
List<LabResult> get labResultList => _patientService.labResultList; List<LabResult> get labResultList => _patientService.labResultList;
get insuranceApporvalsList => _patientService.insuranceApporvalsList; get insuranceApporvalsList => _patientService.insuranceApporvalsList;
get patientProgressNoteList => _patientService.patientProgressNoteList; 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 { Future getPatientVitalSign(patient) async {
setState(ViewState.Busy); setState(ViewState.Busy);
await _patientService.getPatientVitalSign(patient); await _patientService.getPatientVitalSign(patient);
@ -108,7 +133,8 @@ class PatientViewModel extends BaseViewModel {
} else } else
setState(ViewState.Idle); setState(ViewState.Idle);
} }
Future getPatientInsuranceApprovals(patient) async{
Future getPatientInsuranceApprovals(patient) async {
setState(ViewState.Busy); setState(ViewState.Busy);
await _patientService.getPatientInsuranceApprovals(patient); await _patientService.getPatientInsuranceApprovals(patient);
if (_patientService.hasError) { if (_patientService.hasError) {
@ -117,7 +143,8 @@ class PatientViewModel extends BaseViewModel {
} else } else
setState(ViewState.Idle); setState(ViewState.Idle);
} }
Future getPatientProgressNote(patient) async{
Future getPatientProgressNote(patient) async {
setState(ViewState.Busy); setState(ViewState.Busy);
await _patientService.getPatientProgressNote(patient); await _patientService.getPatientProgressNote(patient);
if (_patientService.hasError) { if (_patientService.hasError) {
@ -126,4 +153,92 @@ class PatientViewModel extends BaseViewModel {
} else } else
setState(ViewState.Idle); 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);
}
} }

@ -128,155 +128,155 @@ class PatientsProvider with ChangeNotifier {
throw err; throw err;
} }
/*@author: ibrahem albitar // /*@author: ibrahem albitar
*@Date:3/6/2020 // *@Date:3/6/2020
*@desc: getDoctorsList // *@desc: getDoctorsList
*/ // */
getDoctorsList(String clinicId) async { // getDoctorsList(String clinicId) async {
setBasicData(); // setBasicData();
try { // try {
_doctorsByClinicIdRequest.clinicID = clinicId; // _doctorsByClinicIdRequest.clinicID = clinicId;
await baseAppClient.post(PATIENT_GET_DOCTOR_BY_CLINIC_URL, // await baseAppClient.post(PATIENT_GET_DOCTOR_BY_CLINIC_URL,
onSuccess: (dynamic response, int statusCode) { // onSuccess: (dynamic response, int statusCode) {
doctorsList = response['List_Doctors_All']; // doctorsList = response['List_Doctors_All'];
isLoading = false; // isLoading = false;
isError = false; // isError = false;
this.error = ''; // this.error = '';
}, onFailure: (String error, int statusCode) { // }, onFailure: (String error, int statusCode) {
isLoading = false; // isLoading = false;
isError = true; // isError = true;
this.error = error; // this.error = error;
}, body: _doctorsByClinicIdRequest.toJson()); // }, body: _doctorsByClinicIdRequest.toJson());
notifyListeners(); // notifyListeners();
} catch (err) { // } catch (err) {
handelCatchErrorCase(err); // handelCatchErrorCase(err);
} // }
} // }
//
List getDoctorNameList() { // List getDoctorNameList() {
var doctorNamelist = // var doctorNamelist =
doctorsList.map((value) => value['DoctorName'].toString()).toList(); // doctorsList.map((value) => value['DoctorName'].toString()).toList();
return doctorNamelist; // return doctorNamelist;
} // }
//
/*@author: ibrahem albitar // /*@author: ibrahem albitar
*@Date:3/6/2020 // *@Date:3/6/2020
*@desc: getClinicsList // *@desc: getClinicsList
*/ // */
getClinicsList() async { // getClinicsList() async {
setBasicData(); // setBasicData();
try { // try {
await baseAppClient.post(PATIENT_GET_CLINIC_BY_PROJECT_URL, // await baseAppClient.post(PATIENT_GET_CLINIC_BY_PROJECT_URL,
onSuccess: (dynamic response, int statusCode) { // onSuccess: (dynamic response, int statusCode) {
clinicsList = response['List_Clinic_All']; // clinicsList = response['List_Clinic_All'];
isLoading = false; // isLoading = false;
isError = false; // isError = false;
this.error = ''; // this.error = '';
}, onFailure: (String error, int statusCode) { // }, onFailure: (String error, int statusCode) {
isLoading = false; // isLoading = false;
isError = true; // isError = true;
this.error = error; // this.error = error;
}, body: _clinicByProjectIdRequest.toJson()); // }, body: _clinicByProjectIdRequest.toJson());
notifyListeners(); // notifyListeners();
} catch (err) { // } catch (err) {
handelCatchErrorCase(err); // handelCatchErrorCase(err);
} // }
} // }
//
List getClinicNameList() { // List getClinicNameList() {
var clinicsNameslist = clinicsList // var clinicsNameslist = clinicsList
.map((value) => value['ClinicDescription'].toString()) // .map((value) => value['ClinicDescription'].toString())
.toList(); // .toList();
return clinicsNameslist; // return clinicsNameslist;
} // }
//
/*@author: ibrahem albitar // /*@author: ibrahem albitar
*@Date:3/6/2020 // *@Date:3/6/2020
*@desc: getReferralFrequancyList // *@desc: getReferralFrequancyList
*/ // */
getReferralFrequancyList() async { // getReferralFrequancyList() async {
setBasicData(); // setBasicData();
try { // try {
await baseAppClient.post(PATIENT_GET_LIST_REFERAL_URL, // await baseAppClient.post(PATIENT_GET_LIST_REFERAL_URL,
onSuccess: (dynamic response, int statusCode) { // onSuccess: (dynamic response, int statusCode) {
referalFrequancyList = response['list_STPReferralFrequency']; // referalFrequancyList = response['list_STPReferralFrequency'];
isLoading = false; // isLoading = false;
isError = false; // isError = false;
this.error = ''; // this.error = '';
}, onFailure: (String error, int statusCode) { // }, onFailure: (String error, int statusCode) {
isLoading = false; // isLoading = false;
isError = true; // isError = true;
this.error = error; // this.error = error;
}, body: _referralFrequencyRequest.toJson()); // }, body: _referralFrequencyRequest.toJson());
notifyListeners(); // notifyListeners();
} catch (err) { // } catch (err) {
handelCatchErrorCase(err); // handelCatchErrorCase(err);
} // }
} // }
//
List getReferralNamesList() { // List getReferralNamesList() {
var referralNamesList = referalFrequancyList // var referralNamesList = referalFrequancyList
.map((value) => value['Description'].toString()) // .map((value) => value['Description'].toString())
.toList(); // .toList();
return referralNamesList; // return referralNamesList;
} // }
/*@author: ibrahem albitar /*@author: ibrahem albitar
*@Date:3/6/2020 *@Date:3/6/2020
*@desc: referToDoctor *@desc: referToDoctor
*/ */
referToDoctor(context, // referToDoctor(context,
{String selectedDoctorID, // {String selectedDoctorID,
String selectedClinicID, // String selectedClinicID,
int admissionNo, // int admissionNo,
String extension, // String extension,
String priority, // String priority,
String frequency, // String frequency,
String referringDoctorRemarks, // String referringDoctorRemarks,
int patientID, // int patientID,
int patientTypeID, // int patientTypeID,
String roomID, // String roomID,
int projectID}) async { // int projectID}) async {
setBasicData(); // setBasicData();
try { // try {
String token = await sharedPref.getString(TOKEN); // String token = await sharedPref.getString(TOKEN);
Map profile = await sharedPref.getObj(DOCTOR_PROFILE); // Map profile = await sharedPref.getObj(DOCTOR_PROFILE);
DoctorProfileModel doctorProfile = // DoctorProfileModel doctorProfile =
new DoctorProfileModel.fromJson(profile); // new DoctorProfileModel.fromJson(profile);
int doctorID = doctorProfile.doctorID; // int doctorID = doctorProfile.doctorID;
int clinicId = doctorProfile.clinicID; // int clinicId = doctorProfile.clinicID;
_referToDoctorRequest = ReferToDoctorRequest( // _referToDoctorRequest = ReferToDoctorRequest(
projectID: projectID, // projectID: projectID,
admissionNo: admissionNo, // admissionNo: admissionNo,
roomID: roomID, // roomID: roomID,
referralClinic: selectedClinicID.toString(), // referralClinic: selectedClinicID.toString(),
referralDoctor: selectedDoctorID.toString(), // referralDoctor: selectedDoctorID.toString(),
createdBy: doctorID, // createdBy: doctorID,
editedBy: doctorID, // editedBy: doctorID,
patientID: patientID, // patientID: patientID,
patientTypeID: patientTypeID, // patientTypeID: patientTypeID,
referringClinic: clinicId, // referringClinic: clinicId,
referringDoctor: doctorID, // referringDoctor: doctorID,
referringDoctorRemarks: referringDoctorRemarks, // referringDoctorRemarks: referringDoctorRemarks,
priority: priority, // priority: priority,
frequency: frequency, // frequency: frequency,
extension: extension, // extension: extension,
tokenID: token); // tokenID: token);
await baseAppClient.post(PATIENT_REFER_TO_DOCTOR_URL, // await baseAppClient.post(PATIENT_REFER_TO_DOCTOR_URL,
onSuccess: (dynamic response, int statusCode) { // onSuccess: (dynamic response, int statusCode) {
// print('Done : \n $res'); // // print('Done : \n $res');
Navigator.pop(context); // Navigator.pop(context);
}, // },
onFailure: (String error, int statusCode) { // onFailure: (String error, int statusCode) {
isLoading = false; // isLoading = false;
isError = true; // isError = true;
this.error = error; // this.error = error;
}, // },
body: _referToDoctorRequest.toJson()); // body: _referToDoctorRequest.toJson());
notifyListeners(); // notifyListeners();
//
} catch (err) { // } catch (err) {
handelCatchErrorCase(err); // handelCatchErrorCase(err);
} // }
} // }
} }

@ -1,23 +1,23 @@
import 'package:barcode_scan/platform_wrapper.dart'; import 'package:barcode_scan/platform_wrapper.dart';
import 'package:doctor_app_flutter/config/shared_pref_kay.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/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/patiant_info_model.dart';
import 'package:doctor_app_flutter/models/patient/patient_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/models/patient/topten_users_res_model.dart';
import 'package:doctor_app_flutter/providers/patients_provider.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_shared_pref.dart';
import 'package:doctor_app_flutter/util/dr_app_toast_msg.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_button.dart';
import 'package:doctor_app_flutter/widgets/shared/app_scaffold_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/app_texts_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/card_with_bg_widget.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import '../routes.dart'; import '../routes.dart';
import 'base/base_view.dart';
class QrReaderScreen extends StatefulWidget { class QrReaderScreen extends StatefulWidget {
@override @override
@ -55,18 +55,22 @@ class _QrReaderScreenState extends State<QrReaderScreen> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return AppScaffold( return BaseView<PatientViewModel>(
appBarTitle: TranslationBase.of(context).qr+ TranslationBase.of(context).reader, onModelReady: (model) => model.getClinicsList(),
body: Center( builder: (_, model, w) => AppScaffold(
child: Container( baseViewModel: model,
margin: EdgeInsets.only(top: SizeConfig.realScreenHeight / 7), appBarTitle:
child: FractionallySizedBox( TranslationBase.of(context).qr + TranslationBase.of(context).reader,
widthFactor: 0.9, body: Center(
child: ListView( child: Container(
children: [ margin: EdgeInsets.only(top: SizeConfig.realScreenHeight / 7),
AppText( child: FractionallySizedBox(
TranslationBase.of(context).startScanning, widthFactor: 0.9,
fontSize: 18, child: ListView(
children: [
AppText(
TranslationBase.of(context).startScanning,
fontSize: 18,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
textAlign: TextAlign.center, textAlign: TextAlign.center,
), ),
@ -89,7 +93,7 @@ class _QrReaderScreenState extends State<QrReaderScreen> {
), ),
Button( Button(
onTap: () { onTap: () {
_scanQrAndGetPatient(context); _scanQrAndGetPatient(context, model);
}, },
title: TranslationBase.of(context).scanQr, title: TranslationBase.of(context).scanQr,
loading: isLoading, loading: isLoading,
@ -111,20 +115,22 @@ class _QrReaderScreenState extends State<QrReaderScreen> {
error ?? error ??
TranslationBase.of(context) TranslationBase.of(context)
.errorMessage, .errorMessage,
color: Theme.of(context).errorColor)), color: Theme
.of(context)
.errorColor)),
], ],
), ),
) )
: Container(), : Container(),
], ],
),
),
),
), ),
), ),);
),
),
);
} }
_scanQrAndGetPatient(BuildContext context) async { _scanQrAndGetPatient(BuildContext context, PatientViewModel model) async {
/// When give qr we will change this method to get data /// When give qr we will change this method to get data
/// var result = await BarcodeScanner.scan(); /// var result = await BarcodeScanner.scan();
/// int patientID = get from qr result /// int patientID = get from qr result
@ -148,8 +154,8 @@ class _QrReaderScreenState extends State<QrReaderScreen> {
// Provider.of<PatientsProvider>(context, listen: false); // Provider.of<PatientsProvider>(context, listen: false);
patient.PatientID = 8808; patient.PatientID = 8808;
patient.TokenID = token; patient.TokenID = token;
Provider.of<PatientsProvider>(context, listen: false) model
.getPatientList(patient, "1") .getPatientList(patient, "1", isBusyLocal: true)
.then((response) { .then((response) {
if (response['MessageStatus'] == 1) { if (response['MessageStatus'] == 1) {
switch (patientType) { switch (patientType) {

@ -1,5 +1,8 @@
import 'package:doctor_app_flutter/config/config.dart'; 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/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/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/shared/app_buttons_widget.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/app_text_form_field.dart';
@ -8,7 +11,6 @@ import 'package:doctor_app_flutter/widgets/shared/rounded_container_widget.dart'
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:hexcolor/hexcolor.dart'; import 'package:hexcolor/hexcolor.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'package:provider/provider.dart';
import '../../../config/size_config.dart'; import '../../../config/size_config.dart';
import '../../../providers/patients_provider.dart'; import '../../../providers/patients_provider.dart';
@ -16,7 +18,6 @@ import '../../../util/dr_app_shared_pref.dart';
import '../../../util/extenstions.dart'; import '../../../util/extenstions.dart';
import '../../../widgets/shared/app_scaffold_widget.dart'; import '../../../widgets/shared/app_scaffold_widget.dart';
import '../../../widgets/shared/app_texts_widget.dart'; import '../../../widgets/shared/app_texts_widget.dart';
import '../../../widgets/shared/dr_app_circular_progress_Indeicator.dart';
DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); DrAppSharedPreferances sharedPref = new DrAppSharedPreferances();
@ -34,7 +35,6 @@ class ReferPatientScreen extends StatefulWidget {
} }
class _ReferPatientState extends State<ReferPatientScreen> { class _ReferPatientState extends State<ReferPatientScreen> {
PatientsProvider patientsProv;
var doctorsList; var doctorsList;
final _remarksController = TextEditingController(); final _remarksController = TextEditingController();
final _extController = TextEditingController(); final _extController = TextEditingController();
@ -51,46 +51,32 @@ class _ReferPatientState extends State<ReferPatientScreen> {
int _activePriority = 1; int _activePriority = 1;
FocusNode myFocusNode; FocusNode myFocusNode = FocusNode();
@override
void didChangeDependencies() {
super.didChangeDependencies();
if (_isInit) {
myFocusNode = FocusNode();
doctorsList = null;
patientsProv = Provider.of<PatientsProvider>(context);
patientsProv.getClinicsList();
patientsProv.getReferralFrequancyList();
}
_isInit = false;
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return AppScaffold( return BaseView<PatientViewModel>(
appBarTitle: TranslationBase.of(context).myReferralPatient, onModelReady: (model) => model.getClinicsList(),
body: patientsProv.isLoading builder: (_, model, w) => AppScaffold(
? DrAppCircularProgressIndeicator() baseViewModel: model,
: patientsProv.isError appBarTitle: TranslationBase.of(context).myReferralPatient,
? DrAppEmbeddedError(error: patientsProv.error) body: model.clinicsList == null
: patientsProv.clinicsList == null ? DrAppEmbeddedError(error: 'Something Wrong!')
? DrAppEmbeddedError(error: 'Something Wrong!') : SingleChildScrollView(
: SingleChildScrollView( child: Column(
child: Column( mainAxisAlignment: MainAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[
children: <Widget>[ AppText(
AppText( TranslationBase.of(context).clinic,
TranslationBase.of(context).clinic, fontSize: 18,
fontSize: 18, fontWeight: FontWeight.bold,
fontWeight: FontWeight.bold, marginLeft: 15,
marginLeft: 15, marginTop: 15,
marginTop: 15, ),
), RoundedContainer(
RoundedContainer( margin: 10,
margin: 10, showBorder: true,
showBorder: true,
raduis: 30, raduis: 30,
borderColor: Color(0xff707070), borderColor: Color(0xff707070),
width: double.infinity, width: double.infinity,
@ -112,7 +98,7 @@ class _ReferPatientState extends State<ReferPatientScreen> {
elevation: 16, elevation: 16,
selectedItemBuilder: selectedItemBuilder:
(BuildContext context) { (BuildContext context) {
return patientsProv return model
.getClinicNameList() .getClinicNameList()
.map((item) { .map((item) {
return Row( return Row(
@ -132,7 +118,7 @@ class _ReferPatientState extends State<ReferPatientScreen> {
setState(() { setState(() {
_selectedDoctor = null; _selectedDoctor = null;
_selectedClinic = newValue; _selectedClinic = newValue;
var clinicInfo = patientsProv var clinicInfo = model
.clinicsList .clinicsList
.where((i) => .where((i) =>
i['ClinicDescription'] i['ClinicDescription']
@ -144,10 +130,10 @@ class _ReferPatientState extends State<ReferPatientScreen> {
clinicId = clinicInfo[0]['ClinicID'] clinicId = clinicInfo[0]['ClinicID']
.toString(); .toString();
patientsProv.getDoctorsList(clinicId); model.getDoctorsList(clinicId);
}) })
}, },
items: patientsProv items: model
.getClinicNameList() .getClinicNameList()
.map((item) { .map((item) {
return DropdownMenuItem( return DropdownMenuItem(
@ -197,7 +183,7 @@ class _ReferPatientState extends State<ReferPatientScreen> {
elevation: 16, elevation: 16,
selectedItemBuilder: selectedItemBuilder:
(BuildContext context) { (BuildContext context) {
return patientsProv return model
.getDoctorNameList() .getDoctorNameList()
.map((item) { .map((item) {
return Row( return Row(
@ -217,7 +203,7 @@ class _ReferPatientState extends State<ReferPatientScreen> {
setState(() { setState(() {
_selectedDoctor = newValue; _selectedDoctor = newValue;
doctorsList = doctorsList =
patientsProv.doctorsList; model.doctorsList;
var doctorInfo = doctorsList var doctorInfo = doctorsList
.where((i) => i['DoctorName'] .where((i) => i['DoctorName']
@ -228,7 +214,7 @@ class _ReferPatientState extends State<ReferPatientScreen> {
.toString(); .toString();
}) })
}, },
items: patientsProv items: model
.getDoctorNameList() .getDoctorNameList()
.map((item) { .map((item) {
return DropdownMenuItem( return DropdownMenuItem(
@ -311,7 +297,7 @@ class _ReferPatientState extends State<ReferPatientScreen> {
elevation: 16, elevation: 16,
selectedItemBuilder: selectedItemBuilder:
(BuildContext context) { (BuildContext context) {
return patientsProv return model
.getReferralNamesList() .getReferralNamesList()
.map((item) { .map((item) {
return Row( return Row(
@ -330,7 +316,7 @@ class _ReferPatientState extends State<ReferPatientScreen> {
onChanged: (newValue) => { onChanged: (newValue) => {
setState(() { setState(() {
_selectedReferralFrequancy = newValue; _selectedReferralFrequancy = newValue;
var freqInfo = patientsProv var freqInfo = model
.referalFrequancyList .referalFrequancyList
.singleWhere((i) => i[ .singleWhere((i) => i[
'Description'] 'Description']
@ -342,7 +328,7 @@ class _ReferPatientState extends State<ReferPatientScreen> {
myFocusNode.requestFocus(); myFocusNode.requestFocus();
}) })
}, },
items: patientsProv items: model
.getReferralNamesList() .getReferralNamesList()
.map((item) { .map((item) {
return DropdownMenuItem( return DropdownMenuItem(
@ -391,16 +377,21 @@ class _ReferPatientState extends State<ReferPatientScreen> {
), ),
// TODO replace AppButton with secondary button and add loading // TODO replace AppButton with secondary button and add loading
AppButton( AppButton(
title: TranslationBase.of(context).send, title: TranslationBase
.of(context)
.send,
color: Color(PRIMARY_COLOR), color: Color(PRIMARY_COLOR),
onPressed: () => {referToDoctor(context)}, onPressed: () =>
{
referToDoctor(context, model)
},
) )
], ],
)) ))
], ],
), ),
), ),
); ),);
} }
Widget priorityBar(BuildContext _context) { Widget priorityBar(BuildContext _context) {
@ -489,25 +480,37 @@ class _ReferPatientState extends State<ReferPatientScreen> {
return time; return time;
} }
void referToDoctor(context) { referToDoctor(BuildContext context, PatientViewModel model) async {
if (!validation()) { if (!validation()) {
return; return;
} }
final routeArgs = ModalRoute.of(context).settings.arguments as Map; final routeArgs = ModalRoute
.of(context)
.settings
.arguments as Map;
PatiantInformtion patient = routeArgs['patient']; PatiantInformtion patient = routeArgs['patient'];
patientsProv.referToDoctor(context,
extension: _extController.value.text, try {
admissionNo: int.parse(patient.admissionNo), await model.referToDoctor(
referringDoctorRemarks: _remarksController.value.text, extension: _extController.value.text,
frequency: freqId, admissionNo: int.parse(patient.admissionNo),
patientID: patient.patientId, referringDoctorRemarks: _remarksController.value.text,
patientTypeID: patient.patientType, frequency: freqId,
priority: (_activePriority + 1).toString(), patientID: patient.patientId,
roomID: patient.roomId, patientTypeID: patient.patientType,
selectedClinicID: clinicId.toString(), priority: (_activePriority + 1).toString(),
selectedDoctorID: doctorId.toString(), roomID: patient.roomId,
projectID: patient.projectId); 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() { bool validation() {

Loading…
Cancel
Save