Merge pull request #152 from dikstub-rssa/feat/general-consent-145
✨ feat (encounter): implement general consent feature
This commit is contained in:
@@ -0,0 +1,214 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import Block from '~/components/pub/my-ui/doc-entry/block.vue'
|
||||||
|
import Cell from '~/components/pub/my-ui/doc-entry/cell.vue'
|
||||||
|
import Field from '~/components/pub/my-ui/doc-entry/field.vue'
|
||||||
|
import Label from '~/components/pub/my-ui/doc-entry/label.vue'
|
||||||
|
// Helpers
|
||||||
|
import type z from 'zod'
|
||||||
|
import { toTypedSchema } from '@vee-validate/zod'
|
||||||
|
import { useForm } from 'vee-validate'
|
||||||
|
// import { ref, watch, inject } from 'vue'
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
modelValue: any
|
||||||
|
schema: z.ZodSchema<any>
|
||||||
|
excludeFields?: string[]
|
||||||
|
isReadonly?: boolean
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
(e: 'update:modelValue', val: any): void
|
||||||
|
(e: 'submit', val: any): void
|
||||||
|
}>()
|
||||||
|
|
||||||
|
// Setup form
|
||||||
|
const {
|
||||||
|
validate: _validate,
|
||||||
|
defineField,
|
||||||
|
handleSubmit,
|
||||||
|
errors,
|
||||||
|
values,
|
||||||
|
} = useForm({
|
||||||
|
validationSchema: toTypedSchema(props.schema),
|
||||||
|
initialValues: props.modelValue,
|
||||||
|
})
|
||||||
|
|
||||||
|
watch(values, (val) => emit('update:modelValue', val), { deep: true })
|
||||||
|
|
||||||
|
// Define form fields
|
||||||
|
const [relatives, relativesAttrs] = defineField('relatives')
|
||||||
|
const [responsibleName, responsibleNameAttrs] = defineField('responsibleName')
|
||||||
|
const [responsiblePhone, responsiblePhoneAttrs] = defineField('responsiblePhone')
|
||||||
|
const [informant, informantAttrs] = defineField('informant')
|
||||||
|
const [witness1, witness1Attrs] = defineField('witness1')
|
||||||
|
const [witness2, witness2Attrs] = defineField('witness2')
|
||||||
|
const [tanggal, tanggalAttrs] = defineField('tanggal')
|
||||||
|
|
||||||
|
// Relatives list handling
|
||||||
|
const addRelative = () => {
|
||||||
|
relatives.value = [...(relatives.value || []), { name: '', phone: '' }]
|
||||||
|
}
|
||||||
|
|
||||||
|
const removeRelative = (index: number) => {
|
||||||
|
relatives.value = relatives.value.filter((_: any, i: number) => i !== index)
|
||||||
|
}
|
||||||
|
|
||||||
|
const validate = async () => {
|
||||||
|
const result = await _validate()
|
||||||
|
return {
|
||||||
|
valid: true,
|
||||||
|
data: result.values,
|
||||||
|
errors: result.errors,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
defineExpose({ validate })
|
||||||
|
|
||||||
|
const icdPreview = inject('icdPreview')
|
||||||
|
|
||||||
|
const isExcluded = (key: string) => props.excludeFields?.includes(key)
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<form id="entry-form">
|
||||||
|
<div class="mb-5 border-b border-b-slate-300 pb-3 text-lg xl:text-xl">
|
||||||
|
<Block>
|
||||||
|
<Cell>
|
||||||
|
<Label dynamic>Tanggal</Label>
|
||||||
|
<Field>
|
||||||
|
<Input
|
||||||
|
v-model="tanggal"
|
||||||
|
v-bind="tanggalAttrs"
|
||||||
|
:disabled="props.isReadonly"
|
||||||
|
/>
|
||||||
|
</Field>
|
||||||
|
</Cell>
|
||||||
|
</Block>
|
||||||
|
|
||||||
|
<Separator class="mt-8" />
|
||||||
|
|
||||||
|
<div class="my-2 flex items-center justify-between">
|
||||||
|
<h1 class="font-semibold">Anggota Keluarga</h1>
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
@click="addRelative"
|
||||||
|
>
|
||||||
|
+ Tambah
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-for="(item, idx) in relatives"
|
||||||
|
:key="idx"
|
||||||
|
class="my-2 rounded-md border border-slate-300 p-4"
|
||||||
|
>
|
||||||
|
<Block :colCount="2">
|
||||||
|
<Cell>
|
||||||
|
<Label dynamic>Nama Anggota Keluarga</Label>
|
||||||
|
<Field>
|
||||||
|
<Input v-model="relatives[idx].name" />
|
||||||
|
</Field>
|
||||||
|
</Cell>
|
||||||
|
|
||||||
|
<Cell>
|
||||||
|
<Label dynamic>No. Hp Anggota Keluarga</Label>
|
||||||
|
<Field>
|
||||||
|
<Input v-model="relatives[idx].phone" />
|
||||||
|
</Field>
|
||||||
|
</Cell>
|
||||||
|
</Block>
|
||||||
|
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="mt-3 text-sm text-red-500"
|
||||||
|
@click="removeRelative(idx)"
|
||||||
|
>
|
||||||
|
Hapus
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Separator class="mt-8" />
|
||||||
|
|
||||||
|
<!-- Responsible Section -->
|
||||||
|
<div class="my-2">
|
||||||
|
<h1 class="font-semibold">Penanggung Jawab</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="my-2 rounded-md border border-slate-300 p-4">
|
||||||
|
<Block :colCount="2">
|
||||||
|
<Cell>
|
||||||
|
<Label dynamic>Nama Penanggung Jawab</Label>
|
||||||
|
<Field>
|
||||||
|
<Input
|
||||||
|
v-model="responsibleName"
|
||||||
|
v-bind="responsibleNameAttrs"
|
||||||
|
/>
|
||||||
|
</Field>
|
||||||
|
</Cell>
|
||||||
|
|
||||||
|
<Cell>
|
||||||
|
<Label dynamic>No. Hp Penanggung Jawab</Label>
|
||||||
|
<Field>
|
||||||
|
<Input
|
||||||
|
v-model="responsiblePhone"
|
||||||
|
v-bind="responsiblePhoneAttrs"
|
||||||
|
/>
|
||||||
|
</Field>
|
||||||
|
</Cell>
|
||||||
|
</Block>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Separator class="mt-8" />
|
||||||
|
|
||||||
|
<!-- Informant -->
|
||||||
|
<div class="my-2">
|
||||||
|
<h1 class="font-semibold">Pemberi Informasi</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="my-2 rounded-md border border-slate-300 p-4">
|
||||||
|
<Block>
|
||||||
|
<Cell>
|
||||||
|
<Label dynamic>Informant</Label>
|
||||||
|
<Field>
|
||||||
|
<Input
|
||||||
|
v-model="informant"
|
||||||
|
v-bind="informantAttrs"
|
||||||
|
/>
|
||||||
|
</Field>
|
||||||
|
</Cell>
|
||||||
|
</Block>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Separator class="mt-8" />
|
||||||
|
|
||||||
|
<!-- Witnesses -->
|
||||||
|
<div class="my-2">
|
||||||
|
<h1 class="font-semibold">Saksi</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="my-2 rounded-md border border-slate-300 p-4">
|
||||||
|
<Block :colCount="2">
|
||||||
|
<Cell>
|
||||||
|
<Label dynamic>Saksi 1</Label>
|
||||||
|
<Field>
|
||||||
|
<Input
|
||||||
|
v-model="witness1"
|
||||||
|
v-bind="witness1Attrs"
|
||||||
|
/>
|
||||||
|
</Field>
|
||||||
|
</Cell>
|
||||||
|
|
||||||
|
<Cell>
|
||||||
|
<Label dynamic>Saksi 2</Label>
|
||||||
|
<Field>
|
||||||
|
<Input
|
||||||
|
v-model="witness2"
|
||||||
|
v-bind="witness2Attrs"
|
||||||
|
/>
|
||||||
|
</Field>
|
||||||
|
</Cell>
|
||||||
|
</Block>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
import type { Config, RecComponent, RecStrFuncComponent, RecStrFuncUnknown } from '~/components/pub/my-ui/data-table'
|
||||||
|
import { defineAsyncComponent } from 'vue'
|
||||||
|
import type { GeneralConsent } from '~/models/general-consent'
|
||||||
|
|
||||||
|
type SmallDetailDto = any
|
||||||
|
|
||||||
|
const action = defineAsyncComponent(() => import('~/components/pub/my-ui/data/dropdown-action-ud.vue'))
|
||||||
|
export const config: Config = {
|
||||||
|
cols: [{ width: 100 }, {}, {}, {}, { width: 50 }],
|
||||||
|
headers: [
|
||||||
|
[
|
||||||
|
{ label: 'Tanggal' },
|
||||||
|
{ label: 'Anggota Keluarga' },
|
||||||
|
{ label: 'Penanggung Jawab' },
|
||||||
|
{ label: 'Pemberi Informasi' },
|
||||||
|
{ label: 'Saksi 1' },
|
||||||
|
{ label: 'Saksi 2' },
|
||||||
|
{ label: '' },
|
||||||
|
],
|
||||||
|
],
|
||||||
|
keys: ['date', 'relatives', 'responsible', 'informant', 'witness1', 'witness2', 'action'],
|
||||||
|
delKeyNames: [
|
||||||
|
{ key: 'data', label: 'Tanggal' },
|
||||||
|
{ key: 'dstDoctor.name', label: 'Dokter' },
|
||||||
|
],
|
||||||
|
parses: {
|
||||||
|
date(rec) {
|
||||||
|
const recX = rec as GeneralConsent
|
||||||
|
return recX?.createdAt?.substring(0, 10) || '-'
|
||||||
|
},
|
||||||
|
relatives(rec) {
|
||||||
|
const recX = rec as GeneralConsent
|
||||||
|
const parsed = JSON.parse(recX?.value || '{}')
|
||||||
|
return parsed?.relatives?.join(', ') || '-'
|
||||||
|
},
|
||||||
|
responsible(rec) {
|
||||||
|
const recX = rec as GeneralConsent
|
||||||
|
const parsed = JSON.parse(recX?.value || '{}')
|
||||||
|
return parsed?.responsible || '-'
|
||||||
|
},
|
||||||
|
informant(rec) {
|
||||||
|
const recX = rec as GeneralConsent
|
||||||
|
const parsed = JSON.parse(recX?.value || '{}')
|
||||||
|
return parsed?.informant || '-'
|
||||||
|
},
|
||||||
|
witness1(rec) {
|
||||||
|
const recX = rec as GeneralConsent
|
||||||
|
const parsed = JSON.parse(recX?.value || '{}')
|
||||||
|
return parsed?.witness1 || '-'
|
||||||
|
},
|
||||||
|
witness2(rec) {
|
||||||
|
const recX = rec as GeneralConsent
|
||||||
|
const parsed = JSON.parse(recX?.value || '{}')
|
||||||
|
return parsed?.witness2 || '-'
|
||||||
|
},
|
||||||
|
action(rec, idx) {
|
||||||
|
const res: RecComponent = {
|
||||||
|
idx,
|
||||||
|
rec: rec as object,
|
||||||
|
component: action,
|
||||||
|
props: {
|
||||||
|
size: 'sm',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
},
|
||||||
|
},
|
||||||
|
components: {
|
||||||
|
action(rec, idx) {
|
||||||
|
const res: RecComponent = {
|
||||||
|
idx,
|
||||||
|
rec: rec as object,
|
||||||
|
component: action,
|
||||||
|
props: {
|
||||||
|
size: 'sm',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
},
|
||||||
|
} as RecStrFuncComponent,
|
||||||
|
htmls: {} as RecStrFuncUnknown,
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import type { PaginationMeta } from '~/components/pub/my-ui/pagination/pagination.type'
|
||||||
|
import PaginationView from '~/components/pub/my-ui/pagination/pagination-view.vue'
|
||||||
|
import { config } from './list.cfg'
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
data: any[]
|
||||||
|
paginationMeta: PaginationMeta
|
||||||
|
}
|
||||||
|
const props = defineProps<Props>()
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
pageChange: [page: number]
|
||||||
|
}>()
|
||||||
|
|
||||||
|
function handlePageChange(page: number) {
|
||||||
|
emit('pageChange', page)
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="space-y-4">
|
||||||
|
<PubMyUiDataTable
|
||||||
|
v-bind="config"
|
||||||
|
:rows="data"
|
||||||
|
:skeleton-size="paginationMeta?.pageSize"
|
||||||
|
/>
|
||||||
|
<!-- FIXME: pindahkan ke content/division/list.vue -->
|
||||||
|
<PaginationView
|
||||||
|
:pagination-meta="paginationMeta"
|
||||||
|
@page-change="handlePageChange"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -18,6 +18,7 @@ import Prescription from '~/components/content/prescription/main.vue'
|
|||||||
import CpLabOrder from '~/components/content/cp-lab-order/main.vue'
|
import CpLabOrder from '~/components/content/cp-lab-order/main.vue'
|
||||||
import Radiology from '~/components/content/radiology-order/main.vue'
|
import Radiology from '~/components/content/radiology-order/main.vue'
|
||||||
import Consultation from '~/components/content/consultation/list.vue'
|
import Consultation from '~/components/content/consultation/list.vue'
|
||||||
|
import GeneralConsentList from '~/components/content/general-consent/entry.vue'
|
||||||
import ResumeList from '~/components/content/resume/list.vue'
|
import ResumeList from '~/components/content/resume/list.vue'
|
||||||
import ControlLetterList from '~/components/content/control-letter/list.vue'
|
import ControlLetterList from '~/components/content/control-letter/list.vue'
|
||||||
|
|
||||||
@@ -62,7 +63,7 @@ const tabs: TabItem[] = [
|
|||||||
},
|
},
|
||||||
{ value: 'therapy-protocol', label: 'Protokol Terapi' },
|
{ value: 'therapy-protocol', label: 'Protokol Terapi' },
|
||||||
{ value: 'education-assessment', label: 'Asesmen Kebutuhan Edukasi' },
|
{ value: 'education-assessment', label: 'Asesmen Kebutuhan Edukasi' },
|
||||||
{ value: 'consent', label: 'General Consent' },
|
{ value: 'consent', label: 'General Consent', component: GeneralConsentList, props: { encounter: data } },
|
||||||
{ value: 'patient-note', label: 'CPRJ' },
|
{ value: 'patient-note', label: 'CPRJ' },
|
||||||
{ value: 'prescription', label: 'Order Obat', component: Prescription, props: { encounter_id: data.id } },
|
{ value: 'prescription', label: 'Order Obat', component: Prescription, props: { encounter_id: data.id } },
|
||||||
{ value: 'device', label: 'Order Alkes' },
|
{ value: 'device', label: 'Order Alkes' },
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { computed } from 'vue'
|
||||||
|
import { useRoute } from 'vue-router'
|
||||||
|
import { useQueryMode } from '@/composables/useQueryMode'
|
||||||
|
|
||||||
|
import List from './list.vue'
|
||||||
|
import Form from './form.vue'
|
||||||
|
|
||||||
|
// Models
|
||||||
|
import type { Encounter } from '~/models/encounter'
|
||||||
|
|
||||||
|
// Props
|
||||||
|
interface Props {
|
||||||
|
encounter: Encounter
|
||||||
|
}
|
||||||
|
|
||||||
|
const props = defineProps<Props>()
|
||||||
|
const route = useRoute()
|
||||||
|
|
||||||
|
const { mode, goToEntry, backToList } = useQueryCRUDMode('mode')
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<List
|
||||||
|
v-if="mode === 'list'"
|
||||||
|
:encounter="props.encounter"
|
||||||
|
@add="goToEntry"
|
||||||
|
@edit="goToEntry"
|
||||||
|
/>
|
||||||
|
<Form
|
||||||
|
v-else
|
||||||
|
@back="backToList"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,185 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { z } from 'zod'
|
||||||
|
import Entry from '~/components/app/general-consent/entry.vue'
|
||||||
|
import Action from '~/components/pub/my-ui/nav-footer/ba-dr-su-pr.vue'
|
||||||
|
import ActionDialog from '~/components/pub/my-ui/nav-footer/ba-su.vue'
|
||||||
|
import Dialog from '~/components/pub/my-ui/modal/dialog.vue'
|
||||||
|
import { GeneralConsentSchema } from '~/schemas/general-consent.schema'
|
||||||
|
import { toast } from '~/components/pub/ui/toast'
|
||||||
|
import { handleActionSave, handleActionEdit } from '~/handlers/general-consent.handler'
|
||||||
|
import { create } from '~/services/generate-file.service'
|
||||||
|
// Services
|
||||||
|
import { getDetail } from '~/services/general-consent.service'
|
||||||
|
const { backToList } = useQueryCRUDMode('mode')
|
||||||
|
const { recordId } = useQueryCRUDRecordId('record-id')
|
||||||
|
|
||||||
|
const route = useRoute()
|
||||||
|
const isOpenProcedure = ref(false)
|
||||||
|
const isOpenDiagnose = ref(false)
|
||||||
|
const isOpenFungsional = ref(false)
|
||||||
|
const procedures = ref([])
|
||||||
|
const diagnoses = ref([])
|
||||||
|
const fungsional = ref([])
|
||||||
|
const selectedProcedure = ref<any>(null)
|
||||||
|
const selectedDiagnose = ref<any>(null)
|
||||||
|
const selectedFungsional = ref<any>(null)
|
||||||
|
const schema = GeneralConsentSchema
|
||||||
|
const payload = ref({
|
||||||
|
encounter_id: 0,
|
||||||
|
value: '',
|
||||||
|
})
|
||||||
|
const model = ref({
|
||||||
|
relatives: [],
|
||||||
|
responsibleName: '',
|
||||||
|
responsiblePhone: '',
|
||||||
|
informant: '',
|
||||||
|
witness1: '',
|
||||||
|
witness2: '',
|
||||||
|
})
|
||||||
|
|
||||||
|
const fileUrl = ref('')
|
||||||
|
const isLoading = reactive<DataTableLoader>({
|
||||||
|
isTableLoading: false,
|
||||||
|
})
|
||||||
|
|
||||||
|
async function getDiagnoses() {
|
||||||
|
isLoading.isTableLoading = true
|
||||||
|
const resp = await xfetch('/api/v1/diagnose-src')
|
||||||
|
if (resp.success) {
|
||||||
|
diagnoses.value = (resp.body as Record<string, any>).data
|
||||||
|
}
|
||||||
|
isLoading.isTableLoading = false
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getProcedures() {
|
||||||
|
isLoading.isTableLoading = true
|
||||||
|
const resp = await xfetch('/api/v1/procedure-src')
|
||||||
|
if (resp.success) {
|
||||||
|
procedures.value = (resp.body as Record<string, any>).data
|
||||||
|
}
|
||||||
|
isLoading.isTableLoading = false
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
const mode = route.query.mode
|
||||||
|
const recordId = route.query['record-id']
|
||||||
|
|
||||||
|
if (mode === 'entry' && recordId) {
|
||||||
|
loadEntryForEdit(+recordId)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// TODO: mapping data detail when edit
|
||||||
|
const loadEntryForEdit = async (id: number) => {
|
||||||
|
const result = await getDetail(id)
|
||||||
|
|
||||||
|
if (result?.success) {
|
||||||
|
const data = result.body?.data || {}
|
||||||
|
|
||||||
|
const value = JSON.parse(data.value || '{}')
|
||||||
|
model.value.witness1 = value?.witness1 || ''
|
||||||
|
model.value.witness2 = value?.witness2 || ''
|
||||||
|
model.value.informant = value?.informant || ''
|
||||||
|
model.value.responsibleName = value?.responsible || ''
|
||||||
|
model.value.responsiblePhone = value?.responsiblePhone || ''
|
||||||
|
model.value.relatives = value?.relatives || []
|
||||||
|
console.log('model', model.value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleClick(type: string) {
|
||||||
|
if (type === 'prosedur') {
|
||||||
|
isOpenProcedure.value = true
|
||||||
|
} else if (type === 'diagnosa') {
|
||||||
|
isOpenDiagnose.value = true
|
||||||
|
} else if (type === 'fungsional') {
|
||||||
|
isOpenDiagnose.value = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const entryGeneralConsent = ref()
|
||||||
|
async function actionHandler(type: string) {
|
||||||
|
if (type === 'back') {
|
||||||
|
backToList()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (type === 'print') {
|
||||||
|
const data = await getDetail(recordId.value)
|
||||||
|
const detail = data.body?.data
|
||||||
|
fileUrl.value = detail?.fileUrl
|
||||||
|
isOpenDiagnose.value = true
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const result = await entryGeneralConsent.value?.validate()
|
||||||
|
if (result?.valid) {
|
||||||
|
if (result.data.relatives.length > 0) {
|
||||||
|
result.data.relatives = result.data.relatives.map((item: any) => {
|
||||||
|
return item.name
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('data', result)
|
||||||
|
const resp = await handleActionSave(
|
||||||
|
{
|
||||||
|
...payload.value,
|
||||||
|
value: JSON.stringify(result.data),
|
||||||
|
encounter_id: +route.params.id,
|
||||||
|
},
|
||||||
|
() => {},
|
||||||
|
() => {},
|
||||||
|
toast,
|
||||||
|
)
|
||||||
|
const data = resp.body?.data
|
||||||
|
if (data) {
|
||||||
|
const resp2 = await create({
|
||||||
|
entityType_code: 'encounter',
|
||||||
|
ref_id: data?.id,
|
||||||
|
type_code: 'general-consent',
|
||||||
|
})
|
||||||
|
console.log('resp2', resp2.body?.data)
|
||||||
|
backToList()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.log('Ada error di form', result)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const icdPreview = ref({
|
||||||
|
procedures: [],
|
||||||
|
diagnoses: [],
|
||||||
|
})
|
||||||
|
|
||||||
|
function actionDialogHandler(type: string) {
|
||||||
|
if (type === 'submit') {
|
||||||
|
// icdPreview.value.procedures = selectedProcedure.value || []
|
||||||
|
// icdPreview.value.diagnoses = selectedDiagnose.value || []
|
||||||
|
// icdPreview.value.fungsional = selectedFungsional.value || []
|
||||||
|
}
|
||||||
|
isOpenProcedure.value = false
|
||||||
|
isOpenDiagnose.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
provide('table_data_loader', isLoading)
|
||||||
|
provide('icdPreview', icdPreview)
|
||||||
|
</script>
|
||||||
|
<template>
|
||||||
|
<Entry
|
||||||
|
ref="entryGeneralConsent"
|
||||||
|
v-model="model"
|
||||||
|
:schema="schema"
|
||||||
|
@click="handleClick"
|
||||||
|
/>
|
||||||
|
<div class="my-2 flex justify-end py-2">
|
||||||
|
<Action @click="actionHandler" />
|
||||||
|
</div>
|
||||||
|
<Dialog
|
||||||
|
v-model:open="isOpenDiagnose"
|
||||||
|
title="Preview General Content"
|
||||||
|
size="xl"
|
||||||
|
prevent-outside
|
||||||
|
>
|
||||||
|
<embed
|
||||||
|
style="width: 100%; height: 90vh"
|
||||||
|
:src="fileUrl"
|
||||||
|
/>
|
||||||
|
</Dialog>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,179 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
// Components
|
||||||
|
import Dialog from '~/components/pub/my-ui/modal/dialog.vue'
|
||||||
|
import Header from '~/components/pub/my-ui/nav-header/prep.vue'
|
||||||
|
import RecordConfirmation from '~/components/pub/my-ui/confirmation/record-confirmation.vue'
|
||||||
|
import List from '~/components/app/general-consent/list.vue'
|
||||||
|
import Entry from '~/components/app/general-consent/entry.vue'
|
||||||
|
|
||||||
|
// Helpers
|
||||||
|
import { usePaginatedList } from '~/composables/usePaginatedList'
|
||||||
|
import { toast } from '~/components/pub/ui/toast'
|
||||||
|
|
||||||
|
// Types
|
||||||
|
import { ActionEvents, type HeaderPrep } from '~/components/pub/my-ui/data/types'
|
||||||
|
import { GeneralConsentSchema, type GeneralConsentFormData } from '~/schemas/general-consent.schema'
|
||||||
|
|
||||||
|
// Handlers
|
||||||
|
import {
|
||||||
|
recId,
|
||||||
|
recAction,
|
||||||
|
recItem,
|
||||||
|
isReadonly,
|
||||||
|
isProcessing,
|
||||||
|
isFormEntryDialogOpen,
|
||||||
|
isRecordConfirmationOpen,
|
||||||
|
onResetState,
|
||||||
|
handleActionSave,
|
||||||
|
handleActionEdit,
|
||||||
|
handleActionRemove,
|
||||||
|
handleCancelForm,
|
||||||
|
} from '~/handlers/general-consent.handler'
|
||||||
|
|
||||||
|
// Services
|
||||||
|
import { getList, getDetail } from '~/services/general-consent.service'
|
||||||
|
|
||||||
|
// Models
|
||||||
|
import type { Encounter } from '~/models/encounter'
|
||||||
|
|
||||||
|
// Props
|
||||||
|
interface Props {
|
||||||
|
encounter: Encounter
|
||||||
|
}
|
||||||
|
const props = defineProps<Props>()
|
||||||
|
const emits = defineEmits(['add', 'edit'])
|
||||||
|
const router = useRouter()
|
||||||
|
const route = useRoute()
|
||||||
|
|
||||||
|
const { goToEntry, backToList } = useQueryCRUDMode('mode')
|
||||||
|
|
||||||
|
let units = ref<{ value: string; label: string }[]>([])
|
||||||
|
const encounterId = ref<number>(props?.encounter?.id || 0)
|
||||||
|
const title = ref('')
|
||||||
|
|
||||||
|
const {
|
||||||
|
data,
|
||||||
|
isLoading,
|
||||||
|
paginationMeta,
|
||||||
|
searchInput,
|
||||||
|
handlePageChange,
|
||||||
|
handleSearch,
|
||||||
|
fetchData: getMyList,
|
||||||
|
} = usePaginatedList({
|
||||||
|
fetchFn: async ({ page, search }) => {
|
||||||
|
const result = await getList({ 'encounter-id': props.encounter.id, includes: '', search, page })
|
||||||
|
if (result.success) {
|
||||||
|
data.value = result.body.data
|
||||||
|
}
|
||||||
|
return { success: result.success || false, body: result.body || {} }
|
||||||
|
},
|
||||||
|
entityName: 'general-consent',
|
||||||
|
})
|
||||||
|
|
||||||
|
const headerPrep: HeaderPrep = {
|
||||||
|
title: 'General Consent',
|
||||||
|
icon: 'i-lucide-box',
|
||||||
|
refSearchNav: {
|
||||||
|
placeholder: 'Cari (min. 3 karakter)...',
|
||||||
|
minLength: 3,
|
||||||
|
debounceMs: 500,
|
||||||
|
showValidationFeedback: true,
|
||||||
|
onInput: (value: string) => {
|
||||||
|
searchInput.value = value
|
||||||
|
},
|
||||||
|
onClick: () => {},
|
||||||
|
onClear: () => {},
|
||||||
|
},
|
||||||
|
addNav: {
|
||||||
|
label: 'Tambah',
|
||||||
|
icon: 'i-lucide-plus',
|
||||||
|
onClick: () => {
|
||||||
|
goToEntry()
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
const goEdit = (id: string) => {
|
||||||
|
router.replace({
|
||||||
|
path: route.path,
|
||||||
|
query: {
|
||||||
|
...route.query,
|
||||||
|
mode: 'entry',
|
||||||
|
'record-id': id,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const today = new Date()
|
||||||
|
|
||||||
|
provide('rec_id', recId)
|
||||||
|
provide('rec_action', recAction)
|
||||||
|
provide('rec_item', recItem)
|
||||||
|
provide('table_data_loader', isLoading)
|
||||||
|
|
||||||
|
const getMyDetail = async (id: number | string) => {
|
||||||
|
const result = await getDetail(id)
|
||||||
|
if (result.success) {
|
||||||
|
const currentValue = result.body?.data || {}
|
||||||
|
recItem.value = currentValue
|
||||||
|
isFormEntryDialogOpen.value = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Watch for row actions when recId or recAction changes
|
||||||
|
watch(recId, () => {
|
||||||
|
console.log('recId', recId.value)
|
||||||
|
if (recAction.value === ActionEvents.showEdit) {
|
||||||
|
goEdit(recId.value)
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
isRecordConfirmationOpen.value = true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
await getMyList()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Header
|
||||||
|
v-model="searchInput"
|
||||||
|
:prep="headerPrep"
|
||||||
|
:ref-search-nav="headerPrep.refSearchNav"
|
||||||
|
@search="handleSearch"
|
||||||
|
class="mb-4 xl:mb-5"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<List
|
||||||
|
:data="data"
|
||||||
|
:pagination-meta="paginationMeta"
|
||||||
|
@page-change="handlePageChange"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<!-- Record Confirmation Modal -->
|
||||||
|
<RecordConfirmation
|
||||||
|
v-model:open="isRecordConfirmationOpen"
|
||||||
|
action="delete"
|
||||||
|
:record="recItem"
|
||||||
|
@confirm="() => handleActionRemove(recId, getMyList, toast)"
|
||||||
|
@cancel=""
|
||||||
|
>
|
||||||
|
<template #default="{ record }">
|
||||||
|
<div class="text-sm">
|
||||||
|
<p>
|
||||||
|
<strong>ID:</strong>
|
||||||
|
{{ record?.id }}
|
||||||
|
</p>
|
||||||
|
<p v-if="record?.name">
|
||||||
|
<strong>Nama:</strong>
|
||||||
|
{{ record.name }}
|
||||||
|
</p>
|
||||||
|
<p v-if="record?.code">
|
||||||
|
<strong>Kode:</strong>
|
||||||
|
{{ record.code }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</RecordConfirmation>
|
||||||
|
</template>
|
||||||
@@ -19,7 +19,17 @@ export function useQueryCRUDMode(key: string = 'mode') {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const goToEntry = () => (mode.value = 'entry')
|
const goToEntry = () => (mode.value = 'entry')
|
||||||
const backToList = () =>(mode.value = 'list')
|
const backToList = () => {
|
||||||
|
router.push({
|
||||||
|
path: route.path,
|
||||||
|
query: {
|
||||||
|
...route.query,
|
||||||
|
mode: 'list',
|
||||||
|
// HAPUS record-id
|
||||||
|
'record-id': undefined,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
return { mode, goToEntry, backToList }
|
return { mode, goToEntry, backToList }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
// Handlers
|
||||||
|
import { genCrudHandler } from '~/handlers/_handler'
|
||||||
|
|
||||||
|
// Services
|
||||||
|
import { create, update, remove } from '~/services/general-consent.service'
|
||||||
|
|
||||||
|
export const {
|
||||||
|
recId,
|
||||||
|
recAction,
|
||||||
|
recItem,
|
||||||
|
isReadonly,
|
||||||
|
isProcessing,
|
||||||
|
isFormEntryDialogOpen,
|
||||||
|
isRecordConfirmationOpen,
|
||||||
|
onResetState,
|
||||||
|
handleActionSave,
|
||||||
|
handleActionEdit,
|
||||||
|
handleActionRemove,
|
||||||
|
handleCancelForm,
|
||||||
|
} = genCrudHandler({
|
||||||
|
create,
|
||||||
|
update,
|
||||||
|
remove,
|
||||||
|
})
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
export interface GeneralConsent {
|
||||||
|
id: number
|
||||||
|
encounter_id: number
|
||||||
|
value: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ValueCreateDto {
|
||||||
|
relatives: string[]
|
||||||
|
responsibleName: string
|
||||||
|
responsiblePhone: string
|
||||||
|
informant: string
|
||||||
|
witness1: string
|
||||||
|
witness2: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CreateDto {
|
||||||
|
encounter_id: number
|
||||||
|
value: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UpdateDto {
|
||||||
|
id: number
|
||||||
|
problem: string
|
||||||
|
unit_id: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DeleteDto {
|
||||||
|
id: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export function genCreateDto(): CreateDto {
|
||||||
|
return {
|
||||||
|
encounter_id: 0,
|
||||||
|
problem: '',
|
||||||
|
unit_id: 0,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function genConsultation(): GeneralConsent {
|
||||||
|
return {
|
||||||
|
id: 0,
|
||||||
|
encounter_id: 0,
|
||||||
|
unit_id: 0,
|
||||||
|
doctor_id: 0,
|
||||||
|
problem: '',
|
||||||
|
solution: '',
|
||||||
|
repliedAt: '',
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
export interface GenerateFile {
|
||||||
|
entityType_code: string
|
||||||
|
ref_id: number
|
||||||
|
type_code: string
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import { z } from 'zod'
|
||||||
|
import type { CreateDto } from '~/models/general-consent'
|
||||||
|
|
||||||
|
const GeneralConsentSchema = z.object({
|
||||||
|
relatives: z.array(z.object({ name: z.string(), phone: z.string() })),
|
||||||
|
responsibleName: z.string().optional(),
|
||||||
|
responsiblePhone: z.string().optional(),
|
||||||
|
informant: z.string().optional(),
|
||||||
|
witness1: z.string().optional(),
|
||||||
|
witness2: z.string().optional(),
|
||||||
|
})
|
||||||
|
|
||||||
|
type GeneralConsentFormData = z.infer<typeof GeneralConsentSchema> & CreateDto
|
||||||
|
|
||||||
|
export { GeneralConsentSchema }
|
||||||
|
export type { GeneralConsentFormData }
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
import * as base from './_crud-base'
|
||||||
|
|
||||||
|
const path = '/api/v1/general-consent'
|
||||||
|
|
||||||
|
export function create(data: any) {
|
||||||
|
return base.create(path, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getList(params: any = null) {
|
||||||
|
return base.getList(path, params)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getDetail(id: number | string) {
|
||||||
|
return base.getDetail(path, id)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function update(id: number | string, data: any) {
|
||||||
|
return base.update(path, id, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function remove(id: number | string) {
|
||||||
|
return base.remove(path, id)
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
import * as base from './_crud-base'
|
||||||
|
|
||||||
|
const path = '/api/v1/generate-file'
|
||||||
|
|
||||||
|
export function create(data: any) {
|
||||||
|
return base.create(path, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getList(params: any = null) {
|
||||||
|
return base.getList(path, params)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getDetail(id: number | string) {
|
||||||
|
return base.getDetail(path, id)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user