Merge branch 'base_app_client_one' of https://gitlab.com/Cloud_Solution/doctor_app_flutter into base_app_client

merge-requests/104/head
Elham Rababah 6 years ago
commit d44dabd485

@ -20,6 +20,7 @@ Helpers helpers = new Helpers();
*@return: *@return:
*@desc: *@desc:
*/ */
///Example ///Example
/* /*
await BaseAppClient.post('', await BaseAppClient.post('',
@ -28,7 +29,6 @@ Helpers helpers = new Helpers();
body: null); body: null);
* */ * */
class BaseAppClient { class BaseAppClient {
static post( static post(
String endPoint, { String endPoint, {
Map<String, dynamic> body, Map<String, dynamic> body,
@ -44,7 +44,8 @@ class BaseAppClient {
body['DoctorID'] = doctorProfile?.doctorID; body['DoctorID'] = doctorProfile?.doctorID;
body['EditedBy'] = doctorProfile?.doctorID; body['EditedBy'] = doctorProfile?.doctorID;
body['ProjectID'] = doctorProfile?.projectID; body['ProjectID'] = doctorProfile?.projectID;
body['ClinicID'] = doctorProfile?.clinicID; if (!body.containsKey('ClinicID'))
body['ClinicID'] = doctorProfile?.clinicID;
} }
body['TokenID'] = token ?? ''; body['TokenID'] = token ?? '';
body['LanguageID'] = LANGUAGE_ID; body['LanguageID'] = LANGUAGE_ID;
@ -56,7 +57,7 @@ class BaseAppClient {
body['IsLoginForDoctorApp'] = IS_LOGIN_FOR_DOCTOR_APP; body['IsLoginForDoctorApp'] = IS_LOGIN_FOR_DOCTOR_APP;
body['PatientOutSA'] = PATIENT_OUT_SA; body['PatientOutSA'] = PATIENT_OUT_SA;
if (await Helpers.checkConnection()) { if (await Helpers.checkConnection()) {
final response = await http.post(url, final response = await http.post(url,
body: json.encode(body), body: json.encode(body),
headers: { headers: {

@ -2,8 +2,8 @@ const MAX_SMALL_SCREEN = 660;
const ONLY_NUMBERS = "[0-9]"; const ONLY_NUMBERS = "[0-9]";
const ONLY_LETTERS = "[a-zA-Z]"; const ONLY_LETTERS = "[a-zA-Z]";
const ONLY_DATE = "[0-9/]"; const ONLY_DATE = "[0-9/]";
// const BASE_URL = 'https://hmgwebservices.com/Services/'; const BASE_URL = 'https://hmgwebservices.com/Services/';
const BASE_URL = 'https://uat.hmgwebservices.com/Services/'; //const BASE_URL = 'https://uat.hmgwebservices.com/Services/';
const PHARMACY_ITEMS_URL = "Lists.svc/REST/GetPharmcyItems_Region"; const PHARMACY_ITEMS_URL = "Lists.svc/REST/GetPharmcyItems_Region";
const PHARMACY_LIST_URL = "Patients.svc/REST/GetPharmcyList"; const PHARMACY_LIST_URL = "Patients.svc/REST/GetPharmcyList";
const PATIENT_PROGRESS_NOTE_URL = "DoctorApplication.svc/REST/GetProgressNoteForInPatient"; const PATIENT_PROGRESS_NOTE_URL = "DoctorApplication.svc/REST/GetProgressNoteForInPatient";

@ -16,6 +16,7 @@ class HospitalProvider with ChangeNotifier {
"IsLoginForDoctorApp": true "IsLoginForDoctorApp": true
}; };
dynamic localRes ; dynamic localRes ;
await BaseAppClient.post(url, await BaseAppClient.post(url,
onSuccess: ( response, statusCode) async { onSuccess: ( response, statusCode) async {
localRes= response; localRes= response;

@ -1,6 +1,7 @@
import 'dart:convert'; import 'dart:convert';
import 'package:doctor_app_flutter/client/app_client.dart'; import 'package:doctor_app_flutter/client/app_client.dart';
import 'package:doctor_app_flutter/client/base_app_client.dart';
import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/config/config.dart';
import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; import 'package:doctor_app_flutter/config/shared_pref_kay.dart';
import 'package:doctor_app_flutter/models/pharmacies_List_request_model.dart'; import 'package:doctor_app_flutter/models/pharmacies_List_request_model.dart';
@ -11,47 +12,32 @@ import 'package:flutter/cupertino.dart';
class MedicineProvider with ChangeNotifier { class MedicineProvider with ChangeNotifier {
DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); DrAppSharedPreferances sharedPref = new DrAppSharedPreferances();
var pharmacyItemsList = []; var pharmacyItemsList = [];
var pharmaciesList = []; var pharmaciesList = [];
bool isFinished = true; bool isFinished = true;
bool hasError = false; bool hasError = false;
String errorMsg = ''; String errorMsg = '';
PharmaciesItemsRequestModel _itemsRequestModel =PharmaciesItemsRequestModel(); PharmaciesItemsRequestModel _itemsRequestModel =
PharmaciesItemsRequestModel();
PharmaciesListRequestModel _listRequestModel = PharmaciesListRequestModel(); PharmaciesListRequestModel _listRequestModel = PharmaciesListRequestModel();
Future<String> getMedicineItem(String itemName) async { Future<String> getMedicineItem(String itemName) async {
resetDefaultValues(); resetDefaultValues();
try { try {
if (await Helpers.checkConnection()) { _itemsRequestModel.pHRItemName = itemName;
_itemsRequestModel.pHRItemName = itemName; await BaseAppClient.post(PHARMACY_ITEMS_URL,
onSuccess: (dynamic response, int statusCode) {
final response = await AppClient.post(PHARMACY_ITEMS_URL, pharmacyItemsList = response['ListPharmcy_Region'];
body: json.encode(_itemsRequestModel.toJson())); hasError = false;
final int statusCode = response.statusCode;
isFinished = true; isFinished = true;
if (statusCode < 200 || statusCode >= 400 || json == null) { errorMsg = "Done";
isFinished = true; }, onFailure: (String error, int statusCode) {
hasError = true;
errorMsg = 'Error While Fetching data';
} else {
var parsed = json.decode(response.body.toString());
if (parsed['MessageStatus'] == 1) {
pharmacyItemsList = parsed['ListPharmcy_Region'];
hasError = false;
isFinished = true;
errorMsg = "Done";
} else {
hasError = true;
errorMsg = parsed['ErrorMessage'] ?? parsed['ErrorEndUserMessage'];
}
}
} else {
isFinished = true; isFinished = true;
hasError = true; hasError = true;
errorMsg = 'Please Check The Internet Connection'; errorMsg = error;
} }, body: _itemsRequestModel.toJson());
notifyListeners(); notifyListeners();
} catch (error) { } catch (error) {
throw error; throw error;
@ -61,37 +47,20 @@ class MedicineProvider with ChangeNotifier {
} }
Future<String> getPharmaciesList(int itemId) async { Future<String> getPharmaciesList(int itemId) async {
String token = await sharedPref.getString(TOKEN);
resetDefaultValues(); resetDefaultValues();
try { try {
if (await Helpers.checkConnection()) { _listRequestModel.itemID = itemId;
_listRequestModel.itemID = itemId; await BaseAppClient.post(PHARMACY_LIST_URL,
_listRequestModel.tokenID = token; onSuccess: (dynamic response, int statusCode) {
final response = await AppClient.post(PHARMACY_LIST_URL, pharmaciesList = response['PharmList'];
body: json.encode(_listRequestModel.toJson())); hasError = false;
final int statusCode = response.statusCode;
isFinished = true; isFinished = true;
if (statusCode < 200 || statusCode >= 400 || json == null) { errorMsg = "Done";
isFinished = true; }, onFailure: (String error, int statusCode) {
hasError = true;
errorMsg = 'Error While Fetching data';
} else {
var parsed = json.decode(response.body.toString());
if (parsed['MessageStatus'] == 1) {
pharmaciesList = parsed['PharmList'];
hasError = false;
isFinished = true;
errorMsg = "Done";
} else {
hasError = true;
errorMsg = parsed['ErrorMessage'] ?? parsed['ErrorEndUserMessage'];
}
}
} else {
isFinished = true; isFinished = true;
hasError = true; hasError = true;
errorMsg = 'Please Check The Internet Connection'; errorMsg = error;
} }, body: _listRequestModel.toJson());
notifyListeners(); notifyListeners();
} catch (error) { } catch (error) {
throw error; throw error;

@ -68,17 +68,15 @@ class PatientsProvider with ChangeNotifier {
PatiantInformtion _selectedPatient; PatiantInformtion _selectedPatient;
Future<Map> getPatientList(PatientModel patient, patientType) async { getPatientList(PatientModel patient, patientType) async {
int val = int.parse(patientType); int val = int.parse(patientType);
final url =
BASE_URL + "DoctorApplication.svc/REST/" + SERVICES_PATIANT[val];
try { try {
await BaseAppClient.post(url, var localResponse ;
onSuccess: (dynamic response, int statusCode) { await BaseAppClient.post( 'DoctorApplication.svc/REST/'+SERVICES_PATIANT[val],
return Future.value(response); onSuccess: (dynamic response, int statusCode) async{
}, onFailure: (String error, int statusCode) { localResponse = response;
}, onFailure: (String error, int statusCode) async{
throw error; throw error;
}, body: { }, body: {
"ProjectID": patient.ProjectID, "ProjectID": patient.ProjectID,
@ -102,9 +100,12 @@ class PatientsProvider with ChangeNotifier {
"IsLoginForDoctorApp": patient.IsLoginForDoctorApp, "IsLoginForDoctorApp": patient.IsLoginForDoctorApp,
"PatientOutSA": patient.PatientOutSA "PatientOutSA": patient.PatientOutSA
}); });
return localResponse;
} catch (err) { } catch (err) {
handelCatchErrorCase(error); handelCatchErrorCase(error);
} }
} }
setBasicData() { setBasicData() {
@ -125,21 +126,10 @@ class PatientsProvider with ChangeNotifier {
setBasicData(); setBasicData();
try { try {
if (await Helpers.checkConnection()) { await BaseAppClient.post(GET_PATIENT_VITAL_SIGN,
final response = await AppClient.post(GET_PATIENT_VITAL_SIGN, onSuccess: (dynamic response, int statusCode) {
body: json.encode(patient));
final int statusCode = response.statusCode;
isLoading = false;
if (statusCode < 200 || statusCode >= 400 || json == null) {
isError = true;
error = 'Error While Fetching data';
} else {
var res = json.decode(response.body);
print('$res');
if (res['MessageStatus'] == 1) {
patientVitalSignList = []; patientVitalSignList = [];
res['List_DoctorPatientVitalSign'].forEach((v) { response['List_DoctorPatientVitalSign'].forEach((v) {
patientVitalSignList.add(new VitalSignResModel.fromJson(v)); patientVitalSignList.add(new VitalSignResModel.fromJson(v));
}); });
@ -152,21 +142,22 @@ class PatientsProvider with ChangeNotifier {
a.vitalSignDate.microsecondsSinceEpoch; a.vitalSignDate.microsecondsSinceEpoch;
}); });
patientVitalSignOrderdSubList.clear(); patientVitalSignOrderdSubList.clear();
for (int x = 0; x < 20; x++) { int length = patientVitalSignOrderdSubListTemp.length >= 20 ? 20 : patientVitalSignOrderdSubListTemp.length;
for (int x = 0; x < length; x++) {
patientVitalSignOrderdSubList patientVitalSignOrderdSubList
.add(patientVitalSignOrderdSubListTemp[x]); .add(patientVitalSignOrderdSubListTemp[x]);
} }
} }
} else { isLoading = false;
isError = false;
this.error = '';
},
onFailure: (String error, int statusCode) {
isLoading = false;
isError = true; isError = true;
error = res['ErrorMessage'] ?? res['ErrorEndUserMessage']; this.error = error;
} },
} body: patient);
} else {
isLoading = false;
isError = true;
error = 'Please Check The Internet Connection';
}
notifyListeners(); notifyListeners();
} catch (err) { } catch (err) {
handelCatchErrorCase(err); handelCatchErrorCase(err);
@ -185,33 +176,22 @@ class PatientsProvider with ChangeNotifier {
setBasicData(); setBasicData();
try { try {
if (await Helpers.checkConnection()) { await BaseAppClient.post(GET_PATIENT_LAB_OREDERS,
final response = await AppClient.post(GET_PATIENT_LAB_OREDERS, onSuccess: (dynamic response, int statusCode) {
body: json.encode(patient));
final int statusCode = response.statusCode;
isLoading = false;
if (statusCode < 200 || statusCode >= 400 || json == null) {
isError = true;
error = 'Error While Fetching data';
} else {
var res = json.decode(response.body);
print('$res');
if (res['MessageStatus'] == 1) {
patientLabResultOrdersList = []; patientLabResultOrdersList = [];
res['List_GetLabOreders'].forEach((v) { response['List_GetLabOreders'].forEach((v) {
patientLabResultOrdersList.add(new LabOrdersResModel.fromJson(v)); patientLabResultOrdersList.add(new LabOrdersResModel.fromJson(v));
}); });
} else { isLoading = false;
isError = false;
this.error = '';
},
onFailure: (String error, int statusCode) {
isLoading = false;
isError = true; isError = true;
error = res['ErrorMessage'] ?? res['ErrorEndUserMessage']; this.error = error;
} },
} body: patient);
} else {
isLoading = false;
isError = true;
error = 'Please Check The Internet Connection';
}
notifyListeners(); notifyListeners();
} catch (err) { } catch (err) {
handelCatchErrorCase(err); handelCatchErrorCase(err);
@ -226,36 +206,24 @@ class PatientsProvider with ChangeNotifier {
*/ */
getOutPatientPrescriptions(patient) async { getOutPatientPrescriptions(patient) async {
setBasicData(); setBasicData();
try { try {
if (await Helpers.checkConnection()) { await BaseAppClient.post(GET_PRESCRIPTION,
final response = onSuccess: (dynamic response, int statusCode) {
await AppClient.post(GET_PRESCRIPTION, body: json.encode(patient));
final int statusCode = response.statusCode;
isLoading = false;
if (statusCode < 200 || statusCode >= 400 || json == null) {
isError = true;
error = 'Error While Fetching data';
} else {
var res = json.decode(response.body);
print('$res');
if (res['MessageStatus'] == 1) {
patientPrescriptionsList = []; patientPrescriptionsList = [];
res['PatientPrescriptionList'].forEach((v) { response['PatientPrescriptionList'].forEach((v) {
patientPrescriptionsList patientPrescriptionsList
.add(new PrescriptionResModel.fromJson(v)); .add(new PrescriptionResModel.fromJson(v));
}); });
} else { isLoading = false;
isError = false;
this.error = '';
},
onFailure: (String error, int statusCode) {
isLoading = false;
isError = true; isError = true;
error = res['ErrorMessage'] ?? res['ErrorEndUserMessage']; this.error = error;
} },
} body: patient);
} else {
isLoading = false;
isError = true;
error = 'Please Check The Internet Connection';
}
notifyListeners(); notifyListeners();
} catch (err) { } catch (err) {
handelCatchErrorCase(err); handelCatchErrorCase(err);
@ -339,33 +307,23 @@ class PatientsProvider with ChangeNotifier {
// notifyListeners(); // notifyListeners();
setBasicData(); setBasicData();
try { try {
if (await Helpers.checkConnection()) {
final response =
await AppClient.post(GET_RADIOLOGY, body: json.encode(patient));
final int statusCode = response.statusCode;
isLoading = false;
if (statusCode < 200 || statusCode >= 400 || json == null) { await BaseAppClient.post(GET_RADIOLOGY,
isError = true; onSuccess: (dynamic response, int statusCode) {
error = 'Error While Fetching data';
} else {
var res = json.decode(response.body);
print('$res');
if (res['MessageStatus'] == 1) {
patientRadiologyList = []; patientRadiologyList = [];
res['List_GetRadOreders'].forEach((v) { response['List_GetRadOreders'].forEach((v) {
patientRadiologyList.add(new RadiologyResModel.fromJson(v)); patientRadiologyList.add(new RadiologyResModel.fromJson(v));
}); });
} else { isLoading = false;
isError = false;
this.error = '';
},
onFailure: (String error, int statusCode) {
isLoading = false;
isError = true; isError = true;
error = res['ErrorMessage'] ?? res['ErrorEndUserMessage']; this.error = error;
} },
} body: patient);
} else {
isLoading = false;
isError = true;
error = 'Please Check The Internet Connection';
}
notifyListeners(); notifyListeners();
} catch (err) { } catch (err) {
handelCatchErrorCase(err); handelCatchErrorCase(err);
@ -399,31 +357,19 @@ class PatientsProvider with ChangeNotifier {
getPatientInsuranceApprovals(patient) async { getPatientInsuranceApprovals(patient) async {
setBasicData(); setBasicData();
try { try {
if (await Helpers.checkConnection()) { await BaseAppClient.post(PATIENT_INSURANCE_APPROVALS_URL,
final response = await AppClient.post(PATIENT_INSURANCE_APPROVALS_URL, onSuccess: (dynamic response, int statusCode) {
body: json.encode(patient)); insuranceApporvalsList = response['List_ApprovalMain_InPatient'];
final int statusCode = response.statusCode; isLoading = false;
isLoading = false; isError = false;
this.error = '';
if (statusCode < 200 || statusCode >= 400 || json == null) { },
isError = true; onFailure: (String error, int statusCode) {
error = 'Error While Fetching data'; isLoading = false;
} else {
var res = json.decode(response.body);
print('$res');
if (res['MessageStatus'] == 1) {
//patientRadiologyList = [];
insuranceApporvalsList = res['List_ApprovalMain_InPatient'];
} else {
isError = true; isError = true;
error = res['ErrorMessage'] ?? res['ErrorEndUserMessage']; this.error = error;
} },
} body: patient);
} else {
isLoading = false;
isError = true;
error = 'Please Check The Internet Connection';
}
notifyListeners(); notifyListeners();
} catch (err) { } catch (err) {
handelCatchErrorCase(err); handelCatchErrorCase(err);
@ -437,30 +383,20 @@ class PatientsProvider with ChangeNotifier {
getPatientProgressNote(patient) async { getPatientProgressNote(patient) async {
setBasicData(); setBasicData();
try { try {
if (await Helpers.checkConnection()) {
final response = await AppClient.post(PATIENT_PROGRESS_NOTE_URL,
body: json.encode(patient));
final int statusCode = response.statusCode;
isLoading = false;
if (statusCode < 200 || statusCode >= 400 || json == null) { await BaseAppClient.post(PATIENT_PROGRESS_NOTE_URL,
isError = true; onSuccess: (dynamic response, int statusCode) {
error = 'Error While Fetching data'; patientProgressNoteList = response['List_GetPregressNoteForInPatient'];
} else { isLoading = false;
var res = json.decode(response.body); isError = false;
print('$res'); this.error = '';
if (res['MessageStatus'] == 1) { },
patientProgressNoteList = res['List_GetPregressNoteForInPatient']; onFailure: (String error, int statusCode) {
} else { isLoading = false;
isError = true; isError = true;
error = res['ErrorMessage'] ?? res['ErrorEndUserMessage']; this.error = error;
} },
} body: patient);
} else {
isLoading = false;
isError = true;
error = 'Please Check The Internet Connection';
}
notifyListeners(); notifyListeners();
} catch (err) { } catch (err) {
handelCatchErrorCase(err); handelCatchErrorCase(err);
@ -472,38 +408,22 @@ class PatientsProvider with ChangeNotifier {
*@desc: getDoctorsList *@desc: getDoctorsList
*/ */
getDoctorsList(String clinicId) async { getDoctorsList(String clinicId) async {
String token = await sharedPref.getString(TOKEN);
int projectID = await sharedPref.getInt(PROJECT_ID);
setBasicData(); setBasicData();
try { try {
if (await Helpers.checkConnection()) { _doctorsByClinicIdRequest.clinicID = clinicId;
_doctorsByClinicIdRequest.projectID = projectID; await BaseAppClient.post(PATIENT_GET_DOCTOR_BY_CLINIC_URL,
_doctorsByClinicIdRequest.clinicID = clinicId; onSuccess: (dynamic response, int statusCode) {
_doctorsByClinicIdRequest.tokenID = token; doctorsList = response['List_Doctors_All'];
isLoading = false;
final response = await AppClient.post(PATIENT_GET_DOCTOR_BY_CLINIC_URL, isError = false;
body: json.encode(_doctorsByClinicIdRequest)); this.error = '';
final int statusCode = response.statusCode; },
isLoading = false; onFailure: (String error, int statusCode) {
isLoading = false;
if (statusCode < 200 || statusCode >= 400 || json == null) {
isError = true;
error = 'Error While Fetching data';
} else {
var res = json.decode(response.body);
print('$res');
if (res['MessageStatus'] == 1) {
doctorsList = res['List_Doctors_All'];
} else {
isError = true; isError = true;
error = res['ErrorMessage'] ?? res['ErrorEndUserMessage']; this.error = error;
} },
} body: _doctorsByClinicIdRequest.toJson());
} else {
isLoading = false;
isError = true;
error = 'Please Check The Internet Connection';
}
notifyListeners(); notifyListeners();
} catch (err) { } catch (err) {
handelCatchErrorCase(err); handelCatchErrorCase(err);
@ -521,37 +441,22 @@ class PatientsProvider with ChangeNotifier {
*@desc: getClinicsList *@desc: getClinicsList
*/ */
getClinicsList() async { getClinicsList() async {
String token = await sharedPref.getString(TOKEN);
setBasicData(); setBasicData();
try { try {
if (await Helpers.checkConnection()) {
int projectID = await sharedPref.getInt(PROJECT_ID);
_clinicByProjectIdRequest.projectID = projectID;
_clinicByProjectIdRequest.tokenID = token;
final response = await AppClient.post(PATIENT_GET_CLINIC_BY_PROJECT_URL, await BaseAppClient.post(PATIENT_GET_CLINIC_BY_PROJECT_URL,
body: json.encode(_clinicByProjectIdRequest)); onSuccess: (dynamic response, int statusCode) {
final int statusCode = response.statusCode; clinicsList = response['List_Clinic_All'];
isLoading = false; isLoading = false;
isError = false;
if (statusCode < 200 || statusCode >= 400 || json == null) { this.error = '';
isError = true; },
error = 'Error While Fetching data'; onFailure: (String error, int statusCode) {
} else { isLoading = false;
var res = json.decode(response.body);
print('$res');
if (res['MessageStatus'] == 1) {
clinicsList = res['List_Clinic_All'];
} else {
isError = true; isError = true;
error = res['ErrorMessage'] ?? res['ErrorEndUserMessage']; this.error = error;
} },
} body: _clinicByProjectIdRequest.toJson());
} else {
isLoading = false;
isError = true;
error = 'Please Check The Internet Connection';
}
notifyListeners(); notifyListeners();
} catch (err) { } catch (err) {
handelCatchErrorCase(err); handelCatchErrorCase(err);
@ -570,33 +475,22 @@ class PatientsProvider with ChangeNotifier {
*@desc: getReferralFrequancyList *@desc: getReferralFrequancyList
*/ */
getReferralFrequancyList() async { getReferralFrequancyList() async {
String token = await sharedPref.getString(TOKEN);
setBasicData(); setBasicData();
try { try {
if (await Helpers.checkConnection()) {
_referralFrequencyRequest.tokenID = token; await BaseAppClient.post(PATIENT_GET_LIST_REFERAL_URL,
final response = await AppClient.post(PATIENT_GET_LIST_REFERAL_URL, onSuccess: (dynamic response, int statusCode) {
body: json.encode(_referralFrequencyRequest)); referalFrequancyList = response['list_STPReferralFrequency'];
final int statusCode = response.statusCode; isLoading = false;
isLoading = false; isError = false;
if (statusCode < 200 || statusCode >= 400 || json == null) { this.error = '';
isError = true; },
error = 'Error While Fetching data'; onFailure: (String error, int statusCode) {
} else { isLoading = false;
var res = json.decode(response.body);
print('$res');
if (res['MessageStatus'] == 1) {
referalFrequancyList = res['list_STPReferralFrequency'];
} else {
isError = true; isError = true;
error = res['ErrorMessage'] ?? res['ErrorEndUserMessage']; this.error = error;
} },
} body: _referralFrequencyRequest.toJson());
} else {
isLoading = false;
isError = true;
error = 'Please Check The Internet Connection';
}
notifyListeners(); notifyListeners();
} catch (err) { } catch (err) {
handelCatchErrorCase(err); handelCatchErrorCase(err);

Loading…
Cancel
Save