merge-requests/28/head
her_username 6 years ago
commit ae8a5740f3

@ -0,0 +1,18 @@
import 'package:doctor_app_flutter/config/config.dart';
import 'package:doctor_app_flutter/interceptor/http_interceptor.dart';
import 'package:http/http.dart';
// OWNER : Ibrahim albitar
// DATE : 22-04-2020
// DESCRIPTION : Custom App client to pin base url for all srvices
class AppClient {
static Client client = HttpInterceptor().getClient();
static Future<Response> post(dynamic path, {dynamic body}) async {
String _fullUrl = BASE_URL + path;
final response = await client.post(_fullUrl, body: body);
return response;
}
}

@ -1,2 +1,5 @@
const MAX_SMALL_SCREEN = 660; const MAX_SMALL_SCREEN = 660;
const BASE_URL = 'https://hmgwebservices.com/Services/'; const BASE_URL = 'https://hmgwebservices.com/Services/';
const ONLY_NUMBERS = "[0-9]";
const ONLY_LETTERS = "[a-zA-Z]";
const ONLY_DATE = "[0-9/]";

@ -1,3 +1,9 @@
import 'dart:convert';
import 'package:doctor_app_flutter/config/shared_pref_kay.dart';
import 'package:doctor_app_flutter/providers/auth_provider.dart';
import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart';
import 'package:http/http.dart';
import 'package:http_interceptor/http_interceptor.dart'; import 'package:http_interceptor/http_interceptor.dart';
import '../providers/auth_provider.dart'; import '../providers/auth_provider.dart';
@ -12,8 +18,13 @@ List<String> publicUrls = [
]; ];
class HttpInterceptor extends InterceptorContract { class HttpInterceptor extends InterceptorContract {
Client getClient(){
return HttpClientWithInterceptor.build(interceptors: [this]);
}
Future<RequestData> interceptRequest({RequestData data}) async { Future<RequestData> interceptRequest({RequestData data}) async {
// print('RequestData ${data.body}'); print('RequestData ${data.body}');
try { try {
data.headers["Content-Type"] = "application/json"; data.headers["Content-Type"] = "application/json";
data.headers["Accept"] = "application/json"; data.headers["Accept"] = "application/json";

@ -1,34 +1,25 @@
import 'dart:convert'; import 'dart:convert';
import 'package:doctor_app_flutter/client/app_client.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:http/http.dart';
import 'package:http_interceptor/http_client_with_interceptor.dart';
import '../config/config.dart';
import '../interceptor/http_interceptor.dart';
import '../models/user_model.dart'; import '../models/user_model.dart';
const LOGIN_URL = BASE_URL + 'Sentry.svc/REST/MemberLogIN_New'; const LOGIN_URL =
'Sentry.svc/REST/MemberLogIN_New';
const INSERT_DEVICE_IMEI = const INSERT_DEVICE_IMEI =
BASE_URL + 'Sentry.svc/REST/DoctorApplication_INSERTDeviceIMEI'; 'Sentry.svc/REST/DoctorApplication_INSERTDeviceIMEI';
const SELECT_DEVICE_IMEI = const SELECT_DEVICE_IMEI =
BASE_URL + 'Sentry.svc/REST/DoctorApplication_SELECTDeviceIMEIbyIMEI'; 'Sentry.svc/REST/DoctorApplication_SELECTDeviceIMEIbyIMEI';
const SEND_ACTIVATION_CODE_BY_OTP_NOTIFICATION_TYPE = BASE_URL + const SEND_ACTIVATION_CODE_BY_OTP_NOTIFICATION_TYPE =
'Sentry.svc/REST/DoctorApplication_SendActivationCodebyOTPNotificationType'; 'Sentry.svc/REST/DoctorApplication_SendActivationCodebyOTPNotificationType';
const MEMBER_CHECK_ACTIVATION_CODE_NEW = const MEMBER_CHECK_ACTIVATION_CODE_NEW ='Sentry.svc/REST/MemberCheckActivationCode_New';
BASE_URL + 'Sentry.svc/REST/MemberCheckActivationCode_New';
class AuthProvider with ChangeNotifier { class AuthProvider with ChangeNotifier {
Client client =
HttpClientWithInterceptor.build(interceptors: [HttpInterceptor()]);
Future<Map> login(UserModel userInfo) async { Future<Map> login(UserModel userInfo) async {
const url = LOGIN_URL; const url = LOGIN_URL;
try { try {
final response = await client.post(url, final response = await AppClient.post(url,
// headers: requestHeaders,
body: json.encode({ body: json.encode({
"UserID": userInfo.UserID, "UserID": userInfo.UserID,
"Password": userInfo.Password, "Password": userInfo.Password,
@ -50,7 +41,7 @@ class AuthProvider with ChangeNotifier {
const url = INSERT_DEVICE_IMEI; const url = INSERT_DEVICE_IMEI;
try { try {
final response = await client.post(url, body: json.encode(imei)); final response = await AppClient.post(url, body: json.encode(imei));
return Future.value(json.decode(response.body)); return Future.value(json.decode(response.body));
} catch (error) { } catch (error) {
print(error); print(error);
@ -62,7 +53,7 @@ class AuthProvider with ChangeNotifier {
const url = SELECT_DEVICE_IMEI; const url = SELECT_DEVICE_IMEI;
try { try {
final response = await client.post(url, body: json.encode(imei)); final response = await AppClient.post(url, body: json.encode(imei));
return Future.value(json.decode(response.body)); return Future.value(json.decode(response.body));
} catch (error) { } catch (error) {
print(error); print(error);
@ -75,8 +66,7 @@ class AuthProvider with ChangeNotifier {
const url = SEND_ACTIVATION_CODE_BY_OTP_NOTIFICATION_TYPE; const url = SEND_ACTIVATION_CODE_BY_OTP_NOTIFICATION_TYPE;
try { try {
final response = final response = await AppClient.post(url, body: json.encode(activationCodeModel));
await client.post(url, body: json.encode(activationCodeModel));
return Future.value(json.decode(response.body)); return Future.value(json.decode(response.body));
} catch (error) { } catch (error) {
print(error); print(error);
@ -88,8 +78,7 @@ class AuthProvider with ChangeNotifier {
const url = MEMBER_CHECK_ACTIVATION_CODE_NEW; const url = MEMBER_CHECK_ACTIVATION_CODE_NEW;
try { try {
final response = final response = await AppClient.post(url, body: json.encode(activationCodeModel));
await client.post(url, body: json.encode(activationCodeModel));
return Future.value(json.decode(response.body)); return Future.value(json.decode(response.body));
} catch (error) { } catch (error) {
print(error); print(error);

@ -18,7 +18,7 @@ class PatientsProvider with ChangeNotifier {
try { try {
final response = await client.post(url, final response = await client.post(url,
body: json.encode({ body: json.encode({
"ProjectID": patient.PatientID, "ProjectID": patient.ProjectID,
"ClinicID": patient.ClinicID, "ClinicID": patient.ClinicID,
"DoctorID": patient.DoctorID, "DoctorID": patient.DoctorID,
"FirstName": patient.FirstName, "FirstName": patient.FirstName,

@ -1,5 +1,9 @@
import 'package:doctor_app_flutter/config/shared_pref_kay.dart';
import 'package:doctor_app_flutter/routes.dart';
import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart';
import 'package:flutter/services.dart';
import '../../config/size_config.dart'; import '../../config/size_config.dart';
import '../../util/text_validator.dart';
import '../../widgets/shared/app_buttons_widget.dart'; import '../../widgets/shared/app_buttons_widget.dart';
import '../../widgets/shared/app_scaffold_widget.dart'; import '../../widgets/shared/app_scaffold_widget.dart';
import '../../widgets/shared/app_text_form_field.dart'; import '../../widgets/shared/app_text_form_field.dart';
@ -11,6 +15,9 @@ import 'package:flutter/rendering.dart';
import '../../lookups/patient_lookup.dart'; import '../../lookups/patient_lookup.dart';
import '../../models/patient_model.dart'; import '../../models/patient_model.dart';
import '../../widgets/patients/dynamic_elements.dart'; import '../../widgets/patients/dynamic_elements.dart';
import '../../config/config.dart';
DrAppSharedPreferances sharedPref = new DrAppSharedPreferances();
// OWNER : Ibrahim albitar // OWNER : Ibrahim albitar
// DATE : 19-04-2020 // DATE : 19-04-2020
@ -29,9 +36,9 @@ class _PatientSearchScreenState extends State<PatientSearchScreen> {
bool _autoValidate = false; bool _autoValidate = false;
var _patientSearchFormValues = PatientModel( var _patientSearchFormValues = PatientModel(
ProjectID: 12, ProjectID: 15,
ClinicID: 17, ClinicID: 0,
DoctorID: 98129, DoctorID: 4709,
FirstName: "0", FirstName: "0",
MiddleName: "0", MiddleName: "0",
LastName: "0", LastName: "0",
@ -50,18 +57,31 @@ class _PatientSearchScreenState extends State<PatientSearchScreen> {
IsLoginForDoctorApp: true, IsLoginForDoctorApp: true,
PatientOutSA: false); PatientOutSA: false);
void _validateInputs() { void _validateInputs() {
if (_formKey.currentState.validate()) { print("####IBRAHIM TEST#####"+_patientSearchFormValues.From);
// _patientSearchFormValues.TokenID =
if (_formKey.currentState.validate()) {
// If all data are correct then save data to out variables // If all data are correct then save data to out variables
_formKey.currentState.save(); _formKey.currentState.save();
} else {
sharedPref.getString(TOKEN).then((token) {
print(token+"EEEEEE");
_patientSearchFormValues.TokenID = token;
_patientSearchFormValues.ProjectID= 15;
print(_patientSearchFormValues.PatientMobileNumber+"dfdfdfddf");
Navigator.of(context).pushNamed(PATIENTS, arguments: {
"patientSearchForm": _patientSearchFormValues,
"selectedType": _selectedType
});
});
} else {
// If all data are not valid then start auto validation. // If all data are not valid then start auto validation.
setState(() { setState(() {
_autoValidate = true; _autoValidate = true;
}); });
}
} }
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -154,9 +174,10 @@ class _PatientSearchScreenState extends State<PatientSearchScreen> {
onSaved: (value) { onSaved: (value) {
_patientSearchFormValues.FirstName = value; _patientSearchFormValues.FirstName = value;
}, },
validator: (value) { // validator: (value) {
return TextValidator().validateName(value); // return TextValidator().validateName(value);
}, // },
inputFormatter: ONLY_LETTERS
), ),
SizedBox( SizedBox(
height: 10, height: 10,
@ -166,9 +187,10 @@ class _PatientSearchScreenState extends State<PatientSearchScreen> {
onSaved: (value) { onSaved: (value) {
_patientSearchFormValues.MiddleName = value; _patientSearchFormValues.MiddleName = value;
}, },
validator: (value) { // validator: (value) {
return TextValidator().validateName(value); // return TextValidator().validateName(value);
}, // },
inputFormatter: ONLY_LETTERS
), ),
SizedBox( SizedBox(
height: 10, height: 10,
@ -178,9 +200,10 @@ class _PatientSearchScreenState extends State<PatientSearchScreen> {
onSaved: (value) { onSaved: (value) {
_patientSearchFormValues.LastName = value; _patientSearchFormValues.LastName = value;
}, },
validator: (value) { // validator: (value) {
return TextValidator().validateName(value); // return TextValidator().validateName(value);
}, // },
inputFormatter: ONLY_LETTERS
), ),
SizedBox( SizedBox(
height: 10, height: 10,
@ -188,9 +211,10 @@ class _PatientSearchScreenState extends State<PatientSearchScreen> {
AppTextFormField( AppTextFormField(
textInputType: TextInputType.number, textInputType: TextInputType.number,
hintText: 'Phone Number', hintText: 'Phone Number',
validator: (value) { // validator: (value) {
return TextValidator().validateMobile(value); // return TextValidator().validateMobile(value);
}, // },
inputFormatter: ONLY_NUMBERS,
onSaved: (value) { onSaved: (value) {
_patientSearchFormValues.PatientMobileNumber = _patientSearchFormValues.PatientMobileNumber =
value; value;
@ -202,12 +226,10 @@ class _PatientSearchScreenState extends State<PatientSearchScreen> {
AppTextFormField( AppTextFormField(
textInputType: TextInputType.number, textInputType: TextInputType.number,
hintText: 'Patiant ID', hintText: 'Patiant ID',
validator: (value) { //
return TextValidator().validateIdNumber(value); inputFormatter: ONLY_NUMBERS,
},
onSaved: (value) { onSaved: (value) {
_patientSearchFormValues.PatientID = _patientSearchFormValues.PatientID = 89000;
89000;
}), }),
SizedBox( SizedBox(
height: 10, height: 10,
@ -215,9 +237,10 @@ class _PatientSearchScreenState extends State<PatientSearchScreen> {
AppTextFormField( AppTextFormField(
textInputType: TextInputType.number, textInputType: TextInputType.number,
hintText: 'Patiant File', hintText: 'Patiant File',
validator: (value) { // validator: (value) {
return TextValidator().validateIdNumber(value); // return TextValidator().validateIdNumber(value);
}, // },
inputFormatter: ONLY_NUMBERS,
onSaved: (value) { onSaved: (value) {
//_patientSearchFormValues. = value; //_patientSearchFormValues. = value;
}, },

@ -16,17 +16,21 @@ class _PatientsListScreenState extends State<PatientsListScreen> {
void didChangeDependencies() { void didChangeDependencies() {
final routeArgs = ModalRoute.of(context).settings.arguments as Map; final routeArgs = ModalRoute.of(context).settings.arguments as Map;
PatientModel patient = routeArgs['patientSearchForm']; PatientModel patient = routeArgs['patientSearchForm'];
print(patient.TokenID+"EEEEEE");
String patientType = routeArgs['selectedType']; String patientType = routeArgs['selectedType'];
print(patientType); print(patientType);
if (_isInit) { if (_isInit) {
// setState(() {}); // setState(() {});
PatientsProvider patientsProv = Provider.of<PatientsProvider>(context); PatientsProvider patientsProv = Provider.of<PatientsProvider>(context);
patientsProv.getPatientList(patient, patientType).then((res) { patientsProv.getPatientList(patient, patientType).then((res) {
// print('MessageStatus${res['MessageStatus']}');
print('List_MyInPatient${(res['List_MyInPatient'][0])}');
setState(() { setState(() {
_isLoading = false; _isLoading = false;
_hasError = res['ErrorEndUserMessage']; _hasError = res['ErrorEndUserMessage'];
}); });
print(res);
}).catchError((error) { }).catchError((error) {
print(error); print(error);
}); });

@ -1,7 +1,7 @@
import 'package:doctor_app_flutter/config/config.dart';
import 'package:doctor_app_flutter/models/patient_model.dart'; import 'package:doctor_app_flutter/models/patient_model.dart';
import 'package:doctor_app_flutter/widgets/shared/app_text_form_field.dart'; import 'package:doctor_app_flutter/widgets/shared/app_text_form_field.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../../util/text_validator.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
class DynamicElements extends StatefulWidget { class DynamicElements extends StatefulWidget {
@ -51,14 +51,15 @@ class _DynamicElementsState extends State<DynamicElements> {
textInputType: TextInputType.number, textInputType: TextInputType.number,
hintText: 'From', hintText: 'From',
controller: _fromDateController, controller: _fromDateController,
validator: (value) { // validator: (value) {
return TextValidator().validateDate(_fromDateController.text); // return TextValidator().validateDate(_fromDateController.text);
}, // },
inputFormatter: ONLY_DATE,
onTap: () { onTap: () {
_presentDatePicker('_selectedFromDate'); _presentDatePicker('_selectedFromDate');
}, },
onSaved: (value) { onSaved: (value) {
widget._patientSearchFormValues.From = value; widget._patientSearchFormValues.From = _fromDateController.text;
}, },
), ),
@ -72,11 +73,12 @@ class _DynamicElementsState extends State<DynamicElements> {
onTap: () { onTap: () {
_presentDatePicker('_selectedToDate'); _presentDatePicker('_selectedToDate');
}, },
validator: (value) { // validator: (value) {
return TextValidator().validateDate(_toDateController.text); // return TextValidator().validateDate(_toDateController.text);
}, // },
inputFormatter: ONLY_DATE,
onSaved: (value) { onSaved: (value) {
widget._patientSearchFormValues.To = value; widget._patientSearchFormValues.To = _toDateController.text;
}, },
), ),
], ],

@ -1,6 +1,7 @@
import 'package:doctor_app_flutter/config/size_config.dart'; import 'package:doctor_app_flutter/config/size_config.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
// OWNER : Ibrahim albitar // OWNER : Ibrahim albitar
// DATE : 19-04-2020 // DATE : 19-04-2020
@ -10,6 +11,7 @@ class AppTextFormField extends FormField<String> {
AppTextFormField({ AppTextFormField({
FormFieldSetter<String> onSaved, FormFieldSetter<String> onSaved,
String inputFormatter,
FormFieldValidator<String> validator, FormFieldValidator<String> validator,
ValueChanged<String> onChanged, ValueChanged<String> onChanged,
GestureTapCallback onTap, GestureTapCallback onTap,
@ -26,6 +28,7 @@ class AppTextFormField extends FormField<String> {
children: <Widget>[ children: <Widget>[
TextFormField( TextFormField(
keyboardType: textInputType, keyboardType: textInputType,
inputFormatters: [WhitelistingTextInputFormatter(RegExp(inputFormatter)),],
onChanged: onChanged?? (value){ onChanged: onChanged?? (value){
state.didChange(value); state.didChange(value);
}, },

Loading…
Cancel
Save