From 3cfa07149ce9ace44651cb99a359385c2f002a85 Mon Sep 17 00:00:00 2001 From: Abizrh Date: Wed, 5 Nov 2025 10:04:15 +0700 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat=20(soapi):=20parse=20and=20dis?= =?UTF-8?q?play=20main=20complaint=20and=20diagnoses=20from=20json=20data?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/components/app/soapi/list-cfg.ts | 34 +++++++++++++++++++++++++-- app/components/content/soapi/list.vue | 2 +- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/app/components/app/soapi/list-cfg.ts b/app/components/app/soapi/list-cfg.ts index 959d6177..648297c4 100644 --- a/app/components/app/soapi/list-cfg.ts +++ b/app/components/app/soapi/list-cfg.ts @@ -20,14 +20,44 @@ export const config: Config = { ], ], - keys: ['time', 'employee_id', 'main_complaint', 'examination', 'diagnose', 'status', 'action'], + keys: ['time', 'employee_id', 'main_complaint', 'encounter_id', 'diagnose', 'status', 'action'], delKeyNames: [ { key: 'code', label: 'Kode' }, { key: 'name', label: 'Nama' }, ], - parses: {}, + parses: { + time(rec: any) { + return rec.time ? new Date(rec.time).toLocaleDateString() : '' + }, + main_complaint(rec: any) { + const { value } = rec ?? {} + + if (typeof value !== 'string') return '-' + + try { + const parsed = JSON.parse(value) + console.log('parsed', parsed) + return parsed?.['prim-compl'] || '-' + } catch { + return '-' + } + }, + diagnose(rec: any) { + const { value } = rec ?? {} + + if (typeof value !== 'string') return '-' + + try { + const parsed = JSON.parse(value) + const diagnose = parsed?.diagnose || [] + return diagnose.map((d: any) => d.name).join(', ') + } catch { + return '-' + } + }, + }, components: { action(rec, idx) { diff --git a/app/components/content/soapi/list.vue b/app/components/content/soapi/list.vue index 7547b544..5a960d5d 100644 --- a/app/components/content/soapi/list.vue +++ b/app/components/content/soapi/list.vue @@ -70,7 +70,7 @@ onMounted(async () => { }) async function getMyList() { - const url = `/api/v1/soapi?type-code=${typeCode.value}` + const url = `/api/v1/soapi?type-code=${typeCode.value}?includes=encounter` const resp = await xfetch(url) if (resp.success) { data.value = (resp.body as Record).data