import { mdiAccount, mdiChartTimelineVariant, mdiMail, mdiUpload } from '@mdi/js'
import Head from 'next/head'
import React, { ReactElement } from 'react'
import CardBox from '../../components/CardBox'
import LayoutAuthenticated from '../../layouts/Authenticated'
import SectionMain from '../../components/SectionMain'
import SectionTitleLineWithButton from '../../components/SectionTitleLineWithButton'
import { getPageTitle } from '../../config'

import { Field, Form, Formik } from 'formik'
import FormField from '../../components/FormField'
import BaseDivider from '../../components/BaseDivider'
import BaseButtons from '../../components/BaseButtons'
import BaseButton from '../../components/BaseButton'
import FormCheckRadio from '../../components/FormCheckRadio'
import FormCheckRadioGroup from '../../components/FormCheckRadioGroup'
import FormFilePicker from '../../components/FormFilePicker'
import FormImagePicker from '../../components/FormImagePicker'
import { SwitchField } from '../../components/SwitchField'

import { SelectField } from '../../components/SelectField'
import { SelectFieldMany } from "../../components/SelectFieldMany";
import {RichTextField} from "../../components/RichTextField";

import { create } from '../../stores/consultations/consultationsSlice'
import { useAppDispatch } from '../../stores/hooks'
import { useRouter } from 'next/router'
import moment from 'moment';

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    appointment: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    patient: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    primary_doctor: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    secondary_doctor: '',
    
    
    
    
    
    
    
    
    
    started_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    ended_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    channel: 'in_person',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    consultation_status: 'open',
    
    
    
    
    
    
    
    
    chief_complaint: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    clinical_notes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    diagnosis_summary: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    attachments: [],
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizations: '',
    
    
    
}


const ConsultationsNew = () => {
  const router = useRouter()
  const dispatch = useAppDispatch()

    
    

  const handleSubmit = async (data) => {
    await dispatch(create(data))
    await router.push('/consultations/consultations-list')
  }
  return (
    <>
      <Head>
        <title>{getPageTitle('New Item')}</title>
      </Head>
      <SectionMain>
        <SectionTitleLineWithButton icon={mdiChartTimelineVariant} title="New Item" main>
        {''}
        </SectionTitleLineWithButton>
        <CardBox>
          <Formik
            initialValues={
                
                initialValues
                
            }
            onSubmit={(values) => handleSubmit(values)}
          >
            <Form>





















  <FormField label="Appointment" labelFor="appointment">
      <Field name="appointment" id="appointment" component={SelectField} options={[]} itemRef={'appointments'}></Field>
  </FormField>



























  <FormField label="Patient" labelFor="patient">
      <Field name="patient" id="patient" component={SelectField} options={[]} itemRef={'patient_profiles'}></Field>
  </FormField>



























  <FormField label="PrimaryDoctor" labelFor="primary_doctor">
      <Field name="primary_doctor" id="primary_doctor" component={SelectField} options={[]} itemRef={'doctor_profiles'}></Field>
  </FormField>



























  <FormField label="SecondaryDoctor" labelFor="secondary_doctor">
      <Field name="secondary_doctor" id="secondary_doctor" component={SelectField} options={[]} itemRef={'doctor_profiles'}></Field>
  </FormField>



















  <FormField
      label="StartedAt"
  >
      <Field
          type="datetime-local"
          name="started_at"
          placeholder="StartedAt"
      />
  </FormField>



























  <FormField
      label="EndedAt"
  >
      <Field
          type="datetime-local"
          name="ended_at"
          placeholder="EndedAt"
      />
  </FormField>































  <FormField label="Channel" labelFor="channel">
      <Field name="channel" id="channel" component="select">
      
        <option value="in_person">in_person</option>
      
        <option value="chat">chat</option>
      
        <option value="video">video</option>
      
        <option value="phone">phone</option>
      
      </Field>
  </FormField>



























  <FormField label="ConsultationStatus" labelFor="consultation_status">
      <Field name="consultation_status" id="consultation_status" component="select">
      
        <option value="open">open</option>
      
        <option value="closed">closed</option>
      
        <option value="cancelled">cancelled</option>
      
      </Field>
  </FormField>















    <FormField label="ChiefComplaint" hasTextareaHeight>
        <Field name="chief_complaint" as="textarea" placeholder="ChiefComplaint" />
    </FormField>





























      <FormField label='ClinicalNotes' hasTextareaHeight>
          <Field
              name='clinical_notes'
              id='clinical_notes'
              component={RichTextField}
          ></Field>
      </FormField>

























    <FormField label="DiagnosisSummary" hasTextareaHeight>
        <Field name="diagnosis_summary" as="textarea" placeholder="DiagnosisSummary" />
    </FormField>
















































  <FormField>
      <Field
          label='Attachments'
          color='info'
          icon={mdiUpload}
          path={'consultations/attachments'}
          name='attachments'
          id='attachments'
          schema={{
            size: undefined,
            formats: undefined,
          }}
          component={FormFilePicker}
      ></Field>
  </FormField>






















  <FormField label="organizations" labelFor="organizations">
      <Field name="organizations" id="organizations" component={SelectField} options={[]} itemRef={'organizations'}></Field>
  </FormField>







              <BaseDivider />
              <BaseButtons>
                <BaseButton type="submit" color="info" label="Submit" />
                <BaseButton type="reset" color="info" outline label="Reset" />
                <BaseButton type='reset' color='danger' outline label='Cancel' onClick={() => router.push('/consultations/consultations-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default ConsultationsNew
