import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart';
import 'package:doctor_app_flutter/core/viewModel/SOAP_view_model.dart';
import 'package:doctor_app_flutter/routes.dart';
import 'package:doctor_app_flutter/screens/base/base_view.dart';
import 'package:doctor_app_flutter/utils/translations_delegate_base_utils.dart';
import 'package:doctor_app_flutter/widgets/patients/profile/PatientProfileButton.dart';
import 'package:flutter/material.dart';

class ProfileMedicalInfoWidgetSearch extends StatefulWidget {
  final String? from;
  final String? to;
  final PatiantInformtion? patient;
  final String? patientType;
  final String? arrivalType;
  final bool isInpatient;
  final bool isDischargedPatient;

  ProfileMedicalInfoWidgetSearch({Key? key, this.patient, this.patientType, this.arrivalType, this.from, this.to, this.isInpatient = false, this.isDischargedPatient = false});

  @override
  State<ProfileMedicalInfoWidgetSearch> createState() => _ProfileMedicalInfoWidgetSearchState();
}

class _ProfileMedicalInfoWidgetSearchState extends State<ProfileMedicalInfoWidgetSearch> with SingleTickerProviderStateMixin {
  late TabController _tabController;

  void initState() {
    _tabController = TabController(length: 2, vsync: this);
  }

