first step from search referrals

merge-update-with-lab-changes
Elham Rababah 5 years ago
parent 1e3ff89dbd
commit ae147b5988

@ -203,11 +203,17 @@ const GET_PATIENT_INFO_BY_ID = 'Services/Doctors.svc/REST/GetPatientInfoByPatien
const GET_PATIENT_INFO_BY_ID_AND_MOBILE_NUMBER = 'Services/Patients.svc/REST/AP_GetPatientInfoByPatientIDandMobileNumber';
const SEND_ACTIVATION_CODE_FOR_ADVANCE_PAYMENT = 'Services/Authentication.svc/REST/SendActivationCodeForAdvancePayment';
const CHECK_ACTIVATION_CODE_FOR_ADVANCE_PAYMENT = 'Services/Authentication.svc/REST/CheckActivationCodeForAdvancePayment';
//E_Referral Services
const GET_ALL_RELATIONSHIP_TYPES = "Services/Patients.svc/REST/GetAllRelationshipTypes";
const SEND_ACTIVATION_CODE_FOR_E_REFERRAL = 'Services/Authentication.svc/REST/SendActivationCodeForEReferral';
const CHECK_ACTIVATION_CODE_FOR_E_REFERRAL = 'Services/Authentication.svc/REST/CheckActivationCodeForEReferral';
const GET_ALL_CITIES = 'services/Lists.svc/rest/GetAllCities';
const CREATE_E_REFERRAL = 'Services/Patients.svc/REST/CreateEReferral';
const GET_E_REFERRALS = "Services/Patients.svc/REST/GetEReferrals";
const TIMER_MIN = 10;

@ -4,15 +4,18 @@ import 'package:diplomaticquarterapp/models/AlHabibMedicalServices/EReferral/che
import 'package:diplomaticquarterapp/models/AlHabibMedicalServices/EReferral/create_e_referral_request_model.dart';
import 'package:diplomaticquarterapp/models/AlHabibMedicalServices/EReferral/get_all_cities_response_model.dart';
import 'package:diplomaticquarterapp/models/AlHabibMedicalServices/EReferral/get_all_relationship_types_response_model.dart';
import 'package:diplomaticquarterapp/models/AlHabibMedicalServices/EReferral/search_e_referral_request_model.dart';
import 'package:diplomaticquarterapp/models/AlHabibMedicalServices/EReferral/search_e_referral_response_model.dart';
import 'package:diplomaticquarterapp/models/AlHabibMedicalServices/EReferral/send_activation_code_for_e_referral_request_model.dart';
class EReferralService extends BaseService {
List<GetAllRelationshipTypeResponseModel> _relationTypes = List();
List<GetAllRelationshipTypeResponseModel> get relationTypes => _relationTypes;
List<GetAllCitiesResponseModel> _allCities = List();
List<GetAllCitiesResponseModel> get allCities => _allCities;
List<SearchEReferralResponseModel> _allReferral = List();
List<SearchEReferralResponseModel> get allReferral => _allReferral;
String _activationCode;
String _logInTokenID;
@ -84,7 +87,6 @@ class EReferralService extends BaseService {
}
Future createEReferral(
CreateEReferralRequestModel createEReferralRequestModel
) async {
hasError = false;
@ -97,4 +99,25 @@ class EReferralService extends BaseService {
super.error = error;
}, body: createEReferralRequestModel.toJson());
}
Future getEReferrals(
SearchEReferralRequestModel searchEReferralRequestModel
) async {
hasError = false;
await baseAppClient.post(GET_E_REFERRALS,
onSuccess: (dynamic response, int statusCode) {
print("EEEEEE");
// ToDo change this one when you have data
_allReferral.clear();
response['ListCities'].forEach((city) {
_allReferral
.add(SearchEReferralResponseModel.fromJson(city));
});
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: searchEReferralRequestModel.toJson());
}
}

