|
|
|
|
@ -1,11 +1,9 @@
|
|
|
|
|
import 'package:barcode_scan_fix/barcode_scan.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/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/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/util/dr_app_shared_pref.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';
|
|
|
|
|
@ -26,38 +24,9 @@ class QrReaderScreen extends StatefulWidget {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _QrReaderScreenState extends State<QrReaderScreen> {
|
|
|
|
|
DrAppSharedPreferances sharedPref = new DrAppSharedPreferances();
|
|
|
|
|
|
|
|
|
|
bool isLoading = false;
|
|
|
|
|
bool isError = false;
|
|
|
|
|
PatientModel patient = PatientModel(
|
|
|
|
|
ProjectID: 15,
|
|
|
|
|
ClinicID: 0,
|
|
|
|
|
DoctorID: 1485,
|
|
|
|
|
FirstName: "0",
|
|
|
|
|
MiddleName: "0",
|
|
|
|
|
LastName: "0",
|
|
|
|
|
PatientMobileNumber: "0",
|
|
|
|
|
PatientIdentificationID: "0",
|
|
|
|
|
PatientID: 0,
|
|
|
|
|
From: "0",
|
|
|
|
|
To: "0",
|
|
|
|
|
LanguageID: 2,
|
|
|
|
|
stamp: "2020-03-02T13:56:39.170Z",
|
|
|
|
|
IPAdress: "11.11.11.11",
|
|
|
|
|
VersionID: 5.5,
|
|
|
|
|
Channel: 9,
|
|
|
|
|
TokenID: "@dm!n",
|
|
|
|
|
SessionID: "5G0yXn0Jnq",
|
|
|
|
|
IsLoginForDoctorApp: true,
|
|
|
|
|
PatientOutSA: false);
|
|
|
|
|
List<PatiantInformtion> patientList = [];
|
|
|
|
|
String error = '';
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return BaseView<PatientViewModel>(
|
|
|
|
|
onModelReady: (model) => model.getClinicsList(),
|
|
|
|
|
return BaseView<ScanQrViewModel>(
|
|
|
|
|
builder: (_, model, w) => AppScaffold(
|
|
|
|
|
baseViewModel: model,
|
|
|
|
|
isShowAppBar: false,
|
|
|
|
|
@ -95,26 +64,8 @@ class _QrReaderScreenState extends State<QrReaderScreen> {
|
|
|
|
|
onPressed: () {
|
|
|
|
|
_scanQrAndGetPatient(context, model);
|
|
|
|
|
},
|
|
|
|
|
loading: isLoading,
|
|
|
|
|
icon: Image.asset('assets/images/qr_code_white.png'),
|
|
|
|
|
),
|
|
|
|
|
isError
|
|
|
|
|
? Container(
|
|
|
|
|
margin: EdgeInsets.only(top: 8),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
borderRadius: BorderRadius.circular(6.0),
|
|
|
|
|
color: Theme.of(context).errorColor.withOpacity(0.06),
|
|
|
|
|
),
|
|
|
|
|
padding: EdgeInsets.symmetric(vertical: 8.0, horizontal: 12.0),
|
|
|
|
|
child: Row(
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
Expanded(
|
|
|
|
|
child: AppText(error ?? TranslationBase.of(context).errorMessage,
|
|
|
|
|
color: Theme.of(context).errorColor)),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
: Container(),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
@ -124,82 +75,32 @@ 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
|
|
|
|
|
var result = await BarcodeScanner.scan();
|
|
|
|
|
if (result != "") {
|
|
|
|
|
List<String> listOfParams = result.split(',');
|
|
|
|
|
String patientType = "1";
|
|
|
|
|
setState(() {
|
|
|
|
|
isLoading = true;
|
|
|
|
|
isError = false;
|
|
|
|
|
patientList = [];
|
|
|
|
|
});
|
|
|
|
|
String token = await sharedPref.getString(TOKEN);
|
|
|
|
|
// Map profile = await sharedPref.getObj(DOCTOR_PROFILE);
|
|
|
|
|
// DoctorProfileModel doctorProfile = new DoctorProfileModel.fromJson(profile);
|
|
|
|
|
// patient.PatientID = 8808;
|
|
|
|
|
// patient.TokenID = token;
|
|
|
|
|
// patient.setDoctorID = doctorProfile.projectID;
|
|
|
|
|
// patient.setClinicID = doctorProfile.clinicID;
|
|
|
|
|
// patient.setProjectID = doctorProfile.projectID;
|
|
|
|
|
// Provider.of<PatientsProvider>(context, listen: false);
|
|
|
|
|
patient.PatientID = 8808;
|
|
|
|
|
patient.TokenID = token;
|
|
|
|
|
model.getPatientList(patient, "1", isBusyLocal: true).then((response) {
|
|
|
|
|
if (response['MessageStatus'] == 1) {
|
|
|
|
|
switch (patientType) {
|
|
|
|
|
case "0":
|
|
|
|
|
if (response['List_MyOutPatient'] != null) {
|
|
|
|
|
setState(() {
|
|
|
|
|
patientList = ModelResponse.fromJson(response['List_MyOutPatient']).list;
|
|
|
|
|
isLoading = false;
|
|
|
|
|
});
|
|
|
|
|
Navigator.of(context).pushNamed(PATIENTS_PROFILE, arguments: {
|
|
|
|
|
"patient": patientList[0],
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
setState(() {
|
|
|
|
|
isError = true;
|
|
|
|
|
isLoading = false;
|
|
|
|
|
});
|
|
|
|
|
DrAppToastMsg.showErrorToast('No patient');
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case "1":
|
|
|
|
|
if (response['List_MyInPatient'] != null) {
|
|
|
|
|
setState(() {
|
|
|
|
|
patientList = ModelResponse.fromJson(response['List_MyInPatient']).list;
|
|
|
|
|
isLoading = false;
|
|
|
|
|
error = "";
|
|
|
|
|
});
|
|
|
|
|
Navigator.of(context).pushNamed(PATIENTS_PROFILE, arguments: {
|
|
|
|
|
"patient": patientList[0],
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
setState(() {
|
|
|
|
|
isError = true;
|
|
|
|
|
isLoading = false;
|
|
|
|
|
});
|
|
|
|
|
DrAppToastMsg.showErrorToast('No patient');
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
int patientID = 0;
|
|
|
|
|
if (listOfParams[1].length != 0) patientID = int.parse(listOfParams[1]);
|
|
|
|
|
PatientSearchRequestModel patientSearchRequestModel = PatientSearchRequestModel(
|
|
|
|
|
patientID: patientID,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
await model.getInPatientList(patientSearchRequestModel, isMyInpatient: true).then((d) {
|
|
|
|
|
if (model.state != ViewState.ErrorLocal) {
|
|
|
|
|
if (model.inPatientList.isEmpty)
|
|
|
|
|
DrAppToastMsg.showErrorToast('No patient');
|
|
|
|
|
else
|
|
|
|
|
Navigator.of(context).pushNamed(PATIENTS_PROFILE, arguments: {
|
|
|
|
|
"patient": model.inPatientList[0],
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
setState(() {
|
|
|
|
|
isLoading = false;
|
|
|
|
|
isError = true;
|
|
|
|
|
});
|
|
|
|
|
DrAppToastMsg.showErrorToast(response['ErrorEndUserMessage'] ?? response['ErrorMessage']);
|
|
|
|
|
DrAppToastMsg.showErrorToast(model.error);
|
|
|
|
|
}
|
|
|
|
|
}).catchError((error) {
|
|
|
|
|
setState(() {
|
|
|
|
|
isLoading = false;
|
|
|
|
|
});
|
|
|
|
|
Helpers.showErrorToast(error.message);
|
|
|
|
|
//DrAppToastMsg.showErrorToast(error);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|