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.
228 lines
8.8 KiB
Dart
228 lines
8.8 KiB
Dart
import 'package:diplomaticquarterapp/config/config.dart';
|
|
import 'package:diplomaticquarterapp/core/model/labs/LabOrderResult.dart';
|
|
import 'package:diplomaticquarterapp/core/model/labs/lab_result.dart';
|
|
import 'package:diplomaticquarterapp/core/model/labs/patient_lab_orders.dart';
|
|
import 'package:diplomaticquarterapp/core/model/labs/patient_lab_special_result.dart';
|
|
import 'package:diplomaticquarterapp/core/model/labs/request_patient_lab_special_result.dart';
|
|
import 'package:diplomaticquarterapp/core/model/labs/request_send_lab_report_email.dart';
|
|
import 'package:diplomaticquarterapp/core/service/base_service.dart';
|
|
import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart';
|
|
|
|
class LabsService extends BaseService {
|
|
List<PatientLabOrders> patientLabOrdersList = List();
|
|
|
|
String labReportPDF = "";
|
|
|
|
Future getPatientLabOrdersList() async {
|
|
hasError = false;
|
|
Map<String, dynamic> body = Map();
|
|
body['isDentalAllowedBackend'] = false;
|
|
await baseAppClient.post(GET_Patient_LAB_ORDERS, onSuccess: (dynamic response, int statusCode) {
|
|
patientLabOrdersList.clear();
|
|
response['ListPLO'].forEach((hospital) {
|
|
patientLabOrdersList.add(PatientLabOrders.fromJson(hospital));
|
|
});
|
|
}, onFailure: (String error, int statusCode) {
|
|
hasError = true;
|
|
super.error = error;
|
|
}, body: body);
|
|
}
|
|
|
|
RequestPatientLabSpecialResult _requestPatientLabSpecialResult = RequestPatientLabSpecialResult();
|
|
|
|
List<PatientLabSpecialResult> patientLabSpecialResult = List();
|
|
List<LabResult> labResultList = List();
|
|
List<LabOrderResult> labOrdersResultsList = List();
|
|
|
|
Future getLaboratoryResult({String projectID, int clinicID, String invoiceNo, String orderNo, String setupID}) async {
|
|
hasError = false;
|
|
_requestPatientLabSpecialResult.projectID = projectID;
|
|
_requestPatientLabSpecialResult.clinicID = clinicID;
|
|
_requestPatientLabSpecialResult.invoiceNo = invoiceNo;
|
|
_requestPatientLabSpecialResult.orderNo = orderNo;
|
|
_requestPatientLabSpecialResult.setupID = setupID;
|
|
|
|
await baseAppClient.post(GET_Patient_LAB_SPECIAL_RESULT, onSuccess: (dynamic response, int statusCode) {
|
|
patientLabSpecialResult.clear();
|
|
response['ListPLSR'].forEach((hospital) {
|
|
patientLabSpecialResult.add(PatientLabSpecialResult.fromJson(hospital));
|
|
});
|
|
}, onFailure: (String error, int statusCode) {
|
|
hasError = true;
|
|
super.error = error;
|
|
}, body: _requestPatientLabSpecialResult.toJson());
|
|
}
|
|
|
|
Future getPatientLabResult({PatientLabOrders patientLabOrder}) async {
|
|
hasError = false;
|
|
Map<String, dynamic> body = Map();
|
|
body['InvoiceNo'] = patientLabOrder.invoiceNo;
|
|
body['OrderNo'] = patientLabOrder.orderNo;
|
|
body['isDentalAllowedBackend'] = false;
|
|
body['SetupID'] = patientLabOrder.setupID;
|
|
body['ProjectID'] = patientLabOrder.projectID;
|
|
body['ClinicID'] = patientLabOrder.clinicID;
|
|
await baseAppClient.post(GET_Patient_LAB_RESULT, onSuccess: (dynamic response, int statusCode) {
|
|
patientLabSpecialResult.clear();
|
|
labResultList.clear();
|
|
response['ListPLR'].forEach((lab) {
|
|
labResultList.add(LabResult.fromJson(lab));
|
|
});
|
|
}, onFailure: (String error, int statusCode) {
|
|
hasError = true;
|
|
super.error = error;
|
|
}, body: body);
|
|
}
|
|
|
|
Future generateCovidLabReport(LabResult covidLabResult, String isOutsideKSA) async {
|
|
hasError = false;
|
|
Map<String, dynamic> body = Map();
|
|
|
|
body['To'] = user.emailAddress;
|
|
body['OrderNo'] = covidLabResult.orderNo;
|
|
body['OrderLineItemNo'] = covidLabResult.orderLineItemNo;
|
|
body['LineItemNo'] = covidLabResult.resultValueBasedLineItemNo;
|
|
body['CertificateFormat'] = 5;
|
|
body['GeneratedBy'] = 102;
|
|
body['ShowPassportNumber'] = isOutsideKSA;
|
|
body['isDentalAllowedBackend'] = false;
|
|
body['SetupID'] = covidLabResult.setupID;
|
|
body['ProjectID'] = covidLabResult.projectID;
|
|
|
|
dynamic localRes;
|
|
|
|
await baseAppClient.post(SEND_COVID_LAB_RESULT_EMAIL, onSuccess: (dynamic response, int statusCode) {
|
|
localRes = response;
|
|
}, onFailure: (String error, int statusCode) {
|
|
hasError = true;
|
|
super.error = error;
|
|
}, body: body);
|
|
return Future.value(localRes);
|
|
}
|
|
|
|
Future updateCovidPassportNumber(String passportNumber) async {
|
|
hasError = false;
|
|
Map<String, dynamic> body = Map();
|
|
|
|
body['PassportNo'] = passportNumber;
|
|
|
|
dynamic localRes;
|
|
|
|
await baseAppClient.post(COVID_PASSPORT_UPDATE, onSuccess: (dynamic response, int statusCode) {
|
|
localRes = response;
|
|
}, onFailure: (String error, int statusCode) {
|
|
hasError = true;
|
|
super.error = error;
|
|
}, body: body);
|
|
return Future.value(localRes);
|
|
}
|
|
|
|
Future updateWorkplaceName(String workplaceName, String workplaceNameAR, int requestNumber, String setupID, int projectID) async {
|
|
hasError = false;
|
|
Map<String, dynamic> body = Map();
|
|
|
|
body['Placeofwork'] = workplaceName;
|
|
body['Placeofworkar'] = workplaceNameAR;
|
|
body['Req_ID'] = requestNumber;
|
|
body['TargetSetupID'] = setupID;
|
|
body['ProjectID'] = projectID;
|
|
body['UserID'] = 102;
|
|
body['RequestType'] = 1;
|
|
|
|
dynamic localRes;
|
|
|
|
await baseAppClient.post(UPDATE_WORKPLACE_NAME, onSuccess: (dynamic response, int statusCode) {
|
|
localRes = response;
|
|
}, onFailure: (String error, int statusCode) {
|
|
hasError = true;
|
|
super.error = error;
|
|
}, body: body);
|
|
return Future.value(localRes);
|
|
}
|
|
|
|
Future getCovidPassportNumber() async {
|
|
hasError = false;
|
|
Map<String, dynamic> body = Map();
|
|
|
|
dynamic localRes;
|
|
|
|
await baseAppClient.post(GET_PATIENT_PASSPORT_NUMBER, onSuccess: (dynamic response, int statusCode) {
|
|
localRes = response;
|
|
}, onFailure: (String error, int statusCode) {
|
|
hasError = true;
|
|
super.error = error;
|
|
}, body: body);
|
|
return Future.value(localRes);
|
|
}
|
|
|
|
Future getSickLeaveStatusByAdmissionNo(int projectID, int admissionNo) async {
|
|
hasError = false;
|
|
Map<String, dynamic> body = Map();
|
|
|
|
body['AdmissionNo'] = admissionNo;
|
|
body['ProjectID'] = projectID;
|
|
|
|
dynamic localRes;
|
|
|
|
await baseAppClient.post(GET_SICKLEAVE_STATUS_ADMISSION_NO, onSuccess: (dynamic response, int statusCode) {
|
|
localRes = response;
|
|
}, onFailure: (String error, int statusCode) {
|
|
hasError = true;
|
|
super.error = error;
|
|
}, body: body);
|
|
return Future.value(localRes);
|
|
}
|
|
|
|
Future getPatientLabOrdersResults({PatientLabOrders patientLabOrder, String procedure}) async {
|
|
hasError = false;
|
|
Map<String, dynamic> body = Map();
|
|
body['InvoiceNo'] = patientLabOrder.invoiceNo;
|
|
body['OrderNo'] = patientLabOrder.orderNo;
|
|
body['isDentalAllowedBackend'] = false;
|
|
body['SetupID'] = patientLabOrder.setupID;
|
|
body['ProjectID'] = patientLabOrder.projectID;
|
|
body['ClinicID'] = patientLabOrder.clinicID;
|
|
body['Procedure'] = procedure;
|
|
await baseAppClient.post(GET_Patient_LAB_ORDERS_RESULT, onSuccess: (dynamic response, int statusCode) {
|
|
labOrdersResultsList.clear();
|
|
response['ListPLR'].forEach((lab) {
|
|
labOrdersResultsList.add(LabOrderResult.fromJson(lab));
|
|
});
|
|
}, onFailure: (String error, int statusCode) {
|
|
hasError = true;
|
|
super.error = error;
|
|
}, body: body);
|
|
}
|
|
|
|
RequestSendLabReportEmail _requestSendLabReportEmail = RequestSendLabReportEmail();
|
|
|
|
Future sendLabReportEmail({PatientLabOrders patientLabOrder, AuthenticatedUser userObj, bool isDownload = false}) async {
|
|
_requestSendLabReportEmail.projectID = patientLabOrder.projectID;
|
|
_requestSendLabReportEmail.invoiceNo = patientLabOrder.invoiceNo;
|
|
_requestSendLabReportEmail.doctorName = patientLabOrder.doctorName;
|
|
_requestSendLabReportEmail.clinicName = patientLabOrder.clinicDescription;
|
|
_requestSendLabReportEmail.patientName = userObj.firstName + " " + userObj.lastName;
|
|
_requestSendLabReportEmail.patientIditificationNum = userObj.patientIdentificationNo;
|
|
_requestSendLabReportEmail.dateofBirth = userObj.dateofBirth;
|
|
_requestSendLabReportEmail.to = userObj.emailAddress;
|
|
_requestSendLabReportEmail.orderDate = '${patientLabOrder.orderDate.year}-${patientLabOrder.orderDate.month}-${patientLabOrder.orderDate.day}';
|
|
_requestSendLabReportEmail.patientMobileNumber = userObj.mobileNumber;
|
|
_requestSendLabReportEmail.projectName = patientLabOrder.projectName;
|
|
_requestSendLabReportEmail.setupID = patientLabOrder.setupID;
|
|
_requestSendLabReportEmail.orderNo = patientLabOrder.orderNo;
|
|
_requestSendLabReportEmail.isDownload = isDownload;
|
|
_requestSendLabReportEmail.doctorID = patientLabOrder.doctorID;
|
|
|
|
await baseAppClient.post(SEND_LAB_RESULT_EMAIL, onSuccess: (dynamic response, int statusCode) {
|
|
|
|
if(isDownload) {
|
|
labReportPDF = response['LabReportsPDFContent'];
|
|
}
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
hasError = true;
|
|
super.error = error;
|
|
}, body: _requestSendLabReportEmail.toJson());
|
|
}
|
|
}
|