feat/prescription: integrated non-mix
This commit is contained in:
@@ -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<PrescriptionItem> ({
|
||||
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<PrescriptionItem[]>([])
|
||||
const mixItem = ref<PrescriptionItem>(genPrescriptionItem())
|
||||
const medicinemixItems = ref<MedicinemixItem[]>([])
|
||||
const nonMixItem = ref<PrescriptionItem>(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<Medicine[]>([])
|
||||
|
||||
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 = []
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -94,7 +119,7 @@ function saveNonMix(data: PrescriptionItem) {
|
||||
<Detail :data="data" />
|
||||
|
||||
<ItemListEntry
|
||||
:data="prescriptionItems"
|
||||
:data="items"
|
||||
@add="addItem"/>
|
||||
<Separator class="my-5" />
|
||||
|
||||
@@ -105,28 +130,31 @@ function saveNonMix(data: PrescriptionItem) {
|
||||
<Dialog
|
||||
v-model:open="mixDialogOpen"
|
||||
:title="recItem?.id ? 'Edit Racikan' : 'Tambah Racikan'"
|
||||
size="xl"
|
||||
size="lg"
|
||||
prevent-outside
|
||||
>
|
||||
<MixItemEntry
|
||||
:data="data"
|
||||
:items="items"
|
||||
:data="mixItem"
|
||||
:items="medicinemixItems"
|
||||
:medicines="medicines"
|
||||
@close="mixDialogOpen = false"
|
||||
@save="saveMix"
|
||||
@update:searchText="getMedicines"
|
||||
/>
|
||||
</Dialog>
|
||||
|
||||
<Dialog
|
||||
v-model:open="nonMixDialogOpen"
|
||||
:title="recItem?.id ? 'Edit Non Racikan' : 'Tambah Non Racikan'"
|
||||
size="xl"
|
||||
size="lg"
|
||||
prevent-outside
|
||||
>
|
||||
<NonMixItemEntry
|
||||
:data="data"
|
||||
:items="items"
|
||||
:data="nonMixItem"
|
||||
:medicines="medicines"
|
||||
@close="mixDialogOpen = false"
|
||||
@save="saveNonMix"
|
||||
@update:searchText="getMedicines"
|
||||
/>
|
||||
</Dialog>
|
||||
</template>
|
||||
|
||||
@@ -177,6 +177,16 @@ async function handleActionSubmit(id: number, refresh: () => void, toast: ToastF
|
||||
@confirm="() => handleActionRemove(recId, getMyList, toast)"
|
||||
@cancel=""
|
||||
>
|
||||
<div class="flex">
|
||||
<div class="w-40">Tanggal</div>
|
||||
<div class="w-5 text-cneter">:</div>
|
||||
<div class="">:</div>
|
||||
</div>
|
||||
<div class="flex">
|
||||
<div class="w-40">Tanggal</div>
|
||||
<div class="w-5 text-cneter">:</div>
|
||||
<div class="">:</div>
|
||||
</div>
|
||||
</RecordConfirmation>
|
||||
|
||||
<RecordConfirmation
|
||||
|
||||
Reference in New Issue
Block a user