From 1bbbd18373d1a1fdaceb615a1ccbf41a3f43f718 Mon Sep 17 00:00:00 2001 From: Mohammad Aljammal Date: Thu, 6 Aug 2020 09:29:29 +0300 Subject: [PATCH] labs services --- lib/config/config.dart | 12 ++ lib/core/model/labs/patient_lab_orders.dart | 156 ++++++++++++++++++ .../labs/patient_lab_special_result.dart | 32 ++++ .../labs/request_patient_lab_orders.dart | 64 +++++++ .../request_patient_lab_special_result.dart | 84 ++++++++++ .../labs/request_send_lab_report_email.dart | 112 +++++++++++++ lib/core/service/client/base_app_client.dart | 15 ++ lib/core/service/medical/labs_service.dart | 106 ++++++++++++ .../viewModels/medical/labs_view_model.dart | 110 ++++++++++++ lib/locator.dart | 5 + .../medical/doctor/doctor_profile_page.dart | 2 +- .../medical/labs/laboratory_result_page.dart | 39 +++++ lib/pages/medical/labs/labs_home_page.dart | 104 ++++++++++++ lib/pages/medical/medical_profile_page.dart | 5 +- .../medical/laboratory_result_widget.dart | 143 ++++++++++++++++ 15 files changed, 985 insertions(+), 4 deletions(-) create mode 100644 lib/core/model/labs/patient_lab_orders.dart create mode 100644 lib/core/model/labs/patient_lab_special_result.dart create mode 100644 lib/core/model/labs/request_patient_lab_orders.dart create mode 100644 lib/core/model/labs/request_patient_lab_special_result.dart create mode 100644 lib/core/model/labs/request_send_lab_report_email.dart create mode 100644 lib/core/service/medical/labs_service.dart create mode 100644 lib/core/viewModels/medical/labs_view_model.dart create mode 100644 lib/pages/medical/labs/laboratory_result_page.dart create mode 100644 lib/pages/medical/labs/labs_home_page.dart create mode 100644 lib/widgets/data_display/medical/laboratory_result_widget.dart diff --git a/lib/config/config.dart b/lib/config/config.dart index 1908ee0b..eb84904f 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -21,6 +21,10 @@ const GET_PRESCRIPTION_REPORT = '/Patients.svc/REST/INP_GetPrescriptionReport' const GET_PRESCRIPTION_REPORT_ENH = '/Patients.svc/REST/GetPrescriptionReport_enh'; const SEND_PRESCRIPTION_EMAIL = '/Notifications.svc/REST/SendPrescriptionEmail'; +///Lab Order +const GET_Patient_LAB_ORDERS = '/Patients.svc/REST/GetPatientLabOrders'; +const GET_Patient_LAB_SPECIAL_RESULT = '/Patients.svc/REST/GetPatientLabSpecialResults'; + //const BASE_URL = 'https://hmgwebservices.com/'; // Production Environment //const BASE_URL = 'https://uat.hmgwebservices.com/Services'; // UAT Environment @@ -34,6 +38,14 @@ const CHANNEL = 3; const GENERAL_ID = 'Cs2020@2016\$2958'; const IP_ADDRESS = '10.20.10.20'; const VERSION_ID = 5.5; +const SETUP_ID = '91877'; +const LANGUAGE = 1; +const PATIENT_OUT_SA = 0; +const SESSION_ID = 'TMRhVmkGhOsvamErw'; +const IS_DENTAL_ALLOWED_BACKEND = false; +const PATIENT_TYPE = 1; +const PATIENT_TYPE_ID = 1; + var DeviceTypeID = Platform.isIOS ? 1 : 2; const GET_PHARMCY_ITEMS = "/Lists.svc/REST/GetPharmcyItems_Region"; diff --git a/lib/core/model/labs/patient_lab_orders.dart b/lib/core/model/labs/patient_lab_orders.dart new file mode 100644 index 00000000..26daaff0 --- /dev/null +++ b/lib/core/model/labs/patient_lab_orders.dart @@ -0,0 +1,156 @@ +import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; + +class PatientLabOrders { + int actualDoctorRate; + String clinicDescription; + String clinicDescriptionEnglish; + Null clinicDescriptionN; + int clinicID; + int doctorID; + String doctorImageURL; + String doctorName; + String doctorNameEnglish; + Null doctorNameN; + int doctorRate; + String doctorTitle; + int gender; + String genderDescription; + String invoiceNo; + bool isActiveDoctorProfile; + bool isDoctorAllowVedioCall; + bool isExecludeDoctor; + bool isInOutPatient; + String isInOutPatientDescription; + String isInOutPatientDescriptionN; + bool isRead; + String nationalityFlagURL; + int noOfPatientsRate; + DateTime orderDate; + String orderNo; + String patientID; + String projectID; + String projectName; + Null projectNameN; + String qR; + String setupID; + List speciality; + + PatientLabOrders( + {this.actualDoctorRate, + this.clinicDescription, + this.clinicDescriptionEnglish, + this.clinicDescriptionN, + this.clinicID, + this.doctorID, + this.doctorImageURL, + this.doctorName, + this.doctorNameEnglish, + this.doctorNameN, + this.doctorRate, + this.doctorTitle, + this.gender, + this.genderDescription, + this.invoiceNo, + this.isActiveDoctorProfile, + this.isDoctorAllowVedioCall, + this.isExecludeDoctor, + this.isInOutPatient, + this.isInOutPatientDescription, + this.isInOutPatientDescriptionN, + this.isRead, + this.nationalityFlagURL, + this.noOfPatientsRate, + this.orderDate, + this.orderNo, + this.patientID, + this.projectID, + this.projectName, + this.projectNameN, + this.qR, + this.setupID, + this.speciality}); + + PatientLabOrders.fromJson(Map json) { + actualDoctorRate = json['ActualDoctorRate']; + clinicDescription = json['ClinicDescription']; + clinicDescriptionEnglish = json['ClinicDescriptionEnglish']; + clinicDescriptionN = json['ClinicDescriptionN']; + clinicID = json['ClinicID']; + doctorID = json['DoctorID']; + doctorImageURL = json['DoctorImageURL']; + doctorName = json['DoctorName']; + doctorNameEnglish = json['DoctorNameEnglish']; + doctorNameN = json['DoctorNameN']; + doctorRate = json['DoctorRate']; + doctorTitle = json['DoctorTitle']; + gender = json['Gender']; + genderDescription = json['GenderDescription']; + invoiceNo = json['InvoiceNo']; + isActiveDoctorProfile = json['IsActiveDoctorProfile']; + isDoctorAllowVedioCall = json['IsDoctorAllowVedioCall']; + isExecludeDoctor = json['IsExecludeDoctor']; + isInOutPatient = json['IsInOutPatient']; + isInOutPatientDescription = json['IsInOutPatientDescription']; + isInOutPatientDescriptionN = json['IsInOutPatientDescriptionN']; + isRead = json['IsRead']; + nationalityFlagURL = json['NationalityFlagURL']; + noOfPatientsRate = json['NoOfPatientsRate']; + orderDate = DateUtil.convertStringToDate(json['OrderDate']); + orderNo = json['OrderNo']; + patientID = json['PatientID']; + projectID = json['ProjectID']; + projectName = json['ProjectName']; + projectNameN = json['ProjectNameN']; + qR = json['QR']; + setupID = json['SetupID']; + // speciality = json['Speciality'].cast(); + } + + Map toJson() { + final Map data = new Map(); + data['ActualDoctorRate'] = this.actualDoctorRate; + data['ClinicDescription'] = this.clinicDescription; + data['ClinicDescriptionEnglish'] = this.clinicDescriptionEnglish; + data['ClinicDescriptionN'] = this.clinicDescriptionN; + data['ClinicID'] = this.clinicID; + data['DoctorID'] = this.doctorID; + data['DoctorImageURL'] = this.doctorImageURL; + data['DoctorName'] = this.doctorName; + data['DoctorNameEnglish'] = this.doctorNameEnglish; + data['DoctorNameN'] = this.doctorNameN; + data['DoctorRate'] = this.doctorRate; + data['DoctorTitle'] = this.doctorTitle; + data['Gender'] = this.gender; + data['GenderDescription'] = this.genderDescription; + data['InvoiceNo'] = this.invoiceNo; + data['IsActiveDoctorProfile'] = this.isActiveDoctorProfile; + data['IsDoctorAllowVedioCall'] = this.isDoctorAllowVedioCall; + data['IsExecludeDoctor'] = this.isExecludeDoctor; + data['IsInOutPatient'] = this.isInOutPatient; + data['IsInOutPatientDescription'] = this.isInOutPatientDescription; + data['IsInOutPatientDescriptionN'] = this.isInOutPatientDescriptionN; + data['IsRead'] = this.isRead; + data['NationalityFlagURL'] = this.nationalityFlagURL; + data['NoOfPatientsRate'] = this.noOfPatientsRate; + data['OrderDate'] = this.orderDate; + data['OrderNo'] = this.orderNo; + data['PatientID'] = this.patientID; + data['ProjectID'] = this.projectID; + data['ProjectName'] = this.projectName; + data['ProjectNameN'] = this.projectNameN; + data['QR'] = this.qR; + data['SetupID'] = this.setupID; + data['Speciality'] = this.speciality; + return data; + } +} + +class PatientLabOrdersList { + String filterName = ""; + List patientLabOrdersList = List(); + + PatientLabOrdersList( + {this.filterName, PatientLabOrders patientDoctorAppointment}) { + patientLabOrdersList.add(patientDoctorAppointment); + } +} diff --git a/lib/core/model/labs/patient_lab_special_result.dart b/lib/core/model/labs/patient_lab_special_result.dart new file mode 100644 index 00000000..2fbcb832 --- /dev/null +++ b/lib/core/model/labs/patient_lab_special_result.dart @@ -0,0 +1,32 @@ +class PatientLabSpecialResult { + String invoiceNo; + String moduleID; + String resultData; + String resultDataHTML; + Null resultDataTxt; + + PatientLabSpecialResult( + {this.invoiceNo, + this.moduleID, + this.resultData, + this.resultDataHTML, + this.resultDataTxt}); + + PatientLabSpecialResult.fromJson(Map json) { + invoiceNo = json['InvoiceNo']; + moduleID = json['ModuleID']; + resultData = json['ResultData']; + resultDataHTML = json['ResultDataHTML']; + resultDataTxt = json['ResultDataTxt']; + } + + Map toJson() { + final Map data = new Map(); + data['InvoiceNo'] = this.invoiceNo; + data['ModuleID'] = this.moduleID; + data['ResultData'] = this.resultData; + data['ResultDataHTML'] = this.resultDataHTML; + data['ResultDataTxt'] = this.resultDataTxt; + return data; + } +} diff --git a/lib/core/model/labs/request_patient_lab_orders.dart b/lib/core/model/labs/request_patient_lab_orders.dart new file mode 100644 index 00000000..ce9263ef --- /dev/null +++ b/lib/core/model/labs/request_patient_lab_orders.dart @@ -0,0 +1,64 @@ +class RequestPatientLabOrders { + double versionID; + int channel; + int languageID; + String iPAdress; + String generalid; + int patientOutSA; + String sessionID; + bool isDentalAllowedBackend; + int deviceTypeID; + int patientID; + String tokenID; + int patientTypeID; + int patientType; + + RequestPatientLabOrders( + {this.versionID, + this.channel, + this.languageID, + this.iPAdress, + this.generalid, + this.patientOutSA, + this.sessionID, + this.isDentalAllowedBackend, + this.deviceTypeID, + this.patientID, + this.tokenID, + this.patientTypeID, + this.patientType}); + + RequestPatientLabOrders.fromJson(Map json) { + versionID = json['VersionID']; + channel = json['Channel']; + languageID = json['LanguageID']; + iPAdress = json['IPAdress']; + generalid = json['generalid']; + patientOutSA = json['PatientOutSA']; + sessionID = json['SessionID']; + isDentalAllowedBackend = json['isDentalAllowedBackend']; + deviceTypeID = json['DeviceTypeID']; + patientID = json['PatientID']; + tokenID = json['TokenID']; + patientTypeID = json['PatientTypeID']; + patientType = json['PatientType']; + } + + Map toJson() { + final Map data = new Map(); + data['VersionID'] = this.versionID; + data['Channel'] = this.channel; + data['LanguageID'] = this.languageID; + data['IPAdress'] = this.iPAdress; + data['generalid'] = this.generalid; + data['PatientOutSA'] = this.patientOutSA; + data['SessionID'] = this.sessionID; + data['isDentalAllowedBackend'] = this.isDentalAllowedBackend; + data['DeviceTypeID'] = this.deviceTypeID; + data['PatientID'] = this.patientID; + data['TokenID'] = this.tokenID; + data['PatientTypeID'] = this.patientTypeID; + data['PatientType'] = this.patientType; + return data; + } +} diff --git a/lib/core/model/labs/request_patient_lab_special_result.dart b/lib/core/model/labs/request_patient_lab_special_result.dart new file mode 100644 index 00000000..bdeb3930 --- /dev/null +++ b/lib/core/model/labs/request_patient_lab_special_result.dart @@ -0,0 +1,84 @@ +class RequestPatientLabSpecialResult { + String invoiceNo; + String orderNo; + String setupID; + String projectID; + int clinicID; + double versionID; + int channel; + int languageID; + String iPAdress; + String generalid; + int patientOutSA; + String sessionID; + bool isDentalAllowedBackend; + int deviceTypeID; + int patientID; + String tokenID; + int patientTypeID; + int patientType; + + RequestPatientLabSpecialResult( + {this.invoiceNo, + this.orderNo, + this.setupID, + this.projectID, + this.clinicID, + this.versionID, + this.channel, + this.languageID, + this.iPAdress, + this.generalid, + this.patientOutSA, + this.sessionID, + this.isDentalAllowedBackend, + this.deviceTypeID, + this.patientID, + this.tokenID, + this.patientTypeID, + this.patientType}); + + RequestPatientLabSpecialResult.fromJson(Map json) { + invoiceNo = json['InvoiceNo']; + orderNo = json['OrderNo']; + setupID = json['SetupID']; + projectID = json['ProjectID']; + clinicID = json['ClinicID']; + versionID = json['VersionID']; + channel = json['Channel']; + languageID = json['LanguageID']; + iPAdress = json['IPAdress']; + generalid = json['generalid']; + patientOutSA = json['PatientOutSA']; + sessionID = json['SessionID']; + isDentalAllowedBackend = json['isDentalAllowedBackend']; + deviceTypeID = json['DeviceTypeID']; + patientID = json['PatientID']; + tokenID = json['TokenID']; + patientTypeID = json['PatientTypeID']; + patientType = json['PatientType']; + } + + Map toJson() { + final Map data = new Map(); + data['InvoiceNo'] = this.invoiceNo; + data['OrderNo'] = this.orderNo; + data['SetupID'] = this.setupID; + data['ProjectID'] = this.projectID; + data['ClinicID'] = this.clinicID; + data['VersionID'] = this.versionID; + data['Channel'] = this.channel; + data['LanguageID'] = this.languageID; + data['IPAdress'] = this.iPAdress; + data['generalid'] = this.generalid; + data['PatientOutSA'] = this.patientOutSA; + data['SessionID'] = this.sessionID; + data['isDentalAllowedBackend'] = this.isDentalAllowedBackend; + data['DeviceTypeID'] = this.deviceTypeID; + data['PatientID'] = this.patientID; + data['TokenID'] = this.tokenID; + data['PatientTypeID'] = this.patientTypeID; + data['PatientType'] = this.patientType; + return data; + } +} diff --git a/lib/core/model/labs/request_send_lab_report_email.dart b/lib/core/model/labs/request_send_lab_report_email.dart new file mode 100644 index 00000000..118da906 --- /dev/null +++ b/lib/core/model/labs/request_send_lab_report_email.dart @@ -0,0 +1,112 @@ +class RequestSendLabReportEmail { + double versionID; + int channel; + int languageID; + String iPAdress; + String generalid; + int patientOutSA; + String sessionID; + bool isDentalAllowedBackend; + int deviceTypeID; + int patientID; + String tokenID; + int patientTypeID; + int patientType; + String to; + String dateofBirth; + String patientIditificationNum; + String patientMobileNumber; + String patientName; + String setupID; + String projectName; + String clinicName; + String doctorName; + String projectID; + String invoiceNo; + String orderDate; + + RequestSendLabReportEmail( + {this.versionID, + this.channel, + this.languageID, + this.iPAdress, + this.generalid, + this.patientOutSA, + this.sessionID, + this.isDentalAllowedBackend, + this.deviceTypeID, + this.patientID, + this.tokenID, + this.patientTypeID, + this.patientType, + this.to, + this.dateofBirth, + this.patientIditificationNum, + this.patientMobileNumber, + this.patientName, + this.setupID, + this.projectName, + this.clinicName, + this.doctorName, + this.projectID, + this.invoiceNo, + this.orderDate}); + + RequestSendLabReportEmail.fromJson(Map json) { + versionID = json['VersionID']; + channel = json['Channel']; + languageID = json['LanguageID']; + iPAdress = json['IPAdress']; + generalid = json['generalid']; + patientOutSA = json['PatientOutSA']; + sessionID = json['SessionID']; + isDentalAllowedBackend = json['isDentalAllowedBackend']; + deviceTypeID = json['DeviceTypeID']; + patientID = json['PatientID']; + tokenID = json['TokenID']; + patientTypeID = json['PatientTypeID']; + patientType = json['PatientType']; + to = json['To']; + dateofBirth = json['DateofBirth']; + patientIditificationNum = json['PatientIditificationNum']; + patientMobileNumber = json['PatientMobileNumber']; + patientName = json['PatientName']; + setupID = json['SetupID']; + projectName = json['ProjectName']; + clinicName = json['ClinicName']; + doctorName = json['DoctorName']; + projectID = json['ProjectID']; + invoiceNo = json['InvoiceNo']; + orderDate = json['OrderDate']; + } + + Map toJson() { + final Map data = new Map(); + data['VersionID'] = this.versionID; + data['Channel'] = this.channel; + data['LanguageID'] = this.languageID; + data['IPAdress'] = this.iPAdress; + data['generalid'] = this.generalid; + data['PatientOutSA'] = this.patientOutSA; + data['SessionID'] = this.sessionID; + data['isDentalAllowedBackend'] = this.isDentalAllowedBackend; + data['DeviceTypeID'] = this.deviceTypeID; + data['PatientID'] = this.patientID; + data['TokenID'] = this.tokenID; + data['PatientTypeID'] = this.patientTypeID; + data['PatientType'] = this.patientType; + data['To'] = this.to; + data['DateofBirth'] = this.dateofBirth; + data['PatientIditificationNum'] = this.patientIditificationNum; + data['PatientMobileNumber'] = this.patientMobileNumber; + data['PatientName'] = this.patientName; + data['SetupID'] = this.setupID; + data['ProjectName'] = this.projectName; + data['ClinicName'] = this.clinicName; + data['DoctorName'] = this.doctorName; + data['ProjectID'] = this.projectID; + data['InvoiceNo'] = this.invoiceNo; + data['OrderDate'] = this.orderDate; + return data; + } +} diff --git a/lib/core/service/client/base_app_client.dart b/lib/core/service/client/base_app_client.dart index c48c3e3f..2fd551b0 100644 --- a/lib/core/service/client/base_app_client.dart +++ b/lib/core/service/client/base_app_client.dart @@ -25,6 +25,21 @@ class BaseAppClient { //Map profile = await sharedPref.getObj(DOCTOR_PROFILE); // String token = await sharedPref.getString(TOKEN); + body['SetupID'] = SETUP_ID; + body['VersionID'] = VERSION_ID; + body['Channel'] = CHANNEL; + body['LanguageID'] = LANGUAGE; + body['IPAdress'] = IP_ADDRESS; + body['generalid'] = GENERAL_ID; + body['PatientOutSA'] = PATIENT_OUT_SA; + body['SessionID'] = SESSION_ID; + body['isDentalAllowedBackend'] = IS_DENTAL_ALLOWED_BACKEND; + body['DeviceTypeID'] = DeviceTypeID; + body['PatientType'] = PATIENT_TYPE; + body['PatientTypeID'] = PATIENT_TYPE_ID; + body['TokenID'] = '@dm!n'; + body['PatientID'] = 1231755; + print("URL : $url"); print("Body : ${json.encode(body)}"); diff --git a/lib/core/service/medical/labs_service.dart b/lib/core/service/medical/labs_service.dart new file mode 100644 index 00000000..1f924372 --- /dev/null +++ b/lib/core/service/medical/labs_service.dart @@ -0,0 +1,106 @@ +import 'package:diplomaticquarterapp/config/config.dart'; +import 'package:diplomaticquarterapp/core/model/doctor/doctor_profile.dart'; +import 'package:diplomaticquarterapp/core/model/doctor/doctor_rating.dart'; +import 'package:diplomaticquarterapp/core/model/doctor/patient_doctor_appointment.dart'; +import 'package:diplomaticquarterapp/core/model/doctor/reques_patient_doctor_appointmentt.dart'; +import 'package:diplomaticquarterapp/core/model/doctor/request_doctor_profile.dart'; +import 'package:diplomaticquarterapp/core/model/doctor/request_doctor_rating.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_orders.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/uitl/app_toast.dart'; + +class LabsService extends BaseService { + + + RequestPatientLabOrders _requestPatientLabOrders = RequestPatientLabOrders( + versionID: 5.5, + channel: 3, + languageID: 2, + iPAdress: '10.20.10.20', + generalid: 'Cs2020@2016\$2958', + patientOutSA: 0, + sessionID: 'TMRhVmkGhOsvamErw', + isDentalAllowedBackend: false, + deviceTypeID: 1, + patientID: 1231755, + tokenID: '@dm!n', + patientType: 1, + patientTypeID: 1 + + ); + List patientLabOrdersList = List(); + + + Future getPatientLabOrdersList() async { + 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: _requestPatientLabOrders.toJson()); + } + + + RequestPatientLabSpecialResult _requestPatientLabSpecialResult = RequestPatientLabSpecialResult(); + + + List patientLabSpecialResult = List(); + + Future getLaboratoryResult( + {String projectID, int clinicID, String invoiceNo, String orderNo}) async { + hasError = false; + _requestPatientLabSpecialResult.projectID = projectID; + _requestPatientLabSpecialResult.clinicID = clinicID; + _requestPatientLabSpecialResult.invoiceNo = invoiceNo;//'1800296522';//; + _requestPatientLabSpecialResult.orderNo = orderNo; + + 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()); + } + + RequestSendLabReportEmail _requestSendLabReportEmail = RequestSendLabReportEmail(); + + Future sendLabReportEmail( + {PatientLabOrders patientLabOrder}) async { + + _requestSendLabReportEmail.projectID = patientLabOrder.projectID; + _requestSendLabReportEmail.invoiceNo = patientLabOrder.invoiceNo; + _requestSendLabReportEmail.doctorName = patientLabOrder.doctorName; + _requestSendLabReportEmail.clinicName = patientLabOrder.clinicDescription; + _requestSendLabReportEmail.patientName = 'Tamer';//TODO Change it + _requestSendLabReportEmail.patientIditificationNum = '2344670985';//TODO change it + _requestSendLabReportEmail.dateofBirth = '/Date(536743800000+0300)/';//TODO change it + _requestSendLabReportEmail.to = 'Tamer.fanasheh@gmail.com';//TODO change it + _requestSendLabReportEmail.orderDate = '${patientLabOrder.orderDate.year}-${patientLabOrder.orderDate.month}-${patientLabOrder.orderDate.day}'; + _requestSendLabReportEmail.patientMobileNumber = '537503378';//TODO change it + _requestSendLabReportEmail.projectName = patientLabOrder.projectName; + + await baseAppClient.post(GET_Patient_LAB_SPECIAL_RESULT, + onSuccess: (dynamic response, int statusCode) { + AppToast.showSuccessToast(message: 'A copy has been sent to the email'); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: _requestSendLabReportEmail.toJson()); + } + + +} diff --git a/lib/core/viewModels/medical/labs_view_model.dart b/lib/core/viewModels/medical/labs_view_model.dart new file mode 100644 index 00000000..260870ac --- /dev/null +++ b/lib/core/viewModels/medical/labs_view_model.dart @@ -0,0 +1,110 @@ + +import 'package:diplomaticquarterapp/core/enum/filter_type.dart'; +import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; +import 'package:diplomaticquarterapp/core/model/doctor/doctor_profile.dart'; +import 'package:diplomaticquarterapp/core/model/doctor/doctor_rating.dart'; +import 'package:diplomaticquarterapp/core/model/doctor/patient_doctor_appointment.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/service/medical/labs_service.dart'; +import 'package:diplomaticquarterapp/core/service/medical/my_doctor_service.dart'; + +import '../../../locator.dart'; +import '../base_view_model.dart'; + +class LabsViewModel extends BaseViewModel { + FilterType filterType = FilterType.Clinic; + LabsService _labsService = locator(); + + List _patientLabOrdersListClinic = List(); + List _patientLabOrdersListHospital = List(); + + List get patientLabOrdersList => + filterType == FilterType.Clinic + ? _patientLabOrdersListClinic + : _patientLabOrdersListHospital; + + void getLabs() async { + setState(ViewState.Busy); + await _labsService.getPatientLabOrdersList(); + if (_labsService.hasError) { + error = _labsService.error; + setState(ViewState.Error); + } else { + _labsService.patientLabOrdersList.forEach((element) { + List patientLabOrdersClinic = + _patientLabOrdersListClinic + .where((elementClinic) => + elementClinic.filterName == element.clinicDescription) + .toList(); + + if (patientLabOrdersClinic.length != 0) { + _patientLabOrdersListClinic[_patientLabOrdersListClinic + .indexOf(patientLabOrdersClinic[0])] + .patientLabOrdersList + .add(element); + } else { + _patientLabOrdersListClinic.add(PatientLabOrdersList( + filterName: element.clinicDescription, + patientDoctorAppointment: element)); + } + + // doctor list sort via project + List patientLabOrdersHospital = + _patientLabOrdersListHospital + .where( + (elementClinic) => + elementClinic.filterName == element.projectName, + ) + .toList(); + + if (patientLabOrdersHospital.length != 0) { + _patientLabOrdersListHospital[_patientLabOrdersListHospital + .indexOf(patientLabOrdersHospital[0])] + .patientLabOrdersList + .add(element); + } else { + _patientLabOrdersListHospital.add(PatientLabOrdersList( + filterName: element.projectName, + patientDoctorAppointment: element)); + } + }); + + setState(ViewState.Idle); + } + } + + setFilterType(FilterType filterType) { + this.filterType = filterType; + notifyListeners(); + } + + List get patientLabSpecialResult => + _labsService.patientLabSpecialResult; + + getLaboratoryResult( + {String projectID, + int clinicID, + String invoiceNo, + String orderNo}) async { + setState(ViewState.Busy); + await _labsService.getLaboratoryResult(invoiceNo: invoiceNo,orderNo: orderNo,projectID: projectID,clinicID: clinicID); + if (_labsService.hasError) { + error = _labsService.error; + setState(ViewState.Error); + } else { + setState(ViewState.Idle); + } + } + + sendLabReportEmail({PatientLabOrders patientLabOrder}) async { + setState(ViewState.Busy); + await _labsService.sendLabReportEmail(patientLabOrder: patientLabOrder); + if (_labsService.hasError) { + error = _labsService.error; + setState(ViewState.Error); + } else { + setState(ViewState.Idle); + } + } +} diff --git a/lib/locator.dart b/lib/locator.dart index c1a2a170..44b3bf27 100644 --- a/lib/locator.dart +++ b/lib/locator.dart @@ -1,9 +1,11 @@ import 'package:get_it/get_it.dart'; import 'core/service/hospital_service.dart'; +import 'core/service/medical/labs_service.dart'; import 'core/service/medical/my_doctor_service.dart'; import 'core/service/medical/prescriptions_service.dart'; import 'core/viewModels/hospital_view_model.dart'; +import 'core/viewModels/medical/labs_view_model.dart'; import 'core/viewModels/medical/my_doctor_view_model.dart'; import 'core/viewModels/medical/prescriptions_view_model.dart'; import 'core/viewModels/pharmacies_view_model.dart'; @@ -18,10 +20,13 @@ void setupLocator() { locator.registerLazySingleton(() => PharmacyService()); locator.registerLazySingleton(() => MyDoctorService()); locator.registerLazySingleton(() => PrescriptionsService()); + locator.registerLazySingleton(() => LabsService()); /// View Model locator.registerFactory(() => HospitalViewModel()); locator.registerFactory(() => PharmacyViewModel()); locator.registerFactory(() => MyDoctorViewModel()); locator.registerFactory(() => PrescriptionsViewModel()); + locator.registerFactory(() => LabsViewModel()); + } diff --git a/lib/pages/medical/doctor/doctor_profile_page.dart b/lib/pages/medical/doctor/doctor_profile_page.dart index 61bfd804..79f8c69e 100644 --- a/lib/pages/medical/doctor/doctor_profile_page.dart +++ b/lib/pages/medical/doctor/doctor_profile_page.dart @@ -117,7 +117,7 @@ class _DoctorProfilePageState extends State alignment: Alignment.center, child: RatingBar.readOnly( initialRating: - model.doctorRating.doctorRate.toDouble() ?? + model.doctorRating.doctorRate?.toDouble() ?? 0.0, size: 35.0, filledColor: Colors.yellow[700], diff --git a/lib/pages/medical/labs/laboratory_result_page.dart b/lib/pages/medical/labs/laboratory_result_page.dart new file mode 100644 index 00000000..216b8adb --- /dev/null +++ b/lib/pages/medical/labs/laboratory_result_page.dart @@ -0,0 +1,39 @@ +import 'package:diplomaticquarterapp/core/model/labs/patient_lab_orders.dart'; +import 'package:diplomaticquarterapp/core/viewModels/medical/labs_view_model.dart'; +import 'package:diplomaticquarterapp/pages/base/base_view.dart'; +import 'package:diplomaticquarterapp/widgets/data_display/medical/laboratory_result_widget.dart'; +import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +class LaboratoryResultPage extends StatelessWidget { + final PatientLabOrders patientLabOrders; + + LaboratoryResultPage({Key key, this.patientLabOrders}); + + @override + Widget build(BuildContext context) { + return BaseView( + onModelReady: (model) => model.getLaboratoryResult( + invoiceNo: patientLabOrders.invoiceNo, + clinicID: patientLabOrders.clinicID, + projectID: patientLabOrders.projectID, + orderNo: patientLabOrders.orderNo), + builder: (_, model, widget) => AppScaffold( + isShowAppBar: true, + appBarTitle: 'Laboratory result', + baseViewModel: model, + body: Scaffold( + body: ListView.builder( + itemBuilder: (context, index) => LaboratoryResultWidget( + onTap: () => model.sendLabReportEmail(patientLabOrder: patientLabOrders), + billNo: model.patientLabSpecialResult[index].invoiceNo, + details: model.patientLabSpecialResult[index].resultDataHTML, + ), + itemCount: model.patientLabSpecialResult.length, + ), + ), + ), + ); + } +} diff --git a/lib/pages/medical/labs/labs_home_page.dart b/lib/pages/medical/labs/labs_home_page.dart new file mode 100644 index 00000000..00cd82a1 --- /dev/null +++ b/lib/pages/medical/labs/labs_home_page.dart @@ -0,0 +1,104 @@ +import 'package:diplomaticquarterapp/core/enum/filter_type.dart'; +import 'package:diplomaticquarterapp/core/viewModels/medical/labs_view_model.dart'; +import 'package:diplomaticquarterapp/pages/base/base_view.dart'; +import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; +import 'package:diplomaticquarterapp/widgets/data_display/medical/doctor_card.dart'; +import 'package:diplomaticquarterapp/widgets/others/app_expandable_notifier.dart'; +import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +import 'laboratory_result_page.dart'; + +class LabsHomePage extends StatelessWidget { + @override + Widget build(BuildContext context) { + return BaseView( + onModelReady: (model) => model.getLabs(), + builder: (context, LabsViewModel model, widget) => AppScaffold( + baseViewModel: model, + isShowAppBar: true, + appBarTitle: 'Lab Orders', + body: SingleChildScrollView( + physics: BouncingScrollPhysics(), + child: FractionallySizedBox( + widthFactor: 1.0, + child: Center( + child: Column( + children: [ + Row( + children: [ + Expanded( + flex: 1, + child: InkWell( + onTap: () => model.setFilterType(FilterType.Clinic), + child: ListTile( + title: const Text('Clinic'), + leading: Radio( + value: FilterType.Clinic, + groupValue: model.filterType, + activeColor: Colors.red[800], + onChanged: (FilterType value) { + model.setFilterType(value); + }, + ), + ), + ), + ), + Expanded( + flex: 1, + child: InkWell( + onTap: () => model.setFilterType(FilterType.Hospital), + child: ListTile( + title: const Text('Hospital'), + leading: Radio( + value: FilterType.Hospital, + groupValue: model.filterType, + activeColor: Colors.red[800], + onChanged: (FilterType value) => + model.setFilterType(value), + ), + ), + ), + ) + ], + ), + ...List.generate( + model.patientLabOrdersList.length, + (index) => AppExpandableNotifier( + title: model.patientLabOrdersList[index].filterName, + bodyWidget: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: model + .patientLabOrdersList[index].patientLabOrdersList + .map((labOrder) { + return DoctorCard( + onTap: () => Navigator.push( + context, + FadePage( + page: LaboratoryResultPage( + patientLabOrders: labOrder, + ), + ), + ), + name: labOrder.doctorName, + profileUrl: labOrder.doctorImageURL, + subName: 'Bill No : ${labOrder.invoiceNo}', + date: DateUtil.getMonthDayYearDateFormatted( + labOrder.orderDate), + ); + }).toList(), + ), + ), + ) + ], + ), + ), + ), + ), + ), + ); + } +} diff --git a/lib/pages/medical/medical_profile_page.dart b/lib/pages/medical/medical_profile_page.dart index ceacaed4..68df6558 100644 --- a/lib/pages/medical/medical_profile_page.dart +++ b/lib/pages/medical/medical_profile_page.dart @@ -9,6 +9,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'doctor/doctor_home_page.dart'; +import 'labs/labs_home_page.dart'; class MedicalProfilePage extends StatefulWidget { @override @@ -60,9 +61,7 @@ class _MedicalProfilePageState extends State { Expanded( flex: 1, child: InkWell( - onTap: (){ - - }, + onTap: ()=> Navigator.push(context, FadePage(page: LabsHomePage())), child: MedicalProfileItem( title: 'Lab', imagePath: 'lab_result_icon.png', diff --git a/lib/widgets/data_display/medical/laboratory_result_widget.dart b/lib/widgets/data_display/medical/laboratory_result_widget.dart new file mode 100644 index 00000000..b84b1076 --- /dev/null +++ b/lib/widgets/data_display/medical/laboratory_result_widget.dart @@ -0,0 +1,143 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +import '../text.dart'; + +class LaboratoryResultWidget extends StatefulWidget { + final GestureTapCallback onTap; + final String billNo; + final String details; + + const LaboratoryResultWidget({Key key, this.onTap, this.billNo, this.details}) + : super(key: key); + + @override + _LaboratoryResultWidgetState createState() => _LaboratoryResultWidgetState(); +} + +class _LaboratoryResultWidgetState extends State { + bool _isShowMore = false; + + @override + Widget build(BuildContext context) { + return Container( + margin: EdgeInsets.all(15), + child: Column( + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + margin: EdgeInsets.all(15), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Expanded( + child: Container( + decoration: BoxDecoration( + shape: BoxShape.rectangle, + color: Colors.white, + borderRadius: BorderRadius.all( + Radius.circular(5.0), + )), + padding: EdgeInsets.all(10.0), + margin: EdgeInsets.only(left: 5, right: 5), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Texts('Bill No'), + Texts(widget.billNo), + ], + ), + ), + ), + InkWell( + onTap: widget.onTap, + child: Container( + margin: EdgeInsets.only(left: 5, right: 5), + decoration: BoxDecoration( + shape: BoxShape.rectangle, + color: Colors.red[800], + borderRadius: BorderRadius.all( + Radius.circular(5.0), + )), + child: Container( + padding: EdgeInsets.all(10.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Icon( + Icons.email, + color: Colors.white, + ), + Texts( + 'Send a copy', + color: Colors.white, + ) + ], + ), + ), + ), + ) + ], + ), + ), + SizedBox( + height: 10, + ), + InkWell( + onTap: () { + setState(() { + _isShowMore = !_isShowMore; + }); + }, + child: Container( + padding: EdgeInsets.all(10.0), + margin: EdgeInsets.only(left: 5, right: 5), + decoration: BoxDecoration( + shape: BoxShape.rectangle, + color: Colors.white, + borderRadius: BorderRadius.all( + Radius.circular(5.0), + )), + child: Row( + children: [ + Expanded(child: Texts('Result')), + Container( + width: 25, + height: 25, + decoration: BoxDecoration( + shape: BoxShape.circle, color: Colors.red[900]), + child: Icon( + _isShowMore + ? Icons.keyboard_arrow_up + : Icons.keyboard_arrow_down, + color: Colors.white, + size: 22, + ), + ) + ], + ), + ), + ), + if (_isShowMore) + AnimatedContainer( + padding: EdgeInsets.all(10.0), + margin: EdgeInsets.only(left: 5, right: 5), + decoration: BoxDecoration( + shape: BoxShape.rectangle, + color: Colors.white, + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(5.0), + bottomRight: Radius.circular(5.0), + )), + duration: Duration(milliseconds: 7000), + child: Text(widget.details?? 'No Data'), + ) + ], + ), + ], + ), + ); + } +}