add new prescription
parent
1f770793fd
commit
9461d3d4a1
@ -1,238 +0,0 @@
|
|||||||
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';
|
|
||||||
import 'package:doctor_app_flutter/core/model/Prescriptions/prescription_report.dart';
|
|
||||||
import 'package:doctor_app_flutter/core/model/Prescriptions/prescription_report_enh.dart';
|
|
||||||
import 'package:doctor_app_flutter/core/model/Prescriptions/prescriptions_order.dart';
|
|
||||||
import 'package:doctor_app_flutter/core/model/Prescriptions/request_get_list_pharmacy_for_prescriptions.dart';
|
|
||||||
import 'package:doctor_app_flutter/core/model/Prescriptions/request_prescription_report.dart';
|
|
||||||
import 'package:doctor_app_flutter/core/model/Prescriptions/request_prescription_report_enh.dart';
|
|
||||||
import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart';
|
|
||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
|
|
||||||
import '../../base/base_service.dart';
|
|
||||||
|
|
||||||
class PrescriptionsService extends BaseService {
|
|
||||||
List<Prescriptions> prescriptionsList = List();
|
|
||||||
List<GetMedicationForInPatientModel> medicationForInPatient = List();
|
|
||||||
List<PrescriptionsOrder> prescriptionsOrderList = List();
|
|
||||||
List<PrescriotionInPatient> prescriptionInPatientList = List();
|
|
||||||
|
|
||||||
InPatientPrescriptionRequestModel _inPatientPrescriptionRequestModel =
|
|
||||||
InPatientPrescriptionRequestModel();
|
|
||||||
GetMedicationForInPatientRequestModel _getMedicationForInPatientRequestModel =
|
|
||||||
GetMedicationForInPatientRequestModel();
|
|
||||||
|
|
||||||
Future getPrescriptionInPatient({int mrn, String adn}) async {
|
|
||||||
_inPatientPrescriptionRequestModel = InPatientPrescriptionRequestModel(
|
|
||||||
patientMRN: mrn,
|
|
||||||
admissionNo: adn,
|
|
||||||
);
|
|
||||||
hasError = false;
|
|
||||||
prescriptionInPatientList.clear();
|
|
||||||
|
|
||||||
await baseAppClient.post(GET_PRESCRIPTION_IN_PATIENT,
|
|
||||||
onSuccess: (dynamic response, int statusCode) {
|
|
||||||
prescriptionsList.clear();
|
|
||||||
response['List_PrescriptionReportForInPatient'].forEach((prescriptions) {
|
|
||||||
prescriptionInPatientList
|
|
||||||
.add(PrescriotionInPatient.fromJson(prescriptions));
|
|
||||||
});
|
|
||||||
}, onFailure: (String error, int statusCode) {
|
|
||||||
hasError = true;
|
|
||||||
super.error = error;
|
|
||||||
}, body: _inPatientPrescriptionRequestModel.toJson());
|
|
||||||
}
|
|
||||||
|
|
||||||
Future getPrescriptions(PatiantInformtion patient) async {
|
|
||||||
hasError = false;
|
|
||||||
Map<String, dynamic> body = Map();
|
|
||||||
body['isDentalAllowedBackend'] = false;
|
|
||||||
await baseAppClient.postPatient(PRESCRIPTIONS, patient: patient,
|
|
||||||
onSuccess: (dynamic response, int statusCode) {
|
|
||||||
prescriptionsList.clear();
|
|
||||||
response['PatientPrescriptionList'].forEach((prescriptions) {
|
|
||||||
prescriptionsList.add(Prescriptions.fromJson(prescriptions));
|
|
||||||
});
|
|
||||||
}, onFailure: (String error, int statusCode) {
|
|
||||||
hasError = true;
|
|
||||||
super.error = error;
|
|
||||||
}, body: body);
|
|
||||||
}
|
|
||||||
|
|
||||||
RequestPrescriptionReport _requestPrescriptionReport =
|
|
||||||
RequestPrescriptionReport(
|
|
||||||
appointmentNo: 0, isDentalAllowedBackend: false);
|
|
||||||
List<PrescriptionReport> prescriptionReportList = List();
|
|
||||||
|
|
||||||
Future getPrescriptionReport(
|
|
||||||
{Prescriptions prescriptions,
|
|
||||||
@required PatiantInformtion patient}) async {
|
|
||||||
hasError = false;
|
|
||||||
_requestPrescriptionReport.dischargeNo = prescriptions.dischargeNo;
|
|
||||||
_requestPrescriptionReport.projectID = prescriptions.projectID;
|
|
||||||
_requestPrescriptionReport.clinicID = prescriptions.clinicID;
|
|
||||||
_requestPrescriptionReport.setupID = prescriptions.setupID;
|
|
||||||
_requestPrescriptionReport.episodeID = prescriptions.episodeID;
|
|
||||||
_requestPrescriptionReport.appointmentNo = prescriptions.appointmentNo;
|
|
||||||
|
|
||||||
await baseAppClient.postPatient(
|
|
||||||
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));
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
response['INP_GetPrescriptionReport_List'].forEach((prescriptions) {
|
|
||||||
prescriptionReportList
|
|
||||||
.add(PrescriptionReport.fromJson(prescriptions));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}, onFailure: (String error, int statusCode) {
|
|
||||||
hasError = true;
|
|
||||||
super.error = error;
|
|
||||||
}, body: _requestPrescriptionReport.toJson());
|
|
||||||
}
|
|
||||||
|
|
||||||
RequestGetListPharmacyForPrescriptions
|
|
||||||
requestGetListPharmacyForPrescriptions =
|
|
||||||
RequestGetListPharmacyForPrescriptions(
|
|
||||||
latitude: 0,
|
|
||||||
longitude: 0,
|
|
||||||
isDentalAllowedBackend: false,
|
|
||||||
);
|
|
||||||
List<PharmacyPrescriptions> pharmacyPrescriptionsList = List();
|
|
||||||
|
|
||||||
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) {
|
|
||||||
pharmacyPrescriptionsList.clear();
|
|
||||||
response['PharmList'].forEach((prescriptions) {
|
|
||||||
pharmacyPrescriptionsList
|
|
||||||
.add(PharmacyPrescriptions.fromJson(prescriptions));
|
|
||||||
});
|
|
||||||
}, onFailure: (String error, int statusCode) {
|
|
||||||
hasError = true;
|
|
||||||
super.error = error;
|
|
||||||
}, body: requestGetListPharmacyForPrescriptions.toJson());
|
|
||||||
}
|
|
||||||
|
|
||||||
RequestPrescriptionReportEnh _requestPrescriptionReportEnh =
|
|
||||||
RequestPrescriptionReportEnh(
|
|
||||||
isDentalAllowedBackend: false,
|
|
||||||
);
|
|
||||||
|
|
||||||
List<PrescriptionReportEnh> prescriptionReportEnhList = List();
|
|
||||||
|
|
||||||
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) {
|
|
||||||
if (prescriptionsOrder.appointmentNo == "0") {
|
|
||||||
if (element.dischargeNo == int.parse(prescriptionsOrder.dischargeID)) {
|
|
||||||
_requestPrescriptionReportEnh.appointmentNo = element.appointmentNo;
|
|
||||||
_requestPrescriptionReportEnh.clinicID = element.clinicID;
|
|
||||||
_requestPrescriptionReportEnh.projectID = element.projectID;
|
|
||||||
_requestPrescriptionReportEnh.episodeID = element.episodeID;
|
|
||||||
_requestPrescriptionReportEnh.setupID = element.setupID;
|
|
||||||
_requestPrescriptionReportEnh.dischargeNo = element.dischargeNo;
|
|
||||||
isInPatient = element.isInOutPatient;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (int.parse(prescriptionsOrder.appointmentNo) ==
|
|
||||||
element.appointmentNo) {
|
|
||||||
_requestPrescriptionReportEnh.appointmentNo = element.appointmentNo;
|
|
||||||
_requestPrescriptionReportEnh.clinicID = element.clinicID;
|
|
||||||
_requestPrescriptionReportEnh.projectID = element.projectID;
|
|
||||||
_requestPrescriptionReportEnh.episodeID = element.episodeID;
|
|
||||||
_requestPrescriptionReportEnh.setupID = element.setupID;
|
|
||||||
_requestPrescriptionReportEnh.dischargeNo = element.dischargeNo;
|
|
||||||
isInPatient = element.isInOutPatient;
|
|
||||||
|
|
||||||
///call inpGetPrescriptionReport
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
hasError = false;
|
|
||||||
|
|
||||||
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));
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
response['INP_GetPrescriptionReport_List'].forEach((prescriptions) {
|
|
||||||
PrescriptionReportEnh reportEnh =
|
|
||||||
PrescriptionReportEnh.fromJson(prescriptions);
|
|
||||||
reportEnh.itemDescription = prescriptions['ItemDescriptionN'];
|
|
||||||
prescriptionReportEnhList.add(reportEnh);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}, onFailure: (String error, int statusCode) {
|
|
||||||
hasError = true;
|
|
||||||
super.error = error;
|
|
||||||
}, body: _requestPrescriptionReportEnh.toJson());
|
|
||||||
}
|
|
||||||
|
|
||||||
Future getPrescriptionsOrders() async {
|
|
||||||
Map<String, dynamic> body = Map();
|
|
||||||
body['isDentalAllowedBackend'] = false;
|
|
||||||
await baseAppClient.post(GET_PRESCRIPTIONS_ALL_ORDERS,
|
|
||||||
onSuccess: (dynamic response, int statusCode) {
|
|
||||||
prescriptionsOrderList.clear();
|
|
||||||
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: patient.projectId,
|
|
||||||
);
|
|
||||||
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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,163 +0,0 @@
|
|||||||
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';
|
|
||||||
import 'package:doctor_app_flutter/core/model/Prescriptions/prescriptions_order.dart';
|
|
||||||
import 'package:doctor_app_flutter/core/service/patient_medical_file/prescription/prescriptions_service.dart';
|
|
||||||
import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
import '../../locator.dart';
|
|
||||||
import 'base_view_model.dart';
|
|
||||||
|
|
||||||
class PrescriptionsViewModel extends BaseViewModel {
|
|
||||||
FilterType filterType = FilterType.Clinic;
|
|
||||||
PrescriptionsService _prescriptionsService = locator<PrescriptionsService>();
|
|
||||||
|
|
||||||
List<PrescriptionsList> _prescriptionsOrderListClinic = List();
|
|
||||||
List<PrescriptionsList> _prescriptionsOrderListHospital = List();
|
|
||||||
|
|
||||||
List<PrescriptionReport> get prescriptionReportList =>
|
|
||||||
_prescriptionsService.prescriptionReportList;
|
|
||||||
|
|
||||||
List<Prescriptions> get prescriptionsList =>
|
|
||||||
_prescriptionsService.prescriptionsList;
|
|
||||||
|
|
||||||
List<PharmacyPrescriptions> get pharmacyPrescriptionsList =>
|
|
||||||
_prescriptionsService.pharmacyPrescriptionsList;
|
|
||||||
|
|
||||||
List<PrescriptionReportEnh> get prescriptionReportEnhList =>
|
|
||||||
_prescriptionsService.prescriptionReportEnhList;
|
|
||||||
|
|
||||||
List<PrescriptionsList> get prescriptionsOrderList =>
|
|
||||||
filterType == FilterType.Clinic
|
|
||||||
? _prescriptionsOrderListClinic
|
|
||||||
: _prescriptionsOrderListHospital;
|
|
||||||
|
|
||||||
List<GetMedicationForInPatientModel> get medicationForInPatient =>
|
|
||||||
_prescriptionsService.medicationForInPatient;
|
|
||||||
|
|
||||||
List<PrescriptionsList> _medicationForInPatient = List();
|
|
||||||
|
|
||||||
getPrescriptions(PatiantInformtion patient) async {
|
|
||||||
setState(ViewState.Busy);
|
|
||||||
await _prescriptionsService.getPrescriptions(patient);
|
|
||||||
if (_prescriptionsService.hasError) {
|
|
||||||
error = _prescriptionsService.error;
|
|
||||||
setState(ViewState.Error);
|
|
||||||
} else {
|
|
||||||
_filterList();
|
|
||||||
await _getPrescriptionsOrders();
|
|
||||||
|
|
||||||
setState(ViewState.Idle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_getPrescriptionsOrders() async {
|
|
||||||
await _prescriptionsService.getPrescriptionsOrders();
|
|
||||||
if (_prescriptionsService.hasError) {
|
|
||||||
error = _prescriptionsService.error;
|
|
||||||
setState(ViewState.ErrorLocal);
|
|
||||||
} else {
|
|
||||||
setState(ViewState.Idle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void _filterList() {
|
|
||||||
_prescriptionsService.prescriptionsList.forEach((element) {
|
|
||||||
/// PrescriptionsList list sort clinic
|
|
||||||
List<PrescriptionsList> prescriptionsByClinic =
|
|
||||||
_prescriptionsOrderListClinic
|
|
||||||
.where((elementClinic) =>
|
|
||||||
elementClinic.filterName == element.clinicDescription)
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
if (prescriptionsByClinic.length != 0) {
|
|
||||||
_prescriptionsOrderListClinic[
|
|
||||||
_prescriptionsOrderListClinic.indexOf(prescriptionsByClinic[0])]
|
|
||||||
.prescriptionsList
|
|
||||||
.add(element);
|
|
||||||
} else {
|
|
||||||
_prescriptionsOrderListClinic.add(PrescriptionsList(
|
|
||||||
filterName: element.clinicDescription, prescriptions: element));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// PrescriptionsList list sort via hospital
|
|
||||||
List<PrescriptionsList> prescriptionsByHospital =
|
|
||||||
_prescriptionsOrderListHospital
|
|
||||||
.where(
|
|
||||||
(elementClinic) => elementClinic.filterName == element.name,
|
|
||||||
)
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
if (prescriptionsByHospital.length != 0) {
|
|
||||||
_prescriptionsOrderListHospital[_prescriptionsOrderListHospital
|
|
||||||
.indexOf(prescriptionsByHospital[0])]
|
|
||||||
.prescriptionsList
|
|
||||||
.add(element);
|
|
||||||
} else {
|
|
||||||
_prescriptionsOrderListHospital.add(PrescriptionsList(
|
|
||||||
filterName: element.name, prescriptions: element));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
setFilterType(FilterType filterType) {
|
|
||||||
this.filterType = filterType;
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
getPrescriptionReport(
|
|
||||||
{Prescriptions prescriptions,
|
|
||||||
@required PatiantInformtion patient}) async {
|
|
||||||
setState(ViewState.Busy);
|
|
||||||
await _prescriptionsService.getPrescriptionReport(
|
|
||||||
prescriptions: prescriptions, patient: patient);
|
|
||||||
if (_prescriptionsService.hasError) {
|
|
||||||
error = _prescriptionsService.error;
|
|
||||||
setState(ViewState.ErrorLocal);
|
|
||||||
} else {
|
|
||||||
setState(ViewState.Idle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
getListPharmacyForPrescriptions(
|
|
||||||
{int itemId, @required PatiantInformtion patient}) async {
|
|
||||||
setState(ViewState.Busy);
|
|
||||||
await _prescriptionsService.getListPharmacyForPrescriptions(
|
|
||||||
itemId: itemId, patient: patient);
|
|
||||||
if (_prescriptionsService.hasError) {
|
|
||||||
error = _prescriptionsService.error;
|
|
||||||
setState(ViewState.Error);
|
|
||||||
} else {
|
|
||||||
setState(ViewState.Idle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
getPrescriptionReportEnh(
|
|
||||||
{PrescriptionsOrder prescriptionsOrder,
|
|
||||||
@required PatiantInformtion patient}) async {
|
|
||||||
setState(ViewState.Busy);
|
|
||||||
await _prescriptionsService.getPrescriptionReportEnh(
|
|
||||||
prescriptionsOrder: prescriptionsOrder, patient: patient);
|
|
||||||
if (_prescriptionsService.hasError) {
|
|
||||||
error = _prescriptionsService.error;
|
|
||||||
setState(ViewState.Error);
|
|
||||||
} else {
|
|
||||||
setState(ViewState.Idle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
getMedicationForInPatient(PatiantInformtion patient) async {
|
|
||||||
await _prescriptionsService.getMedicationForInPatient(patient);
|
|
||||||
if (_prescriptionsService.hasError) {
|
|
||||||
error = _prescriptionsService.error;
|
|
||||||
setState(ViewState.ErrorLocal);
|
|
||||||
} else {
|
|
||||||
setState(ViewState.Idle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -0,0 +1,213 @@
|
|||||||
|
import 'package:doctor_app_flutter/core/viewModel/prescription/prescription_view_model.dart';
|
||||||
|
import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart';
|
||||||
|
import 'package:doctor_app_flutter/screens/base/base_view.dart';
|
||||||
|
import 'package:doctor_app_flutter/screens/prescription/prescriptions_items/prescription_items_in_patient.dart';
|
||||||
|
import 'package:doctor_app_flutter/screens/prescription/prescriptions_items/prescription_items_out_patient.dart';
|
||||||
|
import 'package:doctor_app_flutter/screens/procedures/ProcedureType.dart';
|
||||||
|
import 'package:doctor_app_flutter/screens/procedures/base_add_procedure_tab_page.dart';
|
||||||
|
import 'package:doctor_app_flutter/util/date-utils.dart';
|
||||||
|
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
|
||||||
|
import 'package:doctor_app_flutter/widgets/patients/patient_service_title.dart';
|
||||||
|
import 'package:doctor_app_flutter/widgets/patients/profile/add-order/addNewOrder.dart';
|
||||||
|
import 'package:doctor_app_flutter/widgets/patients/profile/app_bar/patient-profile-app-bar.dart';
|
||||||
|
import 'package:doctor_app_flutter/widgets/shared/app_scaffold_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:doctor_app_flutter/widgets/transitions/slide_up_page.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import '../../util/helpers.dart';
|
||||||
|
import '../../widgets/shared/errors/error_message.dart';
|
||||||
|
|
||||||
|
class NewPrescriptionsPage extends StatelessWidget {
|
||||||
|
@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'];
|
||||||
|
bool isInpatient = routeArgs['isInpatient'];
|
||||||
|
bool isFromLiveCare = routeArgs['isFromLiveCare'];
|
||||||
|
return BaseView<PrescriptionViewModel>(
|
||||||
|
onModelReady: (model) async {
|
||||||
|
model.getPrescriptionListNew(
|
||||||
|
mrn: patient.patientMRN, appNo: patient.appointmentNo);
|
||||||
|
},
|
||||||
|
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: SingleChildScrollView(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: <Widget>[
|
||||||
|
SizedBox(
|
||||||
|
height: 12,
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
ServiceTitle(
|
||||||
|
title: TranslationBase.of(context).orders,
|
||||||
|
subTitle:
|
||||||
|
TranslationBase.of(context).prescriptions,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if ((patient.patientStatusType != null &&
|
||||||
|
patient.patientStatusType == 43) ||
|
||||||
|
(isFromLiveCare && patient.appointmentNo != null))
|
||||||
|
AddNewOrder(
|
||||||
|
onTap: () {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
SlideUpPageRoute(
|
||||||
|
widget: BaseAddProcedureTabPage(
|
||||||
|
patient: patient,
|
||||||
|
prescriptionModel: model,
|
||||||
|
procedureType:
|
||||||
|
ProcedureType.PRESCRIPTION,
|
||||||
|
),
|
||||||
|
settingRoute: 'AddProcedureTabPage'),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
label: TranslationBase.of(context)
|
||||||
|
.applyForNewPrescriptionsOrder,
|
||||||
|
),
|
||||||
|
ListView.builder(
|
||||||
|
physics: BouncingScrollPhysics(),
|
||||||
|
itemCount: model.prescriptionsList.length,
|
||||||
|
shrinkWrap: true,
|
||||||
|
itemBuilder: (BuildContext ctxt, int index) {
|
||||||
|
return InkWell(
|
||||||
|
onTap: () => Navigator.push(
|
||||||
|
context,
|
||||||
|
FadePage(
|
||||||
|
page: PrescriptionItemsPage(
|
||||||
|
prescriptions: model
|
||||||
|
.prescriptionsList[index],
|
||||||
|
patient: patient,
|
||||||
|
arrivalType: arrivalType,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
DoctorCard(
|
||||||
|
doctorName:
|
||||||
|
Helpers.convertToTitleCase(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: ErrorMessage(
|
||||||
|
error: TranslationBase.of(context)
|
||||||
|
.noPrescriptionsFound,
|
||||||
|
))
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: NetworkBaseView(
|
||||||
|
baseViewModel: model,
|
||||||
|
child: FractionallySizedBox(
|
||||||
|
widthFactor: 1.0,
|
||||||
|
child: ListView(
|
||||||
|
physics: BouncingScrollPhysics(),
|
||||||
|
children: <Widget>[
|
||||||
|
model.medicationForInPatient.length == 0
|
||||||
|
? Center(
|
||||||
|
child: ErrorMessage(
|
||||||
|
error: TranslationBase.of(context)
|
||||||
|
.noPrescriptionsFound,
|
||||||
|
))
|
||||||
|
: ListView.builder(
|
||||||
|
scrollDirection: Axis.vertical,
|
||||||
|
physics: NeverScrollableScrollPhysics(),
|
||||||
|
shrinkWrap: true,
|
||||||
|
itemCount:
|
||||||
|
model.medicationForInPatient.length,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
//model.medicationForInPatient.length,
|
||||||
|
return InkWell(
|
||||||
|
child: InPatientDoctorCard(
|
||||||
|
doctorName: Helpers.convertToTitleCase(
|
||||||
|
model.medicationForInPatient[index]
|
||||||
|
.pHRItemDescription),
|
||||||
|
profileUrl: 'sss',
|
||||||
|
branch: 'hamza',
|
||||||
|
clinic: 'basheer',
|
||||||
|
isPrescriptions: true,
|
||||||
|
appointmentDate: AppDateUtils
|
||||||
|
.getDateTimeFromServerFormat(
|
||||||
|
model.medicationForInPatient[index]
|
||||||
|
.prescriptionDatetime,
|
||||||
|
),
|
||||||
|
createdBy: Helpers.convertToTitleCase(
|
||||||
|
model.medicationForInPatient[index]
|
||||||
|
.doctorName
|
||||||
|
.toString()),
|
||||||
|
),
|
||||||
|
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,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue