You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
RSGDoctorApp/lib/screens/patients/profile/prescriptions/prescriptions_screen.dart

89 lines
3.1 KiB
Dart

import 'package:doctor_app_flutter/core/viewModel/patient_view_model.dart';
import 'package:doctor_app_flutter/models/patient/reauest_prescription_report_for_in_patient.dart';
import 'package:doctor_app_flutter/screens/base/base_view.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/patients/profile/prescription_in_patinets_widget.dart';
import 'package:doctor_app_flutter/widgets/patients/profile/prescription_out_patinets_widget.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../../config/shared_pref_kay.dart';
import '../../../../models/patient/patiant_info_model.dart';
import '../../../../models/patient/prescription/prescription_req_model.dart';
import '../../../../util/dr_app_shared_pref.dart';
import '../../../../widgets/shared/app_scaffold_widget.dart';
DrAppSharedPreferances sharedPref = new DrAppSharedPreferances();
/*
*@author: Elham Rababah
*@Date:26/4/2020
*@param:
*@return:PrescriptionScreen
*@desc: PrescriptionScreen class
*/
class PrescriptionScreen extends StatefulWidget {
@override
_PrescriptionScreenState createState() => _PrescriptionScreenState();
}
class _PrescriptionScreenState extends State<PrescriptionScreen> {
String type = '2';
/*
*@author: Elham Rababah
*@Date:28/4/2020
*@param: context
*@return:
*@desc: getPrescriptionsList Function
*/
getPrescriptionsList(BuildContext context, PatientViewModel model) async {
final routeArgs = ModalRoute.of(context).settings.arguments as Map;
PatiantInformtion patient = routeArgs['patient'];
String token = await sharedPref.getString(TOKEN);
type = await sharedPref.getString(SLECTED_PATIENT_TYPE);
if (type == '1') {
RequestPrescriptionReportForInPatient prescriptionReqModel =
RequestPrescriptionReportForInPatient(
patientID: patient.patientId,
patientTypeID: patient.patientType,
admissionNo: int.parse(patient.admissionNo));
model.getInPatientPrescriptions(prescriptionReqModel.toJson());
} else {
PrescriptionReqModel prescriptionReqModel = PrescriptionReqModel(
patientID: patient.patientId,
projectID: patient.projectId,
tokenID: token,
patientTypeID: patient.patientType,
languageID: 2,
setupID: 0);
model.getOutPatientPrescriptions(prescriptionReqModel.toJson());
}
}
@override
Widget build(BuildContext context) {
return BaseView<PatientViewModel>(
onModelReady: (model) => getPrescriptionsList(context, model),
builder: (_, model, w) =>
AppScaffold(
baseViewModel: model,
appBarTitle: TranslationBase
.of(context)
.prescription,
body: type == '1'
? PrescriptionInPatientWidget(
prescriptionReportForInPatientList:
model.prescriptionReportForInPatientList,
)
: PrescriptionOutPatientWidget(
patientPrescriptionsList:
model.patientPrescriptionsList,
),
),);
}
}