29 lines
867 B
TypeScript
29 lines
867 B
TypeScript
// Base
|
|
import * as base from './_crud-base'
|
|
|
|
const path = '/api/v1/reference/diagnose'
|
|
const name = 'diagnose'
|
|
|
|
export function getList(params: any = null) {
|
|
let url = path
|
|
if (params && params?.diagnosa) {
|
|
url += `/${params.diagnosa}`
|
|
delete params.diagnosa
|
|
}
|
|
return base.getList(url, params, 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?.response?.diagnosa || []
|
|
const resultUnique = [...new Map(resultData.map((item: any) => [item.kode, item])).values()]
|
|
data = resultUnique.map((item: any) => ({
|
|
value: item.kode ? String(item.kode) : '',
|
|
label: `${item.kode} - ${item.nama}`,
|
|
}))
|
|
}
|
|
return data
|
|
}
|