<script setup lang="ts">
// Types & Consts
import type { Permission } from '~/models/role'
import { permissions } from '~/const/page-permission/inpatient'

// Helpers
import { usePageChecker } from '~/lib/page-checker'

// Pubs
import Error from '~/components/pub/my-ui/error/error.vue'

// Apps
import Content from '~/components/content/encounter/process.vue'

const { getRouteTitle, getPageAccess } = usePageChecker()

definePageMeta({
  middleware: ['rbac'],
  roles: ['emp|doc', 'emp|nur', 'emp|miw', 'emp|nut', 'emp|lab', 'emp|pha', 'emp|thr'],
  title: 'Proses Kunjungan',
  contentFrame: 'cf-full-width',
  contentPadding: 'p-0',
  contentUseCard: false,
})

useHead({
  title: () => `${getRouteTitle()}`,
})

// Preps role checking
const roleAccess: Record<string, Permission[]> = permissions['/inpatient/encounter/[id]/process'] || {}
const hasAccess = getPageAccess(roleAccess, 'read')
</script>

<template>
  <div v-if="hasAccess">
    <Content class-code="inpatient" />
  </div>
  <Error
    v-else
    :status-code="403"
  />
</template>
