mock the calling the second service

merge-requests/877/head
Elham Rababh 4 years ago
parent 324f515253
commit 514fb71c51

@ -17,12 +17,11 @@ class PatientRegistrationViewModel extends BaseViewModel {
GetPatientInfoResponseModel get getPatientInfoResponseModel =>_patientRegistrationService.getPatientInfoResponseModel; GetPatientInfoResponseModel get getPatientInfoResponseModel =>_patientRegistrationService.getPatientInfoResponseModel;
CheckPatientForRegistrationModel checkPatientForRegistrationModel ; CheckPatientForRegistrationModel checkPatientForRegistrationModel ;
Future checkPatientForRegistration( Future checkPatientForRegistration(
CheckPatientForRegistrationModel registrationModel) async { CheckPatientForRegistrationModel registrationModel) async {
checkPatientForRegistrationModel =registrationModel; checkPatientForRegistrationModel =CheckPatientForRegistrationModel.fromJson(registrationModel.toJson());
setState(ViewState.BusyLocal); setState(ViewState.BusyLocal);
await _patientRegistrationService await _patientRegistrationService
.checkPatientForRegistration(registrationModel); .checkPatientForRegistration(registrationModel);
@ -36,13 +35,104 @@ class PatientRegistrationViewModel extends BaseViewModel {
Future getPatientInfo( Future getPatientInfo(
GetPatientInfoRequestModel getPatientInfoRequestModel) async { GetPatientInfoRequestModel getPatientInfoRequestModel) async {
setState(ViewState.BusyLocal); setState(ViewState.BusyLocal);
await _patientRegistrationService. /// TODO Elham* return call service when it working
getPatientInfo(getPatientInfoRequestModel); _patientRegistrationService.getPatientInfoResponseModel = GetPatientInfoResponseModel.fromJson({
if (_patientRegistrationService.hasError) { "Date": null,
error = _patientRegistrationService.error; "LanguageID": 0,
setState(ViewState.ErrorLocal); "ServiceName": 0,
} else "Time": null,
setState(ViewState.Idle); "AndroidLink": null,
"AuthenticationTokenID": null,
"Data": null,
"Dataw": false,
"DietType": 0,
"ErrorCode": null,
"ErrorEndUserMessage": null,
"ErrorEndUserMessageN": null,
"ErrorMessage": null,
"ErrorType": 0,
"FoodCategory": 0,
"IOSLink": null,
"IsAuthenticated": false,
"MealOrderStatus": 0,
"MealType": 0,
"MessageStatus": 1,
"NumberOfResultRecords": 0,
"PatientBlodType": null,
"SuccessMsg": null,
"SuccessMsgN": null,
"VidaUpdatedResponse": null,
"AccessTokenObject": null,
"Age": 33,
"ClientIdentifierId": null,
"CreatedBy": 0,
"DateOfBirth": "07/31/1988",
"FirstNameAr": "سفيان",
"FirstNameEn": "SUFIAN",
"Gender": "M",
"GenderAr": null,
"GenderEn": null,
"HealthId": "30000018540264",
"IdNumber": "1062938285",
"IdType": "NationalId",
"IsHijri": false,
"IsInstertedOrUpdated": 0,
"IsNull": 0,
"IsPatientExistNHIC": 0,
"IsRecordLockedByCurrentUser": false,
"LastNameAr": "عثمان",
"LastNameEn": "OTHMAN",
"List_ActiveAccessToken": null,
"MaritalStatus": "غير معروف",
"MaritalStatusCode": "U",
"NationalDateOfBirth": "18/12/1408",
"Nationality": "السعودية",
"NationalityCode": "SAU",
"Occupation": "طالب",
"PCDTransactionDataResultList": null,
"PCD_GetVidaPatientForManualVerificationList": null,
"PCD_NHIC_HMG_PatientDetailsMatchCalulationList": null,
"PCD_ReturnValue": 0,
"PatientStatus": "-",
"PlaceofBirth": "فينا",
"PractitionerStatusCode": null,
"PractitionerStatusDescAr": null,
"PractitionerStatusDescEn": null,
"RowCount": 0,
"SecondNameAr": "عبدالهادي",
"SecondNameEn": "ABDULHADI",
"ThirdNameAr": "احمد",
"ThirdNameEn": "A",
"YakeenVidaPatientDataStatisticsByPatientIdList": null,
"YakeenVidaPatientDataStatisticsList": null,
"YakeenVidaPatientDataStatisticsPrefferedList": null,
"accessToken": null,
"categoryCode": 0,
"categoryNameAr": null,
"categoryNameEn": null,
"constraintCode": 0,
"constraintNameAr": null,
"constraintNameEn": null,
"content": null,
"errorList": null,
"licenseExpiryDate": null,
"licenseIssuedDate": null,
"licenseStatusCode": null,
"licenseStatusDescAr": null,
"licenseStatusDescEn": null,
"organizations": null,
"registrationNumber": null,
"specialtyCode": 0,
"specialtyNameAr": null,
"specialtyNameEn": null
});
// await _patientRegistrationService.
// getPatientInfo(getPatientInfoRequestModel);
// if (_patientRegistrationService.hasError) {
// error = _patientRegistrationService.error;
// setState(ViewState.ErrorLocal);
// } else
// setState(ViewState.Idle);
} }
Future sendActivationCodeByOTPNotificationType( Future sendActivationCodeByOTPNotificationType(

@ -56,11 +56,10 @@ class _RegisterConfirmationPatientPageState
extends State<RegisterConfirmationPatientPage> { extends State<RegisterConfirmationPatientPage> {
bool isSubmitted = false; bool isSubmitted = false;
ProjectViewModel projectViewModel; ProjectViewModel projectViewModel;
TextEditingController firstName = TextEditingController(text: "Elham"); TextEditingController firstName;
TextEditingController middleName = TextEditingController(text: "Ali"); TextEditingController middleName ;
TextEditingController lastName = TextEditingController(text: "Rababah"); TextEditingController lastName;
TextEditingController emailAddressController = TextEditingController emailAddressController;
TextEditingController(text: "Elham@Rababah.com");
@override @override
@ -132,7 +131,7 @@ class _RegisterConfirmationPatientPageState
fontSize: 12, fontSize: 12,
color: Colors.black), color: Colors.black),
AppText( AppText(
"123456", "${widget.model.getPatientInfoResponseModel.healthId}",
fontSize: 12, fontSize: 12,
color: Colors.grey[600], color: Colors.grey[600],
), ),
@ -148,7 +147,8 @@ class _RegisterConfirmationPatientPageState
fontSize: 12, fontSize: 12,
color: Colors.black), color: Colors.black),
AppText( AppText(
"ss", "${widget.model.getPatientInfoResponseModel.idNumber}",
fontSize: 12, fontSize: 12,
color: Colors.grey[600], color: Colors.grey[600],
), ),
@ -176,7 +176,7 @@ class _RegisterConfirmationPatientPageState
fontSize: 12, fontSize: 12,
color: Colors.black), color: Colors.black),
AppText( AppText(
"Jordanian", "${widget.model.getPatientInfoResponseModel.nationality}",
fontSize: 12, fontSize: 12,
color: Colors.grey[600], color: Colors.grey[600],
), ),
@ -192,7 +192,8 @@ class _RegisterConfirmationPatientPageState
fontSize: 12, fontSize: 12,
color: Colors.black), color: Colors.black),
AppText( AppText(
"--", "${widget.model.getPatientInfoResponseModel.occupation}",
fontSize: 12, fontSize: 12,
color: Colors.grey[600], color: Colors.grey[600],
), ),
@ -220,7 +221,8 @@ class _RegisterConfirmationPatientPageState
fontSize: 12, fontSize: 12,
color: Colors.black), color: Colors.black),
AppText( AppText(
"075XXXXXX", "${widget.model.checkPatientForRegistrationModel.patientMobileNumber}",
fontSize: 12, fontSize: 12,
color: Colors.grey[600], color: Colors.grey[600],
), ),

