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;
@ -500,7 +500,6 @@ 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 =
@ -524,32 +523,19 @@ class PatientsProvider with ChangeNotifier {
frequency: frequency, frequency: frequency,
extension: extension, extension: extension,
tokenID: token); tokenID: token);
await BaseAppClient.post(PATIENT_REFER_TO_DOCTOR_URL,
final response = await AppClient.post(PATIENT_REFER_TO_DOCTOR_URL, onSuccess: (dynamic response, int statusCode) {
body: json.encode(_referToDoctorRequest)); // print('Done : \n $res');
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 { },
isError = true; onFailure: (String error, int statusCode) {
error = res['ErrorMessage'] ?? res['ErrorEndUserMessage'];
}
}
} else {
isLoading = false; isLoading = false;
isError = true; isError = true;
error = 'Please Check The Internet Connection'; this.error = error;
} },
body: _referToDoctorRequest.toJson());
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,8 +75,7 @@ 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,
@ -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 = var doctorInfo = doctorsList
doctorsList.where((i) => .where((i) => i['DoctorName']
i['DoctorName']
.toString() .toString()
.contains(_selectedDoctor)).toList(); .contains(_selectedDoctor))
doctorId = doctorInfo[0]['DoctorID'].toString(); .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[
'Description']
.toString() .toString()
.contains(_selectedReferralFrequancy)); .contains(
freqId = _selectedReferralFrequancy));
freqInfo['ParameterCode'].toString(); 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,
@ -365,11 +378,24 @@ 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,12 +482,16 @@ 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,
@ -470,7 +500,17 @@ class _ReferPatientState extends State<ReferPatientScreen> {
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