@ -6,8 +6,9 @@ import 'package:diplomaticquarterapp/models/AlHabibMedicalServices/EReferral/che
import 'package:diplomaticquarterapp/models/AlHabibMedicalServices/EReferral/create_e_referral_request_model.dart';
import 'package:diplomaticquarterapp/models/AlHabibMedicalServices/EReferral/get_all_cities_response_model.dart';
import 'package:diplomaticquarterapp/models/AlHabibMedicalServices/EReferral/get_all_relationship_types_response_model.dart';
import 'package:diplomaticquarterapp/models/AlHabibMedicalServices/EReferral/search_e_referral_request_model.dart';
import 'package:diplomaticquarterapp/models/AlHabibMedicalServices/EReferral/search_e_referral_response_model.dart';
import 'package:diplomaticquarterapp/models/AlHabibMedicalServices/EReferral/send_activation_code_for_e_referral_request_model.dart';
import 'package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart';
import '../../../locator.dart';
import '../base_view_model.dart';
@ -18,6 +19,7 @@ class EReferralViewModel extends BaseViewModel {
List<GetAllRelationshipTypeResponseModel> get relationTypes =>
_eReferralService.relationTypes;
List<GetAllCitiesResponseModel> get allCities => _eReferralService.allCities;
List<SearchEReferralResponseModel> get allReferral => _eReferralService.allReferral;
@ -64,14 +66,25 @@ class EReferralViewModel extends BaseViewModel {
}
}
void createEReferral(CreateEReferralRequestModel createEReferralRequestModel) async {
void createEReferral(
CreateEReferralRequestModel createEReferralRequestModel) async {
setState(ViewState.BusyLocal);
await _eReferralService.createEReferral(createEReferralRequestModel);
if (_eReferralService.hasError) {
error = _eReferralService.error;
setState(ViewState.ErrorLocal);
} else{
} else {
setState(ViewState.Idle);
}
}
getEReferrals(SearchEReferralRequestModel searchEReferralRequestModel) async {
setState(ViewState.BusyLocal);
await _eReferralService.getEReferrals(searchEReferralRequestModel);
if (_eReferralService.hasError) {
error = _eReferralService.error;
setState(ViewState.ErrorLocal);
} else {
setState(ViewState.Idle);
}
}

@ -0,0 +1,21 @@
class SearchCriteriaModel {
String name;
String nameAr;
int value;
SearchCriteriaModel({this.name, this.nameAr, this.value});
SearchCriteriaModel.fromJson(Map<String, dynamic> json) {
name = json['name'];
nameAr = json['name_ar'];
value = json['value'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['name'] = this.name;
data['name_ar'] = this.nameAr;
data['value'] = this.value;
return data;
}
}

@ -0,0 +1,60 @@
class SearchEReferralRequestModel {
String patientMobileNumber;
double versionID;
int channel;
int languageID;
String iPAdress;
String generalid;
int patientOutSA;
Null sessionID;
bool isDentalAllowedBackend;
int deviceTypeID;
int referralNumber;
String identificationNo;
SearchEReferralRequestModel(
{this.patientMobileNumber,
this.versionID,
this.channel,
this.languageID,
this.iPAdress,
this.generalid,
this.patientOutSA,
this.sessionID,
this.isDentalAllowedBackend,
this.deviceTypeID,
this.referralNumber,
this.identificationNo});
SearchEReferralRequestModel.fromJson(Map<String, dynamic> json) {
patientMobileNumber = json['PatientMobileNumber'];
versionID = json['VersionID'];
channel = json['Channel'];
languageID = json['LanguageID'];
iPAdress = json['IPAdress'];
generalid = json['generalid'];
patientOutSA = json['PatientOutSA'];
sessionID = json['SessionID'];
isDentalAllowedBackend = json['isDentalAllowedBackend'];
deviceTypeID = json['DeviceTypeID'];
referralNumber = json['ReferralNumber'];
identificationNo = json['IdentificationNo'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['PatientMobileNumber'] = this.patientMobileNumber;
data['VersionID'] = this.versionID;
data['Channel'] = this.channel;
data['LanguageID'] = this.languageID;
data['IPAdress'] = this.iPAdress;
data['generalid'] = this.generalid;
data['PatientOutSA'] = this.patientOutSA;
data['SessionID'] = this.sessionID;
data['isDentalAllowedBackend'] = this.isDentalAllowedBackend;
data['DeviceTypeID'] = this.deviceTypeID;
data['ReferralNumber'] = this.referralNumber;
data['IdentificationNo'] = this.identificationNo;
return data;
}
}

@ -0,0 +1,60 @@
class SearchEReferralResponseModel {
String patientMobileNumber;
double versionID;
int channel;
int languageID;
String iPAdress;
String generalid;
int patientOutSA;
Null sessionID;
bool isDentalAllowedBackend;
int deviceTypeID;
int referralNumber;
String identificationNo;
SearchEReferralResponseModel(
{this.patientMobileNumber,
this.versionID,
this.channel,
this.languageID,
this.iPAdress,
this.generalid,
this.patientOutSA,
this.sessionID,
this.isDentalAllowedBackend,
this.deviceTypeID,
this.referralNumber,
this.identificationNo});
SearchEReferralResponseModel.fromJson(Map<String, dynamic> json) {
patientMobileNumber = json['PatientMobileNumber'];
versionID = json['VersionID'];
channel = json['Channel'];
languageID = json['LanguageID'];
iPAdress = json['IPAdress'];
generalid = json['generalid'];
patientOutSA = json['PatientOutSA'];
sessionID = json['SessionID'];
isDentalAllowedBackend = json['isDentalAllowedBackend'];
deviceTypeID = json['DeviceTypeID'];
referralNumber = json['ReferralNumber'];
identificationNo = json['IdentificationNo'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['PatientMobileNumber'] = this.patientMobileNumber;
data['VersionID'] = this.versionID;
data['Channel'] = this.channel;
data['LanguageID'] = this.languageID;
data['IPAdress'] = this.iPAdress;
data['generalid'] = this.generalid;
data['PatientOutSA'] = this.patientOutSA;
data['SessionID'] = this.sessionID;
data['isDentalAllowedBackend'] = this.isDentalAllowedBackend;
data['DeviceTypeID'] = this.deviceTypeID;
data['ReferralNumber'] = this.referralNumber;
data['IdentificationNo'] = this.identificationNo;
return data;
}
}

@ -100,7 +100,7 @@ class _NewEReferralStepOnePageState extends State<NewEReferralStepOnePage> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: 75,
height: 20,
),
Center(
child: Texts(
@ -178,12 +178,6 @@ class _NewEReferralStepOnePageState extends State<NewEReferralStepOnePage> {
),
),
),
SizedBox(
height: 12,
),
SizedBox(
height: 12,
),
],
),
),

