feat(three-burners): render separate Treatment Principle and Treatment cards with updated display order

This commit is contained in:
ShivaniKhaire 2026-10-24 14:54:29 +05:30
parent f267674f78
commit 8e73bcad73
1 changed files with 42 additions and 32 deletions

View File

@ -18,6 +18,7 @@ interface PatternData {
code?: string;
clinicalManifestation?: string | string[];
pathology?: string;
treatmentPrinciple?: string | string[];
treatment?: string;
}
@ -236,6 +237,11 @@ export function ThreeBurnersDetailRenderer({
const clinical = parseBullets(clinicalRaw);
const pathology = asString(a.pathology);
const treatmentPrincipleRaw =
a.treatment_principle ??
a["treatment principle"] ??
a.treatmentPrinciple;
const treatmentPrinciple = parseBullets(treatmentPrincipleRaw);
const treatment = asString(a.treatment);
map.set(normalizeKey(name), {
@ -243,6 +249,7 @@ export function ThreeBurnersDetailRenderer({
code: asString(a.code) || undefined,
clinicalManifestation: clinical.length > 0 ? clinical : undefined,
pathology: pathology || undefined,
treatmentPrinciple: treatmentPrinciple.length > 0 ? treatmentPrinciple : undefined,
treatment: treatment || undefined,
});
}
@ -284,12 +291,18 @@ export function ThreeBurnersDetailRenderer({
data.clinical_manifestation;
const clinical = parseBullets(clinicalRaw);
const treatmentPrincipleRaw =
data.treatment_principle ??
data["treatment principle"] ??
data.treatmentPrinciple;
const treatmentPrinciple = parseBullets(treatmentPrincipleRaw);
return {
name,
code: asString(data.code) || undefined,
clinicalManifestation: clinical.length > 0 ? clinical : undefined,
pathology: asString(data.pathology) || undefined,
treatmentPrinciple: treatmentPrinciple.length > 0 ? treatmentPrinciple : undefined,
treatment: asString(data.treatment) || undefined,
};
}
@ -327,6 +340,20 @@ export function ThreeBurnersDetailRenderer({
activePatternData.treatment || "",
);
const rawPrinciples =
activePatternData.treatmentPrinciple &&
(Array.isArray(activePatternData.treatmentPrinciple)
? activePatternData.treatmentPrinciple
: parseBullets(activePatternData.treatmentPrinciple));
const allPrinciples =
rawPrinciples && rawPrinciples.length > 0 ? rawPrinciples : principles;
const treatmentText =
acupuncture.length > 0
? acupuncture.join("\n")
: activePatternData.treatment;
return (
<ScrollView
contentContainerStyle={styles.container}
@ -334,7 +361,14 @@ export function ThreeBurnersDetailRenderer({
>
<Hero title={activePatternData.name} />
{/* 1. Clinical Manifestations Card */}
{/* 1. Pathology Card */}
{activePatternData.pathology ? (
<SectionCard title="Pathology">
<Paragraphs items={[activePatternData.pathology]} />
</SectionCard>
) : null}
{/* 2. Clinical Manifestations Card */}
{activePatternData.clinicalManifestation ? (
<SectionCard title="Clinical Manifestations">
<BulletList
@ -347,41 +381,17 @@ export function ThreeBurnersDetailRenderer({
</SectionCard>
) : null}
{/* 2. Pathology Card */}
{activePatternData.pathology ? (
<SectionCard title="Pathology">
<Paragraphs items={[activePatternData.pathology]} />
{/* 3. Treatment Principle Card */}
{allPrinciples && allPrinciples.length > 0 ? (
<SectionCard title="Treatment Principle">
<BulletList items={allPrinciples} />
</SectionCard>
) : null}
{/* 3. Treatment Card */}
{activePatternData.treatment ? (
{/* 4. Treatment Card */}
{treatmentText ? (
<SectionCard title="Treatment">
{principles.length > 0 ? (
<View style={styles.subSection}>
<Text style={styles.subSectionTitle}>Treatment Principle:</Text>
{principles.map((p, i) => (
<Text key={i} style={styles.bulletItem}>
• {p}
</Text>
))}
</View>
) : null}
{acupuncture.length > 0 ? (
<View style={[styles.subSection, principles.length > 0 && styles.subSectionSpacing]}>
<Text style={styles.subSectionTitle}>Acupuncture Points:</Text>
{acupuncture.map((a, i) => (
<Text key={i} style={styles.bodyText}>
{a}
</Text>
))}
</View>
) : null}
{principles.length === 0 && acupuncture.length === 0 ? (
<Paragraphs items={[activePatternData.treatment]} />
) : null}
<Paragraphs items={[treatmentText]} />
</SectionCard>
) : null}