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.
PatientApp-KKUMC/lib/core/service/er/am_service.dart

77 lines
2.9 KiB
Dart

import 'package:diplomaticquarterapp/config/config.dart';
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
import 'package:diplomaticquarterapp/core/enum/OrderService.dart';
import 'package:diplomaticquarterapp/core/model/er/PatientAllPresOrders.dart';
import 'package:diplomaticquarterapp/core/model/er/PickUpRequestPresOrder.dart';
import 'package:diplomaticquarterapp/core/model/er/get_all_transportation_method_list_model.dart';
import '../base_service.dart';
class AmService extends BaseService {
List<PatientERTransportationMethod> amModelList = List();
List<PatientAllPresOrders> patientAllPresOrdersList = List();
bool hasPendingOrder = false;
int pendingOrderID = 0;
String pendingOrderStatus = "";
String pendingOrderStatusAR = "";
PickUpRequestPresOrder pickUpRequestPresOrder;
Future getAllTransportationOrders() async {
hasError = false;
Map<String, dynamic> body = Map();
body['isDentalAllowedBackend'] = false;
body['IdentificationNo'] = user.patientIdentificationNo;
await baseAppClient.post(GET_AMBULANCE_REQUEST,
onSuccess: (dynamic response, int statusCode) {
amModelList.clear();
response['PatientER_RRT_GetAllTransportationMethodList'].forEach((item) {
amModelList.add(PatientERTransportationMethod.fromJson(item));
});
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: body);
}
Future getPatientAllPresOrdersList() async {
hasError = false;
hasPendingOrder = false;
await baseAppClient.post(GET_PATIENT_ALL_PRES_ORDERS,
onSuccess: (dynamic response, int statusCode) {
patientAllPresOrdersList.clear();
response['PatientER_GetPatientAllPresOrdersList'].forEach((item) {
if (item['ServiceID'] == OrderService.AMBULANCE.getIdOrderService()) {
var order = PatientAllPresOrders.fromJson(item);
patientAllPresOrdersList.add(order);
if (order.status == 1) {
hasPendingOrder = true;
pendingOrderID = order.iD;
pendingOrderStatus = order.description;
pendingOrderStatusAR = order.descriptionN;
}
}
});
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: Map());
}
Future getOrderDetails() async {
hasError = false;
hasPendingOrder = false;
Map<String, dynamic> body = Map();
body['PresOrderID'] = pendingOrderID;
await baseAppClient.post(GET_PICK_UP_REQUEST_BY_PRES_ORDER_ID,
onSuccess: (dynamic response, int statusCode) {
patientAllPresOrdersList.clear();
response['PatientER_RRT_GetPickUpRequestByPresOrderIDList']
.forEach((item) {
pickUpRequestPresOrder = PickUpRequestPresOrder.fromJson(item);
});
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: Map());
}
}