Merge branch 'referral-facilities-changes' into 'development'

add referral get facilties

See merge request Cloud_Solution/doctor_app_flutter!310
merge-requests/312/merge
Mohammad Aljammal 5 years ago
commit 21ead3b219

@ -27,7 +27,8 @@ const PATIENT_GET_CLINIC_BY_PROJECT_URL =
const PROJECT_GET_INFO = "Services/DoctorApplication.svc/REST/GetProjectInfo"; const PROJECT_GET_INFO = "Services/DoctorApplication.svc/REST/GetProjectInfo";
const GET_CLINICS = "Services/DoctorApplication.svc/REST/GetClinics"; const GET_CLINICS = "Services/DoctorApplication.svc/REST/GetClinics";
//const GET_PROJECTS = 'Services/Lists.svc/REST/GetProjectForDoctorAPP'; const GET_REFERRAL_FACILITIES = 'Services/DoctorApplication.svc/REST/GetReferralFacilities';
const GET_PROJECTS = 'Services/DoctorApplication.svc/REST/GetProjectInfo'; const GET_PROJECTS = 'Services/DoctorApplication.svc/REST/GetProjectInfo';
const GET_PATIENT_VITAL_SIGN = const GET_PATIENT_VITAL_SIGN =

@ -49,6 +49,20 @@ class PatientReferralService extends LookupService {
}, body: info); }, body: info);
} }
Future getReferralFacilities() async {
hasError = false;
Map<String, dynamic> body = Map();
body['isSameBranch'] = false;
await baseAppClient.post(GET_REFERRAL_FACILITIES, onSuccess: (response, statusCode) async {
projectsList = response['ProjectInfo'];
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: body);
}
Future getProjectInfo(int projectId) async { Future getProjectInfo(int projectId) async {
Map<String, dynamic> body = Map(); Map<String, dynamic> body = Map();
body['ProjectID'] = projectId; body['ProjectID'] = projectId;

@ -62,7 +62,7 @@ class PatientReferralViewModel extends BaseViewModel {
Future getBranches() async { Future getBranches() async {
setState(ViewState.BusyLocal); setState(ViewState.BusyLocal);
await _referralPatientService.getProjectsList(); await _referralPatientService.getReferralFacilities();
if (_referralPatientService.hasError) { if (_referralPatientService.hasError) {
error = _referralPatientService.error; error = _referralPatientService.error;
setState(ViewState.Error); setState(ViewState.Error);
@ -77,7 +77,7 @@ class PatientReferralViewModel extends BaseViewModel {
await _referralPatientService.getProjectInfo(projectId); await _referralPatientService.getProjectInfo(projectId);
if (_referralPatientService.hasError) { if (_referralPatientService.hasError) {
error = _referralPatientService.error; error = _referralPatientService.error;
setState(ViewState.Error); setState(ViewState.ErrorLocal);
} else } else
setState(ViewState.Idle); setState(ViewState.Idle);
} }
@ -87,7 +87,7 @@ class PatientReferralViewModel extends BaseViewModel {
await _referralPatientService.getDoctorsList(clinicId); await _referralPatientService.getDoctorsList(clinicId);
if (_referralPatientService.hasError) { if (_referralPatientService.hasError) {
error = _referralPatientService.error; error = _referralPatientService.error;
setState(ViewState.Error); setState(ViewState.ErrorLocal);
} else } else
setState(ViewState.Idle); setState(ViewState.Idle);
} }

@ -1,4 +1,5 @@
import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/config/config.dart';
import 'package:doctor_app_flutter/core/enum/viewstate.dart';
import 'package:doctor_app_flutter/core/viewModel/patient-referral-viewmodel.dart'; import 'package:doctor_app_flutter/core/viewModel/patient-referral-viewmodel.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/screens/base/base_view.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart';
@ -177,15 +178,18 @@ class _PatientMakeReferralScreenState extends State<PatientMakeReferralScreen> {
_selectedBranch = null; _selectedBranch = null;
_selectedClinic = null; _selectedClinic = null;
_selectedDoctor = null; _selectedDoctor = null;
model.getDoctorBranch().then((value) { model.getDoctorBranch().then((value) async {
_selectedBranch = value; _selectedBranch = value;
if (_referTo['id'] == 1) { if (_referTo['id'] == 1) {
GifLoaderDialogUtils.showMyDialog(context); GifLoaderDialogUtils.showMyDialog(context);
model await model
.getClinics(_selectedBranch['facilityId']) .getClinics(_selectedBranch['facilityId'])
.then((_) => .then((_) =>
GifLoaderDialogUtils.hideDialog( GifLoaderDialogUtils.hideDialog(
context)); context));
if (model.state == ViewState.ErrorLocal) {
DrAppToastMsg.showErrorToast(model.error);
}
} }
}); });
}); });
@ -226,15 +230,18 @@ class _PatientMakeReferralScreenState extends State<PatientMakeReferralScreen> {
attributeValueId: 'facilityId', attributeValueId: 'facilityId',
okText: TranslationBase.of(context).ok, okText: TranslationBase.of(context).ok,
okFunction: (selectedValue) { okFunction: (selectedValue) {
setState(() { setState(() async {
_selectedBranch = selectedValue; _selectedBranch = selectedValue;
_selectedClinic = null; _selectedClinic = null;
_selectedDoctor = null; _selectedDoctor = null;
GifLoaderDialogUtils.showMyDialog(context); GifLoaderDialogUtils.showMyDialog(context);
model await model
.getClinics(_selectedBranch['facilityId']) .getClinics(_selectedBranch['facilityId'])
.then((_) => .then((_) =>
GifLoaderDialogUtils.hideDialog(context)); GifLoaderDialogUtils.hideDialog(context));
if (model.state == ViewState.ErrorLocal) {
DrAppToastMsg.showErrorToast(model.error);
}
}); });
}, },
); );
@ -277,15 +284,18 @@ class _PatientMakeReferralScreenState extends State<PatientMakeReferralScreen> {
TranslationBase.of(context).clinicSearch, TranslationBase.of(context).clinicSearch,
okText: TranslationBase.of(context).ok, okText: TranslationBase.of(context).ok,
okFunction: (selectedValue) { okFunction: (selectedValue) {
setState(() { setState(() async {
_selectedDoctor = null; _selectedDoctor = null;
_selectedClinic = selectedValue; _selectedClinic = selectedValue;
GifLoaderDialogUtils.showMyDialog(context); GifLoaderDialogUtils.showMyDialog(context);
model await model
.getClinicDoctors( .getClinicDoctors(
_selectedClinic['ClinicID'].toString()) _selectedClinic['ClinicID'].toString())
.then((_) => .then((_) =>
GifLoaderDialogUtils.hideDialog(context)); GifLoaderDialogUtils.hideDialog(context));
if (model.state == ViewState.ErrorLocal) {
DrAppToastMsg.showErrorToast(model.error);
}
}); });
}, },
); );

Loading…
Cancel
Save