You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
diplomatic-quarter/lib/core/service/parmacyModule/lacum-service.dart

133 lines
4.2 KiB
Dart

import 'package:diplomaticquarterapp/config/config.dart';
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
import 'package:diplomaticquarterapp/core/model/pharmacies/LacumAccountInformation.dart';
import 'package:diplomaticquarterapp/core/service/base_service.dart';
class LacumService extends BaseService{
bool isFinished = true;
bool hasError = false;
String errorMsg = '';
String successMsg = '';
LacumAccountInformation lacumInformation;
LacumAccountInformation lacumGroupInformation;
Future getLacumAccountInformation() async {
hasError = false;
super.error = "";
Map<String, dynamic> body = Map();
body['IdentificationNo'] = user.patientIdentificationNo;
try {
await baseAppClient.post(GET_LACUM_ACCOUNT_INFORMATION,
onSuccess: (response, statusCode) async {
lacumInformation = LacumAccountInformation.fromJson(response);
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: body);
} catch (error) {
throw error;
}
}
Future getLacumGroupInformation() async {
hasError = false;
super.error = "";
Map<String, dynamic> body = Map();
body['IdentificationNo'] = user.patientIdentificationNo;
body['AccountNumber'] = "${lacumInformation.yahalaAccountNo}";
body['IsDetailsRequired'] = true;
try {
await baseAppClient.post(GET_LACUM_GROUP_INFORMATION,
onSuccess: (response, statusCode) async {
lacumGroupInformation = LacumAccountInformation.fromJson(response);
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: body);
} catch (error) {
throw error;
}
}
Future makeAccountActivate() async {
hasError = false;
super.error = "";
int yahalaAccountNo = lacumInformation.yahalaAccountNo;
Map<String, dynamic> body = Map();
body['CreatedBy'] = 103;
body['YahalaAccountNumber'] = yahalaAccountNo;
try {
await baseAppClient.post(LACUM_ACCOUNT_ACTIVATE,
onSuccess: (response, statusCode) async {
// lacumInformation = LacumAccountInformation.fromJson(response);
// lacumInformation.yahalaAccountNo = yahalaAccountNo;
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: body);
} catch (error) {
throw error;
}
}
Future makeAccountDeactivate() async {
hasError = false;
super.error = "";
int yahalaAccountNo = lacumInformation.yahalaAccountNo;
Map<String, dynamic> body = Map();
body['CreatedBy'] = 103;
body['YahalaAccountNumber'] = yahalaAccountNo;
try {
await baseAppClient.post(LACUM_ACCOUNT_DEACTIVATE,
onSuccess: (response, statusCode) async {
// lacumInformation = LacumAccountInformation.fromJson(response);
// lacumInformation.yahalaAccountNo = yahalaAccountNo;
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: body);
} catch (error) {
throw error;
}
}
Future createLakumAccount(String name, String phone, int accountID, String patientIdentificationID, var prefLang) async {
hasError = false;
super.error = "";
if(prefLang == null){
var languageID =
await sharedPref.getStringWithDefaultValue(APP_LANGUAGE, 'en');
prefLang = languageID == 'ar' ? 1 : 2;
}
Map<String, dynamic> body = Map();
body['PrefLang'] = prefLang;
body['AccountID'] = accountID;
body['FullName'] = name;
body['MobileNo'] = phone;
body['PatientIdentificationID'] = patientIdentificationID;
body['PatientID'] = user.patientID;
try {
await baseAppClient.post(CREATE_LAKUM_ACCOUNT,
onSuccess: (response, statusCode) async {
successMsg = LacumAccountInformation.fromJson(response).message;
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: body);
} catch (error) {
throw error;
}
}
}