@ -4,7 +4,6 @@ import 'package:diplomaticquarterapp/models/AlHabibMedicalServices/EReferral/cre
import 'package:diplomaticquarterapp/models/AlHabibMedicalServices/EReferral/get_all_cities_response_model.dart';
import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart';
import 'package:diplomaticquarterapp/models/FamilyFiles/GetAllSharedRecordByStatusResponse.dart';
import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/E-Referral/dialogs/select_country_ingo_Dialog.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
import 'package:diplomaticquarterapp/widgets/bottom_options/BottomSheet.dart';
@ -40,17 +39,6 @@ class _NewEReferralStepThreePageState extends State<NewEReferralStepThreePage> {
List<EReferralAttachment> insuredPatientImages = [];
bool isPatientInsured = false;
// todo create a model for Country
// todo use country from the json
dynamic _selectedCountry = {
"name": "Saudi Arabia",
"name_ar": "المملكة العربية السعودية",
"code": "+966",
"countryCode": "SA",
"pattern": "5xxxxxxxx",
"maxLength": 9
};
AppSharedPreferences sharedPref = AppSharedPreferences();
AuthenticatedUser authUser;
@ -76,7 +64,7 @@ class _NewEReferralStepThreePageState extends State<NewEReferralStepThreePage> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: 40,
height: 20,
),
Center(
child: Texts(
@ -274,6 +262,7 @@ class _NewEReferralStepThreePageState extends State<NewEReferralStepThreePage> {
],
),
),
if(isPatientInsured)
SizedBox(
height: 12,
),

