diff --git a/lib/client/base_app_client.dart b/lib/client/base_app_client.dart index 54c2b92b..13ab8182 100755 --- a/lib/client/base_app_client.dart +++ b/lib/client/base_app_client.dart @@ -29,7 +29,9 @@ class BaseAppClient { required Function(String error, int statusCode) onFailure, bool isAllowAny = false, bool isLiveCare = false, - bool isFallLanguage = false}) async { + bool isFallLanguage = false, + bool isCustomRequest = false + }) async { String url; if (isLiveCare) url = BASE_URL_LIVE_CARE + endPoint; @@ -40,84 +42,85 @@ class BaseAppClient { try { Map? profile = await sharedPref.getObj(DOCTOR_PROFILE); String? token = await sharedPref.getString(TOKEN); + if(!isCustomRequest) { + if (profile != null) { + DoctorProfileModel doctorProfile = DoctorProfileModel.fromJson(profile); + if (body == null || body['DoctorID'] == null) { + body!['DoctorID'] = doctorProfile.doctorID.toString(); + } + if (body['DoctorID'] == "") body['DoctorID'] = doctorProfile.doctorID; // changed from null; because create update episode not working + if (body['EditedBy'] == null) body['EditedBy'] = doctorProfile.doctorID.toString(); + if (body['ProjectID'] == null) { + body['ProjectID'] = doctorProfile.projectID.toString(); + } - if (profile != null) { - DoctorProfileModel doctorProfile = DoctorProfileModel.fromJson(profile); - if (body == null || body['DoctorID'] == null) { - body!['DoctorID'] = doctorProfile.doctorID.toString(); - } - if (body['DoctorID'] == "") body['DoctorID'] = doctorProfile.doctorID; // changed from null; because create update episode not working - if (body['EditedBy'] == null) body['EditedBy'] = doctorProfile.doctorID.toString(); - if (body['ProjectID'] == null) { - body['ProjectID'] = doctorProfile.projectID.toString(); + if (body['ClinicID'] == null) body['ClinicID'] = doctorProfile.clinicID.toString(); + } else { + String? doctorID = await sharedPref.getString(DOCTOR_ID); + if (body!['DoctorID'] == '') { + body['DoctorID'] = null; + } else if (doctorID != null) body['DoctorID'] = int.parse(doctorID); } - if (body['ClinicID'] == null) body['ClinicID'] = doctorProfile.clinicID.toString(); - } else { - String? doctorID = await sharedPref.getString(DOCTOR_ID); - if (body!['DoctorID'] == '') { - body['DoctorID'] = null; - } else if (doctorID != null) body['DoctorID'] = int.parse(doctorID); - } + body['SetupID'] = body.containsKey('SetupID') + ? body['SetupID'] != null + ? body['SetupID'] + : await sharedPref.getString(DOCTOR_SETUP_ID) + : await sharedPref.getString(DOCTOR_SETUP_ID); - body['SetupID'] = body.containsKey('SetupID') - ? body['SetupID'] != null - ? body['SetupID'] - : await sharedPref.getString(DOCTOR_SETUP_ID) - : await sharedPref.getString(DOCTOR_SETUP_ID); + if (body['EditedBy'] == '') { + body.remove("EditedBy"); + } + if (body['TokenID'] == null) { + body['TokenID'] = token ?? ''; + } - if (body['EditedBy'] == '') { - body.remove("EditedBy"); - } - if (body['TokenID'] == null) { - body['TokenID'] = token ?? ''; - } + if (!isFallLanguage) { + String? lang = await sharedPref.getString(APP_Language); + if (lang != null && lang == 'ar') + body['LanguageID'] = '1'; + else + body['LanguageID'] = '2'; + } + body['stamp'] = DateTime.now().toIso8601String(); + body['IPAdress'] = IP_ADDRESS.toString(); + if (body['VersionID'] == null) { + body['VersionID'] = VERSION_ID.toString(); + } + if (body['Channel'] == null) { + body['Channel'] = CHANNEL.toString(); + } + body['SessionID'] = SESSION_ID.toString(); + body['IsLoginForDoctorApp'] = IS_LOGIN_FOR_DOCTOR_APP.toString(); + body['PatientOutSA'] = body['PatientOutSA'] ?? '0'; // PATIENT_OUT_SA; + if (body['VidaAuthTokenID'] == null) { + body['VidaAuthTokenID'] = await sharedPref.getString(VIDA_AUTH_TOKEN_ID); + } + if (body['VidaRefreshTokenID'] == null) { + body['VidaRefreshTokenID'] = await sharedPref.getString(VIDA_REFRESH_TOKEN_ID); + } - if (!isFallLanguage) { - String? lang = await sharedPref.getString(APP_Language); - if (lang != null && lang == 'ar') - body['LanguageID'] = '1'; + int? projectID = await sharedPref.getInt(PROJECT_ID); + if (projectID == 2 || projectID == 3) + body['PatientOutSA'] = true; + else if ((body.containsKey('facilityId') && body['facilityId'] == 2 || body['facilityId'] == 3) || body['ProjectID'] == 2 || body['ProjectID'] == 3) + body['PatientOutSA'] = 'true'; else - body['LanguageID'] = '2'; - } - body['stamp'] = DateTime.now().toIso8601String(); - body['IPAdress'] = IP_ADDRESS.toString(); - if (body['VersionID'] == null) { - body['VersionID'] = VERSION_ID.toString(); - } - if (body['Channel'] == null) { - body['Channel'] = CHANNEL.toString(); - } - body['SessionID'] = SESSION_ID.toString(); - body['IsLoginForDoctorApp'] = IS_LOGIN_FOR_DOCTOR_APP.toString(); - body['PatientOutSA'] = body['PatientOutSA'] ?? '0'; // PATIENT_OUT_SA; - if (body['VidaAuthTokenID'] == null) { - body['VidaAuthTokenID'] = await sharedPref.getString(VIDA_AUTH_TOKEN_ID); - } - if (body['VidaRefreshTokenID'] == null) { - body['VidaRefreshTokenID'] = await sharedPref.getString(VIDA_REFRESH_TOKEN_ID); + body['PatientOutSA'] = 'false'; + + // if (!body.containsKey('ProjectID')) { + // if (projectID != null) { + // body['ProjectID'] = projectID; + // } else { + // body['ProjectID'] = 0; + // } + // } + + body['DeviceTypeID'] = Platform.isAndroid ? '1' : '2'; + if (body['SetupID'] != null) { + body['SetupID'] = body['SetupID'].trim(); + } } - - int? projectID = await sharedPref.getInt(PROJECT_ID); - if (projectID == 2 || projectID == 3) - body['PatientOutSA'] = true; - else if ((body.containsKey('facilityId') && body['facilityId'] == 2 || body['facilityId'] == 3) || body['ProjectID'] == 2 || body['ProjectID'] == 3) - body['PatientOutSA'] = 'true'; - else - body['PatientOutSA'] = 'false'; - - // if (!body.containsKey('ProjectID')) { - // if (projectID != null) { - // body['ProjectID'] = projectID; - // } else { - // body['ProjectID'] = 0; - // } - // } - - body['DeviceTypeID'] = Platform.isAndroid ? '1' : '2'; - if( body['SetupID'] != null) { - body['SetupID'] = body['SetupID'].trim(); - } // body['ClinicID'] = 501; // body['ProjectID'] = 12; @@ -134,7 +137,7 @@ class BaseAppClient { 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; - if (body['DoctorID'] != null) { + if (body!['DoctorID'] != null) { postRequestAndResponse( doctorId: body['DoctorID'], completeUrl: url, diff --git a/lib/core/service/hospitals/hospitals_service.dart b/lib/core/service/hospitals/hospitals_service.dart index 76f46847..6e7189b7 100644 --- a/lib/core/service/hospitals/hospitals_service.dart +++ b/lib/core/service/hospitals/hospitals_service.dart @@ -29,7 +29,8 @@ class HospitalsService extends BaseService { hasError = true; super.error = error; }, - body: {"LanguageID":await sharedPref.getString(APP_Language),"MemberID":getHospitalsRequestModel.memberID,"DoctorID":getHospitalsRequestModel.doctorID} //getHospitalsRequestModel.toJson(), + body: {"LanguageID":2,"MemberID":getHospitalsRequestModel.memberID,"DoctorID":getHospitalsRequestModel.doctorID}, //getHospitalsRequestModel.toJson(), + isCustomRequest: true ); } }