feat(sep): refactor schema

This commit is contained in:
riefive
2025-10-21 14:56:42 +07:00
parent 539b70b4b7
commit 437d1f3fc7
4 changed files with 53 additions and 37 deletions
+18 -19
View File
@@ -26,6 +26,7 @@ const props = defineProps<{
doctors: any[]
diagnoses: any[]
facilities: any[]
supportCodes: any[]
patient?: PatientEntity | null | undefined
values?: any
}>()
@@ -43,12 +44,6 @@ const admissionTypes = [
{ value: '2', label: 'Rujukan' },
]
const items = [
{ value: 'item-1', label: 'Item 1' },
{ value: 'item-2', label: 'Item 2' },
{ value: 'item-3', label: 'Item 3' },
]
// Validation schema (moved to shared file)
const { handleSubmit, errors, defineField, meta } = useForm<IntegrationBpjsFormData>({
validationSchema: toTypedSchema(IntegrationBpjsSchema),
@@ -69,8 +64,10 @@ const [attendingDoctor, attendingDoctorAttrs] = defineField('attendingDoctor')
const [initialDiagnosis, initialDiagnosisAttrs] = defineField('initialDiagnosis')
const [cob, cobAttrs] = defineField('cob')
const [cataract, cataractAttrs] = defineField('cataract')
const [clinicExcecutive, clinicExcecutiveAttrs] = defineField('clinicExcecutive')
const [procedureType, procedureTypeAttrs] = defineField('procedureType')
const [supportCode, supportCodeAttrs] = defineField('supportCode')
const [note, noteAttrs] = defineField('note')
// Submit handler
const onSubmit = handleSubmit((values) => {
@@ -313,23 +310,23 @@ watch(props, (value) => {
</Label>
<Field :errMessage="errors.cob">
<RadioGroup
v-model="cob"
v-model="clinicExcecutive"
v-bind="clinicExcecutiveAttrs"
class="flex items-center gap-2"
v-bind="cobAttrs"
>
<div class="flex items-center space-x-2">
<RadioGroupItem
value="yes"
id="cob-yes"
id="clinicExcecutive-yes"
/>
<Label for="cob-yes">Ya</Label>
<Label for="clinicExcecutive-yes">Ya</Label>
</div>
<div class="flex items-center space-x-2">
<RadioGroupItem
value="no"
id="cob-no"
id="clinicExcecutive-no"
/>
<Label for="cob-no">Tidak</Label>
<Label for="clinicExcecutive-no">Tidak</Label>
</div>
</RadioGroup>
</Field>
@@ -350,7 +347,7 @@ watch(props, (value) => {
placeholder="Pilih DPJP"
search-placeholder="Cari DPJP"
empty-message="Item tidak ditemukan"
@update:searchText="emit('fetch', { menu: 'attendingDoctor', value: $event })"
@update:searchText="emit('fetch', { menu: 'attendingDoctor', value: $event })"
/>
</Field>
</Cell>
@@ -379,7 +376,7 @@ watch(props, (value) => {
<Block
labelSize="thin"
class="!pt-0"
:colCount="1"
:colCount="2"
:cellFlex="false"
>
<Cell>
@@ -387,6 +384,8 @@ watch(props, (value) => {
<Field>
<Textarea
id="note"
v-model="note"
v-bind="noteAttrs"
class="h-[200px] w-full border-gray-400 bg-white"
placeholder="Masukkan catatan opsional"
:disabled="isLoading || isReadonly"
@@ -402,8 +401,8 @@ watch(props, (value) => {
<Field :errMessage="errors.cob">
<RadioGroup
v-model="cob"
class="flex items-center gap-2"
v-bind="cobAttrs"
class="flex items-center gap-2"
>
<div class="flex items-center space-x-2">
<RadioGroupItem
@@ -431,8 +430,8 @@ watch(props, (value) => {
<Field :errMessage="errors.cataract">
<RadioGroup
v-model="cataract"
class="flex items-center gap-2"
v-bind="cataractAttrs"
class="flex items-center gap-2"
>
<div class="flex items-center space-x-2">
<RadioGroupItem
@@ -465,14 +464,14 @@ watch(props, (value) => {
>
<div class="flex items-center space-x-2">
<RadioGroupItem
value="procedure-one"
value="0"
id="procedure-one"
/>
<Label for="procedure-one">Prosedur tidak berkelanjutan</Label>
</div>
<div class="flex items-center space-x-2">
<RadioGroupItem
value="procedure-two"
value="1"
id="procedure-two"
/>
<Label for="procedure-two">Prosedur dan terapi berkelanjutan</Label>
@@ -499,7 +498,7 @@ watch(props, (value) => {
icon-name="i-lucide-chevron-down"
v-model="supportCode"
v-bind="supportCodeAttrs"
:items="items"
:items="supportCodes"
:disabled="isLoading || isReadonly"
placeholder="Pilih Kode Penunjang"
/>
+8 -2
View File
@@ -10,6 +10,9 @@ import type { PatientEntity } from '~/models/patient'
import type { SepHistoryData } from '~/components/app/sep/list-cfg.history'
import type { SepVisitData } from '~/components/app/sep/list-cfg.visit'
// Constants
import { supportCodes } from '~/lib/constants'
// Services
import { getPatientDetail, getPatients } from '~/services/patient.service'
import { getList as getProvinceList } from '~/services/vclaim-region-province.service'
@@ -35,6 +38,7 @@ const patients = ref<Array<{ id: string; identity: string; number: string; bpjs:
const doctors = ref<Array<{ value: string | number; label: string }>>([])
const diagnoses = ref<Array<{ value: string | number; label: string }>>([])
const facilities = ref<Array<{ value: string | number; label: string }>>([])
const supportCodesList = ref<Array<{ value: string; label: string }>>([])
const isPatientsLoading = ref(false)
const paginationMeta = ref<PaginationMeta>({
recordCount: 0,
@@ -203,7 +207,7 @@ function handleSaveLetter() {
console.log('Letter dipilih:', selectedLetter.value)
}
function handleEvent(menu: string, value: string) {
function handleEvent(menu: string, value: any) {
if (menu === 'admission-type') {
console.log('service-type:', value)
return
@@ -230,7 +234,7 @@ function handleEvent(menu: string, value: string) {
navigateTo('/integration/bpjs/sep')
}
if (menu === 'save-sep') {
createSep(createSepPayload()).then(() => {
createSep(createSepPayload(value)).then(() => {
navigateTo('/integration/bpjs/sep')
})
}
@@ -270,6 +274,7 @@ onMounted(async () => {
getDiagnoseReferralList().then((value) => {
console.log('value:', value)
})
supportCodesList.value = Object.keys(supportCodes).map((item) => ({ value: item.toString(), label: supportCodes[item] })) as any
})
</script>
@@ -287,6 +292,7 @@ onMounted(async () => {
:diagnoses="diagnoses"
:facilities="facilities"
:patient="selectedPatientObject"
:support-codes="supportCodesList"
@fetch="handleFetch"
@event="handleEvent"
/>
+5
View File
@@ -1,3 +1,4 @@
import { not } from "@vueuse/math"
import { z } from 'zod'
const ERROR_MESSAGES = {
@@ -16,8 +17,10 @@ const ERROR_MESSAGES = {
initialDiagnosis: 'Diagnosa Awal wajib diisi',
cob: 'COB wajib diisi',
cataract: 'Katarak wajib diisi',
clinicExcecutive: 'Klinkik eksekutif wajib diisi',
procedureType: 'Jenis Prosedur wajib diisi',
supportCode: 'Kode Penunjang wajib diisi',
note: 'Catatan wajib diisi',
},
}
@@ -58,12 +61,14 @@ const IntegrationBpjsSchema = z.object({
.min(1, ERROR_MESSAGES.required.initialDiagnosis),
cob: z.string({ required_error: ERROR_MESSAGES.required.cob }).min(1, ERROR_MESSAGES.required.cob),
cataract: z.string({ required_error: ERROR_MESSAGES.required.cataract }).min(1, ERROR_MESSAGES.required.cataract),
clinicExcecutive: z.string({ required_error: ERROR_MESSAGES.required.clinicExcecutive }).min(1, ERROR_MESSAGES.required.clinicExcecutive),
procedureType: z
.string({ required_error: ERROR_MESSAGES.required.procedureType })
.min(1, ERROR_MESSAGES.required.procedureType),
supportCode: z
.string({ required_error: ERROR_MESSAGES.required.supportCode })
.min(1, ERROR_MESSAGES.required.supportCode),
note: z.string({ required_error: ERROR_MESSAGES.required.note }).min(1, ERROR_MESSAGES.required.note).optional(),
})
type IntegrationBpjsFormData = z.infer<typeof IntegrationBpjsSchema>
+22 -16
View File
@@ -8,48 +8,54 @@ export function create(data: any) {
return base.create(path, data, name)
}
export function createPayload() {
export function createPayload(data: any) {
// "nationalId": "5617213001231231",
// "referralLetterNumber": "12233",
// "referralLetterDate": "2025-10-21",
// "attendingDoctor": "25107",
console.log('data:', data)
const content = {
noKartu: '0001116500714',
tglSep: '2025-08-21',
noKartu: data.bpjsNumber || '',
tglSep: data.sepDate,
ppkPelayanan: '1323R001',
jnsPelayanan: '2',
jnsPelayanan: data.admissionType ? String(data.admissionType) : '1',
klsRawat: {
klsRawatHak: '2',
klsRawatNaik: '',
pembiayaan: '',
penanggungJawab: '',
},
noMR: 'MR9835',
noMR: data.med,
rujukan: {
asalRujukan: '1',
tglRujukan: '2025-08-20',
noRujukan: 'RJKMR9835001',
ppkRujukan: '0301R011',
},
catatan: 'testinsert RI',
diagAwal: 'E10',
catatan: data.note || '',
diagAwal: data.initialDiagnosis || '',
poli: {
tujuan: '',
eksekutif: '0',
tujuan: data.destinationClinic || '',
eksekutif: data.clinicExcecutive === 'yes' ? '1' : '0',
},
cob: {
cob: '0',
cob: data.cob === 'yes' ? '1' : '0',
},
katarak: {
katarak: '0',
katarak: data.cataract === 'yes' ? '1' : '0',
},
tujuanKunj: '0',
flagProcedure: '',
kdPenunjang: '',
tujuanKunj: data.destinationClinic || '',
flagProcedure: data.procedureType || '',
kdPenunjang: data.supportCode || '',
assesmentPel: '',
skdp: {
noSurat: '0208R0060825K000001',
kodeDPJP: '6546',
},
dpjpLayan: '000002',
noTelp: '081111111101',
user: 'Coba Ws',
noTelp: data.phoneNumber || '',
user: data.patientName || '',
jaminan: {
lakaLantas: '0',
noLP: '12345',