import 'package:doctor_app_flutter/config/config.dart';
import 'package:doctor_app_flutter/core/enum/viewstate.dart';
import 'package:doctor_app_flutter/core/viewModel/SOAP_view_model.dart';
import 'package:doctor_app_flutter/models/SOAP/PostEpisodeReqModel.dart';
import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart';
import 'package:doctor_app_flutter/routes.dart';
import 'package:doctor_app_flutter/screens/base/base_view.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/profile/PatientProfileButton.dart';
import 'package:doctor_app_flutter/widgets/shared/dr_app_circular_progress_Indeicator.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:hexcolor/hexcolor.dart';

import '../../../config/size_config.dart';
import '../../shared/app_texts_widget.dart';

class ProfileMedicalInfoWidget extends StatelessWidget {
  String from;
  String to;
  PatiantInformtion patient;
  String patientType;

  ProfileMedicalInfoWidget(
      {Key key, this.patient, this.patientType, this.from, this.to});

  @override
  Widget build(BuildContext context) {
    return BaseView<SOAPViewModel>(
      onModelReady: (model) async {},
      builder: (_, model, w) => GridView.count(
        shrinkWrap: true,
        physics: NeverScrollableScrollPhysics(),
        crossAxisSpacing: 10,
        mainAxisSpacing: 10,
        childAspectRatio: 1 / 1.0,
        crossAxisCount: 3,
        children: [
          /*if (int.parse(patientType) == 7 || int.parse(patientType) == 6)
            PatientProfileButton(
                key: key,
                patient: patient,
                isDisable: patient.episodeNo != 0 ? true : false,
                nameLine1: TranslationBase.of(context).createNew,
                nameLine2: TranslationBase.of(context).episode,
                route: CREATE_EPISODE,
                onTap: () async {
                  PostEpisodeReqModel postEpisodeReqModel = PostEpisodeReqModel(
                      appointmentNo: patient.appointmentNo,
                      patientMRN: patient.patientMRN);
                  await model.postEpisode(postEpisodeReqModel);
                  patient.episodeNo = model.episodeID;
                  Navigator.of(context).pushNamed(CREATE_EPISODE,
                      arguments: {'patient': patient});
                },
                isLoading: model.state == ViewState.BusyLocal,
                icon: 'create-episod.png'),
          if (int.parse(patientType) == 7 || int.parse(patientType) == 6)
            PatientProfileButton(
                key: key,
                patient: patient,
                isDisable: patient.episodeNo == 0 ? true : false,
                nameLine1: TranslationBase.of(context).update,
                nameLine2: TranslationBase.of(context).episode,
                route: UPDATE_EPISODE,
                icon: 'modilfy-episode.png'),*/
          if (int.parse(patientType) == 7 || int.parse(patientType) == 6)
            PatientProfileButton(
                key: key,
                patient: patient,
                from: from,
                to: to,
                nameLine1: TranslationBase.of(context).vital,
                nameLine2: TranslationBase.of(context).signs,
                route: VITAL_SIGN_DETAILS,
                icon: 'patient/vital_signs.png'),
          if (selectedPatientType != 7)
            PatientProfileButton(
                key: key,
                patient: patient,
                route: LAB_ORDERS,
                nameLine1: TranslationBase.of(context).lab,
                nameLine2: TranslationBase.of(context).result,
                icon: 'patient/lab_results.png'),
          PatientProfileButton(
              key: key,
              patient: patient,
              route: MEDICAL_FILE,
              nameLine1: TranslationBase.of(context).previewHealth,
              nameLine2: TranslationBase.of(context).summaryReport,
              icon: 'patient/health_summary.png'),
          if (selectedPatientType != 0 &&
              selectedPatientType != 5 &&
              selectedPatientType != 7)
            PatientProfileButton(
                key: key,
                patient: patient,
                route: PROGRESS_NOTE,
                nameLine1: TranslationBase.of(context).progress,
                nameLine2: TranslationBase.of(context).note,
                icon: 'patient/Progress_notes.png'),
          if (int.parse(patientType) == 7 || int.parse(patientType) == 6)
            PatientProfileButton(
                key: key,
                patient: patient,
                route: PATIENT_ADMISSION_REQUEST,
                nameLine1: TranslationBase.of(context).admission,
                nameLine2: TranslationBase.of(context).request,
                icon: 'patient/admission_req.png'),
          (int.parse(patientType) == 7 || int.parse(patientType) == 6)
              ? PatientProfileButton(
                  key: key,
                  patient: patient,
                  route: ORDER_PRESCRIPTION,
                  nameLine1: TranslationBase.of(context).orders,
                  nameLine2: TranslationBase.of(context).prescription,
                  icon: 'patient/order_prescription.png')
              : PatientProfileButton(
                  key: key,
                  patient: patient,
                  route: ORDER_PRESCRIPTION_HISTORY,
                  nameLine1: TranslationBase.of(context).orders,
                  nameLine2: TranslationBase.of(context).prescription,
                  icon: 'patient/order_prescription.png'),
          if (int.parse(patientType) == 7 || int.parse(patientType) == 6)
            PatientProfileButton(
                key: key,
                patient: patient,
                route: ORDER_PROCEDURE,
                nameLine1: TranslationBase.of(context).orders,
                nameLine2: TranslationBase.of(context).procedures,
                icon: 'patient/Order_Procedures.png'),
          if (int.parse(patientType) == 7 || int.parse(patientType) == 6)
            PatientProfileButton(
                key: key,
                patient: patient,
                route: REFER_PATIENT_TO_DOCTOR,
                nameLine1: TranslationBase.of(context).myReferral,
                nameLine2: TranslationBase.of(context).patient,
                icon: 'patient/refer_patient.png'),
          if (int.parse(patientType) == 7 || int.parse(patientType) == 6)
            PatientProfileButton(
                key: key,
                patient: patient,
                route: ADD_SICKLEAVE,
                nameLine1: TranslationBase.of(context).patientSick,
                nameLine2: TranslationBase.of(context).leave,
                icon: 'patient/patient_sick_leave.png'),
          if (int.parse(patientType) == 7 || int.parse(patientType) == 6)
            PatientProfileButton(
                key: key,
                patient: patient,
                route: PATIENT_UCAF_REQUEST,
                nameLine1: TranslationBase.of(context).patient,
                nameLine2: TranslationBase.of(context).ucaf,
                icon: 'patient/ucaf.png'),
          if (int.parse(patientType) == 7 || int.parse(patientType) == 6)
            PatientProfileButton(
                key: key,
                patient: patient,
                route: RADIOLOGY,
                nameLine1: TranslationBase.of(context).radiology,
                nameLine2: TranslationBase.of(context).service,
                icon: 'patient/health_summary.png'),
          if (int.parse(patientType) == 7 || int.parse(patientType) == 6)
            PatientProfileButton(
                key: key,
                patient: patient,
                route: PATIENT_INSURANCE_APPROVALS,
                nameLine1: TranslationBase.of(context).insurance,
                nameLine2: TranslationBase.of(context).service,
                icon: 'patient/vital_signs.png'),
          PatientProfileButton(
              key: key,
              patient: patient,
              route: PATIENT_ECG,
              nameLine1: TranslationBase.of(context).patient,
              nameLine2: "ECG",
              icon: 'patient/patient_sick_leave.png'),
        ],
      ),
    );
  }
}
