|
|
|
|
@ -23,7 +23,8 @@ import 'package:hexcolor/hexcolor.dart';
|
|
|
|
|
class PatientMakeReferralScreen extends StatefulWidget {
|
|
|
|
|
// previous design page is: ReferPatientScreen
|
|
|
|
|
@override
|
|
|
|
|
_PatientMakeReferralScreenState createState() => _PatientMakeReferralScreenState();
|
|
|
|
|
_PatientMakeReferralScreenState createState() =>
|
|
|
|
|
_PatientMakeReferralScreenState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _PatientMakeReferralScreenState extends State<PatientMakeReferralScreen> {
|
|
|
|
|
@ -56,8 +57,14 @@ class _PatientMakeReferralScreenState extends State<PatientMakeReferralScreen> {
|
|
|
|
|
String arrivalType = routeArgs['arrivalType'];
|
|
|
|
|
|
|
|
|
|
referToList = List();
|
|
|
|
|
dynamic sameBranch = {"id": 1, "name": TranslationBase.of(context).sameBranch};
|
|
|
|
|
dynamic otherBranch = {"id": 2, "name": TranslationBase.of(context).otherBranch};
|
|
|
|
|
dynamic sameBranch = {
|
|
|
|
|
"id": 1,
|
|
|
|
|
"name": TranslationBase.of(context).sameBranch
|
|
|
|
|
};
|
|
|
|
|
dynamic otherBranch = {
|
|
|
|
|
"id": 2,
|
|
|
|
|
"name": TranslationBase.of(context).otherBranch
|
|
|
|
|
};
|
|
|
|
|
referToList.add(sameBranch);
|
|
|
|
|
referToList.add(otherBranch);
|
|
|
|
|
|
|
|
|
|
@ -103,25 +110,57 @@ class _PatientMakeReferralScreenState extends State<PatientMakeReferralScreen> {
|
|
|
|
|
model.patientReferral.length == 0
|
|
|
|
|
? referralForm(model, screenSize)
|
|
|
|
|
: PatientReferralItemWidget(
|
|
|
|
|
referralStatus: model.patientReferral[model.patientReferral.length - 1].referralStatus,
|
|
|
|
|
patientName: model.patientReferral[model.patientReferral.length - 1].patientName,
|
|
|
|
|
patientGender:
|
|
|
|
|
model.patientReferral[model.patientReferral.length - 1].patientDetails.gender,
|
|
|
|
|
referredDate:
|
|
|
|
|
model.patientReferral[model.patientReferral.length - 1].referredOn.split(" ")[0],
|
|
|
|
|
referredTime:
|
|
|
|
|
model.patientReferral[model.patientReferral.length - 1].referredOn.split(" ")[1],
|
|
|
|
|
patientID: "${model.patientReferral[model.patientReferral.length - 1].patientID}",
|
|
|
|
|
isSameBranch:
|
|
|
|
|
model.patientReferral[model.patientReferral.length - 1].isReferralDoctorSameBranch,
|
|
|
|
|
referralStatus: model
|
|
|
|
|
.patientReferral[
|
|
|
|
|
model.patientReferral.length - 1]
|
|
|
|
|
.referralStatus,
|
|
|
|
|
patientName: model
|
|
|
|
|
.patientReferral[
|
|
|
|
|
model.patientReferral.length - 1]
|
|
|
|
|
.patientName,
|
|
|
|
|
patientGender: model
|
|
|
|
|
.patientReferral[
|
|
|
|
|
model.patientReferral.length - 1]
|
|
|
|
|
.patientDetails
|
|
|
|
|
.gender,
|
|
|
|
|
referredDate: model
|
|
|
|
|
.patientReferral[
|
|
|
|
|
model.patientReferral.length - 1]
|
|
|
|
|
.referredOn
|
|
|
|
|
.split(" ")[0],
|
|
|
|
|
referredTime: model
|
|
|
|
|
.patientReferral[
|
|
|
|
|
model.patientReferral.length - 1]
|
|
|
|
|
.referredOn
|
|
|
|
|
.split(" ")[1],
|
|
|
|
|
patientID:
|
|
|
|
|
"${model.patientReferral[model.patientReferral.length - 1].patientID}",
|
|
|
|
|
isSameBranch: model
|
|
|
|
|
.patientReferral[
|
|
|
|
|
model.patientReferral.length - 1]
|
|
|
|
|
.isReferralDoctorSameBranch,
|
|
|
|
|
isReferral: true,
|
|
|
|
|
remark: model.patientReferral[model.patientReferral.length - 1].remarksFromSource,
|
|
|
|
|
nationality:
|
|
|
|
|
model.patientReferral[model.patientReferral.length - 1].patientDetails.nationalityName,
|
|
|
|
|
nationalityFlag: model.patientReferral[model.patientReferral.length - 1].nationalityFlagUrl,
|
|
|
|
|
doctorAvatar: model.patientReferral[model.patientReferral.length - 1].doctorImageUrl,
|
|
|
|
|
referralDoctorName:
|
|
|
|
|
model.patientReferral[model.patientReferral.length - 1].referredByDoctorInfo,
|
|
|
|
|
remark: model
|
|
|
|
|
.patientReferral[
|
|
|
|
|
model.patientReferral.length - 1]
|
|
|
|
|
.remarksFromSource,
|
|
|
|
|
nationality: model
|
|
|
|
|
.patientReferral[
|
|
|
|
|
model.patientReferral.length - 1]
|
|
|
|
|
.patientDetails
|
|
|
|
|
.nationalityName,
|
|
|
|
|
nationalityFlag: model
|
|
|
|
|
.patientReferral[
|
|
|
|
|
model.patientReferral.length - 1]
|
|
|
|
|
.nationalityFlagUrl,
|
|
|
|
|
doctorAvatar: model
|
|
|
|
|
.patientReferral[
|
|
|
|
|
model.patientReferral.length - 1]
|
|
|
|
|
.doctorImageUrl,
|
|
|
|
|
referralDoctorName: model
|
|
|
|
|
.patientReferral[
|
|
|
|
|
model.patientReferral.length - 1]
|
|
|
|
|
.referredByDoctorInfo,
|
|
|
|
|
clinicDescription: null,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
@ -140,22 +179,26 @@ class _PatientMakeReferralScreenState extends State<PatientMakeReferralScreen> {
|
|
|
|
|
eventAction: "Submit Refer",
|
|
|
|
|
);
|
|
|
|
|
if (_referTo == null) {
|
|
|
|
|
branchError = TranslationBase.of(context).fieldRequired;
|
|
|
|
|
branchError =
|
|
|
|
|
TranslationBase.of(context).fieldRequired;
|
|
|
|
|
} else {
|
|
|
|
|
branchError = null;
|
|
|
|
|
}
|
|
|
|
|
if (_selectedBranch == null) {
|
|
|
|
|
hospitalError = TranslationBase.of(context).fieldRequired;
|
|
|
|
|
hospitalError =
|
|
|
|
|
TranslationBase.of(context).fieldRequired;
|
|
|
|
|
} else {
|
|
|
|
|
hospitalError = null;
|
|
|
|
|
}
|
|
|
|
|
if (_selectedClinic == null) {
|
|
|
|
|
clinicError = TranslationBase.of(context).fieldRequired;
|
|
|
|
|
clinicError =
|
|
|
|
|
TranslationBase.of(context).fieldRequired;
|
|
|
|
|
} else {
|
|
|
|
|
clinicError = null;
|
|
|
|
|
}
|
|
|
|
|
if (_selectedDoctor == null) {
|
|
|
|
|
doctorError = TranslationBase.of(context).fieldRequired;
|
|
|
|
|
doctorError =
|
|
|
|
|
TranslationBase.of(context).fieldRequired;
|
|
|
|
|
} else {
|
|
|
|
|
doctorError = null;
|
|
|
|
|
}
|
|
|
|
|
@ -166,10 +209,16 @@ class _PatientMakeReferralScreenState extends State<PatientMakeReferralScreen> {
|
|
|
|
|
_selectedDoctor == null ||
|
|
|
|
|
_remarksController.text == null) return;
|
|
|
|
|
model
|
|
|
|
|
.makeReferral(patient, appointmentDate.toIso8601String(), _selectedBranch['facilityId'],
|
|
|
|
|
_selectedClinic['ClinicID'], _selectedDoctor['DoctorID'], _remarksController.text)
|
|
|
|
|
.makeReferral(
|
|
|
|
|
patient,
|
|
|
|
|
appointmentDate.toIso8601String(),
|
|
|
|
|
_selectedBranch['facilityId'],
|
|
|
|
|
_selectedClinic['ClinicID'],
|
|
|
|
|
_selectedDoctor['DoctorID'],
|
|
|
|
|
_remarksController.text)
|
|
|
|
|
.then((_) {
|
|
|
|
|
DrAppToastMsg.showSuccesToast(TranslationBase.of(context).referralSuccessMsg);
|
|
|
|
|
DrAppToastMsg.showSuccesToast(
|
|
|
|
|
TranslationBase.of(context).referralSuccessMsg);
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
@ -215,7 +264,8 @@ class _PatientMakeReferralScreenState extends State<PatientMakeReferralScreen> {
|
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
|
await model
|
|
|
|
|
.getClinics(_selectedBranch['facilityId'])
|
|
|
|
|
.then((_) => GifLoaderDialogUtils.hideDialog(context));
|
|
|
|
|
.then((_) =>
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context));
|
|
|
|
|
if (model.state == ViewState.ErrorLocal) {
|
|
|
|
|
DrAppToastMsg.showErrorToast(model.error);
|
|
|
|
|
}
|
|
|
|
|
@ -242,42 +292,47 @@ class _PatientMakeReferralScreenState extends State<PatientMakeReferralScreen> {
|
|
|
|
|
AppTextFieldCustom(
|
|
|
|
|
height: screenSize.height * 0.075,
|
|
|
|
|
hintText: TranslationBase.of(context).hospital,
|
|
|
|
|
dropDownText: _selectedBranch != null ? _selectedBranch['facilityName'] : null,
|
|
|
|
|
dropDownText: _selectedBranch != null
|
|
|
|
|
? _selectedBranch['facilityName']
|
|
|
|
|
: null,
|
|
|
|
|
enabled: false,
|
|
|
|
|
isTextFieldHasSuffix: true,
|
|
|
|
|
validationError: hospitalError,
|
|
|
|
|
onClick:
|
|
|
|
|
model.branchesList != null && model.branchesList.length > 0 && _referTo != null && _referTo['id'] == 2
|
|
|
|
|
? () {
|
|
|
|
|
ListSelectDialog dialog = ListSelectDialog(
|
|
|
|
|
list: model.branchesList,
|
|
|
|
|
attributeName: 'facilityName',
|
|
|
|
|
attributeValueId: 'facilityId',
|
|
|
|
|
okText: TranslationBase.of(context).ok,
|
|
|
|
|
okFunction: (selectedValue) {
|
|
|
|
|
setState(() async {
|
|
|
|
|
_selectedBranch = selectedValue;
|
|
|
|
|
_selectedClinic = null;
|
|
|
|
|
_selectedDoctor = null;
|
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
|
await model
|
|
|
|
|
.getClinics(_selectedBranch['facilityId'])
|
|
|
|
|
.then((_) => GifLoaderDialogUtils.hideDialog(context));
|
|
|
|
|
if (model.state == ViewState.ErrorLocal) {
|
|
|
|
|
DrAppToastMsg.showErrorToast(model.error);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
showDialog(
|
|
|
|
|
barrierDismissible: false,
|
|
|
|
|
context: context,
|
|
|
|
|
builder: (BuildContext context) {
|
|
|
|
|
return dialog;
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
: null,
|
|
|
|
|
onClick: model.branchesList != null &&
|
|
|
|
|
model.branchesList.length > 0 &&
|
|
|
|
|
_referTo != null &&
|
|
|
|
|
_referTo['id'] == 2
|
|
|
|
|
? () {
|
|
|
|
|
ListSelectDialog dialog = ListSelectDialog(
|
|
|
|
|
list: model.branchesList,
|
|
|
|
|
attributeName: 'facilityName',
|
|
|
|
|
attributeValueId: 'facilityId',
|
|
|
|
|
okText: TranslationBase.of(context).ok,
|
|
|
|
|
okFunction: (selectedValue) {
|
|
|
|
|
setState(() async {
|
|
|
|
|
_selectedBranch = selectedValue;
|
|
|
|
|
_selectedClinic = null;
|
|
|
|
|
_selectedDoctor = null;
|
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
|
await model
|
|
|
|
|
.getClinics(_selectedBranch['facilityId'])
|
|
|
|
|
.then((_) =>
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context));
|
|
|
|
|
if (model.state == ViewState.ErrorLocal) {
|
|
|
|
|
DrAppToastMsg.showErrorToast(model.error);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
showDialog(
|
|
|
|
|
barrierDismissible: false,
|
|
|
|
|
context: context,
|
|
|
|
|
builder: (BuildContext context) {
|
|
|
|
|
return dialog;
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
: null,
|
|
|
|
|
),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 10,
|
|
|
|
|
@ -285,11 +340,15 @@ class _PatientMakeReferralScreenState extends State<PatientMakeReferralScreen> {
|
|
|
|
|
AppTextFieldCustom(
|
|
|
|
|
height: screenSize.height * 0.075,
|
|
|
|
|
hintText: TranslationBase.of(context).clinic,
|
|
|
|
|
dropDownText: _selectedClinic != null ? _selectedClinic['ClinicDescription'] : null,
|
|
|
|
|
dropDownText: _selectedClinic != null
|
|
|
|
|
? _selectedClinic['ClinicDescription']
|
|
|
|
|
: null,
|
|
|
|
|
enabled: false,
|
|
|
|
|
isTextFieldHasSuffix: true,
|
|
|
|
|
validationError: clinicError,
|
|
|
|
|
onClick: _selectedBranch != null && model.clinicsList != null && model.clinicsList.length > 0
|
|
|
|
|
onClick: _selectedBranch != null &&
|
|
|
|
|
model.clinicsList != null &&
|
|
|
|
|
model.clinicsList.length > 0
|
|
|
|
|
? () {
|
|
|
|
|
ListSelectDialog dialog = ListSelectDialog(
|
|
|
|
|
list: model.clinicsList,
|
|
|
|
|
@ -304,8 +363,12 @@ class _PatientMakeReferralScreenState extends State<PatientMakeReferralScreen> {
|
|
|
|
|
_selectedClinic = selectedValue;
|
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
|
await model
|
|
|
|
|
.getClinicDoctors(patient, _selectedClinic['ClinicID'], _selectedBranch['facilityId'])
|
|
|
|
|
.then((_) => GifLoaderDialogUtils.hideDialog(context));
|
|
|
|
|
.getClinicDoctors(
|
|
|
|
|
patient,
|
|
|
|
|
_selectedClinic['ClinicID'],
|
|
|
|
|
_selectedBranch['facilityId'])
|
|
|
|
|
.then((_) =>
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context));
|
|
|
|
|
if (model.state == ViewState.ErrorLocal) {
|
|
|
|
|
DrAppToastMsg.showErrorToast(model.error);
|
|
|
|
|
}
|
|
|
|
|
@ -328,11 +391,14 @@ class _PatientMakeReferralScreenState extends State<PatientMakeReferralScreen> {
|
|
|
|
|
AppTextFieldCustom(
|
|
|
|
|
height: screenSize.height * 0.075,
|
|
|
|
|
hintText: TranslationBase.of(context).doctor,
|
|
|
|
|
dropDownText: _selectedDoctor != null ? _selectedDoctor['Name'] : null,
|
|
|
|
|
dropDownText:
|
|
|
|
|
_selectedDoctor != null ? _selectedDoctor['Name'] : null,
|
|
|
|
|
enabled: false,
|
|
|
|
|
isTextFieldHasSuffix: true,
|
|
|
|
|
validationError: doctorError,
|
|
|
|
|
onClick: _selectedClinic != null && model.doctorsList != null && model.doctorsList.length > 0
|
|
|
|
|
onClick: _selectedClinic != null &&
|
|
|
|
|
model.doctorsList != null &&
|
|
|
|
|
model.doctorsList.length > 0
|
|
|
|
|
? () {
|
|
|
|
|
ListSelectDialog dialog = ListSelectDialog(
|
|
|
|
|
list: model.doctorsList,
|
|
|
|
|
@ -357,9 +423,12 @@ class _PatientMakeReferralScreenState extends State<PatientMakeReferralScreen> {
|
|
|
|
|
}
|
|
|
|
|
: () {
|
|
|
|
|
if (_selectedClinic == null) {
|
|
|
|
|
DrAppToastMsg.showErrorToast("You need to select a clinic first");
|
|
|
|
|
} else if (model.doctorsList == null || model.doctorsList.length == 0) {
|
|
|
|
|
DrAppToastMsg.showErrorToast("There is no doctors for this clinic");
|
|
|
|
|
DrAppToastMsg.showErrorToast(
|
|
|
|
|
"You need to select a clinic first");
|
|
|
|
|
} else if (model.doctorsList == null ||
|
|
|
|
|
model.doctorsList.length == 0) {
|
|
|
|
|
DrAppToastMsg.showErrorToast(
|
|
|
|
|
"There is no doctors for this clinic");
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
@ -369,8 +438,9 @@ class _PatientMakeReferralScreenState extends State<PatientMakeReferralScreen> {
|
|
|
|
|
AppTextFieldCustom(
|
|
|
|
|
height: screenSize.height * 0.075,
|
|
|
|
|
hintText: TranslationBase.of(context).date,
|
|
|
|
|
dropDownText:
|
|
|
|
|
appointmentDate != null ? "${AppDateUtils.convertDateToFormat(appointmentDate, "yyyy-MM-dd")}" : null,
|
|
|
|
|
dropDownText: appointmentDate != null
|
|
|
|
|
? "${AppDateUtils.convertDateToFormat(appointmentDate, "yyyy-MM-dd")}"
|
|
|
|
|
: null,
|
|
|
|
|
enabled: false,
|
|
|
|
|
isTextFieldHasSuffix: true,
|
|
|
|
|
suffixIcon: IconButton(
|
|
|
|
|
|