WD: error handling and request changes

update_flutter_3.24_vida_plus_episode
taha.alam 11 months ago
parent 8f05d526f6
commit fd4dacee83

@ -25,11 +25,11 @@ class BaseAppClient {
//TODO change the post fun to nun static when you change all service //TODO change the post fun to nun static when you change all service
post(String endPoint, post(String endPoint,
{Map<String, dynamic>? body, {Map<String, dynamic>? body,
required Function(dynamic response, int statusCode) onSuccess, required Function(dynamic response, int statusCode) onSuccess,
required Function(String error, int statusCode) onFailure, required Function(String error, int statusCode) onFailure,
bool isAllowAny = false, bool isAllowAny = false,
bool isLiveCare = false, bool isLiveCare = false,
bool isFallLanguage = false}) async { bool isFallLanguage = false}) async {
String url; String url;
if (isLiveCare) if (isLiveCare)
url = BASE_URL_LIVE_CARE + endPoint; url = BASE_URL_LIVE_CARE + endPoint;
@ -46,7 +46,9 @@ class BaseAppClient {
if (body == null || body['DoctorID'] == null) { if (body == null || body['DoctorID'] == null) {
body!['DoctorID'] = doctorProfile.doctorID; body!['DoctorID'] = doctorProfile.doctorID;
} }
if (body['DoctorID'] == "") body['DoctorID'] = doctorProfile.doctorID; // changed from null; because create update episode not working if (body['DoctorID'] == "")
body['DoctorID'] = doctorProfile
.doctorID; // changed from null; because create update episode not working
if (body['EditedBy'] == null) body['EditedBy'] = doctorProfile.doctorID; if (body['EditedBy'] == null) body['EditedBy'] = doctorProfile.doctorID;
if (body['ProjectID'] == null) { if (body['ProjectID'] == null) {
body['ProjectID'] = doctorProfile.projectID; body['ProjectID'] = doctorProfile.projectID;
@ -62,8 +64,8 @@ class BaseAppClient {
body['SetupID'] = body.containsKey('SetupID') body['SetupID'] = body.containsKey('SetupID')
? body['SetupID'] != null ? body['SetupID'] != null
? body['SetupID'] ? body['SetupID']
: await sharedPref.getString(DOCTOR_SETUP_ID) : await sharedPref.getString(DOCTOR_SETUP_ID)
: await sharedPref.getString(DOCTOR_SETUP_ID); : await sharedPref.getString(DOCTOR_SETUP_ID);
if (body['EditedBy'] == '') { if (body['EditedBy'] == '') {
@ -92,16 +94,21 @@ class BaseAppClient {
body['IsLoginForDoctorApp'] = IS_LOGIN_FOR_DOCTOR_APP; body['IsLoginForDoctorApp'] = IS_LOGIN_FOR_DOCTOR_APP;
body['PatientOutSA'] = body['PatientOutSA'] ?? 0; // PATIENT_OUT_SA; body['PatientOutSA'] = body['PatientOutSA'] ?? 0; // PATIENT_OUT_SA;
if (body['VidaAuthTokenID'] == null) { if (body['VidaAuthTokenID'] == null) {
body['VidaAuthTokenID'] = await sharedPref.getString(VIDA_AUTH_TOKEN_ID); body['VidaAuthTokenID'] =
await sharedPref.getString(VIDA_AUTH_TOKEN_ID);
} }
if (body['VidaRefreshTokenID'] == null) { if (body['VidaRefreshTokenID'] == null) {
body['VidaRefreshTokenID'] = await sharedPref.getString(VIDA_REFRESH_TOKEN_ID); body['VidaRefreshTokenID'] =
await sharedPref.getString(VIDA_REFRESH_TOKEN_ID);
} }
int? projectID = await sharedPref.getInt(PROJECT_ID); int? projectID = await sharedPref.getInt(PROJECT_ID);
if (projectID == 2 || projectID == 3) if (projectID == 2 || projectID == 3)
body['PatientOutSA'] = true; body['PatientOutSA'] = true;
else if ((body.containsKey('facilityId') && body['facilityId'] == 2 || body['facilityId'] == 3) || body['ProjectID'] == 2 || body['ProjectID'] == 3) else if ((body.containsKey('facilityId') && body['facilityId'] == 2 ||
body['facilityId'] == 3) ||
body['ProjectID'] == 2 ||
body['ProjectID'] == 3)
body['PatientOutSA'] = true; body['PatientOutSA'] = true;
else else
body['PatientOutSA'] = false; body['PatientOutSA'] = false;
@ -128,29 +135,47 @@ class BaseAppClient {
var asd = json.encode(body); var asd = json.encode(body);
var asd2; var asd2;
if (await Utils.checkConnection()) { if (await Utils.checkConnection()) {
final response = await http.post(Uri.parse(url), body: json.encode(body), headers: {'Content-Type': 'application/json', 'Accept': 'application/json'}); final response = await http.post(Uri.parse(url),
body: json.encode(body),
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
});
final int statusCode = response.statusCode; final int statusCode = response.statusCode;
if (statusCode < 200 || statusCode >= 400) { if (statusCode < 200 || statusCode >= 400) {
onFailure(Utils.generateContactAdminMsg(), statusCode); onFailure(Utils.generateContactAdminMsg(), statusCode);
if(body['DoctorID'] !=null ) if (body['DoctorID'] != null)
postFailureResponse(doctorId:body['DoctorID'], url:url , request: json.encode(body), response: response.body, exception: "$statusCode"); postFailureResponse(
doctorId: body['DoctorID'],
url: url,
request: json.encode(body),
response: response.body,
exception: "$statusCode");
} else { } else {
var parsed = json.decode(response.body.toString()); var parsed = json.decode(response.body.toString());
if (parsed['ErrorType'] == 4) { if (parsed['ErrorType'] == 4) {
helpers.navigateToUpdatePage(parsed['ErrorEndUserMessage'], parsed['AndroidLink'], parsed['IOSLink']); helpers.navigateToUpdatePage(parsed['ErrorEndUserMessage'],
parsed['AndroidLink'], parsed['IOSLink']);
} }
if (parsed['IsAuthenticated'] != null && !parsed['IsAuthenticated']) { if (parsed['IsAuthenticated'] != null && !parsed['IsAuthenticated']) {
if (body['OTP_SendType'] != null) { if (body['OTP_SendType'] != null) {
if(parsed['ErrorCode'] =='699'){ if (parsed['ErrorCode'] == '699') {
onSuccess(parsed, statusCode); onSuccess(parsed, statusCode);
}else { } else {
if(body['DoctorID'] !=null ) if (body['DoctorID'] != null)
postFailureResponse(doctorId:body['DoctorID'], url:url , request: json.encode(body), response: response.body, exception: getError(parsed)); postFailureResponse(
onFailure(getError(parsed), statusCode); doctorId: body['DoctorID'],
} url: url,
request: json.encode(body),
response: response.body,
exception: getError(parsed));
onFailure(getError(parsed), statusCode);
}
} else if (!isAllowAny) { } else if (!isAllowAny) {
await Provider.of<AuthenticationViewModel>(AppGlobal.CONTEX, listen: false).logout(); await Provider.of<AuthenticationViewModel>(AppGlobal.CONTEX,
listen: false)
.logout();
//todo nofailure is placed here and but have to handle the response here as well //todo nofailure is placed here and but have to handle the response here as well
Utils.showErrorToast('Your session expired Please login again'); Utils.showErrorToast('Your session expired Please login again');
locator<NavigationService>().pushNamedAndRemoveUntil(ROOT); locator<NavigationService>().pushNamedAndRemoveUntil(ROOT);
@ -160,25 +185,38 @@ class BaseAppClient {
} }
} else if (parsed['MessageStatus'] == 1) { } else if (parsed['MessageStatus'] == 1) {
if (!parsed['IsAuthenticated']) { if (!parsed['IsAuthenticated']) {
if(body['DoctorID'] !=null ) if (body['DoctorID'] != null)
postFailureResponse(doctorId:body['DoctorID'], url:url , request: json.encode(body), response: response.body, exception: getError(parsed)); postFailureResponse(
doctorId: body['DoctorID'],
url: url,
request: json.encode(body),
response: response.body,
exception: getError(parsed));
onFailure(getError(parsed), statusCode); onFailure(getError(parsed), statusCode);
} else } else
onSuccess(parsed, statusCode); onSuccess(parsed, statusCode);
} else { } else {
if(body['DoctorID'] !=null ) { final validations = parsed['ValidationErrorsCSI']?['errors']?['Validations'];
postFailureResponse( if (validations is List && validations.isNotEmpty) {
doctorId: body['DoctorID'], final error = validations.first['Error'];
url: url, if (error != null) {
request: json.encode(body), onFailure(error, statusCode);
response: response.body, return;
exception: getError(parsed)); }
}
if (body['DoctorID'] != null) {
postFailureResponse(
doctorId: body['DoctorID'],
url: url,
request: json.encode(body),
response: response.body,
exception: getError(parsed));
}
onFailure(getError(parsed), statusCode);
} }
onFailure(getError(parsed), statusCode);
} }
} } else {
} else {
onFailure('Please Check The Internet Connection', -1); onFailure('Please Check The Internet Connection', -1);
} }
} catch (e) { } catch (e) {
@ -187,202 +225,264 @@ class BaseAppClient {
} }
} }
postPatient(String endPoint, postPatient(String endPoint,
{Map<String, dynamic>? body, {Map<String, dynamic>? body,
required Function(dynamic response, int statusCode) onSuccess, required Function(dynamic response, int statusCode) onSuccess,
required Function(String error, int statusCode) onFailure, required Function(String error, int statusCode) onFailure,
PatiantInformtion? patient, PatiantInformtion? patient,
bool isExternal = false}) async { bool isExternal = false}) async {
String url = BASE_URL + endPoint; String url = BASE_URL + endPoint;
try { try {
Map<String, String> headers = {'Content-Type': 'application/json', 'Accept': 'application/json'}; Map<String, String> headers = {
'Content-Type': 'application/json',
String? token = await sharedPref.getString(TOKEN); 'Accept': 'application/json'
Map<String, dynamic>? profile = await sharedPref.getObj(DOCTOR_PROFILE); };
if (profile != null) { String? token = await sharedPref.getString(TOKEN);
DoctorProfileModel doctorProfile = DoctorProfileModel.fromJson(profile); Map<String, dynamic>? profile = await sharedPref.getObj(DOCTOR_PROFILE);
if (body!['DoctorID'] == null) {
body['DoctorID'] = doctorProfile.doctorID; if (profile != null) {
} DoctorProfileModel doctorProfile = DoctorProfileModel.fromJson(profile);
} if (body!['DoctorID'] == null) {
if (body!['DoctorID'] == 0) { body['DoctorID'] = doctorProfile.doctorID;
body['DoctorID'] = null; }
} }
var languageID = await sharedPref.getStringWithDefaultValue(APP_Language, 'en'); if (body!['DoctorID'] == 0) {
body['SetupID'] = body!.containsKey('SetupID') body['DoctorID'] = null;
? body['SetupID'] != null }
? body['SetupID'] var languageID =
: await sharedPref.getString(DOCTOR_SETUP_ID) await sharedPref.getStringWithDefaultValue(APP_Language, 'en');
: await sharedPref.getString(DOCTOR_SETUP_ID); body['SetupID'] = body!.containsKey('SetupID')
? body['SetupID'] != null
body['VersionID'] = VERSION_ID; ? body['SetupID']
body['Channel'] = CHANNEL; : await sharedPref.getString(DOCTOR_SETUP_ID)
body['LanguageID'] = languageID == 'ar' ? 1 : 2; : await sharedPref.getString(DOCTOR_SETUP_ID);
body['IPAdress'] = "10.20.10.20"; body['VersionID'] = VERSION_ID;
body['generalid'] = GENERAL_ID; body['Channel'] = CHANNEL;
body['PatientOutSA'] = body.containsKey('PatientOutSA') body['LanguageID'] = languageID == 'ar' ? 1 : 2;
? body['PatientOutSA'] != null
? body['PatientOutSA'] body['IPAdress'] = "10.20.10.20";
: PATIENT_OUT_SA_PATIENT_REQ body['generalid'] = GENERAL_ID;
: PATIENT_OUT_SA_PATIENT_REQ; body['PatientOutSA'] = body.containsKey('PatientOutSA')
? body['PatientOutSA'] != null
if (body.containsKey('isDentalAllowedBackend')) { ? body['PatientOutSA']
body['isDentalAllowedBackend'] = body.containsKey('isDentalAllowedBackend') : PATIENT_OUT_SA_PATIENT_REQ
? body['isDentalAllowedBackend'] != null : PATIENT_OUT_SA_PATIENT_REQ;
? body['isDentalAllowedBackend']
: IS_DENTAL_ALLOWED_BACKEND if (body.containsKey('isDentalAllowedBackend')) {
: IS_DENTAL_ALLOWED_BACKEND; body['isDentalAllowedBackend'] =
} body.containsKey('isDentalAllowedBackend')
? body['isDentalAllowedBackend'] != null
body['DeviceTypeID'] = Platform.isAndroid ? 1 : 2; ? body['isDentalAllowedBackend']
: IS_DENTAL_ALLOWED_BACKEND
body['PatientType'] = body.containsKey('PatientType') : IS_DENTAL_ALLOWED_BACKEND;
? body['PatientType'] != null }
? body['PatientType']
: patient!.patientType != null
? patient.patientType
: PATIENT_TYPE
: PATIENT_TYPE;
body['PatientTypeID'] = body.containsKey('PatientTypeID')
? body['PatientTypeID'] != null
? body['PatientTypeID']
: patient!.patientType != null
? patient.patientType
: PATIENT_TYPE_ID
: PATIENT_TYPE_ID;
body['TokenID'] = body.containsKey('TokenID') ? body['TokenID'] ?? token : token;
body['PatientID'] = body['PatientID'] != null ? body['PatientID'] : patient!.patientId ?? patient.patientMRN;
body['PatientOutSA'] = 0; //user['OutSA']; //TODO change it
body['SessionID'] = SESSION_ID; //getSe
int? projectID = await sharedPref.getInt(PROJECT_ID);
if (projectID == 2 || projectID == 3)
body['PatientOutSA'] = true;
else
body['PatientOutSA'] = false;
// if(!body.containsKey('ProjectID')) {
// if (projectID != null) {
// body['ProjectID'] = 313;
// } else {
// body['ProjectID'] = 0;
// }
// }
// body['DoctorID'] = 24; //3844083
// body['TokenID'] = "@dm!n";
print("URL : $url");
print("Body : ${json.encode(body)}");
var asd = json.encode(body);
var asd2;
if (await Utils.checkConnection()) {
final response = await http.post(Uri.parse(url.trim()), body: json.encode(body), headers: headers);
final int statusCode = response.statusCode;
print("statusCode :$statusCode");
if (statusCode < 200 || statusCode >= 400 || json == null) {
onFailure('Error While Fetching data', statusCode);
} else {
// var parsed = json.decode(response.body.toString());
var parsed = json.decode(utf8.decode(response.bodyBytes));
if (parsed['Response_Message'] != null) {
onSuccess(parsed, statusCode);
} else {
if (parsed['ErrorType'] == 4) {
helpers.navigateToUpdatePage(parsed['ErrorEndUserMessage'], parsed['AndroidLink'], parsed['IOSLink']);
}
if (parsed['IsAuthenticated'] == null) {
if (parsed['isSMSSent'] == true) {
onSuccess(parsed, statusCode);
} else if (parsed['MessageStatus'] == 1) {
onSuccess(parsed, statusCode);
} else if (parsed['Result'] == 'OK') {
onSuccess(parsed, statusCode);
} else {
if (parsed != null) {
onSuccess(parsed, statusCode);
} else {
if(body['DoctorID'] !=null )
postFailureResponse(doctorId:body['DoctorID'], url:url , request: json.encode(body), response: response.body, exception: getError(parsed));
onFailure(getError(parsed), statusCode);
}
}
} else if (parsed['MessageStatus'] == 1 || parsed['SMSLoginRequired'] == true) {
onSuccess(parsed, statusCode);
} else if (parsed['MessageStatus'] == 2 && parsed['IsAuthenticated']) {
if (parsed['SameClinicApptList'] != null) {
onSuccess(parsed, statusCode);
} else {
if (parsed['message'] == null && parsed['ErrorEndUserMessage'] == null) {
if (parsed['ErrorSearchMsg'] == null) {
if(body['DoctorID'] !=null )
postFailureResponse(doctorId:body['DoctorID'], url:url , request: json.encode(body), response: response.body, exception: "Server Error found with no available message");
onFailure("Server Error found with no available message", statusCode);
} else {
if(body['DoctorID'] !=null )
postFailureResponse(doctorId:body['DoctorID'], url:url , request: json.encode(body), response: response.body, exception: parsed['ErrorSearchMsg']);
onFailure(parsed['ErrorSearchMsg'], statusCode);
}
} else {
if(body['DoctorID'] !=null )
postFailureResponse(doctorId:body['DoctorID'], url:url , request: json.encode(body), response: response.body, exception: parsed['message'] ?? parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage']);
onFailure(parsed['message'] ?? parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], statusCode);
}
}
} else {
if (parsed['SameClinicApptList'] != null) {
onSuccess(parsed, statusCode);
} else {
if (parsed['message'] != null) {
if(body['DoctorID'] !=null )
postFailureResponse(doctorId:body['DoctorID'], url:url , request: json.encode(body), response: response.body, exception: parsed['message'] );
onFailure(parsed['message'] ?? parsed['message'], statusCode);
} else {
if(body['DoctorID'] !=null )
postFailureResponse(doctorId:body['DoctorID'], url:url , request: json.encode(body), response: response.body, exception: parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage']);
onFailure(parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], statusCode); body['DeviceTypeID'] = Platform.isAndroid ? 1 : 2;
}
} body['PatientType'] = body.containsKey('PatientType')
} ? body['PatientType'] != null
} ? body['PatientType']
} : patient!.patientType != null
} else { ? patient.patientType
onFailure('Please Check The Internet Connection', -1); : PATIENT_TYPE
} : PATIENT_TYPE;
body['PatientTypeID'] = body.containsKey('PatientTypeID')
? body['PatientTypeID'] != null
? body['PatientTypeID']
: patient!.patientType != null
? patient.patientType
: PATIENT_TYPE_ID
: PATIENT_TYPE_ID;
body['TokenID'] =
body.containsKey('TokenID') ? body['TokenID'] ?? token : token;
body['PatientID'] = body['PatientID'] != null
? body['PatientID']
: patient!.patientId ?? patient.patientMRN;
body['PatientOutSA'] = 0; //user['OutSA']; //TODO change it
body['SessionID'] = SESSION_ID; //getSe
int? projectID = await sharedPref.getInt(PROJECT_ID);
if (projectID == 2 || projectID == 3)
body['PatientOutSA'] = true;
else
body['PatientOutSA'] = false;
// if(!body.containsKey('ProjectID')) {
// if (projectID != null) {
// body['ProjectID'] = 313;
// } else {
// body['ProjectID'] = 0;
// }
// }
// body['DoctorID'] = 24; //3844083
// body['TokenID'] = "@dm!n";
print("URL : $url");
print("Body : ${json.encode(body)}");
var asd = json.encode(body);
var asd2;
if (await Utils.checkConnection()) {
final response = await http.post(Uri.parse(url.trim()),
body: json.encode(body), headers: headers);
final int statusCode = response.statusCode;
print("statusCode :$statusCode");
if (statusCode < 200 || statusCode >= 400 || json == null) {
onFailure('Error While Fetching data', statusCode);
} else {
// var parsed = json.decode(response.body.toString());
var parsed = json.decode(utf8.decode(response.bodyBytes));
if (parsed['Response_Message'] != null) {
onSuccess(parsed, statusCode);
} else {
if (parsed['ErrorType'] == 4) {
helpers.navigateToUpdatePage(parsed['ErrorEndUserMessage'],
parsed['AndroidLink'], parsed['IOSLink']);
}
if (parsed['IsAuthenticated'] == null) {
if (parsed['isSMSSent'] == true) {
onSuccess(parsed, statusCode);
} else if (parsed['MessageStatus'] == 1) {
onSuccess(parsed, statusCode);
} else if (parsed['Result'] == 'OK') {
onSuccess(parsed, statusCode);
} else {
if (parsed != null) {
onSuccess(parsed, statusCode);
} else {
if (body['DoctorID'] != null)
postFailureResponse(
doctorId: body['DoctorID'],
url: url,
request: json.encode(body),
response: response.body,
exception: getError(parsed));
onFailure(getError(parsed), statusCode);
}
}
} else if (parsed['MessageStatus'] == 1 ||
parsed['SMSLoginRequired'] == true) {
onSuccess(parsed, statusCode);
} else if (parsed['MessageStatus'] == 2 &&
parsed['IsAuthenticated']) {
if (parsed['SameClinicApptList'] != null) {
onSuccess(parsed, statusCode);
} else {
if (parsed['message'] == null &&
parsed['ErrorEndUserMessage'] == null) {
if (parsed['ErrorSearchMsg'] == null) {
if (body['DoctorID'] != null)
postFailureResponse(
doctorId: body['DoctorID'],
url: url,
request: json.encode(body),
response: response.body,
exception:
"Server Error found with no available message");
onFailure("Server Error found with no available message",
statusCode);
} else {
if (body['DoctorID'] != null)
postFailureResponse(
doctorId: body['DoctorID'],
url: url,
request: json.encode(body),
response: response.body,
exception: parsed['ErrorSearchMsg']);
onFailure(parsed['ErrorSearchMsg'], statusCode);
}
} else {
if (body['DoctorID'] != null)
postFailureResponse(
doctorId: body['DoctorID'],
url: url,
request: json.encode(body),
response: response.body,
exception: parsed['message'] ??
parsed['ErrorEndUserMessage'] ??
parsed['ErrorMessage']);
onFailure(
parsed['message'] ??
parsed['ErrorEndUserMessage'] ??
parsed['ErrorMessage'],
statusCode);
}
}
} else {
if (parsed['SameClinicApptList'] != null) {
onSuccess(parsed, statusCode);
} else {
if (parsed['message'] != null) {
if (body['DoctorID'] != null)
postFailureResponse(
doctorId: body['DoctorID'],
url: url,
request: json.encode(body),
response: response.body,
exception: parsed['message']);
onFailure(parsed['message'] ?? parsed['message'], statusCode);
} else {
if (body['DoctorID'] != null)
postFailureResponse(
doctorId: body['DoctorID'],
url: url,
request: json.encode(body),
response: response.body,
exception: parsed['ErrorEndUserMessage'] ??
parsed['ErrorMessage']);
onFailure(
parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'],
statusCode);
}
}
}
}
}
} else {
onFailure('Please Check The Internet Connection', -1);
}
} catch (e) { } catch (e) {
print(e); print(e);
onFailure(e.toString(), -1); onFailure(e.toString(), -1);
}
} }
}
String getError(parsed) { String getError(parsed) {
//TODO change this fun //TODO change this fun
String? error = parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage']; String? error = parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'];
if (parsed["ValidationErrors"] != null) { if (parsed["ValidationErrors"] != null) {
error = parsed["ValidationErrors"]["StatusMessage"].toString() + "\n"; error = parsed["ValidationErrors"]["StatusMessage"].toString() + "\n";
if (parsed["ValidationErrors"]["ValidationErrors"] != null && parsed["ValidationErrors"]["ValidationErrors"].length != 0) { if (parsed["ValidationErrors"]["ValidationErrors"] != null &&
for (var i = 0; i < parsed["ValidationErrors"]["ValidationErrors"].length; i++) { parsed["ValidationErrors"]["ValidationErrors"].length != 0) {
error = error! + parsed["ValidationErrors"]["ValidationErrors"][i]["Messages"][0] + "\n"; for (var i = 0;
} i < parsed["ValidationErrors"]["ValidationErrors"].length;
} i++) {
error = error! +
parsed["ValidationErrors"]["ValidationErrors"][i]["Messages"][0] +
"\n";
}
}
} }
if (error == null || error == "null" || error == "null\n") { if (error == null || error == "null" || error == "null\n") {
return Utils.generateContactAdminMsg(); return Utils.generateContactAdminMsg();
} }
return error; return error;
} }
get({required String endPoint, required Function(dynamic response, int statusCode) onSuccess, required Function(String error, int statusCode) onFailure}) async { get(
{required String endPoint,
required Function(dynamic response, int statusCode) onSuccess,
required Function(String error, int statusCode) onFailure}) async {
String token = await sharedPref.getString(TOKEN); String token = await sharedPref.getString(TOKEN);
String url = DOCTOR_ROTATION + endPoint + '&token=' + token; String url = DOCTOR_ROTATION + endPoint + '&token=' + token;
print(url); print(url);
@ -390,10 +490,10 @@ class BaseAppClient {
final int statusCode = response.statusCode; final int statusCode = response.statusCode;
if (statusCode < 200 || statusCode >= 400) { if (statusCode < 200 || statusCode >= 400) {
onFailure(Utils.generateContactAdminMsg(), statusCode); onFailure(Utils.generateContactAdminMsg(), statusCode);
} else { } else {
var parsed = json.decode(response.body.toString()); var parsed = json.decode(response.body.toString());
onSuccess(parsed, statusCode); onSuccess(parsed, statusCode);
}
} }
} }
}

@ -1122,10 +1122,10 @@ class SOAPService extends LookupService {
"ProjectID": patientInformation.projectId "ProjectID": patientInformation.projectId
}; };
hasError = false; hasError = false;
patientProgressNoteListVidaPlus.clear();
await baseAppClient.post(GET_PROGRESS_NOTE, await baseAppClient.post(GET_PROGRESS_NOTE,
onSuccess: (dynamic response, int statusCode) { onSuccess: (dynamic response, int statusCode) {
print("Success"); print("Success");
patientProgressNoteListVidaPlus.clear();
response['ListProgressNote']['resultData'].forEach((v) { response['ListProgressNote']['resultData'].forEach((v) {
v['data'].forEach((progressNote) { v['data'].forEach((progressNote) {
patientProgressNoteListVidaPlus patientProgressNoteListVidaPlus
@ -1237,6 +1237,7 @@ class SOAPService extends LookupService {
"condition": conditionType, "condition": conditionType,
"remarks": remarks, "remarks": remarks,
"icdType": searchDiagnosis!.icdType, "icdType": searchDiagnosis!.icdType,
"selectedIcdCode": searchDiagnosis.diseasesCode,
// "icdVersion": searchDiagnosis.icdVersion, // "icdVersion": searchDiagnosis.icdVersion,
"icdSubVersion": searchDiagnosis.icdSubVersion, "icdSubVersion": searchDiagnosis.icdSubVersion,
"isNew": isNew, "isNew": isNew,
@ -1244,7 +1245,7 @@ class SOAPService extends LookupService {
"selectedDisease": searchDiagnosis.diseases, "selectedDisease": searchDiagnosis.diseases,
"diseasesCode": searchDiagnosis.diseasesCode, "diseasesCode": searchDiagnosis.diseasesCode,
"diseasesId": searchDiagnosis.diseasesId, "diseasesId": searchDiagnosis.diseasesId,
"selectedIcdCode": searchDiagnosis.icdId, // "selectedIcdCode": searchDiagnosis.icdId,
"selectedCategoryCode": searchDiagnosis.categoryCode, "selectedCategoryCode": searchDiagnosis.categoryCode,
"selectedSectionCode": searchDiagnosis.sectionCode, "selectedSectionCode": searchDiagnosis.sectionCode,
"selectedChapterCode": searchDiagnosis.chapterCode, "selectedChapterCode": searchDiagnosis.chapterCode,
@ -1357,6 +1358,8 @@ class SOAPService extends LookupService {
success = false; success = false;
}, onFailure: (String error, int statusCode) { }, onFailure: (String error, int statusCode) {
success = false; success = false;
DrAppToastMsg.showErrorToast(error);
hasError = true; hasError = true;
super.error = error; super.error = error;
}, body: request); }, body: request);

Loading…
Cancel
Save