feat(encounter): implement encounter detail loading and update handling in entry form

This commit is contained in:
riefive
2025-11-10 12:44:27 +07:00
parent a8bc3647a1
commit b52f438b23
6 changed files with 404 additions and 36 deletions

No files matched your search

@@ -0,0 +1,56 @@
<script setup lang="ts">
import type { PagePermission } from '~/models/role'
import Error from '~/components/pub/my-ui/error/error.vue'
import { PAGE_PERMISSIONS } from '~/lib/page-permission'
definePageMeta({
middleware: ['rbac'],
roles: ['doctor', 'nurse', 'admisi', 'pharmacy', 'billing', 'management'],
title: 'Edit Kunjungan',
contentFrame: 'cf-full-width',
})
const route = useRoute()
useHead({
title: () => `${route.meta.title}`, // backtick to avoid the ts-plugin(2322) warning
})
const roleAccess: PagePermission = PAGE_PERMISSIONS['/emergency/encounter']
const { checkRole, hasUpdateAccess } = useRBAC()
// Check if user has access to this page
const hasAccess = checkRole(roleAccess)
if (!hasAccess) {
throw createError({
statusCode: 403,
statusMessage: 'Access denied',
})
}
// Define permission-based computed properties
const canUpdate = hasUpdateAccess(roleAccess)
// Get encounter ID from route params
const encounterId = computed(() => {
const id = route.params.id
return typeof id === 'string' ? parseInt(id) : 0
})
</script>
<template>
<div v-if="canUpdate">
<ContentEncounterEntry
:id="encounterId"
class-code="emergency"
sub-class-code="emg"
form-type="Edit"
/>
</div>
<Error
v-else
:status-code="403"
/>
</template>
@@ -0,0 +1,56 @@
<script setup lang="ts">
import type { PagePermission } from '~/models/role'
import Error from '~/components/pub/my-ui/error/error.vue'
import { PAGE_PERMISSIONS } from '~/lib/page-permission'
definePageMeta({
middleware: ['rbac'],
roles: ['doctor', 'nurse', 'admisi', 'pharmacy', 'billing', 'management'],
title: 'Edit Kunjungan',
contentFrame: 'cf-full-width',
})
const route = useRoute()
useHead({
title: () => `${route.meta.title}`, // backtick to avoid the ts-plugin(2322) warning
})
const roleAccess: PagePermission = PAGE_PERMISSIONS['/inpatient/encounter']
const { checkRole, hasUpdateAccess } = useRBAC()
// Check if user has access to this page
const hasAccess = checkRole(roleAccess)
if (!hasAccess) {
throw createError({
statusCode: 403,
statusMessage: 'Access denied',
})
}
// Define permission-based computed properties
const canUpdate = hasUpdateAccess(roleAccess)
// Get encounter ID from route params
const encounterId = computed(() => {
const id = route.params.id
return typeof id === 'string' ? parseInt(id) : 0
})
</script>
<template>
<div v-if="canUpdate">
<ContentEncounterEntry
:id="encounterId"
class-code="inpatient"
sub-class-code="icu"
form-type="Edit"
/>
</div>
<Error
v-else
:status-code="403"
/>
</template>
@@ -0,0 +1,56 @@
<script setup lang="ts">
import type { PagePermission } from '~/models/role'
import Error from '~/components/pub/my-ui/error/error.vue'
import { PAGE_PERMISSIONS } from '~/lib/page-permission'
definePageMeta({
middleware: ['rbac'],
roles: ['doctor', 'nurse', 'admisi', 'pharmacy', 'billing', 'management'],
title: 'Edit Kunjungan',
contentFrame: 'cf-full-width',
})
const route = useRoute()
useHead({
title: () => `${route.meta.title}`, // backtick to avoid the ts-plugin(2322) warning
})
const roleAccess: PagePermission = PAGE_PERMISSIONS['/outpatient/encounter']
const { checkRole, hasUpdateAccess } = useRBAC()
// Check if user has access to this page
const hasAccess = checkRole(roleAccess)
if (!hasAccess) {
throw createError({
statusCode: 403,
statusMessage: 'Access denied',
})
}
// Define permission-based computed properties
const canUpdate = hasUpdateAccess(roleAccess)
// Get encounter ID from route params
const encounterId = computed(() => {
const id = route.params.id
return typeof id === 'string' ? parseInt(id) : 0
})
</script>
<template>
<div v-if="canUpdate">
<ContentEncounterEntry
:id="encounterId"
class-code="ambulatory"
sub-class-code="reg"
form-type="Edit"
/>
</div>
<Error
v-else
:status-code="403"
/>
</template>
@@ -6,7 +6,7 @@ import { PAGE_PERMISSIONS } from '~/lib/page-permission'
definePageMeta({
middleware: ['rbac'],
roles: ['doctor', 'nurse', 'admisi', 'pharmacy', 'billing', 'management'],
title: 'Tambah Kunjungan',
title: 'Edit Kunjungan',
contentFrame: 'cf-full-width',
})
@@ -18,7 +18,7 @@ useHead({
const roleAccess: PagePermission = PAGE_PERMISSIONS['/rehab/encounter']
const { checkRole, hasCreateAccess } = useRBAC()
const { checkRole, hasUpdateAccess } = useRBAC()
// Check if user has access to this page
const hasAccess = checkRole(roleAccess)
@@ -30,12 +30,26 @@ if (!hasAccess) {
}
// Define permission-based computed properties
const canCreate = hasCreateAccess(roleAccess)
const canUpdate = hasUpdateAccess(roleAccess)
// Get encounter ID from route params
const encounterId = computed(() => {
const id = route.params.id
return typeof id === 'string' ? parseInt(id) : 0
})
</script>
<template>
<div v-if="canCreate">
<ContentEncounterEntry :id="1" form-type="Edit" />
<div v-if="canUpdate">
<ContentEncounterEntry
:id="encounterId"
class-code="ambulatory"
sub-class-code="rehab"
form-type="Edit"
/>
</div>
<Error v-else :status-code="403" />
<Error
v-else
:status-code="403"
/>
</template>