merge-requests/117/merge
ibrahim albitar 6 years ago
parent 446e09a1fc
commit 6fd43a281d

@ -63,7 +63,7 @@ class PatientsProvider with ChangeNotifier {
STPReferralFrequencyRequest(); STPReferralFrequencyRequest();
ClinicByProjectIdRequest _clinicByProjectIdRequest = ClinicByProjectIdRequest _clinicByProjectIdRequest =
ClinicByProjectIdRequest(); ClinicByProjectIdRequest();
ReferToDoctorRequest _referToDoctorRequest = ReferToDoctorRequest(); ReferToDoctorRequest _referToDoctorRequest;
PatiantInformtion _selectedPatient; PatiantInformtion _selectedPatient;
@ -486,7 +486,7 @@ class PatientsProvider with ChangeNotifier {
*@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,
@ -500,56 +500,42 @@ class PatientsProvider with ChangeNotifier {
int projectID}) async { int projectID}) async {
setBasicData(); setBasicData();
try { try {
if (await Helpers.checkConnection()) { 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,
onSuccess: (dynamic response, int statusCode) {
final response = await AppClient.post(PATIENT_REFER_TO_DOCTOR_URL, // print('Done : \n $res');
body: json.encode(_referToDoctorRequest));
final int statusCode = response.statusCode;
isLoading = false;
if (statusCode < 200 || statusCode >= 400 || json == null) {
isError = true;
error = 'Error While Fetching data';
} else {
var res = json.decode(response.body);
print('$res');
if (res['MessageStatus'] == 1) {
print('Done : \n $res');
Navigator.pop(context); Navigator.pop(context);
} else { },
onFailure: (String error, int statusCode) {
isLoading = false;
isError = true; isError = true;
error = res['ErrorMessage'] ?? res['ErrorEndUserMessage']; this.error = error;
} },
} body: _referToDoctorRequest.toJson());
} else {
isLoading = false;
isError = true;
error = 'Please Check The Internet Connection';
}
notifyListeners(); notifyListeners();
} catch (err) { } catch (err) {
handelCatchErrorCase(err); handelCatchErrorCase(err);
} }