@ -71,7 +71,7 @@ class _NewEReferralStepTowPageState extends State<NewEReferralStepTowPage> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: 75,
height: 30,
),
Center(
child: Texts(

@ -0,0 +1,139 @@
import 'package:diplomaticquarterapp/core/model/hospitals/hospitals_model.dart';
import 'package:diplomaticquarterapp/models/AlHabibMedicalServices/EReferral/get_all_relationship_types_response_model.dart';
import 'package:diplomaticquarterapp/models/AlHabibMedicalServices/EReferral/search_criteria_model.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
// ignore: must_be_immutable
class SelectSearchCriteriaDialog extends StatefulWidget {
List<SearchCriteriaModel> searchCriteria = [
SearchCriteriaModel(name: "Identification Number",nameAr:"رقم المحول",value: 1),
SearchCriteriaModel(name: "Referral Number",nameAr:"رقم المحول",value: 2),
];
final Function(SearchCriteriaModel) onValueSelected;
SearchCriteriaModel selectedCriteria;
SelectSearchCriteriaDialog(
{Key key, this.onValueSelected, this.selectedCriteria});
@override
_SelectSearchCriteriaDialogState createState() => _SelectSearchCriteriaDialogState();
}
class _SelectSearchCriteriaDialogState extends State<SelectSearchCriteriaDialog> {
@override
void initState() {
super.initState();
widget.selectedCriteria = widget.selectedCriteria ?? widget.searchCriteria[0];
}
@override
Widget build(BuildContext context) {
return SimpleDialog(
children: [
Column(
children: [
Texts(" Select Search Criteria", fontSize: 20,),
Divider(),
...List.generate(
widget.searchCriteria.length,
(index) => Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: 2,
),
Row(
children: <Widget>[
Expanded(
flex: 1,
child: InkWell(
onTap: () {
setState(() {
widget.selectedCriteria = widget.searchCriteria[index];
});
},
child: ListTile(
title: Text(widget.searchCriteria[index].name),
leading: Radio(
value: widget.searchCriteria[index],
groupValue: widget.selectedCriteria,
activeColor: Colors.red[800],
onChanged: (value) {
setState(() {
widget.selectedCriteria = value;
});
},
),
),
),
)
],
),
SizedBox(
height: 5.0,
),
],
),
),
SizedBox(
height: 5.0,
),
Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Expanded(
flex: 1,
child: InkWell(
onTap: () {
Navigator.pop(context);
},
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
child: Center(
child: Texts(
TranslationBase.of(context).cancel.toUpperCase(),
color: Colors.red,
),
),
),
),
),
),
Container(
width: 1,
height: 30,
color: Colors.grey[500],
),
Expanded(
flex: 1,
child: InkWell(
onTap: () {
widget.onValueSelected(widget.selectedCriteria);
Navigator.pop(context);
},
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Center(
child: Texts(
TranslationBase.of(context).ok,
fontWeight: FontWeight.w400,
)),
),
),
),
],
)
],
)
],
);
}
}

