clqms-fe1/backup/tests_backup/referenceRange.js
mahdahar 99d622ad05 refactor(tests): consolidate test management modal components
- Consolidate fragmented test modal components into unified TestFormModal.svelte
- Reorganize reference range components into organized tabs (RefNumTab, RefTxtTab)
- Add new tab components: BasicInfoTab, TechDetailsTab, CalcDetailsTab, MappingsTab, GroupMembersTab
- Move test-related type definitions to src/lib/types/test.types.ts for better type organization
- Delete old component files: TestModal.svelte and 10+ sub-components
- Add backup directory for old component preservation
- Update AGENTS.md with coding guidelines and project conventions
- Update tests.js API client with improved structure
- Add documentation for frontend test management architecture
2026-02-20 13:51:54 +07:00

120 lines
3.0 KiB
JavaScript

// Reference Range Management Functions
export const signOptions = [
{ value: 'GE', label: '≥', description: 'Greater than or equal to' },
{ value: 'GT', label: '>', description: 'Greater than' },
{ value: 'LE', label: '≤', description: 'Less than or equal to' },
{ value: 'LT', label: '<', description: 'Less than' }
];
export const flagOptions = [
{ value: 'N', label: 'N', description: 'Normal' },
{ value: 'L', label: 'L', description: 'Low' },
{ value: 'H', label: 'H', description: 'High' },
{ value: 'C', label: 'C', description: 'Critical' }
];
export const refTypeOptions = [
{ value: 'REF', label: 'REF', description: 'Reference Range' },
{ value: 'CRTC', label: 'CRTC', description: 'Critical Range' },
{ value: 'VAL', label: 'VAL', description: 'Validation Range' },
{ value: 'RERUN', label: 'RERUN', description: 'Rerun Range' },
{ value: 'THOLD', label: 'THOLD', description: 'Threshold Range' }
];
export const textRefTypeOptions = [
{ value: 'TEXT', label: 'TEXT', description: 'Text Reference' },
{ value: 'VSET', label: 'VSET', description: 'Value Set Reference' }
];
export const sexOptions = [
{ value: '2', label: 'Male' },
{ value: '1', label: 'Female' },
{ value: '0', label: 'Any' }
];
export function createNumRef() {
return {
RefType: 'REF',
Sex: '0',
LowSign: 'GE',
HighSign: 'LE',
Low: null,
High: null,
AgeStart: 0,
AgeEnd: 120,
Flag: 'N',
Interpretation: '',
SpcType: '',
Criteria: ''
};
}
export function createTholdRef() {
return {
RefType: 'THOLD',
Sex: '0',
LowSign: 'GE',
HighSign: 'LE',
Low: null,
High: null,
AgeStart: 0,
AgeEnd: 120,
Flag: 'N',
Interpretation: '',
SpcType: '',
Criteria: ''
};
}
export function createTextRef() {
return {
RefType: 'TEXT',
Sex: '0',
AgeStart: 0,
AgeEnd: 120,
RefTxt: '',
Flag: 'N',
SpcType: '',
Criteria: ''
};
}
export function createVsetRef() {
return {
RefType: 'VSET',
Sex: '0',
AgeStart: 0,
AgeEnd: 120,
RefTxt: '',
Flag: 'N',
SpcType: '',
Criteria: ''
};
}
export function validateNumericRange(ref, index) {
const errors = [];
if (ref.Low !== null && ref.High !== null && ref.Low > ref.High) {
errors.push(`Range ${index + 1}: Low value cannot be greater than High value`);
}
if (ref.AgeStart !== null && ref.AgeEnd !== null && ref.AgeStart > ref.AgeEnd) {
errors.push(`Range ${index + 1}: Age start cannot be greater than Age end`);
}
return errors;
}
// Alias for threshold validation (same logic)
export const validateTholdRange = validateNumericRange;
export function validateTextRange(ref, index) {
const errors = [];
if (ref.AgeStart !== null && ref.AgeEnd !== null && ref.AgeStart > ref.AgeEnd) {
errors.push(`Range ${index + 1}: Age start cannot be greater than Age end`);
}
return errors;
}
// Alias for value set validation (same logic)
export const validateVsetRange = validateTextRange;