- Move TestModal from lib/components to routes/(app)/master-data/tests - Add technical configuration form (ResultType, RefType, SpcType, units, etc.) - Add GroupMembersTab for managing group test members - Enhance reference ranges with refvset and refthold support - Update API to handle new test fields (ReqQty, Factor, Decimal, TAT, etc.) - Add database schema documentation (DBML format) - Remove old test-types-reference.md documentation - UI improvements: compact design, updated sidebar, modal sizing - Update DataTable, Modal, SelectDropdown components for compact style - Enhance patient and visit modals with compact layout
101 lines
2.9 KiB
JavaScript
101 lines
2.9 KiB
JavaScript
import { get, post, patch } from './client.js';
|
|
|
|
/**
|
|
* Fetch tests list with optional filters, pagination, and search
|
|
* @param {Object} params - Query parameters
|
|
* @param {number} [params.page=1] - Page number
|
|
* @param {number} [params.perPage=20] - Items per page
|
|
* @param {string} [params.search] - Search by test code or name
|
|
* @param {string} [params.TestType] - Filter by test type (TEST, PARAM, CALC, GROUP, TITLE)
|
|
* @returns {Promise<Object>} API response with test data and pagination
|
|
*/
|
|
export async function fetchTests(params = {}) {
|
|
const query = new URLSearchParams(params).toString();
|
|
return get(query ? `/api/tests?${query}` : '/api/tests');
|
|
}
|
|
|
|
export async function fetchTest(id) {
|
|
return get(`/api/tests/${id}`);
|
|
}
|
|
|
|
export async function createTest(data) {
|
|
const payload = {
|
|
TestSiteCode: data.TestSiteCode,
|
|
TestSiteName: data.TestSiteName,
|
|
TestType: data.TestType,
|
|
DisciplineID: data.DisciplineID,
|
|
DepartmentID: data.DepartmentID,
|
|
SeqScr: data.SeqScr,
|
|
SeqRpt: data.SeqRpt,
|
|
VisibleScr: data.VisibleScr ? '1' : '0',
|
|
VisibleRpt: data.VisibleRpt ? '1' : '0',
|
|
// Type-specific fields
|
|
Unit: data.Unit,
|
|
Formula: data.Formula,
|
|
// Technical Config
|
|
ResultType: data.ResultType,
|
|
RefType: data.RefType,
|
|
SpcType: data.SpcType,
|
|
ReqQty: data.ReqQty,
|
|
ReqQtyUnit: data.ReqQtyUnit,
|
|
Unit1: data.Unit1,
|
|
Factor: data.Factor,
|
|
Unit2: data.Unit2,
|
|
Decimal: data.Decimal,
|
|
CollReq: data.CollReq,
|
|
Method: data.Method,
|
|
ExpectedTAT: data.ExpectedTAT,
|
|
// Reference ranges (only for TEST and CALC)
|
|
refnum: data.refnum,
|
|
reftxt: data.reftxt,
|
|
refvset: data.refvset,
|
|
refthold: data.refthold,
|
|
};
|
|
return post('/api/tests', payload);
|
|
}
|
|
|
|
export async function updateTest(data) {
|
|
const payload = {
|
|
TestSiteID: data.TestSiteID,
|
|
TestSiteCode: data.TestSiteCode,
|
|
TestSiteName: data.TestSiteName,
|
|
TestType: data.TestType,
|
|
DisciplineID: data.DisciplineID,
|
|
DepartmentID: data.DepartmentID,
|
|
SeqScr: data.SeqScr,
|
|
SeqRpt: data.SeqRpt,
|
|
VisibleScr: data.VisibleScr ? '1' : '0',
|
|
VisibleRpt: data.VisibleRpt ? '1' : '0',
|
|
// Type-specific fields
|
|
Unit: data.Unit,
|
|
Formula: data.Formula,
|
|
// Technical Config
|
|
ResultType: data.ResultType,
|
|
RefType: data.RefType,
|
|
SpcType: data.SpcType,
|
|
ReqQty: data.ReqQty,
|
|
ReqQtyUnit: data.ReqQtyUnit,
|
|
Unit1: data.Unit1,
|
|
Factor: data.Factor,
|
|
Unit2: data.Unit2,
|
|
Decimal: data.Decimal,
|
|
CollReq: data.CollReq,
|
|
Method: data.Method,
|
|
ExpectedTAT: data.ExpectedTAT,
|
|
// Reference ranges (only for TEST and CALC)
|
|
refnum: data.refnum,
|
|
reftxt: data.reftxt,
|
|
refvset: data.refvset,
|
|
refthold: data.refthold,
|
|
};
|
|
return patch('/api/tests', payload);
|
|
}
|
|
|
|
export async function deleteTest(id) {
|
|
// Soft delete - set IsActive to '0'
|
|
return patch('/api/tests', {
|
|
TestSiteID: id,
|
|
IsActive: '0',
|
|
});
|
|
}
|