import React, { ReactElement, useEffect } from 'react';
import Head from 'next/head'
import DatePicker from "react-datepicker";
import "react-datepicker/dist/react-datepicker.css";
import dayjs from "dayjs";
import {useAppDispatch, useAppSelector} from "../../stores/hooks";
import {useRouter} from "next/router";
import { fetch } from '../../stores/patients/patientsSlice'
import {saveFile} from "../../helpers/fileSaver";
import dataFormatter from '../../helpers/dataFormatter';
import ImageField from "../../components/ImageField";
import LayoutAuthenticated from "../../layouts/Authenticated";
import {getPageTitle} from "../../config";
import SectionTitleLineWithButton from "../../components/SectionTitleLineWithButton";
import SectionMain from "../../components/SectionMain";
import CardBox from "../../components/CardBox";
import BaseButton from "../../components/BaseButton";
import BaseDivider from "../../components/BaseDivider";
import {mdiChartTimelineVariant} from "@mdi/js";
import {SwitchField} from "../../components/SwitchField";
import FormField from "../../components/FormField";


const PatientsView = () => {
    const router = useRouter()
    const dispatch = useAppDispatch()
    const { patients } = useAppSelector((state) => state.patients)
    

    const { id } = router.query;
    
    function removeLastCharacter(str) {
      console.log(str,`str`)
      return str.slice(0, -1);
    }

    useEffect(() => {
        dispatch(fetch({ id }));
    }, [dispatch, id]);


    return (
      <>
          <Head>
              <title>{getPageTitle('View patients')}</title>
          </Head>
          <SectionMain>
            <SectionTitleLineWithButton icon={mdiChartTimelineVariant} title={removeLastCharacter('View patients')} main>
                <BaseButton
                  color='info'
                  label='Edit'
                  href={`/patients/patients-edit/?id=${id}`}
                />
            </SectionTitleLineWithButton>
            <CardBox>
            

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>الاسمالثلاثي</p>
                    <p>{patients?.full_name}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>الرقمالوطني</p>
                    <p>{patients?.national_number}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>رقمالهاتف</p>
                    <p>{patients?.phone}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              

              
                <FormField label='Multi Text' hasTextareaHeight>
                  <textarea className={'w-full'} disabled value={patients?.address} />
                </FormField>
              

              

              

              

              

              

              

              

              

              

              

              
              

              

              

              

              

              

              

              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>زمرةالدم</p>
                    <p>{patients?.blood_group ?? 'No data'}</p>
                </div>
              

              

              

              

              

              
              

              

              

              

              

              

              

              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>الجنس</p>
                    <p>{patients?.gender ?? 'No data'}</p>
                </div>
              

              

              

              

              

              
              

              

              

              

              

              

              
                <FormField label='تاريخالميلاد'>
                    {patients.birth_date ? <DatePicker
                      dateFormat="yyyy-MM-dd hh:mm"
                      showTimeSelect
                      selected={patients.birth_date ?
                        new Date(
                          dayjs(patients.birth_date).format('YYYY-MM-DD hh:mm'),
                        ) : null
                      }
                      disabled
                    /> : <p>No تاريخالميلاد</p>}
                </FormField>
              

              

              

              

              

              

              

              
              

              

              

              

              

              

              

              

              

              

              
              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>الطبيبالمعالج</p>
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                        <p>{patients?.primary_doctor?.full_name ?? 'No data'}</p>
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                </div>
                 
              

              

              

              
              

                
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Guarantors المريض</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                <th>اسمالكفيل</th>
                                
                                
                                
                                <th>الرقمالوطني</th>
                                
                                
                                
                                <th>هاتفالكفيل</th>
                                
                                
                                
                                <th>عنوانالكفيل</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {patients.guarantors_patient && Array.isArray(patients.guarantors_patient) &&
                              patients.guarantors_patient.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/guarantors/guarantors-view/?id=${item.id}`)}>
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="national_number">
                                        { item.national_number }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="phone">
                                        { item.phone }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="address">
                                        { item.address }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!patients?.guarantors_patient?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Visits المريض</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                <th>رقمالزيارة</th>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>القسم</th>
                                
                                
                                
                                <th>سعرالمعاينة</th>
                                
                                
                                
                                <th>وقتالدخول</th>
                                
                                
                                
                                <th>وقتالخروج</th>
                                
                                
                                
                                <th>قياسالضغط</th>
                                
                                
                                
                                <th>قياسالسكر</th>
                                
                                
                                
                                <th>النبض</th>
                                
                                
                                
                                <th>درجةالحرارة</th>
                                
                                
                                
                                <th>الأكسجة</th>
                                
                                
                                
                                <th>الشكوىالرئيسية</th>
                                
                                
                                
                                <th>التشخيصالأولي</th>
                                
                                
                                
                                <th>أدويةالإسعاف</th>
                                
                                
                                
                                <th>سوائل/وريدي</th>
                                
                                
                                
                                <th>ملاحظات</th>
                                
                                
                                
                                <th>الحالة</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {patients.visits_patient && Array.isArray(patients.visits_patient) &&
                              patients.visits_patient.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/visits/visits-view/?id=${item.id}`)}>
                                    
                                    
                                    <td data-label="visit_number">
                                        { item.visit_number }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="department">
                                        { item.department }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="visit_price">
                                        { item.visit_price }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="arrival_time">
                                        { dataFormatter.dateTimeFormatter(item.arrival_time) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="discharge_time">
                                        { dataFormatter.dateTimeFormatter(item.discharge_time) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="blood_pressure">
                                        { item.blood_pressure }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="glucose">
                                        { item.glucose }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="pulse">
                                        { item.pulse }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="temperature">
                                        { item.temperature }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="spo2">
                                        { item.spo2 }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="chief_complaint">
                                        { item.chief_complaint }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="initial_diagnosis">
                                        { item.initial_diagnosis }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="emergency_treatment">
                                        { item.emergency_treatment }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="fluids_iv">
                                        { item.fluids_iv }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="notes">
                                        { item.notes }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!patients?.visits_patient?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Orders المريض</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                <th>رقمالطلب</th>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>نوعالطلب</th>
                                
                                
                                
                                <th>النوعالتفصيلي</th>
                                
                                
                                
                                <th>السعر</th>
                                
                                
                                
                                <th>حالةالطلب</th>
                                
                                
                                
                                <th>تاريخالإنشاء</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {patients.orders_patient && Array.isArray(patients.orders_patient) &&
                              patients.orders_patient.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/orders/orders-view/?id=${item.id}`)}>
                                    
                                    
                                    <td data-label="order_number">
                                        { item.order_number }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="order_type">
                                        { item.order_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="subtype">
                                        { item.subtype }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="price">
                                        { item.price }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="created_datetime">
                                        { dataFormatter.dateTimeFormatter(item.created_datetime) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!patients?.orders_patient?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                
                
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Surgery_cases المريض</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                <th>رقمالعملية</th>
                                
                                
                                
                                
                                
                                
                                
                                <th>وقتبدئالعملية</th>
                                
                                
                                
                                <th>وقتانتهاءالعملية</th>
                                
                                
                                
                                
                                
                                <th>سعرالعملية</th>
                                
                                
                                
                                
                                
                                <th>حالةالعملية</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {patients.surgery_cases_patient && Array.isArray(patients.surgery_cases_patient) &&
                              patients.surgery_cases_patient.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/surgery_cases/surgery_cases-view/?id=${item.id}`)}>
                                    
                                    
                                    <td data-label="case_number">
                                        { item.case_number }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="scheduled_start">
                                        { dataFormatter.dateTimeFormatter(item.scheduled_start) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="scheduled_end">
                                        { dataFormatter.dateTimeFormatter(item.scheduled_end) }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="price">
                                        { item.price }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!patients?.surgery_cases_patient?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Cathlab_cases المريض</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                <th>رقمالقثطرة</th>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>السعر</th>
                                
                                
                                
                                <th>تاريخالإجراء</th>
                                
                                
                                
                                <th>حالة</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {patients.cathlab_cases_patient && Array.isArray(patients.cathlab_cases_patient) &&
                              patients.cathlab_cases_patient.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/cathlab_cases/cathlab_cases-view/?id=${item.id}`)}>
                                    
                                    
                                    <td data-label="case_number">
                                        { item.case_number }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="price">
                                        { item.price }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="scheduled_date">
                                        { dataFormatter.dateTimeFormatter(item.scheduled_date) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!patients?.cathlab_cases_patient?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Ecg_stress_tests المريض</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                <th>رقمالاختبار</th>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>نتيجةالاختبار</th>
                                
                                
                                
                                <th>السعر</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {patients.ecg_stress_tests_patient && Array.isArray(patients.ecg_stress_tests_patient) &&
                              patients.ecg_stress_tests_patient.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/ecg_stress_tests/ecg_stress_tests-view/?id=${item.id}`)}>
                                    
                                    
                                    <td data-label="test_number">
                                        { item.test_number }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="result_text">
                                        { item.result_text }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="price">
                                        { item.price }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!patients?.ecg_stress_tests_patient?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Pharmacy_sales_invoices المريض</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                <th>رقمالفاتورة</th>
                                
                                
                                
                                
                                
                                <th>العناصر</th>
                                
                                
                                
                                <th>المجموع</th>
                                
                                
                                
                                <th>الضريبة</th>
                                
                                
                                
                                <th>السعرالنهائي</th>
                                
                                
                                
                                <th>التاريخ</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {patients.pharmacy_sales_invoices_patient && Array.isArray(patients.pharmacy_sales_invoices_patient) &&
                              patients.pharmacy_sales_invoices_patient.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/pharmacy_sales_invoices/pharmacy_sales_invoices-view/?id=${item.id}`)}>
                                    
                                    
                                    <td data-label="invoice_number">
                                        { item.invoice_number }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="items">
                                        { item.items }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="total_amount">
                                        { item.total_amount }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="tax">
                                        { item.tax }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="final_price">
                                        { item.final_price }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="date">
                                        { dataFormatter.dateTimeFormatter(item.date) }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!patients?.pharmacy_sales_invoices_patient?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Patient_invoices المريض</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                <th>رقمفاتورةالمريض</th>
                                
                                
                                
                                
                                
                                <th>العناصر</th>
                                
                                
                                
                                <th>المجموعالجزئي</th>
                                
                                
                                
                                <th>الضرائب</th>
                                
                                
                                
                                <th>الإجمالي</th>
                                
                                
                                
                                <th>حالةالفاتورة</th>
                                
                                
                                
                                <th>إخفاءالسعرالحقيقي</th>
                                
                                
                                
                                <th>سعرالطباعة</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {patients.patient_invoices_patient && Array.isArray(patients.patient_invoices_patient) &&
                              patients.patient_invoices_patient.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/patient_invoices/patient_invoices-view/?id=${item.id}`)}>
                                    
                                    
                                    <td data-label="invoice_number">
                                        { item.invoice_number }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="items">
                                        { item.items }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="subtotal">
                                        { item.subtotal }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="tax">
                                        { item.tax }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="total">
                                        { item.total }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="hide_real_price">
                                        { dataFormatter.booleanFormatter(item.hide_real_price) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="print_price">
                                        { item.print_price }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!patients?.patient_invoices_patient?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Room_bookings المريض</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                <th>رقمالحجز</th>
                                
                                
                                
                                
                                
                                
                                
                                <th>تاريخالدخول</th>
                                
                                
                                
                                <th>تاريخالخروج</th>
                                
                                
                                
                                <th>عددالأيام</th>
                                
                                
                                
                                <th>سعراليوم</th>
                                
                                
                                
                                <th>السعرالإجمالي</th>
                                
                                
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {patients.room_bookings_patient && Array.isArray(patients.room_bookings_patient) &&
                              patients.room_bookings_patient.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/room_bookings/room_bookings-view/?id=${item.id}`)}>
                                    
                                    
                                    <td data-label="booking_number">
                                        { item.booking_number }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="admission_date">
                                        { dataFormatter.dateTimeFormatter(item.admission_date) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="discharge_date">
                                        { dataFormatter.dateTimeFormatter(item.discharge_date) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="days">
                                        { item.days }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="price_per_day">
                                        { item.price_per_day }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="total_price">
                                        { item.total_price }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!patients?.room_bookings_patient?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Maternity_cases المريضة</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                <th>رقمالحالة</th>
                                
                                
                                
                                
                                
                                
                                
                                <th>التشخيص</th>
                                
                                
                                
                                <th>نوعالولادة</th>
                                
                                
                                
                                <th>تاريخالدخول</th>
                                
                                
                                
                                <th>تاريخالخروج</th>
                                
                                
                                
                                <th>السعر</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {patients.maternity_cases_patient && Array.isArray(patients.maternity_cases_patient) &&
                              patients.maternity_cases_patient.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/maternity_cases/maternity_cases-view/?id=${item.id}`)}>
                                    
                                    
                                    <td data-label="case_number">
                                        { item.case_number }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="diagnosis">
                                        { item.diagnosis }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="delivery_type">
                                        { item.delivery_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="admission_date">
                                        { dataFormatter.dateTimeFormatter(item.admission_date) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="discharge_date">
                                        { dataFormatter.dateTimeFormatter(item.discharge_date) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="price">
                                        { item.price }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!patients?.maternity_cases_patient?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Pregnancy_followups المريضة</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                <th>رقمالمتابعة</th>
                                
                                
                                
                                
                                
                                <th>الوزن</th>
                                
                                
                                
                                <th>الضغط</th>
                                
                                
                                
                                <th>نوعالولادة</th>
                                
                                
                                
                                <th>تاريخالمراجعةالقادمة</th>
                                
                                
                                
                                <th>سعرالزيارة</th>
                                
                                
                                
                                <th>ملاحظات</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {patients.pregnancy_followups_patient && Array.isArray(patients.pregnancy_followups_patient) &&
                              patients.pregnancy_followups_patient.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/pregnancy_followups/pregnancy_followups-view/?id=${item.id}`)}>
                                    
                                    
                                    <td data-label="followup_number">
                                        { item.followup_number }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="weight">
                                        { item.weight }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="blood_pressure">
                                        { item.blood_pressure }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="delivery_plan">
                                        { item.delivery_plan }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="next_visit_date">
                                        { dataFormatter.dateTimeFormatter(item.next_visit_date) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="price">
                                        { item.price }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="notes">
                                        { item.notes }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!patients?.pregnancy_followups_patient?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Daily_followup_clinic المريض</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                <th>رقمالسجل</th>
                                
                                
                                
                                
                                
                                <th>نوعالمتابعة</th>
                                
                                
                                
                                <th>النوع</th>
                                
                                
                                
                                <th>بياناتخاصة</th>
                                
                                
                                
                                <th>إرسالللمحاسبة</th>
                                
                                
                                
                                <th>السعر</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {patients.daily_followup_clinic_patient && Array.isArray(patients.daily_followup_clinic_patient) &&
                              patients.daily_followup_clinic_patient.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/daily_followup_clinic/daily_followup_clinic-view/?id=${item.id}`)}>
                                    
                                    
                                    <td data-label="record_number">
                                        { item.record_number }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="condition_type">
                                        { item.condition_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="route">
                                        { item.route }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="notes">
                                        { item.notes }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="send_to_accounting">
                                        { dataFormatter.booleanFormatter(item.send_to_accounting) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="price">
                                        { item.price }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!patients?.daily_followup_clinic_patient?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                

                <BaseDivider />

                <BaseButton
                    color='info'
                    label='Back'
                    onClick={() => router.push('/patients/patients-list')}
                />
              </CardBox>
          </SectionMain>
      </>
    );
};

PatientsView.getLayout = function getLayout(page: ReactElement) {
    return (
      <LayoutAuthenticated
        
        permission={'READ_PATIENTS'}
        
      >
          {page}
      </LayoutAuthenticated>
    )
}

export default PatientsView;