import 'package:doctor_app_flutter/core/viewModel/patient_view_model.dart';
import 'package:doctor_app_flutter/models/patient/prescription/prescription_res_model.dart';
import 'package:doctor_app_flutter/models/patient/prescription/request_prescription_report.dart';
import 'package:doctor_app_flutter/screens/base/base_view.dart';
import 'package:doctor_app_flutter/screens/patients/profile/prescriptions/out_patient_prescription_details_item.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/card_with_bgNew_widget.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class OutPatientPrescriptionDetailsScreen extends StatefulWidget {
  final PrescriptionResModel prescriptionResModel;

  OutPatientPrescriptionDetailsScreen({Key key, this.prescriptionResModel});

  @override
  _OutPatientPrescriptionDetailsScreenState createState() =>
      _OutPatientPrescriptionDetailsScreenState();
}

class _OutPatientPrescriptionDetailsScreenState
    extends State<OutPatientPrescriptionDetailsScreen> {


  getPrescriptionReport(BuildContext context,PatientViewModel model ){
    RequestPrescriptionReport prescriptionReqModel =
    RequestPrescriptionReport(
        appointmentNo: widget.prescriptionResModel.appointmentNo,
        episodeID: widget.prescriptionResModel.episodeID,
        setupID: widget.prescriptionResModel.setupID,
        patientTypeID: widget.prescriptionResModel.patientID);
    model.getPrescriptionReport(prescriptionReqModel.toJson());
  }
  @override
  Widget build(BuildContext context) {
    return BaseView<PatientViewModel>(
      onModelReady: (model) => getPrescriptionReport(context, model),
      builder: (_, model, w) => AppScaffold(
        appBarTitle: TranslationBase.of(context).prescriptionDetails,
      body: CardWithBgWidgetNew(
                  widget: ListView.builder(
                      itemCount: model.prescriptionReport.length,
                      itemBuilder: (BuildContext context, int index) {
                        return OutPatientPrescriptionDetailsItem(
                          prescriptionReport:
                              model.prescriptionReport[index],
                        );
                      }),
                ),
    ),);
  }
}
