// 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;