feat: Implement encounter list management with search, date range filtering, and record actions.
This commit is contained in:
@@ -18,25 +18,13 @@ const props = defineProps<{
|
|||||||
onExportCsv?: () => void
|
onExportCsv?: () => void
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
// function emitSearchNavClick() {
|
const emit = defineEmits<{
|
||||||
// props.refSearchNav?.onClick()
|
apply: [filters: { personName: string; startDate: string; endDate: string }]
|
||||||
// }
|
}>()
|
||||||
//
|
|
||||||
// function onInput(event: Event) {
|
|
||||||
// props.refSearchNav?.onInput((event.target as HTMLInputElement).value)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// function btnClick() {
|
|
||||||
// props.prep?.addNav?.onClick?.()
|
|
||||||
// }
|
|
||||||
|
|
||||||
const searchQuery = ref('')
|
const searchQuery = ref('')
|
||||||
const isRoleRegistration = props.activePositon === 'registration'
|
const isRoleRegistration = props.activePositon === 'registration'
|
||||||
const isRoleMedical = props.activePositon === 'medical'
|
const isRoleMedical = props.activePositon === 'medical'
|
||||||
const dateRange = ref<{ from: Date | null; to: Date | null }>({
|
|
||||||
from: new Date(),
|
|
||||||
to: new Date(),
|
|
||||||
})
|
|
||||||
|
|
||||||
const df = new DateFormatter('en-US', {
|
const df = new DateFormatter('en-US', {
|
||||||
dateStyle: 'medium',
|
dateStyle: 'medium',
|
||||||
@@ -49,31 +37,47 @@ const todayCalendar = new CalendarDate(today.getFullYear(), today.getMonth() + 1
|
|||||||
// Get date 1 month ago
|
// Get date 1 month ago
|
||||||
const oneMonthAgo = new Date(today)
|
const oneMonthAgo = new Date(today)
|
||||||
oneMonthAgo.setMonth(today.getMonth() - 1)
|
oneMonthAgo.setMonth(today.getMonth() - 1)
|
||||||
const oneMonthAgoCalendar = new CalendarDate(oneMonthAgo.getFullYear(), oneMonthAgo.getMonth() + 1, oneMonthAgo.getDate())
|
const oneMonthAgoCalendar = new CalendarDate(
|
||||||
|
oneMonthAgo.getFullYear(),
|
||||||
|
oneMonthAgo.getMonth() + 1,
|
||||||
|
oneMonthAgo.getDate(),
|
||||||
|
)
|
||||||
|
|
||||||
const value = ref({
|
const value = ref({
|
||||||
start: oneMonthAgoCalendar,
|
start: oneMonthAgoCalendar,
|
||||||
end: todayCalendar,
|
end: todayCalendar,
|
||||||
}) as Ref<DateRange>
|
}) as Ref<DateRange>
|
||||||
|
|
||||||
// function onFilterClick() {
|
function onFilterClick() {
|
||||||
// console.log('Search:', searchQuery.value)
|
const startDate = value.value.start ? value.value.start.toString() : ''
|
||||||
// console.log('Date Range:', dateRange.value)
|
const endDate = value.value.end ? value.value.end.toString() : startDate
|
||||||
// props.refSearchNav?.onClick()
|
|
||||||
// }
|
emit('apply', {
|
||||||
|
personName: searchQuery.value,
|
||||||
|
startDate,
|
||||||
|
endDate,
|
||||||
|
})
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="relative w-64">
|
<div class="relative w-64">
|
||||||
<Search class="absolute left-3 top-1/2 size-4 -translate-y-1/2 text-gray-400" />
|
<Search class="absolute left-3 top-1/2 size-4 -translate-y-1/2 text-gray-400" />
|
||||||
<Input v-model="searchQuery" type="text" placeholder="Cari Nama /No.RM" class="pl-9" />
|
<Input
|
||||||
|
v-model="searchQuery"
|
||||||
|
type="text"
|
||||||
|
placeholder="Cari Nama /No.RM"
|
||||||
|
class="pl-9"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Popover>
|
<Popover>
|
||||||
<PopoverTrigger as-child>
|
<PopoverTrigger as-child>
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="outline"
|
||||||
:class="cn('min-w-[240px] max-w-[320px] justify-start text-left font-normal', !value && 'text-muted-foreground')"
|
:class="
|
||||||
|
cn('min-w-[240px] max-w-[320px] justify-start text-left font-normal', !value && 'text-muted-foreground')
|
||||||
|
"
|
||||||
>
|
>
|
||||||
<CalendarIcon class="mr-2 h-4 w-4" />
|
<CalendarIcon class="mr-2 h-4 w-4" />
|
||||||
<template v-if="value.start">
|
<template v-if="value.start">
|
||||||
@@ -86,7 +90,7 @@ const value = ref({
|
|||||||
{{ df.format(value.start.toDate(getLocalTimeZone())) }}
|
{{ df.format(value.start.toDate(getLocalTimeZone())) }}
|
||||||
</template>
|
</template>
|
||||||
</template>
|
</template>
|
||||||
<template v-else> Pick a date </template>
|
<template v-else>Pick a date</template>
|
||||||
</Button>
|
</Button>
|
||||||
</PopoverTrigger>
|
</PopoverTrigger>
|
||||||
<PopoverContent class="w-auto p-0">
|
<PopoverContent class="w-auto p-0">
|
||||||
@@ -99,28 +103,32 @@ const value = ref({
|
|||||||
</PopoverContent>
|
</PopoverContent>
|
||||||
</Popover>
|
</Popover>
|
||||||
|
|
||||||
<Button variant="outline" class="border-orange-500 text-orange-600 hover:bg-orange-50" @click="onFilterClick">
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
class="border-orange-500 text-orange-600 hover:bg-orange-50"
|
||||||
|
@click="onFilterClick"
|
||||||
|
>
|
||||||
<FilterIcon class="mr-2 size-4" />
|
<FilterIcon class="mr-2 size-4" />
|
||||||
Filter
|
Filter
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<DropdownMenu v-show="props.enableExport && (isRoleRegistration || isRoleMedical)">
|
<DropdownMenu v-show="props.enableExport && (isRoleRegistration || isRoleMedical)">
|
||||||
<DropdownMenuTrigger as-child>
|
<DropdownMenuTrigger as-child>
|
||||||
<Button variant="outline" class="ml-auto border-orange-500 text-orange-600 hover:bg-orange-50">
|
<Button
|
||||||
<Icon name="i-lucide-download" class="h-4 w-4" />
|
variant="outline"
|
||||||
|
class="ml-auto border-orange-500 text-orange-600 hover:bg-orange-50"
|
||||||
|
>
|
||||||
|
<Icon
|
||||||
|
name="i-lucide-download"
|
||||||
|
class="h-4 w-4"
|
||||||
|
/>
|
||||||
Ekspor
|
Ekspor
|
||||||
</Button>
|
</Button>
|
||||||
</DropdownMenuTrigger>
|
</DropdownMenuTrigger>
|
||||||
<DropdownMenuContent>
|
<DropdownMenuContent>
|
||||||
<DropdownMenuItem @click="onExportPdf">
|
<DropdownMenuItem @click="onExportPdf">Ekspor PDF</DropdownMenuItem>
|
||||||
Ekspor PDF
|
<DropdownMenuItem @click="onExportCsv">Ekspor CSV</DropdownMenuItem>
|
||||||
</DropdownMenuItem>
|
<DropdownMenuItem @click="onExportExcel">Ekspor Excel</DropdownMenuItem>
|
||||||
<DropdownMenuItem @click="onExportCsv">
|
|
||||||
Ekspor CSV
|
|
||||||
</DropdownMenuItem>
|
|
||||||
<DropdownMenuItem @click="onExportExcel">
|
|
||||||
Ekspor Excel
|
|
||||||
</DropdownMenuItem>
|
|
||||||
</DropdownMenuContent>
|
</DropdownMenuContent>
|
||||||
</DropdownMenu>
|
</DropdownMenu>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -13,7 +13,11 @@ import { useSidebar } from '~/components/pub/ui/sidebar/utils'
|
|||||||
import { getServicePosition } from '~/lib/roles' // previously getPositionAs
|
import { getServicePosition } from '~/lib/roles' // previously getPositionAs
|
||||||
|
|
||||||
// Services
|
// Services
|
||||||
import { getList as getEncounterList, remove as removeEncounter, cancel as cancelEncounter } from '~/services/encounter.service'
|
import {
|
||||||
|
getList as getEncounterList,
|
||||||
|
remove as removeEncounter,
|
||||||
|
cancel as cancelEncounter,
|
||||||
|
} from '~/services/encounter.service'
|
||||||
|
|
||||||
// Apps
|
// Apps
|
||||||
import Content from '~/components/app/encounter/list.vue'
|
import Content from '~/components/app/encounter/list.vue'
|
||||||
@@ -40,6 +44,7 @@ const { getActiveRole } = useUserStore()
|
|||||||
// Main data
|
// Main data
|
||||||
const data = ref([])
|
const data = ref([])
|
||||||
const dataFiltered = ref([])
|
const dataFiltered = ref([])
|
||||||
|
const filterParams = ref<any>({})
|
||||||
const activeServicePosition = ref(getServicePosition(getActiveRole()))
|
const activeServicePosition = ref(getServicePosition(getActiveRole()))
|
||||||
const isLoading = reactive<DataTableLoader>({
|
const isLoading = reactive<DataTableLoader>({
|
||||||
summary: false,
|
summary: false,
|
||||||
@@ -99,27 +104,30 @@ provide('rec_action', recAction)
|
|||||||
provide('rec_item', recItem)
|
provide('rec_item', recItem)
|
||||||
provide('table_data_loader', isLoading)
|
provide('table_data_loader', isLoading)
|
||||||
|
|
||||||
watch(getActiveRole, (role? : string) => {
|
watch(getActiveRole, (role?: string) => {
|
||||||
activeServicePosition.value = getServicePosition(role)
|
activeServicePosition.value = getServicePosition(role)
|
||||||
})
|
})
|
||||||
|
|
||||||
watch(() => recAction.value, () => {
|
watch(
|
||||||
const basePath = `/${props.classCode}/encounter`
|
() => recAction.value,
|
||||||
if (recAction.value === ActionEvents.showConfirmDelete) {
|
() => {
|
||||||
isRecordConfirmationOpen.value = true
|
const basePath = `/${props.classCode}/encounter`
|
||||||
} else if (recAction.value === ActionEvents.showCancel) {
|
if (recAction.value === ActionEvents.showConfirmDelete) {
|
||||||
isRecordCancelOpen.value = true
|
isRecordConfirmationOpen.value = true
|
||||||
} else if (recAction.value === ActionEvents.showDetail) {
|
} else if (recAction.value === ActionEvents.showCancel) {
|
||||||
navigateTo(`${basePath}/${recId.value}/detail`)
|
isRecordCancelOpen.value = true
|
||||||
} else if (recAction.value === ActionEvents.showEdit) {
|
} else if (recAction.value === ActionEvents.showDetail) {
|
||||||
navigateTo(`${basePath}/${recId.value}/edit`)
|
navigateTo(`${basePath}/${recId.value}/detail`)
|
||||||
} else if (recAction.value === ActionEvents.showProcess) {
|
} else if (recAction.value === ActionEvents.showEdit) {
|
||||||
navigateTo(`${basePath}/${recId.value}/process`)
|
navigateTo(`${basePath}/${recId.value}/edit`)
|
||||||
} else if (recAction.value === ActionEvents.showConfirmDelete) {
|
} else if (recAction.value === ActionEvents.showProcess) {
|
||||||
isRecordConfirmationOpen.value = true
|
navigateTo(`${basePath}/${recId.value}/process`)
|
||||||
}
|
} else if (recAction.value === ActionEvents.showConfirmDelete) {
|
||||||
recAction.value = '' // reset
|
isRecordConfirmationOpen.value = true
|
||||||
})
|
}
|
||||||
|
recAction.value = '' // reset
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
getPatientList()
|
getPatientList()
|
||||||
@@ -128,13 +136,16 @@ onMounted(() => {
|
|||||||
/////// Functions
|
/////// Functions
|
||||||
async function getPatientList() {
|
async function getPatientList() {
|
||||||
isLoading.isTableLoading = true
|
isLoading.isTableLoading = true
|
||||||
|
const includesParams =
|
||||||
|
'patient,patient-person,patient-person-addresses,unit,Appointment_Doctor,Appointment_Doctor-employee,Appointment_Doctor-employee-person,Responsible_Doctor,Responsible_Doctor-employee,Responsible_Doctor-employee-person'
|
||||||
|
data.value = []
|
||||||
try {
|
try {
|
||||||
const params: any = { includes: 'patient,patient-person' }
|
const params: any = { includes: includesParams, ...filterParams.value }
|
||||||
if (props.classCode) {
|
if (props.classCode) {
|
||||||
params['class-code'] = props.classCode
|
params.class_code = props.classCode
|
||||||
}
|
}
|
||||||
if (props.subClassCode) {
|
if (props.subClassCode) {
|
||||||
params['sub-class-code'] = props.subClassCode
|
params.sub_class_code = props.subClassCode
|
||||||
}
|
}
|
||||||
const result = await getEncounterList(params)
|
const result = await getEncounterList(params)
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
@@ -148,6 +159,15 @@ async function getPatientList() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleFilterApply(filters: { personName: string; startDate: string; endDate: string }) {
|
||||||
|
filterParams.value = {
|
||||||
|
'person-name': filters.personName,
|
||||||
|
'start-date': filters.startDate,
|
||||||
|
'end-date': filters.endDate,
|
||||||
|
}
|
||||||
|
getPatientList()
|
||||||
|
}
|
||||||
|
|
||||||
// Handle confirmation result
|
// Handle confirmation result
|
||||||
async function handleConfirmCancel(record: any, action: string) {
|
async function handleConfirmCancel(record: any, action: string) {
|
||||||
if (action === 'deactivate' && record?.id) {
|
if (action === 'deactivate' && record?.id) {
|
||||||
@@ -243,7 +263,7 @@ function handleRemoveConfirmation() {
|
|||||||
<CH.ContentHeader v-bind="hreaderPrep">
|
<CH.ContentHeader v-bind="hreaderPrep">
|
||||||
<FilterNav
|
<FilterNav
|
||||||
:active-positon="activeServicePosition"
|
:active-positon="activeServicePosition"
|
||||||
@onFilterClick="() => isFilterFormDialogOpen = true"
|
@apply="handleFilterApply"
|
||||||
@onExportPdf="() => {}"
|
@onExportPdf="() => {}"
|
||||||
@onExportExcel="() => {}"
|
@onExportExcel="() => {}"
|
||||||
@nExportCsv="() => {}"
|
@nExportCsv="() => {}"
|
||||||
@@ -259,7 +279,7 @@ function handleRemoveConfirmation() {
|
|||||||
size="lg"
|
size="lg"
|
||||||
prevent-outside
|
prevent-outside
|
||||||
>
|
>
|
||||||
<FilterForm v-bind="filter" />
|
<FilterForm v-bind="filter" />
|
||||||
</Dialog>
|
</Dialog>
|
||||||
|
|
||||||
<!-- Batal -->
|
<!-- Batal -->
|
||||||
|
|||||||
@@ -519,7 +519,7 @@ export function useEncounterEntry(props: {
|
|||||||
|
|
||||||
const payload: any = {
|
const payload: any = {
|
||||||
patient_id: patientId,
|
patient_id: patientId,
|
||||||
appointment_doctor_code: formValues.doctorId || null,
|
appointment_doctor_code: formValues.doctorCode || null,
|
||||||
class_code: props.classCode || '',
|
class_code: props.classCode || '',
|
||||||
subClass_code: props.subClassCode || '',
|
subClass_code: props.subClassCode || '',
|
||||||
infra_id: formValues.infra_id ?? null,
|
infra_id: formValues.infra_id ?? null,
|
||||||
|
|||||||
Reference in New Issue
Block a user