@ -1,21 +1,227 @@
import 'package:diplomaticquarterapp/core/viewModels/medical/prescriptions_view_model.dart';
import 'package:diplomaticquarterapp/pages/medical/prescriptions/prescriptions_history_details_page.dart';
import 'package:diplomaticquarterapp/uitl/date_uitl.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
import 'package:diplomaticquarterapp/core/viewModels/all_habib_medical_services/e_referral_view_model.dart';
import 'package:diplomaticquarterapp/models/AlHabibMedicalServices/EReferral/search_criteria_model.dart';
import 'package:diplomaticquarterapp/models/AlHabibMedicalServices/EReferral/search_e_referral_request_model.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/pages/medical/balance/new_text_Field.dart';
import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/errors/app_embedded_error.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class SearchForReferralsPage extends StatelessWidget {
import 'New_E_Referral/new_e_referral_step_one_page.dart';
import 'dialogs/select_country_ingo_Dialog.dart';
import 'dialogs/select_search_criteria_dialog.dart';
class SearchForReferralsPage extends StatefulWidget {
SearchForReferralsPage({Key key});
@override
_SearchForReferralsPageState createState() => _SearchForReferralsPageState();
}
class _SearchForReferralsPageState extends State<SearchForReferralsPage> {
TextEditingController _searchTextController = TextEditingController();
TextEditingController _mobileTextController = TextEditingController();
bool _isSubmitted = false;
dynamic _selectedCountry = {
"name": "Saudi Arabia",
"name_ar": "المملكة العربية السعودية",
"code": "+966",
"countryCode": "SA",
"pattern": "5xxxxxxxx",
"maxLength": 9
};
SearchCriteriaModel selectedCriteria = SearchCriteriaModel(
name: "Identification Number", nameAr: "رقم المحول", value: 1);
@override
Widget build(BuildContext context) {
return AppScaffold(
body: Container(),
return BaseView<EReferralViewModel>(
onModelReady: (model) => model.getAllCities(),
builder: (_, model, widget) => AppScaffold(
isShowAppBar: false,
body: SingleChildScrollView(
physics: ScrollPhysics(),
child: Container(
margin: EdgeInsets.all(12),
child: Center(
child: FractionallySizedBox(
widthFactor: 0.94,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: 77,
),
InkWell(
onTap: () => selectSearchCriteriaDialog(),
child: Container(
padding: EdgeInsets.all(12),
width: double.infinity,
height: 65,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
color: Colors.white),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Texts(getSearchCriteriaName()),
Icon(Icons.arrow_drop_down)
],
),
),
),
SizedBox(
height: 12,
),
NewTextFields(
hintText: selectedCriteria.value == 1
? "Enter Patient Identification No"
: "Enter Referral Number",
controller: _searchTextController,
),
SizedBox(
height: 12,
),
InkWell(
onTap: () => confirmSelectCountryTypeDialog(),
child: Container(
padding: EdgeInsets.all(12),
width: double.infinity,
height: 65,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
color: Colors.white),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Texts(getCountryName()),
Icon(Icons.arrow_drop_down)
],
),
),
),
SizedBox(
height: 12,
),
MobileNumberTextFiled(
controller: _mobileTextController,
code: _selectedCountry == null
? "11"
: _selectedCountry["code"],
),
SizedBox(
height: 12,
),
if ((model.state == ViewState.Idle &&
model.allReferral.length == 0))
Text("There's No allReferral To deliver"),
if ((
model.state == ViewState.ErrorLocal))
AppEmbeddedError( error:model.error),
NetworkBaseView(
baseViewModel: model,
child: ListView.builder(
shrinkWrap: true,
scrollDirection: Axis.vertical,
itemCount: model.allReferral == null
? 0
: model.allReferral.length < 3
? model.allReferral.length
: 3,
itemBuilder: (BuildContext context, int index) {
return Padding(
padding: EdgeInsets.symmetric(horizontal: 0.2),
child: Container(
child: Texts("TODO add referral info"),
),
);
},
),
),
],
),
),
),
),
),
bottomSheet: Container(
height: MediaQuery.of(context).size.height * 0.1,
width: double.infinity,
padding: EdgeInsets.all(9),
child: SecondaryButton(
textColor: Colors.white,
label: "Search",
onTap: () async {
SearchEReferralRequestModel searchEReferralRequestModel =
new SearchEReferralRequestModel(
patientMobileNumber:
_selectedCountry['code'] + _mobileTextController.text,
);
if (selectedCriteria.value == 1) {
searchEReferralRequestModel.identificationNo =
_searchTextController.text;
searchEReferralRequestModel.referralNumber = 0;
} else {
searchEReferralRequestModel.referralNumber =
int.parse(_searchTextController.text);
searchEReferralRequestModel.identificationNo = '';
}
await model.getEReferrals(searchEReferralRequestModel);
setState(() {
_isSubmitted = true;
});
},
loading: model.state == ViewState.BusyLocal,
disabled: _searchTextController.text.isEmpty ||
_mobileTextController.text.isEmpty,
),
)));
}
void confirmSelectCountryTypeDialog() {
showDialog(
context: context,
child: SelectCountryDialog(
selectedCountry: _selectedCountry,
onValueSelected: (value) {
setState(() {
_selectedCountry = value;
});
},
),
);
}
String getCountryName() {
if (_selectedCountry != null)
return _selectedCountry["name"];
else
return "Country";
}
void selectSearchCriteriaDialog() {
showDialog(
context: context,
child: SelectSearchCriteriaDialog(
selectedCriteria: selectedCriteria,
onValueSelected: (value) {
setState(() {
selectedCriteria = value;
});
},
),
);
}
String getSearchCriteriaName() {
return selectedCriteria.name;
}
}

Loading…
Cancel
Save