fe-prescription-56: wip

This commit is contained in:
2025-10-08 07:58:48 +07:00
parent fdbcfed87f
commit 06476756fb
23 changed files with 492 additions and 136 deletions
@@ -15,5 +15,24 @@ defineProps<{
:func-parsed="funcParsed"
:func-html="funcHtml"
:func-component="funcComponent"
class="border mb-4 2xl:mb-5"
/>
<div class="flex">
<div class="me-auto">
<Button class="me-2">
<Icon name="i-lucide-plus" class="align-middle" />
Tambah Racikan
</Button>
<Button>
<Icon name="i-lucide-plus" class="align-middle" />
Tambah Non-Racikan
</Button>
</div>
<div>
<Button variant="secondary">
<Icon name="i-lucide-x" class="align-middle" />
Batal
</Button>
</div>
</div>
</template>
+44 -40
View File
@@ -1,8 +1,12 @@
<script setup lang="ts">
import type { PaginationMeta } from '~/components/pub/my-ui/pagination/pagination.type'
import type { Prescription } from '~/models/prescription'
import * as DE from '~/components/pub/my-ui/doc-entry';
import PrescriptionItemList from '~/components/app/prescription-item/list-entry.vue';
interface Props {
data: any[]
data: Prescription[]
isLoading: boolean
paginationMeta?: PaginationMeta
}
@@ -14,52 +18,52 @@ defineProps<Props>()
<div v-if="isLoading" class="p-10 text-center">
Memuat data..
</div>
<div v-else-if="data.length == 0" class="p-10 text-center">
<div v-else-if="data && data.length == 0" class="p-10 text-center">
<div class="mb-4 xl:mb-5">Belum Ada Data</div>
<div>
<!-- <div>
<Button>
<Icon name="i-lucide-plus" class="me-2 align-middle" />
Tambah Order
</Button>
</div>
</div> -->
</div>
<div v-else class="md:grid md:grid-cols-2 font-semibold">
<div>
<PubCustomUiDocEntryBlock mode="preview">
<PubCustomUiDocEntryCell>
<PubCustomUiDocEntryLabel>Order #1</PubCustomUiDocEntryLabel>
<PubCustomUiDocEntryColon />
<PubCustomUiDocEntryField>
2025-01-01
</PubCustomUiDocEntryField>
</PubCustomUiDocEntryCell>
<PubCustomUiDocEntryCell>
<PubCustomUiDocEntryLabel>Status</PubCustomUiDocEntryLabel>
<PubCustomUiDocEntryColon />
<PubCustomUiDocEntryField>
Status
</PubCustomUiDocEntryField>
</PubCustomUiDocEntryCell>
</PubCustomUiDocEntryBlock>
</div>
<div>
<PubCustomUiDocEntryBlock mode="preview">
<PubCustomUiDocEntryCell>
<PubCustomUiDocEntryLabel>DPJP</PubCustomUiDocEntryLabel>
<PubCustomUiDocEntryColon />
<PubCustomUiDocEntryField>
Nama Dokter
</PubCustomUiDocEntryField>
</PubCustomUiDocEntryCell>
<PubCustomUiDocEntryCell>
<PubCustomUiDocEntryLabel>PPDS</PubCustomUiDocEntryLabel>
<PubCustomUiDocEntryColon />
<PubCustomUiDocEntryField>
Nama PPDS
</PubCustomUiDocEntryField>
</PubCustomUiDocEntryCell>
</PubCustomUiDocEntryBlock>
<div v-else v-for="(item, idx) in data">
<Separator class="my-5" />
<div class="md:grid md:grid-cols-2 font-semibold">
<div>
<DE.Block mode="preview">
<DE.Cell>
<DE.Label>Order #{{ data.length - idx }}</DE.Label>
<DE.Field>
2025-01-01
</DE.Field>
</DE.Cell>
<DE.Cell>
<DE.Label>Status</DE.Label>
<DE.Field>
{{ item.status_code }}
</DE.Field>
</DE.Cell>
</DE.Block>
</div>
<div>
<DE.Block mode="preview">
<DE.Cell>
<DE.Label>DPJP</DE.Label>
<DE.Field>
{{ item.doctor.employee.person.name }}
</DE.Field>
</DE.Cell>
<DE.Cell>
<DE.Label>PPDS</DE.Label>
<DE.Field>
{{ item.specialistIntern?.person.name }}
</DE.Field>
</DE.Cell>
</DE.Block>
</div>
</div>
<PrescriptionItemList :data="item.items || []" />
</div>
</template>
+2 -1
View File
@@ -9,6 +9,7 @@ import type { TabItem } from '~/components/pub/my-ui/comp-tab/type'
import Status from '~/components/app/encounter/status.vue'
import AssesmentFunctionList from './assesment-function/list.vue'
import PrescriptionList from '~/components/content/prescription/list.vue'
const route = useRoute()
const router = useRouter()
@@ -43,7 +44,7 @@ const tabs: TabItem[] = [
{ value: 'education-assessment', label: 'Asesmen Kebutuhan Edukasi' },
{ value: 'consent', label: 'General Consent' },
{ value: 'patient-note', label: 'CPRJ' },
{ value: 'prescription', label: 'Order Obat' },
{ value: 'prescription', label: 'Order Obat', component: PrescriptionList },
{ value: 'device', label: 'Order Alkes' },
{ value: 'mcu-radiology', label: 'Order Radiologi' },
{ value: 'mcu-lab-pc', label: 'Order Lab PK' },
+155 -61
View File
@@ -1,15 +1,46 @@
<script setup lang="ts">
// Components
import Dialog from '~/components/pub/my-ui/modal/dialog.vue'
import type { DataTableLoader } from '~/components/pub/my-ui/data-table/type'
import type { HeaderPrep, RefSearchNav } from '~/components/pub/my-ui/data/types'
import Header from '~/components/pub/my-ui/nav-header/prep.vue'
import ListEntry from '~/components/app/prescription/list-entry.vue'
import PrescriptionItemListEntry from '~/components/app/prescription-item/list-entry.vue'
import RecordConfirmation from '~/components/pub/my-ui/confirmation/record-confirmation.vue'
import List from '~/components/app/prescription/list-entry.vue'
import { getList } from '~/services/prescription.service'
// Helpers
import { usePaginatedList } from '~/composables/usePaginatedList'
import { toast } from '~/components/pub/ui/toast'
import MixEntry from '~/components/app/prescription-item/mix-entry.vue'
// Types
import { ActionEvents, type HeaderPrep } from '~/components/pub/my-ui/data/types'
import { PrescriptionSchema, type PrescriptionFormData } from '~/schemas/prescription.schema'
import type { Unit } from '~/models/unit'
// Handlers
import {
recId,
recAction,
recItem,
isReadonly,
isProcessing,
isFormEntryDialogOpen,
isRecordConfirmationOpen,
handleActionSave,
handleActionEdit,
handleActionRemove,
handleCancelForm,
} from '~/handlers/prescription.handler'
// Services
import { getList, getDetail } from '~/services/prescription.service'
// import { getList as getUnitList } from '~/services/unit.service' // previously uses getList
// import { getValueLabelList } from '~/services/unit.service'
const route = useRoute()
let units = ref<{ value: string; label: string }[]>([])
const title = ref('')
const plainEid = route.params.id
const encounter_id = (plainEid && typeof plainEid == 'string') ? parseInt(plainEid) : 0
const {
data,
@@ -18,38 +49,42 @@ const {
searchInput,
handlePageChange,
handleSearch,
fetchData: getMedicineList,
fetchData: getMyList,
} = usePaginatedList({
fetchFn: async ({ page, search }) => {
const result = await getList({ search, page })
const result = await getList({
search,
page,
'encounter-id': encounter_id
})
return { success: result.success || false, body: result.body || {} }
},
entityName: 'medicine',
entityName: 'prescription'
})
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: 'Resep Obat',
icon: 'i-lucide-panel-bottom',
title: 'Order Obat',
icon: 'i-lucide-box',
refSearchNav: {
placeholder: 'Cari (min. 3 karakter)...',
minLength: 3,
debounceMs: 500,
showValidationFeedback: true,
onInput: (value: string) => {
searchInput.value = value
},
onClick: () => {},
onClear: () => {},
},
addNav: {
label: 'Tambah',
onClick: () => navigateTo('/tools-equipment-src/equipment/add'),
icon: 'i-lucide-plus',
onClick: () => {
recItem.value = null
recId.value = 0
isFormEntryDialogOpen.value = true
isReadonly.value = false
},
},
}
@@ -58,45 +93,104 @@ provide('rec_action', recAction)
provide('rec_item', recItem)
provide('table_data_loader', isLoading)
let loading = ref(false);
let itemEntryDialogShown = ref(false);
let itemMixEntryDialogShown = ref(false);
let title = '';
const getMyDetail = async (id: number | string) => {
const result = await getDetail(id)
if (result.success) {
const currentValue = result.body?.data || {}
recItem.value = currentValue
isFormEntryDialogOpen.value = true
}
}
onMounted(() => {
getMaterialList()
// const getUnits = async () => {
// const result = await getUnitList()
// if (result.success) {
// const currentMedicineGroups = result.body?.data || []
// units.value = currentMedicineGroups.map((item: Unit) => ({
// value: item.code,
// label: item.name,
// }))
// }
// }
// Watch for row actions when recId or recAction changes
watch([recId, recAction], () => {
switch (recAction.value) {
case ActionEvents.showDetail:
getMyDetail(recId.value)
title.value = 'Detail Konsultasi'
isReadonly.value = true
break
case ActionEvents.showEdit:
getMyDetail(recId.value)
title.value = 'Edit Konsultasi'
isReadonly.value = false
break
case ActionEvents.showConfirmDelete:
isRecordConfirmationOpen.value = true
break
}
})
async function getMaterialList() {
isLoading.dataListLoading = true
// const resp = await xfetch('/api/v1/material')
// if (resp.success) {
// data.value = (resp.body as Record<string, any>).data
// }
isLoading.dataListLoading = false
}
function addMedicine() {
itemEntryDialogShown.value = true;
}
function addMedicineMix() {
itemMixEntryDialogShown.value = true;
}
watch([isFormEntryDialogOpen], () => {
if (isFormEntryDialogOpen.value) {
isFormEntryDialogOpen.value = false;
handleActionSave({
encounter_id,
}, getMyList, () =>{}, toast)
}
})
onMounted(async () => {
// await getMyList()
// units.value = await getValueLabelList()
})
</script>
<template>
<Header :prep="{ ...headerPrep }" :ref-search-nav="refSearchNav" />
<ListEntry v-if="!isLoading.dataListLoading" :data="[]" :isLoading="isLoading.isTableLoading" :paginatin="{}" />
<Header
v-model="searchInput"
:prep="headerPrep"
:ref-search-nav="headerPrep.refSearchNav"
@search="handleSearch"
class="mb-4 xl:mb-5"
/>
<List :data="data" :pagination-meta="paginationMeta" :is-loading="isLoading.isTableLoading" @page-change="handlePageChange" />
<Dialog v-model:open="itemEntryDialogShown" :title="!!recItem ? title : 'Tambah Obat'" size="lg" prevent-outside>
</Dialog>
<Dialog v-model:open="itemMixEntryDialogShown" :title="!!recItem ? title : 'Tambah Obat'" size="lg" prevent-outside>
<MixEntry />
</Dialog>
<!-- <Dialog v-model:open="isFormEntryDialogOpen" :title="!!recItem ? title : 'Tambah Divisi'" size="xl" prevent-outside>
<Entry
:schema="PrescriptionSchema"
:values="recItem"
:units="units"
:is-loading="isProcessing"
:is-readonly="isReadonly"
@submit="
(values: PrescriptionFormData | Record<string, any>, resetForm: () => void) => {
if (recId > 0) {
handleActionEdit(recId, values, getMyList, resetForm, toast)
return
}
handleActionSave(values, getMyList, resetForm, toast)
}
"
@cancel="handleCancelForm"
/>
</Dialog> -->
<!-- Record Confirmation Modal -->
<RecordConfirmation
v-model:open="isRecordConfirmationOpen"
action="delete"
:record="recItem"
@confirm="() => handleActionRemove(recId, getMyList, toast)"
@cancel=""
>
<template #default="{ record }">
<div class="text-sm">
<p><strong>ID:</strong> {{ record?.id }}</p>
<p v-if="record?.name"><strong>Nama:</strong> {{ record.name }}</p>
<p v-if="record?.code"><strong>Kode:</strong> {{ record.code }}</p>
</div>
</template>
</RecordConfirmation>
</template>
@@ -15,6 +15,7 @@ const props = defineProps<{
funcComponent?: RecStrFuncComponent
selectMode?: 'single' | 'multiple'
modelValue?: any[] | any
class?: string
}>()
const emit = defineEmits<{
@@ -61,7 +62,7 @@ function handleActionCellClick(event: Event, _cellRef: string) {
</script>
<template>
<Table>
<Table :class="class">
<TableHeader class="bg-gray-50 dark:bg-gray-800">
<TableRow>
<TableHead
+1 -1
View File
@@ -40,7 +40,7 @@ function btnClick() {
</div>
<div v-if="prep.addNav" class="flex items-center ms-2">
<Button class="rounded-md border border-gray-300 text-white" @click="btnClick">
<Icon name="i-lucide-plus" class="mr-2 h-4 w-4 align-middle" />
<Icon name="i-lucide-plus" class="align-middle" />
{{ prep.addNav.label }}
</Button>
</div>
+4
View File
@@ -54,6 +54,10 @@ export function usePaginatedList<T = any>(options: UsePaginatedListOptions<T>) {
initialValue: defaultQuery,
removeFalsyValues: true,
})
console.log("SAPI PERAH");
console.log(options);
console.log(defaultQuery);
console.log(queryParams);
const params = computed(() => {
const result = querySchema.safeParse(queryParams)
+17
View File
@@ -0,0 +1,17 @@
import { createCrudHandler, genCrudHandler } from '~/handlers/_handler'
import { create, update, remove } from '~/services/prescription.service'
export const {
recId,
recAction,
recItem,
isReadonly,
isProcessing,
isFormEntryDialogOpen,
isRecordConfirmationOpen,
onResetState,
handleActionSave,
handleActionEdit,
handleActionRemove,
handleCancelForm,
} = genCrudHandler({ create, update, remove})
+1 -1
View File
@@ -2,8 +2,8 @@
export interface ItemMeta {
id: number
createdAt: string | null
deletedAt: string | null
updatedAt: string | null
deletedAt?: string | null
}
// Pagination meta model for API responses
+3 -1
View File
@@ -1,4 +1,6 @@
export interface Device {
import type { ItemMeta } from "./_model"
export interface Device extends ItemMeta {
code: string
name: string
uom_code: string
+7
View File
@@ -0,0 +1,7 @@
import type { ItemMeta } from "./_model"
export interface DivisionPosition extends ItemMeta {
code: string
name: string
division_id: number
}
+4 -3
View File
@@ -1,12 +1,13 @@
export interface Division {
id?: number
import type { ItemMeta } from "./_model"
export interface Division extends ItemMeta {
code: string
name: string
parent_id?: number | null
childrens?: Division[] | null
}
export interface DivisionPosition {
export interface DivisionPosition extends ItemMeta {
code: string
name: string
division_id: number
+16 -16
View File
@@ -1,18 +1,17 @@
export interface Doctor {
id: number
createdAt: string
updatedAt: string
name: string
frontTitle?: string
endTitle?: string
specialist_code?: string
sip_no: string
import type { ItemMeta } from "./_model"
import { genEmployee, type Employee } from "./employee"
export interface Doctor extends ItemMeta {
employee_id: number
employee: Employee
ihs_number: string
identity_number: string
phone?: string
bpjs_code?: string
status_code?: number
sip_number: string
unit_id?: number
specialist_id?: number
subspecialist_id?: number
bpjs_code: string
}
// use one dto for both create and update
export interface CreateDto {
name?: string
@@ -53,9 +52,10 @@ export function genDoctor(): Doctor {
id: 0,
createdAt: '',
updatedAt: '',
name: '',
employee_id: 0,
employee: genEmployee(),
ihs_number: '',
identity_number: '',
sip_no: '',
sip_number: '',
bpjs_code: '',
}
}
+8 -6
View File
@@ -1,11 +1,13 @@
import { type Person, genPerson } from "./person"
export interface Employee {
name: string
number: string
status_code: string
user_id: number
person_id: number
person: Person
position_code: string
division_code: string
number: string
status_code: string
}
export interface CreateDto extends Employee {}
@@ -26,12 +28,12 @@ export interface GetListDto extends Employee {
export function genEmployee(): Employee {
return {
name: '',
number: '',
status_code: '',
user_id: 0,
person_id: 0,
person: genPerson(),
position_code: '',
division_code: '',
number: '',
status_code: '',
}
}
+39
View File
@@ -0,0 +1,39 @@
import { type Doctor, genDoctor } from "./doctor"
export interface Encounter {
id: number
patient_id: number
registeredAt: string
class_code: string
unit_id: number
specialist_id?: number
subspecialist_id?: number
visitdate: string
appointment_doctor_id: number
appointment_doctor: Doctor
responsible_doctor_id?: number
responsible_doctor?: Doctor
refSource_name?: string
appointment_id?: number
earlyEducation?: string
medicalDischargeEducation: string
admDischargeEducation?: string
dischargeMethod_code?: string
discharge_reason?: string
status_code: string
}
export function genEncounter(): Encounter {
return {
id: 0,
patient_id: 0,
registeredAt: '',
class_code: '',
unit_id: 0,
visitdate: '',
appointment_doctor_id: 0,
appointment_doctor: genDoctor(),
medicalDischargeEducation: '',
status_code: ''
}
}
+34
View File
@@ -0,0 +1,34 @@
import type { ItemMeta } from '~/models/_model'
export interface Person extends ItemMeta {
id: number
name: string
alias?: string
frontTitle?: string
endTitle?: string
birthDate?: Date | string
birthRegency_code?: string
gender_code?: string
residentIdentityNumber?: string
passportNumber?: string
drivingLicenseNumber?: string
religion_code?: string
education_code?: string
occupation_code?: string
occupation_name?: string
ethnic_code?: string
language_code?: string
residentIdentityFileUrl?: string
passportFileUrl?: string
drivingLicenseFileUrl?: string
familyIdentityFileUrl?: string
}
export function genPerson(): Person {
return {
id: 0,
createdAt: '',
updatedAt: '',
name: '',
}
}
+1 -1
View File
@@ -1,7 +1,7 @@
import { genMedicine, type Medicine } from "./medicine";
import { genMedicinemix, type Medicinemix } from "./medicinemix";
interface PrescriptionItem {
export interface PrescriptionItem {
id: number;
prescription_id: number;
isMix: boolean;
+57
View File
@@ -0,0 +1,57 @@
import { type Encounter, genEncounter } from "./encounter";
import { type Doctor, genDoctor } from "./doctor";
import { type PrescriptionItem } from "./prescription-item";
import type { SpecialistIntern } from "./specialist-intern";
export interface Prescription {
id: number
encounter_id: number
encounter: Encounter
doctor_id: number
doctor: Doctor
specialistIntern_id?: number
specialistIntern?: SpecialistIntern
issuedAt: string
status_code: string
items: PrescriptionItem[]
}
export interface CreateDto {
encounter_id: number
doctor_id: number
issuedAt: string
status_code: string
}
export interface GetListDto {
encounter_id: number
doctor_id: number
issuedAt: string
status_code: string
}
export interface GetDetailDto {
id?: string
}
export interface UpdateDto extends CreateDto {
id?: number
}
export interface DeleteDto {
id?: string
}
export function genPresciption(): Prescription {
return {
id: 0,
encounter_id: 0,
encounter: genEncounter(),
doctor_id: 0,
doctor: genDoctor(),
issuedAt: '',
status_code: '',
items: [],
}
}
+29
View File
@@ -0,0 +1,29 @@
import type { ItemMeta } from "./_model";
import { type Person, genPerson } from "./person";
import { type Specialist, genSpecialist } from "./specialist";
import { type Subspecialist, genSubspecialist } from "./subspecialist";
export interface SpecialistIntern extends ItemMeta {
person_id: number
person: Person
specialist_id: number
specialist: Specialist
subspecialist_id: number
subspecialist: Subspecialist
user_id: number
}
export function genSpecialistIntern(): SpecialistIntern {
return {
id: 0,
createdAt: '',
updatedAt: '',
person_id: 0,
person: genPerson(),
specialist_id: 0,
specialist: genSpecialist(),
subspecialist_id: 0,
subspecialist: genSubspecialist(),
user_id: 0,
}
}
+14 -2
View File
@@ -1,6 +1,18 @@
export interface Specialist {
id?: number
import type { ItemMeta } from "./_model"
export interface Specialist extends ItemMeta {
code: string
name: string
unit_id: number | string
}
export function genSpecialist(): Specialist {
return {
id: 0,
createdAt: '',
updatedAt: '',
code: '',
name: '',
unit_id: 0
}
}
+14 -2
View File
@@ -1,6 +1,18 @@
export interface Subspecialist {
id?: number
import type { ItemMeta } from "./_model"
export interface Subspecialist extends ItemMeta {
code: string
name: string
specialist_id: number | string
}
export function genSubspecialist(): Subspecialist {
return {
id: 0,
createdAt: '',
updatedAt: '',
code: '',
name: '',
specialist_id: 0
}
}
+10
View File
@@ -0,0 +1,10 @@
import { z } from 'zod'
import type { PrescriptionItem } from '~/models/prescription-item'
const PrescriptionItemSchema = z.object({
})
type PrescriptionItemFormData = z.infer<typeof PrescriptionItemSchema> & PrescriptionItem
export { PrescriptionItemSchema }
export type { PrescriptionItemFormData }
+11
View File
@@ -0,0 +1,11 @@
import { z } from 'zod'
import type { Prescription } from '~/models/prescription'
const PrescriptionSchema = z.object({
'encounter-id': z.number().nullable().optional(),
})
type PrescriptionFormData = z.infer<typeof PrescriptionSchema> & Prescription
export { PrescriptionSchema }
export type { PrescriptionFormData }