diff --git a/docs/api-docs.yaml b/docs/api-docs.yaml index 439f531..890ad8e 100644 --- a/docs/api-docs.yaml +++ b/docs/api-docs.yaml @@ -409,7 +409,7 @@ components: enum: [A01, A02, A03, A04, A08] description: | A01: Admit - A02: Transfer + A02: Transfer A03: Discharge A04: Register A08: Update @@ -657,9 +657,11 @@ components: TITLE: Section header DisciplineID: type: integer + DisciplineName: + type: string DepartmentID: type: integer - SpecimenType: + DepartmentName: type: string Unit: type: string @@ -736,28 +738,7 @@ components: Flag: type: string examples: - TEST_simple: - summary: Technical test - no reference range - value: - id: 1 - TestCode: GLU - TestName: Glucose - TestType: TEST - DisciplineID: 1 - DepartmentID: 1 - SpecimenType: SER - Unit: mg/dL - TEST_numeric_nmrc: - summary: Technical test - numeric reference (NMRC) - value: - id: 1 - TestCode: GLU - TestName: Glucose - TestType: TEST - DisciplineID: 1 - DepartmentID: 1 - SpecimenType: SER - Unit: mg/dL + $1 Unit: mg/dL refnum: - RefNumID: 1 NumRefType: NMRC @@ -767,9 +748,9 @@ components: Sex: '2' SexLabel: Male LowSign: GE - LowSignLabel: '>= + LowSignLabel: ">=" HighSign: LE - HighSignLabel: '<=' + HighSignLabel: "<=" Low: 70 High: 100 AgeStart: 18 @@ -785,7 +766,6 @@ components: TestType: TEST DisciplineID: 1 DepartmentID: 1 - SpecimenType: SER Unit: mg/dL refnum: - RefNumID: 2 @@ -796,23 +776,13 @@ components: Sex: '1' SexLabel: Female LowSign: LT - LowSignLabel: '<' + LowSignLabel: "<" High: 40 AgeStart: 0 AgeEnd: 120 Flag: L Interpretation: Critical Low - TEST_text_text: - summary: Technical test - text reference (TEXT) - value: - id: 1 - TestCode: RBC_MORPH - TestName: RBC Morphology - TestType: TEST - DisciplineID: 1 - DepartmentID: 1 - SpecimenType: BLD - Unit: null + $1 Unit: null reftxt: - RefTxtID: 1 TxtRefType: TEXT @@ -832,7 +802,6 @@ components: TestType: TEST DisciplineID: 1 DepartmentID: 1 - SpecimenType: null Unit: null reftxt: - RefTxtID: 2 @@ -853,19 +822,8 @@ components: TestType: PARAM DisciplineID: 1 DepartmentID: 1 - SpecimenType: SER Unit: mg/dL - CALC_numeric_nmrc: - summary: Calculated test - numeric reference (NMRC) - value: - id: 3 - TestCode: BUN_CR_RATIO - TestName: BUN/Creatinine Ratio - TestType: CALC - DisciplineID: 1 - DepartmentID: 1 - SpecimenType: SER - Unit: null + $1 Unit: null Formula: "BUN / Creatinine" refnum: - RefNumID: 5 @@ -876,26 +834,16 @@ components: Sex: '1' SexLabel: Female LowSign: GE - LowSignLabel: '>= + LowSignLabel: ">=" HighSign: LE - HighSignLabel: '<=' + HighSignLabel: "<=" Low: 10 High: 20 AgeStart: 18 AgeEnd: 120 Flag: N Interpretation: Normal - CALC_numeric_thold: - summary: Calculated test - threshold reference (THOLD) - value: - id: 3 - TestCode: BUN_CR_RATIO - TestName: BUN/Creatinine Ratio - TestType: CALC - DisciplineID: 1 - DepartmentID: 1 - SpecimenType: SER - Unit: null + $1 Unit: null Formula: "BUN / Creatinine" refnum: - RefNumID: 6 @@ -906,7 +854,7 @@ components: Sex: '1' SexLabel: Female LowSign: GT - LowSignLabel: '>' + LowSignLabel: ">" Low: 20 AgeStart: 18 AgeEnd: 120 @@ -922,7 +870,6 @@ components: TestType: GROUP DisciplineID: 1 DepartmentID: 1 - SpecimenType: SER Unit: null TITLE: summary: Section header - no reference range allowed @@ -933,7 +880,6 @@ components: TestType: TITLE DisciplineID: 1 DepartmentID: 1 - SpecimenType: null Unit: null TestMap: @@ -1952,6 +1898,68 @@ paths: items: $ref: '#/components/schemas/PatientVisit' + /api/patvisitadt: + post: + tags: [Patient Visits] + summary: Create ADT record + description: Create a new Admission/Discharge/Transfer record + security: + - bearerAuth: [] + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/PatVisitADT' + responses: + '201': + description: ADT record created successfully + content: + application/json: + schema: + $ref: '#/components/schemas/SuccessResponse' + + patch: + tags: [Patient Visits] + summary: Update ADT record + description: Update an existing ADT record + security: + - bearerAuth: [] + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/PatVisitADT' + responses: + '200': + description: ADT record updated successfully + content: + application/json: + schema: + $ref: '#/components/schemas/SuccessResponse' + + delete: + tags: [Patient Visits] + summary: Delete ADT visit (soft delete) + security: + - bearerAuth: [] + requestBody: + required: true + content: + application/json: + schema: + type: object + required: + - PVADTID + properties: + PVADTID: + type: integer + description: ADT record ID to delete + responses: + '200': + description: ADT visit deleted successfully + /api/patvisitadt/visit/{visitId}: get: tags: [Patient Visits] @@ -2026,8 +2034,6 @@ paths: EndDate: type: string format: date-time - -$1 delete: tags: [Patient Visits] summary: Delete ADT visit (soft delete) @@ -2122,7 +2128,7 @@ $1 type: string format: date-time -$2/account/{id}: + /api/organization/account/{id}: get: tags: [Organization] summary: Get account by ID @@ -2137,6 +2143,10 @@ $2/account/{id}: responses: '200': description: Account details + content: + application/json: + schema: + $ref: '#/components/schemas/Account' # ======================================== # Organization - Site Routes @@ -3203,7 +3213,7 @@ $2/account/{id}: summary: Get lib value set by key description: | Get a specific library/system value set from JSON files. - + **Available value set keys:** - `activity_result` - Activity Result - `additive` - Additive diff --git a/src/lib/api/tests.js b/src/lib/api/tests.js index 91fda5f..c95abf9 100644 --- a/src/lib/api/tests.js +++ b/src/lib/api/tests.js @@ -21,7 +21,6 @@ export async function createTest(data) { VisibleScr: data.VisibleScr ? '1' : '0', VisibleRpt: data.VisibleRpt ? '1' : '0', // Type-specific fields - SpecimenType: data.SpecimenType, Unit: data.Unit, Formula: data.Formula, // Reference ranges (only for TEST and CALC) @@ -44,7 +43,6 @@ export async function updateTest(data) { VisibleScr: data.VisibleScr ? '1' : '0', VisibleRpt: data.VisibleRpt ? '1' : '0', // Type-specific fields - SpecimenType: data.SpecimenType, Unit: data.Unit, Formula: data.Formula, // Reference ranges (only for TEST and CALC) diff --git a/src/routes/(app)/master-data/tests/+page.svelte b/src/routes/(app)/master-data/tests/+page.svelte index ded1db8..c32f71e 100644 --- a/src/routes/(app)/master-data/tests/+page.svelte +++ b/src/routes/(app)/master-data/tests/+page.svelte @@ -2,8 +2,7 @@ import { onMount } from 'svelte'; import { fetchTests, createTest, updateTest, deleteTest } from '$lib/api/tests.js'; import { fetchDisciplines, fetchDepartments } from '$lib/api/organization.js'; - import { fetchSpecimenTypes } from '$lib/api/specimens.js'; - import { success as toastSuccess, error as toastError } from '$lib/utils/toast.js'; + import { success as toastSuccess, error as toastError } from '$lib/utils/toast.js'; import DataTable from '$lib/components/DataTable.svelte'; import Modal from '$lib/components/Modal.svelte'; import SelectDropdown from '$lib/components/SelectDropdown.svelte'; @@ -14,7 +13,6 @@ let tests = $state([]); let disciplines = $state([]); let departments = $state([]); - let specimenTypes = $state([]); let modalOpen = $state(false); let modalMode = $state('create'); let saving = $state(false); @@ -38,7 +36,6 @@ VisibleScr: true, VisibleRpt: true, // Type-specific fields - SpecimenType: '', Unit: '', Formula: '', // Reference ranges @@ -96,10 +93,6 @@ formData.TestType === 'TEST' || formData.TestType === 'CALC' ); - const canHaveSpecimen = $derived( - formData.TestType === 'TEST' || formData.TestType === 'PARAM' - ); - const canHaveFormula = $derived( formData.TestType === 'CALC' ); @@ -112,7 +105,6 @@ { key: 'TestSiteCode', label: 'Code', class: 'font-medium' }, { key: 'TestSiteName', label: 'Name' }, { key: 'TestType', label: 'Type', class: 'w-32' }, - { key: 'SpecimenType', label: 'Specimen', class: 'w-32' }, { key: 'Unit', label: 'Unit', class: 'w-24' }, { key: 'DisciplineName', label: 'Discipline' }, { key: 'DepartmentName', label: 'Department' }, @@ -123,8 +115,7 @@ await Promise.all([ loadTests(), loadDisciplines(), - loadDepartments(), - loadSpecimenTypes() + loadDepartments() ]); }); @@ -176,16 +167,7 @@ } } - async function loadSpecimenTypes() { - try { - const response = await fetchSpecimenTypes(); - specimenTypes = Array.isArray(response.data) ? response.data : []; - } catch (err) { - specimenTypes = []; - } - } - - function openCreateModal() { + function openCreateModal() { modalMode = 'create'; activeTab = 'basic'; formData = { @@ -199,7 +181,6 @@ SeqRpt: '0', VisibleScr: true, VisibleRpt: true, - SpecimenType: '', Unit: '', Formula: '', refnum: [], @@ -232,7 +213,6 @@ SeqRpt: row.SeqRpt || '0', VisibleScr: row.VisibleScr === '1' || row.VisibleScr === 1 || row.VisibleScr === true, VisibleRpt: row.VisibleRpt === '1' || row.VisibleRpt === 1 || row.VisibleRpt === true, - SpecimenType: row.SpecimenType || '', Unit: row.Unit || '', Formula: row.Formula || '', refnum: row.refnum || [], @@ -364,9 +344,6 @@ const payload = { ...formData }; // Remove fields not applicable to this type - if (!canHaveSpecimen) { - delete payload.SpecimenType; - } if (!canHaveUnit) { delete payload.Unit; } @@ -447,12 +424,6 @@ filteredDepartments.map(d => ({ value: d.DepartmentID, label: d.DepartmentName })) ); - const specimenTypeOptions = $derived( - specimenTypes.map(s => ({ - value: s.SpecimenCode || s.SpecimenType, - label: s.SpecimenName || s.SpecimenType - })) - );