working on Referral feature

merge-requests/249/head
mosazaid 5 years ago
parent 2f17167e2f
commit 8726653ffb

@ -71,6 +71,12 @@ const CREATE_REFERRAL_PATIENT =
const RESPONSE_PENDING_REFERRAL_PATIENT = const RESPONSE_PENDING_REFERRAL_PATIENT =
'Services/DoctorApplication.svc/REST/CreateReferral'; 'Services/DoctorApplication.svc/REST/CreateReferral';
const GET_PATIENT_REFERRAL =
'Services/DoctorApplication.svc/REST/GetRefferal';
const POST_UCAF =
'Services/DoctorApplication.svc/REST/PostUCAF';
const GET_DOCTOR_WORKING_HOURS_TABLE = const GET_DOCTOR_WORKING_HOURS_TABLE =
'Services/Doctors.svc/REST/GetDoctorWorkingHoursTable'; 'Services/Doctors.svc/REST/GetDoctorWorkingHoursTable';

@ -18,6 +18,7 @@ class PatientReferralService extends LookupService {
List<dynamic> doctorsList = []; List<dynamic> doctorsList = [];
List<MyReferredPatientModel> listMyReferredPatientModel = []; List<MyReferredPatientModel> listMyReferredPatientModel = [];
List<PendingReferral> pendingReferralList = []; List<PendingReferral> pendingReferralList = [];
List<PendingReferral> patientReferralList = [];
String setupID = "0"; String setupID = "0";
Future getProjectsList() async { Future getProjectsList() async {
@ -163,6 +164,33 @@ class PatientReferralService extends LookupService {
); );
} }
Future getPatientReferral(PatiantInformtion patient) async {
hasError = false;
Map<String, dynamic> body = Map();
body['PatientMRN'] = patient.patientMRN;
body['AppointmentNo'] = patient.appointmentNo;
await baseAppClient.post(
GET_PATIENT_REFERRAL,
onSuccess: (dynamic response, int statusCode) {
patientReferralList.clear();
response['ReferralList']['entityList'].forEach((v) {
PendingReferral item = PendingReferral.fromJson(v);
item.isReferralDoctorSameBranch =
item.targetProjectId == item.sourceProjectId;
patientReferralList.add(item);
});
},
onFailure: (String error, int statusCode) {
patientReferralList.clear();
hasError = true;
super.error = error;
},
body: body,
);
}
Future responseReferral(PendingReferral pendingReferral, bool isAccepted) async { Future responseReferral(PendingReferral pendingReferral, bool isAccepted) async {
hasError = false; hasError = false;
DoctorProfileModel doctorProfile = await getDoctorProfile(); DoctorProfileModel doctorProfile = await getDoctorProfile();
@ -221,6 +249,7 @@ class PatientReferralService extends LookupService {
CREATE_REFERRAL_PATIENT, CREATE_REFERRAL_PATIENT,
onSuccess: (dynamic response, int statusCode) { onSuccess: (dynamic response, int statusCode) {
print(response.toString()); print(response.toString());
print("create referral status code = ${statusCode}");
}, },
onFailure: (String error, int statusCode) { onFailure: (String error, int statusCode) {
hasError = true; hasError = true;

@ -27,9 +27,27 @@ class PatientReferralViewModel extends BaseViewModel {
List<PendingReferral> get pendingReferral => List<PendingReferral> get pendingReferral =>
_referralPatientService.pendingReferralList; _referralPatientService.pendingReferralList;
List<PendingReferral> get patientReferral =>
_referralPatientService.patientReferralList;
List<PatiantInformtion> get patientArrivalList => List<PatiantInformtion> get patientArrivalList =>
_referralPatientService.patientArrivalList; _referralPatientService.patientArrivalList;
Future getPatientReferral(PatiantInformtion patient) async {
setState(ViewState.Busy);
await _referralPatientService.getPatientReferral(patient);
if (_referralPatientService.hasError) {
error = _referralPatientService.error;
setState(ViewState.Error);
} else {
if(patientReferral.length == 0){
await getMasterLookup(MasterKeysService.physiotherapyGoals);
} else {
setState(ViewState.Idle);
}
}
}
Future getMasterLookup(MasterKeysService masterKeys) async { Future getMasterLookup(MasterKeysService masterKeys) async {
setState(ViewState.Busy); setState(ViewState.Busy);
await _referralPatientService.getMasterLookup(masterKeys); await _referralPatientService.getMasterLookup(masterKeys);
@ -37,7 +55,7 @@ class PatientReferralViewModel extends BaseViewModel {
error = _referralPatientService.error; error = _referralPatientService.error;
setState(ViewState.Error); setState(ViewState.Error);
} else } else
await getBranches(); await getBranches();
} }
Future getBranches() async { Future getBranches() async {

@ -8,6 +8,7 @@ import 'package:doctor_app_flutter/screens/base/base_view.dart';
import 'package:doctor_app_flutter/util/date-utils.dart'; import 'package:doctor_app_flutter/util/date-utils.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/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/patients/patient-referral-item-widget.dart';
import 'package:doctor_app_flutter/widgets/patients/profile/patient-page-header-widget.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/patient-page-header-widget.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_loader_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_loader_widget.dart';
@ -50,16 +51,21 @@ class _PatientMakeReferralScreenState extends State<PatientMakeReferralScreen> {
patient = routeArgs['patient']; patient = routeArgs['patient'];
referToList = List(); referToList = List();
dynamic sameBranch = {"id": 1, "name": TranslationBase.of(context).sameBranch}; dynamic sameBranch = {
dynamic otherBranch = {"id": 2, "name": TranslationBase.of(context).otherBranch}; "id": 1,
"name": TranslationBase.of(context).sameBranch
};
dynamic otherBranch = {
"id": 2,
"name": TranslationBase.of(context).otherBranch
};
referToList.add(sameBranch); referToList.add(sameBranch);
referToList.add(otherBranch); referToList.add(otherBranch);
final screenSize = MediaQuery.of(context).size; final screenSize = MediaQuery.of(context).size;
return BaseView<PatientReferralViewModel>( return BaseView<PatientReferralViewModel>(
onModelReady: (model) => onModelReady: (model) => model.getPatientReferral(patient),
model.getMasterLookup(MasterKeysService.physiotherapyGoals),
builder: (_, model, w) => AppScaffold( builder: (_, model, w) => AppScaffold(
baseViewModel: model, baseViewModel: model,
appBarTitle: TranslationBase.of(context).referPatient, appBarTitle: TranslationBase.of(context).referPatient,
@ -86,279 +92,50 @@ class _PatientMakeReferralScreenState extends State<PatientMakeReferralScreen> {
indent: 0, indent: 0,
endIndent: 0, endIndent: 0,
), ),
Container( model.patientReferral.length == 0
margin: ? ReferralForm(model, screenSize)
EdgeInsets.symmetric(vertical: 16, horizontal: 16), : PatientReferralItemWidget(
child: Column( patientName: model.patientReferral[0].patientName,
crossAxisAlignment: CrossAxisAlignment.start, referralStatus: "${model.patientReferral[0].referralStatus}",
children: [ isReferredTo: true,
SizedBox( isSameBranch: model.patientReferral[0]
height: 16, .isReferralDoctorSameBranch,
), referralDoctorName:
AppText( model.patientReferral[0].referredByDoctorInfo,
TranslationBase.of(context).referPatient, clinicDescription: null,
fontWeight: FontWeight.bold, remark:
fontSize: 16, model.patientReferral[0].remarksFromSource
),
SizedBox(
height: 16,
),
Container(
height: screenSize.height * 0.070,
child: InkWell(
onTap: referToList != null
? () {
ListSelectDialog dialog =
ListSelectDialog(
list: referToList,
attributeName: 'name',
attributeValueId: 'id',
okText: TranslationBase.of(context).ok,
okFunction: (selectedValue) {
setState(() {
_referTo = selectedValue;
_selectedBranch = null;
_selectedClinic = null;
_selectedDoctor = null;
model
.getDoctorBranch()
.then((value) {
_selectedBranch = value;
if (_referTo['id'] == 1) {
model.getClinics(
_selectedBranch['ID']);
}
});
});
},
);
showDialog(
barrierDismissible: false,
context: context,
builder: (BuildContext context) {
return dialog;
},
);
}
: null,
child: TextField(
decoration: textFieldSelectorDecoration(
TranslationBase.of(context).referTo,
_referTo != null ? _referTo['name'] : null,
true),
enabled: false,
),
),
),
SizedBox(
height: 10,
),
Container(
height: screenSize.height * 0.070,
child: InkWell(
onTap: model.branchesList != null &&
model.branchesList.length > 0 &&
_referTo != null &&
_referTo['id'] == 2
? () {
ListSelectDialog dialog =
ListSelectDialog(
list: model.branchesList,
attributeName: 'Desciption',
attributeValueId: 'ID',
okText: TranslationBase.of(context).ok,
okFunction: (selectedValue) {
setState(() {
_selectedBranch = selectedValue;
_selectedClinic = null;
_selectedDoctor = null;
model.getClinics(
_selectedBranch['ID']);
});
},
);
showDialog(
barrierDismissible: false,
context: context,
builder: (BuildContext context) {
return dialog;
},
);
}
: null,
child: TextField(
decoration: textFieldSelectorDecoration(
TranslationBase.of(context).branch,
_selectedBranch != null
? _selectedBranch['Desciption']
: null,
true),
enabled: false,
),
),
),
SizedBox(
height: 10,
),
Container(
height: screenSize.height * 0.070,
child: InkWell(
onTap: _selectedBranch != null &&
model.clinicsList != null &&
model.clinicsList.length > 0
? () {
ListSelectDialog dialog =
ListSelectDialog(
list: model.clinicsList,
attributeName: 'ClinicDescription',
attributeValueId: 'ClinicID',
okText: TranslationBase.of(context).ok,
okFunction: (selectedValue) {
setState(() {
_selectedDoctor = null;
_selectedClinic = selectedValue;
model.getClinicDoctors(
_selectedClinic['ClinicID']
.toString());
});
},
);
showDialog(
barrierDismissible: false,
context: context,
builder: (BuildContext context) {
return dialog;
},
);
}
: null,
child: TextField(
decoration: textFieldSelectorDecoration(
TranslationBase.of(context).clinic,
_selectedClinic != null
? _selectedClinic['ClinicDescription']
: null,
true),
enabled: false,
),
),
),
SizedBox(
height: 10,
),
Container(
height: screenSize.height * 0.070,
child: InkWell(
onTap: _selectedClinic != null &&
model.doctorsList != null &&
model.doctorsList.length > 0
? () {
ListSelectDialog dialog =
ListSelectDialog(
list: model.doctorsList,
attributeName: 'DoctorName',
attributeValueId: 'DoctorID',
okText: TranslationBase.of(context).ok,
okFunction: (selectedValue) {
setState(() {
_selectedDoctor = selectedValue;
});
},
);
showDialog(
barrierDismissible: false,
context: context,
builder: (BuildContext context) {
return dialog;
},
);
}
: null,
child: TextField(
decoration: textFieldSelectorDecoration(
TranslationBase.of(context).doctor,
_selectedDoctor != null
? _selectedDoctor['DoctorName']
: null,
true),
enabled: false,
),
),
),
SizedBox(
height: 10,
),
Container(
height: screenSize.height * 0.070,
child: InkWell(
onTap: () => _selectDate(context, model),
child: TextField(
decoration: textFieldSelectorDecoration(
TranslationBase.of(context)
.chooseAppointment,
appointmentDate != null
? "${DateUtils.convertDateToFormat(appointmentDate, "yyyy-MM-dd")}"
: null,
true,
suffixIcon: Icon(
Icons.calendar_today,
color: Colors.black,
)),
enabled: false,
),
),
),
SizedBox(
height: 10,
),
Container(
child: TextField(
decoration: textFieldSelectorDecoration(
TranslationBase.of(context).remarks,
null,
false),
enabled: true,
controller: _remarksController,
inputFormatters: [
FilteringTextInputFormatter.allow(
RegExp(ONLY_LETTERS))
],
keyboardType: TextInputType.text,
minLines: 4,
maxLines: 6,
)),
],
),
), ),
], ],
), ),
Container( if (model.patientReferral.length == 0)
margin: EdgeInsets.symmetric(horizontal: 16, vertical: 8), Container(
child: AppButton( margin: EdgeInsets.symmetric(horizontal: 16, vertical: 8),
title: TranslationBase.of(context).refer, child: AppButton(
color: HexColor("#B8382B"), title: TranslationBase.of(context).refer,
onPressed: () { color: HexColor("#B8382B"),
if (appointmentDate == null || onPressed: () {
_selectedBranch == null || if (appointmentDate == null ||
_selectedClinic == null || _selectedBranch == null ||
_selectedDoctor == null || _selectedClinic == null ||
_remarksController.text == null) return; _selectedDoctor == null ||
model _remarksController.text == null) return;
.makeReferral( model
patient, .makeReferral(
appointmentDate.toIso8601String(), patient,
_selectedBranch['ID'], appointmentDate.toIso8601String(),
_selectedClinic['ClinicID'], _selectedBranch['ID'],
_selectedDoctor['DoctorID'], _selectedClinic['ClinicID'],
_remarksController.text) _selectedDoctor['DoctorID'],
.then((_) { _remarksController.text)
DrAppToastMsg.showSuccesToast( .then((_) {
TranslationBase.of(context).referralSuccessMsg); DrAppToastMsg.showSuccesToast(
Navigator.pop(context); TranslationBase.of(context).referralSuccessMsg);
}); Navigator.pop(context);
}, });
), },
) ),
)
], ],
), ),
), ),
@ -367,6 +144,239 @@ class _PatientMakeReferralScreenState extends State<PatientMakeReferralScreen> {
); );
} }
Widget ReferralForm(PatientReferralViewModel model, Size screenSize) {
return Container(
margin: EdgeInsets.symmetric(vertical: 16, horizontal: 16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: 16,
),
AppText(
TranslationBase.of(context).referPatient,
fontWeight: FontWeight.bold,
fontSize: 16,
),
SizedBox(
height: 16,
),
Container(
height: screenSize.height * 0.070,
child: InkWell(
onTap: referToList != null
? () {
ListSelectDialog dialog = ListSelectDialog(
list: referToList,
attributeName: 'name',
attributeValueId: 'id',
okText: TranslationBase.of(context).ok,
okFunction: (selectedValue) {
setState(() {
_referTo = selectedValue;
_selectedBranch = null;
_selectedClinic = null;
_selectedDoctor = null;
model.getDoctorBranch().then((value) {
_selectedBranch = value;
if (_referTo['id'] == 1) {
model.getClinics(_selectedBranch['ID']);
}
});
});
},
);
showDialog(
barrierDismissible: false,
context: context,
builder: (BuildContext context) {
return dialog;
},
);
}
: null,
child: TextField(
decoration: textFieldSelectorDecoration(
TranslationBase.of(context).referTo,
_referTo != null ? _referTo['name'] : null,
true),
enabled: false,
),
),
),
SizedBox(
height: 10,
),
Container(
height: screenSize.height * 0.070,
child: InkWell(
onTap: model.branchesList != null &&
model.branchesList.length > 0 &&
_referTo != null &&
_referTo['id'] == 2
? () {
ListSelectDialog dialog = ListSelectDialog(
list: model.branchesList,
attributeName: 'Desciption',
attributeValueId: 'ID',
okText: TranslationBase.of(context).ok,
okFunction: (selectedValue) {
setState(() {
_selectedBranch = selectedValue;
_selectedClinic = null;
_selectedDoctor = null;
model.getClinics(_selectedBranch['ID']);
});
},
);
showDialog(
barrierDismissible: false,
context: context,
builder: (BuildContext context) {
return dialog;
},
);
}
: null,
child: TextField(
decoration: textFieldSelectorDecoration(
TranslationBase.of(context).branch,
_selectedBranch != null
? _selectedBranch['Desciption']
: null,
true),
enabled: false,
),
),
),
SizedBox(
height: 10,
),
Container(
height: screenSize.height * 0.070,
child: InkWell(
onTap: _selectedBranch != null &&
model.clinicsList != null &&
model.clinicsList.length > 0
? () {
ListSelectDialog dialog = ListSelectDialog(
list: model.clinicsList,
attributeName: 'ClinicDescription',
attributeValueId: 'ClinicID',
okText: TranslationBase.of(context).ok,
okFunction: (selectedValue) {
setState(() {
_selectedDoctor = null;
_selectedClinic = selectedValue;
model.getClinicDoctors(
_selectedClinic['ClinicID'].toString());
});
},
);
showDialog(
barrierDismissible: false,
context: context,
builder: (BuildContext context) {
return dialog;
},
);
}
: null,
child: TextField(
decoration: textFieldSelectorDecoration(
TranslationBase.of(context).clinic,
_selectedClinic != null
? _selectedClinic['ClinicDescription']
: null,
true),
enabled: false,
),
),
),
SizedBox(
height: 10,
),
Container(
height: screenSize.height * 0.070,
child: InkWell(
onTap: _selectedClinic != null &&
model.doctorsList != null &&
model.doctorsList.length > 0
? () {
ListSelectDialog dialog = ListSelectDialog(
list: model.doctorsList,
attributeName: 'DoctorName',
attributeValueId: 'DoctorID',
okText: TranslationBase.of(context).ok,
okFunction: (selectedValue) {
setState(() {
_selectedDoctor = selectedValue;
});
},
);
showDialog(
barrierDismissible: false,
context: context,
builder: (BuildContext context) {
return dialog;
},
);
}
: null,
child: TextField(
decoration: textFieldSelectorDecoration(
TranslationBase.of(context).doctor,
_selectedDoctor != null
? _selectedDoctor['DoctorName']
: null,
true),
enabled: false,
),
),
),
SizedBox(
height: 10,
),
Container(
height: screenSize.height * 0.070,
child: InkWell(
onTap: () => _selectDate(context, model),
child: TextField(
decoration: textFieldSelectorDecoration(
TranslationBase.of(context).chooseAppointment,
appointmentDate != null
? "${DateUtils.convertDateToFormat(appointmentDate, "yyyy-MM-dd")}"
: null,
true,
suffixIcon: Icon(
Icons.calendar_today,
color: Colors.black,
)),
enabled: false,
),
),
),
SizedBox(
height: 10,
),
Container(
child: TextField(
decoration: textFieldSelectorDecoration(
TranslationBase.of(context).remarks, null, false),
enabled: true,
controller: _remarksController,
inputFormatters: [
FilteringTextInputFormatter.allow(RegExp(ONLY_LETTERS))
],
keyboardType: TextInputType.text,
minLines: 4,
maxLines: 6,
)),
],
),
);
}
_selectDate(BuildContext context, PatientReferralViewModel model) async { _selectDate(BuildContext context, PatientReferralViewModel model) async {
// https://medium.com/flutter-community/a-deep-dive-into-datepicker-in-flutter-37e84f7d8d6c good reference // https://medium.com/flutter-community/a-deep-dive-into-datepicker-in-flutter-37e84f7d8d6c good reference
// https://stackoverflow.com/a/63147062/6246772 to customize a date picker // https://stackoverflow.com/a/63147062/6246772 to customize a date picker

@ -37,7 +37,7 @@ class PatientReferralItemWidget extends StatelessWidget {
children: <Widget>[ children: <Widget>[
Center( Center(
child: AppText( child: AppText(
patientName, "${patientName}",
color: Colors.black, color: Colors.black,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
fontSize: 16, fontSize: 16,
@ -48,9 +48,10 @@ class PatientReferralItemWidget extends StatelessWidget {
color: Color(0xFF4BA821), color: Color(0xFF4BA821),
padding: EdgeInsets.all(4), padding: EdgeInsets.all(4),
child: AppText( child: AppText(
referralStatus == "46" referralStatus
/*referralStatus == "46"
? TranslationBase.of(context).approved ? TranslationBase.of(context).approved
: TranslationBase.of(context).rejected, : TranslationBase.of(context).rejected*/,
color: Colors.white, color: Colors.white,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
fontSize: 12, fontSize: 12,

Loading…
Cancel
Save