diff --git a/app/components/app/prescription-item/list-entry.cfg.ts b/app/components/app/prescription-item/list-entry.cfg.ts
index 070dd65f..19b2f3d8 100644
--- a/app/components/app/prescription-item/list-entry.cfg.ts
+++ b/app/components/app/prescription-item/list-entry.cfg.ts
@@ -20,7 +20,7 @@ export const config: Config = {
],
],
- keys: ['name', 'uom_code', 'frequency', 'multiplier', 'interval', 'total', 'action'],
+ keys: ['medicine.name', 'medicine.medicineForm.name', 'frequency', 'dose', 'interval', 'total', 'action'],
delKeyNames: [
{ key: 'code', label: 'Kode' },
diff --git a/app/components/app/prescription-item/mix-entry.vue b/app/components/app/prescription-item/mix-entry.vue
index d9b4881e..187e9569 100644
--- a/app/components/app/prescription-item/mix-entry.vue
+++ b/app/components/app/prescription-item/mix-entry.vue
@@ -1,29 +1,37 @@
-
-
+
+
Nama
-
+
+
+
Frequensi
@@ -66,7 +80,7 @@ function addItem() {
Total
-
+
Cara Pakai
@@ -102,7 +116,7 @@ function addItem() {
diff --git a/app/components/app/prescription-item/non-mix-entry.vue b/app/components/app/prescription-item/non-mix-entry.vue
index 25970646..9115eeb9 100644
--- a/app/components/app/prescription-item/non-mix-entry.vue
+++ b/app/components/app/prescription-item/non-mix-entry.vue
@@ -2,15 +2,26 @@
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, genMedicine } 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--'
+})
+// const selectedMedicine_code = ref(props.data.medicine_code || '')
+
type ClickType = 'close' | 'save'
type Item = {
value: string
@@ -23,19 +34,23 @@ if(!props.data.intervalUnit_code) {
props.data.intervalUnit_code = 'day'
}
-Object.keys(bigTimeUnitCodes).forEach((key) => {
- bigTimeUnitCodeItems.push({
- value: key,
- label: bigTimeUnitCodes[key] || '',
- })
-})
-
+// 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.objectsToItem(data, 'code', 'name')
+})
+
function navClick(type: ClickType) {
if (type === 'close') {
emit('close')
@@ -43,13 +58,23 @@ function navClick(type: ClickType) {
emit('save', props.data)
}
}
+
+function searchMedicineText(value: string) {
+ emit('update:searchText', value)
+}
-
-
- Nama
-
+
+
+ Nama
+
+
+
Frequensi
@@ -59,11 +84,7 @@ function navClick(type: ClickType) {
Dosis
-
- Sediaan
-
-
-
+
Total
-
+
-
+
+ Sediaan
+
+
+
Cara Pakai
diff --git a/app/components/content/prescription/entry.vue b/app/components/content/prescription/entry.vue
index 4b3fa663..3ad9d572 100644
--- a/app/components/content/prescription/entry.vue
+++ b/app/components/content/prescription/entry.vue
@@ -6,20 +6,27 @@ import Dialog from '~/components/pub/my-ui/modal/dialog.vue'
import { useQueryCRUDMode } from '~/composables/useQueryCRUD'
import type { HeaderPrep } from '~/components/pub/my-ui/data/types'
+// medicine
+import { type Medicine } from '~/models/medicine'
+
+// prescription
import { getDetail } from '~/services/prescription.service'
+import { getList as getMedicineList } from '~/services/medicine.service'
import Detail from '~/components/app/prescription/detail.vue'
-import { getList as getPrescriptionItemList } from '~/services/prescription-item.service'
-import ItemListEntry from '~/components/app/prescription-item/list-entry.vue'
-import { type PrescriptionItem } from '~/models/prescription-item'
-
-import MixItemEntry from '~/components/app/prescription-item/mix-entry.vue'
-import { create } from '~/services/prescription-item.service';
-
-import NonMixItemEntry from '~/components/app/prescription-item/non-mix-entry.vue'
+// prescription items
import {
- recItem,
-} from '~/handlers/prescription-item.handler'
+ getList as getPrescriptionItemList,
+ create as createPrescriptionItem,
+ remove as removePrescriptionItem,
+} from '~/services/prescription-item.service'
+import { type PrescriptionItem, genPrescriptionItem } from '~/models/prescription-item'
+import ItemListEntry from '~/components/app/prescription-item/list-entry.vue'
+import type { MedicinemixItem } from '~/models/medicinemix-item';
+
+import { recItem } from '~/handlers/prescription-item.handler'
+import NonMixItemEntry from '~/components/app/prescription-item/non-mix-entry.vue'
+import MixItemEntry from '~/components/app/prescription-item/mix-entry.vue'
// props
const props = defineProps<{
@@ -27,7 +34,8 @@ const props = defineProps<{
}>()
// declaration & flows
-// const route = useRoute()
+
+// Prescription
const { getQueryParam } = useQueryParam()
const id = getQueryParam('id')
const dataRes = await getDetail(
@@ -35,21 +43,15 @@ const dataRes = await getDetail(
{ includes: 'encounter,doctor,doctor-employee,doctor-employee-person' }
)
const data = dataRes.body?.data || null
-const items = ref(data?.items || [])
-const {
- data: prescriptionItems,
- fetchData: getMyList,
-} = usePaginatedList ({
- fetchFn: async ({ page, search }) => {
- const result = await getPrescriptionItemList({ 'prescription-id': id, search, page })
- if (result.success) {
- data.value = result.body.data
- }
- return { success: result.success || false, body: result.body || {} }
- },
- entityName: 'prescription-item',
-})
+// Prescription Items
+const items = ref([])
+const mixItem = ref(genPrescriptionItem())
+const medicinemixItems = ref([])
+const nonMixItem = ref(genPrescriptionItem())
+
+mixItem.value.prescription_id = typeof id === 'string' ? parseInt(id) : 0
+nonMixItem.value.prescription_id = typeof id === 'string' ? parseInt(id) : 0
const { backToList } = useQueryCRUDMode()
@@ -60,6 +62,11 @@ const headerPrep: HeaderPrep = {
const mixDialogOpen = ref(false)
const nonMixDialogOpen = ref(false)
+const medicines = ref([])
+
+onMounted(async () => {
+ await getItems()
+})
function navClick(type: 'back' | 'delete' | 'draft' | 'submit') {
if (type === 'back') {
@@ -76,11 +83,29 @@ function addItem(mode: 'mix' | 'non-mix') {
}
function saveMix() {
- create({data})
+ createPrescriptionItem(mixItem.value)
}
-function saveNonMix(data: PrescriptionItem) {
- create({data})
+function saveNonMix() {
+ createPrescriptionItem(nonMixItem.value)
+}
+
+async function getItems() {
+ const res = await getPrescriptionItemList({ 'prescription-id': id, includes: 'medicine,medicine-medicineForm,medicineMix' })
+ if (res.success) {
+ items.value = res.body.data
+ } else {
+ items.value = []
+ }
+}
+
+async function getMedicines(value: string) {
+ const res = await getMedicineList({ 'search': value, 'includes': 'medicineForm' })
+ if (res.success) {
+ medicines.value = res.body.data
+ } else {
+ medicines.value = []
+ }
}
@@ -94,7 +119,7 @@ function saveNonMix(data: PrescriptionItem) {
@@ -105,28 +130,31 @@ function saveNonMix(data: PrescriptionItem) {
diff --git a/app/components/content/prescription/list.vue b/app/components/content/prescription/list.vue
index 68e2069f..8d83f477 100644
--- a/app/components/content/prescription/list.vue
+++ b/app/components/content/prescription/list.vue
@@ -177,6 +177,16 @@ async function handleActionSubmit(id: number, refresh: () => void, toast: ToastF
@confirm="() => handleActionRemove(recId, getMyList, toast)"
@cancel=""
>
+
+