Merge branch 'dev' of github.com:dikstub-rssa/simrs-fe into feat/education-assessment-79

This commit is contained in:
Khafid Prayoga
2025-12-08 10:18:40 +07:00
835 changed files with 53072 additions and 3507 deletions
+47
View File
@@ -5,6 +5,9 @@ export async function create(path: string, data: any, name: string = 'item') {
const resp = await xfetch(path, 'POST', data)
const result: any = {}
result.success = resp.success
if (resp.status_code !== 200) {
result.error = { ...resp.error }
}
result.body = (resp.body as Record<string, any>) || {}
return result
} catch (error) {
@@ -29,6 +32,9 @@ export async function getList(path: string, params: any = null, name: string = '
const resp = await xfetch(url, 'GET')
const result: any = {}
result.success = resp.success
if (resp.status_code !== 200) {
result.error = { ...resp.error }
}
result.body = (resp.body as Record<string, any>) || {}
return result
} catch (error) {
@@ -53,6 +59,9 @@ export async function getDetail(path: string, id: number | string, name: string
const resp = await xfetch(`${path}/${id}${paramStr}`, 'GET')
const result: any = {}
result.success = resp.success
if (resp.status_code !== 200) {
result.error = { ...resp.error }
}
result.body = (resp.body as Record<string, any>) || {}
return result
} catch (error) {
@@ -66,6 +75,25 @@ export async function update(path: string, id: number | string, data: any, name:
const resp = await xfetch(`${path}/${id}`, 'PATCH', data)
const result: any = {}
result.success = resp.success
if (resp.status_code !== 200) {
result.error = { ...resp.error }
}
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}`)
}
}
export async function updateCustom(path: string, data: any, name: string = 'item') {
try {
const resp = await xfetch(`${path}`, 'PATCH', data)
const result: any = {}
result.success = resp.success
if (resp.status_code !== 200) {
result.error = { ...resp.error }
}
result.body = (resp.body as Record<string, any>) || {}
return result
} catch (error) {
@@ -79,6 +107,25 @@ export async function remove(path: string, id: number | string, name: string = '
const resp = await xfetch(`${path}/${id}`, 'DELETE')
const result: any = {}
result.success = resp.success
if (resp.status_code !== 200) {
result.error = { ...resp.error }
}
result.body = (resp.body as Record<string, any>) || {}
return result
} catch (error) {
console.error(`Error deleting ${name}:`, error)
throw new Error(`Failed to delete ${name}`)
}
}
export async function removeCustom(path: string, data: any, name: string = 'item') {
try {
const resp = await xfetch(`${path}`, 'DELETE', data)
const result: any = {}
result.success = resp.success
if (resp.status_code !== 200) {
result.error = { ...resp.error }
}
result.body = (resp.body as Record<string, any>) || {}
return result
} catch (error) {
+25
View File
@@ -0,0 +1,25 @@
// Base
import * as base from './_crud-base'
const name = 'antibiotic-in-use'
const path = '/api/v1/' + name
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)
}
+25
View File
@@ -0,0 +1,25 @@
// Base
import * as base from './_crud-base'
const name = 'antibiotic-src-category'
const path = '/api/v1/' + name
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)
}
+25
View File
@@ -0,0 +1,25 @@
// Base
import * as base from './_crud-base'
const name = 'antibiotic-src'
const path = '/api/v1/' + name
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)
}
+28
View File
@@ -0,0 +1,28 @@
// Base
import * as base from './_crud-base'
// Constants
import { encounterClassCodes } from '~/lib/constants'
const path = '/api/v1/control-letter'
const name = 'control-letter'
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, 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)
}
+25
View File
@@ -0,0 +1,25 @@
// Base
import * as base from './_crud-base'
const path = '/api/v1/device-order-item'
const name = 'device-order-item'
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)
}
+39
View File
@@ -0,0 +1,39 @@
// Base
import * as base from './_crud-base'
const path = '/api/v1/device-order'
const name = 'device-order'
export function create(data: any) {
console.log('service create', data)
return base.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 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:
+41
View File
@@ -0,0 +1,41 @@
// Base
import * as base from './_crud-base'
import type { Doctor } from "~/models/doctor";
const path = '/api/v1/doctor'
const name = 'doctor'
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, 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 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: Doctor) => ({
value: useCodeAsValue ? item.code
: item.id ? Number(item.id)
: item.id,
label: item.employee?.person?.name || '',
}))
}
return data
}
+4 -3
View File
@@ -1,4 +1,5 @@
// Base
import type { Employee } from '~/models/employee'
import * as base from './_crud-base'
const path = '/api/v1/employee'
@@ -29,9 +30,9 @@ export async function getValueLabelList(params: any = null): Promise<{ value: st
const result = await getList(params)
if (result.success) {
const resultData = result.body?.data || []
data = resultData.map((item: any) => ({
value: item.id ? Number(item.id) : item.code,
label: item.name,
data = resultData.map((item: Employee) => ({
value: item.id,
label: `${item.person.frontTitle} ${item.person.name} ${item.person.endTitle}`.trim(),
}))
}
return data
+19
View File
@@ -1,4 +1,5 @@
// Base
import type { CheckInFormData } from '~/schemas/encounter.schema'
import * as base from './_crud-base'
// Constants
@@ -27,6 +28,11 @@ export function remove(id: number | string) {
return base.remove(path, id, name)
}
export function cancel(id: number | string) {
let url = `${path}/${id}/cancel`
return base.updateCustom(url, null, name)
}
export async function getValueLabelList(params: any = null): Promise<{ value: string; label: string }[]> {
let data: { value: string; label: string }[] = []
const result = await getList(params)
@@ -46,3 +52,16 @@ export function getValueLabelListConstants() {
.filter(([key]) => allowed.includes(key))
.map(([key, value]) => ({ value: key, label: value }))
}
export async function checkIn(id: number, data: CheckInFormData) {
try {
const resp = await xfetch(`${path}/${id}/check-in`, 'PATCH', data)
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}`)
}
}
+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)
}
+19 -11
View File
@@ -1,14 +1,11 @@
// Base
import * as base from './_crud-base'
// Types
import type { Infra } from '~/models/infra'
const path = '/api/v1/infra'
const name = 'infra'
const path = `/api/v1/${name}`
export function create(data: any) {
export function create(data: Infra) {
return base.create(path, data, name)
}
@@ -20,7 +17,7 @@ export function getDetail(id: number | string) {
return base.getDetail(path, id, name)
}
export function update(id: number | string, data: any) {
export function update(id: number | string, data: Infra) {
return base.update(path, id, data, name)
}
@@ -28,15 +25,26 @@ 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, useId = 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: Infra) => ({
value: item.id ? Number(item.id) : item.code,
label: item.name,
}))
data = !useId ?
resultData.map((item: Infra) => ({ value: item.code, label: item.name })) :
resultData.map((item: Infra) => ({ value: item.id, label: item.name }))
}
return data
}
// export async function getProcedureRoomValueLabelList(params: any = null, useId = false): Promise<{ value: string; label: string }[]> {
// let data: { value: string; label: string }[] = []
// const result = await getList({ 'infraGroup_code': 'procedure-room' ,...params})
// if (result.success) {
// const resultData = result.body?.data || []
// data = !useId ?
// resultData.map((item: Infra) => ({ value: item.code, label: item.name })) :
// resultData.map((item: Infra) => ({ value: item.id, label: item.name }))
// }
// return data
// }
@@ -0,0 +1,41 @@
// Base
import * as base from './_crud-base'
// Types
import type { Installation } from '~/models/installation'
const path = '/api/v1/installation-position'
const name = 'installation'
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: Installation) => ({
value: item.id ? Number(item.id) : item.code,
label: item.name,
}))
}
return data
}
+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,
}))
}
+27
View File
@@ -0,0 +1,27 @@
// Base
import * as base from './_crud-base'
// Constants
const path = '/api/v1/kfr'
const name = 'kfr'
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, 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)
}
@@ -0,0 +1,25 @@
// Base
import * as base from './_crud-base'
const name = 'material-package-item'
const path = `/api/v1/${name}`
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)
}
+38
View File
@@ -0,0 +1,38 @@
// Base
import type { MaterialPackage } from '~/models/material-package'
import * as base from './_crud-base'
const name = 'material-package'
const path = `/api/v1/${name}`
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, useId = 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 = !useId ?
resultData.map((item: MaterialPackage) => ({ value: item.code, label: item.name })) :
resultData.map((item: MaterialPackage) => ({ value: item.id, label: item.name }))
}
return data
}
+25
View File
@@ -0,0 +1,25 @@
import * as base from './_crud-base'
import * as model from '~/models/mcu-order-item'
const path = '/api/v1/mcu-order-item'
const name = 'mcu-order-item'
export function create(data: model.CreateDto) {
return base.create(path, data)
}
export function getList(params: model.ReadList | null = null) {
return base.getList(path, params)
}
export function getDetail(id: number | string, params?: any) {
return base.getDetail(path, id, name, params)
}
export function update(id: number | string, data: model.UpdateDto) {
return base.update(path, id, data)
}
export function remove(id: number | string) {
return base.remove(path, id)
}
+37
View File
@@ -0,0 +1,37 @@
import * as base from './_crud-base'
const path = '/api/v1/mcu-order'
const name = 'mcu-order'
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, params?: any) {
return base.getDetail(path, id, name, params)
}
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)
}
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}`)
}
}
+25
View File
@@ -0,0 +1,25 @@
// Base
import * as base from './_crud-base'
const path = '/api/v1/mcu-src-category'
const name = 'mcu-src-category'
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)
}
+25
View File
@@ -0,0 +1,25 @@
// Base
import * as base from './_crud-base'
const path = '/api/v1/mcu-src'
const name = 'mcu-src'
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)
}
+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 @@
// Base
import type { Medicine } from '~/models/medicine'
import * as base from './_crud-base'
const path = '/api/v1/medicine'
@@ -23,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 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: Medicine) => ({
value: item.code,
label: item.name,
}))
}
return data
}
+16
View File
@@ -40,6 +40,22 @@ export async function getPatientDetail(id: number) {
}
}
export async function getPatientByIdentifier(search: string) {
try {
const urlPath = search.length === 16 ? `by-resident-identity/search=${encodeURIComponent(search)}` : `/search/${search}`
const url = `${mainUrl}/${urlPath}`
const resp = await xfetch(url, 'GET')
const result: any = {}
result.success = resp.success
result.body = (resp.body as Record<string, any>) || {}
result.type = urlPath.includes('by-resident-identity') ? 'resident-identity' : 'identity'
return result
} catch (error) {
console.error('Error fetching patient by identifier:', error)
throw new Error('Failed to get patient by identifier')
}
}
export async function postPatient(record: any) {
try {
const resp = await xfetch(mainUrl, 'POST', record)
+28
View File
@@ -0,0 +1,28 @@
// Base
import * as base from './_crud-base'
// Constants
import { encounterClassCodes } from '~/lib/constants'
const path = '/api/v1/prb'
const name = 'prb'
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, 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)
}
+23
View File
@@ -0,0 +1,23 @@
import * as base from './_crud-base'
const path = '/api/v1/prescription-item'
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)
}
+38
View File
@@ -0,0 +1,38 @@
import * as base from './_crud-base'
import { xfetch } from '~/composables/useXfetch'
const path = '/api/v1/prescription'
const name = 'prescription'
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, params?: any) {
return base.getDetail(path, id, name, params)
}
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)
}
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}`)
}
}
@@ -0,0 +1,26 @@
// Base
import type { CreateDto, UpdateDto } from '~/models/procedure-room-order-item'
import * as base from './_crud-base'
const name = 'procedure-room-order-item'
const path = `/api/v1/${name}`
export function create(data: CreateDto) {
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: UpdateDto) {
return base.update(path, id, data, name)
}
export function remove(id: number | string) {
return base.remove(path, id, name)
}
@@ -0,0 +1,42 @@
// Base
import type { ProcedureRoomOrder, CreateDto } from '~/models/procedure-room-order'
import * as base from './_crud-base'
const name = 'procedure-room-order'
const path = `/api/v1/${name}`
export function create(data: CreateDto) {
return base.create(path, data, name)
}
export function getList(params: any = null) {
return base.getList(path, params, name)
}
export function getDetail(id: number | string, params: any = null) {
return base.getDetail(path, id, name, params)
}
export function update(id: number | string, data: ProcedureRoomOrder) {
return base.update(path, id, data, name)
}
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 = {}
if (resp.success) {
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}`)
}
}
+26
View File
@@ -0,0 +1,26 @@
// Base
import type { ProcedureRoom } from '~/models/procedure-room'
import * as base from './_crud-base'
const name = 'procedure-room'
const path = `/api/v1/${name}`
export function create(data: ProcedureRoom) {
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: ProcedureRoom) {
return base.update(path, id, data, name)
}
export function remove(id: number | string) {
return base.remove(path, id, name)
}
+28
View File
@@ -0,0 +1,28 @@
// Base
import * as base from './_crud-base'
// Types
import type { Soapi } from '~/models/soapi'
const path = '/api/v1/soapi'
const name = 'soapi'
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)
}
@@ -0,0 +1,25 @@
// Base
import * as base from './_crud-base'
const path = '/api/v1/specialist-position'
const name = 'specialist-position'
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)
}
+24 -4
View File
@@ -3,6 +3,7 @@ import * as base from './_crud-base'
// Types
import type { Specialist } from '~/models/specialist'
import type { TreeItem } from '~/models/_base'
const path = '/api/v1/specialist'
const name = 'specialist'
@@ -15,8 +16,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) {
@@ -27,16 +28,35 @@ 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: Specialist) => ({
value: item.id ? Number(item.id) : item.code,
value: useCodeAsValue ? item.code
: item.id ? Number(item.id)
: item.code,
label: item.name,
parent: item.unit_id ? Number(item.unit_id) : null,
}))
}
return data
}
/**
* Convert specialist response to TreeItem[] with subspecialist children
* @param specialists Array of specialist objects from API
* @returns TreeItem[]
*/
export function getValueTreeItems(specialists: any[], byCode = true): TreeItem[] {
return specialists.map((specialist: Specialist) => ({
value: byCode ? String(specialist.code) : String(specialist.id),
label: specialist.name,
hasChildren: Array.isArray(specialist.subspecialists) && specialist.subspecialists.length > 0,
children:
Array.isArray(specialist.subspecialists) && specialist.subspecialists.length > 0
? getValueTreeItems(specialist.subspecialists)
: undefined,
}))
}
@@ -0,0 +1,25 @@
// Base
import * as base from './_crud-base'
const path = '/api/v1/subspecialist-position'
const name = 'subspecialist-position'
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)
}
+6 -4
View File
@@ -15,8 +15,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) {
@@ -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: Subspecialist) => ({
value: item.id ? Number(item.id) : item.code,
value: useCodeAsValue ? item.code
: item.id ? Number(item.id)
: item.code,
label: item.name,
parent: item.specialist_id ? Number(item.specialist_id) : null,
}))
+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)
}
@@ -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')
}
}
+28
View File
@@ -0,0 +1,28 @@
// Base
import * as base from './_crud-base'
// Constants
import { encounterClassCodes } from '~/lib/constants'
const path = '/api/v1/surgery-report'
const name = 'surgery-report'
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, 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)
}
+27
View File
@@ -0,0 +1,27 @@
// Base
import * as base from './_crud-base'
// Constants
const path = '/api/v1/therapy-protocol'
const name = 'therapy-protocol'
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, 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)
}
+25
View File
@@ -0,0 +1,25 @@
// Base
import * as base from './_crud-base'
const path = '/api/v1/unit-position'
const name = 'unit-position'
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)
}
+5 -6
View File
@@ -2,7 +2,7 @@
import * as base from './_crud-base'
// Types
import type { Unit } from "~/models/unit";
import type { Unit } from '~/models/unit'
const path = '/api/v1/unit'
const name = 'unit'
@@ -27,15 +27,14 @@ 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, useId = 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: Unit) => ({
value: item.id,
label: item.name,
}))
data = !useId ?
resultData.map((item: Unit) => ({ value: item.code, label: item.name })) :
resultData.map((item: Unit) => ({ value: item.id, label: item.name }))
}
return data
}
+28
View File
@@ -0,0 +1,28 @@
// Base
import * as base from './_crud-base'
// Constants
import { encounterClassCodes } from '~/lib/constants'
const path = '/api/v1/vaccine-data'
const name = 'vaccine-data'
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, 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)
}
@@ -0,0 +1,45 @@
// Base
import * as base from './_crud-base'
const path = '/api/v1/control-plan'
const pathOld = '/api/v1/rencana-kontrol'
const name = 'control-plan' // 'rencana-kontrol'
export function getListOld(params: any = null) {
let url = pathOld
if (params?.letterNumber && params.mode === 'by-control') {
url += `/noSuratKontrol/${params.letterNumber}`
}
if (params?.letterNumber && params.mode === 'by-card') {
url += `/noka/${params.letterNumber}`
}
if (params?.letterNumber && params.mode === 'by-sep') {
url += `/${params.letterNumber}`
}
if (params?.controlDate && params.mode === 'by-schedule') {
url += `/jadwalDokter?jeniskontrol=${params.controlType}&kodepoli=${params.polyCode}&tanggalkontrol=${params.controlDate}`
delete params.controlType
delete params.controlDate
delete params.polyCode
}
if (params) {
delete params.letterNumber
delete params.mode
}
return base.getList(url, params, name)
}
export function getList(params: any = null) {
let url = path
if (params?.controlDate && params.mode === 'by-schedule') {
url += `/${params.controlType}/${params.polyCode}/${params.controlDate}`
delete params.controlType
delete params.controlDate
delete params.polyCode
}
if (params) {
delete params.letterNumber
delete params.mode
}
return base.getList(url, params, name)
}
@@ -0,0 +1,10 @@
// Base
import * as base from './_crud-base'
const path = '/api/v1/reference/diagnose-prb'
const name = 'diagnose-referral'
export function getList(params: any = null) {
const url = path
return base.getList(url, params, name)
}
+28
View File
@@ -0,0 +1,28 @@
// 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
}
+36
View File
@@ -0,0 +1,36 @@
// Base
import * as base from './_crud-base'
const path = '/api/v1/reference/responsible-doctor'
const name = 'responsible-doctor'
export function getList(params: any = null) {
let url = path
if (params?.serviceType) {
url += `/${params.serviceType}`
delete params.serviceType
}
if (params?.serviceDate) {
url += `/${params.serviceDate}`
delete params.serviceDate
}
if (params?.specialistCode || (Number(params.specialistCode) === 0)) {
url += `/${params.specialistCode}`
delete params.specialistCode
}
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?.list || []
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
}
+32
View File
@@ -0,0 +1,32 @@
// Base
import * as base from './_crud-base'
const path = '/api/v1/reference/healthcare'
const name = 'healthcare'
export function getList(params: any = null) {
let url = path
if (params?.healthcare) {
url += `/${params.healthcare}`
delete params.healthcare
}
if (params?.healthcareType) {
url += `/${params.healthcareType}`
delete params.healthcareType
}
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?.faskes || []
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
}
+23
View File
@@ -0,0 +1,23 @@
// Base
import * as base from './_crud-base'
const path = '/api/v1/reference/medicine'
const name = 'medicine'
export function getList(params: any = null) {
const url = path
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?.list || []
data = resultData.map((item: any) => ({
value: item.kode ? String(item.kode) : '',
label: item.nama,
}))
}
return data
}
+21
View File
@@ -0,0 +1,21 @@
// Base
import * as base from './_crud-base'
const path = '/api/v1/member'
const name = 'member'
export function getList(params: any = null) {
let url = path
if (params?.number && params.mode === 'by-identity') {
url += `/nik/${params.number}/${params.date}`
}
if (params?.number && params.mode === 'by-card') {
url += `/bpjs/${params.number}/${params.date}`
}
if (params) {
delete params.number
delete params.mode
delete params.date
}
return base.getList(url, params, name)
}
@@ -0,0 +1,17 @@
// Base
import * as base from './_crud-base'
const path = '/api/v1/monitoring/hist'
const name = 'monitoring-history'
export function getList(params: any = null) {
let url = path
if (params && params?.cardNumber) {
url += `/${params.cardNumber}/${params.startDate}/${params.endDate}`
delete params.cardNumber
delete params.startDate
delete params.endDate
}
return base.getList(url, params, name)
}
@@ -0,0 +1,19 @@
// Base
import * as base from './_crud-base'
const path = '/api/v1/monitoring/visit'
const name = 'monitoring-visit'
export async function getList(params: any = null) {
let url = path
if (params?.date && params.serviceType) {
url += `/${params.date}/${params.serviceType}`
}
if (params) {
delete params.date
delete params.serviceType
}
const resp = await base.getList(url, params, name)
return resp
}
@@ -0,0 +1,16 @@
// Base
import * as base from './_crud-base'
const path = '/api/v1/referral'
const name = 'reference-hospital-letter' // 'rujukan-rumah-sakit'
export function getList(params: any = null) {
let url = path
if (params?.letterNumber) {
url += `/${params.letterNumber}`
}
if (params) {
delete params.letterNumber
}
return base.getList(url, params, name)
}
@@ -0,0 +1,16 @@
// Base
import * as base from './_crud-base'
const path = '/api/vclaim-swagger/RujukanKhusus'
const name = 'rujukan-khusus'
export function getList(params: any = null) {
let url = path
if (params?.letterNumber) {
url += `?noRujukan=${params.letterNumber}`
}
if (params) {
delete params.letterNumber
}
return base.getList(url, params, name)
}
@@ -0,0 +1,27 @@
// Base
import * as base from './_crud-base'
const path = '/api/v1/reference/regency'
const name = 'cities'
export function getList(params: any = null) {
let url = path
if (params?.province) {
url += `/${params.province}`
delete params.province
}
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?.list || []
data = resultData.map((item: any) => ({
value: item.kode ? String(item.kode) : '',
label: item.nama,
}))
}
return data
}
@@ -0,0 +1,27 @@
// Base
import * as base from './_crud-base'
const path = '/api/v1/reference/district'
const name = 'districts'
export function getList(params: any = null) {
let url = path
if (params?.city) {
url += `/${params.city}`
delete params.city
}
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?.list || []
data = resultData.map((item: any) => ({
value: item.kode ? String(item.kode) : '',
label: item.nama,
}))
}
return data
}
@@ -0,0 +1,23 @@
// Base
import * as base from './_crud-base'
const path = '/api/v1/reference/province'
const name = 'provinces'
export function getList(params: any = null) {
const url = path
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?.list || []
data = resultData.map((item: any) => ({
value: item.kode ? String(item.kode) : '',
label: item.nama,
}))
}
return data
}
+142
View File
@@ -0,0 +1,142 @@
// Base
import * as base from './_crud-base'
// Types
import type { IntegrationBpjsFormData } from '~/schemas/integration-bpjs.schema'
const path = '/api/v1/vclaim-sep'
const pathOld = '/api/vclaim-swagger/sep'
const name = 'sep'
// TODO: temporary destinationClinic
const destinationClinic = '1323R001'
export function create(data: any) {
const isNew = true
let url = !isNew ? pathOld : path
let payload: any = data
if (isNew && data?.encounterId) {
payload = {
encounter_id: Number(data.encounterId) || 0,
requestPayload: data?.request ? JSON.stringify({ request: data.request }) : null,
}
} else {
url = pathOld
delete payload.encounterId
}
return base.create(url, payload, name)
}
export function getList(params: any = null) {
const isNew = true
let url = !isNew ? pathOld : path
if (params?.number) {
url += `/${params.number}`
delete params.number
}
return base.getList(url, params, name)
}
export function getDetail(id: number | string) {
const isNew = true
const url = !isNew ? pathOld : path
return base.getDetail(url, id, name)
}
export function remove(id: string) {
const url = `${path}/${id}`
return base.removeCustom(url, {}, name)
}
export function removeOld(payload: any) {
return base.removeCustom(pathOld, payload, name)
}
export function makeSepData(
data: IntegrationBpjsFormData & {
userName: string
polyCode?: string
referralFrom?: string
referralTo?: string
referralLetterDate?: string
referralLetterNumber?: string
},
) {
const content = {
noKartu: data.cardNumber || '',
tglSep: data.sepDate,
ppkPelayanan: destinationClinic || data.fromClinic || '',
jnsPelayanan: data.serviceType ? String(data.serviceType) : '2',
noMR: data.medicalRecordNumber || '',
catatan: data.note || '',
diagAwal: data.initialDiagnosis || '',
poli: {
tujuan: data.polyCode || '',
eksekutif: data.clinicExcecutive === 'yes' ? '1' : '0',
},
cob: {
cob: data.cob === 'yes' ? '1' : '0',
},
katarak: {
katarak: data.cataract === 'yes' ? '1' : '0',
},
tujuanKunj: data.purposeOfVisit || '0',
flagProcedure: data.procedureType || '',
kdPenunjang: data.supportCode || '',
assesmentPel: data.serviceAssessment || '',
skdp: {
noSurat: ['3'].includes(data.admissionType) ? data.referralLetterNumber : '',
kodeDPJP: ['3'].includes(data.admissionType) ? data.attendingDoctor : '',
},
rujukan: {
// Handle referral data for admissionType !== '3'
// asalRujukan: 1 = Faskes 1, 2 = Faskes RS
asalRujukan: !['3'].includes(data.admissionType) ? data?.referralFrom || '' : '',
tglRujukan: !['3'].includes(data.admissionType) ? data?.referralLetterDate || '' : '',
noRujukan: !['3'].includes(data.admissionType) ? data?.referralLetterNumber || '' : '',
ppkRujukan: !['3'].includes(data.admissionType) ? data?.referralTo || '' : '',
},
klsRawat: {
klsRawatHak: data.classLevel || '',
klsRawatNaik: data.classLevelUpgrade || '',
pembiayaan: data.classPaySource || '',
penanggungJawab: data.responsiblePerson || '',
},
dpjpLayan: data.attendingDoctor || '',
noTelp: data.phoneNumber || '',
user: data.userName || '',
jaminan: {
lakaLantas: data.trafficAccident || '0',
noLP: data.lpNumber || '',
penjamin: {
tglKejadian: data.accidentDate || '',
keterangan: data.accidentNote || '',
suplesi: {
suplesi: data.suplesi === 'yes' ? '1' : '0',
noSepSuplesi: data.suplesiNumber || '',
lokasiLaka: {
kdPropinsi: data.accidentProvince || '',
kdKabupaten: data.accidentCity || '',
kdKecamatan: data.accidentDistrict || '',
},
},
},
},
}
return {
request: {
t_sep: content,
},
}
}
export function makeSepDataForRemove(data: any) {
return {
request: {
t_sep: {
noSep: data.sepNumber,
user: data.userName,
},
},
}
}
+28
View File
@@ -0,0 +1,28 @@
// Base
import * as base from './_crud-base'
const path = '/api/v1/reference/unit'
const name = 'unit'
export function getList(params: any = null) {
let url = path
if (params?.unitCode) {
url += `/${params.unitCode}`
delete params.unitCode
}
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?.faskes || []
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
}