@ -98,7 +98,7 @@ class _RegisterPatientPageState extends State<RegisterPatientPage>
}, },
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,
children: <Widget>[ children: <Widget>[
RegisterSearchPatientPage(changePageViewIndex: changePageViewIndex,), RegisterSearchPatientPage(changePageViewIndex: changePageViewIndex,model: model),
RegisterConfirmationPatientPage(model: model,), RegisterConfirmationPatientPage(model: model,),
]), ]),

@ -22,8 +22,10 @@ import 'package:flutter/material.dart';
class RegisterSearchPatientPage extends StatefulWidget { class RegisterSearchPatientPage extends StatefulWidget {
final Function changePageViewIndex; final Function changePageViewIndex;
final PatientRegistrationViewModel model;
const RegisterSearchPatientPage({Key key, this.changePageViewIndex})
const RegisterSearchPatientPage({Key key, this.changePageViewIndex, this.model})
: super(key: key); : super(key: key);
@override @override
@ -50,41 +52,40 @@ class _RegisterSearchPatientPageState extends State<RegisterSearchPatientPage> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final screenSize = MediaQuery.of(context).size; final screenSize = MediaQuery.of(context).size;
return BaseView<PatientRegistrationViewModel>( return AppScaffold(
builder: (_, model, w) => AppScaffold( baseViewModel: widget.model,
baseViewModel: model, isShowAppBar: false,
isShowAppBar: false, body: Column(
body: Column( children: [
children: [ Expanded(
Expanded( child: Container(
child: Container( width: double.infinity,
width: double.infinity, margin: EdgeInsets.all(16.0),
margin: EdgeInsets.all(16.0), child: SingleChildScrollView(
child: SingleChildScrollView( child: Column(
child: Column( crossAxisAlignment: CrossAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start, children: [
children: [ AppText(
AppText( "Please enter mobile number or Identification number",
"Please enter mobile number or Identification number", fontFamily: 'Poppins',
fontFamily: 'Poppins', fontSize: SizeConfig.textMultiplier * 2.2,
fontSize: SizeConfig.textMultiplier * 2.2, fontWeight: FontWeight.w800,
fontWeight: FontWeight.w800, ),
), SizedBox(
SizedBox( height: 10,
height: 10, ),
), AppTextFieldCustom(
AppTextFieldCustom( height: screenSize.height * 0.075,
height: screenSize.height * 0.075, hintText: "Country",
hintText: "Country", isTextFieldHasSuffix: true,
isTextFieldHasSuffix: true, validationError: countryError,
validationError: countryError, dropDownText: _selectedCountry != null
dropDownText: _selectedCountry != null ? _selectedCountry['nameEn']
? _selectedCountry['nameEn'] : "Saudi Arabia",
: "Saudi Arabia", enabled: false,
enabled: false, /*onClick: widget.model.dietTypesList != null && widget.model.dietTypesList.length > 0
/*onClick: model.dietTypesList != null && model.dietTypesList.length > 0
? () { ? () {
openListDialogField('nameEn', 'id', model.dietTypesList, (selectedValue) { openListDialogField('nameEn', 'id', widget.model.dietTypesList, (selectedValue) {
setState(() { setState(() {
_selectedCountry = selectedValue; _selectedCountry = selectedValue;
}); });
@ -95,185 +96,184 @@ class _RegisterSearchPatientPageState extends State<RegisterSearchPatientPage> {
await model await model
.getDietTypes(patient.patientId) .getDietTypes(patient.patientId)
.then((_) => GifLoaderDialogUtils.hideDialog(context)); .then((_) => GifLoaderDialogUtils.hideDialog(context));
if (model.state == ViewState.Idle && model.dietTypesList.length > 0) { if (widget.model.state == ViewState.Idle && widget.model.dietTypesList.length > 0) {
openListDialogField('nameEn', 'id', model.dietTypesList, (selectedValue) { openListDialogField('nameEn', 'id', widget.model.dietTypesList, (selectedValue) {
setState(() { setState(() {
_selectedCountry = selectedValue; _selectedCountry = selectedValue;
}); });
}); });
} else if (model.state == ViewState.ErrorLocal) { } else if (widget.model.state == ViewState.ErrorLocal) {
DrAppToastMsg.showErrorToast(model.error); DrAppToastMsg.showErrorToast(widget.model.error);
} else { } else {
DrAppToastMsg.showErrorToast("Empty List"); DrAppToastMsg.showErrorToast("Empty List");
} }
},*/ },*/
), ),
SizedBox( SizedBox(
height: 10, height: 10,
), ),
Row( Row(
children: [ children: [
Container( Container(
width: MediaQuery.of(context).size.width * 0.3, width: MediaQuery.of(context).size.width * 0.3,
child: AppTextFieldCustom(
height: screenSize.height * 0.075,
hintText: "Code",
inputType: TextInputType.phone,
controller: _phoneCode,
validationError: phoneError,
),
),
Expanded(
child: Container(
// width: MediaQuery.of(context).size.width*0.7,
child: AppTextFieldCustom( child: AppTextFieldCustom(
height: screenSize.height * 0.075, height: screenSize.height * 0.075,
hintText: "Code", hintText: "Phone Number",
inputType: TextInputType.phone, inputType: TextInputType.phone,
controller: _phoneCode, controller: _phoneController,
validationError: phoneError, validationError: phoneError,
), ),
), ),
Expanded(
child: Container(
// width: MediaQuery.of(context).size.width*0.7,
child: AppTextFieldCustom(
height: screenSize.height * 0.075,
hintText: "Phone Number",
inputType: TextInputType.phone,
controller: _phoneController,
validationError: phoneError,
),
),
),
],
),
SizedBox(
height: 10,
),
AppTextFieldCustom(
height: screenSize.height * 0.075,
hintText: "ID Number",
inputType: TextInputType.phone,
controller: _idController,
validationError: idError,
),
SizedBox(
height: 12,
),
AppText(
"Calender",
fontSize: SizeConfig.textMultiplier * 1.8,
fontWeight: FontWeight.w800,
),
SizedBox(
height: 10,
),
AppTextFieldCustom(
height: screenSize.height * 0.075,
hintText: "Birthdate",
dropDownText: _birthDate != null
? "${AppDateUtils.convertStringToDateFormat(_birthDate.toString(), "yyyy/MM/dd")}"
: null,
enabled: false,
isTextFieldHasSuffix: true,
validationError: birthdateError,
suffixIcon: IconButton(
icon: Icon(
Icons.calendar_today,
color: Colors.black,
),
onPressed: null,
), ),
onClick: () { ],
if (_birthDate == null) { ),
_birthDate = DateTime.now(); SizedBox(
} height: 10,
_selectDate(context, _birthDate, (picked) { ),
setState(() { AppTextFieldCustom(
_birthDate = picked; height: screenSize.height * 0.075,
}); hintText: "ID Number",
}); inputType: TextInputType.phone,
}, controller: _idController,
validationError: idError,
),
SizedBox(
height: 12,
),
AppText(
"Calender",
fontSize: SizeConfig.textMultiplier * 1.8,
fontWeight: FontWeight.w800,
),
SizedBox(
height: 10,
),
AppTextFieldCustom(
height: screenSize.height * 0.075,
hintText: "Birthdate",
dropDownText: _birthDate != null
? "${AppDateUtils.convertStringToDateFormat(_birthDate.toString(), "yyyy/MM/dd")}"
: null,
enabled: false,
isTextFieldHasSuffix: true,
validationError: birthdateError,
suffixIcon: IconButton(
icon: Icon(
Icons.calendar_today,
color: Colors.black,
),
onPressed: null,
), ),
], onClick: () {
), if (_birthDate == null) {
_birthDate = DateTime.now();
}
_selectDate(context, _birthDate, (picked) {
setState(() {
_birthDate = picked;
});
});
},
),
],
), ),
), ),
), ),
], ),
), ],
bottomSheet: Container( ),
height: 60, bottomSheet: Container(
margin: EdgeInsets.symmetric(vertical: 16, horizontal: 16), height: 60,
child: Row( margin: EdgeInsets.symmetric(vertical: 16, horizontal: 16),
children: [ child: Row(
Expanded( children: [
child: Container( Expanded(
child: AppButton( child: Container(
title: TranslationBase.of(context).cancel, child: AppButton(
hasBorder: true, title: TranslationBase.of(context).cancel,
vPadding: 12, hasBorder: true,
hPadding: 8, vPadding: 12,
borderColor: Color(0xFFeaeaea), hPadding: 8,
color: Color(0xFFeaeaea), borderColor: Color(0xFFeaeaea),
fontColor: Colors.black, color: Color(0xFFeaeaea),
fontSize: 2.2, fontColor: Colors.black,
onPressed: () { fontSize: 2.2,
Navigator.of(context).pop(); onPressed: () {
}, Navigator.of(context).pop();
), },
), ),
), ),
SizedBox( ),
width: 8, SizedBox(
), width: 8,
Expanded( ),
child: Container( Expanded(
child: AppButton( child: Container(
title: TranslationBase.of(context).next, child: AppButton(
hasBorder: true, title: TranslationBase.of(context).next,
vPadding: 12, hasBorder: true,
hPadding: 8, vPadding: 12,
borderColor: Color(0xFFB8382B), hPadding: 8,
color: Color(0xFFB8382B), borderColor: Color(0xFFB8382B),
fontColor: Colors.white, color: Color(0xFFB8382B),
fontSize: 2.0, fontColor: Colors.white,
onPressed: () async { fontSize: 2.0,
GifLoaderDialogUtils.showMyDialog(context); onPressed: () async {
CheckPatientForRegistrationModel GifLoaderDialogUtils.showMyDialog(context);
checkPatientForRegistrationModel = CheckPatientForRegistrationModel
CheckPatientForRegistrationModel( checkPatientForRegistrationModel =
patientIdentificationID: CheckPatientForRegistrationModel(
int.parse(_idController.text), patientIdentificationID:
patientMobileNumber: int.parse(_idController.text),
int.parse(_phoneController.text), patientMobileNumber:
zipCode: _phoneCode.text, int.parse(_phoneController.text),
isHijri: 0, zipCode: _phoneCode.text,
patientID: 0, isHijri: 0,
isRegister: false, patientID: 0,
isDentalAllowedBackend: false, isRegister: false,
patientOutSA: 0, isDentalAllowedBackend: false,
generalid: GENERAL_ID, patientOutSA: 0,
dOB: generalid: GENERAL_ID,
"${AppDateUtils.convertStringToDateFormat(_birthDate.toString(), "yyyy/MM/dd")}"); dOB:
await model.checkPatientForRegistration( "${AppDateUtils.convertStringToDateFormat(_birthDate.toString(), "yyyy/MM/dd")}");
checkPatientForRegistrationModel); await widget.model.checkPatientForRegistration(
GetPatientInfoRequestModel getPatientInfoRequestModel = checkPatientForRegistrationModel);
GetPatientInfoRequestModel( GetPatientInfoRequestModel getPatientInfoRequestModel =
//TODO Elham* this return the static to dynamic GetPatientInfoRequestModel(
patientIdentificationID:"1062938285", //_idController.text, //TODO Elham* this return the static to dynamic
isHijri: 0, patientIdentificationID:"1062938285", //_idController.text,
isDentalAllowedBackend: false, isHijri: 0,
patientOutSA: 0, isDentalAllowedBackend: false,
generalid: GENERAL_ID, patientOutSA: 0,
sessionID: null, generalid: GENERAL_ID,
dOB:"31/07/1988",//"${AppDateUtils.convertStringToDateFormat(_birthDate.toString(), "dd/MM/yyyy")}" sessionID: null,
dOB:"31/07/1988",//"${AppDateUtils.convertStringToDateFormat(_birthDate.toString(), "dd/MM/yyyy")}"
); );
await model.getPatientInfo(getPatientInfoRequestModel); await widget.model.getPatientInfo(getPatientInfoRequestModel);
if (model.state == ViewState.ErrorLocal) { if (widget.model.state == ViewState.ErrorLocal) {
Helpers.showErrorToast(model.error); Helpers.showErrorToast(widget.model.error);
} else { } else {
widget.changePageViewIndex(1); widget.changePageViewIndex(1);
} }
GifLoaderDialogUtils.hideDialog(context); GifLoaderDialogUtils.hideDialog(context);
}, },
),
), ),
), ),
], ),
), ],
), ),
), ),
); );

Loading…
Cancel
Save