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

@ -63,7 +63,7 @@ class PatientsProvider with ChangeNotifier {
STPReferralFrequencyRequest();
ClinicByProjectIdRequest _clinicByProjectIdRequest =
ClinicByProjectIdRequest();
ReferToDoctorRequest _referToDoctorRequest = ReferToDoctorRequest();
ReferToDoctorRequest _referToDoctorRequest;
PatiantInformtion _selectedPatient;
@ -486,7 +486,7 @@ class PatientsProvider with ChangeNotifier {
*@Date:3/6/2020
*@desc: referToDoctor
*/
referToDoctor(context,
referToDoctor(context,
{String selectedDoctorID,
String selectedClinicID,
int admissionNo,
@ -500,56 +500,42 @@ class PatientsProvider with ChangeNotifier {
int projectID}) async {
setBasicData();
try {
if (await Helpers.checkConnection()) {
String token = await sharedPref.getString(TOKEN);
Map profile = await sharedPref.getObj(DOCTOR_PROFILE);
DoctorProfileModel doctorProfile =
new DoctorProfileModel.fromJson(profile);
int doctorID = doctorProfile.doctorID;
int clinicId = doctorProfile.clinicID;
_referToDoctorRequest = ReferToDoctorRequest(
projectID: projectID,
admissionNo: admissionNo,
roomID: roomID,
referralClinic: selectedClinicID.toString(),
referralDoctor: selectedDoctorID.toString(),
createdBy: doctorID,
editedBy: doctorID,
patientID: patientID,
patientTypeID: patientTypeID,
referringClinic: clinicId,
referringDoctor: doctorID,
referringDoctorRemarks: referringDoctorRemarks,
priority: priority,
frequency: frequency,
extension: extension,
tokenID: token);
final response = await AppClient.post(PATIENT_REFER_TO_DOCTOR_URL,
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');
String token = await sharedPref.getString(TOKEN);
Map profile = await sharedPref.getObj(DOCTOR_PROFILE);
DoctorProfileModel doctorProfile =
new DoctorProfileModel.fromJson(profile);
int doctorID = doctorProfile.doctorID;
int clinicId = doctorProfile.clinicID;
_referToDoctorRequest = ReferToDoctorRequest(
projectID: projectID,
admissionNo: admissionNo,
roomID: roomID,
referralClinic: selectedClinicID.toString(),
referralDoctor: selectedDoctorID.toString(),
createdBy: doctorID,
editedBy: doctorID,
patientID: patientID,
patientTypeID: patientTypeID,
referringClinic: clinicId,
referringDoctor: doctorID,
referringDoctorRemarks: referringDoctorRemarks,
priority: priority,
frequency: frequency,
extension: extension,
tokenID: token);
await BaseAppClient.post(PATIENT_REFER_TO_DOCTOR_URL,
onSuccess: (dynamic response, int statusCode) {
// print('Done : \n $res');
Navigator.pop(context);
} else {
},
onFailure: (String error, int statusCode) {
isLoading = false;
isError = true;
error = res['ErrorMessage'] ?? res['ErrorEndUserMessage'];
}
}
} else {
isLoading = false;
isError = true;
error = 'Please Check The Internet Connection';
}
this.error = error;
},
body: _referToDoctorRequest.toJson());
notifyListeners();
} catch (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_texts_widget.dart';
import '../../../widgets/shared/dr_app_circular_progress_Indeicator.dart';
import '../../../util/extenstions.dart';
DrAppSharedPreferances sharedPref = new DrAppSharedPreferances();
@ -37,6 +38,7 @@ class _ReferPatientState extends State<ReferPatientScreen> {
final _remarksController = TextEditingController();
final _extController = TextEditingController();
var _isInit = true;
bool isValid;
var clinicId;
var doctorId;
@ -49,14 +51,17 @@ class _ReferPatientState extends State<ReferPatientScreen> {
List<String> _priorities = ['Very Urgent', 'Urgent', 'Routine'];
int _activePriority = 2;
FocusNode myFocusNode;
@override
void didChangeDependencies() {
super.didChangeDependencies();
if (_isInit) {
myFocusNode = FocusNode();
doctorsList = null;
patientsProv = Provider.of<PatientsProvider>(context);
patientsProv.getClinicsList();
patientsProv.getReferralFrequancyList();
patientsProv.getReferralFrequancyList();
}
_isInit = false;
}
@ -70,10 +75,9 @@ class _ReferPatientState extends State<ReferPatientScreen> {
: patientsProv.isError
? DrAppEmbeddedError(error: patientsProv.error)
: patientsProv.clinicsList == null
? DrAppEmbeddedError(
error: 'Something Wrong!')
? DrAppEmbeddedError(error: 'Something Wrong!')
: SingleChildScrollView(
child: Column(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
@ -128,13 +132,17 @@ class _ReferPatientState extends State<ReferPatientScreen> {
setState(() {
_selectedDoctor = null;
_selectedClinic = newValue;
var clinicInfo = patientsProv.clinicsList.where((i) =>
var clinicInfo = patientsProv
.clinicsList
.where((i) =>
i['ClinicDescription']
.toString()
.contains(_selectedClinic)).toList();
clinicId =
clinicInfo[0]['ClinicID'].toString();
.contains(
_selectedClinic))
.toList();
clinicId = clinicInfo[0]['ClinicID']
.toString();
patientsProv.getDoctorsList(clinicId);
})
@ -208,15 +216,16 @@ class _ReferPatientState extends State<ReferPatientScreen> {
onChanged: (newValue) => {
setState(() {
_selectedDoctor = newValue;
doctorsList = patientsProv.doctorsList;
var doctorInfo =
doctorsList.where((i) =>
i['DoctorName']
.toString()
.contains(_selectedDoctor)).toList();
doctorId = doctorInfo[0]['DoctorID'].toString();
doctorsList =
patientsProv.doctorsList;
var doctorInfo = doctorsList
.where((i) => i['DoctorName']
.toString()
.contains(_selectedDoctor))
.toList();
doctorId = doctorInfo[0]['DoctorID']
.toString();
})
},
items: patientsProv
@ -320,13 +329,16 @@ class _ReferPatientState extends State<ReferPatientScreen> {
onChanged: (newValue) => {
setState(() {
_selectedReferralFrequancy = newValue;
var freqInfo =
patientsProv.referalFrequancyList.singleWhere((i) =>
i['Description']
.toString()
.contains(_selectedReferralFrequancy));
freqId =
freqInfo['ParameterCode'].toString();
var freqInfo = patientsProv
.referalFrequancyList
.singleWhere((i) => i[
'Description']
.toString()
.contains(
_selectedReferralFrequancy));
freqId = freqInfo['ParameterCode']
.toString();
myFocusNode.requestFocus();
})
},
items: patientsProv
@ -357,6 +369,7 @@ class _ReferPatientState extends State<ReferPatientScreen> {
padding: const EdgeInsets.all(10.0),
child: AppTextFormField(
hintText: "Remarks",
focusNode: myFocusNode,
controller: _remarksController,
inputFormatter: ONLY_LETTERS,
textInputType: TextInputType.text,
@ -364,14 +377,27 @@ class _ReferPatientState extends State<ReferPatientScreen> {
),
),
Padding(
padding: const EdgeInsets.all(20.0),
child: AppButton(title: "Send", color: Color(PRIMARY_COLOR),onPressed: ()=>{
referToDoctor(context)
},),
)
padding: const EdgeInsets.all(20.0),
child: Column(
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;
}
void referToDoctor(context){
void referToDoctor(context) {
if (!validation()) {
return;
}
final routeArgs = ModalRoute.of(context).settings.arguments as Map;
PatiantInformtion patient = routeArgs['patient'];
patientsProv.referToDoctor(context,
extension: _extController.value.text,
admissionNo:int.parse( patient.admissionNo),
referringDoctorRemarks: _remarksController.value.text,
frequency: freqId,
patientID: patient.patientId,
patientTypeID: patient.patientType,
priority: (_activePriority + 1).toString(),
roomID: patient.roomId,
selectedClinicID: clinicId.toString(),
selectedDoctorID: doctorId.toString(),
projectID: patient.projectId
);
extension: _extController.value.text,
admissionNo: int.parse(patient.admissionNo),
referringDoctorRemarks: _remarksController.value.text,
frequency: freqId,
patientID: patient.patientId,
patientTypeID: patient.patientType,
priority: (_activePriority + 1).toString(),
roomID: patient.roomId,
selectedClinicID: clinicId.toString(),
selectedDoctorID: doctorId.toString(),
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,
bool autovalidate = true,
TextInputType textInputType,
String hintText
String hintText,
FocusNode focusNode
}) : super(
onSaved: onSaved,
validator: validator,
@ -27,6 +28,7 @@ class AppTextFormField extends FormField<String> {
return Column(
children: <Widget>[
TextFormField(
focusNode: focusNode,
keyboardType: textInputType,
inputFormatters: [WhitelistingTextInputFormatter(RegExp(inputFormatter)),],
onChanged: onChanged?? (value){

Loading…
Cancel
Save