@ -15,6 +15,7 @@ import '../../../util/dr_app_shared_pref.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'; import '../../../widgets/shared/dr_app_circular_progress_Indeicator.dart';
import '../../../util/extenstions.dart';
DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); DrAppSharedPreferances sharedPref = new DrAppSharedPreferances();
@ -37,6 +38,7 @@ class _ReferPatientState extends State<ReferPatientScreen> {
final _remarksController = TextEditingController(); final _remarksController = TextEditingController();
final _extController = TextEditingController(); final _extController = TextEditingController();
var _isInit = true; var _isInit = true;
bool isValid;
var clinicId; var clinicId;
var doctorId; var doctorId;
@ -49,10 +51,13 @@ class _ReferPatientState extends State<ReferPatientScreen> {
List<String> _priorities = ['Very Urgent', 'Urgent', 'Routine']; List<String> _priorities = ['Very Urgent', 'Urgent', 'Routine'];
int _activePriority = 2; int _activePriority = 2;
FocusNode myFocusNode;
@override @override
void didChangeDependencies() { void didChangeDependencies() {
super.didChangeDependencies(); super.didChangeDependencies();
if (_isInit) { if (_isInit) {
myFocusNode = FocusNode();
doctorsList = null; doctorsList = null;
patientsProv = Provider.of<PatientsProvider>(context); patientsProv = Provider.of<PatientsProvider>(context);
patientsProv.getClinicsList(); patientsProv.getClinicsList();
@ -70,10 +75,9 @@ class _ReferPatientState extends State<ReferPatientScreen> {
: patientsProv.isError : patientsProv.isError
? DrAppEmbeddedError(error: patientsProv.error) ? DrAppEmbeddedError(error: patientsProv.error)
: patientsProv.clinicsList == null : patientsProv.clinicsList == null
? DrAppEmbeddedError( ? DrAppEmbeddedError(error: 'Something Wrong!')
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>[
@ -128,13 +132,17 @@ class _ReferPatientState extends State<ReferPatientScreen> {
setState(() { setState(() {
_selectedDoctor = null; _selectedDoctor = null;
_selectedClinic = newValue; _selectedClinic = newValue;
var clinicInfo = patientsProv.clinicsList.where((i) => var clinicInfo = patientsProv
.clinicsList
.where((i) =>
i['ClinicDescription'] i['ClinicDescription']
.toString() .toString()
.contains(_selectedClinic)).toList(); .contains(
_selectedClinic))
.toList();
clinicId = clinicId = clinicInfo[0]['ClinicID']
clinicInfo[0]['ClinicID'].toString(); .toString();
patientsProv.getDoctorsList(clinicId); patientsProv.getDoctorsList(clinicId);
}) })
@ -208,15 +216,16 @@ class _ReferPatientState extends State<ReferPatientScreen> {
onChanged: (newValue) => { onChanged: (newValue) => {
setState(() { setState(() {
_selectedDoctor = newValue; _selectedDoctor = newValue;
doctorsList = patientsProv.doctorsList; doctorsList =
patientsProv.doctorsList;
var doctorInfo =
doctorsList.where((i) =>
i['DoctorName']
.toString()
.contains(_selectedDoctor)).toList();
doctorId = doctorInfo[0]['DoctorID'].toString();
var doctorInfo = doctorsList
.where((i) => i['DoctorName']
.toString()
.contains(_selectedDoctor))
.toList();
doctorId = doctorInfo[0]['DoctorID']
.toString();
}) })
}, },
items: patientsProv items: patientsProv
@ -320,13 +329,16 @@ class _ReferPatientState extends State<ReferPatientScreen> {
onChanged: (newValue) => { onChanged: (newValue) => {
setState(() { setState(() {
_selectedReferralFrequancy = newValue; _selectedReferralFrequancy = newValue;
var freqInfo = var freqInfo = patientsProv
patientsProv.referalFrequancyList.singleWhere((i) => .referalFrequancyList
i['Description'] .singleWhere((i) => i[
.toString() 'Description']
.contains(_selectedReferralFrequancy)); .toString()
freqId = .contains(
freqInfo['ParameterCode'].toString(); _selectedReferralFrequancy));
freqId = freqInfo['ParameterCode']
.toString();
myFocusNode.requestFocus();
}) })
}, },
items: patientsProv items: patientsProv
@ -357,6 +369,7 @@ class _ReferPatientState extends State<ReferPatientScreen> {
padding: const EdgeInsets.all(10.0), padding: const EdgeInsets.all(10.0),
child: AppTextFormField( child: AppTextFormField(
hintText: "Remarks", hintText: "Remarks",
focusNode: myFocusNode,
controller: _remarksController, controller: _remarksController,
inputFormatter: ONLY_LETTERS, inputFormatter: ONLY_LETTERS,
textInputType: TextInputType.text, textInputType: TextInputType.text,
@ -364,14 +377,27 @@ class _ReferPatientState extends State<ReferPatientScreen> {
), ),
), ),
Padding( Padding(
padding: const EdgeInsets.all(20.0), padding: const EdgeInsets.all(20.0),
child: AppButton(title: "Send", color: Color(PRIMARY_COLOR),onPressed: ()=>{ child: Column(
referToDoctor(context) children: <Widget>[
},), AppText(
) "Please fill all fields..!",
color: Colors.red,
fontWeight: FontWeight.bold,
margin: 10,
visibility:
isValid == null ? false : !isValid,
),
AppButton(
title: "Send",
color: Color(PRIMARY_COLOR),
onPressed: () => {referToDoctor(context)},
)
],
))
], ],
), ),
), ),
); );
} }
@ -456,21 +482,35 @@ class _ReferPatientState extends State<ReferPatientScreen> {
return time; return time;
} }
void referToDoctor(context){ void referToDoctor(context) {
if (!validation()) {
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, patientsProv.referToDoctor(context,
extension: _extController.value.text, extension: _extController.value.text,
admissionNo:int.parse( patient.admissionNo), admissionNo: int.parse(patient.admissionNo),
referringDoctorRemarks: _remarksController.value.text, referringDoctorRemarks: _remarksController.value.text,
frequency: freqId, frequency: freqId,
patientID: patient.patientId, patientID: patient.patientId,
patientTypeID: patient.patientType, patientTypeID: patient.patientType,
priority: (_activePriority + 1).toString(), priority: (_activePriority + 1).toString(),
roomID: patient.roomId, roomID: patient.roomId,
selectedClinicID: clinicId.toString(), selectedClinicID: clinicId.toString(),
selectedDoctorID: doctorId.toString(), selectedDoctorID: doctorId.toString(),
projectID: patient.projectId projectID: patient.projectId);
); }
bool validation() {
setState(() {
isValid = !_extController.value.text.isNullOrEmpty() &&
!_remarksController.value.text.isNullOrEmpty() &&
freqId != null &&
clinicId != null &&
doctorId != null;
});
return isValid;
} }
} }

@ -18,7 +18,8 @@ class AppTextFormField extends FormField<String> {
TextEditingController controller, TextEditingController controller,
bool autovalidate = true, bool autovalidate = true,
TextInputType textInputType, TextInputType textInputType,
String hintText String hintText,
FocusNode focusNode
}) : super( }) : super(
onSaved: onSaved, onSaved: onSaved,
validator: validator, validator: validator,
@ -27,6 +28,7 @@ class AppTextFormField extends FormField<String> {
return Column( return Column(
children: <Widget>[ children: <Widget>[
TextFormField( TextFormField(
focusNode: focusNode,
keyboardType: textInputType, keyboardType: textInputType,
inputFormatters: [WhitelistingTextInputFormatter(RegExp(inputFormatter)),], inputFormatters: [WhitelistingTextInputFormatter(RegExp(inputFormatter)),],
onChanged: onChanged?? (value){ onChanged: onChanged?? (value){

Loading…
Cancel
Save