import 'package:doctor_app_flutter/core/model/labs/patient_lab_orders.dart';
import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart';
import 'package:doctor_app_flutter/core/viewModel/labs_view_model.dart';
import 'package:doctor_app_flutter/screens/base/base_view.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:flutter/cupertino.dart';
import 'package:flutter/material.dart';

import 'laboratory_result_widget.dart';

class LaboratoryResultPage extends StatefulWidget {
  final PatientLabOrders patientLabOrders;
  final PatiantInformtion patient;
  final String patientType;
  final String arrivalType;
  final bool isInpatient;

  LaboratoryResultPage({Key? key, required this.patientLabOrders, required this.patient, required this.patientType, required this.arrivalType, required this.isInpatient});

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

class _LaboratoryResultPageState extends State<LaboratoryResultPage> {
  @override
  Widget build(BuildContext context) {
    return BaseView<LabsViewModel>(
      onModelReady: (model) => model.getPatientLabResult(patientLabOrder: widget.patientLabOrders, patient: widget.patient, isInpatient: true),
      builder: (_, model, w) => AppScaffold(
        isShowAppBar: true,
        appBar: PatientProfileAppBar(
          widget.patient,
          isInpatient: widget.isInpatient,
          isFromLabResult: true,
          appointmentDate: widget.patientLabOrders.orderDate!,
        ),
        baseViewModel: model,
        body: AppScaffold(
          isShowAppBar: false,
          body: SingleChildScrollView(
            child: LaboratoryResultWidget(
                onTap: () async {},
                billNo: widget.patientLabOrders.invoiceNo!,
                details: model.patientLabSpecialResult.length > 0 ? model.patientLabSpecialResult[0].resultDataHTML! : "",
                orderNo: widget.patientLabOrders.orderNo!,
                patientLabOrder: widget.patientLabOrders,
                patient: widget.patient,
                isInpatient: widget.patientType == "1",
                invoiceType: widget.patientLabOrders.invoiceType!),
          ),
        ),
      ),
    );
  }
}
