Merge branch 'dev' into feat/kfr-kemoterapi-174

This commit is contained in:
Muhammad Hasyim Chaidir Ali
2025-11-24 10:25:15 +07:00
committed by GitHub
186 changed files with 8018 additions and 852 deletions
@@ -5,7 +5,6 @@ const path = '/api/v1/device-order-item'
const name = 'device-order-item'
export function create(data: any) {
console.log('service create', data)
return base.create(path, data, name)
}
+15 -2
View File
@@ -13,8 +13,8 @@ export function getList(params: any = null) {
return base.getList(path, params, name)
}
export function getDetail(id: number | string) {
return base.getDetail(path, id, name)
export function getDetail(id: number | string, params?: any) {
return base.getDetail(path, id, name, params)
}
export function update(id: number | string, data: any) {
@@ -24,3 +24,16 @@ export function update(id: number | string, data: any) {
export function remove(id: number | string) {
return base.remove(path, id, name)
}
export async function submit(id: number) {
try {
const resp = await xfetch(`${path}/${id}/submit`, 'PATCH')
const result: any = {}
result.success = resp.success
result.body = (resp.body as Record<string, any>) || {}
return result
} catch (error) {
console.error(`Error putting ${name}:`, error)
throw new Error(`Failed to put ${name}`)
}
}
+8 -4
View File
@@ -28,13 +28,15 @@ export function remove(id: number | string) {
return base.remove(path, id, name)
}
export async function getValueLabelList(params: any = null): Promise<{ value: string; label: string }[]> {
export async function getValueLabelList(params: any = null, useCodeAsValue = false): Promise<{ value: string; label: string }[]> {
let data: { value: string; label: string }[] = []
const result = await getList(params)
if (result.success) {
const resultData = result.body?.data || []
data = resultData.map((item: Division) => ({
value: item.id ? Number(item.id) : item.code,
value: useCodeAsValue ? item.code
: item.id ? Number(item.id)
: item.code,
label: item.name,
}))
}
@@ -46,10 +48,12 @@ export async function getValueLabelList(params: any = null): Promise<{ value: st
* @param divisions Array of division objects from API
* @returns TreeItem[]
*/
export function getValueTreeItems(divisions: any[]): TreeItem[] {
export function getValueTreeItems(divisions: any[], byCode = true): TreeItem[] {
return divisions
.map((division: Division) => ({
value: division.id ? String(division.id) : division.code,
value: byCode ? String(division.code)
: String(division.id) ? String(division.id)
: division.code,
label: division.name,
hasChildren: Array.isArray(division.childrens) && division.childrens.length > 0,
children:
+23
View File
@@ -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)
}
+15
View File
@@ -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)
}
+4 -2
View File
@@ -27,13 +27,15 @@ export function remove(id: number | string) {
return base.remove(path, id, name)
}
export async function getValueLabelList(params: any = null): Promise<{ value: string; label: string }[]> {
export async function getValueLabelList(params: any = null, useCodeAsValue = false): Promise<{ value: string; label: string }[]> {
let data: { value: string; label: string }[] = []
const result = await getList(params)
if (result.success) {
const resultData = result.body?.data || []
data = resultData.map((item: Installation) => ({
value: item.id ? Number(item.id) : item.code,
value: useCodeAsValue ? item.code
: item.id ? Number(item.id)
: item.code,
label: item.name,
}))
}
+41
View File
@@ -0,0 +1,41 @@
// Base
import * as base from './_crud-base'
// Types
import type { MedicineForm } from '~/models/medicine-form'
const path = '/api/v1/medicine-form'
const name = 'medicine-form'
export function create(data: any) {
return base.create(path, data, name)
}
export function getList(params: any = null) {
return base.getList(path, params, name)
}
export function getDetail(id: number | string) {
return base.getDetail(path, id, name)
}
export function update(id: number | string, data: any) {
return base.update(path, id, data, name)
}
export function remove(id: number | string) {
return base.remove(path, id, name)
}
export async function getValueLabelList(params: any = null): Promise<{ value: string; label: string }[]> {
let data: { value: string; label: string }[] = []
const result = await getList(params)
if (result.success) {
const resultData = result.body?.data || []
data = resultData.map((item: MedicineForm) => ({
value: item.code,
label: item.name,
}))
}
return data
}
+14
View File
@@ -1,4 +1,5 @@
import * as base from './_crud-base'
import { xfetch } from '~/composables/useXfetch'
const path = '/api/v1/prescription'
const name = 'prescription'
@@ -22,3 +23,16 @@ export function update(id: number | string, data: any) {
export function remove(id: number | string) {
return base.remove(path, id)
}
export async function submit(id: number) {
try {
const resp = await xfetch(`${path}/${id}/submit`, 'PATCH')
const result: any = {}
result.success = resp.success
result.body = (resp.body as Record<string, any>) || {}
return result
} catch (error) {
console.error(`Error submitting ${name}:`, error)
throw new Error(`Failed to submit ${name}`)
}
}
+1 -1
View File
@@ -36,7 +36,7 @@ export async function getValueLabelList(params: any = null, useCodeAsValue = fal
data = resultData.map((item: Specialist) => ({
value: useCodeAsValue ? item.code
: item.id ? Number(item.id)
: item.id,
: item.code,
label: item.name,
parent: item.unit_id ? Number(item.unit_id) : null,
}))
+2 -2
View File
@@ -33,9 +33,9 @@ export async function getValueLabelList(params: any = null, useCodeAsValue = fal
if (result.success) {
const resultData = result.body?.data || []
data = resultData.map((item: Subspecialist) => ({
value: useCodeAsValue ? item.code
value: useCodeAsValue ? item.code
: item.id ? Number(item.id)
: item.id,
: item.code,
label: item.name,
parent: item.specialist_id ? Number(item.specialist_id) : null,
}))
@@ -0,0 +1,56 @@
// Base
import * as base from './_crud-base'
// Constants
import { uploadCode, type UploadCodeKey } from '~/lib/constants'
const path = '/api/v1/encounter-document'
const create_path = '/api/v1/upload-file'
const name = 'encounter-document'
export function create(data: any) {
return base.create(create_path, data, name)
}
export function getList(params: any = null) {
return base.getList(path, params, name)
}
export function getDetail(id: number | string, params?: any) {
return base.getDetail(path, id, name, params)
}
export function update(id: number | string, data: any) {
return base.update(path, id, data, name)
}
export function remove(id: number | string) {
return base.remove(path, id, name)
}
export async function uploadAttachment(file: File, userId: number, key: UploadCodeKey) {
try {
const resolvedKey = uploadCode[key]
if (!resolvedKey) {
throw new Error(`Invalid upload code key: ${key}`)
}
// siapkan form-data body
const formData = new FormData()
formData.append('code', resolvedKey)
formData.append('content', file)
// kirim via xfetch
const resp = await xfetch(`${path}/${userId}/upload`, 'POST', formData)
// struktur hasil sama seperti patchPatient
const result: any = {}
result.success = resp.success
result.body = (resp.body as Record<string, any>) || {}
return result
} catch (error) {
console.error('Error uploading attachment:', error)
throw new Error('Failed to upload attachment')
}
}
+1 -1
View File
@@ -35,7 +35,7 @@ export async function getValueLabelList(params: any = null, useCodeAsValue = fal
data = resultData.map((item: Unit) => ({
value: useCodeAsValue ? item.code
: item.id ? Number(item.id)
: item.id,
: item.code,
label: item.name,
}))
}