diff --git a/app/components/app/prescription-item/list-entry.cfg.ts b/app/components/app/prescription-item/list-entry.cfg.ts index 070dd65f..cfc6bdbd 100644 --- a/app/components/app/prescription-item/list-entry.cfg.ts +++ b/app/components/app/prescription-item/list-entry.cfg.ts @@ -11,16 +11,17 @@ export const config: Config = { headers: [ [ { label: 'Nama' }, + { label: 'Cara Buat' }, { label: 'Bentuk' }, { label: 'Freq' }, { label: 'Dosis' }, - { label: 'Interval' }, + // { label: 'Interval' }, { label: 'Total' }, { label: '' }, ], ], - keys: ['name', 'uom_code', 'frequency', 'multiplier', 'interval', 'total', 'action'], + keys: ['medicine.name', 'isMix', 'medicine.medicineForm.name', 'frequency', 'dose', 'quantity', 'action'], // delKeyNames: [ { key: 'code', label: 'Kode' }, @@ -28,17 +29,8 @@ export const config: Config = { ], parses: { - cateogry: (rec: unknown): unknown => { - return (rec as SmallDetailDto).medicineCategory?.name || '-' - }, - group: (rec: unknown): unknown => { - return (rec as SmallDetailDto).medicineGroup?.name || '-' - }, - method: (rec: unknown): unknown => { - return (rec as SmallDetailDto).medicineMethod?.name || '-' - }, - unit: (rec: unknown): unknown => { - return (rec as SmallDetailDto).medicineUnit?.name || '-' + isMix: (rec: unknown): unknown => { + return (rec as SmallDetailDto).isMix ? 'Racikan' : 'Non Racikan' }, }, diff --git a/app/components/app/prescription-item/list.cfg.ts b/app/components/app/prescription-item/list.cfg.ts index fd980bb1..5a3447ef 100644 --- a/app/components/app/prescription-item/list.cfg.ts +++ b/app/components/app/prescription-item/list.cfg.ts @@ -12,12 +12,11 @@ export const config: Config = { { label: 'Bentuk' }, { label: 'Freq' }, { label: 'Dosis' }, - { label: 'Interval' }, { label: 'Total' }, ], ], - keys: ['name', 'uom_code', 'frequency', 'multiplier', 'interval', 'total'], + keys: ['medicine.name', 'medicine.medicineForm.name', 'frequency', 'dose', 'total'], delKeyNames: [ { key: 'code', label: 'Kode' }, diff --git a/app/components/app/prescription-item/list.vue b/app/components/app/prescription-item/list.vue index ed64b09e..d8c4c107 100644 --- a/app/components/app/prescription-item/list.vue +++ b/app/components/app/prescription-item/list.vue @@ -1,4 +1,6 @@ diff --git a/app/components/content/prescription/list.vue b/app/components/content/prescription/list.vue index 844cb04f..afd012f6 100644 --- a/app/components/content/prescription/list.vue +++ b/app/components/content/prescription/list.vue @@ -1,8 +1,10 @@ diff --git a/app/components/pub/my-ui/data-table/data-table.vue b/app/components/pub/my-ui/data-table/data-table.vue index 431df276..ecf2bf46 100644 --- a/app/components/pub/my-ui/data-table/data-table.vue +++ b/app/components/pub/my-ui/data-table/data-table.vue @@ -22,7 +22,7 @@ const selected = ref([]) function toggleSelection(row: any, event?: Event) { if (event) event.stopPropagation() // cegah event bubble ke TableRow - const isMultiple = props.selectMode === 'multiple' // props.selectMode === 'multi' || + const isMultiple = props.selectMode === 'multiple' // props.selectMode === 'multi' || // gunakan pembanding berdasarkan id atau stringify data const findIndex = selected.value.findIndex((r) => JSON.stringify(r) === JSON.stringify(row)) @@ -128,7 +128,7 @@ function handleActionCellClick(event: Event, _cellRef: string) { 'bg-green-50': props.selectMode === 'single' && selected.some((r) => JSON.stringify(r) === JSON.stringify(row)), 'bg-blue-50': - (props.selectMode === 'multiple') && // props.selectMode === 'multi' || + (props.selectMode === 'multiple') && // props.selectMode === 'multi' || selected.some((r) => JSON.stringify(r) === JSON.stringify(row)), }" @click="toggleSelection(row)" diff --git a/app/handlers/prescription.handler.ts b/app/handlers/prescription.handler.ts index 62e1861e..10bea176 100644 --- a/app/handlers/prescription.handler.ts +++ b/app/handlers/prescription.handler.ts @@ -1,4 +1,4 @@ -import { createCrudHandler, genCrudHandler } from '~/handlers/_handler' +import { genCrudHandler } from '~/handlers/_handler' import { create, update, remove } from '~/services/prescription.service' export const { diff --git a/app/models/medicine.ts b/app/models/medicine.ts index d3a04752..5aa01da4 100644 --- a/app/models/medicine.ts +++ b/app/models/medicine.ts @@ -1,10 +1,17 @@ +import type { MedicineFormData } from "~/schemas/medicine.schema" import { type Base, genBase } from "./_base" +import type { MedicineGroup } from "./medicine-group" +import type { MedicineMethod } from "./medicine-method" export interface Medicine extends Base { code: string name: string - medicineGroup_code: string - medicineMethod_code: string + medicineGroup_code?: string + medicineGroup?: MedicineGroup + medicineMethod_code?: string + medicineMethod?: MedicineMethod + medicineForm_code?: string + medicineForm?: MedicineFormData uom_code: string infra_id?: string | null stock: number diff --git a/app/models/medicinemix-item.ts b/app/models/medicinemix-item.ts index d2e1f973..9c055294 100644 --- a/app/models/medicinemix-item.ts +++ b/app/models/medicinemix-item.ts @@ -1,7 +1,7 @@ import { type Base, genBase } from "./_base" import { type Medicine, genMedicine } from "./medicine"; -interface MedicinemixItem extends Base { +export interface MedicinemixItem extends Base { id: number medicineMix_id: number medicine_id: number @@ -35,7 +35,7 @@ export interface DeleteDto { id: number } -export function MedicinemixItem(): MedicinemixItem { +export function genMedicinemixItem(): MedicinemixItem { return { ...genBase(), medicineMix_id: 0, diff --git a/app/models/prescription-item.ts b/app/models/prescription-item.ts index 6f0d3716..3349fcbf 100644 --- a/app/models/prescription-item.ts +++ b/app/models/prescription-item.ts @@ -5,10 +5,10 @@ export interface PrescriptionItem { id: number; prescription_id: number; isMix: boolean; - medicine_id: number; - medicine: Medicine; - medicineMix_id: number; - medicineMix: Medicinemix + medicine_code?: string; + medicine?: Medicine; + medicineMix_id?: number; + medicineMix?: Medicinemix frequency: number; dose: number; interval: number; @@ -29,35 +29,35 @@ export interface CreateDto { quantity: number; usage: string; } - + export interface GetListDto { page: number size: number name?: string // code?: string } - + export interface GetDetailDto { id?: string } - + export interface UpdateDto extends CreateDto { id?: number } - + export interface DeleteDto { id?: string } - -export function genPresciptionItem(): PrescriptionItem { + +export function genPrescriptionItem(): PrescriptionItem { return { id: 0, prescription_id: 0, isMix: false, - medicine_id: 0, - medicine: genMedicine(), - medicineMix_id: 0, - medicineMix: genMedicinemix(), + // medicine_code: '', + // medicine: genMedicine(), + // medicineMix_id: 0, + // medicineMix: genMedicinemix(), frequency: 0, dose: 0, interval: 0, @@ -66,4 +66,3 @@ export function genPresciptionItem(): PrescriptionItem { usage: '' } } - \ No newline at end of file diff --git a/app/services/prescription.service.ts b/app/services/prescription.service.ts index 150357ab..7bdc9f51 100644 --- a/app/services/prescription.service.ts +++ b/app/services/prescription.service.ts @@ -1,4 +1,5 @@ import * as base from './_crud-base' +import { xfetch } from '~/composables/useXfetch' const path = '/api/v1/prescription' const name = 'prescription' @@ -22,3 +23,16 @@ export function update(id: number | string, data: any) { export function remove(id: number | string) { return base.remove(path, id) } + +export async function submit(id: number) { + try { + const resp = await xfetch(`${path}/${id}/submit`, 'PATCH') + const result: any = {} + result.success = resp.success + result.body = (resp.body as Record) || {} + return result + } catch (error) { + console.error(`Error submitting ${name}:`, error) + throw new Error(`Failed to submit ${name}`) + } +}