Feat: Integrate Control Letter
This commit is contained in:
@@ -98,7 +98,6 @@ function calculateAge(birthDate: string | Date | undefined): string {
|
||||
id="birthDate"
|
||||
type="date"
|
||||
min="1900-01-01"
|
||||
:max="new Date().toISOString().split('T')[0]"
|
||||
v-bind="componentField"
|
||||
:placeholder="placeholder"
|
||||
@update:model-value="
|
||||
|
||||
@@ -3,8 +3,10 @@ import type { FormErrors } from '~/types/error'
|
||||
import Combobox from '~/components/pub/my-ui/combobox/combobox.vue'
|
||||
import { cn, mapToComboboxOptList } from '~/lib/utils'
|
||||
import { occupationCodes } from '~/lib/constants'
|
||||
import { getValueLabelList as getDoctorLabelList } from '~/services/doctor.service'
|
||||
|
||||
import * as DE from '~/components/pub/my-ui/doc-entry'
|
||||
import type { Item } from '~/components/pub/my-ui/combobox'
|
||||
|
||||
const props = defineProps<{
|
||||
fieldName?: string
|
||||
@@ -28,8 +30,28 @@ const {
|
||||
labelClass,
|
||||
} = props
|
||||
|
||||
// Generate job options from constants, sama seperti pola genderCodes
|
||||
const jobOptions = mapToComboboxOptList(occupationCodes)
|
||||
const doctors = ref<Array<Item>>([])
|
||||
|
||||
async function fetchDpjp() {
|
||||
doctors.value = await getDoctorLabelList({
|
||||
serviceType: 1,
|
||||
serviceDate: new Date().toISOString().substring(0, 10),
|
||||
specialistCode: 0,
|
||||
includes: 'employee-person',
|
||||
})
|
||||
}
|
||||
|
||||
const selectedDpjpId = inject<Ref<string | null>>("selectedDpjpId")!
|
||||
function handleDpjpChange(selected: string) {
|
||||
console.log(`change dphp`)
|
||||
selectedDpjpId.value = selected ?? null
|
||||
const dpjp = doctors.value.find(s => s.value === selectedDpjpId.value)
|
||||
console.log(dpjp)
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
fetchDpjp()
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -56,10 +78,11 @@ const jobOptions = mapToComboboxOptList(occupationCodes)
|
||||
class="focus:ring-0 focus:ring-offset-0"
|
||||
:id="fieldName"
|
||||
v-bind="componentField"
|
||||
:items="jobOptions"
|
||||
:items="doctors"
|
||||
:placeholder="placeholder"
|
||||
search-placeholder="Cari..."
|
||||
empty-message="Data tidak ditemukan"
|
||||
@update:model-value="handleDpjpChange"
|
||||
/>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
|
||||
@@ -3,11 +3,15 @@ import type { FormErrors } from '~/types/error'
|
||||
import Combobox from '~/components/pub/my-ui/combobox/combobox.vue'
|
||||
import { cn, mapToComboboxOptList } from '~/lib/utils'
|
||||
import { occupationCodes } from '~/lib/constants'
|
||||
import type { Item } from '~/components/pub/my-ui/combobox'
|
||||
import { getValueLabelList as getSpecialistLabelList } from '~/services/specialist.service'
|
||||
import { getValueLabelList as getSubspecialistLabelList } from '~/services/subspecialist.service'
|
||||
|
||||
import * as DE from '~/components/pub/my-ui/doc-entry'
|
||||
|
||||
const props = defineProps<{
|
||||
fieldName?: string
|
||||
specialistFieldName?: string
|
||||
subSpecialistFieldName?: string
|
||||
label?: string
|
||||
placeholder?: string
|
||||
errors?: FormErrors
|
||||
@@ -19,7 +23,8 @@ const props = defineProps<{
|
||||
}>()
|
||||
|
||||
const {
|
||||
fieldName = 'job',
|
||||
specialistFieldName = 'job',
|
||||
subSpecialistFieldName = 'job',
|
||||
label = 'Pekerjaan',
|
||||
placeholder = 'Pilih pekerjaan',
|
||||
errors,
|
||||
@@ -28,43 +33,103 @@ const {
|
||||
labelClass,
|
||||
} = props
|
||||
|
||||
// Generate job options from constants, sama seperti pola genderCodes
|
||||
const jobOptions = mapToComboboxOptList(occupationCodes)
|
||||
const specialists = ref<Array<Item>>([])
|
||||
const subspecialists = ref<Array<Item>>([])
|
||||
|
||||
async function fetchSpecialists() {
|
||||
specialists.value = await getSpecialistLabelList({
|
||||
serviceType: 1,
|
||||
serviceDate: new Date().toISOString().substring(0, 10),
|
||||
specialistCode: 0,
|
||||
})
|
||||
subspecialists.value = await getSubspecialistLabelList({
|
||||
serviceType: 1,
|
||||
serviceDate: new Date().toISOString().substring(0, 10),
|
||||
specialistCode: 0,
|
||||
})
|
||||
}
|
||||
|
||||
const selectedSpecialistId = inject<Ref<string | null>>("selectedSpecialistId")!
|
||||
function handleSpecialistChange(selected: string) {
|
||||
selectedSpecialistId.value = selected ?? null
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
fetchSpecialists()
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<DE.Cell :class="cn('select-field-group', fieldGroupClass, containerClass)">
|
||||
<DE.Label
|
||||
:label-for="fieldName"
|
||||
<DE.Block :col-count="2" :class="cn('select-field-group', fieldGroupClass, containerClass)">
|
||||
<div>
|
||||
<DE.Label
|
||||
:label-for="specialistFieldName"
|
||||
:class="cn('select-field-label', labelClass)"
|
||||
:is-required="isRequired"
|
||||
>
|
||||
{{ label }}
|
||||
Spesialis
|
||||
</DE.Label>
|
||||
<DE.Field
|
||||
:id="fieldName"
|
||||
:id="specialistFieldName"
|
||||
:errors="errors"
|
||||
:class="cn('select-field-wrapper')"
|
||||
>
|
||||
<FormField
|
||||
v-slot="{ componentField }"
|
||||
:name="fieldName"
|
||||
:name="specialistFieldName"
|
||||
>
|
||||
<FormItem>
|
||||
<FormControl>
|
||||
<Combobox
|
||||
class="focus:ring-0 focus:ring-offset-0"
|
||||
:id="fieldName"
|
||||
:id="specialistFieldName"
|
||||
v-bind="componentField"
|
||||
:items="jobOptions"
|
||||
:items="specialists"
|
||||
:placeholder="placeholder"
|
||||
search-placeholder="Cari..."
|
||||
empty-message="Data tidak ditemukan"
|
||||
@update:model-value="handleSpecialistChange"
|
||||
/>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
</FormField>
|
||||
</DE.Field>
|
||||
</DE.Cell>
|
||||
</div>
|
||||
<div>
|
||||
<DE.Label
|
||||
:label-for="subSpecialistFieldName"
|
||||
:class="cn('select-field-label', labelClass)"
|
||||
:is-required="isRequired"
|
||||
>
|
||||
Sub Spesialis
|
||||
</DE.Label>
|
||||
<DE.Field
|
||||
:id="subSpecialistFieldName"
|
||||
:errors="errors"
|
||||
:class="cn('select-field-wrapper')"
|
||||
>
|
||||
<FormField
|
||||
v-slot="{ componentField }"
|
||||
:name="subSpecialistFieldName"
|
||||
>
|
||||
<FormItem>
|
||||
<FormControl>
|
||||
<Combobox
|
||||
class="focus:ring-0 focus:ring-offset-0"
|
||||
:id="subSpecialistFieldName"
|
||||
v-bind="componentField"
|
||||
:items="subspecialists"
|
||||
:placeholder="placeholder"
|
||||
search-placeholder="Cari..."
|
||||
empty-message="Data tidak ditemukan"
|
||||
:is-disabled="!selectedSpecialistId"
|
||||
/>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
</FormField>
|
||||
</DE.Field>
|
||||
</div>
|
||||
</DE.Block>
|
||||
</template>
|
||||
|
||||
@@ -45,20 +45,21 @@ defineExpose({
|
||||
:is-disabled="true"
|
||||
/>
|
||||
<SelectDate
|
||||
field-name="controlDate"
|
||||
field-name="date"
|
||||
label="Tanggal Rencana Kontrol"
|
||||
:errors="errors"
|
||||
is-required
|
||||
/>
|
||||
<SelectSpeciality
|
||||
field-name="SpesialisSubSpesialis"
|
||||
specialist-field-name="spesialist_id"
|
||||
sub-specialist-field-name="subspesialist_id"
|
||||
label="Spesialis/Sub Spesialis"
|
||||
placeholder="Pilih Spesialis/Sub Spesialis"
|
||||
:errors="errors"
|
||||
is-required
|
||||
/>
|
||||
<SelectDpjp
|
||||
field-name="dpjp"
|
||||
field-name="doctor_id"
|
||||
label="DPJP"
|
||||
placeholder="Pilih DPJP"
|
||||
:errors="errors"
|
||||
|
||||
@@ -7,19 +7,20 @@ import { calculateAge } from '~/lib/utils'
|
||||
const action = defineAsyncComponent(() => import('~/components/pub/my-ui/data/dropdown-action-dud.vue'))
|
||||
|
||||
export const config: Config = {
|
||||
cols: [{}, {}, {}, {}, {width: 3},],
|
||||
cols: [{width: 180}, {}, {}, {}, {}, {width: 30},],
|
||||
|
||||
headers: [
|
||||
[
|
||||
{ label: 'Tgl Rencana Kontrol' },
|
||||
{ label: 'Spesialis/Sub Spesialis' },
|
||||
{ label: 'Spesialis' },
|
||||
{ label: 'Sub Spesialis' },
|
||||
{ label: 'DPJP' },
|
||||
{ label: 'Status SEP' },
|
||||
{ label: 'Action' },
|
||||
],
|
||||
],
|
||||
|
||||
keys: ['birth_date', 'number', 'person.name', 'birth_date', 'action'],
|
||||
keys: ['date', 'specialist.name', 'subspecialist.name', 'doctor.employee.person.name', 'sep_status', 'action'],
|
||||
|
||||
delKeyNames: [
|
||||
{ key: 'code', label: 'Kode' },
|
||||
@@ -27,50 +28,20 @@ export const config: Config = {
|
||||
],
|
||||
|
||||
parses: {
|
||||
patientId: (rec: unknown): unknown => {
|
||||
const patient = rec as Patient
|
||||
return patient.number
|
||||
},
|
||||
identity_number: (rec: unknown): unknown => {
|
||||
const { person } = rec as Patient
|
||||
|
||||
if (person.nationality == 'WNA') {
|
||||
return person.passportNumber
|
||||
date: (rec: unknown): unknown => {
|
||||
const date = (rec as any).date
|
||||
if (typeof date == 'object' && date) {
|
||||
return (date as Date).toLocaleDateString('id-ID')
|
||||
} else if (typeof date == 'string') {
|
||||
return (date as string).substring(0, 10)
|
||||
}
|
||||
|
||||
return person.residentIdentityNumber || '-'
|
||||
return date
|
||||
},
|
||||
birth_date: (rec: unknown): unknown => {
|
||||
const { person } = rec as Patient
|
||||
|
||||
if (typeof person.birthDate == 'object' && person.birthDate) {
|
||||
return (person.birthDate as Date).toLocaleDateString('id-ID')
|
||||
} else if (typeof person.birthDate == 'string') {
|
||||
return (person.birthDate as string).substring(0, 10)
|
||||
}
|
||||
return person.birthDate
|
||||
},
|
||||
patient_age: (rec: unknown): unknown => {
|
||||
const { person } = rec as Patient
|
||||
return calculateAge(person.birthDate)
|
||||
},
|
||||
gender: (rec: unknown): unknown => {
|
||||
const { person } = rec as Patient
|
||||
|
||||
if (typeof person.gender_code == 'number' && person.gender_code >= 0) {
|
||||
return person.gender_code
|
||||
} else if (typeof person.gender_code === 'string' && person.gender_code) {
|
||||
return genderCodes[person.gender_code] || '-'
|
||||
}
|
||||
specialist_subspecialist: (rec: unknown): unknown => {
|
||||
return '-'
|
||||
},
|
||||
education: (rec: unknown): unknown => {
|
||||
const { person } = rec as Patient
|
||||
if (typeof person.education_code == 'number' && person.education_code >= 0) {
|
||||
return person.education_code
|
||||
} else if (typeof person.education_code === 'string' && person.education_code) {
|
||||
return educationCodes[person.education_code] || '-'
|
||||
}
|
||||
dpjp: (rec: unknown): unknown => {
|
||||
// const { person } = rec as Patient
|
||||
return '-'
|
||||
},
|
||||
},
|
||||
@@ -86,8 +57,8 @@ export const config: Config = {
|
||||
},
|
||||
|
||||
htmls: {
|
||||
patient_address(_rec) {
|
||||
return '-'
|
||||
sep_status(_rec) {
|
||||
return 'SEP Internal'
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user