Merge branch 'feat/consultation-82' into fe-prescription-56
This commit is contained in:
@@ -26,7 +26,7 @@ export async function getList(path: string, params: any = null, name: string = '
|
||||
const queryString = searchParams.toString()
|
||||
if (queryString) url += `?${queryString}`
|
||||
}
|
||||
const resp = await xfetch(path, 'GET')
|
||||
const resp = await xfetch(url, 'GET')
|
||||
const result: any = {}
|
||||
result.success = resp.success
|
||||
result.body = (resp.body as Record<string, any>) || {}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
import * as base from './_crud-base'
|
||||
|
||||
const path = '/api/v1/consultation'
|
||||
|
||||
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)
|
||||
}
|
||||
@@ -3,7 +3,7 @@ import * as base from './_crud-base'
|
||||
|
||||
// Types
|
||||
import type { Division } from '~/models/division'
|
||||
import type { TreeItem } from '~/models/_model'
|
||||
import type { TreeItem } from '~/models/_base'
|
||||
|
||||
const path = '/api/v1/division'
|
||||
const name = 'division'
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
|
||||
// Base
|
||||
import * as base from './_crud-base'
|
||||
|
||||
// Types
|
||||
import type { Infra } from '~/models/infra'
|
||||
|
||||
const path = '/api/v1/infra'
|
||||
const name = 'infra'
|
||||
|
||||
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: Infra) => ({
|
||||
value: item.id ? Number(item.id) : item.code,
|
||||
label: item.name,
|
||||
}))
|
||||
}
|
||||
return data
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
import { xfetch } from '~/composables/useXfetch'
|
||||
|
||||
const mainUrl = '/api/v1/patient'
|
||||
|
||||
export async function getPatients(params: any = null) {
|
||||
try {
|
||||
let url = mainUrl
|
||||
if (params && typeof params === 'object' && Object.keys(params).length > 0) {
|
||||
const searchParams = new URLSearchParams()
|
||||
for (const key in params) {
|
||||
if (params[key] !== null && params[key] !== undefined && params[key] !== '') {
|
||||
searchParams.append(key, params[key])
|
||||
}
|
||||
}
|
||||
const queryString = searchParams.toString()
|
||||
if (queryString) url += `?${queryString}`
|
||||
}
|
||||
const resp = await xfetch(url, 'GET')
|
||||
const result: any = {}
|
||||
result.success = resp.success
|
||||
result.body = (resp.body as Record<string, any>) || {}
|
||||
return result
|
||||
} catch (error) {
|
||||
console.error('Error fetching patients:', error)
|
||||
throw new Error('Failed to fetch patients')
|
||||
}
|
||||
}
|
||||
|
||||
export async function getPatientDetail(id: number) {
|
||||
try {
|
||||
const resp = await xfetch(`${mainUrl}/${id}`, 'GET')
|
||||
const result: any = {}
|
||||
result.success = resp.success
|
||||
result.body = (resp.body as Record<string, any>) || {}
|
||||
return result
|
||||
} catch (error) {
|
||||
console.error('Error fetching patient detail:', error)
|
||||
throw new Error('Failed to get patient detail')
|
||||
}
|
||||
}
|
||||
|
||||
export async function postPatient(record: any) {
|
||||
try {
|
||||
const resp = await xfetch(mainUrl, 'POST', record)
|
||||
const result: any = {}
|
||||
result.success = resp.success
|
||||
result.body = (resp.body as Record<string, any>) || {}
|
||||
return result
|
||||
} catch (error) {
|
||||
console.error('Error posting patient:', error)
|
||||
throw new Error('Failed to post patient')
|
||||
}
|
||||
}
|
||||
|
||||
export async function patchPatient(id: number, record: any) {
|
||||
try {
|
||||
const resp = await xfetch(`${mainUrl}/${id}`, 'PATCH', record)
|
||||
const result: any = {}
|
||||
result.success = resp.success
|
||||
result.body = (resp.body as Record<string, any>) || {}
|
||||
return result
|
||||
} catch (error) {
|
||||
console.error('Error patching patient:', error)
|
||||
throw new Error('Failed to patch patient')
|
||||
}
|
||||
}
|
||||
|
||||
export async function removePatient(id: number) {
|
||||
try {
|
||||
const resp = await xfetch(`${mainUrl}/${id}`, 'DELETE')
|
||||
const result: any = {}
|
||||
result.success = resp.success
|
||||
result.body = (resp.body as Record<string, any>) || {}
|
||||
return result
|
||||
} catch (error) {
|
||||
console.error('Error deleting record:', error)
|
||||
throw new Error('Failed to delete patient')
|
||||
}
|
||||
}
|
||||
@@ -38,4 +38,4 @@ export async function getValueLabelList(params: any = null): Promise<{ value: st
|
||||
}))
|
||||
}
|
||||
return data
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user