fix issues in base app client

merge-requests/34/merge
Mohammad Aljammal 4 years ago
parent d4c9352fd9
commit 2b0e35a907

@ -13,11 +13,11 @@ class BaseService {
AppSharedPreferences sharedPref = AppSharedPreferences();
BaseService() {
getUser();
_getUser();
}
getUser() async {
user = AuthenticatedUser.fromJson(await sharedPref.getObject(USER_PROFILE));
_getUser() async {
var userData = await sharedPref.getObject(USER_PROFILE);
if (userData != null) user = AuthenticatedUser.fromJson(userData);
}
}

@ -24,21 +24,22 @@ class BaseAppClient {
try {
//Map profile = await sharedPref.getObj(DOCTOR_PROFILE);
String token = await sharedPref.getString(TOKEN);
var languageID =
await sharedPref.getStringWithDefaultValue(APP_LANGUAGE, 'ar');
var user = await sharedPref.getObject(USER_PROFILE);
// body['SetupID'] = SETUP_ID;
// body['VersionID'] = VERSION_ID;
// body['Channel'] = CHANNEL;
// body['LanguageID'] = LANGUAGE;
// body['IPAdress'] = IP_ADDRESS;
// body['generalid'] = GENERAL_ID;
// // body['PatientOutSA'] = PATIENT_OUT_SA;
// body['SessionID'] = null; //SESSION_ID;
// body['isDentalAllowedBackend'] = IS_DENTAL_ALLOWED_BACKEND;
// body['DeviceTypeID'] = DeviceTypeID;
// body['PatientType'] = PATIENT_TYPE;
// body['PatientTypeID'] = PATIENT_TYPE_ID;
body['SetupID'] = body.containsKey('SetupID') ? body['SetupID']!=null? body['SetupID'] :SETUP_ID :SETUP_ID;
body['VersionID'] = body.containsKey('VersionID') ? body['VersionID']!=null? body['VersionID'] :VERSION_ID :VERSION_ID;
body['Channel'] = CHANNEL;
body['LanguageID'] = languageID == 'ar' ? 1 : 2;
body['IPAdress'] = IP_ADDRESS;
body['generalid'] = GENERAL_ID;
body['PatientOutSA'] = body.containsKey('PatientOutSA') ? body['PatientOutSA']!=null? body['PatientOutSA'] :PATIENT_OUT_SA :PATIENT_OUT_SA;
body['isDentalAllowedBackend'] = IS_DENTAL_ALLOWED_BACKEND;
body['DeviceTypeID'] = DeviceTypeID;
body['PatientType'] = body.containsKey('PatientType') ? body['PatientType']!=null? body['PatientType'] :PATIENT_TYPE :PATIENT_TYPE;
body['PatientTypeID'] = body.containsKey('PatientTypeID') ? body['PatientTypeID']!=null? body['PatientTypeID'] :PATIENT_TYPE_ID :PATIENT_TYPE_ID;
if (user != null) {
body['TokenID'] = token; //user['TokenID'];
body['TokenID'] = token;
body['PatientID'] = user['PatientID'];
body['PatientOutSA'] = user['OutSA'];
body['SessionID'] = getSessionId(token);

@ -0,0 +1,21 @@
import 'package:diplomaticquarterapp/config/config.dart';
import 'package:diplomaticquarterapp/core/service/base_service.dart';
import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart';
class MedicalService extends BaseService {
List<AppoitmentAllHistoryResultList> appoitmentAllHistoryResultList = List();
getAppointmentHistory() async {
await baseAppClient.post(GET_PATIENT_APPOINTMENT_HISTORY,
onSuccess: (response, statusCode) async {
appoitmentAllHistoryResultList.clear();
response['AppoimentAllHistoryResultList'].forEach((appoitment) {
appoitmentAllHistoryResultList
.add(AppoitmentAllHistoryResultList.fromJson(appoitment));
});
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: Map());
}
}

@ -4,23 +4,20 @@ import 'package:diplomaticquarterapp/core/model/vital_sign/vital_sign_res_model.
import '../base_service.dart';
class VitalSignService extends BaseService {
List<VitalSignResModel> vitalSignResModelList = List();
Map<String, dynamic> body = Map();
Future getPatientRadOrders () async {
Future getPatientRadOrders() async {
hasError = false;
await baseAppClient.post(GET_PATIENT_VITAL_SIGN,
onSuccess: (dynamic response, int statusCode) {
vitalSignResModelList.clear();
response['List_DoctorPatientVitalSign'].forEach((vital) {
vitalSignResModelList.add(VitalSignResModel.fromJson(vital));
});
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: Map());
vitalSignResModelList.clear();
response['List_DoctorPatientVitalSign'].forEach((vital) {
vitalSignResModelList.add(VitalSignResModel.fromJson(vital));
});
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: Map());
}
}

@ -1,4 +1,7 @@
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart';
import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
import 'package:flutter/material.dart';
class BaseViewModel extends ChangeNotifier {
@ -9,8 +12,21 @@ class BaseViewModel extends ChangeNotifier {
String error = "";
AuthenticatedUser user;
AppSharedPreferences sharedPref = AppSharedPreferences();
void setState(ViewState viewState) {
_state = viewState;
notifyListeners();
}
BaseViewModel() {
_getUser();
}
_getUser() async {
var userData = await sharedPref.getObject(USER_PROFILE);
if (userData != null) user = AuthenticatedUser.fromJson(userData);
notifyListeners();
}
}

@ -0,0 +1,22 @@
import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
import 'package:diplomaticquarterapp/core/service/medical/medical_service.dart';
import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart';
import 'package:diplomaticquarterapp/locator.dart';
import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart';
class MedicalViewModel extends BaseViewModel {
List<AppoitmentAllHistoryResultList> get appoitmentAllHistoryResultList =>
List();
MedicalService _medicalService = locator<MedicalService>();
getAppointmentHistory() {
setState(ViewState.Busy);
_medicalService.getAppointmentHistory();
if (_medicalService.hasError) {
error = _medicalService.error;
setState(ViewState.Error);
} else
setState(ViewState.Idle);
}
}

@ -4,6 +4,7 @@ import 'package:get_it/get_it.dart';
import 'core/service/feedback/feedback_service.dart';
import 'core/service/hospital_service.dart';
import 'core/service/medical/labs_service.dart';
import 'core/service/medical/medical_service.dart';
import 'core/service/medical/my_doctor_service.dart';
import 'core/service/medical/prescriptions_service.dart';
import 'core/service/medical/radiology_service.dart';
@ -11,6 +12,7 @@ import 'core/service/medical/vital_sign_service.dart';
import 'core/viewModels/feedback/feedback_view_model.dart';
import 'core/viewModels/hospital_view_model.dart';
import 'core/viewModels/medical/labs_view_model.dart';
import 'core/viewModels/medical/medical_view_model.dart';
import 'core/viewModels/medical/my_doctor_view_model.dart';
import 'core/viewModels/medical/prescriptions_view_model.dart';
import 'core/viewModels/medical/radiology_view_model.dart';
@ -34,7 +36,7 @@ void setupLocator() {
locator.registerLazySingleton(() => FeedbackService());
locator.registerLazySingleton(() => InsuranceCardService());
locator.registerLazySingleton(() => VitalSignService());
locator.registerLazySingleton(() => MedicalService());
/// View Model
locator.registerFactory(() => HospitalViewModel());
@ -46,4 +48,5 @@ void setupLocator() {
locator.registerFactory(() => FeedbackViewModel());
locator.registerFactory(() => VitalSignViewModel());
locator.registerFactory(() => InsuranceViewModel());
locator.registerFactory(() => MedicalViewModel());
}

@ -299,7 +299,6 @@ class _InsuranceUpdateState extends State<InsuranceUpdate>
);
}),
),
////////////////
],
))
],

