|
|
|
@ -17,6 +17,7 @@ import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
|
|
import '../routes.dart';
|
|
|
|
|
import 'base/base_view.dart';
|
|
|
|
|
|
|
|
|
|
Helpers helpers = Helpers();
|
|
|
|
|
|
|
|
|
|
class QrReaderScreen extends StatefulWidget {
|
|
|
|
@ -59,6 +60,7 @@ class _QrReaderScreenState extends State<QrReaderScreen> {
|
|
|
|
|
onModelReady: (model) => model.getClinicsList(),
|
|
|
|
|
builder: (_, model, w) => AppScaffold(
|
|
|
|
|
baseViewModel: model,
|
|
|
|
|
isShowAppBar: false,
|
|
|
|
|
appBarTitle:
|
|
|
|
|
TranslationBase.of(context).qr + TranslationBase.of(context).reader,
|
|
|
|
|
body: Center(
|
|
|
|
@ -71,63 +73,63 @@ class _QrReaderScreenState extends State<QrReaderScreen> {
|
|
|
|
|
AppText(
|
|
|
|
|
TranslationBase.of(context).startScanning,
|
|
|
|
|
fontSize: 18,
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
|
),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 7,
|
|
|
|
|
),
|
|
|
|
|
AppText(TranslationBase.of(context).scanQrCode,
|
|
|
|
|
fontSize: 14,
|
|
|
|
|
fontWeight: FontWeight.w400,
|
|
|
|
|
textAlign: TextAlign.center),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 15,
|
|
|
|
|
),
|
|
|
|
|
Container(
|
|
|
|
|
height: 150,
|
|
|
|
|
child: Image.asset('assets/images/qr_code.png'),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 35,
|
|
|
|
|
),
|
|
|
|
|
Button(
|
|
|
|
|
onTap: () {
|
|
|
|
|
_scanQrAndGetPatient(context, model);
|
|
|
|
|
},
|
|
|
|
|
title: TranslationBase.of(context).scanQr,
|
|
|
|
|
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(),
|
|
|
|
|
],
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
|
),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 7,
|
|
|
|
|
),
|
|
|
|
|
AppText(TranslationBase.of(context).scanQrCode,
|
|
|
|
|
fontSize: 14,
|
|
|
|
|
fontWeight: FontWeight.w400,
|
|
|
|
|
textAlign: TextAlign.center),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 15,
|
|
|
|
|
),
|
|
|
|
|
Container(
|
|
|
|
|
height: 150,
|
|
|
|
|
child: Image.asset('assets/images/qr_code.png'),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 35,
|
|
|
|
|
),
|
|
|
|
|
Button(
|
|
|
|
|
onTap: () {
|
|
|
|
|
_scanQrAndGetPatient(context, model);
|
|
|
|
|
},
|
|
|
|
|
title: TranslationBase.of(context).scanQr,
|
|
|
|
|
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(),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),);
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_scanQrAndGetPatient(BuildContext context, PatientViewModel model) async {
|
|
|
|
@ -135,7 +137,7 @@ class _QrReaderScreenState extends State<QrReaderScreen> {
|
|
|
|
|
/// var result = await BarcodeScanner.scan();
|
|
|
|
|
/// int patientID = get from qr result
|
|
|
|
|
var result = await BarcodeScanner.scan();
|
|
|
|
|
if (result.rawContent != "") {
|
|
|
|
|
if (result.rawContent != "") {
|
|
|
|
|
List<String> listOfParams = result.rawContent.split(',');
|
|
|
|
|
String patientType = "1";
|
|
|
|
|
setState(() {
|
|
|
|
@ -152,66 +154,65 @@ class _QrReaderScreenState extends State<QrReaderScreen> {
|
|
|
|
|
// 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');
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
setState(() {
|
|
|
|
|
isLoading = false;
|
|
|
|
|
isError = true;
|
|
|
|
|
});
|
|
|
|
|
DrAppToastMsg.showErrorToast(
|
|
|
|
|
response['ErrorEndUserMessage'] ?? response['ErrorMessage']);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
}).catchError((error) {
|
|
|
|
|
setState(() {
|
|
|
|
|
isLoading = false;
|
|
|
|
|
isError = true;
|
|
|
|
|
});
|
|
|
|
|
DrAppToastMsg.showErrorToast(
|
|
|
|
|
response['ErrorEndUserMessage'] ?? response['ErrorMessage']);
|
|
|
|
|
}
|
|
|
|
|
}).catchError((error) {
|
|
|
|
|
setState(() {
|
|
|
|
|
isLoading = false;
|
|
|
|
|
helpers.showErrorToast(error.message);
|
|
|
|
|
//DrAppToastMsg.showErrorToast(error);
|
|
|
|
|
});
|
|
|
|
|
helpers.showErrorToast(error.message);
|
|
|
|
|
//DrAppToastMsg.showErrorToast(error);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|