|
|
|
@ -15,22 +15,22 @@ import {
|
|
|
|
import { ErrorBoundary } from '../common/ErrorBoundary';
|
|
|
|
import { ErrorBoundary } from '../common/ErrorBoundary';
|
|
|
|
|
|
|
|
|
|
|
|
const COMMON_TONGUE_SUGGESTIONS = [
|
|
|
|
const COMMON_TONGUE_SUGGESTIONS = [
|
|
|
|
'Pale and Thin.',
|
|
|
|
'Pale and Thin',
|
|
|
|
'Purple.',
|
|
|
|
'Purple',
|
|
|
|
'Normal.',
|
|
|
|
'Normal',
|
|
|
|
'Red with yellow coat.',
|
|
|
|
'Red with yellow coat',
|
|
|
|
'Pale with tooth marks.',
|
|
|
|
'Pale with tooth marks',
|
|
|
|
'Slightly Red sides or normal.',
|
|
|
|
'Slightly Red sides or normal',
|
|
|
|
];
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
const COMMON_PULSE_SUGGESTIONS = [
|
|
|
|
const COMMON_PULSE_SUGGESTIONS = [
|
|
|
|
'Choppy.',
|
|
|
|
'Choppy',
|
|
|
|
'Wiry.',
|
|
|
|
'Wiry',
|
|
|
|
'Deep and Wiry.',
|
|
|
|
'Deep and Wiry',
|
|
|
|
'Deep and Weak.',
|
|
|
|
'Deep and Weak',
|
|
|
|
'Choppy or Fine.',
|
|
|
|
'Choppy or Fine',
|
|
|
|
'Rapid and Slippery.',
|
|
|
|
'Rapid and Slippery',
|
|
|
|
'Floating.',
|
|
|
|
'Floating',
|
|
|
|
];
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
const COMMON_POINT_SUGGESTIONS = [
|
|
|
|
const COMMON_POINT_SUGGESTIONS = [
|
|
|
|
@ -66,6 +66,22 @@ const formatApiError = (err: any, fallback: string): string => {
|
|
|
|
return String(detail);
|
|
|
|
return String(detail);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const normalizeTreatmentPrinciple = (val: string[] | string | undefined): string[] => {
|
|
|
|
|
|
|
|
if (Array.isArray(val)) {
|
|
|
|
|
|
|
|
const cleaned = val.map((v) => String(v || '').trim()).filter(Boolean);
|
|
|
|
|
|
|
|
return cleaned.length > 0 ? cleaned : [''];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
const s = String(val || '').trim();
|
|
|
|
|
|
|
|
return s ? [s] : [''];
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const suggestHyphenatedPoint = (raw: string): string | null => {
|
|
|
|
|
|
|
|
const cleaned = raw.trim().toUpperCase();
|
|
|
|
|
|
|
|
const match = cleaned.match(/^([A-Z]{1,4})\s+(\d+[A-Z]?)$/) || cleaned.match(/^([A-Z]{1,4})(\d+[A-Z]?)$/);
|
|
|
|
|
|
|
|
if (!match) return null;
|
|
|
|
|
|
|
|
return `${match[1]}-${match[2]}`;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const createBlankPattern = (moduleCode: string, catCode: string, disCode: string): BuilderPattern => ({
|
|
|
|
const createBlankPattern = (moduleCode: string, catCode: string, disCode: string): BuilderPattern => ({
|
|
|
|
module_code: moduleCode,
|
|
|
|
module_code: moduleCode,
|
|
|
|
category_code: catCode,
|
|
|
|
category_code: catCode,
|
|
|
|
@ -77,7 +93,7 @@ const createBlankPattern = (moduleCode: string, catCode: string, disCode: string
|
|
|
|
clinical_manifestations: [''],
|
|
|
|
clinical_manifestations: [''],
|
|
|
|
tongue: '',
|
|
|
|
tongue: '',
|
|
|
|
pulse: '',
|
|
|
|
pulse: '',
|
|
|
|
treatment_principle: '',
|
|
|
|
treatment_principle: [''],
|
|
|
|
acupuncture: { points: '', method: '' },
|
|
|
|
acupuncture: { points: '', method: '' },
|
|
|
|
explanation: [''],
|
|
|
|
explanation: [''],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
@ -132,8 +148,11 @@ export const ModuleBuilderTabContent: React.FC = () => {
|
|
|
|
const [newDiseaseName, setNewDiseaseName] = useState('');
|
|
|
|
const [newDiseaseName, setNewDiseaseName] = useState('');
|
|
|
|
const [modalDisError, setModalDisError] = useState<string | null>(null);
|
|
|
|
const [modalDisError, setModalDisError] = useState<string | null>(null);
|
|
|
|
|
|
|
|
|
|
|
|
// Point input state
|
|
|
|
// Chip & Point input state
|
|
|
|
const [customPointInput, setCustomPointInput] = useState('');
|
|
|
|
const [customPointInput, setCustomPointInput] = useState('');
|
|
|
|
|
|
|
|
const [customTongueInput, setCustomTongueInput] = useState('');
|
|
|
|
|
|
|
|
const [customPulseInput, setCustomPulseInput] = useState('');
|
|
|
|
|
|
|
|
const [pendingPointSuggestion, setPendingPointSuggestion] = useState<{ raw: string; suggested: string } | null>(null);
|
|
|
|
|
|
|
|
|
|
|
|
// 0. Load Modules List
|
|
|
|
// 0. Load Modules List
|
|
|
|
const fetchModules = async (selectCode?: string) => {
|
|
|
|
const fetchModules = async (selectCode?: string) => {
|
|
|
|
@ -262,7 +281,7 @@ export const ModuleBuilderTabContent: React.FC = () => {
|
|
|
|
: [''],
|
|
|
|
: [''],
|
|
|
|
tongue: p.clinical_data?.tongue || '',
|
|
|
|
tongue: p.clinical_data?.tongue || '',
|
|
|
|
pulse: p.clinical_data?.pulse || '',
|
|
|
|
pulse: p.clinical_data?.pulse || '',
|
|
|
|
treatment_principle: p.clinical_data?.treatment_principle || '',
|
|
|
|
treatment_principle: normalizeTreatmentPrinciple(p.clinical_data?.treatment_principle),
|
|
|
|
acupuncture: {
|
|
|
|
acupuncture: {
|
|
|
|
points: p.clinical_data?.acupuncture?.points || '',
|
|
|
|
points: p.clinical_data?.acupuncture?.points || '',
|
|
|
|
method: p.clinical_data?.acupuncture?.method || '',
|
|
|
|
method: p.clinical_data?.acupuncture?.method || '',
|
|
|
|
@ -488,7 +507,7 @@ export const ModuleBuilderTabContent: React.FC = () => {
|
|
|
|
clinical_manifestations: [''],
|
|
|
|
clinical_manifestations: [''],
|
|
|
|
tongue: '',
|
|
|
|
tongue: '',
|
|
|
|
pulse: '',
|
|
|
|
pulse: '',
|
|
|
|
treatment_principle: '',
|
|
|
|
treatment_principle: [''],
|
|
|
|
acupuncture: { points: '', method: '' },
|
|
|
|
acupuncture: { points: '', method: '' },
|
|
|
|
explanation: [''],
|
|
|
|
explanation: [''],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
@ -546,24 +565,143 @@ export const ModuleBuilderTabContent: React.FC = () => {
|
|
|
|
}));
|
|
|
|
}));
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Treatment Principle Row Helpers
|
|
|
|
|
|
|
|
const activePrinciples = Array.isArray(activePattern?.clinical_data?.treatment_principle)
|
|
|
|
|
|
|
|
? activePattern.clinical_data.treatment_principle
|
|
|
|
|
|
|
|
: normalizeTreatmentPrinciple(activePattern?.clinical_data?.treatment_principle);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const handlePrincipleChange = (pIdx: number, val: string) => {
|
|
|
|
|
|
|
|
updateActivePattern(p => {
|
|
|
|
|
|
|
|
const list = Array.isArray(p.clinical_data?.treatment_principle)
|
|
|
|
|
|
|
|
? [...p.clinical_data.treatment_principle]
|
|
|
|
|
|
|
|
: normalizeTreatmentPrinciple(p.clinical_data?.treatment_principle);
|
|
|
|
|
|
|
|
list[pIdx] = val;
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
|
|
...p,
|
|
|
|
|
|
|
|
clinical_data: { ...p.clinical_data, treatment_principle: list },
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const handleAddPrinciple = () => {
|
|
|
|
|
|
|
|
updateActivePattern(p => {
|
|
|
|
|
|
|
|
const list = Array.isArray(p.clinical_data?.treatment_principle)
|
|
|
|
|
|
|
|
? p.clinical_data.treatment_principle
|
|
|
|
|
|
|
|
: normalizeTreatmentPrinciple(p.clinical_data?.treatment_principle);
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
|
|
...p,
|
|
|
|
|
|
|
|
clinical_data: {
|
|
|
|
|
|
|
|
...p.clinical_data,
|
|
|
|
|
|
|
|
treatment_principle: [...list, ''],
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const handleRemovePrinciple = (pIdx: number) => {
|
|
|
|
|
|
|
|
updateActivePattern(p => {
|
|
|
|
|
|
|
|
const list = Array.isArray(p.clinical_data?.treatment_principle)
|
|
|
|
|
|
|
|
? p.clinical_data.treatment_principle
|
|
|
|
|
|
|
|
: normalizeTreatmentPrinciple(p.clinical_data?.treatment_principle);
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
|
|
...p,
|
|
|
|
|
|
|
|
clinical_data: {
|
|
|
|
|
|
|
|
...p.clinical_data,
|
|
|
|
|
|
|
|
treatment_principle: list.filter((_, i) => i !== pIdx),
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Tongue & Pulse Chips Helpers
|
|
|
|
|
|
|
|
const parseCommaChips = (val?: string) =>
|
|
|
|
|
|
|
|
(val || '')
|
|
|
|
|
|
|
|
.split(',')
|
|
|
|
|
|
|
|
.map(s => s.trim().replace(/\.+$/, ''))
|
|
|
|
|
|
|
|
.filter(Boolean);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const currentTongueChips = parseCommaChips(activePattern?.clinical_data?.tongue);
|
|
|
|
|
|
|
|
const currentPulseChips = parseCommaChips(activePattern?.clinical_data?.pulse);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const handleAddDiagnosisChip = (field: 'tongue' | 'pulse', raw: string) => {
|
|
|
|
|
|
|
|
const parts = raw
|
|
|
|
|
|
|
|
.split(',')
|
|
|
|
|
|
|
|
.map(s => s.trim().replace(/\.+$/, ''))
|
|
|
|
|
|
|
|
.filter(Boolean);
|
|
|
|
|
|
|
|
if (parts.length === 0) return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const existing = field === 'tongue' ? currentTongueChips : currentPulseChips;
|
|
|
|
|
|
|
|
const merged = [...existing];
|
|
|
|
|
|
|
|
let addedAny = false;
|
|
|
|
|
|
|
|
for (const part of parts) {
|
|
|
|
|
|
|
|
if (!merged.some(item => item.toLowerCase() === part.toLowerCase())) {
|
|
|
|
|
|
|
|
merged.push(part);
|
|
|
|
|
|
|
|
addedAny = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!addedAny) {
|
|
|
|
|
|
|
|
setError(`${field === 'tongue' ? 'Tongue' : 'Pulse'} finding "${parts[0]}" is already selected.`);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
setError(null);
|
|
|
|
|
|
|
|
updateActivePattern(p => ({
|
|
|
|
|
|
|
|
...p,
|
|
|
|
|
|
|
|
clinical_data: { ...p.clinical_data, [field]: merged.join(', ') },
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
if (field === 'tongue') setCustomTongueInput('');
|
|
|
|
|
|
|
|
else setCustomPulseInput('');
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const handleRemoveDiagnosisChip = (field: 'tongue' | 'pulse', chipToRemove: string) => {
|
|
|
|
|
|
|
|
const existing = field === 'tongue' ? currentTongueChips : currentPulseChips;
|
|
|
|
|
|
|
|
const updated = existing.filter(c => c !== chipToRemove).join(', ');
|
|
|
|
|
|
|
|
updateActivePattern(p => ({
|
|
|
|
|
|
|
|
...p,
|
|
|
|
|
|
|
|
clinical_data: { ...p.clinical_data, [field]: updated },
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Point Chips Helpers (100% Safe Optional Chaining)
|
|
|
|
// Point Chips Helpers (100% Safe Optional Chaining)
|
|
|
|
const currentPoints = (activePattern?.clinical_data?.acupuncture?.points || '')
|
|
|
|
const currentPoints = (activePattern?.clinical_data?.acupuncture?.points || '')
|
|
|
|
.split(',')
|
|
|
|
.split(',')
|
|
|
|
.map(s => s.trim())
|
|
|
|
.map(s => s.trim())
|
|
|
|
.filter(Boolean);
|
|
|
|
.filter(Boolean);
|
|
|
|
|
|
|
|
|
|
|
|
const handleAddPointChip = (point: string) => {
|
|
|
|
const handleAddPointChip = (point: string, forceRaw = false) => {
|
|
|
|
const trimmed = point.trim().toUpperCase();
|
|
|
|
const parts = point
|
|
|
|
if (!trimmed) {
|
|
|
|
.split(',')
|
|
|
|
setError('Please enter a valid acupuncture point code (e.g. ST-36, RN-6).');
|
|
|
|
.map(s => s.trim().toUpperCase())
|
|
|
|
|
|
|
|
.filter(Boolean);
|
|
|
|
|
|
|
|
if (parts.length === 0) {
|
|
|
|
|
|
|
|
setError('Please enter an acupuncture point code (e.g. ST-36, RN-6).');
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (currentPoints.includes(trimmed)) {
|
|
|
|
|
|
|
|
setError(`Point "${trimmed}" is already added to this prescription.`);
|
|
|
|
if (!forceRaw && parts.length === 1) {
|
|
|
|
|
|
|
|
const suggested = suggestHyphenatedPoint(parts[0]);
|
|
|
|
|
|
|
|
if (suggested && suggested !== parts[0]) {
|
|
|
|
|
|
|
|
setPendingPointSuggestion({ raw: parts[0], suggested });
|
|
|
|
|
|
|
|
setError(null);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const merged = [...currentPoints];
|
|
|
|
|
|
|
|
let addedAny = false;
|
|
|
|
|
|
|
|
for (const pt of parts) {
|
|
|
|
|
|
|
|
if (!merged.includes(pt)) {
|
|
|
|
|
|
|
|
merged.push(pt);
|
|
|
|
|
|
|
|
addedAny = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!addedAny) {
|
|
|
|
|
|
|
|
setError(`Point "${parts[0]}" is already added to this prescription.`);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
setError(null);
|
|
|
|
setError(null);
|
|
|
|
const updated = [...currentPoints, trimmed].join(', ');
|
|
|
|
setPendingPointSuggestion(null);
|
|
|
|
|
|
|
|
const updated = merged.join(', ');
|
|
|
|
updateActivePattern(p => ({
|
|
|
|
updateActivePattern(p => ({
|
|
|
|
...p,
|
|
|
|
...p,
|
|
|
|
clinical_data: {
|
|
|
|
clinical_data: {
|
|
|
|
@ -625,56 +763,104 @@ export const ModuleBuilderTabContent: React.FC = () => {
|
|
|
|
|
|
|
|
|
|
|
|
// Save Full Disease & Patterns with Granular Validation
|
|
|
|
// Save Full Disease & Patterns with Granular Validation
|
|
|
|
const handleSaveFullDisease = async () => {
|
|
|
|
const handleSaveFullDisease = async () => {
|
|
|
|
|
|
|
|
const showValidationError = (msg: string) => {
|
|
|
|
|
|
|
|
setError(msg);
|
|
|
|
|
|
|
|
window.scrollTo({ top: 0, behavior: 'smooth' });
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
if (!selectedCategoryCode) {
|
|
|
|
if (!selectedCategoryCode) {
|
|
|
|
setError('Please select or create a Category before saving.');
|
|
|
|
showValidationError('Please select or create a Category before saving.');
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const effectiveDiseaseName = diseaseName.trim();
|
|
|
|
const effectiveDiseaseName = diseaseName.trim();
|
|
|
|
if (!effectiveDiseaseName) {
|
|
|
|
if (!effectiveDiseaseName) {
|
|
|
|
setError('Please enter a Disease Name before saving.');
|
|
|
|
showValidationError('Please enter a Disease Name before saving.');
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!patterns || patterns.length === 0) {
|
|
|
|
if (!patterns || patterns.length === 0) {
|
|
|
|
setError('A disease must contain at least one clinical pattern before saving.');
|
|
|
|
showValidationError('A disease must contain at least one clinical pattern before saving.');
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Auto-commit any uncommitted chip inputs on the active pattern before validating
|
|
|
|
|
|
|
|
let patternsToSave = patterns;
|
|
|
|
|
|
|
|
if (customPointInput.trim()) {
|
|
|
|
|
|
|
|
const rawPt = customPointInput.trim().toUpperCase();
|
|
|
|
|
|
|
|
const suggested = suggestHyphenatedPoint(rawPt);
|
|
|
|
|
|
|
|
if (suggested && suggested !== rawPt) {
|
|
|
|
|
|
|
|
setPendingPointSuggestion({ raw: rawPt, suggested });
|
|
|
|
|
|
|
|
showValidationError(
|
|
|
|
|
|
|
|
`Please confirm whether to use "${suggested}" or keep "${rawPt}" in the Acupuncture Prescription before saving.`,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
const pendingParts = rawPt.split(',').map(s => s.trim()).filter(Boolean);
|
|
|
|
|
|
|
|
const mergedPts = [...currentPoints];
|
|
|
|
|
|
|
|
for (const pt of pendingParts) {
|
|
|
|
|
|
|
|
if (!mergedPts.includes(pt)) mergedPts.push(pt);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
const nextPts = mergedPts.join(', ');
|
|
|
|
|
|
|
|
patternsToSave = patternsToSave.map((p, idx) =>
|
|
|
|
|
|
|
|
idx === activePatternIndex
|
|
|
|
|
|
|
|
? { ...p, clinical_data: { ...p.clinical_data, acupuncture: { points: nextPts, method: p.clinical_data?.acupuncture?.method || '' } } }
|
|
|
|
|
|
|
|
: p,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
setPatterns(patternsToSave);
|
|
|
|
|
|
|
|
setCustomPointInput('');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (customTongueInput.trim()) {
|
|
|
|
|
|
|
|
const nextTongue = [...currentTongueChips, ...parseCommaChips(customTongueInput)].join(', ');
|
|
|
|
|
|
|
|
patternsToSave = patternsToSave.map((p, idx) =>
|
|
|
|
|
|
|
|
idx === activePatternIndex ? { ...p, clinical_data: { ...p.clinical_data, tongue: nextTongue } } : p,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
setPatterns(patternsToSave);
|
|
|
|
|
|
|
|
setCustomTongueInput('');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (customPulseInput.trim()) {
|
|
|
|
|
|
|
|
const nextPulse = [...currentPulseChips, ...parseCommaChips(customPulseInput)].join(', ');
|
|
|
|
|
|
|
|
patternsToSave = patternsToSave.map((p, idx) =>
|
|
|
|
|
|
|
|
idx === activePatternIndex ? { ...p, clinical_data: { ...p.clinical_data, pulse: nextPulse } } : p,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
setPatterns(patternsToSave);
|
|
|
|
|
|
|
|
setCustomPulseInput('');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Validate Pattern Names & Duplicates
|
|
|
|
// Validate Pattern Names & Duplicates
|
|
|
|
const seenPatternNames = new Set<string>();
|
|
|
|
const seenPatternNames = new Set<string>();
|
|
|
|
for (let i = 0; i < patterns.length; i++) {
|
|
|
|
for (let i = 0; i < patternsToSave.length; i++) {
|
|
|
|
const pName = patterns[i]?.name?.trim();
|
|
|
|
const pName = patternsToSave[i]?.name?.trim();
|
|
|
|
if (!pName) {
|
|
|
|
if (!pName) {
|
|
|
|
setActivePatternIndex(i);
|
|
|
|
setActivePatternIndex(i);
|
|
|
|
setError(`Clinical Pattern #${i + 1} is missing a name. Please enter a pattern name.`);
|
|
|
|
showValidationError(`Clinical Pattern #${i + 1} is missing a name. Please enter a pattern name.`);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const lower = pName.toLowerCase();
|
|
|
|
const lower = pName.toLowerCase();
|
|
|
|
if (seenPatternNames.has(lower)) {
|
|
|
|
if (seenPatternNames.has(lower)) {
|
|
|
|
setActivePatternIndex(i);
|
|
|
|
setActivePatternIndex(i);
|
|
|
|
setError(`Duplicate pattern name "${pName}". Each clinical pattern within a disease must have a distinct name.`);
|
|
|
|
showValidationError(`Duplicate pattern name "${pName}". Each clinical pattern within a disease must have a distinct name.`);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
seenPatternNames.add(lower);
|
|
|
|
seenPatternNames.add(lower);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Validate Symptoms exist
|
|
|
|
// Validate Symptoms exist
|
|
|
|
for (let i = 0; i < patterns.length; i++) {
|
|
|
|
for (let i = 0; i < patternsToSave.length; i++) {
|
|
|
|
const cleanSymptoms = (patterns[i].clinical_data?.clinical_manifestations || []).filter(s => s && s.trim().length > 0);
|
|
|
|
const cleanSymptoms = (patternsToSave[i].clinical_data?.clinical_manifestations || []).filter(s => s && s.trim().length > 0);
|
|
|
|
if (cleanSymptoms.length === 0) {
|
|
|
|
if (cleanSymptoms.length === 0) {
|
|
|
|
setActivePatternIndex(i);
|
|
|
|
setActivePatternIndex(i);
|
|
|
|
setError(`Pattern "${patterns[i].name}" has no symptoms. Please enter at least one clinical symptom before saving.`);
|
|
|
|
showValidationError(`Pattern "${patternsToSave[i].name}" has no symptoms. Please enter at least one clinical symptom before saving.`);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Validate Points formula exist
|
|
|
|
// Validate Points formula exist
|
|
|
|
for (let i = 0; i < patterns.length; i++) {
|
|
|
|
for (let i = 0; i < patternsToSave.length; i++) {
|
|
|
|
const pts = (patterns[i].clinical_data?.acupuncture?.points || '').trim();
|
|
|
|
const pts = (patternsToSave[i].clinical_data?.acupuncture?.points || '').trim();
|
|
|
|
if (!pts) {
|
|
|
|
if (!pts) {
|
|
|
|
setActivePatternIndex(i);
|
|
|
|
setActivePatternIndex(i);
|
|
|
|
setError(`Pattern "${patterns[i].name}" has no acupuncture points. Please select or add at least one point before saving.`);
|
|
|
|
showValidationError(`Pattern "${patternsToSave[i].name}" has no acupuncture points. Please select or add at least one point before saving.`);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -698,7 +884,7 @@ export const ModuleBuilderTabContent: React.FC = () => {
|
|
|
|
disease_code: effectiveDiseaseCode,
|
|
|
|
disease_code: effectiveDiseaseCode,
|
|
|
|
name: effectiveDiseaseName,
|
|
|
|
name: effectiveDiseaseName,
|
|
|
|
overview: diseaseOverview,
|
|
|
|
overview: diseaseOverview,
|
|
|
|
patterns: patterns.map((p, idx) => ({
|
|
|
|
patterns: patternsToSave.map((p, idx) => ({
|
|
|
|
category_code: selectedCategoryCode,
|
|
|
|
category_code: selectedCategoryCode,
|
|
|
|
disease_code: effectiveDiseaseCode,
|
|
|
|
disease_code: effectiveDiseaseCode,
|
|
|
|
pattern_code: toSnakeCase(p.name?.trim() || `pattern_${idx + 1}`),
|
|
|
|
pattern_code: toSnakeCase(p.name?.trim() || `pattern_${idx + 1}`),
|
|
|
|
@ -708,7 +894,13 @@ export const ModuleBuilderTabContent: React.FC = () => {
|
|
|
|
clinical_manifestations: (p.clinical_data?.clinical_manifestations || []).filter(s => s && s.trim().length > 0),
|
|
|
|
clinical_manifestations: (p.clinical_data?.clinical_manifestations || []).filter(s => s && s.trim().length > 0),
|
|
|
|
tongue: (p.clinical_data?.tongue || '').trim(),
|
|
|
|
tongue: (p.clinical_data?.tongue || '').trim(),
|
|
|
|
pulse: (p.clinical_data?.pulse || '').trim(),
|
|
|
|
pulse: (p.clinical_data?.pulse || '').trim(),
|
|
|
|
treatment_principle: (p.clinical_data?.treatment_principle || '').trim(),
|
|
|
|
treatment_principle: (
|
|
|
|
|
|
|
|
Array.isArray(p.clinical_data?.treatment_principle)
|
|
|
|
|
|
|
|
? p.clinical_data.treatment_principle
|
|
|
|
|
|
|
|
: normalizeTreatmentPrinciple(p.clinical_data?.treatment_principle)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
.map(tp => tp.trim())
|
|
|
|
|
|
|
|
.filter(Boolean),
|
|
|
|
acupuncture: {
|
|
|
|
acupuncture: {
|
|
|
|
points: (p.clinical_data?.acupuncture?.points || '').trim(),
|
|
|
|
points: (p.clinical_data?.acupuncture?.points || '').trim(),
|
|
|
|
method: (p.clinical_data?.acupuncture?.method || '').trim(),
|
|
|
|
method: (p.clinical_data?.acupuncture?.method || '').trim(),
|
|
|
|
@ -1781,87 +1973,164 @@ export const ModuleBuilderTabContent: React.FC = () => {
|
|
|
|
{/* Tongue */}
|
|
|
|
{/* Tongue */}
|
|
|
|
<div className="space-y-1.5">
|
|
|
|
<div className="space-y-1.5">
|
|
|
|
<label className="text-[10px] uppercase font-bold text-slate-500">👅 Tongue Diagnosis</label>
|
|
|
|
<label className="text-[10px] uppercase font-bold text-slate-500">👅 Tongue Diagnosis</label>
|
|
|
|
<input
|
|
|
|
<div className="flex flex-wrap items-center gap-1.5 min-h-[38px] p-2 bg-slate-50 border border-slate-200 rounded-xl">
|
|
|
|
type="text"
|
|
|
|
{currentTongueChips.map((chip, idx) => (
|
|
|
|
value={activePattern.clinical_data?.tongue || ''}
|
|
|
|
<span
|
|
|
|
onChange={(e) =>
|
|
|
|
|
|
|
|
updateActivePattern(p => ({
|
|
|
|
|
|
|
|
...p,
|
|
|
|
|
|
|
|
clinical_data: { ...p.clinical_data, tongue: e.target.value },
|
|
|
|
|
|
|
|
}))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
placeholder="e.g. Pale and Thin."
|
|
|
|
|
|
|
|
className="w-full bg-slate-50 border border-slate-200 rounded-xl px-3 py-2 text-xs font-bold text-slate-800 focus:outline-none focus:border-indigo-500"
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
<div className="flex flex-wrap gap-1.5 pt-1">
|
|
|
|
|
|
|
|
{COMMON_TONGUE_SUGGESTIONS.map((t, idx) => (
|
|
|
|
|
|
|
|
<button
|
|
|
|
|
|
|
|
key={idx}
|
|
|
|
key={idx}
|
|
|
|
type="button"
|
|
|
|
className="inline-flex items-center gap-1 px-2 py-0.5 rounded-lg bg-rose-50 border border-rose-200 text-rose-700 text-xs font-bold"
|
|
|
|
onClick={() =>
|
|
|
|
|
|
|
|
updateActivePattern(p => ({
|
|
|
|
|
|
|
|
...p,
|
|
|
|
|
|
|
|
clinical_data: { ...p.clinical_data, tongue: t },
|
|
|
|
|
|
|
|
}))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
className="text-[10px] px-2 py-0.5 rounded-lg bg-slate-100 hover:bg-slate-200 text-slate-600 font-medium"
|
|
|
|
|
|
|
|
>
|
|
|
|
>
|
|
|
|
{t}
|
|
|
|
{chip}
|
|
|
|
</button>
|
|
|
|
<button
|
|
|
|
|
|
|
|
type="button"
|
|
|
|
|
|
|
|
onClick={() => handleRemoveDiagnosisChip('tongue', chip)}
|
|
|
|
|
|
|
|
className="text-rose-400 hover:text-rose-700 cursor-pointer"
|
|
|
|
|
|
|
|
title="Remove tongue finding"
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
<X className="h-3 w-3" />
|
|
|
|
|
|
|
|
</button>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
))}
|
|
|
|
))}
|
|
|
|
|
|
|
|
<input
|
|
|
|
|
|
|
|
type="text"
|
|
|
|
|
|
|
|
value={customTongueInput}
|
|
|
|
|
|
|
|
onChange={(e) => setCustomTongueInput(e.target.value)}
|
|
|
|
|
|
|
|
onKeyDown={(e) => {
|
|
|
|
|
|
|
|
if (e.key === 'Enter' || e.key === ',') {
|
|
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
handleAddDiagnosisChip('tongue', customTongueInput);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
onBlur={() => {
|
|
|
|
|
|
|
|
if (customTongueInput.trim()) {
|
|
|
|
|
|
|
|
handleAddDiagnosisChip('tongue', customTongueInput);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
placeholder={currentTongueChips.length === 0 ? 'Type tongue finding and press Enter...' : '+ add...'}
|
|
|
|
|
|
|
|
className="flex-1 text-xs font-semibold text-slate-800 focus:outline-none bg-transparent min-w-[120px] px-1 py-0.5"
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className="flex flex-wrap gap-1.5 pt-1">
|
|
|
|
|
|
|
|
{COMMON_TONGUE_SUGGESTIONS.map((t, idx) => {
|
|
|
|
|
|
|
|
const isAdded = currentTongueChips.some(c => c.toLowerCase() === t.toLowerCase());
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
|
|
<button
|
|
|
|
|
|
|
|
key={idx}
|
|
|
|
|
|
|
|
type="button"
|
|
|
|
|
|
|
|
disabled={isAdded}
|
|
|
|
|
|
|
|
onClick={() => handleAddDiagnosisChip('tongue', t)}
|
|
|
|
|
|
|
|
className={`text-[10px] px-2 py-0.5 rounded-lg border font-medium transition-colors ${
|
|
|
|
|
|
|
|
isAdded
|
|
|
|
|
|
|
|
? 'bg-slate-200 text-slate-400 border-slate-200 cursor-default'
|
|
|
|
|
|
|
|
: 'bg-slate-100 hover:bg-rose-50 border-slate-200 hover:border-rose-300 text-slate-600 hover:text-rose-700 cursor-pointer'
|
|
|
|
|
|
|
|
}`}
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
+{t}
|
|
|
|
|
|
|
|
</button>
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
})}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
{/* Pulse */}
|
|
|
|
{/* Pulse */}
|
|
|
|
<div className="space-y-1.5">
|
|
|
|
<div className="space-y-1.5">
|
|
|
|
<label className="text-[10px] uppercase font-bold text-slate-500">💓 Pulse Diagnosis</label>
|
|
|
|
<label className="text-[10px] uppercase font-bold text-slate-500">💓 Pulse Diagnosis</label>
|
|
|
|
<input
|
|
|
|
<div className="flex flex-wrap items-center gap-1.5 min-h-[38px] p-2 bg-slate-50 border border-slate-200 rounded-xl">
|
|
|
|
type="text"
|
|
|
|
{currentPulseChips.map((chip, idx) => (
|
|
|
|
value={activePattern.clinical_data?.pulse || ''}
|
|
|
|
<span
|
|
|
|
onChange={(e) =>
|
|
|
|
|
|
|
|
updateActivePattern(p => ({
|
|
|
|
|
|
|
|
...p,
|
|
|
|
|
|
|
|
clinical_data: { ...p.clinical_data, pulse: e.target.value },
|
|
|
|
|
|
|
|
}))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
placeholder="e.g. Choppy."
|
|
|
|
|
|
|
|
className="w-full bg-slate-50 border border-slate-200 rounded-xl px-3 py-2 text-xs font-bold text-slate-800 focus:outline-none focus:border-indigo-500"
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
<div className="flex flex-wrap gap-1.5 pt-1">
|
|
|
|
|
|
|
|
{COMMON_PULSE_SUGGESTIONS.map((pls, idx) => (
|
|
|
|
|
|
|
|
<button
|
|
|
|
|
|
|
|
key={idx}
|
|
|
|
key={idx}
|
|
|
|
type="button"
|
|
|
|
className="inline-flex items-center gap-1 px-2 py-0.5 rounded-lg bg-pink-50 border border-pink-200 text-pink-700 text-xs font-bold"
|
|
|
|
onClick={() =>
|
|
|
|
|
|
|
|
updateActivePattern(p => ({
|
|
|
|
|
|
|
|
...p,
|
|
|
|
|
|
|
|
clinical_data: { ...p.clinical_data, pulse: pls },
|
|
|
|
|
|
|
|
}))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
className="text-[10px] px-2 py-0.5 rounded-lg bg-slate-100 hover:bg-slate-200 text-slate-600 font-medium"
|
|
|
|
|
|
|
|
>
|
|
|
|
>
|
|
|
|
{pls}
|
|
|
|
{chip}
|
|
|
|
</button>
|
|
|
|
<button
|
|
|
|
|
|
|
|
type="button"
|
|
|
|
|
|
|
|
onClick={() => handleRemoveDiagnosisChip('pulse', chip)}
|
|
|
|
|
|
|
|
className="text-pink-400 hover:text-pink-700 cursor-pointer"
|
|
|
|
|
|
|
|
title="Remove pulse finding"
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
<X className="h-3 w-3" />
|
|
|
|
|
|
|
|
</button>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
))}
|
|
|
|
))}
|
|
|
|
|
|
|
|
<input
|
|
|
|
|
|
|
|
type="text"
|
|
|
|
|
|
|
|
value={customPulseInput}
|
|
|
|
|
|
|
|
onChange={(e) => setCustomPulseInput(e.target.value)}
|
|
|
|
|
|
|
|
onKeyDown={(e) => {
|
|
|
|
|
|
|
|
if (e.key === 'Enter' || e.key === ',') {
|
|
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
handleAddDiagnosisChip('pulse', customPulseInput);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
onBlur={() => {
|
|
|
|
|
|
|
|
if (customPulseInput.trim()) {
|
|
|
|
|
|
|
|
handleAddDiagnosisChip('pulse', customPulseInput);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
placeholder={currentPulseChips.length === 0 ? 'Type pulse finding and press Enter...' : '+ add...'}
|
|
|
|
|
|
|
|
className="flex-1 text-xs font-semibold text-slate-800 focus:outline-none bg-transparent min-w-[120px] px-1 py-0.5"
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className="flex flex-wrap gap-1.5 pt-1">
|
|
|
|
|
|
|
|
{COMMON_PULSE_SUGGESTIONS.map((pls, idx) => {
|
|
|
|
|
|
|
|
const isAdded = currentPulseChips.some(c => c.toLowerCase() === pls.toLowerCase());
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
|
|
<button
|
|
|
|
|
|
|
|
key={idx}
|
|
|
|
|
|
|
|
type="button"
|
|
|
|
|
|
|
|
disabled={isAdded}
|
|
|
|
|
|
|
|
onClick={() => handleAddDiagnosisChip('pulse', pls)}
|
|
|
|
|
|
|
|
className={`text-[10px] px-2 py-0.5 rounded-lg border font-medium transition-colors ${
|
|
|
|
|
|
|
|
isAdded
|
|
|
|
|
|
|
|
? 'bg-slate-200 text-slate-400 border-slate-200 cursor-default'
|
|
|
|
|
|
|
|
: 'bg-slate-100 hover:bg-pink-50 border-slate-200 hover:border-pink-300 text-slate-600 hover:text-pink-700 cursor-pointer'
|
|
|
|
|
|
|
|
}`}
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
+{pls}
|
|
|
|
|
|
|
|
</button>
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
})}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
{/* Treatment Principle */}
|
|
|
|
{/* Treatment Principle (Rows like Clinical Manifestations) */}
|
|
|
|
<div className="space-y-1">
|
|
|
|
<div className="space-y-2">
|
|
|
|
<label className="text-[10px] uppercase font-bold text-slate-500">🎯 Treatment Principle</label>
|
|
|
|
<div className="flex justify-between items-center">
|
|
|
|
<input
|
|
|
|
<label className="text-[10px] uppercase font-bold text-slate-500">
|
|
|
|
type="text"
|
|
|
|
🎯 Treatment Principle ({activePrinciples.length})
|
|
|
|
value={activePattern.clinical_data?.treatment_principle || ''}
|
|
|
|
</label>
|
|
|
|
onChange={(e) =>
|
|
|
|
<button
|
|
|
|
updateActivePattern(p => ({
|
|
|
|
type="button"
|
|
|
|
...p,
|
|
|
|
onClick={handleAddPrinciple}
|
|
|
|
clinical_data: { ...p.clinical_data, treatment_principle: e.target.value },
|
|
|
|
className="text-indigo-600 hover:text-indigo-800 text-[11px] font-bold flex items-center gap-1 cursor-pointer"
|
|
|
|
}))
|
|
|
|
>
|
|
|
|
}
|
|
|
|
<Plus className="h-3 w-3" /> Add Principle
|
|
|
|
placeholder="e.g. Tonify Qi, nourish Blood, stop pain."
|
|
|
|
</button>
|
|
|
|
className="w-full bg-slate-50 border border-slate-200 rounded-xl px-3 py-2 text-xs font-bold text-slate-800 focus:outline-none focus:border-indigo-500"
|
|
|
|
</div>
|
|
|
|
/>
|
|
|
|
<div className="space-y-2">
|
|
|
|
|
|
|
|
{activePrinciples.map((principle, pIdx) => (
|
|
|
|
|
|
|
|
<div key={pIdx} className="flex items-center gap-2">
|
|
|
|
|
|
|
|
<span className="text-[10px] font-mono text-slate-400 w-4 text-right">{pIdx + 1}.</span>
|
|
|
|
|
|
|
|
<input
|
|
|
|
|
|
|
|
type="text"
|
|
|
|
|
|
|
|
value={principle}
|
|
|
|
|
|
|
|
onChange={(e) => handlePrincipleChange(pIdx, e.target.value)}
|
|
|
|
|
|
|
|
placeholder="e.g. Tonify Qi and nourish Blood"
|
|
|
|
|
|
|
|
className="flex-1 bg-slate-50 border border-slate-200 rounded-xl px-3 py-1.5 text-xs font-medium text-slate-800 focus:outline-none focus:border-indigo-500"
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
{activePrinciples.length > 1 && (
|
|
|
|
|
|
|
|
<button
|
|
|
|
|
|
|
|
type="button"
|
|
|
|
|
|
|
|
onClick={() => handleRemovePrinciple(pIdx)}
|
|
|
|
|
|
|
|
className="p-1.5 text-slate-400 hover:text-rose-500 transition-colors cursor-pointer"
|
|
|
|
|
|
|
|
title="Remove principle"
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
<Trash2 className="h-3.5 w-3.5" />
|
|
|
|
|
|
|
|
</button>
|
|
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
))}
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
{/* Acupuncture Formula & Points Chips */}
|
|
|
|
{/* Acupuncture Formula & Points Chips */}
|
|
|
|
@ -1893,17 +2162,61 @@ export const ModuleBuilderTabContent: React.FC = () => {
|
|
|
|
<input
|
|
|
|
<input
|
|
|
|
type="text"
|
|
|
|
type="text"
|
|
|
|
value={customPointInput}
|
|
|
|
value={customPointInput}
|
|
|
|
onChange={(e) => setCustomPointInput(e.target.value)}
|
|
|
|
onChange={(e) => {
|
|
|
|
|
|
|
|
setCustomPointInput(e.target.value);
|
|
|
|
|
|
|
|
if (pendingPointSuggestion) setPendingPointSuggestion(null);
|
|
|
|
|
|
|
|
}}
|
|
|
|
onKeyDown={(e) => {
|
|
|
|
onKeyDown={(e) => {
|
|
|
|
if (e.key === 'Enter') {
|
|
|
|
if (e.key === 'Enter' || e.key === ',') {
|
|
|
|
e.preventDefault();
|
|
|
|
e.preventDefault();
|
|
|
|
handleAddPointChip(customPointInput);
|
|
|
|
handleAddPointChip(customPointInput);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
}}
|
|
|
|
|
|
|
|
onBlur={() => {
|
|
|
|
|
|
|
|
if (customPointInput.trim()) {
|
|
|
|
|
|
|
|
handleAddPointChip(customPointInput);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}}
|
|
|
|
placeholder={currentPoints.length === 0 ? 'Type point (e.g. RN-6) and hit Enter...' : '+ add...'}
|
|
|
|
placeholder={currentPoints.length === 0 ? 'Type point (e.g. RN-6) and hit Enter...' : '+ add...'}
|
|
|
|
className="text-xs font-semibold text-slate-800 focus:outline-none bg-transparent min-w-[120px] px-1 py-0.5"
|
|
|
|
className="flex-1 text-xs font-semibold text-slate-800 focus:outline-none bg-transparent min-w-[120px] px-1 py-0.5"
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
|
|
|
|
{customPointInput.trim() && (
|
|
|
|
|
|
|
|
<button
|
|
|
|
|
|
|
|
type="button"
|
|
|
|
|
|
|
|
onMouseDown={(e) => {
|
|
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
handleAddPointChip(customPointInput);
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
className="px-2 py-0.5 rounded-lg bg-indigo-600 text-white text-[10px] font-bold hover:bg-indigo-500 cursor-pointer"
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
+ Add
|
|
|
|
|
|
|
|
</button>
|
|
|
|
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
{pendingPointSuggestion && (
|
|
|
|
|
|
|
|
<div className="flex flex-wrap items-center justify-between gap-2 px-3 py-2 rounded-xl bg-amber-50 border border-amber-200 text-xs text-amber-900">
|
|
|
|
|
|
|
|
<span>
|
|
|
|
|
|
|
|
Acupuncture points use a hyphen format. Did you mean{' '}
|
|
|
|
|
|
|
|
<strong className="font-mono">{pendingPointSuggestion.suggested}</strong>?
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
<div className="flex items-center gap-1.5">
|
|
|
|
|
|
|
|
<button
|
|
|
|
|
|
|
|
type="button"
|
|
|
|
|
|
|
|
onClick={() => handleAddPointChip(pendingPointSuggestion.suggested, true)}
|
|
|
|
|
|
|
|
className="px-2.5 py-1 rounded-lg bg-amber-600 hover:bg-amber-700 text-white text-[11px] font-bold cursor-pointer"
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
Use {pendingPointSuggestion.suggested}
|
|
|
|
|
|
|
|
</button>
|
|
|
|
|
|
|
|
<button
|
|
|
|
|
|
|
|
type="button"
|
|
|
|
|
|
|
|
onClick={() => handleAddPointChip(pendingPointSuggestion.raw, true)}
|
|
|
|
|
|
|
|
className="px-2.5 py-1 rounded-lg bg-white hover:bg-amber-100 text-amber-800 border border-amber-300 text-[11px] font-bold cursor-pointer"
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
Keep {pendingPointSuggestion.raw}
|
|
|
|
|
|
|
|
</button>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
{/* Quick Suggestions for Points */}
|
|
|
|
{/* Quick Suggestions for Points */}
|
|
|
|
@ -2136,10 +2449,23 @@ export const ModuleBuilderTabContent: React.FC = () => {
|
|
|
|
|
|
|
|
|
|
|
|
{/* Treatment Principle */}
|
|
|
|
{/* Treatment Principle */}
|
|
|
|
<div className="p-3 bg-white rounded-xl border border-amber-200 text-xs">
|
|
|
|
<div className="p-3 bg-white rounded-xl border border-amber-200 text-xs">
|
|
|
|
<span className="text-[10px] font-black uppercase text-amber-600 block mb-0.5">Treatment Principle</span>
|
|
|
|
<span className="text-[10px] font-black uppercase text-amber-600 block mb-1">Treatment Principle</span>
|
|
|
|
<span className="font-bold text-slate-800">
|
|
|
|
{(() => {
|
|
|
|
{patterns[previewPatternIdx].clinical_data?.treatment_principle || '—'}
|
|
|
|
const tpList = normalizeTreatmentPrinciple(
|
|
|
|
</span>
|
|
|
|
patterns[previewPatternIdx].clinical_data?.treatment_principle,
|
|
|
|
|
|
|
|
).filter(Boolean);
|
|
|
|
|
|
|
|
if (tpList.length === 0) return <span className="font-bold text-slate-400">—</span>;
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
|
|
<ul className="space-y-1">
|
|
|
|
|
|
|
|
{tpList.map((tp, idx) => (
|
|
|
|
|
|
|
|
<li key={idx} className="font-bold text-slate-800 flex items-start gap-1.5">
|
|
|
|
|
|
|
|
<span className="text-amber-500 mt-0.5">•</span>
|
|
|
|
|
|
|
|
<span>{tp}</span>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
|
|
|
|
))}
|
|
|
|
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
})()}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
{/* Acupuncture Prescription */}
|
|
|
|
{/* Acupuncture Prescription */}
|
|
|
|
|