delete app client

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

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

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

@ -1,15 +1,11 @@
import 'dart:convert';
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/shared_pref_kay.dart';
import 'package:doctor_app_flutter/models/pharmacies_List_request_model.dart';
import 'package:doctor_app_flutter/models/pharmacies_items_request_model.dart';
import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart';
import 'package:doctor_app_flutter/util/helpers.dart';
import 'package:flutter/cupertino.dart';
import '.../../../util/dr_app_shared_pref.dart';
class MedicineProvider with ChangeNotifier {
DrAppSharedPreferances sharedPref = new DrAppSharedPreferances();

@ -1,6 +1,3 @@
import 'dart:convert';
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/shared_pref_kay.dart';
import 'package:doctor_app_flutter/models/doctor_profile_model.dart';
@ -18,7 +15,6 @@ import 'package:doctor_app_flutter/models/patient/refer_to_doctor_request.dart';
import 'package:doctor_app_flutter/models/prescription_report.dart';
import 'package:flutter/cupertino.dart';
import '../client/app_client.dart';
import '../config/config.dart';
import '../models/patient/lab_orders_res_model.dart';
import '../models/patient/patiant_info_model.dart';
@ -64,19 +60,18 @@ class PatientsProvider with ChangeNotifier {
ClinicByProjectIdRequest();
ReferToDoctorRequest _referToDoctorRequest = ReferToDoctorRequest();
PatiantInformtion _selectedPatient;
getPatientList(PatientModel patient, patientType) async {
int val = int.parse(patientType);
try {
var localResponse ;
await BaseAppClient.post( 'DoctorApplication.svc/REST/'+SERVICES_PATIANT[val],
onSuccess: (dynamic response, int statusCode) async{
localResponse = response;
}, onFailure: (String error, int statusCode) async{
var localResponse;
await BaseAppClient.post(
'DoctorApplication.svc/REST/' + SERVICES_PATIANT[val],
onSuccess: (dynamic response, int statusCode) async {
localResponse = response;
}, onFailure: (String error, int statusCode) async {
throw error;
}, body: {
"ProjectID": patient.ProjectID,
@ -105,7 +100,6 @@ class PatientsProvider with ChangeNotifier {
} catch (err) {
handelCatchErrorCase(error);
}
}
setBasicData() {
@ -128,36 +122,36 @@ class PatientsProvider with ChangeNotifier {
try {
await BaseAppClient.post(GET_PATIENT_VITAL_SIGN,
onSuccess: (dynamic response, int statusCode) {
patientVitalSignList = [];
response['List_DoctorPatientVitalSign'].forEach((v) {
patientVitalSignList.add(new VitalSignResModel.fromJson(v));
});
if (patientVitalSignList.length > 0) {
List<VitalSignResModel> patientVitalSignOrderdSubListTemp = [];
patientVitalSignOrderdSubListTemp = patientVitalSignList;
patientVitalSignOrderdSubListTemp
.sort((VitalSignResModel a, VitalSignResModel b) {
return b.vitalSignDate.microsecondsSinceEpoch -
a.vitalSignDate.microsecondsSinceEpoch;
});
patientVitalSignOrderdSubList.clear();
int length = patientVitalSignOrderdSubListTemp.length >= 20 ? 20 : patientVitalSignOrderdSubListTemp.length;
for (int x = 0; x < length; x++) {
patientVitalSignOrderdSubList
.add(patientVitalSignOrderdSubListTemp[x]);
}
}
isLoading = false;
isError = false;
this.error = '';
},
onFailure: (String error, int statusCode) {
isLoading = false;
isError = true;
this.error = error;
},
body: patient);
patientVitalSignList = [];
response['List_DoctorPatientVitalSign'].forEach((v) {
patientVitalSignList.add(new VitalSignResModel.fromJson(v));
});
if (patientVitalSignList.length > 0) {
List<VitalSignResModel> patientVitalSignOrderdSubListTemp = [];
patientVitalSignOrderdSubListTemp = patientVitalSignList;
patientVitalSignOrderdSubListTemp
.sort((VitalSignResModel a, VitalSignResModel b) {
return b.vitalSignDate.microsecondsSinceEpoch -
a.vitalSignDate.microsecondsSinceEpoch;
});
patientVitalSignOrderdSubList.clear();
int length = patientVitalSignOrderdSubListTemp.length >= 20
? 20
: patientVitalSignOrderdSubListTemp.length;
for (int x = 0; x < length; x++) {
patientVitalSignOrderdSubList
.add(patientVitalSignOrderdSubListTemp[x]);
}
}
isLoading = false;
isError = false;
this.error = '';
}, onFailure: (String error, int statusCode) {
isLoading = false;
isError = true;
this.error = error;
}, body: patient);
notifyListeners();
} catch (err) {
handelCatchErrorCase(err);
@ -178,20 +172,18 @@ class PatientsProvider with ChangeNotifier {
try {
await BaseAppClient.post(GET_PATIENT_LAB_OREDERS,
onSuccess: (dynamic response, int statusCode) {
patientLabResultOrdersList = [];
response['List_GetLabOreders'].forEach((v) {
patientLabResultOrdersList.add(new LabOrdersResModel.fromJson(v));
});
isLoading = false;
isError = false;
this.error = '';
},
onFailure: (String error, int statusCode) {
isLoading = false;
isError = true;
this.error = error;
},
body: patient);
patientLabResultOrdersList = [];
response['List_GetLabOreders'].forEach((v) {
patientLabResultOrdersList.add(new LabOrdersResModel.fromJson(v));
});
isLoading = false;
isError = false;
this.error = '';
}, onFailure: (String error, int statusCode) {
isLoading = false;
isError = true;
this.error = error;
}, body: patient);
notifyListeners();
} catch (err) {
handelCatchErrorCase(err);
@ -209,21 +201,18 @@ class PatientsProvider with ChangeNotifier {
try {
await BaseAppClient.post(GET_PRESCRIPTION,
onSuccess: (dynamic response, int statusCode) {
patientPrescriptionsList = [];
response['PatientPrescriptionList'].forEach((v) {
patientPrescriptionsList
.add(new PrescriptionResModel.fromJson(v));
});
isLoading = false;
isError = false;
this.error = '';
},
onFailure: (String error, int statusCode) {
isLoading = false;
isError = true;
this.error = error;
},
body: patient);
patientPrescriptionsList = [];
response['PatientPrescriptionList'].forEach((v) {
patientPrescriptionsList.add(new PrescriptionResModel.fromJson(v));
});
isLoading = false;
isError = false;
this.error = '';
}, onFailure: (String error, int statusCode) {
isLoading = false;
isError = true;
this.error = error;
}, body: patient);
notifyListeners();
} catch (err) {
handelCatchErrorCase(err);
@ -307,23 +296,20 @@ class PatientsProvider with ChangeNotifier {
// notifyListeners();
setBasicData();
try {
await BaseAppClient.post(GET_RADIOLOGY,
onSuccess: (dynamic response, int statusCode) {
patientRadiologyList = [];
response['List_GetRadOreders'].forEach((v) {
patientRadiologyList.add(new RadiologyResModel.fromJson(v));
});
isLoading = false;
isError = false;
this.error = '';
},
onFailure: (String error, int statusCode) {
isLoading = false;
isError = true;
this.error = error;
},
body: patient);
patientRadiologyList = [];
response['List_GetRadOreders'].forEach((v) {
patientRadiologyList.add(new RadiologyResModel.fromJson(v));
});
isLoading = false;
isError = false;
this.error = '';
}, onFailure: (String error, int statusCode) {
isLoading = false;
isError = true;
this.error = error;
}, body: patient);
notifyListeners();
} catch (err) {
handelCatchErrorCase(err);
@ -359,17 +345,15 @@ class PatientsProvider with ChangeNotifier {
try {
await BaseAppClient.post(PATIENT_INSURANCE_APPROVALS_URL,
onSuccess: (dynamic response, int statusCode) {
insuranceApporvalsList = response['List_ApprovalMain_InPatient'];
isLoading = false;
isError = false;
this.error = '';
},
onFailure: (String error, int statusCode) {
isLoading = false;
isError = true;
this.error = error;
},
body: patient);
insuranceApporvalsList = response['List_ApprovalMain_InPatient'];
isLoading = false;
isError = false;
this.error = '';
}, onFailure: (String error, int statusCode) {
isLoading = false;
isError = true;
this.error = error;
}, body: patient);
notifyListeners();
} catch (err) {
handelCatchErrorCase(err);
@ -383,20 +367,17 @@ class PatientsProvider with ChangeNotifier {
getPatientProgressNote(patient) async {
setBasicData();
try {
await BaseAppClient.post(PATIENT_PROGRESS_NOTE_URL,
onSuccess: (dynamic response, int statusCode) {
patientProgressNoteList = response['List_GetPregressNoteForInPatient'];
isLoading = false;
isError = false;
this.error = '';
},
onFailure: (String error, int statusCode) {
isLoading = false;
isError = true;
this.error = error;
},
body: patient);
patientProgressNoteList = response['List_GetPregressNoteForInPatient'];
isLoading = false;
isError = false;
this.error = '';
}, onFailure: (String error, int statusCode) {
isLoading = false;
isError = true;
this.error = error;
}, body: patient);
notifyListeners();
} catch (err) {
handelCatchErrorCase(err);
@ -413,17 +394,15 @@ class PatientsProvider with ChangeNotifier {
_doctorsByClinicIdRequest.clinicID = clinicId;
await BaseAppClient.post(PATIENT_GET_DOCTOR_BY_CLINIC_URL,
onSuccess: (dynamic response, int statusCode) {
doctorsList = response['List_Doctors_All'];
isLoading = false;
isError = false;
this.error = '';
},
onFailure: (String error, int statusCode) {
isLoading = false;
isError = true;
this.error = error;
},
body: _doctorsByClinicIdRequest.toJson());
doctorsList = response['List_Doctors_All'];
isLoading = false;
isError = false;
this.error = '';
}, onFailure: (String error, int statusCode) {
isLoading = false;
isError = true;
this.error = error;
}, body: _doctorsByClinicIdRequest.toJson());
notifyListeners();
} catch (err) {
handelCatchErrorCase(err);
@ -443,20 +422,17 @@ class PatientsProvider with ChangeNotifier {
getClinicsList() async {
setBasicData();
try {
await BaseAppClient.post(PATIENT_GET_CLINIC_BY_PROJECT_URL,
onSuccess: (dynamic response, int statusCode) {
clinicsList = response['List_Clinic_All'];
isLoading = false;
isError = false;
this.error = '';
},
onFailure: (String error, int statusCode) {
isLoading = false;
isError = true;
this.error = error;
},
body: _clinicByProjectIdRequest.toJson());
clinicsList = response['List_Clinic_All'];
isLoading = false;
isError = false;
this.error = '';
}, onFailure: (String error, int statusCode) {
isLoading = false;
isError = true;
this.error = error;
}, body: _clinicByProjectIdRequest.toJson());
notifyListeners();
} catch (err) {
handelCatchErrorCase(err);
@ -477,20 +453,17 @@ class PatientsProvider with ChangeNotifier {
getReferralFrequancyList() async {
setBasicData();
try {
await BaseAppClient.post(PATIENT_GET_LIST_REFERAL_URL,
onSuccess: (dynamic response, int statusCode) {
referalFrequancyList = response['list_STPReferralFrequency'];
isLoading = false;
isError = false;
this.error = '';
},
onFailure: (String error, int statusCode) {
isLoading = false;
isError = true;
this.error = error;
},
body: _referralFrequencyRequest.toJson());
referalFrequancyList = response['list_STPReferralFrequency'];
isLoading = false;
isError = false;
this.error = '';
}, onFailure: (String error, int statusCode) {
isLoading = false;
isError = true;
this.error = error;
}, body: _referralFrequencyRequest.toJson());
notifyListeners();
} catch (err) {
handelCatchErrorCase(err);
@ -523,45 +496,33 @@ class PatientsProvider with ChangeNotifier {
int clinicId = doctorProfile.clinicID;
setBasicData();
try {
if (await Helpers.checkConnection()) {
// _referToDoctorRequest.tokenID = token;
// _referToDoctorRequest.admissionNo = admissionNo;
// _referToDoctorRequest.projectID = projectID;
// _referToDoctorRequest.tokenID = token;
// _referToDoctorRequest.extension = extension;
// _referToDoctorRequest.frequency = selectedReferralFrequancyID;
// _referToDoctorRequest.patientID =
// _referToDoctorRequest.priority =
// _referToDoctorRequest.referralClinic =
// _referToDoctorRequest.referralDoctor =
// _referToDoctorRequest.referringDoctorRemarks =
// _referToDoctorRequest.roomID =
// _referToDoctorRequest.referringClinic =
// _referToDoctorRequest.referringDoctor =
final response = await AppClient.post(PATIENT_REFER_TO_DOCTOR_URL,
body: json.encode(_referralFrequencyRequest));
final int statusCode = response.statusCode;
// _referToDoctorRequest.tokenID = token;
// _referToDoctorRequest.admissionNo = admissionNo;
// _referToDoctorRequest.projectID = projectID;
// _referToDoctorRequest.tokenID = token;
// _referToDoctorRequest.extension = extension;
// _referToDoctorRequest.frequency = selectedReferralFrequancyID;
// _referToDoctorRequest.patientID =
// _referToDoctorRequest.priority =
// _referToDoctorRequest.referralClinic =
// _referToDoctorRequest.referralDoctor =
// _referToDoctorRequest.referringDoctorRemarks =
// _referToDoctorRequest.roomID =
// _referToDoctorRequest.referringClinic =
// _referToDoctorRequest.referringDoctor =
await BaseAppClient.post(PATIENT_REFER_TO_DOCTOR_URL,
onSuccess: (dynamic response, int statusCode) {
patientProgressNoteList = response['List_GetPregressNoteForInPatient'];
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) {
patientProgressNoteList = res['List_GetPregressNoteForInPatient'];
} else {
isError = true;
error = res['ErrorMessage'] ?? res['ErrorEndUserMessage'];
}
}
} else {
isError = false;
this.error = '';
}, onFailure: (String error, int statusCode) {
isLoading = false;
isError = true;
error = 'Please Check The Internet Connection';
}
this.error = error;
}, body: _referralFrequencyRequest.toJson());
notifyListeners();
} catch (err) {
handelCatchErrorCase(err);

Loading…
Cancel
Save