2026-02-18 07:12:58 +07:00
|
|
|
<script>
|
|
|
|
|
import Modal from '$lib/components/Modal.svelte';
|
|
|
|
|
import BasicInfoForm from './test-modal/BasicInfoForm.svelte';
|
|
|
|
|
import ReferenceRangeSection from './test-modal/ReferenceRangeSection.svelte';
|
refactor(tests): Move TestModal to route folder and add technical config support
- 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
2026-02-18 16:31:20 +07:00
|
|
|
import TechnicalConfigForm from './test-modal/TechnicalConfigForm.svelte';
|
|
|
|
|
import GroupMembersTab from './test-modal/GroupMembersTab.svelte';
|
2026-02-18 07:12:58 +07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @typedef {Object} Props
|
|
|
|
|
* @property {boolean} open - Whether modal is open
|
|
|
|
|
* @property {string} mode - 'create' or 'edit'
|
|
|
|
|
* @property {Object} formData - Form data object
|
|
|
|
|
* @property {boolean} canHaveRefRange - Whether test can have reference ranges
|
|
|
|
|
* @property {boolean} canHaveFormula - Whether test can have a formula
|
refactor(tests): Move TestModal to route folder and add technical config support
- 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
2026-02-18 16:31:20 +07:00
|
|
|
* @property {boolean} canHaveTechnical - Whether test can have technical config
|
|
|
|
|
* @property {boolean} isGroupTest - Whether test is a group test
|
2026-02-18 07:12:58 +07:00
|
|
|
* @property {Array<{value: string, label: string}>} disciplineOptions - Discipline dropdown options
|
|
|
|
|
* @property {Array<{value: string, label: string}>} departmentOptions - Department dropdown options
|
refactor(tests): Move TestModal to route folder and add technical config support
- 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
2026-02-18 16:31:20 +07:00
|
|
|
* @property {Array} availableTests - Available tests for group member selection
|
2026-02-18 07:12:58 +07:00
|
|
|
* @property {boolean} [saving] - Whether save is in progress
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/** @type {Props & { onsave?: () => void, oncancel?: () => void, onupdateFormData?: (formData: Object) => void }} */
|
|
|
|
|
let {
|
|
|
|
|
open = $bindable(false),
|
|
|
|
|
mode = 'create',
|
|
|
|
|
formData = $bindable({}),
|
|
|
|
|
canHaveRefRange = false,
|
|
|
|
|
canHaveFormula = false,
|
refactor(tests): Move TestModal to route folder and add technical config support
- 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
2026-02-18 16:31:20 +07:00
|
|
|
canHaveTechnical = false,
|
|
|
|
|
isGroupTest = false,
|
2026-02-18 07:12:58 +07:00
|
|
|
disciplineOptions = [],
|
|
|
|
|
departmentOptions = [],
|
refactor(tests): Move TestModal to route folder and add technical config support
- 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
2026-02-18 16:31:20 +07:00
|
|
|
availableTests = [],
|
2026-02-18 07:12:58 +07:00
|
|
|
saving = false,
|
|
|
|
|
onsave = () => {},
|
|
|
|
|
oncancel = () => {},
|
|
|
|
|
onupdateFormData = () => {}
|
|
|
|
|
} = $props();
|
|
|
|
|
|
|
|
|
|
// Local state
|
|
|
|
|
let activeTab = $state('basic');
|
|
|
|
|
|
|
|
|
|
function handleCancel() {
|
|
|
|
|
activeTab = 'basic';
|
|
|
|
|
oncancel();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function handleSave() {
|
|
|
|
|
onsave();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Reactive update when modal opens
|
|
|
|
|
$effect(() => {
|
|
|
|
|
if (open) {
|
|
|
|
|
activeTab = 'basic';
|
|
|
|
|
}
|
|
|
|
|
});
|
refactor(tests): Move TestModal to route folder and add technical config support
- 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
2026-02-18 16:31:20 +07:00
|
|
|
|
|
|
|
|
// Get tab count badge for reference range
|
|
|
|
|
function getRefRangeCount() {
|
2026-02-19 16:30:41 +07:00
|
|
|
return (formData.refnum?.length || 0) + (formData.reftxt?.length || 0);
|
refactor(tests): Move TestModal to route folder and add technical config support
- 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
2026-02-18 16:31:20 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Get tab count badge for group members
|
|
|
|
|
function getGroupMemberCount() {
|
|
|
|
|
return formData.groupMembers?.length || 0;
|
|
|
|
|
}
|
2026-02-18 07:12:58 +07:00
|
|
|
</script>
|
|
|
|
|
|
refactor(tests): Move TestModal to route folder and add technical config support
- 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
2026-02-18 16:31:20 +07:00
|
|
|
<Modal bind:open title={mode === 'create' ? 'Add Test' : 'Edit Test'} size="xl" position="top">
|
2026-02-18 07:12:58 +07:00
|
|
|
<!-- Tabs -->
|
|
|
|
|
<div class="tabs tabs-bordered mb-4">
|
|
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
class="tab tab-lg {activeTab === 'basic' ? 'tab-active' : ''}"
|
|
|
|
|
onclick={() => activeTab = 'basic'}
|
|
|
|
|
>
|
|
|
|
|
Basic Information
|
|
|
|
|
</button>
|
refactor(tests): Move TestModal to route folder and add technical config support
- 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
2026-02-18 16:31:20 +07:00
|
|
|
{#if canHaveTechnical}
|
|
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
class="tab tab-lg {activeTab === 'technical' ? 'tab-active' : ''}"
|
|
|
|
|
onclick={() => activeTab = 'technical'}
|
|
|
|
|
>
|
|
|
|
|
Technical
|
|
|
|
|
</button>
|
|
|
|
|
{/if}
|
2026-02-18 07:12:58 +07:00
|
|
|
{#if canHaveRefRange}
|
|
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
class="tab tab-lg {activeTab === 'refrange' ? 'tab-active' : ''}"
|
|
|
|
|
onclick={() => activeTab = 'refrange'}
|
|
|
|
|
>
|
|
|
|
|
Reference Range
|
refactor(tests): Move TestModal to route folder and add technical config support
- 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
2026-02-18 16:31:20 +07:00
|
|
|
{#if getRefRangeCount() > 0}
|
|
|
|
|
<span class="badge badge-sm badge-primary ml-2">{getRefRangeCount()}</span>
|
|
|
|
|
{/if}
|
|
|
|
|
</button>
|
|
|
|
|
{/if}
|
|
|
|
|
{#if isGroupTest}
|
|
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
class="tab tab-lg {activeTab === 'members' ? 'tab-active' : ''}"
|
|
|
|
|
onclick={() => activeTab = 'members'}
|
|
|
|
|
>
|
|
|
|
|
Group Members
|
|
|
|
|
{#if getGroupMemberCount() > 0}
|
|
|
|
|
<span class="badge badge-sm badge-primary ml-2">{getGroupMemberCount()}</span>
|
2026-02-18 07:12:58 +07:00
|
|
|
{/if}
|
|
|
|
|
</button>
|
|
|
|
|
{/if}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{#if activeTab === 'basic'}
|
|
|
|
|
<BasicInfoForm
|
|
|
|
|
bind:formData
|
|
|
|
|
{canHaveFormula}
|
|
|
|
|
{disciplineOptions}
|
|
|
|
|
{departmentOptions}
|
|
|
|
|
onsave={handleSave}
|
|
|
|
|
/>
|
refactor(tests): Move TestModal to route folder and add technical config support
- 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
2026-02-18 16:31:20 +07:00
|
|
|
{:else if activeTab === 'technical' && canHaveTechnical}
|
|
|
|
|
<TechnicalConfigForm
|
|
|
|
|
bind:formData
|
|
|
|
|
{onupdateFormData}
|
|
|
|
|
/>
|
2026-02-18 07:12:58 +07:00
|
|
|
{:else if activeTab === 'refrange' && canHaveRefRange}
|
|
|
|
|
<ReferenceRangeSection
|
|
|
|
|
bind:formData
|
|
|
|
|
{onupdateFormData}
|
|
|
|
|
/>
|
refactor(tests): Move TestModal to route folder and add technical config support
- 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
2026-02-18 16:31:20 +07:00
|
|
|
{:else if activeTab === 'members' && isGroupTest}
|
|
|
|
|
<GroupMembersTab
|
|
|
|
|
bind:formData
|
|
|
|
|
{availableTests}
|
|
|
|
|
{onupdateFormData}
|
|
|
|
|
/>
|
2026-02-18 07:12:58 +07:00
|
|
|
{/if}
|
|
|
|
|
|
|
|
|
|
{#snippet footer()}
|
|
|
|
|
<button class="btn btn-ghost" onclick={handleCancel} type="button">Cancel</button>
|
|
|
|
|
<button class="btn btn-primary" onclick={handleSave} disabled={saving} type="button">
|
|
|
|
|
{#if saving}
|
|
|
|
|
<span class="loading loading-spinner loading-sm mr-2"></span>
|
|
|
|
|
{/if}
|
|
|
|
|
{saving ? 'Saving...' : 'Save'}
|
|
|
|
|
</button>
|
|
|
|
|
{/snippet}
|
|
|
|
|
</Modal>
|