Compare commits
No commits in common. "98d0e49597d8dca0c82949292fe6df6f0b073995" and "2a2c9ebc803e603401ffde4d6bc0940cf1b9d9f4" have entirely different histories.
98d0e49597
...
2a2c9ebc80
|
|
@ -9,49 +9,17 @@ import { BackActionContext } from "../../context/BackActionContext";
|
||||||
import { Hero } from "../shared/Hero";
|
import { Hero } from "../shared/Hero";
|
||||||
import { SectionCard } from "../shared/SectionCard";
|
import { SectionCard } from "../shared/SectionCard";
|
||||||
import { Paragraphs } from "../shared/Paragraphs";
|
import { Paragraphs } from "../shared/Paragraphs";
|
||||||
import { BulletList } from "../shared/BulletList";
|
import { asString } from "../helpers/value";
|
||||||
import { asString, asStringArray } from "../helpers/value";
|
|
||||||
import { useContentSearchInfiniteQuery } from "../../hooks/use-content-search-infinite-query";
|
import { useContentSearchInfiniteQuery } from "../../hooks/use-content-search-infinite-query";
|
||||||
|
|
||||||
interface PatternData {
|
interface PatternData {
|
||||||
name: string;
|
name: string;
|
||||||
code?: string;
|
code?: string;
|
||||||
clinicalManifestation?: string[];
|
clinicalManifestation?: string;
|
||||||
pathology?: string;
|
pathology?: string;
|
||||||
treatment?: string;
|
treatment?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseBullets(raw: unknown): string[] {
|
|
||||||
if (Array.isArray(raw)) {
|
|
||||||
return asStringArray(raw);
|
|
||||||
}
|
|
||||||
const text = asString(raw).trim();
|
|
||||||
if (!text) return [];
|
|
||||||
|
|
||||||
if (text.includes("\n")) {
|
|
||||||
return text
|
|
||||||
.split("\n")
|
|
||||||
.map((s) => s.replace(/^[•\-\*\d+\.]\s*/, "").trim())
|
|
||||||
.filter((s) => s.length > 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (text.includes(";")) {
|
|
||||||
return text
|
|
||||||
.split(";")
|
|
||||||
.map((s) => s.trim().replace(/^and\s+/i, ""))
|
|
||||||
.filter((s) => s.length > 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
const parts = text.split(/,\s*(?![^()]*\))/);
|
|
||||||
if (parts.length > 1) {
|
|
||||||
return parts
|
|
||||||
.map((s) => s.trim().replace(/\.$/, "").replace(/^and\s+/i, ""))
|
|
||||||
.filter((s) => s.length > 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return [text];
|
|
||||||
}
|
|
||||||
|
|
||||||
interface BurnerCategory {
|
interface BurnerCategory {
|
||||||
key: string;
|
key: string;
|
||||||
title: string;
|
title: string;
|
||||||
|
|
@ -215,10 +183,7 @@ export function ThreeBurnersDetailRenderer({
|
||||||
|
|
||||||
// 1. Seed fallback patterns
|
// 1. Seed fallback patterns
|
||||||
for (const p of Object.values(FALLBACK_PATTERNS)) {
|
for (const p of Object.values(FALLBACK_PATTERNS)) {
|
||||||
map.set(normalizeKey(p.name), {
|
map.set(normalizeKey(p.name), p);
|
||||||
...p,
|
|
||||||
clinicalManifestation: parseBullets(p.clinicalManifestation),
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Hydrate from live search query
|
// 2. Hydrate from live search query
|
||||||
|
|
@ -228,20 +193,19 @@ export function ThreeBurnersDetailRenderer({
|
||||||
const name = asString(a.name) || it.title;
|
const name = asString(a.name) || it.title;
|
||||||
if (!name) continue;
|
if (!name) continue;
|
||||||
|
|
||||||
const clinicalRaw =
|
const clinical =
|
||||||
a["clinical menifestation"] ??
|
asString(a["clinical menifestation"]) ||
|
||||||
a["clinical manifestation"] ??
|
asString(a["clinical manifestation"]) ||
|
||||||
a.clinical_manifestations ??
|
asString(a.clinical_manifestations) ||
|
||||||
a.clinical_manifestation;
|
asString(a.clinical_manifestation);
|
||||||
|
|
||||||
const clinical = parseBullets(clinicalRaw);
|
|
||||||
const pathology = asString(a.pathology);
|
const pathology = asString(a.pathology);
|
||||||
const treatment = asString(a.treatment);
|
const treatment = asString(a.treatment);
|
||||||
|
|
||||||
map.set(normalizeKey(name), {
|
map.set(normalizeKey(name), {
|
||||||
name,
|
name,
|
||||||
code: asString(a.code) || undefined,
|
code: asString(a.code) || undefined,
|
||||||
clinicalManifestation: clinical.length > 0 ? clinical : undefined,
|
clinicalManifestation: clinical || undefined,
|
||||||
pathology: pathology || undefined,
|
pathology: pathology || undefined,
|
||||||
treatment: treatment || undefined,
|
treatment: treatment || undefined,
|
||||||
});
|
});
|
||||||
|
|
@ -277,18 +241,13 @@ export function ThreeBurnersDetailRenderer({
|
||||||
const activePatternData: PatternData | null = useMemo(() => {
|
const activePatternData: PatternData | null = useMemo(() => {
|
||||||
if (isDirectLeafPattern) {
|
if (isDirectLeafPattern) {
|
||||||
const name = asString(data.name) || content.title || "Three Burners Pattern";
|
const name = asString(data.name) || content.title || "Three Burners Pattern";
|
||||||
const clinicalRaw =
|
|
||||||
data["clinical menifestation"] ??
|
|
||||||
data["clinical manifestation"] ??
|
|
||||||
data.clinical_manifestations ??
|
|
||||||
data.clinical_manifestation;
|
|
||||||
|
|
||||||
const clinical = parseBullets(clinicalRaw);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name,
|
name,
|
||||||
code: asString(data.code) || undefined,
|
code: asString(data.code) || undefined,
|
||||||
clinicalManifestation: clinical.length > 0 ? clinical : undefined,
|
clinicalManifestation:
|
||||||
|
asString(data["clinical menifestation"]) ||
|
||||||
|
asString(data["clinical manifestation"]) ||
|
||||||
|
asString(data.clinical_manifestations),
|
||||||
pathology: asString(data.pathology) || undefined,
|
pathology: asString(data.pathology) || undefined,
|
||||||
treatment: asString(data.treatment) || undefined,
|
treatment: asString(data.treatment) || undefined,
|
||||||
};
|
};
|
||||||
|
|
@ -335,10 +294,9 @@ export function ThreeBurnersDetailRenderer({
|
||||||
<Hero title={activePatternData.name} />
|
<Hero title={activePatternData.name} />
|
||||||
|
|
||||||
{/* 1. Clinical Manifestations Card */}
|
{/* 1. Clinical Manifestations Card */}
|
||||||
{activePatternData.clinicalManifestation &&
|
{activePatternData.clinicalManifestation ? (
|
||||||
activePatternData.clinicalManifestation.length > 0 ? (
|
|
||||||
<SectionCard title="Clinical Manifestations">
|
<SectionCard title="Clinical Manifestations">
|
||||||
<BulletList items={activePatternData.clinicalManifestation} />
|
<Paragraphs items={[activePatternData.clinicalManifestation]} />
|
||||||
</SectionCard>
|
</SectionCard>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,6 @@ import { Spacing } from "@/theme/spacing";
|
||||||
import { ContentLink } from "../../components/navigation/ContentLink";
|
import { ContentLink } from "../../components/navigation/ContentLink";
|
||||||
import { parseNavigableContentReference } from "../../utils/content-reference";
|
import { parseNavigableContentReference } from "../../utils/content-reference";
|
||||||
import { humanizeKey } from "../helpers/value";
|
import { humanizeKey } from "../helpers/value";
|
||||||
import { BulletList } from "./BulletList";
|
|
||||||
|
|
||||||
export interface ContentValueProps {
|
export interface ContentValueProps {
|
||||||
value: unknown;
|
value: unknown;
|
||||||
|
|
@ -21,28 +20,6 @@ export interface ContentValueProps {
|
||||||
emptyText?: string | null;
|
emptyText?: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseBullets(text: string): string[] {
|
|
||||||
if (text.includes("\n")) {
|
|
||||||
return text
|
|
||||||
.split("\n")
|
|
||||||
.map((s) => s.replace(/^[•\-\*\d+\.]\s*/, "").trim())
|
|
||||||
.filter((s) => s.length > 0);
|
|
||||||
}
|
|
||||||
if (text.includes(";")) {
|
|
||||||
return text
|
|
||||||
.split(";")
|
|
||||||
.map((s) => s.trim().replace(/^and\s+/i, ""))
|
|
||||||
.filter((s) => s.length > 0);
|
|
||||||
}
|
|
||||||
const parts = text.split(/,\s*(?![^()]*\))/);
|
|
||||||
if (parts.length > 1) {
|
|
||||||
return parts
|
|
||||||
.map((s) => s.trim().replace(/\.$/, "").replace(/^and\s+/i, ""))
|
|
||||||
.filter((s) => s.length > 0);
|
|
||||||
}
|
|
||||||
return [text];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reference-aware fallback renderer for arbitrary nested attribute values.
|
* Reference-aware fallback renderer for arbitrary nested attribute values.
|
||||||
*
|
*
|
||||||
|
|
@ -77,10 +54,6 @@ export function ContentValue({
|
||||||
) : null;
|
) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visible.every((item) => typeof item === "string")) {
|
|
||||||
return <BulletList items={visible as string[]} />;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={styles.stack}>
|
<View style={styles.stack}>
|
||||||
{visible.map((item, index) => (
|
{visible.map((item, index) => (
|
||||||
|
|
@ -111,32 +84,12 @@ export function ContentValue({
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={styles.object}>
|
<View style={styles.object}>
|
||||||
{entries.map(([key, child]) => {
|
{entries.map(([key, child]) => (
|
||||||
const isClinical =
|
<View key={key} style={styles.objectRow}>
|
||||||
key.toLowerCase().includes("clinical") ||
|
<Text style={styles.objectLabel}>{humanizeKey(key)}</Text>
|
||||||
key.toLowerCase().includes("manifestation");
|
<ContentValue value={child} textStyle={textStyle} />
|
||||||
|
</View>
|
||||||
const renderChild = () => {
|
))}
|
||||||
if (
|
|
||||||
isClinical &&
|
|
||||||
typeof child === "string" &&
|
|
||||||
child.trim().length > 0
|
|
||||||
) {
|
|
||||||
const bullets = parseBullets(child);
|
|
||||||
if (bullets.length > 1) {
|
|
||||||
return <BulletList items={bullets} />;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return <ContentValue value={child} textStyle={textStyle} />;
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<View key={key} style={styles.objectRow}>
|
|
||||||
<Text style={styles.objectLabel}>{humanizeKey(key)}</Text>
|
|
||||||
{renderChild()}
|
|
||||||
</View>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue