import type { Config } from '~/components/pub/my-ui/data-table'
import type { Patient } from '~/models/patient'
import { defineAsyncComponent } from 'vue'
import { educationCodes, genderCodes } from '~/lib/constants'
import { calculateAge } from '~/lib/utils'

const action = defineAsyncComponent(() => import('~/components/pub/my-ui/data/print-btn.vue'))

export const config: Config = {
  cols: [{}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {width: 130}, {width: 30},],

  headers: [
    [
      { label: 'NAMA PASIEN' },
      { label: 'NO.SURAT KONTROL' },
      { label: 'NO.SEP' },
      { label: 'TANGGAL RENCANA KONTROL' },
      { label: 'TANGGAL TERBIT' },
      { label: 'DPJP' },
      { label: 'SPESIALIS' },
      { label: 'SUBSPESIALIS' },
      { label: 'TIPE RAWAT' },
      { label: 'DIBUAT OLEH' },
      { label: 'DIEDIT OLEH' },
      { label: 'STATUS' },
      { label: 'AKSI' },
    ],
  ],

  keys: [
    'date',
    'name',
    'name',
    'name',
    'name',
    'name',
    'name',
    'name',
    'name',
    'name',
    'name',
    'status',
    'action',
  ],

  delKeyNames: [
    { key: 'code', label: 'Kode' },
    { key: 'name', label: 'Nama' },
  ],

  parses: {
    date: (rec: unknown): unknown => {
      const date = (rec as any).date
      if (typeof date == 'object' && date) {
        return (date as Date).toLocaleDateString('id-ID')
      } else if (typeof date == 'string') {
        return (date as string).substring(0, 10)
      }
      return date
    },
    specialist_subspecialist: (rec: unknown): unknown => {
      return '-'
    },
    dpjp: (rec: unknown): unknown => {
      // const { person } = rec as Patient
      return '-'
    },
  },

  components: {
    action(rec, idx) {
      return {
        idx,
        rec: rec as object,
        component: action,
      }
    },
  },

  htmls: {
    sep_status(_rec) {
      return 'SEP Internal'
    },
  },
}