@ -1,16 +1,21 @@
import 'dart:math';
import 'package:diplomaticquarterapp/core/service/medical/vital_sign_service.dart';
import 'package:diplomaticquarterapp/core/viewModels/medical/medical_view_model.dart';
import 'package:diplomaticquarterapp/pages/MyAppointments/MyAppointments.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/pages/medical/prescriptions/prescriptions_home_page.dart';
import 'package:diplomaticquarterapp/pages/medical/radiology/radiology_home_page.dart';
import 'package:diplomaticquarterapp/pages/medical/vital_sign/vital_sign_details_screen.dart';
import 'package:diplomaticquarterapp/widgets/data_display/medical/medical_profile_item.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:diplomaticquarterapp/widgets/others/sliver_app_bar_delegate.dart';
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:diplomaticquarterapp/pages/insurance/insurance_card_screen.dart';
import '../../locator.dart';
import 'doctor/doctor_home_page.dart';
import 'package:diplomaticquarterapp/pages/insurance/insurance_update_screen.dart';
import 'package:diplomaticquarterapp/pages/insurance/insurance_approval_screen.dart';
@ -22,202 +27,414 @@ class MedicalProfilePage extends StatefulWidget {
}
class _MedicalProfilePageState extends State<MedicalProfilePage> {
@override
Widget build(BuildContext context) {
return AppScaffold(
body: CustomScrollView(
physics: BouncingScrollPhysics(),
key: PageStorageKey("medical"),
slivers: <Widget>[
SliverPersistentHeader(
delegate: SliverAppBarDelegate(
maxHeight: 200.0,
minHeight: 200.0,
child: Container(
width: double.infinity,
height: 200,
color: Colors.grey,
),
),
),
SliverPersistentHeader(
delegate: SliverAppBarDelegate(
maxHeight: double.maxFinite,
minHeight: double.maxFinite,
child: Padding(
padding: EdgeInsets.symmetric(vertical: 12.0),
child: Column(
children: <Widget>[
Row(
children: <Widget>[
Expanded(
flex: 1,
child: InkWell(
onTap: () {
Navigator.push(
context, FadePage(page: DoctorHomePage()));
},
child: MedicalProfileItem(
title: 'My Doctor',
imagePath: 'doctor_icon.png',
subTitle: 'List',
),
),
),
Expanded(
flex: 1,
child: InkWell(
onTap: () {},
child: MedicalProfileItem(
title: 'Lab',
imagePath: 'lab_result_icon.png',
subTitle: 'Result',
return BaseView<MedicalViewModel>(
onModelReady: (model) => model.getAppointmentHistory(),
builder: (_, model, widget) => AppScaffold(
baseViewModel: model,
body: SafeArea(
child: SingleChildScrollView(
child: Column(
children: <Widget>[
Stack(
children: <Widget>[
Column(
children: <Widget>[
Container(
width: double.infinity,
color: Colors.grey,
height: 150,
),
Padding(
padding: EdgeInsets.symmetric(vertical: 12.0),
child: Column(
children: <Widget>[
Container(
width: double.infinity,
height: 30,
),
),
)
],
),
Row(
children: <Widget>[
Expanded(
flex: 1,
child: InkWell(
onTap: () => Navigator.push(
context, FadePage(page: RadiologyHomePage())),
child: MedicalProfileItem(
title: 'Radiology',
imagePath: 'radiology_icon.png',
subTitle: 'Service',
Row(
children: <Widget>[
Expanded(
flex: 1,
child: InkWell(
onTap: () {
Navigator.push(context,
FadePage(page: MyAppointments()));
},
child: MedicalProfileItem(
title: 'My Appointments',
imagePath: 'my_appointment_icon.png',
subTitle: 'List',
),
),
),
Expanded(
flex: 1,
child: InkWell(
onTap: () => Navigator.push(context,
FadePage(page: RadiologyHomePage())),
child: MedicalProfileItem(
title: 'Radiology',
imagePath: 'radiology_icon.png',
subTitle: 'Service',
),
),
),
Expanded(
flex: 1,
child: InkWell(
onTap: () {},
child: MedicalProfileItem(
title: 'Lab',
imagePath: 'lab_result_icon.png',
subTitle: 'Result',
),
),
),
],
),
),
),
Expanded(
flex: 1,
child: InkWell(
onTap: () {
Navigator.push(context,
FadePage(page: HomePrescriptionsPage()));
},
child: MedicalProfileItem(
title: 'Medicines',
imagePath: 'prescription_icon.png',
subTitle: 'Prescriptions',
Row(
children: <Widget>[
Expanded(
flex: 1,
child: InkWell(
onTap: () {
Navigator.push(
context,
FadePage(
page: HomePrescriptionsPage()));
},
child: MedicalProfileItem(
title: 'Medicines',
imagePath: 'prescription_icon.png',
subTitle: 'Prescriptions',
),
),
),
Expanded(
flex: 1,
child: InkWell(
onTap: () => Navigator.push(
context,
FadePage(
page: VitalSignDetailsScreen())),
child: MedicalProfileItem(
title: 'Vital Signs',
imagePath: 'medical_history_icon.png',
subTitle: 'Reports',
),
),
),
Expanded(
flex: 1,
child: InkWell(
// onTap: () => Navigator.push(
// context, FadePage(page: RadiologyHomePage())),
child: MedicalProfileItem(
title: 'My Medicines ',
imagePath: 'radiology_icon.png',
subTitle: 'Service',
),
),
),
],
),
),
)
],
),
Row(
children: <Widget>[
Expanded(
flex: 1,
child: InkWell(
onTap: () {
Navigator.push(
context, FadePage(page: InsuranceCard()));
},
child: MedicalProfileItem(
title: 'Insurance',
imagePath: 'insurance_card_icon.png',
subTitle: 'Card',
Row(
children: <Widget>[
Expanded(
flex: 1,
child: InkWell(
onTap: () {
Navigator.push(context,
FadePage(page: DoctorHomePage()));
},
child: MedicalProfileItem(
title: 'My Doctor',
imagePath: 'doctor_icon.png',
subTitle: 'List',
),
),
),
Expanded(
flex: 1,
child: InkWell(
//TODO
// onTap: () {
// Navigator.push(context,
// FadePage(page: InsuranceApproval()));
// },
child: MedicalProfileItem(
title: 'Eye',
imagePath:
'insurance_approvals_icon.png',
subTitle: 'Measurement',
),
),
),
Expanded(
flex: 1,
child: InkWell(
onTap: () {
Navigator.push(context,
FadePage(page: InsuranceCard()));
},
child: MedicalProfileItem(
title: 'Insurance',
imagePath: 'insurance_card_icon.png',
subTitle: 'Card',
),
),
),
],
),
),
Row(children: <Widget>[
Expanded(
flex: 1,
child: InkWell(
//TODO
// onTap: () {
// Navigator.push(
// context, FadePage(page: DoctorHomePage()));
// },
child: MedicalProfileItem(
title: 'Update Insurance',
imagePath: 'insurance_card_icon.png',
subTitle: 'card',
),
),
),
Expanded(
flex: 1,
child: InkWell(
// onTap: () {
// Navigator.push(
// context, FadePage(page: InsuranceApproval()));
// },
child: MedicalProfileItem(
title: 'Insurance Approval',
imagePath: 'insurance_approvals_icon.png',
subTitle: '',
),
),
),
Expanded(
flex: 1,
child: MedicalProfileItem(
title: 'Allergies',
imagePath: 'medical_history_icon.png',
subTitle: 'Diagnosed',
),
),
]),
Row(children: <Widget>[
Expanded(
flex: 1,
child: InkWell(
//TODO
// onTap: () {
// Navigator.push(
// context, FadePage(page: DoctorHomePage()));
// },
child: MedicalProfileItem(
title: 'My Vaccines',
imagePath: 'insurance_card_icon.png',
subTitle: 'card',
),
),
),
Expanded(
flex: 1,
child: InkWell(
// onTap: () {
// Navigator.push(
// context, FadePage(page: InsuranceApproval()));
// },
child: MedicalProfileItem(
title: 'Medical',
imagePath: 'insurance_approvals_icon.png',
subTitle: 'Reports',
),
),
),
Expanded(
flex: 1,
child: MedicalProfileItem(
title: 'Monthly',
imagePath: 'medical_history_icon.png',
subTitle: 'Report',
),
),
]),
Row(children: <Widget>[
Expanded(
flex: 1,
child: InkWell(
//TODO
// onTap: () {
// Navigator.push(
// context, FadePage(page: DoctorHomePage()));
// },
child: MedicalProfileItem(
title: 'Sick',
imagePath: 'insurance_card_icon.png',
subTitle: 'Leaves',
),
),
),
Expanded(
flex: 1,
child: InkWell(
// onTap: () {
// Navigator.push(
// context, FadePage(page: InsuranceApproval()));
// },
child: MedicalProfileItem(
title: 'My Balance',
imagePath: 'insurance_approvals_icon.png',
subTitle: 'Credit',
),
),
),
Expanded(
flex: 1,
child: MedicalProfileItem(
title: 'Patient Call',
imagePath: 'medical_history_icon.png',
subTitle: 'Service',
),
),
]),
Row(children: <Widget>[
Expanded(
flex: 1,
child: InkWell(
//TODO
// onTap: () {
// Navigator.push(
// context, FadePage(page: DoctorHomePage()));
// },
child: MedicalProfileItem(
title: 'Smart Watches',
imagePath: 'insurance_card_icon.png',
subTitle: 'Pairing',
),
),
),
Expanded(
flex: 1,
child: InkWell(
// onTap: () {
// Navigator.push(
// context, FadePage(page: InsuranceApproval()));
// },
child: MedicalProfileItem(
title: 'My Trackers',
imagePath: 'insurance_approvals_icon.png',
subTitle: 'Service',
),
),
),
Expanded(
flex: 1,
child: MedicalProfileItem(
title: 'Ask Your',
imagePath: 'medical_history_icon.png',
subTitle: 'Doctor',
),
),
]),
Row(children: <Widget>[
Expanded(
flex: 1,
child: InkWell(
//TODO
// onTap: () {
// Navigator.push(
// context, FadePage(page: DoctorHomePage()));
// },
child: MedicalProfileItem(
title: 'Internet',
imagePath: 'insurance_card_icon.png',
subTitle: 'Pairing',
),
),
),
Expanded(
flex: 1,
child: InkWell(
// onTap: () {
// Navigator.push(
// context, FadePage(page: InsuranceApproval()));
// },
child: MedicalProfileItem(
title: 'My Trackers',
imagePath: 'insurance_approvals_icon.png',
subTitle: 'Service',
),
),
),
Expanded(
flex: 1,
child: MedicalProfileItem(
title: 'Ask Your',
imagePath: 'medical_history_icon.png',
subTitle: 'Doctor',
),
),
]),
],
),
Expanded(
flex: 1,
child: InkWell(
onTap: () {
Navigator.push(context,
FadePage(page: InsuranceApproval()));
},
child: MedicalProfileItem(
title: 'Insurance Approval',
imagePath: 'insurance_approvals_icon.png',
subTitle: 'Card',
),
),
)
],
),
Row(children: <Widget>[
Expanded(
flex: 1,
child: MedicalProfileItem(
title: 'Medical',
imagePath: 'medical_history_icon.png',
subTitle: 'Reports',
)
],
),
if (model.user != null)
Positioned(
top: 110,
left: 20,
right: 20,
child: Container(
width: double.infinity,
height: 70,
decoration: BoxDecoration(
color: Colors.grey[600],
shape: BoxShape.rectangle,
border: Border.all(
color: Colors.transparent, width: 0.5),
borderRadius: BorderRadius.all(Radius.circular(5)),
),
),
Expanded(
flex: 1,
child: InkWell(
onTap: () => Navigator.push(context,
FadePage(page: VitalSignDetailsScreen())),
child: MedicalProfileItem(
title: 'Vital Signs',
imagePath: 'medical_history_icon.png',
subTitle: 'Reports',
),
),
),
]),
Row(
children: <Widget>[
Expanded(
flex: 1,
child: InkWell(
onTap: () {
Navigator.push(
context, FadePage(page: InsuranceUpdate()));
},
child: MedicalProfileItem(
title: 'Insurance Update',
imagePath: 'insurance_card_icon.png',
subTitle: 'Card',
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
SizedBox(
height: 8,
),
),
),
Expanded(
flex: 1,
child: InkWell(
onTap: () {},
child: MedicalProfileItem(
title: 'new',
imagePath: 'insurance_card_icon.png',
subTitle: 'Card',
Texts(
model.user.firstName +
" " +
model.user.lastName,
color: Colors.white,
),
),
)
],
),
Row(
children: <Widget>[
Expanded(
flex: 1,
child: InkWell(
onTap: () {
Navigator.push(
context, FadePage(page: MyAppointments()));
},
child: MedicalProfileItem(
title: 'My Appointments',
imagePath: 'my_appointment_icon.png',
subTitle: 'List',
SizedBox(
height: 8,
),
),
),
Expanded(
flex: 1,
child: Container(),
Texts(
'${model.user.patientID}',
color: Colors.white,
),
],
),
],
),
],
),
),
)
],
),
),
],
),
]),
),
),
),
);
}
}

@ -47,6 +47,13 @@ class AppSharedPreferences {
return prefs.getString(key);
}
/// Get String [key] the key was saved
getStringWithDefaultValue(String key, String defaultVal) async {
final SharedPreferences prefs = await _prefs;
String value = prefs.getString(key);
return value == null ? defaultVal : value;
}
/// Get List of String [key] the key was saved
getStringList(String key) async {
final SharedPreferences prefs = await _prefs;

@ -26,7 +26,7 @@ class MedicalProfileItem extends StatelessWidget {
Text(
title,
style: TextStyle(
fontSize: 1.7 * SizeConfig.textMultiplier,
fontSize: 1.5 * SizeConfig.textMultiplier,
color: Hexcolor('#B8382C'),
fontWeight: FontWeight.bold),
),

Loading…
Cancel
Save