From b461af1be28d66feb1ac227b8819389d6df4d844 Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Mon, 6 Sep 2021 13:41:25 +0300 Subject: [PATCH 1/5] medication for in patient --- lib/config/config.dart | 5 +- .../get_medication_for_inpatient_model.dart | 136 +++++++ ...edication_for_inpatient_request_model.dart | 60 +++ .../prescription/prescriptions_service.dart | 97 +++-- .../viewModel/prescription_view_model.dart | 110 +++--- .../viewModel/prescriptions_view_model.dart | 83 ++-- .../prescription_item_in_patient_page.dart | 81 +--- .../prescription/prescriptions_page.dart | 364 +++++++++--------- 8 files changed, 521 insertions(+), 415 deletions(-) create mode 100644 lib/core/model/Prescriptions/get_medication_for_inpatient_model.dart create mode 100644 lib/core/model/Prescriptions/get_medication_for_inpatient_request_model.dart diff --git a/lib/config/config.dart b/lib/config/config.dart index 11a8d8e6..30d83dc5 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -5,8 +5,8 @@ const ONLY_NUMBERS = "[0-9]"; const ONLY_LETTERS = "[a-zA-Z &'\"]"; const ONLY_DATE = "[0-9/]"; const BASE_URL_LIVE_CARE = 'https://livecare.hmg.com/'; -const BASE_URL = 'https://hmgwebservices.com/'; -// const BASE_URL = 'https://uat.hmgwebservices.com/'; +// const BASE_URL = 'https://hmgwebservices.com/'; +const BASE_URL = 'https://uat.hmgwebservices.com/'; const PHARMACY_ITEMS_URL = "Services/Lists.svc/REST/GetPharmcyItems_Region_enh"; const PHARMACY_LIST_URL = "Services/Patients.svc/REST/GetPharmcyList"; const PATIENT_PROGRESS_NOTE_URL = "Services/DoctorApplication.svc/REST/GetProgressNoteForInPatient"; @@ -239,6 +239,7 @@ const REMOVE_PATIENT_FROM_DOCTOR = "LiveCareApi/DoctorApp/BackPatientToQueue"; const CREATE_DOCTOR_RESPONSE = "Services/DoctorApplication.svc/REST/CreateDoctorResponse"; const GET_DOCTOR_NOT_REPLIED_COUNTS = "Services/DoctorApplication.svc/REST/DoctorApp_GetDoctorNotRepliedCounts"; const ALL_SPECIAL_LAB_RESULT = "services/Patients.svc/REST/GetPatientLabSpecialResultsALL"; +const GET_MEDICATION_FOR_IN_PATIENT = "Services/DoctorApplication.svc/REST/Doctor_GetMedicationForInpatient"; var selectedPatientType = 1; diff --git a/lib/core/model/Prescriptions/get_medication_for_inpatient_model.dart b/lib/core/model/Prescriptions/get_medication_for_inpatient_model.dart new file mode 100644 index 00000000..7c6d0db5 --- /dev/null +++ b/lib/core/model/Prescriptions/get_medication_for_inpatient_model.dart @@ -0,0 +1,136 @@ +class GetMedicationForInPatientModel { + String setupID; + int projectID; + int admissionNo; + int patientID; + int orderNo; + int prescriptionNo; + int lineItemNo; + String prescriptionDatetime; + int itemID; + int directionID; + int refillID; + String dose; + int unitofMeasurement; + String startDatetime; + String stopDatetime; + int noOfDoses; + int routeId; + String comments; + int reviewedPharmacist; + dynamic reviewedPharmacistDatetime; + dynamic discountinueDatetime; + dynamic rescheduleDatetime; + int status; + String statusDescription; + int createdBy; + String createdOn; + dynamic editedBy; + dynamic editedOn; + dynamic strength; + String pHRItemDescription; + String pHRItemDescriptionN; + + GetMedicationForInPatientModel( + {this.setupID, + this.projectID, + this.admissionNo, + this.patientID, + this.orderNo, + this.prescriptionNo, + this.lineItemNo, + this.prescriptionDatetime, + this.itemID, + this.directionID, + this.refillID, + this.dose, + this.unitofMeasurement, + this.startDatetime, + this.stopDatetime, + this.noOfDoses, + this.routeId, + this.comments, + this.reviewedPharmacist, + this.reviewedPharmacistDatetime, + this.discountinueDatetime, + this.rescheduleDatetime, + this.status, + this.statusDescription, + this.createdBy, + this.createdOn, + this.editedBy, + this.editedOn, + this.strength, + this.pHRItemDescription, + this.pHRItemDescriptionN}); + + GetMedicationForInPatientModel.fromJson(Map json) { + setupID = json['SetupID']; + projectID = json['ProjectID']; + admissionNo = json['AdmissionNo']; + patientID = json['PatientID']; + orderNo = json['OrderNo']; + prescriptionNo = json['PrescriptionNo']; + lineItemNo = json['LineItemNo']; + prescriptionDatetime = json['PrescriptionDatetime']; + itemID = json['ItemID']; + directionID = json['DirectionID']; + refillID = json['RefillID']; + dose = json['Dose']; + unitofMeasurement = json['UnitofMeasurement']; + startDatetime = json['StartDatetime']; + stopDatetime = json['StopDatetime']; + noOfDoses = json['NoOfDoses']; + routeId = json['RouteId']; + comments = json['Comments']; + reviewedPharmacist = json['ReviewedPharmacist']; + reviewedPharmacistDatetime = json['ReviewedPharmacistDatetime']; + discountinueDatetime = json['DiscountinueDatetime']; + rescheduleDatetime = json['RescheduleDatetime']; + status = json['Status']; + statusDescription = json['StatusDescription']; + createdBy = json['CreatedBy']; + createdOn = json['CreatedOn']; + editedBy = json['EditedBy']; + editedOn = json['EditedOn']; + strength = json['Strength']; + pHRItemDescription = json['PHRItemDescription']; + pHRItemDescriptionN = json['PHRItemDescriptionN']; + } + + Map toJson() { + final Map data = new Map(); + data['SetupID'] = this.setupID; + data['ProjectID'] = this.projectID; + data['AdmissionNo'] = this.admissionNo; + data['PatientID'] = this.patientID; + data['OrderNo'] = this.orderNo; + data['PrescriptionNo'] = this.prescriptionNo; + data['LineItemNo'] = this.lineItemNo; + data['PrescriptionDatetime'] = this.prescriptionDatetime; + data['ItemID'] = this.itemID; + data['DirectionID'] = this.directionID; + data['RefillID'] = this.refillID; + data['Dose'] = this.dose; + data['UnitofMeasurement'] = this.unitofMeasurement; + data['StartDatetime'] = this.startDatetime; + data['StopDatetime'] = this.stopDatetime; + data['NoOfDoses'] = this.noOfDoses; + data['RouteId'] = this.routeId; + data['Comments'] = this.comments; + data['ReviewedPharmacist'] = this.reviewedPharmacist; + data['ReviewedPharmacistDatetime'] = this.reviewedPharmacistDatetime; + data['DiscountinueDatetime'] = this.discountinueDatetime; + data['RescheduleDatetime'] = this.rescheduleDatetime; + data['Status'] = this.status; + data['StatusDescription'] = this.statusDescription; + data['CreatedBy'] = this.createdBy; + data['CreatedOn'] = this.createdOn; + data['EditedBy'] = this.editedBy; + data['EditedOn'] = this.editedOn; + data['Strength'] = this.strength; + data['PHRItemDescription'] = this.pHRItemDescription; + data['PHRItemDescriptionN'] = this.pHRItemDescriptionN; + return data; + } +} diff --git a/lib/core/model/Prescriptions/get_medication_for_inpatient_request_model.dart b/lib/core/model/Prescriptions/get_medication_for_inpatient_request_model.dart new file mode 100644 index 00000000..7c906643 --- /dev/null +++ b/lib/core/model/Prescriptions/get_medication_for_inpatient_request_model.dart @@ -0,0 +1,60 @@ +class GetMedicationForInPatientRequestModel { + bool isDentalAllowedBackend; + double versionID; + int channel; + int languageID; + String iPAdress; + String generalid; + int deviceTypeID; + String tokenID; + int patientID; + int admissionNo; + String sessionID; + int projectID; + + GetMedicationForInPatientRequestModel( + {this.isDentalAllowedBackend, + this.versionID, + this.channel, + this.languageID, + this.iPAdress, + this.generalid, + this.deviceTypeID, + this.tokenID, + this.patientID, + this.admissionNo, + this.sessionID, + this.projectID}); + + GetMedicationForInPatientRequestModel.fromJson(Map json) { + isDentalAllowedBackend = json['isDentalAllowedBackend']; + versionID = json['VersionID']; + channel = json['Channel']; + languageID = json['LanguageID']; + iPAdress = json['IPAdress']; + generalid = json['generalid']; + deviceTypeID = json['DeviceTypeID']; + tokenID = json['TokenID']; + patientID = json['PatientID']; + admissionNo = json['AdmissionNo']; + sessionID = json['SessionID']; + projectID = json['ProjectID']; + } + + Map toJson() { + final Map data = new Map(); + data['isDentalAllowedBackend'] = this.isDentalAllowedBackend; + data['VersionID'] = this.versionID; + data['Channel'] = this.channel; + data['LanguageID'] = this.languageID; + data['IPAdress'] = this.iPAdress; + data['generalid'] = this.generalid; + data['DeviceTypeID'] = this.deviceTypeID; + data['TokenID'] = this.tokenID; + data['PatientID'] = this.patientID; + data['AdmissionNo'] = this.admissionNo; + data['SessionID'] = this.sessionID; + data['ProjectID'] = this.projectID; + return data; + } +} diff --git a/lib/core/service/patient_medical_file/prescription/prescriptions_service.dart b/lib/core/service/patient_medical_file/prescription/prescriptions_service.dart index eb860141..9937286b 100644 --- a/lib/core/service/patient_medical_file/prescription/prescriptions_service.dart +++ b/lib/core/service/patient_medical_file/prescription/prescriptions_service.dart @@ -1,5 +1,7 @@ import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/core/model/Prescriptions/Prescriptions.dart'; +import 'package:doctor_app_flutter/core/model/Prescriptions/get_medication_for_inpatient_model.dart'; +import 'package:doctor_app_flutter/core/model/Prescriptions/get_medication_for_inpatient_request_model.dart'; import 'package:doctor_app_flutter/core/model/Prescriptions/in_patient_prescription_model.dart'; import 'package:doctor_app_flutter/core/model/Prescriptions/perscription_pharmacy.dart'; import 'package:doctor_app_flutter/core/model/Prescriptions/prescription_in_patient.dart'; @@ -16,11 +18,13 @@ import '../../base/base_service.dart'; class PrescriptionsService extends BaseService { List prescriptionsList = List(); + List medicationForInPatient = List(); List prescriptionsOrderList = List(); List prescriptionInPatientList = List(); - InPatientPrescriptionRequestModel _inPatientPrescriptionRequestModel = - InPatientPrescriptionRequestModel(); + InPatientPrescriptionRequestModel _inPatientPrescriptionRequestModel = InPatientPrescriptionRequestModel(); + GetMedicationForInPatientRequestModel _getMedicationForInPatientRequestModel = + GetMedicationForInPatientRequestModel(); Future getPrescriptionInPatient({int mrn, String adn}) async { _inPatientPrescriptionRequestModel = InPatientPrescriptionRequestModel( @@ -30,12 +34,10 @@ class PrescriptionsService extends BaseService { hasError = false; prescriptionInPatientList.clear(); - await baseAppClient.post(GET_PRESCRIPTION_IN_PATIENT, - onSuccess: (dynamic response, int statusCode) { + await baseAppClient.post(GET_PRESCRIPTION_IN_PATIENT, onSuccess: (dynamic response, int statusCode) { prescriptionsList.clear(); response['List_PrescriptionReportForInPatient'].forEach((prescriptions) { - prescriptionInPatientList - .add(PrescriotionInPatient.fromJson(prescriptions)); + prescriptionInPatientList.add(PrescriotionInPatient.fromJson(prescriptions)); }); }, onFailure: (String error, int statusCode) { hasError = true; @@ -47,8 +49,7 @@ class PrescriptionsService extends BaseService { hasError = false; Map body = Map(); body['isDentalAllowedBackend'] = false; - await baseAppClient.postPatient(PRESCRIPTIONS, patient: patient, - onSuccess: (dynamic response, int statusCode) { + await baseAppClient.postPatient(PRESCRIPTIONS, patient: patient, onSuccess: (dynamic response, int statusCode) { prescriptionsList.clear(); response['PatientPrescriptionList'].forEach((prescriptions) { prescriptionsList.add(Prescriptions.fromJson(prescriptions)); @@ -60,13 +61,10 @@ class PrescriptionsService extends BaseService { } RequestPrescriptionReport _requestPrescriptionReport = - RequestPrescriptionReport( - appointmentNo: 0, isDentalAllowedBackend: false); + RequestPrescriptionReport(appointmentNo: 0, isDentalAllowedBackend: false); List prescriptionReportList = List(); - Future getPrescriptionReport( - {Prescriptions prescriptions, - @required PatiantInformtion patient}) async { + Future getPrescriptionReport({Prescriptions prescriptions, @required PatiantInformtion patient}) async { hasError = false; _requestPrescriptionReport.dischargeNo = prescriptions.dischargeNo; _requestPrescriptionReport.projectID = prescriptions.projectID; @@ -76,23 +74,18 @@ class PrescriptionsService extends BaseService { _requestPrescriptionReport.appointmentNo = prescriptions.appointmentNo; await baseAppClient.postPatient( - prescriptions.isInOutPatient - ? GET_PRESCRIPTION_REPORT_ENH - : GET_PRESCRIPTION_REPORT_NEW, + prescriptions.isInOutPatient ? GET_PRESCRIPTION_REPORT_ENH : GET_PRESCRIPTION_REPORT_NEW, patient: patient, onSuccess: (dynamic response, int statusCode) { prescriptionReportList.clear(); prescriptionReportEnhList.clear(); if (prescriptions.isInOutPatient) { response['ListPRM'].forEach((prescriptions) { - prescriptionReportList - .add(PrescriptionReport.fromJson(prescriptions)); - prescriptionReportEnhList - .add(PrescriptionReportEnh.fromJson(prescriptions)); + prescriptionReportList.add(PrescriptionReport.fromJson(prescriptions)); + prescriptionReportEnhList.add(PrescriptionReportEnh.fromJson(prescriptions)); }); } else { response['INP_GetPrescriptionReport_List'].forEach((prescriptions) { - prescriptionReportList - .add(PrescriptionReport.fromJson(prescriptions)); + prescriptionReportList.add(PrescriptionReport.fromJson(prescriptions)); }); } }, onFailure: (String error, int statusCode) { @@ -101,8 +94,7 @@ class PrescriptionsService extends BaseService { }, body: _requestPrescriptionReport.toJson()); } - RequestGetListPharmacyForPrescriptions - requestGetListPharmacyForPrescriptions = + RequestGetListPharmacyForPrescriptions requestGetListPharmacyForPrescriptions = RequestGetListPharmacyForPrescriptions( latitude: 0, longitude: 0, @@ -110,16 +102,13 @@ class PrescriptionsService extends BaseService { ); List pharmacyPrescriptionsList = List(); - Future getListPharmacyForPrescriptions( - {int itemId, @required PatiantInformtion patient}) async { + Future getListPharmacyForPrescriptions({int itemId, @required PatiantInformtion patient}) async { hasError = false; requestGetListPharmacyForPrescriptions.itemID = itemId; - await baseAppClient.postPatient(GET_PHARMACY_LIST, patient: patient, - onSuccess: (dynamic response, int statusCode) { + await baseAppClient.postPatient(GET_PHARMACY_LIST, patient: patient, onSuccess: (dynamic response, int statusCode) { pharmacyPrescriptionsList.clear(); response['PharmList'].forEach((prescriptions) { - pharmacyPrescriptionsList - .add(PharmacyPrescriptions.fromJson(prescriptions)); + pharmacyPrescriptionsList.add(PharmacyPrescriptions.fromJson(prescriptions)); }); }, onFailure: (String error, int statusCode) { hasError = true; @@ -127,16 +116,13 @@ class PrescriptionsService extends BaseService { }, body: requestGetListPharmacyForPrescriptions.toJson()); } - RequestPrescriptionReportEnh _requestPrescriptionReportEnh = - RequestPrescriptionReportEnh( + RequestPrescriptionReportEnh _requestPrescriptionReportEnh = RequestPrescriptionReportEnh( isDentalAllowedBackend: false, ); List prescriptionReportEnhList = List(); - Future getPrescriptionReportEnh( - {PrescriptionsOrder prescriptionsOrder, - @required PatiantInformtion patient}) async { + Future getPrescriptionReportEnh({PrescriptionsOrder prescriptionsOrder, @required PatiantInformtion patient}) async { ///This logic copy from the old app from class [order-history.component.ts] in line 45 bool isInPatient = false; prescriptionsList.forEach((element) { @@ -151,8 +137,7 @@ class PrescriptionsService extends BaseService { isInPatient = element.isInOutPatient; } } else { - if (int.parse(prescriptionsOrder.appointmentNo) == - element.appointmentNo) { + if (int.parse(prescriptionsOrder.appointmentNo) == element.appointmentNo) { _requestPrescriptionReportEnh.appointmentNo = element.appointmentNo; _requestPrescriptionReportEnh.clinicID = element.clinicID; _requestPrescriptionReportEnh.projectID = element.projectID; @@ -168,20 +153,17 @@ class PrescriptionsService extends BaseService { hasError = false; - await baseAppClient.postPatient( - isInPatient ? GET_PRESCRIPTION_REPORT_ENH : GET_PRESCRIPTION_REPORT_NEW, + await baseAppClient.postPatient(isInPatient ? GET_PRESCRIPTION_REPORT_ENH : GET_PRESCRIPTION_REPORT_NEW, patient: patient, onSuccess: (dynamic response, int statusCode) { prescriptionReportEnhList.clear(); if (isInPatient) { response['ListPRM'].forEach((prescriptions) { - prescriptionReportEnhList - .add(PrescriptionReportEnh.fromJson(prescriptions)); + prescriptionReportEnhList.add(PrescriptionReportEnh.fromJson(prescriptions)); }); } else { response['INP_GetPrescriptionReport_List'].forEach((prescriptions) { - PrescriptionReportEnh reportEnh = - PrescriptionReportEnh.fromJson(prescriptions); + PrescriptionReportEnh reportEnh = PrescriptionReportEnh.fromJson(prescriptions); reportEnh.itemDescription = prescriptions['ItemDescriptionN']; prescriptionReportEnhList.add(reportEnh); }); @@ -195,17 +177,34 @@ class PrescriptionsService extends BaseService { Future getPrescriptionsOrders() async { Map body = Map(); body['isDentalAllowedBackend'] = false; - await baseAppClient.post(GET_PRESCRIPTIONS_ALL_ORDERS, - onSuccess: (dynamic response, int statusCode) { + await baseAppClient.post(GET_PRESCRIPTIONS_ALL_ORDERS, onSuccess: (dynamic response, int statusCode) { prescriptionsOrderList.clear(); - response['PatientER_GetPatientAllPresOrdersList'] - .forEach((prescriptionsOrder) { - prescriptionsOrderList - .add(PrescriptionsOrder.fromJson(prescriptionsOrder)); + response['PatientER_GetPatientAllPresOrdersList'].forEach((prescriptionsOrder) { + prescriptionsOrderList.add(PrescriptionsOrder.fromJson(prescriptionsOrder)); }); }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; }, body: body); } + + Future getMedicationForInPatient(PatiantInformtion patient) async { + hasError = false; + _getMedicationForInPatientRequestModel = GetMedicationForInPatientRequestModel( + isDentalAllowedBackend: false, + admissionNo: int.parse(patient.admissionNo), + tokenID: "@dm!n", + projectID: 15, + ); + await baseAppClient.postPatient(GET_MEDICATION_FOR_IN_PATIENT, patient: patient, + onSuccess: (dynamic response, int statusCode) { + medicationForInPatient.clear(); + response['List_GetMedicationForInpatient'].forEach((prescriptions) { + medicationForInPatient.add(GetMedicationForInPatientModel.fromJson(prescriptions)); + }); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: _getMedicationForInPatientRequestModel.toJson()); + } } diff --git a/lib/core/viewModel/prescription_view_model.dart b/lib/core/viewModel/prescription_view_model.dart index 902268da..96645618 100644 --- a/lib/core/viewModel/prescription_view_model.dart +++ b/lib/core/viewModel/prescription_view_model.dart @@ -2,6 +2,7 @@ import 'package:doctor_app_flutter/core/enum/filter_type.dart'; import 'package:doctor_app_flutter/core/enum/viewstate.dart'; import 'package:doctor_app_flutter/core/model/Prescriptions/Prescriptions.dart'; +import 'package:doctor_app_flutter/core/model/Prescriptions/get_medication_for_inpatient_model.dart'; import 'package:doctor_app_flutter/core/model/Prescriptions/perscription_pharmacy.dart'; import 'package:doctor_app_flutter/core/model/Prescriptions/post_prescrition_req_model.dart'; import 'package:doctor_app_flutter/core/model/Prescriptions/prescription_in_patient.dart'; @@ -26,11 +27,10 @@ class PrescriptionViewModel extends BaseViewModel { FilterType filterType = FilterType.Clinic; bool hasError = false; PrescriptionService _prescriptionService = locator(); - List get allMedicationList => - _prescriptionService.allMedicationList; + List get allMedicationList => _prescriptionService.allMedicationList; + List get medicationForInPatient => _prescriptionsService.medicationForInPatient; - List get prescriptionList => - _prescriptionService.prescriptionList; + List get prescriptionList => _prescriptionService.prescriptionList; List get drugsList => _prescriptionService.doctorsList; //List get allMedicationList => _prescriptionService.allMedicationList; List get drugToDrug => _prescriptionService.drugToDrugList; @@ -41,30 +41,22 @@ class PrescriptionViewModel extends BaseViewModel { List _prescriptionsOrderListClinic = List(); List _prescriptionsOrderListHospital = List(); - List get prescriptionReportList => - _prescriptionsService.prescriptionReportList; + List get prescriptionReportList => _prescriptionsService.prescriptionReportList; - List get prescriptionsList => - _prescriptionsService.prescriptionsList; + List get prescriptionsList => _prescriptionsService.prescriptionsList; - List get pharmacyPrescriptionsList => - _prescriptionsService.pharmacyPrescriptionsList; - List get prescriptionReportEnhList => - _prescriptionsService.prescriptionReportEnhList; + List get pharmacyPrescriptionsList => _prescriptionsService.pharmacyPrescriptionsList; + List get prescriptionReportEnhList => _prescriptionsService.prescriptionReportEnhList; List get prescriptionsOrderList => - filterType == FilterType.Clinic - ? _prescriptionsOrderListClinic - : _prescriptionsOrderListHospital; + filterType == FilterType.Clinic ? _prescriptionsOrderListClinic : _prescriptionsOrderListHospital; - List get inPatientPrescription => - _prescriptionsService.prescriptionInPatientList; + List get inPatientPrescription => _prescriptionsService.prescriptionInPatientList; getPrescriptionsInPatient(PatiantInformtion patient) async { setState(ViewState.Busy); error = ""; - await _prescriptionsService.getPrescriptionInPatient( - mrn: patient.patientId, adn: patient.admissionNo); + await _prescriptionsService.getPrescriptionInPatient(mrn: patient.patientId, adn: patient.admissionNo); if (_prescriptionsService.hasError) { error = "No Prescription Found"; setState(ViewState.Error); @@ -100,8 +92,7 @@ class PrescriptionViewModel extends BaseViewModel { setState(ViewState.Idle); } - Future postPrescription( - PostPrescriptionReqModel postProcedureReqModel, int mrn) async { + Future postPrescription(PostPrescriptionReqModel postProcedureReqModel, int mrn) async { hasError = false; //_insuranceCardService.clearInsuranceCard(); setState(ViewState.Busy); @@ -125,8 +116,7 @@ class PrescriptionViewModel extends BaseViewModel { setState(ViewState.Idle); } - Future updatePrescription( - PostPrescriptionReqModel updatePrescriptionReqModel, int mrn) async { + Future updatePrescription(PostPrescriptionReqModel updatePrescriptionReqModel, int mrn) async { hasError = false; //_insuranceCardService.clearInsuranceCard(); setState(ViewState.Busy); @@ -152,16 +142,11 @@ class PrescriptionViewModel extends BaseViewModel { setState(ViewState.Idle); } - Future getDrugToDrug( - VitalSignData vital, - List lstAssessments, - List allergy, - PatiantInformtion patient, - List prescription) async { + Future getDrugToDrug(VitalSignData vital, List lstAssessments, + List allergy, PatiantInformtion patient, List prescription) async { hasError = false; setState(ViewState.Busy); - await _prescriptionService.getDrugToDrug( - vital, lstAssessments, allergy, patient, prescription); + await _prescriptionService.getDrugToDrug(vital, lstAssessments, allergy, patient, prescription); if (_prescriptionService.hasError) { error = _prescriptionService.error; setState(ViewState.ErrorLocal); @@ -174,12 +159,9 @@ class PrescriptionViewModel extends BaseViewModel { notifyListeners(); } - getPrescriptionReport( - {Prescriptions prescriptions, - @required PatiantInformtion patient}) async { + getPrescriptionReport({Prescriptions prescriptions, @required PatiantInformtion patient}) async { setState(ViewState.Busy); - await _prescriptionsService.getPrescriptionReport( - prescriptions: prescriptions, patient: patient); + await _prescriptionsService.getPrescriptionReport(prescriptions: prescriptions, patient: patient); if (_prescriptionsService.hasError) { error = _prescriptionsService.error; setState(ViewState.ErrorLocal); @@ -188,11 +170,9 @@ class PrescriptionViewModel extends BaseViewModel { } } - getListPharmacyForPrescriptions( - {int itemId, @required PatiantInformtion patient}) async { + getListPharmacyForPrescriptions({int itemId, @required PatiantInformtion patient}) async { setState(ViewState.Busy); - await _prescriptionsService.getListPharmacyForPrescriptions( - itemId: itemId, patient: patient); + await _prescriptionsService.getListPharmacyForPrescriptions(itemId: itemId, patient: patient); if (_prescriptionsService.hasError) { error = _prescriptionsService.error; setState(ViewState.Error); @@ -204,48 +184,39 @@ class PrescriptionViewModel extends BaseViewModel { void _filterList() { _prescriptionsService.prescriptionsList.forEach((element) { /// PrescriptionsList list sort clinic - List prescriptionsByClinic = - _prescriptionsOrderListClinic - .where((elementClinic) => - elementClinic.filterName == element.clinicDescription) - .toList(); + List prescriptionsByClinic = _prescriptionsOrderListClinic + .where((elementClinic) => elementClinic.filterName == element.clinicDescription) + .toList(); if (prescriptionsByClinic.length != 0) { - _prescriptionsOrderListClinic[ - _prescriptionsOrderListClinic.indexOf(prescriptionsByClinic[0])] + _prescriptionsOrderListClinic[_prescriptionsOrderListClinic.indexOf(prescriptionsByClinic[0])] .prescriptionsList .add(element); } else { - _prescriptionsOrderListClinic.add(PrescriptionsList( - filterName: element.clinicDescription, prescriptions: element)); + _prescriptionsOrderListClinic + .add(PrescriptionsList(filterName: element.clinicDescription, prescriptions: element)); } /// PrescriptionsList list sort via hospital - List prescriptionsByHospital = - _prescriptionsOrderListHospital - .where( - (elementClinic) => elementClinic.filterName == element.name, - ) - .toList(); + List prescriptionsByHospital = _prescriptionsOrderListHospital + .where( + (elementClinic) => elementClinic.filterName == element.name, + ) + .toList(); if (prescriptionsByHospital.length != 0) { - _prescriptionsOrderListHospital[_prescriptionsOrderListHospital - .indexOf(prescriptionsByHospital[0])] + _prescriptionsOrderListHospital[_prescriptionsOrderListHospital.indexOf(prescriptionsByHospital[0])] .prescriptionsList .add(element); } else { - _prescriptionsOrderListHospital.add(PrescriptionsList( - filterName: element.name, prescriptions: element)); + _prescriptionsOrderListHospital.add(PrescriptionsList(filterName: element.name, prescriptions: element)); } }); } - getPrescriptionReportEnh( - {PrescriptionsOrder prescriptionsOrder, - @required PatiantInformtion patient}) async { + getPrescriptionReportEnh({PrescriptionsOrder prescriptionsOrder, @required PatiantInformtion patient}) async { setState(ViewState.Busy); - await _prescriptionsService.getPrescriptionReportEnh( - prescriptionsOrder: prescriptionsOrder, patient: patient); + await _prescriptionsService.getPrescriptionReportEnh(prescriptionsOrder: prescriptionsOrder, patient: patient); if (_prescriptionsService.hasError) { error = _prescriptionsService.error; setState(ViewState.Error); @@ -280,4 +251,15 @@ class PrescriptionViewModel extends BaseViewModel { setState(ViewState.Idle); } } + + getMedicationForInPatient(PatiantInformtion patient) async { + setState(ViewState.Busy); + await _prescriptionsService.getMedicationForInPatient(patient); + if (_prescriptionsService.hasError) { + error = _prescriptionsService.error; + setState(ViewState.ErrorLocal); + } else { + setState(ViewState.Idle); + } + } } diff --git a/lib/core/viewModel/prescriptions_view_model.dart b/lib/core/viewModel/prescriptions_view_model.dart index b5916bac..2548a59c 100644 --- a/lib/core/viewModel/prescriptions_view_model.dart +++ b/lib/core/viewModel/prescriptions_view_model.dart @@ -1,6 +1,7 @@ import 'package:doctor_app_flutter/core/enum/filter_type.dart'; import 'package:doctor_app_flutter/core/enum/viewstate.dart'; import 'package:doctor_app_flutter/core/model/Prescriptions/Prescriptions.dart'; +import 'package:doctor_app_flutter/core/model/Prescriptions/get_medication_for_inpatient_model.dart'; import 'package:doctor_app_flutter/core/model/Prescriptions/perscription_pharmacy.dart'; import 'package:doctor_app_flutter/core/model/Prescriptions/prescription_report.dart'; import 'package:doctor_app_flutter/core/model/Prescriptions/prescription_report_enh.dart'; @@ -19,21 +20,19 @@ class PrescriptionsViewModel extends BaseViewModel { List _prescriptionsOrderListClinic = List(); List _prescriptionsOrderListHospital = List(); - List get prescriptionReportList => - _prescriptionsService.prescriptionReportList; + List get prescriptionReportList => _prescriptionsService.prescriptionReportList; - List get prescriptionsList => - _prescriptionsService.prescriptionsList; + List get prescriptionsList => _prescriptionsService.prescriptionsList; - List get pharmacyPrescriptionsList => - _prescriptionsService.pharmacyPrescriptionsList; - List get prescriptionReportEnhList => - _prescriptionsService.prescriptionReportEnhList; + List get pharmacyPrescriptionsList => _prescriptionsService.pharmacyPrescriptionsList; + List get prescriptionReportEnhList => _prescriptionsService.prescriptionReportEnhList; List get prescriptionsOrderList => - filterType == FilterType.Clinic - ? _prescriptionsOrderListClinic - : _prescriptionsOrderListHospital; + filterType == FilterType.Clinic ? _prescriptionsOrderListClinic : _prescriptionsOrderListHospital; + + List get medicationForInPatient => _prescriptionsService.medicationForInPatient; + + List _medicationForInPatient = List(); getPrescriptions(PatiantInformtion patient) async { setState(ViewState.Busy); @@ -62,38 +61,32 @@ class PrescriptionsViewModel extends BaseViewModel { void _filterList() { _prescriptionsService.prescriptionsList.forEach((element) { /// PrescriptionsList list sort clinic - List prescriptionsByClinic = - _prescriptionsOrderListClinic - .where((elementClinic) => - elementClinic.filterName == element.clinicDescription) - .toList(); + List prescriptionsByClinic = _prescriptionsOrderListClinic + .where((elementClinic) => elementClinic.filterName == element.clinicDescription) + .toList(); if (prescriptionsByClinic.length != 0) { - _prescriptionsOrderListClinic[ - _prescriptionsOrderListClinic.indexOf(prescriptionsByClinic[0])] + _prescriptionsOrderListClinic[_prescriptionsOrderListClinic.indexOf(prescriptionsByClinic[0])] .prescriptionsList .add(element); } else { - _prescriptionsOrderListClinic.add(PrescriptionsList( - filterName: element.clinicDescription, prescriptions: element)); + _prescriptionsOrderListClinic + .add(PrescriptionsList(filterName: element.clinicDescription, prescriptions: element)); } /// PrescriptionsList list sort via hospital - List prescriptionsByHospital = - _prescriptionsOrderListHospital - .where( - (elementClinic) => elementClinic.filterName == element.name, - ) - .toList(); + List prescriptionsByHospital = _prescriptionsOrderListHospital + .where( + (elementClinic) => elementClinic.filterName == element.name, + ) + .toList(); if (prescriptionsByHospital.length != 0) { - _prescriptionsOrderListHospital[_prescriptionsOrderListHospital - .indexOf(prescriptionsByHospital[0])] + _prescriptionsOrderListHospital[_prescriptionsOrderListHospital.indexOf(prescriptionsByHospital[0])] .prescriptionsList .add(element); } else { - _prescriptionsOrderListHospital.add(PrescriptionsList( - filterName: element.name, prescriptions: element)); + _prescriptionsOrderListHospital.add(PrescriptionsList(filterName: element.name, prescriptions: element)); } }); } @@ -103,12 +96,9 @@ class PrescriptionsViewModel extends BaseViewModel { notifyListeners(); } - getPrescriptionReport( - {Prescriptions prescriptions, - @required PatiantInformtion patient}) async { + getPrescriptionReport({Prescriptions prescriptions, @required PatiantInformtion patient}) async { setState(ViewState.Busy); - await _prescriptionsService.getPrescriptionReport( - prescriptions: prescriptions, patient: patient); + await _prescriptionsService.getPrescriptionReport(prescriptions: prescriptions, patient: patient); if (_prescriptionsService.hasError) { error = _prescriptionsService.error; setState(ViewState.ErrorLocal); @@ -117,11 +107,9 @@ class PrescriptionsViewModel extends BaseViewModel { } } - getListPharmacyForPrescriptions( - {int itemId, @required PatiantInformtion patient}) async { + getListPharmacyForPrescriptions({int itemId, @required PatiantInformtion patient}) async { setState(ViewState.Busy); - await _prescriptionsService.getListPharmacyForPrescriptions( - itemId: itemId, patient: patient); + await _prescriptionsService.getListPharmacyForPrescriptions(itemId: itemId, patient: patient); if (_prescriptionsService.hasError) { error = _prescriptionsService.error; setState(ViewState.Error); @@ -130,12 +118,9 @@ class PrescriptionsViewModel extends BaseViewModel { } } - getPrescriptionReportEnh( - {PrescriptionsOrder prescriptionsOrder, - @required PatiantInformtion patient}) async { + getPrescriptionReportEnh({PrescriptionsOrder prescriptionsOrder, @required PatiantInformtion patient}) async { setState(ViewState.Busy); - await _prescriptionsService.getPrescriptionReportEnh( - prescriptionsOrder: prescriptionsOrder, patient: patient); + await _prescriptionsService.getPrescriptionReportEnh(prescriptionsOrder: prescriptionsOrder, patient: patient); if (_prescriptionsService.hasError) { error = _prescriptionsService.error; setState(ViewState.Error); @@ -143,4 +128,14 @@ class PrescriptionsViewModel extends BaseViewModel { setState(ViewState.Idle); } } + + getMedicationForInPatient(PatiantInformtion patient) async { + await _prescriptionsService.getMedicationForInPatient(patient); + if (_prescriptionsService.hasError) { + error = _prescriptionsService.error; + setState(ViewState.ErrorLocal); + } else { + setState(ViewState.Idle); + } + } } diff --git a/lib/screens/prescription/prescription_item_in_patient_page.dart b/lib/screens/prescription/prescription_item_in_patient_page.dart index 7cf33935..fce49f77 100644 --- a/lib/screens/prescription/prescription_item_in_patient_page.dart +++ b/lib/screens/prescription/prescription_item_in_patient_page.dart @@ -1,3 +1,4 @@ +import 'package:doctor_app_flutter/core/model/Prescriptions/get_medication_for_inpatient_model.dart'; import 'package:doctor_app_flutter/core/model/Prescriptions/prescription_in_patient.dart'; import 'package:doctor_app_flutter/core/viewModel/prescription_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; @@ -13,7 +14,7 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; class PrescriptionItemsInPatientPage extends StatelessWidget { - final PrescriotionInPatient prescriptions; + final GetMedicationForInPatientModel prescriptions; final PatiantInformtion patient; final String patientType; final String arrivalType; @@ -36,16 +37,15 @@ class PrescriptionItemsInPatientPage extends StatelessWidget { ProjectViewModel projectViewModel = Provider.of(context); return BaseView( onModelReady: (model) async { - if (model.inPatientPrescription.length == 0) { - await model.getPrescriptionsInPatient(patient); + if (model.medicationForInPatient.length == 0) { + await model.getMedicationForInPatient(patient); } }, builder: (_, model, widget) => AppScaffold( isShowAppBar: true, backgroundColor: Colors.grey[100], baseViewModel: model, - appBar: PatientProfileAppBar( - patient), + appBar: PatientProfileAppBar(patient), body: SingleChildScrollView( child: Container( child: Column( @@ -64,8 +64,7 @@ class PrescriptionItemsInPatientPage extends StatelessWidget { Container( margin: EdgeInsets.only(left: 18, right: 18), child: AppText( - model.inPatientPrescription[prescriptionIndex] - .itemDescription, + prescriptions.pHRItemDescription, bold: true, ), ), @@ -92,13 +91,7 @@ class PrescriptionItemsInPatientPage extends StatelessWidget { TranslationBase.of(context).direction, color: Colors.grey, ), - Expanded( - child: AppText(" " + - model - .inPatientPrescription[ - prescriptionIndex] - .direction ?? - '')), + Expanded(child: AppText(" " + prescriptions.directionID.toString() ?? '')), ], ), Row( @@ -107,13 +100,7 @@ class PrescriptionItemsInPatientPage extends StatelessWidget { TranslationBase.of(context).route, color: Colors.grey, ), - AppText(" " + - model - .inPatientPrescription[ - prescriptionIndex] - .route - .toString() ?? - ''), + AppText(" " + prescriptions.routeId.toString() ?? ''), ], ), Row( @@ -122,13 +109,7 @@ class PrescriptionItemsInPatientPage extends StatelessWidget { TranslationBase.of(context).refill, color: Colors.grey, ), - Expanded( - child: AppText(" " + - model - .inPatientPrescription[ - prescriptionIndex] - .refillType ?? - '')), + Expanded(child: AppText(" " + prescriptions.refillID.toString() ?? '')), ], ), Row( @@ -169,12 +150,7 @@ class PrescriptionItemsInPatientPage extends StatelessWidget { 'UOM', color: Colors.grey, ), - AppText(" " + - model - .inPatientPrescription[ - prescriptionIndex] - .unitofMeasurementDescription ?? - ''), + AppText(" " + prescriptions.unitofMeasurement.toString() ?? ''), ], ), Row( @@ -183,13 +159,7 @@ class PrescriptionItemsInPatientPage extends StatelessWidget { TranslationBase.of(context).dailyDoses, color: Colors.grey, ), - AppText(" " + - model - .inPatientPrescription[ - prescriptionIndex] - .dose - .toString() ?? - ''), + AppText(" " + prescriptions.dose.toString() ?? ''), ], ), Row( @@ -198,13 +168,7 @@ class PrescriptionItemsInPatientPage extends StatelessWidget { TranslationBase.of(context).status, color: Colors.grey, ), - AppText(" " + - model - .inPatientPrescription[ - prescriptionIndex] - .statusDescription - .toString() ?? - ''), + AppText(" " + prescriptions.statusDescription.toString() ?? ''), ], ), Row( @@ -213,12 +177,7 @@ class PrescriptionItemsInPatientPage extends StatelessWidget { TranslationBase.of(context).processed, color: Colors.grey, ), - AppText(" " + - model - .inPatientPrescription[ - prescriptionIndex] - .processedBy ?? - ''), + // AppText(" " + prescriptions.editedBy.toString() ?? ''), ], ), Row( @@ -227,23 +186,13 @@ class PrescriptionItemsInPatientPage extends StatelessWidget { TranslationBase.of(context).dailyDoses, color: Colors.grey, ), - AppText(" " + - model - .inPatientPrescription[ - prescriptionIndex] - .dose - .toString() ?? - ''), + AppText(" " + prescriptions.dose.toString() ?? ''), ], ), SizedBox( height: 12, ), - AppText(model - .inPatientPrescription[ - prescriptionIndex] - .comments ?? - ''), + AppText(prescriptions.comments ?? ''), ], ), ) diff --git a/lib/screens/prescription/prescriptions_page.dart b/lib/screens/prescription/prescriptions_page.dart index 4c9d986e..f416db46 100644 --- a/lib/screens/prescription/prescriptions_page.dart +++ b/lib/screens/prescription/prescriptions_page.dart @@ -12,6 +12,7 @@ import 'package:doctor_app_flutter/widgets/patients/profile/patient-profile-app- import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/doctor_card.dart'; +import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart'; import 'package:doctor_app_flutter/widgets/shared/user-guid/in_patient_doctor_card.dart'; import 'package:doctor_app_flutter/widgets/transitions/fade_page.dart'; import 'package:flutter/cupertino.dart'; @@ -28,208 +29,191 @@ class PrescriptionsPage extends StatelessWidget { bool isFromLiveCare = routeArgs['isFromLiveCare']; bool isSelectInpatient = routeArgs['isSelectInpatient']; return BaseView( - onModelReady: (model) => isSelectInpatient - ? model.getPrescriptionsInPatient(patient) - : model.getPrescriptions(patient, patientType: patientType), - builder: (_, model, w) => AppScaffold( - baseViewModel: model, - isShowAppBar: true, - backgroundColor: Colors.grey[100], - appBar: PatientProfileAppBar( - patient, - isInpatient: isInpatient, - ), - body: patient.admissionNo == null - ? FractionallySizedBox( - widthFactor: 1.0, - child: ListView( - physics: BouncingScrollPhysics(), - children: [ - SizedBox( - height: 12, - ), - if (model.prescriptionsList.isNotEmpty && - patient.patientStatusType != 43) - Padding( - padding: const EdgeInsets.all(8.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - AppText( - TranslationBase.of(context).orders, - style: "caption2", - color: Colors.black, - fontSize: 13, - ), - AppText( - TranslationBase.of(context).prescriptions, - bold: true, - fontSize: 22, - ), - ], - ), - ), - if (patient.patientStatusType != null && - patient.patientStatusType == 43) - Padding( - padding: const EdgeInsets.all(8.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - AppText( - TranslationBase.of(context).orders, - style: "caption2", - color: Colors.black, - fontSize: 13, - ), - AppText( - TranslationBase.of(context).prescriptions, - bold: true, - fontSize: 22, - ), - ], - ), - ), - if ((patient.patientStatusType != null && - patient.patientStatusType == 43) || - (isFromLiveCare && patient.appointmentNo != null)) - AddNewOrder( - onTap: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => - BaseAddProcedureTabPage( - patient: patient, - prescriptionModel: model, - procedureType: - ProcedureType.PRESCRIPTION, - ),settings: RouteSettings(name: 'AddProcedureTabPage')), - ); - }, - label: TranslationBase.of(context) - .applyForNewPrescriptionsOrder, - ), - ...List.generate( - model.prescriptionsList.length, - (index) => InkWell( - onTap: () => Navigator.push( - context, - FadePage( - page: PrescriptionItemsPage( - prescriptions: - model.prescriptionsList[index], - patient: patient, - patientType: patientType, - arrivalType: arrivalType, - ), + onModelReady: (model) => patient.admissionNo == null + ? model.getPrescriptions(patient, patientType: patientType) + : model.getMedicationForInPatient(patient), + builder: (_, model, w) => NetworkBaseView( + baseViewModel: model, + child: AppScaffold( + baseViewModel: model, + isShowAppBar: true, + backgroundColor: Colors.grey[100], + appBar: PatientProfileAppBar( + patient, + isInpatient: isInpatient, + ), + body: patient.admissionNo == null + ? FractionallySizedBox( + widthFactor: 1.0, + child: ListView( + physics: BouncingScrollPhysics(), + children: [ + SizedBox( + height: 12, + ), + if (model.prescriptionsList.isNotEmpty && patient.patientStatusType != 43) + Padding( + padding: const EdgeInsets.all(8.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AppText( + TranslationBase.of(context).orders, + style: "caption2", + color: Colors.black, + fontSize: 13, ), - ), - child: DoctorCard( - doctorName: - model.prescriptionsList[index].doctorName, - profileUrl: model - .prescriptionsList[index].doctorImageURL, - branch: model.prescriptionsList[index].name, - clinic: model.prescriptionsList[index] - .clinicDescription, - isPrescriptions: true, - appointmentDate: - AppDateUtils.getDateTimeFromServerFormat( - model.prescriptionsList[index] - .appointmentDate, + AppText( + TranslationBase.of(context).prescriptions, + bold: true, + fontSize: 22, + ), + ], ), - ))), - if (model.prescriptionsList.isEmpty && - patient.patientStatusType != 43) - Center( - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - SizedBox( - height: 100, ), - Image.asset('assets/images/no-data.png'), + if (patient.patientStatusType != null && patient.patientStatusType == 43) Padding( padding: const EdgeInsets.all(8.0), - child: AppText(TranslationBase.of(context) - .noPrescriptionsFound), - ) - ], - ), - ) - ], - ), - ) - : FractionallySizedBox( - widthFactor: 1.0, - child: ListView( - physics: BouncingScrollPhysics(), - children: [ - // SizedBox( - // height: 12, - // ), - - ...List.generate( - model.inPatientPrescription.length, - (index) => InkWell( - onTap: () => Navigator.push( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AppText( + TranslationBase.of(context).orders, + style: "caption2", + color: Colors.black, + fontSize: 13, + ), + AppText( + TranslationBase.of(context).prescriptions, + bold: true, + fontSize: 22, + ), + ], + ), + ), + if ((patient.patientStatusType != null && patient.patientStatusType == 43) || + (isFromLiveCare && patient.appointmentNo != null)) + AddNewOrder( + onTap: () { + Navigator.push( context, - FadePage( - page: PrescriptionItemsInPatientPage( - prescriptionIndex: index, - prescriptions: model - .inPatientPrescription[index], - patient: patient, - patientType: patientType, - arrivalType: arrivalType, - startOn: AppDateUtils - .getDateTimeFromServerFormat( - model.inPatientPrescription[index] - .startDatetime, - ), - stopOn: AppDateUtils - .getDateTimeFromServerFormat( - model.inPatientPrescription[index] - .stopDatetime, + MaterialPageRoute( + builder: (context) => BaseAddProcedureTabPage( + patient: patient, + prescriptionModel: model, + procedureType: ProcedureType.PRESCRIPTION, + ), + settings: RouteSettings(name: 'AddProcedureTabPage')), + ); + }, + label: TranslationBase.of(context).applyForNewPrescriptionsOrder, + ), + ...List.generate( + model.prescriptionsList.length, + (index) => InkWell( + onTap: () => Navigator.push( + context, + FadePage( + page: PrescriptionItemsPage( + prescriptions: model.prescriptionsList[index], + patient: patient, + patientType: patientType, + arrivalType: arrivalType, + ), + ), ), + child: DoctorCard( + doctorName: model.prescriptionsList[index].doctorName, + profileUrl: model.prescriptionsList[index].doctorImageURL, + branch: model.prescriptionsList[index].name, + clinic: model.prescriptionsList[index].clinicDescription, + isPrescriptions: true, + appointmentDate: AppDateUtils.getDateTimeFromServerFormat( + model.prescriptionsList[index].appointmentDate, ), + ))), + if (model.prescriptionsList.isEmpty && patient.patientStatusType != 43) + Center( + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + SizedBox( + height: 100, ), - ), - child: InPatientDoctorCard( - doctorName: model.inPatientPrescription[index] - .itemDescription, - profileUrl: 'sss', - branch: 'hamza', - clinic: 'basheer', - isPrescriptions: true, - appointmentDate: - AppDateUtils.getDateTimeFromServerFormat( - model.inPatientPrescription[index] - .prescriptionDatetime, + Image.asset('assets/images/no-data.png'), + Padding( + padding: const EdgeInsets.all(8.0), + child: AppText(TranslationBase.of(context).noPrescriptionsFound), + ) + ], ), - createdBy: model.inPatientPrescription[index] - .createdByName, - ))), - if (model.inPatientPrescription.length == 0) - Center( - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - SizedBox( - height: 100, - ), - Image.asset('assets/images/no-data.png'), - Padding( - padding: const EdgeInsets.all(8.0), - child: AppText(TranslationBase.of(context) - .noPrescriptionsFound), ) + ], + ), + ) + : NetworkBaseView( + baseViewModel: model, + child: FractionallySizedBox( + widthFactor: 1.0, + child: ListView( + physics: BouncingScrollPhysics(), + children: [ + // SizedBox( + // height: 12, + // ), + + ...List.generate( + model.medicationForInPatient.length, + (index) => InkWell( + onTap: () => Navigator.push( + context, + FadePage( + page: PrescriptionItemsInPatientPage( + prescriptionIndex: index, + prescriptions: model.medicationForInPatient[index], + patient: patient, + patientType: patientType, + arrivalType: arrivalType, + startOn: AppDateUtils.getDateTimeFromServerFormat( + model.medicationForInPatient[index].startDatetime, + ), + stopOn: AppDateUtils.getDateTimeFromServerFormat( + model.medicationForInPatient[index].stopDatetime, + ), + ), + ), + ), + child: InPatientDoctorCard( + doctorName: model.medicationForInPatient[index].pHRItemDescription, + profileUrl: 'sss', + branch: 'hamza', + clinic: 'basheer', + isPrescriptions: true, + appointmentDate: AppDateUtils.getDateTimeFromServerFormat( + model.medicationForInPatient[index].prescriptionDatetime, + ), + createdBy: model.medicationForInPatient[index].createdBy.toString(), + ))), + if (model.medicationForInPatient.length == 0) + Center( + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + SizedBox( + height: 100, + ), + Image.asset('assets/images/no-data.png'), + Padding( + padding: const EdgeInsets.all(8.0), + child: AppText(TranslationBase.of(context).noPrescriptionsFound), + ) + ], + ), + ) ], ), - ) - ], - ), - ))); + ), + )), + )); } } From 1ba47515c680204b8411fdfe41438310affb2dfb Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Tue, 7 Sep 2021 14:23:04 +0300 Subject: [PATCH 2/5] changing list genrate to list builder --- .../prescription/prescriptions_page.dart | 61 ++++++++++--------- 1 file changed, 33 insertions(+), 28 deletions(-) diff --git a/lib/screens/prescription/prescriptions_page.dart b/lib/screens/prescription/prescriptions_page.dart index f416db46..e7225e9a 100644 --- a/lib/screens/prescription/prescriptions_page.dart +++ b/lib/screens/prescription/prescriptions_page.dart @@ -162,38 +162,43 @@ class PrescriptionsPage extends StatelessWidget { // height: 12, // ), - ...List.generate( - model.medicationForInPatient.length, - (index) => InkWell( - onTap: () => Navigator.push( - context, - FadePage( - page: PrescriptionItemsInPatientPage( - prescriptionIndex: index, - prescriptions: model.medicationForInPatient[index], - patient: patient, - patientType: patientType, - arrivalType: arrivalType, - startOn: AppDateUtils.getDateTimeFromServerFormat( - model.medicationForInPatient[index].startDatetime, - ), - stopOn: AppDateUtils.getDateTimeFromServerFormat( - model.medicationForInPatient[index].stopDatetime, + ListView.builder( + scrollDirection: Axis.vertical, + shrinkWrap: true, + itemCount: model.medicationForInPatient.length, + itemBuilder: (context, index) { + //model.medicationForInPatient.length, + return InkWell( + onTap: () => Navigator.push( + context, + FadePage( + page: PrescriptionItemsInPatientPage( + prescriptionIndex: index, + prescriptions: model.medicationForInPatient[index], + patient: patient, + patientType: patientType, + arrivalType: arrivalType, + startOn: AppDateUtils.getDateTimeFromServerFormat( + model.medicationForInPatient[index].startDatetime, + ), + stopOn: AppDateUtils.getDateTimeFromServerFormat( + model.medicationForInPatient[index].stopDatetime, + ), ), ), ), + child: InPatientDoctorCard( + doctorName: model.medicationForInPatient[index].pHRItemDescription, + profileUrl: 'sss', + branch: 'hamza', + clinic: 'basheer', + isPrescriptions: true, + appointmentDate: AppDateUtils.getDateTimeFromServerFormat( + model.medicationForInPatient[index].prescriptionDatetime, ), - child: InPatientDoctorCard( - doctorName: model.medicationForInPatient[index].pHRItemDescription, - profileUrl: 'sss', - branch: 'hamza', - clinic: 'basheer', - isPrescriptions: true, - appointmentDate: AppDateUtils.getDateTimeFromServerFormat( - model.medicationForInPatient[index].prescriptionDatetime, - ), - createdBy: model.medicationForInPatient[index].createdBy.toString(), - ))), + createdBy: model.medicationForInPatient[index].createdBy.toString(), + )); + }), if (model.medicationForInPatient.length == 0) Center( child: Column( From 00b7aaf32ad7dbf459bfdbb414a8267092a164c8 Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Wed, 8 Sep 2021 11:23:59 +0300 Subject: [PATCH 3/5] fix sick leave --- .../sick_leave/sick_leave_patient_model.dart | 56 +++++++++---------- lib/screens/sick-leave/add-sickleave.dart | 11 ++-- 2 files changed, 34 insertions(+), 33 deletions(-) diff --git a/lib/core/model/sick_leave/sick_leave_patient_model.dart b/lib/core/model/sick_leave/sick_leave_patient_model.dart index 43dbdb05..1e79833c 100644 --- a/lib/core/model/sick_leave/sick_leave_patient_model.dart +++ b/lib/core/model/sick_leave/sick_leave_patient_model.dart @@ -1,41 +1,41 @@ import 'package:doctor_app_flutter/widgets/shared/StarRating.dart'; class SickLeavePatientModel { - String setupID; - int projectID; - int patientID; - int patientType; - int clinicID; - int doctorID; - int requestNo; - String requestDate; - int sickLeaveDays; - int appointmentNo; - int admissionNo; - int actualDoctorRate; - String appointmentDate; - String clinicName; - String doctorImageURL; - String doctorName; - int doctorRate; - String doctorTitle; - int gender; - String genderDescription; + dynamic setupID; + dynamic projectID; + dynamic patientID; + dynamic patientType; + dynamic clinicID; + dynamic doctorID; + dynamic requestNo; + dynamic requestDate; + dynamic sickLeaveDays; + dynamic appointmentNo; + dynamic admissionNo; + dynamic actualDoctorRate; + dynamic appointmentDate; + dynamic clinicName; + dynamic doctorImageURL; + dynamic doctorName; + dynamic doctorRate; + dynamic doctorTitle; + dynamic gender; + dynamic genderDescription; bool isActiveDoctorProfile; bool isDoctorAllowVedioCall; bool isExecludeDoctor; bool isInOutPatient; - String isInOutPatientDescription; - String isInOutPatientDescriptionN; + dynamic isInOutPatientDescription; + dynamic isInOutPatientDescriptionN; bool isLiveCareAppointment; - int noOfPatientsRate; + dynamic noOfPatientsRate; dynamic patientName; - String projectName; - String qR; + dynamic projectName; + dynamic qR; // List speciality; - String strRequestDate; - String startDate; - String endDate; + dynamic strRequestDate; + dynamic startDate; + dynamic endDate; dynamic isExtendedLeave; dynamic noOfDays; dynamic patientMRN; diff --git a/lib/screens/sick-leave/add-sickleave.dart b/lib/screens/sick-leave/add-sickleave.dart index d7dffd8d..db8dd3c2 100644 --- a/lib/screens/sick-leave/add-sickleave.dart +++ b/lib/screens/sick-leave/add-sickleave.dart @@ -181,7 +181,7 @@ class AddSickLeavScreen extends StatelessWidget { children: [ AppText(TranslationBase.of(context).daysSickleave + ": "), AppText( - item.sickLeaveDays ?? item.noOfDays.toString(), + item.sickLeaveDays.toString() ?? item.noOfDays.toString(), fontWeight: FontWeight.bold, ), ], @@ -211,10 +211,11 @@ class AddSickLeavScreen extends StatelessWidget { child: AppText( AppDateUtils.getDayMonthYearDateFormatted( item.startDate.contains("/Date(") - ? AppDateUtils.convertStringToDate(item.endDate) - .add(Duration(days: item.noOfDays)) - : DateTime.parse(item.startDate) - .add(Duration(days: item.noOfDays))), + ? AppDateUtils.convertStringToDate(item.endDate ?? "") + .add(Duration( + days: item.noOfDays ?? item.sickLeaveDays)) + : DateTime.parse(item.startDate ?? "") + .add(Duration(days: item.noOfDays ?? ""))), fontWeight: FontWeight.bold, ), ) From aae1cba405c18ea087f7118e0be9ef3683676676 Mon Sep 17 00:00:00 2001 From: mosazaid Date: Wed, 8 Sep 2021 15:11:37 +0300 Subject: [PATCH 4/5] re-design UCAF to pager --- lib/config/config.dart | 4 +- .../viewModel/patient-ucaf-viewmodel.dart | 12 +- lib/routes.dart | 7 +- lib/screens/patients/InPatientPage.dart | 56 +++-- .../profile/UCAF/UCAF-detail-screen.dart | 144 ++++-------- .../profile/UCAF/UCAF-input-screen.dart | 80 ++----- .../profile/UCAF/ucaf_pager_screen.dart | 214 ++++++++++++++++++ 7 files changed, 322 insertions(+), 195 deletions(-) create mode 100644 lib/screens/patients/profile/UCAF/ucaf_pager_screen.dart diff --git a/lib/config/config.dart b/lib/config/config.dart index def2806c..7002bc3a 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -5,8 +5,8 @@ const ONLY_NUMBERS = "[0-9]"; const ONLY_LETTERS = "[a-zA-Z &'\"]"; const ONLY_DATE = "[0-9/]"; const BASE_URL_LIVE_CARE = 'https://livecare.hmg.com/'; -const BASE_URL = 'https://hmgwebservices.com/'; -// const BASE_URL = 'https://uat.hmgwebservices.com/'; +// const BASE_URL = 'https://hmgwebservices.com/'; +const BASE_URL = 'https://uat.hmgwebservices.com/'; const PHARMACY_ITEMS_URL = "Services/Lists.svc/REST/GetPharmcyItems_Region_enh"; const PHARMACY_LIST_URL = "Services/Patients.svc/REST/GetPharmcyList"; const PATIENT_PROGRESS_NOTE_URL = "Services/DoctorApplication.svc/REST/GetProgressNoteForInPatient"; diff --git a/lib/core/viewModel/patient-ucaf-viewmodel.dart b/lib/core/viewModel/patient-ucaf-viewmodel.dart index b6887061..fab030d9 100644 --- a/lib/core/viewModel/patient-ucaf-viewmodel.dart +++ b/lib/core/viewModel/patient-ucaf-viewmodel.dart @@ -36,6 +36,8 @@ class UcafViewModel extends BaseViewModel { List get orderProcedures => _ucafService.orderProcedureList; + Function saveUCAFOnTap; + String selectedLanguage; String heightCm = "0"; String weightKg = "0"; @@ -56,7 +58,7 @@ class UcafViewModel extends BaseViewModel { } Future getUCAFData(PatiantInformtion patient) async { - setState(ViewState.Busy); + // setState(ViewState.Busy); String from; String to; @@ -112,7 +114,7 @@ class UcafViewModel extends BaseViewModel { Future getPatientAssessment(PatiantInformtion patient) async { if (patientAssessmentList.isEmpty) { - setState(ViewState.Busy); + // setState(ViewState.Busy); await _ucafService.getPatientAssessment(patient); if (_ucafService.hasError) { error = _ucafService.error; @@ -139,7 +141,7 @@ class UcafViewModel extends BaseViewModel { Future getOrderProcedures(PatiantInformtion patient) async { if (orderProcedures.isEmpty) { - setState(ViewState.Busy); + // setState(ViewState.Busy); await _ucafService.getOrderProcedures(patient); if (_ucafService.hasError) { error = _ucafService.error; @@ -152,7 +154,7 @@ class UcafViewModel extends BaseViewModel { Future getPrescription(PatiantInformtion patient) async { if (prescriptionList == null) { - setState(ViewState.Busy); + // setState(ViewState.Busy); await _ucafService.getPrescription(patient); if (_ucafService.hasError) { error = _ucafService.error; @@ -190,7 +192,7 @@ class UcafViewModel extends BaseViewModel { } Future postUCAF(PatiantInformtion patient) async { - setState(ViewState.Busy); + // setState(ViewState.Busy); await _ucafService.postUCAF(patient); if (_ucafService.hasError) { error = _ucafService.error; diff --git a/lib/routes.dart b/lib/routes.dart index 742ac118..712db98c 100644 --- a/lib/routes.dart +++ b/lib/routes.dart @@ -3,8 +3,6 @@ import 'package:doctor_app_flutter/screens/live_care/end_call_screen.dart'; import 'package:doctor_app_flutter/screens/medical-file/health_summary_page.dart'; import 'package:doctor_app_flutter/screens/patients/ECGPage.dart'; import 'package:doctor_app_flutter/screens/patients/insurance_approval_screen_patient.dart'; -import 'package:doctor_app_flutter/screens/patients/profile/UCAF/UCAF-detail-screen.dart'; -import 'package:doctor_app_flutter/screens/patients/profile/UCAF/UCAF-input-screen.dart'; import 'package:doctor_app_flutter/screens/patients/profile/lab_result/all_lab_special_result_page.dart'; import 'package:doctor_app_flutter/screens/patients/profile/lab_result/labs_home_page.dart'; import 'package:doctor_app_flutter/screens/patients/profile/medical_report/AddVerifyMedicalReport.dart'; @@ -22,6 +20,7 @@ import 'package:doctor_app_flutter/screens/sick-leave/show-sickleave.dart'; import 'package:doctor_app_flutter/screens/auth/verification_methods_screen.dart'; import './screens/auth/login_screen.dart'; +import 'screens/patients/profile/UCAF/ucaf_pager_screen.dart'; import 'screens/patients/profile/profile_screen/patient_profile_screen.dart'; import './screens/patients/profile/vital_sign/vital_sign_details_screen.dart'; import 'landing_page.dart'; @@ -109,8 +108,8 @@ var routes = { ORDER_PRESCRIPTION_NEW: (_) => PrescriptionsPage(), ORDER_PROCEDURE: (_) => ProcedureScreen(), MY_REFERRAL_DETAIL: (_) => MyReferralDetailScreen(), - PATIENT_UCAF_REQUEST: (_) => UCAFInputScreen(), - PATIENT_UCAF_DETAIL: (_) => UcafDetailScreen(), + PATIENT_UCAF_REQUEST: (_) => UCAFPagerScreen(), + // PATIENT_UCAF_DETAIL: (_) => UcafDetailScreen(), PATIENT_ECG: (_) => ECGPage(), ALL_SPECIAL_LAB_RESULT: (_) => AllLabSpecialResult(), }; diff --git a/lib/screens/patients/InPatientPage.dart b/lib/screens/patients/InPatientPage.dart index 3b59e546..b5723c5e 100644 --- a/lib/screens/patients/InPatientPage.dart +++ b/lib/screens/patients/InPatientPage.dart @@ -100,6 +100,7 @@ class _InPatientPageState extends State { margin: EdgeInsets.symmetric(horizontal: 16.0), child: SingleChildScrollView( child: Column( + // mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ ListView.builder( @@ -118,15 +119,15 @@ class _InPatientPageState extends State { arrivalType: "1", isInpatient: true, isMyPatient: widget - .patientSearchViewModel - .filteredInPatientItems[ - index] - .doctorId == + .patientSearchViewModel + .filteredInPatientItems[ + index] + .doctorId == widget.patientSearchViewModel .doctorProfile.doctorID, onTap: () { FocusScopeNode currentFocus = - FocusScope.of(context); + FocusScope.of(context); if (!currentFocus .hasPrimaryFocus) { currentFocus.unfocus(); @@ -145,10 +146,10 @@ class _InPatientPageState extends State { "isInpatient": true, "arrivalType": "1", "isMyPatient": widget - .patientSearchViewModel - .filteredInPatientItems[ - index] - .doctorId == + .patientSearchViewModel + .filteredInPatientItems[ + index] + .doctorId == widget .patientSearchViewModel .doctorProfile @@ -157,12 +158,12 @@ class _InPatientPageState extends State { }, ); else if (widget - .patientSearchViewModel - .filteredInPatientItems[ - index] - .doctorId == - widget.patientSearchViewModel - .doctorProfile.doctorID && + .patientSearchViewModel + .filteredInPatientItems[ + index] + .doctorId == + widget.patientSearchViewModel + .doctorProfile.doctorID && widget.isMyInPatient) return PatientCard( patientInfo: widget @@ -172,15 +173,15 @@ class _InPatientPageState extends State { arrivalType: "1", isInpatient: true, isMyPatient: widget - .patientSearchViewModel - .filteredInPatientItems[ - index] - .doctorId == + .patientSearchViewModel + .filteredInPatientItems[ + index] + .doctorId == widget.patientSearchViewModel .doctorProfile.doctorID, onTap: () { FocusScopeNode currentFocus = - FocusScope.of(context); + FocusScope.of(context); if (!currentFocus .hasPrimaryFocus) { currentFocus.unfocus(); @@ -199,10 +200,10 @@ class _InPatientPageState extends State { "isInpatient": true, "arrivalType": "1", "isMyPatient": widget - .patientSearchViewModel - .filteredInPatientItems[ - index] - .doctorId == + .patientSearchViewModel + .filteredInPatientItems[ + index] + .doctorId == widget .patientSearchViewModel .doctorProfile @@ -222,12 +223,7 @@ class _InPatientPageState extends State { ), ) : NoData() - : Center( - child: Container( - height: 300, - width: 300, - ), - ), + : NoData(), ], ), ); diff --git a/lib/screens/patients/profile/UCAF/UCAF-detail-screen.dart b/lib/screens/patients/profile/UCAF/UCAF-detail-screen.dart index be08aec2..26a34ed2 100644 --- a/lib/screens/patients/profile/UCAF/UCAF-detail-screen.dart +++ b/lib/screens/patients/profile/UCAF/UCAF-detail-screen.dart @@ -9,6 +9,7 @@ import 'package:doctor_app_flutter/models/SOAP/order-procedure.dart'; import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/screens/patients/profile/UCAF/page-stepper-widget.dart'; +import 'package:doctor_app_flutter/screens/patients/profile/UCAF/ucaf_pager_screen.dart'; import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart'; import 'package:doctor_app_flutter/util/helpers.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; @@ -22,33 +23,63 @@ import 'package:hexcolor/hexcolor.dart'; import '../../../../routes.dart'; class UcafDetailScreen extends StatefulWidget { + final PatiantInformtion patient; + final UcafViewModel model; + final Function changeLoadingState; + + UcafDetailScreen(this.patient, this.model, {this.changeLoadingState}); + @override - _UcafDetailScreenState createState() => _UcafDetailScreenState(); + _UcafDetailScreenState createState() => _UcafDetailScreenState(this.patient, this.model); } class _UcafDetailScreenState extends State { + + final PatiantInformtion patient; + final UcafViewModel model; + + UcafViewModel ucafModel; + int _activeTap = 0; + _UcafDetailScreenState(this.patient, this.model); + @override - Widget build(BuildContext context) { - final routeArgs = ModalRoute.of(context).settings.arguments as Map; - PatiantInformtion patient = routeArgs['patient']; - String patientType = routeArgs['patientType']; - String arrivalType = routeArgs['arrivalType']; + void initState() { + model.saveUCAFOnTap = () async{ + widget.changeLoadingState(true); + await ucafModel.postUCAF(patient); + widget.changeLoadingState(false); + if (ucafModel.state == ViewState.Idle) { + DrAppToastMsg.showSuccesToast( + TranslationBase.of(context) + .postUcafSuccessMsg); + Navigator.of(context).popUntil((route) { + return route.settings.name == + PATIENTS_PROFILE; + }); + } else { + DrAppToastMsg.showErrorToast(ucafModel.error); + } + }; + super.initState(); + } + @override + Widget build(BuildContext context) { final screenSize = MediaQuery.of(context).size; return BaseView( onModelReady: (model) async { + ucafModel = model; model.resetDataInFirst(); await model.getLanguage(); await model.getPatientAssessment(patient); + widget.changeLoadingState(false); }, builder: (_, model, w) => AppScaffold( baseViewModel: model, - isShowAppBar: true, - appBar: PatientProfileAppBar(patient), - appBarTitle: TranslationBase.of(context).ucaf, + isShowAppBar: false, body: Column( children: [ Expanded( @@ -57,35 +88,6 @@ class _UcafDetailScreenState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - // PatientHeaderWidgetNoAvatar(patient), - Container( - margin: EdgeInsets.all(16.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - AppText( - "${TranslationBase.of(context).patient}", - fontFamily: 'Poppins', - fontSize: SizeConfig.textMultiplier * 1.6, - fontWeight: FontWeight.w600, - ), - AppText( - "${TranslationBase.of(context).ucaf}", - fontFamily: 'Poppins', - fontSize: SizeConfig.textMultiplier * 3, - fontWeight: FontWeight.bold, - ) - ], - ), - ), - PageStepperWidget( - stepsCount: 2, - currentStepIndex: 2, - screenSize: screenSize, - ), - SizedBox( - height: 10, - ), Container( margin: EdgeInsets.symmetric( vertical: 16, horizontal: 16), @@ -106,64 +108,7 @@ class _UcafDetailScreenState extends State { ), ), ), - Container( - margin: EdgeInsets.symmetric(vertical: 8, horizontal: 16), - child: Row( - children: [ - Expanded( - child: Container( - child: AppButton( - title: TranslationBase.of(context).cancel, - hasBorder: true, - vPadding: 8, - hPadding: 8, - borderColor: Colors.white, - color: Colors.white, - fontColor: HexColor("#B8382B"), - fontSize: 2.2, - onPressed: () { - Navigator.of(context).popUntil((route) { - return route.settings.name == - PATIENTS_PROFILE; - }); - }, - ), - ), - ), - SizedBox( - width: 8, - ), - Expanded( - child: Container( - child: AppButton( - title: TranslationBase.of(context).save, - hasBorder: true, - vPadding: 8, - hPadding: 8, - borderColor: HexColor("#B8382B"), - color: HexColor("#B8382B"), - fontColor: Colors.white, - fontSize: 2.0, - onPressed: () async { - await model.postUCAF(patient); - if (model.state == ViewState.Idle) { - DrAppToastMsg.showSuccesToast( - TranslationBase.of(context) - .postUcafSuccessMsg); - Navigator.of(context).popUntil((route) { - return route.settings.name == - PATIENTS_PROFILE; - }); - } else { - DrAppToastMsg.showErrorToast(model.error); - } - }, - ), - ), - ), - ], - ), - ), + ], ), )); @@ -209,12 +154,18 @@ class _UcafDetailScreenState extends State { onTap: () async { print(__treatmentSteps.indexOf(item)); if (__treatmentSteps.indexOf(item) == 0) { + widget.changeLoadingState(true); await model.getPatientAssessment(patient); + widget.changeLoadingState(false); } else if (__treatmentSteps.indexOf(item) == 1) { + widget.changeLoadingState(true); await model.getPrescription(patient); + widget.changeLoadingState(false); } if (__treatmentSteps.indexOf(item) == 2) { + widget.changeLoadingState(true); await model.getOrderProcedures(patient); + widget.changeLoadingState(false); } setState(() { _activeTap = __treatmentSteps.indexOf(item); @@ -288,6 +239,7 @@ class _UcafDetailScreenState extends State { ]; } } + } class DiagnosisWidget extends StatelessWidget { diff --git a/lib/screens/patients/profile/UCAF/UCAF-input-screen.dart b/lib/screens/patients/profile/UCAF/UCAF-input-screen.dart index 3bbc6637..ab9a3c54 100644 --- a/lib/screens/patients/profile/UCAF/UCAF-input-screen.dart +++ b/lib/screens/patients/profile/UCAF/UCAF-input-screen.dart @@ -19,11 +19,20 @@ import 'package:hexcolor/hexcolor.dart'; import '../../../../routes.dart'; class UCAFInputScreen extends StatefulWidget { + final PatiantInformtion patient; + final Function changeLoadingState; + + UCAFInputScreen(this.patient, {this.changeLoadingState}); + @override - _UCAFInputScreenState createState() => _UCAFInputScreenState(); + _UCAFInputScreenState createState() => _UCAFInputScreenState(this.patient); } class _UCAFInputScreenState extends State { + final PatiantInformtion patient; + + _UCAFInputScreenState(this.patient); + bool _inPatient = false; bool _emergencyCase = false; final _durationOfIllnessController = TextEditingController(); @@ -53,21 +62,15 @@ class _UCAFInputScreenState extends State { @override Widget build(BuildContext context) { - final routeArgs = ModalRoute.of(context).settings.arguments as Map; - PatiantInformtion patient = routeArgs['patient']; - String patientType = routeArgs['patientType']; - String arrivalType = routeArgs['arrivalType']; - - final screenSize = MediaQuery.of(context).size; - return BaseView( - onModelReady: (model) => model.getUCAFData(patient), + onModelReady: (model) async { + // widget.changeLoadingState(true); + await model.getUCAFData(patient); + widget.changeLoadingState(false); + }, builder: (_, model, w) => AppScaffold( baseViewModel: model, - isShowAppBar: true, - appBar: PatientProfileAppBar( - patient), - appBarTitle: TranslationBase.of(context).ucaf, + isShowAppBar: false, body: model.patientVitalSignsHistory.length > 0 && model.patientChiefComplaintList != null && model.patientChiefComplaintList.length > 0 @@ -79,31 +82,6 @@ class _UCAFInputScreenState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ // PatientHeaderWidgetNoAvatar(patient), - Container( - margin: EdgeInsets.all(16.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - AppText( - "${TranslationBase.of(context).patient}", - fontFamily: 'Poppins', - fontSize: SizeConfig.textMultiplier * 1.6, - fontWeight: FontWeight.w600, - ), - AppText( - "${TranslationBase.of(context).ucaf}", - fontFamily: 'Poppins', - fontSize: SizeConfig.textMultiplier * 3, - fontWeight: FontWeight.bold, - ) - ], - ), - ), - PageStepperWidget( - stepsCount: 2, - currentStepIndex: 1, - screenSize: screenSize, - ), Container( margin: EdgeInsets.symmetric( vertical: 0, horizontal: 16), @@ -263,7 +241,7 @@ class _UCAFInputScreenState extends State { fontWeight: FontWeight.w700, color: Color(0xFF2E303A), ), - /* SizedBox( + /* SizedBox( height: 4, ), AppText( @@ -323,7 +301,7 @@ class _UCAFInputScreenState extends State { SizedBox( height: 8, ), - /* AppTextFieldCustom( + /* AppTextFieldCustom( hintText: TranslationBase.of(context).other, dropDownText: TranslationBase.of(context).none, enabled: false, @@ -400,21 +378,6 @@ class _UCAFInputScreenState extends State { ), ), ), - Container( - margin: EdgeInsets.symmetric(horizontal: 16, vertical: 8), - child: AppButton( - title: TranslationBase.of(context).next, - color: HexColor("#D02127"), - onPressed: () { - Navigator.of(context).pushNamed(PATIENT_UCAF_DETAIL, - arguments: { - 'patient': patient, - 'patientType': patientType, - 'arrivalType': arrivalType - }); - }, - ), - ), ], ) : Center( @@ -428,9 +391,10 @@ class _UCAFInputScreenState extends State { Padding( padding: const EdgeInsets.all(8.0), child: AppText( - model.patientVitalSignsHistory.length == 0 - ? TranslationBase.of(context).vitalSignEmptyMsg - : TranslationBase.of(context).chiefComplaintEmptyMsg, + model.patientVitalSignsHistory.length == 0 + ? TranslationBase.of(context).vitalSignEmptyMsg + : TranslationBase.of(context) + .chiefComplaintEmptyMsg, fontWeight: FontWeight.normal, textAlign: TextAlign.center, color: HexColor("#B8382B"), diff --git a/lib/screens/patients/profile/UCAF/ucaf_pager_screen.dart b/lib/screens/patients/profile/UCAF/ucaf_pager_screen.dart new file mode 100644 index 00000000..8c38ece7 --- /dev/null +++ b/lib/screens/patients/profile/UCAF/ucaf_pager_screen.dart @@ -0,0 +1,214 @@ +import 'package:doctor_app_flutter/config/size_config.dart'; +import 'package:doctor_app_flutter/core/viewModel/patient-ucaf-viewmodel.dart'; +import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; +import 'package:doctor_app_flutter/screens/base/base_view.dart'; +import 'package:doctor_app_flutter/screens/patients/profile/UCAF/page-stepper-widget.dart'; +import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; +import 'package:doctor_app_flutter/widgets/patients/profile/patient-profile-app-bar.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/buttons/app_buttons_widget.dart'; +import 'package:flutter/material.dart'; + +import '../../../../routes.dart'; +import 'UCAF-detail-screen.dart'; +import 'UCAF-input-screen.dart'; + +class UCAFPagerScreen extends StatefulWidget { + const UCAFPagerScreen({Key key}) : super(key: key); + + @override + _UCAFPagerScreenState createState() => _UCAFPagerScreenState(); +} + +class _UCAFPagerScreenState extends State + with TickerProviderStateMixin { + PageController _controller; + int _currentIndex = 0; + bool _isLoading = true; + + PatiantInformtion patient; + String patientType; + String arrivalType; + + changePageViewIndex(pageIndex, {isChangeState = true}) { + if (pageIndex != _currentIndex && isChangeState) changeLoadingState(true); + _controller.jumpToPage(pageIndex); + setState(() { + _currentIndex = pageIndex; + }); + } + + void changeLoadingState(bool isLoading) { + setState(() { + _isLoading = isLoading; + }); + } + + @override + void initState() { + _controller = new PageController(); + super.initState(); + } + + @override + Widget build(BuildContext context) { + final routeArgs = ModalRoute.of(context).settings.arguments as Map; + patient = routeArgs['patient']; + patientType = routeArgs['patientType']; + arrivalType = routeArgs['arrivalType']; + + final screenSize = MediaQuery.of(context).size; + + return BaseView( + builder: (_, model, w) => AppScaffold( + isShowAppBar: true, + isLoading: _isLoading, + appBar: PatientProfileAppBar(patient), + appBarTitle: TranslationBase.of(context).ucaf, + body: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Container( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // PatientHeaderWidgetNoAvatar(patient), + Container( + margin: EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AppText( + "${TranslationBase.of(context).patient}", + fontFamily: 'Poppins', + fontSize: SizeConfig.textMultiplier * 1.6, + fontWeight: FontWeight.w600, + ), + AppText( + "${TranslationBase.of(context).ucaf}", + fontFamily: 'Poppins', + fontSize: SizeConfig.textMultiplier * 3, + fontWeight: FontWeight.bold, + ) + ], + ), + ), + PageStepperWidget( + stepsCount: 2, + currentStepIndex: _currentIndex + 1, + screenSize: screenSize, + ), + SizedBox( + height: 10, + ), + Expanded( + child: Container( + color: Theme.of(context).scaffoldBackgroundColor, + child: PageView( + physics: NeverScrollableScrollPhysics(), + controller: _controller, + onPageChanged: (index) { + setState(() { + _currentIndex = index; + }); + }, + scrollDirection: Axis.horizontal, + children: [ + UCAFInputScreen( + patient, + changeLoadingState: changeLoadingState, + ), + UcafDetailScreen( + patient, + model, + changeLoadingState: changeLoadingState, + ), + ]), + ), + ), + ], + ), + ), + ), + _isLoading + ? Container( + height: 0, + ) + : ucafButtons(model), + ], + ), + )); + } + + Widget ucafButtons(UcafViewModel model) { + switch (_currentIndex) { + case 0: + return Container( + margin: EdgeInsets.symmetric(horizontal: 16, vertical: 8), + child: AppButton( + title: TranslationBase.of(context).next, + color: Color(0xFFD02127), + onPressed: () { + changePageViewIndex(1); + // Navigator.of(context).pushNamed(PATIENT_UCAF_DETAIL, arguments: { + // 'patient': patient, + // 'patientType': patientType, + // 'arrivalType': arrivalType + // }); + }, + ), + ); + case 1: + return Container( + margin: EdgeInsets.symmetric(vertical: 8, horizontal: 16), + child: Row( + children: [ + Expanded( + child: Container( + child: AppButton( + title: TranslationBase.of(context).cancel, + hasBorder: true, + vPadding: 8, + hPadding: 8, + borderColor: Colors.white, + color: Colors.white, + fontColor: Color(0xFFB8382B), + fontSize: 2.2, + onPressed: () { + Navigator.of(context).popUntil((route) { + return route.settings.name == PATIENTS_PROFILE; + }); + }, + ), + ), + ), + SizedBox( + width: 8, + ), + Expanded( + child: Container( + child: AppButton( + title: TranslationBase.of(context).save, + hasBorder: true, + vPadding: 8, + hPadding: 8, + borderColor: Color(0xFFB8382B), + color: Color(0xFFB8382B), + fontColor: Colors.white, + fontSize: 2.0, + onPressed: () { + model.saveUCAFOnTap(); + }, + ), + ), + ), + ], + ), + ); + default: + return Container(); + } + } +} From 96ad55b55240508b79e4b317c6f1e3e274795dd2 Mon Sep 17 00:00:00 2001 From: mosazaid Date: Wed, 8 Sep 2021 15:31:30 +0300 Subject: [PATCH 5/5] re-design UCAF to pager --- lib/core/viewModel/patient-ucaf-viewmodel.dart | 6 +++++- lib/screens/patients/profile/UCAF/UCAF-detail-screen.dart | 2 +- lib/screens/patients/profile/UCAF/UCAF-input-screen.dart | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/core/viewModel/patient-ucaf-viewmodel.dart b/lib/core/viewModel/patient-ucaf-viewmodel.dart index fab030d9..1dc34679 100644 --- a/lib/core/viewModel/patient-ucaf-viewmodel.dart +++ b/lib/core/viewModel/patient-ucaf-viewmodel.dart @@ -47,7 +47,11 @@ class UcafViewModel extends BaseViewModel { String respirationBeatPerMinute = "0"; String bloodPressure = "0 / 0"; - resetDataInFirst() { + resetDataInFirst({bool firstPage = true}) { + if(firstPage){ + _ucafService.patientVitalSignsHistory = []; + _ucafService.patientChiefComplaintList = []; + } _ucafService.patientAssessmentList = []; _ucafService.orderProcedureList = []; _ucafService.prescriptionList = null; diff --git a/lib/screens/patients/profile/UCAF/UCAF-detail-screen.dart b/lib/screens/patients/profile/UCAF/UCAF-detail-screen.dart index 26a34ed2..ea4511e3 100644 --- a/lib/screens/patients/profile/UCAF/UCAF-detail-screen.dart +++ b/lib/screens/patients/profile/UCAF/UCAF-detail-screen.dart @@ -72,7 +72,7 @@ class _UcafDetailScreenState extends State { return BaseView( onModelReady: (model) async { ucafModel = model; - model.resetDataInFirst(); + model.resetDataInFirst(firstPage: false); await model.getLanguage(); await model.getPatientAssessment(patient); widget.changeLoadingState(false); diff --git a/lib/screens/patients/profile/UCAF/UCAF-input-screen.dart b/lib/screens/patients/profile/UCAF/UCAF-input-screen.dart index ab9a3c54..9960a1b3 100644 --- a/lib/screens/patients/profile/UCAF/UCAF-input-screen.dart +++ b/lib/screens/patients/profile/UCAF/UCAF-input-screen.dart @@ -64,7 +64,7 @@ class _UCAFInputScreenState extends State { Widget build(BuildContext context) { return BaseView( onModelReady: (model) async { - // widget.changeLoadingState(true); + model.resetDataInFirst(); await model.getUCAFData(patient); widget.changeLoadingState(false); },