add clinic to arrival search patient

merge-requests/349/head
Elham Rababah 5 years ago
parent a329c447a2
commit 340bfd0a1c

@ -202,16 +202,19 @@ class AuthViewModel extends BaseViewModel {
*@return:Future<Map> *@return:Future<Map>
*@desc: getDocProfiles *@desc: getDocProfiles
*/ */
Future<dynamic> getDocProfiles(docInfo) async { Future<dynamic> getDocProfiles(docInfo, {bool allowChangeProfile = true}) async {
try { try {
dynamic localRes; dynamic localRes;
await baseAppClient.post(GET_DOC_PROFILES, await baseAppClient.post(GET_DOC_PROFILES,
onSuccess: (dynamic response, int statusCode) { onSuccess: (dynamic response, int statusCode) {
localRes = response; localRes = response;
doctorProfile = if(allowChangeProfile) {
DoctorProfileModel.fromJson(response['DoctorProfileList'][0]); doctorProfile =
selectedClinicName = DoctorProfileModel.fromJson(response['DoctorProfileList'][0]);
response['DoctorProfileList'][0]['ClinicDescription']; selectedClinicName =
response['DoctorProfileList'][0]['ClinicDescription'];
}
}, onFailure: (String error, int statusCode) { }, onFailure: (String error, int statusCode) {
throw error; throw error;
}, body: docInfo); }, body: docInfo);

@ -1,19 +1,22 @@
import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/config/config.dart';
import 'package:doctor_app_flutter/config/shared_pref_kay.dart';
import 'package:doctor_app_flutter/core/viewModel/auth_view_model.dart';
import 'package:doctor_app_flutter/core/viewModel/patient_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/patient_view_model.dart';
import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart';
import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart'; import 'package:doctor_app_flutter/models/doctor/doctor_profile_model.dart';
import 'package:doctor_app_flutter/models/doctor/profile_req_Model.dart';
import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart';
import 'package:doctor_app_flutter/models/patient/patient_arrival/get_patient_arrival_list_request_model.dart'; import 'package:doctor_app_flutter/models/patient/patient_arrival/get_patient_arrival_list_request_model.dart';
import 'package:doctor_app_flutter/models/patient/patient_model.dart'; import 'package:doctor_app_flutter/models/patient/patient_model.dart';
import 'package:doctor_app_flutter/models/patient/topten_users_res_model.dart'; import 'package:doctor_app_flutter/models/patient/topten_users_res_model.dart';
import 'package:doctor_app_flutter/routes.dart'; import 'package:doctor_app_flutter/routes.dart';
import 'package:doctor_app_flutter/screens/base/base_view.dart'; 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/translations_delegate_base.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/patients/PatientCard.dart'; import 'package:doctor_app_flutter/widgets/patients/PatientCard.dart';
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/dr_app_circular_progress_Indeicator.dart'; import 'package:doctor_app_flutter/widgets/shared/dr_app_circular_progress_Indeicator.dart';
import 'package:doctor_app_flutter/widgets/shared/errors/dr_app_embedded_error.dart'; import 'package:doctor_app_flutter/widgets/shared/errors/dr_app_embedded_error.dart';
import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:hexcolor/hexcolor.dart'; import 'package:hexcolor/hexcolor.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
@ -34,6 +37,9 @@ class _PatientsScreenState extends State<PatientsScreen> {
List date; List date;
List unFilterDate; List unFilterDate;
var clinicId;
AuthViewModel authProvider;
Color sideColor = Colors.black; Color sideColor = Colors.black;
List<PatiantInformtion> responseModelList; List<PatiantInformtion> responseModelList;
List<PatiantInformtion> responseModelList2; List<PatiantInformtion> responseModelList2;
@ -188,14 +194,26 @@ class _PatientsScreenState extends State<PatientsScreen> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
authProvider = Provider.of(context);
_locations = [ _locations = [
TranslationBase.of(context).all, TranslationBase
TranslationBase.of(context).today, .of(context)
TranslationBase.of(context).tomorrow, .all,
TranslationBase.of(context).nextWeek, TranslationBase
.of(context)
.today,
TranslationBase
.of(context)
.tomorrow,
TranslationBase
.of(context)
.nextWeek,
]; ];
projectsProvider = Provider.of(context); projectsProvider = Provider.of(context);
final routeArgs = ModalRoute.of(context).settings.arguments as Map; final routeArgs = ModalRoute
.of(context)
.settings
.arguments as Map;
patient = routeArgs['patientSearchForm']; patient = routeArgs['patientSearchForm'];
@ -218,14 +236,12 @@ class _PatientsScreenState extends State<PatientsScreen> {
model model
.getPatientList( .getPatientList(
val2 == 7 val2 == 7
? getPatientArrivalListRequestModel.toJson() ? getPatientArrivalListRequestModel.toJson()
: patient, : patient,
patientType) patientType)
.then((res) { .then((res) {
setState(() { setState(() {
if (res != null && res['MessageStatus'] == 1) { if (res != null && res['MessageStatus'] == 1) {
if (val2 == 7) { if (val2 == 7) {
if (res[SERVICES_PATIANT2[val2]] == null) { if (res[SERVICES_PATIANT2[val2]] == null) {
@ -253,7 +269,6 @@ class _PatientsScreenState extends State<PatientsScreen> {
responseModelList = new ModelResponse.fromJson(parsed).list; responseModelList = new ModelResponse.fromJson(parsed).list;
responseModelList2 = responseModelList; responseModelList2 = responseModelList;
_isError = false; _isError = false;
} else { } else {
_isError = true; _isError = true;
error = model.error??res['ErrorEndUserMessage'] ?? res['ErrorMessage']; error = model.error??res['ErrorEndUserMessage'] ?? res['ErrorMessage'];
@ -275,114 +290,272 @@ class _PatientsScreenState extends State<PatientsScreen> {
body: _isLoading body: _isLoading
? Container() ? Container()
: _isError : _isError
? DrAppEmbeddedError(error: error) ? DrAppEmbeddedError(error: error)
: lItems == null || lItems.length == 0 : lItems == null || lItems.length == 0
? DrAppEmbeddedError( ? DrAppEmbeddedError(
error: error:
TranslationBase.of(context).youDontHaveAnyPatient) TranslationBase.of(context).youDontHaveAnyPatient)
: Container( : Container(
child: ListView( child: ListView(
scrollDirection: Axis.vertical, scrollDirection: Axis.vertical,
children: <Widget>[ children: <Widget>[
Container( Container(
child: lItems == null child: lItems == null
? Column( ? Column(
crossAxisAlignment: crossAxisAlignment:
CrossAxisAlignment.start, CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
Container( Container(
child: Center( child: Center(
child: Padding( child: Padding(
padding: const EdgeInsets.fromLTRB( padding: const EdgeInsets.fromLTRB(
0, 0, 0, 0), //250 0, 0, 0, 0), //250
child: child:
DrAppCircularProgressIndeicator(), DrAppCircularProgressIndeicator(),
)), )),
), ),
], ],
) )
: Column( : Column(
children: <Widget>[ children: <Widget>[
Padding( Padding(
padding: EdgeInsets.only( padding: EdgeInsets.only(
top: MediaQuery.of(context) top: MediaQuery.of(context)
.size .size
.height * .height *
0.03), 0.03),
child: SERVICES_PATIANT2[ child: SERVICES_PATIANT2[
int.parse(patientType)] == int.parse(patientType)] ==
"List_MyOutPatient" "List_MyOutPatient"
? _locationBar(context) ? _locationBar(context)
: Container(), : Container(),
), ),
SizedBox(height: 18.5), SizedBox(height: 18.5),
Container( Container(
width: SizeConfig.screenWidth * 0.9, width: SizeConfig.screenWidth * 0.9,
height: height:
SizeConfig.screenHeight * 0.05, SizeConfig.screenHeight * 0.05,
child: TextField( child: TextField(
controller: _controller, controller: _controller,
onChanged: (String str) { onChanged: (String str) {
this.searchData(str); this.searchData(str);
}, },
decoration: buildInputDecoration( decoration: buildInputDecoration(
context, context,
TranslationBase.of(context) TranslationBase
.searchPatient), .of(context)
), .searchPatient),
), ),
SizedBox( ),
height: 10.0, SizedBox(
), height: 10.0,
Divider( ),
thickness: 0.8, if(int.parse(patientType)==7)
color: Color(0xffCCCCCC), projectsProvider
), .doctorClinicsList.length >
Container( 0
decoration: BoxDecoration( ? FractionallySizedBox(
color: Color(0Xffffffff), widthFactor: 0.9,
borderRadius: child: Column(
BorderRadius.circular(20)), children: [
margin: Container(
EdgeInsets.fromLTRB(0, 0, 0, 0), width: MediaQuery.of(context).size.width *0.8,
child: (responseModelList.length > 0) child: Center(
? Column( child: DropdownButtonHideUnderline(
// mainAxisAlignment: MainAxisAlignment.center, child: DropdownButton(
children: responseModelList dropdownColor:
.map((PatiantInformtion Colors.white,
item) { iconEnabledColor:
return PatientCard(patientInfo: item, Colors.black,
patientType: patientType, isExpanded: true,
onTap: () { value: clinicId == null
Navigator.of(context) ? projectsProvider
.pushNamed( .doctorClinicsList[
PATIENTS_PROFILE, 0]
arguments: { .clinicID
"patient": item, : clinicId,
"patientType":patientType, iconSize: 25,
"from" : patient.getFrom, elevation: 16,
"to" : patient.getTo, selectedItemBuilder:
}); (BuildContext
},); context) {
}).toList(), return projectsProvider
) .doctorClinicsList
: Center( .map((item) {
child: DrAppEmbeddedError( return Row(
error: TranslationBase.of( mainAxisSize:
context) MainAxisSize
.youDontHaveAnyPatient), .max,
), children: <Widget>[
AppText(
item.clinicName,
fontSize: SizeConfig
.textMultiplier *
2.1,
color: Colors
.black,
),
],
);
}).toList();
},
onChanged: (newValue) {
clinicId = newValue;
changeClinic(newValue, context, model);
},
items: projectsProvider
.doctorClinicsList
.map((item) {
return DropdownMenuItem(
child: Text(
item.clinicName,
textAlign:
TextAlign.end,
), ),
], value: item.clinicID,
), );
) }).toList(),
], )),
), ),
),
],
),
)
: AppText(
TranslationBase
.of(context)
.noClinic),
Divider(
thickness: 0.8,
color: Color(0xffCCCCCC),
),
Container(
decoration: BoxDecoration(
color: Color(0Xffffffff),
borderRadius:
BorderRadius.circular(20)),
margin:
EdgeInsets.fromLTRB(0, 0, 0, 0),
child: (responseModelList.length > 0)
? Column(
// mainAxisAlignment: MainAxisAlignment.center,
children: responseModelList
.map((PatiantInformtion
item) {
return PatientCard(patientInfo: item,
patientType: patientType,
onTap: () {
Navigator.of(context)
.pushNamed(
PATIENTS_PROFILE,
arguments: {
"patient": item,
"patientType":patientType,
"from" : patient.getFrom,
"to" : patient.getTo,
});
},);
}).toList(),
)
: Center(
child: DrAppEmbeddedError(
error: TranslationBase.of(
context)
.youDontHaveAnyPatient),
), ),
),
],
),
)
],
),
),
), ),
); );
} }
changeClinic(clinicId, BuildContext context, model) async {
GifLoaderDialogUtils.showMyDialog(context);
Map profile = await sharedPref.getObj(DOCTOR_PROFILE);
DoctorProfileModel doctorProfile = new DoctorProfileModel.fromJson(profile);
ProfileReqModel docInfo = new ProfileReqModel(
doctorID: doctorProfile.doctorID,
clinicID: clinicId,
license: true,
projectID: doctorProfile.projectID,
tokenID: '',
languageID: 2);
authProvider.getDocProfiles(docInfo.toJson(), allowChangeProfile: false)
.then((profileList) async {
print(profileList['DoctorProfileList'][0]);
int val2 = int.parse(patientType);
GetPatientArrivalListRequestModel
getPatientArrivalListRequestModel = GetPatientArrivalListRequestModel(
from: patient.From,
to: patient.To,
clinicID: profileList['DoctorProfileList'][0]['ClinicID'],
doctorID: profileList['DoctorProfileList'][0]['DoctorID'].toString(),
patientMRN: patient.getPatientID,
pageIndex: 0,
pageSize: 0);
model
.getPatientList(
getPatientArrivalListRequestModel.toJson(),
patientType)
.then((res) {
setState(() {
if (res != null && res['MessageStatus'] == 1) {
if (val2 == 7) {
if (res[SERVICES_PATIANT2[val2]] == null) {
_isError = true;
_isLoading = false;
this.error = error.toString();
} else {
var localList = [];
if (res["patientArrivalList"]["entityList"] == null) {
res["patientArrivalList"]["entityList"] = [];
}
res["patientArrivalList"]["entityList"].forEach((v) {
Map<String, dynamic> mergedPatient = {
...v,
...v["patientDetails"]
};
localList.add(mergedPatient);
});
lItems = localList;
}
}
parsed = lItems;
responseModelList = new ModelResponse.fromJson(parsed).list;
responseModelList2 = responseModelList;
_isError = false;
} else {
_isError = true;
error = model.error ?? res['ErrorEndUserMessage'] ??
res['ErrorMessage'];
}
_isLoading = false;
});
GifLoaderDialogUtils.hideDialog(context);
}).catchError((error) {
helpers.showErrorToast(error.toString());
GifLoaderDialogUtils.hideDialog(context);
});
}).catchError((err) {
GifLoaderDialogUtils.hideDialog(context);
helpers.showErrorToast(err);
});
}
InputDecoration buildInputDecoration(BuildContext context, hint) { InputDecoration buildInputDecoration(BuildContext context, hint) {
return InputDecoration( return InputDecoration(
prefixIcon: Icon(Icons.search, color: Colors.grey), prefixIcon: Icon(Icons.search, color: Colors.grey),

Loading…
Cancel
Save