feat (user): implement user management feature

This commit is contained in:
Abizrh
2025-08-28 01:18:55 +07:00
parent a7a77cb497
commit 35e2c663f5
12 changed files with 517 additions and 121 deletions
+42
View File
@@ -0,0 +1,42 @@
<script setup lang="ts">
import Block from '~/components/pub/custom-ui/form/block.vue'
import FieldGroup from '~/components/pub/custom-ui/form/field-group.vue'
import Field from '~/components/pub/custom-ui/form/field.vue'
import Label from '~/components/pub/custom-ui/form/label.vue'
const props = defineProps<{ modelValue: any }>()
const emit = defineEmits(['update:modelValue', 'event'])
const data = computed({
get: () => props.modelValue,
set: (val) => emit('update:modelValue', val),
})
</script>
<template>
<form id="entry-form">
<div class="mb-5 border-b border-b-slate-300 pb-3 text-lg xl:text-xl">
<Icon name="i-lucide-user" class="me-2" />
<span class="font-semibold">Tambah</span> Dokter
</div>
<div class="mb-5 border-b border-b-slate-300 pb-3 text-lg xl:text-xl">
<div class="flex flex-col justify-between">
<Block>
<FieldGroup :column="2">
<Label>Username</Label>
<Field>
<Input type="text" name="username" />
</Field>
</FieldGroup>
<FieldGroup :column="2">
<Label>Password</Label>
<Field>
<Input type="password" name="password" />
</Field>
</FieldGroup>
</Block>
</div>
</div>
</form>
</template>
+109
View File
@@ -0,0 +1,109 @@
import type {
Col,
KeyLabel,
RecComponent,
RecStrFuncComponent,
RecStrFuncUnknown,
Th,
} from '~/components/pub/custom-ui/data/types'
import { defineAsyncComponent } from 'vue'
type SmallDetailDto = any
const action = defineAsyncComponent(() => import('~/components/pub/custom-ui/data/dropdown-action-dud.vue'))
const doctorStatus = {
0: 'Tidak Aktif',
1: 'Aktif',
}
export const cols: Col[] = [
{ width: 100 },
{ width: 250 },
{},
{ width: 100 },
{ width: 100 },
{},
{},
{},
{ width: 100 },
{ width: 100 },
{ width: 100 },
{ width: 50 },
]
export const header: Th[][] = [
[
{ label: 'Kode JKN' },
{ label: 'Nama' },
{ label: 'No KTP' },
{ label: 'No SIP' },
{ label: 'No IHS' },
{ label: 'Telpon' },
{ label: 'Fee Ranap' },
{ label: 'Fee Rajal' },
{ label: 'Status' },
],
]
export const keys = [
'bpjs_code',
'name',
'identity_number',
'sip_no',
'ihs_number',
'phone',
'inPatient_itemPrice',
'outPatient_itemPrice',
'status',
'action',
]
export const delKeyNames: KeyLabel[] = [
{ key: 'code', label: 'Kode' },
{ key: 'name', label: 'Nama' },
]
export const funcParsed: RecStrFuncUnknown = {
name: (rec: unknown): unknown => {
console.log(rec)
const recX = rec as SmallDetailDto
return `${recX.frontTitle} ${recX.name} ${recX.endTitle}`.trim()
},
identity_number: (rec: unknown): unknown => {
const recX = rec as SmallDetailDto
if (recX.identity_number?.substring(0, 5) === 'BLANK') {
return '(TANPA NIK)'
}
return recX.identity_number
},
inPatient_itemPrice: (rec: unknown): unknown => {
const recX = rec as SmallDetailDto
return Number(recX.inPatient_itemPrice.price).toLocaleString('id-ID')
},
outPatient_itemPrice: (rec: unknown): unknown => {
const recX = rec as SmallDetailDto
return Number(recX.outPatient_itemPrice.price).toLocaleString('id-ID')
},
status: (rec: unknown): unknown => {
const recX = rec as SmallDetailDto
return doctorStatus[recX.status_code as keyof typeof doctorStatus]
},
}
export const funcComponent: RecStrFuncComponent = {
action(rec, idx) {
const res: RecComponent = {
idx,
rec: rec as object,
component: action,
}
return res
},
}
export const funcHtml: RecStrFuncUnknown = {
patient_address(_rec) {
return '-'
},
}
+19
View File
@@ -0,0 +1,19 @@
<script setup lang="ts">
import { cols, funcComponent, funcHtml, funcParsed, header, keys } from './list-cfg'
defineProps<{
data: any[]
}>()
</script>
<template>
<PubBaseDataTable
:rows="data"
:cols="cols"
:header="header"
:keys="keys"
:func-parsed="funcParsed"
:func-html="funcHtml"
:func-component="funcComponent"
/>
</template>
View File
View File
+29
View File
@@ -0,0 +1,29 @@
<script setup lang="ts">
import Action from '~/components/pub/custom-ui/nav-footer/ba-dr-su.vue'
const data = ref({
name: '',
specialization: '',
hospital: '',
})
function onClick(type: string) {
if (type === 'cancel') {
navigateTo('/human-src/user')
} else if (type === 'draft') {
// do something
} else if (type === 'submit') {
// do something
}
}
</script>
<template>
<div>
<AppDoctorEntryForm v-model="data" />
</div>
<AppUserEntryForm v-model="data" />
<div class="my-2 flex justify-end py-2">
<Action @click="onClick" />
</div>
</template>
+53
View File
@@ -0,0 +1,53 @@
<script setup lang="ts">
import type { HeaderPrep, RefSearchNav } from '~/components/pub/nav/types'
import Header from '~/components/pub/custom-ui/nav-header/prep.vue'
const data = ref([])
const refSearchNav: RefSearchNav = {
onClick: () => {
// open filter modal
},
onInput: (_val: string) => {
// filter patient list
},
onClear: () => {
// clear url param
},
}
const recId = ref<number>(0)
const recAction = ref<string>('')
const recItem = ref<any>(null)
const headerPrep: HeaderPrep = {
title: 'User',
icon: 'i-lucide-users',
addNav: {
label: 'Tambah',
onClick: () => navigateTo('/human-src/user/add'),
},
}
useAsyncData('getDoctor', () => xfetch('/api/v1/doctor'), { server: false, immediate: true })
async function getDoctorList() {
const resp = await xfetch('/api/v1/doctor')
if (resp.success) {
data.value = (resp.body as Record<string, any>).data
}
}
onMounted(() => {
getDoctorList()
})
provide('rec_id', recId)
provide('rec_action', recAction)
provide('rec_item', recItem)
</script>
<template>
<Header :prep="{ ...headerPrep }" :ref-search-nav="refSearchNav" />
<AppDoctorList :data="data" />
</template>
+169 -119
View File
@@ -1,170 +1,220 @@
export interface ActiveStatusCode { export const activeStatusCodes: Record<string, string> = {
code: 'active' | 'inactive' active: 'Aktif',
name: 'Aktif' | 'Tidak Aktif' inactive: 'Tidak Aktif',
} }
export interface DataStatusCode { export const dataStatusCodes: Record<string, string> = {
code: 'new' | 'review' | 'process' | 'done' | 'canceled' | 'rejected' | 'skiped' new: 'Baru',
name: 'Baru' | 'Review' | 'Proses' | 'Selesai' | 'Dibatalkan' | 'Ditolak' | 'Dilewati' review: 'Review',
process: 'Proses',
done: 'Selesai',
canceled: 'Dibatalkan',
rejected: 'Ditolak',
skiped: 'Dilewati',
} }
export interface UserStatusCode { export const userStatusCodes: Record<string, string> = {
code: 'new' | 'active' | 'inactive' | 'blocked' | 'suspended' new: 'Baru',
name: 'Baru' | 'Aktif' | 'Tidak Aktif' | 'Diblokir' | 'Dibekukan' active: 'Aktif',
inactive: 'Tidak Aktif',
blocked: 'Diblokir',
suspended: 'Dibekukan',
} }
export interface ItemGroupCode { export const itemGroupCodes: Record<string, string> = {
code: 'infra' | 'medicine' | 'device' | 'material' infra: 'Infrastruktur',
name: 'Infrastruktur' | 'Obat' | 'Peralatan' | 'Perlengkapan' medicine: 'Obat',
device: 'Peralatan',
material: 'Perlengkapan',
} }
export interface UnitTypeCode { export const unitTypeCodes: Record<string, string> = {
code: 'reg' | 'exa' | 'pay' | 'pha' | 'lab' | 'rad' reg: 'Registrasi',
name: 'Registrasi' | 'Pemeriksaan' | 'Pembayaran' | 'Farmasai' | 'Laboratorium' | 'Radiologi' exa: 'Pemeriksaan',
pay: 'Pembayaran',
pha: 'Farmasai',
lab: 'Laboratorium',
rad: 'Radiologi',
} }
export interface QueueStatusCode { export const queueStatusCodes: Record<string, string> = {
code: 'wait' | 'proc' | 'done' | 'cancel' | 'skip' wait: 'Tunggu',
name: 'Tunggu' | 'Proses' | 'Selesai' | 'Batal' | 'Dilewati' proc: 'Proses',
done: 'Selesai',
cancel: 'Batal',
skip: 'Dilewati',
} }
export interface EncounterClassCode { export const encounterClassCodes: Record<string, string> = {
code: 'outpatient' | 'ambulatory' | 'emergency' | 'inpatient' | 'draft' | 'done' | 'cancel' | 'skip' outpatient: 'Rawat Jalan',
name: 'Rawat Jalan' | 'Rawat Jalan' | 'Gawat Darurat' | 'Rawat Inap' | 'Draft' | 'Selesai' | 'Batal' | 'Dilewati' ambulatory: 'Rawat Jalan',
emergency: 'Gawat Darurat',
inpatient: 'Rawat Inap',
draft: 'Draft',
done: 'Selesai',
cancel: 'Batal',
skip: 'Dilewati',
} }
export interface TimeUnitCode { export const timeUnitCodes: Record<string, string> = {
code: 'sec' | 'min' | 'hour' | 'day' | 'week' | 'month' | 'year' sec: 'Detik',
name: 'Detik' | 'Menit' | 'Jam' | 'Hari' | 'Minggu' | 'Bulan' | 'Tahun' min: 'Menit',
hour: 'Jam',
day: 'Hari',
week: 'Minggu',
month: 'Bulan',
year: 'Tahun',
} }
export interface DischargeMethodCode { export const dischargeMethodCodes: Record<string, string> = {
code: 'home' | 'home-request' home: 'Home',
name: 'Home' | 'Home Request' 'home-request': 'Home Request',
} }
export interface GenderCode { export const genderCodes: Record<string, string> = {
code: 'male' | 'female' | 'not-stated' | 'unknown' male: 'Laki - Laki',
name: 'Laki' | 'Perempuan' | 'Tidak Disebutkan' | 'Tidak Diketahui' female: 'Perempuan',
'not-stated': 'Tidak Disebutkan',
unknown: 'Tidak Diketahui',
} }
export interface ReligionCode { export const religionCodes: Record<string, string> = {
code: 'islam' | 'protestan' | 'katolik' | 'hindu' | 'buda' | 'konghucu' islam: 'Islam',
name: 'Islam' | 'Protestan' | 'Katolik' | 'Hindu' | 'Buda' | 'Konghucu' protestan: 'Protestan',
katolik: 'Katolik',
hindu: 'Hindu',
buda: 'Buda',
konghucu: 'Konghucu',
} }
export interface EducationCode { export const educationCodes: Record<string, string> = {
code: 'TS' | 'TK' | 'SD' | 'SMP' | 'SMA' | 'D1' | 'D2' | 'D3' | 'S1' | 'S2' | 'S3' TS: 'TS',
name: 'TS' | 'TK' | 'SD' | 'SMP' | 'SMA' | 'D1' | 'D2' | 'D3' | 'S1' | 'S2' | 'S3' TK: 'TK',
SD: 'SD',
SMP: 'SMP',
SMA: 'SMA',
D1: 'D1',
D2: 'D2',
D3: 'D3',
S1: 'S1',
S2: 'S2',
S3: 'S3',
} }
export interface OccupationCode { export const occupationCodes: Record<string, string> = {
code: 'tidak-bekerja' | 'pns' | 'polisi' | 'tni' | 'guru' | 'wiraswasta' | 'kary-swasta' | 'lainnya' 'tidak-bekerja': 'Tidak Bekerja',
name: pns: 'Pegawai Negeri Sipil',
| 'Tidak Bekerja' polisi: 'Polisi',
| 'Pegawai Negeri Sipil' tni: 'TNI',
| 'Polisi' guru: 'Guru',
| 'TNI' wiraswasta: 'Wiraswasta',
| 'Guru' 'kary-swasta': 'Karyawan Swasta',
| 'Wiraswasta' lainnya: 'Lainnya',
| 'Karyawan Swasta'
| 'Lainnya'
} }
export interface PersonContactType { export const personContactTypes: Record<string, string> = {
code: 'phone' | 'm-phone' | 'email' | 'fax' phone: 'Telepon',
name: 'Telepon' | 'HP / Ponsel' | 'Email' | 'Fax' 'm-phone': 'HP / Ponsel',
email: 'Email',
fax: 'Fax',
} }
export interface DayCode { export const dayCodes: Record<string, string> = {
code: '0' | '1' | '2' | '3' | '4' | '5' | '6' '0': 'Minggu',
name: 'Minggu' | '' | '' | '' | '' | '' | 'Sabtu' '1': '',
'2': '',
'3': '',
'4': '',
'5': '',
'6': 'Sabtu',
} }
export interface PaymentMethodCode { export const paymentMethodCodes: Record<string, string> = {
code: 'cash' | 'debit' | 'credit' | 'insurance' | 'membership' cash: 'Cash',
name: 'Cash' | 'Debit' | 'Kredit' | 'Asuransi' | 'Membership' debit: 'Debit',
credit: 'Kredit',
insurance: 'Asuransi',
membership: 'Membership',
} }
export interface TransportationCode { export const transportationCodes: Record<string, string> = {
code: 'ambulance' | 'car' | 'motor-cycle' | 'other' ambulance: 'Ambulans',
name: 'Ambulans' | 'Mobil' | 'Motor' | 'Lainnya' car: 'Mobil',
'motor-cycle': 'Motor',
other: 'Lainnya',
} }
export interface PersonConditionCode { export const personConditionCodes: Record<string, string> = {
code: 'res' | 'emg' | 'urg' | 'lurg' | 'nurg' | 'doa' res: 'Resutiasi',
name: 'Resutiasi' | 'Darurat' | 'Mendesak' | 'Kurang Mendesak' | 'Mendesak' | 'Meninggal Saat Tiba' emg: 'Darurat',
urg: 'Mendesak',
lurg: 'Kurang Mendesak',
nurg: 'Mendesak',
doa: 'Meninggal Saat Tiba',
} }
export interface EmergencyClassCode { export const emergencyClassCodes: Record<string, string> = {
code: 'emg' | 'eon' emg: 'Darurat',
name: 'Darurat' | 'Ponek' eon: 'Ponek',
} }
export interface OutpatientClassCode { export const outpatientClassCodes: Record<string, string> = {
code: 'op' | 'icu' | 'hcu' | 'vk' op: 'Rawat Inap',
name: 'Rawat Inap' | 'ICU' | 'HCU' | 'Kamar Bersalin' icu: 'ICU',
hcu: 'HCU',
vk: 'Kamar Bersalin',
} }
export interface CheckupScopeCode { export const checkupScopeCodes: Record<string, string> = {
code: 'lab' | 'mic-lab' | 'pa-lab' | 'rad' lab: 'Laboratorium',
name: 'Laboratorium' | 'Microbacterial Laboratorium' | 'Patology Anatomy Laboratorium' | 'Radiology' 'mic-lab': 'Microbacterial Laboratorium',
'pa-lab': 'Patology Anatomy Laboratorium',
rad: 'Radiology',
} }
export interface EmployeePositionCode { export const employeePositionCodes: Record<string, string> = {
code: 'doctor' | 'nurse' | 'nutritionist' | 'laborant' | 'pharmacy' | 'payment' | 'payment-verificator' | 'management' doctor: 'Dokter',
name: nurse: 'Perawat',
| 'Dokter' nutritionist: 'Ahli Gisi',
| 'Perawat' laborant: 'Laboran',
| 'Ahli Gisi' pharmacy: 'Farmasi',
| 'Laboran' payment: 'Pembayaran',
| 'Farmasi' 'payment-verificator': 'Konfirmasi Pembayaran',
| 'Pembayaran' management: 'Management',
| 'Konfirmasi Pembayaran'
| 'Management'
} }
export interface SubjectCode { export const subjectCodes: Record<string, string> = {
code: 'pri-compl': 'Primary Complaint',
| 'pri-compl' 'sec-compl': 'Secondary Complaint',
| 'sec-compl' 'cur-disea-hist': 'Current Disease History',
| 'cur-disea-hist' 'pas-disea-hist': 'Past Disease History',
| 'pas-disea-hist' 'fam-disea-hist': 'Family Disease History',
| 'fam-disea-hist' 'alg-hist': 'Allergic Hist',
| 'alg-hist' 'alg-react': 'Allergic Reaction',
| 'alg-react' 'med-hist': 'Medication Hist',
| 'med-hist'
name:
| 'Primary Complaint'
| 'Secondary Complaint'
| 'Current Disease History'
| 'Past Disease History'
| 'Family Disease History'
| 'Allergic Hist'
| 'Allergic Reaction'
| 'Medication Hist'
} }
export interface ObjectCode { export const objectCodes: Record<string, string> = {
code: 'consc-level' | 'consc-level-det' | 'syst-bp' | 'diast-bp' | 'hear-rt' | 'temp' | 'spo2' | 'weight' | 'height' 'consc-level': 'Tingkat Kesadaran',
name: 'consc-level-det': 'Detail Tingkat Kesadaran',
| 'Tingkat Kesadaran' 'syst-bp': 'Tekanan Darah Systolic',
| 'Detail Tingkat Kesadaran' 'diast-bp': 'Tekanan Darah Diastolic',
| 'Tekanan Darah Systolic' 'hear-rt': 'Detak Jantung',
| 'Tekanan Darah Diastolic' temp: 'Suhu',
| 'Detak Jantung' spo2: 'SpO2',
| 'Suhu' weight: 'Berat Badan',
| 'SpO2' height: 'Tinggi Badan',
| 'Berat Badan'
| 'Tinggi Badan'
} }
export interface AssessmentCode { export const assessmentCodes: Record<string, string> = {
code: 'early-diag' | 'late-diag' | 'sec-diag' 'early-diag': 'Diagnosis Awal',
name: 'Diagnosis Awal' | 'Diagnosis Akhir' | 'Diagnosis Sekunder' 'late-diag': 'Diagnosis Akhir',
'sec-diag': 'Diagnosis Sekunder',
} }
export interface InstructionCode { export const instructionCodes: Record<string, string> = {
code: 'detail' | 'med-act' | 'medication' | 'material' detail: 'Detail Instruksi',
name: 'Detail Instruksi' | 'Tindakan medis' | 'Obat' | 'BMHP' 'med-act': 'Tindakan medis',
medication: 'Obat',
material: 'BMHP',
} }
@@ -0,0 +1,41 @@
<script setup lang="ts">
import type { PagePermission } from '~/models/role'
import Error from '~/components/pub/base/error/error.vue'
import { PAGE_PERMISSIONS } from '~/lib/page-permission'
definePageMeta({
middleware: ['rbac'],
roles: ['doctor', 'nurse', 'admisi', 'pharmacy', 'billing', 'management'],
title: 'Tambah User',
contentFrame: 'cf-full-width',
})
const route = useRoute()
useHead({
title: () => route.meta.title as string,
})
const roleAccess: PagePermission = PAGE_PERMISSIONS['/doctor']
const { checkRole, hasCreateAccess } = 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 canCreate = hasCreateAccess(roleAccess)
</script>
<template>
<div v-if="canCreate">
<FlowUserEntry />
</div>
<Error v-else :status-code="403" />
</template>
@@ -0,0 +1,40 @@
<script setup lang="ts">
import type { PagePermission } from '~/models/role'
import Error from '~/components/pub/base/error/error.vue'
import { PAGE_PERMISSIONS } from '~/lib/page-permission'
definePageMeta({
middleware: ['rbac'],
roles: ['doctor', 'nurse', 'admisi', 'pharmacy', 'billing', 'management'],
title: 'Daftar User',
contentFrame: 'cf-full-width',
})
const route = useRoute()
useHead({
title: () => route.meta.title as string,
})
const roleAccess: PagePermission = PAGE_PERMISSIONS['/doctor']
const { checkRole, hasReadAccess } = useRBAC()
// Check if user has access to this page
const hasAccess = checkRole(roleAccess)
if (!hasAccess) {
navigateTo('/403')
}
// Define permission-based computed properties
const canRead = hasReadAccess(roleAccess)
</script>
<template>
<div>
<div v-if="canRead">
<FlowUserList />
</div>
<Error v-else :status-code="403" />
</div>
</template>
+4 -2
View File
@@ -10,6 +10,7 @@ export default withNuxt(
stylistic: { stylistic: {
semi: false, semi: false,
quotes: 'single', quotes: 'single',
quoteProps: 'as-needed',
// Less strict formatting // Less strict formatting
jsx: false, jsx: false,
trailingComma: 'all', trailingComma: 'all',
@@ -18,14 +19,15 @@ export default withNuxt(
{ {
rules: { rules: {
// Basic rules // Basic rules
'quotes': ['error', 'single', { avoidEscape: true }], quotes: ['error', 'single', { avoidEscape: true }],
'style/quote-props': 'off',
'style/no-trailing-spaces': ['error', { ignoreComments: true }], 'style/no-trailing-spaces': ['error', { ignoreComments: true }],
'no-console': 'off', 'no-console': 'off',
// Relax strict formatting rules // Relax strict formatting rules
'style/brace-style': 'off', // Allow inline if 'style/brace-style': 'off', // Allow inline if
'curly': ['error', 'multi-line'], // Only require braces for multi-line curly: ['error', 'multi-line'], // Only require braces for multi-line
'style/arrow-parens': 'off', 'style/arrow-parens': 'off',
// UnoCSS - make it warning instead of error, or disable completely // UnoCSS - make it warning instead of error, or disable completely
+11
View File
@@ -30,6 +30,17 @@
} }
] ]
}, },
{
"title": "Karyawan",
"icon": "i-lucide-users",
"children": [
{
"title": "User",
"icon": "i-lucide-user",
"link": "/human-src/user"
}
]
},
{ {
"title": "Dokter", "title": "Dokter",
"icon": "i-lucide-cross", "icon": "i-lucide-cross",