  void dispose() {
    _tabController.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return BaseView<SOAPViewModel>(
      onModelReady: (model) async {},
      builder: (_, model, w) => DefaultTabController(
        length: 2,
        initialIndex: widget.isInpatient ? 0 : 1,
        child: SizedBox(
          height: MediaQuery.of(context).size.height * 1.0,
          width: double.infinity,
          child: Scaffold(
            body: GridView.count(
              shrinkWrap: true,
              physics: NeverScrollableScrollPhysics(),
              crossAxisSpacing: 8,
              mainAxisSpacing: 10,
              childAspectRatio: 1 / 1.0,
              crossAxisCount: 3,
              children: [
                PatientProfileButton(
                  key: widget.key,
                  patient: widget.patient,
                  patientType: widget.patientType,
                  arrivalType: widget.arrivalType,
                  from: widget.from,
                  to: widget.to,
                  nameLine1: TranslationBase.of(context).vital,
                  nameLine2: TranslationBase.of(context).signs,
                  route: VITAL_SIGN_DETAILS,
                  icon: 'assets/images/svgs/profile_screen/vital signs.svg',
//                   onTap: () {
// print("Hello.");
//                   },
                ),
                // if (selectedPatientType != 7)
                PatientProfileButton(
                  key: widget.key,
                  patient: widget.patient,
                  patientType: widget.patientType,
                  arrivalType: widget.arrivalType,
                  route: HEALTH_SUMMARY,
                  nameLine1: "Health",
                  //TranslationBase.of(context).medicalReport,
                  nameLine2: "Summary",
                  //TranslationBase.of(context).summaryReport,
                  icon: 'assets/images/svgs/profile_screen/health summary.svg', onTap: () {},
                ),
                PatientProfileButton(
                  key: widget.key,
                  patient: widget.patient,
                  patientType: widget.patientType,
                  arrivalType: widget.arrivalType,
                  route: LAB_RESULT,
                  nameLine1: TranslationBase.of(context).lab,
                  nameLine2: TranslationBase.of(context).result,
                  icon: 'assets/images/svgs/profile_screen/lab results.svg',
                  // onTap: () {},
                ),
                // if (int.parse(patientType) == 7 || int.parse(patientType) == 6)
                PatientProfileButton(
                  key: widget.key,
                  patient: widget.patient,
                  patientType: widget.patientType,
                  arrivalType: widget.arrivalType,
                  isInPatient: widget.isInpatient,
                  route: RADIOLOGY_PATIENT,
                  nameLine1: TranslationBase.of(context).radiology,
                  nameLine2: TranslationBase.of(context).service,
                  icon: 'assets/images/svgs/profile_screen/health summary.svg',
                  // onTap: () {},
                ),
                PatientProfileButton(
                  key: widget.key,
                  patient: widget.patient,
                  patientType: widget.patientType,
                  arrivalType: widget.arrivalType,
                  route: PATIENT_ECG,
                  nameLine1: TranslationBase.of(context).patient,
                  nameLine2: "ECG",
                  icon: 'assets/images/svgs/profile_screen/ECG.svg',
                  // onTap: () {
                  //
                  // },
                ),
                PatientProfileButton(
                  key: widget.key,
                  patient: widget.patient,
                  patientType: widget.patientType,
                  arrivalType: widget.arrivalType,
                  route: ORDER_PRESCRIPTION_OLD,
                  nameLine1: TranslationBase.of(context).orders,
                  nameLine2: TranslationBase.of(context).prescription,
                  icon: 'assets/images/svgs/profile_screen/order prescription.svg',
                  // onTap: () {},
                ),
                // if (int.parse(patientType) == 7 || int.parse(patientType) == 6)
                PatientProfileButton(
                  key: widget.key,
                  patient: widget.patient,
                  patientType: widget.patientType,
                  arrivalType: widget.arrivalType,
                  route: ORDER_PROCEDURE,
                  nameLine1: TranslationBase.of(context).orders,
                  nameLine2: TranslationBase.of(context).procedures,
                  icon: 'assets/images/svgs/profile_screen/Order Procedures.svg',
                  // onTap: () {},
                ),
                //if (int.parse(patientType) == 7 || int.parse(patientType) == 6)
                PatientProfileButton(
                  key: widget.key,
                  patient: widget.patient,
                  patientType: widget.patientType,
                  arrivalType: widget.arrivalType,
                  route: PATIENT_INSURANCE_APPROVALS_NEW,
                  nameLine1: TranslationBase.of(context).insurance,
                  nameLine2: TranslationBase.of(context).service,
                  icon: 'assets/images/svgs/profile_screen/insurance approval.svg',
                  // onTap: () {},
                ),
                // if (int.parse(patientType) == 7 || int.parse(patientType) == 6)
                PatientProfileButton(
                  key: widget.key,
                  patient: widget.patient,
                  patientType: widget.patientType,
                  arrivalType: widget.arrivalType,
                  route: ADD_SICKLEAVE,
                  nameLine1: TranslationBase.of(context).patientSick,
                  nameLine2: TranslationBase.of(context).leave,
                  icon: 'assets/images/svgs/profile_screen/patient sick leave.svg',
                  // onTap: () {},
                ),
                if (widget.patient!.appointmentNo != null && widget.patient!.appointmentNo != 0)
                  PatientProfileButton(
                    key: widget.key,
                    patient: widget.patient,
                    patientType: widget.patientType,
                    arrivalType: widget.arrivalType,
                    route: PATIENT_UCAF_REQUEST,
                    isDisable: widget.patient!.patientStatusType != 43 ? true : false,
                    nameLine1: TranslationBase.of(context).patient,
                    nameLine2: TranslationBase.of(context).ucaf,
                    icon: 'assets/images/svgs/profile_screen/UCAF.svg',
                    // onTap: () {},
                  ),
                if (widget.patient!.appointmentNo != null && widget.patient!.appointmentNo != 0)
                  PatientProfileButton(
                    key: widget.key,
                    patient: widget.patient,
                    patientType: widget.patientType,
                    arrivalType: widget.arrivalType,
                    route: REFER_PATIENT_TO_DOCTOR,
                    isDisable: widget.patient!.patientStatusType != 43 ? true : false,
                    nameLine1: TranslationBase.of(context).referral,
                    nameLine2: TranslationBase.of(context).patient,
                    icon: 'assets/images/svgs/profile_screen/refer patient.svg',
                    // onTap: () {},
                  ),
                if (widget.patient!.appointmentNo != null && widget.patient!.appointmentNo != 0)
                  PatientProfileButton(
                    key: widget.key,
                    patient: widget.patient,
                    patientType: widget.patientType,
                    arrivalType: widget.arrivalType,
                    route: PATIENT_ADMISSION_REQUEST,
                    isDisable: widget.patient!.patientStatusType != 43 ? true : false,
                    nameLine1: TranslationBase.of(context).admission,
                    nameLine2: TranslationBase.of(context).request,
                    icon: 'assets/images/svgs/profile_screen/admission req.svg',
                    // onTap: () {},
                  ),
                if (widget.isInpatient)
                  PatientProfileButton(
                    key: widget.key,
                    patient: widget.patient,
                    patientType: widget.patientType,
                    arrivalType: widget.arrivalType,
                    route: PROGRESS_NOTE,
                    nameLine1: TranslationBase.of(context).progress,
                    nameLine2: TranslationBase.of(context).note,
                    icon: 'assets/images/svgs/profile_screen/Progress notes.svg',
                    // onTap: () {},
                  ),
                if (widget.isInpatient)
                  PatientProfileButton(
                    key: widget.key,
                    patient: widget.patient,
                    patientType: widget.patientType,
                    arrivalType: widget.arrivalType,
                    route: ORDER_NOTE,
                    nameLine1: "Order",
                    //"Text",
                    nameLine2: "Sheet",
                    icon: 'assets/images/svgs/profile_screen/Progress notes.svg', onTap: () {},
                  ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
