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/app/prescription-item/mix-entry.vue b/app/components/app/prescription-item/mix-entry.vue index d9b4881e..05960307 100644 --- a/app/components/app/prescription-item/mix-entry.vue +++ b/app/components/app/prescription-item/mix-entry.vue @@ -1,29 +1,36 @@ - - - Nama - + + + Nama + + + - Frequensi - + Frequensi + - Dosis - + Dosis + - Sediaan - + Sediaan + - Total - + Total + - - Cara Pakai - + + Cara Pakai + Daftar Obat @@ -77,20 +94,29 @@ function addItem() { Nama Dosis - Satuan - .. + + - + - + - + + + + + @@ -102,7 +128,7 @@ function addItem() { - + Tambah diff --git a/app/components/app/prescription-item/non-mix-entry.vue b/app/components/app/prescription-item/non-mix-entry.vue index 25970646..78ee9ada 100644 --- a/app/components/app/prescription-item/non-mix-entry.vue +++ b/app/components/app/prescription-item/non-mix-entry.vue @@ -2,40 +2,45 @@ import * as DE from '~/components/pub/my-ui/doc-entry' import Separator from '~/components/pub/ui/separator/Separator.vue' import Nav from '~/components/pub/my-ui/nav-footer/cl-sa.vue' +import * as CB from '~/components/pub/my-ui/combobox' -import { bigTimeUnitCodes } from '~/lib/constants' +// import { bigTimeUnitCodes } from '~/lib/constants' +import { type Medicine } from '~/models/medicine'; import type { PrescriptionItem } from '~/models/prescription-item' const props = defineProps<{ data: PrescriptionItem + medicines: Medicine[] }>() +const { medicines } = toRefs(props) +const medicineItems = ref([]) +const medicineForm = computed(() => { + const medicine = props.medicines.find(m => m.code === props.data.medicine_code) + return medicine ? medicine.medicineForm?.name : '--tidak diketahui--' +}) + type ClickType = 'close' | 'save' type Item = { value: string label: string } -const bigTimeUnitCodeItems: Item[] = [] - if(!props.data.intervalUnit_code) { props.data.intervalUnit_code = 'day' } -Object.keys(bigTimeUnitCodes).forEach((key) => { - bigTimeUnitCodeItems.push({ - value: key, - label: bigTimeUnitCodes[key] || '', - }) -}) - - const emit = defineEmits<{ close: [], save: [data: PrescriptionItem], + 'update:searchText': [value: string] }>() +watch(medicines, (data) => { + medicineItems.value = CB.objectsToItems(data, 'code', 'name') +}) + function navClick(type: ClickType) { if (type === 'close') { emit('close') @@ -43,13 +48,23 @@ function navClick(type: ClickType) { emit('save', props.data) } } + +function searchMedicineText(value: string) { + emit('update:searchText', value) +} - - - Nama - + + + Nama + + + Frequensi @@ -59,11 +74,7 @@ function navClick(type: ClickType) { Dosis - - Sediaan - - - + Total - + - + + Sediaan + + + Cara Pakai - + diff --git a/app/components/app/prescription/detail.vue b/app/components/app/prescription/detail.vue index 694eb9a1..21962532 100644 --- a/app/components/app/prescription/detail.vue +++ b/app/components/app/prescription/detail.vue @@ -13,7 +13,7 @@ const props = defineProps<{ Order {{ data.issuedAt?.substring(0, 10) || data.createdAt?.substring(0, 10) }} - {{ data.status_code }} - + DPJP diff --git a/app/components/app/prescription/entry.vue b/app/components/app/prescription/entry.vue index ef8756e8..28041eea 100644 --- a/app/components/app/prescription/entry.vue +++ b/app/components/app/prescription/entry.vue @@ -1,17 +1,25 @@ + + - + Tgl Order - + Status - + @@ -21,16 +29,22 @@ DPJP - + PPDS - + + diff --git a/app/components/app/prescription/flat-list.vue b/app/components/app/prescription/flat-list.vue new file mode 100644 index 00000000..fe0bab9c --- /dev/null +++ b/app/components/app/prescription/flat-list.vue @@ -0,0 +1,86 @@ + + + + + Belum Ada Data + + + + Tambah Order + + + + + + + Tgl Order + DPJP + PPDS + Jenis Obat + Status + + + + + + + {{ item.issuedAt?.substring(0, 10) || item.createdAt?.substring(0, 10) }} + + + {{ item.doctor?.employee?.person?.name || '-' }} + + + + + + Racikan: {{ item.items.filter(function(element){ return element.isMix}).length }} + + + Non Racikan: {{ item.items.filter(function(element){ return !element.isMix}).length }} + + + + {{ item.status_code }} + + + { navClick(type, item) }" + /> + + + + + + + diff --git a/app/components/app/prescription/list.vue b/app/components/app/prescription/grouped-list.vue similarity index 95% rename from app/components/app/prescription/list.vue rename to app/components/app/prescription/grouped-list.vue index ae5126ca..07d6fcaa 100644 --- a/app/components/app/prescription/list.vue +++ b/app/components/app/prescription/grouped-list.vue @@ -5,7 +5,6 @@ import Nav from '~/components/pub/my-ui/nav-footer/ca-ed-su.vue' import type { Prescription } from '~/models/prescription'; import PrescriptionItem from '~/components/app/prescription-item/list.vue'; -import { add } from 'date-fns'; interface Props { data: Prescription[] @@ -66,7 +65,7 @@ function navClick(type: 'cancel' | 'edit' | 'submit', data: Prescription): void /> - + diff --git a/app/components/app/prescription/list-with-sub.vue b/app/components/app/prescription/list-with-sub.vue index 14bc1785..4d1a2cdf 100644 --- a/app/components/app/prescription/list-with-sub.vue +++ b/app/components/app/prescription/list-with-sub.vue @@ -1,7 +1,5 @@ @@ -17,40 +15,40 @@ - - - Order #1 - - + + + Order #1 + + 2025-01-01 - - - - Status - - + + + + Status + + Status - - - + + + - - - DPJP - - + + + DPJP + + Nama Dokter - - - - PPDS - - + + + + PPDS + + Nama PPDS - - - + + + diff --git a/app/components/content/prescription/entry.vue b/app/components/content/prescription/entry.vue index 4b3fa663..46768432 100644 --- a/app/components/content/prescription/entry.vue +++ b/app/components/content/prescription/entry.vue @@ -1,86 +1,215 @@ @@ -91,42 +220,147 @@ function saveNonMix(data: PrescriptionItem) { class="mb-4 xl:mb-5" /> - + + + + + + + + + + + + + + + + + + Nama + + + {{ recItem.medicine.name }} + + + + Dosis + + + {{ recItem.dose }} + + + + Sediaan + + + {{ recItem.medicine.medicineForm.name }} + + + + Jumlah + + + {{ recItem.quantity }} + + + + Cara Pakai + + + {{ recItem.Usage }} + + + + + + + handleActionRemove(recId, getPrescriptionItems, toast)" + @cancel="" + > + + + + ID: + {{ record?.id }} + + + Nama: + {{ record.name }} + + + Kode: + {{ record.code }} + + + + 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 @@ - + + + + + + handleActionRemove(recId, getMyList, toast)" @cancel="" > + + Tanggal + : + {{ recItem.createdAt.substring(0, 10) }} + + + DPJP + : + {{ recItem.doctor?.employee?.person?.name }} + + + + handleActionSubmit(recId, getMyList, toast)" + @cancel="" + > + + Tanggal + : + {{ recItem.createdAt.substring(0, 10) }} + + + DPJP + : + {{ recItem.doctor?.employee?.person?.name }} + 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}`) + } +}
+ ID: + {{ record?.id }} +
+ Nama: + {{ record.name }} +
+ Kode: + {{ record.code }} +